javax.swing.tree.TreeSelectionModel Java Examples

The following examples show how to use javax.swing.tree.TreeSelectionModel. 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: AquaLocationSourceList.java    From pumpernickel with MIT License 6 votes vote down vote up
public AquaLocationSourceList(LocationHistory directoryStack,
		GraphicCache graphicCache) {
	super(new DefaultTreeModel(new DefaultMutableTreeNode("root")));

	treeModel = (DefaultTreeModel) getModel();
	root = (DefaultMutableTreeNode) treeModel.getRoot();

	this.directoryStack = directoryStack;
	this.graphicCache = graphicCache;

	treeModel.insertNodeInto(devices, root, 0);
	treeModel.insertNodeInto(places, root, 1);
	addTreeSelectionListener(treeSelectionListener);
	directoryStack.addChangeListener(directoryStackListener);
	setExpandsSelectedPaths(true);
	setCellRenderer(new SourceListLocationRenderer(graphicCache, this));
	getSelectionModel().setSelectionMode(
			TreeSelectionModel.SINGLE_TREE_SELECTION);
	setUI(new SourceListTreeUI(this));

	expandPath(new TreePath(devices.getPath()));
	expandPath(new TreePath(places.getPath()));
}
 
Example #2
Source File: RTreeTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void noNodesSelected() throws Throwable, InvocationTargetException {
    final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    siw(new Runnable() {
        @Override
        public void run() {
            tree.expandRow(0);
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override
        public void run() {
            RTree rTree = new RTree(tree, null, null, lr);
            rTree.focusLost(null);
        }
    });
    AssertJUnit.assertEquals(0, lr.getCalls().size());
}
 
Example #3
Source File: RegisterTree.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public RegisterTree() {
	super(new RegisterTreeRootNode());
	root = (RegisterTreeRootNode) getModelRoot();

	setEditable(false);

	getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	setHorizontalScrollPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

	// add change listener to prevent tree from scrolling horizontally since we will
	// never have a horizontal scroll bar.
	JScrollPane scrollPane = getScrollPane();
	final JViewport viewport = scrollPane.getViewport();
	scrollPane.getViewport().addChangeListener(new ChangeListener() {
		@Override
		public void stateChanged(ChangeEvent e) {
			Point viewPosition = viewport.getViewPosition();
			if (viewPosition.x != 0) {
				// if it scrolls horizontally, put it back
				viewPosition.x = 0;
				viewport.setViewPosition(viewPosition);
			}
		}
	});
	setMinimumSize(new Dimension(175, 30));
}
 
Example #4
Source File: RTreeTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void singleNodeSelected() throws Throwable, InvocationTargetException {
    final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    siw(new Runnable() {
        @Override
        public void run() {
            tree.expandRow(0);
            tree.setSelectionRow(0);
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override
        public void run() {
            Rectangle rowBounds = tree.getRowBounds(0);
            RTree rTree = new RTree(tree, null, rowBounds.getLocation(), lr);
            rTree.mouseButton1Pressed(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("click", call.getFunction());
    AssertJUnit.assertEquals("/Root Node", call.getCellinfo());
}
 
Example #5
Source File: RTreeTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void singleNodeWithSpecialChars() throws Throwable, InvocationTargetException {
    final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    siw(new Runnable() {
        @Override
        public void run() {
            DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
            DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
            root.setUserObject("Root Node [] , / Special");
            tree.expandRow(0);
            tree.setSelectionRow(0);
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override
        public void run() {
            Rectangle cb = tree.getPathBounds(tree.getPathForRow(0));
            RTree rTree = new RTree(tree, null, new Point(cb.x + 2, cb.y + 2), lr);
            rTree.mouseButton1Pressed(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("click", call.getFunction());
    AssertJUnit.assertEquals("/Root Node [] , \\/ Special", call.getCellinfo());
}
 
Example #6
Source File: StructureViewComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void setupTree() {
  myTree.setCellRenderer(new NodeRenderer());
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  myTree.setShowsRootHandles(true);
  registerPsiListener(myProject, this, this::queueUpdate);
  myProject.getMessageBus().connect(this).subscribe(UISettingsListener.TOPIC, o -> rebuild());

  if (showScrollToFromSourceActions()) {
    myAutoScrollToSourceHandler.install(myTree);
    myAutoScrollFromSourceHandler.install();
  }

  TreeUtil.installActions(getTree());

  new TreeSpeedSearch(getTree(), treePath -> {
    Object userObject = TreeUtil.getLastUserObject(treePath);
    return userObject != null ? FileStructurePopup.getSpeedSearchText(userObject) : null;
  });

  addTreeKeyListener();
  addTreeMouseListeners();
  restoreState();
}
 
Example #7
Source File: Overview.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
ThreadPane(String name_, int tabIdx_) {
     name   = name_;
     tabIdx = tabIdx_;
     setLayout(new BorderLayout());
     setName(name + " (" + msgCount + ")");
     jtree.setRootVisible(false);
     jtree.setShowsRootHandles(true);
     jtree.setCellRenderer(new TreeRenderer());
     jtree.setScrollsOnExpand(true); 
     jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
     jtree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
  public void valueChanged(TreeSelectionEvent e) {
    if(e.getNewLeadSelectionPath() == null) return;
    if(e.getNewLeadSelectionPath().getLastPathComponent() instanceof LogMessageNode) {
      LogMessage m = ((LogMessageNode)e.getNewLeadSelectionPath().getLastPathComponent()).m;
      info.setText(Const.LOG_STRINGS[m.priority] + " from " + m.thread + " @ " + new Date(m.time).toString() + "\n" +
		   m.message + "\n" + 
		   m.getException());
    }
  }
});
     add(new JScrollPane(jtree), BorderLayout.CENTER);
   }
 
Example #8
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Inits the IR tree.
 */
private void initIRTree() {
  DefaultMutableTreeNode root = new DefaultMutableTreeNode(noIndexReposLabel);
  DefaultTreeModel model = new DefaultTreeModel(root);
  this.indexTree = new JTree(model);
  this.indexTree.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 2));
  // Only one node can be selected at any one time.
  this.indexTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.indexTree.addTreeSelectionListener(new IndexTreeSelectionListener(this));
  // No icons.
  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  // cellRenderer.setIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  this.indexTree.setCellRenderer(cellRenderer);
}
 
Example #9
Source File: CheckTreeView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates a new instance of CheckTreeView */
public CheckTreeView() {
    
    setFocusable( false );
    
    CheckListener l = new CheckListener();
    tree.addMouseListener( l );
    tree.addKeyListener( l );

    CheckRenderer check = new CheckRenderer();
    tree.setCellRenderer( check );
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    
    tree.setShowsRootHandles(false);
    
    InputMap input = tree.getInputMap( JTree.WHEN_FOCUSED );
    if( null != input )
        input.remove( KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) );
    
    setBorder( UIManager.getBorder("ScrollPane.border") );
}
 
Example #10
Source File: DownloadListWizardPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
private void createSelectionDialog(final byte type) {
	WebServiceClient client = (WebServiceClient) context.getAttribute(PublishWizard.CLIENT);
	jcrBrowserTree = new JcrBrowserTree(type, client);
	jcrBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
	JPanel selectionPanel = JcrBrowserTreeUtil.createSelectionPanel(jcrBrowserTree, type);

	JDialog dialog = new BaseDialog(selectionPanel, I18NSupport.getString("wizard.publish.file.path.select"),
			true) {
		protected boolean ok() {
			return selection(jcrBrowserTree, type);
		}
	};
	dialog.pack();
	Show.centrateComponent((JDialog) context.getAttribute(PublishWizard.MAIN_FRAME), dialog);
	dialog.setVisible(true);
}
 
Example #11
Source File: AnnotationFeaturesViewer.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Populate.
 *
 * @param analysisEngine the analysis engine
 * @param aeMetaData the ae meta data
 */
public void populate(AnalysisEngine analysisEngine, AnalysisEngineMetaData aeMetaData) {
  tree = generateTreeView(analysisEngine, aeMetaData);

  tree.setDragEnabled(true); // To allow drag to stylemap table.
  tree.setRootVisible(false);
  tree.setShowsRootHandles(true); // Displays node expansion glyphs.

  TreeSelectionModel selectionModel = tree.getSelectionModel();
  selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  tree.setCellRenderer(cellRenderer);

  scrollPane.getViewport().add(tree, null);
}
 
Example #12
Source File: DefaultClientSelectionPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initUserComponents() {
    treeView = new BeanTreeView();
    treeView.setRootVisible(false);
    treeView.setPopupAllowed(false);

    java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(11, 11, 0, 11);
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(treeView, gridBagConstraints);
    jLblTreeView.setLabelFor(treeView.getViewport().getView());
    treeView.getAccessibleContext().setAccessibleName(
            NbBundle.getMessage(DefaultClientSelectionPanel.class, "ACSD_AvailableWebServicesTree"));
    treeView.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(DefaultClientSelectionPanel.class, "ACSD_AvailableWebServicesTree"));
    treeView.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
}
 
Example #13
Source File: BrowseFolders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
BrowseFolders(SourceGroup[] folders, Class<?> target, String preselectedFileName) {
    initComponents();
    String description = target == DataFolder.class ? "ACSD_BrowseFolders" : "ACSD_BrowseFiles"; // NOI18N
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BrowseFolders.class, description));

    this.folders = folders;
    this.target = target;
    manager = new ExplorerManager();
    AbstractNode rootNode = new AbstractNode(new SourceGroupsChildren(folders));
    manager.setRootContext(rootNode);

    // Create the templates view
    btv = new BeanTreeView();
    btv.setRootVisible(false);
    btv.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    btv.setBorder(SAMPLE_SCROLL_PANE.getBorder());
    expandSelection(preselectedFileName);
    folderPanel.add(btv, BorderLayout.CENTER);
}
 
Example #14
Source File: InspectorTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public InspectorTree(final DefaultMutableTreeNode treemodel,
                     String treeName,
                     boolean detailsSubtree,
                     String parentTreeName,
                     boolean rootVisible,
                     boolean legacyMode,
                     Disposable parentDisposable) {
  super(treemodel);
  setUI(new InspectorTreeUI());
  final BasicTreeUI ui = (BasicTreeUI)getUI();
  this.detailsSubtree = detailsSubtree;

  setRootVisible(rootVisible);
  getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  registerShortcuts(parentDisposable);
  if (detailsSubtree) {
    // TODO(devoncarew): This empty text is not showing up for the details area, even when there are no detail nodes.
    getEmptyText().setText(treeName + " subtree of the selected " + parentTreeName);
  }
  else {
    getEmptyText().setText(treeName + " tree for the running app");
  }
}
 
Example #15
Source File: InspectorTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public InspectorTree(final DefaultMutableTreeNode treemodel,
                     String treeName,
                     boolean detailsSubtree,
                     String parentTreeName,
                     boolean rootVisible,
                     boolean legacyMode,
                     Disposable parentDisposable) {
  super(treemodel);
  setUI(new InspectorTreeUI());
  final BasicTreeUI ui = (BasicTreeUI)getUI();
  this.detailsSubtree = detailsSubtree;

  setRootVisible(rootVisible);
  getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  registerShortcuts(parentDisposable);
  if (detailsSubtree) {
    // TODO(devoncarew): This empty text is not showing up for the details area, even when there are no detail nodes.
    getEmptyText().setText(treeName + " subtree of the selected " + parentTreeName);
  }
  else {
    getEmptyText().setText(treeName + " tree for the running app");
  }
}
 
Example #16
Source File: TagTree.java    From jpexs-decompiler with GNU General Public License v3.0 6 votes vote down vote up
public List<TreeItem> getSelected() {
    if (!mainPanel.folderPreviewPanel.selectedItems.isEmpty()) {
        return new ArrayList<>(mainPanel.folderPreviewPanel.selectedItems.values());
    }
    TreeSelectionModel tsm = getSelectionModel();
    TreePath[] tps = tsm.getSelectionPaths();
    List<TreeItem> ret = new ArrayList<>();
    if (tps == null) {
        return ret;
    }

    for (TreePath tp : tps) {
        TreeItem treeNode = (TreeItem) tp.getLastPathComponent();
        ret.add(treeNode);
    }
    return ret;
}
 
Example #17
Source File: AnalyzeDependenciesComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize components
 */
private void init() {
  myTree.setCellRenderer(new ColoredTreeCellRenderer() {
    @Override
    public void customizeCellRenderer(JTree tree,
                                      Object value,
                                      boolean selected,
                                      boolean expanded,
                                      boolean leaf,
                                      int row,
                                      boolean hasFocus) {
      //if(getBackground() == null) {
      //  setBackground(UIUtil.getTreeTextBackground());
      //}
      if (value instanceof MyNode && !(value instanceof MyRootNode)) {
        final MyNode node = (MyNode)value;
        PathNode<?> n = (PathNode<?>)node.getUserObject();
        CellAppearanceEx a = n.getAppearance(selected, node.isDisplayInBold());
        a.customize(this);
      }
    }
  });
  myTree.setShowsRootHandles(false);
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  reloadTree();
}
 
Example #18
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 #19
Source File: PlotConfigurationTree.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
public PlotConfigurationTree(PlotConfiguration plotConfiguration, DataTable dataTable,
		DataTableColumnListTransferHandler aTH) {
	super();
	expandAll();

	// forces the tree to ask the nodes for the correct row heights
	// must also be invoked after LaF changes...
	setRowHeight(0);

	getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	setExpandsSelectedPaths(true);

	// DnD support
	setDragEnabled(true);
	setDropMode(DropMode.INSERT);

	// Rendering
	setShowsRootHandles(false);
	setBackground(Colors.WHITE);
	setCellRenderer(new PlotConfigurationTreeCellRenderer(aTH));
	putClientProperty("JTree.lineStyle", "Horizontal");

	createNewTreeModel(plotConfiguration);
}
 
Example #20
Source File: SelectSettlersFolderDialog.java    From settlers-remake with MIT License 6 votes vote down vote up
/**
 * Initialize the Tree with the filesystem
 */
private void initTree() {
	RootTreeNode root = new RootTreeNode(executorService);

	for (File f : File.listRoots()) {
		root.add(new FilesystemTreeNode(f));
	}

	model = new DefaultTreeModel(root);

	// to fire change event when the loading is finished
	root.setModel(model);
	tree = new JTree(model);

	tree.addTreeSelectionListener(selectionListener);
	tree.addTreeExpansionListener(expansionListener);
	tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	tree.expandRow(0);
	tree.setRootVisible(false);
	tree.setCellRenderer(new FileTreeCellRenderer());
}
 
Example #21
Source File: ChooseActionsDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
public ChooseActionsDialog(Component parent, Keymap keymap, QuickList[] quicklists) {
  super(parent, true);
  myKeymap = keymap;
  myQuicklists = quicklists;

  myActionsTree = new ActionsTree();
  myActionsTree.reset(keymap, quicklists);
  myActionsTree.getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);

  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      doOKAction();
      return true;
    }
  }.installOn(myActionsTree.getTree());


  myTreeExpansionMonitor = TreeExpansionMonitor.install(myActionsTree.getTree());

  setTitle("Add Actions to Quick List");
  init();
}
 
