org.eclipse.core.runtime.Status#OK_STATUS源码实例Demo

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

源代码1 项目: thym   文件: WizardNewHybridProjectCreationPage.java
@Override
protected IStatus run(IProgressMonitor monitor) {
	try {
		ErrorDetectingCLIResult result = new CordovaCLI().version(monitor).convertTo(ErrorDetectingCLIResult.class);
		if(result.asStatus().getCode() == CordovaCLIErrors.ERROR_COMMAND_MISSING){
			return Status.OK_STATUS;
		}
		if(result.asStatus().isOK()){
			cordovaVersion = Version.parseVersion(result.getMessage()).toString();
			return Status.OK_STATUS;
		}
	} catch (Exception e) {
		HybridUI.log(WARNING, "Unable to determine if cordova is available", e);
	}
	return new Status(Status.WARNING, HybridUI.PLUGIN_ID, "");
	
}
 
源代码2 项目: codewind-eclipse   文件: NodeJSDebugLauncher.java
private IStatus openBrowserDialog(final String chromeDevToolsUrl, final String browserName ) {
	final AtomicInteger returnCode =new AtomicInteger(0);
	Display.getDefault().syncExec(new Runnable() {
		@Override
		public void run() {
			NodeJsBrowserDialog nodeDialog = new NodeJsBrowserDialog(Display.getDefault().getActiveShell(), 
					Messages.NodeJSOpenBrowserTitle, 
					null, 
					Messages.NodeJSOpenBrowserDesc, 
					MessageDialog.CONFIRM, 
					new String[] { IDialogConstants.OK_LABEL}, 
					0, chromeDevToolsUrl, browserName);
			nodeDialog.open();
			returnCode.set(nodeDialog.getReturnCode());
		}
	});
	
	if (returnCode.get() != Window.OK){
		// Cancelled
		return Status.CANCEL_STATUS;
	}		

	return Status.OK_STATUS;
}
 
protected final IStatus calculateASTandInform(ITypeRoot input, ITextSelection selection, IProgressMonitor monitor) {
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	// create AST
	try {
		CompilationUnit astRoot= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_ACTIVE_ONLY, monitor);

		if (astRoot != null && !monitor.isCanceled()) {
			Object[] listeners;
			synchronized (PartListenerGroup.this) {
				listeners= fAstListeners.getListeners();
			}
			for (int i= 0; i < listeners.length; i++) {
				((ISelectionListenerWithAST) listeners[i]).selectionChanged(fPart, selection, astRoot);
				if (monitor.isCanceled()) {
					return Status.CANCEL_STATUS;
				}
			}
			return Status.OK_STATUS;
		}
	} catch (OperationCanceledException e) {
		// thrown when canceling the AST creation
	}
	return Status.CANCEL_STATUS;
}
 
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	monitor.beginTask(NLS.bind(TypeScriptCoreMessages.SaveProjectPreferencesJob_taskName, project.getName()), 1);

	try {
		preferences.flush();
	} catch (BackingStoreException e) {
		IStatus status = new Status(Status.ERROR, TypeScriptCorePlugin.PLUGIN_ID,
				"Error while saving  project preferences", e);
		throw new CoreException(status);
	}

	monitor.worked(1);
	monitor.done();

	return Status.OK_STATUS;
}
 
源代码5 项目: statecharts   文件: SCTPerspectiveManager.java
protected void schedulePerspectiveSwitchJob(final String perspectiveID) {
	Job switchJob = new UIJob(DebugUIPlugin.getStandardDisplay(), "Perspective Switch Job") { //$NON-NLS-1$
		public IStatus runInUIThread(IProgressMonitor monitor) {
			IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
			if (window != null && !(isCurrentPerspective(window, perspectiveID))) {
				switchToPerspective(window, perspectiveID);
			}
			// Force the debug view to open
			if (window != null) {
				try {
					window.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(SIMULATION_VIEW_ID);
				} catch (PartInitException e) {
					e.printStackTrace();
				}
			}
			return Status.OK_STATUS;
		}
	};
	switchJob.setSystem(true);
	switchJob.setPriority(Job.INTERACTIVE);
	switchJob.setRule(AsynchronousSchedulingRuleFactory.getDefault().newSerialPerObjectRule(this));
	switchJob.schedule();
}
 
源代码6 项目: Pydev   文件: PyGoToDefinition.java
/**
 * Remove the editor from askReparse and if it's the last one, do the find.
 */
