Java Code Examples for org.eclipse.core.runtime.Status

The following examples show how to use org.eclipse.core.runtime.Status. These examples are extracted from open source projects.
Example 1
Project: texlipse   File: KpsewhichRunner.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
    * 
    * @param command The command string to execute
    * @param resource The path to run the command in
    * @return Output from the command
    * @throws CoreException Thrown if running the external command generates an exception
    */
protected String run(String[] command, IResource resource) throws CoreException {
    // check if we are using console
       String console = null;
       if (TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.BUILDER_CONSOLE_OUTPUT)) {
           console = getProgramName();
       }
       
	extrun.setup(command, resource.getLocation().toFile().getParentFile(), console);
	
       String output = null;
       try {
               output = extrun.run();
           
       } catch (Exception e) {
           throw new CoreException(new Status(IStatus.ERROR, TexlipsePlugin.getPluginId(),
                   IStatus.ERROR, "Building the project: ", e));
       } finally {
           extrun.stop();
       }
       
       return output;
	
}
 
Example 2
Project: orion.server   File: DeleteApplicationCommand.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected IStatus validateParams() {
	try {
		/* read deploy parameters */
		ManifestParseTree manifest = application.getManifest();
		ManifestParseTree app = manifest.get("applications").get(0); //$NON-NLS-1$

		if (application.getName() != null) {
			appName = application.getName();
			return Status.OK_STATUS;
		}

		appName = app.get(CFProtocolConstants.V2_KEY_NAME).getValue();
		return Status.OK_STATUS;

	} catch (InvalidAccessException e) {
		return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null);
	}
}
 
Example 3
Project: sarl   File: EnableSarlMavenNatureAction.java    License: Apache License 2.0 6 votes vote down vote up
/** Create the configuration job for a Java project.
 *
 * @param project the project to configure.
 * @return the job.
 */
@SuppressWarnings("static-method")
protected Job createJobForJavaProject(IProject project) {
	return new Job(Messages.EnableSarlMavenNatureAction_0) {

		@Override
		protected IStatus run(IProgressMonitor monitor) {
			final SubMonitor mon = SubMonitor.convert(monitor, 3);
			// Force the project configuration to SARL.
			SARLProjectConfigurator.configureSARLProject(
					// Project to configure
					project,
					// Add SARL natures
					true,
					// Force java configuration
					true,
					// Create folders
					true,
					// Monitor
					mon.newChild(3));
			return Status.OK_STATUS;
		}
	};
}
 
Example 4
Project: APICloud-Studio   File: NodeJSService.java    License: GNU General Public License v3.0 6 votes vote down vote up
public IStatus validateSourcePath(IPath path)
{
	if (path == null || path.isEmpty())
	{
		return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, Messages.NodeJSService_EmptySourcePath);
	}

	if (!path.toFile().isDirectory())
	{
		return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, INodeJS.ERR_DOES_NOT_EXIST, MessageFormat.format(
				Messages.NodeJSService_NoDirectory_0, path), null);
	}

	if (!path.append(LIB).toFile().isDirectory())
	{
		return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, MessageFormat.format(
				Messages.NodeJSService_InvalidLocation_0, LIB));
	}
	// TODO Any other things we want to check for to "prove" it's a NodeJS source install?

	return Status.OK_STATUS;
}
 
Example 5
Project: codewind-eclipse   File: EnableDisableInjectMetricsAction.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public static void enableDisableInjectMetrics(CodewindApplication app, boolean enable) {
	Job job = new Job(NLS.bind(Messages.EnableDisableInjectMetricsJob, app.name)) {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			try {
				app.connection.requestInjectMetrics(app.projectID, enable);
				app.connection.refreshApps(app.projectID);
				return Status.OK_STATUS;
			} catch (Exception e) {
				Logger.logError("An error occurred changing inject metric setting for: " + app.name + ", with id: " + app.projectID, e); //$NON-NLS-1$ //$NON-NLS-2$
				return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ErrorOnEnableDisableInjectMetrics, app.name), e);
			}
		}
	};
	job.schedule();
}
 
