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. 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 Project: texlipse   Source 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
@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
Source Project: sarl   Source 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
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
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
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
Source Project: tm4e   Source 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
Source Project: tlaplus   Source 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
Source Project: Flashtool   Source 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
@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
Source Project: KaiZen-OpenAPI-Editor   Source 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
Source Project: tlaplus   Source 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
Source Project: gama   Source 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
@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
Source Project: JReFrameworker   Source 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
Source Project: elexis-3-core   Source 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
Source Project: gwt-eclipse-plugin   Source 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
Source Project: JReFrameworker   Source 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
Source Project: thym   Source 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
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
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
/**
 * 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
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
Source Project: APICloud-Studio   Source 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
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
Source Project: birt   Source 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
@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
Source Project: gwt-eclipse-plugin   Source 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
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
Source Project: gef   Source 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;
}