private void doFindIfLast() {
    synchronized (lock) {
        askReparse.remove(editToReparse);
        if (askReparse.size() > 0) {
            return; //not the last one (we'll only do the find when all are reparsed.
        }
    }
    /**
     * Create an ui job to actually make the find.
     */
    UIJob job = new UIJob("Find") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            try {
                findDefinitionsAndOpen(true);
            } catch (Throwable e) {
                Log.log(e);
            }
            return Status.OK_STATUS;
        }
    };
    job.setPriority(Job.INTERACTIVE);
    job.schedule();
}
 
@Override
public IStatus setPropertyClass(CustomPropertyClass propertyClass) {
  myPropertyClass = propertyClass;
  myTypeAsString = propertyClass.getID();
  setDefaultValueAsString(getDefaultValueAsString());
  return Status.OK_STATUS;
}
 
源代码8 项目: tmxeditor8   文件: NeedsReviewOperation.java
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	if (rowIdList != null && rowIdList.size() > 0) {
		if("yes".equals(state)){
			handler.changeTuPropValue(rowIdList, "hs:needs-review", state);				
		}else{
			handler.deleteTuProp(rowIdList, "hs:needs-review");
		}
		table.redraw();
	}
	return Status.OK_STATUS;
}
 
源代码9 项目: spotbugs   文件: FilterFilesTab.java
List<IPathElement> getFilterFiles(UserPreferences prefs) {
    IProject project = propertyPage.getProject();
    final List<IPathElement> newPaths = new ArrayList<>();
    Map<String, Boolean> filterPaths = kind.selectedPaths(prefs);
    if (filterPaths != null) {
        for (Entry<String, Boolean> entry : filterPaths.entrySet()) {
            IPath filterPath = FindBugsWorker.getFilterPath(entry.getKey(), project);
            PathElement element = new PathElement(filterPath, Status.OK_STATUS);
            element.setEnabled(entry.getValue().booleanValue());
            newPaths.add(element);
        }
    }
    return newPaths;
}
 
源代码10 项目: gef   文件: RevealOperation.java
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
		throws ExecutionException {
	// restore the viewport translation
	viewer.getCanvas().setHorizontalScrollOffset(tx);
	viewer.getCanvas().setVerticalScrollOffset(ty);
	return Status.OK_STATUS;
}
 
源代码11 项目: xds-ide   文件: BuildJob.java
@Override
protected final IStatus run(IProgressMonitor monitor) {
	try {
		doBuild(project, monitor);
	} 
	catch (CoreException e) {
		return e.getStatus();
	} 
	finally {
		monitor.done();
	}
	return Status.OK_STATUS;
}
 
源代码12 项目: gwt-eclipse-plugin   文件: NewHostPageWizardPage.java
private IStatus validateFileName() {
  fileName = null;

  String str = fileNameField.getText().trim();
  if (str.length() == 0) {
    return Util.newErrorStatus("Enter a file name");
  }

  // Validate the file name
  IStatus nameStatus = ResourcesPlugin.getWorkspace().validateName(str,
      IResource.FILE);
  if (nameStatus.matches(IStatus.ERROR)) {
    return Util.newErrorStatus("Invalid file name. {0}",
        nameStatus.getMessage());
  }

  // Make sure the host page doesn't already exist in the public path
  if (hostPagePath != null) {
    IPath htmlFilePath = hostPagePath.append(str).removeFileExtension().addFileExtension(
        ((AbstractNewFileWizard) getWizard()).getFileExtension());
    IFile htmlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(
        htmlFilePath);
    if (htmlFile.exists()) {
      return Util.newErrorStatus("''{0}'' already exists",
          htmlFilePath.toString());
    }
  }

  fileName = str;
  return Status.OK_STATUS;
}
 
@Override
public IStatus canStop() {
  int serverState = getServer().getServerState();
  if (serverState == IServer.STATE_STARTED) {
    return Status.OK_STATUS;
  }
  return StatusUtil.error(this, "Not started");
}
 
