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

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

Introduction

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

Prototype

public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
        int dialogImageType, int defaultIndex, String... dialogButtonLabels) 

Source Link

Document

Create a message dialog.

Usage

From source file:com.siteview.mde.internal.ui.editor.monitor.OverviewPage.java

License:Open Source License

private void activateExtensionPages(String activePageId) {
    MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(),
            MDEUIMessages.OverviewPage_extensionPageMessageTitle, null,
            MDEUIMessages.OverviewPage_extensionPageMessageBody, MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
    if (mdiag.open() != Window.OK)
        return;//from  w w w  .  j a  va  2 s.  com
    try {
        MonitorEditor monitorEditor = (MonitorEditor) getEditor();
        monitorEditor.addExtensionTabs();
        monitorEditor.setShowExtensions(true);
        monitorEditor.setActivePage(activePageId);
    } catch (PartInitException e) {
    } catch (BackingStoreException e) {
    }
}

From source file:com.siteview.mde.internal.ui.editor.product.IntroSection.java

License:Open Source License

private void handleNewIntro() {
    boolean needNewProduct = false;
    if (!productDefined()) {
        needNewProduct = true;/*from ww w  .  j  av a2  s.com*/
        MessageDialog mdiag = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(),
                MDEUIMessages.IntroSection_undefinedProductId, null,
                MDEUIMessages.IntroSection_undefinedProductIdMessage, MessageDialog.QUESTION,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        if (mdiag.open() != Window.OK)
            return;
    }
    ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct);
    WizardDialog dialog = new WizardDialog(MDEPlugin.getActiveWorkbenchShell(), wizard);
    dialog.create();
    if (dialog.open() == Window.OK) {
        String id = wizard.getIntroId();
        fIntroCombo.add(id, 0);
        fIntroCombo.setText(id);
        getIntroInfo().setId(id);
        addDependenciesAndPlugins();
    }
}

From source file:com.siteview.mde.internal.ui.launcher.LauncherUtilsStatusHandler.java

License:Open Source License

/**
 * Creates a message dialog using a syncExec in case we are launching in the background.
 * Dialog will be a question dialog with Yes, No and Cancel buttons.
 * @param message Message to use in the dialog
 * @return int representing the button clicked (-1 or 2 for cancel, 0 for yes, 1 for no).
 *///from w  w  w.ja  v  a2s  . c  om
private static Integer generateDialog(final String message) {
    final int[] result = new int[1];
    getDisplay().syncExec(new Runnable() {
        public void run() {
            String title = MDEUIMessages.LauncherUtils_title;
            MessageDialog dialog = new MessageDialog(getActiveShell(), title, null, message,
                    MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
                            IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
                    0);
            result[0] = dialog.open();
        }
    });
    return new Integer(result[0]);
}

From source file:com.siteview.mde.internal.ui.launcher.LauncherUtilsStatusHandler.java

License:Open Source License

private static void generateErrorDialog(final String title, final String message,
        final ILaunchConfiguration launchConfig, final String mode) {
    getDisplay().syncExec(new Runnable() {
        public void run() {
            Shell parentShell = getActiveShell();
            MessageDialog dialog = new MessageDialog(parentShell, title, null, message, MessageDialog.ERROR,
                    new String[] { MDEUIMessages.LauncherUtils_edit, IDialogConstants.OK_LABEL }, 1);
            int res = dialog.open();
            if (res == 0) {
                IStructuredSelection selection = new StructuredSelection(launchConfig);
                ILaunchGroup group = DebugUITools.getLaunchGroup(launchConfig, mode);
                String groupIdentifier = group == null ? IDebugUIConstants.ID_RUN_LAUNCH_GROUP
                        : group.getIdentifier();
                IStatus status = new Status(IStatus.OK, PDELaunchingPlugin.getPluginId(),
                        LauncherUtils.SELECT_WORKSPACE_FIELD, "", null); //$NON-NLS-1$
                DebugUITools.openLaunchConfigurationDialogOnGroup(parentShell, selection, groupIdentifier,
                        status);/* w w w.java 2 s. c  o  m*/
            }
        }
    });
}

From source file:com.siteview.mde.internal.ui.launcher.LaunchTerminationStatusHandler.java

License:Open Source License

private void handleOtherReasonsFoundInLog(final ILaunch launch) {
    Display.getDefault().asyncExec(new Runnable() {
        public void run() {
            try {
                File log = LaunchListener.getMostRecentLogFile(launch.getLaunchConfiguration());
                if (log != null && log.exists()) {
                    MessageDialog dialog = new MessageDialog(MDEPlugin.getActiveWorkbenchShell(),
                            MDEUIMessages.Launcher_error_title, null, // accept the default window icon
                            MDEUIMessages.Launcher_error_code13, MessageDialog.ERROR,
                            new String[] { MDEUIMessages.Launcher_error_displayInLogView,
                                    MDEUIMessages.Launcher_error_displayInSystemEditor,
                                    IDialogConstants.NO_LABEL },
                            OPEN_IN_ERROR_LOG_VIEW);
                    int dialog_value = dialog.open();
                    if (dialog_value == OPEN_IN_ERROR_LOG_VIEW) {
                        IWorkbenchPage page = MDEPlugin.getActivePage();
                        if (page != null) {
                            LogView errlog = (LogView) page.showView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
                            errlog.handleImportPath(log.getAbsolutePath());
                            errlog.sortByDateDescending();
                        }//from w  w  w  . java 2  s  .  c  om
                    } else if (dialog_value == OPEN_IN_SYSTEM_EDITOR) {
                        openInEditor(log);
                    }
                }
            } catch (CoreException e) {
            }
        }
    });
}

