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

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

Introduction

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

Prototype

public static boolean openConfirm(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple confirm (OK/Cancel) dialog.

Usage

From source file:com.ecfeed.ui.modelif.MethodInterface.java

License:Open Source License

public boolean generateTestSuite() {
    TestSuiteGenerationSupport testGenerationSupport = new TestSuiteGenerationSupport(getTarget(),
            fFileInfoProvider);/*from  w  w w  . j  a v a 2 s  . c om*/
    testGenerationSupport.proceed();
    if (testGenerationSupport.hasData() == false)
        return false;

    String testSuiteName = testGenerationSupport.getTestSuiteName();
    List<List<ChoiceNode>> testData = testGenerationSupport.getGeneratedData();

    int dataLength = testData.size();
    if (dataLength < 0 && (testGenerationSupport.wasCancelled() == false)) {
        MessageDialog.openInformation(Display.getDefault().getActiveShell(),
                Messages.DIALOG_ADD_TEST_SUITE_PROBLEM_TITLE,
                Messages.DIALOG_EMPTY_TEST_SUITE_GENERATED_MESSAGE);
        return false;
    }
    if (testData.size() > Constants.TEST_SUITE_SIZE_WARNING_LIMIT) {
        if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(),
                Messages.DIALOG_LARGE_TEST_SUITE_GENERATED_TITLE,
                Messages.DIALOG_LARGE_TEST_SUITE_GENERATED_MESSAGE(dataLength)) == false) {
            return false;
        }
    }
    IModelOperation operation = new MethodOperationAddTestSuite(getTarget(), testSuiteName, testData,
            fAdapterProvider);
    return execute(operation, Messages.DIALOG_ADD_TEST_SUITE_PROBLEM_TITLE);
}

From source file:com.ecfeed.ui.modelif.MethodParameterInterface.java

License:Open Source License

public boolean setExpected(boolean expected) {
    if (expected != getTarget().isExpected()) {
        MethodNode method = getTarget().getMethod();
        if (method != null) {
            boolean testCases = method.getTestCases().size() > 0;
            boolean constraints = method.mentioningConstraints(getTarget()).size() > 0;
            if (testCases || constraints) {
                String message = "";
                if (testCases) {
                    if (expected) {
                        message += Messages.DIALOG_SET_CATEGORY_EXPECTED_TEST_CASES_ALTERED + "\n";
                    } else {
                        message += Messages.DIALOG_SET_CATEGORY_EXPECTED_TEST_CASES_REMOVED + "\n";
                    }/*from  w w  w  .j  ava 2s.  c o  m*/
                }
                if (constraints) {
                    message += Messages.DIALOG_SET_CATEGORY_EXPECTED_CONSTRAINTS_REMOVED;
                }
                if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
                        Messages.DIALOG_SET_CATEGORY_EXPECTED_WARNING_TITLE, message) == false) {
                    return false;
                }
            }
        }
        return execute(new ParameterOperationSetExpected(getTarget(), expected),
                Messages.DIALOG_SET_CATEGORY_EXPECTED_PROBLEM_TITLE);
    }
    return false;
}

From source file:com.ecfeed.ui.modelif.RootInterface.java

License:Open Source License

public boolean removeClasses(Collection<ClassNode> removedClasses) {
    if (MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), Messages.DIALOG_REMOVE_CLASSES_TITLE,
            Messages.DIALOG_REMOVE_CLASSES_MESSAGE)) {
        return removeChildren(removedClasses, Messages.DIALOG_REMOVE_CLASSES_PROBLEM_TITLE);
    }/*  w  w w. j  a va  2s .  c  o m*/
    return false;
}

From source file:com.embedthis.ejs.ide.properties.EJScriptProjectPropertyPage.java

License:Open Source License