源代码14 项目: eclipse-cs   文件: FixCheckstyleMarkersJob.java
/**
 * {@inheritDoc}
 */
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {

  try {

    CheckstyleMarkerResolutionGenerator generator = new CheckstyleMarkerResolutionGenerator();

    IMarker[] markers = mFile.findMarkers(CheckstyleMarker.MARKER_ID, true,
            IResource.DEPTH_INFINITE);

    for (int i = 0; i < markers.length; i++) {

      ICheckstyleMarkerResolution[] resolutions = (ICheckstyleMarkerResolution[]) generator
              .getResolutions(markers[i]);

      if (resolutions.length > 0) {
        // only run the first fix for this marker
        resolutions[0].run(markers[i]);
      }

    }
  } catch (CoreException e) {
    return new Status(IStatus.ERROR, CheckstyleUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
  }

  return Status.OK_STATUS;
}
 
源代码15 项目: neoscada   文件: ExportEventsImpl.java
private IStatus storeExcel ( final File file, final List<Event> events, final List<Field> columns, final IProgressMonitor monitor ) throws IOException
{
    final HSSFWorkbook workbook = new HSSFWorkbook ();

    final HSSFDataFormat dateFormat = workbook.createDataFormat ();
    final HSSFCellStyle dateCellStyle = workbook.createCellStyle ();
    dateCellStyle.setDataFormat ( dateFormat.getFormat ( "YYYY-MM-DD hh:mm:ss.000" ) );

    try
    {
        monitor.beginTask ( Messages.ExportImpl_Progress_ExportingEvents, events.size () + 3 + columns.size () );

        try
        {
            monitor.subTask ( Messages.ExportImpl_Progress_CreateWorkbook );
            monitor.worked ( 1 );

            final HSSFSheet sheet = createSheet ( events, workbook, columns );
            monitor.worked ( 1 );

            monitor.setTaskName ( Messages.ExportImpl_Progress_ExportEvents );

            for ( int i = 0; i < events.size (); i++ )
            {
                final HSSFRow row = sheet.createRow ( i + 1 );

                final Event e = events.get ( i );
                for ( int j = 0; j < columns.size (); j++ )
                {
                    final Field field = columns.get ( j );
                    final ExcelCell cell = new ExcelCell ( row, j, dateCellStyle );
                    field.render ( e, cell );
                }
                monitor.worked ( 1 );
                if ( monitor.isCanceled () )
                {
                    return Status.CANCEL_STATUS;
                }
            }

            sheet.setRepeatingRows ( new CellRangeAddress ( 0, 1, -1, -1 ) );

            monitor.setTaskName ( "Auto sizing" );
            for ( int i = 0; i < columns.size (); i++ )
            {
                monitor.subTask ( String.format ( "Auto sizing column: %s", columns.get ( i ).getHeader () ) );
                sheet.autoSizeColumn ( i );
                monitor.worked ( 1 );

                if ( monitor.isCanceled () )
                {
                    return Status.CANCEL_STATUS;
                }
            }

        }
        finally
        {
            monitor.subTask ( Messages.ExportImpl_Progress_CloseFile );
            if ( workbook != null )
            {
                makeDocInfo ( workbook );

                final FileOutputStream stream = new FileOutputStream ( file );
                workbook.write ( stream );
                stream.close ();
            }
            monitor.worked ( 1 );
        }
    }
    finally
    {
        monitor.done ();
    }

    return Status.OK_STATUS;
}
 
源代码16 项目: ganttproject   文件: FtpDocument.java
@Override
public IStatus canWrite() {
  return Status.OK_STATUS;
}
 
源代码17 项目: Pydev   文件: ScriptConsoleDocumentListener.java
/**
 * Here is where we run things not using the UI thread. It's a recursive function. In summary, it'll
 * run each line in the commands received in a new thread, and as each finishes, it calls itself again
 * for the next command. The last command will reconnect to the document.
 *
 * Exceptions had to be locally handled, because they're not well tolerated under this scenario
 * (if on of the callbacks fail, the others won't be executed and we'd get into a situation
 * where the shell becomes unusable).
 */
private void execCommand(final boolean addedNewLine, final String delim, final String[] finalIndentString,
        final String cmd, final List<String> commands, final int currentCommand, final String text,
        final char addedParen, final int start, final char addedCloseParen, final int newDeltaCaretPosition) {
    applyStyleToUserAddedText(cmd, doc.getLength());

    //the cmd could be something as '\n'
    appendText(cmd);

    //and the command line the actual contents to be executed at this time
    final String commandLine = getCommandLine();

    if (handler.isOnStateWhereCommandHandlingShouldStop(commandLine)) {
        return;
    }

    history.update(commandLine);

    // handle the command line:
    // When the user presses a return and goes to a new line,  the contents of the current line are sent to
    // the interpreter (and its results properly handled).

    appendText(getDelimeter());
    final boolean finalAddedNewLine = addedNewLine;
    final String finalDelim = delim;

    final ICallback<Object, InterpreterResponse> onResponseReceived = new ICallback<Object, InterpreterResponse>() {

        @Override
        public Object call(final InterpreterResponse arg) {
            //When we receive the response, we must handle it in the UI thread.
            Runnable runnable = new Runnable() {

                @Override
                public void run() {
                    try {
                        processResult(arg);
                        if (finalAddedNewLine) {
                            List<String> historyList = history.getAsList();
                            IDocument historyDoc = new Document(StringUtils.join("\n",
                                    historyList.subList(historyFullLine, historyList.size())) + "\n");
                            int currHistoryLen = historyDoc.getLength();
                            if (currHistoryLen > 0) {
                                DocCmd docCmd = new DocCmd(currHistoryLen - 1, 0, finalDelim);
                                strategy.customizeNewLine(historyDoc, docCmd);
                                finalIndentString[0] = docCmd.text.replaceAll("\\r\\n|\\n|\\r", ""); //remove any new line added!
                                if (currHistoryLen != historyDoc.getLength()) {
                                    Log.log("Error: the document passed to the customizeNewLine should not be changed!");
                                }
                            }
                        }
                    } catch (Throwable e) {
                        //Yeap, it can never fail!
                        Log.log(e);
                    }
                    if (currentCommand + 1 < commands.size()) {
                        execCommand(finalAddedNewLine, finalDelim, finalIndentString,
                                commands.get(currentCommand + 1), commands, currentCommand + 1, text, addedParen,
                                start, addedCloseParen, newDeltaCaretPosition);
                    } else {
                        //last one
                        try {
                            onAfterAllLinesHandled(text, addedParen, start, readOnlyColumnsInCurrentBeforePrompt,
                                    addedCloseParen,
                                    finalIndentString[0], newDeltaCaretPosition);
                        } finally {
                            //We must disconnect
                            stopDisconnected(); //reconnect with the document
                        }
                    }
                }
            };
            RunInUiThread.async(runnable);
            return null;
        }
    };

    handler.beforeHandleCommand(commandLine, onResponseReceived);

    //Handle the command in a thread that doesn't block the U/I.
    Job j = new Job("PyDev Console Hander") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            promptReady = false;
            handler.handleCommand(commandLine, onResponseReceived);
            return Status.OK_STATUS;
        };
    };
    j.setSystem(true);
    j.schedule();
}
 
