use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class FormEditingUtil method deleteComponents.
public static void deleteComponents(final Collection<? extends RadComponent> selection, boolean deleteEmptyCells) {
if (selection.size() == 0) {
return;
}
final RadRootContainer rootContainer = (RadRootContainer) getRoot(selection.iterator().next());
final Set<String> deletedComponentIds = new HashSet<>();
for (final RadComponent component : selection) {
boolean wasSelected = component.isSelected();
final RadContainer parent = component.getParent();
boolean wasPackedHorz = false;
boolean wasPackedVert = false;
if (parent.getParent() != null && parent.getParent().isXY()) {
final Dimension minSize = parent.getMinimumSize();
wasPackedHorz = parent.getWidth() == minSize.width;
wasPackedVert = parent.getHeight() == minSize.height;
}
iterate(component, new ComponentVisitor() {
public boolean visit(final IComponent c) {
RadComponent rc = (RadComponent) c;
BindingProperty.checkRemoveUnusedField(rootContainer, rc.getBinding(), null);
deletedComponentIds.add(rc.getId());
return true;
}
});
GridConstraints delConstraints = parent.getLayoutManager().isGrid() ? component.getConstraints() : null;
int index = parent.indexOfComponent(component);
parent.removeComponent(component);
if (wasSelected) {
if (parent.getComponentCount() > index) {
parent.getComponent(index).setSelected(true);
} else if (index > 0 && parent.getComponentCount() == index) {
parent.getComponent(index - 1).setSelected(true);
} else {
parent.setSelected(true);
}
}
if (delConstraints != null && deleteEmptyCells) {
deleteEmptyGridCells(parent, delConstraints);
}
if (wasPackedHorz || wasPackedVert) {
final Dimension minSize = parent.getMinimumSize();
Dimension newSize = new Dimension(parent.getWidth(), parent.getHeight());
if (wasPackedHorz) {
newSize.width = minSize.width;
}
if (wasPackedVert) {
newSize.height = minSize.height;
}
parent.setSize(newSize);
}
}
iterate(rootContainer, new ComponentVisitor() {
public boolean visit(final IComponent component) {
RadComponent rc = (RadComponent) component;
for (IProperty p : component.getModifiedProperties()) {
if (p instanceof IntroComponentProperty) {
IntroComponentProperty icp = (IntroComponentProperty) p;
final String value = icp.getValue(rc);
if (deletedComponentIds.contains(value)) {
try {
icp.resetValue(rc);
} catch (Exception e) {
// ignore
}
}
}
}
return true;
}
});
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class FormEditingUtil method canDeleteSelection.
public static boolean canDeleteSelection(final GuiEditor editor) {
final ArrayList<RadComponent> selection = getSelectedComponents(editor);
if (selection.isEmpty())
return false;
final RadRootContainer rootContainer = editor.getRootContainer();
if (rootContainer.getComponentCount() > 0 && selection.contains(rootContainer.getComponent(0))) {
return false;
}
return true;
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class StringDescriptorManager method resolve.
@Nullable
public String resolve(@NotNull RadComponent component, @Nullable StringDescriptor descriptor) {
RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
Locale locale = (root != null) ? root.getStringDescriptorLocale() : null;
return resolve(descriptor, locale);
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class PassiveDecorationLayer method paint.
public void paint(final Graphics g) {
// Passive decoration
final RadRootContainer root = myEditor.getRootContainer();
for (int i = root.getComponentCount() - 1; i >= 0; i--) {
final RadComponent component = root.getComponent(i);
paintPassiveDecoration(component, g);
}
// Paint active decorators
paintChildren(g);
}
use of com.intellij.uiDesigner.radComponents.RadRootContainer in project intellij-community by JetBrains.
the class PassiveDecorationLayer method paintPassiveDecoration.
/**
* Paints all necessary decoration for the specified <code>component</code>
*/
protected final void paintPassiveDecoration(final RadComponent component, final Graphics g) {
// Paint component bounds and grid markers
Painter.paintComponentDecoration(myEditor, component, g);
final Set<RadButtonGroup> paintedGroups = new HashSet<>();
final RadRootContainer rootContainer = myEditor.getRootContainer();
final ComponentTree componentTree = DesignerToolWindowManager.getInstance(myEditor).getComponentTree();
final Collection<RadButtonGroup> selectedGroups = componentTree != null ? componentTree.getSelectedElements(RadButtonGroup.class) : Collections.<RadButtonGroup>emptyList();
// Paint selection and dragger
FormEditingUtil.iterate(component, new FormEditingUtil.ComponentVisitor<RadComponent>() {
public boolean visit(final RadComponent component) {
final Point point = SwingUtilities.convertPoint(component.getDelegee(), 0, 0, rootContainer.getDelegee());
RadButtonGroup group = (RadButtonGroup) FormEditingUtil.findGroupForComponent(rootContainer, component);
if (group != null && !paintedGroups.contains(group) && (component.isSelected() || selectedGroups.contains(group))) {
paintedGroups.add(group);
Painter.paintButtonGroupLines(rootContainer, group, g);
}
g.translate(point.x, point.y);
try {
if (myEditor.isShowComponentTags() && FormEditingUtil.isComponentSwitchedInView(component)) {
Painter.paintComponentTag(component, g);
}
Painter.paintSelectionDecoration(component, g, myEditor.getGlassLayer().isFocusOwner());
// Over selection we have to paint dragger
if (component.hasDragger()) {
final Icon icon = getDragIcon();
icon.paintIcon(PassiveDecorationLayer.this, g, -icon.getIconWidth(), -icon.getIconHeight());
}
} finally {
g.translate(-point.x, -point.y);
}
return true;
}
});
}
Aggregations