/** Return the state controller creating a new one if needed. */ public CloudDebugProcessStateController getStateController() { if (stateController == null) { stateController = new CloudDebugProcessStateController(); } return stateController; }
/** Called when the user deletes a snapshot from the snapshot list. */ public void deleteBreakpoint(@NotNull Breakpoint serverBreakpoint) { if (!Boolean.TRUE.equals(serverBreakpoint.getIsFinalState())) { setStateToDisabled(serverBreakpoint); } process.getStateController().deleteBreakpointAsync(serverBreakpoint.getId()); }
/** * Binds this controller to a {@link CloudDebugProcessState} and initializes that state from the * server. * * @param state the {@link CloudDebugProcessState} the controller will be bound to */ public void initialize(@NotNull CloudDebugProcessState state) { this.state = state; state.setWaitToken(null); waitForChanges(); }
CloudDebugProcessStateController controller = new CloudDebugProcessStateController(); controller.initialize(state); createBreakpoint("b1", Boolean.TRUE, 1000, "com/google/ex1.java", 15, null, null)); controller.waitForChanges(); List<Breakpoint> changedList = state.getCurrentServerBreakpointList(); assertNotEmpty(changedList);
List<Breakpoint> currentList; try { currentList = queryServerForBreakpoints(state, client, tokenToSend); } catch (SocketTimeoutException ex) { currentList = queryServerForBreakpoints(state, client, tokenToSend); } catch (IOException ioException) { LOG.warn("exception listing breakpoints", ioException); if (!isBackgroundListening()) { return; pruneBreakpointCache(currentList); fireBreakpointsChanged();
.setBreakpointAsync(any(Breakpoint.class), any(SetBreakpointHandler.class)); .deleteBreakpointAsync(anyString());
CloudDebugProcessStateController controller = new CloudDebugProcessStateController(); controller.initialize(state);
public void testRegisterRegisteredBreakpoint() { XLineBreakpointImpl<CloudLineBreakpointProperties> breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); handler.registerBreakpoint(breakpoint); verify(stateController, times(1)) .setBreakpointAsync(isA(Breakpoint.class), isA(SetBreakpointHandler.class)); }
eq(xLineBreakpointImpl), any(Icon.class), eq(breakPointErrorMessage)); process.getStateController().stopBackgroundListening();
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); getStateController().initialize(CloudDebugProcess.this.processState); getRepositoryValidator().hardRefresh(); } }.queue();
/** * Initializes the current state, synchronously checks for the latest set of changes and kicks off * the background job to poll for changes. */ public void initialize(@NotNull CloudDebugProcessState processState) { this.processState = processState; currentSnapshot = null; new Task.Modal( getXDebugSession().getProject(), StackdriverDebuggerBundle.getString("clouddebug.attachingtext"), false) { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); getStateController().initialize(CloudDebugProcess.this.processState); getRepositoryValidator().hardRefresh(); } }.queue(); // Start breakpoints refresh job on first use. getStateController().addListener(this); getStateController().startBackgroundListening(); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { getBreakpointHandler().createIdeRepresentationsIfNecessary(getCurrentBreakpointList()); } }); }
void deleteBreakpointAsync(@NotNull final String breakpointId) { deleteBreakpoint(breakpointId, true); }
public void addListener(@NotNull CloudBreakpointListener listener) { getStateController().addListener(listener); }
public void fireBreakpointsChanged() { getStateController().fireBreakpointsChanged(); }
if (tokenToSend != null && !isBackgroundListening()) { return null; if (tokenToSend != null && !isBackgroundListening()) { return null;
public void testRegisterRegisteredButDisabledBreakpoint() { XLineBreakpointImpl<CloudLineBreakpointProperties> breakpoint = registerMockBreakpoint( psiJavaFile, NO_WATCHES, NO_CONDITION, 13, "fileName", "packageName", false, "12abc"); handler.setStateToDisabled(new Breakpoint().setId("12abc")); handler.registerBreakpoint(breakpoint); verify(stateController, times(2)) .setBreakpointAsync(isA(Breakpoint.class), isA(SetBreakpointHandler.class)); }
}); process.getStateController().stopBackgroundListening();
void deleteBreakpoint(@NotNull final String breakpointId) { deleteBreakpoint(breakpointId, false); }
@Override public void unregisterBreakpoint( @NotNull XLineBreakpoint<CloudLineBreakpointProperties> ideBreakpoint, boolean temporary) { // If the state was set to disabled as a result of a server update, // then we do not need to update the server side. if (!ideBreakpoint.getProperties().isDisabledByServer()) { String breakpointId = ideBreakpoint.getUserData(CLOUD_ID); if (!Strings.isNullOrEmpty(breakpointId)) { process.getStateController().deleteBreakpointAsync(breakpointId); } else { LOG.warn("could not delete breakpoint because it was not added through the cloud handler."); } } // reset this flag: either it has been disabled by the server or the client has deleted it, in // both cases we need to add it again, if it is re-enabled ideBreakpoint.getProperties().setAddedOnServer(false); } }
.setBreakpointAsync( serverNewBreakpoint, new SetBreakpointHandler() {