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

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

Introduction

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

Prototype

int QUESTION

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

Click Source Link

Document

Constant for the question image, or a simple dialog with the question image and Yes/No buttons (value 3).

Usage

From source file:de.anbos.eclipse.easyshell.plugin.preferences.Initializer.java

License:Open Source License

private int migrate_check_pref_and_ask_user(IPreferenceStore store, Version version, List<String> prefList,
        int migrateState) {
    // if cancel or no just skip this time
    if (migrateState == 1 || migrateState == 2) {
        return migrateState;
    }//  w w  w .j  a  v  a2  s  . com
    boolean migrationPossible = false;
    for (String pref : prefList) {
        if (!store.isDefault(pref)) {
            migrationPossible = true;
            break;
        }
    }
    if (migrationPossible) {
        // ask user if not already asked and said yes
        if (migrateState != 0) {
            String title = Activator.getResourceString("easyshell.plugin.name");
            String question = MessageFormat.format(Activator.getResourceString("easyshell.question.migrate"),
                    version.getName());
            MessageDialog dialog = new MessageDialog(null, title, null, question, MessageDialog.QUESTION,
                    new String[] { "Yes", "No", "Cancel" }, 0); // no is the default
            migrateState = dialog.open();
        }
    }
    return migrateState;
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.MenuDataDialog.java

License:Open Source License

private void removeDialog() {
    // get the selected commands and referenced menus as lists
    List<CommandData> commands = new ArrayList<CommandData>();
    List<MenuData> menus = new ArrayList<MenuData>();
    // get the selected
    int index = commandCombo.getSelectionIndex();
    CommandData data = cmdList.get(index);
    commands.add(data);//from w  w w. j a v a2s  .  c  o m
    // get referenced menus and remove the the actual menus
    menus.addAll(MenuDataStore.instance().getRefencedBy(data.getId()));
    menus.remove(this.menuData);
    // ask user
    String commandNames = commandCombo.getItem(index);
    String title = null;
    String question = null;
    if (data.getPresetType() == PresetType.presetPluginAndUser) {
        title = Activator.getResourceString("easyshell.menu.editor.dialog.title.user.remove");
        question = MessageFormat.format(
                Activator.getResourceString("easyshell.menu.editor.dialog.question.user.remove"), commandNames);
    } else {
        title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove");
        question = MessageFormat.format(
                Activator.getResourceString("easyshell.menu.editor.dialog.question.remove"), commandNames);
    }
    int dialogImageType = MessageDialog.QUESTION;
    if (menus.size() > 0) {
        dialogImageType = MessageDialog.WARNING;
        String menuNames = "";
        for (MenuData menu : menus) {
            menuNames += menu.getNameExpanded() + "\n";
        }
        if (data.getPresetType() == PresetType.presetPluginAndUser) {
            title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove.user.menu");
            question = MessageFormat.format(
                    Activator.getResourceString("easyshell.menu.editor.dialog.question.remove.user.menu"),
                    commandNames, menuNames);
        } else {
            title = Activator.getResourceString("easyshell.menu.editor.dialog.title.remove.menu");
            question = MessageFormat.format(
                    Activator.getResourceString("easyshell.menu.editor.dialog.question.remove.menu"),
                    commandNames, menuNames);
        }
    }
    MessageDialog dialog = new MessageDialog(null, title, null, question, dialogImageType,
            new String[] { "Yes", "No" }, 1); // no is the default
    int result = dialog.open();
    if (result == 0) {
        for (MenuData menu : menus) {
            MenuDataStore.instance().delete(menu);
        }
        removeCommand(index, data);
        refreshCommandCombo();
    }
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.MenuPage.java

License:Open Source License

private void removeDialog() {
    // get the selected menus as lists
    List<MenuData> menus = new ArrayList<MenuData>();
    IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
    Iterator<?> elements = selection.iterator();
    while (elements.hasNext()) {
        MenuData data = (MenuData) elements.next();
        menus.add(data);// w  w w  . ja  v  a  2  s .  c o  m
    }
    if (menus.size() > 0) {
        String title = Activator.getResourceString("easyshell.menu.page.dialog.remove.title");
        String menuNames = "";
        for (MenuData menu : menus) {
            menuNames += menu.getNameExpanded() + "\n";
        }
        String question = MessageFormat
                .format(Activator.getResourceString("easyshell.menu.page.dialog.remove.question"), menuNames);
        MessageDialog dialog = new MessageDialog(null, title, null, question, MessageDialog.QUESTION,
                new String[] { "Yes", "No" }, 1); // no is the default
        int result = dialog.open();
        if (result == 0) {
            for (MenuData menu : menus) {
                MenuDataStore.instance().delete(menu);
            }
            refreshTableViewer();
        }
    }
}

From source file:de.fraunhofer.esk.ernest.core.cdt.wizards.GenerateSimulationWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    /* Initializing */
    final String projName = this.page.getProjName();
    final String projPath = this.page.getLocation() + "/" + this.page.getProjName();
    final String projTool = "MinGW GCC";

    /* If Project/Folder with this name already exists in path, ask override question (message dialog) */
    if (new java.io.File(projPath).exists()) {
        final MessageDialog dg = new MessageDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), UI_USERMSG_TITLE, null,
                UI_USERMSG_EXISTQST, MessageDialog.QUESTION,
                new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        /* override dialog returns
         * in case "yes" 0//from www . j  a va 2  s . com
         * in case "no" 1
         */
        if (dg.open() == 1) {
            return false;
        }
    }

    /*
     * ProgressMonitor, work parted in
     * 70% GenerateSimulationProject
     * 30% runGenerator
     */
    try {
        this.getContainer().run(true, true, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(UI_MONITOR_MAINTASKNAME, 100000);
                /* Generate Project */
                if (!new GenerateSimulationProject().createSimulationProj(projName, projPath, monitor, 70000,
                        projTool)) {
                    return;
                }
                if (monitor.isCanceled()) {
                    return;
                }

                /* Execute Generator */
                try {
                    GenerateSimulationWizard.this.runGenerator(GenerateSimulationWizard.this.file, projPath,
                            monitor, 30000);
                } catch (CoreException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                /* End Monitor */
                monitor.done();

            }
        });
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    return true;
}

