public TablePanel(Table table) { $$$setupUI$$$(); rootPanel.setBorder(IdeBorderFactory.createTitledBorder(table.getTableName(), false)); //不可整列移动 fieldTable.getTableHeader().setReorderingAllowed(false); //不可拉动表格 fieldTable.getTableHeader().setResizingAllowed(false); fieldTable.getEmptyText().setText("No Columns"); JPanel panel = ToolbarDecorator.createDecorator(fieldTable) .setAddAction(it -> addAction()) .setRemoveAction(it -> removeAction()) .setEditAction(it -> editAction()) .createPanel(); panel.setPreferredSize(JBUI.size(300, 200)); columnsPanel.setBorder(IdeBorderFactory.createTitledBorder("Columns", false)); columnsPanel.add(panel, BorderLayout.CENTER); mainPanel.add(columnsPanel); modelTextField.setText(table.getModelName()); tableTextField.setText(table.getTableName()); initFields(table.getFields()); this.getRootComponent().registerKeyboardAction(e -> this.getRootComponent().disable(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); }
private void createUIComponents() { defaultExtensionLabel = new JBLabel(TesterBundle.message("settings.defaultExtension")); defaultExtensionCombobox = new ComboBox<>(new String[]{"phpt", "php"}); bootstrapFileLabel = new JBLabel(TesterBundle.message("settings.bootstrapFile")); bootstrapFileField = new TextFieldWithBrowseButton(); bootstrapFileField.addBrowseFolderListener(null, null, project, FileChooserDescriptorFactory.createSingleFileDescriptor("php")); namespaceMappingTable = new NamespaceMappingTable(project); namespaceMappingPanel = ToolbarDecorator.createDecorator(namespaceMappingTable.getTableView(), new ElementProducer<TesterNamespaceMapping>() { @Override public TesterNamespaceMapping createElement() { return new TesterNamespaceMapping(); } @Override public boolean canCreateElement() { return true; } }).createPanel(); namespaceMappingPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, JBColor.LIGHT_GRAY), TesterBundle.message("settings.namespaceMappings.title"))); }
@NotNull public CheckBoxListModelEditor<T> copyAction(final @NotNull Consumer<T> consumer) { toolbarDecorator.addExtraAction(new ToolbarDecorator.ElementActionButton(IdeBundle.message("button.copy"), PlatformIcons.COPY_ICON) { @Override public void actionPerformed(AnActionEvent e) { int[] indices = list.getSelectedIndices(); if (indices == null || indices.length == 0) { return; } for (int index : indices) { T item = list.getItemAt(index); if (item != null) { consumer.consume(item); } } } }); return this; }
public JComponent getMainComponent() { final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>(); component.setText("Default &project copyright:"); component.setLabelLocation(BorderLayout.WEST); component.setComponent(myProfilesComboBox); ElementProducer<ScopeSetting> producer = new ElementProducer<ScopeSetting>() { @Override public ScopeSetting createElement() { return new ScopeSetting(DefaultScopesProvider.getAllScope(), myProfilesModel.getAllProfiles().values().iterator().next()); } @Override public boolean canCreateElement() { return !myProfilesModel.getAllProfiles().isEmpty(); } }; ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myScopeMappingTable, producer); return JBUI.Panels.simplePanel(0, 10) .addToTop(component) .addToCenter(decorator.createPanel()) .addToBottom(myScopesLink); }
/** * This instance is created by Swing. * Do not call this constructor manually. */ public LanguagesPanel() { super(new BorderLayout()); SpoofaxIdeaPlugin.injector().injectMembers(this); final LanguageTreeModel model = new LanguageTreeModel(this.iconManager); this.languagesTree = new TreeTableView(model); this.languagesTree.setTreeCellRenderer(new LanguageTreeModel.LanguageTreeCellRenderer()); this.languagesTree.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(this.languagesTree) .setAddAction(this::addLanguage) .setAddActionUpdater(e -> this.controller != null) .setRemoveAction(button -> removeLanguage(getSelectedNode())) .setRemoveActionUpdater(e -> this.controller != null && getSelectedNode() != null) .disableUpDownActions(); add(toolbarDecorator.createPanel(), BorderLayout.CENTER); setBorder(IdeBorderFactory.createTitledBorder("Loaded languages", false)); }
public JComponent getMainComponent() { final JPanel panel = new JPanel(new BorderLayout(0, 10)); final LabeledComponent<JComboBox> component = new LabeledComponent<JComboBox>(); component.setText("Default &project copyright:"); component.setLabelLocation(BorderLayout.WEST); component.setComponent(myProfilesComboBox); panel.add(component, BorderLayout.NORTH); ElementProducer<ScopeSetting> producer = new ElementProducer<ScopeSetting>() { @Override public ScopeSetting createElement() { return new ScopeSetting(DefaultScopesProvider.getAllScope(), myProfilesModel.getAllProfiles().values().iterator().next()); } @Override public boolean canCreateElement() { return !myProfilesModel.getAllProfiles().isEmpty(); } }; ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myScopeMappingTable, producer); panel.add(decorator.createPanel(), BorderLayout.CENTER); panel.add(myScopesLink, BorderLayout.SOUTH); return panel; }
FileMaskPanel(Set<String> patterns, String textEmpty, String textTitle, String textAddMessage, String textAddTitle, String textEditMessage, String textEditTitle) { this.textAddMessage = textAddMessage; this.textAddTitle = textAddTitle; this.textEditMessage = textEditMessage; this.textEditTitle = textEditTitle; patternList = new JBList(patternModels); patternList.setEmptyText(textEmpty); patternPanel = ToolbarDecorator.createDecorator(patternList) .setAddAction(getAddActionButtonRunnable(patterns)) .setRemoveAction(getRemoveActionButtonRunnable(patterns)) .setEditAction(getEditActionButtonRunnable(patterns)) .disableUpDownActions() .createPanel(); patternPanel.setBorder(IdeBorderFactory.createTitledBorder(textTitle)); }
private void addWebDeploymentButton(ToolbarDecorator tablePanel) { tablePanel.addExtraAction(new AnActionButton("Remote", WebDeploymentIcons.Download) { @Override public void actionPerformed(AnActionEvent anActionEvent) { UiSettingsUtil.openFileDialogForDefaultWebServerConnection(project, new WebServerFileDialogExtensionCallback("xml") { @Override public void success(@NotNull WebServerConfig server, @NotNull WebServerConfig.RemotePath remotePath) { ContainerSettingsForm.this.tableView.getListTableModel().addRow( new ContainerFile("remote://" + org.apache.commons.lang.StringUtils.stripStart(remotePath.path, "/")) ); ContainerSettingsForm.this.changed = true; } }); } }); }
private void addWebDeploymentButton(ToolbarDecorator tablePanel) { tablePanel.addExtraAction(new AnActionButton("Remote", WebDeploymentIcons.Download) { @Override public void actionPerformed(AnActionEvent anActionEvent) { UiSettingsUtil.openFileDialogForDefaultWebServerConnection(project, new WebServerFileDialogExtensionCallback("php") { @Override public void success(@NotNull WebServerConfig server, @NotNull WebServerConfig.RemotePath remotePath) { RoutingSettingsForm.this.tableView.getListTableModel().addRow( new RoutingFile("remote://" + org.apache.commons.lang.StringUtils.stripStart(remotePath.path, "/")) ); RoutingSettingsForm.this.changed = true; } }); } }); }
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); showCheckbox = psiClass.getFields().length != psiClass.getAllFields().length; updateFieldsDisplay(psiClass); init(); }
public static JPanel createAddRemovePanel(final ListTable table) { return ToolbarDecorator.createDecorator(table) .setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final ListWrappingTableModel tableModel = table.getModel(); tableModel.addRow(); EventQueue.invokeLater(new Runnable() { @Override public void run() { final int lastRowIndex = tableModel.getRowCount() - 1; final Rectangle rectangle = table.getCellRect(lastRowIndex, 0, true); table.scrollRectToVisible(rectangle); table.editCellAt(lastRowIndex, 0); final ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(lastRowIndex, lastRowIndex); final TableCellEditor editor = table.getCellEditor(); final Component component = editor.getTableCellEditorComponent(table, null, true, lastRowIndex, 0); component.requestFocus(); } }); } }).setRemoveAction(new RemoveAction(table)) .disableUpDownActions().createPanel(); }
private void createUIComponents() { VirtualFile[] data = event.getData(DataKeys.VIRTUAL_FILE_ARRAY); fieldList = new JBList(data); fieldList.setEmptyText("No File Selected!"); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList); filePanel = decorator.createPanel(); }
public UserRenderersConfigurable() { super(new BorderLayout(4, 0)); myRendererChooser = new ElementsChooser<NodeRenderer>(true); setupRenderersList(); ToolbarDecorator decorator = ToolbarDecorator.createDecorator((JTable)myRendererChooser.getComponent()); decorator.setToolbarPosition(ActionToolbarPosition.TOP); decorator.setAddAction(new AddAction()); decorator.setRemoveAction(new RemoveAction()); decorator.setMoveUpAction(new MoveAction(true)); decorator.setMoveDownAction(new MoveAction(false)); decorator.addExtraAction(new CopyAction()); myNameField = new JTextField(); myNameFieldPanel = new JPanel(new BorderLayout()); myNameFieldPanel.add(new JLabel(DebuggerBundle.message("label.user.renderers.configurable.renderer.name")), BorderLayout.WEST); myNameFieldPanel.add(myNameField, BorderLayout.CENTER); myNameFieldPanel.setVisible(false); final JPanel center = new JPanel(new BorderLayout(0, 4)); center.add(myNameFieldPanel, BorderLayout.NORTH); center.add(myRendererDataConfigurable, BorderLayout.CENTER); myNameField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { if (myCurrentRenderer != null) { myCurrentRenderer.setName(myNameField.getText()); myRendererChooser.refresh(myCurrentRenderer); } } }); Splitter splitter = new Splitter(false); splitter.setProportion(0.3f); splitter.setFirstComponent(decorator.createPanel()); splitter.setSecondComponent(center); add(splitter, BorderLayout.CENTER); }
public JComponent createComponent() { final JPanel panel = ToolbarDecorator.createDecorator(myMembersOrderList) .disableAddAction().disableRemoveAction().createPanel(); myMembersPanel.add(panel, BorderLayout.CENTER); myVisibilityPanel.add(myJavaVisibilityPanel, BorderLayout.CENTER); return myPanel; }
public CheckBoxListModelEditor(@NotNull Function<T, String> toNameConverter, @NotNull String emptyText) { this.toNameConverter = toNameConverter; list = new CheckBoxList<T>(); list.setEmptyText(emptyText); // toolbar decorator is responsible for border list.setBorder(null); toolbarDecorator = ToolbarDecorator.createDecorator(list); }
private JPanel createRulesPanel(MyTableModel model, TableView<DependencyRule> table) { table.setSurrendersFocusOnKeystroke(true); table.setPreferredScrollableViewportSize(JBUI.size(300, 150)); table.setShowGrid(true); table.setRowHeight(new PackageSetChooserCombo(myProject, null).getPreferredSize().height); return ToolbarDecorator.createDecorator(table).createPanel(); }
public PyModuleDependenciesConfigurable(Module module) { myModule = module; myDependenciesList = new CheckBoxList<Module>(); resetModel(); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDependenciesList, new EditableListModelDecorator((DefaultListModel) myDependenciesList.getModel())); decorator.disableRemoveAction(); myListHolderPanel.add(decorator.createPanel(), BorderLayout.CENTER); }
@Override protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) { AnActionButton reloadButton = new AnActionButton(PyBundle.message("sdk.paths.dialog.reload.paths"), AllIcons.Actions.Refresh) { @Override public void actionPerformed(AnActionEvent e) { onReloadButtonClicked(); } }; toolbarDecorator.addExtraAction(reloadButton); }
private void createUIComponents() { mySourcesLoadingIcon = new AsyncProcessIcon("Loading..."); mySourcesTableModel = new SourcesTableModel(); myUpdateSitesTable = new TableView<SourcesTableModel.Row>(mySourcesTableModel); ToolbarDecorator userDefinedDecorator = ToolbarDecorator.createDecorator(myUpdateSitesTable); mySourcesPanel = addExtraActions(userDefinedDecorator).createPanel(); }
@Override protected JComponent createCenterPanel() { JPanel panel = new JPanel(new BorderLayout()); panel.setBorder(IdeBorderFactory.createTitledBorder("Run Configurations", false)); panel.add( ToolbarDecorator.createDecorator(table).addExtraAction(new SelectAllButton()).createPanel(), BorderLayout.CENTER); return panel; }
protected GenerateDialog(PsiClass psiClass) { super(psiClass.getProject()); setTitle("Select fields for SerializableParcelable generation"); PsiField[] allFields = psiClass.getAllFields(); PsiField[] fields = new PsiField[allFields.length]; int i = 0; for (PsiField field : allFields) { // Exclude static fields if (!field.hasModifierProperty(PsiModifier.STATIC)) { fields[i++] = field; } } // i is post-incremented, so no need to add 1 for the count fields = Arrays.copyOfRange(fields, 0, i); myFields = new CollectionListModel<PsiField>(fields); JBList fieldList = new JBList(myFields); fieldList.setCellRenderer(new DefaultPsiElementCellRenderer()); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList); decorator.disableAddAction(); JPanel panel = decorator.createPanel(); myComponent = LabeledComponent.create(panel, "Fields to include in Parcelable"); init(); }
@Nullable @Override protected JComponent createCenterPanel() { ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table).disableUpDownActions(); initDecorator(decorator); initColumnWidth(table); mGradleConfirmationDisableTaskListForm.mDisableTaskListPanel.add(decorator.createPanel(), BorderLayout.CENTER); return mGradleConfirmationDisableTaskListForm.mRootPanel; }
/** Sets up the the toolbar that appears in the cloud debugger snapshots panel. */ private void configureToolbar() { final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table) .disableUpDownActions() .disableAddAction() .setToolbarPosition(ActionToolbarPosition.TOP); decorator.setRemoveAction(new RemoveSelectedBreakpointsAction()); decorator.addExtraAction(new RemoveAllBreakpointsAction()); decorator.addExtraAction(new ReactivateBreakpointAction()); this.add(decorator.createPanel()); }
protected GeneratorDialog(PsiClass psiClass, List<PsiPropertyContainer> allProperties) { super(psiClass.getProject()); setTitle("Configure Step Builder"); this.properties = new JBList(new CollectionListModel<PsiPropertyContainer>(allProperties)); this.properties.setCellRenderer(new PropertyCellRenderer()); this.properties.setSelectedIndices(range(allProperties.size())); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(properties); decorator.disableAddAction(); decorator.disableRemoveAction(); JPanel panel = decorator.createPanel(); component = LabeledComponent.create(panel, "Properties to include in Step Builder:"); init(); }
private JPanel createRulesPanel(MyTableModel model, TableView<DependencyRule> table) { table.setSurrendersFocusOnKeystroke(true); table.setPreferredScrollableViewportSize(new Dimension(300, 150)); table.setShowGrid(true); table.setRowHeight(new PackageSetChooserCombo(myProject, null).getPreferredSize().height); return ToolbarDecorator.createDecorator(table).createPanel(); }
@Nullable @Override public JComponent createComponent() { ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<MethodSignatureSetting>() { @Override public MethodSignatureSetting createElement() { //IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true); return null; } @Override public boolean canCreateElement() { return true; } }); tablePanel.setEditAction(anActionButton -> MethodSignatureTypeSettingsForm.this.openTwigPathDialog(MethodSignatureTypeSettingsForm.this.tableView.getSelectedObject()) ); tablePanel.setAddAction(anActionButton -> MethodSignatureTypeSettingsForm.this.openTwigPathDialog(null) ); tablePanel.disableUpAction(); tablePanel.disableDownAction(); this.panelConfigTableView.add(tablePanel.createPanel()); return this.panel1; }
@Nullable @Override public JComponent createComponent() { ToolbarDecorator tablePanel = ToolbarDecorator.createDecorator(this.tableView, new ElementProducer<MethodParameterSetting>() { @Override public MethodParameterSetting createElement() { //IdeFocusManager.getInstance(TwigSettingsForm.this.project).requestFocus(TwigNamespaceDialog.getWindows(), true); return null; } @Override public boolean canCreateElement() { return true; } }); tablePanel.setEditAction(anActionButton -> MethodParameterReferenceSettingsForm.this.openTwigPathDialog(MethodParameterReferenceSettingsForm.this.tableView.getSelectedObject()) ); tablePanel.setAddAction(anActionButton -> MethodParameterReferenceSettingsForm.this.openTwigPathDialog(null) ); tablePanel.disableUpAction(); tablePanel.disableDownAction(); this.panelConfigTableView.add(tablePanel.createPanel()); return this.panel1; }
private void createUIComponents() { mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(0, 1)); this.modelList = new ListTableModel<>( new IconColumn(), new NamespaceColumn(), new ServiceColumn() ); for (Map.Entry<String, Set<String>> entry : this.arguments.entrySet()) { this.modelList.addRow(new ServiceParameter(entry.getKey(), entry.getValue())); } this.tableView = new TableView<>(); this.tableView.setModelAndUpdateColumns(this.modelList); mainPanel.add(ToolbarDecorator.createDecorator(this.tableView) .disableAddAction() .disableDownAction() .disableRemoveAction() .disableUpDownActions() .createPanel() ); }
private void initUI() { myComponent = new JPanel(new BorderLayout()); mySplitter = new Splitter(false, 0.3f); myComponent.add(mySplitter, BorderLayout.CENTER); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setBorder(IdeBorderFactory.createTitledBorder("Project XSLT Files", false, new Insets(0, 0, 0, 0))); myTree = new Tree(); myTree.setRootVisible(false); myTree.setShowsRootHandles(false); leftPanel.add(new JBScrollPane(myTree), BorderLayout.CENTER); mySplitter.setFirstComponent(leftPanel); myList = new JBList(); myList.setCellRenderer(new MyCellRenderer()); myList.setMinimumSize(new Dimension(120, 200)); myList.getEmptyText().setText("No associated files"); JPanel rightPanel = ToolbarDecorator.createDecorator(myList) .addExtraAction(AnActionButton.fromAction(new AddAssociationActionWrapper())) .addExtraAction(AnActionButton.fromAction(new RemoveAssociationAction())) .disableUpDownActions().disableAddAction().disableRemoveAction().createPanel(); UIUtil.addBorder(rightPanel, IdeBorderFactory.createTitledBorder("Associated Files", false, new Insets(0, 0, 0, 0))); mySplitter.setSecondComponent(rightPanel); final float dividerProportion = myProperties.getFloat(DIVIDER_PROPORTION, 0.3f); mySplitter.setProportion(dividerProportion); }
public TargetOptionsComponent(Project project) { super(new GridBagLayout()); myProject = project; //setBorder(BorderFactory.createTitledBorder("Bytecode target level")); myCbProjectTargetLevel = createTargetOptionsCombo(); myTable = new JBTable(new TargetLevelTableModel()); myTable.setRowHeight(22); myTable.getEmptyText().setText("All modules will be compiled with project bytecode version"); final TableColumn moduleColumn = myTable.getColumnModel().getColumn(0); moduleColumn.setHeaderValue("Module"); moduleColumn.setCellRenderer(new ModuleCellRenderer()); final TableColumn targetLevelColumn = myTable.getColumnModel().getColumn(1); final String columnTitle = "Target bytecode version"; targetLevelColumn.setHeaderValue(columnTitle); targetLevelColumn.setCellEditor(new TargetLevelCellEditor()); targetLevelColumn.setCellRenderer(new TargetLevelCellRenderer()); final int width = myTable.getFontMetrics(myTable.getFont()).stringWidth(columnTitle) + 10; targetLevelColumn.setPreferredWidth(width); targetLevelColumn.setMinWidth(width); targetLevelColumn.setMaxWidth(width); add(new JLabel("Project bytecode version (leave blank for jdk default): "), constraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE)); add(myCbProjectTargetLevel, constraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NONE)); add(new JLabel("Per-module bytecode version(obsolete - use module extension settings):"), constraints(0, 1, 2, 1, 1.0, 0.0, GridBagConstraints.NONE)); final JPanel tableComp = ToolbarDecorator.createDecorator(myTable).disableUpAction().disableDownAction().setRemoveAction(anActionButton -> removeSelectedModules()).createPanel(); tableComp.setPreferredSize(new Dimension(myTable.getWidth(), 150)); add(tableComp, constraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.BOTH)); }
private void disableActionsIfNeed(ToolbarDecorator toolbarDecorator) { toolbarDecorator.disableUpDownActions(); if(myIsReadonlyFile) { toolbarDecorator.disableUpDownActions(); toolbarDecorator.disableAddAction(); toolbarDecorator.disableRemoveAction(); } }
@RequiredDispatchThread @Override public JComponent createComponent() { final JPanel panel = ToolbarDecorator.createDecorator(myMembersOrderList).disableAddAction().disableRemoveAction().createPanel(); myMembersPanel.add(panel, BorderLayout.CENTER); return myPanel; }
private void createUIComponents() { // TODO: place custom component creation code here splitPanel = new JPanel(); splitPanel.setPreferredSize(JBUI.size(300, 400)); jSplitPane = new JSplitPane(); jSplitPane.setOrientation(0); jSplitPane.setContinuousLayout(true); jSplitPane.setBorder(BorderFactory.createEmptyBorder()); varPanel = new JPanel(new BorderLayout()); varPanel.setBorder(IdeBorderFactory.createTitledBorder("Predefined Variables", false)); varTable = new JBTable(); varTable.getEmptyText().setText("No Variables"); //不可整列移动 varTable.getTableHeader().setReorderingAllowed(false); //不可拉动表格 varTable.getTableHeader().setResizingAllowed(false); JPanel panel = ToolbarDecorator.createDecorator(varTable) .setAddAction(it -> addAction()) .setRemoveAction(it -> removeAction()) .setEditAction(it -> editAction()).createPanel(); varPanel.add(panel, BorderLayout.CENTER); descPanel = new JPanel(new BorderLayout()); descPanel.setBorder(IdeBorderFactory.createTitledBorder("Default Variables & Directives", false)); String inHouseVariables; try { inHouseVariables = FileUtil.loadTextAndClose(VariableUI.class.getResourceAsStream("/variables.md")); } catch (Exception e) { inHouseVariables = "something error"; } descArea = new JTextArea(); descArea.setText(inHouseVariables); descArea.setEditable(false); descPanel.add(ScrollPaneFactory.createScrollPane(descArea), BorderLayout.CENTER); // ignore fields ignorePane = new JPanel(); ignorePane.setBorder(IdeBorderFactory.createTitledBorder("The Ignore Fields", false)); }
private void createUIComponents() { ElementProducer<RegExSampleSet> producer = new ElementProducer<RegExSampleSet>() { @Override public RegExSampleSet createElement() { return new RegExSampleSet(); } @Override public boolean canCreateElement() { return true; } }; GridConstraints constraints = new GridConstraints(0, 0, 1, 1 , GridConstraints.ANCHOR_CENTER , GridConstraints.FILL_BOTH , GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW , GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW | GridConstraints.SIZEPOLICY_WANT_GROW , null, null, null); ColumnInfo[] sampleTextColumns = { new SampleColumn(), new ResultColumn() }; myTextModel = new ListTableModel<>(sampleTextColumns, new ArrayList<>(), 0); myTextTable = new TableView<RegExSampleSet>(myTextModel) { @Override public void editingCanceled(ChangeEvent e) { super.editingCanceled(e); ApplicationManager.getApplication().invokeLater(() -> validateResults(false)); } }; myTextTable.setPreferredScrollableViewportSize(JBUI.size(-1, 500)); myTextTable.setRowSelectionAllowed(true); //int height = (int) myTextTable.getTableHeader().getPreferredSize().getHeight() + 10; //myTextTable.setRowHeight(height); int height = myTextTable.getRowHeight(); myTableRowPadding = 8; myTextTable.setRowHeight(height + myTableRowPadding); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTextTable, producer); myTablesPanel = new JPanel(new GridLayoutManager(1, 1)); myTablesPanel.add(decorator.createPanel(), constraints); myViewPanel = new JPanel(new BorderLayout()); myViewPanel.add(myTablesPanel, BorderLayout.CENTER); }
public ToolbarDecorator getToolbar() { return toolbarDecorator; }
private JComponent createVariablesTable() { final String[] names = { CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"), CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined") }; // Create a model of the data. TableModel dataModel = new VariablesModel(names); // Create the table myTable = new JBTable(dataModel); myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8)); myTable.getColumn(names[0]).setPreferredWidth(120); myTable.getColumn(names[1]).setPreferredWidth(200); myTable.getColumn(names[2]).setPreferredWidth(200); myTable.getColumn(names[3]).setPreferredWidth(100); if (myVariables.size() > 0) { myTable.getSelectionModel().setSelectionInterval(0, 0); } ComboBox comboField = new ComboBox(); Macro[] macros = MacroFactory.getMacros(); Arrays.sort(macros, new Comparator<Macro> () { @Override public int compare(@NotNull Macro m1, @NotNull Macro m2) { return m1.getPresentableName().compareTo(m2.getPresentableName()); } }); eachMacro: for (Macro macro : macros) { for (TemplateContextType contextType : myContextTypes) { if (macro.isAcceptableInContext(contextType)) { comboField.addItem(macro.getPresentableName()); continue eachMacro; } } } comboField.setEditable(true); DefaultCellEditor cellEditor = new DefaultCellEditor(comboField); cellEditor.setClickCountToStart(1); myTable.getColumn(names[1]).setCellEditor(cellEditor); myTable.setRowHeight(comboField.getPreferredSize().height); JTextField textField = new JTextField(); /*textField.addMouseListener( new PopupHandler(){ public void invokePopup(Component comp,int x,int y){ showCellPopup((JTextField)comp,x,y); } } );*/ cellEditor = new DefaultCellEditor(textField); cellEditor.setClickCountToStart(1); myTable.setDefaultEditor(String.class, cellEditor); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction(); return decorator.createPanel(); }
@NotNull @Override protected List<Pair<String, JPanel>> createAdditionalPanels() { // this method is invoked before constructor body myExceptionsModel = new ExceptionsTableModel(myMethod.getMethod().getThrowsList()); myExceptionsModel.setTypeInfos(myMethod.getMethod()); final JBTable table = new JBTable(myExceptionsModel); table.setStriped(true); table.setRowHeight(20); table.getColumnModel().getColumn(0).setCellRenderer(new CodeFragmentTableCellRenderer(myProject)); final JavaCodeFragmentTableCellEditor cellEditor = new JavaCodeFragmentTableCellEditor(myProject); cellEditor.addDocumentListener(new DocumentAdapter() { @Override public void documentChanged(DocumentEvent e) { final int row = table.getSelectedRow(); final int col = table.getSelectedColumn(); myExceptionsModel.setValueAt(cellEditor.getCellEditorValue(), row, col); updateSignature(); } }); table.getColumnModel().getColumn(0).setCellEditor(cellEditor); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.getSelectionModel().setSelectionInterval(0, 0); table.setSurrendersFocusOnKeystroke(true); /* myPropExceptionsButton = new AnActionButton( //todo propagate parameters RefactoringBundle.message("changeSignature.propagate.exceptions.title"), null, PlatformIcons.NEW_EXCEPTION) { @Override public void actionPerformed(AnActionEvent e) { final Ref<JavaCallerChooser> chooser = new Ref<JavaCallerChooser>(); Consumer<Set<PsiMethod>> callback = new Consumer<Set<PsiMethod>>() { @Override public void consume(Set<PsiMethod> psiMethods) { myMethodsToPropagateExceptions = psiMethods; myExceptionPropagationTree = chooser.get().getTree(); } }; chooser.set(new JavaCallerChooser(myMethod.getMethod(), myProject, RefactoringBundle.message("changeSignature.exception.caller.chooser"), myExceptionPropagationTree, callback)); chooser.get().show(); } }; myPropExceptionsButton.setShortcut(CustomShortcutSet.fromString("alt X"));*/ final JPanel panel = ToolbarDecorator.createDecorator(table).createPanel(); //.addExtraAction(myPropExceptionsButton).createPanel(); panel.setBorder(IdeBorderFactory.createEmptyBorder()); myExceptionsModel.addTableModelListener(mySignatureUpdater); final ArrayList<Pair<String, JPanel>> result = new ArrayList<Pair<String, JPanel>>(); final String message = RefactoringBundle.message("changeSignature.exceptions.panel.border.title"); result.add(Pair.create(message, panel)); return result; }
public JComponent createComponent() { final JPanel panel = ToolbarDecorator.createDecorator(myMembersOrderList) .disableAddAction().disableRemoveAction().createPanel(); myMembersPanel.add(panel, BorderLayout.CENTER); return myPanel; }