use of javax.swing.event.TreeSelectionEvent in project android-classyshark by google.
the class FilesTree method configureJTree.
private void configureJTree(final JTree jTree) {
jTree.setRootVisible(false);
DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
cellRenderer.setFont(new Font("Monospaced", Font.PLAIN, 20));
jTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
jTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
Object selection = jTree.getLastSelectedPathComponent();
if (selection == null)
return;
DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection;
if (selection.toString().endsWith(".dex")) {
FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
return;
}
if (selection.toString().endsWith(".jar")) {
FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
return;
}
if (selection.toString().endsWith(".apk")) {
FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
return;
}
if (selection.toString().endsWith(".so")) {
FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
return;
}
if (!defaultMutableTreeNode.isLeaf())
return;
if (FilesTree.this.viewerController != null) {
if (defaultMutableTreeNode.getUserObject() instanceof String) {
FilesTree.this.viewerController.onSelectedClassName((String) defaultMutableTreeNode.getUserObject());
} else {
FilesTree.this.viewerController.onSelectedClassName(((NodeInfo) defaultMutableTreeNode.getUserObject()).fullname);
}
}
}
});
}
use of javax.swing.event.TreeSelectionEvent in project android-classyshark by google.
the class MethodsCountPanel method setup.
private void setup() {
this.setLayout(new BorderLayout());
treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(null));
jTree = new JTree(treeModel);
jTree.setRootVisible(false);
jTree.setCellRenderer(new CellRenderer());
theme.applyTo(jTree);
DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
cellRenderer.setFont(new Font("Monospaced", Font.PLAIN, 20));
jTree.setCellRenderer(cellRenderer);
jTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
Object selection = jTree.getLastSelectedPathComponent();
DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection;
ClassNode node = (ClassNode) defaultMutableTreeNode.getUserObject();
viewerController.onSelectedMethodCount(node);
}
});
JScrollPane jScrollPane = new JScrollPane(jTree);
this.setBorder(new EmptyBorder(0, 0, 0, 0));
this.add(jScrollPane, BorderLayout.CENTER);
theme.applyTo(jScrollPane);
jTree.setDragEnabled(true);
jTree.setTransferHandler(new FileTransferHandler(viewerController));
}
use of javax.swing.event.TreeSelectionEvent in project qi4j-sdk by Qi4j.
the class EntityViewer method initUI.
private void initUI() {
propertiesPanel = new PropertiesPanel();
propertiesPanel.initializeQi4J(qi4jspi);
propertiesAreaPane.add(propertiesPanel, BorderLayout.CENTER);
treePanel = new TreePanel();
treePanel.initializeQi4J(qi4jspi, model);
treePanel.reload();
splitPane.setLeftComponent(treePanel);
splitPane.setDividerLocation(200);
DefaultComboBoxModel entityComboModel = new DefaultComboBoxModel();
entitiesCombo.setModel(entityComboModel);
entitiesCombo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent evt) {
entitiesComboItemStateChanged(evt);
}
});
treePanel.getTreeComponent().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent evt) {
treePanelValueChanged(evt);
}
});
initEntityCombo(entityComboModel);
}
use of javax.swing.event.TreeSelectionEvent in project qi4j-sdk by Qi4j.
the class TreeModelPane method initQi4J.
/**
* Initialize Qi4J for this component
*
* @param descriptor the Application descriptor
*/
public void initQi4J(ApplicationDetailDescriptor descriptor) {
this.descriptor = descriptor;
// Application Application = (Application) application;
// ApplicationDetailDescriptor descriptor = ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor( Application );
// traverse the model and build JTree representation
MutableTreeNode rootNode1 = StructureModelBuilder.build(descriptor);
MutableTreeNode rootNode2 = TypeModelBuilder.build(descriptor);
structureTree.setModel(new DefaultTreeModel(rootNode1));
typeTree.setModel(new DefaultTreeModel(rootNode2));
structureTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent evt) {
structureTreeValueChanged();
}
});
typeTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent evt) {
typeTreeValueChanged();
}
});
}
use of javax.swing.event.TreeSelectionEvent in project java-swing-tips by aterai.
the class BackgroundTask method valueChanged.
@Override
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent();
if (!node.isLeaf()) {
return;
}
File parent = (File) node.getUserObject();
if (!parent.isDirectory()) {
return;
}
JTree tree = (JTree) e.getSource();
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
new BackgroundTask(fileSystemView, parent) {
@Override
protected void process(List<File> chunks) {
if (isCancelled()) {
return;
}
if (!tree.isDisplayable()) {
cancel(true);
return;
}
chunks.stream().map(DefaultMutableTreeNode::new).forEach(child -> model.insertNodeInto(child, node, node.getChildCount()));
// model.reload(node);
}
}.execute();
}
Aggregations