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

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

Introduction

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

Prototype

int WARNING

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

Click Source Link

Document

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

Usage

From source file:org.rssowl.ui.internal.dialogs.importer.ImportWizard.java

License:Open Source License

private boolean doImport() {

    /* Collect Elements to Import */
    List<IFolderChild> folderChilds = fImportElementsPage.getFolderChildsToImport();
    boolean isRSSOwlOPML = isRSSOwlOPMLImport(folderChilds);
    if (fImportElementsPage.excludeExisting())
        folderChilds = excludeExisting(folderChilds);

    /* Check for Errors First */
    if (StringUtils.isSet(fImportElementsPage.getErrorMessage())) {
        getContainer().showPage(fImportElementsPage);
        return false;
    }// w  w w.j a  v  a 2  s.co m

    List<ILabel> labels = fImportElementsPage.getLabelsToImport();
    List<ISearchFilter> filters = fImportElementsPage.getFiltersToImport();
    List<IPreference> preferences = fImportElementsPage.getPreferencesToImport();

    /* Normalize Elements to Import */
    CoreUtils.normalize(folderChilds);

    /* Get Target Location (may be null) */
    IFolder target = fIsWelcome ? null : fImportTargetPage.getTargetLocation();

    /* Get Options */
    boolean importLabels = fImportOptionsPage.importLabels();
    if (!importLabels)
        labels = null;

    boolean importFilters = fImportOptionsPage.importFilters();
    if (!importFilters)
        filters = null;

    boolean importPreferences = fImportOptionsPage.importPreferences();
    if (!importPreferences)
        preferences = null;

    /* Show warning and ask for confirmation if preferences should be imported */
    if (!fIsWelcome && importPreferences && preferences != null && !preferences.isEmpty()) {
        MessageDialog dialog = new MessageDialog(getShell(), Messages.ImportWizard_ATTENTION, null,
                Messages.ImportWizard_PREFERENCE_OVERWRITE, MessageDialog.WARNING,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        if (dialog.open() != 0)
            return false;
    }

    /* Run Import */
    ImportUtils.doImport(target, folderChilds, labels, filters, preferences, !fIsWelcome);

    /* Add Default Saved Searches if this is from Welcome Wizard */
    if (fIsWelcome && !isRSSOwlOPML && !importLabels && !importFilters && !importPreferences)
        addDefaultSearches();

    /* Save Settings of Pages */
    fImportSourcePage.saveSettings();

    /* Ask for a restart if preferences have been imported */
    if (importPreferences && preferences != null && !preferences.isEmpty()) {
        boolean restart = MessageDialog.openQuestion(getShell(), Messages.ImportWizard_RESTART_RSSOWL,
                Messages.ImportWizard_RESTART_RSSOWL_INFO);
        if (restart) {
            BookMarkExplorer explorer = OwlUI.getOpenedBookMarkExplorer();
            if (explorer != null)
                explorer.saveStateOnDispose(false);

            Controller.getDefault().restart();
            return true;
        }
    }

    /* Reveal and Select Target Folder */
    if (target != null && target.getParent() != null) {
        BookMarkExplorer explorer = OwlUI.getOpenedBookMarkExplorer();
        if (explorer != null)
            explorer.reveal(target, true);
    }

    /* Reload Imported Elements */
    new ReloadTypesAction(new StructuredSelection(folderChilds), OwlUI.getPrimaryShell()).run();

    /* Force to rerun saved searches */
    JobRunner.runDelayedInBackgroundThread(new Runnable() {
        public void run() {
            Controller.getDefault().getSavedSearchService().updateSavedSearches(true);
        }
    });

    return true;
}

From source file:org.rssowl.ui.internal.dialogs.properties.GeneralPropertyPage.java

License:Open Source License

private boolean internalPerformSingle(Set<IEntity> entitiesToSave) {
    IEntity entity = fEntities.get(0);//from  w w w .j a  v a 2s. co m

    /* Require a Link */
    if (entity instanceof IBookMark && fFeedInput.getText().length() == 0) {
        fSite.select(this);
        fFeedInput.setFocus();

        fSite.setMessage(Messages.GeneralPropertyPage_ENTER_LINK, IPropertyDialogSite.MessageType.ERROR);

        return false;
    }

    /* Require a Name */
    if (fNameInput.getText().length() == 0) {
        fSite.select(this);
        fNameInput.setFocus();

        if (entity instanceof IFolder)
            fSite.setMessage(Messages.GeneralPropertyPage_ENTER_NAME_FOLDER,
                    IPropertyDialogSite.MessageType.ERROR);
        else if (entity instanceof IBookMark)
            fSite.setMessage(Messages.GeneralPropertyPage_ENTER_NAME_BOOKMARK,
                    IPropertyDialogSite.MessageType.ERROR);
        else if (entity instanceof INewsBin)
            fSite.setMessage(Messages.GeneralPropertyPage_ENTER_NAME_BIN,
                    IPropertyDialogSite.MessageType.ERROR);

        return false;
    }

    /* Update Folder */
    if (entity instanceof IFolder) {
        IFolder folder = (IFolder) entity;

        /* Name */
        if (!folder.getName().equals(fNameInput.getText())) {
            folder.setName(fNameInput.getText());
            entitiesToSave.add(folder);
        }
    }

    /* Update BookMark */
    else if (entity instanceof IBookMark) {
        IBookMark bookmark = (IBookMark) entity;

        /* Check for changed Name */
        if (!bookmark.getName().equals(fNameInput.getText())) {
            bookmark.setName(fNameInput.getText());
            entitiesToSave.add(bookmark);
        }

        /* Append "http" to Link if missing */
        String uriAsString = URIUtils.fastEncode(fFeedInput.getText());
        if (URIUtils.looksLikeLink(uriAsString))
            uriAsString = URIUtils.ensureProtocol(uriAsString);

        /* Check for changed Feed */
        if (!fIsSingleSynchronizedBookMark
                && !bookmark.getFeedLinkReference().getLinkAsText().equals(uriAsString)) {

            /* Check if this operation has the potential of deleting existing news */
            boolean containsNews = ModelUtils.countNews(bookmark) > 0;
            if (containsNews) {
                String msg = Messages.GeneralPropertyPage_CHANGE_LINK_WARNING;
                MessageDialog dialog = new MessageDialog(fParent.getShell(),
                        Messages.GeneralPropertyPage_WARNING, null, msg, MessageDialog.WARNING,
                        new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1);
                if (dialog.open() == IDialogConstants.CANCEL_ID)
                    return false;
            }

            try {
                DAOService daoService = Owl.getPersistenceService().getDAOService();

                /* Create URL */
                URI newFeedLink = new URI(uriAsString.trim());
                fReloadRequired = true;

                /* This is a new Feed, so create it! */
                if (!daoService.getFeedDAO().exists(newFeedLink)) {
                    IFeed feed = Owl.getModelFactory().createFeed(null, newFeedLink);
                    feed = DynamicDAO.save(feed);
                }

                /* Check if the old reference can be deleted now */
                FeedLinkReference oldFeedRef = bookmark.getFeedLinkReference();
                if (daoService.getBookMarkDAO().loadAll(oldFeedRef).size() == 1)
                    DynamicDAO.delete(oldFeedRef.resolve());

                /* Apply the new Reference */
                bookmark.setFeedLinkReference(new FeedLinkReference(newFeedLink));
                entitiesToSave.add(bookmark);

                /* Delete the Favicon since the feed has changed */
                OwlUI.deleteImage(bookmark.getId());
            }

            /* Supplied Feed Link not valid */
            catch (URISyntaxException e) {
                fSite.select(this);
                fFeedInput.selectAll();
                fFeedInput.setFocus();
                fSite.setMessage(Messages.GeneralPropertyPage_INVALID_LINK,
                        IPropertyDialogSite.MessageType.ERROR);
                return false;
            }
        }
    }

    /* Update NewsBin */
    else if (entity instanceof INewsBin) {
        INewsBin newsbin = (INewsBin) entity;

        /* Check for changed Name */
        if (!newsbin.getName().equals(fNameInput.getText())) {
            newsbin.setName(fNameInput.getText());
            entitiesToSave.add(newsbin);
        }
    }

    return true;
}

From source file:org.rssowl.ui.internal.dialogs.UpdateDialog.java

License:Open Source License

@Override
protected void okPressed() {

    /* Show an Extra Warning if Update will Fail due to missing write Permissions */
    if (!fCanUpdate) {
        MessageDialog dialog = new MessageDialog(getShell(), Messages.UpdateDialog_WARNING, null,
                Messages.UpdateDialog_MISSING_PERMISSIONS_WARNING, MessageDialog.WARNING,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        if (dialog.open() != 0)
            return;
    }/*from  w  w  w .  j a  v  a 2  s.com*/

    super.okPressed();
}

From source file:org.rubypeople.rdt.internal.ui.text.ruby.ContentAssistProcessor.java

License:Open Source License

/**
 * Informs the user about the fact that there are no enabled categories in the default content
 * assist set and shows a link to the preferences.
 * /*from   w w w  .j ava  2 s .  c  o m*/
 * @since 3.3
 */
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = RubyPlugin.getActiveWorkbenchShell();
        String title = RubyTextMessages.ContentAssistProcessor_all_disabled_title;
        String message = RubyTextMessages.ContentAssistProcessor_all_disabled_message;
        // see PreferencePage#createControl for the 'defaults' label
        final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
        final String linkMessage = Messages.format(
                RubyTextMessages.ContentAssistProcessor_all_disabled_preference_link,
                LegacyActionTools.removeMnemonics(restoreButtonLabel));
        final int restoreId = IDialogConstants.CLIENT_ID + 10;
        final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY,
                shell, title, null /* default image */, message, MessageDialog.WARNING,
                new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
            /*
             * @see org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            protected Control createCustomArea(Composite composite) {
                // wrap link and checkbox in one composite without space
                Composite parent = new Composite(composite, SWT.NONE);
                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                parent.setLayout(layout);

                Composite linkComposite = new Composite(parent, SWT.NONE);
                layout = new GridLayout();
                layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
                layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
                linkComposite.setLayout(layout);

                Link link = new Link(linkComposite, SWT.NONE);
                link.setText(linkMessage);
                link.addSelectionListener(new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent e) {
                        close();
                        PreferencesUtil.createPreferenceDialogOn(shell,
                                "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                                .open();
                    }
                });
                GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
                gridData.widthHint = this.getMinimumMessageWidth();
                link.setLayoutData(gridData);

                // create checkbox and "don't show this message" prompt
                super.createCustomArea(parent);

                return parent;
            }

            /*
             * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
             */
            protected void createButtonsForButtonBar(Composite parent) {
                Button[] buttons = new Button[2];
                buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
                buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL,
                        true);
                setButtons(buttons);
            }
        };
        if (restoreId == dialog.open()) {
            IPreferenceStore store = RubyPlugin.getDefault().getPreferenceStore();
            store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
            store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
            registry.reload();
            return true;
        }
    }
    return false;
}

