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:org.eclipse.wst.server.ui.internal.ServerUIPlugin.java

License:Open Source License

/**
 * Prompts the user if the server is dirty. Returns true if the server was
 * not dirty or if the user decided to continue anyway. Returns false if
 * the server is dirty and the user chose to cancel the operation.
 *
 * @param shell a shell/*from w w  w.  j ava2s .co  m*/
 * @param server a server
 * @return boolean
 */
public static boolean promptIfDirty(Shell shell, IServer server) {
    if (server == null)
        return false;

    if (!(server instanceof IServerWorkingCopy))
        return true;

    String title = Messages.resourceDirtyDialogTitle;

    IServerWorkingCopy wc = (IServerWorkingCopy) server;
    if (wc.isDirty()) {
        String message = NLS.bind(Messages.resourceDirtyDialogMessage, server.getName());
        String[] labels = new String[] { Messages.resourceDirtyDialogContinue, IDialogConstants.CANCEL_LABEL };
        MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.INFORMATION, labels,
                0);

        if (dialog.open() != 0)
            return false;
    }

    return true;
}

From source file:org.eclipse.wst.xquery.set.internal.ui.dialogs.InfoLinkMessageDialog.java

License:Open Source License

public InfoLinkMessageDialog(Shell parentShell, String dialogTitle, String dialogMessage, String linkText,
        URL linkUrl) {//ww w.j  av  a 2s.c  om
    super(parentShell, dialogTitle, null, dialogMessage, MessageDialog.INFORMATION,
            new String[] { IDialogConstants.OK_LABEL }, 0);
    fLinkText = linkText;
    fLinkUrl = linkUrl;
}

From source file:org.eclipse.wst.xquery.set.internal.ui.handlers.SETCoreSDKCommandHandler.java

License:Open Source License

protected IJobChangeListener createSuccessListener(final IProject project) {
    JobChangeAdapter successListener = new JobChangeAdapter() {
        @Override//  w w w .j a va  2 s . com
        public void done(IJobChangeEvent event) {
            IStatus result = event.getResult();
            if (result.isOK()) {
                Display.getDefault().syncExec(new Runnable() {
                    public void run() {
                        MessageDialog md = new MessageDialog(Display.getDefault().getActiveShell(),
                                getProjectActionLabel(project), null, getSuccessMessage(project),
                                MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0);
                        md.open();
                    }
                });
            }
        }
    };
    return successListener;
}

From source file:org.eclipse.xtext.xtext.ui.editor.quickfix.XtextGrammarQuickfixProvider.java

License:Open Source License

