private void createUIComponents() { myMainClass = new LabeledComponent<>(); myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, (declaration, place) -> { if (declaration instanceof PsiClass) { final PsiClass aClass = (PsiClass) declaration; if (ConfigurationUtil.MAIN_CLASS.value(aClass) && PsiMethodUtil.findMainMethod(aClass) != null) { return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE; } } return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE; } )); }
private void createUIComponents() { myMainClass = new LabeledComponent<EditorTextFieldWithBrowseButton>(); 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; } })); }
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); } }
TestRunParameters(Project project, ConfigurationModuleSelector moduleSelector) { myProject = project; myModuleSelector = moduleSelector; myPackageComponent.setComponent(new EditorTextFieldWithBrowseButton(project, false)); bind(myPackageComponent, new MyPackageBrowser()); myClassComponent .setComponent(new EditorTextFieldWithBrowseButton(project, true, new AndroidTestClassVisibilityChecker(moduleSelector))); bind(myClassComponent, new AndroidTestClassBrowser(project, moduleSelector, AndroidBundle.message("android.browse.test.class.dialog.title"), false)); myRunnerComponent.setComponent(new EditorTextFieldWithBrowseButton(project, true, new AndroidInheritingClassVisibilityChecker(myProject, moduleSelector, AndroidUtils.INSTRUMENTATION_RUNNER_BASE_CLASS))); bind(myRunnerComponent, new AndroidInheritingClassBrowser(project, moduleSelector, AndroidUtils.INSTRUMENTATION_RUNNER_BASE_CLASS, AndroidBundle.message("android.browse.instrumentation.class.dialog.title"), true )); bind(myMethodComponent, new MyMethodBrowser()); addTestingType(TEST_ALL_IN_MODULE, myAllInModuleButton); addTestingType(TEST_ALL_IN_PACKAGE, myAllInPackageButton); addTestingType(TEST_CLASS, myClassButton); addTestingType(TEST_METHOD, myTestMethodButton); setAnchor(myPackageComponent.getLabel()); }
/** * Creates UI Components */ private void createUIComponents() { myMainClass = new LabeledComponent<>(); myMainClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, (declaration, 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 JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE; } } return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE; })); }
private void createUIComponents() { myMainClass = new LabeledComponent<EditorTextFieldWithBrowseButton>(); 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; } })); }
public void testEditJUnitConfiguration() throws ConfigurationException { if (IdeaTestUtil.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); } }
private static <T extends ComboBox<?>> boolean isClassInProductionSources(T moduleComboBox, Function<T, Module> getSelectedModule, EditorTextFieldWithBrowseButton classSelector) { Module module = getSelectedModule.apply(moduleComboBox); if(module == null) { return false; } return ObjectUtil.notNull(JavaParametersUtil.isClassInProductionSources(classSelector.getText(), module), Boolean.FALSE); }
public EditorTextFieldWithBrowseButton getMainClassField() { return myMainClass.getComponent(); }
private void createClassTextField() { myClass = new LabeledComponent<EditorTextFieldWithBrowseButton>(); EditorTextFieldWithBrowseButton myClassBrowseTextField = new EditorTextFieldWithBrowseButton(project, true, JavaCodeFragment.VisibilityChecker.PROJECT_SCOPE_VISIBLE); myClass.setComponent(myClassBrowseTextField); }
private void createUIComponents() { myPackage = new LabeledComponent<EditorTextFieldWithBrowseButton>(); myPackage.setComponent(new EditorTextFieldWithBrowseButton(myProject, false)); myClass = new LabeledComponent<EditorTextFieldWithBrowseButton>(); final TestClassBrowser classBrowser = new TestClassBrowser(myProject); myClass.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() { @Override public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) { try { if (declaration instanceof PsiClass && classBrowser.getFilter().isAccepted(((PsiClass)declaration))) { return Visibility.VISIBLE; } } catch (ClassBrowser.NoFilterException e) { return Visibility.NOT_VISIBLE; } return Visibility.NOT_VISIBLE; } })); myMethod = new LabeledComponent<EditorTextFieldWithBrowseButton>(); final EditorTextFieldWithBrowseButton textFieldWithBrowseButton = new EditorTextFieldWithBrowseButton(myProject, true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, PlainTextLanguage.INSTANCE.getAssociatedFileType()); new TextFieldCompletionProvider() { @Override protected void addCompletionVariants(@NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result) { final String className = getClassName(); if (className.trim().length() == 0) { return; } final PsiClass testClass = getModuleSelector().findClass(className); if (testClass == null) return; final JUnitUtil.TestMethodFilter filter = new JUnitUtil.TestMethodFilter(testClass); for (PsiMethod psiMethod : testClass.getAllMethods()) { if (filter.value(psiMethod)) { result.addElement(LookupElementBuilder.create(psiMethod.getName())); } } } }.apply(textFieldWithBrowseButton.getChildComponent()); myMethod.setComponent(textFieldWithBrowseButton); }
private String getClassName() { return ((LabeledComponent<EditorTextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.CLASS)).getComponent().getText(); }
private void setPackage(final PsiPackage aPackage) { if (aPackage == null) return; ((LabeledComponent<EditorTextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.ALL_IN_PACKAGE)).getComponent() .setText(aPackage.getQualifiedName()); }
public EditorTextFieldWithBrowseButton getMainClassField() { return myMainClassField; }
public SdkFromSourceRootDependencies(T moduleComboBox, Function<T, Module> getSelectedModule, EditorTextFieldWithBrowseButton classSelector) { super(moduleComboBox, getSelectedModule, () -> isClassInProductionSources(moduleComboBox, getSelectedModule, classSelector)); myClassSelector = classSelector; }
@NotNull public static DefaultJreSelector fromSourceRootsDependencies(ModulesComboBox modulesCombobox, EditorTextFieldWithBrowseButton classSelector) { return new SdkFromSourceRootDependencies<>(modulesCombobox, ModulesComboBox::getSelectedModule, classSelector); }
@NotNull public static DefaultJreSelector fromSourceRootsDependencies(ModuleDescriptionsComboBox modulesCombobox, EditorTextFieldWithBrowseButton classSelector) { return new SdkFromSourceRootDependencies<>(modulesCombobox, ModuleDescriptionsComboBox::getSelectedModule, classSelector); }
private EditorTextFieldWithBrowseButton getClassNameComponent() { return myClassName; }
private void createUIComponents() { myClassName = new EditorTextFieldWithBrowseButton(myProject, true); }
/** * Gets the main class to execute java app against * @return */ public EditorTextFieldWithBrowseButton getMainClassField() { return myMainClass.getComponent(); }