当前位置: 首页>>代码示例>>Java>>正文


Java TreeTableModel类代码示例

本文整理汇总了Java中org.jdesktop.swingx.treetable.TreeTableModel的典型用法代码示例。如果您正苦于以下问题:Java TreeTableModel类的具体用法?Java TreeTableModel怎么用?Java TreeTableModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TreeTableModel类属于org.jdesktop.swingx.treetable包,在下文中一共展示了TreeTableModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findNextRow

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
private TreeTableNode findNextRow(final String startName,
                                  final boolean wordsOrder) {
    final TreeTableModel model = getTreeTableModel();
    final int cc = getColumnCount();
    final TreeTableNode node = lastFindIndex;
    nextNode();
    if (node == null && lastFindIndex == null)
        return null;
    do {
        if (findRow(startName, wordsOrder, cc, model, lastFindIndex))
            return lastFindIndex;
        if (node == lastFindIndex)
            return null;
        nextNode();
    } while (true);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:17,代码来源:RowTreeTable.java

示例2: testTableEventOnSetRootNoStructureChange

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #493-swingx: incorrect table events fired.
 * Issue #592-swingx: (no structureChanged table events) is a special
 *   case of the former.
 * 
 * Here: add support to prevent a structureChanged even when setting
 * the root. May be required if the columns are stable and the
 * model lazily loaded. Quick hack would be to add a clientProperty?
 * 
 * @throws InvocationTargetException 
 * @throws InterruptedException 
 */
public void testTableEventOnSetRootNoStructureChange() throws InterruptedException, InvocationTargetException {
    TreeTableModel model = createCustomTreeTableModelFromDefault();
    final JXTreeTable table = new JXTreeTable(model);
    table.setRootVisible(true);
    table.expandAll();
    final TableModelReport report = new TableModelReport();
    table.getModel().addTableModelListener(report);
    ((DefaultTreeTableModel) model).setRoot(new DefaultMutableTreeTableNode("other"));  
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            assertEquals("tableModel must have fired", 1, report.getEventCount());
            assertTrue("event type must be dataChanged " + TableModelReport.printEvent(report.getLastEvent()), 
                    report.isDataChanged(report.getLastEvent()));
        }
    });        
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:31,代码来源:JXTreeTableIssues.java

示例3: testTableEventUpdateOnTreeTableSetValueForRoot

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #493-swingx: JXTreeTable.TreeTableModelAdapter: Inconsistency
 * firing update.
 * 
 * Test update events after updating table.
 * 
 * from [email protected]
 * 
 * @throws InvocationTargetException 
 * @throws InterruptedException 
 */
public void testTableEventUpdateOnTreeTableSetValueForRoot() throws InterruptedException, InvocationTargetException {
    TreeTableModel model = createCustomTreeTableModelFromDefault();
    final JXTreeTable table = new JXTreeTable(model);
    table.setRootVisible(true);
    table.expandAll();
    final int row = 0;
    // sanity
    assertEquals("JTree", table.getValueAt(row, 0).toString());
    assertTrue("root must be editable", table.getModel().isCellEditable(0, 0));
    final TableModelReport report = new TableModelReport();
    table.getModel().addTableModelListener(report);
    // doesn't fire or isn't detectable? 
    // Problem was: model was not-editable.
    table.setValueAt("games", row, 0);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            assertEquals("tableModel must have fired", 1, report.getEventCount());
            assertEquals("the event type must be update " + TableModelReport.printEvent(report.getLastEvent())
                    , 1, report.getUpdateEventCount());
            TableModelEvent event = report.getLastUpdateEvent();
            assertEquals("the updated row ", row, event.getFirstRow());
        }
    });        
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:37,代码来源:JXTreeTableIssues.java

示例4: interactiveTreeTableModelAdapterDelete

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #493-swingx: JXTreeTable.TreeTableModelAdapter: Inconsistency
 * firing delete.
 * 
 * from [email protected]
 */
