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:com.intellij.refactoring.util.duplicates.DuplicatesImpl.java

License:Apache License

public static void processDuplicates(@NotNull MatchProvider provider, @NotNull Project project,
        @NotNull Editor editor) {/*from  w w  w  .j  a va2  s. co  m*/
    boolean hasDuplicates = provider.hasDuplicates();
    if (hasDuplicates) {
        List<Match> duplicates = provider.getDuplicates();
        if (duplicates.size() == 1) {
            previewMatch(project, duplicates.get(0), editor);
        }
        final int answer = ApplicationManager.getApplication().isUnitTestMode() ? 0
                : Messages.showYesNoDialog(project, RefactoringBundle.message(
                        "0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.method",
                        ApplicationNamesInfo.getInstance().getProductName(), duplicates.size()),
                        "Process Duplicates", Messages.getQuestionIcon());
        if (answer == 0) {
            invoke(project, editor, provider);
        }
    }
}

From source file:com.intellij.struts2.facet.ui.FileSetConfigurationTab.java

License:Apache License

private void remove() {
    final SimpleNode[] nodes = myTree.getSelectedNodesIfUniform();
    for (final SimpleNode node : nodes) {

        if (node instanceof FileSetNode) {
            final StrutsFileSet fileSet = ((FileSetNode) node).mySet;
            if (fileSet.getFiles().isEmpty()) {
                myBuffer.remove(fileSet);
                return;
            }//w  w  w. j  a  va  2s . c  o m

            final int result = Messages.showYesNoDialog(myPanel,
                    StrutsBundle.message("facet.fileset.remove.fileset.question", fileSet.getName()),
                    StrutsBundle.message("facet.fileset.remove.fileset.title"), Messages.getQuestionIcon());
            if (result == Messages.YES) {
                if (fileSet.isAutodetected()) {
                    fileSet.setRemoved(true);
                    myBuffer.add(fileSet);
                } else {
                    myBuffer.remove(fileSet);
                }
            }
        } else if (node instanceof ConfigFileNode) {
            final VirtualFilePointer filePointer = ((ConfigFileNode) node).myFilePointer;
            final StrutsFileSet fileSet = ((FileSetNode) node.getParent()).mySet;
            fileSet.removeFile(filePointer);
        }
    }
}

From source file:com.intellij.testIntegration.createTest.CreateTestAction.java

License:Apache License

@Override
public void invoke(final @NotNull Project project, Editor editor, @NotNull PsiElement element)
        throws IncorrectOperationException {
    if (!FileModificationService.getInstance().preparePsiElementForWrite(element))
        return;//from w  w w  .j a  va  2 s .  c o m
    final Module srcModule = ModuleUtilCore.findModuleForPsiElement(element);
    final PsiClass srcClass = getContainingClass(element);

    if (srcClass == null)
        return;

    PsiDirectory srcDir = element.getContainingFile().getContainingDirectory();
    PsiJavaPackage srcPackage = JavaDirectoryService.getInstance().getPackage(srcDir);

    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    final HashSet<VirtualFile> testFolders = new HashSet<VirtualFile>();
    checkForTestRoots(srcModule, testFolders);
    if (testFolders.isEmpty() && !propertiesComponent.getBoolean(CREATE_TEST_IN_THE_SAME_ROOT, false)) {
        if (Messages.showOkCancelDialog(project, "Create test in the same source root?", "No Test Roots Found",
                Messages.getQuestionIcon()) != DialogWrapper.OK_EXIT_CODE) {
            return;
        }

        propertiesComponent.setValue(CREATE_TEST_IN_THE_SAME_ROOT, String.valueOf(true));
    }

    final CreateTestDialog d = new CreateTestDialog(project, getText(), srcClass, srcPackage, srcModule);
    d.show();
    if (!d.isOK())
        return;

    CommandProcessor.getInstance().executeCommand(project, new Runnable() {
        @Override
        public void run() {
            TestFramework framework = d.getSelectedTestFrameworkDescriptor();
            TestGenerator generator = TestGenerators.INSTANCE.forLanguage(framework.getLanguage());
            generator.generateTest(project, d);
        }
    }, CodeInsightBundle.message("intention.create.test"), this);
}

