org.eclipse.jface.viewers.ArrayContentProvider#org.eclipse.core.runtime.IStatus源码实例Demo

下面列出了org.eclipse.jface.viewers.ArrayContentProvider#org.eclipse.core.runtime.IStatus 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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();
}
 
源代码2 项目: bonita-studio   文件: ConstraintInputIndexer.java
@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;
}
 
源代码3 项目: tmxeditor8   文件: ConverterViewModel.java
/**
 * 验证 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;
}
 
源代码4 项目: bonita-studio   文件: AssignableConstraint.java
@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();
}
 
源代码5 项目: bonita-studio   文件: DialogSupport.java
@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;
}
 
源代码6 项目: tlaplus   文件: RefreshSpecHandler.java
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;
}
 
源代码7 项目: thym   文件: PluginContentProvider.java
@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();
}
 
源代码8 项目: tracecompass   文件: GdbEventsTable.java
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();
}
 
源代码9 项目: tmxeditor8   文件: KeysPreferencePage.java
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;
}
 
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;
}
 
源代码11 项目: gemfirexd-oss   文件: DerbyClasspathContainer.java
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);
}
 
源代码12 项目: gwt-eclipse-plugin   文件: GwtMavenPlugin.java
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);
  }
}
 
源代码13 项目: APICloud-Studio   文件: ProjectTemplate.java
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$
	}
}
 
源代码14 项目: elexis-3-core   文件: BillingUtil.java
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());
		}
	}
}
 
源代码15 项目: gwt-eclipse-plugin   文件: AddSdkDialog.java
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;
}
 
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);
	}
}
 
源代码17 项目: Pydev   文件: PyCollapse.java
@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);
    }
}
 
/**
 * 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;
}
 
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));
}
 
源代码20 项目: APICloud-Studio   文件: RepositoryStatusHelper.java
public static CoreException wrap(IStatus status)
{
	CoreException e = new CoreException(status);
	Throwable t = status.getException();
	if (t != null)
		e.initCause(t);
	return e;
}
 
源代码21 项目: bonita-studio   文件: StartEngineJob.java
@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;
}
 
@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());
}
 
源代码23 项目: google-cloud-eclipse   文件: CloudSdkManagerTest.java
@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());
}
 
源代码24 项目: gama   文件: ThreadedUpdater.java
@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;
}
 
源代码25 项目: Pydev   文件: ProjectSelectionDialog.java
@Override
protected void updateStatus(IStatus status) {
    super.updateStatus(status);
    Control area = this.getDialogArea();
    if (area != null) {
        SharedUiPlugin.fixSelectionStatusDialogStatusLineColor(this, area.getBackground());
    }
}
 
public IStatus deleteBeforeDeploy(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final DeleteApplicationContainerRunnable deleteApplicationRunnable = new DeleteApplicationContainerRunnable(
            applicationAPI,
            applicationNodeContainer).ignoreErrors();
    deleteApplicationRunnable.run(monitor);
    return deleteApplicationRunnable.getStatus();
}
 
源代码27 项目: birt   文件: ErrorStatusTest.java
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( ) );
}
 
@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();
}
 
源代码29 项目: tracecompass   文件: LinuxTestCase.java
/**
 * 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;
}
 
源代码30 项目: APICloud-Studio   文件: FormatterControlManager.java
public void statusChanged(IStatus status)
{
	if (!initialization)
	{
		listener.statusChanged(status);
	}
}