Example usage for org.eclipse.jface.dialogs MessageDialog WARNING

List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog WARNING.

Prototype

int WARNING

To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.

Click Source Link

Document

Constant for the warning image, or a simple dialog with the warning image and a single OK button (value 4).

Usage

From source file:org.eclipse.mylyn.internal.tasks.ui.preferences.TasksUiPreferencePage.java

License:Open Source License

private boolean checkForExistingTasklist(String dir) {
    File newDataFolder = new File(dir);
    if (!newDataFolder.exists() && !newDataFolder.mkdirs()) {
        MessageDialog.openWarning(getControl().getShell(), Messages.TasksUiPreferencePage_Change_data_directory,
                Messages.TasksUiPreferencePage_Destination_folder_cannot_be_created);
        return false;
    }/*from w w  w . ja  va2  s. c o m*/

    MessageDialog dialogConfirm = new MessageDialog(null,
            Messages.TasksUiPreferencePage_Confirm_Task_List_data_directory_change, null,
            Messages.TasksUiPreferencePage_A_new_empty_Task_List_will_be_created_in_the_chosen_directory_if_one_does_not_already_exists,
            MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL },
            IDialogConstants.CANCEL_ID);
    int taskDataDirectoryAction = dialogConfirm.open();
    if (taskDataDirectoryAction != IDialogConstants.OK_ID) {
        return false;
    }

    for (TaskEditor taskEditor : TasksUiInternal.getActiveRepositoryTaskEditors()) {
        TasksUiInternal.closeTaskEditorInAllPages(taskEditor.getTaskEditorInput().getTask(), true);
    }
    return true;
}

From source file:org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal.java

License:Open Source License

private static void displayStatus(Shell shell, final String title, final IStatus status,
        boolean showLinkToErrorLog) {
    // avoid blocking ui when in test mode
    if (CoreUtil.TEST_MODE) {
        StatusHandler.log(status);/*w ww. j  a  va2s.c  om*/
        return;
    }

    if (status instanceof RepositoryStatus && ((RepositoryStatus) status).isHtmlMessage()) {
        WebBrowserDialog.openAcceptAgreement(shell, title, status.getMessage(),
                ((RepositoryStatus) status).getHtmlMessage());
    } else {
        String message = status.getMessage();
        if (message == null || message.trim().length() == 0) {
            message = Messages.TasksUiInternal_An_unknown_error_occurred;
        }
        if (message.length() > 256) {
            message = message.substring(0, 256) + "..."; //$NON-NLS-1$
        }
        if (showLinkToErrorLog) {
            message += "\n\n" + Messages.TasksUiInternal_See_error_log_for_details; //$NON-NLS-1$
        }
        switch (status.getSeverity()) {
        case IStatus.CANCEL:
        case IStatus.INFO:
            createDialog(shell, title, message, MessageDialog.INFORMATION).open();
            break;
        case IStatus.WARNING:
            createDialog(shell, title, message, MessageDialog.WARNING).open();
            break;
        case IStatus.ERROR:
        default:
            createDialog(shell, title, message, MessageDialog.ERROR).open();
            break;
        }
    }
}

From source file:org.eclipse.mylyn.reviews.connector.ui.EmfRepositorySettingsPage.java

License:Open Source License

