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:com.google.cloud.tools.intellij.debugger.ProjectRepositoryValidator.java

License:Apache License

/**
 * Restore the repository to its original state.
 *//*from  w ww  .  java2s.  c o  m*/
public void restoreToOriginalState(final @NotNull Project project) {
    if (repoState.hasSourceRepository()) {
        assert repoState.getSourceRepository() != null;
        final VirtualFile root = repoState.getSourceRepository().getRoot();

        //check for an unstash requirement.
        final Ref<StashInfo> targetStash = new Ref<StashInfo>();
        if (!Strings.isNullOrEmpty(repoState.getStashMessage())) {
            GitStashUtils.loadStashStack(project, root, new Consumer<StashInfo>() {
                @Override
                public void consume(StashInfo stashInfo) {
                    if (!Strings.isNullOrEmpty(stashInfo.getMessage())
                            && stashInfo.getMessage().equals(repoState.getStashMessage())) {
                        targetStash.set(stashInfo);
                    }
                }
            });
        }

        // If an unstash is required, we will always have an original branch name as well.
        if (!Strings.isNullOrEmpty(repoState.getOriginalBranchName())) {
            assert repoState.getOriginalBranchName() != null;
            String branchDisplayName = repoState.getOriginalBranchName();
            if (branchDisplayName.length() > 10) {
                branchDisplayName = branchDisplayName.substring(0, 7) + "...";
            }
            if (Messages.showYesNoDialog(GctBundle.getString("clouddebug.restorestash", branchDisplayName),
                    GctBundle.getString("clouddebug.restorechanges.title"),
                    Messages.getInformationIcon()) == Messages.YES) {
                final GitBrancher brancher = ServiceManager.getService(project, GitBrancher.class);
                brancher.checkout(repoState.getOriginalBranchName(), false,
                        Collections.singletonList(repoState.getSourceRepository()), new Runnable() {
                            @Override
                            public void run() {
                                repoState.getSourceRepository().update();
                                if (!targetStash.isNull()) {
                                    unstash(project, targetStash, root);
                                }
                            }
                        });
            }
        }
    }
}

From source file:com.google.gct.idea.appengine.deploy.AppEngineUpdateDialog.java

License:Apache License

@Override
protected void doOKAction() {
    if (getOKAction().isEnabled()) {
        Module selectedModule = myModuleComboBox.getSelectedModule();
        String sdk = "";
        String war = "";
        AppEngineGradleFacet facet = AppEngineGradleFacet.getAppEngineFacetByModule(selectedModule);
        if (facet != null) {
            AppEngineConfigurationProperties model = facet.getConfiguration().getState();
            if (model != null) {
                sdk = model.APPENGINE_SDKROOT;
                war = model.WAR_DIR;//  w  w  w .j a  v a 2 s  . co m
            }
        }

        String client_secret = null;
        String client_id = null;
        String refresh_token = null;

        CredentialedUser selectedUser = myElysiumProjectId.getSelectedUser();
        if (selectedUser == null) {
            selectedUser = GoogleLogin.getInstance().getActiveUser();
            // Ask the user if he wants to continue using the active user credentials.
            if (selectedUser != null) {
                if (Messages.showYesNoDialog(this.getPeer().getOwner(),
                        "The Project ID you entered could not be found.  Do you want to deploy anyway using "
                                + GoogleLogin.getInstance().getActiveUser().getEmail() + " for credentials?",
                        "Deploy", Messages.getQuestionIcon()) != Messages.YES) {
                    return;
                }
            } else {
                // This should not happen as its validated.
                Messages.showErrorDialog(this.getPeer().getOwner(), "You need to be logged in to deploy.",
                        "Login");
                return;
            }
        }

        if (selectedUser != null) {
            client_secret = selectedUser.getGoogleLoginState().fetchOAuth2ClientSecret();
            client_id = selectedUser.getGoogleLoginState().fetchOAuth2ClientId();
            refresh_token = selectedUser.getGoogleLoginState().fetchOAuth2RefreshToken();
        }

        if (Strings.isNullOrEmpty(client_secret) || Strings.isNullOrEmpty(client_id)
                || Strings.isNullOrEmpty(refresh_token)) {
            // The login is somehow invalid, bail -- this shouldn't happen.
            LOG.error("StartUploading while logged in, but it doesn't have full credentials.");
            if (Strings.isNullOrEmpty(client_secret)) {
                LOG.error("(null) client_secret");
            }
            if (Strings.isNullOrEmpty(client_id)) {
                LOG.error("(null) client_id");
            }
            if (Strings.isNullOrEmpty(refresh_token)) {
                LOG.error("(null) refresh_token");
            }
            Messages.showErrorDialog(this.getPeer().getOwner(),
                    "The project ID is not a valid Google Console Developer Project.", "Login");
            return;
        }

        // These should not fail as they are a part of the dialog validation.
        if (Strings.isNullOrEmpty(sdk) || Strings.isNullOrEmpty(war)
                || Strings.isNullOrEmpty(myElysiumProjectId.getText()) || selectedModule == null) {
            Messages.showErrorDialog(this.getPeer().getOwner(),
                    "Could not deploy due to missing information (sdk/war/projectid).", "Deploy");
            LOG.error("StartUploading was called with bad module/sdk/war");
            return;
        }

        close(OK_EXIT_CODE); // We close before kicking off the update so it doesn't interfere with the output window coming to focus.

        // Kick off the upload.  detailed status will be shown in an output window.
        new AppEngineUpdater(myProject, selectedModule, sdk, war, myElysiumProjectId.getText(),
                myVersion.getText(), client_secret, client_id, refresh_token).startUploading();
    }
}

