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

The following examples show how to use org.eclipse.core.runtime.IStatus. 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
/**
 * Update the shown name with the server stop/stopping state.
 */
private void updateName(int serverState) {
  final String computedName;
  if (serverState == IServer.STATE_STARTING) {
    computedName = Messages.getString("SERVER_STARTING_TEMPLATE", unprefixedName);
  } else if (serverState == IServer.STATE_STOPPING) {
    computedName = Messages.getString("SERVER_STOPPING_TEMPLATE", unprefixedName);
  } else if (serverState == IServer.STATE_STOPPED) {
    computedName = Messages.getString("SERVER_STOPPED_TEMPLATE", unprefixedName);
  } else {
    computedName = unprefixedName;
  }
  UIJob nameUpdateJob = new UIJob("Update server name") {
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      LocalAppEngineConsole.this.setName(computedName);
      return Status.OK_STATUS;
    }
  };
  nameUpdateJob.setSystem(true);
  nameUpdateJob.schedule();
}
 
Example 2
@Override
protected IStatus run(final IProgressMonitor monitor) {
    if (monitor != null) {
        monitor.beginTask("Computing referenced inputs...", IProgressMonitor.UNKNOWN);
    }
    referencedInputs.clear();
    if (groovyCompilationUnit.getModuleNode() != null) {
        BlockStatement astNode = groovyCompilationUnit.getModuleNode().getStatementBlock();
        if (astNode instanceof BlockStatement) {
            final BlockStatement blockStatement = (BlockStatement) astNode;
            addRefrencedInputs(blockStatement);
        }
    }
    constraint.getInputNames().clear();
    constraint.getInputNames().addAll(getReferencedInputs());
    return Status.OK_STATUS;
}
 
Example 3
/**
 * 验证 xliff 所需要转换的 xliff 文件
 * @param xliffPath
 *            xliff 文件路径
 * @param monitor
 * @return ;
 */
public IStatus validateXliffFile(String xliffPath, XLFHandler handler, IProgressMonitor monitor) {
	IStatus result = new ReverseConversionValidateWithLibrary3().validate(xliffPath, configBean, monitor);
	if (!result.isOK()) {
		return result;
	}
	// 验证是否存在 xliff 对应的源文件类型的转换器实现
	String fileType = configBean.getFileType();
	Converter converter = getConverter(fileType);
	if (converter != null) {
		result = validateFileNodeInXliff(handler, xliffPath, converter.getType()); // 验证 XLIFF 文件的 file 节点
		if (!result.isOK()) {
			return result;
		}

		result = validIsSplitedXliff(handler, xliffPath);
		if (!result.isOK()) {
			return result;
		}
		setSelectedType(fileType);
		result = Status.OK_STATUS;
	} else {
		result = ValidationStatus.error(Messages.getString("model.ConverterViewModel.msg3") + fileType);
	}
	return result;
}
 
Example 4
@Override
protected IStatus performBatchValidation(IValidationContext ctx) {
    final EObject eObj = ctx.getTarget();
    if (eObj instanceof Assignable) {
        final Assignable assignable = (Assignable) eObj;
        if (!hasActorsDefined(assignable)) {
            if (assignable instanceof Lane) {
                if (hasTaskUsingLaneActor((Lane) assignable)) {
                    return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
                }
            } else {
                return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
            }
        }
    }
    return ctx.createSuccessStatus();
}
 
Example 5
Source Project: bonita-studio   Source File: DialogSupport.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Object calculate() {
    int maxSeverity = IStatus.OK;
    ValidationStatusProvider maxSeverityProvider = null;
    for (Iterator it = validationStatusProviders.iterator(); it.hasNext();) {
        ValidationStatusProvider provider = (ValidationStatusProvider) it
                .next();
        IStatus status = (IStatus) provider.getValidationStatus()
                .getValue();
        if (status.getSeverity() > maxSeverity) {
            maxSeverity = status.getSeverity();
            maxSeverityProvider = provider;
        }
    }
    return maxSeverityProvider;
}
 
Example 6
Source Project: tlaplus   Source File: RefreshSpecHandler.java    License: MIT License 6 votes vote down vote up
public Object execute(final ExecutionEvent event) throws ExecutionException {
	final IWorkbenchPage activePage = UIHelper.getActivePage();
	if (activePage != null) {
		final ISelection selection = activePage.getSelection(ToolboxExplorer.VIEW_ID);
		if (selection != null && selection instanceof IStructuredSelection
				&& !((IStructuredSelection) selection).isEmpty()) {

			final Job job = new ToolboxJob("Refreshing spec...") {
				/* (non-Javadoc)
				 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
				 */
				protected IStatus run(IProgressMonitor monitor) {
					final Iterator<Spec> selectionIterator = ((IStructuredSelection) selection).iterator();
					while (selectionIterator.hasNext()) {
						ResourceHelper.refreshSpec(selectionIterator.next(), monitor);
					}
					return Status.OK_STATUS;
				}
			};
			job.schedule();
		}
	}
	return null;
}
 
