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

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

Introduction

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

Prototype

int ERROR

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

Click Source Link

Document

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

Usage

From source file:org.jboss.tools.browsersim.eclipse.launcher.ExternalProcessLauncher.java

License:Open Source License

public static void showErrorDialog(final String programName) {
    Display.getDefault().asyncExec(new Runnable() {

        @Override/* w  w  w.ja v  a2s. c  o  m*/
        public void run() {
            Shell shell = Display.getDefault().getActiveShell();
            if (shell == null) {
                shell = Display.getDefault().getShells()[0]; // Hot fix for gtk3 
            }
            BrowserSimErrorDialog e = new BrowserSimErrorDialog(shell, Messages.ExternalProcessLauncher_ERROR,
                    shell.getDisplay().getSystemImage(SWT.ICON_ERROR), programName, MessageDialog.ERROR,
                    new String[] { IDialogConstants.OK_LABEL }, 0);
            e.open();
        }
    });
}

From source file:org.jboss.tools.common.model.ui.dialog.test.MessageAndCheckboxDialogTest.java

License:Open Source License

public void testDialogSingleCheckBox() {
    Properties properties = new Properties();
    properties.put(MessageAndCheckboxDialog.MESSAGE, "Message");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE, "Checkbox message");
    properties.put(MessageAndCheckboxDialog.CHECKED, Boolean.TRUE);
    properties.put(MessageAndCheckboxDialog.BUTTONS, new String[] { " B1", "B2" });
    MessageAndCheckboxDialog dialog = new MessageAndCheckboxDialog(Display.getCurrent().getActiveShell(),
            "title", MessageDialog.ERROR, properties);
    dialog.setBlockOnOpen(false);//from   w  w  w . java  2 s .  c om
    dialog.open();
    dialog.close();
}

From source file:org.jboss.tools.common.model.ui.dialog.test.MessageAndCheckboxDialogTest.java

License:Open Source License

public void testDialogMultiCheckBox() {
    Properties properties = new Properties();
    properties.put(MessageAndCheckboxDialog.MESSAGE, "Message");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE, "Checkbox message");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE + "_1", "Checkbox message1");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE + "_2", "Checkbox message2");
    properties.put(MessageAndCheckboxDialog.CHECKED, Boolean.TRUE);
    properties.put(MessageAndCheckboxDialog.CHECKED + "_1", Boolean.TRUE);
    properties.put(MessageAndCheckboxDialog.CHECKED + "_2", Boolean.TRUE);
    properties.put(MessageAndCheckboxDialog.SEPARATOR + "_" + 1, "5");
    properties.put(MessageAndCheckboxDialog.SEPARATOR + "_" + 2, "5");
    MessageAndCheckboxDialog dialog = new MessageAndCheckboxDialog(Display.getCurrent().getActiveShell(),
            "title", MessageDialog.ERROR, properties);
    dialog.setBlockOnOpen(false);/* w  w w.  j  av a 2s .  c  o m*/
    dialog.open();
    dialog.close();
}

From source file:org.jboss.tools.common.model.ui.dialog.test.MessageAndCheckboxDialogTest.java

License:Open Source License

public void testDialogMultiCheckBoxNoSeparator() {
    Properties properties = new Properties();
    properties.put(MessageAndCheckboxDialog.MESSAGE, "Message");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE, "Checkbox message");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE + "_1", "Checkbox message1");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE + "_2", "Checkbox message2");
    properties.put(MessageAndCheckboxDialog.CHECKED, Boolean.TRUE);
    properties.put(MessageAndCheckboxDialog.CHECKED + "_1", Boolean.TRUE);
    properties.put(MessageAndCheckboxDialog.CHECKED + "_2", Boolean.TRUE);
    MessageAndCheckboxDialog dialog = new MessageAndCheckboxDialog(Display.getCurrent().getActiveShell(),
            "title", MessageDialog.ERROR, properties);
    dialog.setBlockOnOpen(false);//w  ww.j  a va2s. c  o  m
    dialog.open();
    dialog.close();
}

From source file:org.jboss.tools.common.model.ui.dialog.test.MessageAndCheckboxDialogTest.java

License:Open Source License

/**
 * Test method for {@link org.jboss.tools.common.model.ui.dialog.MessageAndCheckboxDialog#buttonPressed(int)}.
 *///ww  w .j  a v a  2 s .  c  om