private void create() {
    FileDialog browseDialog = new FileDialog(getShell(), SWT.SAVE);
    String fileName = null;// w w w  .  j  av  a2s. c  om
    String filterPath;
    File currentLocation = new File(uriEditor.getText());
    if (currentLocation.exists()) {
        String currentPath = currentLocation.getAbsolutePath();
        if (currentLocation.isFile()) {
            filterPath = StringUtils.substringBeforeLast(currentPath, File.separator);
            fileName = StringUtils.substringAfterLast(currentPath, File.separator);
        } else {
            filterPath = currentPath;
        }
    } else {
        IPath configurationDir = ConfigurationScope.INSTANCE.getLocation();
        filterPath = configurationDir.toString();
    }
    browseDialog.setFilterPath(filterPath);
    if (fileName == null) {
        fileName = StringUtils.deleteWhitespace(labelEditor.getText());
    }
    if (fileName != null) {
        browseDialog.setFileName(fileName);
    }
    browseDialog.setFilterExtensions(getConnectorUi().getFileNameExtensions());
    String browseResult = browseDialog.open();
    if (browseResult != null) {
        File checkFile = new File(browseResult);
        if (checkFile.exists()) {
            MessageDialog dialog = new MessageDialog(getShell(), "Replace Existing?", null,
                    checkFile.getName() + " already exists. Are you sure you want to replace it?",
                    MessageDialog.WARNING, new String[] { "Yes", "No" }, 1);
            int open = dialog.open();
            if (open == 1) {
                return;
            }
        }
        ResourceSet resourceSet = new ResourceSetImpl();
        URI fileURI = URI.createFileURI(browseResult);
        Resource resource = resourceSet.createResource(fileURI);
        EReference containmentRef = getConnector().getContainmentReference();
        EClass eContainingClass = containmentRef.getEContainingClass();
        EObject rootObject = eContainingClass.getEPackage().getEFactoryInstance().create(eContainingClass);
        if (rootObject != null) {
            resource.getContents().add(rootObject);
            rootObject.eSet(getConnector().getContentsNameAttribute(), labelEditor.getText());
            Map<Object, Object> options = new HashMap<Object, Object>();
            try {
                resource.save(options);
            } catch (IOException e) {
                StatusManager.getManager().handle(
                        new Status(IStatus.WARNING, EmfUiPlugin.PLUGIN_ID, "Couldn't create repository."));
                return;
            }
        }

        uriEditor.setText(browseResult);
    }
}

From source file:org.eclipse.mylyn.reviews.r4e.report.internal.util.Popup.java

License:Open Source License

/**
 * Display a warning message dialog// w w  w.ja  va2s .c om
 * 
 * @param aTitle
 *            String
 * @param aMessage
 *            String
 * @return index int
 */
public final static int displayWarningMessageDialog(final String aTitle, final String aMessage) {

    MessageDialog dialog = new MessageDialog(null, // Shell
            aTitle, // Dialog title
            null, // Dialog title image message
            aMessage, // Dialog message
            MessageDialog.WARNING, // Dialog type
            FWarningButtonLabels, // Dialog button labels
            0 // Default index (selection)
    );

    return dialog.open();
}

From source file:org.eclipse.mylyn.reviews.r4e.ui.internal.utils.AnomalyUtils.java

License:Open Source License

/**
 * Method displayDifferentFileVersionDialog.
 * //from ww w. j  a  va2s .co  m
 * @param aTargetFileVersion
 *            R4EFileVersion
 * @param aTempFileContext
 *            R4EUIFileContext
 * @return MessageDialog
 */
private static MessageDialog displayDifferentFileVersionDialog(R4EFileVersion aTargetFileVersion,
        R4EUIFileContext aTempFileContext) {

    //The file exist with a different file version
    final String wsFileName = aTargetFileVersion.getRepositoryPath();
    final String wsFileVersion = aTargetFileVersion.getVersionID();
    final String riFileName = aTempFileContext.getTargetFileVersion().getRepositoryPath();
    final String riFileVersion = aTempFileContext.getTargetFileVersion().getVersionID();

    final StringBuilder sb = new StringBuilder();
    sb.append(MESSAGE_STR + R4EUIConstants.LINE_FEED + R4EUIConstants.LINE_FEED);
    sb.append(FILE_VERSION_STR);
    sb.append(riFileName + R4EUIConstants.LINE_FEED);
    sb.append(VERSION_STR);
    sb.append(riFileVersion + R4EUIConstants.LINE_FEED + R4EUIConstants.LINE_FEED);
    sb.append(WORKSPACE_FILE_STR);
    sb.append(wsFileName + R4EUIConstants.LINE_FEED);
    sb.append(VERSION_STR);
    sb.append(wsFileVersion + R4EUIConstants.LINE_FEED + R4EUIConstants.LINE_FEED);
    sb.append(QUESTION_STR);

    final MessageDialog dialog = new MessageDialog(null, // Shell
            QUESTION_TITLE, // Dialog title
            null, // Dialog title image message
            sb.toString(), // Dialog message
            MessageDialog.WARNING, // Dialog type
            WARNING_BUTTONS_LABELS, // Dialog button labels
            Window.OK // Default index (selection)
    );

    return dialog;
}

