use of com.intellij.uiDesigner.propertyInspector.properties.BindingProperty 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());
}
}
}
}
}
}
use of com.intellij.uiDesigner.propertyInspector.properties.BindingProperty in project intellij-community by JetBrains.
the class MorphAction method morphComponent.
private static boolean morphComponent(final GuiEditor editor, final RadComponent oldComponent, ComponentItem targetItem) {
targetItem = InsertComponentProcessor.replaceAnyComponentItem(editor, targetItem, "Morph to Non-Palette Component");
if (targetItem == null) {
return false;
}
final RadComponent newComponent = InsertComponentProcessor.createInsertedComponent(editor, targetItem);
if (newComponent == null)
return false;
newComponent.setBinding(oldComponent.getBinding());
newComponent.setCustomLayoutConstraints(oldComponent.getCustomLayoutConstraints());
newComponent.getConstraints().restore(oldComponent.getConstraints());
updateBoundFieldType(editor, oldComponent, targetItem);
final IProperty[] oldProperties = oldComponent.getModifiedProperties();
final Palette palette = Palette.getInstance(editor.getProject());
for (IProperty prop : oldProperties) {
IntrospectedProperty newProp = palette.getIntrospectedProperty(newComponent, prop.getName());
if (newProp == null || !prop.getClass().equals(newProp.getClass()))
continue;
Object oldValue = prop.getPropertyValue(oldComponent);
try {
//noinspection unchecked
newProp.setValue(newComponent, oldValue);
} catch (Exception e) {
// ignore
}
}
retargetComponentProperties(editor, oldComponent, newComponent);
final RadContainer parent = oldComponent.getParent();
int index = parent.indexOfComponent(oldComponent);
parent.removeComponent(oldComponent);
parent.addComponent(newComponent, index);
newComponent.setSelected(true);
if (oldComponent.isDefaultBinding()) {
final String text = FormInspectionUtil.getText(newComponent.getModule(), newComponent);
if (text != null) {
String binding = BindingProperty.suggestBindingFromText(newComponent, text);
if (binding != null) {
new BindingProperty(newComponent.getProject()).setValueEx(newComponent, binding);
}
}
newComponent.setDefaultBinding(true);
}
return true;
}
Aggregations