Example 6
Project: tracecompass   File: RenameExperimentDialog.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void validateNewExperimentName() {

        String name = fNewExperimentName.getText();
        IWorkspace workspace = fExperimentFolder.getWorkspace();
        IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);

        if ("".equals(name)) { //$NON-NLS-1$
            updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_EmptyNameError, null));
            return;
        }

        if (!nameStatus.isOK()) {
            updateStatus(nameStatus);
            return;
        }

        IPath path = new Path(name);
        if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) {
            updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_ExistingNameError, null));
            return;
        }

        updateStatus(new Status(IStatus.OK, Activator.PLUGIN_ID, "")); //$NON-NLS-1$
    }
 
Example 7
Project: tm4e   File: DocumentLineList.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void documentChanged(DocumentEvent event) {
	IDocument document = event.getDocument();
	try {
		int startLine = DocumentHelper.getStartLine(event);
		if (!DocumentHelper.isRemove(event)) {
			int endLine = DocumentHelper.getEndLine(event, false);
			// Insert new lines
			for (int i = startLine; i < endLine; i++) {
				DocumentLineList.this.addLine(i + 1);
			}
			if (startLine == endLine) {
				DocumentLineList.this.updateLine(startLine);
			}
		} else {
			// Update line
			DocumentLineList.this.updateLine(startLine);
		}
		invalidateLine(startLine);
	} catch (BadLocationException e) {
		TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
	}
}
 
Example 8
Project: tlaplus   File: EC2CloudTLCInstanceParameters.java    License: MIT License 6 votes vote down vote up
@Override
public IStatus validateCredentials() {
	// must not be null
	if (getIdentity() != null && getCredentials() != null) {
		// identity always starts with "AIKA" and has 20 chars
		if (getIdentity().matches("AKIA[a-zA-Z0-9]{16}")) {
			// secret has 40 chars
			if (getCredentials().length() == 40) {
				return Status.OK_STATUS;
			}
		}
	}
	return new Status(Status.ERROR, "org.lamport.tla.toolbox.jcloud",
			"Invalid credentials, please check the environment variables "
					+ "(AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY) are correctly "
					+ "set up and picked up by the Toolbox."
					+ "\n\nPlease visit the Toolbox help and read section 4 "
					+ "of \"Cloud based distributed TLC\" on how to setup authentication.");
}
 
Example 9
Project: Flashtool   File: APKInstallJob.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected IStatus run(IProgressMonitor monitor) {
 	try {
File files = new File(instpath);
File[] chld = files.listFiles(new APKFilter());
LogProgress.initProgress(chld.length);
for(int i = 0; i < chld.length; i++){
	if (chld[i].getName().toUpperCase().endsWith(".APK"))
		AdbUtility.install(chld[i].getPath());
	LogProgress.updateProgress();
}
LogProgress.initProgress(0);
logger.info("APK Installation finished");
return Status.OK_STATUS;
 	}
 	catch (Exception e) {
 		e.printStackTrace();
 		logger.error(e.getMessage());
 		LogProgress.initProgress(0);
 		return Status.CANCEL_STATUS;
 	}
 }
 
Example 10
Project: xtext-eclipse   File: XtextEditorErrorTickUpdater.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
	IEditorSite site = null != editor ? editor.getEditorSite() : null;
	if (site != null) {
		if (!monitor.isCanceled() && editor != null) {
			if (titleImage != null && !titleImage.isDisposed()) {
				editor.updatedTitleImage(titleImage);
				titleImage = null;
			} else if (titleImageDescription != null) {
				Image image = imageHelper.getImage(titleImageDescription);
				if (editor.getTitleImage() != image) {
					editor.updatedTitleImage(image);
				}
				titleImageDescription = null;
			}
		}
	}
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	return Status.OK_STATUS;
}
 
