Example usage for com.intellij.openapi.ui Messages YES

List of usage examples for com.intellij.openapi.ui Messages YES

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages YES.

Prototype

int YES

To view the source code for com.intellij.openapi.ui Messages YES.

Click Source Link

Usage

From source file:org.jboss.forge.plugin.idea.runtime.UIPromptImpl.java

License:Open Source License

@Override
public boolean promptBoolean(final String message) {
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
        @Override//from  ww w.j  ava 2s  .c o  m
        public void run() {
            booleanValue = Messages.showYesNoDialog(message, "", Messages.getQuestionIcon()) == Messages.YES;
        }
    }, ModalityState.any());
    return booleanValue;
}

From source file:org.jboss.forge.plugin.idea.runtime.UIPromptImpl.java

License:Open Source License

@Override
public boolean promptBoolean(final String message, final boolean defaultValue) {
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
        @Override//  w  w  w. j av  a  2s  .c  o m
        public void run() {
            int result = Messages.showYesNoCancelDialog(message, "", Messages.getQuestionIcon());
            booleanValue = result == Messages.CANCEL ? defaultValue : result == Messages.YES;
        }
    }, ModalityState.any());
    return booleanValue;
}

From source file:org.jetbrains.android.actions.AndroidEnableAdbServiceAction.java

License:Apache License

private static boolean askForClosingDebugSessions(@NotNull Project project) {
    final List<Pair<ProcessHandler, RunContentDescriptor>> pairs = new ArrayList<Pair<ProcessHandler, RunContentDescriptor>>();

    for (Project p : ProjectManager.getInstance().getOpenProjects()) {
        final ProcessHandler[] processes = ExecutionManager.getInstance(p).getRunningProcesses();

        for (ProcessHandler process : processes) {
            if (!process.isProcessTerminated()) {
                final AndroidSessionInfo info = process.getUserData(AndroidDebugRunner.ANDROID_SESSION_INFO);
                if (info != null) {
                    pairs.add(Pair.create(process, info.getDescriptor()));
                }/* w  w  w .  j  a  v  a 2 s .c  om*/
            }
        }
    }

    if (pairs.size() == 0) {
        return true;
    }

    final StringBuilder s = new StringBuilder();

    for (Pair<ProcessHandler, RunContentDescriptor> pair : pairs) {
        if (s.length() > 0) {
            s.append('\n');
        }
        s.append(pair.getSecond().getDisplayName());
    }

    final int r = Messages.showYesNoDialog(project,
            AndroidBundle.message("android.debug.sessions.will.be.closed", s),
            AndroidBundle.message("android.disable.adb.service.title"), Messages.getQuestionIcon());
    return r == Messages.YES;
}

From source file:org.jetbrains.android.run.testing.AndroidTestRunConfiguration.java

License:Apache License

@Override
public AndroidRunningState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env)
        throws ExecutionException {
    final AndroidRunningState state = super.getState(executor, env);

    if (state == null) {
        return null;
    }//from w  ww.ja  va2  s .c om

    final AndroidFacet facet = state.getFacet();
    final AndroidFacetConfiguration configuration = facet.getConfiguration();

    if (!facet.isGradleProject() && !configuration.getState().PACK_TEST_CODE) {
        final Module module = facet.getModule();
        final int count = getTestSourceRootCount(module);

        if (count > 0) {
            final String message = "Code and resources under test source " + (count > 1 ? "roots" : "root")
                    + " aren't included into debug APK.\nWould you like to include them and recompile "
                    + module.getName() + " module?"
                    + "\n(You may change this option in Android facet settings later)";
            final int result = Messages.showYesNoCancelDialog(getProject(), message,
                    "Test code not included into APK", Messages.getQuestionIcon());

            if (result == Messages.YES) {
                configuration.getState().PACK_TEST_CODE = true;
            } else if (result == Messages.CANCEL) {
                return null;
            }
        }
    }
    return state;
}

From source file:org.jetbrains.android.sdk.AndroidSdkUtils.java

License:Apache License

