org.eclipse.core.runtime.Status Java Examples

The following examples show how to use org.eclipse.core.runtime.Status. 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: NodeJSService.java    From APICloud-Studio with 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 #2
Source File: KpsewhichRunner.java    From texlipse with 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 #3
Source File: EnableSarlMavenNatureAction.java    From sarl with 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
Source File: XtextEditorErrorTickUpdater.java    From xtext-eclipse with 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 #5
Source File: DocumentLineList.java    From tm4e with 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 #6
Source File: APKInstallJob.java    From Flashtool with 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 #7
Source File: ConvertToHybridProjectHandler.java    From thym with 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 #8
Source File: AzureARMCloudTLCInstanceParameters.java    From tlaplus with 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 #9
Source File: JsonEditor.java    From KaiZen-OpenAPI-Editor with 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 #10
Source File: GamlEditTemplateDialog.java    From gama with 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 #11
Source File: RenameExperimentDialog.java    From tracecompass with 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 #12
Source File: EnableDisableInjectMetricsAction.java    From codewind-eclipse with 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 #13
Source File: EC2CloudTLCInstanceParameters.java    From tlaplus with 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 #14
Source File: DeleteApplicationCommand.java    From orion.server with 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 #15
Source File: ExtractJob.java    From gwt-eclipse-plugin with 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 #16
Source File: ShowHiddenNeighborsOperation.java    From gef with 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 #17
Source File: ApplicationFileStore.java    From bonita-studio with 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 #18
Source File: CompletionProposalComputerDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Checks that the given attribute value is not <code>null</code>.
 *
 * @param value the object to check if not null
 * @param attribute the attribute
 * @throws InvalidRegistryObjectException if the registry element is no longer valid
 * @throws CoreException if <code>value</code> is <code>null</code>
 */
private void checkNotNull(Object value, String attribute) throws InvalidRegistryObjectException, CoreException {
	if (value == null) {
		Object[] args= { getId(), fElement.getContributor().getName(), attribute };
		String message= Messages.format(JavaTextMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
		IStatus status= new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, message, null);
		throw new CoreException(status);
	}
}
 
Example #19
Source File: URIBasedStorage.java    From n4js with 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 #20
Source File: CordovaPlugin.java    From thym with 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 #21
Source File: DiagnosticHandler.java    From APICloud-Studio with 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 #22
Source File: DeployProcessOperation.java    From bonita-studio with 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 #23
Source File: LocalAppEngineServerDelegateTest.java    From google-cloud-eclipse with 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 #24
Source File: UpdateTriggerCompilationParticipant.java    From gwt-eclipse-plugin with 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 #25
Source File: ExportExternal.java    From translationstudio8 with 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 #26
Source File: DefaultValidationJob.java    From statecharts with 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 #27
Source File: LineWrappingTabPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void forceSplitChanged(boolean forceSplit) {
    Iterator<Category> iterator= fSelectionState.fElements.iterator();
    String currentKey;
       while (iterator.hasNext()) {
           currentKey= iterator.next().key;
           try {
               changeForceSplit(currentKey, forceSplit);
           } catch (IllegalArgumentException e) {
   			fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT));
   			JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK,
   			        Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
   		}
       }
       fSelectionState.refreshState(fSelection);
}
 
Example #28
Source File: LegacyGWTHostPageSelectionDialog.java    From gwt-eclipse-plugin with 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 #29
Source File: BaseQuickOutlineSelectionDialog.java    From Pydev with 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 #30
Source File: Trace.java    From typescript.java with 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();
}