Example 11
Project: KaiZen-OpenAPI-Editor   File: JsonEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected void runValidate(final boolean onOpen) {
    ValidationOperation validationOperation = createValidationOperation(onOpen);
    SafeWorkspaceJob validationJob = new SafeWorkspaceJob("Update KaiZen Editor validation markers") {
        @Override
        public IStatus doRunInWorkspace(IProgressMonitor monitor) throws CoreException {
            validationOperation.run(monitor);
            return Status.OK_STATUS;
        }

        @Override
        public boolean belongsTo(Object family) {
            if (family instanceof ValidationOperation) {
                return getEditorInput().equals(((ValidationOperation) family).getEditorInput());
            }
            return false;
        }
    };
    Job.getJobManager().cancel(validationOperation);
    validationJob.schedule();
}
 
Example 12
Project: tlaplus   File: AzureARMCloudTLCInstanceParameters.java    License: MIT License 6 votes vote down vote up
@Override
public IStatus validateCredentials() {
	final String credential = System.getenv(AZURE_COMPUTE_SERVICE_PRINCIPAL_PASSWORD);
	final String identity = System.getenv(AZURE_COMPUTE_SERVICE_PRINCIPAL);
	final String subscription = System.getenv(AZURE_COMPUTE_SUBSCRIPTION);
	final String tenantId = System.getenv(AZURE_COMPUTE_TENANT);
	if (credential == null || identity == null || subscription == null || tenantId == null) {
		return new Status(Status.ERROR, "org.lamport.tla.toolbox.jcloud",
				"Invalid credentials, please check the environment variables "
						+ "(" + AZURE_COMPUTE_SERVICE_PRINCIPAL_PASSWORD + " & " + AZURE_COMPUTE_SERVICE_PRINCIPAL + " "
						+ "& " + AZURE_COMPUTE_TENANT + " and " + AZURE_COMPUTE_SUBSCRIPTION + ") are correctly "
						+ "set up and picked up by the Toolbox."
						+ "\n\nPlease visit the Toolbox help and read section 4 "
						+ "of \"Cloud based distributed TLC\" on how to setup authentication.");
	}
	return Status.OK_STATUS;
}
 
Example 13
Project: gama   File: GamlEditTemplateDialog.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected SourceViewer createViewer(final Composite parent) {
	final Builder editorBuilder = configuration.getEmbeddedEditorFactory().newEditor(resourceProvider);
	editorBuilder.processIssuesBy((issues, monitor) -> {
		IStatus result = Status.OK_STATUS;
		final StringBuilder messages = new StringBuilder();
		for (final Issue issue : issues) {
			if (issue.getSeverity() == Severity.ERROR) {
				if (messages.length() != 0) {
					messages.append('\n');
				}
				messages.append(issue.getMessage());
			}
		}
		if (messages.length() != 0) {
			result = createErrorStatus(messages.toString(), null);
		}
		final IStatus toBeUpdated = result;
		getShell().getDisplay().asyncExec(() -> updateStatus(toBeUpdated));
	});
	final EmbeddedEditor handle = editorBuilder.withParent(parent);
	partialModelEditor = handle.createPartialEditor(getPrefix(), data.getTemplate().getPattern(), "", true);
	return handle.getViewer();
}
 
Example 14
Project: thym   File: ConvertToHybridProjectHandler.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    
    IProject project = getProject(event);
    if(project != null ){
        final IProject theProject = project;//to pass to Job
        WorkspaceJob job = new WorkspaceJob(NLS.bind("Convert {0} to Hybrid Mobile project", project.getName())) {
            
            @Override
            public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                HybridProjectCreator creator = new HybridProjectCreator();
                creator.convertProject(theProject, new NullProgressMonitor());
                return Status.OK_STATUS;
            }
        };
        job.schedule();
    }
    return null;
}
 
