Example usage for org.eclipse.jface.dialogs Dialog open

List of usage examples for org.eclipse.jface.dialogs Dialog open

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog open.

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:org.apache.directory.studio.apacheds.configuration.editor.ServerConfigurationEditorUtils.java

License:Apache License

/**
 * Opens a {@link Dialog} in the UI thread.
 *
 * @param dialog the dialog//from  w w  w  .  j  a v a2s . c om
 * @return the result of the dialog
 */
private static int openDialogInUIThread(final Dialog dialog) {
    // Defining our own encapsulating class for the result
    class DialogResult {
        private int result;

        public int getResult() {
            return result;
        }

        public void setResult(int result) {
            this.result = result;
        }
    }

    // Creating an object to hold the result
    final DialogResult result = new DialogResult();

    // Opening the dialog in the UI thread
    Display.getDefault().syncExec(() -> result.setResult(dialog.open()));

    return result.getResult();
}

From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.AEMarkupWidget.java

License:Open Source License

private void createMarkupWidget() {
    this.setLayout(new GridLayout(1, false));
    ((GridLayout) this.getLayout()).marginHeight = 0;
    ((GridLayout) this.getLayout()).verticalSpacing = 0;
    ((GridLayout) this.getLayout()).marginWidth = 0;

    _parentComposite = new Composite(this, SWT.NONE);
    _parentComposite.setLayoutData(new GridData());
    ((GridData) _parentComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _parentComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    if (Platform.getPreferencesService().getBoolean(CommonActivator.PLUGIN_ID, "ASPECT_LITE_EDIT_ANA_KEY",
            AEConstants.ASPECT_LITE_EDIT_ANA_KEY, null)) {
        _parentComposite.setLayout(new GridLayout(3, false));
    } else {/*from  ww  w. j a v  a 2  s  .  co m*/
        _parentComposite.setLayout(new GridLayout(2, false));
    }
    ((GridLayout) _parentComposite.getLayout()).marginHeight = 0;
    ((GridLayout) _parentComposite.getLayout()).verticalSpacing = 0;
    ((GridLayout) _parentComposite.getLayout()).marginWidth = 0;

    if (_widgetType == AEAspectWidgetCustomizable.TYPE_TEXT) {
        createMarkupTextWidget();
    } else if (_widgetType == AEAspectWidgetCustomizable.TYPE_COMBO) {
        createMarkupComboWidget();
    } else if (_widgetType == AEAspectWidgetCustomizable.TYPE_DATE) {
        createMarkupDateWidget();
    } else if (_widgetType == AEAspectWidgetCustomizable.TYPE_DATE_COMBO) {
        createMarkupDateComboWidget();
    }
    if (_markupTemplate.getWidgetType() < 4) {
        if (Platform.getPreferencesService().getBoolean(CommonActivator.PLUGIN_ID, "ASPECT_LITE_EDIT_ANA_KEY",
                AEConstants.ASPECT_LITE_EDIT_ANA_KEY, null)) {
            Button anaKeyButton = new Button(_parentComposite, SWT.PUSH);
            anaKeyButton.setImage(_imageReg.get(IconsInternal.KEY));
            anaKeyButton.setToolTipText(NLMessages.getString("Editor_edit_ana_key"));
            anaKeyButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    String ana = _inputElement.getAttribute("ana");
                    String key = _inputElement.getAttribute("key");
                    TaggingRange tr = new TaggingRange();
                    tr.setAna(ana);
                    tr.setKey(key);
                    Dialog dialog = new SelectOwnerAndKeyDialog(_parentComposite.getShell(), tr);
                    int returnCode = dialog.open();
                    if (returnCode == 0) {
                        _inputElement.setAttribute("ana", tr.getAna());
                        _inputElement.setAttribute("key", tr.getKey());
                        contentChanged();
                    }

                }
            });

        }
    }
}

From source file:org.bbaw.pdr.ae.view.editorlite.view.EasyAspectEditor.java

License:Open Source License

/**
 * Sets the markup.//ww w .j av a2  s  .c  o m
 * @param cd
 */