From source file:org.summer.sdt.internal.ui.text.java.ContentAssistProcessor.java

License:Open Source License

/**
 * Informs the user about the fact that there are no enabled categories in the default content
 * assist set and shows a link to the preferences.
 *
 * @return  <code>true</code> if the default should be restored
 * @since 3.3/*  w w  w.  j  a  v  a  2  s .  co m*/
 */
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = JavaPlugin.getActiveWorkbenchShell();
        String title = JavaTextMessages.ContentAssistProcessor_all_disabled_title;
        String message = JavaTextMessages.ContentAssistProcessor_all_disabled_message;
        // see PreferencePage#createControl for the 'defaults' label
        final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
        final String linkMessage = Messages.format(
                JavaTextMessages.ContentAssistProcessor_all_disabled_preference_link,
                LegacyActionTools.removeMnemonics(restoreButtonLabel));
        final int restoreId = IDialogConstants.CLIENT_ID + 10;
        final int settingsId = IDialogConstants.CLIENT_ID + 11;
        final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY,
                shell, title, null /* default image */, message, MessageDialog.WARNING,
                new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
            /*
             * @see org.summer.sdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            @Override
            protected Control createCustomArea(Composite composite) {
                // wrap link and checkbox in one composite without space
                Composite parent = new Composite(composite, SWT.NONE);
                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                parent.setLayout(layout);

                Composite linkComposite = new Composite(parent, SWT.NONE);
                layout = new GridLayout();
                layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
                layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
                linkComposite.setLayout(layout);

                Link link = new Link(linkComposite, SWT.NONE);
                link.setText(linkMessage);
                link.addSelectionListener(new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        setReturnCode(settingsId);
                        close();
                    }
                });
                GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
                gridData.widthHint = this.getMinimumMessageWidth();
                link.setLayoutData(gridData);

                // create checkbox and "don't show this message" prompt
                super.createCustomArea(parent);

                return parent;
            }

            /*
             * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
             */
            @Override
            protected void createButtonsForButtonBar(Composite parent) {
                Button[] buttons = new Button[2];
                buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
                buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL,
                        true);
                setButtons(buttons);
            }
        };
        int returnValue = dialog.open();
        if (restoreId == returnValue || settingsId == returnValue) {
            if (restoreId == returnValue) {
                IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
                store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
                store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            }
            if (settingsId == returnValue)
                PreferencesUtil
                        .createPreferenceDialogOn(shell,
                                "org.summer.sdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                        .open();
            fComputerRegistry.reload();
            return true;
        }
    }
    return false;
}

