Search in sources :

Example 1 with DefaultMutableTreeTableNode

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;
}
Also used : DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)

Example 2 with DefaultMutableTreeTableNode

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);
}
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)

Example 3 with DefaultMutableTreeTableNode

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);
    }
}
Also used : ClassEntity(org.gsonformat.intellij.entity.ClassEntity) FieldEntity(org.gsonformat.intellij.entity.FieldEntity) DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)

Example 4 with DefaultMutableTreeTableNode

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;
}
Also used : CellProvider(org.jdesktop.swingx.ux.CellProvider) DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)

Example 5 with DefaultMutableTreeTableNode

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());
        }
    }
}
Also used : CellProvider(org.jdesktop.swingx.ux.CellProvider) DefaultMutableTreeTableNode(org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)

Aggregations

DefaultMutableTreeTableNode (org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode)7 TreePath (javax.swing.tree.TreePath)2 ClassEntity (org.gsonformat.intellij.entity.ClassEntity)2 FieldEntity (org.gsonformat.intellij.entity.FieldEntity)2 CellProvider (org.jdesktop.swingx.ux.CellProvider)2 FiledTreeTableModel (cn.vearn.checktreetable.FiledTreeTableModel)1 BorderLayout (java.awt.BorderLayout)1 JTree (javax.swing.JTree)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ListSelectionListener (javax.swing.event.ListSelectionListener)1 JXTreeTable (org.jdesktop.swingx.JXTreeTable)1 CheckTreeTableManager (org.jdesktop.swingx.ux.CheckTreeTableManager)1