public void interactiveTreeTableModelAdapterDelete() {
    final TreeTableModel customTreeTableModel = createCustomTreeTableModelFromDefault();
    final JXTreeTable table = new JXTreeTable(customTreeTableModel);
    table.setRootVisible(true);
    table.expandAll();
    JXTree xtree = new JXTree(customTreeTableModel);
    xtree.setRootVisible(true);
    xtree.expandAll();
    final JXFrame frame = wrapWithScrollingInFrame(table, xtree,
            "JXTreeTable.TreeTableModelAdapter: Inconsistency firing update");
    Action changeValue = new AbstractAction("delete first child of sports") {
        @Override
        public void actionPerformed(ActionEvent e) {
            MutableTreeTableNode firstChild = (MutableTreeTableNode) table.getPathForRow(6 +1).getLastPathComponent();
            ((DefaultTreeTableModel) customTreeTableModel).removeNodeFromParent(firstChild);
        }
    };
    addAction(frame, changeValue);
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:JXTreeTableIssues.java

示例5: createTreeTableModelWithLongNode

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * @return
 */
private TreeTableModel createTreeTableModelWithLongNode() {
    MutableTreeTableNode root = createLongNode("some really, maybe really really long text -  "
            + "wrappit .... where needed ");
    root.insert(createLongNode("another really, maybe really really long text -  "
            + "with nothing but junk. wrappit .... where needed"), 0);
    root.insert(createLongNode("another really, maybe really really long text -  "
            + "with nothing but junk. wrappit .... where needed"), 0);
    MutableTreeTableNode node = createLongNode("some really, maybe really really long text -  "
            + "wrappit .... where needed ");
    node.insert(createLongNode("another really, maybe really really long text -  "
            + "with nothing but junk. wrappit .... where needed"), 0);
    root.insert(node, 0);
    root.insert(createLongNode("another really, maybe really really long text -  "
            + "with nothing but junk. wrappit .... where needed"), 0);
    Vector<String> ids = new Vector<String>();
    ids.add("long text");
    ids.add("dummy");
    return new DefaultTreeTableModel(root, ids);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:23,代码来源:JXTreeTableIssues.java

示例6: interactiveTreeTableGetValueRenderer

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Dirty example how to configure a custom renderer to use
 * treeTableModel.getValueAt(...) for showing.
 * 
 */
public void interactiveTreeTableGetValueRenderer() {
    JXTreeTable tree = new JXTreeTable(new ComponentTreeTableModel(new JXFrame()));
    ComponentProvider<?> provider = new CheckBoxProvider(StringValues.TO_STRING) {
        
        @Override
        protected String getValueAsString(CellContext context) {
            // this is dirty because the design idea was to keep the renderer 
            // unaware of the context type
            TreeTableModel model = (TreeTableModel) ((JXTree) context.getComponent()).getModel();
            // beware: currently works only if the node is not a DefaultMutableTreeNode
            // otherwise the WrappingProvider tries to be smart and replaces the node
            // by the userObject before passing on to the wrappee! 
            Object nodeValue = model.getValueAt(context.getValue(), 0);
            return formatter.getString(nodeValue);            
          }

      
    };
    tree.setTreeCellRenderer(new DefaultTreeRenderer(provider));
    tree.expandAll();
    tree.setHighlighters(HighlighterFactory.createSimpleStriping());
    JFrame frame = wrapWithScrollingInFrame(tree, "treeTable and getValueAt renderer");
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:30,代码来源:JXTreeTableIssues.java

示例7: interactiveCustomColumnFactory

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #1379-swingx: support access to underlying treeTableModel of TreeTableModelAdapter.
 * 
 * Needed f.i. in a custom ColumnFactory to configure the hierarchical column specifically.
 */
public void interactiveCustomColumnFactory() {
    JXTreeTable table = new JXTreeTable();
    ColumnFactory factory = new ColumnFactory() {

        /** 
         * @inherited <p>
         */
        @Override
        public void configureTableColumn(TableModel model,
                TableColumnExt columnExt) {
            super.configureTableColumn(model, columnExt);
            if (model instanceof TreeTableModelProvider) {
                TreeTableModel treeTableModel = ((TreeTableModelProvider) model).getTreeTableModel();
                if (treeTableModel.getHierarchicalColumn() == columnExt.getModelIndex()) {
                    columnExt.setTitle("Hierarchical: " + columnExt.getTitle());
                }
            }
        }
    };
    table.setColumnFactory(factory);
    table.setTreeTableModel(new FileSystemModel());
    showWithScrollingInFrame(table, "custom columnFactory");
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:29,代码来源:JXTreeTableVisualCheck.java

示例8: interactiveEditWithComboBox

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
     * Issue #1126: combo editor is closed immediately after starting
     * 
     * Happens if row is not selected at the moment of starting, okay if selected.
     * Inserts on pressed, removes on released. Same for 1.5 and 1.6
     * 
     * Problem was hacker's completeEditing: must only jump in if editing the hierarchical
     * column. Which still leaves the problem if combo editing in hierarchical ... but
     * that's a different issue ... 
     * 
     * Back to start: fix introduced regression on expand/collapse
     */
    public void interactiveEditWithComboBox() {
        // quick for having an editable treeTableModel (non hierarchical column)
        TreeTableModel model = createEditableTreeTableModel();
        JXTreeTable treeTable = new JXTreeTable(model) {

            @Override
            public void removeEditor() {
                // TODO Auto-generated method stub
                super.removeEditor();
            }
            
        };
//        treeTable.setExpandsSelectedPaths(false);
        treeTable.expandAll();
        JComboBox box = new JComboBox(new Object[] {200, 300, 400});
        box.setEditable(true);
        treeTable.getColumn(3).setCellEditor(new DefaultCellEditor(box));
        JTable table = new JXTable(treeTable.getModel());
        JComboBox box2 = new JComboBox(new Object[] {200, 300, 400});
        box2.setEditable(true);
        table.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(box2));
        showWithScrollingInFrame(treeTable, table, "combo editor in column 3");
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:36,代码来源:JXTreeTableVisualCheck.java

示例9: interactiveTreeTableModelEditing

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * visualize editing of the hierarchical column, both
 * in a tree and a treeTable
 *
 */
public void interactiveTreeTableModelEditing() {
    final TreeTableModel model = createMutableVisualizeModel();
    final JXTreeTable table = new JXTreeTable(model);
    JTree tree =  new JTree(model) {

        @Override
        public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            if (value instanceof Component) {
                return ((Component) value).getName();
            }
            return super.convertValueToText(value, selected, expanded, leaf, row, hasFocus);
        }
        
    };
    tree.setEditable(true);
    final JXFrame frame = wrapWithScrollingInFrame(table, tree, "Editing: compare treetable and tree");
    addComponentOrientationToggle(frame);
    frame.setVisible(true);
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:26,代码来源:JXTreeTableVisualCheck.java

示例10: interactiveRToLTreeTableEditor

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
     * Issue #224-swingx: TreeTableEditor not bidi compliant.
     *
     * the textfield for editing is at the wrong position in RToL.
     */
    public void interactiveRToLTreeTableEditor() {
        final TreeTableModel model = createMutableVisualizeModel();
        final JXTreeTable table = new JXTreeTable(model);
//        table.setTreeCellRenderer(new DefaultTreeRenderer());
        table.expandAll();
        
        final JXFrame frame = wrapWithScrollingInFrame(table, new JTable(table.getModel()),
                "Editor: position follows Component orientation");
        addComponentOrientationToggle(frame);
        Action edit = new AbstractAction("edit 1/1") {
            
            @Override
            public void actionPerformed(ActionEvent e) {
                table.editCellAt(1, 1);
            }
        };
        addAction(frame, edit);
        show(frame);
    }
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:JXTreeTableVisualCheck.java

示例11: interactiveTestSetModel

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * see effect of switching treeTableModel.
 * Problem when toggling back to FileSystemModel: hierarchical 
 * column does not show filenames, need to click into table first.
 * JW: fixed. The issue was updating of the conversionMethod 
 * field - needed to be done before calling super.setModel().
 * 
 */
public void interactiveTestSetModel() {
    final JXTreeTable treeTable = new JXTreeTable(treeTableModel);
    treeTable.setColumnControlVisible(true);
    JXFrame frame = wrapWithScrollingInFrame(treeTable, "toggle model");
    frame.setVisible(true);
    final TreeTableModel model = new ComponentTreeTableModel(frame);
    Action action = new AbstractAction("Toggle model") {

        @Override
        public void actionPerformed(ActionEvent e) {
            TreeTableModel myModel = treeTable.getTreeTableModel();
            treeTable.setTreeTableModel(myModel == model ? treeTableModel : model);
            
        }
        
    };
    addAction(frame, action);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:JXTreeTableVisualCheck.java

示例12: testTableEventOnSetNullRoot

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #493-swingx: incorrect table events fired.
 * Issue #592-swingx: (no structureChanged table events) is a special
 *   case of the former.
 *    
 * Here: must fire structureChanged on setRoot(null).
 * fails - because the treeStructureChanged is mapped to a 
 * tableDataChanged.
 *
 * @throws InvocationTargetException 
 * @throws InterruptedException 
 */
@Test
public void testTableEventOnSetNullRoot() throws InterruptedException, InvocationTargetException {
    TreeTableModel model = createCustomTreeTableModelFromDefault();
    final JXTreeTable table = new JXTreeTable(model);
    table.setRootVisible(true);
    table.expandAll();
    final TableModelReport report = new TableModelReport();
    table.getModel().addTableModelListener(report);
    ((DefaultTreeTableModel) model).setRoot(null);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            assertEquals("tableModel must have fired", 1, report.getEventCount());
            assertTrue("event type must be structureChanged " + TableModelReport.printEvent(report.getLastEvent()), 
                    report.isStructureChanged(report.getLastEvent()));
        }
    });        
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:32,代码来源:JXTreeTableUnitTest.java

示例13: testTableEventOnSetRoot

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #493-swingx: incorrect table events fired.
 * Issue #592-swingx: (no structureChanged table events) is a special
 *   case of the former.
 * 
 * Here: must fire structureChanged on setRoot(otherroot).
 * failed - because the treeStructureChanged is mapped to a 
 * tableDataChanged.
 * 
 * @throws InvocationTargetException 
 * @throws InterruptedException 
 */
@Test
public void testTableEventOnSetRoot() throws InterruptedException, InvocationTargetException {
    TreeTableModel model = createCustomTreeTableModelFromDefault();
    final JXTreeTable table = new JXTreeTable(model);
    table.setRootVisible(true);
    table.expandAll();
    final TableModelReport report = new TableModelReport();
    table.getModel().addTableModelListener(report);
    ((DefaultTreeTableModel) model).setRoot(new DefaultMutableTreeTableNode("other"));  
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            assertEquals("tableModel must have fired", 1, report.getEventCount());
            assertTrue("event type must be structureChanged " + TableModelReport.printEvent(report.getLastEvent()), 
                    report.isStructureChanged(report.getLastEvent()));
        }
    });        
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:32,代码来源:JXTreeTableUnitTest.java

示例14: testTableEventOnSetModel

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #493-swingx: incorrect table events fired.
 * Issue #592-swingx: (no structureChanged table events) is a special
 *   case of the former.
 * 
 * Here: must fire structureChanged on setModel.
 * This was okay, because the setTreeTableModel on the table is handled
 * directly (through tableChanged)
 * @throws InvocationTargetException 
 * @throws InterruptedException 
 */
@Test
public void testTableEventOnSetModel() throws InterruptedException, InvocationTargetException {
    TreeTableModel model = createCustomTreeTableModelFromDefault();
    final JXTreeTable table = new JXTreeTable(model);
    table.setRootVisible(true);
    table.expandAll();
    final TableModelReport report = new TableModelReport();
    table.getModel().addTableModelListener(report);
    table.setTreeTableModel(createCustomTreeTableModelFromDefault());  
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            assertEquals("tableModel must have fired", 1, report.getEventCount());
            assertTrue("event type must be structureChanged " + TableModelReport.printEvent(report.getLastEvent()), 
                    report.isStructureChanged(report.getLastEvent()));
        }
    });        
    
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:31,代码来源:JXTreeTableUnitTest.java

