public HintsPanel(HintMetadata preselected, @NullAllowed final CustomizerContext<?, ?> cc, ClassPathBasedHintWrapper cpBased) { this.cpBased = cpBased; this.queryStatus = cc == null ? QueryStatus.NEVER : QueryStatus.SHOW_QUERIES; this.showHeavyInspections = true; init(null, true, false, false, false, cc == null, false, cc != null); select(preselected); configurationsPanel.setVisible(false); if (cc != null) { errorTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { HintMetadata hm = getSelectedHint(); if (hm != null) { cc.setSelectedId(AnalyzerImpl.ID_JAVA_HINTS_PREFIX + hm.id); } } }); } }
public AvailableTreeTable() { super(); setTreeTableModel(new AvailableTreeTableModel(data.getRoot())); sizeColumns(); setRowHeight(CELL_HEIGHT); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); getTableHeader().setReorderingAllowed(false); addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); TreeTableNode node = (TreeTableNode) path.getLastPathComponent(); if ("template".equals(node.getType())) { tempDownload.setEnabled(true); } else { tempDownload.setEnabled(false); } } }); }
/** Construct a Tree object with the given font size. */ public OurTree(int fontSize) { Font font = OurUtil.getVizFont().deriveFont((float) fontSize); OurTreeRenderer renderer = new OurTreeRenderer(fontSize); renderer.setFont(font); renderer.invalidate(); renderer.validate(); setRowHeight(0); // To allow variable row height on Mac OS X setCellRenderer(renderer); setFont(font); setBorder(new EmptyBorder(8, 8, 2, 2)); getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); putClientProperty("JTree.lineStyle", "Angled"); setRootVisible(true); setForeground(Color.BLACK); setBackground(Color.WHITE); setOpaque(true); addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { TreePath path = OurTree.this.getSelectionPath(); if (path != null) OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent()); } }); }
protected void createInnerComponent() { panel.removeAll(); Attribute[] attributes = getAttributes(); RootCreater rootCreater = getRootCreater(); component = new RowTreeTableComponent(engine, qualifier, accessRules, rootCreater, attributes, framework); rowSet = component.getRowSet(); table = component.getTable(); table.getTreeSelectionModel().addTreeSelectionListener( new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { refreshActions(); } }); refreshActions(); panel.add(component, BorderLayout.CENTER); panel.revalidate(); panel.repaint(); }
/** Construct a Tree object with the given font size. */ public OurTree(int fontSize) { Font font = OurUtil.getVizFont().deriveFont((float)fontSize); OurTreeRenderer renderer = new OurTreeRenderer(fontSize); renderer.setFont(font); renderer.invalidate(); renderer.validate(); setRowHeight(0); // To allow variable row height on Mac OS X setCellRenderer(renderer); setFont(font); setBorder(new EmptyBorder(8, 8, 2, 2)); getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); putClientProperty("JTree.lineStyle", "Angled"); setRootVisible(true); setForeground(Color.BLACK); setBackground(Color.WHITE); setOpaque(true); addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { TreePath path = OurTree.this.getSelectionPath(); if (path!=null) OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent()); } }); }
/** Construct a FileTree */ public FileTree(File dir) { setLayout(new BorderLayout()); applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); setBorder(null); // Make a tree list with all the nodes, and make it a JTree JTree tree = new JTree(addNodes(null, dir)); tree.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); // Add a listener tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e .getPath().getLastPathComponent(); } }); add(BorderLayout.CENTER, tree); JScrollPane scrollBarExplorer = new JScrollPane(); scrollBarExplorer.getViewport().add(tree); scrollBarExplorer.setBorder(null); add(scrollBarExplorer, BorderLayout.CENTER); }
public ViewTreeGroups(String directory) { //super("JTree FileSystem Viewer - JavaProgrammingForums.com"); setTitle("GroupsTree Structure"); fileDetailsTextArea.setEditable(false); fileSystemModel = new FileSystemModel(new File(directory)); fileTree = new JTree(fileSystemModel); fileTree.setEditable(true); fileTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent event) { File file = (File) fileTree.getLastSelectedPathComponent(); fileDetailsTextArea.setText(getFileDetails(file)); } }); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, new JScrollPane(fileTree), new JScrollPane( fileDetailsTextArea)); getContentPane().add(splitPane); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(640, 480); setVisible(true); }
public NavigatorTopComponent() { initComponents(); tsl = new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); if(path != null) processSelection(path); } }; tree = new ProjectTree("root"); jTree1.addTreeSelectionListener(tsl); DefaultMutableTreeNode root = new DefaultMutableTreeNode(tree.getRoot().getName()); jTree1.setModel(new DefaultTreeModel(processNodes(root, tree.getRoot()))); jTree1.setRootVisible(false); jTree1.revalidate(); setName(Bundle.CTL_ProjectsTopComponent()); setToolTipText(Bundle.HINT_ProjectsTopComponent()); putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); putClientProperty(TopComponent.PROP_DRAGGING_DISABLED, Boolean.TRUE); putClientProperty(TopComponent.PROP_MAXIMIZATION_DISABLED, Boolean.TRUE); putClientProperty(TopComponent.PROP_SLIDING_DISABLED, Boolean.TRUE); putClientProperty(TopComponent.PROP_UNDOCKING_DISABLED, Boolean.TRUE); putClientProperty(TopComponent.PROP_KEEP_PREFERRED_SIZE_WHEN_SLIDED_IN, Boolean.TRUE); }
private TreeSelectionListener getTreeSelectionListener() { return new TreeSelectionListener() { @Override public void valueChanged( TreeSelectionEvent e ) { TreePath path = e.getPath(); switch ( path.getPathCount() ) { case 1: //This shouldn't be possible because the root node is invisible. break; case 2: tablemodel.clear(); break; case 3: DefaultMutableTreeNode dmtn = DefaultMutableTreeNode.class.cast( e.getPath().getLastPathComponent() ); URI instance = URI.class.cast( dmtn.getUserObject() ); ModelQueryAdapter mqa = ModelQueryAdapter.describe( instance ); mqa.useInferred( false ); tablemodel.setModel( engine.constructNoEx( mqa ) ); break; default: break; } } }; }
private void createView() { tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) { return; } Object nodeInfo = node.getUserObject(); if (node.isLeaf()) { switchView(nodeInfo.toString()); } } }); windowPane = new JPanel(); windowPane.add(new TaskScreenPanel()); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tree, windowPane); getContentPane().add(pane); }
public void setSelectionModel(TreeSelectionModel selectionModel) { if (selectionModel == null) return; TreeSelectionModel oldValue = this.selectionModel; if (accessibleContext != null) { this.selectionModel .removeTreeSelectionListener((TreeSelectionListener) accessibleContext); selectionModel .addTreeSelectionListener((TreeSelectionListener) accessibleContext); } this.selectionModel = selectionModel; // firePropertyChange(SELECTION_MODEL_PROPERTY, oldValue, this.selectionModel); }
/** * Initialize tree properties and add listener. */ public void setupTreeListener(){ libTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); libTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) libTree.getLastSelectedPathComponent(); if (node == null) return; if (!node.children().hasMoreElements()) { Method m = methodCache.get(node.getUserObject()); if (m != null){ callFrame.createParameterList(m); callFrame.setVisible(true); } } } }); }
private void addTreeListener() { for (int i = 1; i < tree.getRowCount(); i++) { tree.setSelectionRow(i); if (selected.equals(lastSelected)) { break; } } tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { node = (IconNode) e.getPath().getLastPathComponent(); updateVariableChoices(node,null); } }); tree.setSelectionRow(0); }
/** * return category tree with filtered child nodes */ public JComponent getCatComponent(EventListener listener) { if(isFilterEnabled() && ((filteredCatTree == null) || (getLastUpdated() < PrefManager.get().getFiltersLastChanged()))) { // first refresh filter checker with current filters setFilterChecker(FilterChecker.getFilterChecker()); // apply new filter settings. filteredCatTree = new JTree(filterNodes(getRootNode())); if(getName().startsWith("Monitors") || getName().startsWith("Threads blocked by Monitors")) { filteredCatTree.setShowsRootHandles(true); } filteredCatTree.setCellRenderer(new TreeRenderer()); filteredCatTree.setRootVisible(false); filteredCatTree.addTreeSelectionListener((TreeSelectionListener) listener); setLastUpdated(); } else if (!isFilterEnabled() && (filteredCatTree == null) || (getLastUpdated() < PrefManager.get().getFiltersLastChanged())) { filteredCatTree = new JTree(getRootNode()); if(getName().startsWith("Monitors") || getName().startsWith("Threads blocked by Monitors")) { filteredCatTree.setShowsRootHandles(true); } filteredCatTree.setCellRenderer(new TreeRenderer()); filteredCatTree.setRootVisible(false); filteredCatTree.addTreeSelectionListener((TreeSelectionListener) listener); } return(filteredCatTree); }
/** * Adds the listeners that manage selection synchronization in this tree. */ private void addSelectionListeners(final FurnitureCatalog catalog, final FurnitureCatalogController controller) { final SelectionListener modelSelectionListener = new SelectionListener() { public void selectionChanged(SelectionEvent selectionEvent) { updateTreeSelectedFurniture(catalog, controller); } }; this.treeSelectionListener = new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent ev) { // Updates selected furniture in catalog from selected nodes in tree. controller.removeSelectionListener(modelSelectionListener); controller.setSelectedFurniture(getSelectedFurniture()); controller.addSelectionListener(modelSelectionListener); } }; controller.addSelectionListener(modelSelectionListener); getSelectionModel().addTreeSelectionListener(this.treeSelectionListener); }
protected void installTreeListener(@NotNull final JTree tree) { tree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(final TreeSelectionEvent e) { if (!isHintVisible(HintUpdateSupply.this.myHint) || isSelectedByMouse(tree)) return; TreePath path = tree.getSelectionPath(); if (path != null) { final PsiElement psiElement = getPsiElementForHint(path.getLastPathComponent()); if (psiElement != null && psiElement.isValid()) { updateHint(psiElement); } } } }); }
TreeToolbarDecorator(JTree tree, @Nullable final ElementProducer<?> producer) { myTree = tree; myProducer = producer; myAddActionEnabled = myRemoveActionEnabled = myUpActionEnabled = myDownActionEnabled = myTree.getModel() instanceof EditableTreeModel; if (myTree.getModel() instanceof EditableTreeModel) { createDefaultTreeActions(); } myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { updateButtons(); } }); myTree.addPropertyChangeListener("enabled", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { updateButtons(); } }); }
public MyUI() { myStructureTree = new Tree(); myStructureTree.setRootVisible(false); myStructureTree.setShowsRootHandles(true); myStructureTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(final TreeSelectionEvent e) { final List<FilePath> filePaths = new ArrayList<FilePath>(mySelection); mySelection.clear(); final TreePath[] selectionPaths = myStructureTree.getSelectionPaths(); if (selectionPaths != null) { for (TreePath selectionPath : selectionPaths) { Collections.addAll(mySelection, ((ChangesBrowserNode)selectionPath.getLastPathComponent()).getFilePathsUnder()); } } if (Comparing.haveEqualElements(filePaths, mySelection)) return; for (ChangeListener listener : myListeners) { listener.stateChanged(new ChangeEvent(this)); } } }); myScrollPane = ScrollPaneFactory.createScrollPane(myStructureTree); myBuilder = new TreeModelBuilder(myProject, false); }
protected ToolSelectDialog(@Nullable Project project, @Nullable String actionIdToSelect, BaseToolsPanel toolsPanel) { super(project); myToolsPanel = toolsPanel; myToolsPanel.reset(); setOKActionEnabled(myToolsPanel.getSingleSelectedTool() != null); myToolsPanel.addSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { setOKActionEnabled(myToolsPanel.getSingleSelectedTool() != null); } }); init(); pack(); if (actionIdToSelect != null) { myToolsPanel.selectTool(actionIdToSelect); } setTitle(ToolsBundle.message("tools.dialog.title")); }
protected FileTemplateTabAsTree(String title) { super(title); myRoot = initModel(); MyTreeModel treeModel = new MyTreeModel(myRoot); myTree = new Tree(treeModel); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); UIUtil.setLineStyleAngled(myTree); myTree.expandPath(TreeUtil.getPathFromRoot(myRoot)); myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); myTree.setCellRenderer(new MyTreeCellRenderer()); myTree.expandRow(0); myTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { onTemplateSelected(); } }); new TreeSpeedSearch(myTree); }
@Override protected void initTree() { myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { final TreePath path = e.getOldLeadSelectionPath(); if (path != null) { final MyNode node = (MyNode)path.getLastPathComponent(); final NamedConfigurable namedConfigurable = node.getConfigurable(); if (namedConfigurable instanceof ScopeConfigurable) { ((ScopeConfigurable)namedConfigurable).cancelCurrentProgress(); } } } }); super.initTree(); myTree.setShowsRootHandles(false); new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() { @Override public String convert(final TreePath treePath) { return ((MyNode)treePath.getLastPathComponent()).getDisplayName(); } }, true); myTree.getEmptyText().setText(IdeBundle.message("scopes.no.scoped")); }
protected void init() { super.init(); final String urlString = myURL.toString(); if (myAllowActions) { // initialize repo browser this way - to make actions work correctly myRepositoryBrowser.setRepositoryURLs(new SVNURL[]{myURL}, myIsShowFiles, new UrlOpeningExpander.Factory(urlString, urlString), true); } else { myRepositoryBrowser.setRepositoryURL(myURL, myIsShowFiles, new UrlOpeningExpander.Factory(urlString, urlString)); } myRepositoryBrowser.addChangeListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { getOKAction().setEnabled(isOKActionEnabled()); } }); }
@Override protected void init() { super.init(); myFollowRemoteTarget = true; setTitle("Select Target For External"); setOKButtonText("Select"); getRepositoryBrowser().addChangeListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { if (getOKAction() != null) { final String selectedURL = getRepositoryBrowser().getSelectedURL(); if (myFollowRemoteTarget && selectedURL != null) { myFolderName.setText(SVNPathUtil.tail(selectedURL)); } checkEnabled(); } } }); getOKAction().setEnabled(getRepositoryBrowser().getSelectedURL() != null); }
public MapAreaHighlightingLayer(JAtlasTree tree) { this.tree = tree; object = (AtlasObject) tree.getSelectionPath().getLastPathComponent(); MainGUI.getMainGUI().previewMap.repaint(); treeListener = new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent event) { try { object = (AtlasObject) event.getNewLeadSelectionPath().getLastPathComponent(); } catch (Exception e) { object = null; } MainGUI.getMainGUI().previewMap.repaint(); } }; tree.addTreeSelectionListener(treeListener); tree.getModel().addTreeModelListener(this); }
public void testAddTreeSelectionListener() { ConcreteTreeSelectionListener listener1 = new ConcreteTreeSelectionListener(); ConcreteTreeSelectionListener listener2 = new ConcreteTreeSelectionListener(); TreeSelectionListener[] listenersArray = null; model.addTreeSelectionListener(listener1); listenersArray = model.getTreeSelectionListeners(); assertTrue(listenersArray.length == 1); assertEquals(1, model.listenerList.getListeners(TreeSelectionListener.class).length); assertEquals(1, model.getListeners(TreeSelectionListener.class).length); assertTrue(listener1.findMe(listenersArray) > 0); model.addTreeSelectionListener(listener2); listenersArray = model.getTreeSelectionListeners(); assertEquals(2, listenersArray.length); assertTrue(listener1.findMe(listenersArray) > 0); assertTrue(listener2.findMe(listenersArray) > 0); model.addTreeSelectionListener(listener2); listenersArray = model.getTreeSelectionListeners(); assertEquals(3, listenersArray.length); }
public void testGetTreeSelectionListeners() { ConcreteTreeSelectionListener changeListener1 = new ConcreteTreeSelectionListener(); ConcreteTreeSelectionListener changeListener2 = new ConcreteTreeSelectionListener(); ConcreteTreeSelectionListener changeListener3 = new ConcreteTreeSelectionListener(); TreeSelectionListener[] listenersArray = null; listenersArray = model.getTreeSelectionListeners(); assertTrue(listenersArray != null && listenersArray.length == 0); model.addTreeSelectionListener(changeListener1); model.addTreeSelectionListener(changeListener2); model.addTreeSelectionListener(changeListener3); model.addTreeSelectionListener(changeListener2); listenersArray = model.getTreeSelectionListeners(); assertTrue(listenersArray.length == 4); assertTrue(changeListener1.findMe(listenersArray) == 1); assertTrue(changeListener2.findMe(listenersArray) == 2); assertTrue(changeListener3.findMe(listenersArray) == 1); }
public void testFireValueChange() { ConcreteTreeSelectionListener listener = new ConcreteTreeSelectionListener(); TreeSelectionListener[] listenersArray = null; listenersArray = model.getTreeSelectionListeners(); assertTrue(listenersArray != null && listenersArray.length == 0); model.addTreeSelectionListener(listener); TreePath path = new TreePath("asd"); TreePath oldSelection = new TreePath("old"); TreePath newSelection = new TreePath("new"); Object source = new Object(); boolean isNew = true; TreeSelectionEvent event = new TreeSelectionEvent(source, path, isNew, oldSelection, newSelection); model.fireValueChanged(event); assertSame(event, listener.event); listener.reset(); model.fireValueChanged(null); assertTrue(listener.fired); assertNull(listener.event); }
public void testGetListenersClass() { PropertyChangeController changeListener1 = new PropertyChangeController(); PropertyChangeController changeListener2 = new PropertyChangeController(); TreeSelectionListener treeSelectionListener = new ConcreteTreeSelectionListener(); EventListener[] listenersArray = null; listenersArray = model.getListeners(TreeSelectionListener.class); assertEquals(0, listenersArray.length); listenersArray = model.getListeners(PropertyChangeListener.class); assertEquals(0, listenersArray.length); model.addPropertyChangeListener(changeListener1); model.addTreeSelectionListener(treeSelectionListener); model.addPropertyChangeListener(changeListener2); model.addPropertyChangeListener(changeListener2); listenersArray = model.getListeners(PropertyChangeListener.class); assertEquals(0, listenersArray.length); listenersArray = model.getListeners(TreeSelectionListener.class); assertEquals(1, listenersArray.length); model.removeTreeSelectionListener(treeSelectionListener); listenersArray = model.getListeners(TreeSelectionListener.class); assertEquals(0, listenersArray.length); }
public void testFireValueChanged() { final Marker changeMarker = new Marker(); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(final TreeSelectionEvent e) { changeMarker.setOccurred(); changeMarker.setAuxiliary(e); } }); TreePath eventPath = new TreePath(new DefaultMutableTreeNode("anyRoot")) .pathByAddingChild(new DefaultMutableTreeNode("anyNode")); tree.getSelectionModel().addSelectionPath(eventPath); assertTrue(changeMarker.isOccurred()); assertSame(eventPath, ((TreeSelectionEvent) changeMarker.getAuxiliary()).getPath()); changeMarker.reset(); tree.fireValueChanged(null); assertTrue(changeMarker.isOccurred()); assertNull(changeMarker.getAuxiliary()); }
/** * This method initializes domTree * * @return javax.swing.JTree */ private JTree getDomTree() { if (domTree == null) { domTree = new JTree(); domTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { //DefaultMutableTreeNode node = (DefaultMutableTreeNode) domTree.getLastSelectedPathComponent(); /*if (node != null) { Box box = (Box) node.getUserObject(); if (box != null) { box.drawExtent(((BrowserCanvas) contentCanvas).getImageGraphics()); contentCanvas.repaint(); displayBoxInfo(box); } }*/ } }); } return domTree; }
private void addSelectionListener() { addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(final TreeSelectionEvent e) { if (isHintBeingShown() && getClientProperty(PopupChooserBuilder.SELECTED_BY_MOUSE_EVENT) != Boolean.TRUE) { final TreePath path = getSelectionPath(); if (path != null) { final PsiElement psiElement = getPsiElementForHint(path.getLastPathComponent()); if (psiElement != null && psiElement.isValid()) { updateHint(psiElement); } } } } }); }