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

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

Introduction

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

Prototype

int INFORMATION

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

Click Source Link

Document

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

Usage

From source file:com.genuitec.org.eclipse.egit.ui.internal.branch.CleanupUncomittedChangesDialog.java

License:Open Source License

/**
 * @param shell/*  ww  w  .ja v a 2  s .  c o m*/
 * @param dialogTitle
 * @param dialogMessage
 * @param repository
 * @param fileList
 */
public CleanupUncomittedChangesDialog(Shell shell, String dialogTitle, String dialogMessage,
        Repository repository, List<String> fileList) {
    super(shell, dialogTitle, INFO, dialogMessage, MessageDialog.INFORMATION, new String[] {}, -1);
    setShellStyle(getShellStyle() | SWT.SHELL_TRIM);
    this.repository = repository;
    this.fileList = fileList;
}

From source file:com.google.appraise.eclipse.ui.editor.AppraiseReviewTaskActivationListener.java

License:Open Source License

/**
 * Asks the user if they want to switch to the review branch, and performs
 * the switch if so./*from w w  w. j  a  v  a2 s  .c o m*/
 */
private void promptSwitchToReviewBranch(TaskRepository taskRepository, String reviewBranch) {
    MessageDialog dialog = new MessageDialog(null, "Appraise Review", null,
            "Do you want to switch to the review branch (" + reviewBranch + ")", MessageDialog.QUESTION,
            new String[] { "Yes", "No" }, 0);
    int result = dialog.open();
    if (result == 0) {
        Repository repo = AppraisePluginUtils.getGitRepoForRepository(taskRepository);
        try (Git git = new Git(repo)) {
            previousBranch = repo.getFullBranch();
            git.checkout().setName(reviewBranch).call();
        } catch (RefNotFoundException rnfe) {
            MessageDialog alert = new MessageDialog(null, "Oops", null, "Branch " + reviewBranch + " not found",
                    MessageDialog.INFORMATION, new String[] { "OK" }, 0);
            alert.open();
        } catch (Exception e) {
            AppraiseUiPlugin.logError("Unable to switch to review branch: " + reviewBranch, e);
        }
    }
}

From source file:com.google.gapid.widgets.Licenses.java

License:Apache License

