Java Code Examples for javax.swing.tree.DefaultTreeSelectionModel#setSelectionMode()

The following examples show how to use javax.swing.tree.DefaultTreeSelectionModel#setSelectionMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PullRequestsTreeModel.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
public PullRequestsTreeModel() {
    super(null);

    this.root = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_TITLE));
    setRoot(root);
    this.requestedByMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_REQUESTED_BY_ME));
    root.insert(requestedByMeRoot, 0);
    this.assignedToMeRoot = new PRTreeNode(TfPluginBundle.message(TfPluginBundle.KEY_VCS_PR_ASSIGNED_TO_ME));
    root.insert(assignedToMeRoot, 1);

    allRequestedByMePullRequests = new ArrayList<GitPullRequest>();
    allAssignedToMePullRequests = new ArrayList<GitPullRequest>();

    selectionModel = new DefaultTreeSelectionModel();
    selectionModel.setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
}
 
Example 2
Source File: ActiveConnectionPanel.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
private void setup() {
    root = new JPanel(new BorderLayout());
    JScrollPane scroll = new JBScrollPane();
    root.add(scroll, BorderLayout.CENTER);
    connectionTree = new Tree();
    scroll.setViewportView(connectionTree);

    connectionTree.getEmptyText().setText(P4Bundle.getString("connection.tree.initial"));
    connectionTree.setEditable(false);
    connectionTreeModel = new DefaultTreeModel(treeNode);
    connectionTree.setModel(connectionTreeModel);
    connectionTree.setCellRenderer(new ConnectionTreeCellRenderer());
    connectionTree.setRootVisible(false);
    DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    connectionTree.setSelectionModel(selectionModel);

    ActionGroup actionButtons = createActionGroup();
    ActionToolbar toolbar =
            ActionManager.getInstance().createActionToolbar("p4.active-connection",
                    actionButtons, false);
    root.add(toolbar.getComponent(), BorderLayout.WEST);

    // TODO add context menu support for each selected node type.
    // TODO add support for navigating to a file if a FilePath is selected.
}
 
Example 3
Source File: ExpressionChooserDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void init() {
  setTitle( EditorExpressionsMessages.getString( "ExpressionChooserDialog.Title" ) );
  setModal( true );

  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
  selectionModel.addTreeSelectionListener( new ExpressionSelectionHandler() );

  expressionsTree = new JTree( ExpressionsTreeModel.getTreeModel() );
  expressionsTree.setRootVisible( false );
  expressionsTree.setSelectionModel( selectionModel );
  expressionsTree.addMouseListener( new DblClickHandler() );
  expressionsTree.setCellRenderer( new ExpressionTreeCellRenderer() );

  addAction = new AddAction();

  super.init();
}
 
Example 4
Source File: CTagsTree.java    From binnavi with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new tree object.
 *
 * @param parent Parent window used for dialogs.
 * @param graph Graph shown in the window.
 * @param manager Provides tag information.
 */
public CTagsTree(final JFrame parent, final ZyGraph graph, final ITagManager manager) {
  m_parent = Preconditions.checkNotNull(parent, "IE02308: Perent argument can not be null");
  m_graph = Preconditions.checkNotNull(graph, "IE01776: Graph can not be null");
  m_tagManager = Preconditions.checkNotNull(manager, "IE01777: Manager argument can not be null");

  m_model = new CTagsTreeModel(this);
  setModel(m_model);
  getModel().addTreeModelListener(new InternalModelListener());
  addMouseListener(m_mouseListener);
  m_graph.addListener(m_graphSelectionListener);
  m_graph.addListener(m_graphVisibilityListener);

  setRootVisible(false);

  m_rootNode = new CRootTagTreeNode(parent, this, graph, m_tagManager);
  m_model.setRoot(m_rootNode);

  setCellRenderer(new CTagTreeCellRenderer()); // ATTENTION: UNDER NO CIRCUMSTANCES MOVE THIS LINE
                                               // ABOVE THE SETROOT LINE

  m_model.nodeStructureChanged(m_rootNode);

  final List<IDropHandler> handlers = new ArrayList<IDropHandler>();

  handlers.add(new CTagSortingHandler());

  new CDefaultTransferHandler(this, DnDConstants.ACTION_COPY_OR_MOVE, handlers);

  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  setSelectionModel(selectionModel);

  final InputMap windowImap = getInputMap(JComponent.WHEN_FOCUSED);

  windowImap.put(HotKeys.DELETE_HK.getKeyStroke(), "DELETE");
  getActionMap().put("DELETE", CActionProxy.proxy(new DeleteAction()));
}
 
Example 5
Source File: TypesTree.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public TypesTree() {
  setRootVisible(false);
  setDragEnabled(true);
  setDropMode(DropMode.INSERT); // Dropped objects are inserted behind the drop location.
  setToggleClickCount(1); // Child nodes expand with a single click.
  final DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  setSelectionModel(selectionModel);
  final IconNodeRenderer renderer = new IconNodeRenderer();
  renderer.setFont(GuiHelper.MONOSPACED_FONT);
  setCellRenderer(renderer);
}