public void testButtonPressed() {
    Properties properties = new Properties();
    properties.put(MessageAndCheckboxDialog.MESSAGE, "Message");
    properties.put(MessageAndCheckboxDialog.CHECKBOX_MESSAGE, "Checkbox message");
    properties.put(MessageAndCheckboxDialog.CHECKED, Boolean.TRUE);
    MessageAndCheckboxDialogWrapperTest dialog = new MessageAndCheckboxDialogWrapperTest(
            Display.getCurrent().getActiveShell(), "title", MessageDialog.ERROR, properties);
    dialog.setBlockOnOpen(false);
    dialog.open();
    dialog.buttonPressed(MessageAndCheckboxDialog.OK);
    assertEquals(dialog.getReturnCode(), Window.OK);

    dialog = new MessageAndCheckboxDialogWrapperTest(Display.getCurrent().getActiveShell(), "title",
            MessageDialog.ERROR, properties);
    dialog.setBlockOnOpen(false);
    dialog.open();
    dialog.buttonPressed(MessageAndCheckboxDialog.CANCEL);
    assertEquals(dialog.getReturnCode(), Window.CANCEL);
}

From source file:org.jboss.tools.common.model.ui.wizards.one.ServiceDialogImpl.java

License:Open Source License

private int getEclipseType(int type) {
    if (type == ERROR)
        return MessageDialog.ERROR;
    if (type == MESSAGE)
        return MessageDialog.INFORMATION;
    if (type == WARNING)
        return MessageDialog.WARNING;
    if (type == QUESTION)
        return MessageDialog.QUESTION;
    return MessageDialog.NONE;
}

From source file:org.jboss.tools.common.ui.widget.editor.SwtFieldEditorFactory.java

License:Open Source License

/**
 * //  w  w  w  . j  a v a  2  s .c  o  m
 */
public ButtonFieldEditor.ButtonPressedAction createNotImplementedYetAction(String buttonName) {
    return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
        @Override
        public void run() {
            new MessageDialog(Display.getCurrent().getActiveShell(),
                    CommonUIMessages.SWT_FIELD_EDITOR_FACTORY_ERROR, null,
                    CommonUIMessages.SWT_FIELD_EDITOR_FACTORY_NOT_IMPLEMENTED_YET, MessageDialog.ERROR,
                    new String[] { CommonUIMessages.SWT_FIELD_EDITOR_FACTORY_OK }, 1).open();
        }
    };
}

From source file:org.jboss.tools.openshift.internal.ui.handler.AbstractOpenShiftCliHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    String location = OCBinary.getInstance().getLocation();
    if (StringUtils.isBlank(location)) {

        final MessageDialog dialog = new MessageDialog(HandlerUtil.getActiveShell(event),
                "Unknown executable location", null,
                "The OpenShift Client '" + OCBinary.getInstance().getName() + "' executable can not be found.",
                MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {
            @Override/* ww w.  j  a  v a  2 s  .c o m*/
            protected Control createCustomArea(Composite parent) {
                Composite container = new Composite(parent, SWT.NONE);
                GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container);
                GridLayoutFactory.fillDefaults().applyTo(container);
                Link link = new Link(container, SWT.WRAP);
                link.setText("You must set the executable location in the <a>OpenShift 3 preferences</a>.");
                link.addSelectionListener(new OpenPreferencesListener(this));
                container.setFocus();
                return container;
            }
        };
        dialog.open();
        return null;
    }
    handleEvent(event);
    return null;
}

From source file:org.jboss.tools.smooks.configuration.editors.SmooksReaderFormPage.java

License:Open Source License

