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

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

Introduction

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

Prototype

int NO_ID

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

Click Source Link

Document

Button id for a "No" button (value 3).

Usage

From source file:org.eclipse.birt.report.designer.internal.ui.editors.schematic.tools.LibraryElementsToolHandleExtends.java

License:Open Source License

@Override
public boolean postHandleCreation() {
    Object model = getModel();//from  w w w. j a  v  a2 s . co m
    boolean isMove = false;
    if (needProcessDataItem(model)) {
        String prompt = ReportPlugin.getDefault().getPreferenceStore()
                .getString(ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE);

        MessageDialogWithToggle dialog;

        if (MessageDialogWithToggle.ALWAYS.equals(prompt)) {
            moveBindToHost((DataItemHandle) model);
            isMove = true;
        } else if ((prompt == null || MessageDialogWithToggle.PROMPT.equals(prompt))
                && ((dialog = MessageDialogWithToggle.openYesNoQuestion(UIUtil.getDefaultShell(),
                        Messages.getString("LibraryElementsToolHandleExtends_question"), //$NON-NLS-1$
                        Messages.getString("LibraryElementsToolHandleExtends_message"), //$NON-NLS-1$
                        Messages.getString("LibraryElementsToolHandleExtends_toggle"), //$NON-NLS-1$
                        false, ReportPlugin.getDefault().getPreferenceStore(),
                        ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE)) != null)) {
            if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
                moveBindToHost((DataItemHandle) model);
                isMove = true;
            }

            if (dialog.getToggleState()) {
                if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
                    ReportPlugin.getDefault().getPreferenceStore().setValue(
                            ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE, MessageDialogWithToggle.ALWAYS);
                } else if (dialog.getReturnCode() == IDialogConstants.NO_ID) {
                    ReportPlugin.getDefault().getPreferenceStore().setValue(
                            ReportPlugin.LIBRARY_MOVE_BINDINGS_PREFERENCE, MessageDialogWithToggle.NEVER);
                }
            }
        }
    }
    if (!isMove && model instanceof DataItemHandle) {
        DataItemHandle dataHandle = (DataItemHandle) model;
        Iterator iter = dataHandle.columnBindingsIterator();
        String resultColumnName = dataHandle.getResultSetColumn();
        ComputedColumnHandle activeBinding = null;
        while (iter.hasNext()) {
            ComputedColumnHandle computedColumnHandle = (ComputedColumnHandle) iter.next();
            if (computedColumnHandle.getName().equals(resultColumnName)) {
                Expression newExpression = (Expression) computedColumnHandle
                        .getExpressionProperty(ComputedColumn.EXPRESSION_MEMBER).getValue();
                if (newExpression == null || newExpression.getExpression() == null) {
                    activeBinding = computedColumnHandle;
                } else if (newExpression.getExpression() instanceof String
                        && ((String) newExpression.getExpression()).length() == 0) {
                    activeBinding = computedColumnHandle;
                }
                break;
            }
        }
        if (activeBinding != null) {
            DataColumnBindingDialog dialog = new DataColumnBindingDialog(false);
            dialog.setNeedPrompt(false);
            dialog.setInput(dataHandle, activeBinding);

            if (dialog.open() == Dialog.OK) {
                //do nothing now
            }
        }
    }
    return super.postHandleCreation();
}

From source file:org.eclipse.birt.report.item.crosstab.internal.ui.editors.model.CrosstabAdaptUtil.java

License:Open Source License

public static boolean needRemoveInvaildBindings(CrosstabReportItemHandle handle) {
    String preferenceData = PreferenceFactory.getInstance().getPreferences(CrosstabPlugin.getDefault())
            .getString(CrosstabPlugin.PREFERENCE_AUTO_DEL_BINDINGS);
    if (preferenceData == null || preferenceData.length() == 0
            || preferenceData.equals(MessageDialogWithToggle.PROMPT)) {
        MessageDialogWithToggle msgDlg = MessageDialogWithToggle.openYesNoQuestion(UIUtil.getDefaultShell(),
                Messages.getString("DeleteBindingDialog.Title"), //$NON-NLS-1$
                Messages.getString("DeleteBindingDialog.Message"), //$NON-NLS-1$
                Messages.getString("DeleteBindingDialog.ToggleMessage"), //$NON-NLS-1$
                false, null, null);/*from  w  w w  .  jav  a2  s.  co m*/

        if (msgDlg.getToggleState()) {
            String value = "";
            if (msgDlg.getReturnCode() == IDialogConstants.YES_ID) {
                value = MessageDialogWithToggle.ALWAYS;
            } else if (msgDlg.getReturnCode() == IDialogConstants.NO_ID) {
                value = MessageDialogWithToggle.NEVER;
            }
            PreferenceFactory.getInstance().getPreferences(CrosstabPlugin.getDefault())
                    .setValue(CrosstabPlugin.PREFERENCE_AUTO_DEL_BINDINGS, value);
        }
        if (msgDlg.getReturnCode() == IDialogConstants.YES_ID) {
            return true;
            // removeInvalidBindings( handle );
        } else if (msgDlg.getReturnCode() == IDialogConstants.NO_ID) {
            return false;
            // dothing
        }

    } else if (preferenceData != null && preferenceData.equals(MessageDialogWithToggle.ALWAYS)) {
        return true;
        // removeInvalidBindings( handle );
    }
    return false;
    // removeInvalidBindings(handle);
}