Example 7
Source Project: thym   Source File: PluginContentProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object[] getChildren(Object parentElement) {
	if (!(parentElement instanceof IFolder)) {
		return new Object[0];
	}
	IFolder folder = (IFolder) parentElement;
	if (folder.getProjectRelativePath().segmentCount() > 1) {// only plugins folder at the root of the project
		return new Object[0];
	}
	List<HybridPluginFolder> plugins = new ArrayList<>();
	HybridProject project = HybridProject.getHybridProject(folder.getProject());
	try {
		for (IResource member : folder.members()) {
			if (member instanceof IFolder) {
				IFolder pluginFolder = (IFolder) member;
				plugins.add(new HybridPluginFolder(pluginFolder, getPlugin(pluginFolder.getName(), project)));
			}
		}
	} catch (CoreException e) {
		HybridUI.log(IStatus.ERROR, "Error retrieving the installed plugins", e);
	}

	return plugins.toArray();
}
 
Example 8
Source Project: tracecompass   Source File: GdbEventsTable.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void selectFrame(final GdbTrace gdbTrace, final long frameNumber) {
    Job b = new Job("GDB Trace select frame") { //$NON-NLS-1$
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            // This sends commands to GDB and can potentially wait on the UI
            // thread (gdb traces console buffer full) so it needs to be
            // exectued on a non-UI thread
            gdbTrace.selectFrame(frameNumber);
            fSelectedTrace = gdbTrace;
            fSelectedFrame = frameNumber;
            return Status.OK_STATUS;
        }
    };
    b.setSystem(true);
    b.schedule();
}
 
Example 9
public Image getColumnImage(Object element, int index) {
	BindingElement be = (BindingElement) element;
	switch (index) {
	case COMMAND_NAME_COLUMN:
		final String commandId = be.getId();
		final ImageDescriptor imageDescriptor = commandImageService.getImageDescriptor(commandId);
		if (imageDescriptor == null) {
			return null;
		}
		try {
			return localResourceManager.createImage(imageDescriptor);
		} catch (final DeviceResourceException e) {
			final String message = "Problem retrieving image for a command '" //$NON-NLS-1$
					+ commandId + '\'';
			final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e);
			WorkbenchPlugin.log(message, status);
		}
		return null;
	}

	return null;
}
 
Example 10
private static Set<EObject> collectTargetElements(final IStatus status,
        final Set<EObject> targetElementCollector, final List allConstraintStatuses) {
    if (status instanceof IConstraintStatus) {
        targetElementCollector
                .add(((IConstraintStatus) status).getTarget());
        allConstraintStatuses.add(status);
    }
    if (status.isMultiStatus()) {
        final IStatus[] children = status.getChildren();
        for (int i = 0; i < children.length; i++) {
            collectTargetElements(children[i], targetElementCollector,
                    allConstraintStatuses);
        }
    }
    return targetElementCollector;
}
 
Example 11
Source Project: gemfirexd-oss   Source File: DerbyClasspathContainer.java    License: Apache License 2.0 6 votes vote down vote up
public DerbyClasspathContainer() {
    List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
    Bundle bundle = Platform.getBundle(CommonNames.CORE_PATH);
    Enumeration en = bundle.findEntries("/", "*.jar", true);
    String rootPath = null;
    try { 
        rootPath = FileLocator.resolve(FileLocator.find(bundle, new Path("/"), null)).getPath();
    } catch(IOException e) {
        Logger.log(e.getMessage(), IStatus.ERROR);
    }
    while(en.hasMoreElements()) {
        IClasspathEntry cpe = JavaCore.newLibraryEntry(new Path(rootPath+'/'+((URL)en.nextElement()).getFile()), null, null);
        entries.add(cpe);
    }    
    IClasspathEntry[] cpes = new IClasspathEntry[entries.size()];
    _entries = (IClasspathEntry[])entries.toArray(cpes);
}
 
Example 12
Source Project: gwt-eclipse-plugin   Source File: GwtMavenPlugin.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private static void logToStderr(int severity, String message, Throwable t) {
  switch(severity) {
    case IStatus.OK:
      System.err.print("OK: ");
      break;
    case IStatus.INFO:
      System.err.print("INFO: ");
      break;
    case IStatus.WARNING:
      System.err.print("WARNING: ");
      break;
    case IStatus.ERROR:
      System.err.print("ERROR: ");
      break;
    case IStatus.CANCEL:
      System.err.print("CANCEL: ");
      break;
    default:
      break;
  }
  System.err.println(message);
  if (t != null) {
    t.printStackTrace(System.err);
  }
}
 