protected void createInputDataSection(FormToolkit toolkit, Composite parent) {
    Section section = toolkit.createSection(parent,
            Section.TITLE_BAR | Section.DESCRIPTION | Section.TWISTIE | Section.EXPANDED);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    section.setLayoutData(gd);/*from  ww w. j  ava  2s .  co m*/
    section.setText(Messages.SmooksReaderFormPage_InputDataSectionTitle);
    section.setDescription(Messages.SmooksReaderFormPage_InputDataSectionDes);
    FillLayout flayout = new FillLayout();
    section.setLayout(flayout);

    Composite mainComposite = toolkit.createComposite(section, SWT.NONE);
    GridLayout gl = new GridLayout();
    gl.numColumns = 2;
    mainComposite.setLayout(gl);
    section.setClient(mainComposite);

    Composite tableComposite = toolkit.createComposite(mainComposite, SWT.NONE);
    FillLayout fillLayout = new FillLayout();
    fillLayout.marginHeight = 1;
    fillLayout.marginWidth = 1;
    gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 70;
    tableComposite.setLayoutData(gd);
    tableComposite.setBackground(GraphicsConstants.BORDER_CORLOR);
    tableComposite.setLayout(fillLayout);

    inputDataViewer = CheckboxTableViewer.newCheckList(tableComposite, SWT.MULTI | SWT.FULL_SELECTION);
    // inputDataViewer.set
    inputDataViewer.setCheckStateProvider(new ICheckStateProvider() {

        public boolean isGrayed(Object element) {
            return isIncorrectInputType((InputType) element);
        }

        public boolean isChecked(Object element) {
            if (element instanceof InputType) {
                return ((InputType) element).isActived();
            }
            return false;
        }
    });
    inputDataViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (lockCheck)
                return;
            boolean checked = event.getChecked();
            InputType inputType = (InputType) event.getElement();
            if (isIncorrectInputType(inputType)) {
                lockCheck = true;
                inputDataViewer.setChecked(inputType, false);
                lockCheck = false;
                return;
            }
            CompoundCommand compoundCommand = new CompoundCommand();
            if (checked) {
                ParamType param = SmooksUIUtils.getInputTypeAssociatedParamType(inputType,
                        getSmooksConfigResourceList());
                if (param != null) {
                    inputType.setActived(checked);
                    String value = SmooksModelUtils.INPUT_ACTIVE_TYPE;
                    Command c = SetCommand.create(getEditingDomain(), param,
                            SmooksPackage.Literals.PARAM_TYPE__TYPE, value);
                    if (c.canExecute())
                        compoundCommand.append(c);
                }

                Object[] checkedObjects = inputDataViewer.getCheckedElements();
                for (int i = 0; i < checkedObjects.length; i++) {
                    InputType type = (InputType) checkedObjects[i];
                    if (type == inputType) {
                        continue;
                    }
                    type.setActived(!checked);
                    ParamType param1 = SmooksUIUtils.getInputTypeAssociatedParamType(type,
                            getSmooksConfigResourceList());
                    if (param1 != null) {
                        String value1 = SmooksModelUtils.INPUT_DEACTIVE_TYPE;
                        Command c1 = SetCommand.create(getEditingDomain(), param1,
                                SmooksPackage.Literals.PARAM_TYPE__TYPE, value1);
                        compoundCommand.append(c1);
                    }

                    lockCheck = true;
                    inputDataViewer.setChecked(type, false);
                    lockCheck = false;
                }

            } else {
                ParamType param = SmooksUIUtils.getInputTypeAssociatedParamType(inputType,
                        getSmooksConfigResourceList());
                if (param != null) {
                    String value = SmooksModelUtils.INPUT_DEACTIVE_TYPE;
                    Command c = SetCommand.create(getEditingDomain(), param,
                            SmooksPackage.Literals.PARAM_TYPE__TYPE, value);
                    compoundCommand.append(c);
                }
            }
            try {
                getEditingDomain().getCommandStack().execute(compoundCommand);
            } catch (Exception e) {
                // e.printStackTrace();
            }

            // refreshInputModelView();
        }
    });
    inputDataViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Object element = selection.getFirstElement();
            if (element instanceof InputType) {
                String type = ((InputType) element).getType();
                String filePath = ((InputType) element).getPath();
                if (type != null && filePath != null) {
                    if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
                        IFile file = ((IFileEditorInput) getEditorInput()).getFile();
                        IJavaProject javaProject = JavaCore.create(file.getProject());
                        if (javaProject != null) {
                            try {
                                if (filePath.endsWith("[]")) { //$NON-NLS-1$
                                    filePath = filePath.substring(0, filePath.length() - 2);
                                }
                                IJavaElement result = javaProject.findType(filePath);
                                if (result != null)
                                    JavaUI.openInEditor(result);
                                else {
                                    MessageDialog.openError(getSite().getWorkbenchWindow().getShell(),
                                            Messages.SmooksReaderFormPage_CantFindTypeErrorTitle,
                                            "Can't find type \"" + filePath + "\" in \"" //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                                                    + javaProject.getProject().getName() + "\" project."); //$NON-NLS-1$
                                }
                            } catch (Exception e) {

                            }
                        }
                    } else {
                        try {
                            filePath = SmooksUIUtils.parseFilePath(filePath);
                            if (filePath != null) {
                                IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(filePath));
                                IFileInfo fetchInfo = fileStore.fetchInfo();
                                if (!fetchInfo.isDirectory() && fetchInfo.exists()) {
                                    IWorkbenchWindow window = getSite().getWorkbenchWindow();
                                    IWorkbenchPage page = window.getActivePage();
                                    try {
                                        IDE.openEditorOnFileStore(page, fileStore);
                                    } catch (PartInitException e) {
                                        MessageDialog.open(MessageDialog.ERROR, window.getShell(),
                                                Messages.SmooksReaderFormPage_OpenFileErrorTitle,
                                                "Can't open the file : '" + filePath + "'", SWT.SHEET); //$NON-NLS-1$ //$NON-NLS-2$
                                    }
                                } else {
                                }
                            }
                        } catch (Exception e) {
                            MessageDialog.open(MessageDialog.ERROR, getSite().getWorkbenchWindow().getShell(),
                                    Messages.SmooksReaderFormPage_OpenFileErrorTitle,
                                    "Can't open the file : '" + filePath + "'", SWT.SHEET); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                        }
                    }
                }
            }
        }
    });
    TableColumn header = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
    header.setText(Messages.SmooksReaderFormPage_TypeColumnText);
    header.setWidth(100);
    TableColumn pathColumn = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
    pathColumn.setText(Messages.SmooksReaderFormPage_PathColumnText);
    pathColumn.setWidth(300);

    // TableColumn extColumn = new TableColumn(inputDataViewer.getTable(),
    // SWT.NONE);
    // extColumn.setText("Extension Paramers");
    // extColumn.setWidth(400);
    inputDataViewer.setContentProvider(new ExtentionInputContentProvider());
    inputDataViewer.setLabelProvider(new InputDataViewerLabelProvider());
    inputDataViewer.getTable().setHeaderVisible(true);
    inputDataViewer.getTable().setLinesVisible(true);
    ISmooksModelProvider provider = getSmooksModelProvider();
    if (provider != null) {
        inputDataViewer.setInput(SmooksUIUtils.getInputTypeList(getSmooksConfigResourceList()));
    }
    Composite buttonComposite = toolkit.createComposite(mainComposite, SWT.NONE);
    gd = new GridData(GridData.FILL_VERTICAL);
    buttonComposite.setLayoutData(gd);
    GridLayout l = new GridLayout();
    buttonComposite.setLayout(l);

    addInputDataButton = toolkit.createButton(buttonComposite, Messages.SmooksReaderFormPage_AddButtonLabel,
            SWT.FLAT);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    addInputDataButton.setLayoutData(gd);
    addInputDataButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            showInputDataWizard();
        }

    });

    removeInputDataButton = toolkit.createButton(buttonComposite,
            Messages.SmooksReaderFormPage_DeleteButtonLabel, SWT.FLAT);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    removeInputDataButton.setLayoutData(gd);
    removeInputDataButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) inputDataViewer.getSelection();
            if (selection != null) {
                List<?> inputs = selection.toList();
                ISmooksModelProvider smooksModelProvider = getSmooksModelProvider();
                for (Iterator<?> iterator = inputs.iterator(); iterator.hasNext();) {
                    InputType input = (InputType) iterator.next();
                    SmooksUIUtils.removeInputType(input, smooksModelProvider);
                }
                if (!inputs.isEmpty()) {
                    List<?> viewerInput = (List<?>) inputDataViewer.getInput();
                    viewerInput.removeAll(inputs);
                    // inputTypeChanged();
                    if (inputDataViewer != null) {
                        inputDataViewer.refresh();
                    }
                }
            }
        }
    });
}

From source file:org.jboss.tools.windup.ui.internal.explorer.MarkerNode.java

License:Open Source License

public void delete() {
    try {/*ww  w .  j a  va  2s.com*/
        marker.delete();
    } catch (CoreException e) {
        WindupUIPlugin.log(e);
        MessageDialog.open(MessageDialog.ERROR, Display.getDefault().getActiveShell(), operationError,
                issueDeleteError, SWT.NONE);
    }
}