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

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

Introduction

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

Prototype

@NotNull
    public static Icon getQuestionIcon() 

Source Link

Usage

From source file:org.jetbrains.android.run.CreateAvdDialog.java

License:Apache License

@Override
protected void doOKAction() {
    if (myNameField.getText().length() == 0) {
        Messages.showErrorDialog(myPanel, AndroidBundle.message("specify.avd.name.error"));
        return;/*from w  ww .j av  a  2  s  .  co  m*/
    } else if (myTargetBox.getSelectedItem() == null) {
        Messages.showErrorDialog(myPanel, AndroidBundle.message("select.target.dialog.text"));
        return;
    }
    String avdName = myNameField.getText();
    AvdInfo info = myAvdManager.getAvd(avdName, false);
    if (info != null) {
        boolean replace = Messages.showYesNoDialog(myPanel,
                AndroidBundle.message("replace.avd.question", avdName),
                AndroidBundle.message("create.avd.dialog.title"), Messages.getQuestionIcon()) == 0;
        if (!replace)
            return;
    }
    File avdFolder;
    try {
        avdFolder = new File(AndroidLocation.getFolder() + FOLDER_AVD,
                avdName + AvdManager.AVD_FOLDER_EXTENSION);
    } catch (AndroidLocation.AndroidLocationException e) {
        Messages.showErrorDialog(myPanel, e.getMessage(), "Error");
        return;
    }
    super.doOKAction();
    IAndroidTarget selectedTarget = (IAndroidTarget) myTargetBox.getSelectedItem();
    String skin = (String) mySkinField.getSelectedItem();
    String abi = (String) myAbiCombo.getSelectedItem();
    String sdCard = getSdCardParameter();
    MessageBuildingSdkLog log = new MessageBuildingSdkLog();
    myCreatedAvd = myAvdManager.createAvd(avdFolder, avdName, selectedTarget, abi, skin, sdCard, null, true,
            false, false, log);
    if (log.getErrorMessage().length() > 0) {
        Messages.showErrorDialog(myProject, log.getErrorMessage(),
                AndroidBundle.message("android.avd.error.title"));
    }
}

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 w  w  . j a v a 2  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  .ja va2 s . co 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.android.util.AndroidUtils.java

License:Apache License

public static void addRunConfiguration(@NotNull final AndroidFacet facet, @Nullable final String activityClass,
        final boolean ask, @Nullable final TargetSelectionMode targetSelectionMode,
        @Nullable final String preferredAvdName) {
    final Module module = facet.getModule();
    final Project project = module.getProject();

    final Runnable r = new Runnable() {
        @Override//from   w w w  .  java2  s.c  o m
        public void run() {
            final RunManagerEx runManager = RunManagerEx.getInstanceEx(project);
            final RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(module.getName(),
                    AndroidRunConfigurationType.getInstance().getFactory());
            final AndroidRunConfiguration configuration = (AndroidRunConfiguration) settings.getConfiguration();
            configuration.setModule(module);

            if (activityClass != null) {
                configuration.MODE = AndroidRunConfiguration.LAUNCH_SPECIFIC_ACTIVITY;
                configuration.ACTIVITY_CLASS = activityClass;
            } else {
                configuration.MODE = AndroidRunConfiguration.LAUNCH_DEFAULT_ACTIVITY;
            }

            if (targetSelectionMode != null) {
                configuration.setTargetSelectionMode(targetSelectionMode);
            }
            if (preferredAvdName != null) {
                configuration.PREFERRED_AVD = preferredAvdName;
            }
            runManager.addConfiguration(settings, false);
            runManager.setActiveConfiguration(settings);
        }
    };
    if (!ask) {
        r.run();
    } else {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
            @Override
            public void run() {
                final String moduleName = facet.getModule().getName();
                final int result = Messages.showYesNoDialog(project,
                        AndroidBundle.message("create.run.configuration.question", moduleName),
                        AndroidBundle.message("create.run.configuration.title"), Messages.getQuestionIcon());
                if (result == 0) {
                    r.run();
                }
            }
        });
    }
}

From source file:org.jetbrains.idea.devkit.actions.GenerateClassAndPatchPluginXmlActionBase.java

License:Apache License

