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

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

源代码1 项目: ganttproject   文件: WebPublisher.java
private Job createTransferJob(final Ftp ftp, final File file) {
  Job result = new Job("transfer file " + file.getName()) {
    @Override
    protected IStatus run(IProgressMonitor monitor) {
      try {
        IStatus ftpStatus = ftp.put(file);
        if (!ftpStatus.isOK()) {
          GPLogger.getLogger(WebPublisher.class).warning(ftpStatus.getMessage());
          return ftpStatus;
        }
        monitor.worked(1);
        return Status.OK_STATUS;
      } catch (IOException e) {
        if (!GPLogger.log(e)) {
          e.printStackTrace(System.err);
        }
        return Status.CANCEL_STATUS;
      } finally {
      }
    }
  };
  return result;
}
 
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;
}
 
源代码3 项目: xtext-eclipse   文件: XtextReconciler.java
@Override
protected IStatus run(final IProgressMonitor monitor) {
	if (monitor.isCanceled() || paused)
		return Status.CANCEL_STATUS;

	if (pendingChanges.isEmpty()) {
		return Status.OK_STATUS;
	}
	long start = System.currentTimeMillis();
	final IXtextDocument document = xtextDocumentUtil.getXtextDocument(textViewer);
	if (document instanceof XtextDocument) {
		((XtextDocument) document).internalModify(new IUnitOfWork.Void<XtextResource>() {
			@Override
			public void process(XtextResource state) throws Exception {
				doRun(state, monitor);
			}
		});
	}
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	if (log.isDebugEnabled())
		log.debug("Reconciliation finished. Time required: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
	return Status.OK_STATUS;
}
 
源代码4 项目: Flashtool   文件: APKInstallJob.java
protected IStatus run(IProgressMonitor monitor) {
 	try {
File files = new File(instpath);
File[] chld = files.listFiles(new APKFilter());
LogProgress.initProgress(chld.length);
for(int i = 0; i < chld.length; i++){
	if (chld[i].getName().toUpperCase().endsWith(".APK"))
		AdbUtility.install(chld[i].getPath());
	LogProgress.updateProgress();
}
LogProgress.initProgress(0);
logger.info("APK Installation finished");
return Status.OK_STATUS;
 	}
 	catch (Exception e) {
 		e.printStackTrace();
 		logger.error(e.getMessage());
 		LogProgress.initProgress(0);
 		return Status.CANCEL_STATUS;
 	}
 }
 
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
	IEditorSite site = null != editor ? editor.getEditorSite() : null;
	if (site != null) {
		if (!monitor.isCanceled() && editor != null) {
			if (titleImage != null && !titleImage.isDisposed()) {
				editor.updatedTitleImage(titleImage);
				titleImage = null;
			} else if (titleImageDescription != null) {
				Image image = imageHelper.getImage(titleImageDescription);
				if (editor.getTitleImage() != image) {
					editor.updatedTitleImage(image);
				}
				titleImageDescription = null;
			}
		}
	}
	if (monitor.isCanceled()) {
		return Status.CANCEL_STATUS;
	}
	return Status.OK_STATUS;
}
 
源代码6 项目: gama   文件: LayeredDisplayView.java
@Override
protected GamaUIJob createUpdateJob() {
	return new GamaUIJob() {

		@Override
		protected UpdatePriority jobPriority() {
			return UpdatePriority.HIGHEST;
		}

		@Override
		public IStatus runInUIThread(final IProgressMonitor monitor) {
			if (getDisplaySurface() == null) { return Status.CANCEL_STATUS; }
			getDisplaySurface().updateDisplay(false);
			return Status.OK_STATUS;
		}
	};
}
 
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	project = getSelectedExtension(HandlerUtil.getCurrentSelection(event));
	Job job = new Job("[y] Build") {
		@Override
		protected IStatus run(IProgressMonitor monitor) {
			try {
				if (FixProjectsUtils.isAHybrisExtension(project)) {
					BuildUtils.refreshAndBuild(monitor, CFG_NAME, project);
					monitor.done();
					return Status.OK_STATUS;
				} else {
					return Status.CANCEL_STATUS;
				}
			} catch (Exception e) {
				Activator.logError("Failed to build project", e);
				throw new IllegalStateException("Failed to build project, see workspace logs for details", e);
			}

		}
	};
	job.setUser(true);
	job.schedule();
	return null;
}
 
源代码8 项目: Flashtool   文件: DevicesSyncJob.java
protected IStatus run(IProgressMonitor monitor) {
try {
	logger.info("Syncing devices from github");
	DevicesGit.gitSync();
   	logger.info("Devices sync finished.");
	return Status.OK_STATUS;
}
catch (Exception e) {
	e.printStackTrace();
	logger.error("Cannot sync devices : "+e.getMessage());
	return Status.CANCEL_STATUS;
}
  }
 
