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

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

Introduction

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

Prototype

String OK_LABEL

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

Click Source Link

Document

The label for OK buttons.

Usage

From source file:com.aptana.ui.dialogs.HyperlinkMessageDialog.java

License:Open Source License

public static String[] getButtonLabels(int kind) {
    switch (kind) {
    case ERROR:/*from www.  jav a  2s .co m*/
    case INFORMATION:
    case WARNING:
        return new String[] { IDialogConstants.OK_LABEL };
    case CONFIRM:
        return new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    case QUESTION:
        return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
    case QUESTION_WITH_CANCEL:
        return new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
    default:
        throw new IllegalArgumentException("Illegal value for kind in HyperlinkMessageDialog.open()"); //$NON-NLS-1$
    }
}

From source file:com.aptana.ui.dialogs.InputMessageDialog.java

License:Open Source License

public InputMessageDialog(JsonNode questionNode, String title, String description) {
    super(UIUtils.getActiveShell(), title, null, description, MessageDialog.CONFIRM,
            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    this.dialogMessage = questionNode.path(MESSAGE).asText();
    this.inputType = questionNode.path(TYPE).asText();
    this.values = (ArrayNode) questionNode.path(CHOICES);

    input = new ArrayList<Object>();
}

From source file:com.aptana.ui.dialogs.InputURLDialog.java

License:Open Source License

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
    loadList();/* w ww.  j av a  2s .  c  o m*/
    combo.setFocus();
    if (value != null) {
        combo.setText(value);
        setErrorMessage(null);
        if (validator.isValid(value) != null) {
            Control button = getButton(IDialogConstants.OK_ID);
            if (button != null) {
                button.setEnabled(false);
            }

        }
    }
}

From source file:com.aptana.ui.dialogs.MultipleInputMessageDialog.java

License:Open Source License

