Search in sources :

Example 16 with FormBuilder

use of com.intellij.util.ui.FormBuilder in project Perl5-IDEA by Camelcade.

the class MasonSettingsConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    FormBuilder builder = FormBuilder.createFormBuilder();
    builder.getPanel().setLayout(new VerticalFlowLayout());
    createGlobalsComponent(builder);
    createAutobaseNamesComponent(builder);
    return builder.getPanel();
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with FormBuilder

use of com.intellij.util.ui.FormBuilder in project Perl5-IDEA by Camelcade.

the class HTMLMasonSettingsConfigurable method createCustomTagsComponent.

protected void createCustomTagsComponent(FormBuilder builder) {
    myTagNameColumnInfo myTagNameColumnInfo = new myTagNameColumnInfo();
    customTagsModel = new ListTableModel<>(myTagNameColumnInfo, new myTagRoleColumInfo());
    myTagNameColumnInfo.setCustomTagsModel(customTagsModel);
    customTagsTable = new JBTable(customTagsModel);
    final TableColumn secondColumn = customTagsTable.getColumnModel().getColumn(1);
    ComboBoxTableRenderer<HTMLMasonCustomTagRole> roleComboBoxTableRenderer = new ComboBoxTableRenderer<HTMLMasonCustomTagRole>(HTMLMasonCustomTagRole.values()) {

        @Override
        protected String getTextFor(@NotNull HTMLMasonCustomTagRole value) {
            return value.getTitle();
        }

        @Override
        public boolean isCellEditable(EventObject event) {
            if (event instanceof MouseEvent) {
                return ((MouseEvent) event).getClickCount() >= 1;
            }
            return true;
        }
    };
    secondColumn.setCellRenderer(roleComboBoxTableRenderer);
    secondColumn.setCellEditor(roleComboBoxTableRenderer);
    builder.addLabeledComponent(new JLabel("Custom tags that mimics built-in HTML::Mason tags:"), ToolbarDecorator.createDecorator(customTagsTable).setAddAction(anActionButton -> {
        final TableCellEditor cellEditor = customTagsTable.getCellEditor();
        if (cellEditor != null) {
            cellEditor.stopCellEditing();
        }
        final TableModel model = customTagsTable.getModel();
        int indexToEdit = -1;
        for (HTMLMasonCustomTag entry : customTagsModel.getItems()) {
            if (StringUtil.isEmpty(entry.getText())) {
                indexToEdit = customTagsModel.indexOf(entry);
                break;
            }
        }
        if (indexToEdit == -1) {
            customTagsModel.addRow(new HTMLMasonCustomTag("customTag" + customTagsModel.getItems().size(), HTMLMasonCustomTagRole.PERL));
            indexToEdit = model.getRowCount() - 1;
        }
        TableUtil.editCellAt(customTagsTable, indexToEdit, 0);
    }).disableDownAction().disableUpAction().setPreferredSize(JBUI.size(0, PerlConfigurationUtil.WIDGET_HEIGHT)).createPanel());
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) WriteAction(com.intellij.openapi.application.WriteAction) PerlLexer(com.perl5.lang.perl.lexer.PerlLexer) HTMLMasonSyntaxElements(com.perl5.lang.htmlmason.HTMLMasonSyntaxElements) ColumnInfo(com.intellij.util.ui.ColumnInfo) THashSet(gnu.trove.THashSet) ToolbarDecorator(com.intellij.ui.ToolbarDecorator) ArrayList(java.util.ArrayList) EventObject(java.util.EventObject) TableCellEditor(javax.swing.table.TableCellEditor) JBUI(com.intellij.util.ui.JBUI) TableUtil(com.intellij.ui.TableUtil) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) ListTableModel(com.intellij.util.ui.ListTableModel) TableModel(javax.swing.table.TableModel) JBList(com.intellij.ui.components.JBList) VariableDescription(com.perl5.lang.mason2.idea.configuration.VariableDescription) StringUtil(com.intellij.openapi.util.text.StringUtil) TableColumn(javax.swing.table.TableColumn) PerlConfigurationUtil(com.perl5.lang.perl.util.PerlConfigurationUtil) Set(java.util.Set) ComboBoxTableRenderer(com.intellij.openapi.ui.ComboBoxTableRenderer) CollectionListModel(com.intellij.ui.CollectionListModel) FileTypeManagerEx(com.intellij.openapi.fileTypes.ex.FileTypeManagerEx) MouseEvent(java.awt.event.MouseEvent) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) JBTable(com.intellij.ui.table.JBTable) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull) FormBuilder(com.intellij.util.ui.FormBuilder) javax.swing(javax.swing) MouseEvent(java.awt.event.MouseEvent) JBTable(com.intellij.ui.table.JBTable) TableColumn(javax.swing.table.TableColumn) NotNull(org.jetbrains.annotations.NotNull) EventObject(java.util.EventObject) ComboBoxTableRenderer(com.intellij.openapi.ui.ComboBoxTableRenderer) TableCellEditor(javax.swing.table.TableCellEditor) ListTableModel(com.intellij.util.ui.ListTableModel) TableModel(javax.swing.table.TableModel)