Example 13
public IStatus apply(final IProject project, boolean promptForOverwrite)
{
	IInputStreamTransformer transform = new TemplateSubstitutionTransformer(project);
	File zipFile = new File(getDirectory(), getLocation());
	try
	{
		return ZipUtil.extract(zipFile, project.getLocation().toFile(),
				promptForOverwrite ? ZipUtil.Conflict.PROMPT : ZipUtil.Conflict.OVERWRITE, transform,
				new NullProgressMonitor());
	}
	catch (IOException e)
	{
		return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, MessageFormat.format(
				"IOException reading zipfile {0}", zipFile.getAbsolutePath()), e); //$NON-NLS-1$
	}
}
 
Example 14
Source Project: elexis-3-core   Source File: BillingUtil.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private void changeCountLeistung(Object item){
	leistungDTO = (LeistungDTO) item;
	verrechnet = leistungDTO.getVerrechnet();
	if (verrechnet != null) {
		acquireLock(locks, verrechnet, false);
		IStatus ret =
			verrechnet.changeAnzahlValidated(leistungDTO.getCount());
		log.debug("invoice correction: changed count from leistung id [{}]",
			leistungDTO.getId());
		if (ret.isOK()) {
			verrechnet.setSecondaryScaleFactor(leistungDTO.getScale2());
		} else {
			addToOutput(output, ret.getMessage());
			success = false;
			log.warn(
				"invoice correction: cannot change count from leistung with id [{}]",
				leistungDTO.getId());
		}
	}
}
 
Example 15
Source Project: gwt-eclipse-plugin   Source File: AddSdkDialog.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected boolean validateDirectory() {
  String directory = directoryText.getText().trim();
  if (directory.length() == 0) {
    // No directory specified
    updateStatus(new Status(IStatus.ERROR, pluginId,
        "Enter the installation directory for the SDK."));
    return false;
  }

  IPath sdkHome = getSdkHome(directory);
  File dir = sdkHome.toFile();
  if (!dir.isDirectory()) {
    updateStatus(new Status(IStatus.ERROR, pluginId,
        "The installation directory does not exist"));
    return false;
  }
  return true;
}
 
Example 16
protected void testDeleteDeletedDerivedResource(IContainer output) {
	try {
		File outputDirectory = output.getLocation().toFile();
		int expectedSize = 0;
		if (outputDirectory.exists()) {
			expectedSize = outputDirectory.list().length;
		}
		IFile sourceFile = createFile(project.getFile(("src/Foo" + F_EXT)).getFullPath(), "object Foo");
		build();
		Assert.assertNotEquals(expectedSize, outputDirectory.list().length);
		IFile file = output.getFile(new Path("Foo.txt"));
		file.refreshLocal(0, null);
		Assert.assertTrue(isSynchronized(file));
		new WorkspaceJob("file.delete") {
			@Override
			public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
				Assert.assertTrue(file.getLocation().toFile().delete());
				Assert.assertFalse(isSynchronized(file));
				return Status.OK_STATUS;
			}
		}.run(monitor());
		sourceFile.delete(false, monitor());
		build();
		Assert.assertEquals(expectedSize, outputDirectory.list().length);
	} catch (CoreException e) {
		throw Exceptions.sneakyThrow(e);
	}
}
 
Example 17
Source Project: Pydev   Source File: PyCollapse.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run(IAction action) {
    PySelection ps = PySelectionFromEditor.createPySelectionFromEditor(getTextEditor());

    ProjectionAnnotationModel model = getTextEditor().getAdapter(
            ProjectionAnnotationModel.class);
    try {
        if (model != null) {
            //put annotations in array list.
            Iterator iter = model.getAnnotationIterator();
            while (iter != null && iter.hasNext()) {
                PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next();
                Position position = model.getPosition(element);

                int line = ps.getDoc().getLineOfOffset(position.offset);

                int start = ps.getStartLineIndex();
                int end = ps.getEndLineIndex();

                for (int i = start; i <= end; i++) {
                    if (i == line) {
                        model.collapse(element);
                        break;
                    }
                }
            }

        }
    } catch (BadLocationException e) {
        Log.log(IStatus.ERROR, "Unexpected error collapsing", e);
    }
}
 
Example 18
/**
 * Finds the most severe status from a array of stati.
 * An error is more severe than a warning, and a warning is more severe
 * than ok.
 * @param status an array of stati
 * @return the most severe status
 */
public static IStatus getMostSevere(IStatus[] status) {
	IStatus max= null;
	for (int i= 0; i < status.length; i++) {
		IStatus curr= status[i];
		if (curr.matches(IStatus.ERROR)) {
			return curr;
		}
		if (max == null || curr.getSeverity() > max.getSeverity()) {
			max= curr;
		}
	}
	return max;
}
 
