use of com.intellij.uiDesigner.palette.Palette in project intellij-community by JetBrains.
the class FirstComponentInsertLocation method processDrop.
@Override
public void processDrop(final GuiEditor editor, final RadComponent[] components, final GridConstraints[] constraintsToAdjust, final ComponentDragObject dragObject) {
RadAbstractGridLayoutManager gridLayout = myContainer.getGridLayoutManager();
if (myContainer.getGridRowCount() == 0 && myContainer.getGridColumnCount() == 0) {
gridLayout.insertGridCells(myContainer, 0, false, true, true);
gridLayout.insertGridCells(myContainer, 0, true, true, true);
}
super.processDrop(editor, components, constraintsToAdjust, dragObject);
Palette palette = Palette.getInstance(editor.getProject());
ComponentItem hSpacerItem = palette.getItem(HSpacer.class.getName());
ComponentItem vSpacerItem = palette.getItem(VSpacer.class.getName());
InsertComponentProcessor icp = new InsertComponentProcessor(editor);
if (myXPart == 0) {
insertSpacer(icp, hSpacerItem, GridInsertMode.ColumnAfter);
}
if (myXPart == 2) {
insertSpacer(icp, hSpacerItem, GridInsertMode.ColumnBefore);
}
if (myYPart == 0) {
insertSpacer(icp, vSpacerItem, GridInsertMode.RowAfter);
}
if (myYPart == 2) {
insertSpacer(icp, vSpacerItem, GridInsertMode.RowBefore);
}
}
use of com.intellij.uiDesigner.palette.Palette in project intellij-community by JetBrains.
the class FormEditingUtil method getDefaultConstraints.
public static GridConstraints getDefaultConstraints(final RadComponent component) {
final Palette palette = Palette.getInstance(component.getProject());
final ComponentItem item = palette.getItem(component.getComponentClassName());
if (item != null) {
return item.getDefaultConstraints();
}
return new GridConstraints();
}
use of com.intellij.uiDesigner.palette.Palette 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;
}
use of com.intellij.uiDesigner.palette.Palette in project intellij-community by JetBrains.
the class RadComponent method getComponentTitle.
@Nullable
public String getComponentTitle() {
Palette palette = Palette.getInstance(getProject());
IntrospectedProperty[] props = palette.getIntrospectedProperties(this);
for (IntrospectedProperty prop : props) {
if (prop.getName().equals(SwingProperties.TEXT) && prop instanceof IntroStringProperty) {
StringDescriptor value = (StringDescriptor) prop.getValue(this);
if (value != null) {
return "\"" + value.getResolvedValue() + "\"";
}
}
}
if (this instanceof RadContainer) {
RadContainer container = (RadContainer) this;
StringDescriptor descriptor = container.getBorderTitle();
if (descriptor != null) {
if (descriptor.getResolvedValue() == null) {
descriptor.setResolvedValue(StringDescriptorManager.getInstance(getModule()).resolve(this, descriptor));
}
return "\"" + descriptor.getResolvedValue() + "\"";
}
}
if (getParent() instanceof RadTabbedPane) {
RadTabbedPane parentTabbedPane = (RadTabbedPane) getParent();
final StringDescriptor descriptor = parentTabbedPane.getChildTitle(this);
if (descriptor != null) {
if (descriptor.getResolvedValue() == null) {
descriptor.setResolvedValue(StringDescriptorManager.getInstance(getModule()).resolve(this, descriptor));
}
return "\"" + descriptor.getResolvedValue() + "\"";
} else {
parentTabbedPane.getChildTitle(this);
}
}
return null;
}
Aggregations