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:de.instanttouch.ui.scaffolding.swt.viewer.SnakeTableViewer.java

License:Open Source License

protected void open(SnakeType type) {

    boolean bValidate = false;
    boolean allowOk = true;
    Dialog typeDialog = SnakeDialogRegistry.createForType(getTable().getShell(), type, allowOk, bValidate);
    if (typeDialog != null) {
        if (Dialog.OK == typeDialog.open()) {
            refresh();/*from   w  ww.j a  va 2 s .c  om*/
        }
    }

}

From source file:de.jaret.util.ui.table.util.action.ConfigureColumnsAction.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w  w  w .  ja v a  2 s  .com*/
 */
public void run() {
    save();

    Dialog confColsDialog = new Dialog(Display.getCurrent().getActiveShell()) {
        @Override
        protected Control createDialogArea(Composite parent) {
            return createColumnControlPanel(parent);
        }

    };
    int result = confColsDialog.open();
    if (result == Dialog.CANCEL) {
        restore();
    }
}

From source file:de.walware.statet.r.internal.debug.ui.preferences.REnvPreferencePage.java

License:Open Source License

private boolean doEdit(final IREnvConfiguration.WorkingCopy config, final boolean newConfig) {
    final List<IREnvConfiguration> existingConfigs = new ArrayList<IREnvConfiguration>(fList);
    if (!newConfig) {
        for (final Iterator<IREnvConfiguration> iter = existingConfigs.iterator(); iter.hasNext();) {
            final IREnvConfiguration existing = iter.next();
            if (existing.getReference() == config.getReference()) {
                iter.remove();//from w  ww .  jav  a  2s  . com
                break;
            }
        }
    }
    Dialog dialog;
    if (config.isLocal()) {
        dialog = new REnvLocalConfigDialog(getShell(), config, newConfig, existingConfigs);
    } else if (config.isRemote()) {
        dialog = new REnvRemoteConfigDialog(getShell(), config, newConfig, existingConfigs);
    } else {
        return false;
    }
    return (dialog.open() == Dialog.OK);
}

From source file:de.walware.statet.r.internal.ui.pkgmanager.RRepoPreferencePage.java

License:Open Source License

@Override
public RRepo edit(final int command, final RRepo item, final Object parent) {
    final RRepo repo = new RRepo(((command & ButtonGroup.ADD_ANY) != 0) ? newId() : item.getId());
    if (item != null) {
        repo.set(item);/*from   w w  w . j a  v  a 2  s . c  o  m*/
    }
    final Dialog dialog = new EditRepoDialog(getShell(), repo, item == null);
    if (dialog.open() == Dialog.OK) {
        if (repo.getName().isEmpty()) {
            repo.setName(RRepo.hintName(repo));
        }
        return repo;
    }
    return null;
}

From source file:eclipse.testframework.ui.util.DialogCheck.java

License:Open Source License

/**
 * Automated test that checks all the labels and buttons of a dialog
 * to make sure there is enough room to display all the text.  Any
 * text that wraps is only approximated and is currently not accurate.
 *
 * @param dialog the test dialog to be verified.
 *///from w ww  .ja  v a 2 s .  c  om
public static void assertDialogTexts(Dialog dialog) {
    Assert.assertNotNull(dialog);
    dialog.setBlockOnOpen(false);
    dialog.open();
    Shell shell = dialog.getShell();
    verifyCompositeText(shell);
    dialog.close();
}

From source file:eu.hydrologis.jgrass.formeditor.model.widgets.FormComboCellEditor.java

License:Open Source License

