public MainWatchPanel(Project project, DebuggerStateManager stateManager) { super(project, stateManager); final WatchDebuggerTree watchTree = getWatchTree(); final AnAction removeWatchesAction = ActionManager.getInstance().getAction(DebuggerActions.REMOVE_WATCH); removeWatchesAction.registerCustomShortcutSet(CommonShortcuts.DELETE, watchTree); final AnAction newWatchAction = ActionManager.getInstance().getAction(DebuggerActions.NEW_WATCH); newWatchAction.registerCustomShortcutSet(CommonShortcuts.INSERT, watchTree); final ClickListener mouseListener = new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent e) { AnAction editWatchAction = ActionManager.getInstance().getAction(DebuggerActions.EDIT_WATCH); Presentation presentation = editWatchAction.getTemplatePresentation().clone(); DataContext context = DataManager.getInstance().getDataContext(watchTree); AnActionEvent actionEvent = new AnActionEvent( null, context, "WATCH_TREE", presentation, ActionManager.getInstance(), 0); editWatchAction.actionPerformed(actionEvent); return true; } }; ListenerUtil.addClickListener(watchTree, mouseListener); final AnAction editWatchAction = ActionManager.getInstance().getAction(DebuggerActions.EDIT_WATCH); editWatchAction.registerCustomShortcutSet( new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), watchTree); registerDisposable( new Disposable() { public void dispose() { ListenerUtil.removeClickListener(watchTree, mouseListener); removeWatchesAction.unregisterCustomShortcutSet(watchTree); newWatchAction.unregisterCustomShortcutSet(watchTree); editWatchAction.unregisterCustomShortcutSet(watchTree); } }); DnDManager.getInstance() .registerTarget( new DnDNativeTarget() { public boolean update(final DnDEvent aEvent) { Object object = aEvent.getAttachedObject(); if (object == null) return true; String add = DebuggerBundle.message("watchs.add.text"); if (object.getClass().isArray()) { Class<?> type = object.getClass().getComponentType(); if (DebuggerTreeNodeImpl.class.isAssignableFrom(type)) { aEvent.setHighlighting( myTree, DnDEvent.DropTargetHighlightingType.RECTANGLE | DnDEvent.DropTargetHighlightingType.TEXT); aEvent.setDropPossible( add, new DropActionHandler() { public void performDrop(final DnDEvent aEvent) { addWatchesFrom((DebuggerTreeNodeImpl[]) aEvent.getAttachedObject()); } }); } } else if (object instanceof EventInfo) { EventInfo info = (EventInfo) object; final String text = info.getTextForFlavor(DataFlavor.stringFlavor); if (text != null) { aEvent.setHighlighting( myTree, DnDEvent.DropTargetHighlightingType.RECTANGLE | DnDEvent.DropTargetHighlightingType.TEXT); aEvent.setDropPossible( add, new DropActionHandler() { public void performDrop(final DnDEvent aEvent) { addWatchesFrom(text); } }); } } return true; } public void drop(final DnDEvent aEvent) {} public void cleanUpOnLeave() {} public void updateDraggedImage( final Image image, final Point dropPoint, final Point imageOffset) {} }, myTree); }