use of com.intellij.uiDesigner.core.GridLayoutManager in project intellij-community by JetBrains.
the class GridLayoutCodeGenerator method generateContainerLayout.
public void generateContainerLayout(final LwContainer lwContainer, final GeneratorAdapter generator, final int componentLocal) {
if (lwContainer.isGrid()) {
// arg 0: object
generator.loadLocal(componentLocal);
// arg 1: layout
final GridLayoutManager layout = (GridLayoutManager) lwContainer.getLayout();
generator.newInstance(myGridLayoutManagerType);
generator.dup();
generator.push(layout.getRowCount());
generator.push(layout.getColumnCount());
AsmCodeGenerator.pushPropValue(generator, "java.awt.Insets", layout.getMargin());
generator.push(layout.getHGap());
generator.push(layout.getVGap());
generator.push(layout.isSameSizeHorizontally());
generator.push(layout.isSameSizeVertically());
generator.invokeConstructor(myGridLayoutManagerType, ourGridLayoutManagerConstructor);
generator.invokeVirtual(ourContainerType, ourSetLayoutMethod);
}
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project intellij-community by JetBrains.
the class GridLayoutSerializer method readLayout.
void readLayout(Element element, LwContainer container) {
final int rowCount = LwXmlReader.getRequiredInt(element, UIFormXmlConstants.ATTRIBUTE_ROW_COUNT);
final int columnCount = LwXmlReader.getRequiredInt(element, UIFormXmlConstants.ATTRIBUTE_COLUMN_COUNT);
final int hGap = LwXmlReader.getOptionalInt(element, UIFormXmlConstants.ATTRIBUTE_HGAP, -1);
final int vGap = LwXmlReader.getOptionalInt(element, UIFormXmlConstants.ATTRIBUTE_VGAP, -1);
// attribute is optional for compatibility with IDEA 4.0 forms
final boolean sameSizeHorizontally = LwXmlReader.getOptionalBoolean(element, UIFormXmlConstants.ATTRIBUTE_SAME_SIZE_HORIZONTALLY, false);
final boolean sameSizeVertically = LwXmlReader.getOptionalBoolean(element, UIFormXmlConstants.ATTRIBUTE_SAME_SIZE_VERTICALLY, false);
final Element marginElement = LwXmlReader.getRequiredChild(element, "margin");
final Insets margin = new Insets(LwXmlReader.getRequiredInt(marginElement, "top"), LwXmlReader.getRequiredInt(marginElement, "left"), LwXmlReader.getRequiredInt(marginElement, "bottom"), LwXmlReader.getRequiredInt(marginElement, "right"));
final GridLayoutManager layout = new GridLayoutManager(rowCount, columnCount);
layout.setMargin(margin);
layout.setVGap(vGap);
layout.setHGap(hGap);
layout.setSameSizeHorizontally(sameSizeHorizontally);
layout.setSameSizeVertically(sameSizeVertically);
container.setLayout(layout);
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project android by JetBrains.
the class TemplateParameterStep2 method addParameterComponents.
private int addParameterComponents(final int rowCount, final Set<Parameter> parameters) {
CellLocation location = new CellLocation();
myTemplateParameters.removeAll();
GridLayoutManager layout = new GridLayoutManager(rowCount + 1, COLUMN_COUNT);
layout.setSameSizeHorizontally(false);
myTemplateParameters.setLayout(layout);
for (final Parameter parameter : parameters) {
addComponents(parameter, location);
}
if (location.column > 0) {
//add spacers before moving to the next row.
if (location.column < COLUMN_COUNT) {
addComponent(myTemplateParameters, new Spacer(), location.row, location.column, true);
}
location.row++;
}
return location.row;
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project android by JetBrains.
the class WizardStepHeaderPanel method updateHeader.
private void updateHeader() {
boolean updateLayout = false;
if (myTitleLabel == null) {
myTitleLabel = new JLabel(myTitle);
updateLayout = true;
}
myTitleLabel.setText(myTitle);
updateLayout |= myDescriptionLabel.updateValue(StringUtil.nullize(myDescription, true)) || myWizardIconComponent.updateValue(myWizardIcon) || myStepIconComponent.updateValue(myStepIcon);
if (updateLayout) {
final int rows = myDescriptionLabel.getComponent() == null ? 1 : 2;
final int columns = 1 + (myWizardIconComponent.getComponent() == null ? 0 : 1) + (myStepIconComponent.getComponent() == null ? 0 : 1);
for (Component component : getComponents()) {
remove(component);
}
setLayout(new GridLayoutManager(rows, columns, new Insets(18, 0, 12, 0), 2, 2));
int currentColumn = addIconIfExists(myWizardIconComponent.getComponent(), 0, rows) ? 1 : 0;
addLabels(myTitleLabel, myDescriptionLabel.getComponent(), currentColumn);
addIconIfExists(myStepIconComponent.getComponent(), currentColumn + 1, rows);
}
}
use of com.intellij.uiDesigner.core.GridLayoutManager in project android by JetBrains.
the class InspectorPanelTest method findComponents.
@NotNull
private static Multimap<Integer, Component> findComponents(@NotNull InspectorPanel inspector) {
Multimap<Integer, Component> components = ArrayListMultimap.create();
JPanel panel = (JPanel) inspector.getComponent(0);
GridLayoutManager layout = (GridLayoutManager) panel.getLayout();
for (Component component : panel.getComponents()) {
GridConstraints constraints = layout.getConstraintsForComponent(component);
int row = constraints.getRow();
components.put(row, component);
}
return components;
}
Aggregations