public MultipleInputMessageDialog(JsonNode questionNode, String dialogTitle, String dialogMessage) {
    super(UIUtils.getDisplay().getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.CONFIRM,
            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
    this.questionsNode = questionNode;
    userInput = JsonNodeFactory.instance.objectNode();
}

From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java

License:Open Source License

/**
 * The constructor./*from   w w w .  ja  va  2  s .  c o m*/
 */
public UISeeCodePlugin() {
    super();
    plugin = this;
    try {
        resourceBundle = ResourceBundle.getBundle("com.arc.cdt.debug.seecode.ui.SeeCode");
    } catch (MissingResourceException x) {
        resourceBundle = null;
    }

    //        // Create the object that intercepts "create-display"
    //        // events from the core plugin so as to create
    //        // the Custom seecode displays.
    //        new DisplayCreatorDelegate();

    // The core plugin doesn't "see" us to avoid
    // circular dependencies. But it needs to
    // instantiate the CustomDisplayCallback class
    // that is defined in this package.
    // We use a callback to do that:
    SeeCodePlugin.getDefault().setCustomDisplayCallbackCreator(new ICustomDisplayCallbackCreator() {

        @Override
        public ICustomDisplayCallback create(ICDITarget target) {
            return new CustomDisplayCallback(target);
        }
    });

    SeeCodePlugin.getDefault().setLicenseExpirationChecker(new ILicenseExpirationChecker() {

        @Override
        public void checkLicenseExpiration(int days) {
            UISeeCodePlugin.this.checkLicensingAlert(days);
        }
    });

    SeeCodePlugin.getDefault().setLicensingFailure(new ILicenseFailure() {

        @Override
        public void reportLicenseFailure(final String msg) {
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    String fullMsg = "A valid license for " + UISeeCodePlugin.getTheDebuggerName()
                            + " was not found.\n\n" + msg;
                    IStatus status = makeErrorStatus(fullMsg);
                    ErrorDialog.openError(shell, UISeeCodePlugin.getDebuggerName() + " Licensing Failure", null,
                            status);

                }
            });

        }
    });

    SeeCodePlugin.getDefault().setStatusWriter(new IStatusWriter() {

        @Override
        public void setStatus(final String msg) {
            // We need to get to the status line manager, but we can only get
            // access to from a viewsite. Unfortunately, we have
            // no direct reference to such. Therefore, look for
            // the debug view whose ID is "org.eclipse.debug.ui.DebugView"
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    if (window != null) {
                        IWorkbenchPage page = window.getActivePage();
                        if (page != null) {
                            IViewPart viewPart = page.findView(IDebugUIConstants.ID_DEBUG_VIEW);
                            if (viewPart != null) {
                                IStatusLineManager statusLine = viewPart.getViewSite().getActionBars()
                                        .getStatusLineManager();
                                statusLine.setMessage(msg);
                            }
                        }
                    }
                }
            });

        }
    });

    SeeCodePlugin.getDefault().setTermSimInstantiator(new TermSimInstantiator());

    SeeCodePlugin.getDefault().setDisplayError(new IDisplayMessage() {

        @Override
        public void displayError(final String title, final String msg) {
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    showError(title, msg);
                }
            });

        }

        @Override
        public void displayNote(final String title, final String msg) {
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    showNote(title, msg);
                }
            });

        }
    });

    SeeCodePlugin.getDefault().setEngineVersionStrategyCallback(new IEngineResolver() {

        @Override
        public boolean useToolSetEngine(final int bundledEngineId, final int toolsetEngineId,
                final String toolsetPath) {
            switch (SeeCodePlugin.getDefault().getPreferences().getInt(
                    ISeeCodeConstants.PREF_ENGINE_VERSION_MANAGEMENT,
                    ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET)) {
            case ISeeCodeConstants.ENGINE_VERSION_PROMPT:
                if (bundledEngineId != toolsetEngineId) {
                    final boolean results[] = new boolean[1];
                    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                        @Override
                        public void run() {
                            results[0] = new PromptForEngineSelectionDialog(
                                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                    bundledEngineId, toolsetEngineId, toolsetPath).open();

                        }
                    });
                    return results[0];
                }
                return false;
            case ISeeCodeConstants.ENGINE_VERSION_USE_BUNDLED:
                return false;
            case ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET:
                return true;
            case ISeeCodeConstants.ENGINE_VERSION_USE_LATEST:
                return toolsetEngineId > bundledEngineId;
            }
            return false; // shouldn't get here
        }
    });

    /*        SeeCodePlugin.getDefault().setProgramLoadTimeoutCallback(new IDiagnoseProgramLoadTimeout(){
            
    public void diagnoseTimeout (final String exeName, final int timeout) {
        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
            
            public void run () {
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                String fullMsg =  
                  "The debugger engine timed out while loading\n\"" +
                  exeName + "\".\n" +
                  "The current timeout for loading a program is " + timeout + " milliseconds.\n" +
                  "If you have a slow target connection, or if you are doing a long-running\n"+
                  "blast operation, you may need to increase the timeout value. Go to the\n" +
                  "preference page: \"Windows->Preferences->C/C++->Debugger->MetaWare Debugger\".\n";
                        
                IStatus status = SeeCodePlugin.makeErrorStatus(fullMsg);
                ErrorDialog.openError(shell, "Program load timeout failure", null, status);
            
            }
        });
                
    }});*/

    SeeCodePlugin.getDefault().setLoadTimeoutCallback(new ITimeoutCallback() {
        private int _newTimeout = 0;

        @Override
        public int getNewTimeout(final int timeout) {
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
                @Override
                public void run() {
                    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                    String fullMsg = "The debugger engine is attempting to load a program and it has not\n"
                            + "completed after \"" + (timeout + 500) / 1000 + "\" seconds (as specified in the "
                            + "MetaWare Debugger\npreferences page).\n\n"
                            + "If you are loading over a slow connnection, or if you are doing a blast\n"
                            + "operation, the engine may need more time.\n\n"
                            + "What do you want the IDE to do?\n";

                    MessageDialog dialog = new MessageDialog(shell, "Engine Timeout Alert", null, // accept
                            fullMsg, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0) {

                        @Override
                        protected Control createCustomArea(Composite parent) {
                            Composite container = new Group(parent, 0);
                            container.setLayout(new GridLayout(4, false));
                            GridData gd = new GridData();
                            gd.horizontalSpan = 1;
                            gd.grabExcessHorizontalSpace = false;
                            final Button b1 = new Button(container, SWT.RADIO);
                            b1.setLayoutData(gd);
                            b1.setText("Wait no longer;");
                            // Label on button appears to be limited in size; add additional
                            // as a label
                            Label label1 = new Label(container, SWT.LEFT);
                            label1.setText("abort if load is not yet complete.");
                            GridData gd1 = new GridData();
                            gd1.horizontalSpan = 3;
                            gd1.grabExcessHorizontalSpace = true;
                            label1.setLayoutData(gd1);

                            gd = new GridData();
                            gd.horizontalSpan = 4;
                            gd.grabExcessHorizontalSpace = true;
                            final Button b2 = new Button(container, SWT.RADIO);
                            b2.setLayoutData(gd);
                            b2.setText("Continue waiting indefinitely.");
                            final Button b3 = new Button(container, SWT.RADIO);
                            b3.setText("Wait for an additional number of seconds");
                            b3.setLayoutData(gd);
                            final Label label = new Label(container, SWT.LEFT);
                            label.setText("    Number of additional seconds to wait: ");
                            gd = new GridData();
                            gd.horizontalSpan = 2;
                            label.setLayoutData(gd);
                            final Text field = new Text(container, SWT.SINGLE);
                            field.setText("" + (timeout + 500) / 1000);
                            gd = new GridData();
                            gd.horizontalSpan = 2;
                            gd.grabExcessHorizontalSpace = true;
                            gd.minimumWidth = 80;
                            field.setLayoutData(gd);
                            SelectionListener listener = new SelectionListener() {

                                @Override
                                public void widgetDefaultSelected(SelectionEvent e) {
                                }

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    if (e.widget == b1) {
                                        _newTimeout = 0;
                                        field.setEnabled(false);
                                        label.setEnabled(false);
                                    } else if (e.widget == b2) {
                                        _newTimeout = -1;
                                        field.setEnabled(false);
                                        label.setEnabled(false);
                                    } else {
                                        field.setEnabled(true);
                                        label.setEnabled(true);
                                        try {
                                            _newTimeout = Integer.parseInt(field.getText()) * 1000;
                                        } catch (NumberFormatException e1) {
                                            field.setText("0");
                                            _newTimeout = 0;
                                        }
                                    }
                                }
                            };
                            b1.addSelectionListener(listener);
                            b2.addSelectionListener(listener);
                            b3.addSelectionListener(listener);
                            field.addModifyListener(new ModifyListener() {

                                @Override
                                public void modifyText(ModifyEvent e) {
                                    try {
                                        if (b3.getSelection()) {
                                            _newTimeout = Integer.parseInt(field.getText()) * 1000;
                                            if (_newTimeout < 0) {
                                                field.setText("0");
                                                _newTimeout = 0;
                                            }
                                        }
                                    } catch (NumberFormatException e1) {
                                        field.setText("0");
                                        _newTimeout = 0;
                                    }

                                }
                            });
                            return container;
                        }
                    };
                    if (dialog.open() != Window.OK) {
                        _newTimeout = 0; // terminate immediately.
                    }
                }

            });
            return _newTimeout;

        }
    });

    /*
     * Set the Run wrapper for all engine callbacks so that they are in the UI thread.
     */
    SeeCodePlugin.getDefault().setCallbackRunner(new IRunner() {

        @Override
        public void invoke(Runnable run, boolean async) throws Throwable {
            Display display = PlatformUI.getWorkbench().getDisplay();
            try {
                // Run asynchronously to avoid deadlock of UI thread is
                // waiting for the engine to return.
                // display is null or disposed after workbench has shutdown,
                // but the engine may still be sending stuff...
                if (display != null && !display.isDisposed()) {
                    if (async) {
                        display.asyncExec(run);
                    } else
                        display.syncExec(run);
                }
            } catch (SWTException e) {
                if (e.throwable != null) {
                    // If the display is disposed of after the above
                    // check, but before the "run" is invoked, then
                    // we can get an exception. Ignore such cases.
                    if (display != null && !display.isDisposed())
                        throw e.throwable;
                }
                throw e;
            }
        }

    });

}

