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

项目: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    文件:CreateComponentAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  Processor<ComponentItem> processor = new Processor<ComponentItem>() {
    public boolean process(final ComponentItem selectedValue) {
      if (selectedValue != null) {
        myLastCreatedComponent = selectedValue;
        editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection));
      }
      return true;
    }
  };

  PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor,
                                                       UIDesignerBundle.message("create.component.title"));
  final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);

  if (selection.size() > 0) {
    FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
  }
  else {
    listPopup.showInCenterOf(editor.getRootContainer().getDelegee());
  }
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
protected void processKeyEvent(final KeyEvent e) {
  if (e.getID() == KeyEvent.KEY_PRESSED) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      if (myLastLocation != null) {
        myEditor.getMainProcessor().stopCurrentProcessor();
        processComponentInsert(getComponentToInsert(), myLastLocation);
      }
    }
    else {
      ComponentItem componentToInsert = getComponentToInsert();
      if (componentToInsert == null) {
        cancelOperation();
      }
      else {
        myLastLocation = moveDropLocation(myEditor, myLastLocation, new ComponentItemDragObject(componentToInsert), e);
      }
    }
  }
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
protected void processMouseEvent(final MouseEvent e) {
  if (e.getID() == MouseEvent.MOUSE_PRESSED) {
    final ComponentItem componentItem = getComponentToInsert();
    if (componentItem != null) {
      processComponentInsert(e.getPoint(), componentItem);
    }
  }
  else if (e.getID() == MouseEvent.MOUSE_MOVED) {
    final ComponentItem componentToInsert = getComponentToInsert();
    if (componentToInsert != null) {
      ComponentItemDragObject dragObject = new ComponentItemDragObject(componentToInsert);
      myLastLocation = myGridInsertProcessor.processDragEvent(e.getPoint(), dragObject);
      if (myLastLocation.canDrop(dragObject)) {
        setCursor(FormEditingUtil.getCopyDropCursor());
      }
      else {
        setCursor(FormEditingUtil.getMoveNoDropCursor());
      }
    }
  }
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
private boolean checkAddDependencyOnInsert(final ComponentItem item) {
  if (item.getClassName().equals(HSpacer.class.getName()) || item.getClassName().equals(VSpacer.class.getName())) {
    // this is mostly required for IDEA developers, so that developers don't receive prompt to offer ui-designer-impl dependency
    return true;
  }
  PsiManager manager = PsiManager.getInstance(myEditor.getProject());
  final GlobalSearchScope projectScope = GlobalSearchScope.allScope(myEditor.getProject());
  final GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(myEditor.getModule());
  final PsiClass componentClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), projectScope);
  if (componentClass != null && JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), moduleScope) == null) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myEditor.getProject()).getFileIndex();
    List<OrderEntry> entries = fileIndex.getOrderEntriesForFile(componentClass.getContainingFile().getVirtualFile());
    if (entries.size() > 0) {
      if (entries.get(0) instanceof ModuleSourceOrderEntry) {
        if (!checkAddModuleDependency(item, (ModuleSourceOrderEntry)entries.get(0))) return false;
      }
      else if (entries.get(0) instanceof LibraryOrderEntry) {
        if (!checkAddLibraryDependency(item, (LibraryOrderEntry)entries.get(0))) return false;
      }
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
private boolean checkAddLibraryDependency(final ComponentItem item, final LibraryOrderEntry libraryOrderEntry) {
  int rc = Messages.showYesNoCancelDialog(
    myEditor,
    UIDesignerBundle.message("add.library.dependency.prompt", item.getClassName(), libraryOrderEntry.getPresentableName(),
                             myEditor.getModule().getName()),
    UIDesignerBundle.message("add.library.dependency.title"),
    Messages.getQuestionIcon());
  if (rc == Messages.CANCEL) return false;
  if (rc == Messages.YES) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        final ModifiableRootModel model = ModuleRootManager.getInstance(myEditor.getModule()).getModifiableModel();
        if (libraryOrderEntry.isModuleLevel()) {
          copyModuleLevelLibrary(libraryOrderEntry.getLibrary(), model);
        }
        else {
          model.addLibraryEntry(libraryOrderEntry.getLibrary());
        }
        model.commit();
      }
    });
  }
  return true;
}
项目:intellij-ce-playground    文件:DesignDropTargetListener.java   
public void dragEnter(DropTargetDragEvent dtde) {
  try {
    DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
    if (dcl != null) {
      myDraggedComponentList = dcl;
      myComponentDragObject = dcl;
      processDragEnter(dcl, dtde.getLocation(), dtde.getDropAction());
      dtde.acceptDrag(dtde.getDropAction());
      myLastPoint = dtde.getLocation();
    }
    else {
      ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
      if (componentItem != null) {
        myComponentDragObject = new ComponentItemDragObject(componentItem);
        dtde.acceptDrag(dtde.getDropAction());
        myLastPoint = dtde.getLocation();
      }
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
项目:intellij-ce-playground    文件:RadComponent.java   
public void initDefaultProperties(@NotNull final ComponentItem item) {
  final IntrospectedProperty[] properties = getPalette().getIntrospectedProperties(this);
  for (final IntrospectedProperty property : properties) {
    final Object initialValue = item.getInitialValue(property);
    if (initialValue != null) {
      try {
        //noinspection unchecked
        property.setValue(this, initialValue);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }

  myConstraints.restore(item.getDefaultConstraints());
}
项目: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    文件:CreateComponentAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  Processor<ComponentItem> processor = new Processor<ComponentItem>() {
    public boolean process(final ComponentItem selectedValue) {
      if (selectedValue != null) {
        myLastCreatedComponent = selectedValue;
        editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection));
      }
      return true;
    }
  };

  PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor,
                                                       UIDesignerBundle.message("create.component.title"));
  final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);

  if (selection.size() > 0) {
    FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
  }
  else {
    listPopup.showInCenterOf(editor.getRootContainer().getDelegee());
  }
}
项目:tools-idea    文件:InsertComponentProcessor.java   
protected void processKeyEvent(final KeyEvent e) {
  if (e.getID() == KeyEvent.KEY_PRESSED) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      if (myLastLocation != null) {
        myEditor.getMainProcessor().stopCurrentProcessor();
        processComponentInsert(getComponentToInsert(), myLastLocation);
      }
    }
    else {
      ComponentItem componentToInsert = getComponentToInsert();
      if (componentToInsert == null) {
        cancelOperation();
      }
      else {
        myLastLocation = moveDropLocation(myEditor, myLastLocation, new ComponentItemDragObject(componentToInsert), e);
      }
    }
  }
}
项目:tools-idea    文件:InsertComponentProcessor.java   
protected void processMouseEvent(final MouseEvent e) {
  if (e.getID() == MouseEvent.MOUSE_PRESSED) {
    final ComponentItem componentItem = getComponentToInsert();
    if (componentItem != null) {
      processComponentInsert(e.getPoint(), componentItem);
    }
  }
  else if (e.getID() == MouseEvent.MOUSE_MOVED) {
    final ComponentItem componentToInsert = getComponentToInsert();
    if (componentToInsert != null) {
      ComponentItemDragObject dragObject = new ComponentItemDragObject(componentToInsert);
      myLastLocation = myGridInsertProcessor.processDragEvent(e.getPoint(), dragObject);
      if (myLastLocation.canDrop(dragObject)) {
        setCursor(FormEditingUtil.getCopyDropCursor());
      }
      else {
        setCursor(FormEditingUtil.getMoveNoDropCursor());
      }
    }
  }
}
项目:tools-idea    文件:InsertComponentProcessor.java   
private boolean checkAddDependencyOnInsert(final ComponentItem item) {
  if (item.getClassName().equals(HSpacer.class.getName()) || item.getClassName().equals(VSpacer.class.getName())) {
    // this is mostly required for IDEA developers, so that developers don't receive prompt to offer ui-designer-impl dependency
    return true;
  }
  PsiManager manager = PsiManager.getInstance(myEditor.getProject());
  final GlobalSearchScope projectScope = GlobalSearchScope.allScope(myEditor.getProject());
  final GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(myEditor.getModule());
  final PsiClass componentClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), projectScope);
  if (componentClass != null && JavaPsiFacade.getInstance(manager.getProject()).findClass(item.getClassName(), moduleScope) == null) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myEditor.getProject()).getFileIndex();
    List<OrderEntry> entries = fileIndex.getOrderEntriesForFile(componentClass.getContainingFile().getVirtualFile());
    if (entries.size() > 0) {
      if (entries.get(0) instanceof ModuleSourceOrderEntry) {
        if (!checkAddModuleDependency(item, (ModuleSourceOrderEntry)entries.get(0))) return false;
      }
      else if (entries.get(0) instanceof LibraryOrderEntry) {
        if (!checkAddLibraryDependency(item, (LibraryOrderEntry)entries.get(0))) return false;
      }
    }
  }
  return true;
}
项目:tools-idea    文件:InsertComponentProcessor.java   
private boolean checkAddLibraryDependency(final ComponentItem item, final LibraryOrderEntry libraryOrderEntry) {
  int rc = Messages.showYesNoCancelDialog(
    myEditor,
    UIDesignerBundle.message("add.library.dependency.prompt", item.getClassName(), libraryOrderEntry.getPresentableName(),
                             myEditor.getModule().getName()),
    UIDesignerBundle.message("add.library.dependency.title"),
    Messages.getQuestionIcon());
  if (rc == 2) return false;
  if (rc == 0) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        final ModifiableRootModel model = ModuleRootManager.getInstance(myEditor.getModule()).getModifiableModel();
        if (libraryOrderEntry.isModuleLevel()) {
          copyModuleLevelLibrary(libraryOrderEntry.getLibrary(), model);
        }
        else {
          model.addLibraryEntry(libraryOrderEntry.getLibrary());
        }
        model.commit();
      }
    });
  }
  return true;
}
项目:tools-idea    文件:DesignDropTargetListener.java   
public void dragEnter(DropTargetDragEvent dtde) {
  try {
    DraggedComponentList dcl = DraggedComponentList.fromTransferable(dtde.getTransferable());
    if (dcl != null) {
      myDraggedComponentList = dcl;
      myComponentDragObject = dcl;
      processDragEnter(dcl, dtde.getLocation(), dtde.getDropAction());
      dtde.acceptDrag(dtde.getDropAction());
      myLastPoint = dtde.getLocation();
    }
    else {
      ComponentItem componentItem = SimpleTransferable.getData(dtde.getTransferable(), ComponentItem.class);
      if (componentItem != null) {
        myComponentDragObject = new ComponentItemDragObject(componentItem);
        dtde.acceptDrag(dtde.getDropAction());
        myLastPoint = dtde.getLocation();
      }
    }
  }
  catch (Exception e) {
    LOG.error(e);
  }
}
项目:tools-idea    文件:RadComponent.java   
public void initDefaultProperties(@NotNull final ComponentItem item) {
  final IntrospectedProperty[] properties = getPalette().getIntrospectedProperties(this);
  for (final IntrospectedProperty property : properties) {
    final Object initialValue = item.getInitialValue(property);
    if (initialValue != null) {
      try {
        //noinspection unchecked
        property.setValue(this, initialValue);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }

  myConstraints.restore(item.getDefaultConstraints());
}
项目: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    文件:CreateComponentAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  Processor<ComponentItem> processor = new Processor<ComponentItem>() {
    public boolean process(final ComponentItem selectedValue) {
      if (selectedValue != null) {
        myLastCreatedComponent = selectedValue;
        editor.getMainProcessor().startInsertProcessor(selectedValue, getCreateLocation(editor, selection));
      }
      return true;
    }
  };

  PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastCreatedComponent, processor,
                                                       UIDesignerBundle.message("create.component.title"));
  final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);

  if (selection.size() > 0) {
    FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
  }
  else {
    listPopup.showInCenterOf(editor.getRootContainer().getDelegee());
  }
}
项目:consulo-ui-designer    文件:InsertComponentProcessor.java   
private boolean checkAddModuleDependency(final ComponentItem item, final ModuleSourceOrderEntry moduleSourceOrderEntry)
{
    final Module ownerModule = moduleSourceOrderEntry.getOwnerModule();
    int rc = Messages.showYesNoCancelDialog(myEditor, UIDesignerBundle.message("add.module.dependency.prompt", item.getClassName(),
            ownerModule.getName(), myEditor.getModule().getName()), UIDesignerBundle.message("add.module.dependency.title"),
            Messages.getQuestionIcon());
    if(rc == Messages.CANCEL)
    {
        return false;
    }
    if(rc == Messages.YES)
    {
        ModuleRootModificationUtil.addDependency(myEditor.getModule(), ownerModule);
    }
    return true;
}
项目:consulo-ui-designer    文件:InsertComponentProcessor.java   
private boolean validateNestedFormInsert(final ComponentItem item)
{
    PsiFile boundForm = item.getBoundForm();
    if(boundForm != null)
    {
        try
        {
            final String formName = FormEditingUtil.buildResourceName(boundForm);
            final String targetForm = FormEditingUtil.buildResourceName(myEditor.getPsiFile());
            Utils.validateNestedFormLoop(formName, new PsiNestedFormLoader(myEditor.getModule()), targetForm);
        }
        catch(Exception ex)
        {
            Messages.showErrorDialog(myEditor, ex.getMessage(), CommonBundle.getErrorTitle());
            return false;
        }
    }
    return true;
}
项目:consulo-ui-designer    文件:InsertComponentProcessor.java   
@Nullable
public static ComponentItem replaceAnyComponentItem(GuiEditor editor, ComponentItem item, final String title)
{
    if(item.isAnyComponent())
    {
        ComponentItem newItem = item.clone();
        ComponentItemDialog dlg = new ComponentItemDialog(editor.getProject(), editor, newItem, true);
        dlg.setTitle(title);
        dlg.show();
        if(!dlg.isOK())
        {
            return null;
        }

        return newItem;
    }
    return item;
}
项目:consulo-ui-designer    文件:MainProcessor.java   
protected boolean cancelOperation()
{
    if(myCurrentProcessor != null)
    {
        if(myCurrentProcessor.cancelOperation())
        {
            myCurrentProcessor = null;
            myEditor.getLayeredPane().setCursor(Cursor.getDefaultCursor());
            myEditor.getActiveDecorationLayer().removeFeedback();
            return true;
        }
    }
    else if(PaletteToolWindowManager.getInstance(myEditor).getActiveItem(ComponentItem.class) != null)
    {
        cancelPaletteInsert();
        return true;
    }
    return false;
}
项目:consulo-ui-designer    文件:RadComponent.java   
public void initDefaultProperties(@NotNull final ComponentItem item) {
  final IntrospectedProperty[] properties = getPalette().getIntrospectedProperties(this);
  for (final IntrospectedProperty property : properties) {
    final Object initialValue = item.getInitialValue(property);
    if (initialValue != null) {
      try {
        //noinspection unchecked
        property.setValue(this, initialValue);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }

  myConstraints.restore(item.getDefaultConstraints());
}
项目: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    文件:AlignProperty.java   
@Override
public boolean isModified(final RadComponent component) {
  AlignPropertyProvider provider = getAlignPropertyProvider(component);
  if (provider != null) {
    return provider.isAlignmentModified(component, myHorizontal);
  }
  final ComponentItem item = component.getPalette().getItem(component.getComponentClassName());
  if (item == null) return false;
  return Utils.alignFromConstraints(component.getConstraints(), myHorizontal) !=
         Utils.alignFromConstraints(item.getDefaultConstraints(), myHorizontal);
}
项目:intellij-ce-playground    文件:AlignProperty.java   
@Override
public void resetValue(final RadComponent component) throws Exception {
  AlignPropertyProvider provider = getAlignPropertyProvider(component);
  if (provider != null) {
    provider.resetAlignment(component, myHorizontal);
  }
  else {
    final ComponentItem item = component.getPalette().getItem(component.getComponentClassName());
    if (item != null) {
      setValueEx(component, Utils.alignFromConstraints(item.getDefaultConstraints(), myHorizontal));
    }
  }
}
项目:intellij-ce-playground    文件:MorphAction.java   
protected void actionPerformed(final GuiEditor editor, final List<RadComponent> selection, final AnActionEvent e) {
  Processor<ComponentItem> processor = new Processor<ComponentItem>() {
    public boolean process(final ComponentItem selectedValue) {
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          Runnable runnable = new Runnable() {
            public void run() {
              for(RadComponent c: selection) {
                if (!morphComponent(editor, c, selectedValue)) break;
              }
              editor.refreshAndSave(true);
            }
          };
          CommandProcessor.getInstance().executeCommand(editor.getProject(), runnable, UIDesignerBundle.message("morph.component.command"), null);
          editor.getGlassLayer().requestFocus();
        }
      });
      return true;
    }
  };

  PaletteListPopupStep step = new PaletteListPopupStep(editor, myLastMorphComponent, processor,
                                                       UIDesignerBundle.message("morph.component.title"));
  step.hideNonAtomic();
  if (selection.size() == 1) {
    step.hideComponentClass(selection.get(0).getComponentClassName());
  }
  final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
  FormEditingUtil.showPopupUnderComponent(listPopup, selection.get(0));
}
项目:intellij-ce-playground    文件:MorphAction.java   
private static void updateBoundFieldType(final GuiEditor editor, final RadComponent oldComponent, final ComponentItem targetItem) {
  PsiField oldBoundField = BindingProperty.findBoundField(editor.getRootContainer(), oldComponent.getBinding());
  if (oldBoundField != null) {
    final PsiElementFactory factory = JavaPsiFacade.getInstance(editor.getProject()).getElementFactory();
    try {
      PsiType componentType = factory.createTypeFromText(targetItem.getClassName().replace('$', '.'), null);
      new ChangeFieldTypeFix(editor, oldBoundField, componentType).run();
    }
    catch (IncorrectOperationException e) {
      LOG.error(e);
    }
  }
}
项目: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    文件:PaletteListPopupStep.java   
@NotNull
public String getTextFor(final ComponentItem value) {
  if (value.isAnyComponent()) {
    return UIDesignerBundle.message("palette.non.palette.component");
  }
  return value.getClassShortName();
}
项目:intellij-ce-playground    文件:PaletteListPopupStep.java   
public void hideComponentClass(final String componentClassName) {
  for(ComponentItem item: myItems) {
    if (item.getClassName().equals(componentClassName)) {
      myItems.remove(item);
      break;
    }
  }
}
项目:intellij-ce-playground    文件:PaletteListPopupStep.java   
public void hideNonAtomic() {
  for(int i=myItems.size()-1; i >= 0; i--) {
    ComponentItem item = myItems.get(i);
    if (InsertComponentProcessor.getRadComponentFactory(myProject, item.getClassName()) != null || item.getBoundForm() != null) {
      myItems.remove(i);
    }
  }
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
private boolean checkAddModuleDependency(final ComponentItem item, final ModuleSourceOrderEntry moduleSourceOrderEntry) {
  final Module ownerModule = moduleSourceOrderEntry.getOwnerModule();
  int rc = Messages.showYesNoCancelDialog(
    myEditor,
    UIDesignerBundle.message("add.module.dependency.prompt", item.getClassName(), ownerModule.getName(), myEditor.getModule().getName()),
    UIDesignerBundle.message("add.module.dependency.title"),
    Messages.getQuestionIcon());
  if (rc == Messages.CANCEL) return false;
  if (rc == Messages.YES) {
    ModuleRootModificationUtil.addDependency(myEditor.getModule(), ownerModule);
  }
  return true;
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
private boolean validateNestedFormInsert(final ComponentItem item) {
  PsiFile boundForm = item.getBoundForm();
  if (boundForm != null) {
    try {
      final String formName = FormEditingUtil.buildResourceName(boundForm);
      final String targetForm = FormEditingUtil.buildResourceName(myEditor.getPsiFile());
      Utils.validateNestedFormLoop(formName, new PsiNestedFormLoader(myEditor.getModule()), targetForm);
    }
    catch (Exception ex) {
      Messages.showErrorDialog(myEditor, ex.getMessage(), CommonBundle.getErrorTitle());
      return false;
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
@Nullable
public static ComponentItem replaceAnyComponentItem(GuiEditor editor, ComponentItem item, final String title) {
  if (item.isAnyComponent()) {
    ComponentItem newItem = item.clone();
    ComponentItemDialog dlg = new ComponentItemDialog(editor.getProject(), editor, newItem, true);
    dlg.setTitle(title);
    if (!dlg.showAndGet()) {
      return null;
    }

    return newItem;
  }
  return item;
}
项目:intellij-ce-playground    文件:InsertComponentProcessor.java   
public Cursor processMouseMoveEvent(final MouseEvent e) {
  final ComponentItem componentItem = PaletteToolWindowManager.getInstance(myEditor).getActiveItem(ComponentItem.class);
  if (componentItem != null) {
    return myGridInsertProcessor.processMouseMoveEvent(e.getPoint(), false, new ComponentItemDragObject(componentItem));
  }
  return FormEditingUtil.getMoveNoDropCursor();
}
项目:intellij-ce-playground    文件:MainProcessor.java   
protected void processKeyEvent(final KeyEvent e){
  if (e.getKeyCode() == KeyEvent.VK_SHIFT) {
    if (e.getID() == KeyEvent.KEY_PRESSED) {
      if ((myCurrentProcessor != null && myCurrentProcessor.isDragActive()) ||
          (PaletteToolWindowManager.getInstance(myEditor).getActiveItem(ComponentItem.class) != null &&
           myCurrentProcessor != myInsertComponentProcessor)) {
        myEditor.setDesignTimeInsets(12);
      }
    }
    else {
      myEditor.setDesignTimeInsets(2);
    }
  }
  if (myCurrentProcessor != null) {
    myCurrentProcessor.processKeyEvent(e);
  }
  else if (e.getID() == KeyEvent.KEY_TYPED && Character.isLetterOrDigit(e.getKeyChar()) &&
    (e.getModifiers() & (InputEvent.ALT_MASK | InputEvent.CTRL_MASK | InputEvent.META_MASK)) == 0) {
    final ArrayList<RadComponent> selection = FormEditingUtil.getAllSelectedComponents(myEditor);
    if (selection.size() > 0) {
      final RadComponent component = selection.get(0);
      final InplaceEditingLayer inplaceLayer = myEditor.getInplaceEditingLayer();
      inplaceLayer.startInplaceEditing(component, component.getDefaultInplaceProperty(),
                                       component.getDefaultInplaceEditorBounds(), new InplaceContext(false, e.getKeyChar()));
      e.consume();
    }
  }
}