public static void removeNode(ReportTreeNode node) { TestElement testElement = node.getTestElement(); if (testElement.canRemove()) { ReportGuiPackage.getInstance().getTreeModel().removeNodeFromParent(node); ReportGuiPackage.getInstance().removeNode(testElement); } else { String message = testElement.getClass().getName() + " is busy"; JOptionPane.showMessageDialog(null, message, "Cannot remove item", JOptionPane.ERROR_MESSAGE); } }
@Override public void mousePressed(MouseEvent e) { // Get the Main Frame. ReportMainFrame mainFrame = ReportGuiPackage.getInstance().getMainFrame(); // Close any Main Menu that is open mainFrame.closeMenu(); int selRow = tree.getRowForLocation(e.getX(), e.getY()); if (tree.getPathForLocation(e.getX(), e.getY()) != null) { log.debug("mouse pressed, updating currentPath"); currentPath = tree.getPathForLocation(e.getX(), e.getY()); } if (selRow != -1) { // updateMainMenu(((JMeterGUIComponent) // getCurrentNode().getUserObject()).createPopupMenu()); if (isRightClick(e)) { if (tree.getSelectionCount() < 2) { tree.setSelectionPath(currentPath); } if (getCurrentNode() != null) { log.debug("About to display pop-up"); displayPopUp(e); } } } }
@Override public void mouseReleased(MouseEvent e) { if (dragging && isValidDragAction(draggedNodes, getCurrentNode())) { dragging = false; JPopupMenu dragNdrop = new JPopupMenu(); JMenuItem item = new JMenuItem(JMeterUtils.getResString("insert_before")); // $NON-NLS-1$ item.addActionListener(actionHandler); item.setActionCommand(ReportDragNDrop.INSERT_BEFORE); dragNdrop.add(item); item = new JMenuItem(JMeterUtils.getResString("insert_after")); // $NON-NLS-1$ item.addActionListener(actionHandler); item.setActionCommand(ReportDragNDrop.INSERT_AFTER); dragNdrop.add(item); item = new JMenuItem(JMeterUtils.getResString("add_as_child")); // $NON-NLS-1$ item.addActionListener(actionHandler); item.setActionCommand(ReportDragNDrop.ADD); dragNdrop.add(item); dragNdrop.addSeparator(); item = new JMenuItem(JMeterUtils.getResString("cancel")); // $NON-NLS-1$ dragNdrop.add(item); displayPopUp(e, dragNdrop); } else { ReportGuiPackage.getInstance().getMainFrame().repaint(); } dragging = false; }
private void changeSelectionIfDragging(MouseEvent e) { if (dragging) { ReportGuiPackage.getInstance() .getMainFrame() .drawDraggedComponent(dragIcon, e.getX(), e.getY()); if (tree.getPathForLocation(e.getX(), e.getY()) != null) { currentPath = tree.getPathForLocation(e.getX(), e.getY()); if (!contains(draggedNodes, getCurrentNode())) { tree.setSelectionPath(currentPath); } } } }
public void doAction(ActionEvent e) { ReportActionRouter.getInstance() .actionPerformed(new ActionEvent(e.getSource(), e.getID(), ReportCheckDirty.REMOVE)); ReportGuiPackage guiPackage = ReportGuiPackage.getInstance(); ReportTreeNode[] nodes = guiPackage.getTreeListener().getSelectedNodes(); TreePath newTreePath = // Save parent node for later guiPackage.getTreeListener().removedSelectedNode(); for (int i = nodes.length - 1; i >= 0; i--) { removeNode(nodes[i]); } guiPackage.getTreeListener().getJTree().setSelectionPath(newTreePath); guiPackage.updateCurrentGui(); }
private void displayPopUp(MouseEvent e) { JPopupMenu pop = getCurrentNode().createPopupMenu(); ReportGuiPackage.getInstance().displayPopUp(e, pop); }