示例15: testTableEventUpdateOnTreeTableModelSetValue

import org.jdesktop.swingx.treetable.TreeTableModel; //导入依赖的package包/类
/**
 * Issue #493-swingx: JXTreeTable.TreeTableModelAdapter: Inconsistency
 * firing update.
 * 
 * Test update events after updating treeTableModel.
 * 
 * from [email protected]
 * @throws InvocationTargetException 
 * @throws InterruptedException 
 */
@Test
public void testTableEventUpdateOnTreeTableModelSetValue() throws InterruptedException, InvocationTargetException {
    TreeTableModel model = createCustomTreeTableModelFromDefault();
    final JXTreeTable table = new JXTreeTable(model);
    table.setRootVisible(true);
    table.expandAll();
    final int row = 6;
    // sanity
    assertEquals("sports", table.getValueAt(row, 0).toString());
    final TableModelReport report = new TableModelReport();
    table.getModel().addTableModelListener(report);
    model.setValueAt("games",
            table.getPathForRow(6).getLastPathComponent(), 0);   
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            assertEquals("tableModel must have fired", 1, report.getEventCount());
            assertEquals("the event type must be update", 1, report.getUpdateEventCount());
            TableModelEvent event = report.getLastUpdateEvent();
            assertEquals("the updated row ", row, event.getFirstRow());
        }
    });        
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:34,代码来源:JXTreeTableUnitTest.java


注:本文中的org.jdesktop.swingx.treetable.TreeTableModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。