源代码9 项目: saros   文件: UndoManager.java
@Override
public IStatus proceedRedoing(
    final IUndoableOperation operation, IOperationHistory history, IAdaptable info) {

  if (!enabled) return Status.OK_STATUS;

  if (currentActiveEditor == null) {
    log.info("Redo called on an unknown editor");
    return Status.OK_STATUS;
  }

  if (log.isDebugEnabled()) log.debug(opInfo(operation));

  if (operation.getLabel().equals(TYPING_LABEL)
      || operation.getLabel().equals(NullOperation.LABEL)) {

    updateCurrentLocalAtomicOperation(null);
    storeCurrentLocalOperation();

    SWTUtils.runSafeSWTSync(
        log,
        new Runnable() {
          @Override
          public void run() {
            log.debug("redoing operation " + operation);
            redo(currentActiveEditor);

            /*
             * For reactivating redo an undo has to be simulated, so
             * the Eclipse history knows, there is something to
             * redo.
             */
            if (undoHistory.canRedo(currentActiveEditor)) simulateUndo();
          }
        });
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}
 
源代码10 项目: tracecompass   文件: DropAdapterAssistant.java
@Override
public IStatus validateDrop(Object target, int operation, TransferData transferType) {
    if (target instanceof TmfTraceFolder) {
        return Status.OK_STATUS;
    }
    if (target instanceof TmfExperimentElement) {
        return Status.OK_STATUS;
    }
    if (target instanceof TmfTraceElement) {
        ITmfProjectModelElement parent = ((TmfTraceElement) target).getParent();
        if (parent instanceof TmfTraceFolder) {
            return Status.OK_STATUS;
        }
        if (parent instanceof TmfExperimentElement) {
            return Status.OK_STATUS;
        }
    }

    if (target instanceof TmfProjectElement) {
        return Status.OK_STATUS;
    }

    if (target instanceof IProject) {
        return Status.CANCEL_STATUS;
    }

    return Status.CANCEL_STATUS;
}
 
源代码11 项目: texlipse   文件: TexDocumentModel.java
/**
 * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
 */
public IStatus runInUIThread(IProgressMonitor monitor) {
    try {
    	//long time = System.currentTimeMillis();
        updateDocumentPositions(rootNodes, monitor);
        //System.out.println("updateDocPos: " + (System.currentTimeMillis() - time));
        
        pollCancel(monitor);
        
        //time = System.currentTimeMillis();
        editor.updateCodeFolder(rootNodes, monitor);
        //System.out.println("updateCodeFolder: " + (System.currentTimeMillis() - time));
        pollCancel(monitor);
        
        if (editor.getOutlinePage() != null) {
        	//time = System.currentTimeMillis();
        	editor.getOutlinePage().update(outlineInput);
        	//System.out.println("updateOutline: " + (System.currentTimeMillis() - time));
        }
        
        //Update FullOutline
        if (fullOutlineNodes != null) {

            pollCancel(monitor);
            if (editor.getFullOutline() != null) {
            	//time = System.currentTimeMillis();
            	//createOutlineInput(fullOutlineNodes, monitor);
            	editor.getFullOutline().update(new TexOutlineInput(new ArrayList<OutlineNode>(fullOutlineNodes)));
            	//System.out.println("updateFullOutline: " + (System.currentTimeMillis() - time));
            }
        }

        return Status.OK_STATUS;
    } catch (Exception e) {
        // npe when exiting eclipse and saving
        return Status.CANCEL_STATUS;
    }
}
 
源代码12 项目: tmxeditor8   文件: UpdateDataOperation.java
@Override
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
	CellEditorCanonicalValue newValue = null;
	Object obj = command.getNewValue();
	if (obj instanceof CellEditorCanonicalValue) {
		newValue = (CellEditorCanonicalValue) obj;
	}
	if (newValue == null) {
		return Status.CANCEL_STATUS;
	}
	TeActiveCellEditor.commit();
	return updateData(newValue.getNewFullValue(), true);
}
 