private void handleEvent() {

    Shell shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
    Dialog dialog = new Dialog(shell) {

        @Override/*from   w w  w  .  ja va2s  .c om*/
        protected void configureShell(Shell shell) {
            super.configureShell(shell);
            shell.setText("Insert data");
        }

        @Override
        protected Point getInitialSize() {
            return new Point(320, 300);
        }

        @Override
        protected Control createDialogArea(Composite parent) {

            Composite mainComposite = new Composite(parent, SWT.NONE);
            mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            mainComposite.setLayout(new GridLayout(2, false));

            manualButton = new Button(mainComposite, SWT.RADIO);
            manualButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            manualButton.setText("Manual");
            manualButton.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    boolean selection = manualButton.getSelection();
                    handleEnablements(selection);
                }

            });

            manualText = new Text(mainComposite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            manualText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
            manualText.setText("");

            fileButton = new Button(mainComposite, SWT.RADIO);
            GridData fileButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
            fileButtonGD.horizontalSpan = 2;
            fileButton.setLayoutData(fileButtonGD);
            fileButton.setText("File");
            fileButton.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    boolean selection = fileButton.getSelection();
                    handleEnablements(!selection);
                }
            });

            Group fileGroup = new Group(mainComposite, SWT.NONE);
            GridData fileGroupGD = new GridData(SWT.FILL, SWT.FILL, true, false);
            fileGroupGD.horizontalSpan = 2;
            fileGroup.setLayoutData(fileGroupGD);
            fileGroup.setLayout(new GridLayout(3, false));
            // fileGroup.setText();

            Label pathLabel = new Label(fileGroup, SWT.NONE);
            pathLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            pathLabel.setText("Path");

            pathText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.READ_ONLY);
            pathText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
            pathText.setText("");

            browseButton = new Button(fileGroup, SWT.PUSH);
            browseButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
            browseButton.setText("..."); //$NON-NLS-1$
            browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
                public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                    IMap activeMap = ApplicationGIS.getActiveMap();
                    ILayer selectedLayer = activeMap.getEditManager().getSelectedLayer();
                    ID id = selectedLayer.getGeoResource().getID();
                    if (id.isFile()) {
                        File layerFile = id.toFile();

                        FileDialog fileDialog = new FileDialog(pathText.getShell(), SWT.OPEN);
                        // fileDialog.setFilterExtensions(extentions);
                        fileDialog.setFilterPath(layerFile.getParent());

                        String path = fileDialog.open();
                        if (path != null && path.length() >= 1) {
                            File tableFile = new File(path);
                            String tableParentName = tableFile.getParentFile().getName().trim();
                            String layerParentName = layerFile.getParentFile().getName().trim();
                            if (tableParentName.equals(layerParentName)) {
                                pathText.setText(tableFile.getName());
                            } else {
                                MessageDialog.openWarning(browseButton.getShell(), "WARNING",
                                        "The linked table needs to be inside of the same folder as the resource file.");
                            }
                        }
                    } else {
                        MessageDialog.openWarning(browseButton.getShell(), "WARNING",
                                "Currently linking of files is supported only for file based resources.");
                        handleEnablements(true);
                    }
                }
            });

            Label separatorBabel = new Label(fileGroup, SWT.NONE);
            separatorBabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            separatorBabel.setText("Separator");

            separatorText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            GridData separatorTextGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
            separatorTextGD.horizontalSpan = 2;
            separatorText.setLayoutData(separatorTextGD);
            separatorText.setText(",");

            linkButton = new Button(fileGroup, SWT.CHECK);
            GridData linkButtonGD = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
            linkButtonGD.horizontalSpan = 3;
            linkButton.setLayoutData(linkButtonGD);
            linkButton.setText("link file");

            Label attributeValueLabel = new Label(fileGroup, SWT.NONE);
            attributeValueLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            attributeValueLabel.setText("Attribute value column");

            attributeValueText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            GridData attributeValueGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
            attributeValueGD.horizontalSpan = 2;
            attributeValueText.setLayoutData(attributeValueGD);
            attributeValueText.setText("1");

            Label guiNameLabel = new Label(fileGroup, SWT.NONE);
            guiNameLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            guiNameLabel.setText("Interface name column");

            guiNameText = new Text(fileGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            GridData guiNameTextGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
            guiNameTextGD.horizontalSpan = 2;
            guiNameText.setLayoutData(guiNameTextGD);
            guiNameText.setText("2");

            setValuesFromValueString();

            return mainComposite;
        }

        @Override
        protected void buttonPressed(int buttonId) {
            if (buttonId == OK) {
                if (manualButton.getSelection()) {
                    valueString = manualText.getText();
                } else {
                    setValueStringFromFileType();
                }
                editOccured(null);
            }
            super.buttonPressed(buttonId);
        }

    };
    dialog.setBlockOnOpen(true);
    dialog.open();

    // Point location = mainButton.getLocation();
    //
    // Point size = dialog.getSize();
    // dialog.setLocation(location.x - size.x, location.y + size.y);
}