From source file:com.google.gct.idea.debugger.ProjectRepositoryValidator.java

License:Apache License

public void restoreToOriginalState(final @NotNull Project project) {
    if (myRepoState.hasSourceRepository()) {
        assert myRepoState.getSourceRepository() != null;
        final VirtualFile root = myRepoState.getSourceRepository().getRoot();

        //check for an unstash requirement.
        final Ref<StashInfo> targetStash = new Ref<StashInfo>();
        if (!Strings.isNullOrEmpty(myRepoState.getStashMessage())) {
            GitStashUtils.loadStashStack(project, root, new Consumer<StashInfo>() {
                @Override/*from   www  .  j  a  v a  2 s.co  m*/
                public void consume(StashInfo stashInfo) {
                    if (!Strings.isNullOrEmpty(stashInfo.getMessage())
                            && stashInfo.getMessage().equals(myRepoState.getStashMessage())) {
                        targetStash.set(stashInfo);
                    }
                }
            });
        }

        // If an unstash is required, we will always have an original branch name as well.
        if (!Strings.isNullOrEmpty(myRepoState.getOriginalBranchName())) {
            assert myRepoState.getOriginalBranchName() != null;
            String branchDisplayName = myRepoState.getOriginalBranchName();
            if (branchDisplayName.length() > 10) {
                branchDisplayName = branchDisplayName.substring(0, 7) + "...";
            }
            if (Messages.showYesNoDialog(GctBundle.getString("clouddebug.restorestash", branchDisplayName),
                    GctBundle.getString("clouddebug.restorechanges.title"),
                    Messages.getInformationIcon()) == Messages.YES) {
                final GitBrancher brancher = ServiceManager.getService(project, GitBrancher.class);
                brancher.checkout(myRepoState.getOriginalBranchName(),
                        Collections.singletonList(myRepoState.getSourceRepository()), new Runnable() {
                            @Override
                            public void run() {
                                myRepoState.getSourceRepository().update();
                                if (!targetStash.isNull()) {
                                    unstash(project, targetStash, root);
                                }
                            }
                        });
            }
        }
    }
}

From source file:com.google.idea.blaze.android.sync.importer.problems.AddGeneratedResourceDirectoryNavigatable.java

License:Open Source License

@Override
public void navigate(boolean requestFocus) {
    int addToProjectView = Messages
            .showYesNoDialog(String.format("Whitelist generated resource directory \"%s\" in project view?",
                    generatedResDir.getRelativePath()), "Whitelist generated resource", null);
    if (addToProjectView == Messages.YES) {
        addDirectoryToProjectView(project, projectViewFile, generatedResDir);
    }//  w w w  .  j  a  v  a  2  s.c  o  m
}

From source file:com.hp.alm.ali.idea.action.attachment.AttachmentDeleteAction.java

License:Apache License

