use of com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty 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.propertyInspector.properties.IntroComponentProperty in project intellij-community by JetBrains.
the class SnapshotContext method postProcess.
public void postProcess() {
for (ButtonGroup group : myButtonGroups) {
RadButtonGroup radButtonGroup = myRootContainer.createGroup(myRootContainer.suggestGroupName());
Enumeration<AbstractButton> elements = group.getElements();
while (elements.hasMoreElements()) {
AbstractButton btn = elements.nextElement();
RadComponent c = myImportMap.get(btn);
if (c != null) {
radButtonGroup.add(c);
}
}
}
for (ComponentProperty prop : myComponentProperties) {
RadComponent radOwner = myImportMap.get(prop.owner);
RadComponent radValue = myImportMap.get(prop.value);
if (radOwner != null && radValue != null) {
final IntrospectedProperty property = radOwner.getPalette().getIntrospectedProperty(radOwner, prop.name);
assert property != null;
//noinspection unchecked
IntroComponentProperty icp = (IntroComponentProperty) property;
try {
icp.setValue(radOwner, radValue.getId());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
use of com.intellij.uiDesigner.propertyInspector.properties.IntroComponentProperty in project intellij-community by JetBrains.
the class DuplicateComponentsAction method adjustDuplicates.
private static void adjustDuplicates(final Map<RadComponent, RadComponent> duplicates) {
for (RadComponent c : duplicates.keySet()) {
RadComponent copy = duplicates.get(c);
if (c.getBinding() != null) {
String binding = BindingProperty.getDefaultBinding(copy);
new BindingProperty(c.getProject()).setValueEx(copy, binding);
copy.setDefaultBinding(true);
}
for (IProperty prop : copy.getModifiedProperties()) {
if (prop instanceof IntroComponentProperty) {
final IntroComponentProperty componentProperty = (IntroComponentProperty) prop;
String copyValue = componentProperty.getValue(copy);
for (RadComponent original : duplicates.keySet()) {
if (original.getId().equals(copyValue)) {
componentProperty.setValueEx(copy, duplicates.get(original).getId());
}
}
}
}
}
}
Aggregations