public IStatus updateConnection(IProgressMonitor monitor) {
	SubMonitor mon = SubMonitor.convert(monitor, 100);
	
	if (connection.isConnected()) {
		connection.disconnect();
	}
	try {
		ConnectionUtil.updateConnection(connection.getConid(), name, url, user, mon.split(20));
		if (mon.isCanceled()) {
			return Status.CANCEL_STATUS;
		}
		connection.setName(name);
		connection.setBaseURI(new URI(url));
		connection.setUsername(user);
		
		AuthToken token = AuthUtil.genAuthToken(user, pass, connection.getConid(), mon.split(30));
		if (mon.isCanceled()) {
			return Status.CANCEL_STATUS;
		}
		connection.setAuthToken(token);
		
		connection.connect(mon.split(50));
		if (mon.isCanceled()) {
			return Status.CANCEL_STATUS;
		}
	} catch (Exception e) {
		return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.CodewindConnectionUpdateError, name), e);
	} finally {
		ViewHelper.openCodewindExplorerView();
		CodewindUIPlugin.getUpdateHandler().updateConnection(connection);
	}
	
	return Status.OK_STATUS;
}
 
源代码14 项目: ADT_Frontend   文件: AbapGitStagingView.java
private IStatus getGitCredentials(String previousErrorMessage) {
	//get credentials
	if (this.repositoryCredentials == null) {
		this.repositoryCredentials = GitCredentialsService.getCredentialsFromUser(getSite().getShell(), this.repository.getUrl(), previousErrorMessage);
		if (this.repositoryCredentials == null) {
			return Status.CANCEL_STATUS;
		}
	}
	return Status.OK_STATUS;
}
 
源代码15 项目: APICloud-Studio   文件: FileUtil.java
/**
 * Creates a symlink or shortcut folder.
 * 
 * @param symLinkName
 * @param sourcePath
 * @param targetPath
 * @return
 */
public static IStatus createSymlink(String symLinkName, IPath sourcePath, IPath targetPath)
{
	if (PlatformUtil.isMac() || PlatformUtil.isLinux())
	{
		return new ProcessRunner().runInBackground(sourcePath, "ln", "-s", targetPath.toOSString(), symLinkName); //$NON-NLS-1$ //$NON-NLS-2$
	}
	else if (PlatformUtil.isWindows())
	{
		return new ProcessRunner()
				.runInBackground(sourcePath, "mklink", "/D", symLinkName, targetPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$
	}
	return Status.CANCEL_STATUS;
}
 
源代码16 项目: gama   文件: NavigatorDropAssistant.java
@Override
public IStatus handleDrop(final CommonDropAdapter adapter, final DropTargetEvent event, final Object target) {
	if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
		final String[] files = (String[]) event.data;
		if (files != null && files.length > 0) {
			PasteAction.handlePaste(files);
			return Status.OK_STATUS;
		}
	} else if (ResourceTransfer.getInstance().isSupportedType(event.currentDataType)) {

	}
	return Status.CANCEL_STATUS;
}
 
源代码17 项目: gama   文件: NavigatorDropAssistant.java
@Override
public IStatus validateDrop(final Object target, final int operation, final TransferData transferType) {
	return target instanceof NavigatorRoot ? Status.OK_STATUS : Status.CANCEL_STATUS;
}
 
源代码18 项目: Pydev   文件: HistoryFilteredList.java
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
    if (fTable.isDisposed()) {
        return Status.CANCEL_STATUS;
    }
    int itemCount = fTable.getItemCount();

    // Remove excess items
    if (fCount < itemCount) {
        fTable.setRedraw(false);
        fTable.remove(fCount, itemCount - 1);
        fTable.setRedraw(true);
        itemCount = fTable.getItemCount();
    }
    // table empty -> no selection
    if (fCount == 0) {
        fTable.notifyListeners(SWT.Selection, new Event());
        return Status.OK_STATUS;
    }
    // How many we are going to do this time.
    int iterations = Math.min(250, fCount - currentIndex);
    for (int i = 0; i < iterations; i++) {
        if (monitor.isCanceled()) {
            return Status.CANCEL_STATUS;
        }
        final TableItem item = (currentIndex < itemCount) ? fTable.getItem(currentIndex) : new TableItem(
                fTable, SWT.NONE);
        final Label label = fLabels[fFilteredIndices[fFoldedIndices[currentIndex]]];
        item.setText(label.string);
        item.setImage(label.image);
        currentIndex++;
    }
    if (monitor.isCanceled()) {
        return Status.CANCEL_STATUS;
    }
    if (currentIndex < fCount) {
        schedule(0);
    } else {
        if (indicesToSelect == null) {
            // Make a default selection in the table if there is none.
            // If a selection has already been made, honor it.
            // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=112146
            if (fCount > 0) {
                if (fTable.getSelectionIndices().length == 0) {
                    defaultSelect();
                } else {
                    // There is a selection, but it likely hasn't changed since the
                    // job started.  Force a selection notification, since the
                    // items represented by the selection have changed.
                    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=119456
                    fTable.notifyListeners(SWT.Selection, new Event());
                }
            }
        } else {
            // Set the selection as indicated.
            selectAndNotify(indicesToSelect);
        }
        // This flag signifies that the selection can now be directly
        // updated in the widget.
        readyForSelection = true;
    }
    return Status.OK_STATUS;
}
 