@Override
protected void actionPerformed(AnActionEvent event, final Project project, final Entity entity) {
    if (Messages.showYesNoDialog("Do you really want to delete this attachment?", "Confirmation",
            null) == Messages.YES) {
        ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
            @Override//from  w  w w  .j  a  v  a2  s. co  m
            public void run() {
                EntityRef parent = new EntityRef(entity.getPropertyValue("parent-type"),
                        Integer.valueOf(entity.getPropertyValue("parent-id")));
                project.getComponent(AttachmentService.class).deleteAttachment(entity.getPropertyValue("name"),
                        parent);
            }
        });
    }
}

From source file:com.hp.alm.ali.idea.action.DeleteEntityAction.java

License:Apache License

@Override
protected void actionPerformed(AnActionEvent event, final Project project, final Entity entity) {
    EntityLabelService entityLabelService = project.getComponent(EntityLabelService.class);
    entityLabelService.loadEntityLabelAsync(entity.getType(),
            new AbstractCachingService.DispatchCallback<String>() {
                @Override/*  w w  w  .  j  a v  a 2 s  .c o  m*/
                public void loaded(String entityLabel) {
                    if (Messages.showYesNoDialog("Do you really want to delete this " + entityLabel + "?",
                            "Confirmation", null) == Messages.YES) {
                        ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
                            @Override
                            public void run() {
                                EntityService entityService = project.getComponent(EntityService.class);
                                entityService.deleteEntity(entity);
                            }
                        });
                    }
                }
            });
}

From source file:com.hp.alm.ali.idea.action.link.LinkDeleteAction.java

License:Apache License

@Override
protected void actionPerformed(AnActionEvent event, Project project, Entity entity) {
    if (Messages.showYesNoDialog("Do you really want to remove the link?", "Confirmation",
            null) == Messages.YES) {
        project.getComponent(EntityService.class).deleteEntity(entity);
    }//from   w w w  .j  a  va2 s. c  o  m
}

From source file:com.hp.alm.ali.idea.action.task.TaskDeleteAction.java

License:Apache License

@Override
protected void actionPerformed(AnActionEvent event, final Project project, final Entity entity) {
    if (Messages.showYesNoDialog("Do you really want to delete this task?", "Confirmation",
            null) == Messages.YES) {
        ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
            @Override/*  www . j a  va 2s. c o m*/
            public void run() {
                EntityService entityService = project.getComponent(EntityService.class);
                if (entityService.deleteEntity(entity)) {
                    // make sure item values are propagated
                    entityService.getEntityAsync(new EntityRef("release-backlog-item",
                            Integer.valueOf(entity.getPropertyValue("release-backlog-item-id"))), null);
                }
            }
        });
    }
}

From source file:com.hp.alm.ali.idea.cfg.AliConfigurable.java

License:Apache License

protected Component getSouthernComponent() {
    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final TroubleShootService troubleShootService = ApplicationManager.getApplication()
            .getComponent(TroubleShootService.class);
    final JButton troubleshoot = new JButton(
            troubleShootService.isRunning() ? "Stop Troubleshoot" : "Troubleshoot");
    troubleshoot.addActionListener(new ActionListener() {
        @Override//from   w w  w.ja  v  a 2s .  com
        public void actionPerformed(ActionEvent e) {
            if (troubleshoot.getText().equals("Troubleshoot")) {
                if (!troubleShootService.isRunning()) {
                    if (Messages.showYesNoDialog("Do you want to log complete ALM server communication?",
                            "Confirmation", null) == Messages.YES) {
                        FileSaverDescriptor desc = new FileSaverDescriptor("Log server communication",
                                "Log server communication on the local filesystem.");
                        final VirtualFileWrapper file = FileChooserFactory.getInstance()
                                .createSaveFileDialog(desc, troubleshoot).save(null, "REST_log.txt");
                        if (file == null) {
                            return;
                        }

                        troubleShootService.start(file.getFile());
                        troubleshoot.setText("Stop Troubleshoot");
                    }
                }
            } else {
                troubleShootService.stop();
                troubleshoot.setText("Troubleshoot");
            }
        }
    });
    southPanel.add(troubleshoot);
    return southPanel;
}

From source file:com.hp.alm.ali.idea.entity.EntityEditManager.java

License:Apache License

private boolean askForApproval() {
    return askUser() == Messages.YES;
}