Search in sources :

Example 1 with MessageInfoException

use of com.theoryinpractice.testng.MessageInfoException in project intellij-community by JetBrains.

the class TestClassBrowser method showDialog.

@Override
protected String showDialog() {
    ClassFilter.ClassFilterWithScope filter;
    try {
        filter = getFilter();
    } catch (MessageInfoException e) {
        MessagesEx.MessageInfo message = e.getMessageInfo();
        message.showNow();
        return null;
    }
    TreeClassChooser chooser = TreeClassChooserFactory.getInstance(getProject()).createWithInnerClassesScopeChooser("Choose Test Class", filter.getScope(), filter, null);
    init(chooser);
    chooser.showDialog();
    PsiClass psiclass = chooser.getSelected();
    if (psiclass == null) {
        return null;
    } else {
        onClassChoosen(psiclass);
        return psiclass.getQualifiedName();
    }
}
Also used : TreeClassChooser(com.intellij.ide.util.TreeClassChooser) ClassFilter(com.intellij.ide.util.ClassFilter) TestClassFilter(com.theoryinpractice.testng.model.TestClassFilter) PsiClass(com.intellij.psi.PsiClass) MessageInfoException(com.theoryinpractice.testng.MessageInfoException)

Example 2 with MessageInfoException

use of com.theoryinpractice.testng.MessageInfoException in project intellij-community by JetBrains.

the class TestNGConfigurationEditor method createView.

private void createView() {
    commonParametersPanel.add(commonJavaParameters, BorderLayout.CENTER);
    classField.setComponent(new EditorTextFieldWithBrowseButton(project, true, new JavaCodeFragment.VisibilityChecker() {

        @Override
        public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
            if (declaration instanceof PsiClass && place.getParent() instanceof PsiJavaCodeReferenceElement) {
                return Visibility.VISIBLE;
            }
            try {
                if (declaration instanceof PsiClass && new TestClassBrowser(project, TestNGConfigurationEditor.this).getFilter().isAccepted((PsiClass) declaration)) {
                    return Visibility.VISIBLE;
                }
            } catch (MessageInfoException e) {
                return Visibility.NOT_VISIBLE;
            }
            return Visibility.NOT_VISIBLE;
        }
    }));
    final EditorTextFieldWithBrowseButton methodEditorTextField = new EditorTextFieldWithBrowseButton(project, true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, PlainTextLanguage.INSTANCE.getAssociatedFileType());
    methodField.setComponent(methodEditorTextField);
    groupField.setComponent(new TextFieldWithBrowseButton.NoPathCompletion());
    suiteField.setComponent(new TextFieldWithBrowseButton());
    packageField.setVisible(true);
    packageField.setEnabled(true);
    packageField.setComponent(new EditorTextFieldWithBrowseButton(project, false));
    TextFieldWithBrowseButton outputDirectoryButton = new TextFieldWithBrowseButton();
    outputDirectory.setComponent(outputDirectoryButton);
    outputDirectoryButton.addBrowseFolderListener("TestNG", "Select test output directory", project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
    moduleClasspath.setEnabled(true);
    moduleClasspath.setComponent(new ModulesComboBox());
    propertiesTableModel = new TestNGParametersTableModel();
    listenerModel = new TestNGListenersTableModel();
    TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
    propertiesFile.setComponent(textFieldWithBrowseButton);
    FileChooserDescriptor propertiesFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {

        @Override
        public boolean isFileVisible(VirtualFile virtualFile, boolean showHidden) {
            if (!showHidden && virtualFile.getName().charAt(0) == '.')
                return false;
            return virtualFile.isDirectory() || "properties".equals(virtualFile.getExtension());
        }
    };
    textFieldWithBrowseButton.addBrowseFolderListener("TestNG", "Select .properties file for test properties", project, propertiesFileDescriptor);
    propertiesTableView = new TableView(propertiesTableModel);
    myPropertiesPanel.add(ToolbarDecorator.createDecorator(propertiesTableView).setAddAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            propertiesTableModel.addParameter();
            int index = propertiesTableModel.getRowCount() - 1;
            propertiesTableView.setRowSelectionInterval(index, index);
        }
    }).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            int idx = propertiesTableView.getSelectedRow() - 1;
            for (int row : propertiesTableView.getSelectedRows()) {
                propertiesTableModel.removeProperty(row);
            }
            if (idx > -1)
                propertiesTableView.setRowSelectionInterval(idx, idx);
        }
    }).disableUpDownActions().createPanel(), BorderLayout.CENTER);
    myListenersList = new JBList(listenerModel);
    myListenersPanel.add(ToolbarDecorator.createDecorator(myListenersList).setAddAction(new AddActionButtonRunnable()).setRemoveAction(new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            int idx = myListenersList.getSelectedIndex() - 1;
            for (int row : myListenersList.getSelectedIndices()) {
                listenerModel.removeListener(row);
            }
            if (idx > -1)
                myListenersList.setSelectedIndex(idx);
        }
    }).setAddActionUpdater(new AnActionButtonUpdater() {

        @Override
        public boolean isEnabled(AnActionEvent e) {
            return !project.isDefault();
        }
    }).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) MessageInfoException(com.theoryinpractice.testng.MessageInfoException) ModulesComboBox(com.intellij.application.options.ModulesComboBox) TestClassBrowser(com.theoryinpractice.testng.configuration.browser.TestClassBrowser) JBList(com.intellij.ui.components.JBList) TableView(com.intellij.ui.table.TableView)

Aggregations

MessageInfoException (com.theoryinpractice.testng.MessageInfoException)2 ModulesComboBox (com.intellij.application.options.ModulesComboBox)1 ClassFilter (com.intellij.ide.util.ClassFilter)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiClass (com.intellij.psi.PsiClass)1 JBList (com.intellij.ui.components.JBList)1 TableView (com.intellij.ui.table.TableView)1 TestClassBrowser (com.theoryinpractice.testng.configuration.browser.TestClassBrowser)1 TestClassFilter (com.theoryinpractice.testng.model.TestClassFilter)1