Java Code Examples for javax.swing.event.TreeSelectionListener

The following are top voted examples for showing how to use javax.swing.event.TreeSelectionListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: HintsPanel.java   Source Code and License 6 votes vote down vote up
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);
                }
            }
        });
    }
}
 
Example 2
Project: jmt   File: TemplateAddingPanel.java   Source Code and License 6 votes vote down vote up
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);
			}
		}
	});
}
 
Example 3
Project: org.alloytools.alloy   File: OurTree.java   Source Code and License 6 votes vote down vote up
/** 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());
		}
	});
}
 
Example 4
Project: ramus   File: AbstractTableView.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 5
Project: Tarski   File: OurTree.java   Source Code and License 6 votes vote down vote up
/** 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());
      }
   });
}
 
Example 6
Project: Tarski   File: OurTree.java   Source Code and License 6 votes vote down vote up
/** 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());
      }
   });
}
 
Example 7
Project: Mujeed-Arabic-Prolog   File: FileTree.java   Source Code and License 6 votes vote down vote up
/** 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);

 }
 
Example 8
Project: Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud   File: ViewTreeGroups.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 9
Project: Analyst   File: NavigatorTopComponent.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 10
Project: semtool   File: SemanticExplorerPanel.java   Source Code and License 6 votes vote down vote up
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;
			}
		}
	};
}
 
Example 11
Project: mtg-desktop-okhttp   File: ViewChecklist.java   Source Code and License 6 votes vote down vote up
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);
	}
 
Example 12
Project: j2se_for_android   File: JTree.java   Source Code and License 6 votes vote down vote up
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);
	}
 
Example 13
Project: CVForge   File: CVForgeFrame.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
                }
            }
        }
    });
}
 
Example 14
Project: iBioSim   File: Graph.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 15
Project: tda   File: TreeCategory.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 16
Project: SweetHome3D   File: FurnitureCatalogTree.java   Source Code and License 6 votes vote down vote up
/** 
 * 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);
}
 
Example 17
Project: intellij-ce-playground   File: HintUpdateSupply.java   Source Code and License 6 votes vote down vote up
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);
        }
      }
    }
  });
}
 
Example 18
Project: intellij-ce-playground   File: TreeToolbarDecorator.java   Source Code and License 6 votes vote down vote up
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();
    }
  });
}
 
Example 19
Project: intellij-ce-playground   File: StructureFilteringStrategy.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 20
Project: intellij-ce-playground   File: ToolSelectDialog.java   Source Code and License 6 votes vote down vote up
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"));
}
 
Example 21
Project: intellij-ce-playground   File: FileTemplateTabAsTree.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 22
Project: intellij-ce-playground   File: ScopeChooserConfigurable.java   Source Code and License 6 votes vote down vote up
@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"));
}
 
Example 23
Project: intellij-ce-playground   File: SelectLocationDialog.java   Source Code and License 6 votes vote down vote up
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());
    }
  });
}
 
Example 24
Project: intellij-ce-playground   File: SelectCreateExternalTargetDialog.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 25
Project: thread-dump-analysis   File: TreeCategory.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 26
Project: mobac   File: MapAreaHighlightingLayer.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 27
Project: WP3   File: OurTree.java   Source Code and License 6 votes vote down vote up
/** 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());
      }
   });
}
 
Example 28
Project: WP3   File: OurTree.java   Source Code and License 6 votes vote down vote up
/** 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());
      }
   });
}
 
Example 29
Project: cn1   File: DefaultTreeSelectionModelTest.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 30
Project: cn1   File: DefaultTreeSelectionModelTest.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 31
Project: cn1   File: DefaultTreeSelectionModelTest.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 32
Project: cn1   File: DefaultTreeSelectionModelTest.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 33
Project: cn1   File: JTreeTest.java   Source Code and License 6 votes vote down vote up
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());
}
 
Example 34
Project: CSSBox   File: BoxBrowser.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 35
Project: tools-idea   File: TreeToolbarDecorator.java   Source Code and License 6 votes vote down vote up
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();
    }
  });
}
 
Example 36
Project: tools-idea   File: StructureFilteringStrategy.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 37
Project: tools-idea   File: JBTreeWithHintProvider.java   Source Code and License 6 votes vote down vote up
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);
          }
        }
      }
    }
  });
}
 
Example 38
Project: tools-idea   File: ToolSelectDialog.java   Source Code and License 6 votes vote down vote up
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"));
}
 
Example 39
Project: tools-idea   File: FileTemplateTabAsTree.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 40
Project: tools-idea   File: ScopeChooserConfigurable.java   Source Code and License 6 votes vote down vote up
@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"));
}
 
Example 41
Project: tools-idea   File: UIDesignerToolWindowManager.java   Source Code and License 6 votes vote down vote up
private void initToolWindow() {
  myToolWindowPanel = new MyToolWindowPanel();
  myComponentTree = new ComponentTree(myProject);
  for (TreeSelectionListener listener : myPendingListeners) {
    myComponentTree.addTreeSelectionListener(listener);
  }
  myPendingListeners.clear();
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myComponentTree);
  scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
  scrollPane.setPreferredSize(new Dimension(250, -1));
  myComponentTree.initQuickFixManager(scrollPane.getViewport());
  myPropertyInspector= new PropertyInspector(myProject, myComponentTree);
  myToolWindowPanel.setFirstComponent(scrollPane);
  myToolWindowPanel.setSecondComponent(myPropertyInspector);
  myToolWindow = ToolWindowManager.getInstance(myProject).registerToolWindow(UIDesignerBundle.message("toolwindow.ui.designer"),
                                                                             myToolWindowPanel,
                                                                             ToolWindowAnchor.LEFT, myProject, true);
  myToolWindow.setIcon(UIDesignerIcons.ToolWindowUIDesigner);
  myToolWindow.setAvailable(false, null);
}
 
Example 42
Project: tools-idea   File: SelectCreateExternalTargetDialog.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 43
Project: Reer   File: TaskTreeTab.java   Source Code and License 5 votes vote down vote up
private Component createTreePanel() {
    treeComponent = new TaskTreeComponent(gradlePluginLord, new TaskTreeComponent.Interaction() {
        public void rightClick(JTree tree, int x, int y) {
            enableThingsAppropriately();
            popupMenu.show(tree, x, y);
        }

        public void taskInvoked(TaskView task, boolean isCtrlKeyDown) {
            if (isCtrlKeyDown) {
                gradlePluginLord.addExecutionRequestToQueue(task, false, "-a");
            } else {
                gradlePluginLord.addExecutionRequestToQueue(task, false);
            }
        }

        public void projectInvoked(ProjectView project) {
            executeDefaultTasksInProject(project);
        }
    });

    treeComponent.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            enableThingsAppropriately();
        }
    });

    defaultTreeBackground = treeComponent.getTree().getBackground();

    treeScrollPane = new JScrollPane();

    treeComponent.getTree().setBackground(workingBackgroundColor);  //change the color to better indicate that
    showTextInViewport("Has not built projects/tasks yet.");

    return treeScrollPane;
}
 
Example 44
Project: MapAnalyst   File: CheckBoxTree.java   Source Code and License 5 votes vote down vote up
public static void main(final String[] args) {
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode(new CheckBoxNodeData("Root", Boolean.TRUE));

    final DefaultMutableTreeNode accessibility =
        add(root, "Accessibility", true);
    add(accessibility, "Move system caret with focus/selection changes", false);
    add(accessibility, "Always expand alt text for images", true);
    root.add(accessibility);

    final DefaultMutableTreeNode browsing =
        new DefaultMutableTreeNode(new CheckBoxNodeData("Browsing", null));
    add(browsing, "Notify when downloads complete", true);
    add(browsing, "Disable script debugging", true);
    add(browsing, "Use AutoComplete", true);
    add(browsing, "Browse in a new process", false);
    root.add(browsing);

    final CheckBoxTree tree = new CheckBoxTree(root);
    ((DefaultMutableTreeNode) tree.getModel().getRoot()).add(new DefaultMutableTreeNode(new CheckBoxNodeData("gggg", null)));
    ((DefaultTreeModel) tree.getModel()).reload();
    // listen for changes in the selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(final TreeSelectionEvent e) {
            //System.out.println("selection changed");
        }
    });
    // show the tree on screen
    final JFrame frame = new JFrame("CheckBox Tree");
    final JScrollPane scrollPane = new JScrollPane(tree);
    frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 150);
    frame.setVisible(true);
}
 
Example 45
Project: Equella   File: SchemaAndTargetChooserDialog.java   Source Code and License 5 votes vote down vote up
public SchemaAndTargetChooserDialog(final ClientService clientService, final JComponent parent,
	final boolean indexedForPowersearchOnly)
{
	this.clientService = clientService;
	this.indexedForPowersearchOnly = indexedForPowersearchOnly;

	chooser = new JComboBox();

	model = new SchemaModel();

	tree = new SchemaTree(model, indexedForPowersearchOnly);
	tree.setEnabled(false);
	tree.addMouseListener(new TreeDoubleClickListener(tree, okAction));
	tree.addTreeSelectionListener(new TreeSelectionListener()
	{
		@Override
		public void valueChanged(TreeSelectionEvent e)
		{
			updateActions();
		}
	});

	panel = new JPanel(new MigLayout("wrap, fill", "[grow, fill]", "[][grow, fill][]"));
	panel.add(chooser);
	panel.add(new JScrollPane(tree));
	panel.add(new JButton(okAction), "split, alignx right, tag ok");
	panel.add(new JButton(cancelAction), "tag cancel");

	updateActions();

	dialog = ComponentHelper.createJDialog(parent);
	dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	dialog.setContentPane(panel);
	dialog.setTitle(getString("searchset.virtualisation.xpathchooser.dialogtitle"));
	dialog.setModal(true);
	dialog.pack();

	ComponentHelper.ensureMinimumSize(dialog, 500, 500);
	ComponentHelper.centreOnScreen(dialog);
}
 
Example 46
Project: featurea   File: AttributesDialog.java   Source Code and License 5 votes vote down vote up
private void initComponents() {
    this.jSplitPane1 = new JSplitPane();
    this.attribDisplayPane = new JPanel();
    this.treeAttributes = new JTree();
    getContentPane().setLayout(new GridLayout(1, 0));
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent paramAnonymousWindowEvent) {
            AttributesDialog.this.closeDialog(paramAnonymousWindowEvent);
        }
    });
    this.jSplitPane1.setDividerLocation(150);
    this.jSplitPane1.setMinimumSize(new Dimension(462, 402));
    this.jSplitPane1.setOneTouchExpandable(true);
    this.jSplitPane1.setAutoscrolls(true);
    this.attribDisplayPane.setLayout(new GridLayout(1, 0));
    this.attribDisplayPane.setPreferredSize(new Dimension(600, 400));
    this.attribDisplayPane.setMinimumSize(new Dimension(300, 400));
    this.jSplitPane1.setRightComponent(this.attribDisplayPane);
    this.treeAttributes.setShowsRootHandles(true);
    this.treeAttributes.setPreferredSize(new Dimension(100, 400));
    this.treeAttributes.setRootVisible(false);
    this.treeAttributes.setMinimumSize(new Dimension(100, 400));
    this.treeAttributes.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent paramAnonymousTreeSelectionEvent) {
            AttributesDialog.this.treeAttributesValueChanged(paramAnonymousTreeSelectionEvent);
        }
    });
    this.jSplitPane1.setLeftComponent(this.treeAttributes);
    getContentPane().add(this.jSplitPane1);
    pack();
}
 
Example 47
Project: openjdk-jdk10   File: JTreeOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JTree.addTreeSelectionListener(TreeSelectionListener)}
 * through queue
 */
