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));
}
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);
}
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);
}
};
}
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));
}
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);
}
Aggregations