Example usage for org.eclipse.jface.util Policy JFACE

List of usage examples for org.eclipse.jface.util Policy JFACE

Introduction

In this page you can find the example usage for org.eclipse.jface.util Policy JFACE.

Prototype

String JFACE

To view the source code for org.eclipse.jface.util Policy JFACE.

Click Source Link

Document

The unique identifier of the JFace plug-in.

Usage

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  ava  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.codesourcery.internal.installer.ui.WizardDialog.java

License:Open Source License

/**
 * Closes this window.//from w  ww  .  j av  a2 s  .  co m
 * 
 * @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:de.walware.ecommons.ui.util.ViewerUtil.java

License:Open Source License

public static void setSelectionProvider(final Control control, final ISelectionProvider selectionProvider) {
    control.setData(Policy.JFACE + ".selectionProvider", selectionProvider); //$NON-NLS-1$
}

From source file:de.walware.ecommons.ui.util.ViewerUtil.java

License:Open Source License

public static ISelectionProvider getSelectionProvider(final Control control) {
    if (control != null) {
        final Object data = control.getData(Policy.JFACE + ".selectionProvider"); //$NON-NLS-1$
        if (data instanceof ISelectionProvider) {
            return (ISelectionProvider) data;
        }//from   w w  w.j  a va 2 s  . c  o  m
    }
    return null;
}

From source file:net.karlmartens.ui.viewer.CellSelectionModifier.java

License:Apache License

private TableViewerColumn getViewerColumn(int index) {
    final TableColumn column = (TableColumn) _viewer.doGetColumn(index);
    return (TableViewerColumn) column.getData(Policy.JFACE + ".columnViewer");
}

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  2 s.  c  om*/
        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  w ww.  j  a  v a2 s .  c o 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}//from   www. 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.e4.tools.emf.ui.internal.common.component.tabs.EAttributeEditingSupport.java

License:Open Source License

static public TableViewerColumn getTableViewerColumn(TableViewer viewer, int index) {
    return (TableViewerColumn) viewer.getTable().getColumn(index).getData(Policy.JFACE + ".columnViewer"); //$NON-NLS-1$

}

From source file:org.eclipse.e4.xwt.tools.ui.designer.dialogs.AccessorConfigurationDialog.java

License:Open Source License

private void updateStatus(String message) {
    if (message != null && !"".equals(message)) {
        isError = true;//from  w w  w.  j a va  2  s . c  o  m
        fLastStatus = new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, message, null);
        setPropertyFieldEnable(true);
    } else {
        isError = false;
        fLastStatus = new Status(IStatus.OK, Policy.JFACE, IStatus.OK, Util.ZERO_LENGTH_STRING, null);
    }
    updateStatus(fLastStatus);
}