From source file:org.eclipse.nebula.snippets.grid.viewer.GridViewerSnippetDisposePerformance.java

License:Open Source License

public GridViewerSnippetDisposePerformance(final Shell shell, boolean createButtons) {
    final GridTableViewer v = new GridTableViewer(new Grid(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL) {
        @Override/*from w ww. j  a v  a  2 s. c o m*/
        protected void onKeyDown(Event e) {
            super.onKeyDown(e);
            System.out.println(e.keyCode + " Called");
        }
    });
    v.setLabelProvider(new MyLabelProvider());
    v.setContentProvider(new MyContentProvider());
    v.getGrid().setCellSelectionEnabled(true);

    v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getGrid()), new TextCellEditor(v.getGrid()) });
    v.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            return true;
        }

        public Object getValue(Object element, String property) {
            if (element == null)
                return "Element is null";
            return "Column " + property + " => " + element.toString();
        }

        public void modify(Object element, String property, Object value) {

        }

    });

    v.setColumnProperties(new String[] { "1", "2" });

    ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v) {

        @Override
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                    || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                    || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                            && event.keyCode == SWT.CR);
        }
    };

    GridViewerEditor.create(v, actSupport,
            ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
                    | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);

    for (int i = 0; i < NUM_COLUMNS; i++) {
        createColumn(v, "Column " + i);
    }
    if (createButtons) {
        Composite buttons = new Composite(shell, SWT.NONE);
        buttons.setLayout(new RowLayout());

        final Button remove3 = new Button(buttons, SWT.NONE);
        remove3.setText("remove row with index 3");
        final String restore = "restore grid";
        remove3.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                //               button.dispose();
                try {
                    v.getGrid().remove(3);
                } catch (java.lang.IllegalArgumentException ie) {
                    new MessageDialog(shell, "IndexOutOfBound error", null,
                            "Restore the grid with button \"" + restore + "\"", MessageDialog.WARNING,
                            new String[] { "Ok" }, 0).open();
                }

                shell.layout();
            }
        });

        final Button add3 = new Button(buttons, SWT.NONE);
        add3.setText("add row with index 3");
        add3.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                GridItem gridItem = new GridItem(v.getGrid(), SWT.NONE, 3);
                gridItem.setText(0, "Added in 3");
                shell.layout();
            }
        });
        final Button addColumn1 = new Button(buttons, SWT.NONE);
        addColumn1.setText("add column in 1");
        addColumn1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                new GridColumn(v.getGrid(), SWT.NONE, 1);
                shell.layout();
            }
        });
        final Button removeColumn = new Button(buttons, SWT.NONE);
        removeColumn.setText("remove first column");
        removeColumn.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                //               button.dispose();
                try {
                    v.getGrid().getColumn(0).dispose();
                    v.getGrid().redraw();
                    v.getGrid().layout();
                } catch (java.lang.IllegalArgumentException ie) {
                    new MessageDialog(shell, "IndexOutOfBound error", null,
                            "Restore the grid with button \"" + restore + "\"", MessageDialog.WARNING,
                            new String[] { "Ok" }, 0).open();
                }

                shell.layout();
            }
        });
        final Button hideColumn = new Button(buttons, SWT.NONE);
        hideColumn.setText("hide first column");
        hideColumn.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                try {
                    GridColumn[] columns = v.getGrid().getColumns();
                    for (GridColumn gridColumn : columns) {
                        if (gridColumn.isVisible()) {
                            gridColumn.setVisible(false);
                            break;
                        }
                    }
                } catch (java.lang.IllegalArgumentException ie) {
                    new MessageDialog(shell, "IndexOutOfBound error", null,
                            "Restore the grid with button \"" + restore + "\"", MessageDialog.WARNING,
                            new String[] { "Ok" }, 0).open();
                }
                shell.layout();
            }
        });
        final Button manualDeselect = new Button(buttons, SWT.NONE);
        manualDeselect.setText("Manual Deselect");
        manualDeselect.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                Grid grid = v.getGrid();
                Point focus = grid.getFocusCell();
                int[] selected = grid.getSelectionIndices();
                grid.deselect(selected);
                grid.remove(selected);
                while (focus.y >= grid.getItemCount())
                    --focus.y;
                if (focus.y >= 0) {
                    grid.setFocusItem(grid.getItem(focus.y));
                    grid.setFocusColumn(grid.getColumn(focus.x));
                    grid.setCellSelection(focus);
                }
            }
        });
        final Button addColumn = new Button(buttons, SWT.NONE);
        addColumn.setText("add column");
        addColumn.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                //               button.dispose();
                try {
                    createColumn(v, "Added");
                } catch (java.lang.IllegalArgumentException ie) {
                    new MessageDialog(shell, "IndexOutOfBound error", null,
                            "Restore the grid with button \"" + restore + "\"", MessageDialog.WARNING,
                            new String[] { "Ok" }, 0).open();
                }

                shell.layout();
            }
        });
        final Button changeFont = new Button(buttons, SWT.NONE);
        changeFont.setText("Change Default");
        changeFont.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                v.getGrid().setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
                v.getGrid().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
                v.getGrid().setFont(
                        registry.getItalic(Display.getCurrent().getSystemFont().getFontData()[0].getName()));
                shell.layout();
            }
        });
        Button exportGrid = new Button(buttons, SWT.NONE);
        exportGrid.setText("Export Grid");
        exportGrid.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                try {
                    if (v.getGrid().isDisposed())
                        return;
                    FileDialog fileDialog = new FileDialog(shell);
                    fileDialog.setFilterExtensions(new String[] { "*.xml" });
                    String open = fileDialog.open();
                    if (open != null) {
                        open = open.endsWith(".xml") ? open : open + ".xml";
                        FileOutputStream outputStream = new FileOutputStream(new File(open));
                        try {
                            GridUtils.gridToXml(v.getGrid(), outputStream);
                            new MessageDialog(shell, "Success", null, "Exported in " + open,
                                    MessageDialog.INFORMATION, new String[] { "Great!" }, 1).open();
                        } catch (ParserConfigurationException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        } catch (TransformerException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        } finally {
                            try {
                                outputStream.close();
                            } catch (IOException e1) {
                                e1.printStackTrace();
                            }
                        }
                    }
                } catch (FileNotFoundException e1) {
                    e1.printStackTrace();
                }
            }
        });
        final Button restoreButton = new Button(buttons, SWT.NONE);
        restoreButton.setText(restore);
        restoreButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                GridColumn[] columns = v.getGrid().getColumns();
                for (GridColumn gridColumn : columns) {
                    gridColumn.dispose();
                }
                for (int i = 0; i < NUM_COLUMNS; i++) {
                    createColumn(v, "Column " + i);
                }
                v.setInput(createModel());
                v.getGrid().setItemCount(10);
                v.getGrid().redraw();
                v.getGrid().layout();
                shell.layout();
            }
        });
        final Button enableDisableKeyListenerButton = new Button(buttons, SWT.NONE);
        enableDisableKeyListenerButton.setText("Disable default key listener");
        enableDisableKeyListenerButton.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                if (enable) {
                    v.getGrid().disableDefaultKeyListener();
                    enable = false;
                    enableDisableKeyListenerButton.setText("Enable default key listener");
                } else {
                    v.getGrid().enableDefaultKeyListener();
                    enable = true;
                    enableDisableKeyListenerButton.setText("Disable default key listener");
                }
            }
        });
        Button gcButton = new Button(buttons, SWT.NONE);
        gcButton.setText("gc");
        gcButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDown(MouseEvent e) {
                System.gc();
            }
        });

    }
    MyModel[] model = createModel();
    v.setInput(model);
    v.getGrid().setLinesVisible(true);
    v.getGrid().setHeaderVisible(true);
}

