/** * Constructs a JXTreeTable using a * {@link org.jdesktop.swingx.treetable.DefaultTreeTableModel}. */ public JXTreeTable() { this(new DefaultTreeTableModel()); }
/** * Replaces the column identifiers in the model. If the number of * <code>newIdentifier</code>s is greater than the current number of * columns, new columns are added to the end of each row in the model. If * the number of <code>newIdentifier</code>s is less than the current * number of columns, all the extra columns at the end of a row are * discarded. * <p> * * @param columnIdentifiers * vector of column identifiers. If <code>null</code>, set the * model to zero columns */ // from DefaultTableModel public void setColumnIdentifiers(List<?> columnIdentifiers) { useAutoCalculatedIdentifiers = columnIdentifiers == null; this.columnIdentifiers = useAutoCalculatedIdentifiers ? getAutoCalculatedIdentifiers(getRoot()) : columnIdentifiers; modelSupport.fireNewRoot(); }
/** * Sets the user object for a node. Client code must use this method, so * that the model can notify listeners that a change has occurred. * <p> * This method is a convenient cover for * {@link #valueForPathChanged(TreePath, Object)}. * * @param node * the node to modify * @param userObject * the new user object to set * @throws NullPointerException * if {@code node} is {@code null} * @throws IllegalArgumentException * if {@code node} is not a node managed by this model */ public void setUserObject(TreeTableNode node, Object userObject) { valueForPathChanged(new TreePath(getPathToRoot(node)), userObject); } }
/** * {@inheritDoc} */ @Override public void setValueAt(Object value, Object node, int column) { if (!isValidTreeTableNode(node)) { throw new IllegalArgumentException( "node must be a valid node managed by this model"); } if (column < 0 || column >= getColumnCount()) { throw new IllegalArgumentException("column must be a valid index"); } TreeTableNode ttn = (TreeTableNode) node; if (column < ttn.getColumnCount()) { ttn.setValueAt(value, column); modelSupport.firePathChanged(new TreePath(getPathToRoot(ttn))); } }
/** * {@inheritDoc} */ @Override public boolean isCellEditable(Object node, int column) { if (!isValidTreeTableNode(node)) { throw new IllegalArgumentException( "node must be a valid node managed by this model"); } if (column < 0 || column >= getColumnCount()) { throw new IllegalArgumentException("column must be a valid index"); } TreeTableNode ttn = (TreeTableNode) node; if (column >= ttn.getColumnCount()) { return false; } return ttn.isEditable(column); }
/** * {@inheritDoc} */ @Override public int getIndexOfChild(Object parent, Object child) { if (!isValidTreeTableNode(parent) || !isValidTreeTableNode(child)) { return -1; } return ((TreeTableNode) parent).getIndex((TreeTableNode) child); }
/** * Invoked this to insert newChild at location index in parents children. * This will then message nodesWereInserted to create the appropriate event. * This is the preferred way to add children as it will create the * appropriate event. */ public void insertNodeInto(MutableTreeTableNode newChild, MutableTreeTableNode parent, int index) { parent.insert(newChild, index); modelSupport.fireChildAdded(new TreePath(getPathToRoot(parent)), index, newChild); }
/** * Creates a new {@code DefaultTreeTableModel} with the specified {@code * root} and column names. * * @param root * the root node of the tree * @param columnNames * the names of the columns used by this model * @see #setColumnIdentifiers(List) */ public DefaultTreeTableModel(TreeTableNode root, List<?> columnNames) { super(root); setColumnIdentifiers(columnNames); }
/** * {@inheritDoc} */ @Override public void setValueAt(Object value, Object node, int column) { if (!isValidTreeTableNode(node)) { throw new IllegalArgumentException( "node must be a valid node managed by this model"); } if (column < 0 || column >= getColumnCount()) { throw new IllegalArgumentException("column must be a valid index"); } TreeTableNode ttn = (TreeTableNode) node; if (column < ttn.getColumnCount()) { ttn.setValueAt(value, column); modelSupport.firePathChanged(new TreePath(getPathToRoot(ttn))); } }
/** * {@inheritDoc} */ @Override public boolean isCellEditable(Object node, int column) { if (!isValidTreeTableNode(node)) { throw new IllegalArgumentException( "node must be a valid node managed by this model"); } if (column < 0 || column >= getColumnCount()) { throw new IllegalArgumentException("column must be a valid index"); } TreeTableNode ttn = (TreeTableNode) node; if (column >= ttn.getColumnCount()) { return false; } return ttn.isEditable(column); }
/** * {@inheritDoc} */ @Override public int getIndexOfChild(Object parent, Object child) { if (!isValidTreeTableNode(parent) || !isValidTreeTableNode(child)) { return -1; } return ((TreeTableNode) parent).getIndex((TreeTableNode) child); }
/** * Invoked this to insert newChild at location index in parents children. * This will then message nodesWereInserted to create the appropriate event. * This is the preferred way to add children as it will create the * appropriate event. */ public void insertNodeInto(MutableTreeTableNode newChild, MutableTreeTableNode parent, int index) { parent.insert(newChild, index); modelSupport.fireChildAdded(new TreePath(getPathToRoot(parent)), index, newChild); }
/** * Creates a new {@code DefaultTreeTableModel} with the specified {@code * root} and column names. * * @param root * the root node of the tree * @param columnNames * the names of the columns used by this model * @see #setColumnIdentifiers(List) */ public DefaultTreeTableModel(TreeTableNode root, List<?> columnNames) { super(root); setColumnIdentifiers(columnNames); }
/** * {@inheritDoc} */ @Override public void setValueAt(Object value, Object node, int column) { if (!isValidTreeTableNode(node)) { throw new IllegalArgumentException( "node must be a valid node managed by this model"); } if (column < 0 || column >= getColumnCount()) { throw new IllegalArgumentException("column must be a valid index"); } TreeTableNode ttn = (TreeTableNode) node; if (column < ttn.getColumnCount()) { ttn.setValueAt(value, column); modelSupport.firePathChanged(new TreePath(getPathToRoot(ttn))); } }
/** * {@inheritDoc} */ @Override public boolean isCellEditable(Object node, int column) { if (!isValidTreeTableNode(node)) { throw new IllegalArgumentException( "node must be a valid node managed by this model"); } if (column < 0 || column >= getColumnCount()) { throw new IllegalArgumentException("column must be a valid index"); } TreeTableNode ttn = (TreeTableNode) node; if (column >= ttn.getColumnCount()) { return false; } return ttn.isEditable(column); }
/** * Constructs a JXTreeTable using a * {@link org.jdesktop.swingx.treetable.DefaultTreeTableModel}. */ public JXTreeTable() { this(new DefaultTreeTableModel()); }
/** * {@inheritDoc} */ @Override public int getIndexOfChild(Object parent, Object child) { if (!isValidTreeTableNode(parent) || !isValidTreeTableNode(child)) { return -1; } return ((TreeTableNode) parent).getIndex((TreeTableNode) child); }
/** * Replaces the column identifiers in the model. If the number of * <code>newIdentifier</code>s is greater than the current number of * columns, new columns are added to the end of each row in the model. If * the number of <code>newIdentifier</code>s is less than the current * number of columns, all the extra columns at the end of a row are * discarded. * <p> * * @param columnIdentifiers * vector of column identifiers. If <code>null</code>, set the * model to zero columns */ // from DefaultTableModel public void setColumnIdentifiers(List<?> columnIdentifiers) { useAutoCalculatedIdentifiers = columnIdentifiers == null; this.columnIdentifiers = useAutoCalculatedIdentifiers ? getAutoCalculatedIdentifiers(getRoot()) : columnIdentifiers; modelSupport.fireNewRoot(); }
/** * Sets the user object for a node. Client code must use this method, so * that the model can notify listeners that a change has occurred. * <p> * This method is a convenient cover for * {@link #valueForPathChanged(TreePath, Object)}. * * @param node * the node to modify * @param userObject * the new user object to set * @throws NullPointerException * if {@code node} is {@code null} * @throws IllegalArgumentException * if {@code node} is not a node managed by this model */ public void setUserObject(TreeTableNode node, Object userObject) { valueForPathChanged(new TreePath(getPathToRoot(node)), userObject); } }
/** * Invoked this to insert newChild at location index in parents children. * This will then message nodesWereInserted to create the appropriate event. * This is the preferred way to add children as it will create the * appropriate event. */ public void insertNodeInto(MutableTreeTableNode newChild, MutableTreeTableNode parent, int index) { parent.insert(newChild, index); modelSupport.fireChildAdded(new TreePath(getPathToRoot(parent)), index, newChild); }