From source file:org.eclipse.cdt.core.testplugin.util.VerifyDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    _yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}

From source file:org.eclipse.cdt.core.testplugin.util.VerifyDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    if (IDialogConstants.YES_ID == buttonId) {
        setReturnCode(IDialogConstants.YES_ID);
        if (_testDialog.getShell() != null) {
            _testDialog.close();// w  w w.j av a 2s. c  om
        }
        close();
    } else if (IDialogConstants.NO_ID == buttonId) {
        handleFailure();
    }
}

From source file:org.eclipse.cdt.core.testplugin.util.VerifyDialog.java

License:Open Source License

@Override
public int open() {
    _failureText = "Testing dialog is required, use VerifyDialog::open(Dialog)";
    return IDialogConstants.NO_ID;
}

From source file:org.eclipse.cdt.core.testplugin.util.VerifyDialog.java

License:Open Source License

private void handleFailure() {
    IDialogTestPass test = _dialogTests[TEST_TYPE];
    StringBuffer text = new StringBuffer();
    String label = test.label();/*from   ww w .ja v a2s.com*/
    label = label.substring(0, label.indexOf("&")) + label.substring(label.indexOf("&") + 1);
    text.append(label).append(" failed on the ").append(SWT.getPlatform()).append(" platform:\n");

    String failureMessages[] = test.failureTexts();
    for (int i = 0; i < test.checkListTexts().size(); i++) {
        if (!_checkList[i].getSelection()) {
            text.append("- ").append(failureMessages[i]).append("\n");
        }
    }
    FailureDialog dialog = new FailureDialog(getShell());
    dialog.create();
    //String temp = text.toString();
    dialog.setText(text.toString());
    if (dialog.open() == IDialogConstants.OK_ID) {
        _failureText = dialog.toString();
        setReturnCode(IDialogConstants.NO_ID);
        if (_testDialog.getShell() != null) {
            _testDialog.close();
        }
        close();
    }
}

From source file:org.eclipse.cdt.make.internal.ui.dnd.MakeTargetDndUtil.java

License:Open Source License

/**
 * Overwrite Make Target dialog./*from w  ww .  ja v a2s.  c  o  m*/
 *
 * @param name - name of make target to display to a user.
 * @param shell - shell where to display the dialog.
 *
 * @return user's answer.
 */
private static int overwriteMakeTargetDialog(String name, Shell shell) {

    if (lastUserAnswer == IDialogConstants.YES_TO_ALL_ID || lastUserAnswer == IDialogConstants.NO_TO_ALL_ID
            || lastUserAnswer == RENAME_TO_ALL_ID) {

        return lastUserAnswer;
    }

    String labels[] = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
            MakeUIPlugin.getResourceString("MakeTargetDnD.button.rename"), //$NON-NLS-1$
            IDialogConstants.CANCEL_LABEL, };

    String title = MakeUIPlugin.getResourceString("MakeTargetDnD.title.overwriteTargetConfirm"); //$NON-NLS-1$
    String question = MessageFormat.format(
            MakeUIPlugin.getResourceString("MakeTargetDnD.message.overwriteTargetConfirm"), //$NON-NLS-1$
            new Object[] { name });
    String toggleApplyToAll = MakeUIPlugin.getResourceString("MakeTargetDnD.toggle.applyToAll"); //$NON-NLS-1$

    MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, question,
            MessageDialog.QUESTION, labels, 0, toggleApplyToAll, false);

    try {
        dialog.open();
        lastUserAnswer = dialog.getReturnCode();
        boolean toAll = dialog.getToggleState();
        if (toAll && lastUserAnswer == IDialogConstants.YES_ID) {
            lastUserAnswer = IDialogConstants.YES_TO_ALL_ID;
        } else if (toAll && lastUserAnswer == IDialogConstants.NO_ID) {
            lastUserAnswer = IDialogConstants.NO_TO_ALL_ID;
        } else if (toAll && lastUserAnswer == RENAME_ID) {
            lastUserAnswer = RENAME_TO_ALL_ID;
        }
    } catch (SWTException e) {
        MakeUIPlugin.log(e);
        lastUserAnswer = IDialogConstants.CANCEL_ID;
    }

    if (lastUserAnswer == SWT.DEFAULT) {
        // A window close returns SWT.DEFAULT, which has to be
        // mapped to a cancel
        lastUserAnswer = IDialogConstants.CANCEL_ID;
    }
    return lastUserAnswer;
}

