下面列出了org.eclipse.ui.console.IConsole#org.eclipse.core.runtime.Status 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
*
* @param command The command string to execute
* @param resource The path to run the command in
* @return Output from the command
* @throws CoreException Thrown if running the external command generates an exception
*/
protected String run(String[] command, IResource resource) throws CoreException {
// check if we are using console
String console = null;
if (TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.BUILDER_CONSOLE_OUTPUT)) {
console = getProgramName();
}
extrun.setup(command, resource.getLocation().toFile().getParentFile(), console);
String output = null;
try {
output = extrun.run();
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, TexlipsePlugin.getPluginId(),
IStatus.ERROR, "Building the project: ", e));
} finally {
extrun.stop();
}
return output;
}
@Override
protected IStatus validateParams() {
try {
/* read deploy parameters */
ManifestParseTree manifest = application.getManifest();
ManifestParseTree app = manifest.get("applications").get(0); //$NON-NLS-1$
if (application.getName() != null) {
appName = application.getName();
return Status.OK_STATUS;
}
appName = app.get(CFProtocolConstants.V2_KEY_NAME).getValue();
return Status.OK_STATUS;
} catch (InvalidAccessException e) {
return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null);
}
}
/** Create the configuration job for a Java project.
*
* @param project the project to configure.
* @return the job.
*/
@SuppressWarnings("static-method")
protected Job createJobForJavaProject(IProject project) {
return new Job(Messages.EnableSarlMavenNatureAction_0) {
@Override
protected IStatus run(IProgressMonitor monitor) {
final SubMonitor mon = SubMonitor.convert(monitor, 3);
// Force the project configuration to SARL.
SARLProjectConfigurator.configureSARLProject(
// Project to configure
project,
// Add SARL natures
true,
// Force java configuration
true,
// Create folders
true,
// Monitor
mon.newChild(3));
return Status.OK_STATUS;
}
};
}
public IStatus validateSourcePath(IPath path)
{
if (path == null || path.isEmpty())
{
return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, Messages.NodeJSService_EmptySourcePath);
}
if (!path.toFile().isDirectory())
{
return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, INodeJS.ERR_DOES_NOT_EXIST, MessageFormat.format(
Messages.NodeJSService_NoDirectory_0, path), null);
}
if (!path.append(LIB).toFile().isDirectory())
{
return new Status(Status.ERROR, JSCorePlugin.PLUGIN_ID, MessageFormat.format(
Messages.NodeJSService_InvalidLocation_0, LIB));
}
// TODO Any other things we want to check for to "prove" it's a NodeJS source install?
return Status.OK_STATUS;
}
public static void enableDisableInjectMetrics(CodewindApplication app, boolean enable) {
Job job = new Job(NLS.bind(Messages.EnableDisableInjectMetricsJob, app.name)) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
app.connection.requestInjectMetrics(app.projectID, enable);
app.connection.refreshApps(app.projectID);
return Status.OK_STATUS;
} catch (Exception e) {
Logger.logError("An error occurred changing inject metric setting for: " + app.name + ", with id: " + app.projectID, e); //$NON-NLS-1$ //$NON-NLS-2$
return new Status(IStatus.ERROR, CodewindUIPlugin.PLUGIN_ID, NLS.bind(Messages.ErrorOnEnableDisableInjectMetrics, app.name), e);
}
}
};
job.schedule();
}
private void validateNewExperimentName() {
String name = fNewExperimentName.getText();
IWorkspace workspace = fExperimentFolder.getWorkspace();
IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);
if ("".equals(name)) { //$NON-NLS-1$
updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_EmptyNameError, null));
return;
}
if (!nameStatus.isOK()) {
updateStatus(nameStatus);
return;
}
IPath path = new Path(name);
if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) {
updateStatus(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.Dialog_ExistingNameError, null));
return;
}
updateStatus(new Status(IStatus.OK, Activator.PLUGIN_ID, "")); //$NON-NLS-1$
}
@Override
public void documentChanged(DocumentEvent event) {
IDocument document = event.getDocument();
try {
int startLine = DocumentHelper.getStartLine(event);
if (!DocumentHelper.isRemove(event)) {
int endLine = DocumentHelper.getEndLine(event, false);
// Insert new lines
for (int i = startLine; i < endLine; i++) {
DocumentLineList.this.addLine(i + 1);
}
if (startLine == endLine) {
DocumentLineList.this.updateLine(startLine);
}
} else {
// Update line
DocumentLineList.this.updateLine(startLine);
}
invalidateLine(startLine);
} catch (BadLocationException e) {
TMUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TMUIPlugin.PLUGIN_ID, e.getMessage(), e));
}
}
@Override
public IStatus validateCredentials() {
// must not be null
if (getIdentity() != null && getCredentials() != null) {
// identity always starts with "AIKA" and has 20 chars
if (getIdentity().matches("AKIA[a-zA-Z0-9]{16}")) {
// secret has 40 chars
if (getCredentials().length() == 40) {
return Status.OK_STATUS;
}
}
}
return new Status(Status.ERROR, "org.lamport.tla.toolbox.jcloud",
"Invalid credentials, please check the environment variables "
+ "(AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY) are correctly "
+ "set up and picked up by the Toolbox."
+ "\n\nPlease visit the Toolbox help and read section 4 "
+ "of \"Cloud based distributed TLC\" on how to setup authentication.");
}
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;
}
protected void runValidate(final boolean onOpen) {
ValidationOperation validationOperation = createValidationOperation(onOpen);
SafeWorkspaceJob validationJob = new SafeWorkspaceJob("Update KaiZen Editor validation markers") {
@Override
public IStatus doRunInWorkspace(IProgressMonitor monitor) throws CoreException {
validationOperation.run(monitor);
return Status.OK_STATUS;
}
@Override
public boolean belongsTo(Object family) {
if (family instanceof ValidationOperation) {
return getEditorInput().equals(((ValidationOperation) family).getEditorInput());
}
return false;
}
};
Job.getJobManager().cancel(validationOperation);
validationJob.schedule();
}
@Override
public IStatus validateCredentials() {
final String credential = System.getenv(AZURE_COMPUTE_SERVICE_PRINCIPAL_PASSWORD);
final String identity = System.getenv(AZURE_COMPUTE_SERVICE_PRINCIPAL);
final String subscription = System.getenv(AZURE_COMPUTE_SUBSCRIPTION);
final String tenantId = System.getenv(AZURE_COMPUTE_TENANT);
if (credential == null || identity == null || subscription == null || tenantId == null) {
return new Status(Status.ERROR, "org.lamport.tla.toolbox.jcloud",
"Invalid credentials, please check the environment variables "
+ "(" + AZURE_COMPUTE_SERVICE_PRINCIPAL_PASSWORD + " & " + AZURE_COMPUTE_SERVICE_PRINCIPAL + " "
+ "& " + AZURE_COMPUTE_TENANT + " and " + AZURE_COMPUTE_SUBSCRIPTION + ") are correctly "
+ "set up and picked up by the Toolbox."
+ "\n\nPlease visit the Toolbox help and read section 4 "
+ "of \"Cloud based distributed TLC\" on how to setup authentication.");
}
return Status.OK_STATUS;
}
protected SourceViewer createViewer(final Composite parent) {
final Builder editorBuilder = configuration.getEmbeddedEditorFactory().newEditor(resourceProvider);
editorBuilder.processIssuesBy((issues, monitor) -> {
IStatus result = Status.OK_STATUS;
final StringBuilder messages = new StringBuilder();
for (final Issue issue : issues) {
if (issue.getSeverity() == Severity.ERROR) {
if (messages.length() != 0) {
messages.append('\n');
}
messages.append(issue.getMessage());
}
}
if (messages.length() != 0) {
result = createErrorStatus(messages.toString(), null);
}
final IStatus toBeUpdated = result;
getShell().getDisplay().asyncExec(() -> updateStatus(toBeUpdated));
});
final EmbeddedEditor handle = editorBuilder.withParent(parent);
partialModelEditor = handle.createPartialEditor(getPrefix(), data.getTemplate().getPattern(), "", true);
return handle.getViewer();
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IProject project = getProject(event);
if(project != null ){
final IProject theProject = project;//to pass to Job
WorkspaceJob job = new WorkspaceJob(NLS.bind("Convert {0} to Hybrid Mobile project", project.getName())) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
HybridProjectCreator creator = new HybridProjectCreator();
creator.convertProject(theProject, new NullProgressMonitor());
return Status.OK_STATUS;
}
};
job.schedule();
}
return null;
}
public static void log(int severity, String string, Throwable e) {
if(log == null){
System.err.println(string + "\n" + e);
} else {
IStatus status = new Status(severity, Activator.PLUGIN_ID, string, e);
log.log(status);
}
}
/**
* From @see DelayableJob.IWorker
*/
public IStatus work(IProgressMonitor monitor, HashMap<String, Object> params){
if (isSuspended()) {
return Status.CANCEL_STATUS;
}
final TableViewer tv = (TableViewer) cv.getViewerWidget();
if (filtered != null) {
filtered.clear();
}
filtered = null;
setQuery();
applyQueryFilters();
if (orderFields != null) {
qbe.orderBy(false, orderFields);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
raw = qbe.execute();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
UiDesk.asyncExec(new Runnable() {
public void run(){
// Avoid access to disposed table
if (tv != null && !tv.getTable().isDisposed()) {
tv.setItemCount(0);
filtered = raw;
tv.setItemCount(raw.size());
}
}
});
return Status.OK_STATUS;
}
private void createUpdateJob() {
new WorkbenchJob("WebAppTabGroup") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
ILaunchConfigurationTab tab = launchConfigurationDialog.getActiveTab();
if (tab != null && !tab.getControl().isDisposed()) {
launchConfigurationDialog.updateButtons();
launchConfigurationDialog.updateMessage();
}
return Status.OK_STATUS;
}
}.schedule();
}
public static IStatus deleteProject(IProject project) {
if (project != null && project.exists())
try {
project.delete(true, true, new NullProgressMonitor());
} catch (CoreException e) {
Log.error("Could not delete project", e);
return new Status(Status.ERROR, Activator.PLUGIN_ID, "Could not delete project", e);
}
return Status.OK_STATUS;
}
/**
* Checks if the given engine is compatible with this plug-in. Returns a
* {@link MultiStatus} as there may be more than one reason for an engine to
* fail.
*
* @param engine
* @return A WARNING or OK level status
*
*/
public IStatus isEngineCompatible(HybridMobileEngine engine) {
if (supportedEngines == null || supportedEngines.isEmpty())
return Status.OK_STATUS;
MultiStatus status = new MultiStatus(HybridCore.PLUGIN_ID, 0,
NLS.bind("Plug-in {0} is not compatible with {1} version {2}",
new Object[] { getLabel(), engine.getName(), engine.getSpec() }),
null);
for (EngineDefinition definition : supportedEngines) {
status.add(isDefinitionSatisfied(definition, engine));
}
return status;
}
protected IStatus addImplementationJar(final ConnectorImplementation implementation, final IFolder classpathFolder, final SourceRepositoryStore sourceStore, final IRepositoryStore implStore, final List<IResource> resourcesToExport) throws CoreException, InvocationTargetException, InterruptedException {
final String connectorJarName = NamingUtils.toConnectorImplementationFilename(implementation.getImplementationId(), implementation.getImplementationVersion(),false) +".jar";
final IFile jarFile = classpathFolder.getFile(Path.fromOSString(connectorJarName)) ;
final String qualifiedClassName = impl.getImplementationClassname() ;
String packageName ="" ;
if(qualifiedClassName.indexOf(".")!= -1){
packageName = qualifiedClassName.substring(0, qualifiedClassName.lastIndexOf(".")) ;
}
final PackageFileStore file = (PackageFileStore) sourceStore.getChild(packageName, true) ;
if(file != null){
file.exportAsJar(jarFile.getLocation().toFile().getAbsolutePath(), false) ;
if(includeSources){
final IFolder srcFolder = implStore.getResource().getFolder(SRC_DIR) ;
if(srcFolder.exists()){
srcFolder.delete(true, Repository.NULL_PROGRESS_MONITOR) ;
}
srcFolder.create(true, true, Repository.NULL_PROGRESS_MONITOR) ;
cleanAfterExport.add(srcFolder) ;
final IPath path = file.getResource().getFullPath().makeRelativeTo(sourceStore.getResource().getFullPath()) ;
final IFolder newFolder = srcFolder.getFolder(path) ;
newFolder.getLocation().toFile().getParentFile().mkdirs() ;
srcFolder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR) ;
file.getResource().copy(newFolder.getFullPath(),true, Repository.NULL_PROGRESS_MONITOR) ;
resourcesToExport.add(srcFolder) ;
}
}
return Status.OK_STATUS ;
}
protected void indentStyleChanged(int indentStyle) {
Iterator<Category> iterator= fSelectionState.fElements.iterator();
String currentKey;
while (iterator.hasNext()) {
currentKey= iterator.next().key;
try {
changeIndentStyle(currentKey, indentStyle);
} catch (IllegalArgumentException e) {
fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle));
JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK,
Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e));
}
}
fSelectionState.refreshState(fSelection);
}
/**
* Download the remote content.
*
* @param monitor
*/
protected IStatus download(IProgressMonitor monitor)
{
SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.DownloadManager_downloadingContent,
downloads.size());
MultiStatus multi = new MultiStatus(CoreIOPlugin.PLUGIN_ID, IStatus.OK, null, null);
completedDownloadsPaths = new ArrayList<IPath>(downloads.size());
for (Iterator<ContentDownloadRequest> iterator = downloads.iterator(); iterator.hasNext();)
{
if (subMonitor.isCanceled())
{
// TODO Append to multi status and return that?
return Status.CANCEL_STATUS;
}
ContentDownloadRequest request = iterator.next();
request.execute(subMonitor.newChild(1));
IStatus result = request.getResult();
if (result != null)
{
if (result.isOK())
{
completedDownloadsPaths.add(request.getDownloadLocation());
iterator.remove();
}
multi.add(result);
}
subMonitor.setWorkRemaining(downloads.size());
}
return multi;
}
protected IStatus undeploy(final IProgressMonitor monitor) {
for (final AbstractProcess process : processes) {
try {
undeployProcess(process, monitor);
} catch (Exception e) {
BonitaStudioLog.error(e, EnginePlugin.PLUGIN_ID);
return new Status(Status.ERROR, EnginePlugin.PLUGIN_ID, String.format("%s (%s): %s",process.getName(),process.getVersion(),e.getMessage()), e);
}
}
return Status.OK_STATUS;
}
public boolean isAvailable() {
boolean available = JhlClientAdapterFactory.isAvailable();
if (!available && !loadErrorLogged) {
getLog().log(new Status(IStatus.INFO, PLUGIN_ID, 0, getLoadErrors(), null));
loadErrorLogged = true;
org.tigris.subversion.clientadapter.Activator.getDefault().handleLoadErrors(this);
}
return available;
}
protected IStatus openProcessEnablementProblemsDialog(final AbstractProcess process,
final List<Problem> processResolutionProblems) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
problemResolutionResult = createProcessEnablementProblemsDialog(process, processResolutionProblems)
.open();
}
});
return problemResolutionResult == IDialogConstants.OK_ID ? Status.OK_STATUS : Status.CANCEL_STATUS;
}
private void deleteTempFile( )
{
Job deleteJob = new Job( "Delete temporary files" ) { //$NON-NLS-1$
protected IStatus run( IProgressMonitor monitor )
{
deleteFile( new File( getTempFolder( ) ) );
return Status.OK_STATUS;
}
};
deleteJob.setSystem( true );
deleteJob.schedule( );
}
@Override
public IStatus build(IPath buildPath, IProgressMonitor monitor) {
IPath applicationFolderPath = buildPath.append("application");
IFolder applicationFolder = getRepository().getProject()
.getFolder(applicationFolderPath.makeRelativeTo(getRepository().getProject().getLocation()));
if (!applicationFolder.exists()) {
try {
applicationFolder.create(true, true, new NullProgressMonitor());
getResource().copy(applicationFolder.getFile(getName()).getFullPath(), false, new NullProgressMonitor());
} catch (CoreException e) {
return e.getStatus();
}
}
return Status.OK_STATUS;
}
/**
* If we've finished the job and it didn't fail, fire the specified completed
* action.
*/
protected void maybeFireCompletedAction(IStatus jobStatus) {
if (completedAction != null && jobStatus == Status.OK_STATUS) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
completedAction.run();
}
});
}
}
public Object execute(ExecutionEvent event) throws ExecutionException
{
Job job = new Job("Getting Diagnostic Logs") //$NON-NLS-1$
{
@Override
protected IStatus run(IProgressMonitor monitor)
{
final String content = getLogContent();
UIUtils.getDisplay().asyncExec(new Runnable()
{
public void run()
{
DiagnosticDialog dialog = new DiagnosticDialog(UIUtils.getActiveShell());
dialog.open();
dialog.setText(content);
}
});
return Status.OK_STATUS;
}
};
EclipseUtil.setSystemForJob(job);
job.schedule();
return null;
}
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
for (NodePart neighborPart : shownNeighbors) {
hidingModel.hide(neighborPart);
neighborPart.deactivate();
}
return Status.OK_STATUS;
}