public static void showLicensesDialog(Shell shell) {
    new MessageDialog(shell, Messages.LICENSES, null, Messages.LICENSES, MessageDialog.INFORMATION, 0,
            IDialogConstants.OK_LABEL) {
        @Override// w w w .ja  v  a2 s  .  co m
        protected boolean isResizable() {
            return true;
        }

        @Override
        protected Control createCustomArea(Composite parent) {
            Browser browser;
            try {
                browser = new Browser(parent, SWT.NONE);
            } catch (SWTError e) {
                // Failed to initialize the browser. Show it as a plain text widget.
                Text text = new Text(parent,
                        SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
                text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                text.setText(readLicenses(false));
                return text;
            }

            GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
            data.widthHint = 600;
            data.heightHint = 400;
            browser.setLayoutData(data);
            browser.setText(readLicenses(true));
            browser.addLocationListener(new LocationAdapter() {
                @Override
                public void changing(LocationEvent event) {
                    if ("about:blank".equals(event.location)) {
                        browser.setText(readLicenses(true));
                    }
                }
            });
            return browser;
        }
    }.open();
}

From source file:com.google.gapid.widgets.TextViewer.java

License:Apache License

public static void showViewTextPopup(Shell shell, Widgets widgets, String title,
        ListenableFuture<String> text) {
    new MessageDialog(shell, Messages.VIEW_DETAILS, null, title, MessageDialog.INFORMATION, 0,
            IDialogConstants.OK_LABEL) {
        protected LoadablePanel<Text> loadable;

        @Override/*from   ww  w .  j  ava 2  s.com*/
        protected boolean isResizable() {
            return true;
        }

        @Override
        protected Control createCustomArea(Composite parent) {
            loadable = new LoadablePanel<Text>(parent, widgets, panel -> new Text(panel,
                    SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL));
            loadable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

            loadable.startLoading();
            Rpc.listen(text, new UiErrorCallback<String, String, String>(parent, LOG) {
                @Override
                protected ResultOrError<String, String> onRpcThread(Rpc.Result<String> result) {
                    try {
                        return success(result.get());
                    } catch (RpcException e) {
                        return error(e.getMessage());
                    } catch (ExecutionException e) {
                        return error(e.getCause().toString());
                    }
                }

                @Override
                protected void onUiThreadSuccess(String result) {
                    loadable.getContents().setText(result);
                    loadable.stopLoading();
                }

                @Override
                protected void onUiThreadError(String error) {
                    loadable.showMessage(MessageType.Error, error);
                }
            });
            return loadable;
        }

        @Override
        protected Point getInitialSize() {
            Point size = super.getInitialSize();
            size.y = Math.max(size.y, INITIAL_MIN_HEIGHT);
            return size;
        }
    }.open();
}

From source file:com.googlecode.osde.internal.runtime.ShowKeysAction.java

License:Apache License

public void run(IAction action) {
    try {/*from   w w w  .  j ava  2  s .  c o  m*/
        ApplicationInformation appInfo = OpenSocialUtil.createApplicationInformation(file);
        ApplicationService service = Activator.getDefault().getApplicationService();
        final ApplicationImpl application = service.getApplication(appInfo.getAppId());
        if (application != null) {
            ImageDescriptor imageDescriptor = Activator.getDefault().getImageRegistry()
                    .getDescriptor("icons/icon_key.gif");
            MessageDialog dialog = new MessageDialog(shell, "Application information",
                    imageDescriptor.createImage(), "This is keys for accessing from external service.",
                    MessageDialog.INFORMATION, new String[] { "OK" }, 0) {
                @Override
                protected Control createCustomArea(Composite parent) {
                    Composite composite = new Composite(parent, SWT.NONE);
                    GridLayout gridLayout = new GridLayout();
                    gridLayout.numColumns = 2;
                    composite.setLayout(gridLayout);
                    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
                    composite.setLayoutData(layoutData);
                    Label label = new Label(composite, SWT.NONE);
                    label.setText("Title:");
                    label = new Label(composite, SWT.NONE);
                    label.setText(application.getTitle());
                    label = new Label(composite, SWT.NONE);
                    label.setText("Path:");
                    label = new Label(composite, SWT.NONE);
                    label.setText(application.getPath());
                    label = new Label(composite, SWT.NONE);
                    label.setText("Consumer Key:");
                    Text text = new Text(composite, SWT.BORDER | SWT.MULTI);
                    text.setText(application.getConsumerKey());
                    text.setEditable(false);
                    text.setSelection(0);
                    layoutData = new GridData(GridData.FILL_HORIZONTAL);
                    layoutData.heightHint = 20;
                    text.setLayoutData(layoutData);
                    label = new Label(composite, SWT.NONE);
                    label.setText("Consumer Secret:");
                    text = new Text(composite, SWT.BORDER | SWT.MULTI);
                    text.setText(application.getConsumerSecret());
                    text.setEditable(false);
                    text.setSelection(0);
                    layoutData = new GridData(GridData.FILL_HORIZONTAL);
                    layoutData.heightHint = 20;
                    text.setLayoutData(layoutData);
                    return parent;
                }
            };
            dialog.open();
        } else {
            MessageDialog.openWarning(shell, "Warning", "This application does not run yet.");
        }
    } catch (CoreException e) {
        MessageDialog.openError(shell, "Error", "Invalid gadget file. " + e.getMessage());
    } catch (ConnectionException e) {
        MessageDialog.openError(shell, "Error", "Shindig database not started yet.");
    } catch (ParserException e) {
        MessageDialog.openError(shell, "Error", "Invalid gadget file. " + e.getMessage());
    }
}

From source file:com.googlecode.osde.internal.shindig.ShowPublicCertificateAction.java

License:Apache License

public void run(IAction action) {
    ImageDescriptor imageDescriptor = Activator.getDefault().getImageRegistry()
            .getDescriptor("icons/icon_key.gif");
    MessageDialog dialog = new MessageDialog(shell, "Public Certificate", imageDescriptor.createImage(),
            "This is Public Certificate for OAuth.", MessageDialog.INFORMATION, new String[] { "OK" }, 0) {
        @Override//from   w ww. j av  a2  s  . com
        protected Control createCustomArea(Composite parent) {
            Composite composite = new Composite(parent, SWT.NONE);
            composite.setLayout(new GridLayout());
            GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
            composite.setLayoutData(layoutData);
            Text text = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
            text.setText(PUBLIC_CER);
            text.setSelection(0, PUBLIC_CER.length());
            text.setEditable(false);
            layoutData = new GridData(GridData.FILL_HORIZONTAL);
            layoutData.heightHint = 250;
            text.setLayoutData(layoutData);
            return parent;
        }
    };
    dialog.open();
}

From source file:com.htmlhifive.tools.codeassist.ui.view.OptionConfigureComposite.java

License:Apache License

/**
 * ??./*from  ww w  .  ja  va2 s  .c o m*/
 *
 * @throws CoreException ??.
 */
private void createComposite() throws CoreException {

    this.setLayoutData(new GridData(GridData.FILL_BOTH));
    this.setLayout(new GridLayout(1, false));
    // ??.
    Group optionGroup = new Group(this, SWT.None);
    optionGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    optionGroup.setText(UIMessages.UICL0001.getText());
    optionGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins(5, 5, 10, 5).create());

    // ?.
    Label optionPathLabel = new Label(optionGroup, SWT.None);
    GridData gdOptionPathLabel = new GridData();
    gdOptionPathLabel.horizontalSpan = 1;
    gdOptionPathLabel.grabExcessHorizontalSpace = false;
    gdOptionPathLabel.verticalAlignment = SWT.BEGINNING;
    optionPathLabel.setText(UIMessages.UICL0002.getText());
    optionPathLabel.setLayoutData(gdOptionPathLabel);

    // ??.
    optionPathText = new Text(optionGroup, SWT.BORDER);
    GridData gdText = new GridData(GridData.FILL_HORIZONTAL);
    gdText.horizontalSpan = 1;
    gdText.verticalAlignment = SWT.BEGINNING;
    optionPathText.setLayoutData(gdText);
    if (bean.getOptionFilePath() != null) {
        optionPathText.setText(bean.getOptionFilePath());
    }
    optionPathText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {

            updateBean();
        }

    });
    Composite btnCompsite = new Composite(optionGroup, SWT.None);
    btnCompsite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 5).create());
    btnCompsite.setLayoutData(GridDataFactory.fillDefaults().create());

    Button btnSelect = new Button(btnCompsite, SWT.None);
    btnSelect.setText(UIMessages.UIBT0001.getText());
    btnSelect.setLayoutData(GridDataFactory.fillDefaults().hint(60, -1).create());

    btnSelect.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            FileSelectionDialog dialog = new FileSelectionDialog(getShell(), UIMessages.UIDT0001.getText(),
                    UIMessages.UIDM0001.getText(), new String[] { H5CodeAssistCorePluginConst.EXTENTION_XML });
            dialog.setInitialSelection(
                    ResourcesPlugin.getWorkspace().getRoot().findMember(optionPathText.getText()));
            if (dialog.open() == Window.OK) {
                IFile file = (IFile) dialog.getFirstResult();
                optionPathText.setText(file.getFullPath().toString());
                updateBean();
            }
        }
    });

    Button btnExport = new Button(this, SWT.None);
    btnExport.setText(UIMessages.UIBT0002.getText());
    btnExport.setLayoutData(GridDataFactory.swtDefaults().hint(-1, -1).create());
    btnExport.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            SaveAsDialog dialog = new SaveAsDialog(getShell());
            dialog.setTitle(UIMessages.UIDT0003.getText());
            dialog.setHelpAvailable(false);
            dialog.setOriginalFile(getProject().getFile("h5-code-assist.xml"));
            if (dialog.open() == Window.OK) {
                IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(dialog.getResult());
                boolean fileExist = file.exists();
                InputStream is = H5CodeAssistCorePlugin.class.getClassLoader()
                        .getResourceAsStream("h5-code-assist.xml");
                try {
                    if (!fileExist) {
                        file.create(is, true, null);
                    } else {
                        file.setContents(is, IResource.DEPTH_INFINITE, null);
                    }
                    MessageDialog.open(MessageDialog.INFORMATION, getShell(), UIMessages.UIDT0004.getText(),
                            UIMessages.UIDM0002.format(file.getFullPath().toString()), SWT.None);
                } catch (CoreException e1) {
                    logger.log(UIMessages.UIEM0002, e1);
                    ErrorDialog.openError(getShell(), UIMessages.UIDT0002.getText(), e1.getMessage(),
                            e1.getStatus());
                } finally {
                    IOUtils.closeQuietly(is);
                }
            }

        }
    });

}