源代码18 项目: translationstudio8   文件: LockOperation.java
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	changeTransUnitBeanProperties(this.lock);
	return Status.OK_STATUS;
}
 
源代码19 项目: translationstudio8   文件: AutomaticUpdate.java
public void checkForUpdates() throws OperationCanceledException {
	// 检查 propfile
	String profileId = getProvisioningUI().getProfileId();
	IProvisioningAgent agent = getProvisioningUI().getSession().getProvisioningAgent();
	IProfile profile = null;
	if (agent != null) {
		IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
		if (registry != null) {
			profile = registry.getProfile(profileId);
		}
	}
	if (profile == null) {
		// Inform the user nicely
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_AUTO_CHECK);
		return;
	}

	// 开始检查前先确定是否有repository
	RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
	if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) {
		P2UpdateUtil.openConnectErrorInfoDialog(getShell(), P2UpdateUtil.INFO_TYPE_AUTO_CHECK);
		return;
	}

	final IStatus[] checkStatus = new IStatus[1];
	Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
	final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()) {
		public IStatus runModal(IProgressMonitor monitor) {
			SubMonitor sub = SubMonitor.convert(monitor, P2UpdateUtil.CHECK_UPDATE_TASK_NAME, 1000);
			// load repository
			IStatus status = super.runModal(sub.newChild(500));
			if (status.getSeverity() == IStatus.CANCEL) {
				return status;
			}
			if (status.getSeverity() != Status.OK) {
				// load repository error
				checkStatus[0] = status;
			}
			operation = getProvisioningUI().getUpdateOperation(null, null);
			// check for updates
			IStatus resolveStatus = operation.resolveModal(sub.newChild(500));
			if (resolveStatus.getSeverity() == IStatus.CANCEL) {
				return Status.CANCEL_STATUS;
			}
			return Status.OK_STATUS;
		}
	};
	loadJob.setName(P2UpdateUtil.ATUO_CHECK_UPDATE_JOB_NAME);
	loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
	loadJob.addJobChangeListener(new JobChangeAdapter() {
		public void done(IJobChangeEvent event) {
			if (PlatformUI.isWorkbenchRunning())
				if (event.getResult().isOK()) {
					PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
						public void run() {
							if (checkStatus[0] != null) {
								// 提示连接异常
								P2UpdateUtil.openConnectErrorInfoDialog(getShell(),
										P2UpdateUtil.INFO_TYPE_AUTO_CHECK);
								return;
							}
							doUpdate();
						}
					});
				}
		}
	});
	loadJob.setUser(true);
	loadJob.schedule();
}
 
源代码20 项目: bonita-studio   文件: UpdatePoolSizeCommand.java
@Override
protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	executeChangingSpanFor(typeChangeSpan,monitor,info);
	return Status.OK_STATUS;
}