コード例 #1
0
    public void mouseClicked(MouseEvent e) {
      JTableHeader h = (JTableHeader) e.getSource();
      TableColumnModel columnModel = h.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = columnModel.getColumn(viewColumn).getModelIndex();
      if (column != -1) {
        sorting_column = column;

        // 0 == priority icon column
        // 4 == priority text column
        if (column == 0) sorting_column = 4;

        if (e.isControlDown()) sorting_column = -1;
        else opposite = !opposite;

        TaskTable treetable = ((TaskTable) h.getTable());

        // java.util.Collection expanded = treetable.getExpandedTreeNodes();

        treetable.tableChanged();
        // treetable.setExpandedTreeNodes(expanded);
        // h.updateUI();
        h.resizeAndRepaint();
      }
    }
コード例 #2
0
    public void mouseClicked(MouseEvent e) {
      int selRow = tree.getRowForLocation(e.getX(), e.getY());
      TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());

      if (e.getClickCount() == 2) {
        myDoubleClick(selRow, selPath);
      }
    }
コード例 #3
0
 /**
  * Handles mouse moved events.
  *
  * @param e the mouse event
  */
 public void mouseMoved(MouseEvent e) {
   TreePath path = tree.getPathForLocation(e.getX(), e.getY());
   if (path == null) return;
   if (e.getX() > tree.getPathBounds(path).x + hotspot - 3
       || e.getX() < tree.getPathBounds(path).x + 2) tree.setCursor(Cursor.getDefaultCursor());
   else {
     tree.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   }
 }
コード例 #4
0
ファイル: ClutoTree.java プロジェクト: hiralv/TableViewNew
 public void mousePressed(MouseEvent e) {
   if (ctx != null) {
     // save the current selection set operator
     prevSetOp = ctx.getSetOperator(tm).getSetOperator();
     // set the selection set operator
     ctx.getSetOperator(tm).setFromInputEventMask(e.getModifiers());
   }
   start = e.getPoint();
   current = e.getPoint();
   selecting = true;
   repaint();
 }
コード例 #5
0
ファイル: HyperSearchResults.java プロジェクト: SELab/jEdit
    // {{{ mousePressed() method
    @Override
    public void mousePressed(MouseEvent evt) {
      if (evt.isConsumed()) return;

      TreePath path1 = resultTree.getPathForLocation(evt.getX(), evt.getY());
      if (path1 == null) return;

      resultTree.setSelectionPath(path1);
      if (GUIUtilities.isPopupTrigger(evt)) showPopupMenu(evt);
      else {
        goToSelectedNode(M_OPEN);
      }
    } // }}}
コード例 #6
0
ファイル: ClutoTree.java プロジェクト: hiralv/TableViewNew
 public void mouseReleased(MouseEvent e) {
   current = e.getPoint();
   // intersect with graph
   Rectangle selrect =
       new Rectangle(start.x, start.y, current.x - start.x, current.y - start.y);
   int[] gi = gs.getIndicesAt(selrect, graph.getXAxis(), graph.getYAxis());
   DefaultListSelectionModel rsm = new DefaultListSelectionModel();
   if (gi != null) {
     rsm.setValueIsAdjusting(true);
     for (int j = 0; j < gi.length; j++) {
       // find node and select segs for node and all descendents
       int nodeidx = gi[j] / 2;
       TreeNode tn = nodemap[nodeidx];
       selectTraverse(tn, rsm);
     }
     rsm.setValueIsAdjusting(false);
   }
   if (ctx != null) {
     // Merge this selection with the table selection list
     // using the current set selection operator
     ColumnMap cmap = ctx.getColumnMap(tm, 0);
     if (cmap != null) {
       cmap.selectValues(rsm);
     }
   }
   if (ctx != null) {
     // restore the original selection set operator
     ctx.getSetOperator(tm).setSetOperator(prevSetOp);
   }
   repaint();
 }
