Java 类com.intellij.uiDesigner.palette.Palette 实例源码

项目:intellij-ce-playground    文件:BoundIconRenderer.java   
public BoundIconRenderer(@NotNull final PsiElement element) {
  myElement = element;
  if (myElement instanceof PsiField) {
    final PsiField field = (PsiField)myElement;
    final PsiType type = field.getType();
    if (type instanceof PsiClassType) {
      PsiClass componentClass = ((PsiClassType)type).resolve();
      if (componentClass != null) {
        String qName = componentClass.getQualifiedName();
        if (qName != null) {
          final ComponentItem item = Palette.getInstance(myElement.getProject()).getItem(qName);
          if (item != null) {
            myIcon = item.getIcon();
          }
        }
      }
    }
    myQName = field.getContainingClass().getQualifiedName() + "#" + field.getName();
  }
  else {
    myQName = ((PsiClass) element).getQualifiedName();
  }
}
项目:intellij-ce-playground    文件:PropertyInspectorTable.java   
/**
 * @return false if some of the set value operations have failed; true if everything successful
 */
private boolean setSelectionValue(Property property, Object newValue) {
  if (!setPropValue(property, mySelection.get(0), newValue)) return false;
  for(int i=1; i<mySelection.size(); i++) {
    if (property instanceof IntrospectedProperty) {
      IntrospectedProperty[] props = Palette.getInstance(myProject).getIntrospectedProperties(mySelection.get(i));
      for(IntrospectedProperty otherProperty: props) {
        if (otherProperty.getName().equals(property.getName())) {
          if (!setPropValue(otherProperty, mySelection.get(i), newValue)) return false;
          break;
        }
      }
    }
    else {
      if (!setPropValue(property, mySelection.get(i), newValue)) return false;
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:NoLabelForInspection.java   
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);
}
项目:intellij-ce-playground    文件:ComponentTree.java   
public static Icon getComponentIcon(final RadComponent component) {
  if (!(component instanceof RadErrorComponent)) {
    final Palette palette = Palette.getInstance(component.getProject());
    final ComponentItem item = palette.getItem(component.getComponentClassName());
    final Icon icon;
    if (item != null) {
      icon = item.getSmallIcon();
    }
    else {
      icon = UIDesignerIcons.Unknown_small;
    }
    return icon;
  }
  else {
    return AllIcons.General.Error;
  }
}
项目:tools-idea    文件:BoundIconRenderer.java   
public BoundIconRenderer(@NotNull final PsiElement element) {
  myElement = element;
  if (myElement instanceof PsiField) {
    final PsiField field = (PsiField)myElement;
    final PsiType type = field.getType();
    if (type instanceof PsiClassType) {
      PsiClass componentClass = ((PsiClassType)type).resolve();
      if (componentClass != null) {
        String qName = componentClass.getQualifiedName();
        if (qName != null) {
          final ComponentItem item = Palette.getInstance(myElement.getProject()).getItem(qName);
          if (item != null) {
            myIcon = item.getIcon();
          }
        }
      }
    }
    myQName = field.getContainingClass().getQualifiedName() + "#" + field.getName();
  }
  else {
    myQName = ((PsiClass) element).getQualifiedName();
  }
}
项目:tools-idea    文件:PropertyInspectorTable.java   
/**
 * @return false if some of the set value operations have failed; true if everything successful
 */
private boolean setSelectionValue(Property property, Object newValue) {
  if (!setPropValue(property, mySelection.get(0), newValue)) return false;
  for(int i=1; i<mySelection.size(); i++) {
    if (property instanceof IntrospectedProperty) {
      IntrospectedProperty[] props = Palette.getInstance(myProject).getIntrospectedProperties(mySelection.get(i));
      for(IntrospectedProperty otherProperty: props) {
        if (otherProperty.getName().equals(property.getName())) {
          if (!setPropValue(otherProperty, mySelection.get(i), newValue)) return false;
          break;
        }
      }
    }
    else {
      if (!setPropValue(property, mySelection.get(i), newValue)) return false;
    }
  }
  return true;
}
项目:tools-idea    文件:NoLabelForInspection.java   
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);
}
项目:tools-idea    文件:ComponentTree.java   
public static Icon getComponentIcon(final RadComponent component) {
  if (!(component instanceof RadErrorComponent)) {
    final Palette palette = Palette.getInstance(component.getProject());
    final ComponentItem item = palette.getItem(component.getComponentClassName());
    final Icon icon;
    if (item != null) {
      icon = item.getSmallIcon();
    }
    else {
      icon = UIDesignerIcons.Unknown_small;
    }
    return icon;
  }
  else {
    return AllIcons.General.Error;
  }
}
项目:consulo-ui-designer    文件:BoundIconRenderer.java   
public BoundIconRenderer(@NotNull final PsiElement element) {
  myElement = element;
  if (myElement instanceof PsiField) {
    final PsiField field = (PsiField)myElement;
    final PsiType type = field.getType();
    if (type instanceof PsiClassType) {
      PsiClass componentClass = ((PsiClassType)type).resolve();
      if (componentClass != null) {
        String qName = componentClass.getQualifiedName();
        if (qName != null) {
          final ComponentItem item = Palette.getInstance(myElement.getProject()).getItem(qName);
          if (item != null) {
            myIcon = item.getIcon();
          }
        }
      }
    }
    myQName = field.getContainingClass().getQualifiedName() + "#" + field.getName();
  }
  else {
    myQName = ((PsiClass) element).getQualifiedName();
  }
}
项目:consulo-ui-designer    文件:NoLabelForInspection.java   
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);
}
项目:consulo-ui-designer    文件:ComponentTree.java   
public static Icon getComponentIcon(final RadComponent component)
{
    if(!(component instanceof RadErrorComponent))
    {
        final Palette palette = Palette.getInstance(component.getProject());
        final ComponentItem item = palette.getItem(component.getComponentClassName());
        final Icon icon;
        if(item != null)
        {
            icon = item.getSmallIcon();
        }
        else
        {
            icon = UIDesignerIcons.Unknown_small;
        }
        return icon;
    }
    else
    {
        return AllIcons.General.Error;
    }
}
项目:intellij-ce-playground    文件:FormEditingUtil.java   
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();
}
项目:intellij-ce-playground    文件:PropertyInspectorTable.java   
private Object getSelectionValue(final Property property) {
  if (mySelection.size() == 0) {
    return null;
  }
  //noinspection unchecked
  Object result = property.getValue(mySelection.get(0));
  for(int i=1; i<mySelection.size(); i++) {
    Object otherValue = null;
    if (property instanceof IntrospectedProperty) {
      IntrospectedProperty[] props = Palette.getInstance(myProject).getIntrospectedProperties(mySelection.get(i));
      for(IntrospectedProperty otherProperty: props) {
        if (otherProperty.getName().equals(property.getName())) {
          otherValue = otherProperty.getValue(mySelection.get(i));
          break;
        }
      }
    }
    else {
      //noinspection unchecked
      otherValue = property.getValue(mySelection.get(i));
    }
    if (!Comparing.equal(result, otherValue)) {
      return null;
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:PaletteListPopupStep.java   
PaletteListPopupStep(GuiEditor editor, ComponentItem initialSelection, final Processor<ComponentItem> runnable, final String title) {
  myInitialSelection = initialSelection;
  myRunnable = runnable;
  myProject = editor.getProject();
  Palette palette = Palette.getInstance(editor.getProject());
  for(GroupItem group: palette.getToolWindowGroups()) {
    Collections.addAll(myItems, group.getItems());
  }
  myTitle = title;
}
项目:intellij-ce-playground    文件:AddTabAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  RadTabbedPane tabbedPane = (RadTabbedPane) selection.get(0);
  Palette palette = Palette.getInstance(editor.getProject());

  final RadComponent radComponent = InsertComponentProcessor.createPanelComponent(editor);
  final ComponentDropLocation dropLocation = tabbedPane.getDropLocation(null);
  dropLocation.processDrop(editor, new RadComponent[] { radComponent }, null, 
                           new ComponentItemDragObject(palette.getPanelItem()));
}
项目:intellij-ce-playground    文件:FirstComponentInsertLocation.java   
@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);
  }
}
项目:intellij-ce-playground    文件:FormPropertyTableCellRenderer.java   
FormPropertyTableCellRenderer(@NotNull final Project project) {
  myPalette = Palette.getInstance(project);
  myAttrs1 = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
  myAttrs2 = SimpleTextAttributes.REGULAR_ATTRIBUTES;
  myAttrs3 = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, Color.GRAY);

  setFocusBorderAroundIcon(true);
}
项目:intellij-ce-playground    文件:NoScrollPaneInspection.java   
public void run() {
  String scrollPane = JScrollPane.class.getName();
  ComponentItem item = Palette.getInstance(myEditor.getProject()).getItem(scrollPane);

  SurroundAction action = new SurroundAction(item == null ? JBScrollPane.class.getName() : scrollPane);

  ArrayList<RadComponent> targetList = new ArrayList<RadComponent>(Collections.singletonList(myComponent));
  action.actionPerformed(myEditor, targetList, null);
}
项目:intellij-ce-playground    文件:RadTabbedPane.java   
public void processDrop(GuiEditor editor,
                        RadComponent[] components,
                        GridConstraints[] constraintsToAdjust,
                        ComponentDragObject dragObject) {
  if (myInsertBeforeId != null) {
    for(int i=0; i<getTabbedPane().getTabCount(); i++) {
      if (getRadComponent(i).getId().equals(myInsertBeforeId)) {
        myInsertIndex = i;
        break;
      }
    }
  }
  if (myInsertIndex > getTabbedPane().getTabCount()) {
    myInsertIndex = getTabbedPane().getTabCount();
  }
  RadComponent componentToAdd = components [0];
  if (componentToAdd instanceof RadContainer) {
    addComponent(componentToAdd, myInsertIndex);
  }
  else {
    Palette palette = Palette.getInstance(editor.getProject());
    RadContainer panel = InsertComponentProcessor.createPanelComponent(editor);
    addComponent(panel);
    panel.getDropLocation(null).processDrop(editor, new RadComponent[] { componentToAdd }, null,
                                            new ComponentItemDragObject(palette.getPanelItem()));
  }
  getTabbedPane().setSelectedIndex(myInsertIndex);
}
项目:tools-idea    文件:FormEditingUtil.java   
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();
}
项目:tools-idea    文件:PropertyInspectorTable.java   
private Object getSelectionValue(final Property property) {
  if (mySelection.size() == 0) {
    return null;
  }
  //noinspection unchecked
  Object result = property.getValue(mySelection.get(0));
  for(int i=1; i<mySelection.size(); i++) {
    Object otherValue = null;
    if (property instanceof IntrospectedProperty) {
      IntrospectedProperty[] props = Palette.getInstance(myProject).getIntrospectedProperties(mySelection.get(i));
      for(IntrospectedProperty otherProperty: props) {
        if (otherProperty.getName().equals(property.getName())) {
          otherValue = otherProperty.getValue(mySelection.get(i));
          break;
        }
      }
    }
    else {
      //noinspection unchecked
      otherValue = property.getValue(mySelection.get(i));
    }
    if (!Comparing.equal(result, otherValue)) {
      return null;
    }
  }
  return result;
}
项目:tools-idea    文件:PaletteListPopupStep.java   
PaletteListPopupStep(GuiEditor editor, ComponentItem initialSelection, final Processor<ComponentItem> runnable, final String title) {
  myInitialSelection = initialSelection;
  myRunnable = runnable;
  myProject = editor.getProject();
  Palette palette = Palette.getInstance(editor.getProject());
  for(GroupItem group: palette.getToolWindowGroups()) {
    Collections.addAll(myItems, group.getItems());
  }
  myTitle = title;
}
项目:tools-idea    文件:AddTabAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  RadTabbedPane tabbedPane = (RadTabbedPane) selection.get(0);
  Palette palette = Palette.getInstance(editor.getProject());

  final RadComponent radComponent = InsertComponentProcessor.createPanelComponent(editor);
  final ComponentDropLocation dropLocation = tabbedPane.getDropLocation(null);
  dropLocation.processDrop(editor, new RadComponent[] { radComponent }, null, 
                           new ComponentItemDragObject(palette.getPanelItem()));
}
项目:tools-idea    文件:FirstComponentInsertLocation.java   
@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);
  }
}
项目:tools-idea    文件:FormPropertyTableCellRenderer.java   
FormPropertyTableCellRenderer(@NotNull final Project project) {
  myPalette = Palette.getInstance(project);
  myAttrs1 = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
  myAttrs2 = SimpleTextAttributes.REGULAR_ATTRIBUTES;
  myAttrs3 = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, Color.GRAY);

  setFocusBorderAroundIcon(true);
}
项目:tools-idea    文件:NoScrollPaneInspection.java   
public void run() {
  String scrollPane = JScrollPane.class.getName();
  ComponentItem item = Palette.getInstance(myEditor.getProject()).getItem(scrollPane);

  SurroundAction action = new SurroundAction(item == null ? JBScrollPane.class.getName() : scrollPane);

  ArrayList<RadComponent> targetList = new ArrayList<RadComponent>(Collections.singletonList(myComponent));
  action.actionPerformed(myEditor, targetList, null);
}
项目:tools-idea    文件:RadTabbedPane.java   
public void processDrop(GuiEditor editor,
                        RadComponent[] components,
                        GridConstraints[] constraintsToAdjust,
                        ComponentDragObject dragObject) {
  if (myInsertBeforeId != null) {
    for(int i=0; i<getTabbedPane().getTabCount(); i++) {
      if (getRadComponent(i).getId().equals(myInsertBeforeId)) {
        myInsertIndex = i;
        break;
      }
    }
  }
  if (myInsertIndex > getTabbedPane().getTabCount()) {
    myInsertIndex = getTabbedPane().getTabCount();
  }
  RadComponent componentToAdd = components [0];
  if (componentToAdd instanceof RadContainer) {
    addComponent(componentToAdd, myInsertIndex);
  }
  else {
    Palette palette = Palette.getInstance(editor.getProject());
    RadContainer panel = InsertComponentProcessor.createPanelComponent(editor);
    addComponent(panel);
    panel.getDropLocation(null).processDrop(editor, new RadComponent[] { componentToAdd }, null,
                                            new ComponentItemDragObject(palette.getPanelItem()));
  }
  getTabbedPane().setSelectedIndex(myInsertIndex);
}
项目:consulo-ui-designer    文件:FormEditingUtil.java   
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();
}
项目:consulo-ui-designer    文件:PropertyInspectorTable.java   
private Object getSelectionValue(final Property property)
{
    if(mySelection.size() == 0)
    {
        return null;
    }
    //noinspection unchecked
    Object result = property.getValue(mySelection.get(0));
    for(int i = 1; i < mySelection.size(); i++)
    {
        Object otherValue = null;
        if(property instanceof IntrospectedProperty)
        {
            IntrospectedProperty[] props = Palette.getInstance(myProject).getIntrospectedProperties(mySelection.get(i));
            for(IntrospectedProperty otherProperty : props)
            {
                if(otherProperty.getName().equals(property.getName()))
                {
                    otherValue = otherProperty.getValue(mySelection.get(i));
                    break;
                }
            }
        }
        else
        {
            //noinspection unchecked
            otherValue = property.getValue(mySelection.get(i));
        }
        if(!Comparing.equal(result, otherValue))
        {
            return null;
        }
    }
    return result;
}
项目:consulo-ui-designer    文件:PropertyInspectorTable.java   
/**
 * @return false if some of the set value operations have failed; true if everything successful
 */