protected PsiElement[] invokeDialogImpl(Project project, PsiDirectory directory) {
    MyInputValidator validator = new MyInputValidator(project, directory);
    Messages.showInputDialog(project, getClassNamePrompt(), getClassNamePromptTitle(),
            Messages.getQuestionIcon(), "", validator);
    return validator.getCreatedElements();
}

From source file:org.jetbrains.idea.devkit.util.ChooseModulesDialog.java

License:Apache License

public ChooseModulesDialog(final Project project, List<Module> candidateModules, @NonNls String title,
        final String message) {
    super(project, false);
    setTitle(title);/*  w w  w  .  j ava  2s.  c  o m*/

    myCandidateModules = candidateModules;
    myIcon = Messages.getQuestionIcon();
    myMessage = message;
    myView = new JBTable(new AbstractTableModel() {
        public int getRowCount() {
            return myCandidateModules.size();
        }

        public int getColumnCount() {
            return 2;
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return columnIndex == 0;
        }

        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            myStates[rowIndex] = (Boolean) aValue;
            fireTableCellUpdated(rowIndex, columnIndex);
        }

        public Class<?> getColumnClass(int columnIndex) {
            return columnIndex == 0 ? Boolean.class : Module.class;
        }

        public Object getValueAt(int rowIndex, int columnIndex) {
            return columnIndex == 0 ? myStates[rowIndex] : myCandidateModules.get(rowIndex);
        }
    });

    myView.setShowGrid(false);
    myView.setTableHeader(null);
    myView.setIntercellSpacing(new Dimension(0, 0));
    myView.getColumnModel().getColumn(0).setMaxWidth(new JCheckBox().getPreferredSize().width);
    myView.getModel().addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            getOKAction().setEnabled(getSelectedModules().size() > 0);
        }
    });
    myView.addKeyListener(new KeyAdapter() {
        public void keyTyped(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyChar() == '\n') {
                doOKAction();
            }
        }
    });
    myView.setDefaultRenderer(Module.class, new MyTableCellRenderer(project));

    myStates = new boolean[candidateModules.size()];
    Arrays.fill(myStates, true);

    init();
}

From source file:org.jetbrains.idea.maven.importing.MavenProjectImporter.java

License:Apache License

private boolean deleteObsoleteModules() {
    final List<Module> obsoleteModules = collectObsoleteModules();
    if (obsoleteModules.isEmpty()) {
        return false;
    }//w  w  w .jav  a2s .  co  m

    setMavenizedModules(obsoleteModules, false);

    final int[] result = new int[1];
    MavenUtil.invokeAndWait(myProject, myModelsProvider.getModalityStateForQuestionDialogs(), new Runnable() {
        @Override
        public void run() {
            result[0] = Messages.showYesNoDialog(myProject,
                    ProjectBundle.message("maven.import.message.delete.obsolete",
                            formatModules(obsoleteModules)),
                    ProjectBundle.message("maven.project.import.title"), Messages.getQuestionIcon());
        }
    });

    if (result[0] == Messages.NO) {
        return false;// NO
    }

    for (Module each : obsoleteModules) {
        if (!each.isDisposed()) {
            myModuleModel.disposeModule(each);
        }
    }

    return true;
}

From source file:org.jetbrains.idea.maven.indices.MavenRepositoriesConfigurable.java

License:Apache License