From source file:com.intellij.tools.ScanSourceCommentsAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {

    final Project p = CommonDataKeys.PROJECT.getData(e.getDataContext());
    final String file = Messages.showInputDialog(p, "Enter path to the file comments will be extracted to",
            "Comments File Path", Messages.getQuestionIcon());

    try {//w w  w. j a  v  a 2 s  .  co m
        final PrintStream stream = new PrintStream(file);
        stream.println("Comments in " + p.getName());

        ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
            @Override
            public void run() {
                final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
                ProjectRootManager.getInstance(p).getFileIndex().iterateContent(new ContentIterator() {
                    @Override
                    public boolean processFile(VirtualFile fileOrDir) {
                        if (fileOrDir.isDirectory()) {
                            indicator.setText("Extracting comments");
                            indicator.setText2(fileOrDir.getPresentableUrl());
                        }
                        scanCommentsInFile(p, fileOrDir);
                        return true;
                    }
                });

                indicator.setText2("");
                int count = 1;
                for (CommentDescriptor descriptor : myComments.values()) {
                    stream.println(
                            "#" + count + " ---------------------------------------------------------------");
                    descriptor.print(stream);
                    stream.println();
                    count++;
                }

            }
        }, "Generating Comments", true, p);

        stream.close();

    } catch (Throwable e1) {
        LOG.error(e1);
        Messages.showErrorDialog(p, "Error writing? " + e1.getMessage(), "Problem writing");
    }
}

From source file:com.intellij.ui.classFilter.ClassFilterEditorAddDialog.java

License:Apache License

protected JComponent createCenterPanel() {
    final JPanel panel = new JPanel(new GridBagLayout());
    final JLabel header = new JLabel(UIBundle.message("label.class.filter.editor.add.dialog.filter.pattern"));
    myClassName = new TextFieldWithBrowseButton(new JTextField(35));
    final JLabel iconLabel = new JLabel(Messages.getQuestionIcon());

    panel.add(header, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
    panel.add(myClassName, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 10, 0, 0), 0, 0));
    panel.add(iconLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 1.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE, new Insets(15, 0, 0, 0), 0, 0));

    myClassName.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            PsiClass currentClass = getSelectedClass();
            TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject)
                    .createNoInnerClassesScopeChooser(
                            UIBundle.message("class.filter.editor.choose.class.title"),
                            GlobalSearchScope.allScope(myProject), null, null);
            if (currentClass != null) {
                PsiFile containingFile = currentClass.getContainingFile();
                if (containingFile != null) {
                    PsiDirectory containingDirectory = containingFile.getContainingDirectory();
                    if (containingDirectory != null) {
                        chooser.selectDirectory(containingDirectory);
                    }/*w w w  .  j  a  v  a  2 s .c  om*/
                }
            }
            chooser.showDialog();
            PsiClass selectedClass = chooser.getSelected();
            if (selectedClass != null) {
                myClassName.setText(selectedClass.getQualifiedName());
            }
        }
    });

    myClassName.setEnabled(myProject != null);

    return panel;
}

From source file:com.intellij.ui.ReplacePromptDialog.java

License:Apache License

@Override
public JComponent createNorthPanel() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    Icon icon = Messages.getQuestionIcon();
    if (icon != null) {
        JLabel iconLabel = new JLabel(icon);
        panel.add(iconLabel, BorderLayout.WEST);
    }//from   w ww.j av a  2  s  . c  o m
    JLabel label = new JLabel(getMessage());
    label.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 10));
    label.setForeground(JBColor.foreground());
    panel.add(label, BorderLayout.CENTER);
    return panel;
}

From source file:com.intellij.ui.tabs.impl.DragHelper.java

License:Apache License

@Override
protected void processDragFinish(MouseEvent event, boolean willDragOutStart) {
    super.processDragFinish(event, willDragOutStart);

    endDrag(willDragOutStart);/*from w w  w  .  j  a  va  2  s  . c  o  m*/

    final JBTabsPosition position = myTabs.getTabsPosition();

    if (!willDragOutStart && myTabs.isAlphabeticalMode() && position != JBTabsPosition.top
            && position != JBTabsPosition.bottom) {
        Point p = new Point(event.getPoint());
        p = SwingUtilities.convertPoint(event.getComponent(), p, myTabs);
        if (myTabs.getVisibleRect().contains(p)
                && myPressedOnScreenPoint.distance(new RelativePoint(event).getScreenPoint()) > 15) {
            final int answer = Messages.showOkCancelDialog(myTabs,
                    IdeBundle.message("alphabetical.mode.is.on.warning"), IdeBundle.message("title.warning"),
                    Messages.getQuestionIcon());
            if (answer == Messages.OK) {
                JBEditorTabs.setAlphabeticalMode(false);
                myTabs.relayout(true, false);
                myTabs.revalidate();
            }
        }
    }
}