From source file:de.ovgu.featureide.examples.wizards.ExampleNewWizardPage.java

License:Open Source License

/**
 * The <code>WizardDataTransfer</code> implementation of this
 * <code>IOverwriteQuery</code> method asks the user whether the existing
 * resource at the given path should be overwritten.
 * /*from   ww  w  .  jav a  2s .com*/
 * @param pathString
 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
 *         <code>"ALL"</code>, or <code>"CANCEL"</code>
 */
public String queryOverwrite(String pathString) {
    Path path = new Path(pathString);

    String messageString;
    // Break the message up if there is a file name and a directory
    // and there are at least 2 segments.
    if (path.getFileExtension() == null || path.segmentCount() < 2) {
        messageString = pathString + " already exists. Would you like to overwrite it?";
    } else {
        messageString = "Overwrite " + path.lastSegment() + " in folder "
                + path.removeLastSegments(1).toOSString() + " ?";
    }

    final MessageDialog dialog = new MessageDialog(getContainer().getShell(), "Question", null, messageString,
            MessageDialog.QUESTION,
            new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL,
                    IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL,
                    IDialogConstants.CANCEL_LABEL },
            0);

    // run in syncExec because callback is from an operation,
    // which is probably not running in the UI thread.
    getControl().getDisplay().syncExec(new Runnable() {
        public void run() {
            dialog.open();
        }
    });
    return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()];
}

From source file:de.quamoco.adaptation.todo.listener.TodoController.java

License:Apache License

/**
 * Upon initialization all FeatureRequiredActions are executed against the {@link QualityModel}s
 * that are contained in the editingDomain to provide a consistent state. 
 *///  ww w.j a  va2  s .c o m
