@Override public boolean update(DnDEvent aEvent) { aEvent.setDropPossible(false); aEvent.hideHighlighter(); final Object object = aEvent.getAttachedObject(); if (object instanceof PackagingElementDraggingObject) { final DefaultMutableTreeNode parent = findParentCompositeElementNode(aEvent.getRelativePoint().getPoint(myTree)); if (parent != null) { final PackagingElementDraggingObject draggingObject = (PackagingElementDraggingObject)object; final PackagingElementNode node = getNode(parent); if (node != null && draggingObject.canDropInto(node)) { final PackagingElement element = node.getFirstElement(); if (element instanceof CompositePackagingElement) { draggingObject.setTargetNode(node); draggingObject.setTargetElement((CompositePackagingElement<?>)element); final Rectangle bounds = myTree.getPathBounds(TreeUtil.getPathFromRoot(parent)); aEvent.setHighlighting(new RelativeRectangle(myTree, bounds), DnDEvent.DropTargetHighlightingType.RECTANGLE); aEvent.setDropPossible(true); } } } } return false; }
private void highlight(FavoritesListNode node, DnDEvent event) { if (node != null) { TreePath pathToList = myTree.getPath(node); while (pathToList != null) { final Object pathObj = pathToList.getLastPathComponent(); if (pathObj instanceof DefaultMutableTreeNode) { final Object userObject = ((DefaultMutableTreeNode)pathObj).getUserObject(); if (userObject instanceof FavoritesTreeNodeDescriptor) { if (((FavoritesTreeNodeDescriptor)userObject).getElement() == node) { break; } } } pathToList = pathToList.getParentPath(); } if (pathToList != null) { Rectangle bounds = myTree.getPathBounds(pathToList); if (bounds != null) { event.setHighlighting(new RelativeRectangle(myTree, bounds), DnDEvent.DropTargetHighlightingType.RECTANGLE); } } } else { event.hideHighlighter(); } }
@Override public RelativeRectangle getRectangle() { TabLabel label = myInfo2Label.get(myInfo); if (label.getRootPane() == null) return null; Rectangle b = label.getBounds(); b.x += 2; b.width -= 4; b.y += 2; b.height -= 4; return new RelativeRectangle(label.getParent(), b); }
@NotNull @Override public DockContainer.ContentResponse getResponse(MouseEvent e) { RelativePoint point = new RelativePoint(e); for (DockContainer each : myContainers) { RelativeRectangle rec = each.getAcceptArea(); if (rec.contains(point)) { DockContainer.ContentResponse response = each.getContentResponse(myContent, point); if (response.canAccept()) { return response; } } } return DockContainer.ContentResponse.DENY; }
@Override public boolean update(DnDEvent aEvent) { aEvent.hideHighlighter(); aEvent.setDropPossible(false, ""); Object attached = aEvent.getAttachedObject(); if (!(attached instanceof ChangeListDragBean)) return false; final ChangeListDragBean dragBean = (ChangeListDragBean)attached; if (dragBean.getSourceComponent() != ChangesListView.this) return false; dragBean.setTargetNode(null); RelativePoint dropPoint = aEvent.getRelativePoint(); Point onTree = dropPoint.getPoint(ChangesListView.this); final TreePath dropPath = getPathForLocation(onTree.x, onTree.y); if (dropPath == null) return false; ChangesBrowserNode dropNode = (ChangesBrowserNode)dropPath.getLastPathComponent(); while(!((ChangesBrowserNode) dropNode.getParent()).isRoot()) { dropNode = (ChangesBrowserNode)dropNode.getParent(); } if (!dropNode.canAcceptDrop(dragBean)) { return false; } final Rectangle tableCellRect = getPathBounds(new TreePath(dropNode.getPath())); if (fitsInBounds(tableCellRect)) { aEvent.setHighlighting(new RelativeRectangle(ChangesListView.this, tableCellRect), DnDEvent.DropTargetHighlightingType.RECTANGLE); } aEvent.setDropPossible(true); dragBean.setTargetNode(dropNode); return false; }
@Nullable private DockContainer findContainerFor(RelativePoint point, @NotNull DockableContent content) { for (DockContainer each : myContainers) { RelativeRectangle rec = each.getAcceptArea(); if (rec.contains(point) && each.getContentResponse(content, point).canAccept()) { return each; } } return null; }
@Nonnull @Override public DockContainer.ContentResponse getResponse(MouseEvent e) { RelativePoint point = new RelativePoint(e); for (DockContainer each : myContainers) { RelativeRectangle rec = each.getAcceptArea(); if (rec.contains(point)) { DockContainer.ContentResponse response = each.getContentResponse(myContent, point); if (response.canAccept()) { return response; } } } return DockContainer.ContentResponse.DENY; }
@Override public boolean update(DnDEvent aEvent) { aEvent.hideHighlighter(); aEvent.setDropPossible(false, ""); Object attached = aEvent.getAttachedObject(); if (!(attached instanceof ChangeListDragBean)) return false; final ChangeListDragBean dragBean = (ChangeListDragBean)attached; if (dragBean.getSourceComponent() != myTree) return false; dragBean.setTargetNode(null); RelativePoint dropPoint = aEvent.getRelativePoint(); Point onTree = dropPoint.getPoint(myTree); final TreePath dropPath = myTree.getPathForLocation(onTree.x, onTree.y); if (dropPath == null) return false; ChangesBrowserNode dropNode = (ChangesBrowserNode)dropPath.getLastPathComponent(); while (!((ChangesBrowserNode)dropNode.getParent()).isRoot()) { dropNode = (ChangesBrowserNode)dropNode.getParent(); } if (!dropNode.canAcceptDrop(dragBean)) { return false; } final Rectangle tableCellRect = myTree.getPathBounds(new TreePath(dropNode.getPath())); if (fitsInBounds(tableCellRect)) { aEvent.setHighlighting(new RelativeRectangle(myTree, tableCellRect), DnDEvent.DropTargetHighlightingType.RECTANGLE); } aEvent.setDropPossible(true); dragBean.setTargetNode(dropNode); return false; }
@Override public RelativeRectangle getRectangleFor(Content content) { return null; }
public RelativeRectangle getRectangle() { return myTabsLayout.getRectangleFor(myContent); }
@Override public RelativeRectangle getRectangleFor(Content content) { ContentTabLabel label = myContent2Tabs.get(content); return new RelativeRectangle(label.getParent(), label.getBounds()); }
@Override public RelativeRectangle getAcceptArea() { return new RelativeRectangle(mySplitters); }
public RelativeRectangle getAcceptAreaFallback() { JRootPane root = mySplitters.getRootPane(); return root != null ? new RelativeRectangle(root) : new RelativeRectangle(mySplitters); }
@Override public RelativeRectangle getRectangle() { return new RelativeRectangle(myButton.getParent(), myButton.getBounds()); }
public void setHighlighting(RelativeRectangle rectangle, int aType) { getHandlerComponent(); myManager.showHighlighter(rectangle, aType, this); myHighlighting = aType; }
public void setHighlighting(JLayeredPane layeredPane, RelativeRectangle rectangle, int aType) { myManager.showHighlighter(layeredPane, rectangle, aType, this); }
void showHighlighter(final RelativeRectangle rectangle, final int aType, final DnDEvent aEvent) { final JLayeredPane layeredPane = getLayeredPane(rectangle.getPoint().getComponent()); final Rectangle bounds = rectangle.getRectangleOn(layeredPane); showHighlighter(layeredPane, aEvent, bounds, aType); }
void showHighlighter(JLayeredPane layeredPane, final RelativeRectangle rectangle, final int aType, final DnDEvent event) { final Rectangle bounds = rectangle.getRectangleOn(layeredPane); showHighlighter(layeredPane, event, bounds, aType); }
@Override public RelativeRectangle getAcceptArea() { return new RelativeRectangle(myTabs.getComponent()); }
@Override public RelativeRectangle getAcceptAreaFallback() { return getAcceptArea(); }
@Override public RelativeRectangle getAcceptArea() { return new RelativeRectangle(myTree); }
@Override public boolean update(DnDEvent event) { event.setDropPossible(false, ""); final Object attached = event.getAttachedObject(); final int dropAction = event.getAction().getActionId(); final DropHandler dropHandler = getDropHandler(dropAction); final TreeNode[] sourceNodes = getSourceNodes(attached); final Point point = event.getPoint(); final TreeNode targetNode = getTargetNode(point); if (targetNode == null || (dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0 || sourceNodes == null && !FileCopyPasteUtil.isFileListFlavorAvailable(event) || sourceNodes != null && ArrayUtilRt.find(sourceNodes, targetNode) != -1 || sourceNodes != null && !dropHandler.isValidSource(sourceNodes, targetNode)) { return false; } if (sourceNodes != null) { boolean redundant = true; for (TreeNode sourceNode : sourceNodes) { if (!dropHandler.isDropRedundant(sourceNode, targetNode)) { redundant = false; break; } } if (redundant) return false; } else { // it seems like it's not possible to obtain dragged items _before_ accepting _drop_ on Macs, so just skip this check if (!SystemInfo.isMac) { final PsiFileSystemItem[] psiFiles = getPsiFiles(FileCopyPasteUtil.getFileListFromAttachedObject(attached)); if (psiFiles == null || psiFiles.length == 0) return false; if (!MoveHandler.isValidTarget(getPsiElement(targetNode), psiFiles)) return false; } } final Rectangle pathBounds = myTree.getPathBounds(myTree.getClosestPathForLocation(point.x, point.y)); if (pathBounds != null && pathBounds.y + pathBounds.height < point.y) return false; event.setHighlighting(new RelativeRectangle(myTree, pathBounds), DnDEvent.DropTargetHighlightingType.RECTANGLE); event.setDropPossible(true); return false; }
@Override public RelativeRectangle getAcceptArea() { return new RelativeRectangle(myTerminalToolWindow.getComponent()); }
@Override public RelativeRectangle getAcceptArea() { JRootPane root = mySplitters.getRootPane(); return root != null ? new RelativeRectangle(root) : new RelativeRectangle(mySplitters); }