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

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

Introduction

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

Prototype

public static void openInformation(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard information dialog.

Usage

From source file:com.astra.ses.spell.gui.preferences.ui.pages.GeneralPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    // CONTAINER/*from   w  w  w .  java  2s  .c  om*/
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, true);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    container.setLayout(layout);
    container.setLayoutData(layoutData);

    /* Page layout */
    GridData expand = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    expand.grabExcessVerticalSpace = true;
    expand.grabExcessHorizontalSpace = true;

    /*
     * Startup connection button
     */
    Composite startupConnection = new Composite(container, SWT.NONE);
    startupConnection.setLayout(new GridLayout(2, false));
    startupConnection.setLayoutData(GridDataFactory.copyData(expand));
    // Button
    m_startupConnect = new Button(startupConnection, SWT.CHECK);
    // Label
    Label startupDesc = new Label(startupConnection, SWT.NONE);
    startupDesc.setText("Connect to server at startup");

    // Label
    Label scpUser = new Label(startupConnection, SWT.NONE);
    scpUser.setText("User for SCP connections");
    // Text
    m_scpUser = new Text(startupConnection, SWT.BORDER);
    m_scpUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Label
    Label scpPwd = new Label(startupConnection, SWT.NONE);
    scpPwd.setText("Password for SCP connections");
    // Text
    m_scpPassword = new Text(startupConnection, SWT.BORDER | SWT.PASSWORD);
    m_scpPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    /*
     * Communication group
     */
    GridLayout communicationLayout = new GridLayout(3, false);
    Group communicationGroup = new Group(container, SWT.BORDER);
    communicationGroup.setText("Communication");
    communicationGroup.setLayout(communicationLayout);
    communicationGroup.setLayoutData(GridDataFactory.copyData(expand));
    /*
     * Response timeout
     */
    // Label
    Label responseTimeout = new Label(communicationGroup, SWT.NONE);
    responseTimeout.setText("Response timeout");
    // Text
    m_responseTimeout = new Text(communicationGroup, SWT.BORDER | SWT.RIGHT);
    m_responseTimeout.setLayoutData(GridDataFactory.copyData(expand));
    // Units label
    Label units = new Label(communicationGroup, SWT.NONE);
    units.setText("milliseconds");
    /*
     * Procedure opening timeout
     */
    // Label
    Label procedureOpenLabel = new Label(communicationGroup, SWT.NONE);
    procedureOpenLabel.setText("Procedure opening timeout");
    // Text
    m_openTimeout = new Text(communicationGroup, SWT.BORDER | SWT.RIGHT);
    m_openTimeout.setLayoutData(GridDataFactory.copyData(expand));
    // Label
    Label openUnits = new Label(communicationGroup, SWT.NONE);
    openUnits.setText("milliseconds");

    /*
     * User group
     */
    GridLayout userLayout = new GridLayout(3, true);
    Group userGroup = new Group(container, SWT.BORDER);
    userGroup.setText("User settings");
    userGroup.setLayout(userLayout);
    userGroup.setLayoutData(GridDataFactory.copyData(expand));
    /*
     * Prompt delay
     */
    // Label
    Label promptDelayLabel = new Label(userGroup, SWT.NONE);
    promptDelayLabel.setText("Prompt blinking delay");
    m_promptDelay = new Text(userGroup, SWT.BORDER | SWT.RIGHT);
    m_promptDelay.setLayoutData(GridDataFactory.copyData(expand));
    // Label
    Label promptDelayUnitsLabel = new Label(userGroup, SWT.NONE);
    promptDelayUnitsLabel.setText("seconds");
    /*
     * Prompt sound file
     */
    // Label
    Label promptSoundLabel = new Label(userGroup, SWT.NONE);
    promptSoundLabel.setText("Prompt sound file");
    m_soundFile = new Text(userGroup, SWT.BORDER);
    m_soundFile.setLayoutData(GridDataFactory.copyData(expand));
    // Browse button
    final Button browse = new Button(userGroup, SWT.PUSH);
    browse.setText("Browse...");
    browse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            FileDialog dialog = new FileDialog(browse.getShell());
            dialog.setFilterExtensions(new String[] { "*.wav" });
            dialog.setText("Select prompt sound file");
            dialog.setFilterNames(new String[] { "Waveform files (*.wav)" });
            String selected = dialog.open();
            if (selected != null) {
                m_soundFile.setText(selected);
            }
        }
    });

    /*
     * Save group
     */
    GridLayout saveLayout = new GridLayout(3, true);
    Group saveGroup = new Group(container, SWT.BORDER);
    saveGroup.setText("Save preferences");
    saveGroup.setLayout(saveLayout);
    saveGroup.setLayoutData(GridDataFactory.copyData(expand));

    /*
     * Save to current XML file
     */
    final Button saveBtn = new Button(saveGroup, SWT.PUSH);
    saveBtn.setText("Save to current file");
    saveBtn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            IConfigurationManager conf = getConfigurationManager();
            String cfgFile = conf.getConfigurationFile();
            try {
                if (!MessageDialog.openConfirm(saveBtn.getShell(), "Overwrite preferences?",
                        "This action will overwrite the current preferences stored in "
                                + "the default configuration file '" + cfgFile + "'. Do you want to continue?"))
                    return;

                GUIPreferencesSaver saver = new GUIPreferencesSaver(cfgFile);
                saver.savePreferences();
                MessageDialog.openInformation(saveBtn.getShell(), "Preferences saved",
                        "Preferences saved to file '" + cfgFile + "'");
            } catch (Exception ex) {
                MessageDialog.openError(saveBtn.getShell(), "Cannot save preferences",
                        "Unable to save preferences to '" + cfgFile + "'\n" + ex.getLocalizedMessage());
            }
        }
    });

    /*
     * Save to alternate XML file
     */
    final Button saveOtherBtn = new Button(saveGroup, SWT.PUSH);
    saveOtherBtn.setText("Save to another file...");
    saveOtherBtn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            FileDialog dialog = new FileDialog(saveOtherBtn.getShell(), SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*.xml" });
            dialog.setText("Select file to save preferences");
            dialog.setFilterNames(new String[] { "XML files (*.xml)" });
            String selected = dialog.open();
            if (selected != null) {
                /*
                 * If user has not set the file extension, then add it
                 */
                if (!selected.endsWith(".xml")) {
                    selected += ".xml";
                }
                try {
                    File file = new File(selected);
                    if (file.exists()) {
                        if (!MessageDialog.openConfirm(saveOtherBtn.getShell(), "Overwrite file?",
                                "File '" + selected + "' already exists. Overwrite?"))
                            return;
                    }
                    GUIPreferencesSaver saver = new GUIPreferencesSaver(selected);
                    saver.savePreferences();
                    MessageDialog.openInformation(saveOtherBtn.getShell(), "Preferences saved",
                            "Preferences saved to file '" + selected + "'");
                } catch (Exception ex) {
                    MessageDialog.openError(saveOtherBtn.getShell(), "Cannot save preferences",
                            "Unable to save preferences to '" + selected + "'\n" + ex.getLocalizedMessage());
                }
            }
        }
    });

    /*
     * Load preferences from an external file
     */
    final Button loadPrefsBtn = new Button(saveGroup, SWT.PUSH);
    loadPrefsBtn.setText("Load from external file...");
    loadPrefsBtn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            FileDialog dialog = new FileDialog(loadPrefsBtn.getShell(), SWT.OPEN);
            dialog.setFilterExtensions(new String[] { "*.xml", "*.XML" });
            String selected = dialog.open();
            if (selected != null) {
                File file = new File(selected);
                if (file.exists()) {
                    if (!MessageDialog.openConfirm(loadPrefsBtn.getShell(), "Overwrite preferences?",
                            "All the current values will be replaced with the ones defined in the selected file.\n"
                                    + "Do you wish to continue?"))
                        return;

                }

                /*
                 * Overwrite preferences dialog
                 */
                IPreferenceStore store = Activator.getDefault().getPreferenceStore();
                GUIPreferencesLoader loader = new GUIPreferencesLoader(selected, store);
                boolean loaded = loader.overwrite();
                if (!loaded) {
                    MessageDialog.openError(loadPrefsBtn.getShell(), "Error while loading configuration file",
                            "An unexpected error ocurred while loading the configuration file.\n"
                                    + "Check the application log for details");
                }
            }
        }
    });

    refreshPage();
    return container;
}