From source file:org.talend.componentdesigner.ui.preferencepage.ComponentProjectPreferencePage.java

License:Open Source License

public void propertyChange(PropertyChangeEvent event) {

    super.propertyChange(event);

    MessageDialog warningMessageDialog = new MessageDialog(getFieldEditorParent().getShell(),
            Messages.getString("ComponentProjectPreferencePage.Warning"), null, //$NON-NLS-1$
            Messages.getString("ComponentProjectPreferencePage.WarningMSG"), MessageDialog.WARNING, //$NON-NLS-1$
            new String[] { Messages.getString("ComponentProjectPreferencePage.ButtonLabel0") }, 0); //$NON-NLS-1$
    warningMessageDialog.open();//from w w w  .  ja  v a2 s.c  om
}

From source file:org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.java

License:Open Source License

/**
 * DOC bZhou Comment method "showDialog".
 * /*from www .ja v a 2 s  .c  o  m*/
 * @param parentShell
 * @param file
 * @param dependencyElements
 * @param dialogMessage
 * @return
 */
public static boolean showDialog(Shell parentShell, Object obj, ModelElement[] dependencyElements,
        String dialogMessage, boolean isNeedCheckbox) {
    // MOD qiongli 2011-3-1 feature 17588.return boolean,add 'dialog.setNeedCheckbox(true)'
    for (ModelElement element : dependencyElements) {
        ImpactNode node = new ImpactNode(element);
        if (!impactNodes.contains(node)) {
            node.addRequireModelElement(obj);
            impactNodes.add(node);
        }
    }

    ImpactNode[] impactElements = getImpactNodes();
    boolean isChecked = false;
    if (impactElements.length > 0) {
        TreeMessageInfoDialog dialog = new TreeMessageInfoDialog(parentShell,
                DefaultMessagesImpl.getString("DeleteModelElementConfirmDialog.confirmResourceDelete"), null, //$NON-NLS-1$
                dialogMessage, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 1);
        dialog.setNeedCheckbox(isNeedCheckbox);
        dialog.setContentProvider(new DialogContentProvider(impactElements));
        dialog.setInput(new Object());
        clear();
        // MOD qiongli 2012-1-6 if don't click OK button,should return false;
        int result = dialog.open();
        isChecked = dialog.isChecked() && (result == Window.OK);

    }

    return isChecked;
}