public static boolean activateDdmsIfNecessary(@NotNull Project project,
        @NotNull Computable<AndroidDebugBridge> bridgeProvider) {
    if (AndroidEnableAdbServiceAction.isAdbServiceEnabled()) {
        AndroidDebugBridge bridge = bridgeProvider.compute();
        if (bridge != null && isDdmsCorrupted(bridge)) {
            LOG.info("DDMLIB is corrupted and will be restarted");
            restartDdmlib(project);//from   w  w w  . j a v a  2s  . c  o  m
        }
    } else {
        final OSProcessHandler ddmsProcessHandler = AndroidRunDdmsAction.getDdmsProcessHandler();
        if (ddmsProcessHandler != null) {
            int r = Messages.showYesNoDialog(project,
                    "Monitor will be closed to enable ADB integration. Continue?", "ADB Integration",
                    Messages.getQuestionIcon());
            if (r != Messages.YES) {
                return false;
            }

            Runnable destroyingRunnable = new Runnable() {
                @Override
                public void run() {
                    if (!ddmsProcessHandler.isProcessTerminated()) {
                        OSProcessManager.getInstance().killProcessTree(ddmsProcessHandler.getProcess());
                        ddmsProcessHandler.waitFor();
                    }
                }
            };
            if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(destroyingRunnable,
                    "Closing Monitor", true, project)) {
                return false;
            }
            AndroidEnableAdbServiceAction.setAdbServiceEnabled(project, true);
            return true;
        }

        int result = Messages.showYesNoDialog(project, AndroidBundle.message("android.ddms.disabled.error"),
                AndroidBundle.message("android.ddms.disabled.dialog.title"), Messages.getQuestionIcon());
        if (result != Messages.YES) {
            return false;
        }
        AndroidEnableAdbServiceAction.setAdbServiceEnabled(project, true);
    }
    return true;
}

From source file:org.jetbrains.idea.maven.navigator.actions.RemoveMavenRunConfigurationAction.java

License:Apache License

@RequiredUIAccess
@Override// www . ja  v  a  2  s . c o m
public void actionPerformed(@Nonnull AnActionEvent e) {
    Project project = e.getProject();
    RunnerAndConfigurationSettings settings = e.getData(MavenDataKeys.RUN_CONFIGURATION);

    assert settings != null && project != null;

    int res = Messages.showYesNoDialog(project, "Delete \"" + settings.getName() + "\"?", "Confirmation",
            Messages.getQuestionIcon());
    if (res == Messages.YES) {
        ((RunManagerEx) RunManager.getInstance(project)).removeConfiguration(settings);
    }
}

From source file:org.jetbrains.idea.svn.actions.MarkLocallyDeletedTreeConflictResolvedAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    final MyLocallyDeletedChecker locallyDeletedChecker = new MyLocallyDeletedChecker(e);
    if (!locallyDeletedChecker.isEnabled())
        return;// w w w  .j av a 2 s .c  om

    final String markText = SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.title");
    final Project project = locallyDeletedChecker.getProject();
    final int result = Messages.showYesNoDialog(project,
            SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.text"), markText,
            Messages.getQuestionIcon());
    if (result == Messages.YES) {
        final Ref<VcsException> exception = new Ref<VcsException>();
        ProgressManager.getInstance()
                .run(new Task.Backgroundable(project, markText, true, BackgroundFromStartOption.getInstance()) {
                    public void run(@NotNull ProgressIndicator indicator) {
                        resolveLocallyDeletedTextConflict(locallyDeletedChecker, exception);
                    }
                });
        if (!exception.isNull()) {
            AbstractVcsHelper.getInstance(project).showError(exception.get(), markText);
        }
    }
}

From source file:org.jetbrains.idea.svn.actions.MarkTreeConflictResolvedAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    final MyChecker checker = new MyChecker(e);
    if (!checker.isEnabled())
        return;/*from w w w. ja v a  2 s  . c  o  m*/

    final String markText = SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.title");
    final int result = Messages.showYesNoDialog(checker.getProject(),
            SvnBundle.message("action.mark.tree.conflict.resolved.confirmation.text"), markText,
            Messages.getQuestionIcon());
    if (result == Messages.YES) {
        final Ref<VcsException> exception = new Ref<VcsException>();
        ProgressManager.getInstance().run(new Task.Backgroundable(checker.getProject(), markText, true,
                BackgroundFromStartOption.getInstance()) {
            public void run(@NotNull ProgressIndicator indicator) {
                final ConflictedSvnChange change = checker.getChange();
                final FilePath path = change.getTreeConflictMarkHolder();
                SvnVcs vcs = SvnVcs.getInstance(checker.getProject());

                try {
                    vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(),
                            SVNDepth.EMPTY, false, false, true);
                } catch (VcsException e) {
                    exception.set(e);
                }
                VcsDirtyScopeManager.getInstance(checker.getProject()).filePathsDirty(getDistinctFiles(change),
                        null);
            }
        });
        if (!exception.isNull()) {
            AbstractVcsHelper.getInstance(checker.getProject()).showError(exception.get(), markText);
        }
    }
}

From source file:org.jetbrains.idea.svn.actions.ShareProjectAction.java

License:Apache License