From source file:org.eclipse.cdt.ui.testplugin.util.VerifyDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    _yesButton = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    _noButton = createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
}

From source file:org.eclipse.datatools.sqltools.sqleditor.internal.editor.SQLUpdater.java

License:Open Source License

/**
 * Enable syntax validation based on preference options and user's selection.
 * //  ww  w  .  jav a 2s . com
 * @return true means syntax validation is enabled.
 * @author lihuang
 */
private boolean enableSyntaxValidation() {
    if (_editor != null && _editor.getConnectionInfo() != null) {
        ISQLEditorConnectionInfo connInfo = _editor.getConnectionInfo();
        SQLDevToolsConfiguration conf = SQLToolsFacade.getConfiguration(_editor.getDatabaseIdentifier(),
                connInfo.getDatabaseVendorDefinitionId());
        SQLParser p = conf.getSQLService().getSQLParser();
        if (p == null || !p.isComplete()) {
            return false;
        }
    }
    IPreferenceStore preferenceStore = SQLEditorPlugin.getDefault().getPreferenceStore();

    boolean enableSyntaxValidation = true;
    boolean isMaxLineLimitation = preferenceStore.getBoolean(PreferenceConstants.SYNTAX_VALIDATION_MAX_LINE);
    // just return false if syntax validation is turned off.
    if (preferenceStore.getBoolean(PreferenceConstants.SYNTAX_VALIDATION) == false) {
        enableSyntaxValidation = false;
    } else if (isMaxLineLimitation) {

        // show prompt dialog when the number of lines is more than maximun number of lines.
        int lines = ((SQLEditor) _editor).getSV().getDocument().getNumberOfLines();
        int maximunLines = Integer
                .parseInt(preferenceStore.getString(PreferenceConstants.SYNTAX_VALIDATION_MAX_LINE_NUMBER));
        if (preferenceStore.getBoolean(PreferenceConstants.SHOW_DAILOG_FOR_SYNTAX_VALIDATION) == true) {
            if (lines >= maximunLines) {
                Shell shell = SQLEditorPlugin.getActiveWorkbenchShell();

                // Activate the shell if necessary so the prompt is visible
                if (shell.getMinimized()) {
                    shell.setMinimized(false);
                }
                MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell,
                        SQLEditorResources.SQLUpdate_dialog_title,
                        NLS.bind(SQLEditorResources.SQLUpdate_dialog_message,
                                (new Object[] { Integer.toString(maximunLines) })),
                        SQLEditorResources.SQLUpdate_dialog_toggle, false,
                        SQLEditorPlugin.getDefault().getPreferenceStore(),
                        PreferenceConstants.SHOW_DAILOG_FOR_SYNTAX_VALIDATION);
                if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
                    enableSyntaxValidation = false;
                } else if (dialog.getReturnCode() == IDialogConstants.NO_ID
                        && preferenceStore.getString(PreferenceConstants.SHOW_DAILOG_FOR_SYNTAX_VALIDATION)
                                .equals(MessageDialogWithToggle.NEVER)) {
                    enableSyntaxValidation = true;
                    preferenceStore.setValue(PreferenceConstants.SYNTAX_VALIDATION_MAX_LINE, false);
                } else {
                    enableSyntaxValidation = true;
                }
            }
        } else {
            if (lines >= maximunLines) {
                enableSyntaxValidation = false;
            } else {
                enableSyntaxValidation = true;
            }
        }

    }
    if (enableSyntaxValidation == false) {
        if (_fOutlinePage != null) {
            _fOutlinePage.update(null);
        }
        if (_annotationModel != null) {
            removeMarkers();
        }
        return false;
    } else {
        return true;
    }
}

From source file:org.eclipse.debug.internal.ui.actions.breakpoints.RemoveBreakpointAction.java

License:Open Source License