From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java

License:Open Source License

private void checkLicensingAlert(final int daysRemaining) {
    final int alertDays = SeeCodePlugin.getDefault().getPreferences().getInt(
            ISeeCodeConstants.PREF_LICENSE_EXPIRATION_DAYS, ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS);
    if (daysRemaining >= 0) {
        boolean alert = SeeCodePlugin.getDefault().getPreferences()
                .getBoolean(ISeeCodeConstants.PREF_LICENSE_EXPIRATION_ALERT, true);
        if (alertDays >= daysRemaining) {
            if (alert) {
                PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                    @Override//w w  w.ja  v  a 2  s  . co m
                    public void run() {
                        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                        String s;
                        if (daysRemaining == 0)
                            s = "after today";
                        else if (daysRemaining == 1)
                            s = "after tomorrow";
                        else
                            s = "in " + daysRemaining + " days";
                        MessageDialog dialog = new MessageDialog(shell, "License Expiration Alert", null, // accept
                                "Debugger license will expire " + s, MessageDialog.WARNING,
                                new String[] { IDialogConstants.OK_LABEL }, 0) {

                            @Override
                            protected Control createCustomArea(Composite parent) {
                                if (daysRemaining > 0 && daysRemaining <= 2) {
                                    Label label = new Label(parent, SWT.RIGHT);
                                    GridData data = new GridData();
                                    data.horizontalAlignment = GridData.END;
                                    data.grabExcessHorizontalSpace = true;
                                    label.setLayoutData(data);
                                    label.setText("You will be reminded again tomorrow.");
                                    setAlertDays(daysRemaining - 1);
                                    return label;
                                }
                                if (daysRemaining > 0) {
                                    Composite container = new Composite(parent, 0);
                                    GridData data = new GridData();
                                    data.horizontalAlignment = GridData.END;
                                    data.grabExcessHorizontalSpace = true;
                                    container.setLayoutData(data);
                                    container.setLayout(new GridLayout(3, false));
                                    Label label1 = new Label(container, SWT.LEFT);
                                    label1.setText("Remind me again when ");
                                    final Combo combo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
                                    Label label2 = new Label(container, SWT.LEFT);
                                    label2.setText(" days remain.");
                                    label2.setLayoutData(data);
                                    for (int i = Math.min(15, daysRemaining - 1); i >= 0; i--) {
                                        combo.add("" + i);
                                    }
                                    combo.select(0);
                                    setAlertDays(Integer.parseInt(combo.getItem(0)));
                                    combo.addSelectionListener(new SelectionListener() {

                                        @Override
                                        public void widgetDefaultSelected(SelectionEvent e) {
                                        }

                                        @Override
                                        public void widgetSelected(SelectionEvent e) {
                                            setAlertDays(Integer.parseInt(combo.getText()));
                                        }
                                    });
                                    return container;
                                }
                                return null;
                            }
                        };
                        if (dialog.open() == Window.OK) {
                            SeeCodePlugin.getDefault().getPreferences()
                                    .putInt(ISeeCodeConstants.PREF_LICENSE_EXPIRATION_DAYS, mAlertDays);
                        }
                    }
                });

            }
        } else if (daysRemaining > ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS
                && alertDays != ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS) {
            // License has been renewed. Reset things to default.
            restoreDefaultAlertDays();
        }
    } else if (alertDays != ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS) {
        // Evidently a permanent license; make sure we reset alert if he previously
        // had an expired one.
        restoreDefaultAlertDays();
    }
}

