本文整理汇总了Java中org.jdesktop.swingx.treetable.DefaultTreeTableModel类的典型用法代码示例。如果您正苦于以下问题:Java DefaultTreeTableModel类的具体用法?Java DefaultTreeTableModel怎么用?Java DefaultTreeTableModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultTreeTableModel类属于org.jdesktop.swingx.treetable包,在下文中一共展示了DefaultTreeTableModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTableEventOnSetRootNoStructureChange
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的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()));
}
});
}
示例2: interactiveTreeTableModelAdapterDelete
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的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);
}
示例3: createTreeTableModelWithLongNode
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的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);
}
示例4: testTableEventOnSetNullRoot
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的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()));
}
});
}
示例5: testTableEventOnSetRoot
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的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()));
}
});
}
示例6: testIsHierarchical
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
/**
* Clarify contract of isHierarchical.
*/
@Test
public void testIsHierarchical() {
TreeTableModel model = new DefaultTreeTableModel();
//sanity
assertEquals(-1, model.getHierarchicalColumn());
JXTreeTable treeTable = new JXTreeTable(model);
assertEquals(model.getHierarchicalColumn(), treeTable.getHierarchicalColumn());
// either this or throw an exception for -1 index
// illegal view index anyway
try {
treeTable.isHierarchical(-1);
fail("expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
//success
}
}
示例7: createNamedColorTreeTableModel
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
/**
*
* Creates and returns a DefaultTreeModel with a String root and
* children of type NamedColor wrapped into DefaultMutableTreeNodes.
* @return a DefaultTreeModel containing items of type NamedColor.
*/
public static TreeTableModel createNamedColorTreeTableModel() {
final TableModel wrappee = new AncientSwingTeam();
DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode("Named Colors");
for (int i = 0; i < wrappee.getRowCount(); i++) {
MutableTreeTableNode node = createNamedColorTreeTableNode(wrappee,
i);
root.add(node);
}
return new DefaultTreeTableModel(root, Arrays.asList(new String[] { "Color", "LastName" }));
}
示例8: testNewRootNull
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
/**
* test modelSupport newRoot: not null root.
*
*/
@Test
public void testNewRootNull() {
DefaultTreeTableModel model = new DefaultTreeTableModel();
assertNull(model.getRoot());
TreeModelSupport support = new TreeModelSupport(model);
support.addTreeModelListener(report);
support.fireNewRoot();
assertEquals(1, report.getEventCount());
assertEquals(1, report.getStructureEventCount());
TreeModelEvent structureEvent = report.getLastStructureEvent();
assertNull(structureEvent.getChildren());
assertNull(structureEvent.getTreePath());
assertNull(structureEvent.getPath());
}
示例9: testRendererProperties
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
/**
* Issue #151: renderer properties ignored after setting treeTableModel.
*
*/
@Test
public void testRendererProperties() {
JXTreeTable treeTable = new JXTreeTable(treeTableModel);
// storing negates of properties
boolean expandsSelected = !treeTable.getExpandsSelectedPaths();
boolean scrollsOnExpand = !treeTable.getScrollsOnExpand();
boolean showRootHandles = !treeTable.getShowsRootHandles();
boolean rootVisible = !treeTable.isRootVisible();
// setting negates properties
treeTable.setExpandsSelectedPaths(expandsSelected);
treeTable.setScrollsOnExpand(scrollsOnExpand);
treeTable.setShowsRootHandles(showRootHandles);
treeTable.setRootVisible(rootVisible);
// assert negates are set - sanity assert
assertEquals("expand selected", expandsSelected, treeTable
.getExpandsSelectedPaths());
assertEquals("scrolls expand", scrollsOnExpand, treeTable
.getScrollsOnExpand());
assertEquals("shows handles", showRootHandles, treeTable
.getShowsRootHandles());
assertEquals("root visible", rootVisible, treeTable.isRootVisible());
// setting a new model
treeTable.setTreeTableModel(new DefaultTreeTableModel());
// assert negates are set
assertEquals("expand selected", expandsSelected, treeTable
.getExpandsSelectedPaths());
assertEquals("scrolls expand", scrollsOnExpand, treeTable
.getScrollsOnExpand());
assertEquals("shows handles", showRootHandles, treeTable
.getShowsRootHandles());
assertEquals("root visible", rootVisible, treeTable.isRootVisible());
}
示例10: convertDefaultTreeModel
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
public static DefaultTreeTableModel convertDefaultTreeModel(DefaultTreeModel model) {
Vector<String> v = new Vector<String>();
v.add("A");
DefaultTreeTableModel ttModel = new DefaultTreeTableModel(null, v);
ttModel.setRoot(convertDefaultMutableTreeNode((DefaultMutableTreeNode) model.getRoot()));
return ttModel;
}
示例11: GuildSearchService
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
public GuildSearchService(DefaultTreeTableModel model, String userNameOrId, boolean preciMatch) {
this.model = model;
this.preciMatch = preciMatch;
this.userNameOrId = userNameOrId;
this.databaseName = ConfigManager.getConfigAsString(ConfigKey.mongoDBName);
this.namespace = ConfigManager.getConfigAsString(ConfigKey.mongoNamespace);
}
示例12: GuildBagSearchService
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
public GuildBagSearchService(DefaultTreeTableModel model, String userNameOrId, boolean preciMatch) {
this.model = model;
this.preciMatch = preciMatch;
this.userNameOrId = userNameOrId;
this.databaseName = ConfigManager.getConfigAsString(ConfigKey.mongoDBName);
this.namespace = ConfigManager.getConfigAsString(ConfigKey.mongoNamespace);
}
示例13: GuildMemberSearchService
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
public GuildMemberSearchService(DefaultTreeTableModel model, String userNameOrId, boolean preciMatch) {
this.model = model;
this.preciMatch = preciMatch;
this.userNameOrId = userNameOrId;
this.databaseName = ConfigManager.getConfigAsString(ConfigKey.mongoDBName);
this.namespace = ConfigManager.getConfigAsString(ConfigKey.mongoNamespace);
}
示例14: AccountSearchService
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
public AccountSearchService(DefaultTreeTableModel model, String userNameOrId, boolean preciMatch) {
this.model = model;
this.preciMatch = preciMatch;
this.userNameOrId = userNameOrId;
this.databaseName = ConfigManager.getConfigAsString(ConfigKey.mongoDBName);
this.namespace = ConfigManager.getConfigAsString(ConfigKey.mongoNamespace);
}
示例15: UserSearchService
import org.jdesktop.swingx.treetable.DefaultTreeTableModel; //导入依赖的package包/类
public UserSearchService(DefaultTreeTableModel model,
String userNameOrId, boolean preciMatch) {
this.model = model;
this.preciMatch = preciMatch;
this.userNameOrId = userNameOrId;
this.databaseName = ConfigManager.getConfigAsString(ConfigKey.mongoDBName);
this.namespace = ConfigManager.getConfigAsString(ConfigKey.mongoNamespace);
}