@Fix(INVALID_PACKAGE_REFERENCE_EXTERNAL)
public void fixExternalImportedPackage(final Issue issue, IssueResolutionAcceptor acceptor) {
    if (issue.getData().length == 1)
        acceptor.accept(issue, "Update the imported package '" + issue.getData()[0] + "'",
                "Fix the bogus package import\n" + "import '" + issue.getData()[0] + "'", NULL_QUICKFIX_IMAGE,
                new IModification() {
                    @Override//  w w w.j  a  v  a2  s  . c om
                    public void apply(IModificationContext context) throws BadLocationException {
                        String replaceString = valueConverterService.toString(issue.getData()[0], "STRING");
                        IXtextDocument document = context.getXtextDocument();
                        final List<String> importedPackages = document
                                .priorityReadOnly(new IUnitOfWork<List<String>, XtextResource>() {

                                    @Override
                                    public List<String> exec(XtextResource state) throws Exception {
                                        IResourceDescriptions descriptions = resourceDescriptionsProvider
                                                .getResourceDescriptions(state);
                                        ResourceSet resourceSet = state.getResourceSet();
                                        final Map<URI, URI> uriMap = Maps.newHashMap();
                                        EPackage ePackage = loadPackageFromIndex(descriptions, resourceSet,
                                                uriMap, issue.getData()[0]);
                                        if (ePackage != null) {
                                            final Map<String, EPackage> packagePerNsURI = Maps.newHashMap();
                                            packagePerNsURI.put(ePackage.getNsURI(), ePackage);
                                            final Set<URI> updatedReferences = fixReferencesInPackages(ePackage,
                                                    packagePerNsURI, uriMap, descriptions, resourceSet);
                                            if (updatedReferences.isEmpty())
                                                return null;
                                            Iterator<EPackage> iterator = packagePerNsURI.values().iterator();
                                            while (iterator.hasNext()) {
                                                EPackage pack = iterator.next();
                                                Resource resource = pack.eResource();
                                                if (!resource.getURI().isPlatformResource()) {
                                                    iterator.remove();
                                                }
                                            }
                                            final List<String> result = Lists.newArrayList();
                                            new WorkspaceModifyOperation( /* workspace lock */ ) {

                                                @Override
                                                protected void execute(IProgressMonitor monitor)
                                                        throws CoreException, InvocationTargetException,
                                                        InterruptedException {
                                                    try {
                                                        for (EPackage pack : packagePerNsURI.values()) {
                                                            Resource resource = pack.eResource();
                                                            resource.save(Collections.singletonMap(
                                                                    XMLResource.OPTION_URI_HANDLER,
                                                                    new URIHandlerImpl.PlatformSchemeAware() {
                                                                        @Override
                                                                        public URI deresolve(URI uri) {
                                                                            // replace archive uris with platform:/plugin
                                                                            if (!uri.isArchive()
                                                                                    || !updatedReferences
                                                                                            .contains(uri)) {
                                                                                return super.deresolve(uri);
                                                                            }
                                                                            URI withoutFragment = uri
                                                                                    .trimFragment();
                                                                            if (uriMap.containsKey(
                                                                                    withoutFragment)) {
                                                                                withoutFragment = uriMap
                                                                                        .get(withoutFragment);
                                                                            }
                                                                            return super.deresolve(
                                                                                    withoutFragment
                                                                                            .appendFragment(uri
                                                                                                    .fragment()));
                                                                        }
                                                                    }));
                                                            result.add(resource.getURI().toString());
                                                        }
                                                    } catch (IOException ioe) {
                                                        throw new InvocationTargetException(ioe);
                                                    }
                                                }
                                            }.run(new NullProgressMonitor());

                                            for (int i = resourceSet.getResources().size() - 1; i >= 0; i--) {
                                                Resource resource = resourceSet.getResources().get(i);
                                                if (!resource.getContents().isEmpty()
                                                        && resource.getContents().get(0) instanceof GenModel) {
                                                    resourceSet.getResources().remove(i);
                                                }
                                            }
                                            return result;
                                        }
                                        return null;
                                    }

                                    private Set<URI> fixReferencesInPackages(EPackage ePackage,
                                            Map<String, EPackage> packagePerNsURI, Map<URI, URI> uriMap,
                                            IResourceDescriptions descriptions, ResourceSet resourceSet) {
                                        Set<URI> result = Sets.newHashSet();
                                        Map<EObject, Collection<Setting>> allReferences = EcoreUtil.CrossReferencer
                                                .find(Collections.singletonList(ePackage));
                                        for (final Setting setting : Iterables.concat(allReferences.values())) {
                                            if (setting.getEStructuralFeature().isChangeable()) {
                                                final Object referenced = setting.get(true);
                                                List<Object> references = null;
                                                if (referenced instanceof EObject) {
                                                    references = new AbstractList<Object>() {
                                                        @Override
                                                        public Object set(int index, Object element) {
                                                            setting.set(element);
                                                            return referenced;
                                                        }

                                                        @Override
                                                        public Object get(int index) {
                                                            return referenced;
                                                        }

                                                        @Override
                                                        public int size() {
                                                            return 1;
                                                        }
                                                    };
                                                } else {
                                                    @SuppressWarnings("unchecked")
                                                    List<Object> casted = (List<Object>) referenced;
                                                    references = casted;
                                                }
                                                for (int i = 0; i < references.size(); i++) {
                                                    if (references.get(i) instanceof EObject) {
                                                        EObject referencedEObject = (EObject) references.get(i);
                                                        EPackage transitive = EcoreUtil2.getContainerOfType(
                                                                referencedEObject, EPackage.class);
                                                        if (isRegisteredPackage(transitive)) {
                                                            if (referencedEObject instanceof EDataType)
                                                                continue;
                                                            if (referencedEObject == EcorePackage.Literals.EOBJECT)
                                                                continue;
                                                            EPackage fromWorkspace = packagePerNsURI
                                                                    .get(transitive.getNsURI());
                                                            if (fromWorkspace == null && !packagePerNsURI
                                                                    .containsKey(transitive.getNsURI())) {
                                                                fromWorkspace = loadPackageFromIndex(
                                                                        descriptions, resourceSet, uriMap,
                                                                        transitive.getNsURI());
                                                                packagePerNsURI.put(transitive.getNsURI(),
                                                                        fromWorkspace);
                                                            }
                                                            if (fromWorkspace != null) {
                                                                String fragment = transitive.eResource()
                                                                        .getURIFragment(referencedEObject);
                                                                EObject replacement = fromWorkspace.eResource()
                                                                        .getEObject(fragment);
                                                                if (replacement != null) {
                                                                    result.add(EcoreUtil.getURI(replacement));
                                                                    references.set(i, replacement);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        return result;
                                    }

                                    private boolean isRegisteredPackage(EPackage ePackage) {
                                        return ePackage != null && (ePackage.eResource() == null || ePackage
                                                .getNsURI().equals(ePackage.eResource().getURI().toString()));
                                    }

                                    private EPackage loadPackageFromIndex(IResourceDescriptions descriptions,
                                            ResourceSet resourceSet, Map<URI, URI> uriMap, String nsURI) {
                                        Iterable<IEObjectDescription> fixUs = descriptions.getExportedObjects(
                                                EcorePackage.Literals.EPACKAGE, QualifiedName.create(nsURI),
                                                false);
                                        for (IEObjectDescription description : fixUs) {
                                            if (description.getEObjectURI().isPlatformResource()) {
                                                EObject result = resourceSet
                                                        .getEObject(description.getEObjectURI(), true);
                                                if (result instanceof EPackage) {
                                                    return (EPackage) result;
                                                }
                                            }
                                        }
                                        URI genModelURI = EcorePlugin
                                                .getEPackageNsURIToGenModelLocationMap(false).get(nsURI);
                                        if (genModelURI != null) {
                                            Resource genmodelResource = resourceSet.getResource(genModelURI,
                                                    true);
                                            GenModel genModel = (GenModel) genmodelResource.getContents()
                                                    .get(0);
                                            for (GenPackage genPackage : genModel.getGenPackages()) {
                                                Object object = genPackage.eGet(
                                                        GenModelPackage.Literals.GEN_PACKAGE__ECORE_PACKAGE,
                                                        false);
                                                if (object instanceof EObject) {
                                                    EObject proxy = (EObject) object;
                                                    URI proxyURI = EcoreUtil.getURI(proxy);
                                                    URI resolvedProxyURI = proxyURI.resolve(genModelURI);
                                                    if (nsURI.equals(genPackage.getEcorePackage().getNsURI())) {
                                                        EPackage result = genPackage.getEcorePackage();
                                                        uriMap.put(result.eResource().getURI(),
                                                                resolvedProxyURI.trimFragment());
                                                        return result;
                                                    }
                                                }
                                            }
                                        }
                                        return null;
                                    }

                                });
                        String delimiter = document.get(issue.getOffset(), 1);
                        if (!replaceString.startsWith(delimiter)) {
                            replaceString = delimiter + replaceString.substring(1, replaceString.length() - 1)
                                    + delimiter;
                        }
                        document.replace(issue.getOffset(), issue.getLength(), replaceString);
                        if (importedPackages != null && !importedPackages.isEmpty()) {
                            final Shell shell = workbench.getActiveWorkbenchWindow().getShell();
                            shell.getDisplay().asyncExec(new Runnable() {
                                @Override
                                public void run() {
                                    String title = "Please update the Ecore2XtextDslProjectContributor that generates the language.";
                                    String message = "Please make sure that the Ecore2XtextDslProjectContributor that generates the language is up-to date.\n"
                                            + "Especially important is the registration of the referenced packages.\n"
                                            + "Please refer to the reference documentation for details.";

                                    MessageDialog dialog = new MessageDialog(shell, title, null, message,
                                            MessageDialog.INFORMATION,
                                            new String[] { "Open Documentation", "Close" }, 1);
                                    if (dialog.open() == 0) {
                                        try {
                                            workbench.getBrowserSupport().getExternalBrowser()
                                                    .openURL(new URL(GRAMMAR_LANG_DOC));
                                        } catch (Exception e) {
                                            // ignore
                                        }
                                    }
                                }
                            });

                        }
                    }
                });
}

From source file:org.entirej.framework.plugin.preferences.EntirejConnectionPreferencePage.java

License:Apache License

/**
 * Creates the field editors. Field editors are abstractions of the common
 * GUI blocks needed to manipulate various types of preferences. Each field
 * editor knows how to save and restore itself.
 *//*w ww . j  a v  a2s  .  com*/

@Override
public void createFieldEditors() {
    if (getElement() instanceof IProject) {
        addField(new LabelFieldEditor(getFieldEditorParent(), "Database Settings:"));
        addField(new LabelFieldEditor(getFieldEditorParent(), ""));

        final StringFieldEditor driver = new StringFieldEditor(EntireJFrameworkPlugin.P_DBDRIVER, "  &Driver:",
                getFieldEditorParent());
        addField(driver);
        final StringFieldEditor url = new StringFieldEditor(EntireJFrameworkPlugin.P_URL, "  &Connection URL:",
                getFieldEditorParent());
        addField(url);
        final StringFieldEditor schema = new StringFieldEditor(EntireJFrameworkPlugin.P_SCHEMA, "  &Schema:",
                getFieldEditorParent());
        addField(schema);
        final StringFieldEditor user = new StringFieldEditor(EntireJFrameworkPlugin.P_USERNAME, "  User&name:",
                getFieldEditorParent());
        addField(user);
        final StringFieldEditor password = new StringFieldEditor(EntireJFrameworkPlugin.P_PASSWORD,
                "  P&assword:", getFieldEditorParent());
        password.getTextControl(getFieldEditorParent()).setEchoChar('*');
        addField(password);

        final IProject project = (IProject) getElement();

        new Label(getFieldEditorParent(), SWT.NONE);
        final Button test = new Button(getFieldEditorParent(), SWT.PUSH);
        test.setText("Validate");
        addField(new LabelFieldEditor(getFieldEditorParent(), "") {

            @Override
            public void setEnabled(boolean enabled, Composite parent) {
                super.setEnabled(enabled, parent);
                test.setEnabled(enabled);
            }

            @Override
            public int getNumberOfControls() {
                return 1;
            }
        });

        new Label(getFieldEditorParent(), SWT.NONE);
        test.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent evt) {
                final String driverV = driver.getStringValue();
                final String urlV = url.getStringValue();
                final String schemaV = schema.getStringValue();
                final String userV = user.getStringValue();
                final String passV = password.getStringValue();
                final IRunnableWithProgress activation = new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor) {
                        try {
                            monitor.beginTask("Validating connection", 2);
                            monitor.worked(1);
                            try {

                                validConnection(driverV, urlV, schemaV, userV, passV, project);
                                final Display display = EJCorePlugin.getStandardDisplay();
                                display.asyncExec(new Runnable() {

                                    public void run() {
                                        // Validation error
                                        MessageDialog dialog = new MessageDialog(getShell(), //
                                                "Validation", //
                                                null, "Successfully validated!", MessageDialog.INFORMATION, //
                                                new String[] { IDialogConstants.OK_LABEL }, //
                                                0);
                                        dialog.open();
                                    }
                                });
                            } catch (EJDevFrameworkException e) {
                                final String error = e.getMessage();
                                final Display display = EJCorePlugin.getStandardDisplay();
                                display.asyncExec(new Runnable() {

                                    public void run() {
                                        // Validation error
                                        MessageDialog dialog = new MessageDialog(getShell(), //
                                                "Validation error", //
                                                null, error, MessageDialog.ERROR, //
                                                new String[] { IDialogConstants.OK_LABEL }, //
                                                0);
                                        dialog.open();
                                    }
                                });
                            }
                            monitor.worked(2);
                        } finally {
                            monitor.done();

                        }

                    }
                };
                ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
                try {
                    dialog.run(true, true, activation);
                } catch (InvocationTargetException e) {
                    EJCoreLog.log(e);
                } catch (InterruptedException e) {
                    EJCoreLog.log(e);
                }
            }
        });
    }

}

From source file:org.fusesource.ide.projecttemplates.wizards.pages.WhereToFindMoreTemplatesMessageDialog.java

License:Open Source License

public WhereToFindMoreTemplatesMessageDialog(Shell parentShell) {
    super(parentShell, Messages.newProjectWizardTemplatePageWhereToFindMoreExamples, null,
            Messages.newProjectWizardTemplatePageListOfOtherExamplesReposMessage, MessageDialog.INFORMATION, 0,
            IDialogConstants.OK_LABEL);/*  ww  w.ja v  a  2s. c  om*/
}

From source file:org.jboss.ide.eclipse.as.classpath.ui.ClasspathUIPlugin.java

License:Open Source License

public static void alert(String string) {
    MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            Messages.ClasspathUIPlugin_ALERT, Display.getDefault().getSystemImage(SWT.ICON_INFORMATION), string,
            MessageDialog.INFORMATION, new String[] { Messages.ClasspathUIPlugin_OK, }, 0);

    dialog.setBlockOnOpen(true);//from   w  w  w.  j ava2 s.  co m
    dialog.open();
}

From source file:org.jboss.tools.common.model.ui.reporting.ReportProblemWizard.java

License:Open Source License

private void showConfirmDialog() {
    final String filename = logFileName.getText();
    String message = NLS.bind(UIMessages.REPORT_PROBLEM_RESULT, filename);

    MessageDialog dialog = new MessageDialog(problemDescription.getShell(), "Info", null, message,
            MessageDialog.INFORMATION, new String[] { UIMessages.REPORT_PROBLEM_COPY_BUTTON, "Close" }, 1) {
        protected void buttonPressed(int buttonId) {
            if (buttonId == 0) {
                Clipboard clipboard = new Clipboard(problemDescription.getShell().getDisplay());
                try {
                    clipboard.setContents(new String[] { filename },
                            new Transfer[] { TextTransfer.getInstance() });
                } finally {
                    clipboard.dispose();
                }//from  w ww .  ja va  2s.co  m
            }
            super.buttonPressed(buttonId);
        }
    };
    dialog.open();
}

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.modeshape.rest.dialogs.PublishedLocationsDialog.java

License:Open Source License

/**
 * @param parentShell the dialog parent/*from   w ww.  j a  va 2 s.co  m*/
 * @param file the file whose workspaces it has been published on is being requested (never <code>null</code>)
 * @param workspaceLocations the workspace locations (never <code>null</code>)
 */
public PublishedLocationsDialog(Shell parentShell, IFile file,
        Collection<WorkspaceLocation> workspaceLocations) {
    super(parentShell, RestClientI18n.publishedLocationsDialogTitle,
            Activator.getDefault().getImage(ModeShape_IMAGE_16x),
            NLS.bind(RestClientI18n.publishedLocationsDialogMsg, file.getFullPath()), MessageDialog.INFORMATION,
            new String[] { IDialogConstants.OK_LABEL }, 0);

    CheckArg.isNotNull(workspaceLocations, "workspaceLocations"); //$NON-NLS-1$
    this.workspaceLocations = workspaceLocations;

    // make sure dialog is resizable
    setShellStyle(getShellStyle() | SWT.RESIZE);
}