Example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Prototype

int OK_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_ID.

Click Source Link

Document

Button id for an "Ok" button (value 0).

Usage

From source file:au.gov.ga.earthsci.application.about.AboutDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
}

From source file:au.gov.ga.earthsci.application.parts.globe.handlers.GotoCoordinateDialog.java

License:Apache License

@Override
protected Button createButton(Composite parent, int id, String label, boolean defaultButton) {
    Button button = super.createButton(parent, id, label, defaultButton);
    if (id == IDialogConstants.OK_ID) {
        okButton = button;/*from  w  w w .  ja  va  2 s.com*/
        button.setEnabled(false);
    }
    return button;
}

From source file:au.gov.ga.earthsci.bookmark.part.editor.BookmarkEditorDialog.java

License:Apache License

private void updateValidityIndicators(IBookmarkEditor editor, boolean valid,
        IBookmarkEditorMessage[] messages) {
    if (editor == null) {
        return;/*  ww w.j  ava 2s  .  co m*/
    }
    if (valid || !currentEditorIncludedInBookmark()) {
        messageArea.restoreTitle();
        if (getButton(IDialogConstants.OK_ID) != null) {
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    } else if (!valid) {
        if (messages != null && messages.length > 0) {
            messageArea.updateText(messages[0].getMessage(),
                    messages[0].getLevel() == Level.ERROR ? IMessageProvider.ERROR
                            : messages[0].getLevel() == Level.WARNING ? IMessageProvider.WARNING
                                    : IMessageProvider.INFORMATION);
        }
        if (getButton(IDialogConstants.OK_ID) != null) {
            getButton(IDialogConstants.OK_ID).setEnabled(false);
        }
    }
}

From source file:au.gov.ga.earthsci.catalog.ui.handler.BrowseInputDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        value = text.getText();/*from  w w w . j  a v  a  2s. c  o m*/
    } else {
        value = null;
    }
    super.buttonPressed(buttonId);
}

From source file:au.gov.ga.earthsci.catalog.ui.handler.BrowseInputDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    //do this here because setting the text will set enablement on the ok
    // button//from  w ww  .ja  v a 2  s.  c  o m
    text.setFocus();
    if (value != null) {
        text.setText(value);
        text.selectAll();
    }
}

From source file:au.gov.ga.earthsci.catalog.ui.handler.BrowseInputDialog.java

License:Open Source License

/**
 * Sets or clears the error message. If not <code>null</code>, the OK button
 * is disabled./*from www.  j ava  2 s.c o m*/
 * 
 * @param errorMessage
 *            the error message, or <code>null</code> to clear
 * @since 3.0
 */
public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
    if (errorMessageText != null && !errorMessageText.isDisposed()) {
        errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); //$NON-NLS-1$
        // Disable the error message text control if there is no error, or
        // no error text (empty or whitespace only).  Hide it also to avoid
        // color change.
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=130281
        boolean hasError = errorMessage != null
                && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
        errorMessageText.setEnabled(hasError);
        errorMessageText.setVisible(hasError);
        errorMessageText.getParent().update();
        // Access the ok button by id, in case clients have overridden button creation.
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}

From source file:au.gov.ga.earthsci.common.ui.dialogs.SpatialReferenceSelectorDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    super.createButtonsForButtonBar(parent);
    getButton(IDialogConstants.OK_ID).setEnabled(false);
}

From source file:au.gov.ga.earthsci.common.ui.dialogs.SpatialReferenceSelectorDialog.java

License:Apache License

private void wireReferenceSelectionListener() {
    referencesView.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override//from   w w  w  .  j a  v  a  2 s  .  c o  m
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.isEmpty()) {
                getButton(IDialogConstants.OK_ID).setEnabled(false);
                selectedSummary = null;
            } else {
                getButton(IDialogConstants.OK_ID).setEnabled(true);
                selectedSummary = (SpatialReferenceSummary) selection.getFirstElement();
            }
        }
    });
}

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  .  jav a2s  . co  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:au.gov.ga.earthsci.discovery.csw.CSWURLSelectionDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    validate();/*from   ww w  .j  a v  a  2 s .  com*/
}