Java Code Examples for org.eclipse.core.runtime.Status#OK_STATUS

The following examples show how to use org.eclipse.core.runtime.Status#OK_STATUS . 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: SaveProjectPreferencesJob.java    From typescript.java with MIT License 6 votes vote down vote up
@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;
}
 
Example 2
Source File: PyGoToDefinition.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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();
}
 
Example 3
Source File: SCTPerspectiveManager.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
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();
}
 
Example 4
Source File: SelectionListenerWithASTManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: NodeJSDebugLauncher.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: WizardNewHybridProjectCreationPage.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@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, "");
	
}
 
Example 7
Source File: FilterFilesTab.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
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;
}
 
Example 8
Source File: RevealOperation.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@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;
}
 
Example 9
Source File: BuildJob.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected final IStatus run(IProgressMonitor monitor) {
	try {
		doBuild(project, monitor);
	} 
	catch (CoreException e) {
		return e.getStatus();
	} 
	finally {
		monitor.done();
	}
	return Status.OK_STATUS;
}
 
Example 10
Source File: DefaultCustomPropertyDefinition.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IStatus setPropertyClass(CustomPropertyClass propertyClass) {
  myPropertyClass = propertyClass;
  myTypeAsString = propertyClass.getID();
  setDefaultValueAsString(getDefaultValueAsString());
  return Status.OK_STATUS;
}
 
Example 11
Source File: NewHostPageWizardPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: LocalAppEngineServerBehaviour.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
public IStatus canStop() {
  int serverState = getServer().getServerState();
  if (serverState == IServer.STATE_STARTED) {
    return Status.OK_STATUS;
  }
  return StatusUtil.error(this, "Not started");
}
 
Example 13
Source File: FixCheckstyleMarkersJob.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@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;
}
 
Example 14
Source File: NeedsReviewOperation.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 15
Source File: ExportEventsImpl.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
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;
}
 
Example 16
Source File: FtpDocument.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IStatus canWrite() {
  return Status.OK_STATUS;
}
 
Example 17
Source File: ScriptConsoleDocumentListener.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 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();
}
 
Example 18
Source File: LockOperation.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	changeTransUnitBeanProperties(this.lock);
	return Status.OK_STATUS;
}
 
Example 19
Source File: AutomaticUpdate.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
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();
}
 
Example 20
Source File: UpdatePoolSizeCommand.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	executeChangingSpanFor(typeChangeSpan,monitor,info);
	return Status.OK_STATUS;
}