protected final void setMarkup(ConfigData cd) {
    if (_stackUndo.size() == UNDO_STACKSIZE) {
        _stackUndo.removeElementAt(0);
    }

    _stackUndo.push(new UndoInformation(_aspect.getNotification(), _aspect.getRangeList()));

    if (!_protectRedoStack) {
        _stackRedo.clear();
    }
    if (_undoAction != null) {
        _undoAction.setEnabled(_stackUndo.size() > 0);
    }
    if (_redoAction != null) {
        _redoAction.setEnabled(_stackRedo.size() > 0);
    }
    ConfigItem ci = (ConfigItem) cd;
    ConfigItem ciParent;
    ConfigItem ciGrandParent;
    ConfigItem ciGreatGrandParent;
    String name;
    String type = null;
    String subtype = null;
    String role = null;
    String ana = _currentPerson.getPdrId().toString();
    if (ci.getParent() != null) {
        if (ci.getParent() instanceof ConfigItem) {
            ciParent = (ConfigItem) ci.getParent();
            if (ciParent.getParent() != null) {
                if (ciParent.getParent() instanceof ConfigItem) {
                    ciGrandParent = (ConfigItem) ciParent.getParent();
                    if (ciGrandParent.getParent() != null) {
                        if (ciGrandParent.getParent() instanceof ConfigItem) {
                            ciGreatGrandParent = (ConfigItem) ciGrandParent.getParent();
                            name = ciGreatGrandParent.getValue();
                            type = ciGrandParent.getValue();
                            subtype = ciParent.getValue();
                            role = ci.getValue();
                        } else {
                            name = ciGrandParent.getParent().getValue();
                            type = ciGrandParent.getValue();
                            subtype = ciParent.getValue();
                            role = ci.getValue();
                        }

                    } else {
                        name = ciGrandParent.getValue();
                        type = ciParent.getValue();
                        subtype = ci.getValue();
                    }
                } else {
                    name = ciParent.getParent().getValue();
                    type = ciParent.getValue();
                    subtype = ci.getValue();
                }
            } else {
                name = ciParent.getValue();
                type = ci.getValue();
            }
        } else {
            name = ci.getParent().getValue();
            type = ci.getValue();
        }
    } else {
        name = ci.getValue();
    }

    if (name.startsWith("aodl:")) {
        name = name.substring(5);
    }
    // FIXME testselection!!!???
    if (name.length() > 0 && type.length() > 0) {
        // StyleRange sr = new StyleRange();
        // sr.start = styledTextAspect.getSelection().x;
        // sr.length = styledTextAspect.getSelectionCount();
        // sr.background = chooseColor(name);
        TaggingRange tr = new TaggingRange(name, type, subtype, role, ana, null);
        if (name.equals("date")) {
            if (_pointOfTime) {
                tr.setWhen(_dateFrom);
            } else {
                tr.setFrom(_dateFrom);
                tr.setTo(_dateTo);
            }
        }
        // TODO anakeydialog einfgen

        int returnCode = 0;
        if (Platform.getPreferencesService().getBoolean(CommonActivator.PLUGIN_ID, "ASPECT_LITE_EDIT_ANA_KEY",
                AEConstants.ASPECT_LITE_EDIT_ANA_KEY, null)) {
            Dialog dialog = new SelectOwnerAndKeyDialog(this.getShell(), tr);
            returnCode = dialog.open();
        }
        if (returnCode < 2) {
            setDirty(true);
            if (_markupEditor.getSelectionText() == null
                    || _markupEditor.getSelectionText().trim().length() == 0) {
                tr.setTextValue(PDRConfigProvider.getLabelOfMarkup(name, type, subtype, role));
                _markupEditor.insertContentSetMarkup(tr);
            } else {
                _markupEditor.setMarkup(tr);
            }
            _aspect.getRangeList().add(tr);

            //            System.out.println("vor sort "+ sr.start + " - " + sr.length); //$NON-NLS-1$ //$NON-NLS-2$
            // _sText.setSelection(tr.getStart() + tr.getLength());
            saveMarkup();
        }
    }
}

From source file:org.bonitasoft.studio.document.ui.DocumentPropertySection.java

License:Open Source License