From source file:com.iw.plugins.spindle.ui.properties.ProjectPropertyPage.java

License:Mozilla Public License

private void doOk(IProgressMonitor monitor) throws CoreException {
    // store the values as properties
    IResource resource = (IResource) getElement();

    // resource.setPersistentProperty(
    // new QualifiedName("", PROJECT_TYPE_PROPERTY),
    // new Integer(TapestryProject.APPLICATION_PROJECT_TYPE).toString());

    resource.setPersistentProperty(new QualifiedName("", CONTEXT_ROOT_PROPERTY), fWebContextRoot.getText());

    resource.setPersistentProperty(new QualifiedName("", VALIDATE_WEBXML_PROPERTY),
            Boolean.toString(fValidateWebXML.getSelection()));

    final IProject workspaceProject = (IProject) (this.getElement().getAdapter(IProject.class));
    IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
        public void run(IProgressMonitor monitor) throws CoreException {
            if (fIsTapestryProjectCheck.getSelection()) {

                String projectName = workspaceProject.getProject().getName();
                String temp = fWebContextRoot.getText();
                createFolderIfRequired(projectName + temp);
                fNewProjectMetadata.setWebContext(temp);
                fNewProjectMetadata.setValidateWebXML(fValidateWebXML.getSelection());
                fNewProjectMetadata.saveProperties(monitor);
                IJavaProject jproject = getJavaProject();
                TapestryProject prj = getTapestryProject();
                if (prj == null) {
                    TapestryProject.addTapestryNature(jproject, true);
                } else {
                    prj.clearMetadata();
                }//w ww. j a  v  a2 s .co  m
                try {
                    if (jproject
                            .findType(TapestryCore.getString("TapestryComponentSpec.specInterface")) == null) {
                        MessageDialog dialog = new MessageDialog(getShell(), "Tapestry jars missing", null,
                                "Add the Tapestry jars to the classpath?", MessageDialog.INFORMATION,
                                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
                        // OK is the default
                        int result = dialog.open();
                        if (result == 0) {
                            List entries = Arrays.asList(jproject.getRawClasspath());
                            ArrayList useEntries = new ArrayList(entries);
                            useEntries.add(JavaCore.newContainerEntry(new Path(TapestryCore.CORE_CONTAINER)));
                            jproject.setRawClasspath(
                                    (IClasspathEntry[]) useEntries.toArray(new IClasspathEntry[entries.size()]),
                                    monitor);
                        }
                    }
                } catch (JavaModelException e) {
                    UIPlugin.log(e);
                }

            } else {
                TapestryProject.removeTapestryNature(getJavaProject());
            }

            if (fIsTapestryProjectCheck.getSelection()) {
                IProject project = getJavaProject().getProject();
                project.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
            }
        }

    };

    UIPlugin.getWorkspace().run(runnable, monitor);
}