/**
 * Prompt the user that they have selected to add/remove the EJScript Nature and 
 * confirm that they want to do this.// ww w  .  j a  v a 2s . co m
 * @param isAddingNature true if selected action is 
 *          to add the nature, false otherwise 
 * @return true if action can continue, false otherwise
 */
private boolean verify(boolean isAddingNature) {
    Shell shell = getShell();
    String message;
    boolean result;

    EJScriptTrace.trace(EJScriptTrace.TRACE_VERBOSE, EJScriptTrace.GENERAL_TRACE,
            "+ToggleProjectNature:verify");

    if (isAddingNature) {
        message = "This will add the EJScript Nature, do you want to continue?";
    } else {
        message = "This will remove the EJScript Nature, do you want to continue?";
    }
    result = MessageDialog.openConfirm(shell, "Confirm", message);

    return result;
}

From source file:com.flagleader.builder.BuilderManager.java

public boolean showConfirm(String paramString) {
    return MessageDialog.openConfirm(getShell(), ResourceTools.getMessage("confirm.dialog"), paramString);
}

From source file:com.flagleader.builder.BuilderManager.java

public void showConfirm(String paramString, IAfterAction paramIAfterAction) {
    if (MessageDialog.openConfirm(getShell(), ResourceTools.getMessage("confirm.dialog"), paramString))
        paramIAfterAction.ok();/*from   w ww  . j a  v  a  2s.co m*/
    else
        paramIAfterAction.cancel();
}

From source file:com.flagleader.builder.shell.RuleExecuteViewer.java

public static RuleExecuteViewer f() {
    if (new File("execute.lck").exists())
        if (!MessageDialog.openConfirm(null, "",
                ResourceTools.formatMessage("existlock.RuleExecuteViewer", new String[] { "execute.lck" })))
            return null;
    try {//from www. java  2s.c o m
        new File("execute.lck").createNewFile();
    } catch (Exception localException) {
    }
    RuleExecuteViewer localRuleExecuteViewer = new RuleExecuteViewer();
    Shell localShell = localRuleExecuteViewer.b(null);
    localShell.addDisposeListener(new cV());
    Display localDisplay = localShell.getDisplay();
    while (!localShell.isDisposed()) {
        if (localDisplay.readAndDispatch())
            continue;
        localDisplay.sleep();
    }
    return localRuleExecuteViewer;
}

From source file:com.flamefire.importsmalinames.handlers.RenameVariablesHandler.java

License:Open Source License

