Search in sources :

Example 76 with DefaultTreeModel

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);
}
Also used : DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 77 with DefaultTreeModel

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();
}
Also used : JTree(javax.swing.JTree) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer)

Example 78 with DefaultTreeModel

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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ArrayList(java.util.ArrayList) List(java.util.List) JDialog(javax.swing.JDialog)

Example 79 with DefaultTreeModel

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);
}
Also used : ArrayList(java.util.ArrayList) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 80 with DefaultTreeModel

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();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Aggregations

DefaultTreeModel (javax.swing.tree.DefaultTreeModel)196 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)99 TreePath (javax.swing.tree.TreePath)50 Tree (com.intellij.ui.treeStructure.Tree)22 Test (org.junit.Test)21 JTree (javax.swing.JTree)17 MockTreeModelListener (com.facebook.buck.intellij.ideabuck.test.util.MockTreeModelListener)16 JScrollPane (javax.swing.JScrollPane)16 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)15 TreeSelectionListener (javax.swing.event.TreeSelectionListener)14 ArrayList (java.util.ArrayList)10 TreeNode (javax.swing.tree.TreeNode)10 NotNull (org.jetbrains.annotations.NotNull)10 Module (com.intellij.openapi.module.Module)9 MouseEvent (java.awt.event.MouseEvent)9 DefaultTreeCellRenderer (javax.swing.tree.DefaultTreeCellRenderer)9 Project (com.intellij.openapi.project.Project)7 javax.swing (javax.swing)7 JPanel (javax.swing.JPanel)7 ColumnTreeBuilder (com.android.tools.adtui.common.ColumnTreeBuilder)6