From source file:org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.java

License:Open Source License

/**
 * //www .  j a v a2  s  .  c  om
 * DOC qiongli Comment method "showDialog".
 * 
 * @param parentShell
 * @param repositoryNodes
 * @param dependencyElements
 * @param dialogMessage
 * @return
 */
public static int showDialog(Shell parentShell, List<IRepositoryNode> repositoryNodes, String dialogMessage) {
    for (IRepositoryNode repNode : repositoryNodes) {
        List<ModelElement> dependencies = EObjectHelper.getDependencyClients(repNode);
        Object object = RepositoryNodeHelper.getModelElementFromRepositoryNode(repNode);
        for (ModelElement element : dependencies) {
            ImpactNode node = new ImpactNode(element);
            if (!impactNodes.contains(node)) {
                node.addRequireModelElement(object);
                impactNodes.add(node);
            } else if (!Arrays.asList(node.getChildren()).contains(object)) {
                int index = impactNodes.indexOf(node);
                if (index != -1) {
                    impactNodes.get(index).addRequireModelElement(object);
                }
            }
        }
    }
    ImpactNode[] impactElements = getImpactNodes();
    if (impactElements.length > 0) {
        TreeMessageInfoDialog dialog = new TreeMessageInfoDialog(parentShell,
                DefaultMessagesImpl.getString("DeleteModelElementConfirmDialog.confirmResourceDelete"), null, //$NON-NLS-1$
                dialogMessage, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 1);
        dialog.setContentProvider(new DialogContentProvider(impactElements));
        dialog.setInput(new Object());
        clear();
        return dialog.open();
    }

    return Window.CANCEL;
}