private void doRename(Shell shell, ICompilationUnit cu) {
    IJavaProject proj = getProject(cu);//w w w  .j  a va  2  s  . co  m
    String cClassName = null;
    String pName = null;
    try {
        cClassName = cu.getCorrespondingResource().getName();
        if (proj != null)
            pName = proj.getElementName();
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    if (cClassName == null || pName == null || cClassName.length() == 0 || pName.length() == 0) {
        MessageDialog.openError(shell, "Error", "Could not access project and class names");
        return;
    }
    boolean classOnly = MessageDialog.openQuestion(shell, "Apply smali names only to current class?",
            "Do you want to apply the names only to current java file (" + cClassName + ") ->YES\n"
                    + "Or to the whole project (" + pName + ") -> NO");
    String lastFolder = null;
    IResource res = null;
    try {
        res = proj.getCorrespondingResource();
        lastFolder = com.flamefire.importsmalinames.utils.Util.getPersistentProperty(res, LASTFOLDER);
    } catch (JavaModelException e) {
    }
    JFileChooser j = new JFileChooser();
    j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    j.setDialogTitle("Select smali directory");
    if (lastFolder != null)
        j.setSelectedFile(new File(lastFolder));
    if (j.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
        return;
    com.flamefire.importsmalinames.utils.Util.setPersistentProperty(res, LASTFOLDER,
            j.getSelectedFile().getAbsolutePath());
    File smaliFolder = j.getSelectedFile();
    RefactoringController controller = new RefactoringController();
    if (!controller.init(smaliFolder)) {
        MessageDialog.openError(shell, "Error", "Could not parse smali classes");
        return;
    }
    if (classOnly) {
        if (!controller.renameVariablesInFile(cu)) {
            MessageDialog.openError(shell, "Error", "Initializing the changes failed. Please check output.");
            return;
        }
    } else {
        try {
            IPackageFragment[] packages = proj.getPackageFragments();
            for (IPackageFragment mypackage : packages) {
                if (mypackage.getKind() != IPackageFragmentRoot.K_SOURCE)
                    continue;
                for (ICompilationUnit unit : mypackage.getCompilationUnits()) {
                    if (!controller.renameVariablesInFile(unit)) {
                        if (!MessageDialog.openConfirm(shell,
                                "Error in " + unit.getCorrespondingResource().getName(),
                                "Initializing the changes to " + unit.getCorrespondingResource().getName()
                                        + " failed. Please check output.\n\nContinue?"))
                            return;
                    }
                }
            }
        } catch (JavaModelException e) {
            e.printStackTrace();
        }
    }
    String msg = "This will apply the smali names to the ";
    if (classOnly)
        msg += "java file " + cClassName;
    else
        msg += "whole project " + pName;
    msg += "\n\nPlease note that you HAVE to check the changes without a preview and it is better to apply this to the decompiled source before you do any changes yourself.";
    msg += "\nThis might fail under certain circumstances e.g. with nested classes and certain name combinations.";
    msg += "\n\nProceed?";
    if (!MessageDialog.openConfirm(shell, "Apply smali names", msg))
        return;
    if (controller.applyRenamings(shell))
        MessageDialog.openInformation(shell, "Success",
                "Names were changed. Please have a look at the output in the console for warnings and errors");
    else
        MessageDialog.openInformation(shell, "Error",
                "There were erros changing the names. Some may have been changed. Please have a look at the output in the console for warnings and errors");
}

From source file:com.flamefire.importsmalinames.refactoring.RefactoringController.java

License:Open Source License

public boolean applyRenamings(Shell shell) {
    boolean res = true;
    try {// www  .j ava2  s. c  om
        for (ICompilationUnit cu : renamings.keySet()) {
            RenamingEntry entry = renamings.get(cu);
            CompilationUnit unit = Util.createCU(cu, true);
            unit.recordModifications();
            ASTRewrite astRewrite = ASTRewrite.create(unit.getAST());
            RenameVariablesVisitor v = new RenameVariablesVisitor(entry.classes, entry.renamings, astRewrite);
            unit.accept(v);
            if (!RefactoringHelper.rewriteAST(cu, astRewrite)) {
                if (renamings.size() == 1 || !MessageDialog.openConfirm(shell,
                        "Error in " + cu.getCorrespondingResource().getName(),
                        "Applying the changes to " + cu.getCorrespondingResource().getName()
                                + " failed. Please check output.\n\nContinue?"))
                    return false;
                else
                    res = false;
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    return res;
}

From source file:com.foosbar.mailsnag.commands.DeleteMessage.java

License:Open Source License

/**
 * Main execution/*  w ww  .j  a  va 2  s  .  c o  m*/
 */
public Object execute(ExecutionEvent event) throws ExecutionException {

    IWorkbenchPart part = HandlerUtil.getActivePart(event);

    if (part instanceof MessagesView) {

        final MessagesView viewer = (MessagesView) part;

        viewer.showLogo();

        IStructuredSelection iss = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);

        if (!iss.isEmpty()) {
            String message = getConfirmationMessage(iss.size());

            ResourceBundle BUNDLE = Activator.getResourceBundle();
            boolean confirm = MessageDialog.openConfirm(viewer.getViewer().getControl().getShell(),
                    BUNDLE.getString("action.delete.confirm"), message);

            if (confirm) {
                deleteMessages(iss, viewer);
            }
        }
    }
    return null;
}