use of javax.swing.tree.DefaultTreeModel in project jabref by JabRef.
the class FindUnlinkedFilesDialog method searchFinishedHandler.
/**
* Will be called from the Thread in which the "unlinked files search" is
* processed. As the result of the search, the root node of the determined
* file structure is passed.
*
* @param rootNode
* The root of the file structure as the result of the search.
*/
private void searchFinishedHandler(CheckableTreeNode rootNode) {
treeModel = new DefaultTreeModel(rootNode);
tree.setModel(treeModel);
tree.setRootVisible(rootNode.getChildCount() > 0);
tree.invalidate();
tree.repaint();
progressBarSearching.setVisible(false);
labelSearchingDirectoryInfo.setVisible(false);
buttonScan.setVisible(true);
actionSelectAll.actionPerformed(null);
disOrEnableDialog(true);
buttonApply.setEnabled(true);
}
use of javax.swing.tree.DefaultTreeModel in project JMRI by JMRI.
the class CatalogPanel method init.
protected void init(boolean treeDnD) {
_model = new DefaultTreeModel(new CatalogTreeNode("mainRoot"));
if (treeDnD) {
// index editor (right pane)
_dTree = new DropJTree(_model);
_noDrag = true;
} else {
// Catalog (left pane index editor or all icon editors)
_dTree = new JTree(_model);
_noDrag = false;
}
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setLeafIcon(renderer.getClosedIcon());
_dTree.setCellRenderer(renderer);
_dTree.setRootVisible(false);
_dTree.setShowsRootHandles(true);
_dTree.setScrollsOnExpand(true);
//_dTree.setDropMode(DropMode.ON);
_dTree.getSelectionModel().setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
_dTree.addTreeSelectionListener((TreeSelectionEvent e) -> {
updatePanel();
});
_dTree.setExpandsSelectedPaths(true);
_treePane.setViewportView(_dTree);
// setupPanel();
}
use of javax.swing.tree.DefaultTreeModel in project JMRI by JMRI.
the class WarrantRoute method pickRoute.
/**
* Callback from RouteFinder - several routes found
*
* @param destNodes the destination blocks
* @param routeTree the routes
*/
protected void pickRoute(List<DefaultMutableTreeNode> destNodes, DefaultTreeModel routeTree) {
if (destNodes.size() == 1) {
showRoute(destNodes.get(0), routeTree);
selectedRoute(_orders);
return;
}
_pickRouteDialog = new JDialog(this, Bundle.getMessage("DialogTitle"), false);
_pickRouteDialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
clearTempWarrant();
}
});
_tempWarrant = null;
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout(5, 5));
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.add(new JLabel(Bundle.getMessage("NumberRoutes1", destNodes.size())));
panel.add(new JLabel(Bundle.getMessage("NumberRoutes2")));
mainPanel.add(panel, BorderLayout.NORTH);
ButtonGroup buttons = new ButtonGroup();
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
for (int i = 0; i < destNodes.size(); i++) {
JRadioButton button = new JRadioButton(Bundle.getMessage("RouteSize", i + 1, destNodes.get(i).getLevel() + 1));
button.setActionCommand("" + i);
button.addActionListener((ActionEvent e) -> {
clearTempWarrant();
});
buttons.add(button);
panel.add(button);
}
JScrollPane scrollPane = new JScrollPane(panel);
mainPanel.add(scrollPane, BorderLayout.CENTER);
JButton ok = new JButton(Bundle.getMessage("ButtonSelect"));
ok.addActionListener(new ActionListener() {
ButtonGroup buts;
JDialog dialog;
List<DefaultMutableTreeNode> dNodes;
DefaultTreeModel tree;
@Override
public void actionPerformed(ActionEvent e) {
if (buts.getSelection() != null) {
clearTempWarrant();
int i = Integer.parseInt(buttons.getSelection().getActionCommand());
showRoute(dNodes.get(i), tree);
selectedRoute(_orders);
dialog.dispose();
} else {
showWarning(Bundle.getMessage("SelectRoute"));
}
}
ActionListener init(ButtonGroup bg, JDialog d, List<DefaultMutableTreeNode> dn, DefaultTreeModel t) {
buts = bg;
dialog = d;
dNodes = dn;
tree = t;
return this;
}
}.init(buttons, _pickRouteDialog, destNodes, routeTree));
ok.setMaximumSize(ok.getPreferredSize());
JButton show = new JButton(Bundle.getMessage("ButtonReview"));
show.addActionListener(new ActionListener() {
ButtonGroup buts;
List<DefaultMutableTreeNode> destinationNodes;
DefaultTreeModel tree;
@Override
public void actionPerformed(ActionEvent e) {
if (buts.getSelection() != null) {
clearTempWarrant();
int i = Integer.parseInt(buttons.getSelection().getActionCommand());
showRoute(destinationNodes.get(i), tree);
showTempWarrant(_orders);
} else {
showWarning(Bundle.getMessage("SelectRoute"));
}
}
ActionListener init(ButtonGroup bg, List<DefaultMutableTreeNode> dn, DefaultTreeModel t) {
buts = bg;
destinationNodes = dn;
tree = t;
return this;
}
}.init(buttons, destNodes, routeTree));
show.setMaximumSize(show.getPreferredSize());
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(show);
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(ok);
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
mainPanel.add(panel, BorderLayout.SOUTH);
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(makeRouteTablePanel());
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
panel.add(mainPanel);
panel.add(Box.createHorizontalStrut(STRUT_SIZE));
_pickRouteDialog.getContentPane().add(panel);
_pickRouteDialog.setLocation(getLocation().x - 20, getLocation().y + 150);
_pickRouteDialog.pack();
_pickRouteDialog.setVisible(true);
}
use of javax.swing.tree.DefaultTreeModel in project JMRI by JMRI.
the class RouteFinder method run.
@Override
public void run() {
_destBlock = _destBlockOrder.getBlock();
_dPathName = _destBlockOrder.getPathName();
_dEntryName = _destBlockOrder.getEntryName();
_viaBlock = null;
_vPathName = null;
if (_viaBlockOrder != null) {
_vPathName = _viaBlockOrder.getPathName();
_viaBlock = _viaBlockOrder.getBlock();
}
_avoidBlock = null;
_aPathName = null;
if (_avoidBlockOrder != null) {
_aPathName = _avoidBlockOrder.getPathName();
_avoidBlock = _avoidBlockOrder.getBlock();
}
_destNodes = new ArrayList<>();
_quit = false;
int level = 0;
RouteNode root = new RouteNode(_originBlockOrder, (_viaBlockOrder != null));
_tree = new DefaultTreeModel(root);
ArrayList<RouteNode> nodes = new ArrayList<>();
nodes.add(root);
while (level < _maxBlocks && !_quit) {
nodes = makeLevel(nodes, level);
level++;
// _pcs.firePropertyChange("RouteSearch", Integer.valueOf(level), Integer.valueOf(_destNodes.size()));
}
if (_destNodes.isEmpty()) {
_caller.debugRoute(_tree, _originBlockOrder, _destBlockOrder);
} else {
_caller.pickRoute(_destNodes, _tree);
}
// _pcs.removePropertyChangeListener(_caller);
}
use of javax.swing.tree.DefaultTreeModel in project android by JetBrains.
the class LayersTree method setImage.
void setImage(@Nullable Image image) {
myRoot = new DefaultMutableTreeNode("Layers");
if (image != null) {
addLayers(myRoot, image.getLayers());
}
DefaultTreeModel model = (DefaultTreeModel) getModel();
model.setRoot(myRoot);
model.reload();
expandAllRows();
}
Aggregations