1 2 25 26 package org.aspectj.ajde.ui.swing; 27 28 import java.util.*; 29 import java.awt.Component ; 30 import java.awt.Color ; 31 import java.awt.Font ; 32 import java.awt.font.*; 33 import java.awt.event.*; 34 import javax.swing.*; 35 import javax.swing.tree.*; 36 import javax.swing.event.*; 37 import org.aspectj.ajde.Ajde; 38 import org.aspectj.asm.*; 39 import org.aspectj.asm.associations.*; 40 import org.aspectj.asm.views.*; 41 import org.aspectj.ajde.ui.*; 42 43 46 class BrowserViewTreeListener implements TreeSelectionListener, MouseListener { 47 private StructureTree tree = null; 48 49 public BrowserViewTreeListener(StructureTree tree) { 50 this.tree = tree; 51 } 52 53 public void valueChanged(TreeSelectionEvent e) { } 54 55 public void mouseEntered(MouseEvent e) { } 56 57 public void mouseExited(MouseEvent e) { } 58 59 public void mousePressed(MouseEvent e) { } 60 61 public void mouseReleased(MouseEvent e) { } 62 63 public void mouseClicked(MouseEvent e) { 64 singleClickNavigation(e); 65 maybeShowPopup(e); 67 } 68 69 public void singleClickNavigation(MouseEvent e) { 70 SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent(); 71 if (treeNode != null && !e.isControlDown() && !e.isShiftDown() && e.getModifiers() != 4) { 72 StructureNode currNode = (StructureNode)treeNode.getUserObject(); 73 if (currNode instanceof ProgramElementNode && !e.isControlDown() 74 && !e.isShiftDown() && e.getModifiers() != 4) { 75 } else if (currNode instanceof LinkNode) { 80 } 86 } 87 } 88 89 public void doubleClickNavigation(MouseEvent e) { 90 int clickCount = e.getClickCount(); 91 SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent(); 92 if (treeNode != null) { 93 StructureNode currNode = (StructureNode)treeNode.getUserObject(); 94 if (currNode instanceof ProgramElementNode && !e.isControlDown() && !e.isShiftDown() 95 && e.getModifiers() != 4) { 96 } else if (currNode instanceof LinkNode) { 99 if (clickCount == 1) { 100 } else if (clickCount == 2) { 102 } 104 } 105 } 106 } 107 108 113 private void maybeShowPopup(MouseEvent e) { 114 if (e.getModifiers() == e.BUTTON3_MASK && tree.getSelectionCount() > 0) { 115 TreePath[] selectionPaths = tree.getSelectionPaths(); 116 final List signatures = new ArrayList(); 117 for (int i = 0; i < selectionPaths.length; i++) { 118 StructureNode currNode = (StructureNode)((SwingTreeViewNode)selectionPaths[i].getLastPathComponent()).getUserObject(); 119 if (currNode instanceof LinkNode || currNode instanceof ProgramElementNode) { 120 signatures.add(currNode); 121 } 122 } 123 124 JPopupMenu popup = new JPopupMenu(); 125 JMenuItem showSourcesItem = new JMenuItem("Display sources", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.CODE)); 126 showSourcesItem.setFont(new java.awt.Font ("Dialog", 0, 11)); 127 showSourcesItem.addActionListener(new AbstractAction() { 128 public void actionPerformed(ActionEvent e) { 129 } 131 }); 132 popup.add(showSourcesItem); 133 134 popup.addSeparator(); 135 JMenuItem generatePCD = new JMenuItem("Pointcut Wizard (alpha)...", AjdeUIManager.getDefault().getIconRegistry().getStructureSwingIcon(ProgramElementNode.Kind.POINTCUT)); 136 generatePCD.setFont(new java.awt.Font ("Dialog", 0, 11)); 137 generatePCD.addActionListener(new AbstractAction() { 138 public void actionPerformed(ActionEvent e) { 139 AjdeUIManager.getDefault().getViewManager().extractAndInsertSignatures(signatures, true); 140 } 141 }); 142 popup.add(generatePCD); 143 144 popup.show(e.getComponent(), e.getX(), e.getY()); 145 } 146 } 147 } | Popular Tags |