Example 18 with FormBuilder

use of com.intellij.util.ui.FormBuilder in project Perl5-IDEA by Camelcade.

the class HTMLMasonSettingsConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    FormBuilder builder = FormBuilder.createFormBuilder();
    builder.getPanel().setLayout(new VerticalFlowLayout());
    defaulthandlerName = new JTextField();
    builder.addLabeledComponent(new JLabel("Default handler name:"), defaulthandlerName);
    autohandlerName = new JTextField();
    builder.addLabeledComponent(new JLabel("Auto-handler name:"), autohandlerName);
    createGlobalsComponent(builder);
    createSubstitutedExtensionsComponent(builder);
    createCustomTagsComponent(builder);
    return builder.getPanel();
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with FormBuilder

use of com.intellij.util.ui.FormBuilder in project azure-tools-for-java by Microsoft.

the class FunctionTriggerChooserStep method getComponent.

@Override
public JComponent getComponent() {
    final FormBuilder builder = new FormBuilder();
    builder.addComponent(new JBLabel("Choose Functions Triggers:"));
    triggerList = new CheckBoxList<>();
    setupFunctionTriggers();
    final BorderLayoutPanel customPanel = JBUI.Panels.simplePanel(10, 0);
    customPanel.addToTop(triggerList);
    builder.addComponent(customPanel);
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(builder.getPanel(), "North");
    return panel;
}
Also used : FormBuilder(com.intellij.util.ui.FormBuilder) BorderLayout(java.awt.BorderLayout) JBLabel(com.intellij.ui.components.JBLabel) BorderLayoutPanel(com.intellij.util.ui.components.BorderLayoutPanel)

Aggregations

FormBuilder (com.intellij.util.ui.FormBuilder)19 Nullable (org.jetbrains.annotations.Nullable)10 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)4 JBLabel (com.intellij.ui.components.JBLabel)3 JBList (com.intellij.ui.components.JBList)3 NotNull (org.jetbrains.annotations.NotNull)3 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 ComboBox (com.intellij.openapi.ui.ComboBox)2 Messages (com.intellij.openapi.ui.Messages)2 StringUtil (com.intellij.openapi.util.text.StringUtil)2 TableUtil (com.intellij.ui.TableUtil)2 ToolbarDecorator (com.intellij.ui.ToolbarDecorator)2 JBScrollPane (com.intellij.ui.components.JBScrollPane)2 JBTextField (com.intellij.ui.components.JBTextField)2 JBTable (com.intellij.ui.table.JBTable)2 ColumnInfo (com.intellij.util.ui.ColumnInfo)2 JBUI (com.intellij.util.ui.JBUI)2 ListTableModel (com.intellij.util.ui.ListTableModel)2 VariableDescription (com.perl5.lang.mason2.idea.configuration.VariableDescription)2