/** * ********************************************************************************* REQUIRED * METHODS FOR INTERFACES * ******************************************************************************** */ public void mouseClicked(MouseEvent e) { if (e.isConsumed()) { return; } TreePath path = ((JTree) e.getSource()).getClosestPathForLocation(e.getX(), e.getY()); ((TreeView) WorkspaceController.getCurrentModeExtension().getView()).addSelectionPath(path); if (path != null) { AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent(); // encode buttons int eventType = 0; if (e.getButton() == MouseEvent.BUTTON1) { eventType += WorkspaceActionEvent.MOUSE_LEFT; } if (e.getButton() == MouseEvent.BUTTON3) { eventType += WorkspaceActionEvent.MOUSE_RIGHT; } if (e.getClickCount() % 2 == 0) { eventType += WorkspaceActionEvent.MOUSE_DBLCLICK; } else { eventType += WorkspaceActionEvent.MOUSE_CLICK; } if (e.isPopupTrigger()) { eventType += WorkspaceActionEvent.POPUP_TRIGGER; } WorkspaceActionEvent event = new WorkspaceActionEvent(node, eventType, e.getX(), e.getY(), e.getComponent()); List<IWorkspaceNodeActionListener> nodeEventListeners = WorkspaceController.getCurrentModeExtension() .getIOController() .getNodeActionListeners(node.getClass(), eventType); if (nodeEventListeners != null) { for (IWorkspaceNodeActionListener listener : nodeEventListeners) { if (event.isConsumed()) { break; } listener.handleAction(event); } } if (!event.isConsumed() && node instanceof IWorkspaceNodeActionListener) { ((IWorkspaceNodeActionListener) node).handleAction(event); } } else { if (e.getButton() == MouseEvent.BUTTON3) { // WorkspaceController.getController().getPopups().showWorkspacePopup(e.getComponent(), // e.getX(), e.getY()); ((AWorkspaceTreeNode) WorkspaceController.getCurrentModel().getRoot()) .showPopup(e.getComponent(), e.getX(), e.getY()); } } }
/** * ********************************************************************************* REQUIRED * METHODS FOR INTERFACES * ******************************************************************************** */ public void handleAction(WorkspaceActionEvent event) { if (event.getType() == WorkspaceActionEvent.MOUSE_LEFT_DBLCLICK) { try { AWorkspaceProject project = WorkspaceController.getSelectedProject(this); File f = URIUtils.getAbsoluteFile(getLinkURI()); if (f == null) { return; } if (!f.exists()) { if (WorkspaceNewMapAction.createNewMap(project, f.toURI(), getName(), true) == null) { LogUtils.warn("could not create " + getLinkURI()); } } Controller.getCurrentController().selectMode(MModeController.MODENAME); final MapIO mapIO = (MapIO) MModeController.getMModeController().getExtension(MapIO.class); try { if (mapIO.newMap(f.toURI().toURL())) { DocearEvent evnt = new DocearEvent( this, (DocearWorkspaceProject) project, DocearEventType.NEW_MY_PUBLICATIONS, Controller.getCurrentController().getMap()); DocearController.getController().getEventQueue().dispatchEvent(evnt); } } catch (Exception e) { LogUtils.severe(e); return; } } catch (Exception e) { LogUtils.warn("could not open document (" + getLinkURI() + ")", e); } } else if (event.getType() == WorkspaceActionEvent.MOUSE_RIGHT_CLICK) { showPopup((Component) event.getBaggage(), event.getX(), event.getY()); } else { // do nth for now } }
/** * ********************************************************************************* REQUIRED * METHODS FOR INTERFACES * ******************************************************************************** */ public void handleAction(WorkspaceActionEvent event) { if (event.getType() == WorkspaceActionEvent.MOUSE_RIGHT_CLICK) { showPopup((Component) event.getBaggage(), event.getX(), event.getY()); } }