From source file:eu.hydrologis.jgrass.ui.actions.g_setmapset.java

License:Open Source License

public void run(IAction action) {

    final ScopedPreferenceStore m_preferences = (ScopedPreferenceStore) ConsoleEditorPlugin.getDefault()
            .getPreferenceStore();/*from  w  w  w.  j a v  a  2  s. c  om*/

    Dialog dialog = new Dialog(window.getShell()) {

        private Text text;

        protected Control createDialogArea(Composite parent) {
            Composite composite = (Composite) super.createDialogArea(parent);
            composite.setLayout(new GridLayout(4, false));

            Label label = new Label(composite, SWT.NONE);
            label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            label.setText("mapset path");

            mapset = m_preferences.getString(PreferencesInitializer.CONSOLE_ARGV_MAPSET);
            if (mapset != null) {
                File f = new File(mapset);
                if (!f.exists()) {
                    mapset = "";
                }
            }
            text = new Text(composite, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
            text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
            text.setText(mapset);

            final Button mapsetSelectionButton = new Button(composite, SWT.PUSH);
            mapsetSelectionButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            mapsetSelectionButton.setToolTipText("Select a mapset from the catalog.");
            mapsetSelectionButton.setText("catalog");
            mapsetSelectionButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
                public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {

                    CatalogJGrassMapsetTreeViewerDialog cDialog = new CatalogJGrassMapsetTreeViewerDialog();
                    cDialog.open(mapsetSelectionButton.getShell());
                    List<JGrassMapsetGeoResource> selectedLayers = cDialog.getSelectedLayers();
                    if (selectedLayers == null || selectedLayers.size() == 0) {
                        return;
                    }
                    JGrassMapsetGeoResource grassMapsetGeoResource = selectedLayers.get(0);
                    File mapsetFile = grassMapsetGeoResource.getFile();
                    if (mapsetFile.exists()
                            && GrassPlugin.getDefault().isMapsetConsistent(mapsetFile.getAbsolutePath())) {
                        text.setText(mapsetFile.getAbsolutePath());
                    } else {
                        String msg = "This is not a valid GRASS mapset folder. Please supply a valid mapset folder.";
                        popupError(msg);
                    }
                }

            });

            Button browseButton = new Button(composite, SWT.PUSH);
            browseButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
            browseButton.setText("...");
            browseButton.setToolTipText("Browse the filesystem for a mapset folder.");
            browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
                public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
                    DirectoryDialog fileDialog = new DirectoryDialog(window.getShell(), SWT.OPEN);
                    String path = fileDialog.open();
                    if (path != null) {
                        File f = new File(path);
                        if (f.exists() && GrassPlugin.getDefault().isMapsetConsistent(path)) {
                            text.setText(f.getAbsolutePath());
                        } else {
                            String msg = "This is not a valid GRASS mapset folder. Please supply a valid mapset folder.";
                            popupError(msg);
                        }
                    }
                }

            });

            return composite;
        }

        protected void configureShell(Shell shell) {
            super.configureShell(shell);
            shell.setText("g.setmapset");
            shell.setSize(new Point(450, 120));

            Shell mainshell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
            Rectangle bounds = mainshell.getBounds();
            Rectangle rect = shell.getBounds();
            int x = bounds.x + (bounds.width - rect.width) / 2;
            int y = bounds.y + (bounds.height - rect.height) / 2;
            shell.setLocation(x, y);
        }

        protected void okPressed() {
            m_preferences.setValue(PreferencesInitializer.CONSOLE_ARGV_MAPSET, text.getText());
            super.okPressed();
        }

    };

    dialog.setBlockOnOpen(true);
    dialog.open();
}

From source file:eu.hydrologis.jgrass.ui.utilities.CatalogJGrassMapsetTreeViewerDialog.java

License:Open Source License