コード例 #7
0
  /**
   * Handles mouse click events.
   *
   * @param e the mouse event
   */
  public void mouseClicked(MouseEvent e) {
    TreePath path = tree.getPathForLocation(e.getX(), e.getY());
    if (path == null) return;
    if (e.getX() > tree.getPathBounds(path).x + hotspot) return;

    boolean selected = selectionModel.isAncestorSelected(path);
    try {
      ignoreEvents = true;
      if (selected) {
        selectionModel.removeSelectionPath(path);
      } else {
        selectionModel.addSelectionPath(path);
      }
    } finally {
      ignoreEvents = false;
      tree.treeDidChange();
    }
  }
コード例 #8
0
    public void mouseReleased(MouseEvent e) {
      if (e.isPopupTrigger()) {
        DefaultTreeModel model = (DefaultTreeModel) m_tree.getModel();
        TreePath path = m_tree.getSelectionPath();
        if (path != null) {
          DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

          if (node == model.getRoot()) {
            mi_add.setEnabled(true);
            mi_edit.setEnabled(false);
            mi_delete.setEnabled(false);
          } else {
            mi_add.setEnabled(true);
            mi_edit.setEnabled(true);
            mi_delete.setEnabled(true);
          }

          Rectangle rectangle = m_tree.getPathBounds(path);
          if (rectangle.contains(e.getPoint())) m_popupMenu.show(m_tree, e.getX(), e.getY());
        }
      }
    }
コード例 #9
0
 @Override
 public boolean isCellEditable(EventObject e) {
   if (e instanceof MouseEvent && e.getSource() instanceof JTree) {
     MouseEvent me = (MouseEvent) e;
     JTree tree = (JTree) e.getSource();
     TreePath path = tree.getPathForLocation(me.getX(), me.getY());
     Rectangle r = tree.getPathBounds(path);
     if (r == null) {
       return false;
     }
     Dimension d = getPreferredSize();
     r.setSize(new Dimension(d.width, r.height));
     if (r.contains(me.getX(), me.getY())) {
       if (str == null && System.getProperty("java.version").startsWith("1.7.0")) {
         setBounds(new Rectangle(0, 0, d.width, r.height));
       }
       // System.out.println(getBounds());
       return true;
     }
   }
   return false;
 }
コード例 #10
0
ファイル: HyperSearchResults.java プロジェクト: SELab/jEdit
    // {{{ showPopupMenu method
    private void showPopupMenu(MouseEvent evt) {
      TreePath path = resultTree.getSelectionPath();
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();

      popupMenu = new JPopupMenu();
      Object userObj = node.getUserObject();
      if (userObj instanceof HyperSearchFileNode || userObj instanceof HyperSearchResult) {
        popupMenu.add(new GoToNodeAction("hypersearch-results.open", M_OPEN));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-view", M_OPEN_NEW_VIEW));
        popupMenu.add(
            new GoToNodeAction("hypersearch-results.open-plain-view", M_OPEN_NEW_PLAIN_VIEW));
        popupMenu.add(new GoToNodeAction("hypersearch-results.open-split", M_OPEN_NEW_SPLIT));
      }
      if (!(userObj instanceof HyperSearchFolderNode)) popupMenu.add(new RemoveTreeNodeAction());
      popupMenu.add(new ExpandChildTreeNodesAction());
      if (userObj instanceof HyperSearchFolderNode || userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new CollapseChildTreeNodesAction());
        if (userObj instanceof HyperSearchFolderNode) popupMenu.add(new NewSearchAction());
      }
      if (userObj instanceof HyperSearchOperationNode) {
        popupMenu.add(new JPopupMenu.Separator());
        HyperSearchOperationNode resultNode = (HyperSearchOperationNode) userObj;
        JCheckBoxMenuItem chkItem =
            new JCheckBoxMenuItem(
                jEdit.getProperty("hypersearch-results.tree-view"),
                resultNode.isTreeViewDisplayed());
        chkItem.addActionListener(new TreeDisplayAction());
        popupMenu.add(chkItem);

        popupMenu.add(new RedoSearchAction((HyperSearchOperationNode) userObj));
      }
      popupMenu.add(new CopyToClipboardAction());

      GUIUtilities.showPopupMenu(popupMenu, evt.getComponent(), evt.getX(), evt.getY());
      evt.consume();
    } // }}}