From source file:com.atlassian.connector.eclipse.internal.crucible.ui.actions.AbstractReviewFromResourcesAction.java

License:Open Source License

@Override
protected void processResources(List<ResourceEditorBean> selection, final Shell shell) {

    final Set<ITeamUiResourceConnector> connectors = new HashSet<ITeamUiResourceConnector>();

    for (ResourceEditorBean resourceBean : selection) {
        ITeamUiResourceConnector connector = AtlassianTeamUiPlugin.getDefault().getTeamResourceManager()
                .getTeamConnector(resourceBean.getResource());

        if (connector != null) {
            connectors.add(connector);//from  w  w w .j av a  2 s .c  o m
        } else {
            connectors.add(new LocalTeamResourceConnector());
        }
    }

    if (connectors.size() > 1) {
        MessageDialog.openInformation(shell, CrucibleUiPlugin.PLUGIN_ID,
                "Cannot create review for more than one SCM provider at once.");
        return;
    } else if (connectors.size() == 0) {
        MessageDialog.openInformation(shell, CrucibleUiPlugin.PLUGIN_ID,
                "Cannot create review. No Atlassian SCM provider found.");
        return;
    }

    if (selection.size() > 1
            || (selection.size() == 1 && selection.get(0) != null && selection.get(0).getLineRange() == null)) {
        // process workbench selection
        processWorkbenchSelection(selection, connectors.iterator().next(), shell);
    } else if (selection.size() == 1 && selection.get(0) != null && selection.get(0).getLineRange() != null) {
        // process editor selection
        processEditorSelection(selection.get(0), connectors.iterator().next(), shell);
    } else {
        // we should not be here
        handleError(shell, "Cannot determine selection.");
        return;
    }

}

