public SuggestionPanel(JTextArea textarea, int position, String subWord, Point location) { this.insertionPosition = position; this.subWord = subWord; popupMenu = new JPopupMenu(); popupMenu.removeAll(); popupMenu.setOpaque(false); popupMenu.setBorder(null); popupMenu.add(list = createSuggestionList(position, subWord), BorderLayout.CENTER); popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y); }
private void createPopupMenus() { // menu myPopup = new JPopupMenu(); JMenuItem mi = new JMenuItem("Save"); mi.addActionListener(this); mi.setActionCommand("save"); myPopup.add(mi); mi = new JMenuItem("Print"); mi.addActionListener(this); mi.setActionCommand("print"); myPopup.add(mi); // myPopup.addSeparator(); // // gridMi = new JMenuItem("Turn Off Grid"); // gridMi.addActionListener(this); // gridMi.setActionCommand("grid"); // myPopup.add(gridMi); // myPopup.setOpaque(true); myPopup.setLightWeightPopupEnabled(true); }
public void initializeGUI() { setTitle(frameTitle); setSize(detailsFrameXsize, detailsFrameYsize); setLocation(detailsFrameXlocation, detailsFrameYlocation); treemodel = new DefaultTreeModel(new DefaultMutableTreeNode("LSM File Information")); detailsTree = new JTree(treemodel); detailsTree.putClientProperty("JTree.lineStyle", "Angled"); detailsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); detailsTree.setShowsRootHandles(true); tablemodel = new TreeTableModel(); table = new JTable(tablemodel); table.setCellSelectionEnabled(true); JScrollPane treepane = new JScrollPane(detailsTree); JScrollPane detailspane = new JScrollPane(table); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treepane, detailspane); splitPane.setBorder(null); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(300); Dimension minimumSize = new Dimension(WIDTH, HEIGHT - 50); treepane.setMinimumSize(minimumSize); detailspane.setMinimumSize(minimumSize); exitButton = new JButton(new ImageIcon(getClass().getResource("images/exit.png"))); exitButton.setToolTipText("Close this window"); searchButton = new JButton(new ImageIcon(getClass().getResource("images/find.png"))); searchButton.setToolTipText("Find tag, property or value"); filterButton = new JToggleButton(new ImageIcon(getClass().getResource("images/filter.png"))); filterButton.setToolTipText("Filter unused tags"); dumpButton = new JButton(new ImageIcon(getClass().getResource("images/dump.png"))); dumpButton.setToolTipText("Dump data to textwindow, saving to text file is possible"); xmlButton = new JButton(new ImageIcon(getClass().getResource("images/xml.png"))); xmlButton.setToolTipText("Dump xml data to textwindow, saving to text file is possible"); searchTF = new JTextField(""); detailsTreePopupMenu = new JPopupMenu(); expandAllItem = new JMenuItem("Expand all", new ImageIcon(getClass().getResource("images/plus.png"))); collapseAllItem = new JMenuItem("Collapse all", new ImageIcon(getClass().getResource("images/minus.png"))); filterCBItem = new JCheckBoxMenuItem( "Filtered", new ImageIcon(getClass().getResource("images/filter.png"))); detailsTreePopupMenu.add(expandAllItem); detailsTreePopupMenu.add(collapseAllItem); detailsTreePopupMenu.add(new JSeparator()); detailsTreePopupMenu.add(filterCBItem); detailsTreePopupMenu.setOpaque(true); detailsTree.add(detailsTreePopupMenu); detailsTree.setExpandsSelectedPaths(true); toolBar = new JToolBar(); toolBar.add(exitButton); toolBar.add(dumpButton); toolBar.add(xmlButton); toolBar.add(filterButton); toolBar.add(new JSeparator()); toolBar.add(new JLabel(" Search: ")); toolBar.add(searchTF); toolBar.add(searchButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(toolBar, BorderLayout.NORTH); getContentPane().add(splitPane, BorderLayout.CENTER); // filterCBItem.setSelected(true); // filterButton.setSelected(true); pack(); centerWindow(); setListeners(); }
public JSVNTree(SVNTreeModel root) { this.setModel(new DefaultTreeModel(buildTreeNode(root).getRoot())); // define the mainPopup mainPopup = new JPopupMenu(); miAdd = new JMenuItem(ACTION_ADD); miAdd.addActionListener(this); miAdd.setActionCommand(ACTION_ADD); mainPopup.add(miAdd); miCat = new JMenuItem(ACTION_CAT); miCat.addActionListener(this); miCat.setActionCommand(ACTION_CAT); miCat.setEnabled(true); mainPopup.add(miCat); miCheckout = new JMenuItem(ACTION_CHECKOUT); miCheckout.addActionListener(this); miCheckout.setActionCommand(ACTION_CHECKOUT); miCheckout.setEnabled(true); mainPopup.add(miCheckout); miCleanup = new JMenuItem(ACTION_CLEANUP); miCleanup.addActionListener(this); miCleanup.setActionCommand(ACTION_CLEANUP); miCleanup.setEnabled(true); mainPopup.add(miCleanup); miCommit = new JMenuItem(ACTION_COMMIT); miCommit.addActionListener(this); miCommit.setActionCommand(ACTION_COMMIT); mainPopup.add(miCommit); miCopy = new JMenuItem(ACTION_COPY); miCopy.addActionListener(this); miCopy.setActionCommand(ACTION_COPY); miCopy.setEnabled(true); mainPopup.add(miCopy); miDelete = new JMenuItem(ACTION_DELETE); miDelete.addActionListener(this); miDelete.setActionCommand(ACTION_DELETE); miDelete.setEnabled(true); mainPopup.add(miDelete); miDiff = new JMenuItem(ACTION_DIFF); miDiff.addActionListener(this); miDiff.setActionCommand(ACTION_DIFF); mainPopup.add(miDiff); miImport = new JMenuItem(ACTION_IMPORT); miImport.addActionListener(this); miImport.setActionCommand(ACTION_IMPORT); miImport.setEnabled(false); mainPopup.add(miImport); miMerge = new JMenuItem(ACTION_MERGE); miMerge.addActionListener(this); miMerge.setActionCommand(ACTION_MERGE); miMerge.setEnabled(true); mainPopup.add(miMerge); miMkDir = new JMenuItem(ACTION_MKDIR); miMkDir.addActionListener(this); miMkDir.setActionCommand(ACTION_MKDIR); miMkDir.setEnabled(false); mainPopup.add(miMkDir); miMove = new JMenuItem(ACTION_MOVE); miMove.addActionListener(this); miMove.setActionCommand(ACTION_MOVE); miMove.setEnabled(true); mainPopup.add(miMove); miResolve = new JMenuItem(ACTION_RESOLVE); miResolve.addActionListener(this); miResolve.setActionCommand(ACTION_RESOLVE); miResolve.setEnabled(true); mainPopup.add(miResolve); miRevert = new JMenuItem(ACTION_REVERT); miRevert.addActionListener(this); miRevert.setActionCommand(ACTION_REVERT); miRevert.setEnabled(true); mainPopup.add(miRevert); miSwitch = new JMenuItem(ACTION_SWITCH); miSwitch.addActionListener(this); miSwitch.setActionCommand(ACTION_SWITCH); miSwitch.setEnabled(true); mainPopup.add(miSwitch); miUpdate = new JMenuItem(ACTION_UPDATE); miUpdate.addActionListener(this); miUpdate.setActionCommand(ACTION_UPDATE); miUpdate.setEnabled(true); mainPopup.add(miUpdate); mainPopup.add(new JPopupMenu.Separator()); miInfo = new JMenuItem(ACTION_INFO); miInfo.addActionListener(this); miInfo.setActionCommand(ACTION_INFO); mainPopup.add(miInfo); miLog = new JMenuItem(ACTION_LOG); miLog.addActionListener(this); miLog.setActionCommand(ACTION_LOG); mainPopup.add(miLog); miLs = new JMenuItem(ACTION_LS); miLs.addActionListener(this); miLs.setActionCommand(ACTION_LS); mainPopup.add(miLs); miStatus = new JMenuItem(ACTION_STATUS); miStatus.addActionListener(this); miStatus.setActionCommand(ACTION_STATUS); mainPopup.add(miStatus); // define property menu mainPopup.add(new JPopupMenu.Separator()); JMenu propertyMenu = new JMenu(ACTION_PROPERTY); miPropList = new JMenuItem(ACTION_PROPLIST); miPropList.addActionListener(this); miPropList.setActionCommand(ACTION_PROPLIST); miPropList.setEnabled(false); propertyMenu.add(miPropList); miPropGet = new JMenuItem(ACTION_PROPGET); miPropGet.addActionListener(this); miPropGet.setActionCommand(ACTION_PROPGET); miPropGet.setEnabled(false); propertyMenu.add(miPropGet); miPropSet = new JMenuItem(ACTION_PROPSET); miPropSet.addActionListener(this); miPropSet.setActionCommand(ACTION_PROPSET); miPropSet.setEnabled(false); propertyMenu.add(miPropSet); miPropEdit = new JMenuItem(ACTION_PROPEDIT); miPropEdit.addActionListener(this); miPropEdit.setActionCommand(ACTION_PROPEDIT); miPropEdit.setEnabled(false); propertyMenu.add(miPropEdit); miPropDel = new JMenuItem(ACTION_PROPDEL); miPropDel.addActionListener(this); miPropDel.setActionCommand(ACTION_PROPDEL); miPropDel.setEnabled(false); propertyMenu.add(miPropDel); mainPopup.add(propertyMenu); mainPopup.add(new JPopupMenu.Separator()); JMenu refreshMenu = new JMenu(ACTION_REFRESH_RECURSIVELY); miRefreshOffline = new JMenuItem(ACTION_REFRESH_OFFLINE); miRefreshOffline.addActionListener(this); miRefreshOffline.setActionCommand(ACTION_REFRESH_OFFLINE); refreshMenu.add(miRefreshOffline); miRefreshOnline = new JMenuItem(ACTION_REFRESH_ONLINE); miRefreshOnline.addActionListener(this); miRefreshOnline.setActionCommand(ACTION_REFRESH_ONLINE); refreshMenu.add(miRefreshOnline); mainPopup.add(refreshMenu); mainPopup.setOpaque(true); mainPopup.setLightWeightPopupEnabled(true); addMouseListener( new MouseAdapter() { private void popup(MouseEvent e) { if (e.isPopupTrigger() && (getSelectedTargetsAsString() != null)) { // These can't operate on multi selections if (getSelectedTargetsAsArray().length > 1) { miCat.setEnabled(false); miCopy.setEnabled(false); miMerge.setEnabled(false); miMove.setEnabled(false); } else { // Turn them back on miCat.setEnabled(true); miCopy.setEnabled(true); miMerge.setEnabled(true); miMove.setEnabled(true); } mainPopup.show((JComponent) e.getSource(), e.getX(), e.getY()); } } public void mousePressed(MouseEvent e) { popup(e); } public void mouseClicked(MouseEvent e) { popup(e); } public void mouseReleased(MouseEvent e) { popup(e); } }); // register the tree cell renderer setCellRenderer(new JSVNTreeCellRenderer()); // register tree component with tooltip manager ToolTipManager.sharedInstance().registerComponent(this); }