From source file:org.eclipse.nebula.snippets.grid.viewer.GridViewerSnippetDisposeTreeTest.java

License:Open Source License

public GridViewerSnippetDisposeTreeTest(final Shell shell) {
    final GridTreeViewer v = new GridTreeViewer(shell);

    Composite buttons = new Composite(shell, SWT.NONE);
    buttons.setLayout(new RowLayout());
    final Button remove3 = new Button(buttons, SWT.NONE);
    remove3.setText("remove row with index 3");
    final String restore = "restore grid";
    remove3.addMouseListener(new MouseAdapter() {
        @Override//from w w  w.  j a  v  a  2 s  .c o  m
        public void mouseDown(MouseEvent e) {
            //               button.dispose();
            try {
                v.getGrid().remove(3);
            } catch (java.lang.IllegalArgumentException ie) {
                new MessageDialog(shell, "IndexOutOfBound error", null,
                        "Restore the grid with button \"" + restore + "\"", MessageDialog.WARNING,
                        new String[] { "Ok" }, 0).open();
            }

            shell.layout();
        }
    });
    final Button add3 = new Button(buttons, SWT.NONE);
    add3.setText("add row with index 3");
    add3.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            GridItem gridItem = new GridItem(v.getGrid(), SWT.NONE, 3);
            gridItem.setText(0, "Added in 3");
            shell.layout();
        }
    });
    final Button addColumn1 = new Button(buttons, SWT.NONE);
    addColumn1.setText("add column in 1");
    addColumn1.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            new GridColumn(v.getGrid(), SWT.NONE, 1);
            shell.layout();
        }
    });
    final Button removeColumn = new Button(buttons, SWT.NONE);
    removeColumn.setText("remove first column");
    removeColumn.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            //               button.dispose();
            try {
                v.getGrid().getColumn(0).dispose();
                v.getGrid().redraw();
                v.getGrid().layout();
            } catch (java.lang.IllegalArgumentException ie) {
                new MessageDialog(shell, "IndexOutOfBound error", null,
                        "Restore the grid with button \"" + restore + "\"", MessageDialog.WARNING,
                        new String[] { "Ok" }, 0).open();
            }

            shell.layout();
        }
    });
    final Button addColumn = new Button(buttons, SWT.NONE);
    addColumn.setText("add column");
    addColumn.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            //               button.dispose();
            try {
                createColumn(v, "Added");
            } catch (java.lang.IllegalArgumentException ie) {
                new MessageDialog(shell, "IndexOutOfBound error", null,
                        "Restore the grid with button \"" + restore + "\"", MessageDialog.WARNING,
                        new String[] { "Ok" }, 0).open();
            }

            shell.layout();
        }
    });
    Button exportGrid = new Button(buttons, SWT.NONE);
    exportGrid.setText("Export Grid");
    exportGrid.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            try {
                if (v.getGrid().isDisposed())
                    return;
                FileDialog fileDialog = new FileDialog(shell);
                fileDialog.setFilterExtensions(new String[] { "*.xml" });
                String open = fileDialog.open();
                if (open != null) {
                    open = open.endsWith(".xml") ? open : open + ".xml";
                    FileOutputStream outputStream = new FileOutputStream(new File(open));
                    try {
                        GridUtils.gridToXml(v.getGrid(), outputStream);
                        new MessageDialog(shell, "Success", null, "Exported in " + open,
                                MessageDialog.INFORMATION, new String[] { "Great!" }, 1).open();
                    } catch (ParserConfigurationException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (TransformerException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } finally {
                        try {
                            outputStream.close();
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }
                    }
                }
            } catch (FileNotFoundException e1) {
                e1.printStackTrace();
            }
        }
    });
    final Button changeFont = new Button(buttons, SWT.NONE);
    changeFont.setText("Change Default");
    changeFont.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            v.getGrid().setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
            v.getGrid().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
            v.getGrid().setFont(
                    registry.getItalic(Display.getCurrent().getSystemFont().getFontData()[0].getName()));
            shell.layout();
        }
    });
    final Button restoreButton = new Button(buttons, SWT.NONE);
    restoreButton.setText(restore);
    restoreButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            GridColumn[] columns = v.getGrid().getColumns();
            for (GridColumn gridColumn : columns) {
                gridColumn.dispose();
            }
            revertGrid(v);
            shell.layout();
        }
    });
    revertGrid(v);
}