public void addTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
    runMapping(new MapVoidAction("addTreeSelectionListener") {
        @Override
        public void map() {
            ((JTree) getSource()).addTreeSelectionListener(treeSelectionListener);
        }
    });
}
 
Example 48
Project: openjdk-jdk10   File: JTreeOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps
 * {@code JTree.removeTreeSelectionListener(TreeSelectionListener)}
 * through queue
 */
public void removeTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
    runMapping(new MapVoidAction("removeTreeSelectionListener") {
        @Override
        public void map() {
            ((JTree) getSource()).removeTreeSelectionListener(treeSelectionListener);
        }
    });
}
 
Example 49
Project: openjdk9   File: JTreeOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JTree.addTreeSelectionListener(TreeSelectionListener)}
 * through queue
 */
public void addTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
    runMapping(new MapVoidAction("addTreeSelectionListener") {
        @Override
        public void map() {
            ((JTree) getSource()).addTreeSelectionListener(treeSelectionListener);
        }
    });
}
 
Example 50
Project: openjdk9   File: JTreeOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps
 * {@code JTree.removeTreeSelectionListener(TreeSelectionListener)}
 * through queue
 */
public void removeTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
    runMapping(new MapVoidAction("removeTreeSelectionListener") {
        @Override
        public void map() {
            ((JTree) getSource()).removeTreeSelectionListener(treeSelectionListener);
        }
    });
}
 
