예제 #1
0
 @Nullable
 public Object getData(String dataId) {
   Object data = myPaletteWindow.getData(dataId);
   if (data != null) return data;
   Project project = CommonDataKeys.PROJECT.getData(myPaletteWindow);
   return myGroup.getData(project, dataId);
 }
예제 #2
0
 public void showGroupPopupMenu(final Component comp, final int x, final int y) {
   ActionGroup group = myGroup.getPopupActionGroup();
   if (group != null) {
     ActionPopupMenu popupMenu =
         ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group);
     popupMenu.getComponent().show(comp, x, y);
   }
 }
예제 #3
0
  public PaletteGroupHeader(PaletteWindow paletteWindow, PaletteGroup group) {
    myPaletteWindow = paletteWindow;
    myGroup = group;
    if (group.getName() == null) {
      setVisible(false);
    } else {
      setText(group.getName());
    }
    setSelected(true);
    addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (myComponentList != null) {
              myComponentList.setVisible(isSelected());
            }
          }
        });

    addMouseListener(
        new PopupHandler() {
          public void invokePopup(Component comp, int x, int y) {
            myPaletteWindow.setLastFocusedGroup(PaletteGroupHeader.this);
            showGroupPopupMenu(comp, x, y);
          }
        });

    setIcon(UIUtil.getTreeCollapsedIcon());
    setSelectedIcon(UIUtil.getTreeExpandedIcon());
    setFont(getFont().deriveFont(Font.BOLD));
    setFocusPainted(false);
    setMargin(new Insets(0, 3, 0, 3));
    setOpaque(true);
    if (getBorder() instanceof CompoundBorder) { // from BasicLookAndFeel
      Dimension pref = getPreferredSize();
      pref.height -= 3;
      setPreferredSize(pref);
    }

    DnDManager.getInstance()
        .registerTarget(
            new DnDTarget() {
              public boolean update(DnDEvent aEvent) {
                setBorderPainted(true);
                aEvent.setDropPossible(aEvent.getAttachedObject() instanceof PaletteItem);
                return true;
              }

              public void drop(DnDEvent aEvent) {
                setBorderPainted(false);
                if (aEvent.getAttachedObject() instanceof PaletteItem) {
                  myGroup.handleDrop(
                      myPaletteWindow.getProject(), (PaletteItem) aEvent.getAttachedObject(), -1);
                }
              }

              public void cleanUpOnLeave() {
                setBorderPainted(false);
              }

              public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) {}
            },
            this);

    addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            myPaletteWindow.setLastFocusedGroup(PaletteGroupHeader.this);
          }
        });

    initActions();
  }