From source file:org.eclipse.nebula.widgets.nattable.edit.config.DialogErrorHandling.java

License:Open Source License

/**
 * Shows a warning dialog if the conversion or the validation returned an error message.
 * Otherwise nothing happens./*from  w  w  w  .j  av  a 2  s  .c  om*/
 */
protected void showWarningDialog(String dialogMessage, String dialogTitle) {
    if (!isWarningDialogActive()) {
        //conversion/validation failed - so open dialog with error message

        if (dialogMessage != null) {
            String[] buttonLabels = this.allowCommit
                    ? new String[] { changeButtonLabel, discardButtonLabel, commitButtonLabel }
                    : new String[] { changeButtonLabel, discardButtonLabel };
            MessageDialog warningDialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle,
                    null, dialogMessage, MessageDialog.WARNING, buttonLabels, 0);

            //if discard was selected close the editor
            int returnCode = warningDialog.open();
            if (returnCode == 1) {
                this.editor.close();
            }
            //if commit was selected, commit the value by skipping the validation
            else if (returnCode == 2) {
                this.editor.commit(MoveDirectionEnum.NONE, true, true);
            }
        }
    }
}

From source file:org.eclipse.nebula.widgets.nattable.examples.examples._110_Editing.CrossValidationGridExample.java

License:Open Source License

