本文整理汇总了Java中javax.swing.event.TreeSelectionEvent类的典型用法代码示例。如果您正苦于以下问题:Java TreeSelectionEvent类的具体用法?Java TreeSelectionEvent怎么用?Java TreeSelectionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TreeSelectionEvent类属于javax.swing.event包,在下文中一共展示了TreeSelectionEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent ev) {
TreePath[] paths = tree.getSelectionPaths();
if (paths == null) {
// part of bugfix #37279, if DnD is active then is useless select a nearby node
if (ExplorerDnDManager.getDefault().isDnDActive()) {
return;
}
callSelectionChanged(new Node[0]);
} else {
// we need to force no changes to nodes hierarchy =>
// we are requesting read request, but it is not necessary
// to execute the next action immediatelly, so postReadRequest
// should be enough
readAccessPaths = paths;
Children.MUTEX.postReadRequest(this);
}
}
示例2: HintsPanel
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
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);
}
}
});
}
}
示例3: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent e) {
if (e.isAddedPath()) {
otherTreeSelectionModel.clearSelection();
}
int idx = treeModel.getIndexOfChild(treeModel.getRoot(), e.getPath().getLastPathComponent());
if (idx >= 0) {
if (otherListModel != null) {
idx += otherListModel.getSize() + 1;
}
if (e.isAddedPath()) {
list.setSelectionInterval(idx, idx);
} else {
list.removeSelectionInterval(idx, idx);
}
} else {
list.clearSelection();
}
}
示例4: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath newLeadSelectionPath = e.getNewLeadSelectionPath();
if (newLeadSelectionPath == null) {
return;
}
Object lastPathComponent = newLeadSelectionPath.getLastPathComponent();
if (lastPathComponent instanceof ValueSourceTreeNode) {
ValueSourceTreeNode valueSourceNode = (ValueSourceTreeNode) lastPathComponent;
// get the selected PVC
ValueSource selectedValueSource = valueSourceNode.getUserObject();
if (selectedValueSource == currentValueSource) {
return;
}
// change current PlotValueConfig
currentValueSource = selectedValueSource;
} else {
currentValueSource = null;
}
}
示例5: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath newLeadSelectionPath = e.getNewLeadSelectionPath();
if (newLeadSelectionPath == null) {
selectedRangeAxisConfig = null;
return;
}
Object lastPathComponent = newLeadSelectionPath.getLastPathComponent();
if (lastPathComponent instanceof RangeAxisConfigTreeNode) {
RangeAxisConfig selectedConfig = ((RangeAxisConfigTreeNode) lastPathComponent).getUserObject();
selectedRangeAxisConfig = selectedConfig;
adaptGUI();
} else {
selectedRangeAxisConfig = null;
}
}
示例6: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent e) {
TreePath[] paths = getSelectionPaths();
// If only one item has been selected, then change the text in the
// description area
if (paths == null) {
return;
}
if (paths.length == 1) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[0].getLastPathComponent();
if (!node.getAllowsChildren()) {
ClusterTreeLeaf leaf = (ClusterTreeLeaf) node.getUserObject();
ObjectVisualizer viz = ObjectVisualizerService.getVisualizerForObject(clusterModel);
viz.startVisualization(leaf.getId());
}
}
}
示例7: AvailableTreeTable
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
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);
}
}
});
}
示例8: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
/** Required by TreeSelectionListener interface. */
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node == null)
return;
Object nodeInfo = node.getUserObject();
if (node.isLeaf()) {
BookInfo book = (BookInfo) nodeInfo;
displayURL(book.bookURL);
if (DEBUG) {
System.out.print(book.bookURL + ": \n ");
}
} else {
displayURL(helpURL);
}
if (DEBUG) {
System.out.println(nodeInfo.toString());
}
}
示例9: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
public void valueChanged(TreeSelectionEvent e) {
super.valueChanged(e);
final TreePath p = e.getPath();
if (p != null) {
final DefaultMutableTreeNode node =
(DefaultMutableTreeNode) p.getLastPathComponent();
Object x[] = node.getUserObjectPath();
Configurable[] userObjectPath = new Configurable[x.length];
for (int i = 0; i < x.length; i++) {
userObjectPath[i] = (Configurable) x[i];
}
path = ArrayUtils.copyOfRange(userObjectPath, 1, userObjectPath.length);
}
else {
path = null;
}
}
示例10: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
/** Required by TreeSelectionListener interface. */
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
if (node == null) return;
Object nodeInfo = node.getUserObject();
if (node.isLeaf()) {
BookInfo book = (BookInfo)nodeInfo;
displayURL(book.bookURL);
if (DEBUG) {
System.out.print(book.bookURL + ": \n ");
}
} else {
displayURL(helpURL);
}
if (DEBUG) {
System.out.println(nodeInfo.toString());
}
}
示例11: OurTree
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
/** 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());
}
});
}
示例12: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
/**
* Emphasises/deemphasises cells in the associated jmodel, based on the list
* selection.
*/
@Override
public void valueChanged(TreeSelectionEvent e) {
Set<JCell<?>> emphSet = new HashSet<>();
TreePath[] selectionPaths = getSelectionPaths();
if (selectionPaths != null) {
for (TreePath selectedPath : selectionPaths) {
Object treeNode = selectedPath.getLastPathComponent();
if (treeNode instanceof LabelTree.EntryNode) {
Entry entry = ((EntryNode) treeNode).getEntry();
Set<JCell<G>> occurrences = getFilter().getJCells(entry);
if (occurrences != null) {
emphSet.addAll(occurrences);
}
}
}
}
this.jGraph.setSelectionCells(emphSet.toArray());
}
示例13: createInnerComponent
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
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();
}
示例14: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
/**
* This function analyses a tree selection event and calls the
* right methods to take care of building the requested unit's
* details.
*
* @param event The incoming TreeSelectionEvent.
*/
@Override
public void valueChanged(TreeSelectionEvent event) {
detailPanel.removeAll();
DefaultMutableTreeNode node
= (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (node != null) {
if (node.isLeaf()) {
OptionGroup group = (OptionGroup) node.getUserObject();
for (Option option : group.getOptions()) {
addOptionUI(option, editable && group.isEditable());
}
} else {
tree.expandPath(event.getPath());
}
}
detailPanel.revalidate();
detailPanel.repaint();
}
示例15: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent evt) {
// Get all nodes whose selection status has changed
TreePath[] paths = evt.getPaths();
if (paths.length > 0
&& evt.isAddedPath(0)
&& paths[0].getLastPathComponent() instanceof DefaultMutableTreeNode) {
if (((DefaultMutableTreeNode) paths[0].getLastPathComponent())
.isLeaf()
&& !((DefaultMutableTreeNode) paths[0]
.getLastPathComponent()).isRoot()) {
// a leaf has been selected, allow delete relation
deleteRelationButton.setEnabled(true);
} else {
deleteRelationButton.setEnabled(false);
}
}
}