Example 51
Project: balloonist   File: TreeSelectionListenerSupport.java   Source Code and License 5 votes vote down vote up
/**
 * @param tse if the source inside the event is not null, that component will be excluded from
 * the list of components to be notified about the selection.
 */
public void fireValueChanged(TreeSelectionEvent tse)
{
	for (int loop=size()-1; loop>=0; loop--)
	{
		TreeSelectionListener tsl = (TreeSelectionListener) get(loop);
		
		if (tse==null || tsl!=tse.getSource())
		{
			// System.out.println("fireValueChanged: tsl: "+tsl);
			// System.out.println("fireValueChanged: tse.getSource(): "+tse.getSource());
			tsl.valueChanged(tse);
		}
	}
}
 
Example 52
Project: semtool   File: WeightDropDownButton.java   Source Code and License 5 votes vote down vote up
private TreeSelectionListener getTreeSelectionListener( int mode ) {
	return new TreeSelectionListener() {
		private static final int edgeMode = 1;
		private static final int vertMode = 2;
		private final int thisMode = mode;

		@Override
		public void valueChanged( TreeSelectionEvent e ) {
			if ( e.getPath().getPathCount() == 2 ) {
				//this is not a property, this is a node type
				return;
			}

			TreePath path = e.getPath();
			DefaultMutableTreeNode typenode
					= DefaultMutableTreeNode.class.cast( path.getPathComponent( 1 ) );
			URI type = URI.class.cast( typenode.getUserObject() );

			DefaultMutableTreeNode dmtn
					= DefaultMutableTreeNode.class.cast( e.getPath().getLastPathComponent() );
			URI prop = URI.class.cast( dmtn.getUserObject() );

			if ( thisMode == edgeMode ) {
				rescaleEdges( type, prop );
			}
			else if ( thisMode == vertMode ) {
				rescaleVertices( type, prop );
			}
		}
	};
}
 
