List of usage examples for com.intellij.openapi.ui LabeledComponent create
@NotNull
public static <Comp extends JComponent> LabeledComponent<Comp> create(@NotNull Comp component,
@NotNull String text)
From source file:ch.mjava.intellij.FieldChoiceDialog.java
License:Apache License
public FieldChoiceDialog(Project project, PsiMethod[] allFields) { super(project); setTitle("Select Fields"); myFields = new CollectionListModel<PsiMethod>(allFields); fieldList = new JList(myFields); fieldList.setCellRenderer(new DefaultPsiElementCellRenderer()); fieldList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList); decorator.disableAddAction();//w ww . ja v a 2s. c om decorator.disableUpDownActions(); decorator.disableRemoveAction(); JPanel panel = decorator.createPanel(); myComponent = LabeledComponent.create(panel, "Candidates"); init(); }
From source file:cn.nekocode.plugin.parcelablegenerator.GenerateDialog.java
License:Apache License
protected GenerateDialog(KtClass ktClass) { super(ktClass.getProject()); setTitle("Select Fields for Parcelable Generation"); myFileds = new CollectionListModel<>(KtClassHelper.findParams(ktClass)); JBList fieldList = new JBList(myFileds); fieldList.setCellRenderer(new DefaultListCellRenderer() { @Override//from w ww.j a va 2 s .c o m public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { ValueParameterDescriptor descriptor = (ValueParameterDescriptor) value; String name = descriptor.getName().asString(); String type = descriptor.getType().toString(); Component renderer = super.getListCellRendererComponent(list, name + ": " + type, index, isSelected, cellHasFocus); return renderer; } }); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList); decorator.disableAddAction(); JPanel panel = decorator.createPanel(); myComponent = LabeledComponent.create(panel, "Fields to include in Parcelable"); init(); }
From source file:com.booking.android.parcelable_plugin.GenerateDialog.java
License:Apache License
protected GenerateDialog(final PsiClass psiClass) { super(psiClass.getProject()); setTitle("Select Fields for Parcelable Generation"); fieldsCollection = new CollectionListModel<PsiField>(); final JBList fieldList = new JBList(fieldsCollection); fieldList.setCellRenderer(new DefaultPsiElementCellRenderer()); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList).disableAddAction(); final JPanel panel = decorator.createPanel(); fieldsComponent = LabeledComponent.create(panel, "Fields to include in Parcelable"); includeSubclasses = new JBCheckBox("Include fields from base classes"); setupCheckboxClickAction(psiClass);//from w w w .ja va 2s . c om showCheckbox = psiClass.getFields().length != psiClass.getAllFields().length; fieldList.setSelectionInterval(0, fieldsCollection.getSize() - 1); updateFieldsDisplay(psiClass); init(); }
From source file:com.intellij.execution.ui.CommonJavaParametersPanel.java
License:Apache License
@Override protected void addComponents() { myVMParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), ExecutionBundle.message("run.configuration.java.vm.parameters.label")); copyDialogCaption(myVMParametersComponent); myVMParametersComponent.setLabelLocation(BorderLayout.WEST); add(myVMParametersComponent);/* ww w.j a v a2s .c o m*/ super.addComponents(); }
From source file:com.intellij.execution.ui.CommonProgramParametersPanel.java
License:Apache License
protected void initComponents() { myProgramParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), ExecutionBundle.message("run.configuration.program.parameters")); final JPanel panel = new JPanel(new BorderLayout()); myWorkingDirectoryField = new TextFieldWithBrowseButton(new ActionListener() { @Override/* www . j av a 2s . com*/ public void actionPerformed(ActionEvent e) { FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory .createSingleFolderDescriptor(); fileChooserDescriptor.setTitle(ExecutionBundle.message("select.working.directory.message")); fileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModuleContext); Project project = myModuleContext != null ? myModuleContext.getProject() : null; VirtualFile file = FileChooser.chooseFile(fileChooserDescriptor, myWorkingDirectoryComponent, project, null); if (file != null) { setWorkingDirectory(file.getPresentableUrl()); } } }) { @Override protected void installPathCompletion(FileChooserDescriptor fileChooserDescriptor) { super.installPathCompletion(FileChooserDescriptorFactory.createSingleFolderDescriptor()); } }; panel.add(myWorkingDirectoryField, BorderLayout.CENTER); final FixedSizeButton button = new FixedSizeButton(myWorkingDirectoryField); button.setIcon(AllIcons.RunConfigurations.Variables); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final List<String> macros = new ArrayList<String>(PathMacros.getInstance().getUserMacroNames()); if (myHaveModuleContext) macros.add("MODULE_DIR"); final JList list = new JBList(ArrayUtil.toStringArray(macros)); final JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list) .setItemChoosenCallback(new Runnable() { @Override public void run() { final Object value = list.getSelectedValue(); if (value instanceof String) { setWorkingDirectory("$" + value + "$"); } } }).setMovable(false).setResizable(false).createPopup(); popup.showUnderneathOf(button); } }); panel.add(button, BorderLayout.EAST); myWorkingDirectoryComponent = LabeledComponent.create(panel, ExecutionBundle.message("run.configuration.working.directory.label")); myEnvVariablesComponent = new EnvironmentVariablesComponent(); myEnvVariablesComponent.setLabelLocation(BorderLayout.WEST); myProgramParametersComponent.setLabelLocation(BorderLayout.WEST); myWorkingDirectoryComponent.setLabelLocation(BorderLayout.WEST); addComponents(); setPreferredSize(new Dimension(10, 10)); setAnchor(myEnvVariablesComponent.getLabel()); }
From source file:com.intellij.plugins.haxe.runner.debugger.HaxeFlexSDKConfigurable.java
License:Apache License
@Override public JComponent createComponent() { return LabeledComponent.create(flexSdkCombo, HaxeBundle.message("flex.sdk.label")); }
From source file:com.johnnyyin.jsonplugin.GenerateDialog.java
License:Apache License
protected GenerateDialog(final PsiClass psiClass) { super(psiClass.getProject()); setTitle("Select Fields for Json Generation"); fieldsCollection = new CollectionListModel<PsiField>(); final JBList fieldList = new JBList(fieldsCollection); fieldList.setCellRenderer(new DefaultPsiElementCellRenderer()); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList).disableAddAction(); final JPanel panel = decorator.createPanel(); fieldsComponent = LabeledComponent.create(panel, "Fields to include in Json"); includeSubclasses = new JBCheckBox("Include fields from base classes"); setupCheckboxClickAction(psiClass);/*from ww w . j a va2 s.c o m*/ showCheckbox = psiClass.getFields().length != psiClass.getAllFields().length; updateFieldsDisplay(psiClass); init(); }
From source file:com.perl5.lang.perl.idea.configuration.settings.PerlSettingsConfigurable.java
License:Apache License
@Nullable @Override//from w w w .j av a2 s. c o m public JComponent createComponent() { FormBuilder builder = FormBuilder.createFormBuilder(); builder.getPanel().setLayout(new VerticalFlowLayout()); if (!PlatformUtils.isIntelliJ()) { createMicroIdeComponents(builder); } simpleMainCheckbox = new JCheckBox( "Use simple main:: subs resolution (many scripts with same named subs in main:: namespace)"); builder.addComponent(simpleMainCheckbox); autoInjectionCheckbox = new JCheckBox("Automatically inject other languages in here-docs by marker text"); builder.addComponent(autoInjectionCheckbox); allowInjectionWithInterpolation = new JCheckBox( "Allow injections in QQ here-docs with interpolated entities"); builder.addComponent(allowInjectionWithInterpolation); perlTryCatchCheckBox = new JCheckBox("Enable TryCatch syntax extension"); builder.addComponent(perlTryCatchCheckBox); perlAnnotatorCheckBox = new JCheckBox("Enable perl -cw annotations [NYI]"); // builder.addComponent(perlAnnotatorCheckBox); perlCriticCheckBox = new JCheckBox("Enable Perl::Critic annotations (should be installed)"); builder.addComponent(perlCriticCheckBox); perlCriticPathInputField = new TextFieldWithBrowseButton(); perlCriticPathInputField.setEditable(false); FileChooserDescriptor perlCriticDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { if (!super.isFileVisible(file, showHiddenFiles)) return false; return file.isDirectory() || StringUtil.equals(file.getName(), PerlCriticAnnotator.PERL_CRITIC_NAME); } }; perlCriticPathInputField.addBrowseFolderListener("Select file", "Choose a Perl::Critic executable", null, // project perlCriticDescriptor); builder.addLabeledComponent(new JLabel("Path to PerlCritic executable:"), perlCriticPathInputField); perlCriticArgsInputField = new RawCommandLineEditor(); builder.addComponent(copyDialogCaption( LabeledComponent.create(perlCriticArgsInputField, "Perl::Critic command line arguments:"), "Perl::Critic command line arguments:")); perlTidyPathInputField = new TextFieldWithBrowseButton(); perlTidyPathInputField.setEditable(false); FileChooserDescriptor perlTidyDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { if (!super.isFileVisible(file, showHiddenFiles)) return false; return file.isDirectory() || StringUtil.equals(file.getName(), PerlFormatWithPerlTidyAction.PERL_TIDY_NAME); } }; perlTidyPathInputField.addBrowseFolderListener("Select file", "Choose a Perl::Tidy executable", null, // project perlTidyDescriptor); builder.addLabeledComponent(new JLabel("Path to PerlTidy executable:"), perlTidyPathInputField); perlTidyArgsInputField = new RawCommandLineEditor(); builder.addComponent(copyDialogCaption( LabeledComponent.create(perlTidyArgsInputField, "Perl::Tidy command line arguments (-se -se arguments will be added automatically):"), "Perl::Tidy command line arguments:")); regeneratePanel = new JPanel(new BorderLayout()); regenerateButton = new JButton("Re-generate XSubs declarations"); regenerateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PerlXSubsState.getInstance(myProject).reparseXSubs(); } }); regeneratePanel.add(regenerateButton, BorderLayout.WEST); builder.addComponent(regeneratePanel); deparseArgumentsTextField = new JTextField(); builder.addLabeledComponent("Comma-separated B::Deparse options for deparse action", deparseArgumentsTextField); selfNamesModel = new CollectionListModel<String>(); selfNamesList = new JBList(selfNamesModel); builder.addLabeledComponent( new JLabel("Scalar names considered as an object self-reference (without a $):"), ToolbarDecorator.createDecorator(selfNamesList).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton anActionButton) { String variableName = Messages.showInputDialog(myProject, "Type variable name:", "New Self-Reference Variable Name", Messages.getQuestionIcon(), "", null); if (StringUtil.isNotEmpty(variableName)) { while (variableName.startsWith("$")) { variableName = variableName.substring(1); } if (StringUtil.isNotEmpty(variableName) && !selfNamesModel.getItems().contains(variableName)) { selfNamesModel.add(variableName); } } } }).createPanel()); return builder.getPanel(); }
From source file:com.perl5.lang.perl.idea.configuration.settings.sdk.Perl5ProjectConfigurable.java
License:Apache License
@Nullable @Override/*from ww w . j av a2 s . c o m*/ public JComponent createComponent() { FormBuilder builder = FormBuilder.createFormBuilder(); builder.getPanel().setLayout(new VerticalFlowLayout()); builder.addComponent(myPerl5SdkConfigurable.createComponent()); FormBuilder versionBuilder = FormBuilder.createFormBuilder(); ComboBoxModel<PerlVersion> versionModel = new CollectionComboBoxModel<>(PerlVersion.ALL_VERSIONS); myTargetPerlVersionComboBox = new ComboBox<>(versionModel); myTargetPerlVersionComboBox.setRenderer(new ColoredListCellRenderer<PerlVersion>() { @Override protected void customizeCellRenderer(@NotNull JList<? extends PerlVersion> list, PerlVersion value, int index, boolean selected, boolean hasFocus) { append(value.getStrictDottedVersion()); String versionDescription = PerlVersion.PERL_VERSION_DESCRIPTIONS.get(value); if (StringUtil.isNotEmpty(versionDescription)) { append(" (" + versionDescription + ")"); } } }); versionBuilder.addLabeledComponent(PerlBundle.message("perl.config.language.level"), myTargetPerlVersionComboBox); builder.addComponent(versionBuilder.getPanel()); myLibsModel = new CollectionListModel<>(); myLibsList = new JBList<>(myLibsModel); myLibsList.setVisibleRowCount(ourRowsCount); myLibsList.setCellRenderer(new ColoredListCellRenderer<VirtualFile>() { @Override protected void customizeCellRenderer(@NotNull JList<? extends VirtualFile> list, VirtualFile value, int index, boolean selected, boolean hasFocus) { setIcon(PerlIcons.PERL_LANGUAGE_ICON); append(FileUtil.toSystemDependentName(value.getPath())); } }); builder.addLabeledComponent(PerlBundle.message("perl.settings.external.libs"), ToolbarDecorator .createDecorator(myLibsList).setAddAction(this::doAddExternalLibrary).createPanel()); simpleMainCheckbox = new JCheckBox(PerlBundle.message("perl.config.simple.main")); builder.addComponent(simpleMainCheckbox); autoInjectionCheckbox = new JCheckBox(PerlBundle.message("perl.config.heredoc.injections")); builder.addComponent(autoInjectionCheckbox); allowInjectionWithInterpolation = new JCheckBox(PerlBundle.message("perl.config.heredoc.injections.qq")); builder.addComponent(allowInjectionWithInterpolation); allowRegexpInjections = new JCheckBox(PerlBundle.message("perl.config.regex.injections")); builder.addComponent(allowRegexpInjections); allowRegexpInjections.setEnabled(false); allowRegexpInjections.setVisible(false); perlAnnotatorCheckBox = new JCheckBox(PerlBundle.message("perl.config.annotations.cw")); // builder.addComponent(perlAnnotatorCheckBox); perlCriticCheckBox = new JCheckBox(PerlBundle.message("perl.config.annotations.critic")); builder.addComponent(perlCriticCheckBox); enablePerlSwitchCheckbox = new JCheckBox(PerlBundle.message("perl.config.enable.switch")); builder.addComponent(enablePerlSwitchCheckbox); perlCriticPathInputField = new TextFieldWithBrowseButton(); perlCriticPathInputField.setEditable(false); FileChooserDescriptor perlCriticDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || StringUtil .equals(file.getNameWithoutExtension(), PerlCriticAnnotator.PERL_CRITIC_LINUX_NAME)); } }; //noinspection DialogTitleCapitalization perlCriticPathInputField.addBrowseFolderListener(PerlBundle.message("perl.config.select.file.title"), PerlBundle.message("perl.config.select.critic"), null, // project perlCriticDescriptor); builder.addLabeledComponent(new JLabel(PerlBundle.message("perl.config.path.critic")), perlCriticPathInputField); perlCriticArgsInputField = new RawCommandLineEditor(); builder.addComponent(copyDialogCaption( LabeledComponent.create(perlCriticArgsInputField, PerlBundle.message("perl.config.critic.cmd.arguments")), PerlBundle.message("perl.config.critic.cmd.arguments"))); perlTidyPathInputField = new TextFieldWithBrowseButton(); perlTidyPathInputField.setEditable(false); FileChooserDescriptor perlTidyDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || StringUtil .equals(file.getNameWithoutExtension(), PerlFormatWithPerlTidyAction.PERL_TIDY_LINUX_NAME)); } }; //noinspection DialogTitleCapitalization perlTidyPathInputField.addBrowseFolderListener(PerlBundle.message("perl.config.select.file.title"), PerlBundle.message("perl.config.select.tidy"), null, // project perlTidyDescriptor); builder.addLabeledComponent(new JLabel(PerlBundle.message("perl.config.path.tidy")), perlTidyPathInputField); perlTidyArgsInputField = new RawCommandLineEditor(); builder.addComponent(copyDialogCaption( LabeledComponent.create(perlTidyArgsInputField, PerlBundle.message("perl.config.tidy.options.label")), PerlBundle.message("perl.config.tidy.options.label.short"))); JPanel regeneratePanel = new JPanel(new BorderLayout()); JButton regenerateButton = new JButton(PerlBundle.message("perl.config.generate.xsubs")); regenerateButton.addActionListener(e -> PerlXSubsState.getInstance(myProject).reparseXSubs()); regeneratePanel.add(regenerateButton, BorderLayout.WEST); builder.addComponent(regeneratePanel); deparseArgumentsTextField = new JTextField(); builder.addLabeledComponent(PerlBundle.message("perl.config.deparse.options.label"), deparseArgumentsTextField); selfNamesModel = new CollectionListModel<>(); JBList selfNamesList = new JBList<>(selfNamesModel); selfNamesList.setVisibleRowCount(ourRowsCount); builder.addLabeledComponent(new JLabel(PerlBundle.message("perl.config.self.names.label")), ToolbarDecorator.createDecorator(selfNamesList).setAddAction(anActionButton -> { String variableName = Messages.showInputDialog(myProject, PerlBundle.message("perl.config.self.add.text"), PerlBundle.message("perl.config.self.add.title"), Messages.getQuestionIcon(), "", null); if (StringUtil.isNotEmpty(variableName)) { while (variableName.startsWith("$")) { variableName = variableName.substring(1); } if (StringUtil.isNotEmpty(variableName) && !selfNamesModel.getItems().contains(variableName)) { selfNamesModel.add(variableName); } } }).createPanel()); JBScrollPane scrollPane = new JBScrollPane(builder.getPanel(), ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(new JBEmptyBorder(JBUI.emptyInsets())); return scrollPane; }
From source file:com.perl5.lang.perl.idea.run.PerlConfigurationEditor.java
License:Apache License
@NotNull @Override//from ww w .j a v a2s .c o m protected JComponent createEditor() { myScriptField = new TextFieldWithBrowseButton(); myScriptField.addBrowseFolderListener("Select Perl Script", "Please select perl script file", myProject, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor() .withFileFilter(new Condition<VirtualFile>() { @Override public boolean value(VirtualFile virtualFile) { return PerlConfigurationProducer.isExecutableFile(virtualFile); } }), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myStartMode = new ComboBox(new MapComboBoxModel<String, String>(PerlDebugOptionsSets.STARTUP_OPTIONS)) { @Override public void setRenderer(ListCellRenderer renderer) { super.setRenderer(new ColoredListCellRenderer<String>() { @Override protected void customizeCellRenderer(JList list, String value, int index, boolean selected, boolean hasFocus) { append(PerlDebugOptionsSets.STARTUP_OPTIONS.get(value)); } }); } }; myConsoleCharset = new ComboBox( new CollectionComboBoxModel(new ArrayList<String>(Charset.availableCharsets().keySet()))); myScriptField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent documentEvent) { VirtualFile file = LocalFileSystem.getInstance().findFileByPath(myScriptField.getText()); if (file != null) { myConsoleCharset.setSelectedItem(file.getCharset().displayName()); } else { myConsoleCharset.setSelectedItem(null); } } }); myAlternativeSdkPanel = new PerlAlternativeSdkPanel(); myParametersPanel = new CommonProgramParametersPanel() { @Override protected void addComponents() { LabeledComponent<?> scriptLabel = LabeledComponent.create(myScriptField, "Script"); scriptLabel.setLabelLocation(BorderLayout.WEST); add(scriptLabel); LabeledComponent<?> consoleEncoding = LabeledComponent.create(myConsoleCharset, "Script output encoding"); consoleEncoding.setLabelLocation(BorderLayout.WEST); add(consoleEncoding); myScriptCharset = new JTextField(); LabeledComponent<JTextField> myScriptCharsetLabel = LabeledComponent.create(myScriptCharset, "Script encoding"); myScriptCharsetLabel.setLabelLocation(BorderLayout.WEST); add(myScriptCharsetLabel); LabeledComponent<?> startMode = LabeledComponent.create(myStartMode, "Debugger startup mode"); startMode.setLabelLocation(BorderLayout.WEST); add(startMode); myPerlParametersPanel = new RawCommandLineEditor(); LabeledComponent<RawCommandLineEditor> perlParametersPanel = LabeledComponent .create(myPerlParametersPanel, "Perl5 parameters"); perlParametersPanel.setLabelLocation(BorderLayout.WEST); copyDialogCaption(perlParametersPanel); add(perlParametersPanel); super.addComponents(); add(myAlternativeSdkPanel); } }; myParametersPanel.setProgramParametersLabel("Script parameters:"); return myParametersPanel; }