private boolean setSelectionValue(Property property, Object newValue)
{
    if(!setPropValue(property, mySelection.get(0), newValue))
    {
        return false;
    }
    for(int i = 1; i < mySelection.size(); i++)
    {
        if(property instanceof IntrospectedProperty)
        {
            IntrospectedProperty[] props = Palette.getInstance(myProject).getIntrospectedProperties(mySelection.get(i));
            for(IntrospectedProperty otherProperty : props)
            {
                if(otherProperty.getName().equals(property.getName()))
                {
                    if(!setPropValue(otherProperty, mySelection.get(i), newValue))
                    {
                        return false;
                    }
                    break;
                }
            }
        }
        else
        {
            if(!setPropValue(property, mySelection.get(i), newValue))
            {
                return false;
            }
        }
    }
    return true;
}
项目:consulo-ui-designer    文件:PaletteListPopupStep.java   
PaletteListPopupStep(GuiEditor editor, ComponentItem initialSelection, final Processor<ComponentItem> runnable, final String title) {
  myInitialSelection = initialSelection;
  myRunnable = runnable;
  myProject = editor.getProject();
  Palette palette = Palette.getInstance(editor.getProject());
  for(GroupItem group: palette.getToolWindowGroups()) {
    Collections.addAll(myItems, group.getItems());
  }
  myTitle = title;
}
项目:consulo-ui-designer    文件:AddTabAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  RadTabbedPane tabbedPane = (RadTabbedPane) selection.get(0);
  Palette palette = Palette.getInstance(editor.getProject());

  final RadComponent radComponent = InsertComponentProcessor.createPanelComponent(editor);
  final ComponentDropLocation dropLocation = tabbedPane.getDropLocation(null);
  dropLocation.processDrop(editor, new RadComponent[] { radComponent }, null, 
                           new ComponentItemDragObject(palette.getPanelItem()));
}
项目:consulo-ui-designer    文件:InsertComponentProcessor.java   
/**
 * Tries to create binding for {@link #myInsertedComponent}
 *
 * @param editor
 * @param insertedComponent
 * @param forceBinding
 */
