private static void retargetComponentProperties(final GuiEditor editor, final RadComponent c, final RadComponent newComponent) { FormEditingUtil.iterate(editor.getRootContainer(), new FormEditingUtil.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 (value.equals(c.getId())) { try { icp.setValue((RadComponent)component, newComponent.getId()); } catch (Exception e) { // ignore } } } } return true; } }); }
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()); } } } } } }
public void run() { if (!myEditor.ensureEditable()) { return; } Runnable runnable = new Runnable() { public void run() { final Palette palette = Palette.getInstance(myEditor.getProject()); IntrospectedProperty[] props = palette.getIntrospectedProperties(myLabel); boolean modified = false; for(IntrospectedProperty prop: props) { if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) { IntroComponentProperty icp = (IntroComponentProperty) prop; icp.setValueEx(myLabel, myComponent.getId()); modified = true; break; } } if (modified) myEditor.refreshAndSave(false); } }; CommandProcessor.getInstance().executeCommand(myEditor.getProject(), runnable, UIDesignerBundle.message("inspection.no.label.for.command"), null); }