private void configControls() {
    myServiceList.setModel(myModel);/*www . j  a v  a 2  s.c  o m*/
    myServiceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    myAddButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final String value = (String) myServiceList.getSelectedValue();
            final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Add Service URL",
                    Messages.getQuestionIcon(), value == null ? "http://" : value, new URLInputVaslidator());
            if (StringUtil.isNotEmpty(text)) {
                myModel.add(text);
                myServiceList.setSelectedValue(text, true);
            }
        }
    });
    myEditButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final int index = myServiceList.getSelectedIndex();
            final String text = Messages.showInputDialog("Artifactory or Nexus Service URL", "Edit Service URL",
                    Messages.getQuestionIcon(), myModel.getElementAt(index), new URLInputVaslidator());
            if (StringUtil.isNotEmpty(text)) {
                myModel.setElementAt(text, index);
            }
        }
    });
    ListUtil.addRemoveListener(myRemoveButton, myServiceList);
    ListUtil.disableWhenNoSelection(myTestButton, myServiceList);
    ListUtil.disableWhenNoSelection(myEditButton, myServiceList);
    myTestButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final String value = (String) myServiceList.getSelectedValue();
            if (value != null) {
                testServiceConnection(value);
            }
        }
    });

    myUpdateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doUpdateIndex();
        }
    });

    myIndicesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            updateButtonsState();
        }
    });

    myIndicesTable.addMouseMotionListener(new MouseMotionListener() {
        public void mouseDragged(MouseEvent e) {
        }

        public void mouseMoved(MouseEvent e) {
            int row = myIndicesTable.rowAtPoint(e.getPoint());
            if (row == -1)
                return;
            updateIndexHint(row);
        }
    });

    myIndicesTable.setDefaultRenderer(Object.class, new MyCellRenderer());
    myIndicesTable.setDefaultRenderer(MavenIndicesManager.IndexUpdatingState.class, new MyIconCellRenderer());

    myServiceList.getEmptyText().setText("No services");
    myIndicesTable.getEmptyText().setText("No remote repositories");

    updateButtonsState();
}

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

License:Apache License

@RequiredUIAccess
@Override/*from  w w  w .  j  a  va 2  s. com*/
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.CreateBranchOrTagAction.java

License:Apache License

protected void perform(final Project project, final SvnVcs activeVcs, VirtualFile file, DataContext context)
        throws VcsException {
    CreateBranchOrTagDialog dialog = new CreateBranchOrTagDialog(project, true, new File(file.getPath()));
    dialog.show();//from   w w w  . j av a2s  .c  o  m
    if (dialog.isOK()) {
        final String dstURL = dialog.getToURL();
        final SVNRevision revision = dialog.getRevision();
        final String comment = dialog.getComment();
        final Ref<Exception> exception = new Ref<Exception>();
        final boolean isSrcFile = dialog.isCopyFromWorkingCopy();
        final File srcFile = new File(dialog.getCopyFromPath());
        final SVNURL srcUrl;
        final SVNURL dstSvnUrl;
        final SVNURL parentUrl;
        try {
            srcUrl = SVNURL.parseURIEncoded(dialog.getCopyFromUrl());
            dstSvnUrl = SVNURL.parseURIEncoded(dstURL);
            parentUrl = dstSvnUrl.removePathTail();

            if (!dirExists(activeVcs, project, parentUrl)) {
                int rc = Messages.showYesNoDialog(project,
                        "The repository path '" + parentUrl + "' does not exist. Would you like to create it?",
                        "Branch or Tag", Messages.getQuestionIcon());
                if (rc == Messages.NO) {
                    return;
                }
            }

        } catch (SVNException e) {
            throw new VcsException(e);
        }

        Runnable copyCommand = new Runnable() {
            public void run() {
                try {
                    ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
                    CommitEventHandler handler = null;
                    if (progress != null) {
                        progress.setText(SvnBundle.message("progress.text.copy.to", dstURL));
                        handler = new IdeaCommitHandler(progress);
                    }
                    checkCreateDir(parentUrl, activeVcs, comment);

                    SvnTarget source = isSrcFile ? SvnTarget.fromFile(srcFile, revision)
                            : SvnTarget.fromURL(srcUrl, revision);
                    long newRevision = activeVcs.getFactory(source).createCopyMoveClient().copy(source,
                            SvnTarget.fromURL(dstSvnUrl), revision, true, comment, handler);

                    updateStatusBar(newRevision, project);
                } catch (Exception e) {
                    exception.set(e);
                }
            }
        };
        ProgressManager.getInstance().runProcessWithProgressSynchronously(copyCommand,
                SvnBundle.message("progress.title.copy"), false, project);
        if (!exception.isNull()) {
            throw new VcsException(exception.get());
        }

        if (dialog.isCopyFromWorkingCopy() && dialog.isSwitchOnCreate()) {
            SingleRootSwitcher switcher = new SingleRootSwitcher(project,
                    VcsUtil.getFilePath(srcFile, srcFile.isDirectory()), dstSvnUrl.toDecodedString());

            AutoSvnUpdater.run(switcher, SvnBundle.message("action.name.switch"));
        }
    }
}