From source file:com.atlassian.connector.eclipse.internal.crucible.ui.actions.AbstractReviewFromResourcesAction.java

License:Open Source License

protected void handleError(final Shell shell, String message) {
    StatusHandler.log(new Status(IStatus.WARNING, CrucibleUiPlugin.PLUGIN_ID, message));
    MessageDialog.openInformation(shell, CrucibleUiPlugin.PLUGIN_ID, message);
}

From source file:com.atlassian.connector.eclipse.internal.crucible.ui.dialogs.CrucibleAddFileAddCommentDialog.java

License:Open Source License

@Override
public boolean addComment() {

    // add file to review first if needed
    if (resource != null) {
        try {/*  w w  w .  ja  v  a 2s  .c om*/
            run(true, false, new AddFileToReviewRunable());
        } catch (InvocationTargetException e) {
            StatusHandler.log(new Status(IStatus.ERROR, CrucibleUiPlugin.PLUGIN_ID, e.getMessage(), e));
            setErrorMessage("Unable to add file to the review.");
            return false;
        } catch (InterruptedException e) {
            StatusHandler.log(new Status(IStatus.ERROR, CrucibleUiPlugin.PLUGIN_ID, e.getMessage(), e));
            setErrorMessage("Unable to add file to the review.");
            return false;
        }

        if (reviewItem == null) {
            StatusHandler.log(
                    new Status(IStatus.ERROR, CrucibleUiPlugin.PLUGIN_ID, "Adding file to review failed."));
            setErrorMessage("Unable to determine CrucibleFile.");
            return false;
        }

        if (review == null) {
            StatusHandler.log(new Status(IStatus.ERROR, CrucibleUiPlugin.PLUGIN_ID,
                    "Failed to refresh review after file was added."));
            setErrorMessage("Unable to refresh the review");
            return false;
        }

        setReview(review);
        setReviewItem(reviewItem);
    }

    // add comment
    boolean ok = super.addComment();
    if (ok && resource != null && decoratedResource != null && !decoratedResource.isUpToDate()) {
        MessageDialog.openInformation(getShell(), "",
                "Please reopen the file in Review Explorer in order to see comment annotation.");
    }

    return ok;
}

From source file:com.atlassian.connector.eclipse.internal.crucible.ui.wizards.ReviewWizard.java

License:Open Source License