Example #22
Source File: ProjectFileExplorer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void initUserComponents() {
    treeView = new BeanTreeView();
    treeView.setRootVisible(false);
    treeView.setPopupAllowed(false);
    treeView.setDefaultActionAllowed(false);
    treeView.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(11, 11, 0, 11);
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    eventBlocker.setOpaque(false);
    eventBlocker.setVisible(dontCopyCB.isSelected());
    add(eventBlocker, gridBagConstraints);
    add(treeView, gridBagConstraints);
    jLblTreeView.setLabelFor(treeView.getViewport().getView());
    treeView.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ClientExplorerPanel.class, "ACSD_AvailableWebServicesTree")); // NOI18N
    treeView.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ClientExplorerPanel.class, "ACSD_AvailableWebServicesTree")); // NOI18N
    dontCopyCB.setToolTipText(NbBundle.getMessage(ProjectFileExplorer.class, "TXT_DONOTCOPY_TOOLTIP")); // NOI18N
}
 
Example #23
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Inits the.
 */
private void init() {
  // Set the title.
  this.setTitle("Type System Editor");
  JSplitPane contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
  this.setContentPane(contentPane);

  // Set up the type tree. Use simple DefaultTreeModel.
  DefaultMutableTreeNode root = new DefaultMutableTreeNode("<html><b>No CAS!</b></html>");
  DefaultTreeModel treeModel = new DefaultTreeModel(root);
  this.typeTree = new JTree(treeModel);
  this.typeTree.addTreeSelectionListener(new TypeTreeSelectionListener());
  TreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();
  treeSelectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  this.typeTree.setSelectionModel(treeSelectionModel);
  JScrollPane treePane = new JScrollPane(this.typeTree);
  contentPane.setLeftComponent(treePane);
  DefaultTreeCellRenderer cellRenderer = new DefaultTreeCellRenderer();
  cellRenderer.setLeafIcon(null);
  // cellRenderer.setIcon(null);
  cellRenderer.setClosedIcon(null);
  cellRenderer.setOpenIcon(null);
  this.typeTree.setCellRenderer(cellRenderer);

  // Set up the feature table.
  this.featureTable = new JTable(new FeatureTableModel());
  JScrollPane featurePane = new JScrollPane(this.featureTable);
  featurePane.getViewport().setBackground(Color.WHITE);
  contentPane.setRightComponent(featurePane);

  this.setJMenuBar(createMenuBar());
}
 