Example 15
Project: JReFrameworker   File: Log.java    License: MIT License 5 votes vote down vote up
public static void log(int severity, String string, Throwable e) {
	if(log == null){
		System.err.println(string + "\n" + e);
	} else {
		IStatus status = new Status(severity, Activator.PLUGIN_ID, string, e);
		log.log(status);
	}
}
 
Example 16
Project: elexis-3-core   File: FlatDataLoader.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * From @see DelayableJob.IWorker
 */
public IStatus work(IProgressMonitor monitor, HashMap<String, Object> params){
	if (isSuspended()) {
		return Status.CANCEL_STATUS;
	}
	final TableViewer tv = (TableViewer) cv.getViewerWidget();
	if (filtered != null) {
		filtered.clear();
	}
	filtered = null;
	setQuery();
	applyQueryFilters();
	if (orderFields != null) {
		qbe.orderBy(false, orderFields);
	}
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	raw = qbe.execute();
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	UiDesk.asyncExec(new Runnable() {
		public void run(){
			// Avoid access to disposed table
			if (tv != null && !tv.getTable().isDisposed()) {
				tv.setItemCount(0);
				filtered = raw;
				tv.setItemCount(raw.size());
			}
		}
	});
	
	return Status.OK_STATUS;
}
 
Example 17
Project: gwt-eclipse-plugin   File: WebAppTabGroup.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void createUpdateJob() {
  new WorkbenchJob("WebAppTabGroup") {
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      ILaunchConfigurationTab tab = launchConfigurationDialog.getActiveTab();
      if (tab != null && !tab.getControl().isDisposed()) {
        launchConfigurationDialog.updateButtons();
        launchConfigurationDialog.updateMessage();
      }
      return Status.OK_STATUS;
    }
  }.schedule();
}
 
Example 18
Project: JReFrameworker   File: JReFrameworker.java    License: MIT License 5 votes vote down vote up
public static IStatus deleteProject(IProject project) {
	if (project != null && project.exists())
		try {
			project.delete(true, true, new NullProgressMonitor());
		} catch (CoreException e) {
			Log.error("Could not delete project", e);
			return new Status(Status.ERROR, Activator.PLUGIN_ID, "Could not delete project", e);
		}
	return Status.OK_STATUS;
}
 
Example 19
Project: thym   File: CordovaPlugin.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks if the given engine is compatible with this plug-in. Returns a
 * {@link MultiStatus} as there may be more than one reason for an engine to
 * fail.
 * 
 * @param engine
 * @return A WARNING or OK level status
 * 
 */
public IStatus isEngineCompatible(HybridMobileEngine engine) {
	if (supportedEngines == null || supportedEngines.isEmpty())
		return Status.OK_STATUS;
	MultiStatus status = new MultiStatus(HybridCore.PLUGIN_ID, 0,
			NLS.bind("Plug-in {0} is not compatible with {1} version {2}",
					new Object[] { getLabel(), engine.getName(), engine.getSpec() }),
			null);
	for (EngineDefinition definition : supportedEngines) {
		status.add(isDefinitionSatisfied(definition, engine));
	}
	return status;
}
 