public static void createBindingWhenDrop(final GuiEditor editor, final RadComponent insertedComponent, final boolean forceBinding)
{
    final ComponentItem item = Palette.getInstance(editor.getProject()).getItem(insertedComponent.getComponentClassName());
    if((item != null && item.isAutoCreateBinding()) || insertedComponent.isCustomCreateRequired() || forceBinding)
    {
        doCreateBindingWhenDrop(editor, insertedComponent);
    }
}
项目:consulo-ui-designer    文件:FirstComponentInsertLocation.java   
@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);
  }
}
项目:consulo-ui-designer    文件:FormPropertyTableCellRenderer.java   
FormPropertyTableCellRenderer(@NotNull final Project project) {
  myPalette = Palette.getInstance(project);
  myAttrs1 = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
  myAttrs2 = SimpleTextAttributes.REGULAR_ATTRIBUTES;
  myAttrs3 = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, Color.GRAY);

  setFocusBorderAroundIcon(true);
}
项目:consulo-ui-designer    文件:NoScrollPaneInspection.java   
public void run() {
  String scrollPane = JScrollPane.class.getName();
  ComponentItem item = Palette.getInstance(myEditor.getProject()).getItem(scrollPane);

  SurroundAction action = new SurroundAction(item == null ? JBScrollPane.class.getName() : scrollPane);

  ArrayList<RadComponent> targetList = new ArrayList<RadComponent>(Collections.singletonList(myComponent));
  action.actionPerformed(myEditor, targetList, null);
}
项目:consulo-ui-designer    文件:RadTabbedPane.java   
public void processDrop(GuiEditor editor,
                        RadComponent[] components,
                        GridConstraints[] constraintsToAdjust,
                        ComponentDragObject dragObject) {
  if (myInsertBeforeId != null) {
    for(int i=0; i<getTabbedPane().getTabCount(); i++) {
      if (getRadComponent(i).getId().equals(myInsertBeforeId)) {
        myInsertIndex = i;
        break;
      }
    }
  }
  if (myInsertIndex > getTabbedPane().getTabCount()) {
    myInsertIndex = getTabbedPane().getTabCount();
  }
  RadComponent componentToAdd = components [0];
  if (componentToAdd instanceof RadContainer) {
    addComponent(componentToAdd, myInsertIndex);
  }
  else {
    Palette palette = Palette.getInstance(editor.getProject());
    RadContainer panel = InsertComponentProcessor.createPanelComponent(editor);
    addComponent(panel);
    panel.getDropLocation(null).processDrop(editor, new RadComponent[] { componentToAdd }, null,
                                            new ComponentItemDragObject(palette.getPanelItem()));
  }
  getTabbedPane().setSelectedIndex(myInsertIndex);
}
项目:intellij-ce-playground    文件:SnapshotContext.java   
public SnapshotContext() {
  myPalette = new Palette(null);
  myRootContainer = new RadRootContainer(null, "1");
}
项目:intellij-ce-playground    文件:SnapshotContext.java   
public Palette getPalette() {
  return myPalette;
}
项目:intellij-ce-playground    文件:MorphAction.java   
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;
}