com.jidesoft.swing.CheckBoxTree Java Examples

The following examples show how to use com.jidesoft.swing.CheckBoxTree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RJideCheckBoxTreeTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectNoSelection() {
    tree = (CheckBoxTree) ComponentUtils.findComponent(CheckBoxTree.class, frame);
    siw(new Runnable() {
        @Override
        public void run() {
            tree.expandRow(0);
        }
    });
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override
        public void run() {
            RTree rTree = new RTree(tree, null, null, lr);
            rTree.focusLost(null);
        }
    });
    AssertJUnit.assertEquals(0, lr.getCalls().size());
}
 
Example #2
Source File: RJideCheckBoxTreeTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectUnCheckedCheckBox() throws Throwable {
    tree = (CheckBoxTree) ComponentUtils.findComponent(CheckBoxTree.class, frame);
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override
        public void run() {
            tree.expandRow(0);
            TreePath pathForRow = tree.getPathForRow(1);
            Rectangle cb = tree.getPathBounds(pathForRow);
            RTree rTree = new RTree(tree, null, new Point(cb.x + 2, cb.y + 2), lr);
            tree.getCheckBoxTreeSelectionModel().setSelectionPath(pathForRow);
            rTree.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("/Root/Child 1", call.getCellinfo());
    AssertJUnit.assertEquals("true", call.getState());
}
 
Example #3
Source File: RJideCheckBoxTreeTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Test
public void selectCheckedCheckBoxUnchecked() {
    tree = (CheckBoxTree) ComponentUtils.findComponent(CheckBoxTree.class, frame);
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override
        public void run() {
            tree.expandRow(0);
            TreePath row1 = tree.getPathForRow(1);
            Rectangle cb = tree.getPathBounds(row1);
            tree.getCheckBoxTreeSelectionModel().setSelectionPath(row1);
            RTree rTree = new RTree(tree, null, new Point(cb.x + 2, cb.y + 2), lr);
            tree.getCheckBoxTreeSelectionModel().removeSelectionPath(row1);
            rTree.focusLost(null);
        }
    });
    Call call = lr.getCall();
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("/Root/Child 1", call.getCellinfo());
    AssertJUnit.assertEquals("false", call.getState());
}
 
Example #4
Source File: JideCheckBoxTreeNodeElement.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static boolean clicksInCheckBox(CheckBoxTree tree, Point e, TreePath path) {
    int hotspot = new JCheckBox().getPreferredSize().width;
    if (!tree.isCheckBoxVisible(path)) {
        return false;
    } else {
        Rectangle bounds = tree.getPathBounds(path);
        if (tree.getComponentOrientation().isLeftToRight()) {
            return e.getX() < bounds.x + hotspot;
        } else {
            return e.getX() > bounds.x + bounds.width - hotspot;
        }
    }
}
 
Example #5
Source File: JideCheckBoxTreeTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Test
public void selectCheckBoxNode() throws Throwable {
    driver = new JavaAgent();
    IJavaElement tree = driver.findElementByCssSelector("tree");
    tree.click();
    IJavaElement root = tree.findElementByCssSelector(".::root::editor");
    AssertJUnit.assertEquals("Root", root.getText());
    root.click();
    root.marathon_select("true");
    CheckBoxTree listComponent = (CheckBoxTree) ComponentUtils.findComponent(CheckBoxTree.class, frame);
    Assert.assertTrue(listComponent.getCheckBoxTreeSelectionModel().isRowSelected(0));
}
 
Example #6
Source File: JideCheckBoxTreeTest.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Test
public void uncheckCheckedCheckBoxRoot() throws Throwable {
    driver = new JavaAgent();
    IJavaElement tree = driver.findElementByCssSelector("tree");
    tree.click();
    IJavaElement root = tree.findElementByCssSelector(".::root::editor");
    AssertJUnit.assertEquals("Root", root.getText());
    root.click();
    CheckBoxTree listComponent = (CheckBoxTree) ComponentUtils.findComponent(CheckBoxTree.class, frame);
    root.marathon_select("true");
    Assert.assertTrue(listComponent.getCheckBoxTreeSelectionModel().isRowSelected(0));
    root.marathon_select("false");
    Assert.assertFalse(listComponent.getCheckBoxTreeSelectionModel().isRowSelected(0));

}
 
