Search in sources :

Example 11 with GridBag

use of com.intellij.util.ui.GridBag in project android by JetBrains.

the class GradleEditorComponent method setData.

/**
   * Configures current control to represent given groups (discarding all previously shown information).
   *
   * @param groups  groups to show
   */
public void setData(@NotNull List<GradleEditorEntityGroup> groups) {
    // Most likely use-case is that just table's data should be updated.
    boolean sameTables = groups.size() == myTablesByGroupName.size();
    for (GradleEditorEntityGroup group : groups) {
        GradleEditorEntityTable table = myTablesByGroupName.get(group.getName());
        if (table == null) {
            sameTables = false;
        } else {
            if (table.isEditing()) {
                table.getCellEditor().stopCellEditing();
            }
            table.getModel().setData(group.getEntities());
        }
    }
    if (sameTables) {
        return;
    }
    myCanvas.removeAll();
    Map<String, GradleEditorEntityTable> tablesByGroupName = Maps.newHashMap(myTablesByGroupName);
    myTablesByGroupName.clear();
    Map<String, JBPanel> panelsByGroupName = Maps.newHashMap(myPanelsByGroupName);
    myPanelsByGroupName.clear();
    for (GradleEditorEntityGroup group : groups) {
        JBPanel panel = panelsByGroupName.get(group.getName());
        GradleEditorEntityTable table = tablesByGroupName.get(group.getName());
        if (panel != null && table != null) {
            addUiForGroup(group.getName(), panel, table);
        } else {
            addUiForGroup(group);
        }
    }
    myCanvas.add(new JLabel(" "), new GridBag().weighty(1));
}
Also used : GradleEditorEntityGroup(com.android.tools.idea.gradle.editor.entity.GradleEditorEntityGroup) GridBag(com.intellij.util.ui.GridBag) JBPanel(com.intellij.ui.components.JBPanel)

Example 12 with GridBag

use of com.intellij.util.ui.GridBag in project android by JetBrains.

the class GradleEditorComponent method addUiForGroup.

private void addUiForGroup(@NotNull String groupName, @NotNull JBPanel component, @NotNull GradleEditorEntityTable table) {
    GridBagConstraints constraints = new GridBag().weightx(1).anchor(GridBagConstraints.WEST).fillCellHorizontally().coverLine().insets(8, 8, 8, 8);
    myCanvas.add(component, constraints);
    myTablesByGroupName.put(groupName, table);
    myPanelsByGroupName.put(groupName, component);
}
Also used : GridBag(com.intellij.util.ui.GridBag)

Example 13 with GridBag

use of com.intellij.util.ui.GridBag in project intellij-community by JetBrains.

the class DiffSplitter method createDivider.

@Override
protected Divider createDivider() {
    return new DividerImpl() {

        @Override
        public void setOrientation(boolean isVerticalSplit) {
            removeAll();
            setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
            List<JComponent> actionComponents = ContainerUtil.list(createActionComponent(myTopAction), createActionComponent(myBottomAction));
            List<JComponent> syncComponents = DiffUtil.createSyncHeightComponents(actionComponents);
            GridBag bag = new GridBag();
            if (syncComponents.get(0) != null) {
                add(syncComponents.get(0), bag.nextLine());
                add(Box.createVerticalStrut(JBUI.scale(20)), bag.nextLine());
            }
            add(new JLabel(AllIcons.General.SplitGlueH), bag.nextLine());
            if (syncComponents.get(1) != null) {
                add(Box.createVerticalStrut(JBUI.scale(20)), bag.nextLine());
                add(syncComponents.get(1), bag.nextLine());
            }
            revalidate();
            repaint();
        }

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (myPainter != null)
                myPainter.paint(g, this);
        }
    };
}
Also used : GridBag(com.intellij.util.ui.GridBag)

Example 14 with GridBag

use of com.intellij.util.ui.GridBag in project intellij-community by JetBrains.

the class ArrangementListRowDecorator method init.

private void init() {
    setLayout(new GridBagLayout());
    GridBag constraints = new GridBag().anchor(GridBagConstraints.CENTER).insets(0, ArrangementConstants.HORIZONTAL_PADDING, 0, ArrangementConstants.HORIZONTAL_GAP * 2);
    add(myRowIndexControl, constraints);
    add(new InsetsPanel(mySortLabel), new GridBag().anchor(GridBagConstraints.CENTER).insets(0, 0, 0, ArrangementConstants.HORIZONTAL_GAP));
    add(myDelegate.getUiComponent(), new GridBag().weightx(1).anchor(GridBagConstraints.WEST));
    add(myEditButton, new GridBag().anchor(GridBagConstraints.EAST));
    setBorder(IdeBorderFactory.createEmptyBorder(ArrangementConstants.VERTICAL_GAP));
}
Also used : GridBag(com.intellij.util.ui.GridBag)