From source file:com.siteview.mde.internal.ui.wizards.imports.PluginImportWizard.java

License:Open Source License

public boolean performFinish() {
    page1.storeSettings();//w  ww  . j a  va  2  s  .  c  om
    ((BaseImportWizardSecondPage) page1.getNextPage()).storeSettings();
    final IMonitorModelBase[] models = getModelsToImport();
    int launchedConfiguration = getConflictingConfigurationsCount(models);
    if (launchedConfiguration > 0) {
        String message = launchedConfiguration == 1 ? MDEUIMessages.PluginImportWizard_runningConfigDesc
                : MDEUIMessages.PluginImportWizard_runningConfigsDesc;
        MessageDialog dialog = new MessageDialog(getShell(),
                MDEUIMessages.PluginImportWizard_runningConfigsTitle, null, message, MessageDialog.WARNING,
                new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);
        if (dialog.open() != IDialogConstants.OK_ID)
            return false;

    }
    if (page1.getImportType() == PluginImportOperation.IMPORT_FROM_REPOSITORY) {
        if (getContainer().getCurrentPage() instanceof BaseImportWizardSecondPage) {
            // ensure to set the models to import when finished is pressed without advancing to the repository pages
            page1.configureBundleImportPages(models);
        }
    }
    // finish contributed pages
    if (!page1.finishPages()) {
        return false;
    }
    doImportOperation(page1.getImportType(), models, page2.forceAutoBuild(), launchedConfiguration > 0,
            page1.getAlternateSourceLocations(), page1.getImportDescriptions());

    return true;
}

From source file:com.technophobia.substeps.editor.preferences.page.SubstepsPropertyPage.java

License:Open Source License

private ConfirmationStatus getConfirmationStatus(final IPath previousPath, final IPath newPath,
        final SubstepsFolderChangedListener folderChangeListener) {
    final MessageDialog messageDialog = new MessageDialog(getShell(), "Confirm", null,
            folderChangeListener.confirmationMessage(previousPath, newPath), MessageDialog.QUESTION_WITH_CANCEL,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);//from  ww  w.ja v a 2s .com
    final int status = messageDialog.open();

    return ConfirmationStatus.values()[status];
}

From source file:com.testify.ecfeed.ui.wizards.NewEcFileWizard.java

License:Open Source License

public boolean performFinish() {
    IFile file = fPage.createNewFile();/*from  w w w .  j  ava2  s.  c om*/
    try {

        if (file.getContents().read() != -1) {
            MessageDialog dialog = new MessageDialog(getShell(), Messages.WIZARD_FILE_EXISTS_TITLE,
                    Display.getDefault().getSystemImage(SWT.ICON_QUESTION), Messages.WIZARD_FILE_EXISTS_MESSAGE,
                    MessageDialog.QUESTION_WITH_CANCEL,
                    new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL },
                    IDialogConstants.OK_ID);
            if (dialog.open() != IDialogConstants.OK_ID) {
                return false;
            }
        }

        final IPath newFileFullPath = fPage.getContainerFullPath().append(fPage.getFileName());
        String modelName = newFileFullPath.removeFileExtension().lastSegment();
        RootNode model = new RootNode(modelName != null ? modelName : Constants.DEFAULT_NEW_ECT_MODEL_NAME);
        ByteArrayOutputStream ostream = new ByteArrayOutputStream();
        new EctSerializer(ostream).serialize(model);
        ByteArrayInputStream istream = new ByteArrayInputStream(ostream.toByteArray());
        file.setContents(istream, true, true, null);

        //open new file in an ect editor
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

        page.openEditor(new FileEditorInput(file), Constants.ECT_EDITOR_ID);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return true;
}

From source file:com.toedter.e4.demo.contacts.rap.views.DetailsView.java

License:Open Source License

@Inject
public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) {
    if (contact != null) {
        if (dirtyable.isDirty()) {
            MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null,
                    "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM,
                    new String[] { "Yes", "No" }, 0);
            dialog.create();/*from   ww w.  java2  s .  co m*/
            ThemeUtil.applyDialogStyles(engine, dialog.getShell());
            if (dialog.open() == Window.OK) {
                ParameterizedCommand saveCommand = commandService.createCommand("contacts.save",
                        Collections.EMPTY_MAP);
                handlerService.executeHandler(saveCommand);
            }
        }

        updatePartTitle(contact);
    } else {
        uiItem.setLabel("Details");
    }
    dirtyable.setDirty(false);
    detailComposite.update(contact);
}

From source file:com.toedter.e4.demo.contacts.swt.views.DetailsView.java

License:Open Source License

@Inject
public void setSelection(@Optional Contact contact) {
    if (contact != null) {
        if (dirtyable.isDirty()) {
            MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null,
                    "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
            dialog.create();//from  w  w w  .  ja  va 2 s  . c om
            if (engine != null) {
                ThemeUtil.applyDialogStyles(engine, dialog.getShell());
            }
            if (dialog.open() == Window.OK) {
                ParameterizedCommand saveCommand = commandService.createCommand("contacts.save",
                        Collections.EMPTY_MAP);
                handlerService.executeHandler(saveCommand);
            }
        }

        updatePartTitle(contact);
    } else {
        uiItem.setLabel("Details");
    }
    dirtyable.setDirty(false);
    detailComposite.update(contact);
}