List of usage examples for org.eclipse.jface.util Policy getStatusHandler
public static StatusHandler getStatusHandler()
From source file:au.gov.ga.earthsci.common.ui.preferences.LazyPreferenceDialog.java
License:Apache License
@Override protected void okPressed() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; /*//w w w .j av a 2 s .c om * (non-Javadoc) * * @see org.eclipse.core.runtime.ISafeRunnable#run() */ @Override public void run() { getButton(IDialogConstants.OK_ID).setEnabled(false); errorOccurred = false; boolean hasFailedOK = false; try { // Notify all the pages and give them a chance to abort Iterator<?> nodes = getPreferenceManager().getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { IPreferenceNode node = (IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page != null && pagesWithCreatedControls.contains(page)) { if (!page.performOk()) { hasFailedOK = true; return; } } } } catch (Exception e) { handleException(e); } finally { //Don't bother closing if the OK failed if (hasFailedOK) { setReturnCode(FAILED); getButton(IDialogConstants.OK_ID).setEnabled(true); return; } if (!errorOccurred) { //Give subclasses the choice to save the state of the //preference pages. handleSave(); } setReturnCode(OK); close(); } } /* * (non-Javadoc) * * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ @Override public void handleException(Throwable e) { errorOccurred = true; Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e)); setSelectedNodePreference(null); String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$ Policy.getStatusHandler().show(new Status(IStatus.ERROR, Policy.JFACE, message, e), JFaceResources.getString("Error")); //$NON-NLS-1$ } }); if (getReturnCode() == FAILED) { return; } if (workingCopyManager != null) { try { workingCopyManager.applyChanges(); } catch (BackingStoreException e) { String msg = e.getMessage(); if (msg == null) { msg = WorkbenchMessages.FilteredPreferenceDialog_PreferenceSaveFailed; } StatusUtil.handleStatus(WorkbenchMessages.PreferencesExportDialog_ErrorDialogTitle + ": " + msg, e, //$NON-NLS-1$ StatusManager.SHOW, getShell()); } } // Run the update jobs Iterator<Job> updateIterator = updateJobs.iterator(); while (updateIterator.hasNext()) { updateIterator.next().schedule(); } }
From source file:com.genuitec.eclipse.gerrit.tools.internal.utils.commands.TagAndPushHandler.java
License:Open Source License
@Override protected Object internalExecute(ExecutionEvent event) throws Exception { IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); final Shell shell = HandlerUtil.getActiveShell(event); List<Repository> repositories = new ArrayList<Repository>(); //acquire the list of repositories for (Object o : selection.toArray()) { RepositoryNode node = (RepositoryNode) o; repositories.add(node.getRepository()); assert node.getRepository() != null; }/* ww w. jav a2 s. c o m*/ //configure tagging operation TagAndPushDialog tagAndPushConfigDialog = new TagAndPushDialog(shell, repositories); if (tagAndPushConfigDialog.open() != IDialogConstants.OK_ID) { return null; } //perform tagging operation try { ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell); final TagAndPushOperation op = new TagAndPushOperation(progressDialog.getShell(), repositories, tagAndPushConfigDialog.getSettings()); progressDialog.run(true, true, op); shell.getDisplay().asyncExec(new Runnable() { public void run() { if (op.getResult().getSeverity() >= IStatus.WARNING) { Policy.getStatusHandler().show(op.getResult(), "Results of the operation"); } else { MessageDialog.openInformation(shell, "Create and Push Tag", "Repositories has been successfully tagged."); } } }); } catch (InterruptedException e) { //ignore } catch (Exception e) { GerritToolsPlugin.getDefault().getLog() .log(new Status(IStatus.ERROR, GerritToolsPlugin.PLUGIN_ID, e.getLocalizedMessage(), e)); MessageDialog.openError(shell, "Create and Push Tag", e.getLocalizedMessage()); } return null; }
From source file:org.eclipse.egit.ui.internal.preferences.DoublePreferencesPreferencePage.java
License:Open Source License
private void saveSecondaryPreferenceStore() { IPreferenceStore store = getSecondaryPreferenceStore(); if (store != null && store.needsSaving() && (store instanceof IPersistentPreferenceStore)) { try {// ww w.ja v a 2 s .co m ((IPersistentPreferenceStore) store).save(); } catch (IOException e) { String message = JFaceResources.format("PreferenceDialog.saveErrorMessage", //$NON-NLS-1$ new Object[] { getTitle(), e.getMessage() }); Policy.getStatusHandler().show(new Status(IStatus.ERROR, Activator.getPluginId(), message, e), JFaceResources.getString("PreferenceDialog.saveErrorTitle")); //$NON-NLS-1$ } } }
From source file:org.eclipse.gyrex.admin.ui.cloud.internal.ClusterAdminPage.java
License:Open Source License
void approveSelectedNodes() { final ICloudManager cloudManager = getCloudManager(); final MultiStatus result = new MultiStatus(CloudUiActivator.SYMBOLIC_NAME, 0, "Some nodes could not be approved.", null); for (final Iterator stream = ((IStructuredSelection) getTreeViewer().getSelection()).iterator(); stream .hasNext();) {//from w w w . jav a2 s . c om final Object object = stream.next(); if (object instanceof NodeItem) { final NodeItem nodeItem = (NodeItem) object; if (!nodeItem.isApproved()) { final IStatus status = cloudManager.approveNode(nodeItem.getDescriptor().getId()); if (!status.isOK()) { result.add(status); } } } } if (!result.isOK()) { Policy.getStatusHandler().show(result, "Error"); } }
From source file:org.eclipse.gyrex.admin.ui.cloud.internal.ClusterAdminPage.java
License:Open Source License
void disconnectNode() { final ICloudManager cloudManager = getCloudManager(); final INodeConfigurer nodeConfigurer = cloudManager .getNodeConfigurer(cloudManager.getLocalInfo().getNodeId()); final IStatus status = nodeConfigurer.configureConnection(null); if (!status.isOK()) { Policy.getStatusHandler().show(status, "Error Disconnecting Node"); return;/* w w w . j a va2 s.c o m*/ } refresh(); }
From source file:org.eclipse.gyrex.admin.ui.cloud.internal.ClusterAdminPage.java
License:Open Source License
void retireSelectedNodes() { final ICloudManager cloudManager = getCloudManager(); final MultiStatus result = new MultiStatus(CloudUiActivator.SYMBOLIC_NAME, 0, "Some nodes could not be retired.", null); for (final Iterator stream = ((IStructuredSelection) getTreeViewer().getSelection()).iterator(); stream .hasNext();) {//from w w w . ja v a 2s . com final Object object = stream.next(); if (object instanceof NodeItem) { final NodeItem nodeItem = (NodeItem) object; if (nodeItem.isApproved()) { final IStatus status = cloudManager.retireNode(nodeItem.getDescriptor().getId()); if (!status.isOK()) { result.add(status); } } } } if (!result.isOK()) { Policy.getStatusHandler().show(result, "Error"); } }
From source file:org.eclipse.gyrex.admin.ui.cloud.internal.ConnectToCloudDialog.java
License:Open Source License
@Override protected void okPressed() { validate();/*from www. j ava2 s. c om*/ if (!getStatus().isOK()) { return; } final INodeConfigurer nodeConfigurer = cloudManager .getNodeConfigurer(cloudManager.getLocalInfo().getNodeId()); final IStatus status = nodeConfigurer.configureConnection(connectStringField.getText()); if (!status.isOK()) { Policy.getStatusHandler().show(status, "Error Connecting Node"); return; } super.okPressed(); }
From source file:org.eclipse.gyrex.admin.ui.internal.application.AdminApplication.java
License:Open Source License
private void openPage(final PageContribution contribution, final String[] args) { try {/*w w w . j ava2 s . c o m*/ final AdminPage page = getPage(contribution); if (null == page) { Policy.getStatusHandler().show(new Status(IStatus.ERROR, AdminUiActivator.SYMBOLIC_NAME, String.format("Page '%s' not found!", contribution.getId())), "Error Opening Page"); return; } if (page == currentPage) // don't do anything if it's the same page return; else if (null != currentPage) { // deactivate old page first deactivate(currentPage); } currentPage = page; navigation.selectNavigationEntry(contribution); activate(page, contribution, args); } catch (final Exception | LinkageError | AssertionError e) { Policy.getStatusHandler().show( e instanceof CoreException ? ((CoreException) e).getStatus() : new Status(IStatus.ERROR, AdminUiActivator.SYMBOLIC_NAME, String.format("Unable to open page '%s (id %s)'. Please check the server logs.", contribution.getName(), contribution.getId()), e), "Error Opening Page"); } }
From source file:org.eclipse.gyrex.admin.ui.internal.application.AdminApplication.java
License:Open Source License
private void setupJFacePolicy() { Policy.setLog(new ILogger() { @Override//from ww w. ja va 2 s .c om public void log(final IStatus status) { if (status.matches(IStatus.CANCEL) || status.matches(IStatus.ERROR)) { LOG.error(status.getMessage(), status.getException()); } else if (status.matches(IStatus.WARNING)) { LOG.warn(status.getMessage(), status.getException()); } else { LOG.info(status.getMessage(), status.getException()); } } }); final StatusHandler defaultStatusHandler = Policy.getStatusHandler(); Policy.setStatusHandler(new StatusHandler() { @Override public void show(final IStatus status, final String title) { Policy.getLog().log(status); defaultStatusHandler.show(status, title); } }); }
From source file:org.eclipse.gyrex.admin.ui.internal.widgets.NonBlockingStatusDialog.java
License:Open Source License
@Override public final int open() { try {/*from ww w . j a v a 2 s . c o m*/ return super.open(); } catch (final Exception | LinkageError | AssertionError e) { Policy.getStatusHandler().show( e instanceof CoreException ? ((CoreException) e).getStatus() : new Status(IStatus.ERROR, AdminUiActivator.SYMBOLIC_NAME, "Unable to open dialog. Please check the server logs.", e), "Error Opening Dialog"); return CANCEL; } }