Java Code Examples for org.eclipse.debug.core.IStatusHandler#handleStatus()

The following examples show how to use org.eclipse.debug.core.IStatusHandler#handleStatus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/** Check for an updated {@code datastore-index-auto.xml} in the {@code default} module. */
private void checkUpdatedDatastoreIndex(ILaunchConfiguration configuration) {
  DatastoreIndexUpdateData update = DatastoreIndexUpdateData.detect(configuration, server);
  if (update == null) {
    return;
  }
  logger.fine("datastore-indexes-auto.xml found " + update.datastoreIndexesAutoXml);
  
  // punts to UI thread
  IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
  if (prompter != null) {
    try {
      prompter.handleStatus(DatastoreIndexesUpdatedStatusHandler.DATASTORE_INDEXES_UPDATED,
          update);
    } catch (CoreException ex) {
      logger.log(Level.WARNING, "Unexpected failure", ex);
    }
  }
}
 
Example 2
Source File: AbstractExecutionFlowSimulationEngine.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init() {
	try {
		ListBasedValidationIssueAcceptor acceptor = new ListBasedValidationIssueAcceptor();
		ExecutionFlow flow = sequencer.transform(statechart, acceptor);
		if (acceptor.getTraces(Severity.ERROR).size() > 0) {
			Status errorStatus = new Status(Status.ERROR, SimulationCoreActivator.PLUGIN_ID,
					ERROR_DURING_SIMULATION, acceptor.getTraces(Severity.ERROR).iterator().next().toString(), null);
			IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(errorStatus);
			try {
				statusHandler.handleStatus(errorStatus, getDebugTarget());
			} catch (CoreException e) {
				e.printStackTrace();
			}
		}

		if (!context.isSnapshot()) {
			contextInitializer.initialize(context, flow);
		}
		interpreter.initialize(flow, context, useInternalEventQueue());
	} catch (Exception ex) {
		handleException(ex);
		throw new InitializationException(ex.getMessage());
	}
}
 
Example 3
Source File: AbstractSimulationEngine.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void handleException(Throwable t) {
	if (t instanceof WrappedException) {
		t = ((WrappedException) t).getCause();
	}
	String statusMessage = t.getMessage() == null ? ERROR_MSG : t.getMessage();
	Status errorStatus = new Status(Status.ERROR, SimulationCoreActivator.PLUGIN_ID, ERROR_DURING_SIMULATION,
			statusMessage, t);
	SimulationCoreActivator.getDefault().getLog().log(errorStatus);
	IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(errorStatus);
	try {
		statusHandler.handleStatus(errorStatus, getDebugTarget());
	} catch (CoreException e) {
		e.printStackTrace();
	} finally {
		terminate();
	}
}
 
Example 4
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode,
    IProgressMonitor monitor) throws CoreException {
  SubMonitor progress = SubMonitor.convert(monitor, 50);
  if (!super.finalLaunchCheck(configuration, mode, progress.newChild(10))) {
    return false;
  }
  IStatus status = validateCloudSdk(progress.newChild(20));
  if (!status.isOK()) {
    // Throwing a CoreException will result in the ILaunch hanging around in
    // an invalid state
    StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
    return false;
  }

  // If we're auto-publishing before launch, check if there may be stale
  // resources not yet published. See
  // https://github.com/GoogleCloudPlatform/google-cloud-eclipse/issues/1832
  if (ServerCore.isAutoPublishing() && ResourcesPlugin.getWorkspace().isAutoBuilding()) {
    // Must wait for any current autobuild to complete so resource changes are triggered
    // and WTP will kick off ResourceChangeJobs. Note that there may be builds
    // pending that are unrelated to our resource changes, so simply checking
    // <code>JobManager.find(FAMILY_AUTO_BUILD).length > 0</code> produces too many
    // false positives.
    try {
      Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, progress.newChild(20));
    } catch (InterruptedException ex) {
      /* ignore */
    }
    IServer server = ServerUtil.getServer(configuration);
    if (server.shouldPublish() || hasPendingChangesToPublish()) {
      IStatusHandler prompter = DebugPlugin.getDefault().getStatusHandler(promptStatus);
      if (prompter != null) {
        Object continueLaunch = prompter
            .handleStatus(StaleResourcesStatusHandler.CONTINUE_LAUNCH_REQUEST, configuration);
        if (!(Boolean) continueLaunch) {
          // cancel the launch so Server.StartJob won't raise an error dialog, since the
          // server won't have been started
          monitor.setCanceled(true);
          return false;
        }
      }
    }
  }
  return true;
}