Example #24
Source File: TfsTreeForm.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public TfsTreeForm() {
    DataManager.registerDataProvider(tree, this);
    new TreeSpeedSearch(tree);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            selectedItem = doGetSelectedItem();
            pathField.setText(selectedItem != null ? selectedItem.path : null);
            eventDispatcher.getMulticaster().selectionChanged();
        }
    });
    PopupHandler.installPopupHandler(tree, POPUP_ACTION_GROUP, ActionPlaces.REMOTE_HOST_DIALOG_POPUP);
    setMessage(null, false);
}
 
Example #25
Source File: JTreeOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTree.getSelectionModel()} through queue
 */
public TreeSelectionModel getSelectionModel() {
    return (runMapping(new MapAction<TreeSelectionModel>("getSelectionModel") {
        @Override
        public TreeSelectionModel map() {
            return ((JTree) getSource()).getSelectionModel();
        }
    }));
}
 
Example #26
Source File: LastNodeLowerHalfDrop.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private JScrollPane getContent() {
    jTree = new JTree(getTreeModel());
    jTree.setRootVisible(false);
    jTree.setDragEnabled(true);
    jTree.setDropMode(DropMode.INSERT);
    jTree.setTransferHandler(new TreeTransferHandler());
    jTree.getSelectionModel().setSelectionMode(
            TreeSelectionModel.SINGLE_TREE_SELECTION);
    expandTree(jTree);
    return new JScrollPane(jTree);
}
 
