use of org.jdesktop.swingx.ux.CheckTreeTableManager 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);
}
Aggregations