Example 53
Project: djigger   File: MetricPane.java   Source Code and License 5 votes vote down vote up
public MetricPane(final Session session) {
	super(new BorderLayout());
	
	this.session = session;
	
	metricTree = new JTree(metricTreeModel);
	metricTree.addTreeSelectionListener(new TreeSelectionListener() {
		@Override
		public void valueChanged(TreeSelectionEvent arg0) {
			updateChart();
		}
	});
	JScrollPane metricTreePane = new JScrollPane(metricTree);
	metricTreePane.setPreferredSize(new Dimension(400, 0));
	add(BorderLayout.WEST, metricTreePane);
	
	dataset = new TimeSeriesCollection();
	XYLineAndShapeRenderer dot = new XYLineAndShapeRenderer(true, false);
	
	DateAxis xax = new DateAxis();
	NumberAxis yax = new NumberAxis("");
	
	XYPlot plot = new XYPlot(dataset, xax, yax, dot);
	
	JFreeChart chart = new JFreeChart(plot);
	
	ChartPanel chartPanel = new ChartPanel(chart);
	add(BorderLayout.CENTER,chartPanel);	
	
	queryMetrics();
}
 
Example 54
Project: sldeditor   File: FSTree.java   Source Code and License 5 votes vote down vote up
/**
 * Sets the tree selection callback.
 *
 * @param fileSelection the new tree selection
 */
public void setTreeSelection(FileSelectionInterface fileSelection) {

    addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            if (!shouldIgnoreSelection()) {
                if (fileSelection != null) {
                    fileSelection.treeSelection(e);
                }
            }
        }
    });
}
 