public void run(IAction action) {
    IStructuredSelection selection = getSelection();
    if (selection.isEmpty()) {
        return;/*from   w w w.  j  a  va  2s . c o  m*/
    }
    final Iterator itr = selection.iterator();
    final CoreException[] exception = new CoreException[1];
    IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) {
            ArrayList breakpointsToDelete = new ArrayList();
            ArrayList groupsToDelete = new ArrayList();
            boolean deleteAll = false;
            boolean deleteContainer = false;
            boolean prompted = false;
            while (itr.hasNext()) {
                Object next = itr.next();
                IBreakpoint breakpoint = (IBreakpoint) DebugPlugin.getAdapter(next, IBreakpoint.class);
                if (breakpoint != null) {
                    breakpointsToDelete.add(breakpoint);
                } else if (next instanceof IBreakpointContainer) {
                    //the the container is a workingset, ask if they want to delete it as well
                    IBreakpointContainer bpc = (IBreakpointContainer) next;
                    if (bpc.getCategory() instanceof WorkingSetCategory) {
                        IWorkingSet set = ((WorkingSetCategory) bpc.getCategory()).getWorkingSet();
                        if (!prompted) {
                            prompted = true;
                            DeleteWorkingsetsMessageDialog dialog = new DeleteWorkingsetsMessageDialog(
                                    getView().getSite().getShell(), ActionMessages.RemoveBreakpointAction_3,
                                    null, ActionMessages.RemoveBreakpointAction_4, MessageDialog.QUESTION,
                                    new String[] { ActionMessages.RemoveBreakpointAction_5,
                                            ActionMessages.RemoveBreakpointAction_6 },
                                    0);
                            if (dialog.open() == Window.CANCEL) {
                                return;
                            }
                            deleteAll = dialog.deleteAllBreakpoints();
                            deleteContainer = dialog.deleteWorkingset();
                        }
                        if (deleteContainer) {
                            groupsToDelete.add(set);
                        }
                    } else {
                        if (!prompted) {
                            IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
                            prompted = store.getBoolean(
                                    IDebugPreferenceConstants.PREF_PROMPT_REMOVE_BREAKPOINTS_FROM_CONTAINER);
                            if (prompted) {
                                MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoQuestion(
                                        getView().getSite().getShell(), ActionMessages.RemoveBreakpointAction_0,
                                        ActionMessages.RemoveBreakpointAction_1,
                                        ActionMessages.RemoveAllBreakpointsAction_3, !prompted, null, null);
                                if (mdwt.getReturnCode() == IDialogConstants.NO_ID) {
                                    deleteAll = false;
                                } else {
                                    store.setValue(
                                            IDebugPreferenceConstants.PREF_PROMPT_REMOVE_BREAKPOINTS_FROM_CONTAINER,
                                            !mdwt.getToggleState());
                                    deleteAll = true;
                                }
                            } else {
                                deleteAll = !prompted;
                            }
                        }
                    }
                    if (deleteAll) {
                        IBreakpoint[] breakpoints = bpc.getBreakpoints();
                        for (int i = 0; i < breakpoints.length; i++) {
                            breakpointsToDelete.add(breakpoints[i]);
                        }
                    }
                }
            }
            final IBreakpoint[] breakpoints = (IBreakpoint[]) breakpointsToDelete.toArray(new IBreakpoint[0]);
            final IWorkingSet[] sets = (IWorkingSet[]) groupsToDelete
                    .toArray(new IWorkingSet[groupsToDelete.size()]);
            if (breakpoints.length > 0) {
                ((BreakpointsView) getView()).preserveSelection(getSelection());
            }
            new Job(ActionMessages.RemoveBreakpointAction_2) {
                protected IStatus run(IProgressMonitor pmonitor) {
                    try {
                        Shell shell = getView() != null ? getView().getSite().getShell() : null;
                        DebugUITools.deleteBreakpoints(breakpoints, shell, pmonitor);

                        for (int i = 0; i < sets.length; i++) {
                            PlatformUI.getWorkbench().getWorkingSetManager().removeWorkingSet(sets[i]);
                        }
                        return Status.OK_STATUS;
                    } catch (CoreException e) {
                        DebugUIPlugin.log(e);
                    }
                    return Status.CANCEL_STATUS;
                }
            }.schedule();
        }
    };
    try {
        ResourcesPlugin.getWorkspace().run(runnable, null, 0, null);
    } catch (CoreException ce) {
        exception[0] = ce;
    }
    if (exception[0] != null) {
        IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
        if (window != null) {
            DebugUIPlugin.errorDialog(window.getShell(),
                    ActionMessages.RemoveBreakpointAction_Removing_a_breakpoint_4,
                    ActionMessages.RemoveBreakpointAction_Exceptions_occurred_attempting_to_remove_a_breakpoint__5,
                    exception[0]);
        } else {
            DebugUIPlugin.log(exception[0]);
        }
    }
}