List of usage examples for org.eclipse.jface.preference IPreferencePage performOk
public boolean performOk();
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; /*/* www .j a va 2 s .com*/ * (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.mindquarry.desktop.preferences.dialog.FilteredPreferenceDialog.java
License:Open Source License
/** * The preference dialog implementation of this <code>Dialog</code> * framework method sends <code>performOk</code> to all pages of the * preference dialog, then calls <code>handleSave</code> on this dialog to * save any state, and then calls <code>close</code> to close this dialog. *//* www .j a v a2 s .com*/ @Override protected void okPressed() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; /* * (non-Javadoc) * * @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 = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { IPreferenceNode node = (IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page != null) { 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(); } } /** * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ @Override public void handleException(Throwable e) { errorOccurred = true; log.error(e.toString(), e); //Policy.getLog().log( // new Status(IStatus.ERROR, Policy.JFACE, 0, // e.toString(), e)); clearSelectedNode(); String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$ MessageDialog.openError(getShell(), JFaceResources.getString("Error"), //$NON-NLS-1$ message + ": " + e.toString()); //$NON-NLS-1$ } }); }
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.jav 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:net.sourceforge.eclipsetrader.trading.wizards.accounts.NewAccountWizard.java
License:Open Source License
public boolean performFinish() { for (Iterator iter = additionalPages.iterator(); iter.hasNext();) { IPreferencePage page = (PreferencePage) ((WizardPageAdapter) iter.next()).getPreferencePage(); if (page.getControl() != null) page.performOk(); }// w w w . j a v a2 s . c o m account = CorePlugin.createAccount(pluginSelectionPage.getPluginId(), preferenceStore, new ArrayList()); account.setPluginId(pluginSelectionPage.getPluginId()); account.setGroup(group); account.setDescription(generalPage.getText()); account.setCurrency(generalPage.getCurrency()); account.setInitialBalance(generalPage.getBalance()); if (group != null) { account.setGroup(group); CorePlugin.getRepository().save(group); } CorePlugin.getRepository().save(account); return true; }
From source file:org.bonitasoft.studio.preferences.dialog.BonitaPreferenceDialog.java
License:Open Source License
@Override public boolean close() { for (IPreferencePage page : applyOnBack) { page.performOk(); }// w ww. j av a 2 s.c om applyOnBack.clear(); return super.close(); }
From source file:org.bonitasoft.studio.preferences.dialog.BonitaPreferenceDialog.java
License:Open Source License
/** * Create contents of the dialog.// www.jav a 2 s . c om * @param parent */ @Override protected Control createDialogArea(Composite parent) { final Composite container = (Composite) super.createDialogArea(parent); GridLayout gl_container = new GridLayout(1, false); gl_container.horizontalSpacing = 0; gl_container.verticalSpacing = 0; gl_container.marginWidth = 0; gl_container.marginHeight = 0; gl_container.marginBottom = 0; container.setLayout(gl_container); Composite composite = new Composite(container, SWT.NONE); GridLayout gl_composite = new GridLayout(2, false); gl_composite.marginTop = 10; gl_composite.marginRight = 10; gl_composite.marginLeft = 10; gl_composite.marginHeight = 0; gl_composite.verticalSpacing = 0; gl_composite.marginWidth = 0; gl_composite.marginBottom = 10; gl_composite.horizontalSpacing = 0; composite.setLayout(gl_composite); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); composite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY)); composite.setBackgroundImage(Pics.getImage("/bg-coolbar-repeat.png")); btnDisplay = new Button(composite, SWT.PUSH); GridData gd_btnDisplay = GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).indent(10, 5).create(); gd_btnDisplay.horizontalIndent = 0; gd_btnDisplay.verticalIndent = 0; btnDisplay.setLayoutData(gd_btnDisplay); btnDisplay.setText(Messages.BonitaPreferenceDialog_back); btnDisplay.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { for (IPreferencePage page : applyOnBack) { page.performOk(); } applyOnBack.clear(); stack.topControl = menuComposite; mainComposite.layout(); btnDisplay.setEnabled(false); updateShellSize(true); } }); btnDisplay.setEnabled(false); final Text searchTxt = new Text(composite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.CANCEL); GridData gd_searchTxt = GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).indent(10, 5).create(); gd_searchTxt.grabExcessHorizontalSpace = true; gd_searchTxt.verticalIndent = 0; gd_searchTxt.horizontalAlignment = SWT.RIGHT; gd_searchTxt.horizontalIndent = 0; gd_searchTxt.widthHint = 150; searchTxt.setLayoutData(gd_searchTxt); searchTxt.setText(Messages.BonitaPreferenceDialog_search); searchTxt.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); searchTxt.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { searchTxt.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); cleanHighlights(); if (!searchTxt.getText().trim().isEmpty()) { filter(searchTxt.getText()); updateShellSize(false); } } }); searchTxt.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (searchTxt.getText().equals(Messages.BonitaPreferenceDialog_search)) { searchTxt.setText(""); } } }); Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL); separator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); mainComposite = new Composite(container, SWT.NONE); stack = new StackLayout(); mainComposite.setLayout(stack); mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); menuComposite = createMenuComposite(mainComposite); preferencePageComposite = createPreferencePageComposite(mainComposite); stack.topControl = menuComposite; mainComposite.layout(); menuComposite.setFocus(); return container; }
From source file:org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder.java
License:Open Source License
private void saveAll(final boolean closeDialog) { SafeRunner.run(new SafeRunnable() { private boolean errorOccurred; private boolean invalid; public void run() { errorOccurred = false;/* www. j a v a 2 s .c om*/ invalid = 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) { if (!page.performOk()) { invalid = true; return; } } } } catch (Exception e) { handleException(e); } finally { // Give subclasses the choice to save the state of the // preference pages. if (!errorOccurred) { handleSave(); } // Need to restore state if (!invalid && closeDialog) { close(); } } } public void handleException(Throwable e) { errorOccurred = true; if (Platform.isRunning()) { String bundle = Platform.PI_RUNTIME; Platform.getLog(Platform.getBundle(bundle)) .log(new Status(IStatus.ERROR, bundle, 0, e.toString(), e)); } else { logger.log(Level.SEVERE, e.getMessage(), e); } setSelectedNodePreference(null); String message = ""; //$NON-NLS-1$ MessageDialog.openError(getShell(), "", message); //$NON-NLS-1$ } }); }
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.mailster.gui.prefs.ConfigurationDialog.java
License:Open Source License
/** * The preference dialog implementation of this <code>Dialog</code> * framework method sends <code>performOk</code> to all pages of the * preference dialog, then calls <code>handleSave</code> on this dialog to * save any state, and then calls <code>close</code> to close this dialog. *///from w w w. j a va 2s .c o m protected void okPressed() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; /** * @see org.eclipse.core.runtime.ISafeRunnable#run() */ public void run() { // getButton(IDialogConstants.OK_ID).setEnabled(false); errorOccurred = false; boolean hasFailedOK = false; try { PreferenceManager preferenceManager = getPreferenceManager(); // Notify all the pages and give them a chance to abort Iterator<?> nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { IPreferenceNode node = (IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page != 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(); } } /** * @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)); clearLastSelectedNode(); String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$ MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$ } }); }
From source file:org.talend.repository.ui.dialog.ProjectSettingsPreferenceDialog.java
License:Open Source License
protected void saveCurrentSettings() { SafeRunnable.run(new SafeRunnable() { private boolean errorOccurred; @Override//from www. jav a 2 s. c om public void run() { errorOccurred = false; boolean hasFailedOK = false; try { Iterator nodes = getPreferenceManager().getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { IPreferenceNode node = (IPreferenceNode) nodes.next(); IPreferencePage page = node.getPage(); if (page != null) { if (!page.performOk()) { hasFailedOK = true; return; } } } } catch (Exception e) { handleException(e); } finally { if (hasFailedOK) { setReturnCode(FAILED); return; } if (!errorOccurred) { handleSave(); } setReturnCode(OK); } } @Override public void handleException(Throwable e) { errorOccurred = true; Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e)); clearSelectedNode(); 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$ } }); }