use of org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode in project GsonFormat by zzz40500.
the class FieldsDialog method createData.
private DefaultMutableTreeTableNode createData(ClassEntity classEntity) {
DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode(classEntity);
createDataNode(root, classEntity);
return root;
}
use of org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode in project GsonFormat by zzz40500.
the class FieldsDialog method initListener.
private void initListener(ClassEntity classEntity, String generateClassStr) {
this.classEntity = classEntity;
defaultMutableTreeTableNodeList = new ArrayList<DefaultMutableTreeTableNode>();
JXTreeTable treetable = new JXTreeTable(new FiledTreeTableModel(createData(classEntity)));
CheckTreeTableManager manager = new CheckTreeTableManager(treetable);
manager.getSelectionModel().addPathsByNodes(defaultMutableTreeTableNodeList);
treetable.getColumnModel().getColumn(0).setPreferredWidth(150);
// treetable.setSelectionBackground(treetable.getBackground());
treetable.expandAll();
treetable.setCellSelectionEnabled(false);
final DefaultListSelectionModel defaultListSelectionModel = new DefaultListSelectionModel();
treetable.setSelectionModel(defaultListSelectionModel);
defaultListSelectionModel.setSelectionMode(SINGLE_SELECTION);
defaultListSelectionModel.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
defaultListSelectionModel.clearSelection();
}
});
defaultMutableTreeTableNodeList = null;
treetable.setRowHeight(30);
sp.setViewportView(treetable);
generateClass.setText(generateClassStr);
buttonOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onOK();
}
});
buttonCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onCancel();
}
});
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
onCancel();
}
});
contentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onCancel();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
contentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onOK();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
use of org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode in project GsonFormat by zzz40500.
the class FieldsDialog method createDataNode.
private void createDataNode(DefaultMutableTreeTableNode root, ClassEntity innerClassEntity) {
for (FieldEntity field : innerClassEntity.getFields()) {
DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(field);
root.add(node);
defaultMutableTreeTableNodeList.add(node);
}
for (ClassEntity classEntity : innerClassEntity.getInnerClasss()) {
DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(classEntity);
root.add(node);
createDataNode(node, classEntity);
}
}
use of org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode in project GsonFormat by zzz40500.
the class FiledTreeTableModel method getValueAt.
/**
* 返回在单元格中显示的Object
*/
@Override
public Object getValueAt(Object node, int column) {
Object value = "";
if (node instanceof DefaultMutableTreeTableNode) {
DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node;
Object o = mutableNode.getUserObject();
if (o != null && o instanceof CellProvider) {
CellProvider cellProvider = (CellProvider) o;
value = cellProvider.getCellTitle(column);
}
}
return value;
}
use of org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode in project GsonFormat by zzz40500.
the class FiledTreeTableModel method setValueAt.
@Override
public void setValueAt(Object value, Object node, int column) {
super.setValueAt(value, node, column);
if (node instanceof DefaultMutableTreeTableNode) {
DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node;
Object o = mutableNode.getUserObject();
if (o != null && o instanceof CellProvider) {
CellProvider cellProvider = (CellProvider) o;
cellProvider.setValueAt(column, value.toString());
}
}
}
Aggregations