public void open(Shell parentShell) {
    try {/*  w w  w. ja va2  s  . c om*/
        setRequireContinue(false);

        Dialog dialog = new Dialog(parentShell) {

            @Override
            protected void configureShell(Shell shell) {
                super.configureShell(shell);
                shell.setText(Messages.getString("CatalogJGrassMapsetTreeViewerDialog.choosemapset")); //$NON-NLS-1$
            }

            @Override
            protected Point getInitialSize() {
                return new Point(250, 250);
            }

            @Override
            protected Control createDialogArea(Composite parent) {
                Composite parentPanel = (Composite) super.createDialogArea(parent);
                GridLayout gLayout = (GridLayout) parentPanel.getLayout();

                gLayout.numColumns = 1;

                active = new CatalogJGrassMapsetsTreeViewer(parentPanel, SWT.BORDER, SWT.SINGLE);

                return parentPanel;
            }

            @Override
            protected void buttonPressed(int buttonId) {
                super.buttonPressed(buttonId);
                if (buttonId == OK) {
                    newLayers = active.getSelectedLayers();
                } else {
                    newLayers = null;
                }
                setRequireContinue(true);
            }

        };

        dialog.setBlockOnOpen(true);
        dialog.open();

        while (!isContinueRequired()) {
            if (dialog.getShell().isDisposed()) {
                break;
            }

            if (Display.getCurrent().readAndDispatch()) {
                continue;
            }

            try {
                Thread.sleep(300);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:eu.hydrologis.jgrass.uibuilder.jgrassdependent.GuiBuilderDialog.java

License:Open Source License

private void openHelpResult(final String helpString) {
    Display.getDefault().asyncExec(new Runnable() {

        public void run() {
            Dialog helpDialog = new Dialog(getShell()) {

                protected void configureShell(Shell newShell) {
                    commandName = properties.getProperty(UIBuilderJGrassConstants.DIALOG_TITLE);
                    if (commandName != null) {
                        newShell.setText("Help for: " + commandName);
                        newShell.setSize(600, 400);
                    }//  www  . j a v a2s  . c o  m

                    // set the position of the shell
                    Point cursorLocation = parent.getDisplay().getCursorLocation();
                    cursorLocation.x = cursorLocation.x - newShell.getSize().x / 2;
                    newShell.setLocation(cursorLocation);

                    super.configureShell(newShell);
                }

                protected Control createDialogArea(Composite parent) {
                    Composite composite = (Composite) super.createDialogArea(parent);
                    final Text text = new Text(composite,
                            SWT.READ_ONLY | SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
                    text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                    if (helpString.contains("Total run time")) {
                        String[] split1 = helpString.split("Running model... -------------------------------");
                        String[] split2 = split1[1].split("Total run time");
                        text.setText(split2[0].trim());
                    } else {
                        text.setText(helpString);
                    }
                    return composite;
                }
            };

            helpDialog.open();
        }
    });
}

From source file:eu.udig.catalog.jgrass.activeregion.dialogs.CatalogJGrassMapsetTreeViewerDialog.java

License:Open Source License

public void open(Shell parentShell) {
    try {/*from   www  . j  a v a2 s.  c  om*/
        setRequireContinue(false);

        Dialog dialog = new Dialog(parentShell) {

            @Override
            protected void configureShell(Shell shell) {
                super.configureShell(shell);
                shell.setText("Select mapset"); //$NON-NLS-1$
            }

            @Override
            protected Point getInitialSize() {
                return new Point(250, 250);
            }

            @Override
            protected Control createDialogArea(Composite parent) {
                Composite parentPanel = (Composite) super.createDialogArea(parent);
                GridLayout gLayout = (GridLayout) parentPanel.getLayout();

                gLayout.numColumns = 1;

                active = new CatalogJGrassMapsetsTreeViewer(parentPanel, SWT.BORDER, SWT.SINGLE);

                return parentPanel;
            }

            @Override
            protected void buttonPressed(int buttonId) {
                super.buttonPressed(buttonId);
                if (buttonId == OK) {
                    newLayers = active.getSelectedLayers();
                } else {
                    newLayers = null;
                }
                setRequireContinue(true);
            }

        };

        dialog.setBlockOnOpen(true);
        dialog.open();

        while (!isContinueRequired()) {
            if (dialog.getShell().isDisposed()) {
                break;
            }

            if (Display.getCurrent().readAndDispatch()) {
                continue;
            }

            try {
                Thread.sleep(300);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}