private static boolean performImpl(final Project project, final SvnVcs activeVcs, final VirtualFile file)
        throws VcsException {
    final ShareDialog shareDialog = new ShareDialog(project, file.getName());
    shareDialog.show();/*from   w  ww.j av  a 2 s .com*/

    final String parent = shareDialog.getSelectedURL();
    if (shareDialog.isOK() && parent != null) {
        final Ref<Boolean> actionStarted = new Ref<Boolean>(Boolean.TRUE);
        final Exception[] error = new Exception[1];

        final ShareDialog.ShareTarget shareTarget = shareDialog.getShareTarget();
        final ProgressManager progressManager = ProgressManager.getInstance();

        if (ShareDialog.ShareTarget.useSelected.equals(shareTarget)) {
            final boolean folderEmpty = checkRemoteFolder(project, activeVcs, parent, progressManager);

            if (!folderEmpty) {
                final int promptAnswer = Messages.showYesNoDialog(project,
                        "Remote folder \"" + parent + "\" is not empty.\nDo you want to continue sharing?",
                        "Share directory", Messages.getWarningIcon());
                if (Messages.YES != promptAnswer)
                    return false;
            }
        }

        final WorkingCopyFormat format = SvnCheckoutProvider
                .promptForWCopyFormat(VfsUtilCore.virtualToIoFile(file), project);
        actionStarted.set(format != WorkingCopyFormat.UNKNOWN);
        // means operation cancelled
        if (format == WorkingCopyFormat.UNKNOWN) {
            return true;
        }

        ExclusiveBackgroundVcsAction.run(project, new Runnable() {
            public void run() {
                progressManager.runProcessWithProgressSynchronously(new Runnable() {
                    public void run() {
                        try {
                            final ProgressIndicator indicator = ProgressManager.getInstance()
                                    .getProgressIndicator();
                            final File path = new File(file.getPath());

                            SvnWorkingCopyFormatHolder.setPresetFormat(format);

                            final SVNURL parenUrl = SVNURL.parseURIEncoded(parent);
                            final SVNURL checkoutUrl;
                            final SVNRevision revision;
                            final String commitText = shareDialog.getCommitText();
                            if (ShareDialog.ShareTarget.useSelected.equals(shareTarget)) {
                                checkoutUrl = parenUrl;
                                revision = SVNRevision.HEAD;
                            } else if (ShareDialog.ShareTarget.useProjectName.equals(shareTarget)) {
                                final Pair<SVNRevision, SVNURL> pair = createRemoteFolder(activeVcs, parenUrl,
                                        file.getName(), commitText);
                                revision = pair.getFirst();
                                checkoutUrl = pair.getSecond();
                            } else {
                                final Pair<SVNRevision, SVNURL> pair = createRemoteFolder(activeVcs, parenUrl,
                                        file.getName(), commitText);
                                final Pair<SVNRevision, SVNURL> trunkPair = createRemoteFolder(activeVcs,
                                        pair.getSecond(), "trunk", commitText);
                                checkoutUrl = trunkPair.getSecond();
                                revision = trunkPair.getFirst();

                                if (shareDialog.createStandardStructure()) {
                                    createRemoteFolder(activeVcs, pair.getSecond(), "branches", commitText);
                                    createRemoteFolder(activeVcs, pair.getSecond(), "tags", commitText);
                                }
                            }

                            if (indicator != null) {
                                indicator.checkCanceled();
                                indicator.setText(SvnBundle.message(
                                        "share.directory.checkout.back.progress.text", checkoutUrl.toString()));
                            }

                            final ClientFactory factory = SvnCheckoutProvider.getFactory(activeVcs, format);

                            factory.createCheckoutClient().checkout(SvnTarget.fromURL(checkoutUrl), path,
                                    revision, SVNDepth.INFINITY, false, false, format, null);
                            addRecursively(activeVcs, factory, file);
                        } catch (SVNException e) {
                            error[0] = e;
                        } catch (VcsException e) {
                            error[0] = e;
                        } finally {
                            activeVcs.invokeRefreshSvnRoots();
                            SvnWorkingCopyFormatHolder.setPresetFormat(null);
                        }
                    }
                }, SvnBundle.message("share.directory.title"), true, project);
            }
        });

        if (Boolean.TRUE.equals(actionStarted.get())) {
            if (error[0] != null) {
                throw new VcsException(error[0].getMessage());
            }
            Messages.showInfoMessage(project, SvnBundle.message("share.directory.info.message", file.getName()),
                    SvnBundle.message("share.directory.title"));
        }
        return true;
    }
    return false;
}

From source file:org.jetbrains.idea.svn.SvnAuthenticationManager.java

License:Apache License

/**
 * Shows a yes/no question whether user wants to store his password in plain text and returns his answer.
 * @param title   title of the questioning dialog.
 * @param message questioning message to be displayed.
 * @return true if user agrees to store his password in plaintext, false if he doesn't.
 */// w  w w .j a v  a 2 s .c  o m
@CalledInAwt
private boolean askToStoreUnencrypted(String title, String message) {
    final int answer = Messages.showYesNoDialog(myProject, message, title, Messages.getQuestionIcon());
    return answer == Messages.YES;
}