List of usage examples for com.intellij.openapi.ui LabeledComponent LabeledComponent
public LabeledComponent()
From source file:com.google.idea.blaze.android.run.test.BlazeAndroidTestRunConfigurationStateEditor.java
License:Open Source License
/** Initially generated by IntelliJ from a .form file, then checked in. */ private void doSetupUI(Project project) throws ClassCastException, InstantiationException, IllegalAccessException, ClassNotFoundException { panel = new JPanel(); panel.setLayout(new GridLayoutManager(6, 6, new Insets(0, 0, 0, 0), -1, -1)); panel.setAlignmentX(0.0f);// w ww . ja v a 2 s. c o m allInPackageButton = new JRadioButton(); allInPackageButton.setActionCommand(ResourceBundle.getBundle("messages/ExecutionBundle") .getString("jnit.configuration.all.tests.in.package.radio")); this.loadButtonText(allInPackageButton, ResourceBundle.getBundle("messages/AndroidBundle") .getString("android.run.configuration.all.in.package.radio")); panel.add(allInPackageButton, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); classButton = new JRadioButton(); classButton.setActionCommand(ResourceBundle.getBundle("messages/ExecutionBundle") .getString("junit.configuration.test.class.radio")); classButton.setEnabled(true); classButton.setSelected(false); this.loadButtonText(classButton, ResourceBundle.getBundle("messages/AndroidBundle") .getString("android.run.configuration.class.radio")); panel.add(classButton, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); testMethodButton = new JRadioButton(); testMethodButton.setActionCommand(ResourceBundle.getBundle("messages/ExecutionBundle") .getString("junit.configuration.test.method.radio")); testMethodButton.setSelected(false); this.loadButtonText(testMethodButton, ResourceBundle.getBundle("messages/AndroidBundle") .getString("android.run.configuration.method.radio")); panel.add(testMethodButton, new GridConstraints(1, 4, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); labelTest = new JBLabel(); labelTest.setHorizontalAlignment(2); labelTest.setHorizontalTextPosition(2); labelTest.setIconTextGap(4); this.loadLabelText(labelTest, ResourceBundle.getBundle("messages/ExecutionBundle") .getString("junit.configuration.configure.junit.test.label")); panel.add(labelTest, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel.add(spacer1, new GridConstraints(1, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); allInTargetButton = new JRadioButton(); allInTargetButton.setText("All in test target"); allInTargetButton.setMnemonic('A'); allInTargetButton.setDisplayedMnemonicIndex(0); panel.add(allInTargetButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); classComponent = new LabeledComponent(); classComponent.setComponentClass("javax.swing.JPanel"); classComponent.setLabelLocation("West"); classComponent.setText(ResourceBundle.getBundle("messages/AndroidBundle") .getString("android.run.configuration.class.label")); panel.add(classComponent, new GridConstraints(3, 0, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); methodComponent = new LabeledComponent(); methodComponent.setComponentClass("com.intellij.openapi.ui.TextFieldWithBrowseButton$NoPathCompletion"); methodComponent.setLabelLocation("West"); methodComponent.setText(ResourceBundle.getBundle("messages/AndroidBundle") .getString("android.run.configuration.method.label")); panel.add(methodComponent, new GridConstraints(4, 0, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); runnerComponent = new LabeledComponent(); runnerComponent.setComponentClass("javax.swing.JPanel"); runnerComponent.setEnabled(true); runnerComponent.setLabelLocation("North"); runnerComponent.setText(ResourceBundle.getBundle("messages/AndroidBundle") .getString("android.test.run.configuration.instrumentation.label")); panel.add(runnerComponent, new GridConstraints(5, 0, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); packageComponent = new LabeledComponent(); packageComponent.setComponentClass("javax.swing.JPanel"); packageComponent.setLabelLocation("West"); packageComponent.setText(ResourceBundle.getBundle("messages/AndroidBundle") .getString("android.run.configuration.package.label")); panel.add(packageComponent, new GridConstraints(2, 0, 1, 6, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); runThroughBlazeTestCheckBox = new JCheckBox(); runThroughBlazeTestCheckBox .setText(String.format("Run through '%s test'", Blaze.buildSystemName(project).toLowerCase())); runThroughBlazeTestCheckBox .setToolTipText(String.format("Slower, but more truthful to %s", Blaze.buildSystemName(project))); panel.add(runThroughBlazeTestCheckBox, new GridConstraints(0, 0, 1, 6, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); ButtonGroup buttonGroup; buttonGroup = new ButtonGroup(); buttonGroup.add(allInPackageButton); buttonGroup.add(classButton); buttonGroup.add(testMethodButton); buttonGroup.add(allInTargetButton); }
From source file:com.intellij.codeEditor.printing.ExportToHTMLDialog.java
License:Apache License
public static LabeledComponent<TextFieldWithBrowseButton> assignLabel( TextFieldWithBrowseButton targetDirectoryField, Project project) { LabeledComponent<TextFieldWithBrowseButton> labeledComponent = new LabeledComponent<TextFieldWithBrowseButton>(); labeledComponent.setText(CodeEditorBundle.message("export.to.html.output.directory.label")); targetDirectoryField.addBrowseFolderListener( CodeEditorBundle.message("export.to.html.select.output.directory.title"), CodeEditorBundle.message("export.to.html.select.output.directory.description"), project, FileChooserDescriptorFactory.createSingleFolderDescriptor()); labeledComponent.setComponent(targetDirectoryField); return labeledComponent; }
From source file:com.intellij.codeInspection.dataFlow.MethodCheckerDetailsDialog.java
License:Apache License
@Override protected JComponent createCenterPanel() { final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); final LabeledComponent<ClassField> classComponent = new LabeledComponent<ClassField>(); final LabeledComponent<MethodDropDown> methodComponent = new LabeledComponent<MethodDropDown>(); final LabeledComponent<ParameterDropDown> parameterComponent = new LabeledComponent<ParameterDropDown>(); classComponent.setText("Class"); methodComponent.setText("Method"); parameterComponent.setText("Parameter"); classComponent.setComponent(classField); methodComponent.setComponent(methodDropDown); parameterComponent.setComponent(parameterDropDown); panel.add(classComponent);/*from ww w. ja v a2 s .c o m*/ panel.add(methodComponent); panel.add(parameterComponent); return panel; }
From source file:com.intellij.debugger.ui.tree.render.configurables.ClassLabelExpressionConfigurable.java
License:Apache License
public ClassLabelExpressionConfigurable(@NotNull Project project, LabelRenderer renderer) { myRenderer = renderer;/*from w ww . j a v a 2 s . c o m*/ myCompletionEditor = new LabeledComponent<CompletionEditor>(); final PsiClass psiClass = DebuggerUtils.findClass(myRenderer.getClassName(), project, GlobalSearchScope.allScope(project)); myCompletionEditor.setComponent(((DebuggerUtilsEx) DebuggerUtils.getInstance()).createEditor(project, psiClass, "ClassLabelExpression")); myCompletionEditor.setText(DebuggerBundle.message("label.class.label.expression.configurable.node.label")); myPanel = new JPanel(new BorderLayout()); myPanel.add(myCompletionEditor, BorderLayout.NORTH); }
From source file:com.intellij.execution.application.ApplicationConfigurable.java
License:Apache License
private void createUIComponents() { myMainClass = new LabeledComponent<EditorTextFieldWithBrowseButton>(); myMainClass.setComponent(/* w w w.ja va 2 s .c o m*/ 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; } })); }
From source file:com.intellij.execution.jar.JarApplicationConfigurable.java
License:Apache License
private void createUIComponents() { myJarPathComponent = new LabeledComponent<TextFieldWithBrowseButton>(); TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton(); textFieldWithBrowseButton.addBrowseFolderListener("Choose JAR File", null, myProject, new FileChooserDescriptor(false, false, true, true, false, false)); myJarPathComponent.setComponent(textFieldWithBrowseButton); }
From source file:com.intellij.execution.junit2.configuration.JUnitConfigurable.java
License:Apache License
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(//w w w .ja v a2s.c o m 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); }
From source file:com.intellij.execution.scratch.JavaScratchConfigurable.java
License:Apache License
public JavaScratchConfigurable(final Project project) { myMainClass = new LabeledComponent<JTextField>(); myMainClass.setLabelLocation(BorderLayout.WEST); myMainClass.setText("Main &class:"); myMainClass.setComponent(new JTextField()); myScratchPathField = new LabeledComponent<TextFieldWithBrowseButton>(); myScratchPathField.setLabelLocation(BorderLayout.WEST); myScratchPathField.setText("&Path to scratch file:"); myScratchPathField.setComponent(new TextFieldWithBrowseButton(new ActionListener() { @Override// www .j a v a 2 s . c o m public void actionPerformed(ActionEvent e) { VirtualFile toSelect = getVFileFromEditor(); if (toSelect == null) { final String scratchesRoot = ScratchFileService.getInstance() .getRootPath(ScratchRootType.getInstance()); toSelect = LocalFileSystem.getInstance().findFileByPath(scratchesRoot); } final VirtualFile file = FileChooser.chooseFile( FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(), myScratchPathField.getComponent(), project, toSelect); if (file != null) { setVFileToEditor(file); } } }, this)); myModule = new LabeledComponent<ModulesComboBox>(); myModule.setLabelLocation(BorderLayout.WEST); myModule.setComponent(new ModulesComboBox()); myModule.setText("Use classpath of &module:"); myModuleSelector = new ConfigurationModuleSelector(project, myModule.getComponent()); myCommonProgramParameters = new CommonJavaParametersPanel(); myCommonProgramParameters.setModuleContext(myModuleSelector.getModule()); myModule.getComponent().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myCommonProgramParameters.setModuleContext(myModuleSelector.getModule()); } }); myJrePathEditor = new JrePathEditor(DefaultJreSelector.projectSdk(project)); myWholePanel = new JPanel(new GridBagLayout()); myWholePanel.add(myMainClass, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, JBUI.insetsTop(6), 0, 0)); myWholePanel.add(myScratchPathField, new GridBagConstraints(RELATIVE, 1, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, JBUI.insetsTop(6), 0, 0)); myWholePanel.add(myCommonProgramParameters, new GridBagConstraints(RELATIVE, 2, 1, 1, 1.0, 1.0, NORTHWEST, BOTH, JBUI.insets(12, 0), 0, 0)); myWholePanel.add(myModule, new GridBagConstraints(RELATIVE, 3, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, JBUI.emptyInsets(), 0, 0)); myWholePanel.add(myJrePathEditor, new GridBagConstraints(RELATIVE, 4, 1, 1, 1.0, 0.0, NORTHWEST, HORIZONTAL, JBUI.insetsTop(6), 0, 0)); myAnchor = UIUtil.mergeComponentsWithAnchor(myMainClass, myScratchPathField, myCommonProgramParameters, myJrePathEditor, myModule); }
From source file:com.intellij.internal.GenerateVisitorByHierarchyAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { final Ref<String> visitorNameRef = Ref.create("MyVisitor"); final Ref<PsiClass> parentClassRef = Ref.create(null); final Project project = e.getData(CommonDataKeys.PROJECT); assert project != null; final PsiNameHelper helper = PsiNameHelper.getInstance(project); final PackageChooserDialog dialog = new PackageChooserDialog( "Choose Target Package and Hierarchy Root Class", project) { @Override//from www . ja va 2 s .c o m protected ValidationInfo doValidate() { PsiDocumentManager.getInstance(project).commitAllDocuments(); if (!helper.isQualifiedName(visitorNameRef.get())) { return new ValidationInfo("Visitor class name is not valid"); } else if (parentClassRef.isNull()) { return new ValidationInfo("Hierarchy root class should be specified"); } else if (parentClassRef.get().isAnnotationType() || parentClassRef.get().isEnum()) { return new ValidationInfo("Hierarchy root class should be an interface or a class"); } return super.doValidate(); } protected JComponent createCenterPanel() { final JPanel panel = new JPanel(new BorderLayout()); panel.add(super.createCenterPanel(), BorderLayout.CENTER); panel.add(createNamePanel(), BorderLayout.NORTH); panel.add(createBaseClassPanel(), BorderLayout.SOUTH); return panel; } private JComponent createNamePanel() { LabeledComponent<JTextField> labeledComponent = new LabeledComponent<JTextField>(); labeledComponent.setText("Visitor class"); final JTextField nameField = new JTextField(visitorNameRef.get()); labeledComponent.setComponent(nameField); nameField.getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(final DocumentEvent e) { visitorNameRef.set(nameField.getText()); } }); return labeledComponent; } private JComponent createBaseClassPanel() { LabeledComponent<EditorTextField> labeledComponent = new LabeledComponent<EditorTextField>(); labeledComponent.setText("Hierarchy root class"); final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project); final PsiTypeCodeFragment codeFragment = factory.createTypeCodeFragment("", null, true, JavaCodeFragmentFactory.ALLOW_VOID); final Document document = PsiDocumentManager.getInstance(project).getDocument(codeFragment); final EditorTextField editorTextField = new EditorTextField(document, project, JavaFileType.INSTANCE); labeledComponent.setComponent(editorTextField); editorTextField.addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() { public void documentChanged(final com.intellij.openapi.editor.event.DocumentEvent e) { parentClassRef.set(null); try { final PsiType psiType = codeFragment.getType(); final PsiClass psiClass = psiType instanceof PsiClassType ? ((PsiClassType) psiType).resolve() : null; parentClassRef.set(psiClass); } catch (PsiTypeCodeFragment.IncorrectTypeException e1) { // ok } } }); return labeledComponent; } }; final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(e.getDataContext()); if (element instanceof PsiJavaPackage) { dialog.selectPackage(((PsiJavaPackage) element).getQualifiedName()); } else if (element instanceof PsiDirectory) { final PsiJavaPackage aPackage = JavaDirectoryService.getInstance().getPackage((PsiDirectory) element); if (aPackage != null) { dialog.selectPackage(aPackage.getQualifiedName()); } } dialog.show(); if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE || dialog.getSelectedPackage() == null || dialog.getSelectedPackage().getQualifiedName().length() == 0 || parentClassRef.isNull()) { return; } final String visitorQName = generateEverything(dialog.getSelectedPackage(), parentClassRef.get(), visitorNameRef.get()); final IdeView ideView = LangDataKeys.IDE_VIEW.getData(e.getDataContext()); final PsiClass visitorClass = JavaPsiFacade.getInstance(project).findClass(visitorQName, GlobalSearchScope.projectScope(project)); if (ideView != null && visitorClass != null) { ideView.selectElement(visitorClass); } }
From source file:com.intellij.refactoring.introduceParameter.InplaceIntroduceParameterUI.java
License:Apache License
@Override protected JPanel createReplaceFieldsWithGettersPanel() { final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>(); myReplaceFieldsCb = new JComboBox( new Integer[] { IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_ALL, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE }); myReplaceFieldsCb.setRenderer(new ListCellRendererWrapper<Integer>() { @Override//from www . j a v a 2s. c o m public void customize(JList list, Integer value, int index, boolean selected, boolean hasFocus) { switch (value) { case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE: setText(UIUtil.removeMnemonic(RefactoringBundle.message("do.not.replace"))); break; case IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE: setText(UIUtil.removeMnemonic( RefactoringBundle.message("replace.fields.inaccessible.in.usage.context"))); break; default: setText(UIUtil.removeMnemonic(RefactoringBundle.message("replace.all.fields"))); } } }); myReplaceFieldsCb.setSelectedItem( JavaRefactoringSettings.getInstance().INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS); KeyboardComboSwitcher.setupActions(myReplaceFieldsCb, myProject); component.setComponent(myReplaceFieldsCb); component.setText(RefactoringBundle.message("replace.fields.used.in.expressions.with.their.getters")); component.getLabel().setDisplayedMnemonic('u'); component.setLabelLocation(BorderLayout.NORTH); component.setBorder(IdeBorderFactory.createEmptyBorder(3, 3, 2, 2)); return component; }