@Override
public void addPages() {
    if (types.contains(Type.ADD_CHANGESET)) {
        addChangeSetsFromCruciblePage = new SelectChangesetsFromCruciblePage(getTaskRepository(),
                preselectedLogEntries);//from www .j a v  a 2  s.c o  m
        addPage(addChangeSetsFromCruciblePage);
    }

    if (types.contains(Type.ADD_PATCH)) {
        addPatchPage = new CrucibleAddPatchPage(getTaskRepository());
        addPage(addPatchPage);
    }

    // pre-commit
    if (types.contains(Type.ADD_WORKSPACE_PATCH)) {
        //         addWorkspacePatchPage = new WorkspacePatchSelectionPage(getTaskRepository(), selectedWorkspaceResources);
        //         addPage(addWorkspacePatchPage);
    }

    // post-commit for editor selection
    if (types.contains(Type.ADD_SCM_RESOURCES)) {

        if (selectedWorkspaceResources.size() > 0 && selectedWorkspaceResources.get(0) != null) {

            // single SCM integration selection supported
            final ITeamUiResourceConnector teamConnector = AtlassianTeamUiPlugin.getDefault()
                    .getTeamResourceManager().getTeamConnector(selectedWorkspaceResources.get(0));
            if (teamConnector == null) {
                MessageDialog.openInformation(getShell(), CrucibleUiPlugin.PRODUCT_NAME,
                        "Cannot find Atlassian SCM Integration for '"
                                + selectedWorkspaceResources.get(0).getName() + "'.");
            } else {
                boolean missingMapping = false;
                Collection<String> scmPaths = new ArrayList<String>();
                // TODO use job below if there are plenty of resource (currently it is used for single resource)
                for (IResource resource : selectedWorkspaceResources) {
                    try {
                        LocalStatus status = teamConnector.getLocalRevision(resource);
                        if (status.getScmPath() != null && status.getScmPath().length() > 0) {
                            String scmPath = TeamUiUtils.getScmPath(resource, teamConnector);

                            if (TaskRepositoryUtil.getMatchingSourceRepository(
                                    TaskRepositoryUtil.getScmRepositoryMappings(getTaskRepository()),
                                    scmPath) == null) {
                                // we need to see mapping page
                                missingMapping = true;
                                scmPaths.add(scmPath);
                            }

                        }
                    } catch (CoreException e) {
                        // resource is probably not under version control
                        // skip
                    }
                }

                if (missingMapping) {
                    defineMappingPage = new DefineRepositoryMappingsPage(scmPaths, getTaskRepository());
                    addPage(defineMappingPage);
                }
            }
        }
    }

    // mixed review
    if (types.contains(Type.ADD_RESOURCES)) {
        resourceSelectionPage = new ResourceSelectionPage(getTaskRepository(), selectedWorkspaceTeamConnector,
                selectedWorkspaceResources);
        addPage(resourceSelectionPage);
    }

    // only add details page if review is not already existing
    if (crucibleReview == null) {
        detailsPage = new CrucibleReviewDetailsPage(getTaskRepository(),
                types.contains(Type.ADD_COMMENT_TO_FILE));
        addPage(detailsPage);
    }
}

From source file:com.atlassian.connector.eclipse.team.ui.TeamUiMessageUtils.java

License:Open Source License

private static void internalOpenFileDeletedErrorMessage(String repoUrl, String filePath, String revision) {
    String message = "Unable to open file.  Please check that:\n\n" + getErrorHints();
    MessageDialog.openInformation(null, MESSAGE_DIALOG_TITLE, message);
}

From source file:com.atlassian.connector.eclipse.team.ui.TeamUiMessageUtils.java

License:Open Source License

private static void internalOpenUnableToCompareErrorMessage(String repoUrl, String filePath, String oldRevision,
        String newRevision, Throwable e) {
    String message = "Unable to compare revisions. ";

    if (e != null) {
        message += "Following exception was catched:\n\n";
        message += e.getMessage();/*from   w  w w.jav  a  2 s . co m*/
        message += "\n\n";
    }

    message += "Please check that:\n\n" + getErrorHints();
    message += "\n\nPlease check also Error Log for details.";
    MessageDialog.openInformation(null, MESSAGE_DIALOG_TITLE, message);
}

From source file:com.b3dgs.lionengine.editor.utility.dialog.UtilDialog.java

License:Open Source License

/**
 * Show an info dialog.//from w w w  .j  av  a 2  s.  c  o m
 * 
 * @param parent The parent shell.
 * @param title The info title.
 * @param message The info message.
 */
public static void info(Shell parent, String title, String message) {
    MessageDialog.openInformation(parent, title, message);
}

From source file:com.beck.ep.team.TFMPlugin.java

License:BSD License

public static void showMessage(Shell shell, String message) {
    MessageDialog.openInformation(shell, "Team File List", message);
}

From source file:com.bluexml.side.Class.modeler.ClazzPlugin.java

License:Open Source License

/**
 * Display a dialog box with the specified level
 * // w  w w .  j  a  va  2s.  c  om
 * @param title title dialog box
 * @param message message displayed
 * @param level message level
 * @_generated
 */
public static void displayDialog(final String title, final String message, int level) {
    if (level == IStatus.INFO) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                MessageDialog.openInformation(getActiveWorkbenchShell(),
                        (title == null) ? "Information" : title, (message == null) ? "" : message);
            }
        });
    } else if (level == IStatus.WARNING) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                MessageDialog.openWarning(getActiveWorkbenchShell(), (title == null) ? "Warning" : title,
                        (message == null) ? "" : message);
            }
        });
    } else if (level == IStatus.ERROR) {
        Display.getDefault().asyncExec(new Runnable() {
            public void run() {
                MessageDialog.openError(getActiveWorkbenchShell(), (title == null) ? "Error" : title,
                        (message == null) ? "" : message);
            }
        });
    }
}