Search in sources :

Example 1 with EditorTextFieldWithBrowseButton

use of com.intellij.ui.EditorTextFieldWithBrowseButton in project intellij-community by JetBrains.

the class ApplicationConfigurable method createUIComponents.

private void createUIComponents() {
    myMainClass = new LabeledComponent<>();
    myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() {

        @Override
        public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
            if (declaration instanceof PsiClass) {
                final PsiClass aClass = (PsiClass) declaration;
                if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null && myModuleSelector.findClass(((PsiClass) declaration).getQualifiedName()) != null) {
                    return Visibility.VISIBLE;
                }
            }
            return Visibility.NOT_VISIBLE;
        }
    }));
}
Also used : EditorTextFieldWithBrowseButton(com.intellij.ui.EditorTextFieldWithBrowseButton) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement)

Example 2 with EditorTextFieldWithBrowseButton

use of com.intellij.ui.EditorTextFieldWithBrowseButton in project intellij-community by JetBrains.

the class ConfigurationsTest method testEditJUnitConfiguration.

public void testEditJUnitConfiguration() throws ConfigurationException {
    if (PlatformTestUtil.COVERAGE_ENABLED_BUILD)
        return;
    PsiClass testA = findTestA(getModule2());
    JUnitConfiguration configuration = createConfiguration(testA);
    JUnitConfigurable editor = new JUnitConfigurable(myProject);
    try {
        Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
        configurable.reset();
        final EditorTextFieldWithBrowseButton component = ((LabeledComponent<EditorTextFieldWithBrowseButton>) editor.getTestLocation(JUnitConfigurationModel.CLASS)).getComponent();
        assertEquals(testA.getQualifiedName(), component.getText());
        PsiClass otherTest = findClass(getModule2(), "test2.Test2");
        component.setText(otherTest.getQualifiedName());
        configurable.apply();
        assertEquals(otherTest.getName(), configuration.getName());
        String specialName = "My name";
        configuration.setName(specialName);
        configuration.setNameChangedByUser(true);
        configurable.reset();
        component.setText(testA.getQualifiedName());
        configurable.apply();
        assertEquals(specialName, configuration.getName());
    } finally {
        Disposer.dispose(editor);
    }
}
Also used : EditorTextFieldWithBrowseButton(com.intellij.ui.EditorTextFieldWithBrowseButton) JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable) Configurable(com.intellij.openapi.options.Configurable) ApplicationConfigurable(com.intellij.execution.application.ApplicationConfigurable) JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable) LabeledComponent(com.intellij.openapi.ui.LabeledComponent)

Example 3 with EditorTextFieldWithBrowseButton

use of com.intellij.ui.EditorTextFieldWithBrowseButton in project intellij-plugins by JetBrains.

the class CucumberJavaApplicationConfigurable method createUIComponents.

private void createUIComponents() {
    myMainClass = new LabeledComponent<>();
    myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() {

        @Override
        public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
            if (declaration instanceof PsiClass) {
                final PsiClass aClass = (PsiClass) declaration;
                if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null) {
                    return Visibility.VISIBLE;
                }
            }
            return Visibility.NOT_VISIBLE;
        }
    }));
}
Also used : EditorTextFieldWithBrowseButton(com.intellij.ui.EditorTextFieldWithBrowseButton) PsiClass(com.intellij.psi.PsiClass) PsiElement(com.intellij.psi.PsiElement)

Aggregations

EditorTextFieldWithBrowseButton (com.intellij.ui.EditorTextFieldWithBrowseButton)3 PsiClass (com.intellij.psi.PsiClass)2 PsiElement (com.intellij.psi.PsiElement)2 ApplicationConfigurable (com.intellij.execution.application.ApplicationConfigurable)1 JUnitConfigurable (com.intellij.execution.junit2.configuration.JUnitConfigurable)1 Configurable (com.intellij.openapi.options.Configurable)1 LabeledComponent (com.intellij.openapi.ui.LabeledComponent)1