private void createAddButton(final Composite buttonComposite) {
    final Button addButton = getWidgetFactory().createButton(buttonComposite,
            org.bonitasoft.studio.document.i18n.Messages.AddSimple, SWT.FLAT);
    addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(85, SWT.DEFAULT).create());
    addButton.addSelectionListener(new SelectionAdapter() {

        @Override//w w  w  .ja v  a 2 s .c  o  m
        public void widgetSelected(final SelectionEvent e) {
            super.widgetSelected(e);

            final DocumentWizard documentWizard = new DocumentWizard(getEObject());
            final Dialog dialog = new DocumentWizardDialog(Display.getDefault().getActiveShell(),
                    documentWizard, true);
            if (IDialogConstants.OK_ID == dialog.open()) {
                final Document newDocument = documentWizard.getDocument();
                documentListViewer.setSelection(new StructuredSelection(newDocument));
            }
        }
    });
}

From source file:org.bonitasoft.studio.document.ui.DocumentPropertySection.java

License:Open Source License

private void editDocumentAction(final ISelection selection) {
    if (!selection.isEmpty()) {
        final Document selectedDocument = (Document) ((IStructuredSelection) selection).getFirstElement();
        final DocumentWizard documentWizard = new DocumentWizard(getEObject(), selectedDocument, true);
        final Dialog dialog = new CustomWizardDialog(Display.getDefault().getActiveShell(), documentWizard,
                IDialogConstants.OK_LABEL);
        dialog.open();
        documentListViewer.refresh();/*w  w  w .j  ava2  s.c  o  m*/
        documentListViewer.setSelection(new StructuredSelection(documentWizard.getDocument()));
    }
}

From source file:org.bonitasoft.studio.tests.draw2d.TestLifeCycleWidget.java

License:Open Source License

private void testSelectionEvent(final String eventType, final ConnectorEvent eventTypeThatShouldBeselected,
        final int taskLifeCycle) {

    UIThreadRunnable.syncExec(new VoidResult() {
        public void run() {
            Dialog dialog = new Dialog(Display.getDefault().getActiveShell()) {
                @Override/* w  ww  .  j a v  a2  s .c  o  m*/
                protected Control createDialogArea(Composite parent) {
                    Control superParent = super.createDialogArea(parent);

                    lcw = new LifeCycleWidget(parent, eventType, null);
                    return superParent;
                }

                @Override
                protected void configureShell(Shell newShell) {
                    super.configureShell(newShell);
                    newShell.setText("Test Life cycle widget: " + eventType + eventTypeThatShouldBeselected
                            + taskLifeCycle);
                }
            };
            dialog.setBlockOnOpen(false);
            dialog.open();
            bot.waitUntil(Conditions.shellIsActive(
                    "Test Life cycle widget: " + eventType + eventTypeThatShouldBeselected + taskLifeCycle),
                    10000);
            bot.button(IDialogConstants.CANCEL_LABEL).click();
        }
    });

    final String eventTypeTheoric = eventTypeThatShouldBeselected.toString();
    for (EventCircle eventCircle : lcw.getEventFigures()) {
        final String event = eventCircle.getEvent();
        if (event.equals(eventTypeTheoric)) {
            assertEquals("The event circle" + event + " should be selected",
                    eventCircle.getLocalForegroundColor().getRed(), 73);
        } else {
            assertEquals("The event circle" + event + " should not be selected",
                    eventCircle.getLocalForegroundColor().getRed(), 235);
        }
    }

    bot.waitUntil(Conditions.shellIsActive("Bonita BPM"));

}

From source file:org.codecover.eclipse.views.controls.DeleteTestElementsSelectDialog.java

License:Open Source License

@Override
protected void okPressed() {
    Object[] elementsToDelete;/*ww w .ja v a 2  s  . com*/
    Dialog confirmDialog;
    elementsToDelete = removeTestCasesOfContainedTestSessions(this.viewer.getCheckedElements());
    this.close();
    if (elementsToDelete.length > 0) {
        confirmDialog = new DeleteTestElementsConfirmDialog(this.getParentShell(), elementsToDelete);
        confirmDialog.setBlockOnOpen(true);
        if (confirmDialog.open() == DeleteTestElementsConfirmDialog.YES_BUTTON_INDEX) {
            try {
                CodeCoverPlugin.getDefault().getTSContainerManager().setActiveTSContainer(this.tscInfo,
                        new DeleteTestElementsRunnable(elementsToDelete), null);
            } catch (FileLoadException e) {
                showRaceConditionErrorDialog(e);
            } catch (OutOfMemoryError e) {
                showRaceConditionErrorDialog(e);
                logger.error("Out of memory while loading" + //$NON-NLS-1$
                        " test session container: " //$NON-NLS-1$
                        + this.tscInfo.getPath().toString(), new InvocationTargetException(e));
            } catch (InvocationTargetException e) {
                if (e.getCause() instanceof ConcurrentModificationException) {
                    showRaceConditionErrorDialog(e.getCause());
                } else {
                    logger.error("Unknown error during" + //$NON-NLS-1$
                            " deletion of" + //$NON-NLS-1$
                            " test sessions/test cases", e); //$NON-NLS-1$
                }
            } catch (CancelException e) {
                logger.warning("User canceled deletion of" + //$NON-NLS-1$
                        " test sessions/test cases during" + //$NON-NLS-1$
                        " execution", e); //$NON-NLS-1$
            }
        }
    }
}