From source file:com.mentor.nucleus.bp.core.util.UIUtil.java

License:Open Source License

/**
 * Note this "MessageDialog" currently only supports an array of 2 dialog button
 * labels.   This is why the result is a boolean.  It simply behaves in
 * a similar manner as if a yes/no question had been asked (offset 0 is
 * yes and offset 1 is no).   If additional buttons are ever needed this
 * will need to be modified to handle it.
 *//* w  w  w  . j a  v  a 2s.c om*/
public static boolean openMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage,
        String dialogMessage, BPMessageTypes dialogType, String[] dialogButtonLabels, int defaultIndex) {
    int standardDialogType = MessageDialog.WARNING;
    if (dialogType == BPMessageTypes.ERROR) {
        standardDialogType = MessageDialog.ERROR;
    } else if ((dialogType == BPMessageTypes.INFORMATION)) {
        standardDialogType = MessageDialog.INFORMATION;
    }
    boolean result = (defaultIndex == MessageDialog.OK);
    if (CoreUtil.IsRunningHeadless) {
        outputTextForheadlessRun(dialogType, dialogTitle, dialogMessage, "");
    } else {
        MessageDialog dialog = new MessageDialog(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
                standardDialogType, dialogButtonLabels, defaultIndex);
        dialog.setBlockOnOpen(true);
        int actualResult = dialog.open();
        result = MessageDialog.OK == actualResult;
    }
    return result;
}

From source file:com.mercatis.lighthouse3.ui.status.handler.ViewReasonHandler.java

License:Apache License

@Override
protected void execute(Object element) throws ExecutionException {
    if (element instanceof ManualStatusClearance) {
        ManualStatusClearance msc = (ManualStatusClearance) element;
        String message = "Cleared by: " + msc.getClearer() + "\n\n";
        message += msc.getReason() != null && !msc.getReason().equals("") ? msc.getReason()
                : "No reason defined";
        MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                "Manual Clearance Reason", null, message, MessageDialog.INFORMATION, new String[] { "Ok" }, 0);
        md.open();/*from  ww  w.  ja v a  2  s.c  o m*/
    }
}