Example 20
Project: bonita-studio   File: ExportConnectorArchiveOperation.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected IStatus addImplementationJar(final ConnectorImplementation implementation, final IFolder classpathFolder, final SourceRepositoryStore sourceStore, final IRepositoryStore implStore, final List<IResource> resourcesToExport) throws CoreException, InvocationTargetException, InterruptedException {
    final String connectorJarName = NamingUtils.toConnectorImplementationFilename(implementation.getImplementationId(), implementation.getImplementationVersion(),false) +".jar";
    final IFile jarFile = classpathFolder.getFile(Path.fromOSString(connectorJarName)) ;
    final String qualifiedClassName = impl.getImplementationClassname() ;
    String packageName ="" ;
    if(qualifiedClassName.indexOf(".")!= -1){
        packageName = qualifiedClassName.substring(0, qualifiedClassName.lastIndexOf(".")) ;
    }
    final PackageFileStore file =  (PackageFileStore) sourceStore.getChild(packageName, true) ;
    if(file != null){
        file.exportAsJar(jarFile.getLocation().toFile().getAbsolutePath(), false) ;
        if(includeSources){
            final IFolder srcFolder = implStore.getResource().getFolder(SRC_DIR) ;
            if(srcFolder.exists()){
                srcFolder.delete(true, Repository.NULL_PROGRESS_MONITOR) ;
            }
            srcFolder.create(true, true, Repository.NULL_PROGRESS_MONITOR) ;
            cleanAfterExport.add(srcFolder) ;

            final IPath path = file.getResource().getFullPath().makeRelativeTo(sourceStore.getResource().getFullPath()) ;
            final IFolder newFolder = srcFolder.getFolder(path) ;
            newFolder.getLocation().toFile().getParentFile().mkdirs() ;
            srcFolder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR) ;
            file.getResource().copy(newFolder.getFullPath(),true, Repository.NULL_PROGRESS_MONITOR) ;


            resourcesToExport.add(srcFolder) ;
        }
    }

    return Status.OK_STATUS ;
}
 
Example 21
Project: Eclipse-Postfix-Code-Completion   File: LineWrappingTabPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void indentStyleChanged(int indentStyle) {
    Iterator<Category> iterator= fSelectionState.fElements.iterator();
    String currentKey;
       while (iterator.hasNext()) {
           currentKey= iterator.next().key;
       	try {
           	changeIndentStyle(currentKey, indentStyle);
       	} catch (IllegalArgumentException e) {
   			fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle));
   			JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK,
   			        Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
   		}
       }
       fSelectionState.refreshState(fSelection);
}
 
Example 22
Project: APICloud-Studio   File: DownloadManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Download the remote content.
 * 
 * @param monitor
 */
protected IStatus download(IProgressMonitor monitor)
{
	SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.DownloadManager_downloadingContent,
			downloads.size());
	MultiStatus multi = new MultiStatus(CoreIOPlugin.PLUGIN_ID, IStatus.OK, null, null);
	completedDownloadsPaths = new ArrayList<IPath>(downloads.size());
	for (Iterator<ContentDownloadRequest> iterator = downloads.iterator(); iterator.hasNext();)
	{
		if (subMonitor.isCanceled())
		{
			// TODO Append to multi status and return that?
			return Status.CANCEL_STATUS;
		}

		ContentDownloadRequest request = iterator.next();
		request.execute(subMonitor.newChild(1));
		IStatus result = request.getResult();
		if (result != null)
		{
			if (result.isOK())
			{
				completedDownloadsPaths.add(request.getDownloadLocation());
				iterator.remove();
			}
			multi.add(result);
		}
		subMonitor.setWorkRemaining(downloads.size());
	}

	return multi;
}
 
Example 23
Project: bonita-studio   File: UndeployProcessOperation.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected IStatus undeploy(final IProgressMonitor monitor) {
    for (final AbstractProcess process : processes) {
        try {
            undeployProcess(process, monitor);
        } catch (Exception e) {
            BonitaStudioLog.error(e, EnginePlugin.PLUGIN_ID);
            return new Status(Status.ERROR, EnginePlugin.PLUGIN_ID, String.format("%s (%s): %s",process.getName(),process.getVersion(),e.getMessage()), e);
        }
    }
    return Status.OK_STATUS;
}
 
Example 24
Project: APICloud-Studio   File: Activator.java    License: GNU General Public License v3.0 5 votes vote down vote up
public boolean isAvailable() {
	boolean available = JhlClientAdapterFactory.isAvailable();
	if (!available && !loadErrorLogged) {
		getLog().log(new Status(IStatus.INFO, PLUGIN_ID, 0, getLoadErrors(), null));
		loadErrorLogged = true;
		org.tigris.subversion.clientadapter.Activator.getDefault().handleLoadErrors(this);
	}
	return available;
}
 
