下面列出了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();
}
@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;
}
/**
* 验证 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;
}
@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();
}
@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;
}
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;
}
@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();
}
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();
}
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;
}
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);
}
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);
}
}
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$
}
}
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());
}
}
}
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);
}
}
@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));
}
public static CoreException wrap(IStatus status)
{
CoreException e = new CoreException(status);
Throwable t = status.getException();
if (t != null)
e.initCause(t);
return e;
}
@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());
}
@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());
}
@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;
}
@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();
}
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();
}
/**
* 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;
}
public void statusChanged(IStatus status)
{
if (!initialization)
{
listener.statusChanged(status);
}
}