源代码19 项目: ice   文件: ICEJob.java
@Override
protected IStatus run(IProgressMonitor monitor) {
	final int ticks = 100;
	int worked = 0;
	monitor.beginTask("Executing the Job Launch Action...", ticks);
	status = FormStatus.Processing;

	// Clear any existing Eclipse Console content
	Action.clearConsole();

	// Execute the Actions
	for (Action action : actions) {
		// Get a reference to the Current Action
		currentlyRunningAction = action;
		monitor.subTask("Executing " + currentlyRunningAction.getActionName() + "...");

		// Execute the Action
		FormStatus tempStatus = currentlyRunningAction.execute(actionDataMap);

		// If the Action returned with an InfoError status,
		// then we need to report that and throw an Error
		// Eclipse Status
		if (tempStatus.equals(FormStatus.InfoError)) {
			return error("Error in executing the " + action.getActionName() + " Action.", null);
		}

		// Check for Eclipse Job cancellations.
		if (monitor.isCanceled()) {
			currentlyRunningAction.cancel();
			status = FormStatus.Processed;
			return Status.CANCEL_STATUS;
		}

		// If the Action is still processing, then
		// lets just wait until its done.
		while (tempStatus.equals(FormStatus.Processing)) {
			try {
				Thread.sleep(100);
			} catch (InterruptedException e1) {
				// Complain
				return error("Error in executing the " + action.getActionName() + " Action.", e1);
			}
			tempStatus = currentlyRunningAction.getStatus();
		}

		// Increment the worked ticker
		worked += ticks / actions.size();
		monitor.worked(worked);
	}

	// Once done executing all Actions, indicate
	// so by setting the status flag.
	status = FormStatus.Processed;
	monitor.worked(ticks);
	monitor.done();

	// Clean up the docker container if this was a 
	// launch using docker
	if (actionDataMap.get("containerId") != null) {
		cleanDockerExecution();
	}
	return Status.OK_STATUS;
}
 
public IStatus validateEdit(IFile[] files, Object context) {
     String comment = "";
     boolean stealLock = false;
     // reduce the array to just read only files
     ReadOnlyFiles readOnlyFiles = processFileArray(files);
     if (readOnlyFiles.size() == 0) return Status.OK_STATUS;
     // of the read-only files, get array of ones which are versioned
  IFile[] managedFiles = readOnlyFiles.getManaged();
  if (managedFiles.length > 0) {
  	// Prompt user to lock files
  	if (context != null) {
  		ISVNFileModificationValidatorPrompt svnFileModificationValidatorPrompt = 
  			SVNProviderPlugin.getPlugin().getSvnFileModificationValidatorPrompt();
  		if (svnFileModificationValidatorPrompt != null) {
  			if (!svnFileModificationValidatorPrompt.prompt(managedFiles, context))
  				return Status.CANCEL_STATUS;
  			comment = svnFileModificationValidatorPrompt.getComment();
  			stealLock = svnFileModificationValidatorPrompt.isStealLock();
  		}
  	}
  	// Run the svn lock command
  	RepositoryProvider provider = RepositoryProvider.getProvider(managedFiles[0].getProject());
  	if ((provider != null) && (provider instanceof SVNTeamProvider)) {
  		SVNTeamProvider svnTeamProvider = (SVNTeamProvider) provider;
  		LockResourcesCommand command = new LockResourcesCommand(svnTeamProvider.getSVNWorkspaceRoot(), managedFiles, stealLock, comment, false);
  		try {
  			command.run(new NullProgressMonitor());
  		} catch (SVNException e) {
  			SVNProviderPlugin.log(IStatus.ERROR, e.getMessage(), e);
  			return Status.CANCEL_STATUS;
  		}
  	}
     }
  // Process any unmanaged but read-only files.  For
  // those we need to prompt the user to flip the read only bit
  IFile[] unManagedFiles = readOnlyFiles.getUnManaged();
  if (unManagedFiles.length > 0) {
   synchronized (this) {
       if (uiValidator == null) 
           uiValidator = loadUIValidator();
   }
   if (uiValidator != null) {
       return uiValidator.validateEdit(unManagedFiles, context);
   }
   // There was no plugged in validator so fail gracefully
return getStatus(unManagedFiles); 
  }
  return Status.OK_STATUS;
 }