From source file:org.codecover.eclipse.views.controls.DeleteTSCsSelectDialog.java

License:Open Source License

@Override
protected void okPressed() {
    List<TSContainerInfo> tscsToDelete = new ArrayList<TSContainerInfo>();
    Dialog confirmDialog;
    for (Object tsc : this.viewer.getCheckedElements()) {
        tscsToDelete.add((TSContainerInfo) tsc);
    }//from  ww  w  .j  av  a 2  s.  com
    this.close();
    if (tscsToDelete.isEmpty()) {
        return;
    }
    confirmDialog = new DeleteTSCsConfirmDialog(this.getParentShell(), tscsToDelete);
    confirmDialog.setBlockOnOpen(true);
    if (confirmDialog.open() == DeleteTSCsConfirmDialog.YES_BUTTON_INDEX) {
        try {
            CodeCoverPlugin.getDefault().getTSContainerManager().deleteTestSessionContainers(tscsToDelete,
                    null);
        } catch (CoreException e) {
            ErrorDialog.openError(this.getParentShell(), DIALOG_ERROR_TITLE, null,
                    new Status(IStatus.ERROR, CodeCoverPlugin.PLUGIN_ID, IStatus.OK, DIALOG_ERROR_MSG, e));
        } catch (CancelException e) {
            // ignore because it can't be thrown if no monitor was passed
        }
    }
}

From source file:org.csstudio.email.ui.AbstractSendEMailAction.java

License:Open Source License

/** {@inheritDoc} */
@Override//ww w .  j  a  va  2  s.  co m
public void run() {
    if (body == null)
        body = getBody();
    if (body == null)
        body = ""; //$NON-NLS-1$

    // This action might be invoked from a context menu. In principle, RCP
    // closes the context menu before invoking this action.
    // Tools that need to implement getImage() by taking a screenshot thus capture the original display,
    // without the context menu.
    // On Linux (X11, GTK), however, the context menu is still visible.
    // Presumably, the X11 display update queue is not 'flushed'?
    // By delaying the getImage() call into another Runnable, the context menu
    // was successfully closed in tests on Linux.

    final Display display = shell == null ? Display.getCurrent() : shell.getDisplay();

    /*
     * Change parent shell to null if in full-screen mode, so the dialog is detached from main shell.
     * The change was made to fix the appearance of dialog in full-screen mode.
     *
     * Changed made by Borut Terpinc -- borut.terpinc@cosylab.com
     */

    final Shell fixupShell = shell.getFullScreen() == true ? null : shell;

    display.asyncExec(new Runnable() {
        @Override
        public void run() {
            final String image_filename = getImage();

            final Dialog dlg;
            if (image_filename == null)
                dlg = new EMailSenderDialog(fixupShell, Preferences.getSMTP_Host(), from,
                        Messages.DefaultDestination, subject, body);
            else
                dlg = new EMailSenderDialog(fixupShell, Preferences.getSMTP_Host(), from,
                        Messages.DefaultDestination, subject, body, image_filename);
            dlg.open();
        }
    });
}

From source file:org.csstudio.email.ui.EMailDialogDemo.java

License:Open Source License

@Test
public void testEMailDialogWithImage() {
    final Shell shell = new Shell();

    final Dialog dlg = new EMailSenderDialog(shell, host, from, to, "Test", "This is a test",
            "icons/mail-edit-48.png");
    dlg.open();
}