Example #7
Source File: RJideCheckBoxTreeNode.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public boolean isSelectCall() {
    CheckBoxTreeCellRenderer cbListRenderer = (CheckBoxTreeCellRenderer) getComponent();
    if (cbListRenderer instanceof JComponent) {
        CheckBoxTree tree = (CheckBoxTree) cbListRenderer.getClientProperty("jtree");
        int row = (Integer) cbListRenderer.getClientProperty("row");
        return JideCheckBoxTreeNodeElement.clicksInCheckBox(tree, point, tree.getPathForRow(row));
    }
    return false;
}
 
Example #8
Source File: GroupedBandChoosingStrategy.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public JPanel createCheckersPane() {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    Map<String, Integer> groupNodeMap = initGrouping(root);
    List<TreePath> selectedPaths = new ArrayList<>();
    addBandCheckBoxes(root, selectedPaths, groupNodeMap);
    addTiePointGridCheckBoxes(root, selectedPaths, groupNodeMap);
    removeEmptyGroups(root, groupNodeMap);

    TreeModel treeModel = new DefaultTreeModel(root);

    checkBoxTree = new CheckBoxTree(treeModel);
    checkBoxTree.getCheckBoxTreeSelectionModel().setSelectionPaths(selectedPaths.toArray(new TreePath[selectedPaths.size()]));
    checkBoxTree.setRootVisible(false);
    checkBoxTree.setShowsRootHandles(true);
    checkBoxTree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            updateCheckBoxStates();
        }
    });
    final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
    renderer.setFont(SMALL_ITALIC_FONT);
    renderer.setLeafIcon(null);
    renderer.setOpenIcon(null);
    renderer.setClosedIcon(null);
    Color color = new Color(240, 240, 240);
    checkBoxTree.setBackground(color);
    renderer.setBackgroundSelectionColor(color);
    renderer.setBackgroundNonSelectionColor(color);
    renderer.setBorderSelectionColor(color);
    renderer.setTextSelectionColor(Color.BLACK);

    GridBagConstraints gbc2 = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=BOTH");
    final JPanel checkersPane = GridBagUtils.createPanel();
    GridBagUtils.addToPanel(checkersPane, checkBoxTree, gbc2, "weightx=1.0,weighty=1.0");
    return checkersPane;
}
 
Example #9
Source File: LayerManagerForm.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private CheckBoxTree createCheckBoxTree(LayerTreeModel treeModel) {

        final CheckBoxTree checkBoxTree = new CheckBoxTree(treeModel) {
            @Override
            public boolean isPathEditable(TreePath path) {
                Layer layer = getLayer(path);
                if (layer != null) {
                    return isLayerNameEditable(layer);
                }
                return false;
            }  
        };
        checkBoxTree.setRootVisible(false);
        checkBoxTree.setShowsRootHandles(true);
        checkBoxTree.setDigIn(false);

        checkBoxTree.setEditable(true);
        checkBoxTree.setDragEnabled(true);
        checkBoxTree.setDropMode(DropMode.ON_OR_INSERT);
        checkBoxTree.setTransferHandler(new LayerTreeTransferHandler(view, checkBoxTree));

        checkBoxTree.getSelectionModel().addTreeSelectionListener(new LayerSelectionListener());

        final CheckBoxTreeSelectionModel checkBoxSelectionModel = checkBoxTree.getCheckBoxTreeSelectionModel();
        checkBoxSelectionModel.addTreeSelectionListener(new CheckBoxTreeSelectionListener());

        final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) checkBoxTree.getActualCellRenderer();
        renderer.setLeafIcon(null);
        renderer.setClosedIcon(null);
        renderer.setOpenIcon(null);
        return checkBoxTree;
    }