org.eclipse.core.runtime.IStatus Java Examples

The following examples show how to use org.eclipse.core.runtime.IStatus. 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: LocalAppEngineConsole.java    From google-cloud-eclipse with Apache License 2.0 8 votes vote down vote up
/**
 * 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
Source File: DerbyClasspathContainer.java    From gemfirexd-oss with 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 #3
Source File: AddSdkDialog.java    From gwt-eclipse-plugin with 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 #4
Source File: ConstraintInputIndexer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 #5
Source File: ConverterViewModel.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 验证 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 #6
Source File: GwtMavenPlugin.java    From gwt-eclipse-plugin with 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 #7
Source File: AssignableConstraint.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 #8
Source File: DialogSupport.java    From bonita-studio with 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 #9
Source File: RefreshSpecHandler.java    From tlaplus with 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 #10
Source File: PluginContentProvider.java    From thym with 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 #11
Source File: BillingUtil.java    From elexis-3-core with 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 #12
Source File: ProjectTemplate.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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 #13
Source File: GdbEventsTable.java    From tracecompass with 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 #14
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
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 #15
Source File: AbstractLiveValidationMarkerConstraint.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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 #16
Source File: NameUnicityInProcessScopeValidatorTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testPerformBatchValidationOnPool_Failure_withSeveralSameNameForProcessContractInputAndProcessData() throws Exception {
    final Pool pool = PoolBuilder.aPool()
            .havingContract(ContractBuilder.aContract().havingInput(ContractInputBuilder.aContractInput().withName("test").build(),
                    ContractInputBuilder.aContractInput().withName("test1").build()))
            .havingData(DataBuilder.aData().withName("test"), DataBuilder.aData().withName("test")).build();
    doReturn(pool).when(ctx).getTarget();

    final NameUnicityInProcessScopeValidator nameUnicityInProcessScopeValidator = spy(new NameUnicityInProcessScopeValidator());
    doReturn(failureSTatus).when(nameUnicityInProcessScopeValidator).createMultiStatusConstraint(any(IValidationContext.class), anyListOf(IStatus.class));
    final IStatus res = nameUnicityInProcessScopeValidator.performBatchValidation(ctx);
    assertThat(res.isOK()).isFalse();
}
 
Example #17
Source File: AbstractFSSynchronizationTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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 #18
Source File: NewSpecHandlerTest.java    From tlaplus with MIT License 5 votes vote down vote up
private IStatus runJob(String specName) throws IOException, InterruptedException {
	final NewSpecHandlerJob job = new NewSpecHandlerJob(specName,
			Files.createTempFile(specName, TLAConstants.Files.TLA_EXTENSION).toFile().getAbsolutePath(), false);
	MyJobChangeAdapter listener = new MyJobChangeAdapter();
	job.addJobChangeListener(listener);
	job.schedule();

	listener.await();

	assertNotNull(listener.getOuterEvent());
	return listener.getOuterEvent();
}
 
Example #19
Source File: FormatterControlManager.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void statusChanged(IStatus status)
{
	if (!initialization)
	{
		listener.statusChanged(status);
	}
}
 
Example #20
Source File: LengthValidatorTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_fails_with_given_error_message_input_is_too_long() throws Exception {
    final LengthValidator validator = new LengthValidator.Builder()
            .withMessage("'%v' is too long (max = %max)")
            .maxLength(10)
            .create();

    final IStatus status = validator.validate("I'm too long man");

    StatusAssert.assertThat(status).isNotOK().hasMessage("'I'm too long man' is too long (max = 10)");
}
 
Example #21
Source File: LinuxTestCase.java    From tracecompass with 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 #22
Source File: OperationReturnTypesValidatorTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_fail_when_assigning_a_business_object_in_a_process_data() throws Exception {
    final Expression leftOperand = ExpressionHelper
            .createVariableExpression(aJavaObjectData().withName("employee").withClassname("org.test.Employee")
                    .build());
    final Expression rightOperand = anExpression().withExpressionType(ExpressionConstants.QUERY_TYPE)
            .withName("Employee.findById")
            .withContent("SELECT AN EMPLOYEE").withReturnType("org.test.Employee").build();
    final Operation operation = createOperation(leftOperand, rightOperand, ExpressionConstants.ASSIGNMENT_OPERATOR);

    final OperationReturnTypesValidator validator = new OperationReturnTypesValidator();
    final IStatus status = validator.validate(operation.getRightOperand());

    StatusAssert.assertThat(status).isNotOK().hasMessage(Messages.cannotStoreBusinessObjectInProcessVariable);
}
 
Example #23
Source File: NewSarlEventWizardPage.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
protected void doStatusUpdate() {
	final IStatus[] status = new IStatus[] {
		this.fContainerStatus,
		this.fPackageStatus,
		this.fTypeNameStatus,
		this.fSuperClassStatus,
	};
	updateStatus(status);
}
 
Example #24
Source File: AdditionalResourceProjectPathValidatorTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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 #25
Source File: ErrorStatusTest.java    From birt with 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 #26
Source File: AndroidEmulatorLaunchShortcut.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected boolean validateBuildToolsReady() throws CoreException {
	
	AndroidSDKManager sdkManager = AndroidSDKManager.getManager();
	List<AndroidSDK> targets = sdkManager.listTargets();
	if(targets == null || targets.isEmpty() ){
		throw new CoreException(new Status(IStatus.ERROR, AndroidUI.PLUGIN_ID, "No targets to build against"));
	}
	return true;
}
 
Example #27
Source File: DeployApplicationDescriptorOperation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public IStatus deleteBeforeDeploy(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final DeleteApplicationContainerRunnable deleteApplicationRunnable = new DeleteApplicationContainerRunnable(
            applicationAPI,
            applicationNodeContainer).ignoreErrors();
    deleteApplicationRunnable.run(monitor);
    return deleteApplicationRunnable.getStatus();
}
 
Example #28
Source File: OptInDialogTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void scheduleClosingDialogAfterOpen(final CloseAction closeAction) {
  dialogCloser = new UIJob("dialog closer") {
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      if (dialog.getShell() != null && dialog.getShell().isVisible()) {
        closeDialog(closeAction);
      } else {
        schedule(100);
      }
      return Status.OK_STATUS;
    }
  };
  dialogCloser.schedule();
}
 
Example #29
Source File: FilterFilesTab.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected IStatus validate() {
    SelectionValidator validator = new SelectionValidator(kind, propertyPage);
    IStatus bad = null;
    IProject project = propertyPage.getProject();
    for (IPathElement path : paths) {
        String filterPath = FindBugsWorker.toFilterPath(path.getPath(), project).toOSString();
        IStatus status = validator.validate(filterPath);
        path.setStatus(status);
        if (!status.isOK()) {
            bad = status;
        }
    }
    return bad;
}
 
Example #30
Source File: ProjectSelectionDialog.java    From Pydev with 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());
    }
}