use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class FlattenAction method flattenGrid.
private static void flattenGrid(final RadContainer container) {
RadContainer parent = container.getParent();
GridConstraints containerConstraints = (GridConstraints) container.getConstraints().clone();
// ensure there will be enough rows and columns to fit the container contents
for (int i = containerConstraints.getRowSpan(); i < container.getGridRowCount(); i++) {
GridChangeUtil.splitRow(parent, containerConstraints.getRow());
}
for (int i = containerConstraints.getColSpan(); i < container.getGridColumnCount(); i++) {
GridChangeUtil.splitColumn(parent, containerConstraints.getColumn());
}
ArrayList<RadComponent> contents = new ArrayList<>();
for (int i = container.getComponentCount() - 1; i >= 0; i--) {
contents.add(0, container.getComponent(i));
container.removeComponent(container.getComponent(i));
}
if (contents.size() == 1) {
contents.get(0).setCustomLayoutConstraints(container.getCustomLayoutConstraints());
}
FormEditingUtil.deleteComponents(Collections.singletonList(container), false);
for (RadComponent child : contents) {
final GridConstraints childConstraints = child.getConstraints();
childConstraints.setRow(childConstraints.getRow() + containerConstraints.getRow());
childConstraints.setColumn(childConstraints.getColumn() + containerConstraints.getColumn());
parent.addComponent(child);
child.revalidate();
}
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class IncreaseIndentAction method update.
protected void update(@NotNull GuiEditor editor, final ArrayList<RadComponent> selection, final AnActionEvent e) {
final boolean applicable = canAdjustIndent(selection);
e.getPresentation().setVisible(applicable);
final Component focusOwner = IdeFocusManager.findInstanceByComponent(editor).getFocusOwner();
e.getPresentation().setEnabled(applicable && (focusOwner == editor || editor.isAncestorOf(focusOwner)));
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class ComponentTreeBuilder method syncSelection.
/**
* This method synchronizes selection in the tree with the selected
* RadComponent in the component hierarchy
*/
private void syncSelection() {
// Found selected components
final RadContainer rootContainer = myEditor.getRootContainer();
final ArrayList<RadComponent> selection = new ArrayList<>();
FormEditingUtil.iterate(rootContainer, new FormEditingUtil.ComponentVisitor<RadComponent>() {
public boolean visit(final RadComponent component) {
if (component.isSelected()) {
selection.add(component);
}
return true;
}
});
if (selection.size() == 0) {
// If there is no selected component in the hierarchy, then
// we have to select RadRootContainer
selection.add(rootContainer);
}
final ComponentPtr[] componentPtrs = new ComponentPtr[selection.size()];
for (int i = 0; i < selection.size(); i++) {
componentPtrs[i] = new ComponentPtr(myEditor, selection.get(i));
}
// Set selection in the tree
select(componentPtrs, null);
// Notify the ComponentTree that selected component changed
myEditor.fireSelectedComponentChanged();
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class ComponentTreeStructure method getChildElements.
public Object[] getChildElements(final Object element) {
if (element == myRootElement) {
ArrayList<Object> elements = new ArrayList<>();
final RadRootContainer rootContainer = myEditor.getRootContainer();
elements.add(new ComponentPtr(myEditor, rootContainer));
final LwInspectionSuppression[] suppressions = rootContainer.getInspectionSuppressions();
if (suppressions.length > 0) {
elements.add(suppressions);
}
RadButtonGroup[] buttonGroups = rootContainer.getButtonGroups();
if (buttonGroups.length > 0) {
elements.add(buttonGroups);
}
return elements.toArray();
} else if (element instanceof ComponentPtr) {
final ComponentPtr ptr = (ComponentPtr) element;
// pointer must be valid
LOG.assertTrue(ptr.isValid());
final RadComponent component = ptr.getComponent();
if (component instanceof RadContainer) {
final RadContainer container = (RadContainer) component;
final ComponentPtr[] ptrs = new ComponentPtr[container.getComponentCount()];
for (int i = 0; i < ptrs.length; i++) {
ptrs[i] = new ComponentPtr(myEditor, container.getComponent(i));
}
return ptrs;
} else {
return ourEmptyObjectArray;
}
} else if (element instanceof LwInspectionSuppression[]) {
ArrayList<LwInspectionSuppression> result = new ArrayList<>();
for (LwInspectionSuppression suppression : (LwInspectionSuppression[]) element) {
if (suppression.getComponentId() == null || FormEditingUtil.findComponent(myEditor.getRootContainer(), suppression.getComponentId()) != null) {
result.add(suppression);
}
}
return ArrayUtil.toObjectArray(result);
} else if (element instanceof RadButtonGroup[]) {
return (RadButtonGroup[]) element;
} else if (element instanceof LwInspectionSuppression || element instanceof RadButtonGroup) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
} else {
throw new IllegalArgumentException("unknown element: " + element);
}
}
use of com.intellij.uiDesigner.radComponents.RadComponent in project intellij-community by JetBrains.
the class ComponentTreeStructure method getParentElement.
public Object getParentElement(final Object element) {
if (element instanceof ComponentTreeStructureRoot) {
return null;
} else if (element instanceof LwInspectionSuppression[] || element instanceof RadButtonGroup[]) {
return myRootElement;
} else if (element instanceof LwInspectionSuppression) {
return myEditor.getRootContainer().getInspectionSuppressions();
} else if (element instanceof RadButtonGroup) {
return myEditor.getRootContainer().getButtonGroups();
} else if (element instanceof ComponentPtr) {
// RadContainer is also RadComponent
final ComponentPtr ptr = (ComponentPtr) element;
if (!ptr.isValid())
return myRootElement;
final RadComponent component = ptr.getComponent();
if (component instanceof RadRootContainer) {
return myRootElement;
} else {
return component.getParent() != null ? new ComponentPtr(myEditor, component.getParent(), false) : null;
}
} else {
throw new IllegalArgumentException("unknown element: " + element);
}
}
Aggregations