Example 25
Project: bonita-studio   File: DeployProcessOperation.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected IStatus openProcessEnablementProblemsDialog(final AbstractProcess process,
        final List<Problem> processResolutionProblems) {
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            problemResolutionResult = createProcessEnablementProblemsDialog(process, processResolutionProblems)
                    .open();
        }

    });

    return problemResolutionResult == IDialogConstants.OK_ID ? Status.OK_STATUS : Status.CANCEL_STATUS;
}
 
Example 26
Project: birt   File: StaticHTMLPrviewPlugin.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void deleteTempFile( )
{
	Job deleteJob = new Job( "Delete temporary files" ) { //$NON-NLS-1$

		protected IStatus run( IProgressMonitor monitor )
		{
			deleteFile( new File( getTempFolder( ) ) );
			return Status.OK_STATUS;
		}
	};
	deleteJob.setSystem( true );
	deleteJob.schedule( );
}
 
Example 27
Project: bonita-studio   File: ApplicationFileStore.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public IStatus build(IPath buildPath, IProgressMonitor monitor) {
    IPath applicationFolderPath = buildPath.append("application");
    IFolder applicationFolder = getRepository().getProject()
            .getFolder(applicationFolderPath.makeRelativeTo(getRepository().getProject().getLocation()));
    if (!applicationFolder.exists()) {
        try {
            applicationFolder.create(true, true, new NullProgressMonitor());
            getResource().copy(applicationFolder.getFile(getName()).getFullPath(), false, new NullProgressMonitor());
        } catch (CoreException e) {
            return e.getStatus();
        }
    }
    return Status.OK_STATUS;
}
 
Example 28
Project: gwt-eclipse-plugin   File: ExtractJob.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * If we've finished the job and it didn't fail, fire the specified completed
 * action.
 */
protected void maybeFireCompletedAction(IStatus jobStatus) {
  if (completedAction != null && jobStatus == Status.OK_STATUS) {
    Display.getDefault().asyncExec(new Runnable() {
      public void run() {
        completedAction.run();
      }
    });
  }
}
 
Example 29
Project: APICloud-Studio   File: DiagnosticHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	Job job = new Job("Getting Diagnostic Logs") //$NON-NLS-1$
	{

		@Override
		protected IStatus run(IProgressMonitor monitor)
		{
			final String content = getLogContent();
			UIUtils.getDisplay().asyncExec(new Runnable()
			{

				public void run()
				{
					DiagnosticDialog dialog = new DiagnosticDialog(UIUtils.getActiveShell());
					dialog.open();
					dialog.setText(content);
				}
			});
			return Status.OK_STATUS;
		}
	};
	EclipseUtil.setSystemForJob(job);
	job.schedule();

	return null;
}
 
Example 30
Project: gef   File: ShowHiddenNeighborsOperation.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	for (NodePart neighborPart : shownNeighbors) {
		hidingModel.hide(neighborPart);
		neighborPart.deactivate();
	}
	return Status.OK_STATUS;
}
 
Example 31
Project: google-cloud-eclipse   File: LocalAppEngineServerDelegateTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCheckProjectFacets_appEngineStandardFacet() throws CoreException {
  delegate = getDelegateWithServer();
  IModule[] add = new IModule[]{ module1 };
  when(module1.getProject()).thenReturn(appEngineStandardProject.getProject());
  Assert.assertEquals(Status.OK_STATUS, delegate.checkProjectFacets(add));
}
 
Example 32
Project: gwt-eclipse-plugin   File: UpdateTriggerCompilationParticipant.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void checkUpdates() {
  Job job = new Job("Check Update") {
    @Override
    protected IStatus run(IProgressMonitor monitor) {
      try {
        GdtExtPlugin.getFeatureUpdateManager().checkForUpdates();
      } catch (Exception e) {
        // No need to catch network issues.
      }
      System.out.println("check updates");
      return Status.OK_STATUS;
    }
  };
  job.schedule();
}
 