From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java

License:Open Source License

/**
 * Show an note box./*from  www.  jav a2 s  . c o m*/
 * (We use JFace ErrorDialog instead of MessageBox. The latter is done outside
 * of Java and the WindowTester framework loses control).
 * @param title
 * @param message
 */
public static void showNote(String title, String message) {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    MessageDialog dialog = new MessageDialog(shell, title, null, // accept
            // the
            // default
            // window
            // icon
            message, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
    dialog.setBlockOnOpen(false); // we want to be able to make box expire
    // ok is the default
    dialog.open();
    long expireTime = System.currentTimeMillis() + NOTE_TIME_OUT;
    Display display = shell.getDisplay();
    try {
        while (dialog.getShell() != null && !dialog.getShell().isDisposed()
                && System.currentTimeMillis() < expireTime) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    } finally {
        if (dialog.getShell() != null && !dialog.getShell().isDisposed()) {
            dialog.close();
        }
    }
}

From source file:com.archimatetool.editor.diagram.dialog.NewNestedRelationDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, Messages.NewNestedRelationDialog_3, false);
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * This is the method that is called everytime the selection in the outline
 * (treeviewer) changes.  //from  w  w  w  .j a v  a  2 s.c o  m
 */
protected void handleOutlineSelectionChanged() {
    PaletteEntry entry = getSelectedPaletteEntry();

    if (activeEntry == entry) {
        return;
    }

    if (errorMessage != null) {
        MessageDialog dialog = new MessageDialog(getShell(), PaletteMessages.ERROR, null,
                PaletteMessages.ABORT_PAGE_FLIPPING_MESSAGE + "\n" + errorMessage, //$NON-NLS-1$
                MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0);
        dialog.open();
        treeviewer.addPostSelectionChangedListener(pageFlippingPreventer);
    } else {
        setActiveEntry(entry);
    }
    updateActions();
}

From source file:com.arm.cmsis.pack.ui.wizards.RteWizardDialog.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Control contents = super.createContents(parent);
    Button finishButton = getButton(IDialogConstants.FINISH_ID);
    finishButton.setText(IDialogConstants.OK_LABEL);
    return contents;
}