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

The following examples show how to use org.eclipse.core.runtime.Status#OK . 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: JStructPlugin.java    From junion with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static void log(int status, String msg, Exception e) {
		if(instance != null) {
			Status st = new Status(status, PLUGIN_ID, Status.OK, msg, e);
			instance.getLog().log(st);
			if(status == Status.ERROR || status == Status.WARNING) {
//				StatusManager sm = StatusManager.getManager();
//				log("SM handle" + sm);
//		    	if(sm != null) {
//		    		
//		    		sm.handle(st, StatusManager.SHOW);
//		    	}
			}
		}
		else {
			if(e != null) System.out.println(msg + ", " + e.toString());
			else System.out.println(msg);
		}
	}
 
Example 2
Source File: WaitDeviceForFastboot.java    From Flashtool with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Open the dialog.
 * @return the result
 */
public Object open() {
	createContents();
	shlWaitForFastbootmode.open();
	shlWaitForFastbootmode.layout();
	shlWaitForFastbootmode.addListener(SWT.Close, new Listener() {
	      public void handleEvent(Event event) {
				job.stopSearch();
				result = new String("Canceled");
	      }
	    });
	Display display = getParent().getDisplay();
	job = new SearchFastbootJob("Search Fastboot Job");
	job.schedule();
	while (!shlWaitForFastbootmode.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
		if (job.getState() == Status.OK) {
			result = new String("OK");
			shlWaitForFastbootmode.dispose();
		}
	}
	return result;
}
 
Example 3
Source File: WaitDeviceForFlashmode.java    From Flashtool with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Open the dialog.
 * @return the result
 */
public Object open() {
	createContents();
	shlWaitForFlashmode.open();
	shlWaitForFlashmode.layout();
	shlWaitForFlashmode.addListener(SWT.Close, new Listener() {
	      public void handleEvent(Event event) {
				job.stopSearch();
				result = new String("Canceled");
	      }
	    });
	Display display = getParent().getDisplay();
	job = new SearchJob("Search Job");
	DeviceChangedListener.disableDetection();
	job.schedule();
	while (!shlWaitForFlashmode.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
		if (job.getState() == Status.OK) {
			shlWaitForFlashmode.dispose();
		}
	}
	return result;
}
 
Example 4
Source File: ProcessDataViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void moveData(final IStructuredSelection structuredSelection) {
    final DataAware container = (DataAware) getDataContainerObservable().getValue();
    final MoveDataWizard moveDataWizard = new MoveDataWizard(container);
    if (createWizardDialog(moveDataWizard, IDialogConstants.FINISH_LABEL).open() == Dialog.OK) {
        final DataAware dataAware = moveDataWizard.getSelectedDataAwareElement();
        try {
            final MoveDataCommand cmd = new MoveDataCommand(TransactionUtil.getEditingDomain(dataAware), container,
                    structuredSelection.toList(), dataAware);
            OperationHistoryFactory.getOperationHistory().execute(cmd, null, null);

            if (!(cmd.getCommandResult().getStatus().getSeverity() == Status.OK)) {
                final List<Object> data = (List<Object>) cmd.getCommandResult().getReturnValue();
                String dataNames = "";
                for (final Object d : data) {
                    dataNames = dataNames + ((Element) d).getName() + ",";
                }
                dataNames = dataNames.substring(0, dataNames.length() - 1);
                MessageDialog.openWarning(Display.getDefault().getActiveShell(), Messages.PromoteDataWarningTitle,
                        Messages.bind(Messages.PromoteDataWarningMessage, dataNames));
            }

        } catch (final ExecutionException e1) {
            BonitaStudioLog.error(e1);
        }
    }
}
 