protected void runActionsGlobally(Map<EClass, List<FeatureRequiredAction>> eClassToFeatureRequiredActionMap) {
    // Get the QualityModels of the ResourceSet
    List<QualityModel> qualityModels = new LinkedList<QualityModel>();
    ResourceSet resourceSet = editingDomain.getResourceSet();

    for (Resource resource : resourceSet.getResources()) {
        if (resource.getContents().size() > 0) {
            if (resource.getContents().get(0) instanceof QualityModel) {
                qualityModels.add((QualityModel) resource.getContents().get(0));
            }
        }
    }

    // Gather commands for each QualityModel and for each action
    final CompoundCommand commandToExecute = new CompoundCommand();
    for (QualityModel qualityModel : qualityModels) {
        if (runGlobalActionsForModel(qualityModel)) {
            for (List<FeatureRequiredAction> actionList : eClassToFeatureRequiredActionMap.values()) {
                for (FeatureRequiredAction action : actionList) {
                    Command command = action.getCommand(qualityModel, editingDomain);
                    if (command.canExecute()) {
                        commandToExecute.append(command);
                    }
                }
            }
        }
    }

    // Execute the command on the editing domain
    // Execute in Runnable to avoid SWT actions (probably caused by update)
    PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
        public void run() {
            if (commandToExecute.canExecute()) {
                if (adaptationModel.getRunGlobalActionsOnEditorStartup()
                        .equals(TodoActionsOnStartup.ASK_USER)) {
                    MessageDialog dialog = new MessageDialog(null, "Add Todo Tasks", null,
                            "There are some todo tasks that should be added to your model. Do you want to add them now?",
                            MessageDialog.QUESTION, new String[] { "Yes", "No" }, 0);
                    int result = dialog.open();
                    if (result == 0) {
                        editingDomain.getCommandStack().execute(commandToExecute);
                    }
                } else {
                    editingDomain.getCommandStack().execute(commandToExecute);
                }

            }
        }
    });

}

From source file:de.quamoco.qm.properties.eval.section.AbstractAggregationSection.java

License:Apache License

private Evaluation showMessage(List<Evaluation> evals) {
    String[] evalsstring = new String[evals.size()];

    for (int i = 0; i < evalsstring.length; i++) {
        evalsstring[i] = evals.get(i).getQualifiedName();
    }/* w  w w  . java  2  s  . c  o m*/

    MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(),
            "Select the evaluation to copy from", null, "Which evaluation should be copied?",
            MessageDialog.QUESTION, evalsstring, 2);
    int answer = dialog.open();

    return evals.get(answer);
}

From source file:de.tub.tfs.henshin.editor.ui.dialog.resources.ResourcesDialog.java

License:Open Source License

@Override
protected void okPressed() {
    IPath path = resourceGroup.getResourceFullPath();
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);

    if (file.exists() && type == SWT.SAVE) {
        String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL,
                IDialogConstants.CANCEL_LABEL };
        MessageDialog confirm = new MessageDialog(getShell(), "Overwrite Question", null,
                "The file" + file.getName() + " already exists. Do you want to replace the existing file?",
                MessageDialog.QUESTION, buttons, 0);

        int result = confirm.open();

        switch (result) {
        case 0:/*  w ww. j  av a 2s  . c  o  m*/
            break;
        case 1:
            return;
        default:
            cancelPressed();
            break;
        }
    }

    this.result = file.getRawLocation().toFile();
    super.okPressed();
}

From source file:de.uni_jena.iaa.linktype.atomic.model.pepper.wizard.TextInputDialog.java

License:Apache License

/**
 * Legt eine neue Instanz des Typs TextInputDialog an.
 * @param parentShell/*w  ww. ja v  a2 s.c  o  m*/
 * @param dialogTitle
 * @param dialogMessage
 */
public TextInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String labelText,
        String initialText, TextInputVerifier textInputVerifier) {
    super(parentShell, dialogTitle, null, dialogMessage, MessageDialog.QUESTION,
            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);

    this.labelText = labelText;
    this.initialText = initialText;
    this.textInputVerifier = textInputVerifier;

    setShellStyle(getShellStyle() | SWT.SHEET);
}

From source file:descent.internal.ui.preferences.BuildPathsPropertyPage.java

License:Open Source License

public void setVisible(boolean visible) {
    if (fBuildPathsBlock != null) {
        if (!visible) {
            if (fBuildPathsBlock.hasChangesInDialog()) {
                String title = PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_title;
                String message = PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_message;
                String[] buttonLabels = new String[] {
                        PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_save,
                        PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_discard,
                        PreferencesMessages.BuildPathsPropertyPage_unsavedchanges_button_ignore };
                MessageDialog dialog = new MessageDialog(getShell(), title, null, message,
                        MessageDialog.QUESTION, buttonLabels, 0);
                int res = dialog.open();
                if (res == 0) {
                    performOk();//  ww  w  .  j a  va2s . c o  m
                } else if (res == 1) {
                    fBuildPathsBlock.init(JavaCore.create(getProject()), null, null);
                } else {
                    // keep unsaved
                }
            }
        } else {
            if (!fBuildPathsBlock.hasChangesInDialog() && fBuildPathsBlock.hasChangesInClasspathFile()) {
                fBuildPathsBlock.init(JavaCore.create(getProject()), null, null);
            }
        }
    }
    super.setVisible(visible);
}