Search in sources :

Example 6 with Palette

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);
    }
}
Also used : ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) VSpacer(com.intellij.uiDesigner.VSpacer) Palette(com.intellij.uiDesigner.palette.Palette) RadAbstractGridLayoutManager(com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager) HSpacer(com.intellij.uiDesigner.HSpacer)

Example 7 with Palette

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();
}
Also used : ComponentItem(com.intellij.uiDesigner.palette.ComponentItem) Palette(com.intellij.uiDesigner.palette.Palette) GridConstraints(com.intellij.uiDesigner.core.GridConstraints)

Example 8 with Palette

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;
}
Also used : Palette(com.intellij.uiDesigner.palette.Palette) IProperty(com.intellij.uiDesigner.lw.IProperty) IntrospectedProperty(com.intellij.uiDesigner.propertyInspector.IntrospectedProperty) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) BindingProperty(com.intellij.uiDesigner.propertyInspector.properties.BindingProperty) IncorrectOperationException(com.intellij.util.IncorrectOperationException) RadContainer(com.intellij.uiDesigner.radComponents.RadContainer)

Example 9 with Palette

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;
}
Also used : Palette(com.intellij.uiDesigner.palette.Palette) IntrospectedProperty(com.intellij.uiDesigner.propertyInspector.IntrospectedProperty) IntroStringProperty(com.intellij.uiDesigner.propertyInspector.properties.IntroStringProperty) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Palette (com.intellij.uiDesigner.palette.Palette)9 ComponentItem (com.intellij.uiDesigner.palette.ComponentItem)4 IntrospectedProperty (com.intellij.uiDesigner.propertyInspector.IntrospectedProperty)3 GridConstraints (com.intellij.uiDesigner.core.GridConstraints)2 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)2 XYLayoutManager (com.intellij.uiDesigner.shared.XYLayoutManager)2 JBColor (com.intellij.ui.JBColor)1 HSpacer (com.intellij.uiDesigner.HSpacer)1 VSpacer (com.intellij.uiDesigner.VSpacer)1 RecursiveFormNestingException (com.intellij.uiDesigner.compiler.RecursiveFormNestingException)1 GridLayoutManager (com.intellij.uiDesigner.core.GridLayoutManager)1 ComponentDropLocation (com.intellij.uiDesigner.designSurface.ComponentDropLocation)1 ComponentItemDragObject (com.intellij.uiDesigner.designSurface.ComponentItemDragObject)1 IProperty (com.intellij.uiDesigner.lw.IProperty)1 PsiNestedFormLoader (com.intellij.uiDesigner.make.PsiNestedFormLoader)1 BindingProperty (com.intellij.uiDesigner.propertyInspector.properties.BindingProperty)1 IntroStringProperty (com.intellij.uiDesigner.propertyInspector.properties.IntroStringProperty)1 RadAbstractGridLayoutManager (com.intellij.uiDesigner.radComponents.RadAbstractGridLayoutManager)1 RadContainer (com.intellij.uiDesigner.radComponents.RadContainer)1 RadTabbedPane (com.intellij.uiDesigner.radComponents.RadTabbedPane)1