From source file:com.intellij.uiDesigner.actions.DataBindingWizardAction.java

License:Apache License

public void actionPerformed(final AnActionEvent e) {
    final Project project;
    final VirtualFile formFile;
    GuiEditor editor = FormEditingUtil.getActiveEditor(e.getDataContext());
    assert editor != null;
    project = editor.getProject();//from   www. ja va  2  s . c om
    formFile = editor.getFile();

    try {
        final WizardData wizardData = new WizardData(project, formFile);

        final Module module = ModuleUtil.findModuleForFile(formFile, wizardData.myProject);
        LOG.assertTrue(module != null);

        final LwRootContainer[] rootContainer = new LwRootContainer[1];
        Generator.exposeForm(wizardData.myProject, formFile, rootContainer);
        final String classToBind = rootContainer[0].getClassToBind();
        if (classToBind == null) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.form.not.bound"),
                    UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }

        final PsiClass boundClass = FormEditingUtil.findClassToBind(module, classToBind);
        if (boundClass == null) {
            Messages.showErrorDialog(project,
                    UIDesignerBundle.message("error.bound.to.not.found.class", classToBind),
                    UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }

        Generator.prepareWizardData(wizardData, boundClass);

        if (!hasBinding(rootContainer[0])) {
            Messages.showInfoMessage(project, UIDesignerBundle.message("info.no.bound.components"),
                    UIDesignerBundle.message("title.data.binding.wizard"));
            return;
        }

        if (!wizardData.myBindToNewBean) {
            final String[] variants = new String[] { UIDesignerBundle.message("action.alter.data.binding"),
                    UIDesignerBundle.message("action.bind.to.another.bean"),
                    CommonBundle.getCancelButtonText() };
            final int result = Messages.showYesNoCancelDialog(project,
                    MessageFormat.format(UIDesignerBundle.message("info.data.binding.regenerate"),
                            wizardData.myBeanClass.getQualifiedName()),
                    UIDesignerBundle.message("title.data.binding"), variants[0], variants[1], variants[2],
                    Messages.getQuestionIcon());
            if (result == 0) {
                // do nothing here
            } else if (result == 1) {
                wizardData.myBindToNewBean = true;
            } else {
                return;
            }
        }

        final DataBindingWizard wizard = new DataBindingWizard(project, formFile, wizardData);
        wizard.show();
    } catch (Generator.MyException exc) {
        Messages.showErrorDialog(project, exc.getMessage(), CommonBundle.getErrorTitle());
    }
}

From source file:com.intellij.uiDesigner.actions.GroupButtonsAction.java

License:Apache License

public static void groupButtons(final GuiEditor editor, final List<RadComponent> selectedComponents) {
    if (!editor.ensureEditable())
        return;//from  w ww  . j a  va 2  s.com
    String groupName = Messages.showInputDialog(editor.getProject(),
            UIDesignerBundle.message("group.buttons.name.prompt"),
            UIDesignerBundle.message("group.buttons.title"), Messages.getQuestionIcon(),
            editor.getRootContainer().suggestGroupName(), new IdentifierValidator(editor.getProject()));
    if (groupName == null)
        return;
    RadRootContainer rootContainer = editor.getRootContainer();
    RadButtonGroup group = rootContainer.createGroup(groupName);
    for (RadComponent component : selectedComponents) {
        rootContainer.setGroupForComponent(component, group);
    }
    editor.refreshAndSave(true);
}

From source file:com.intellij.uiDesigner.designSurface.InsertComponentProcessor.java

License:Apache License

private boolean checkAddModuleDependency(final ComponentItem item,
        final ModuleSourceOrderEntry moduleSourceOrderEntry) {
    final Module ownerModule = moduleSourceOrderEntry.getOwnerModule();
    int rc = Messages.showYesNoCancelDialog(myEditor,
            UIDesignerBundle.message("add.module.dependency.prompt", item.getClassName(), ownerModule.getName(),
                    myEditor.getModule().getName()),
            UIDesignerBundle.message("add.module.dependency.title"), Messages.getQuestionIcon());
    if (rc == Messages.CANCEL) {
        return false;
    }// ww w  .ja v a2  s . c  o  m
    if (rc == Messages.YES) {
        ModuleRootModificationUtil.addDependency(myEditor.getModule(), ownerModule);
    }
    return true;
}