Search in sources :

Example 1 with FiledTreeTableModel

use of cn.vearn.checktreetable.FiledTreeTableModel 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);
}
Also used : ListSelectionEvent(javax.swing.event.ListSelectionEvent) FiledTreeTableModel(cn.vearn.checktreetable.FiledTreeTableModel) DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode) ListSelectionListener(javax.swing.event.ListSelectionListener) CheckTreeTableManager(org.jdesktop.swingx.ux.CheckTreeTableManager) JXTreeTable(org.jdesktop.swingx.JXTreeTable)

Aggregations

FiledTreeTableModel (cn.vearn.checktreetable.FiledTreeTableModel)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 JXTreeTable (org.jdesktop.swingx.JXTreeTable)1 DefaultMutableTreeTableNode (org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)1 CheckTreeTableManager (org.jdesktop.swingx.ux.CheckTreeTableManager)1