@Override
protected void showWarningDialog(String dialogMessage, String dialogTitle) {
    if (!isWarningDialogActive()) {
        //conversion/validation failed - so open dialog with error message

        if (dialogMessage != null) {
            MessageDialog warningDialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle,
                    null, dialogMessage, MessageDialog.WARNING,
                    new String[] { getChangeButtonLabel(), getDiscardButtonLabel(), "Commit" }, 0);

            //if discard was selected close the editor
            int returnCode = warningDialog.open();
            if (returnCode == 1) {
                this.editor.close();
            } else if (returnCode == 2) {
                this.editor.commit(MoveDirectionEnum.NONE, true, true);
            }// w  ww.jav a 2s .c  o m
        }
    }
}

From source file:org.eclipse.nebula.widgets.nattable.examples._400_Configuration._440_Editing._4451_CrossValidationGridExample.java

License:Open Source License

@Override
protected void showWarningDialog(String dialogMessage, String dialogTitle) {
    if (!isWarningDialogActive()) {
        // conversion/validation failed - so open dialog with error message

        if (dialogMessage != null) {
            MessageDialog warningDialog = new MessageDialog(Display.getCurrent().getActiveShell(), dialogTitle,
                    null, dialogMessage, MessageDialog.WARNING,
                    new String[] { getChangeButtonLabel(), getDiscardButtonLabel(), "Commit" }, 0);

            // if discard was selected close the editor
            int returnCode = warningDialog.open();
            if (returnCode == 1) {
                this.editor.close();
            } else if (returnCode == 2) {
                this.editor.commit(MoveDirectionEnum.NONE, true, true);
            }/*from w  ww  . ja  va2 s .c o  m*/
        }
    }
}