Example #27
Source File: CheckboxTree.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
/**
        * Convenience initialization method.
        */
   private void initialize() {
setCheckingModel(new DefaultTreeCheckingModel(this.treeModel));
setCellRenderer(new DefaultCheckboxTreeCellRenderer());
addMouseListener(new NodeCheckListener());
this.selectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
setShowsRootHandles(true);
putClientProperty("JTree.lineStyle", "Angled");// for Metal L&F
   }
 
Example #28
Source File: MindMapTreePanel.java    From netbeans-mmd-plugin with Apache License 2.0 5 votes vote down vote up
public MindMapTreePanel(final MindMap map, final ExtraTopic selectedTopicUid, final boolean expandAll, final ActionListener listener) {
  initComponents();
  this.treeMindMap.setCellRenderer(this.cellRenderer);
  this.treeMindMap.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  if (map != null) {
    this.sortedModel = new SortedTreeModelWrapper(map, this);
    this.treeMindMap.setModel(this.sortedModel);
    if (selectedTopicUid != null) {
      final Topic topic = map.findTopicForLink(selectedTopicUid);
      if (topic != null) {
        this.treeMindMap.setSelectionPath(new TreePath(topic.getPath()));
      }
    }
  } else {
    this.sortedModel = null;
  }

  this.treeMindMap.addMouseListener(new MouseAdapter() {

    @Override
    public void mouseClicked(final MouseEvent e) {
      if (!e.isPopupTrigger() && e.getClickCount() > 1) {
        if (listener != null) {
          listener.actionPerformed(new ActionEvent(this, 0, "doubleClick"));
        }
      }
    }
  });

  this.setPreferredSize(new Dimension(450, 400));

  this.treeMindMap.requestFocus();

  if (expandAll) {
    expandAll();
  }
}
 
Example #29
Source File: ManagementModel.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private JTree makeTree(ManagementModelNode root) {
    root.explore();
    JTree tree = new CommandBuilderTree(cliGuiCtx, new DefaultTreeModel(root));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeExpansionListener(new ManagementTreeExpansionListener((DefaultTreeModel) tree.getModel()));
    tree.addTreeSelectionListener(new ManagementTreeSelectionListener());
    tree.addMouseListener(new ManagementTreeMouseListener(tree));
    return tree;
}
 
Example #30
Source File: ProcessingComponent.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
private @Nullable DefaultMutableTreeNode getSelectedItem(@Nonnull JTree tree) {
  TreeSelectionModel selectionModel = tree.getSelectionModel();
  if (selectionModel == null)
    return null;
  TreePath path = selectionModel.getSelectionPath();
  if (path == null)
    return null;
  return (DefaultMutableTreeNode) path.getLastPathComponent();
}