From source file:org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.java

License:Open Source License

/**
 * DOC bzhou Comment method "showConfirmDialog".
 * /*www  .j  a v a 2s  .c  om*/
 * @param parentShell
 * @param obj
 * @param dependencyElements
 * @param dialogMessage
 * @return
 */
public static int showConfirmDialog(Shell parentShell, Object obj, ModelElement[] dependencyElements,
        String dialogTitle, String dialogMessage) {
    for (ModelElement element : dependencyElements) {
        ImpactNode node = new ImpactNode(element);
        if (!impactNodes.contains(node)) {
            node.addRequireModelElement(obj);
            impactNodes.add(node);
        }
    }

    ImpactNode[] impactElements = getImpactNodes();
    if (impactElements.length > 0) {
        TreeMessageInfoDialog dialog = new TreeMessageInfoDialog(parentShell, dialogTitle, null, dialogMessage,
                MessageDialog.WARNING,
                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
        dialog.setContentProvider(new DialogContentProvider(impactElements));
        dialog.setInput(new Object());
        clear();
        return dialog.open();
    }

    return Window.OK;
}

From source file:org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.java

License:Open Source License

/**
 * DOC rli Comment method "showDialog".//  ww  w .  j  a va 2  s .  co m
 * 
 * @param parentShell
 * @param modelElements
 * @param dialogMessage
 * @return
 */
public static int showDialog(Shell parentShell, ModelElement[] modelElements, String dialogMessage) {
    addDenpendencyElements(modelElements);
    ImpactNode[] impactElements = getImpactNodes();
    if (impactElements.length > 0) {
        TreeMessageInfoDialog dialog = new TreeMessageInfoDialog(parentShell,
                DefaultMessagesImpl.getString("DeleteModelElementConfirmDialog.confirmResourceDelete"), null, //$NON-NLS-1$
                dialogMessage, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 1);
        dialog.setContentProvider(new DialogContentProvider(impactElements));
        dialog.setInput(new Object());
        clear();
        dialog.open();
        return Window.CANCEL;
    } else {
        return popConfirmDialog(modelElements);
    }
}