Example 5
Source File: AbstractDataSection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void moveData(final IStructuredSelection structuredSelection) {
    final MoveDataWizard moveDataWizard = new MoveDataWizard((DataAware) getEObject());
    if (new WizardDialog(Display.getDefault().getActiveShell(), moveDataWizard).open() == Dialog.OK) {
        final DataAware dataAware = moveDataWizard.getSelectedDataAwareElement();
        try {
            final MoveDataCommand cmd = new MoveDataCommand(getEditingDomain(), (DataAware) getEObject(), structuredSelection.toList(), dataAware);
            OperationHistoryFactory.getOperationHistory().execute(cmd, null, null);

            if (!(cmd.getCommandResult().getStatus().getSeverity() == Status.OK)) {
                final List<Object> data = (List<Object>) cmd.getCommandResult().getReturnValue();
                String dataNames = "";
                for (final Object d : data) {
                    dataNames = dataNames + ((Element) d).getName() + ",";
                }
                dataNames = dataNames.substring(0, dataNames.length() - 1);
                MessageDialog.openWarning(Display.getDefault().getActiveShell(), Messages.PromoteDataWarningTitle,
                        Messages.bind(Messages.PromoteDataWarningMessage, dataNames));
            }

        } catch (final ExecutionException e1) {
            BonitaStudioLog.error(e1);
        }
        refresh();
    }
}
 
Example 6
Source File: StatusUtil.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private static String getSeverityString(int severity) {
	switch (severity) {
	case Status.OK:
		return "OK";
	case Status.WARNING:
		return "WARNING";
	case Status.ERROR:
		return "ERROR";
	case Status.INFO:
		return "INFO";
	case Status.CANCEL:
		return "CANCEL";
	default:
		return "? " + severity + " ?";
	}
}
 
Example 7
Source File: ResultAdapter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Mapping zwischen Severity und RCP Status Severity (Status.OK, Stauts.INFO, usw)
 */
public static int getSeverityAsStatus(final Result.SEVERITY severity){
	switch (severity.ordinal()) {
	case 0:
		return Status.OK;
	case 3:
		return Status.ERROR;
	case 2:
		return Status.ERROR;
	case 1:
		return Status.INFO;
	}
	return Status.ERROR;
}
 
Example 8
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 9
Source File: AutomaticUpdate.java    From tmxeditor8 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 10
Source File: StatusUtil.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Log a status to the corresponding log-level; does nothing if
 * {@link Status#isOK()}
 * 
 * @param prependMessage              an optional message to prepend the status
 *                                    message
 * @param log
 * @param status
 * @param includeExceptionIfAvailable
 * @param logDebugIfOk                log to level debug if the status is ok
 */
public static void logStatus(String prependMessage, @NonNull Logger log, @NonNull IStatus status,
		boolean includeExceptionIfAvailable, boolean logDebugIfOk) {
	if (status.isOK() && !logDebugIfOk) {
		return;
	}

	StringBuilder sb = new StringBuilder();
	if (status.isMultiStatus()) {
		sb.append("[MULTISTATUS] ");
	}
	if (prependMessage != null) {
		sb.append(prependMessage + " ");
	}
	sb.append("(c" + status.getCode() + "/s" + status.getSeverity() + ") ");
	sb.append(status.getMessage());
	String message = sb.toString();

	boolean includeException = (includeExceptionIfAvailable && status.getException() != null);

	int severity = status.getSeverity();
	switch (severity) {
	case Status.ERROR:
		if (includeException) {
			log.error(message, status.getException());
		} else {
			log.error(message);
		}
		break;
	case Status.WARNING:
		if (includeException) {
			log.warn(message, status.getException());
		} else {
			log.warn(message);
		}
		break;
	case Status.INFO:
	case Status.CANCEL:
		if (includeException) {
			log.info(message, status.getException());
		} else {
			log.info(message);
		}
		break;
	case Status.OK:
		log.debug(message);
		break;
	default:
		break;
	}

	if (status.isMultiStatus()) {
		Arrays.asList(status.getChildren()).stream().forEach(c -> logStatus(prependMessage, log, c, true, false));
	}
}
 
Example 11
Source File: ResultStatusAdapter.java    From elexis-3-core with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Adapt the result of an {@link IIdentifiedRunnable} to an {@link IStatus}
 * 
 * @param run
 * @return
 */
public static IStatus adapt(Map<String, Serializable> result){
	String resultData = (String) result.get(IIdentifiedRunnable.ReturnParameter.RESULT_DATA);
	boolean isWarning = result.containsKey(IIdentifiedRunnable.ReturnParameter.MARKER_WARN);
	return new Status(isWarning ? Status.WARNING : Status.OK, "unknown", resultData);
}