Example 33
Project: statecharts   File: DefaultValidationJob.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void run() {
	try {
		List<Issue> result = validator.validate(resource, checkMode, indicator);
		setResult(result);
		setStatus(Status.OK_STATUS);
	} catch (OperationCanceledException ex) {
		setStatus(Status.CANCEL_STATUS);
	}
}
 
Example 34
Project: gwt-eclipse-plugin   File: LegacyGWTHostPageSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public IStatus validate(Object[] selection) {
  if (selection.length == 1) {
    LegacyGWTHostPageSelectionTreeItem selectedItem = (LegacyGWTHostPageSelectionTreeItem) selection[0];
    if (selectedItem.isHostPage()) {
      // Can't use Status.OK_STATUS because we don't want the "ok" visible
      return OK_STATUS;
    }
  }

  return new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "");
}
 
Example 35
Project: Pydev   File: BaseQuickOutlineSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
    if (!monitor.isCanceled()) {
        getTreeViewer().setInput(rootWithParents);
    } else {
        //Will be recalculated if asked again!
        rootWithParents = null;
    }

    return Status.OK_STATUS;
}
 
Example 36
Project: typescript.java   File: Trace.java    License: MIT License 5 votes vote down vote up
/**
 * Trace the given message and exception.
 * 
 * @param level
 *            a trace level
 * @param s
 *            a message
 * @param t
 *            a throwable
 */
public static void trace(byte level, String s, Throwable t) {
	if (s == null)
		return;

	if (level == SEVERE) {
		if (!logged.contains(s)) {
			JSDTTypeScriptUIPlugin
					.getDefault()
					.getLog()
					.log(new Status(IStatus.ERROR,
							JSDTTypeScriptUIPlugin.PLUGIN_ID, s, t));
			logged.add(s);
		}
	}

	if (!JSDTTypeScriptUIPlugin.getDefault().isDebugging())
		return;

	StringBuilder sb = new StringBuilder(JSDTTypeScriptUIPlugin.PLUGIN_ID);
	sb.append(" ");
	sb.append(levelNames[level]);
	sb.append(" ");
	sb.append(sdf.format(new Date()));
	sb.append(" ");
	sb.append(s);
	System.out.println(sb.toString());
	if (t != null)
		t.printStackTrace();
}
 
Example 37
Project: translationstudio8   File: ExportExternal.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void openErrorDialog(final Shell shell, final Throwable e) {
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {
			ErrorDialog.openError(shell, Messages.getString("all.dialog.error"), e.getMessage(), new Status(
					IStatus.ERROR, Activator.PLUGIN_ID, e.getCause() == null ? null : e.getCause().getMessage(), e));
		}
	});
}
 
Example 38
Project: n4js   File: URIBasedStorage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public InputStream getContents() throws CoreException {
	try {
		return URIConverter.INSTANCE.createInputStream(uri);
	} catch (IOException e) {
		throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.n4js.ts.ui", "Cannot load "
				+ getFullPath(), e));
	}
}
 
Example 39
Project: elexis-3-core   File: ResultAdapter.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Mapping zwischen Severity und RCP Status Severity (Status.OK, Stauts.INFO, usw)
 */
public static int getSeverityAsStatus(final Result.SEVERITY severity){
	switch (severity.ordinal()) {
	case 0:
		return Status.OK;
	case 3:
		return Status.ERROR;
	case 2:
		return Status.ERROR;
	case 1:
		return Status.INFO;
	}
	return Status.ERROR;
}
 
Example 40
Project: eip-designer   File: Activator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Handle an error. The error is logged. If <code>show</code> is
 * <code>true</code> the error is shown to the user.
 * @param message a localized message
 * @param throwable
 * @param show
 */
public static void handleError(String message, Throwable throwable, boolean show) {
   IStatus status = new Status(IStatus.ERROR, getPluginId(), message, throwable);
   int style = StatusManager.LOG;
   if (show) {
      style |= StatusManager.SHOW;
   }
   StatusManager.getManager().handle(status, style);
}