List of usage examples for org.eclipse.jface.util Policy getLog
public static ILogger getLog()
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; /*/*from w w w .j a va 2 s . c o m*/ * (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.codesourcery.internal.installer.ui.WizardDialog.java
License:Open Source License
/** * Closes this window.//from w w w . ja va2 s . c om * * @return <code>true</code> if the window is (or was already) closed, and * <code>false</code> if it is still open */ private boolean hardClose() { // inform wizards for (int i = 0; i < createdWizards.size(); i++) { IWizard createdWizard = (IWizard) createdWizards.get(i); try { createdWizard.dispose(); } catch (Exception e) { Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e); Policy.getLog().log(status); } // Remove this dialog as a parent from the managed wizard. // Note that we do this after calling dispose as the wizard or // its pages may need access to the container during // dispose code createdWizard.setContainer(null); } // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534 // disposing the wizards could cause the image currently set in // this dialog to be disposed. A subsequent repaint event during // close would then fail. To prevent this case, we null out the image. setTitleImage(null); return super.close(); }
From source file:net.sourceforge.eclipsetrader.trading.wizards.accounts.AccountSettingsDialog.java
License:Open Source License
protected void okPressed() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; /* (non-Javadoc) * @see org.eclipse.core.runtime.ISafeRunnable#run() *//*from w w w . j a v a 2s . c o m*/ 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 && page.getControl() != null) { if (!page.performOk()) { hasFailedOK = true; return; } } } } catch (Exception e) { handleException(e); } finally { //Don't bother closing if the OK failed if (hasFailedOK) return; if (!errorOccurred) //Give subclasses the choice to save the state of the //preference pages. handleSave(); close(); } } /* (non-Javadoc) * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ 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$ MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$ } }); }
From source file:org.bonitasoft.studio.common.jface.ExtensibleWizard.java
License:Open Source License
@Override public void dispose() { super.dispose(); // notify pages for (int i = 0; i < additionalPages.size(); i++) { try {//from ww w .ja v a2s .co m ((IWizardPage) additionalPages.get(i)).dispose(); } catch (Exception e) { Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e); Policy.getLog().log(status); } } }
From source file:org.csstudio.sds.ui.internal.layers.LayerTransfer.java
License:Open Source License
/** * {@inheritDoc}// w ww . j a v a2 s.c o m */ @Override public Object nativeToJava(final TransferData transferData) { Object result = super.nativeToJava(transferData); if (isInvalidNativeType(result)) { Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, JFaceResources.getString("LocalSelectionTransfer.errorMessage"), null)); //$NON-NLS-1$ } return _selectedLayer; }
From source file:org.eclipse.gmf.runtime.diagram.ui.internal.dialogs.sortfilter.SortFilterDialog.java
License:Open Source License
protected void okPressed() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; /* (non-Javadoc) * /*from w w w. j a v a 2s. c o m*/ * @see org.eclipse.core.runtime.ISafeRunnable#run() */ 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(); CompoundCommand cc = new CompoundCommand(); while (nodes.hasNext()) { IPreferenceNode node = (IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page != null) { if (page instanceof SortFilterPage) { Command cmd = ((SortFilterPage) page).getCommand(); if (cmd != null && cmd.canExecute()) cc.add(cmd); } else if (!page.performOk()) { hasFailedOK = true; return; } } } if (cc.canExecute()) commandStack.execute(cc); } 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) */ 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$ MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$ } }); }
From source file:org.eclipse.gyrex.admin.ui.internal.application.AdminApplication.java
License:Open Source License
private void setupJFacePolicy() { Policy.setLog(new ILogger() { @Override//w ww . jav a 2 s .com 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.rcptt.sherlock.jface.JfacePolicyEventProvider.java
License:Open Source License
@Override protected void initializeBuilder(IReportBuilder builder) { fJfaceNativeLogger = Policy.getLog(); Policy.setLog(fJFaceLogger); }
From source file:org.eclipse.ui.tests.preferences.FontPreferenceTestCase.java
License:Open Source License
/** * The test added to assess results of accessing FontRegistry from a non-UI * thread. See bug 230360.//from www . jav a 2 s . com */ public void testNonUIThreadFontAccess() { // create a separate font registry to avoid contaminating other tests final FontRegistry fontRegistry = new FontRegistry("org.eclipse.jface.resource.jfacefonts"); //$NON-NLS-1$ // pre-calculate the default font; calling it in worker thread will only cause SWTException Font defaultFont = fontRegistry.defaultFont(); defaultFont.toString(); // avoids compiler warning // redirect logging so that we catch the error log final boolean[] errorLogged = new boolean[] { false }; ILogger logger = Policy.getLog(); Policy.setLog(new ILogger() { public void log(IStatus status) { if (status != null && status.getSeverity() == IStatus.ERROR && status.getPlugin().equals(Policy.JFACE)) errorLogged[0] = true; } }); Job job = new Job("Non-UI thread FontRegistry Access Test") { protected IStatus run(IProgressMonitor monitor) { // this should produce no exception, but should log a error boolean created = checkFont(fontRegistry); assertFalse(created); return Status.OK_STATUS; } }; job.schedule(); try { job.join(); assertTrue(errorLogged[0]); } catch (InterruptedException e) { fail("Worker thread was interrupted in the FontRegistry access test"); } finally { Policy.setLog(logger); } // now let's try to create the same font in the UI thread and check that the correct boolean created = checkFont(fontRegistry); assertTrue(created); }
From source file:org.eclipse.vtp.desktop.core.dialogs.FramedDialog.java
License:Open Source License
/** * Constructs a new FramedDialog with the given shell as its parent window. * //from w ww. j av a 2 s. com * @param parentShell The parent window of this dialog */ public FramedDialog(Shell parentShell) { this(new SameShellProvider(parentShell)); if ((parentShell == null) && Policy.DEBUG_DIALOG_NO_PARENT) { Policy.getLog() .log(new Status(IStatus.INFO, Policy.JFACE, IStatus.INFO, this.getClass() + " created with no shell", //$NON-NLS-1$ new Exception())); } }