Example 55
Project: j2se_for_android   File: DefaultTreeSelectionModel.java   Source Code and License 5 votes vote down vote up
protected void fireValueChanged(TreeSelectionEvent e) {
	Object[] listeners = listenerList.getListenerList();
	for (int i = listeners.length - 2; i >= 0; i -= 2) {
		if (listeners[i] == TreeSelectionListener.class) {
			((TreeSelectionListener) listeners[i + 1]).valueChanged(e);
		}
	}
}
 
Example 56
Project: j2se_for_android   File: JTree.java   Source Code and License 5 votes vote down vote up
public void addTreeSelectionListener(TreeSelectionListener tsl) {
       list.add(TreeSelectionListener.class,tsl);
       if(list.getListenerCount(TreeSelectionListener.class) != 0
          && selectionRedirector == null) {
           selectionRedirector = new TreeSelectionRedirector();
           selectionModel.addTreeSelectionListener(selectionRedirector);
       }
}
 
Example 57
Project: j2se_for_android   File: JTree.java   Source Code and License 5 votes vote down vote up
public void removeTreeSelectionListener(TreeSelectionListener tsl) {
	list.remove(TreeSelectionListener.class,tsl);
       if(list.getListenerCount(TreeSelectionListener.class) == 0
          && selectionRedirector != null) {
           selectionModel.removeTreeSelectionListener
               (selectionRedirector);
           selectionRedirector = null;
       }
}
 
Example 58
Project: j2se_for_android   File: JTree.java   Source Code and License 5 votes vote down vote up
protected void fireValueChanged(TreeSelectionEvent e) {
	Object[] listeners = list.getListenerList();
	for (int i = listeners.length - 2; i >= 0; i -= 2) {
		if (listeners[i] == TreeSelectionListener.class) {
			((TreeSelectionListener) listeners[i + 1]).valueChanged(e);
		}
	}
}
 
Example 59
Project: sdk   File: AddNodeDialog.java   Source Code and License 5 votes vote down vote up
private void fillList(final ProjectAssetManager mgr) {
    List<String> l = new ArrayList<String>();
    l.addAll(mgr.getProjectShaderNodeDefs());
    l.addAll(mgr.getDependenciesShaderNodeDefs());
    String[] leaves = l.toArray(new String[l.size()]);
    TreeUtil.createTree(jTree1, leaves);
    TreeUtil.expandTree(jTree1, (TreeNode) jTree1.getModel().getRoot(), 10);
    jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    jTree1.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();

            if (node == null) {
                return;
            }


            if (node.isLeaf()) {
                jTabbedPane1.removeAll();
                path = TreeUtil.getPath(node.getUserObjectPath());
                path = path.substring(0, path.lastIndexOf("/"));
                ShaderNodeDefinitionKey k = new ShaderNodeDefinitionKey(path);
                k.setLoadDocumentation(true);
                defList = mgr.loadAsset(k);

                for (ShaderNodeDefinition def : defList) {
                    createDoc(def);
                }

            }
        }
    });
}
 
Example 60
Project: tda   File: TDA.java   Source Code and License 5 votes vote down vote up
/**
 * add a tree listener for enabling/disabling menu and toolbar icons.
 * @param tree
 */
private void addTreeListener(JTree tree) {
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        ViewScrollPane emptyView = null;

        public void valueChanged(TreeSelectionEvent e) {
            getMainMenu().getCloseMenuItem().setEnabled(e.getPath() != null);
            if(getMainMenu().getCloseToolBarButton() != null) {
                getMainMenu().getCloseToolBarButton().setEnabled(e.getPath() != null);
            }
            // reset right pane of the top view:
            
            if(emptyView == null) {
                JEditorPane emptyPane = new JEditorPane("text/html", "<html><body bgcolor=\"ffffff\">   </body></html>");
                emptyPane.setEditable(false);

                emptyView = new ViewScrollPane(emptyPane, runningAsVisualVMPlugin);                    
            }

            if(e.getPath() == null || 
                    !(((DefaultMutableTreeNode) e.getPath().getLastPathComponent()).
                    getUserObject() instanceof Category)) {
                resetPane();
            }
        }
        
        private void resetPane() {
            int dividerLocation = topSplitPane.getDividerLocation();
            topSplitPane.setRightComponent(emptyView);
            topSplitPane.setDividerLocation(dividerLocation);
        }
        
    });
}