Example 15 with GridBag

use of com.intellij.util.ui.GridBag in project intellij-community by JetBrains.

the class ArrangementMatchingRuleEditor method addToken.

private void addToken(@NotNull CompositeArrangementSettingsToken rowToken) {
    List<CompositeArrangementSettingsToken> tokens = ArrangementUtil.flatten(rowToken);
    GridBag labelConstraints = new GridBag().anchor(GridBagConstraints.NORTHWEST).insets(ArrangementConstants.VERTICAL_PADDING, 0, 0, 0);
    MultiRowFlowPanel panel = new MultiRowFlowPanel(FlowLayout.LEFT, ArrangementConstants.HORIZONTAL_GAP, ArrangementConstants.VERTICAL_GAP);
    List<ArrangementSettingsToken> prevTokens = ContainerUtilRt.newArrayList();
    StdArrangementTokenUiRole prevRole = null;
    ArrangementUiComponent component;
    JComponent uiComponent;
    for (CompositeArrangementSettingsToken token : tokens) {
        StdArrangementTokenUiRole role = token.getRole();
        if (role != prevRole && !prevTokens.isEmpty()) {
            component = ArrangementUtil.buildUiComponent(role, prevTokens, myColorsProvider, mySettingsManager);
            component.setListener(this);
            for (ArrangementSettingsToken prevToken : prevTokens) {
                myComponents.put(prevToken, component);
            }
            panel.add(component.getUiComponent());
            panel = addRowIfNecessary(panel);
            prevRole = null;
            prevTokens.clear();
        }
        component = ArrangementUtil.buildUiComponent(role, Collections.singletonList(token.getToken()), myColorsProvider, mySettingsManager);
        component.setListener(this);
        uiComponent = component.getUiComponent();
        switch(role) {
            case LABEL:
                panel = addRowIfNecessary(panel);
                add(uiComponent, labelConstraints);
                myLabelWidth = Math.max(myLabelWidth, uiComponent.getPreferredSize().width);
                prevRole = null;
                break;
            case TEXT_FIELD:
                panel = addRowIfNecessary(panel);
                ArrangementUiComponent textLabel = ArrangementUtil.buildUiComponent(StdArrangementTokenUiRole.LABEL, Collections.singletonList(token.getToken()), myColorsProvider, mySettingsManager);
                JComponent textLabelComponent = textLabel.getUiComponent();
                add(textLabelComponent, labelConstraints);
                myLabelWidth = Math.max(myLabelWidth, textLabelComponent.getPreferredSize().width);
                panel.add(uiComponent);
                panel = addRowIfNecessary(panel);
                prevRole = null;
                myComponents.put(token.getToken(), component);
                if (myDefaultFocusRequestor == null) {
                    myDefaultFocusRequestor = uiComponent;
                }
                break;
            default:
                if (role == StdArrangementTokenUiRole.COMBO_BOX) {
                    prevTokens.add(token.getToken());
                    prevRole = role;
                    break;
                }
                panel.add(uiComponent);
                myComponents.put(token.getToken(), component);
        }
    }
    if (prevRole != null && !prevTokens.isEmpty()) {
        component = ArrangementUtil.buildUiComponent(prevRole, prevTokens, myColorsProvider, mySettingsManager);
        panel.add(component.getUiComponent());
        component.setListener(this);
        for (ArrangementSettingsToken prevToken : prevTokens) {
            myComponents.put(prevToken, component);
        }
    }
    addRowIfNecessary(panel);
}
Also used : MultiRowFlowPanel(com.intellij.util.ui.MultiRowFlowPanel) GridBag(com.intellij.util.ui.GridBag)

Aggregations

GridBag (com.intellij.util.ui.GridBag)22 JBLabel (com.intellij.ui.components.JBLabel)7 JBCheckBox (com.intellij.ui.components.JBCheckBox)4 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 MultiRowFlowPanel (com.intellij.util.ui.MultiRowFlowPanel)2 GradleEditorEntityGroup (com.android.tools.idea.gradle.editor.entity.GradleEditorEntityGroup)1 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)1 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)1 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)1 ExternalProjectPathField (com.intellij.openapi.externalSystem.service.ui.ExternalProjectPathField)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 Splitter (com.intellij.openapi.ui.Splitter)1 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 EditorTextField (com.intellij.ui.EditorTextField)1 RawCommandLineEditor (com.intellij.ui.RawCommandLineEditor)1 JBPanel (com.intellij.ui.components.JBPanel)1 JBRadioButton (com.intellij.ui.components.JBRadioButton)1 JBTextField (com.intellij.ui.components.JBTextField)1 CheckBox (com.intellij.util.ui.CheckBox)1