Example 19
private IStatus validateClassFile() {
	IPackageFragmentRoot root = getPackageFragmentRoot();
	try {
		if (root.getKind() != IPackageFragmentRoot.K_BINARY)
			return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root);
	} catch (JavaModelException e) {
		return e.getJavaModelStatus();
	}
	IJavaProject project = getJavaProject();
	return JavaConventions.validateClassFileName(getElementName(), project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true));
}
 
Example 20
public static CoreException wrap(IStatus status)
{
	CoreException e = new CoreException(status);
	Throwable t = status.getException();
	if (t != null)
		e.initCause(t);
	return e;
}
 
Example 21
Source Project: bonita-studio   Source File: StartEngineJob.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected IStatus run(IProgressMonitor monitor) {
	try {
		BOSEngineManager.getInstance(monitor).start() ;
	} catch (Exception e) {
		BonitaStudioLog.error(e);
		return Status.CANCEL_STATUS ;
	}
	return Status.OK_STATUS;
}
 
Example 22
@Test
public void testValidate_relativePathNotFile() {
  basePath.append("some.war").toFile().mkdir();
  when(deployArtifactPath.getValue()).thenReturn("some.war");

  IStatus result = pathValidator.validate();
  assertEquals(IStatus.ERROR, result.getSeverity());
  assertEquals("Path is a directory: " + new Path(basePath + "/some.war").toOSString(),
      result.getMessage());
}
 
Example 23
Source Project: google-cloud-eclipse   Source File: CloudSdkManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testRunInstallJob_canceled() {
  CloudSdkModifyJob cancelJob = new FakeModifyJob(Status.CANCEL_STATUS);
  IStatus result = CloudSdkManager.runInstallJob(null, cancelJob, null);
  assertEquals(Job.NONE, cancelJob.getState());
  assertEquals(Status.CANCEL, result.getSeverity());
}
 
Example 24
Source Project: gama   Source File: ThreadedUpdater.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
	if (control.isDisposed()) {
		return Status.CANCEL_STATUS;
	}
	if (control.isBusy() || !control.isVisible()) {
		return Status.OK_STATUS;
	}
	control.updateWith(message);
	return Status.OK_STATUS;
}
 
Example 25
Source Project: Pydev   Source File: ProjectSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void updateStatus(IStatus status) {
    super.updateStatus(status);
    Control area = this.getDialogArea();
    if (area != null) {
        SharedUiPlugin.fixSelectionStatusDialogStatusLineColor(this, area.getBackground());
    }
}
 
Example 26
public IStatus deleteBeforeDeploy(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final DeleteApplicationContainerRunnable deleteApplicationRunnable = new DeleteApplicationContainerRunnable(
            applicationAPI,
            applicationNodeContainer).ignoreErrors();
    deleteApplicationRunnable.run(monitor);
    return deleteApplicationRunnable.getStatus();
}
 
Example 27
Source Project: birt   Source File: ErrorStatusTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void testAddChildren( )
{
	status.addWarning( REASON );
	assertEquals( 1, status.getChildren( ).length );
	assertEquals( IStatus.WARNING, status.getSeverity( ) );
	status.addError( REASON );
	assertEquals( 2, status.getChildren( ).length );
	assertEquals( IStatus.ERROR, status.getSeverity( ) );
	status.addInformation( REASON );
	assertEquals( 3, status.getChildren( ).length );
	assertEquals( IStatus.ERROR, status.getSeverity( ) );
}
 
Example 28
@Test
public void should_return_error_for_unknown_project_path() {
    Resource resource = ConfigurationFactory.eINSTANCE.createResource();
    resource.setProjectPath(UNKNOWN_RESOURCE);
    IStatus status = validator.validate(resource);
    StatusAssert.assertThat(status).isError();
}
 
Example 29
Source Project: tracecompass   Source File: LinuxTestCase.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Initializes the trace for this test case. This method will always create
 * a new trace. The caller must dispose of it the proper way.
 *
 * @return The {@link TmfXmlKernelTraceStub} created for this test case
 */
public TmfXmlKernelTraceStub getKernelTrace() {
    TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
    IPath filePath = Activator.getAbsoluteFilePath(fTraceFile);
    IStatus status = trace.validate(null, filePath.toOSString());
    if (!status.isOK()) {
        fail(status.getException().getMessage());
    }
    try {
        trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
    } catch (TmfTraceException e) {
        fail(e.getMessage());
    }
    return trace;
}
 
Example 30
public void statusChanged(IStatus status)
{
	if (!initialization)
	{
		listener.statusChanged(status);
	}
}