From: <cpm...@us...> - 2008-02-15 09:09:52
|
Revision: 5210 http://pcgen.svn.sourceforge.net/pcgen/?rev=5210&view=rev Author: cpmeister Date: 2008-02-15 01:09:59 -0800 (Fri, 15 Feb 2008) Log Message: ----------- treeview folder moved from proto Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/util/ branches/cdomui/code/src/java/pcgen/gui/util/AbstractTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModelAdapter.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/ branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataView.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeView.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewMode.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewNode.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewPath.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewPathComparator.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/proto/util/AbstractTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeTable.java branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModelAdapter.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-15 09:09:55 UTC (rev 5209) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -6,7 +6,7 @@ package pcgen.gui.proto.editor; -import pcgen.gui.proto.util.JTreeTable; +import pcgen.gui.util.JTreeTable; /** * Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/AbstractTreeTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/AbstractTreeTableModel.java 2008-02-15 09:09:55 UTC (rev 5209) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/AbstractTreeTableModel.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -1,220 +0,0 @@ -/* - * @(#)AbstractTreeTableModel.java 1.2 98/10/27 - * - * Copyright 1997, 1998 by Sun Microsystems, Inc., - * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. - * All rights reserved. - * - * This software is the confidential and proprietary information - * of Sun Microsystems, Inc. ("Confidential Information"). You - * shall not disclose such Confidential Information and shall use - * it only in accordance with the terms of the license agreement - * you entered into with Sun. - */ -package pcgen.gui.proto.util; - -import javax.swing.event.EventListenerList; -import javax.swing.event.TreeModelEvent; -import javax.swing.event.TreeModelListener; -import javax.swing.tree.TreePath; - -/** - * An abstract implementation of the TreeTableModel interface, handling the list - * of listeners. - * @author Philip Milne - * @version 1.2 10/27/98 - * Modified 6/1/2002 Scott Ellsworth added implemenation of getChildren(Object, int) which assumes parent fulfils the PObjectNode - */ -public abstract class AbstractTreeTableModel implements TreeTableModel { - protected Object root; - protected EventListenerList listenerList = new EventListenerList(); - - public AbstractTreeTableModel() - { - this(null); - } - - public AbstractTreeTableModel(Object root) { - this.root = root; - } - - // - // Default implementations for methods in the TreeModel interface. - // - - public Object getRoot() { - return root; - } - - public boolean isLeaf(Object node) { - return getChildCount(node) == 0; - } - - public void valueForPathChanged(TreePath path, Object newValue) {} - - // This is not called in the JTree's default mode: - // use a naive implementation. - public int getIndexOfChild(Object parent, Object child) { - for (int i = 0; i < getChildCount(parent); i++) { - if (getChild(parent, i).equals(child)) { - return i; - } - } - return -1; - } - - public void addTreeModelListener(TreeModelListener l) { - listenerList.add(TreeModelListener.class, l); - } - - public void removeTreeModelListener(TreeModelListener l) { - listenerList.remove(TreeModelListener.class, l); - } - - /* - * Notifies all listeners that have registered interest for - * notification on this event type. The event instance - * is lazily created using the parameters passed into - * the fire method. - * @see EventListenerList - */ - protected void fireTreeNodesChanged(Object source, Object[] path, - int[] childIndices, - Object[] children) { - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - TreeModelEvent e = null; - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - // Lazily create the event: - if (e == null) - e = new TreeModelEvent(source, path, - childIndices, children); - ((TreeModelListener)listeners[i+1]).treeNodesChanged(e); - } - } - } - - /* - * Notifies all listeners that have registered interest for - * notification on this event type. The event instance - * is lazily created using the parameters passed into - * the fire method. - * @see EventListenerList - */ - protected void fireTreeNodesInserted(Object source, Object[] path, - int[] childIndices, - Object[] children) { - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - TreeModelEvent e = null; - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - // Lazily create the event: - if (e == null) - e = new TreeModelEvent(source, path, - childIndices, children); - ((TreeModelListener)listeners[i+1]).treeNodesInserted(e); - } - } - } - - /* - * Notifies all listeners that have registered interest for - * notification on this event type. The event instance - * is lazily created using the parameters passed into - * the fire method. - * @see EventListenerList - */ - protected void fireTreeNodesRemoved(Object source, Object[] path, - int[] childIndices, - Object[] children) { - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - TreeModelEvent e = null; - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - // Lazily create the event: - if (e == null) - e = new TreeModelEvent(source, path, - childIndices, children); - ((TreeModelListener)listeners[i+1]).treeNodesRemoved(e); - } - } - } - - /* - * Notifies all listeners that have registered interest for - * notification on this event type. The event instance - * is lazily created using the parameters passed into - * the fire method. - * @see EventListenerList - */ - protected void fireTreeStructureChanged(Object source, Object[] path, - int[] childIndices, - Object[] children) { - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - TreeModelEvent e = null; - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - // Lazily create the event: - if (e == null) - e = new TreeModelEvent(source, path, - childIndices, children); - ((TreeModelListener)listeners[i+1]).treeStructureChanged(e); - } - } - } - - protected void fireTreeStructureChanged(Object source, TreePath path) - { - // Guaranteed to return a non-null array - Object[] listeners = listenerList.getListenerList(); - TreeModelEvent e = null; - // Process the listeners last to first, notifying - // those that are interested in this event - for (int i = listeners.length-2; i>=0; i-=2) { - if (listeners[i]==TreeModelListener.class) { - // Lazily create the event: - if (e == null) - e = new TreeModelEvent(source, path); - ((TreeModelListener)listeners[i+1]).treeStructureChanged(e); - } - } - } - // - // Default impelmentations for methods in the TreeTableModel interface. - // - - public Class getColumnClass(int column) { return Object.class; } - - /** By default, make the column with the Tree in it the only editable one. - * Making this column editable causes the JTable to forward mouse - * and keyboard events in the Tree column to the underlying JTree. - */ - public boolean isCellEditable(Object node, int column) { - return getColumnClass(column) == TreeTableModel.class; - } - - public void setValueAt(Object aValue, Object node, int column) {} - - - // Left to be implemented in the subclass: - - /* - * public Object getChild(Object parent, int index) - * public int getChildCount(Object parent) - * public int getColumnCount() - * public String getColumnName(Object node, int column) - * public Object getValueAt(Object node, int column) - */ -} Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeTable.java 2008-02-15 09:09:55 UTC (rev 5209) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeTable.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -1,721 +0,0 @@ -/** - * @(#)JTreeTable.java 1.2 98/10/27 - * - * Copyright 1997, 1998 by Sun Microsystems, Inc., - * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. - * All rights reserved. - * - * This software is the confidential and proprietary information - * of Sun Microsystems, Inc. ("Confidential Information"). You - * shall not disclose such Confidential Information and shall use - * it only in accordance with the terms of the license agreement - * you entered into with Sun. - * - * Current Ver: $Revision: 5184 $ - * Last Editor: $Author: cpmeister $ - * Last Edited: $Date: 2008-02-13 17:03:32 -0800 (Wed, 13 Feb 2008) $ - * - **/ -package pcgen.gui.proto.util; - -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.EventObject; - -import javax.swing.CellRendererPane; -import javax.swing.JComponent; -import javax.swing.JPopupMenu; -import javax.swing.JTable; -import javax.swing.JTree; -import javax.swing.ListSelectionModel; -import javax.swing.LookAndFeel; -import javax.swing.UIManager; -import javax.swing.event.CellEditorListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.DefaultTreeSelectionModel; -import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreePath; - - -/** - * This example shows how to create a simple JTreeTable component, - * by using a JTree as a renderer (and editor) for the cells in a - * particular column in the JTable. - * - * @version 1.2 10/27/98 - * - * @author Philip Milne - * @author Scott Violet - **/ -public class JTreeTable extends JTable -{ - - static final long serialVersionUID = -3571248405124682593L; - - /** A subclass of JTree. */ - private TreeTableCellRenderer tree; - private TreeTableModelAdapter adapter; - - public JTreeTable() - { - this(null); - } - /** - * Constructor - * @param treeTableModel - */ - public JTreeTable(TreeTableModel treeTableModel) - { - super(); - - /* - JTreeTable's event handling assumes bad things about - mouse pressed/released that are not true on MacOS X. - For example, one gets NPEs thrown when the mouse is - hit because the event manager is waiting for released - and one never gets the release. - It turns out that the MetalLAF handles this happily and - thus we can use that to get appropriate line styles, - without knackering Mac support. - Fix done by LeeAnn Rucker, formerly at Apple for Javasoft. - Added to pcgen by Scott Ellsworth - */ - UIManager.put("TreeTableUI", "javax.swing.plaf.metal.MetalTreeUI"); //$NON-NLS-1$ //$NON-NLS-2$ - UIManager.put("Tree.leftChildIndent", Integer.valueOf(3)); //$NON-NLS-1$ - UIManager.put("Tree.rightChildIndent", Integer.valueOf(8)); //$NON-NLS-1$ - - // Create the tree. It will be used as a renderer and editor. - tree = new TreeTableCellRenderer(treeTableModel); - adapter = new TreeTableModelAdapter(treeTableModel, tree); - // Install a tableModel representing the visible rows in tree. - - super.setModel(adapter); - - // Force the JTable and JTree to share row selection models. - ListToTreeSelectionModelWrapper selectionWrapper = - new ListToTreeSelectionModelWrapper(); - tree.setSelectionModel(selectionWrapper); - setSelectionModel(selectionWrapper.getListSelectionModel()); - - // Install the tree editor renderer and editor. - setDefaultRenderer(TreeTableModel.class, tree); - setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor()); - - // No grid. - setShowGrid(false); - - // No intercell spacing - setIntercellSpacing(new Dimension(0, 0)); - - // And update the height of the trees row to match the table - if (tree.getRowHeight() < 1) - { - // Metal looks better like this. - setRowHeight(18); - } - else - { - // If the UI has specified a rowHeight, - // we'd better all be using the same one! - setRowHeight(tree.getRowHeight()); - } - } - - public void setTreeTableModel(TreeTableModel model) - { - tree.setModel(model); - adapter.setTreeTableModel(model); - } - /** - * Workaround for BasicTableUI anomaly. Make sure the UI never tries to - * paint the editor. The UI currently uses different techniques to - * paint the renderers and editors and overriding setBounds() below - * is not the right thing to do for an editor. Returning -1 for the - * editing row in this case, ensures the editor is never painted. - * @return editing row - **/ - @Override - public int getEditingRow() - { - return (getColumnClass(editingColumn) == TreeTableModel.class) ? (-1) - : editingRow; - } - - /** - * Overridden to pass the new rowHeight to the tree. - * @param aRowHeight - **/ - @Override - public void setRowHeight(int aRowHeight) - { - super.setRowHeight(aRowHeight); - - if ((tree != null) && (tree.getRowHeight() != aRowHeight)) - { - tree.setRowHeight(getRowHeight()); - } - } - - /** - * Returns the tree that is being shared between the model. - * @return JTree - **/ - public JTree getTree() - { - return tree; - } - - /** - * Forwards the <code>scrollRectToVisible()</code> message to the - * <code>JComponent</code>'s parent. Components that can service - * the request, such as <code>JViewport</code>, - * override this method and perform the scrolling. - * - * @param aRect the visible <code>Rectangle</code> - * @see javax.swing.JViewport - */ - @Override - public void scrollRectToVisible(Rectangle aRect) - { - Container parent; - int dx = getX(); - int dy = getY(); - - for (parent = getParent(); !(parent == null) && !(parent instanceof JComponent) && !(parent instanceof CellRendererPane); parent = - parent.getParent()) - { - final Rectangle bounds = parent.getBounds(); - - dx += bounds.x; - dy += bounds.y; - } - - if ((parent != null) && !(parent instanceof CellRendererPane)) - { - aRect.x += dx; - aRect.y += dy; - - ((JComponent) parent).scrollRectToVisible(aRect); - aRect.x -= dx; - aRect.y -= dy; - } - } - - /** - * Overridden to message super and forward the method to the tree. - * Since the tree is not actually in the component hieachy it will - * never receive this unless we forward it in this manner. - **/ - @Override - public void updateUI() - { - super.updateUI(); - - if (tree != null) - { - tree.updateUI(); - } - - // Use the tree's default foreground and background - // colors in the table - LookAndFeel.installColorsAndFont(this, - "Tree.background", "Tree.foreground", "Tree.font"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ - } - - /** - * Makes sure all the path components in path are expanded (except - * for the last path component) and scrolls so that the - * node identified by the path is displayed. Only works when this - * <code>JTree</code> is contained in a <code>JScrollPane</code>. - * - * @param path the <code>TreePath</code> identifying the node to - * bring into view - */ - private void scrollPathToVisible(TreePath path) - { - if (path != null) - { - tree.makeVisible(path); - - Rectangle bounds = tree.getPathBounds(path); - - if (bounds != null) - { - scrollRectToVisible(bounds); - } - } - } - - /** - * A TreeCellRenderer that displays a JTree. - **/ - final class TreeTableCellRenderer extends JTree implements - TableCellRenderer - { - // Last table/tree row asked to render - private int visibleRow; - - TreeTableCellRenderer(TreeModel model) - { - super(model); - } - - /** - * This is overridden to set the height - * to match that of the JTable. - * @param x - * @param y - * @param w - * @param h - **/ - @Override - public void setBounds(int x, - - @SuppressWarnings("unused") int y, int w, - - @SuppressWarnings("unused") int h) - { - super.setBounds(x, 0, w, JTreeTable.this.getHeight()); - } - - /** - * Sets the row height of the tree and forwards - * the row height to the table. - * @param aRowHeight - **/ - @Override - public void setRowHeight(int aRowHeight) - { - if (aRowHeight > 0) - { - super.setRowHeight(aRowHeight); - - if ((JTreeTable.this != null) && (JTreeTable.this.getRowHeight() != aRowHeight)) - { - JTreeTable.this.setRowHeight(JTreeTable.this.getRowHeight()); - } - } - } - - /** - * TreeCellRenderer method. - * Overridden to update the visible row. - * @param table - * @param value - * @param isSelected - * @param hasFocus - * @param row - * @param column - * @return Component - **/ - public Component getTableCellRendererComponent(JTable table, - - @SuppressWarnings("unused") Object value, boolean isSelected, - - @SuppressWarnings("unused") boolean hasFocus, int row, - - @SuppressWarnings("unused") int column) - { - if (isSelected) - { - this.setBackground(table.getSelectionBackground()); - } - else - { - this.setBackground(table.getBackground()); - } - - visibleRow = row; - - return this; - } - - /** - * Fix to bad event handling on MacOS X - * @return UI Class ID - **/ - @Override - public String getUIClassID() - { - return "TreeTableUI"; //$NON-NLS-1$ - } - - /** - * Sublcassed to translate the graphics such - * that the last visible row will be drawn at 0,0. - * @param g - **/ - @Override - public void paint(final Graphics g) - { - g.translate(0, -visibleRow * JTreeTable.this.getRowHeight()); - try - { - super.paint(g); - } catch (Exception e) - { - // TODO Handle this? - } - } - - /** - * updateUI is overridden to set the colors - * of the Trees renderer to match that of the table. - **/ - @Override - public void updateUI() - { - super.updateUI(); - - // Make the tree's cell renderer use the - // table's cell selection colors. - TreeCellRenderer tcr = getCellRenderer(); - - if (tcr instanceof DefaultTreeCellRenderer) - { - DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr); - dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground")); //$NON-NLS-1$ - dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground")); //$NON-NLS-1$ - } - } - - } - - /** - * ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel - * to listen for changes in the ListSelectionModel it maintains. Once - * a change in the ListSelectionModel happens, the paths are updated - * in the DefaultTreeSelectionModel. - **/ - private final class ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel - { - - static final long serialVersionUID = -3571248405124682593L; - - // Set to true when we are updating the ListSelectionModel - private boolean updatingListSelectionModel; - - private ListToTreeSelectionModelWrapper() - { - super(); - getListSelectionModel().addListSelectionListener( - createListSelectionListener()); - } - - /** - * This is overridden to set updatingListSelectionModel - * and message super. This is the only place - * DefaultTreeSelectionModel alters the ListSelectionModel. - **/ - @Override - public void resetRowSelection() - { - if (!updatingListSelectionModel) - { - updatingListSelectionModel = true; - - try - { - super.resetRowSelection(); - } finally - { - updatingListSelectionModel = false; - } - } - - // Notice how we don't message super if - // updatingListSelectionModel is true. If - // updatingListSelectionModel is true, it implies the - // ListSelectionModel has already been updated and the - // paths are the only thing that needs to be updated. - } - - /** - * Returns the list selection model. - * ListToTreeSelectionModelWrapper listens for changes - * to this model and updates the selected paths accordingly. - * @return ListSelectionModel - **/ - private ListSelectionModel getListSelectionModel() - { - return listSelectionModel; - } - - /** - * Creates and returns an instance of ListSelectionHandler. - * @return ListSelectionListener - **/ - private ListSelectionListener createListSelectionListener() - { - return new ListSelectionHandler(); - } - - /** - * If <code>updatingListSelectionModel</code> is false, - * this will reset the selected paths from the selected - * rows in the list selection model. - **/ - private void updateSelectedPathsFromSelectedRows() - { - if (!updatingListSelectionModel) - { - updatingListSelectionModel = true; - - try - { - int[] sRows = getSelectedRows(); - - if ((sRows == null) || (sRows.length == 0)) - { - return; - } - - int count = 0; - - for (int i = 0; i < sRows.length; i++) - { - if (tree.getPathForRow(sRows[i]) != null) - { - count++; - } - } - - if (count == 0) - { - return; - } - - TreePath[] tps = new TreePath[count]; - count = 0; - - for (int i = 0; i < sRows.length; i++) - { - TreePath tp = tree.getPathForRow(sRows[i]); - - if (tp != null) - { - tps[count++] = tp; - } - } - - // don't ned a clear as we are - // using setSelectionPaths() - //clearSelection(); - setSelectionPaths(tps); - } finally - { - updatingListSelectionModel = false; - } - } - } - - /** - * Class responsible for calling - * updateSelectedPathsFromSelectedRows when the - * selection of the list changse. - **/ - final class ListSelectionHandler implements ListSelectionListener - { - - /** - * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) - */ - public void valueChanged( - - @SuppressWarnings("unused") ListSelectionEvent e) - { - updateSelectedPathsFromSelectedRows(); - } - - } - } - - /** - * TreeTableCellEditor implementation. - * Component returned is the JTree. - **/ - private final class TreeTableCellEditor implements TableCellEditor - { - - /** - * Overridden to return false, and if the event is a mouse event - * it is forwarded to the tree.<p> - * The behavior for this is debatable, and should really be offered - * as a property. By returning false, all keyboard actions are - * implemented in terms of the table. By returning true, the - * tree would get a chance to do something with the keyboard - * events. For the most part this is ok. But for certain keys, - * such as left/right, the tree will expand/collapse where as - * the table focus should really move to a different column. Page - * up/down should also be implemented in terms of the table. - * By returning false this also has the added benefit that clicking - * outside of the bounds of the tree node, but still in the tree - * column will select the row, whereas if this returned true - * that wouldn't be the case. - * <p>By returning false we are also enforcing the policy that - * the tree will never be editable (at least by a key sequence). - * @param e - * @return true if cell editable - */ - @Override - public boolean isCellEditable(EventObject e) - { - if (e instanceof MouseEvent) - { - for (int counter = getColumnCount() - 1; counter >= 0; counter--) - { - if (getColumnClass(counter) == TreeTableModel.class) - { - MouseEvent me = (MouseEvent) e; - MouseEvent newME = - new MouseEvent(tree, me.getID(), me.getWhen(), - me.getModifiers(), me.getX(), me.getY(), me.getClickCount(), me.isPopupTrigger()); - tree.dispatchEvent(newME); - - break; - } - } - } - - return false; - } - - /** - * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int) - */ - public Component getTableCellEditorComponent( - - @SuppressWarnings("unused") JTable table, - - @SuppressWarnings("unused") Object value, - - @SuppressWarnings("unused") boolean isSelected, - - @SuppressWarnings("unused") int r, - - @SuppressWarnings("unused") int c) - { - return tree; - } - - public Object getCellEditorValue() - { - return null; - } - - public boolean shouldSelectCell(EventObject anEvent) - { - return false; - } - - public boolean stopCellEditing() - { - return true; - } - - public void cancelCellEditing() - { - - } - - public void addCellEditorListener(CellEditorListener l) - { - - } - - public void removeCellEditorListener(CellEditorListener l) - { - - } - - } - - /** - * Associates a popup menu with the tree table. - * - * <p>This handles showing the popup based on a right click and also handles - * any menu accelerators. - * - * @param aPopupMenu Menu to associate. - */ - public void addPopupMenu(final JPopupMenu aPopupMenu) - { - addMouseListener(new PopupListener(this, aPopupMenu)); - } - - private class PopupListener extends MouseAdapter - { - - private JPopupMenu theMenu; - private JTree theTree; - - private PopupListener(final JTreeTable treeTable, final JPopupMenu aMenu) - { - theTree = treeTable.getTree(); - theMenu = aMenu; - } - - /** - * Overridden to potential show the popup menu. - * - * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) - */ - @Override - public void mousePressed(MouseEvent evt) - { - maybeShowPopup(evt); - } - - /** - * Overridden to potentially show the popup menu. - * - * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent) - */ - @Override - public void mouseReleased(MouseEvent evt) - { - maybeShowPopup(evt); - } - - private void maybeShowPopup(MouseEvent evt) - { - if (evt.isPopupTrigger()) - { - final TreePath selPath = - theTree.getClosestPathForLocation(evt.getX(), evt.getY()); - - if (selPath == null) - { - return; - } - - if (theTree.isSelectionEmpty()) - { - theTree.setSelectionPath(selPath); - theMenu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - else if (!theTree.isPathSelected(selPath)) - { - theTree.setSelectionPath(selPath); - theMenu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - else - { - theTree.addSelectionPath(selPath); - theMenu.show(evt.getComponent(), evt.getX(), evt.getY()); - } - } - } - - } -} Modified: branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java 2008-02-15 09:09:55 UTC (rev 5209) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -27,5 +27,5 @@ */ public class JTreeViewTable { - + } Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModel.java 2008-02-15 09:09:55 UTC (rev 5209) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModel.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -1,83 +0,0 @@ -/* - * TreeTableModel.java - * - * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved. - * - * This software is the confidential and proprietary information of Sun - * Microsystems, Inc. ("Confidential Information"). You shall not - * disclose such Confidential Information and shall use it only in - * accordance with the terms of the license agreement you entered into - * with Sun. - * - * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE - * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR - * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES - * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING - * THIS SOFTWARE OR ITS DERIVATIVES. - * - */ -package pcgen.gui.proto.util; - -import javax.swing.tree.TreeModel; - -/** - * TreeTableModel is the model used by a JTreeTable. It extends TreeModel - * to add methods for getting inforamtion about the set of columns each - * node in the TreeTableModel may have. Each column, like a column in - * a TableModel, has a name and a type associated with it. Each node in - * the TreeTableModel can return a value for each of the columns and - * set that value if isCellEditable() returns true. - * - * @author Philip Milne - * @author Scott Violet - */ -public interface TreeTableModel extends TreeModel -{ - /** - * Indicates whether the the value for node <code>node</code>, - * at column number <code>column</code> is editable. - * @param node - * @param column - * @return TRUE if cell is editable - */ - boolean isCellEditable(Object node, int column); - - /** - * Returns the type for column number <code>column</code>. - * @param column - * @return Class - */ - Class<?> getColumnClass(int column); - - /** - * Returns the number ofs availible column. - * @return column count - */ - int getColumnCount(); - - /** - * Returns the name for column number <code>column</code>. - * @param column - * @return column name - */ - String getColumnName(int column); - - /** - * Sets the value for node <code>node</code>, - * at column number <code>column</code>. - * @param aValue - * @param node - * @param column - */ - void setValueAt(Object aValue, Object node, int column); - - /** - * Returns the value to be displayed for node <code>node</code>, - * at column number <code>column</code>. - * @param node - * @param column - * @return Object - */ - Object getValueAt(Object node, int column); -} Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModelAdapter.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModelAdapter.java 2008-02-15 09:09:55 UTC (rev 5209) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeTableModelAdapter.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -1,190 +0,0 @@ -/* - * @(#)TreeTableModelAdapter.java 1.2 98/10/27 - * - * Copyright 1997, 1998 by Sun Microsystems, Inc., - * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. - * All rights reserved. - * - * This software is the confidential and proprietary information - * of Sun Microsystems, Inc. ("Confidential Information"). You - * shall not disclose such Confidential Information and shall use - * it only in accordance with the terms of the license agreement - * you entered into with Sun. - */ -package pcgen.gui.proto.util; - -import javax.swing.JTree; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeExpansionListener; -import javax.swing.event.TreeModelEvent; -import javax.swing.event.TreeModelListener; -import javax.swing.table.AbstractTableModel; -import javax.swing.tree.TreePath; - -/** - * This is a wrapper class takes a TreeTableModel and implements - * the table model interface. The implementation is trivial, with - * all of the event dispatching support provided by the superclass: - * the AbstractTableModel. - * - * @version 1.2 10/27/98 - * - * @author Philip Milne - * @author Scott Violet - */ -final class TreeTableModelAdapter extends AbstractTableModel -{ - - private JTree tree; - private TreeTableModel treeTableModel; - private TreeModelListener modelListener; - - /** - * Constructor - * @param treeTableModel - * @param tree - */ - public TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree) - { - this.tree = tree; - this.treeTableModel = treeTableModel; - - tree.addTreeExpansionListener(new TreeExpansionListener() - { - // Don't use fireTableRowsInserted() here; - // the selection model would get updated twice. - public void treeExpanded(TreeExpansionEvent event) - { - fireTableDataChanged(); - } - - public void treeCollapsed(TreeExpansionEvent event) - { - fireTableDataChanged(); - } - - }); - - /** - * Install a TreeModelListener that can update the table when - * tree changes. We use delayedFireTableDataChanged as we can - * not be guaranteed the tree will have finished processing - * the event before us. - **/ - modelListener = new TreeModelListener() - { - - public void treeNodesChanged(TreeModelEvent e) - { - fireTableDataChanged(); - } - - public void treeNodesInserted(TreeModelEvent e) - { - fireTableDataChanged(); - } - - public void treeNodesRemoved(TreeModelEvent e) - { - fireTableDataChanged(); - } - - public void treeStructureChanged(TreeModelEvent e) - { - fireTableStructureChanged(); - } - - }; - if (treeTableModel != null) - { - treeTableModel.addTreeModelListener(modelListener); - } - } - - public void setTreeTableModel(TreeTableModel model) - { - if (treeTableModel != null) - { - treeTableModel.removeTreeModelListener(modelListener); - } - treeTableModel = model; - if (treeTableModel != null) - { - treeTableModel.addTreeModelListener(modelListener); - } - } - - @Override - public boolean isCellEditable(int row, int column) - { - if (treeTableModel == null) - { - return false; - } - return treeTableModel.isCellEditable(nodeForRow(row), column); - } - - public Class<?> getColumnClass(int column) - { - if (treeTableModel == null) - { - return Object.class; - } - return treeTableModel.getColumnClass(column); - } - - // Wrappers, implementing TableModel interface. - public int getColumnCount() - { - if (treeTableModel == null) - { - return 0; - } - return treeTableModel.getColumnCount(); - } - - @Override - public String getColumnName(int column) - { - if (treeTableModel == null) - { - return null; - } - return treeTableModel.getColumnName(column); - } - - public int getRowCount() - { - return tree.getRowCount(); - } - - @Override - public void setValueAt(Object value, int row, int column) - { - if (treeTableModel == null) - { - return; - } - treeTableModel.setValueAt(value, nodeForRow(row), column); - } - - public Object getValueAt(int row, int column) - { - if (treeTableModel == null) - { - return null; - } - return treeTableModel.getValueAt(nodeForRow(row), column); - } - - private Object nodeForRow(int row) - { - TreePath treePath = tree.getPathForRow(row); - if (treePath != null) - { - return treePath.getLastPathComponent(); - } - return null; - } - -} Copied: branches/cdomui/code/src/java/pcgen/gui/util/AbstractTreeTableModel.java (from rev 5207, branches/cdomui/code/src/java/pcgen/gui/proto/util/AbstractTreeTableModel.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/AbstractTreeTableModel.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/AbstractTreeTableModel.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -0,0 +1,220 @@ +/* + * @(#)AbstractTreeTableModel.java 1.2 98/10/27 + * + * Copyright 1997, 1998 by Sun Microsystems, Inc., + * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. + * All rights reserved. + * + * This software is the confidential and proprietary information + * of Sun Microsystems, Inc. ("Confidential Information"). You + * shall not disclose such Confidential Information and shall use + * it only in accordance with the terms of the license agreement + * you entered into with Sun. + */ +package pcgen.gui.util; + +import javax.swing.event.EventListenerList; +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.tree.TreePath; + +/** + * An abstract implementation of the TreeTableModel interface, handling the list + * of listeners. + * @author Philip Milne + * @version 1.2 10/27/98 + * Modified 6/1/2002 Scott Ellsworth added implemenation of getChildren(Object, int) which assumes parent fulfils the PObjectNode + */ +public abstract class AbstractTreeTableModel implements TreeTableModel { + protected Object root; + protected EventListenerList listenerList = new EventListenerList(); + + public AbstractTreeTableModel() + { + this(null); + } + + public AbstractTreeTableModel(Object root) { + this.root = root; + } + + // + // Default implementations for methods in the TreeModel interface. + // + + public Object getRoot() { + return root; + } + + public boolean isLeaf(Object node) { + return getChildCount(node) == 0; + } + + public void valueForPathChanged(TreePath path, Object newValue) {} + + // This is not called in the JTree's default mode: + // use a naive implementation. + public int getIndexOfChild(Object parent, Object child) { + for (int i = 0; i < getChildCount(parent); i++) { + if (getChild(parent, i).equals(child)) { + return i; + } + } + return -1; + } + + public void addTreeModelListener(TreeModelListener l) { + listenerList.add(TreeModelListener.class, l); + } + + public void removeTreeModelListener(TreeModelListener l) { + listenerList.remove(TreeModelListener.class, l); + } + + /* + * Notifies all listeners that have registered interest for + * notification on this event type. The event instance + * is lazily created using the parameters passed into + * the fire method. + * @see EventListenerList + */ + protected void fireTreeNodesChanged(Object source, Object[] path, + int[] childIndices, + Object[] children) { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + // Lazily create the event: + if (e == null) + e = new TreeModelEvent(source, path, + childIndices, children); + ((TreeModelListener)listeners[i+1]).treeNodesChanged(e); + } + } + } + + /* + * Notifies all listeners that have registered interest for + * notification on this event type. The event instance + * is lazily created using the parameters passed into + * the fire method. + * @see EventListenerList + */ + protected void fireTreeNodesInserted(Object source, Object[] path, + int[] childIndices, + Object[] children) { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + // Lazily create the event: + if (e == null) + e = new TreeModelEvent(source, path, + childIndices, children); + ((TreeModelListener)listeners[i+1]).treeNodesInserted(e); + } + } + } + + /* + * Notifies all listeners that have registered interest for + * notification on this event type. The event instance + * is lazily created using the parameters passed into + * the fire method. + * @see EventListenerList + */ + protected void fireTreeNodesRemoved(Object source, Object[] path, + int[] childIndices, + Object[] children) { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + // Lazily create the event: + if (e == null) + e = new TreeModelEvent(source, path, + childIndices, children); + ((TreeModelListener)listeners[i+1]).treeNodesRemoved(e); + } + } + } + + /* + * Notifies all listeners that have registered interest for + * notification on this event type. The event instance + * is lazily created using the parameters passed into + * the fire method. + * @see EventListenerList + */ + protected void fireTreeStructureChanged(Object source, Object[] path, + int[] childIndices, + Object[] children) { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + // Lazily create the event: + if (e == null) + e = new TreeModelEvent(source, path, + childIndices, children); + ((TreeModelListener)listeners[i+1]).treeStructureChanged(e); + } + } + } + + protected void fireTreeStructureChanged(Object source, TreePath path) + { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + TreeModelEvent e = null; + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length-2; i>=0; i-=2) { + if (listeners[i]==TreeModelListener.class) { + // Lazily create the event: + if (e == null) + e = new TreeModelEvent(source, path); + ((TreeModelListener)listeners[i+1]).treeStructureChanged(e); + } + } + } + // + // Default impelmentations for methods in the TreeTableModel interface. + // + + public Class getColumnClass(int column) { return Object.class; } + + /** By default, make the column with the Tree in it the only editable one. + * Making this column editable causes the JTable to forward mouse + * and keyboard events in the Tree column to the underlying JTree. + */ + public boolean isCellEditable(Object node, int column) { + return getColumnClass(column) == TreeTableModel.class; + } + + public void setValueAt(Object aValue, Object node, int column) {} + + + // Left to be implemented in the subclass: + + /* + * public Object getChild(Object parent, int index) + * public int getChildCount(Object parent) + * public int getColumnCount() + * public String getColumnName(Object node, int column) + * public Object getValueAt(Object node, int column) + */ +} Copied: branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java (from rev 5205, branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeTable.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java 2008-02-15 09:09:59 UTC (rev 5210) @@ -0,0 +1,721 @@ +/** + * @(#)JTreeTable.java 1.2 98/10/27 + * + * Copyright 1997, 1998 by Sun Microsystems, Inc., + * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. + * All rights reserved. + * + * This software is the confidential and proprietary information + * of Sun Microsystems, Inc. ("Confidential Information"). You + * shall not disclose such Confidential Information and shall use + * it only in accordance with the terms of the license agreement + * you entered into with Sun. + * + * Current Ver: $Revision: 5184 $ + * Last Editor: $Author: cpmeister $ + * Last Edited: $Date: 2008-02-13 17:03:32 -0800 (Wed, 13 Feb 2008) $ + * + **/ +package pcgen.gui.util; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.CellRendererPane; +import javax.swing.JComponent; +import javax.swing.JPopupMenu; +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.ListSelectionModel; +import javax.swing.LookAndFeel; +import javax.swing.UIManager; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeSelectionModel; +import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + + +/** + * This example shows how to create a simple JTreeTable component, + * by using a JTree as a renderer (and editor) for the cells in a + * particular column in the JTable. + * + * @version 1.2 10/27/98 + * + * @author Philip Milne + * @author Scott Violet + **/ +public class JTreeTable extends JTable +{ + + static final long serialVersionUID = -3571248405124682593L; + + /** A subclass of JTree. */ + private TreeTableCellRenderer tree; + private TreeTableModelAdapter adapter; + + public JTreeTable() + { + this(null); + } + /** + * Constructor + * @param treeTableModel + */ + public JTreeTable(TreeTableModel treeTableModel) + { + super(); + + /* + JTreeTable's event handling assumes bad things about + mouse pressed/released that are not true on MacOS X. + For example, one gets NPEs thrown when the mouse is + hit because the event manager is waiting for released + and one never gets the release. + It turns out that the MetalLAF handles this happily and + thus we can use that to get appropriate line styles, + without knackering Mac support. + Fix done by LeeAnn Rucker, formerly at Apple for Javasoft. + Added to pcgen by Scott Ellsworth + */ + UIManager.put("TreeTableUI", "javax.swing.plaf.metal.MetalTreeUI"); //$NON-NLS-1$ //$NON-NLS-2$ + UIManager.put("Tree.leftChildIndent", Integer.valueOf(3)); //$NON-NLS-1$ + UIManager.put("Tree.rightChildIndent", Integer.valueOf(8)); //$NON-NLS-1$ + + // Create the tree. It will be used as a renderer and editor. + tree = new TreeTableCellRenderer(treeTableModel); + adapter = new TreeTableModelAdapter(treeTableModel, tree); + // Install a tableModel representing the visible rows in tree. + + super.setModel(adapter); + + // Force the JTable and JTree to share row selection models. + ListToTreeSelectionModelWrapper selectionWrapper = + new ListToTreeSelectionModelWrapper(); + tree.setSelectionModel(selectionWrapper); + setSelectionModel(selectionWrapper.getListSelectionModel()); + + // Install the tree editor renderer and editor. + setDefaultRenderer(TreeTableModel.class, tree); + setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor()); + + // No grid. + setShowGrid(false); + + // No intercell spacing + setIntercellSpacing(new Dimension(0, 0)); + + // And update the height of the trees row to match the table + if (tree.getRowHeight() < 1) + { + // Metal looks better like this. + setRowHeight(18); + } + else + { + // If the UI has specified a rowHeight, + // we'd better all be using the same one! + setRowHeight(tree.getRowHeight()); + } + } + + public void setTreeTableModel(TreeTableModel model) + { + tree.setModel(model); + adapter.setTreeTableModel(model); + } + /** + * Workaround for BasicTableUI anomaly. Make sure the UI never tries to + * paint the editor. The UI currently uses different techniques to + * paint the renderers and editors and overriding setBounds() below + * is not the right thing to do for an editor. Returning -1 for the + * editing row in this case, ensures the editor is never painted. + * @return editing row + **/ + @Override + public int getEditingRow() + { + return (getColumnClass(editingColumn) == TreeTableModel.class) ? (-1) + : editingRow; + } + + /** + * Overridden to pass the new rowHeight to the tree. + * @param aRowHeight + **/ + @Override + public void setRowHeight(int aRowHeight) + { + super.setRowHeight(aRowHeight); + + if ((tree != null) && (tree.getRowHeight() != aRowHeight)) + { + tree.setRowHeight(getRowHeight()); + } + } + + /** + * Returns the tree that is being shared between the model. + * @return JTree + **/ + public JTree getTree() + { + return tree; + } + + /** + * Forwards the <code>scrollRectToVisible()</code> message to the + * <code>JComponent</code>'s parent. Components that can service + * the request, such as <code>JViewport</code>, + * override this method and perform the scrolling. + * + * @param aRect the visible <code>Rectangle</code> + * @see javax.swing.JViewport + */ + @Override + public void scrollRectToVisible(Rectangle aRect) + { + Container parent; + int dx = getX(); + int dy = getY(); + + for (parent = getParent(); !(parent == null) && !(parent instanceof JComponent) && !(parent instanceof CellRendererPane); parent = + parent.getParent()) + { + final Rectangle bounds = parent.getBounds(); + + dx += bounds.x; + dy += bounds.y; + } + + if ((parent != null) && !(parent instanceof CellRendererPane)) + { + aRect.x += dx; + aRect.y += dy; + + ((JComponent) parent).scrollRectToVisible(aRect); + aRect.x -= dx; + aRect.y -= dy; + } + } + + /** + * Overridden to message super and forward the method to the tree. + * Since the tree is not actually in the component hieachy it will + * never receive this unless we forward it in this manner. + **/ + @Override + public void updateUI() + { + super.updateUI(); + + if (tree != null) + { + tree.updateUI(); + } + + // Use the tree's default foreground and background + // colors in the table + LookAndFeel.installColorsAndFont(this, + "Tree.background", "Tree.foreground", "Tree.font"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ + } + + /** + * Makes sure all the path components in path are expanded (except + * for the last path component) and scrolls so that the + * node identified by the path is displayed. Only works when this + * <code>JTree</code> is contained in a <code>JScrollPane</code>. + * + * @param path the <code>TreePath</code> identifying the node to + * bring into view + */ + private void scrollPathToVisible(TreePath path) + { + if (path != null) + { + tree.makeVisible(path); + + Rectangle bounds = tree.getPathBounds(path); + + if (bounds != null) + { + scrollRectToVisible(bounds); + } + } + } + + /** + * A TreeCellRenderer that displays a JTree. + **/ + final class TreeTableCellRenderer extends JTree implements + TableCellRenderer + { + // Last table/tree row asked to render + private int visibleRow; + + TreeTableCellRenderer(TreeModel model) + { + super(model); + } + + /** + * This is overridden to set the height + * to match that of the JTable. + * @param x + * @param y + * @param w + * @param h + **/ + @Override + public void setBounds(int x, + + @SuppressWarnings("unused") int y, int w, + + @SuppressWarnings("unused") int h) + { + super.setBounds(x, 0, w, JTreeTable.this.getHeight()); + } + + /** + * Sets the row height of the tree and forwards + * the row height to the table. + * @param aRowHeight + **/ + @Override + public void setRowHeight(int aRowHeight) + { + if (aRowHeight > 0) + { + super.setRowHeight(aRowHeight); + + if ((JTreeTable.this != null) && (JTreeTable.this.getRowHeight() != aRowHeight)) + { + JTreeTable.this.setRowHeight(JTreeTable.this.getRowHeight()); + } + } + } + + /** + * TreeCellRenderer method. + * Overridden to update the visible row. + * @param table + * @param value + * @param isSelected + * @param hasFocus + * @param row + * @param column + * @return Component + **/ + public Component getTableCellRendererComponent(JTable table, + + @SuppressWarnings("unused") Object value, boolean isSelected, + + @SuppressWarnings("unused") boolean hasFocus, int row, + + @SuppressWarnings("unused") int column) + { + if (isSelected) + { + this.setBackground(table.getSelectionBackground()); + } + else + { + this.setBackground(table.getBackground()); + } + + visibleRow = row; + + return this; + } + + /** + * Fix to bad event handling on MacOS X + * @return UI Class ID + **/ + @Override + public String getUIClassID() + { + return "TreeTableUI"; //$NON-NLS-1$ + } + + /** + * Sublcassed to translate the graphics such + * that the last visible row will be drawn at 0,0. + * @param g + **/ + @Override + public void paint(final Graphics g) + { + g.translate(0, -visibleRow * JTreeTable.this.getRowHeight()); + try + { + super.paint(g); + } catch (Exception e) + { + // TODO Handle this? + } + } + + /** + * updateUI is overridden to set the colors + * of the Trees renderer to match that of the table. + **/ + @Override + public void updateUI() + { + super.updateUI(); + + // Make the tree's cell renderer use the + // table's cell selection colors. + TreeCellRenderer tcr = getCellRenderer(); + + if (tcr instanceof DefaultTreeCellRenderer) + { + DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr); + dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground")); //$NON-NLS-1$ + dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground")); //$NON-NLS-1$ + } + } + + } + + /** + * ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel + * to listen for changes in the ListSelectionModel it maintains. Once + * a change in the ListSelectionModel happens, the paths are updated + * in the DefaultTreeSelectionModel. + **/ + private final class ListToTreeSelectionModelWrapper extends DefaultTreeSelectionModel + { + + static final long serialVersionUID = -3571248405124682593L; + + // Set to true when we are updating the ListSelectionModel + private boolean updatingListSelectionModel; + + private ListToTreeSelectionModelWrapper() + { + super(); + getListSelectionModel().addListSelectionListener( + createListSelectionListener()); + } + + /** + * This is overridden to set updatingListSelectionModel + * and message super. This is the only place + * DefaultTreeSelectionModel alters the ListSelectionModel. + **/ + @Override + public void resetRowSelection() + { + if (!updatingListSelectionModel) + { + updatingListSelectionModel = true; + + try + { + super.resetRowSelection(); + } finally + { + updatingListSelectionModel = false; + } + } + + // Notice how we don't message super if + // updatingListSelectionModel is true. If + // updatingListSelectionModel is true, it implies the + // ListSelectionModel has already been updated and the + // paths are the only thing that needs to be updated. + } + + /** + * Returns the list selection model. + * ListToTreeSelectionModelWrapper listens for changes + * to this model and updates the selected paths accordingly. + * @return ListSelectionModel + **/ + private ListSelectionModel getListSelectionModel() + { + return listSelectionModel; + } + + /** + * Creates and returns an instance of ListSelectionHandler. + * @return ListSelectionListener + **/ + private ListSelectionListener createListSelectionListener() + { + return new ListSelectionHandler(); + } + + /** + * If <code>updatingListSelectionModel</code> is false, + * this will reset the selected paths fr... [truncated message content] |
From: <cpm...@us...> - 2008-02-19 04:23:53
|
Revision: 5227 http://pcgen.svn.sourceforge.net/pcgen/?rev=5227&view=rev Author: cpmeister Date: 2008-02-18 20:23:55 -0800 (Mon, 18 Feb 2008) Log Message: ----------- Added TreeViewHeaderRenderer Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewNode.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-19 00:40:36 UTC (rev 5226) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -97,13 +97,15 @@ ButtonModelHandler handler = new ButtonModelHandler(); JTreeViewTableHeader.this.addMouseListener(handler); JTreeViewTableHeader.this.addMouseMotionListener(handler); + //this.setRolloverEnabled(true); } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - if (usedcolumn != null && usedcolumn.getHeaderValue() == value) { + if (usedcolumn != null && usedcolumn.getHeaderValue() == value && + usedcolumn == JTreeViewTableHeader.this.getDraggedColumn()) setModel(usedModel); - } else { + else { setModel(emptyModel); } setText(value.toString()); Modified: branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java 2008-02-19 00:40:36 UTC (rev 5226) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -21,6 +21,7 @@ package pcgen.gui.proto.util; import java.util.Collection; +import javax.swing.table.JTableHeader; import pcgen.gui.util.JTreeTable; import pcgen.gui.util.treeview.TreeViewModel; import pcgen.gui.util.treeview.TreeViewTableModel; @@ -42,6 +43,13 @@ super(model); } + + @Override + protected JTableHeader createDefaultTableHeader() + { + return new JTreeViewTableHeader(this); + } + public TreeViewTableModel getTreeViewTableModel() { return (TreeViewTableModel) super.getTreeTableModel(); Modified: branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java 2008-02-19 00:40:36 UTC (rev 5226) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -20,11 +20,11 @@ */ package pcgen.gui.proto.util; +import java.awt.Component; import pcgen.gui.util.SortingHeaderRenderer; import javax.swing.JTable; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; -import pcgen.gui.util.treeview.TreeViewModel; import pcgen.gui.util.treeview.TreeViewTableModel; /** @@ -33,20 +33,48 @@ */ public class JTreeViewTableHeader extends JTableHeader { + private TreeViewTableModel tableModel; + public JTreeViewTableHeader(JTreeViewTable table) { super(table.getColumnModel()); tableModel = table.getTreeViewTableModel(); } + @Override public TableCellRenderer createDefaultRenderer() { - return new SortingHeaderRenderer(this); + return new CompoundHeaderRenderer(); } public TreeViewTableModel getTableModel() { return tableModel; } + + private final class CompoundHeaderRenderer implements TableCellRenderer + { + + private TreeViewHeaderRenderer treeRenderer = new TreeViewHeaderRenderer(JTreeViewTableHeader.this); + private SortingHeaderRenderer sortRenderer = new SortingHeaderRenderer(JTreeViewTableHeader.this); + + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) + { + if (value == null) + { + return treeRenderer; + } + else + { + return sortRenderer; + } + } + + } } Added: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form 2008-02-19 04:23:55 UTC (rev 5227) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-82,0,0,1,13"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="treeSortButton"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="treeSortButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="West"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="treeViewButton"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="treeViewButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="textSortButton"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="textSortButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> +</Form> Added: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -0,0 +1,175 @@ +/* + * TreeViewHeaderRenderer.java + * + * Created on February 18, 2008, 4:53 PM + */ +package pcgen.gui.proto.util; + +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellRenderer; +import pcgen.gui.util.SortingConstants; +import pcgen.gui.util.treeview.TreeViewMode; +import pcgen.gui.util.treeview.TreeViewTableModel; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class TreeViewHeaderRenderer extends javax.swing.JPanel implements TableCellRenderer, + SortingConstants +{ + + private final JTreeViewTableHeader header; + private ButtonModel usedModel = null; + + /** Creates new form TreeViewHeaderRenderer */ + public TreeViewHeaderRenderer(final JTreeViewTableHeader header) + { + + this.header = header; + header.addMouseListener( + new MouseListener() + { + + public void mouseClicked(MouseEvent e) + { + SwingUtilities.convertMouseEvent(header, e, TreeViewHeaderRenderer.this); + if (textSortButton.contains(e.getPoint())) + { + textSortButton.doClick(); + } + else if (treeViewButton.contains(e.getPoint())) + { + treeViewButton.doClick(); + } + else if (treeSortButton.contains(e.getPoint())) + { + treeSortButton.doClick(); + } + } + + public void mousePressed(MouseEvent e) + { + SwingUtilities.convertMouseEvent(header, e, TreeViewHeaderRenderer.this); + if (textSortButton.contains(e.getPoint())) + { + usedModel = textSortButton.getModel(); + } + else if (treeViewButton.contains(e.getPoint())) + { + usedModel = treeViewButton.getModel(); + } + else if (treeSortButton.contains(e.getPoint())) + { + usedModel = treeSortButton.getModel(); + } + usedModel.setPressed(true); + } + + public void mouseReleased(MouseEvent e) + { + usedModel.setPressed(false); + } + + public void mouseEntered(MouseEvent e) + { + } + + public void mouseExited(MouseEvent e) + { + } + + }); + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + treeSortButton = new javax.swing.JButton(); + treeViewButton = new javax.swing.JButton(); + textSortButton = new javax.swing.JButton(); + + setLayout(new java.awt.BorderLayout()); + + treeSortButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + treeSortButtonActionPerformed(evt); + } + }); + add(treeSortButton, java.awt.BorderLayout.WEST); + + treeViewButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + treeViewButtonActionPerformed(evt); + } + }); + add(treeViewButton, java.awt.BorderLayout.CENTER); + + textSortButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + textSortButtonActionPerformed(evt); + } + }); + add(textSortButton, java.awt.BorderLayout.EAST); + }// </editor-fold>//GEN-END:initComponents + private void treeSortButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_treeSortButtonActionPerformed + if (header.getTableModel().getTreeViewMode() == TreeViewMode.ASCENDING) + { + treeSortButton.setIcon(DESCENDING_ICON); + } + else + { + treeSortButton.setIcon(ASCENDING_ICON); + } + header.getTableModel().switchTreeViewMode(); + }//GEN-LAST:event_treeSortButtonActionPerformed + + private void treeViewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_treeViewButtonActionPerformed + + }//GEN-LAST:event_treeViewButtonActionPerformed + + private void textSortButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textSortButtonActionPerformed + Icon icon = null; + if (header.getTableModel().getSortedColumn() == 0) + { + icon = DESCENDING_ICON; + } + else + { + icon = ASCENDING_ICON; + } + textSortButton.setIcon(icon); + header.getTableModel().sortColumn(0); + }//GEN-LAST:event_textSortButtonActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton textSortButton; + private javax.swing.JButton treeSortButton; + private javax.swing.JButton treeViewButton; + // End of variables declaration//GEN-END:variables + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, + boolean hasFocus, int row, + int column) + { + if (header.getTableModel().getSortedColumn() != 0) + { + textSortButton.setIcon(null); + } + treeViewButton.setText(header.getTableModel().getSelectedTreeView().getViewName()); + return this; + } + +} Added: branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -0,0 +1,34 @@ +/* + * SortingConstants.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 18, 2008, 5:19:25 PM + */ + +package pcgen.gui.util; + +import javax.swing.Icon; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public interface SortingConstants +{ +public static final Icon ASCENDING_ICON = null;//TODO: implement +public static final Icon DESCENDING_ICON = null;//TODO: implement +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java 2008-02-19 00:40:36 UTC (rev 5226) +++ branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -46,11 +46,10 @@ * * @author Connor Petty <mis...@gm...> */ -public class SortingHeaderRenderer extends JButton implements TableCellRenderer +public class SortingHeaderRenderer extends JButton implements TableCellRenderer, + SortingConstants { - private static final Icon ascendingIcon = null;//TODO: GET CORRECT ICON - private static final Icon descendingIcon = null;//TODO: GET CORRECT ICON private static final ButtonModel defaultModel = new DefaultButtonModel(); private final ButtonModel usedModel = new DefaultButtonModel(); private final JTreeViewTableHeader header; @@ -73,6 +72,7 @@ public void mousePressed(MouseEvent e) { usedModel.setPressed(true); + header.repaint(); } public void mouseReleased(MouseEvent e) @@ -114,17 +114,18 @@ public void actionPerformed(ActionEvent e) { TreeViewTableModel model = header.getTableModel(); - DataViewColumn datacolumn = model.getDataColumn(trackedColumn.getModelIndex()); - Comparator comparator = datacolumn.getComparator(); - Icon icon = ascendingIcon; + Icon icon = null; if (iconMap.containsKey(trackedColumn)) { - icon = descendingIcon; - comparator = Comparators.inverseComparator(comparator); + icon = DESCENDING_ICON; } + else + { + icon = ASCENDING_ICON; + } iconMap = Collections.singletonMap(trackedColumn, icon); - model.setComparator(comparator); + model.sortColumn(trackedColumn.getModelIndex()); } }); @@ -137,7 +138,8 @@ boolean hasFocus, int row, int column) { - if (trackedColumn != null && trackedColumn.getHeaderValue() == value) + if (trackedColumn != null && trackedColumn.getHeaderValue() == value && + trackedColumn == header.getDraggedColumn()) { setModel(usedModel); } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewNode.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewNode.java 2008-02-19 00:40:36 UTC (rev 5226) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewNode.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -44,128 +44,130 @@ TreeViewNode(TreeViewPathComparator<E> comparator) { - this(0, comparator, null); - treepath = new TreePath(this); + this(0, comparator, null); + treepath = new TreePath(this); } - private TreeViewNode(int depth, TreeViewPathComparator comparator, Object item) + private TreeViewNode(int depth, TreeViewPathComparator comparator, + Object item) { - this.pathMap = new TreeMap<TreeViewPath, TreeViewNode<E>>(comparator); - this.comparator = comparator; - this.depth = depth; - this.item = item; + this.pathMap = new TreeMap<TreeViewPath, TreeViewNode<E>>(comparator); + this.comparator = comparator; + this.depth = depth; + this.item = item; } TreeViewPathComparator<E> getTreeViewPathComparator() { - return comparator; + return comparator; } - + void setTreeViewPathComparator(TreeViewPathComparator<E> comparator) { - resetMap(comparator); + resetMap(comparator); } private void resetMap(TreeViewPathComparator comparator) { - Map<TreeViewPath, TreeViewNode<E>> map = new TreeMap<TreeViewPath, TreeViewNode<E>>(comparator); - map.putAll(pathMap); - if (!map.equals(pathMap)) - { - pathMap = map; - } - for (TreeViewPath path : pathMap.keySet()) - { - TreeViewNode child = pathMap.get(path); - child.resetMap(comparator); - } + Map<TreeViewPath, TreeViewNode<E>> map = new TreeMap<TreeViewPath, TreeViewNode<E>>(comparator); + map.putAll(pathMap); + if (!map.equals(pathMap)) + { + pathMap = map; + } + for (TreeViewPath path : pathMap.keySet()) + { + TreeViewNode child = pathMap.get(path); + child.resetMap(comparator); + } } void createChild(TreeViewPath<E> path) { - if (path.getPathCount() < depth) - { - TreeViewPath key = path.getParentPath(depth); - TreeViewNode<E> node = pathMap.get(key); - if (node == null) - { - node = new TreeViewNode(depth + 1, comparator, key.getLastPathComponent()); - node.setParent(this); - pathMap.put(key, node); - } - node.createChild(path); - } + if (path.getPathCount() < depth) + { + TreeViewPath key = path.getParentPath(depth); + TreeViewNode<E> node = pathMap.get(key); + if (node == null) + { + node = new TreeViewNode(depth + 1, comparator, + key.getLastPathComponent()); + node.setParent(this); + pathMap.put(key, node); + } + node.createChild(path); + } } public Object getItem() { - return item; + return item; } public TreeNode getChildAt(int childIndex) { - Iterator<TreeViewNode<E>> it = pathMap.values().iterator(); - for (int i = 0; i < childIndex; i++) - { - if (it.hasNext()) - { - it.next(); - } - else - { - throw new IndexOutOfBoundsException("childIndex: " + childIndex); - } - } - return it.next(); + Iterator<TreeViewNode<E>> it = pathMap.values().iterator(); + for (int i = 0; i < childIndex; i++) + { + if (it.hasNext()) + { + it.next(); + } + else + { + throw new IndexOutOfBoundsException("childIndex: " + childIndex); + } + } + return it.next(); } public int getChildCount() { - return pathMap.size(); + return pathMap.size(); } public TreePath getTreePath() { - return treepath; + return treepath; } public TreeViewNode<E> getParent() { - return parent; + return parent; } private void setParent(TreeViewNode<E> parent) { - this.parent = parent; - this.treepath = parent.getTreePath().pathByAddingChild(this); + this.parent = parent; + this.treepath = parent.getTreePath().pathByAddingChild(this); } public int getIndex(TreeNode node) { - Iterator<TreeViewNode<E>> it = pathMap.values().iterator(); - for (int i = 0; it.hasNext(); i++) - { - if (it.next().equals(node)) - { - return i; - } - } - return -1; + Iterator<TreeViewNode<E>> it = pathMap.values().iterator(); + for (int i = 0; it.hasNext(); i++) + { + if (it.next().equals(node)) + { + return i; + } + } + return -1; } public boolean getAllowsChildren() { - return true; + return true; } public boolean isLeaf() { - return pathMap.isEmpty(); + return pathMap.isEmpty(); } public Enumeration<TreeViewNode<E>> children() { - return Collections.enumeration(pathMap.values()); + return Collections.enumeration(pathMap.values()); } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-19 00:40:36 UTC (rev 5226) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-19 04:23:55 UTC (rev 5227) @@ -44,10 +44,11 @@ private final Map<TreeView<E>, TreeViewNode<E>> viewMap = new HashMap<TreeView<E>, TreeViewNode<E>>(); private Comparator<E> comparator = Comparators.toStringComparator(); private TreeViewMode mode = TreeViewMode.ASCENDING; + private DataViewColumn sortedColumn = null; private TreeView<E> selectedView; public TreeViewTableModel(TreeViewModel<E> model, - Collection<E> data) + Collection<E> data) { this.treeviews = model.getTreeViews(); this.selectedView = treeviews.iterator().next(); @@ -57,6 +58,11 @@ root = viewMap.get(selectedView); } + public TreeView<E> getSelectedTreeView() + { + return selectedView; + } + public void setSelectedTreeView(TreeView<E> view) { this.selectedView = view; @@ -67,7 +73,8 @@ } root = node; TreeViewPathComparator<E> pathcomparator = node.getTreeViewPathComparator(); - if (!pathcomparator.getTreeViewMode().equals(mode) || !pathcomparator.getComparator().equals(comparator)) + if (!pathcomparator.getTreeViewMode().equals(mode) || + !pathcomparator.getComparator().equals(comparator)) { resetTreeViewPathComparator(); } @@ -77,13 +84,45 @@ } } + public void sortColumn(int column) + { + DataViewColumn<E> dataColumn = getDataColumn(column); + Comparator<E> comp = null; + if (dataColumn != null) + { + comp = dataColumn.getComparator(); + if (dataColumn == sortedColumn) + { + comp = Comparators.inverseComparator(comparator); + } + } + else if (sortedColumn != null) + { + comp = Comparators.toStringComparator(); + } + else + { + comp = Comparators.inverseComparator(comparator); + } + setComparator(comp); + sortedColumn = dataColumn; + } + + public int getSortedColumn() + { + if(!datacolumns.contains(sortedColumn)) + return 0; + + return datacolumns.indexOf(sortedColumn)+1; + } + public void setData(Collection<E> data) { populateDataMap(data); populateViewMap(data); } - public void setComparator(Comparator<E> comparator) + private void setComparator(Comparator<E> comparator) { this.comparator = comparator; resetTreeViewPathComparator(); @@ -106,9 +145,17 @@ super.fireTreeStructureChanged(root, rootNode.getTreePath()); } - public void setTreeViewMode(TreeViewMode mode) + public TreeViewMode getTreeViewMode() { - this.mode = mode; + return mode; + } + + public void switchTreeViewMode() + { + if(mode == TreeViewMode.ASCENDING) + mode = TreeViewMode.DESCENDING; + else + mode = TreeViewMode.ASCENDING; resetTreeViewPathComparator(); } @@ -162,23 +209,23 @@ switch (column) { case 0: - return selectedView.getViewName(); + return null; default: return getDataColumn(column).getName(); } } - public DataViewColumn getDataColumn(int column) + private DataViewColumn getDataColumn(int column) { - switch(column) + switch (column) { - case 0: - return null; + case 0: + return null; default: - return datacolumns.get(column-1); + return datacolumns.get(column - 1); } } - + public Object getValueAt(Object node, int column) { Object item = ((TreeViewNode<E>) node).getItem(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-02-22 08:58:09
|
Revision: 5249 http://pcgen.svn.sourceforge.net/pcgen/?rev=5249&view=rev Author: cpmeister Date: 2008-02-22 00:58:14 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Resource Check-in and Utilities update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModelAdapter.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataView.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataViewColumn.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/resource/ branches/cdomui/code/src/java/pcgen/gui/resource/About16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Add16.gif branches/cdomui/code/src/java/pcgen/gui/resource/AlignBottom16.gif branches/cdomui/code/src/java/pcgen/gui/resource/AlignCenter16.gif branches/cdomui/code/src/java/pcgen/gui/resource/AlignJustifyHorizontal16.gif branches/cdomui/code/src/java/pcgen/gui/resource/AlignJustifyVertical16.gif branches/cdomui/code/src/java/pcgen/gui/resource/AlignLeft16.gif branches/cdomui/code/src/java/pcgen/gui/resource/AlignRight16.gif branches/cdomui/code/src/java/pcgen/gui/resource/AlignTop16.gif branches/cdomui/code/src/java/pcgen/gui/resource/BBack16.gif branches/cdomui/code/src/java/pcgen/gui/resource/BBack24.gif branches/cdomui/code/src/java/pcgen/gui/resource/Back16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Bookmarks16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Checklist16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Close16.gif branches/cdomui/code/src/java/pcgen/gui/resource/CloseAll16.gif branches/cdomui/code/src/java/pcgen/gui/resource/ComposeMail16.gif branches/cdomui/code/src/java/pcgen/gui/resource/ContextualHelp16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Copy16.gif branches/cdomui/code/src/java/pcgen/gui/resource/CustomZoom16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Cut16.gif branches/cdomui/code/src/java/pcgen/gui/resource/D20_logo_RGB.jpg branches/cdomui/code/src/java/pcgen/gui/resource/DDown16.gif branches/cdomui/code/src/java/pcgen/gui/resource/DDown24.gif branches/cdomui/code/src/java/pcgen/gui/resource/DefaultPortrait.gif branches/cdomui/code/src/java/pcgen/gui/resource/Delete16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Down16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Edit16.gif branches/cdomui/code/src/java/pcgen/gui/resource/EditZoom16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Export16.gif branches/cdomui/code/src/java/pcgen/gui/resource/FForward16.gif branches/cdomui/code/src/java/pcgen/gui/resource/FForward24.gif branches/cdomui/code/src/java/pcgen/gui/resource/Find16.gif branches/cdomui/code/src/java/pcgen/gui/resource/FindAgain16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Forward16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Help16.gif branches/cdomui/code/src/java/pcgen/gui/resource/History16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Import16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Information16.gif branches/cdomui/code/src/java/pcgen/gui/resource/MediaStop16.gif branches/cdomui/code/src/java/pcgen/gui/resource/New16.gif branches/cdomui/code/src/java/pcgen/gui/resource/NewEnvelope.gif branches/cdomui/code/src/java/pcgen/gui/resource/NewNPC16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Open16.gif branches/cdomui/code/src/java/pcgen/gui/resource/PCGenApp.png branches/cdomui/code/src/java/pcgen/gui/resource/PageSetup16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Paste16.gif branches/cdomui/code/src/java/pcgen/gui/resource/PcgenIcon.gif branches/cdomui/code/src/java/pcgen/gui/resource/Preferences16.gif branches/cdomui/code/src/java/pcgen/gui/resource/PreferencesHighlightBlue16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Print16.gif branches/cdomui/code/src/java/pcgen/gui/resource/PrintPreview16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Properties16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Redo16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Refresh16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Remove16.gif branches/cdomui/code/src/java/pcgen/gui/resource/RemovePreferences16.gif branches/cdomui/code/src/java/pcgen/gui/resource/RemoveZoom16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Replace16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Save16.gif branches/cdomui/code/src/java/pcgen/gui/resource/SaveAll16.gif branches/cdomui/code/src/java/pcgen/gui/resource/SaveAs16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Search16.gif branches/cdomui/code/src/java/pcgen/gui/resource/SendMail16.gif branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen-Alpha.png branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen.gif branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_510.png branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_5101.png branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_512.png branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_Beta.png branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_Ennie.png branches/cdomui/code/src/java/pcgen/gui/resource/SplashScreen.png branches/cdomui/code/src/java/pcgen/gui/resource/Stop16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Thumbs.db branches/cdomui/code/src/java/pcgen/gui/resource/TipOfTheDay16.gif branches/cdomui/code/src/java/pcgen/gui/resource/TipOfTheDay24.gif branches/cdomui/code/src/java/pcgen/gui/resource/UUp16.gif branches/cdomui/code/src/java/pcgen/gui/resource/UUp24.gif branches/cdomui/code/src/java/pcgen/gui/resource/Undo16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Up16.gif branches/cdomui/code/src/java/pcgen/gui/resource/Zoom16.gif branches/cdomui/code/src/java/pcgen/gui/resource/ZoomHighlightBlue16.gif branches/cdomui/code/src/java/pcgen/gui/resource/ZoomIn16.gif branches/cdomui/code/src/java/pcgen/gui/resource/ZoomOut16.gif branches/cdomui/code/src/java/pcgen/gui/resource/bronze100x100-2003.gif branches/cdomui/code/src/java/pcgen/gui/resource/bronze200x200-2003.gif branches/cdomui/code/src/java/pcgen/gui/resource/bronze300x300-2003.gif branches/cdomui/code/src/java/pcgen/gui/resource/gmgen_icon.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-application-msword.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-application-pdf.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-application-rtf.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-application-vnd.ms-excel.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-application-vnd.ms-powerpoint.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-application-x-staroffice-words.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-generic.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-image-generic.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-text-html.png branches/cdomui/code/src/java/pcgen/gui/resource/gnome-text-plain.png branches/cdomui/code/src/java/pcgen/gui/resource/gold100x100-2005.gif branches/cdomui/code/src/java/pcgen/gui/resource/gold200x200-2005.gif branches/cdomui/code/src/java/pcgen/gui/resource/gold300x300-2005.gif branches/cdomui/code/src/java/pcgen/gui/resource/menu-mode-RGB-alt.png branches/cdomui/code/src/java/pcgen/gui/resource/stock-tool-button-by-color-select.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_broken_image-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_color-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_copy-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_cut-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_export-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_insert_graphic-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_insert_table-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_list_bulet-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_list_enum-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_new-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_paste-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_print-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_revert-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_save-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_spellcheck-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_text_align_center-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_text_align_left-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_text_align_right-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_text_bold-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_text_italic-16.png branches/cdomui/code/src/java/pcgen/gui/resource/stock_text_underline-16.png branches/cdomui/code/src/java/pcgen/gui/resource/win-acrobat.png branches/cdomui/code/src/java/pcgen/gui/resource/win-cc2.png branches/cdomui/code/src/java/pcgen/gui/resource/win-excel.png branches/cdomui/code/src/java/pcgen/gui/resource/win-word.png branches/cdomui/code/src/java/pcgen/gui/resource/win-zip.png branches/cdomui/code/src/java/pcgen/gui/resource/wrench.gif branches/cdomui/code/src/java/pcgen/gui/util/IconUtilities.java branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java branches/cdomui/code/src/java/pcgen/gui/util/ModelSorterEvent.java branches/cdomui/code/src/java/pcgen/gui/util/ModelSorterListener.java branches/cdomui/code/src/java/pcgen/gui/util/SortMode.java branches/cdomui/code/src/java/pcgen/gui/util/SortableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/ branches/cdomui/code/src/java/pcgen/gui/util/treetable/AbstractTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/SortableTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/SortableTreeTableNode.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/TreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/TreeTableNode.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java branches/cdomui/code/src/java/pcgen/gui/util/AbstractTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewNode.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-22 08:57:51 UTC (rev 5248) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-22 08:58:14 UTC (rev 5249) @@ -34,9 +34,6 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTable" name="jTable1"> - <AuxValues> - <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JTreeViewTable(new StringModel(), Arrays.asList(1, 5, 4, 3, 6, 4, 2, 6, 2, 7 , 5))"/> - </AuxValues> </Component> </SubComponents> </Container> Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-22 08:57:51 UTC (rev 5248) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-22 08:58:14 UTC (rev 5249) @@ -22,7 +22,7 @@ import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; -import pcgen.gui.proto.util.JTreeViewTable; +import pcgen.gui.util.JTreeViewTable; import pcgen.gui.util.treeview.DataView; import pcgen.gui.util.treeview.DataViewColumn; import pcgen.gui.util.treeview.TreeView; @@ -50,7 +50,7 @@ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); - jTable1 = new JTreeViewTable(new StringModel(), Arrays.asList(1, 5, 4, 3, 6, 4, 2, 6, 2, 7 , 5)); + jTable1 = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); @@ -85,7 +85,7 @@ public DataView<Integer> getDataView() { - return new IntegerData(); + return null; } } @@ -123,20 +123,5 @@ } } } - private class IntegerData implements DataView<Integer> - { - - public List<?> getData(Integer obj) - { - return Arrays.asList(Integer.numberOfTrailingZeros(obj), Integer.toHexString(obj)); - } - - public List<DataViewColumn<Integer>> getDataColumns() - { - Comparator<Integer> comp = Comparators.hashCodeComparator(); - List<DataViewColumn<Integer>> list = Arrays.asList(new DataViewColumn<Integer>("Trailing Zeros", Integer.class, Comparators.integerComparator()), - new DataViewColumn<Integer>("Hex String", String.class, comp)); - return list; - } - } + } Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java 2008-02-22 08:57:51 UTC (rev 5248) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTable.java 2008-02-22 08:58:14 UTC (rev 5249) @@ -1,56 +0,0 @@ -/* - * JTreeViewTable.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 14, 2008, 10:18:26 PM - */ -package pcgen.gui.proto.util; - -import java.util.Collection; -import javax.swing.table.JTableHeader; -import pcgen.gui.util.JTreeTable; -import pcgen.gui.util.treeview.TreeViewModel; -import pcgen.gui.util.treeview.TreeViewTableModel; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class JTreeViewTable extends JTreeTable -{ - - public <T> JTreeViewTable(TreeViewModel<T> model, Collection<T> collection) - { - this(new TreeViewTableModel(model, collection)); - } - - public JTreeViewTable(TreeViewTableModel model) - { - super(model); - setTableHeader(new JTreeViewTableHeader(this)); - } - - public TreeViewTableModel getTreeViewTableModel() - { - return (TreeViewTableModel) super.getTreeTableModel(); - } - - public void setTreeViewTableModel(TreeViewTableModel model) - { - super.setTreeTableModel(model); - } -} Modified: branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java 2008-02-22 08:57:51 UTC (rev 5248) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java 2008-02-22 08:58:14 UTC (rev 5249) @@ -20,6 +20,7 @@ */ package pcgen.gui.proto.util; +import pcgen.gui.util.JTreeViewTable; import java.awt.Component; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form 2008-02-22 08:57:51 UTC (rev 5248) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.form 2008-02-22 08:58:14 UTC (rev 5249) @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> - <AuxValues> - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-82,0,0,1,13"/> - </AuxValues> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> - <SubComponents> - <Component class="javax.swing.JButton" name="treeSortButton"> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="treeSortButtonActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="West"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="treeViewButton"> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="treeViewButtonActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="Center"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="textSortButton"> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="textSortButtonActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="East"/> - </Constraint> - </Constraints> - </Component> - </SubComponents> -</Form> Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java 2008-02-22 08:57:51 UTC (rev 5248) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java 2008-02-22 08:58:14 UTC (rev 5249) @@ -1,198 +0,0 @@ -/* - * TreeViewHeaderRenderer.java - * - * Created on February 18, 2008, 4:53 PM - */ -package pcgen.gui.proto.util; - -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import javax.swing.ButtonModel; -import javax.swing.DefaultButtonModel; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import pcgen.gui.util.SortingConstants; -import pcgen.gui.util.treeview.TreeViewMode; -import pcgen.gui.util.treeview.TreeViewTableModel; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class TreeViewHeaderRenderer extends javax.swing.JPanel implements TableCellRenderer, - SortingConstants -{ - - private static final ButtonModel defaultModel = new DefaultButtonModel(); - private final ButtonModel usedModel = new DefaultButtonModel(); - private final JTreeViewTableHeader header; - - /** Creates new form TreeViewHeaderRenderer */ - public TreeViewHeaderRenderer(final JTreeViewTableHeader header) - { - - this.header = header; - header.addMouseListener( - new MouseListener() - { - - public void mouseClicked(MouseEvent e) - { - TableColumn trackedColumn = header.getTrackedColumn(); - if (trackedColumn == header.getDraggedColumn()) - { - findPressedButton().doClick(); - } - } - - public void mousePressed(MouseEvent evt) - { - usedModel.setPressed(true); - header.repaint(); - } - - public void mouseReleased(MouseEvent e) - { - usedModel.setPressed(false); - } - - public void mouseEntered(MouseEvent e) - { - } - - public void mouseExited(MouseEvent e) - { - } - - }); - initComponents(); - } - - private JButton findPressedButton() - { - Point p = header.getMousePosition(); - Rectangle rect = header.getHeaderRect(header.columnAtPoint(p)); - p.translate(-rect.x, -rect.y); - JButton button; - if (p.getX() < treeSortButton.getWidth()) - { - button = treeSortButton; - } - else if (p.getX() < treeSortButton.getWidth() + - treeViewButton.getWidth()) - { - button = treeViewButton; - } - else - { - button = textSortButton; - } - return button; - } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents - private void initComponents() { - - treeSortButton = new javax.swing.JButton(); - treeViewButton = new javax.swing.JButton(); - textSortButton = new javax.swing.JButton(); - - setLayout(new java.awt.BorderLayout()); - - treeSortButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - treeSortButtonActionPerformed(evt); - } - }); - add(treeSortButton, java.awt.BorderLayout.WEST); - - treeViewButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - treeViewButtonActionPerformed(evt); - } - }); - add(treeViewButton, java.awt.BorderLayout.CENTER); - - textSortButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - textSortButtonActionPerformed(evt); - } - }); - add(textSortButton, java.awt.BorderLayout.EAST); - }// </editor-fold>//GEN-END:initComponents - private void treeSortButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_treeSortButtonActionPerformed - if (header.getTableModel().getTreeViewMode() == TreeViewMode.ASCENDING) - { - treeSortButton.setIcon(DESCENDING_ICON); - } - else - { - treeSortButton.setIcon(ASCENDING_ICON); - } - header.getTableModel().switchTreeViewMode(); - }//GEN-LAST:event_treeSortButtonActionPerformed - - private void treeViewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_treeViewButtonActionPerformed - - }//GEN-LAST:event_treeViewButtonActionPerformed - - private void textSortButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textSortButtonActionPerformed - Icon icon = null; - if (header.getTableModel().getSortedColumn() == 0) - { - icon = DESCENDING_ICON; - } - else - { - icon = ASCENDING_ICON; - } - textSortButton.setIcon(icon); - header.getTableModel().sortColumn(0); - }//GEN-LAST:event_textSortButtonActionPerformed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton textSortButton; - private javax.swing.JButton treeSortButton; - private javax.swing.JButton treeViewButton; - // End of variables declaration//GEN-END:variables - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, - boolean hasFocus, int row, - int column) - { - if (header.getTableModel().getSortedColumn() != 0) - { - textSortButton.setIcon(null); - } - TableColumn trackedColumn = header.getTrackedColumn(); - if (trackedColumn != null && trackedColumn.getHeaderValue() == null && trackedColumn == - header.getDraggedColumn()) - { - findPressedButton().setModel(usedModel); - } - else - { - treeViewButton.setModel(defaultModel); - treeSortButton.setModel(defaultModel); - textSortButton.setModel(defaultModel); - } - treeViewButton.setText(header.getTableModel().getSelectedTreeView().getViewName()); - return this; - } - -} Added: branches/cdomui/code/src/java/pcgen/gui/resource/About16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/About16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Add16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Add16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/AlignBottom16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/AlignBottom16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/AlignCenter16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/AlignCenter16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/AlignJustifyHorizontal16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/AlignJustifyHorizontal16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/AlignJustifyVertical16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/AlignJustifyVertical16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/AlignLeft16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/AlignLeft16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/AlignRight16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/AlignRight16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/AlignTop16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/AlignTop16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/BBack16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/BBack16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/BBack24.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/BBack24.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Back16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Back16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Bookmarks16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Bookmarks16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Checklist16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Checklist16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Close16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Close16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/CloseAll16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/CloseAll16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/ComposeMail16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/ComposeMail16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/ContextualHelp16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/ContextualHelp16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Copy16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Copy16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/CustomZoom16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/CustomZoom16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Cut16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Cut16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/D20_logo_RGB.jpg =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/D20_logo_RGB.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/DDown16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/DDown16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/DDown24.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/DDown24.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/DefaultPortrait.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/DefaultPortrait.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Delete16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Delete16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Down16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Down16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Edit16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Edit16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/EditZoom16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/EditZoom16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Export16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Export16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/FForward16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/FForward16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/FForward24.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/FForward24.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Find16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Find16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/FindAgain16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/FindAgain16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Forward16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Forward16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Help16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Help16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/History16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/History16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Import16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Import16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Information16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Information16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/MediaStop16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/MediaStop16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/New16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/New16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/NewEnvelope.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/NewEnvelope.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/NewNPC16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/NewNPC16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Open16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Open16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/PCGenApp.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/PCGenApp.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/PageSetup16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/PageSetup16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Paste16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Paste16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/PcgenIcon.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/PcgenIcon.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Preferences16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Preferences16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/PreferencesHighlightBlue16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/PreferencesHighlightBlue16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Print16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Print16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/PrintPreview16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/PrintPreview16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Properties16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Properties16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Redo16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Redo16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Refresh16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Refresh16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Remove16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Remove16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/RemovePreferences16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/RemovePreferences16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/RemoveZoom16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/RemoveZoom16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Replace16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Replace16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Save16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Save16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SaveAll16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SaveAll16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SaveAs16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SaveAs16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Search16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Search16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SendMail16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SendMail16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen-Alpha.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen-Alpha.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_510.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_510.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_5101.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_5101.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_512.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_512.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_Beta.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_Beta.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_Ennie.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashPcgen_Ennie.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/SplashScreen.png =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/SplashScreen.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Stop16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Stop16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Thumbs.db =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Thumbs.db ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/TipOfTheDay16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/TipOfTheDay16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/TipOfTheDay24.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/TipOfTheDay24.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/UUp16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/UUp16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/UUp24.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/UUp24.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Undo16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Undo16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Up16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Up16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/Zoom16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/Zoom16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/ZoomHighlightBlue16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/ZoomHighlightBlue16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/ZoomIn16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/ZoomIn16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/ZoomOut16.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/ZoomOut16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/bronze100x100-2003.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/bronze100x100-2003.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/bronze200x200-2003.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/bronze200x200-2003.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/cdomui/code/src/java/pcgen/gui/resource/bronze300x300-2003.gif =================================================================== (Binary files differ) Property changes on: branches/cdomui/code/src/java/pcgen/gui/resource/bronze300x300-2003.gif ________________________________________________________... [truncated message content] |
From: <cpm...@us...> - 2008-02-22 09:58:08
|
Revision: 5253 http://pcgen.svn.sourceforge.net/pcgen/?rev=5253&view=rev Author: cpmeister Date: 2008-02-22 01:58:13 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Utilities update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/resource/Thumbs.db branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-22 09:12:13 UTC (rev 5252) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-22 09:58:13 UTC (rev 5253) @@ -75,53 +75,5 @@ private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; // End of variables declaration//GEN-END:variables - private class StringModel implements TreeViewModel<Integer> - { - - public EnumSet<? extends TreeView<Integer>> getTreeViews() - { - return EnumSet.allOf(StringView.class); - } - - public DataView<Integer> getDataView() - { - return null; - } - - } - private enum StringView implements TreeView<Integer> - { - ONE("one"), - TWO("two"), - THREE("three"), - FOUR("four"), - FIVE("five"), - SIX("six"), - SEVEN("seven"), - EIGHT("eight"), - NINE("nine"), - TEN("ten"); - private final String name; - - private StringView(String name) - { - this.name = name; - } - public String getViewName() - { - return name; - } - - public List<TreeViewPath<Integer>> getPaths(Integer pobj) - { - switch(this) - { - case ONE: - return Arrays.asList(new TreeViewPath<Integer>(pobj, pobj.toString())); - default: - return Arrays.asList(new TreeViewPath<Integer>(pobj)); - } - } - } } Modified: branches/cdomui/code/src/java/pcgen/gui/resource/Thumbs.db =================================================================== (Binary files differ) Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-02-22 09:12:13 UTC (rev 5252) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-02-22 09:58:13 UTC (rev 5253) @@ -6,13 +6,13 @@ package pcgen.gui.util.treeview; -import java.util.EnumSet; +import java.util.List; /** * * @author Connor Petty */ public interface TreeViewModel<E>{ - EnumSet<? extends TreeView<E>> getTreeViews(); + List<? extends TreeView<E>> getTreeViews(); DataView<E> getDataView(); } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-22 09:12:13 UTC (rev 5252) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-22 09:58:13 UTC (rev 5253) @@ -22,15 +22,12 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Comparator; -import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; import pcgen.gui.util.treetable.AbstractTreeTableModel; import pcgen.gui.util.treetable.DefaultSortableTreeTableNode; import pcgen.gui.util.treetable.TreeTableModel; -import pcgen.util.Comparators; import pcgen.util.UnboundedArrayList; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-02-23 03:34:16
|
Revision: 5264 http://pcgen.svn.sourceforge.net/pcgen/?rev=5264&view=rev Author: cpmeister Date: 2008-02-22 19:34:22 -0800 (Fri, 22 Feb 2008) Log Message: ----------- Utilities update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java branches/cdomui/code/src/java/pcgen/gui/util/SortableModel.java branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/AbstractTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/TreeTableNode.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataViewColumn.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/table/ branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/table/SortableTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModelAdapter.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -24,7 +24,7 @@ import javax.swing.table.TableColumnModel; import pcgen.gui.util.JTreeViewTable; import pcgen.gui.util.treeview.DataView; -import pcgen.gui.util.treeview.DataViewColumn; +import pcgen.gui.util.treeview.DefaultDataViewColumn; import pcgen.gui.util.treeview.TreeView; import pcgen.gui.util.treeview.TreeViewModel; import pcgen.gui.util.treeview.TreeViewPath; Copied: branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java (from rev 5249, branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,83 @@ +/* + * JSortableTableHeader.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 16, 2008, 8:27:21 PM + */ +package pcgen.gui.proto.util; + +import pcgen.gui.util.JTreeViewTable; +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionListener; +import javax.swing.table.TableColumn; +import pcgen.gui.util.SortingHeaderRenderer; +import javax.swing.JTable; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import pcgen.gui.util.treeview.TreeViewTableModel; + +/** + * + * @author Connor Petty<mis...@gm...> + */ +public class JSortableTableHeader extends JTableHeader +{ + + private TreeViewTableModel tableModel; + private TableColumn trackedColumn; + + public JSortableTableHeader(JTreeViewTable table) + { + super(table.getColumnModel()); + addMouseMotionListener(new ColumnTracker()); + tableModel = table.getTreeViewTableModel(); + } + + @Override + public TableCellRenderer createDefaultRenderer() + { + return new SortingHeaderRenderer(this); + } + + public TableColumn getTrackedColumn() + { + return trackedColumn; + } + + public TreeViewTableModel getTableModel() + { + return tableModel; + } + + private final class ColumnTracker implements MouseMotionListener + { + + public void mouseDragged(MouseEvent e) + { + + } + + public void mouseMoved(MouseEvent e) + { + TableColumnModel model = getColumnModel(); + trackedColumn = model.getColumn(model.getColumnIndexAtX(e.getX())); + } + + } +} Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JTreeViewTableHeader.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -1,114 +0,0 @@ -/* - * JTreeViewTableHeader.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 16, 2008, 8:27:21 PM - */ -package pcgen.gui.proto.util; - -import pcgen.gui.util.JTreeViewTable; -import java.awt.Component; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionListener; -import javax.swing.table.TableColumn; -import pcgen.gui.util.SortingHeaderRenderer; -import javax.swing.JTable; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumnModel; -import pcgen.gui.util.treeview.TreeViewTableModel; - -/** - * - * @author Connor Petty<mis...@gm...> - */ -public class JTreeViewTableHeader extends JTableHeader -{ - - private TreeViewTableModel tableModel; - private TableColumn trackedColumn; - - public JTreeViewTableHeader(JTreeViewTable table) - { - super(table.getColumnModel()); - addMouseMotionListener(new ColumnTracker()); - tableModel = table.getTreeViewTableModel(); - } - - @Override - public TableCellRenderer createDefaultRenderer() - { - return new CompoundHeaderRenderer(); - } - - public TableColumn getTrackedColumn() - { - return trackedColumn; - } - - public TreeViewTableModel getTableModel() - { - return tableModel; - } - - private final class ColumnTracker implements MouseMotionListener - { - - public void mouseDragged(MouseEvent e) - { - - } - - public void mouseMoved(MouseEvent e) - { - TableColumnModel model = getColumnModel(); - trackedColumn = model.getColumn(model.getColumnIndexAtX(e.getX())); - } - - } - - private final class CompoundHeaderRenderer implements TableCellRenderer - { - - private TreeViewHeaderRenderer treeRenderer = new TreeViewHeaderRenderer(JTreeViewTableHeader.this); - private SortingHeaderRenderer sortRenderer = new SortingHeaderRenderer(JTreeViewTableHeader.this); - - public Component getTableCellRendererComponent(JTable table, - Object value, - boolean isSelected, - boolean hasFocus, - int row, - int column) - { - if (value == null) - { - return treeRenderer.getTableCellRendererComponent(table, value, - isSelected, - hasFocus, row, - column); - } - else - { - return sortRenderer.getTableCellRendererComponent(table, value, - isSelected, - hasFocus, row, - column); - } - } - - } -} Modified: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -29,7 +29,7 @@ public class TreeViewHeaderRenderer extends SortingHeaderRenderer { - public TreeViewHeaderRenderer(JTreeViewTableHeader header) + public TreeViewHeaderRenderer(JSortableTableHeader header) { super(header); } Added: branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,87 @@ +/* + * JSortableTable.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 22, 2008, 3:42:02 PM + */ +package pcgen.gui.util; + +import javax.swing.JTable; +import javax.swing.table.TableModel; +import pcgen.gui.util.table.DefaultSortableTableModel; +import pcgen.gui.util.table.SortableTableModel; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class JSortableTable extends JTable +{ + + private ModelSorter sorter; + + public JSortableTable() + { + super(); + } + + public JSortableTable(TableModel model) + { + super(model); + } + + @Override + public void setModel(TableModel model) + { + if (model instanceof SortableTableModel) + { + super.setModel(model); + } + else + { + super.setModel(new DefaultSortableTableModel(model)); + } + } + + @Override + @SuppressWarnings("unchecked") + public SortableTableModel getModel() + { + return (SortableTableModel) super.getModel(); + } + + public ModelSorter getModelSorter() + { + return sorter; + } + + public void setModelSorter(ModelSorter sorter) + { + ModelSorter old = this.sorter; + if (old != null) + { + old.setModel(null); + } + if (sorter != null) + { + sorter.setModel(getModel()); + } + this.sorter = sorter; + //TODO: do something with old + } + +} Added: branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,119 @@ +/* + * JSortableTreeTable.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 22, 2008, 4:10:15 PM + */ +package pcgen.gui.util; + +import java.util.Comparator; +import java.util.List; +import javax.swing.JTree; +import pcgen.gui.util.table.SortableTableModel; +import pcgen.gui.util.treetable.DefaultSortableTreeTableModel; +import pcgen.gui.util.treetable.SortableTreeTableModel; +import pcgen.gui.util.treetable.TreeTableModel; +import pcgen.util.Comparators; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class JSortableTreeTable extends JTreeTable +{ + + private ModelSorter sorter; + + public JSortableTreeTable() + { + this(null); + } + + public JSortableTreeTable(SortableTreeTableModel model) + { + super(model); + } + + @Override + protected TreeTableModelAdapter createDefaultTreeTableModelAdapter(TreeTableModel treeTableModel, + JTree tree) + { + return new SortableTreeTableModelAdapter((SortableTreeTableModel) treeTableModel, + tree); + } + + public ModelSorter getModelSorter() + { + return sorter; + } + + @Override + public void setTreeTableModel(TreeTableModel model) + { + if (model instanceof SortableTreeTableModel) + { + super.setTreeTableModel(model); + } + else + { + super.setTreeTableModel(new DefaultSortableTreeTableModel(model)); + } + } + + public void setModelSorter(ModelSorter sorter) + { + ModelSorter old = this.sorter; + if (old != null) + { + old.setModel(null); + } + if (sorter != null) + { + sorter.setModel((SortableTreeTableModelAdapter) getModel()); + } + this.sorter = sorter; + //TODO: do something with old + } + + private static final class SortableTreeTableModelAdapter extends TreeTableModelAdapter + implements SortableTableModel + { + + SortableTreeTableModelAdapter(SortableTreeTableModel model, JTree tree) + { + super(model, tree); + } + + public void sortModel(Comparator<List<?>> comparator) + { + if (treeTableModel != null) + { + ((SortableTreeTableModel) treeTableModel).sortModel(comparator); + } + } + + public Comparator<?> getComparator(int column) + { + if (treeTableModel != null) + { + return ((SortableTreeTableModel) treeTableModel).getComparator(column); + } + return Comparators.toStringComparator(); + } + + } +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -39,13 +39,21 @@ import javax.swing.event.CellEditorListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.event.TreeExpansionEvent; +import javax.swing.event.TreeExpansionListener; +import javax.swing.event.TreeModelEvent; +import javax.swing.event.TreeModelListener; +import javax.swing.table.AbstractTableModel; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableModel; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeSelectionModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; +import pcgen.gui.util.treetable.DefaultTreeTableModel; +import pcgen.gui.util.treetable.TreeTableNode; /** * This example shows how to create a simple JTreeTable component, @@ -97,7 +105,7 @@ // Create the tree. It will be used as a renderer and editor. tree = new TreeTableCellRenderer(treeTableModel); tree.setRootVisible(false); - adapter = new TreeTableModelAdapter(treeTableModel, tree); + adapter = createDefaultTreeTableModelAdapter(treeTableModel, tree); // Install a tableModel representing the visible rows in tree. super.setModel(adapter); @@ -109,8 +117,8 @@ setSelectionModel(selectionWrapper.getListSelectionModel()); // Install the tree editor renderer and editor. - setDefaultRenderer(TreeTableModel.class, tree); - setDefaultEditor(TreeTableModel.class, new TreeTableCellEditor()); + setDefaultRenderer(TreeTableNode.class, tree); + setDefaultEditor(TreeTableNode.class, new TreeTableCellEditor()); // No grid. setShowGrid(false); @@ -132,6 +140,12 @@ } } + protected TreeTableModelAdapter createDefaultTreeTableModelAdapter(TreeTableModel treeTableModel, + JTree tree) + { + return new TreeTableModelAdapter(treeTableModel, tree); + } + @SuppressWarnings("unchecked") public TreeTableModel getTreeTableModel() { @@ -144,6 +158,22 @@ adapter.setTreeTableModel(model); } + @Override + public void setModel(TableModel model) + { + if (model instanceof TreeTableModelAdapter) + { + adapter.setTreeTableModel(null); + adapter = (TreeTableModelAdapter) model; + adapter.setTreeTableModel((TreeTableModel)tree.getModel()); + super.setModel(model); + } + else + { + setTreeTableModel(new DefaultTreeTableModel(model)); + } + } + /** * Workaround for BasicTableUI anomaly. Make sure the UI never tries to * paint the editor. The UI currently uses different techniques to @@ -155,7 +185,7 @@ @Override public int getEditingRow() { - return (getColumnClass(editingColumn) == TreeTableModel.class) ? (-1) + return (getColumnClass(editingColumn) == TreeTableNode.class) ? (-1) : editingRow; } @@ -268,6 +298,175 @@ } /** + * This is a wrapper class takes a TreeTableModel and implements + * the table model interface. The implementation is trivial, with + * all of the event dispatching support provided by the superclass: + * the AbstractTableModel. + * + * @version 1.2 10/27/98 + * + * @author Philip Milne + * @author Scott Violet + */ + protected static class TreeTableModelAdapter extends AbstractTableModel + { + + private JTree tree; + protected TreeTableModel treeTableModel; + private TreeModelListener modelListener; + + /** + * Constructor + * @param treeTableModel + * @param tree + */ + TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree) + { + this.tree = tree; + this.treeTableModel = treeTableModel; + + tree.addTreeExpansionListener(new TreeExpansionListener() + { + // Don't use fireTableRowsInserted() here; + // the selection model would get updated twice. + public void treeExpanded(TreeExpansionEvent event) + { + fireTableDataChanged(); + } + + public void treeCollapsed(TreeExpansionEvent event) + { + fireTableDataChanged(); + } + + }); + + /** + * Install a TreeModelListener that can update the table when + * tree changes. We use delayedFireTableDataChanged as we can + * not be guaranteed the tree will have finished processing + * the event before us. + **/ + modelListener = new TreeModelListener() + { + + public void treeNodesChanged(TreeModelEvent e) + { + fireTableDataChanged(); + } + + public void treeNodesInserted(TreeModelEvent e) + { + fireTableDataChanged(); + } + + public void treeNodesRemoved(TreeModelEvent e) + { + fireTableDataChanged(); + } + + public void treeStructureChanged(TreeModelEvent e) + { + fireTableStructureChanged(); + } + + }; + if (treeTableModel != null) + { + treeTableModel.addTreeModelListener(modelListener); + } + } + + public void setTreeTableModel(TreeTableModel model) + { + if (treeTableModel != null) + { + treeTableModel.removeTreeModelListener(modelListener); + } + treeTableModel = model; + if (treeTableModel != null) + { + treeTableModel.addTreeModelListener(modelListener); + } + } + + @Override + public boolean isCellEditable(int row, int column) + { + if (treeTableModel == null) + { + return false; + } + return treeTableModel.isCellEditable(nodeForRow(row), column); + } + + @Override + public Class<?> getColumnClass(int column) + { + if (treeTableModel == null) + { + return Object.class; + } + return treeTableModel.getColumnClass(column); + } + + // Wrappers, implementing TableModel interface. + public int getColumnCount() + { + if (treeTableModel == null) + { + return 0; + } + return treeTableModel.getColumnCount(); + } + + @Override + public String getColumnName(int column) + { + if (treeTableModel == null) + { + return null; + } + return treeTableModel.getColumnName(column); + } + + public int getRowCount() + { + return tree.getRowCount(); + } + + @Override + public void setValueAt(Object value, int row, int column) + { + if (treeTableModel == null) + { + return; + } + treeTableModel.setValueAt(value, nodeForRow(row), column); + } + + public Object getValueAt(int row, int column) + { + if (treeTableModel == null) + { + return null; + } + return treeTableModel.getValueAt(nodeForRow(row), column); + } + + private Object nodeForRow(int row) + { + TreePath treePath = tree.getPathForRow(row); + if (treePath != null) + { + return treePath.getLastPathComponent(); + } + return null; + } + + } + + /** * A TreeCellRenderer that displays a JTree. **/ final class TreeTableCellRenderer extends JTree implements @@ -588,7 +787,7 @@ { for (int counter = getColumnCount() - 1; counter >= 0; counter--) { - if (getColumnClass(counter) == TreeTableModel.class) + if (getColumnClass(counter) == TreeTableNode.class) { MouseEvent me = (MouseEvent) e; MouseEvent newME = Modified: branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -37,7 +37,6 @@ private final EventListenerList listenerList = new EventListenerList(); private final RowComparator rowComparator = new RowComparator(); private List<? extends SortingPriority> columnkeys = null; - private Map<Integer, Comparator<?>> comparatorMap = null; private SortableModel model; public void addTableSorterListener(ModelSorterListener listener) @@ -62,24 +61,6 @@ listenerList.remove(ModelSorterListener.class, listener); } - public Comparator<?> getComparator(int column) - { - if (comparatorMap != null) - { - return comparatorMap.get(column); - } - return null; - } - - public void setComparator(Comparator<?> comparator, int column) - { - if (comparatorMap == null) - { - comparatorMap = new HashMap<Integer, Comparator<?>>(); - } - comparatorMap.put(column, comparator); - } - public void toggleSort(int column) { List<SortingPriority> list = new ArrayList<SortingPriority>(getSortingPriority()); @@ -111,7 +92,7 @@ public void setSortingPriority(List<? extends SortingPriority> keys) { - this.columnkeys = new ArrayList(keys); + this.columnkeys = new ArrayList<SortingPriority>(keys); sort(); } @@ -134,6 +115,7 @@ private final class RowComparator implements Comparator<List<?>> { + @SuppressWarnings("unchecked") public int compare(List<?> o1, List<?> o2) { @@ -145,7 +127,7 @@ continue; } int column = priority.getColumn(); - Comparator comparator = getComparator(column); + Comparator comparator = model.getComparator(column); int ret = comparator.compare(o1.get(column), o2.get(column)); if (priority.getMode() == SortMode.DESCENDING) { Modified: branches/cdomui/code/src/java/pcgen/gui/util/SortableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SortableModel.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/SortableModel.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -31,4 +31,5 @@ public interface SortableModel { void sortModel(Comparator<List<?>> comparator); + Comparator<?> getComparator(int column); } Modified: branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -34,11 +34,12 @@ import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JTable; +import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; -import pcgen.gui.proto.util.JTreeViewTableHeader; -import pcgen.gui.util.treeview.DataViewColumn; +import pcgen.gui.proto.util.JSortableTableHeader; +import pcgen.gui.util.treeview.DefaultDataViewColumn; import pcgen.gui.util.treeview.TreeViewTableModel; import pcgen.util.Comparators; @@ -52,10 +53,10 @@ private static final ButtonModel defaultModel = new DefaultButtonModel(); private final ButtonModel usedModel = new DefaultButtonModel(); - private final JTreeViewTableHeader header; + private final JSortableTableHeader header; private Map<TableColumn, Icon> iconMap = Collections.emptyMap(); - public SortingHeaderRenderer(final JTreeViewTableHeader header) + public SortingHeaderRenderer(final JSortableTableHeader header) { this.header = header; Deleted: branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModelAdapter.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModelAdapter.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/TreeTableModelAdapter.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -1,191 +0,0 @@ -/* - * @(#)TreeTableModelAdapter.java 1.2 98/10/27 - * - * Copyright 1997, 1998 by Sun Microsystems, Inc., - * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. - * All rights reserved. - * - * This software is the confidential and proprietary information - * of Sun Microsystems, Inc. ("Confidential Information"). You - * shall not disclose such Confidential Information and shall use - * it only in accordance with the terms of the license agreement - * you entered into with Sun. - */ -package pcgen.gui.util; - -import pcgen.gui.util.treetable.TreeTableModel; -import javax.swing.JTree; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeExpansionListener; -import javax.swing.event.TreeModelEvent; -import javax.swing.event.TreeModelListener; -import javax.swing.table.AbstractTableModel; -import javax.swing.tree.TreePath; - -/** - * This is a wrapper class takes a TreeTableModel and implements - * the table model interface. The implementation is trivial, with - * all of the event dispatching support provided by the superclass: - * the AbstractTableModel. - * - * @version 1.2 10/27/98 - * - * @author Philip Milne - * @author Scott Violet - */ -final class TreeTableModelAdapter extends AbstractTableModel -{ - - private JTree tree; - private TreeTableModel treeTableModel; - private TreeModelListener modelListener; - - /** - * Constructor - * @param treeTableModel - * @param tree - */ - public TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree) - { - this.tree = tree; - this.treeTableModel = treeTableModel; - - tree.addTreeExpansionListener(new TreeExpansionListener() - { - // Don't use fireTableRowsInserted() here; - // the selection model would get updated twice. - public void treeExpanded(TreeExpansionEvent event) - { - fireTableDataChanged(); - } - - public void treeCollapsed(TreeExpansionEvent event) - { - fireTableDataChanged(); - } - - }); - - /** - * Install a TreeModelListener that can update the table when - * tree changes. We use delayedFireTableDataChanged as we can - * not be guaranteed the tree will have finished processing - * the event before us. - **/ - modelListener = new TreeModelListener() - { - - public void treeNodesChanged(TreeModelEvent e) - { - fireTableDataChanged(); - } - - public void treeNodesInserted(TreeModelEvent e) - { - fireTableDataChanged(); - } - - public void treeNodesRemoved(TreeModelEvent e) - { - fireTableDataChanged(); - } - - public void treeStructureChanged(TreeModelEvent e) - { - fireTableStructureChanged(); - } - - }; - if (treeTableModel != null) - { - treeTableModel.addTreeModelListener(modelListener); - } - } - - public void setTreeTableModel(TreeTableModel model) - { - if (treeTableModel != null) - { - treeTableModel.removeTreeModelListener(modelListener); - } - treeTableModel = model; - if (treeTableModel != null) - { - treeTableModel.addTreeModelListener(modelListener); - } - } - - @Override - public boolean isCellEditable(int row, int column) - { - if (treeTableModel == null) - { - return false; - } - return treeTableModel.isCellEditable(nodeForRow(row), column); - } - - public Class<?> getColumnClass(int column) - { - if (treeTableModel == null) - { - return Object.class; - } - return treeTableModel.getColumnClass(column); - } - - // Wrappers, implementing TableModel interface. - public int getColumnCount() - { - if (treeTableModel == null) - { - return 0; - } - return treeTableModel.getColumnCount(); - } - - @Override - public String getColumnName(int column) - { - if (treeTableModel == null) - { - return null; - } - return treeTableModel.getColumnName(column); - } - - public int getRowCount() - { - return tree.getRowCount(); - } - - @Override - public void setValueAt(Object value, int row, int column) - { - if (treeTableModel == null) - { - return; - } - treeTableModel.setValueAt(value, nodeForRow(row), column); - } - - public Object getValueAt(int row, int column) - { - if (treeTableModel == null) - { - return null; - } - return treeTableModel.getValueAt(nodeForRow(row), column); - } - - public Object nodeForRow(int row) - { - TreePath treePath = tree.getPathForRow(row); - if (treePath != null) - { - return treePath.getLastPathComponent(); - } - return null; - } - -} Added: branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,176 @@ +/* + * DefaultSortableTableModel.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 22, 2008, 3:08:09 PM + */ +package pcgen.gui.util.table; + +import pcgen.gui.util.*; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Vector; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import pcgen.util.Comparators; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class DefaultSortableTableModel extends DefaultTableModel implements SortableTableModel +{ + + private Map<Integer, Comparator<?>> comparatorMap = null; + + /** + * Constructs a default <code>DefaultSortableTableModel</code> + * which is a table of zero columns and zero rows. + */ + public DefaultSortableTableModel() + { + super(); + } + + /** + * Constructs a <code>DefaultSortableTableModel</code> with + * <code>rowCount</code> and <code>columnCount</code> of + * <code>null</code> object values. + * + * @param rowCount the number of rows the table holds + * @param columnCount the number of columns the table holds + * + * @see #setValueAt + */ + public DefaultSortableTableModel(int rowCount, int columnCount) + { + super(rowCount, columnCount); + } + + /** + * Constructs a <code>DefaultSortableTableModel</code> with as many columns + * as there are elements in <code>columnNames</code> + * and <code>rowCount</code> of <code>null</code> + * object values. Each column's name will be taken from + * the <code>columnNames</code> vector. + * + * @param columnNames <code>vector</code> containing the names + * of the new columns; if this is + * <code>null</code> then the model has no columns + * @param rowCount the number of rows the table holds + * @see #setDataVector + * @see #setValueAt + */ + public DefaultSortableTableModel(Vector columnNames, int rowCount) + { + super(columnNames, rowCount); + } + + /** + * Constructs a <code>DefaultSortableTableModel</code> with as many + * columns as there are elements in <code>columnNames</code> + * and <code>rowCount</code> of <code>null</code> + * object values. Each column's name will be taken from + * the <code>columnNames</code> array. + * + * @param columnNames <code>array</code> containing the names + * of the new columns; if this is + * <code>null</code> then the model has no columns + * @param rowCount the number of rows the table holds + * @see #setDataVector + * @see #setValueAt + */ + public DefaultSortableTableModel(Object[] columnNames, int rowCount) + { + super(columnNames, rowCount); + } + + /** + * Constructs a <code>DefaultSortableTableModel</code> and initializes the table + * by passing <code>data</code> and <code>columnNames</code> + * to the <code>setDataVector</code> method. + * + * @param data the data of the table, a <code>Vector</code> + * of <code>Vector</code>s of <code>Object</code> + * values + * @param columnNames <code>vector</code> containing the names + * of the new columns + * @see #getDataVector + * @see #setDataVector + */ + public DefaultSortableTableModel(Vector data, Vector columnNames) + { + super(data, columnNames); + } + + /** + * Constructs a <code>DefaultSortableTableModel</code> and initializes the table + * by passing <code>data</code> and <code>columnNames</code> + * to the <code>setDataVector</code> + * method. The first index in the <code>Object[][]</code> array is + * the row index and the second is the column index. + * + * @param data the data of the table + * @param columnNames the names of the columns + * @see #getDataVector + * @see #setDataVector + */ + public DefaultSortableTableModel(Object[][] data, Object[] columnNames) + { + super(data, columnNames); + } + + public DefaultSortableTableModel(TableModel model) + { + super(model.getRowCount(), model.getColumnCount()); + for (int x = 0; x < getRowCount(); x++) + { + for (int y = 0; y < getColumnCount(); y++) + { + setValueAt(model.getValueAt(x, y), x, y); + } + } + } + + @SuppressWarnings("unchecked") + public void sortModel(Comparator<List<?>> comparator) + { + Collections.sort(dataVector, comparator); + } + + public Comparator<?> getComparator(int column) + { + if (comparatorMap != null && comparatorMap.containsKey(column)) + { + return comparatorMap.get(column); + } + return Comparators.toStringComparator(); + } + + public void setComparator(int column, Comparator<?> comparator) + { + if (comparatorMap == null) + { + comparatorMap = new HashMap<Integer, Comparator<?>>(); + } + comparatorMap.put(column, comparator); + } + +} Added: branches/cdomui/code/src/java/pcgen/gui/util/table/SortableTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/table/SortableTableModel.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/table/SortableTableModel.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,34 @@ +/* + * SortableTableModel.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 22, 2008, 3:26:34 PM + */ + +package pcgen.gui.util.table; + +import javax.swing.table.TableModel; +import pcgen.gui.util.SortableModel; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public interface SortableTableModel extends TableModel, SortableModel +{ + +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/treetable/AbstractTreeTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/AbstractTreeTableModel.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/AbstractTreeTableModel.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -25,6 +25,11 @@ public abstract class AbstractTreeTableModel extends DefaultTreeModel implements TreeTableModel { + protected AbstractTreeTableModel() + { + this(null); + } + public AbstractTreeTableModel(TreeTableNode root) { super(root); @@ -36,7 +41,7 @@ */ public boolean isCellEditable(Object node, int column) { - return getColumnClass(column) == TreeTableModel.class; + return getColumnClass(column) == TreeTableNode.class; } public Class<?> getColumnClass(int column) Added: branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableModel.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableModel.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,79 @@ +/* + * DefaultSortableTreeTableModel.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 22, 2008, 4:49:49 PM + */ +package pcgen.gui.util.treetable; + +import java.util.Comparator; +import java.util.List; +import javax.swing.table.TableModel; +import javax.swing.tree.TreeNode; +import pcgen.util.Comparators; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class DefaultSortableTreeTableModel extends DefaultTreeTableModel + implements SortableTreeTableModel +{ + + protected DefaultSortableTreeTableModel() + { + super(); + } + + protected DefaultSortableTreeTableModel(SortableTreeTableNode root) + { + super(root); + } + + public DefaultSortableTreeTableModel(TableModel model) + { + super(model); + } + + public DefaultSortableTreeTableModel(TreeTableModel model) + { + super(model); + } + + @Override + protected TreeTableNode createDefaultTreeTableNode() + { + return new DefaultSortableTreeTableNode(); + } + + @Override + protected TreeTableNode createDefaultTreeTableNode(TreeNode node) + { + return new DefaultSortableTreeTableNode(node); + } + + public void sortModel(Comparator<List<?>> comparator) + { + ((SortableTreeTableNode) getRoot()).sortChildren(comparator); + } + + public Comparator<?> getComparator(int column) + { + return Comparators.toStringComparator(); + } + +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -26,6 +26,8 @@ import java.util.Vector; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.MutableTreeNode; +import javax.swing.tree.TreeNode; +import pcgen.util.UnboundedArrayList; /** * @@ -37,6 +39,34 @@ protected Vector<List<Object>> childData = null; + public DefaultSortableTreeTableNode() + { + super(); + } + + public DefaultSortableTreeTableNode(TreeNode node) + { + for (int x = 0; x < node.getChildCount(); x++) + { + TreeNode treeNode = node.getChildAt(x); + DefaultSortableTreeTableNode child = new DefaultSortableTreeTableNode(treeNode); + if (treeNode instanceof TreeTableNode) + { + TreeTableNode treeTableNode = (TreeTableNode) treeNode; + List<Object> data = treeTableNode.getValues(); + if (data != null) + { + data = new UnboundedArrayList<Object>(data); + } + add(child, data); + } + else + { + add(child); + } + } + } + @Override public void add(MutableTreeNode newChild) { @@ -87,7 +117,7 @@ return null; } - private List<Object> getData() + public List<Object> getValues() { DefaultSortableTreeTableNode parentNode = getSortableParent(); if (parentNode != null) @@ -108,7 +138,7 @@ public Object getValueAt(int column) { - List<Object> data = getData(); + List<Object> data = getValues(); if (data != null) { return data.get(column); @@ -118,7 +148,7 @@ public void setValueAt(Object value, int column) { - List<Object> data = getData(); + List<Object> data = getValues(); if (data != null) { data.set(column, value); @@ -172,7 +202,7 @@ public int compare(DefaultSortableTreeTableNode o1, DefaultSortableTreeTableNode o2) { - return comparator.compare(o1.getData(), o2.getData()); + return comparator.compare(o1.getValues(), o2.getValues()); } } Added: branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,121 @@ +/* + * DefaultTreeTableModel.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 22, 2008, 5:47:03 PM + */ +package pcgen.gui.util.treetable; + +import java.util.ArrayList; +import java.util.List; +import javax.swing.table.TableModel; +import javax.swing.tree.TreeNode; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class DefaultTreeTableModel extends AbstractTreeTableModel +{ + + private List<Class<?>> columnClasses; + private List<String> columnNames; + private int columnCount; + + protected DefaultTreeTableModel() + { + super(); + } + + protected DefaultTreeTableModel(TreeTableNode root) + { + super(root); + } + + public DefaultTreeTableModel(TableModel tableModel) + { + super(null); + TreeTableNode rootNode = createDefaultTreeTableNode(); + columnCount = tableModel.getColumnCount(); + for (int x = 0; x < tableModel.getRowCount(); x++) + { + TreeTableNode child = createDefaultTreeTableNode(); + for (int y = 0; y < columnCount; y++) + { + child.setValueAt(tableModel.getValueAt(x, y), y); + } + rootNode.insert(child, x); + } + columnClasses = new ArrayList<Class<?>>(columnCount); + columnNames = new ArrayList<String>(columnCount); + for (int x = 0; x < columnCount; x++) + { + columnClasses.add(tableModel.getColumnClass(x)); + columnNames.add(tableModel.getColumnName(x)); + } + setRoot(rootNode); + } + + public DefaultTreeTableModel(TreeTableModel treeTableModel) + { + super(null); + TreeTableNode rootNode = createDefaultTreeTableNode((TreeNode) treeTableModel.getRoot()); + columnCount = treeTableModel.getColumnCount(); + columnClasses = new ArrayList<Class<?>>(columnCount); + columnNames = new ArrayList<String>(columnCount); + for (int x = 0; x < columnCount; x++) + { + columnClasses.add(treeTableModel.getColumnClass(x)); + columnNames.add(treeTableModel.getColumnName(x)); + } + setRoot(rootNode); + } + + protected TreeTableNode createDefaultTreeTableNode() + { + return new DefaultTreeTableNode(); + } + + protected TreeTableNode createDefaultTreeTableNode(TreeNode node) + { + return new DefaultTreeTableNode(node); + } + + public int getColumnCount() + { + return columnCount; + } + + @Override + public Class<?> getColumnClass(int column) + { + switch (column) + { + case 0: + return TreeTableNode.class; + default: + return columnClasses.get(column); + } + } + + @Override + public String getColumnName(int column) + { + return columnNames.get(column); + } + +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -20,8 +20,11 @@ */ package pcgen.gui.util.treetable; +import java.util.Collections; +import java.util.List; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; +import pcgen.util.UnboundedArrayList; /** * @@ -29,21 +32,62 @@ */ public class DefaultTreeTableNode extends DefaultMutableTreeNode implements TreeTableNode { - private Object[] data; - public DefaultTreeTableNode(Object name, Object[] data) + private List<Object> data; + + public DefaultTreeTableNode() { - super(name); - this.data = data; + this(Collections.emptyList()); } + public DefaultTreeTableNode(List<Object> data) + { + setValues(data); + } + + public DefaultTreeTableNode(TreeNode node) + { + this(); + if (node instanceof TreeTableNode) + { + TreeTableNode treeTableNode = (TreeTableNode) node; + setValues(treeTableNode.getValues()); + } + for (int x = 0; x < node.getChildCount(); x++) + { + add(new DefaultTreeTableNode(node.getChildAt(x))); + } + } + public Object getValueAt(int column) { - return data[column]; + return data.get(column); } public void setValueAt(Object value, int column) { - data[column] = value; + data.set(column, value); } + + public List<Object> getValues() + { + return data; + } + + private void setValues(List<Object> values) + { + this.data = new UnboundedArrayList<Object>(data); + } + + @Override + public String toString() + { + Object name = data.get(0); + if (name != null) + { + return name.toString(); + } + return super.toString(); + } + } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treetable/TreeTableNode.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/TreeTableNode.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/TreeTableNode.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -20,6 +20,7 @@ */ package pcgen.gui.util.treetable; +import java.util.List; import javax.swing.tree.MutableTreeNode; /** @@ -28,6 +29,7 @@ */ public interface TreeTableNode extends MutableTreeNode { + public List<Object> getValues(); public Object getValueAt(int column); public void setValueAt(Object value, int column); } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataViewColumn.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataViewColumn.java 2008-02-22 23:56:50 UTC (rev 5263) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataViewColumn.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -26,34 +26,13 @@ * * @author Connor Petty <mis...@gm...> */ -public class DataViewColumn +public interface DataViewColumn { - private String name; - private Class<?> dataclass; - private Comparator<?> comparator; + public String getName(); - public <T> DataViewColumn(String name, Class<T> dataclass, - Comparator<T> comparator) - { - this.name = name; - this.dataclass = dataclass; - this.comparator = comparator; - } + public Class<?> getDataClass(); - public String getName() - { - return name; - } + public Comparator<?> getComparator(); - public Class<?> getDataClass() - { - return dataclass; - } - - public Comparator<?> getComparator() - { - return comparator; - } - } Copied: branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java (from rev 5249, branches/cdomui/code/src/java/pcgen/gui/util/treeview/DataViewColumn.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java 2008-02-23 03:34:22 UTC (rev 5264) @@ -0,0 +1,59 @@ +/* + * DefaultDataViewColumn.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 22, 2008, 2:45:05 PM + */ +package pcgen.gui.util.treeview; + +import java.util.Comparator; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class DefaultDataViewColumn implements DataViewColumn +{ + + private String name; + private Class<?> dataclass; + private Comparator<?> comparator; + + public <T> DefaultDataViewColumn(String name, Class<T> dataclass, + Comparator<? super T> comparator) + { + this.name = name; + this.dataclass = dataclass; + this.comparator = comparator; + } + + public String getName() + { + return name; + } + + public Class<?> getDataClass() ... [truncated message content] |
From: <cpm...@us...> - 2008-02-24 07:37:00
|
Revision: 5274 http://pcgen.svn.sourceforge.net/pcgen/?rev=5274&view=rev Author: cpmeister Date: 2008-02-23 23:37:05 -0800 (Sat, 23 Feb 2008) Log Message: ----------- Table and TreeTable Sorting Completed Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 07:37:05 UTC (rev 5274) @@ -33,7 +33,36 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> - <Component class="javax.swing.JTable" name="jTable1"> + <Component class="pcgen.gui.util.JSortableTable" name="jSortableTable1"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="3"> + <Column editable="true" title="Title 1" type="java.lang.Object"> + <Data value="johny"/> + <Data value="ged"/> + <Data value="swr"/> + </Column> + <Column editable="true" title="Title 2" type="java.lang.Object"> + <Data value="nznz"/> + <Data value="drsd"/> + <Data value="fewws"/> + </Column> + <Column editable="true" title="Title 3" type="java.lang.Object"> + <Data value="adf"/> + <Data value="wer"/> + <Data value="vxz"/> + </Column> + <Column editable="true" title="Title 4" type="java.lang.Object"> + <Data value="wer"/> + <Data value="adfa"/> + <Data value="null"/> + </Column> + </Table> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new JSortableTableHeader(jSortableTable1)" type="code"/> + </Property> + </Properties> </Component> </SubComponents> </Container> Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -5,30 +5,7 @@ */ package pcgen.gui.proto.editor; -import java.awt.Component; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.Arrays; -import java.util.Comparator; -import java.util.EnumSet; -import java.util.List; -import javax.swing.ButtonModel; -import javax.swing.DefaultButtonModel; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JTable; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import pcgen.gui.util.JTreeViewTable; -import pcgen.gui.util.treeview.DataView; -import pcgen.gui.util.treeview.DefaultDataViewColumn; -import pcgen.gui.util.treeview.TreeView; -import pcgen.gui.util.treeview.TreeViewModel; -import pcgen.gui.util.treeview.TreeViewPath; -import pcgen.util.Comparators; +import pcgen.gui.proto.util.JSortableTableHeader; /** * @@ -50,11 +27,22 @@ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); - jTable1 = new javax.swing.JTable(); + jSortableTable1 = new pcgen.gui.util.JSortableTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - jScrollPane1.setViewportView(jTable1); + jSortableTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {"johny", "nznz", "adf", "wer"}, + {"ged", "drsd", "wer", "adfa"}, + {"swr", "fewws", "vxz", null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + jSortableTable1.setTableHeader(new JSortableTableHeader(jSortableTable1)); + jScrollPane1.setViewportView(jSortableTable1); getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); @@ -73,7 +61,7 @@ } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTable jTable1; + private pcgen.gui.util.JSortableTable jSortableTable1; // End of variables declaration//GEN-END:variables } Modified: branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -20,17 +20,25 @@ */ package pcgen.gui.proto.util; -import pcgen.gui.util.JTreeViewTable; import java.awt.Component; +import java.awt.Cursor; import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; +import java.util.List; +import javax.swing.ButtonModel; +import javax.swing.DefaultButtonModel; +import javax.swing.Icon; +import javax.swing.JButton; import javax.swing.table.TableColumn; -import pcgen.gui.util.SortingHeaderRenderer; import javax.swing.JTable; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumnModel; -import pcgen.gui.util.treeview.TreeViewTableModel; +import pcgen.gui.util.IconUtilities; +import pcgen.gui.util.JSortableTable; +import pcgen.gui.util.ModelSorter; +import pcgen.gui.util.ModelSorter.SortingPriority; /** * @@ -39,20 +47,26 @@ public class JSortableTableHeader extends JTableHeader { - private TreeViewTableModel tableModel; + private static final Icon ASCENDING_ICON = IconUtilities.getImageIcon("Down16.gif");//TODO: implement + private static final Icon DESCENDING_ICON = IconUtilities.getImageIcon("Up16.gif"); + private static final ButtonModel defaultModel = new DefaultButtonModel(); + private final ButtonModel usedModel = new DefaultButtonModel(); + private ModelSorter sorter; private TableColumn trackedColumn; - public JSortableTableHeader(JTreeViewTable table) + public JSortableTableHeader(JSortableTable table) { super(table.getColumnModel()); - addMouseMotionListener(new ColumnTracker()); - tableModel = table.getTreeViewTableModel(); + MouseTracker tracker = new MouseTracker(); + addMouseListener(tracker); + addMouseMotionListener(tracker); + sorter = table.getModelSorter(); } @Override - public TableCellRenderer createDefaultRenderer() + protected TableCellRenderer createDefaultRenderer() { - return new SortingHeaderRenderer(this); + return new SortingHeaderRenderer(); } public TableColumn getTrackedColumn() @@ -60,14 +74,24 @@ return trackedColumn; } - public TreeViewTableModel getTableModel() + public ModelSorter getModelSorter() { - return tableModel; + return sorter; } - private final class ColumnTracker implements MouseMotionListener + private final class MouseTracker implements MouseMotionListener, + MouseListener { + public void mouseClicked(MouseEvent e) + { + if (getCursor() == Cursor.getDefaultCursor()) + { + sorter.toggleSort(trackedColumn.getModelIndex()); + repaint(); + } + } + public void mouseDragged(MouseEvent e) { @@ -79,5 +103,77 @@ trackedColumn = model.getColumn(model.getColumnIndexAtX(e.getX())); } + public void mousePressed(MouseEvent e) + { + usedModel.setPressed(true); + usedModel.setArmed(true); + repaint(); + } + + public void mouseReleased(MouseEvent e) + { + usedModel.setPressed(false); + } + + public void mouseEntered(MouseEvent e) + { + usedModel.setRollover(true); + } + + public void mouseExited(MouseEvent e) + { + usedModel.setRollover(false); + } + } + + public class SortingHeaderRenderer extends JButton implements TableCellRenderer + { + + public SortingHeaderRenderer() + { + setHorizontalTextPosition(LEADING); + } + + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) + { + if (trackedColumn != null && trackedColumn.getHeaderValue() == value && + trackedColumn == getDraggedColumn()) + { + setModel(usedModel); + } + else + { + setModel(defaultModel); + } + Icon icon = null; + TableColumn currentColumn = table.getColumn(value); + List<? extends SortingPriority> list = sorter.getSortingPriority(); + if (!list.isEmpty()) + { + SortingPriority order = list.get(0); + if (order.getColumn() == currentColumn.getModelIndex()) + { + switch (order.getMode()) + { + case ASCENDING: + icon = ASCENDING_ICON; + break; + case DESCENDING: + icon = DESCENDING_ICON; + break; + } + } + } + setIcon(icon); + setText(value.toString()); + return this; + } + + } } Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/TreeViewHeaderRenderer.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -1,37 +0,0 @@ -/* - * TreeViewHeaderRenderer.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 22, 2008, 12:48:10 AM - */ -package pcgen.gui.proto.util; - -import pcgen.gui.util.SortingHeaderRenderer; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class TreeViewHeaderRenderer extends SortingHeaderRenderer -{ - - public TreeViewHeaderRenderer(JSortableTableHeader header) - { - super(header); - } - -} Modified: branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -36,24 +36,26 @@ public JSortableTable() { - super(); + this(null); } public JSortableTable(TableModel model) { super(model); + setModelSorter(new ModelSorter()); } @Override public void setModel(TableModel model) { - if (model instanceof SortableTableModel) + if (!(model instanceof SortableTableModel)) { - super.setModel(model); + model = new DefaultSortableTableModel(model); } - else + super.setModel(model); + if (sorter != null) { - super.setModel(new DefaultSortableTableModel(model)); + sorter.setModel(getModel()); } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -23,11 +23,12 @@ import java.util.Comparator; import java.util.List; import javax.swing.JTree; +import javax.swing.table.TableModel; +import pcgen.gui.util.table.DefaultSortableTableModel; import pcgen.gui.util.table.SortableTableModel; import pcgen.gui.util.treetable.DefaultSortableTreeTableModel; import pcgen.gui.util.treetable.SortableTreeTableModel; import pcgen.gui.util.treetable.TreeTableModel; -import pcgen.util.Comparators; /** * @@ -46,6 +47,7 @@ public JSortableTreeTable(SortableTreeTableModel model) { super(model); + setModelSorter(new ModelSorter()); } @Override @@ -56,21 +58,44 @@ tree); } + @Override + public void setModel(TableModel model) + { + if (!(model instanceof SortableTableModel)) + { + model = new DefaultSortableTableModel(model); + } + super.setModel(model); + if (sorter != null) + { + sorter.setModel(getModel()); + } + } + public ModelSorter getModelSorter() { return sorter; } @Override + @SuppressWarnings("unchecked") + public SortableTableModel getModel() + { + return (SortableTableModel) super.getModel(); + } + + @Override public void setTreeTableModel(TreeTableModel model) { - if (model instanceof SortableTreeTableModel) + if (!(model instanceof SortableTreeTableModel)) { - super.setTreeTableModel(model); + model = new DefaultSortableTreeTableModel(model); } - else + + super.setTreeTableModel(model); + if (sorter != null) { - super.setTreeTableModel(new DefaultSortableTreeTableModel(model)); + sorter.setModel(getModel()); } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/util/ModelSorter.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -21,6 +21,7 @@ package pcgen.gui.util; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -38,7 +39,7 @@ private final EventListenerList listenerList = new EventListenerList(); private final RowComparator rowComparator = new RowComparator(); - private List<? extends SortingPriority> columnkeys = null; + private List<? extends SortingPriority> columnkeys = Collections.emptyList(); private SortableModel model; public void addTableSorterListener(ModelSorterListener listener) @@ -77,14 +78,20 @@ switch (index) { case 0: - list.set(0, new SortingPriority(column, SortMode.DESCENDING)); - break; + if (list.get(0).getMode() == SortMode.ASCENDING) + { + list.set(0, new SortingPriority(column, SortMode.DESCENDING)); + break; + } default: list.remove(index); case -1: list.add(0, new SortingPriority(column, SortMode.ASCENDING)); } - list.setSize(2); + if (list.size() > 2) + { + list.setSize(2); + } setSortingPriority(list); } @@ -124,7 +131,6 @@ { for (SortingPriority priority : columnkeys) { - if (priority.getMode() == SortMode.UNORDERED) { continue; Deleted: branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/util/SortingHeaderRenderer.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -1,145 +0,0 @@ -/* - * SortingHeaderRenderer.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 18, 2008, 2:09:04 PM - */ -package pcgen.gui.util; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.Collections; -import java.util.Comparator; -import java.util.Map; -import javax.swing.ButtonModel; -import javax.swing.DefaultButtonModel; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.JTable; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumn; -import javax.swing.table.TableColumnModel; -import pcgen.gui.proto.util.JSortableTableHeader; -import pcgen.gui.util.treeview.DefaultDataViewColumn; -import pcgen.gui.util.treeview.TreeViewTableModel; -import pcgen.util.Comparators; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class SortingHeaderRenderer extends JButton implements TableCellRenderer, - SortingConstants -{ - - private static final ButtonModel defaultModel = new DefaultButtonModel(); - private final ButtonModel usedModel = new DefaultButtonModel(); - private final JSortableTableHeader header; - private Map<TableColumn, Icon> iconMap = Collections.emptyMap(); - - public SortingHeaderRenderer(final JSortableTableHeader header) - { - - this.header = header; - header.addMouseListener( - new MouseListener() - { - - public void mouseClicked(MouseEvent e) - { - TableColumn trackedColumn = header.getTrackedColumn(); - if (trackedColumn.getHeaderValue() != null) - { - doClick(); - } - } - - public void mousePressed(MouseEvent e) - { - usedModel.setPressed(true); - header.repaint(); - } - - public void mouseReleased(MouseEvent e) - { - usedModel.setPressed(false); - } - - public void mouseEntered(MouseEvent e) - { - usedModel.setRollover(true); - } - - public void mouseExited(MouseEvent e) - { - usedModel.setRollover(false); - } - - }); - addActionListener( - new ActionListener() - { - - public void actionPerformed(ActionEvent e) - { - TreeViewTableModel model = header.getTableModel(); - TableColumn trackedColumn = header.getTrackedColumn(); - Icon icon = null; - if (iconMap.containsKey(trackedColumn)) - { - icon = DESCENDING_ICON; - } - else - { - icon = ASCENDING_ICON; - } - iconMap = Collections.singletonMap(trackedColumn, - icon); - //model.sortColumn(trackedColumn.getModelIndex()); - } - - }); -// this.setRolloverEnabled(true); - setHorizontalTextPosition(LEADING); - } - - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, - boolean hasFocus, int row, - int column) - { - TableColumn trackedColumn = header.getTrackedColumn(); - if (trackedColumn != null && trackedColumn.getHeaderValue() == value && - trackedColumn == header.getDraggedColumn()) - { - setModel(usedModel); - } - else - { - setModel(defaultModel); - } - setIcon(iconMap.get(trackedColumn)); - setText(value.toString()); - return this; - } - -} Modified: branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultSortableTableModel.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -147,12 +147,19 @@ setValueAt(model.getValueAt(x, y), x, y); } } + Vector titles = new Vector(); + for(int x = 0; x < getColumnCount(); x++) + { + titles.add(model.getColumnName(x)); + } + setColumnIdentifiers(titles); } @SuppressWarnings("unchecked") public void sortModel(Comparator<List<?>> comparator) { Collections.sort(dataVector, comparator); + fireTableDataChanged(); } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultSortableTreeTableNode.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -176,8 +176,11 @@ if (!child.isLeaf()) { child.sortChildren(comparator); - Collections.swap(children, index, x); - Collections.swap(childData, index, x); + if (index != x) + { + Collections.swap(children, index, x); + Collections.swap(childData, index, x); + } index++; } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-24 06:25:24 UTC (rev 5273) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-24 07:37:05 UTC (rev 5274) @@ -30,7 +30,6 @@ import pcgen.gui.util.treetable.DefaultSortableTreeTableNode; import pcgen.gui.util.treetable.SortableTreeTableModel; import pcgen.gui.util.treetable.TreeTableNode; -import pcgen.util.Comparators; import pcgen.util.UnboundedArrayList; /** @@ -198,7 +197,7 @@ ArrayList<Object> datalist = new UnboundedArrayList<Object>(1); datalist.add(key); List<?> data = dataMap.get(key); - if (key != null) + if (data != null) { datalist.add(data); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-02-24 09:15:29
|
Revision: 5277 http://pcgen.svn.sourceforge.net/pcgen/?rev=5277&view=rev Author: cpmeister Date: 2008-02-24 01:15:34 -0800 (Sun, 24 Feb 2008) Log Message: ----------- eliminated parallel class hierarchy Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 09:15:34 UTC (rev 5277) @@ -16,7 +16,7 @@ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,73,0,0,1,-112"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-44,0,0,1,104"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> @@ -33,36 +33,7 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> - <Component class="pcgen.gui.util.JSortableTable" name="jSortableTable1"> - <Properties> - <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> - <Table columnCount="4" rowCount="3"> - <Column editable="true" title="Title 1" type="java.lang.Object"> - <Data value="johny"/> - <Data value="ged"/> - <Data value="swr"/> - </Column> - <Column editable="true" title="Title 2" type="java.lang.Object"> - <Data value="nznz"/> - <Data value="drsd"/> - <Data value="fewws"/> - </Column> - <Column editable="true" title="Title 3" type="java.lang.Object"> - <Data value="adf"/> - <Data value="wer"/> - <Data value="vxz"/> - </Column> - <Column editable="true" title="Title 4" type="java.lang.Object"> - <Data value="wer"/> - <Data value="adfa"/> - <Data value="null"/> - </Column> - </Table> - </Property> - <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> - <Connection code="new JSortableTableHeader(jSortableTable1)" type="code"/> - </Property> - </Properties> + <Component class="pcgen.gui.util.JTreeTable" name="jTreeTable1"> </Component> </SubComponents> </Container> Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -5,7 +5,8 @@ */ package pcgen.gui.proto.editor; -import pcgen.gui.proto.util.JSortableTableHeader; +import pcgen.gui.util.JTableSortingHeader; +import pcgen.gui.util.JTreeTable; /** * @@ -27,22 +28,11 @@ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); - jSortableTable1 = new pcgen.gui.util.JSortableTable(); + jTreeTable1 = new pcgen.gui.util.JTreeTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - jSortableTable1.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - {"johny", "nznz", "adf", "wer"}, - {"ged", "drsd", "wer", "adfa"}, - {"swr", "fewws", "vxz", null} - }, - new String [] { - "Title 1", "Title 2", "Title 3", "Title 4" - } - )); - jSortableTable1.setTableHeader(new JSortableTableHeader(jSortableTable1)); - jScrollPane1.setViewportView(jSortableTable1); + jScrollPane1.setViewportView(jTreeTable1); getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); @@ -61,7 +51,7 @@ } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; - private pcgen.gui.util.JSortableTable jSortableTable1; + private pcgen.gui.util.JTreeTable jTreeTable1; // End of variables declaration//GEN-END:variables } Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/proto/util/JSortableTableHeader.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -1,179 +0,0 @@ -/* - * JSortableTableHeader.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 16, 2008, 8:27:21 PM - */ -package pcgen.gui.proto.util; - -import java.awt.Component; -import java.awt.Cursor; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.List; -import javax.swing.ButtonModel; -import javax.swing.DefaultButtonModel; -import javax.swing.Icon; -import javax.swing.JButton; -import javax.swing.table.TableColumn; -import javax.swing.JTable; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableColumnModel; -import pcgen.gui.util.IconUtilities; -import pcgen.gui.util.JSortableTable; -import pcgen.gui.util.ModelSorter; -import pcgen.gui.util.ModelSorter.SortingPriority; - -/** - * - * @author Connor Petty<mis...@gm...> - */ -public class JSortableTableHeader extends JTableHeader -{ - - private static final Icon ASCENDING_ICON = IconUtilities.getImageIcon("Down16.gif");//TODO: implement - private static final Icon DESCENDING_ICON = IconUtilities.getImageIcon("Up16.gif"); - private static final ButtonModel defaultModel = new DefaultButtonModel(); - private final ButtonModel usedModel = new DefaultButtonModel(); - private ModelSorter sorter; - private TableColumn trackedColumn; - - public JSortableTableHeader(JSortableTable table) - { - super(table.getColumnModel()); - MouseTracker tracker = new MouseTracker(); - addMouseListener(tracker); - addMouseMotionListener(tracker); - sorter = table.getModelSorter(); - } - - @Override - protected TableCellRenderer createDefaultRenderer() - { - return new SortingHeaderRenderer(); - } - - public TableColumn getTrackedColumn() - { - return trackedColumn; - } - - public ModelSorter getModelSorter() - { - return sorter; - } - - private final class MouseTracker implements MouseMotionListener, - MouseListener - { - - public void mouseClicked(MouseEvent e) - { - if (getCursor() == Cursor.getDefaultCursor()) - { - sorter.toggleSort(trackedColumn.getModelIndex()); - repaint(); - } - } - - public void mouseDragged(MouseEvent e) - { - - } - - public void mouseMoved(MouseEvent e) - { - TableColumnModel model = getColumnModel(); - trackedColumn = model.getColumn(model.getColumnIndexAtX(e.getX())); - } - - public void mousePressed(MouseEvent e) - { - usedModel.setPressed(true); - usedModel.setArmed(true); - repaint(); - } - - public void mouseReleased(MouseEvent e) - { - usedModel.setPressed(false); - } - - public void mouseEntered(MouseEvent e) - { - usedModel.setRollover(true); - } - - public void mouseExited(MouseEvent e) - { - usedModel.setRollover(false); - } - - } - - public class SortingHeaderRenderer extends JButton implements TableCellRenderer - { - - public SortingHeaderRenderer() - { - setHorizontalTextPosition(LEADING); - } - - public Component getTableCellRendererComponent(JTable table, - Object value, - boolean isSelected, - boolean hasFocus, - int row, - int column) - { - if (trackedColumn != null && trackedColumn.getHeaderValue() == value && - trackedColumn == getDraggedColumn()) - { - setModel(usedModel); - } - else - { - setModel(defaultModel); - } - Icon icon = null; - TableColumn currentColumn = table.getColumn(value); - List<? extends SortingPriority> list = sorter.getSortingPriority(); - if (!list.isEmpty()) - { - SortingPriority order = list.get(0); - if (order.getColumn() == currentColumn.getModelIndex()) - { - switch (order.getMode()) - { - case ASCENDING: - icon = ASCENDING_ICON; - break; - case DESCENDING: - icon = DESCENDING_ICON; - break; - } - } - } - setIcon(icon); - setText(value.toString()); - return this; - } - - } -} Deleted: branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/JSortableTable.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -1,89 +0,0 @@ -/* - * JSortableTable.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 22, 2008, 3:42:02 PM - */ -package pcgen.gui.util; - -import javax.swing.JTable; -import javax.swing.table.TableModel; -import pcgen.gui.util.table.DefaultSortableTableModel; -import pcgen.gui.util.table.SortableTableModel; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class JSortableTable extends JTable -{ - - private ModelSorter sorter; - - public JSortableTable() - { - this(null); - } - - public JSortableTable(TableModel model) - { - super(model); - setModelSorter(new ModelSorter()); - } - - @Override - public void setModel(TableModel model) - { - if (!(model instanceof SortableTableModel)) - { - model = new DefaultSortableTableModel(model); - } - super.setModel(model); - if (sorter != null) - { - sorter.setModel(getModel()); - } - } - - @Override - @SuppressWarnings("unchecked") - public SortableTableModel getModel() - { - return (SortableTableModel) super.getModel(); - } - - public ModelSorter getModelSorter() - { - return sorter; - } - - public void setModelSorter(ModelSorter sorter) - { - ModelSorter old = this.sorter; - if (old != null) - { - old.setModel(null); - } - if (sorter != null) - { - sorter.setModel(getModel()); - } - this.sorter = sorter; - //TODO: do something with old - } - -} Deleted: branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/JSortableTreeTable.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -1,135 +0,0 @@ -/* - * JSortableTreeTable.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 22, 2008, 4:10:15 PM - */ -package pcgen.gui.util; - -import java.util.Comparator; -import java.util.List; -import javax.swing.JTree; -import javax.swing.table.TableModel; -import pcgen.gui.util.table.DefaultSortableTableModel; -import pcgen.gui.util.table.SortableTableModel; -import pcgen.gui.util.treetable.DefaultSortableTreeTableModel; -import pcgen.gui.util.treetable.SortableTreeTableModel; -import pcgen.gui.util.treetable.TreeTableModel; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class JSortableTreeTable extends JTreeTable -{ - - private ModelSorter sorter; - - public JSortableTreeTable() - { - this(null); - } - - public JSortableTreeTable(SortableTreeTableModel model) - { - super(model); - setModelSorter(new ModelSorter()); - } - - @Override - protected TreeTableModelAdapter createDefaultTreeTableModelAdapter(TreeTableModel treeTableModel, - JTree tree) - { - return new SortableTreeTableModelAdapter((SortableTreeTableModel) treeTableModel, - tree); - } - - @Override - public void setModel(TableModel model) - { - if (!(model instanceof SortableTableModel)) - { - model = new DefaultSortableTableModel(model); - } - super.setModel(model); - if (sorter != null) - { - sorter.setModel(getModel()); - } - } - - public ModelSorter getModelSorter() - { - return sorter; - } - - @Override - @SuppressWarnings("unchecked") - public SortableTableModel getModel() - { - return (SortableTableModel) super.getModel(); - } - - @Override - public void setTreeTableModel(TreeTableModel model) - { - if (!(model instanceof SortableTreeTableModel)) - { - model = new DefaultSortableTreeTableModel(model); - } - - super.setTreeTableModel(model); - if (sorter != null) - { - sorter.setModel(getModel()); - } - } - - public void setModelSorter(ModelSorter sorter) - { - ModelSorter old = this.sorter; - if (old != null) - { - old.setModel(null); - } - if (sorter != null) - { - sorter.setModel((SortableTreeTableModelAdapter) getModel()); - } - this.sorter = sorter; - //TODO: do something with old - } - - private static final class SortableTreeTableModelAdapter extends TreeTableModelAdapter - implements SortableTableModel - { - - SortableTreeTableModelAdapter(SortableTreeTableModel model, JTree tree) - { - super(model, tree); - } - - public void sortModel(Comparator<List<?>> comparator) - { - if (treeTableModel != null) - { - ((SortableTreeTableModel) treeTableModel).sortModel(comparator); - } - } - - } -} Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -20,16 +20,16 @@ */ package pcgen.gui.util; -import pcgen.core.Constants; -import pcgen.util.Logging; - import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; -import javax.swing.table.*; import java.awt.Component; -import java.awt.Dimension; import java.math.BigDecimal; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import pcgen.gui.util.table.DefaultSortableTableModel; +import pcgen.gui.util.table.SortableTableModel; /** * <code>JTableEx</code> extends JTable to provide auto-tooltips. @@ -39,376 +39,146 @@ */ public class JTableEx extends JTable { - static final long serialVersionUID = 514835142307946415L; - /** - * Constructor - */ - public JTableEx() - { - this(null, null, null); - } + private static final long serialVersionUID = 514835142307946415L; + protected ModelSorter sorter; - /** - * Constructor - * @param tm - */ - public JTableEx(TableModel tm) - { - this(tm, null, null); - } + /** + * Constructor + */ + public JTableEx() + { + this(null, null, null); + } - /** - * Constructor - * @param tm - * @param tcm - */ - public JTableEx(TableModel tm, TableColumnModel tcm) - { - this(tm, tcm, null); - } + /** + * Constructor + * @param tm + */ + public JTableEx(TableModel tm) + { + this(tm, null, null); + } - private JTableEx(TableModel tm, TableColumnModel tcm, ListSelectionModel lsm) - { - super(tm, tcm, lsm); + /** + * Constructor + * @param tm + * @param tcm + */ + public JTableEx(TableModel tm, TableColumnModel tcm) + { + this(tm, tcm, null); + } - setDefaultRenderer(BigDecimal.class, new AlignCellRenderer( - SwingConstants.RIGHT)); - setDefaultRenderer(Float.class, new AlignCellRenderer( - SwingConstants.RIGHT)); - setDefaultRenderer(Integer.class, new AlignCellRenderer( - SwingConstants.RIGHT)); - } + private JTableEx(TableModel tm, TableColumnModel tcm, + ListSelectionModel lsm) + { + super(tm, tcm, lsm); - /** - * Calculate 'optimal' width (for example, minimum to show full text) - * for the columns in the columns list - * - * @param columns - **/ - public final void setOptimalColumnWidths(int[] columns) - { - final JTableHeader header = getTableHeader(); - final TableCellRenderer defaultHeaderRenderer = - ((header != null) ? header.getDefaultRenderer() : null); - final TableColumnModel aColumnModel = getColumnModel(); + setDefaultRenderer(BigDecimal.class, new AlignCellRenderer( + SwingConstants.RIGHT)); + setDefaultRenderer(Float.class, new AlignCellRenderer( + SwingConstants.RIGHT)); + setDefaultRenderer(Integer.class, new AlignCellRenderer( + SwingConstants.RIGHT)); + setModelSorter(new ModelSorter()); + setTableHeader(new JTableSortingHeader(this)); + } - if (aColumnModel == null) - { - return; - } + @Override + public void setModel(TableModel model) + { + if (!(model instanceof SortableTableModel)) + { + model = new DefaultSortableTableModel(model); + } + super.setModel(model); + if (sorter != null) + { + sorter.setModel(getModel()); + } + } - final int columncount = aColumnModel.getColumnCount(); + @Override + @SuppressWarnings("unchecked") + public SortableTableModel getModel() + { + return (SortableTableModel) super.getModel(); + } - if ((columns.length <= 0) || (columncount < columns.length) - || (columncount < columns[columns.length - 1])) - { - Logging - .errorPrint("Bad parameters passed to setOptimalColumnWidth."); + public ModelSorter getModelSorter() + { + return sorter; + } - return; - } + public void setModelSorter(ModelSorter sorter) + { + ModelSorter old = this.sorter; + if (old != null) + { + old.setModel(null); + } + if (sorter != null) + { + sorter.setModel(getModel()); + } + this.sorter = sorter; + //TODO: do something with old + } - final TableModel data = getModel(); + /** + * set horizontal alignment of column + * and attach a new cell renderer + * @param col + * @param alignment + **/ + public void setColAlign(int col, int alignment) + { + getColumnModel().getColumn(col).setCellRenderer( + new AlignCellRenderer(alignment)); + } - final int rowCount = data.getRowCount(); - int totalWidth = 0; + /** + * Align the cell text in a column + **/ + public static final class AlignCellRenderer extends DefaultTableCellRenderer + { - for (int i = 0; i < columns.length; i++) - { - try - { - final TableColumn column = aColumnModel.getColumn(columns[i]); + /** + * align is one of: + * SwingConstants.LEFT + * SwingConstants.CENTER + * SwingConstants.RIGHT + **/ + private int align = SwingConstants.LEFT; - if (column == null) - { - continue; - } + /** + * Align the cell renderer + * @param anInt + */ + public AlignCellRenderer(int anInt) + { + super(); + align = anInt; + setHorizontalAlignment(align); + } - final int columnIndex = column.getModelIndex(); - int width = -1; + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) + { + super.getTableCellRendererComponent(table, value, isSelected, + hasFocus, row, column); + setEnabled((table == null) || table.isEnabled()); - // - // Get the width of the header cell - // - TableCellRenderer h = column.getHeaderRenderer(); + setHorizontalAlignment(align); - if (h == null) - { - h = defaultHeaderRenderer; - } + return this; + } - if (h != null) // Not explicitly impossible - { - final Object value = column.getHeaderValue(); - - if (value != null) - { - final Component c = - h.getTableCellRendererComponent(this, value, - false, false, -1, i); - - if (c != null) - { - width = c.getPreferredSize().width; - } - } - } - - // - // Cycle through entire column to get the largest cell - // - TableCellRenderer r = column.getCellRenderer(); - - if (r == null) - { - r = - this.getDefaultRenderer(data - .getColumnClass(columnIndex)); - } - - if (r != null) - { - for (int row = rowCount - 1; row >= 0; --row) - { - final Object value = data.getValueAt(row, columnIndex); - - if (value != null) - { - final Component c = - r.getTableCellRendererComponent(this, - value, false, false, row, columnIndex); - - if (c != null) - { - width = - Math.max(width, - c.getPreferredSize().width); - } - } - } - } - - if (width >= 0) - { - column.setPreferredWidth(width + 5); //It seems to get it just a bit too small. - } - - totalWidth += column.getPreferredWidth(); - } - catch (Exception e) - { - Logging.errorPrint("Exception JTableEx.setOptimalColumnWidths:" - + i + ":" + columns.length + ":" + columncount - + Constants.s_LINE_SEP + "Exception type:" - + e.getClass().getName() + Constants.s_LINE_SEP - + "Message:" + e.getMessage()); - } - } - - totalWidth += (columncount * aColumnModel.getColumnMargin()); - - final Dimension size = getPreferredScrollableViewportSize(); - size.width = totalWidth; - - setPreferredScrollableViewportSize(size); - sizeColumnsToFit(-1); - - if (header != null) - { - header.repaint(); - } - } - -// public final String getToolTipText(MouseEvent event) -// { -// if (SettingsHandler.isToolTipTextShown()) -// { -// final int row = rowAtPoint(event.getPoint()); -// final int col = columnAtPoint(event.getPoint()); -// -// //Did we get the event from something that was *over* the table (e.g. a listbox's menu)? -// if ((row < 0) || (col < 0)) -// { -// return null; -// } -// -// final Object o = getValueAt(row, col); -// -// if ((o == null) || "".equals(o.toString())) -// { -// return null; -// } -// return wrap(o.toString()); -// } -// return null; -// } - - /** - * set horizontal alignment of column - * and attach a new cell renderer - * @param col - * @param alignment - **/ - public void setColAlign(int col, int alignment) - { - getColumnModel().getColumn(col).setCellRenderer( - new AlignCellRenderer(alignment)); - } - - /* - * fixes a bug which caused the - * JTableHeaderUI not to be updated - * correctly on initialization - * - * author: Thomas Behr 13-03-02 - */ - public void updateUI() - { - super.updateUI(); - getTableHeader().updateUI(); - } - - /** - * If text is longer than 20 chars, show t - * @param argText - * @return String - **/ - private static String wrap(String argText) - { - String text = argText.substring(argText.lastIndexOf("|") + 1); - int textLength = text.length(); - StringBuffer wrapped = new StringBuffer(textLength); - final int length = 70; - - while (textLength > length) - { - // XXX correct the line below for Linux - if (text.indexOf('\\') >= 0) - { - break; - } - - int pos; - int lastBreak = -1; - boolean bInHtmlTag = false; - int displayedCount = 0; - - for (pos = 0; pos < textLength; pos++) - { - if (displayedCount >= length) - { - break; - } - - switch (text.charAt(pos)) - { - case ' ': - - if (!bInHtmlTag) - { - lastBreak = pos; - displayedCount += 1; - } - - break; - - case '<': - bInHtmlTag = true; - - break; - - case '>': - bInHtmlTag = false; - - break; - - default: - - if (!bInHtmlTag) - { - displayedCount += 1; - } - - break; - } - } - - if (displayedCount < length) - { - lastBreak = textLength; - } - - if (lastBreak == -1) - { - lastBreak = length; - } - - if (wrapped.length() != 0) - { - wrapped.append("<br>"); - } - - wrapped.append(text.substring(0, lastBreak)); - text = text.substring(lastBreak).trim(); - textLength = text.length(); - } - - if (text.length() != 0) - { - if (wrapped.length() != 0) - { - wrapped.append("<br>"); - } - - wrapped.append(text); - } - - if (!wrapped.toString().startsWith("<html>")) - { - wrapped.insert(0, "<html>"); - wrapped.append("</html>"); - } - - return wrapped.toString(); - } - - /** - * Align the cell text in a column - **/ - public static final class AlignCellRenderer extends - DefaultTableCellRenderer - { - /** - * align is one of: - * SwingConstants.LEFT - * SwingConstants.CENTER - * SwingConstants.RIGHT - **/ - private int align = SwingConstants.LEFT; - - /** - * Align the cell renderer - * @param anInt - */ - public AlignCellRenderer(int anInt) - { - super(); - align = anInt; - setHorizontalAlignment(align); - } - - public Component getTableCellRendererComponent(JTable table, - Object value, boolean isSelected, boolean hasFocus, int row, - int column) - { - super.getTableCellRendererComponent(table, value, isSelected, - hasFocus, row, column); - setEnabled((table == null) || table.isEnabled()); - - setHorizontalAlignment(align); - - return this; - } - } + } } Added: branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -0,0 +1,175 @@ +/* + * JTableSortingHeader.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 16, 2008, 8:27:21 PM + */ +package pcgen.gui.util; + +import java.awt.Component; +import java.awt.Cursor; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.util.List; +import javax.swing.ButtonModel; +import javax.swing.DefaultButtonModel; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.table.TableColumn; +import javax.swing.JTable; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumnModel; +import pcgen.gui.util.ModelSorter.SortingPriority; + +/** + * + * @author Connor Petty<mis...@gm...> + */ +public class JTableSortingHeader extends JTableHeader +{ + + private static final Icon ASCENDING_ICON = IconUtilities.getImageIcon("Down16.gif");//TODO: implement + private static final Icon DESCENDING_ICON = IconUtilities.getImageIcon("Up16.gif"); + private static final ButtonModel defaultModel = new DefaultButtonModel(); + private final ButtonModel usedModel = new DefaultButtonModel(); + private ModelSorter sorter; + private TableColumn trackedColumn; + + public JTableSortingHeader(JTableEx table) + { + super(table.getColumnModel()); + MouseTracker tracker = new MouseTracker(); + addMouseListener(tracker); + addMouseMotionListener(tracker); + sorter = table.getModelSorter(); + } + + @Override + protected TableCellRenderer createDefaultRenderer() + { + return new SortingHeaderRenderer(); + } + + public TableColumn getTrackedColumn() + { + return trackedColumn; + } + + public ModelSorter getModelSorter() + { + return sorter; + } + + private final class MouseTracker implements MouseMotionListener, + MouseListener + { + + public void mouseClicked(MouseEvent e) + { + if (getCursor() == Cursor.getDefaultCursor()) + { + sorter.toggleSort(trackedColumn.getModelIndex()); + repaint(); + } + } + + public void mouseDragged(MouseEvent e) + { + + } + + public void mouseMoved(MouseEvent e) + { + TableColumnModel model = getColumnModel(); + trackedColumn = model.getColumn(model.getColumnIndexAtX(e.getX())); + } + + public void mousePressed(MouseEvent e) + { + usedModel.setPressed(true); + repaint(); + } + + public void mouseReleased(MouseEvent e) + { + usedModel.setPressed(false); + } + + public void mouseEntered(MouseEvent e) + { + usedModel.setRollover(true); + } + + public void mouseExited(MouseEvent e) + { + usedModel.setRollover(false); + } + + } + + public class SortingHeaderRenderer extends JButton implements TableCellRenderer + { + + public SortingHeaderRenderer() + { + setHorizontalTextPosition(LEADING); + } + + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, + int column) + { + if (trackedColumn != null && trackedColumn.getHeaderValue() == value && + trackedColumn == getDraggedColumn()) + { + setModel(usedModel); + } + else + { + setModel(defaultModel); + } + Icon icon = null; + TableColumn currentColumn = table.getColumn(value); + List<? extends SortingPriority> list = sorter.getSortingPriority(); + if (!list.isEmpty()) + { + SortingPriority order = list.get(0); + if (order.getColumn() == currentColumn.getModelIndex()) + { + switch (order.getMode()) + { + case ASCENDING: + icon = ASCENDING_ICON; + break; + case DESCENDING: + icon = DESCENDING_ICON; + break; + } + } + } + setIcon(icon); + setText(value.toString()); + return this; + } + + } +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -18,6 +18,8 @@ **/ package pcgen.gui.util; +import java.util.Comparator; +import java.util.List; import pcgen.gui.util.treetable.TreeTableModel; import java.awt.Component; import java.awt.Container; @@ -52,7 +54,10 @@ import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; +import pcgen.gui.util.table.SortableTableModel; +import pcgen.gui.util.treetable.DefaultSortableTreeTableModel; import pcgen.gui.util.treetable.DefaultTreeTableModel; +import pcgen.gui.util.treetable.SortableTreeTableModel; import pcgen.gui.util.treetable.TreeTableNode; /** @@ -65,10 +70,10 @@ * @author Philip Milne * @author Scott Violet **/ -public class JTreeTable extends JTable +public class JTreeTable extends JTableEx { - static final long serialVersionUID = -3571248405124682593L; + private static final long serialVersionUID = -3571248405124682593L; /** A subclass of JTree. */ private TreeTableCellRenderer tree; private TreeTableModelAdapter adapter; @@ -102,14 +107,10 @@ UIManager.put("Tree.leftChildIndent", Integer.valueOf(3)); //$NON-NLS-1$ UIManager.put("Tree.rightChildIndent", Integer.valueOf(8)); //$NON-NLS-1$ - // Create the tree. It will be used as a renderer and editor. - tree = new TreeTableCellRenderer(treeTableModel); - tree.setRootVisible(false); - adapter = createDefaultTreeTableModelAdapter(treeTableModel, tree); - // Install a tableModel representing the visible rows in tree. - + tree = new TreeTableCellRenderer(); + adapter = new TreeTableModelAdapter(tree); + setTreeTableModel(treeTableModel); super.setModel(adapter); - // Force the JTable and JTree to share row selection models. ListToTreeSelectionModelWrapper selectionWrapper = new ListToTreeSelectionModelWrapper(); @@ -140,12 +141,6 @@ } } - protected TreeTableModelAdapter createDefaultTreeTableModelAdapter(TreeTableModel treeTableModel, - JTree tree) - { - return new TreeTableModelAdapter(treeTableModel, tree); - } - @SuppressWarnings("unchecked") public TreeTableModel getTreeTableModel() { @@ -154,24 +149,12 @@ public void setTreeTableModel(TreeTableModel model) { - tree.setModel(model); - adapter.setTreeTableModel(model); - } - - @Override - public void setModel(TableModel model) - { - if (model instanceof TreeTableModelAdapter) + if (model != null && !(model instanceof SortableTreeTableModel)) { - adapter.setTreeTableModel(null); - adapter = (TreeTableModelAdapter) model; - adapter.setTreeTableModel((TreeTableModel)tree.getModel()); - super.setModel(model); + model = new DefaultSortableTreeTableModel(model); } - else - { - setTreeTableModel(new DefaultTreeTableModel(model)); - } + tree.setModel(model); + adapter.setTreeTableModel((SortableTreeTableModel) model); } /** @@ -309,10 +292,11 @@ * @author Scott Violet */ protected static class TreeTableModelAdapter extends AbstractTableModel + implements SortableTableModel { private JTree tree; - protected TreeTableModel treeTableModel; + private SortableTreeTableModel treeTableModel; private TreeModelListener modelListener; /** @@ -320,11 +304,9 @@ * @param treeTableModel * @param tree */ - TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree) + TreeTableModelAdapter(JTree tree) { this.tree = tree; - this.treeTableModel = treeTableModel; - tree.addTreeExpansionListener(new TreeExpansionListener() { // Don't use fireTableRowsInserted() here; @@ -377,7 +359,7 @@ } } - public void setTreeTableModel(TreeTableModel model) + public void setTreeTableModel(SortableTreeTableModel model) { if (treeTableModel != null) { @@ -464,6 +446,11 @@ return null; } + public void sortModel(Comparator<List<?>> comparator) + { + treeTableModel.sortModel(comparator); + } + } /** @@ -475,11 +462,6 @@ // Last table/tree row asked to render private int visibleRow; - TreeTableCellRenderer(TreeModel model) - { - super(model); - } - /** * This is overridden to set the height * to match that of the JTable. Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -28,7 +28,7 @@ * * @author Connor Petty <mis...@gm...> */ -public class JTreeViewTable extends JSortableTreeTable +public class JTreeViewTable extends JTreeTable { public <T> JTreeViewTable(TreeViewModel<T> model, Collection<T> collection) Deleted: branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/SortingConstants.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -1,34 +0,0 @@ -/* - * SortingConstants.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 18, 2008, 5:19:25 PM - */ - -package pcgen.gui.util; - -import javax.swing.Icon; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public interface SortingConstants -{ -public static final Icon ASCENDING_ICON = IconUtilities.getImageIcon("Down16.gif");//TODO: implement -public static final Icon DESCENDING_ICON = IconUtilities.getImageIcon("Up16.gif");//TODO: implement -} Modified: branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableModel.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -40,12 +40,12 @@ { super(); } - + protected DefaultTreeTableModel(TreeTableNode root) { super(root); } - + public DefaultTreeTableModel(TableModel tableModel) { super(null); Modified: branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java 2008-02-24 08:11:49 UTC (rev 5276) +++ branches/cdomui/code/src/java/pcgen/gui/util/treetable/DefaultTreeTableNode.java 2008-02-24 09:15:34 UTC (rev 5277) @@ -76,7 +76,7 @@ private void setValues(List<Object> values) { - this.data = new UnboundedArrayList<Object>(data); + this.data = new UnboundedArrayList<Object>(values); } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-02-24 21:02:51
|
Revision: 5322 http://pcgen.svn.sourceforge.net/pcgen/?rev=5322&view=rev Author: cpmeister Date: 2008-02-24 13:02:56 -0800 (Sun, 24 Feb 2008) Log Message: ----------- JTreeViewTable completed Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 20:08:15 UTC (rev 5321) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 21:02:56 UTC (rev 5322) @@ -33,7 +33,7 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> - <Component class="pcgen.gui.util.JTreeTable" name="jTreeTable1"> + <Component class="pcgen.gui.util.JTreeViewTable" name="jTreeViewTable1"> </Component> </SubComponents> </Container> Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 20:08:15 UTC (rev 5321) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 21:02:56 UTC (rev 5322) @@ -5,9 +5,6 @@ */ package pcgen.gui.proto.editor; -import pcgen.gui.util.JTableSortingHeader; -import pcgen.gui.util.JTreeTable; - /** * * @author Connor Petty <mis...@gm...> @@ -28,11 +25,11 @@ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); - jTreeTable1 = new pcgen.gui.util.JTreeTable(); + jTreeViewTable1 = new pcgen.gui.util.JTreeViewTable(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - jScrollPane1.setViewportView(jTreeTable1); + jScrollPane1.setViewportView(jTreeViewTable1); getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); @@ -51,7 +48,7 @@ } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; - private pcgen.gui.util.JTreeTable jTreeTable1; + private pcgen.gui.util.JTreeViewTable jTreeViewTable1; // End of variables declaration//GEN-END:variables } Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java 2008-02-24 20:08:15 UTC (rev 5321) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java 2008-02-24 21:02:56 UTC (rev 5322) @@ -22,6 +22,7 @@ import java.awt.Component; import java.awt.Cursor; +import java.awt.Insets; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -41,10 +42,11 @@ * * @author Connor Petty<mis...@gm...> */ -public class JTableSortingHeader extends JTableHeader +public class JTableSortingHeader extends JTableHeader implements MouseListener, + MouseMotionListener { - private static final Icon ASCENDING_ICON = IconUtilities.getImageIcon("Down16.gif");//TODO: implement + private static final Icon ASCENDING_ICON = IconUtilities.getImageIcon("Down16.gif"); private static final Icon DESCENDING_ICON = IconUtilities.getImageIcon("Up16.gif"); private static final ButtonModel defaultModel = new DefaultButtonModel(); private final ButtonModel usedModel = new DefaultButtonModel(); @@ -54,9 +56,8 @@ public JTableSortingHeader(JTableEx table) { super(table.getColumnModel()); - MouseTracker tracker = new MouseTracker(); - addMouseListener(tracker); - addMouseMotionListener(tracker); + addMouseListener(this); + addMouseMotionListener(this); sorter = table.getModelSorter(); } @@ -76,59 +77,13 @@ return sorter; } - private final class MouseTracker implements MouseMotionListener, - MouseListener - { - - public void mouseClicked(MouseEvent e) - { - if (getCursor() == Cursor.getDefaultCursor()) - { - sorter.toggleSort(trackedColumn.getModelIndex()); - repaint(); - } - } - - public void mouseDragged(MouseEvent e) - { - - } - - public void mouseMoved(MouseEvent e) - { - TableColumnModel model = getColumnModel(); - trackedColumn = model.getColumn(model.getColumnIndexAtX(e.getX())); - } - - public void mousePressed(MouseEvent e) - { - usedModel.setPressed(true); - repaint(); - } - - public void mouseReleased(MouseEvent e) - { - usedModel.setPressed(false); - } - - public void mouseEntered(MouseEvent e) - { - usedModel.setRollover(true); - } - - public void mouseExited(MouseEvent e) - { - usedModel.setRollover(false); - } - - } - public class SortingHeaderRenderer extends JButton implements TableCellRenderer { public SortingHeaderRenderer() { setHorizontalTextPosition(LEADING); + this.setMargin(new Insets(0,0,0,0)); } public Component getTableCellRendererComponent(JTable table, @@ -172,4 +127,46 @@ } } + + public void mouseClicked(MouseEvent e) + { + if (getResizingColumn() == null) + { + sorter.toggleSort(trackedColumn.getModelIndex()); + repaint(); + } + } + + public void mouseDragged(MouseEvent e) + { + + } + + public void mouseMoved(MouseEvent e) + { + TableColumnModel model = getColumnModel(); + trackedColumn = model.getColumn(model.getColumnIndexAtX(e.getX())); + } + + public void mousePressed(MouseEvent e) + { + usedModel.setPressed(true); + repaint(); + } + + public void mouseReleased(MouseEvent e) + { + usedModel.setPressed(false); + } + + public void mouseEntered(MouseEvent e) + { + usedModel.setRollover(true); + } + + public void mouseExited(MouseEvent e) + { + usedModel.setRollover(false); + } + } Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java 2008-02-24 20:08:15 UTC (rev 5321) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeTable.java 2008-02-24 21:02:56 UTC (rev 5322) @@ -48,15 +48,12 @@ import javax.swing.table.AbstractTableModel; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableModel; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeSelectionModel; import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import pcgen.gui.util.table.SortableTableModel; import pcgen.gui.util.treetable.DefaultSortableTreeTableModel; -import pcgen.gui.util.treetable.DefaultTreeTableModel; import pcgen.gui.util.treetable.SortableTreeTableModel; import pcgen.gui.util.treetable.TreeTableNode; @@ -291,7 +288,7 @@ * @author Philip Milne * @author Scott Violet */ - protected static class TreeTableModelAdapter extends AbstractTableModel + private static class TreeTableModelAdapter extends AbstractTableModel implements SortableTableModel { @@ -353,10 +350,6 @@ } }; - if (treeTableModel != null) - { - treeTableModel.addTreeModelListener(modelListener); - } } public void setTreeTableModel(SortableTreeTableModel model) Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java 2008-02-24 20:08:15 UTC (rev 5321) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewTable.java 2008-02-24 21:02:56 UTC (rev 5322) @@ -20,7 +20,16 @@ */ package pcgen.gui.util; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; import java.util.Collection; +import javax.swing.AbstractAction; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.table.TableColumnModel; +import pcgen.gui.util.treeview.TreeView; import pcgen.gui.util.treeview.TreeViewModel; import pcgen.gui.util.treeview.TreeViewTableModel; @@ -31,6 +40,12 @@ public class JTreeViewTable extends JTreeTable { + public JTreeViewTable() + { + this(null); + } + + @SuppressWarnings("unchecked") public <T> JTreeViewTable(TreeViewModel<T> model, Collection<T> collection) { this(new TreeViewTableModel(model, collection)); @@ -39,8 +54,10 @@ public JTreeViewTable(TreeViewTableModel model) { super(model); + setTableHeader(new JTreeViewHeader()); } + @SuppressWarnings("unchecked") public TreeViewTableModel getTreeViewTableModel() { return (TreeViewTableModel) super.getTreeTableModel(); @@ -51,4 +68,103 @@ super.setTreeTableModel(model); } + private class JTreeViewHeader extends JTableSortingHeader + { + + public JTreeViewHeader() + { + super(JTreeViewTable.this); + } + + @Override + public void mouseClicked(MouseEvent e) + { + super.mouseClicked(e); + } + + @Override + public void mouseDragged(MouseEvent e) + { + + } + + @Override + public void mouseMoved(MouseEvent e) + { + super.mouseMoved(e); + } + + @Override + public void mousePressed(MouseEvent e) + { + super.mousePressed(e); + maybeShowPopup(e); + } + + @Override + public void mouseReleased(MouseEvent e) + { + super.mouseReleased(e); + maybeShowPopup(e); + } + + @Override + public void mouseEntered(MouseEvent e) + { + super.mouseEntered(e); + } + + @Override + public void mouseExited(MouseEvent e) + { + super.mouseExited(e); + } + + @SuppressWarnings("unchecked") + private void maybeShowPopup(MouseEvent e) + { + if (e.isPopupTrigger() && getTrackedColumn().getModelIndex() == 0) + { + JPopupMenu treeviewMenu = new JPopupMenu(); + Collection<TreeView> views = getTreeViewTableModel().getSelectableTreeViews(); + for (TreeView treeview : views) + { + treeviewMenu.add(new JMenuItem(new ChangeViewAction(treeview))); + } + treeviewMenu.setPopupSize(getTrackedColumn().getWidth(), -1); + Point loc = getPopupLocation(e); + treeviewMenu.show(e.getComponent(), + loc.x, loc.y); + } + } + + @Override + public Point getPopupLocation(MouseEvent e) + { + TableColumnModel columnmodel = getColumnModel(); + Rectangle rect = getHeaderRect(columnmodel.getColumnIndexAtX(e.getX())); + rect.translate(0, rect.height); + return rect.getLocation(); + } + + } + + @SuppressWarnings("unchecked") + private class ChangeViewAction extends AbstractAction + { + + private TreeView view; + + public ChangeViewAction(TreeView view) + { + super(view.getViewName()); + this.view = view; + } + + public void actionPerformed(ActionEvent e) + { + getTreeViewTableModel().setSelectedTreeView(view); + } + + } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-24 20:08:15 UTC (rev 5321) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewTableModel.java 2008-02-24 21:02:56 UTC (rev 5322) @@ -88,6 +88,11 @@ } } + public Collection<TreeView<E>> getSelectableTreeViews() + { + return viewMap.keySet(); + } + public TreeView<E> getSelectedTreeView() { return selectedView; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-02-24 21:18:12
|
Revision: 5324 http://pcgen.svn.sourceforge.net/pcgen/?rev=5324&view=rev Author: cpmeister Date: 2008-02-24 13:18:13 -0800 (Sun, 24 Feb 2008) Log Message: ----------- corrected ui behavior Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 21:08:37 UTC (rev 5323) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-24 21:18:13 UTC (rev 5324) @@ -33,7 +33,37 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> - <Component class="pcgen.gui.util.JTreeViewTable" name="jTreeViewTable1"> + <Component class="pcgen.gui.util.JTableEx" name="jTableEx1"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="4"> + <Column editable="true" title="Title 1" type="java.lang.Object"> + <Data value="sdfa"/> + <Data value="ghjd"/> + <Data value="null"/> + <Data value="dfg"/> + </Column> + <Column editable="true" title="Title 2" type="java.lang.Object"> + <Data value="tegh"/> + <Data value="asdf"/> + <Data value="asdrj"/> + <Data value="cbnc"/> + </Column> + <Column editable="true" title="Title 3" type="java.lang.Object"> + <Data value="wvczs"/> + <Data value="trtw"/> + <Data value="kjffs"/> + <Data value="mnvx"/> + </Column> + <Column editable="true" title="Title 4" type="java.lang.Object"> + <Data value="yuue"/> + <Data value="sfdgj"/> + <Data value="sfgj"/> + <Data value="xssd"/> + </Column> + </Table> + </Property> + </Properties> </Component> </SubComponents> </Container> Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 21:08:37 UTC (rev 5323) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-24 21:18:13 UTC (rev 5324) @@ -25,11 +25,22 @@ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); - jTreeViewTable1 = new pcgen.gui.util.JTreeViewTable(); + jTableEx1 = new pcgen.gui.util.JTableEx(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - jScrollPane1.setViewportView(jTreeViewTable1); + jTableEx1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {"sdfa", "tegh", "wvczs", "yuue"}, + {"ghjd", "asdf", "trtw", "sfdgj"}, + {null, "asdrj", "kjffs", "sfgj"}, + {"dfg", "cbnc", "mnvx", "xssd"} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + jScrollPane1.setViewportView(jTableEx1); getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); @@ -48,7 +59,7 @@ } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; - private pcgen.gui.util.JTreeViewTable jTreeViewTable1; + private pcgen.gui.util.JTableEx jTableEx1; // End of variables declaration//GEN-END:variables } Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java 2008-02-24 21:08:37 UTC (rev 5323) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableSortingHeader.java 2008-02-24 21:18:13 UTC (rev 5324) @@ -130,7 +130,7 @@ public void mouseClicked(MouseEvent e) { - if (getResizingColumn() == null) + if (getCursor() == Cursor.getDefaultCursor()) { sorter.toggleSort(trackedColumn.getModelIndex()); repaint(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-02-29 05:11:09
|
Revision: 5380 http://pcgen.svn.sourceforge.net/pcgen/?rev=5380&view=rev Author: cpmeister Date: 2008-02-28 21:11:12 -0800 (Thu, 28 Feb 2008) Log Message: ----------- Completed Adding/Removing Table Column functionality within JTablePane Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultDynamicTableColumnModel.java branches/cdomui/code/src/java/pcgen/gui/util/table/DynamicTableColumnModel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/util/JTablePane.java branches/cdomui/code/src/java/pcgen/gui/util/event/ branches/cdomui/code/src/java/pcgen/gui/util/event/DynamicTableColumnModelListener.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/util/JTableExScrollPane.java Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-29 04:58:47 UTC (rev 5379) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.form 2008-02-29 05:11:12 UTC (rev 5380) @@ -21,21 +21,17 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> <SubComponents> - <Container class="javax.swing.JScrollPane" name="jScrollPane1"> - <AuxValues> - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> - </AuxValues> + <Component class="pcgen.gui.util.JTablePane" name="jTablePane1"> + <Properties> + <Property name="model" type="pcgen.gui.util.table.SortableTableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getTableModel()" type="code"/> + </Property> + </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> <BorderConstraints direction="Center"/> </Constraint> </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> - <SubComponents> - <Component class="pcgen.gui.util.JTableEx" name="jTableEx1"> - </Component> - </SubComponents> - </Container> + </Component> </SubComponents> </Form> Modified: branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-29 04:58:47 UTC (rev 5379) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/PlayerCharacterEditor.java 2008-02-29 05:11:12 UTC (rev 5380) @@ -5,7 +5,11 @@ */ package pcgen.gui.proto.editor; +import javax.swing.table.TableModel; +import pcgen.gui.util.JTablePane; import pcgen.gui.util.panes.SpinningTabbedPane; +import pcgen.gui.util.table.DefaultSortableTableModel; +import pcgen.gui.util.table.SortableTableModel; /** * @@ -26,26 +30,13 @@ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { - jScrollPane1 = new javax.swing.JScrollPane(); - jTableEx1 = new pcgen.gui.util.JTableEx(); + jTablePane1 = new pcgen.gui.util.JTablePane(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - jTableEx1.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - {"sdfa", "tegh", "wvczs", "yuue"}, - {"ghjd", "asdf", "trtw", "sfdgj"}, - {null, "asdrj", "kjffs", "sfgj"}, - {"dfg", "cbnc", "mnvx", "xssd"} - }, - new String [] { - "Title 1", "Title 2", "Title 3", "Title 4" - } - )); - jScrollPane1.setViewportView(jTableEx1); + jTablePane1.setModel(getTableModel()); + getContentPane().add(jTablePane1, java.awt.BorderLayout.CENTER); - getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); - pack(); }// </editor-fold>//GEN-END:initComponents /** @@ -59,9 +50,22 @@ } }); } + public SortableTableModel getTableModel() + { + return new DefaultSortableTableModel( + new Object [][] { + {"sdfa", "tegh", "wvczs", "yuue"}, + {"ghjd", "asdf", "trtw", "pin"}, + {"hty", "iohf", "kjffs", "sfgj"}, + {"dfg", "cbnc", "mnvx", "xssd"} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + ); + } // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JScrollPane jScrollPane1; - private pcgen.gui.util.JTableEx jTableEx1; + private pcgen.gui.util.JTablePane jTablePane1; // End of variables declaration//GEN-END:variables } Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-02-29 04:58:47 UTC (rev 5379) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-02-29 05:11:12 UTC (rev 5380) @@ -25,7 +25,6 @@ import javax.swing.SwingConstants; import java.awt.Component; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -35,8 +34,6 @@ import javax.swing.table.TableModel; import pcgen.gui.util.table.DefaultSortableTableModel; import pcgen.gui.util.table.SortableTableModel; -import pcgen.gui.util.table.DefaultDynamicTableColumnModel; -import pcgen.gui.util.table.DynamicTableColumnModel; import pcgen.util.Comparators; /** @@ -74,12 +71,12 @@ * @param tm * @param tcm */ - public JTableEx(SortableTableModel tm, DynamicTableColumnModel tcm) + public JTableEx(SortableTableModel tm, TableColumnModel tcm) { this(tm, tcm, null); } - private JTableEx(SortableTableModel tm, DynamicTableColumnModel tcm, + public JTableEx(SortableTableModel tm, TableColumnModel tcm, ListSelectionModel lsm) { super(tm, tcm, lsm); @@ -115,22 +112,6 @@ return (SortableTableModel) super.getModel(); } - @Override - public void setColumnModel(TableColumnModel columnModel) - { - if (!(columnModel instanceof DynamicTableColumnModel)) - { - columnModel = new DefaultDynamicTableColumnModel(columnModel, 1); - } - super.setColumnModel(columnModel); - } - - @Override - public DynamicTableColumnModel getColumnModel() - { - return (DynamicTableColumnModel) super.getColumnModel(); - } - /** * set horizontal alignment of column * and attach a new cell renderer Deleted: branches/cdomui/code/src/java/pcgen/gui/util/JTableExScrollPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableExScrollPane.java 2008-02-29 04:58:47 UTC (rev 5379) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableExScrollPane.java 2008-02-29 05:11:12 UTC (rev 5380) @@ -1,110 +0,0 @@ -/* - * JTableExScrollPane.java - * Copyright 2008 (C) Connor Petty <mis...@gm...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Feb 27, 2008, 10:44:14 PM - */ -package pcgen.gui.util; - -import java.awt.event.ActionEvent; -import java.util.List; -import javax.swing.AbstractAction; -import javax.swing.JButton; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.table.TableColumn; -import pcgen.gui.util.table.DynamicTableColumnModel; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class JTableExScrollPane extends JScrollPane -{ - - private JTableEx table; - - public JTableExScrollPane() - { - - } - - public JTableExScrollPane(JTableEx table) - { - setTable(table); - } - - public void setTable(JTableEx table) - { - this.table = table; - DynamicTableColumnModel model = table.getColumnModel(); - List<TableColumn> columns = model.getAvailableColumns(); - if (!columns.isEmpty()) - { - JPopupMenu menu = new JPopupMenu(); - for (TableColumn column : columns) - { - JCheckBoxMenuItem item = new JCheckBoxMenuItem(); - item.setSelected(model.isVisible(column)); - item.setAction(new MenuAction(column)); - menu.add(item); - } - setCorner(JScrollPane.UPPER_RIGHT_CORNER, new JButton(new CornerAction(menu))); - } - else - { - setCorner(JScrollPane.UPPER_RIGHT_CORNER, null); - } - setViewportView(table); - } - - private class CornerAction extends AbstractAction - { - - private JPopupMenu menu; - - public CornerAction(JPopupMenu menu) - { - super("..."); - this.menu = menu; - } - - public void actionPerformed(ActionEvent e) - { - menu.show(table, table.getWidth() - menu.getWidth(), 0); - } - - } - - private class MenuAction extends AbstractAction - { - - private TableColumn column; - - public MenuAction(TableColumn column) - { - super(column.getHeaderValue().toString()); - this.column = column; - } - - public void actionPerformed(ActionEvent e) - { - table.getColumnModel().toggleVisible(column); - } - } -} Copied: branches/cdomui/code/src/java/pcgen/gui/util/JTablePane.java (from rev 5373, branches/cdomui/code/src/java/pcgen/gui/util/JTableExScrollPane.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTablePane.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTablePane.java 2008-02-29 05:11:12 UTC (rev 5380) @@ -0,0 +1,190 @@ +/* + * JTablePane.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 27, 2008, 10:44:14 PM + */ +package pcgen.gui.util; + +import java.awt.event.ActionEvent; +import java.util.List; +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.event.TableColumnModelEvent; +import javax.swing.table.TableColumn; +import pcgen.gui.util.event.DynamicTableColumnModelListener; +import pcgen.gui.util.table.DefaultDynamicTableColumnModel; +import pcgen.gui.util.table.DynamicTableColumnModel; +import pcgen.gui.util.table.SortableTableModel; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class JTablePane extends JScrollPane +{ + + private final JButton cornerButton = new JButton(new CornerAction()); + private final ModelListener listener = new ModelListener(); + private JPopupMenu menu = new JPopupMenu(); + private DynamicTableColumnModel columnModel; + private JTableEx table; + + /** + * Constructor + */ + public JTablePane() + { + this(null, null, null); + } + + /** + * Constructor + * @param tm + */ + public JTablePane(SortableTableModel tm) + { + this(tm, null, null); + } + + /** + * Constructor + * @param tm + * @param tcm + */ + public JTablePane(SortableTableModel tm, DynamicTableColumnModel tcm) + { + this(tm, tcm, null); + } + + private JTablePane(SortableTableModel tm, DynamicTableColumnModel tcm, + ListSelectionModel lsm) + { + super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED); + setTable(new JTableEx(tm, tcm, lsm)); + setColumnModel(createDefaultDynamicTableColumnModel()); + } + + protected DynamicTableColumnModel createDefaultDynamicTableColumnModel() + { + return new DefaultDynamicTableColumnModel(table.getColumnModel(), 1); + } + + public void setModel(SortableTableModel model) + { + table.setModel(model); + } + + public void setColumnModel(DynamicTableColumnModel columnModel) + { + if (this.columnModel != null) + { + this.columnModel.removeDynamicTableColumnModelListener(listener); + } + this.columnModel = columnModel; + columnModel.addDynamicTableColumnModelListener(listener); + table.setColumnModel(columnModel); + List<TableColumn> columns = columnModel.getAvailableColumns(); + if (!columns.isEmpty()) + { + menu = new JPopupMenu(); + for (TableColumn column : columns) + { + JCheckBoxMenuItem item = new JCheckBoxMenuItem(); + item.setSelected(columnModel.isVisible(column)); + item.setAction(new MenuAction(column)); + menu.add(item); + } + setCorner(JScrollPane.UPPER_RIGHT_CORNER, cornerButton); + } + else + { + setCorner(JScrollPane.UPPER_RIGHT_CORNER, null); + } + } + + private void setTable(JTableEx table) + { + this.table = table; + setViewportView(table); + } + + private class CornerAction extends AbstractAction + { + + public CornerAction() + { + super("..."); + } + + public void actionPerformed(ActionEvent e) + { + menu.show(table, table.getWidth() - menu.getWidth(), 0); + } + + } + + private class MenuAction extends AbstractAction + { + + private TableColumn column; + + public MenuAction(TableColumn column) + { + super(column.getHeaderValue().toString()); + this.column = column; + } + + public void actionPerformed(ActionEvent e) + { + columnModel.toggleVisible(column); + } + + } + + private class ModelListener implements DynamicTableColumnModelListener + { + + public void availableColumnAdded(TableColumnModelEvent event) + { + int index = event.getToIndex(); + TableColumn column = columnModel.getAvailableColumns().get(index); + JCheckBoxMenuItem item = new JCheckBoxMenuItem(); + item.setSelected(columnModel.isVisible(column)); + item.setAction(new MenuAction(column)); + menu.insert(item, index); + if (getCorner(JScrollPane.UPPER_RIGHT_CORNER) == null) + { + setCorner(JScrollPane.UPPER_RIGHT_CORNER, cornerButton); + } + } + + public void availableColumnRemove(TableColumnModelEvent event) + { + menu.remove(event.getFromIndex()); + if (menu.getComponentCount() == 0) + { + setCorner(JScrollPane.UPPER_RIGHT_CORNER, null); + } + } + + } +} Added: branches/cdomui/code/src/java/pcgen/gui/util/event/DynamicTableColumnModelListener.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/event/DynamicTableColumnModelListener.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/event/DynamicTableColumnModelListener.java 2008-02-29 05:11:12 UTC (rev 5380) @@ -0,0 +1,35 @@ +/* + * DynamicTableColumnModelListener.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Feb 28, 2008, 7:47:48 PM + */ + +package pcgen.gui.util.event; + +import java.util.EventListener; +import javax.swing.event.TableColumnModelEvent; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public interface DynamicTableColumnModelListener extends EventListener +{ + public void availableColumnAdded(TableColumnModelEvent event); + public void availableColumnRemove(TableColumnModelEvent event); +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultDynamicTableColumnModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultDynamicTableColumnModel.java 2008-02-29 04:58:47 UTC (rev 5379) +++ branches/cdomui/code/src/java/pcgen/gui/util/table/DefaultDynamicTableColumnModel.java 2008-02-29 05:11:12 UTC (rev 5380) @@ -23,9 +23,11 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.swing.event.TableColumnModelEvent; import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; +import pcgen.gui.util.event.DynamicTableColumnModelListener; /** * @@ -35,37 +37,146 @@ implements DynamicTableColumnModel { - private final List<TableColumn> availableColumns; + private final List<TableColumn> availableColumns = new ArrayList<TableColumn>(5); + private final List<TableColumn> safeColumns = Collections.unmodifiableList(availableColumns); + private int offset; + /** + * This constructs an empty table model with an intial offset of <code>offset</code>. + * When adding columns to the model, the first <code>offset<code> number of colums added will + * be made always visible. + * @param offset this is the number of always visible columns when this model is populated. + */ + public DefaultDynamicTableColumnModel(int offset) + { + this.offset = offset; + } + + /** + * + * @param model the columns model to copy data from + * @param offset describes the number of always visible columns + */ public DefaultDynamicTableColumnModel(TableColumnModel model, int offset) { + this(offset); ArrayList<TableColumn> allColumns = Collections.list(model.getColumns()); if (offset < allColumns.size()) { - this.availableColumns = Collections.unmodifiableList(allColumns.subList(offset, - allColumns.size())); - for (int x = 0; x < offset; x++) - { - this.addColumn(allColumns.get(x)); - } + tableColumns.addAll(allColumns.subList(0, offset)); + availableColumns.addAll(allColumns.subList(offset, allColumns.size())); } - else - this.availableColumns = Collections.emptyList(); } + /** + * + * @param model the columns model to copy data from + * @param offset describes the number of always visible columns + * @param visibleColumns used to specify additional columns + * that will be visible upon initialization + */ public DefaultDynamicTableColumnModel(TableColumnModel model, int offset, int[] visibleColumns) { this(model, offset); for (int column : visibleColumns) { - this.addColumn(availableColumns.get(column - offset)); + super.addColumn(availableColumns.get(column - offset)); } } + public void addDynamicTableColumnModelListener(DynamicTableColumnModelListener listener) + { + listenerList.add(DynamicTableColumnModelListener.class, listener); + } + + public void removeDynamicTableColumnModelListener(DynamicTableColumnModelListener listener) + { + listenerList.remove(DynamicTableColumnModelListener.class, listener); + } + + /** + * Notifies all listeners that have registered interest for + * notification on this event type. The event instance + * is lazily created using the parameters passed into + * the fire method. + * @param e the event received + * @see EventListenerList + */ + protected void fireAvailableColumnAdded(TableColumnModelEvent e) + { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == DynamicTableColumnModelListener.class) + { + // Lazily create the event: + // if (e == null) + // e = new ChangeEvent(this); + ((DynamicTableColumnModelListener) listeners[i + 1]).availableColumnAdded(e); + } + } + } + + /** + * Notifies all listeners that have registered interest for + * notification on this event type. The event instance + * is lazily created using the parameters passed into + * the fire method. + * @param e the event received + * @see EventListenerList + */ + protected void fireAvailableColumnRemoved(TableColumnModelEvent e) + { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length - 2; i >= 0; i -= 2) + { + if (listeners[i] == DynamicTableColumnModelListener.class) + { + // Lazily create the event: + // if (e == null) + // e = new ChangeEvent(this); + ((DynamicTableColumnModelListener) listeners[i + 1]).availableColumnRemove(e); + } + } + } + + @Override + public void addColumn(TableColumn column) + { + if (getColumnCount() < offset) + { + super.addColumn(column); + } + else + { + int index = availableColumns.size(); + availableColumns.add(column); + fireAvailableColumnAdded(new TableColumnModelEvent(this, -1, index)); + } + } + + @Override + public void removeColumn(TableColumn column) + { + super.removeColumn(column); + if (availableColumns.contains(column)) + { + int index = availableColumns.indexOf(column); + availableColumns.remove(column); + fireAvailableColumnRemoved(new TableColumnModelEvent(this, index, -1)); + } + } + public List<TableColumn> getAvailableColumns() { - return availableColumns; + return safeColumns; } public boolean isVisible(TableColumn column) @@ -79,11 +190,11 @@ { if (isVisible(column)) { - removeColumn(column); + super.removeColumn(column); } else { - addColumn(column); + super.addColumn(column); } } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/table/DynamicTableColumnModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/table/DynamicTableColumnModel.java 2008-02-29 04:58:47 UTC (rev 5379) +++ branches/cdomui/code/src/java/pcgen/gui/util/table/DynamicTableColumnModel.java 2008-02-29 05:11:12 UTC (rev 5380) @@ -18,12 +18,12 @@ * * Created on Feb 25, 2008, 3:57:47 PM */ - package pcgen.gui.util.table; import java.util.List; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; +import pcgen.gui.util.event.DynamicTableColumnModelListener; /** * @@ -31,7 +31,15 @@ */ public interface DynamicTableColumnModel extends TableColumnModel { + + public void addDynamicTableColumnModelListener(DynamicTableColumnModelListener listener); + + public void removeDynamicTableColumnModelListener(DynamicTableColumnModelListener listener); + public List<TableColumn> getAvailableColumns(); + public boolean isVisible(TableColumn column); + public void toggleVisible(TableColumn column); + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-05-02 02:21:26
|
Revision: 6162 http://pcgen.svn.sourceforge.net/pcgen/?rev=6162&view=rev Author: cpmeister Date: 2008-05-01 19:21:29 -0700 (Thu, 01 May 2008) Log Message: ----------- minor changes Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.java branches/cdomui/code/src/java/pcgen/gui/test/ branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.form branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.form branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.java branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.form branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.java Deleted: branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.form 2008-05-01 16:35:31 UTC (rev 6161) +++ branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.form 2008-05-02 02:21:29 UTC (rev 6162) @@ -1,188 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> - <NonVisualComponents> - <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> - <SubComponents> - <Menu class="javax.swing.JMenu" name="jMenu1"> - <Properties> - <Property name="text" type="java.lang.String" value="File"/> - </Properties> - </Menu> - <Menu class="javax.swing.JMenu" name="jMenu2"> - <Properties> - <Property name="text" type="java.lang.String" value="Edit"/> - </Properties> - </Menu> - </SubComponents> - </Menu> - </NonVisualComponents> - <Properties> - <Property name="defaultCloseOperation" type="int" value="3"/> - </Properties> - <SyntheticProperties> - <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> - <SyntheticProperty name="formSizePolicy" type="int" value="1"/> - </SyntheticProperties> - <AuxValues> - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,108,0,0,1,-66"/> - </AuxValues> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> - <SubComponents> - <Container class="javax.swing.JToolBar" name="jToolBar1"> - <Properties> - <Property name="floatable" type="boolean" value="false"/> - <Property name="rollover" type="boolean" value="true"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="First"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> - <SubComponents> - <Component class="javax.swing.JButton" name="jButton5"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/pcgen/gui/resource/New16.gif"/> - </Property> - <Property name="focusable" type="boolean" value="false"/> - <Property name="horizontalTextPosition" type="int" value="0"/> - <Property name="verticalTextPosition" type="int" value="3"/> - </Properties> - </Component> - <Component class="javax.swing.JButton" name="jButton6"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/pcgen/gui/resource/Close16.gif"/> - </Property> - <Property name="focusable" type="boolean" value="false"/> - <Property name="horizontalTextPosition" type="int" value="0"/> - <Property name="verticalTextPosition" type="int" value="3"/> - </Properties> - </Component> - <Component class="javax.swing.JToolBar$Separator" name="jSeparator1"> - </Component> - <Component class="javax.swing.JButton" name="jButton1"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/pcgen/gui/resource/Undo16.gif"/> - </Property> - <Property name="focusable" type="boolean" value="false"/> - <Property name="horizontalTextPosition" type="int" value="0"/> - <Property name="verticalTextPosition" type="int" value="3"/> - </Properties> - </Component> - <Component class="javax.swing.JButton" name="jButton2"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/pcgen/gui/resource/Redo16.gif"/> - </Property> - <Property name="focusable" type="boolean" value="false"/> - <Property name="horizontalTextPosition" type="int" value="0"/> - <Property name="verticalTextPosition" type="int" value="3"/> - </Properties> - </Component> - </SubComponents> - </Container> - <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane1"> - <Properties> - <Property name="orientation" type="int" value="0"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="Center"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> - <SubComponents> - <Container class="pcgen.gui.util.panes.SpinningTabbedPane" name="spinningTabbedPane1"> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> - <JSplitPaneConstraints position="left"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> - <SubComponents> - <Container class="javax.swing.JScrollPane" name="jScrollPane1"> - <AuxValues> - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> - </AuxValues> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> - <JTabbedPaneConstraints tabName="tab1"> - <Property name="tabTitle" type="java.lang.String" value="tab1"/> - </JTabbedPaneConstraints> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> - <SubComponents> - <Component class="javax.swing.JList" name="jList1"> - <Properties> - <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> - <StringArray count="5"> - <StringItem index="0" value="Item 1"/> - <StringItem index="1" value="Item 2"/> - <StringItem index="2" value="Item 3"/> - <StringItem index="3" value="Item 4"/> - <StringItem index="4" value="Item 5"/> - </StringArray> - </Property> - </Properties> - </Component> - </SubComponents> - </Container> - </SubComponents> - </Container> - <Container class="javax.swing.JPanel" name="jPanel1"> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> - <JSplitPaneConstraints position="right"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> - <SubComponents> - <Component class="javax.swing.JComboBox" name="jComboBox1"> - <Properties> - <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> - <StringArray count="4"> - <StringItem index="0" value="Item 1"/> - <StringItem index="1" value="Item 2"/> - <StringItem index="2" value="Item 3"/> - <StringItem index="3" value="Item 4"/> - </StringArray> - </Property> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="First"/> - </Constraint> - </Constraints> - </Component> - <Component class="pcgen.gui.util.JTreeTablePane" name="jTreeTablePane1"> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="Center"/> - </Constraint> - </Constraints> - </Component> - </SubComponents> - </Container> - </SubComponents> - </Container> - </SubComponents> -</Form> Deleted: branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.java 2008-05-01 16:35:31 UTC (rev 6161) +++ branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.java 2008-05-02 02:21:29 UTC (rev 6162) @@ -1,141 +0,0 @@ -/* - * LstEditor.java - * - * Created on March 4, 2008, 2:43 PM - */ - -package pcgen.gui.editor; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class LstEditor extends javax.swing.JFrame { - - /** Creates new form LstEditor */ - public LstEditor() { - initComponents(); - } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents - private void initComponents() { - - jToolBar1 = new javax.swing.JToolBar(); - jButton5 = new javax.swing.JButton(); - jButton6 = new javax.swing.JButton(); - jSeparator1 = new javax.swing.JToolBar.Separator(); - jButton1 = new javax.swing.JButton(); - jButton2 = new javax.swing.JButton(); - flippingSplitPane1 = new pcgen.gui.util.panes.FlippingSplitPane(); - spinningTabbedPane1 = new pcgen.gui.util.panes.SpinningTabbedPane(); - jScrollPane1 = new javax.swing.JScrollPane(); - jList1 = new javax.swing.JList(); - jPanel1 = new javax.swing.JPanel(); - jComboBox1 = new javax.swing.JComboBox(); - jTreeTablePane1 = new pcgen.gui.util.JTreeTablePane(); - jMenuBar1 = new javax.swing.JMenuBar(); - jMenu1 = new javax.swing.JMenu(); - jMenu2 = new javax.swing.JMenu(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - - jToolBar1.setFloatable(false); - jToolBar1.setRollover(true); - - jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/New16.gif"))); // NOI18N - jButton5.setFocusable(false); - jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jToolBar1.add(jButton5); - - jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/Close16.gif"))); // NOI18N - jButton6.setFocusable(false); - jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jToolBar1.add(jButton6); - jToolBar1.add(jSeparator1); - - jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/Undo16.gif"))); // NOI18N - jButton1.setFocusable(false); - jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jToolBar1.add(jButton1); - - jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/Redo16.gif"))); // NOI18N - jButton2.setFocusable(false); - jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - jToolBar1.add(jButton2); - - getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START); - - flippingSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); - - jList1.setModel(new javax.swing.AbstractListModel() { - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; - public int getSize() { return strings.length; } - public Object getElementAt(int i) { return strings[i]; } - }); - jScrollPane1.setViewportView(jList1); - - spinningTabbedPane1.addTab("tab1", jScrollPane1); - - flippingSplitPane1.setLeftComponent(spinningTabbedPane1); - - jPanel1.setLayout(new java.awt.BorderLayout()); - - jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); - jPanel1.add(jComboBox1, java.awt.BorderLayout.PAGE_START); - jPanel1.add(jTreeTablePane1, java.awt.BorderLayout.CENTER); - - flippingSplitPane1.setRightComponent(jPanel1); - - getContentPane().add(flippingSplitPane1, java.awt.BorderLayout.CENTER); - - jMenu1.setText("File"); - jMenuBar1.add(jMenu1); - - jMenu2.setText("Edit"); - jMenuBar1.add(jMenu2); - - setJMenuBar(jMenuBar1); - - pack(); - }// </editor-fold>//GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new LstEditor().setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane1; - private javax.swing.JButton jButton1; - private javax.swing.JButton jButton2; - private javax.swing.JButton jButton5; - private javax.swing.JButton jButton6; - private javax.swing.JComboBox jComboBox1; - private javax.swing.JList jList1; - private javax.swing.JMenu jMenu1; - private javax.swing.JMenu jMenu2; - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JPanel jPanel1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JToolBar.Separator jSeparator1; - private javax.swing.JToolBar jToolBar1; - private pcgen.gui.util.JTreeTablePane jTreeTablePane1; - private pcgen.gui.util.panes.SpinningTabbedPane spinningTabbedPane1; - // End of variables declaration//GEN-END:variables - -} Copied: branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.form (from rev 6161, branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.form) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.form (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.form 2008-05-02 02:21:29 UTC (rev 6162) @@ -0,0 +1,194 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <NonVisualComponents> + <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> + <SubComponents> + <Menu class="javax.swing.JMenu" name="jMenu1"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <PlainString value="File"/> + </Property> + </Properties> + </Menu> + <Menu class="javax.swing.JMenu" name="jMenu2"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <PlainString value="Edit"/> + </Property> + </Properties> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,108,0,0,1,-66"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JToolBar" name="jToolBar1"> + <Properties> + <Property name="floatable" type="boolean" value="false"/> + <Property name="rollover" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton5"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/pcgen/gui/resource/New16.gif"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton6"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/pcgen/gui/resource/Close16.gif"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + <Component class="javax.swing.JToolBar$Separator" name="jSeparator1"> + </Component> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/pcgen/gui/resource/Undo16.gif"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/pcgen/gui/resource/Redo16.gif"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane1"> + <Properties> + <Property name="orientation" type="int" value="0"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Container class="pcgen.gui.util.panes.SpinningTabbedPane" name="spinningTabbedPane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="left"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="tab1"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <PlainString value="tab1"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="jList1"> + <Properties> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="5"> + <StringItem index="0" value="Item 1"/> + <StringItem index="1" value="Item 2"/> + <StringItem index="2" value="Item 3"/> + <StringItem index="3" value="Item 4"/> + <StringItem index="4" value="Item 5"/> + </StringArray> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="javax.swing.JComboBox" name="jComboBox1"> + <Properties> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="4"> + <StringItem index="0" value="Item 1"/> + <StringItem index="1" value="Item 2"/> + <StringItem index="2" value="Item 3"/> + <StringItem index="3" value="Item 4"/> + </StringArray> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + </Component> + <Component class="pcgen.gui.util.JTreeTablePane" name="jTreeTablePane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> Copied: branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.java (from rev 6161, branches/cdomui/code/src/java/pcgen/gui/editor/LstEditor.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/LstEditor.java 2008-05-02 02:21:29 UTC (rev 6162) @@ -0,0 +1,141 @@ +/* + * LstEditor.java + * + * Created on March 4, 2008, 2:43 PM + */ + +package pcgen.gui.proto.editor; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class LstEditor extends javax.swing.JFrame { + + /** Creates new form LstEditor */ + public LstEditor() { + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jToolBar1 = new javax.swing.JToolBar(); + jButton5 = new javax.swing.JButton(); + jButton6 = new javax.swing.JButton(); + jSeparator1 = new javax.swing.JToolBar.Separator(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + flippingSplitPane1 = new pcgen.gui.util.panes.FlippingSplitPane(); + spinningTabbedPane1 = new pcgen.gui.util.panes.SpinningTabbedPane(); + jScrollPane1 = new javax.swing.JScrollPane(); + jList1 = new javax.swing.JList(); + jPanel1 = new javax.swing.JPanel(); + jComboBox1 = new javax.swing.JComboBox(); + jTreeTablePane1 = new pcgen.gui.util.JTreeTablePane(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenu2 = new javax.swing.JMenu(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jToolBar1.setFloatable(false); + jToolBar1.setRollover(true); + + jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/New16.gif"))); // NOI18N + jButton5.setFocusable(false); + jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(jButton5); + + jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/Close16.gif"))); // NOI18N + jButton6.setFocusable(false); + jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(jButton6); + jToolBar1.add(jSeparator1); + + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/Undo16.gif"))); // NOI18N + jButton1.setFocusable(false); + jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(jButton1); + + jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pcgen/gui/resource/Redo16.gif"))); // NOI18N + jButton2.setFocusable(false); + jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jToolBar1.add(jButton2); + + getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START); + + flippingSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + + jList1.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + public int getSize() { return strings.length; } + public Object getElementAt(int i) { return strings[i]; } + }); + jScrollPane1.setViewportView(jList1); + + spinningTabbedPane1.addTab("tab1", jScrollPane1); + + flippingSplitPane1.setLeftComponent(spinningTabbedPane1); + + jPanel1.setLayout(new java.awt.BorderLayout()); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + jPanel1.add(jComboBox1, java.awt.BorderLayout.PAGE_START); + jPanel1.add(jTreeTablePane1, java.awt.BorderLayout.CENTER); + + flippingSplitPane1.setRightComponent(jPanel1); + + getContentPane().add(flippingSplitPane1, java.awt.BorderLayout.CENTER); + + jMenu1.setText("File"); + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + jMenuBar1.add(jMenu2); + + setJMenuBar(jMenuBar1); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new LstEditor().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane1; + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton5; + private javax.swing.JButton jButton6; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JList jList1; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JToolBar.Separator jSeparator1; + private javax.swing.JToolBar jToolBar1; + private pcgen.gui.util.JTreeTablePane jTreeTablePane1; + private pcgen.gui.util.panes.SpinningTabbedPane spinningTabbedPane1; + // End of variables declaration//GEN-END:variables + +} Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.form 2008-05-01 16:35:31 UTC (rev 6161) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.form 2008-05-02 02:21:29 UTC (rev 6162) @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> - <Properties> - <Property name="defaultCloseOperation" type="int" value="3"/> - </Properties> - <SyntheticProperties> - <SyntheticProperty name="formSizePolicy" type="int" value="1"/> - </SyntheticProperties> - <AuxValues> - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-44,0,0,1,104"/> - </AuxValues> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> - <SubComponents> - <Component class="pcgen.gui.util.JTreeViewPane" name="jTreeViewPane1"> - <Properties> - <Property name="treeViewModel" type="pcgen.gui.util.treeview.TreeViewModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> - <Connection code="new DateModel()" type="code"/> - </Property> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="Center"/> - </Constraint> - </Constraints> - </Component> - </SubComponents> -</Form> Deleted: branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.java 2008-05-01 16:35:31 UTC (rev 6161) +++ branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.java 2008-05-02 02:21:29 UTC (rev 6162) @@ -1,231 +0,0 @@ -/* - * UtilitiesTester.java - * - * Created on February 14, 2008, 8:31 PM - */ -package pcgen.gui.proto.editor; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import pcgen.gui.util.table.DefaultSortableTableModel; -import pcgen.gui.util.table.SortableTableModel; -import pcgen.gui.util.treetable.DefaultSortableTreeTableModel; -import pcgen.gui.util.treeview.AbstractTreeViewModel; -import pcgen.gui.util.treeview.DataView; -import pcgen.gui.util.treeview.DataViewColumn; -import pcgen.gui.util.treeview.DefaultDataViewColumn; -import pcgen.gui.util.treeview.TreeView; -import pcgen.gui.util.treeview.TreeViewModel; -import pcgen.gui.util.treeview.TreeViewPath; - -/** - * - * @author Connor Petty <mis...@gm...> - */ -public class UtilitiesTester extends javax.swing.JFrame -{ - - /** Creates new form UtilitiesTester */ - public UtilitiesTester() - { - initComponents(); - } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents - private void initComponents() { - - jTreeViewPane1 = new pcgen.gui.util.JTreeViewPane(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - - jTreeViewPane1.setTreeViewModel(new DateModel()); - getContentPane().add(jTreeViewPane1, java.awt.BorderLayout.CENTER); - - pack(); - }// </editor-fold>//GEN-END:initComponents - /** - * @param args the command line arguments - */ - public static void main(String args[]) - { - java.awt.EventQueue.invokeLater(new Runnable() - { - - public void run() - { - new UtilitiesTester().setVisible(true); - } - - }); - } - - public SortableTableModel getTableModel() - { - return new DefaultSortableTableModel( - new Object[][]{ - {"sdfa", - "tegh", - "wvczs", - "yuue" - }, - {"ghjd", - "asdf", - "trtw", - "pin" - }, - {"hty", - "iohf", - "kjffs", - "sfgj" - }, - {"dfg", - "cbnc", - "mnvx", - "xssd" - } - }, - new String[]{ - "Title 1", - "Title 2", - "Title 3", - "Title 4" - }); - } - - public TreeViewModel<Date> getViewModel() - { - return new DateModel(); - } - private static Collection<Date> getData() - { - ArrayList<Date> list = new ArrayList<Date>(); - Calendar cal = Calendar.getInstance(); - cal.set(1543, 12, 9); - list.add(cal.getTime()); - cal.set(1453, 4, 23); - list.add(cal.getTime()); - cal.set(3734, 7, 18); - list.add(cal.getTime()); - cal.set(1682, 10, 2); - list.add(cal.getTime()); - cal.set(6432, 2, 2); - list.add(cal.getTime()); - cal.set(1543, 9, 12); - list.add(cal.getTime()); - cal.set(2345, 4, 12); - list.add(cal.getTime()); - return list; - } - // Variables declaration - do not modify//GEN-BEGIN:variables - private pcgen.gui.util.JTreeViewPane jTreeViewPane1; - // End of variables declaration//GEN-END:variables - private static class DateModel extends AbstractTreeViewModel<Date> - { - - private static List<? extends TreeView<Date>> views = Arrays.asList(DateTree.values()); - private static DataView<Date> data = new DateView(); - - public DateModel() - { - super(UtilitiesTester.getData()); - } - public List<? extends TreeView<Date>> getTreeViews() - { - return views; - } - - public int getStartingIndex() - { - return 0; - } - - public DataView<Date> getDataView() - { - return data; - } - - } - - private static class DateView implements DataView<Date> - { - - public List<?> getData(Date obj) - { - Calendar cal = Calendar.getInstance(); - cal.setTime(obj); - return Arrays.asList(cal.get(Calendar.MONTH), - cal.get(Calendar.WEEK_OF_MONTH), - cal.get(Calendar.DAY_OF_WEEK)); - } - - public List<? extends DataViewColumn> getDataColumns() - { - return Arrays.asList(new DefaultDataViewColumn("Month", - Integer.class), - new DefaultDataViewColumn("Week", Integer.class), - new DefaultDataViewColumn("Day of Week", - Integer.class)); - } - - } - - private static enum DateTree implements TreeView<Date> - { - - TIME("Time"), - DAY_TIME("Day/Time"), - MONTH_TIME("Month/Time"), - MONTH_WEEK_DAY_TIME("Month/Week/Day/Time"); - private String name; - - private DateTree(String name) - { - this.name = name; - } - - public String getViewName() - { - return name; - } - - public List<TreeViewPath<Date>> getPaths(Date pobj) - { - Calendar cal = Calendar.getInstance(); - cal.setTime(pobj); - switch (this) - { - case TIME: - return Collections.singletonList(new TreeViewPath<Date>(pobj)); - case DAY_TIME: - return Collections.singletonList(new TreeViewPath<Date>(pobj, - "" + - cal.get(Calendar.DAY_OF_MONTH))); - case MONTH_TIME: - return Collections.singletonList(new TreeViewPath<Date>(pobj, - "" + - cal.get(Calendar.MONTH))); - case MONTH_WEEK_DAY_TIME: - return Collections.singletonList(new TreeViewPath<Date>(pobj, - "" + - cal.get(Calendar.MONTH), - "" + - cal.get(Calendar.WEEK_OF_MONTH), - "" + - cal.get(Calendar.DAY_OF_MONTH))); - default: - return null; - } - } - - } -} Copied: branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.form (from rev 6161, branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.form) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.form (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.form 2008-05-02 02:21:29 UTC (rev 6162) @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-44,0,0,1,104"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="pcgen.gui.util.JTreeViewPane" name="jTreeViewPane1"> + <Properties> + <Property name="treeViewModel" type="pcgen.gui.util.treeview.TreeViewModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new DateModel()" type="code"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> +</Form> Copied: branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java (from rev 6161, branches/cdomui/code/src/java/pcgen/gui/proto/editor/UtilitiesTester.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java 2008-05-02 02:21:29 UTC (rev 6162) @@ -0,0 +1,231 @@ +/* + * UtilitiesTester.java + * + * Created on February 14, 2008, 8:31 PM + */ +package pcgen.gui.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import pcgen.gui.util.table.DefaultSortableTableModel; +import pcgen.gui.util.table.SortableTableModel; +import pcgen.gui.util.treetable.DefaultSortableTreeTableModel; +import pcgen.gui.util.treeview.AbstractTreeViewModel; +import pcgen.gui.util.treeview.DataView; +import pcgen.gui.util.treeview.DataViewColumn; +import pcgen.gui.util.treeview.DefaultDataViewColumn; +import pcgen.gui.util.treeview.TreeView; +import pcgen.gui.util.treeview.TreeViewModel; +import pcgen.gui.util.treeview.TreeViewPath; + +/** + * + * @author Connor Petty <mis...@gm...> + */ +public class UtilitiesTester extends javax.swing.JFrame +{ + + /** Creates new form UtilitiesTester */ + public UtilitiesTester() + { + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jTreeViewPane1 = new pcgen.gui.util.JTreeViewPane(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jTreeViewPane1.setTreeViewModel(new DateModel()); + getContentPane().add(jTreeViewPane1, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + /** + * @param args the command line arguments + */ + public static void main(String args[]) + { + java.awt.EventQueue.invokeLater(new Runnable() + { + + public void run() + { + new UtilitiesTester().setVisible(true); + } + + }); + } + + public SortableTableModel getTableModel() + { + return new DefaultSortableTableModel( + new Object[][]{ + {"sdfa", + "tegh", + "wvczs", + "yuue" + }, + {"ghjd", + "asdf", + "trtw", + "pin" + }, + {"hty", + "iohf", + "kjffs", + "sfgj" + }, + {"dfg", + "cbnc", + "mnvx", + "xssd" + } + }, + new String[]{ + "Title 1", + "Title 2", + "Title 3", + "Title 4" + }); + } + + public TreeViewModel<Date> getViewModel() + { + return new DateModel(); + } + private static Collection<Date> getData() + { + ArrayList<Date> list = new ArrayList<Date>(); + Calendar cal = Calendar.getInstance(); + cal.set(1543, 12, 9); + list.add(cal.getTime()); + cal.set(1453, 4, 23); + list.add(cal.getTime()); + cal.set(3734, 7, 18); + list.add(cal.getTime()); + cal.set(1682, 10, 2); + list.add(cal.getTime()); + cal.set(6432, 2, 2); + list.add(cal.getTime()); + cal.set(1543, 9, 12); + list.add(cal.getTime()); + cal.set(2345, 4, 12); + list.add(cal.getTime()); + return list; + } + // Variables declaration - do not modify//GEN-BEGIN:variables + private pcgen.gui.util.JTreeViewPane jTreeViewPane1; + // End of variables declaration//GEN-END:variables + private static class DateModel extends AbstractTreeViewModel<Date> + { + + private static List<? extends TreeView<Date>> views = Arrays.asList(DateTree.values()); + private static DataView<Date> data = new DateView(); + + public DateModel() + { + super(UtilitiesTester.getData()); + } + public List<? extends TreeView<Date>> getTreeViews() + { + return views; + } + + public int getStartingIndex() + { + return 0; + } + + public DataView<Date> getDataView() + { + return data; + } + + } + + private static class DateView implements DataView<Date> + { + + public List<?> getData(Date obj) + { + Calendar cal = Calendar.getInstance(); + cal.setTime(obj); + return Arrays.asList(cal.get(Calendar.MONTH), + cal.get(Calendar.WEEK_OF_MONTH), + cal.get(Calendar.DAY_OF_WEEK)); + } + + public List<? extends DataViewColumn> getDataColumns() + { + return Arrays.asList(new DefaultDataViewColumn("Month", + Integer.class), + new DefaultDataViewColumn("Week", Integer.class), + new DefaultDataViewColumn("Day of Week", + Integer.class)); + } + + } + + private static enum DateTree implements TreeView<Date> + { + + TIME("Time"), + DAY_TIME("Day/Time"), + MONTH_TIME("Month/Time"), + MONTH_WEEK_DAY_TIME("Month/Week/Day/Time"); + private String name; + + private DateTree(String name) + { + this.name = name; + } + + public String getViewName() + { + return name; + } + + public List<TreeViewPath<Date>> getPaths(Date pobj) + { + Calendar cal = Calendar.getInstance(); + cal.setTime(pobj); + switch (this) + { + case TIME: + return Collections.singletonList(new TreeViewPath<Date>(pobj)); + case DAY_TIME: + return Collections.singletonList(new TreeViewPath<Date>(pobj, + "" + + cal.get(Calendar.DAY_OF_MONTH))); + case MONTH_TIME: + return Collections.singletonList(new TreeViewPath<Date>(pobj, + "" + + cal.get(Calendar.MONTH))); + case MONTH_WEEK_DAY_TIME: + return Collections.singletonList(new TreeViewPath<Date>(pobj, + "" + + cal.get(Calendar.MONTH), + "" + + cal.get(Calendar.WEEK_OF_MONTH), + "" + + cal.get(Calendar.DAY_OF_MONTH))); + default: + return null; + } + } + + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-18 09:21:41
|
Revision: 6701 http://pcgen.svn.sourceforge.net/pcgen/?rev=6701&view=rev Author: cpmeister Date: 2008-06-18 02:21:49 -0700 (Wed, 18 Jun 2008) Log Message: ----------- Begin filter implementation Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/tools/ branches/cdomui/code/src/java/pcgen/gui/tools/FilterGroup.java branches/cdomui/code/src/java/pcgen/gui/tools/FilterListener.java branches/cdomui/code/src/java/pcgen/gui/tools/FilterPanel.java Added: branches/cdomui/code/src/java/pcgen/gui/tools/FilterGroup.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilterGroup.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tools/FilterGroup.java 2008-06-18 09:21:49 UTC (rev 6701) @@ -0,0 +1,30 @@ +/* + * FilterGroup.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 17, 2008, 11:42:12 PM + */ + +package pcgen.gui.tools; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class FilterGroup { + +} Added: branches/cdomui/code/src/java/pcgen/gui/tools/FilterListener.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilterListener.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tools/FilterListener.java 2008-06-18 09:21:49 UTC (rev 6701) @@ -0,0 +1,32 @@ +/* + * FilterListener.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 17, 2008, 5:51:49 PM + */ + +package pcgen.gui.tools; + +import java.util.EventListener; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public interface FilterListener extends EventListener{ + public void updateQFilter(String filter); +} Added: branches/cdomui/code/src/java/pcgen/gui/tools/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilterPanel.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tools/FilterPanel.java 2008-06-18 09:21:49 UTC (rev 6701) @@ -0,0 +1,142 @@ +/* + * FilterPanel.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 17, 2008, 11:46:31 PM + */ +package pcgen.gui.tools; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.AbstractAction; +import javax.swing.Icon; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.JToolBar; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import pcgen.gui.util.TextIcon; +import pcgen.util.PropertyFactory; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class FilterPanel extends JPanel +{ + + private static final String filter = PropertyFactory.getString("in_filter") + + ":"; + private static final String clear = PropertyFactory.getString("in_clear"); + private static final String advanced = PropertyFactory.getString("in_demAdv"); + private final JTextField textfield; + private final FilterListener listener; + + public FilterPanel(FilterListener listener) + { + this.textfield = new JTextField(); + this.listener = listener; + initComponents(); + } + + private void initComponents() + { + JToolBar toolbar = new JToolBar(); + + toolbar.setRollover(true); + toolbar.setFloatable(false); + + JButton button = new JButton(); + button.setFocusable(false); + + Icon icon = new TextIcon(button, filter); + button.setIcon(icon); + + icon = new TextIcon(button, clear); + button.setRolloverIcon(icon); + button.setPressedIcon(icon); + + button.addActionListener(new ActionListener() + { + + public void actionPerformed(ActionEvent e) + { + textfield.setText(""); + } + + }); + toolbar.add(button); + + textfield.getDocument().addDocumentListener( + new DocumentListener() + { + + public void insertUpdate(DocumentEvent e) + { + updateFilter(); + } + + public void removeUpdate(DocumentEvent e) + { + updateFilter(); + } + + public void changedUpdate(DocumentEvent e) + { + updateFilter(); + } + + }); + + toolbar.add(textfield); + + button = new JButton(new AdvancedAction()); + button.setFocusable(false); + toolbar.add(button); + + toolbar.addSeparator(); + } + + private void updateFilter() + { + String text = textfield.getText(); + if (text.length() == 0) + { + listener.updateQFilter(null); + } + else + { + listener.updateQFilter(text); + } + } + + private class AdvancedAction extends AbstractAction + { + + public AdvancedAction() + { + super(advanced); + } + + public void actionPerformed(ActionEvent e) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-18 22:47:48
|
Revision: 6712 http://pcgen.svn.sourceforge.net/pcgen/?rev=6712&view=rev Author: cpmeister Date: 2008-06-18 15:47:55 -0700 (Wed, 18 Jun 2008) Log Message: ----------- minor refactoring Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterListener.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/filter/ branches/cdomui/code/src/java/pcgen/gui/filter/Filter.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroup.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroupListener.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroup.java Copied: branches/cdomui/code/src/java/pcgen/gui/filter (from rev 6701, branches/cdomui/code/src/java/pcgen/gui/tools) Copied: branches/cdomui/code/src/java/pcgen/gui/filter/Filter.java (from rev 6711, branches/cdomui/code/src/java/pcgen/gui/tools/Filter.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/Filter.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/filter/Filter.java 2008-06-18 22:47:55 UTC (rev 6712) @@ -0,0 +1,30 @@ +/* + * Filter.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 18, 2008, 3:37:22 PM + */ + +package pcgen.gui.filter; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class Filter { + +} Deleted: branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroup.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilterGroup.java 2008-06-18 09:21:49 UTC (rev 6701) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroup.java 2008-06-18 22:47:55 UTC (rev 6712) @@ -1,30 +0,0 @@ -/* - * FilterGroup.java - * Copyright 2008 Connor Petty <cpm...@us...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Jun 17, 2008, 11:42:12 PM - */ - -package pcgen.gui.tools; - -/** - * - * @author Connor Petty <cpm...@us...> - */ -public class FilterGroup { - -} Copied: branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroup.java (from rev 6711, branches/cdomui/code/src/java/pcgen/gui/tools/FilterGroup.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroup.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroup.java 2008-06-18 22:47:55 UTC (rev 6712) @@ -0,0 +1,41 @@ +/* + * FilterGroup.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 17, 2008, 11:42:12 PM + */ + +package pcgen.gui.filter; + +import java.util.Collection; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class FilterGroup { + private Collection<Filter> filters; + public void addFilterGroupListener(FilterGroupListener listener) + { + + } + + public void removeFilterGroupListener(FilterGroupListener listener) + { + + } +} Copied: branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroupListener.java (from rev 6711, branches/cdomui/code/src/java/pcgen/gui/tools/FilterGroupListener.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroupListener.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterGroupListener.java 2008-06-18 22:47:55 UTC (rev 6712) @@ -0,0 +1,33 @@ +/* + * FilterGroupListener.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 18, 2008, 3:38:24 PM + */ + +package pcgen.gui.filter; + +import java.util.EventListener; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public interface FilterGroupListener extends EventListener { + public void filterAdded(Filter filter); + public void filterRemoved(Filter filter); +} Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterListener.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilterListener.java 2008-06-18 09:21:49 UTC (rev 6701) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterListener.java 2008-06-18 22:47:55 UTC (rev 6712) @@ -19,7 +19,7 @@ * Created on Jun 17, 2008, 5:51:49 PM */ -package pcgen.gui.tools; +package pcgen.gui.filter; import java.util.EventListener; Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilterPanel.java 2008-06-18 09:21:49 UTC (rev 6701) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-18 22:47:55 UTC (rev 6712) @@ -18,7 +18,7 @@ * * Created on Jun 17, 2008, 11:46:31 PM */ -package pcgen.gui.tools; +package pcgen.gui.filter; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-19 05:59:39
|
Revision: 6728 http://pcgen.svn.sourceforge.net/pcgen/?rev=6728&view=rev Author: cpmeister Date: 2008-06-18 22:59:48 -0700 (Wed, 18 Jun 2008) Log Message: ----------- minor refactoring Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/core/ branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java Added: branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java 2008-06-19 05:59:48 UTC (rev 6728) @@ -0,0 +1,32 @@ +/* + * UIContext.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 17, 2008, 3:52:41 PM + */ + +package pcgen.gui.core; + +import pcgen.gui.filter.FilterList; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public interface UIContext { + public FilterList getToggleFilters(Class<?> c); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-22 05:07:17
|
Revision: 6817 http://pcgen.svn.sourceforge.net/pcgen/?rev=6817&view=rev Author: cpmeister Date: 2008-06-21 21:51:24 -0700 (Sat, 21 Jun 2008) Log Message: ----------- type safety support Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterListEvent.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterListListener.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java Modified: branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java 2008-06-22 04:46:58 UTC (rev 6816) +++ branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java 2008-06-22 04:51:24 UTC (rev 6817) @@ -28,5 +28,5 @@ * @author Connor Petty <cpm...@us...> */ public interface UIContext { - public FilterList getToggleFilters(Class<?> c); + public <T> FilterList<T> getToggleFilters(Class<T> c); } Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java 2008-06-22 04:46:58 UTC (rev 6816) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java 2008-06-22 04:51:24 UTC (rev 6817) @@ -28,44 +28,45 @@ * * @author Connor Petty <cpm...@us...> */ -public class FilterList +public class FilterList<E> { - private final List<FilterListListener> listeners; - private List<NamedFilter> filters = null; + private final List<FilterListListener<E>> listeners; + private List<NamedFilter<? super E>> filters = null; public FilterList() { - this.listeners = new LinkedList<FilterListListener>(); + this.listeners = new LinkedList<FilterListListener<E>>(); this.filters = Collections.emptyList(); } - public void setFilters(List<NamedFilter> filters) + public void setFilters(List<NamedFilter<? super E>> filters) { - FilterListEvent event = new FilterListEvent(this, this.filters, filters); + FilterListEvent<E> event = new FilterListEvent<E>(this, this.filters, + filters); this.filters = filters; fireFiltersChanged(event); } - private void fireFiltersChanged(FilterListEvent event) + private void fireFiltersChanged(FilterListEvent<E> event) { - for (FilterListListener listener : listeners) + for (FilterListListener<E> listener : listeners) { listener.filtersChanged(event); } } - public void addFilterListListener(FilterListListener listener) + public void addFilterListListener(FilterListListener<E> listener) { listeners.add(listener); } - public void removeFilterListListener(FilterListListener listener) + public void removeFilterListListener(FilterListListener<E> listener) { listeners.remove(listener); } - public List<NamedFilter> getFilters() + public List<NamedFilter<? super E>> getFilters() { return filters; } Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterListEvent.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterListEvent.java 2008-06-22 04:46:58 UTC (rev 6816) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterListEvent.java 2008-06-22 04:51:24 UTC (rev 6817) @@ -27,12 +27,15 @@ * * @author Connor Petty <cpm...@us...> */ -public class FilterListEvent extends EventObject +public class FilterListEvent<E> extends EventObject { - private List<NamedFilter> oldFilters; - private List<NamedFilter> newFilters; - public FilterListEvent(FilterList source, List<NamedFilter> oldFilters, List<NamedFilter> newFilters) + private List<NamedFilter<? super E>> oldFilters; + private List<NamedFilter<? super E>> newFilters; + + public FilterListEvent(FilterList source, + List<NamedFilter<? super E>> oldFilters, + List<NamedFilter<? super E>> newFilters) { super(source); this.oldFilters = oldFilters; @@ -45,12 +48,14 @@ return (FilterList) super.getSource(); } - public List<NamedFilter> getOldFilters() + public List<NamedFilter<? super E>> getOldFilters() { return oldFilters; } - public List<NamedFilter> getNewFilters() + + public List<NamedFilter<? super E>> getNewFilters() { return newFilters; } + } Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterListListener.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterListListener.java 2008-06-22 04:46:58 UTC (rev 6816) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterListListener.java 2008-06-22 04:51:24 UTC (rev 6817) @@ -27,6 +27,6 @@ * * @author Connor Petty <cpm...@us...> */ -public interface FilterListListener extends EventListener{ - public void filtersChanged(FilterListEvent event); +public interface FilterListListener<E> extends EventListener{ + public void filtersChanged(FilterListEvent<E> event); } Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-22 04:46:58 UTC (rev 6816) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-22 04:51:24 UTC (rev 6817) @@ -22,6 +22,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import javax.swing.AbstractAction; @@ -41,91 +42,70 @@ * * @author Connor Petty <cpm...@us...> */ -public class FilterPanel extends JPanel +public class FilterPanel<E> extends JPanel { private static final String filterString = PropertyFactory.getString("in_filter") + ":"; private static final String clearString = PropertyFactory.getString("in_clear"); private static final String advancedString = PropertyFactory.getString("in_demAdv"); - private final FilterPanelListener listener; + private final List<Filter<? super E>> selectedFilters; + private final List<JToggleButton> filterbuttons; + private final FilterPanelListener<E> listener; private final JTextField textfield; - private List<JToggleButton> filterbuttons; - private FilterList filters; - public FilterPanel(UIContext context, Class<?> filterclass, - FilterPanelListener listener) + public FilterPanel(UIContext context, Class<E> filterclass, + FilterPanelListener<E> listener) { this.textfield = new JTextField(); this.listener = listener; initComponents(); - - this.filters = context.getToggleFilters(filterclass); + + FilterList<E> filters = context.getToggleFilters(filterclass); filters.addFilterListListener( - new FilterListListener() + new FilterListListener<E>() { - public void filtersChanged(FilterListEvent event) + public void filtersChanged(FilterListEvent<E> event) { setFilterButtons(event.getNewFilters()); } }); + this.selectedFilters = new ArrayList<Filter<? super E>>(); + this.filterbuttons = new LinkedList<JToggleButton>(); setFilterButtons(filters.getFilters()); } - private void setFilterButtons(List<NamedFilter> filters) + private void setFilterButtons(List<NamedFilter<? super E>> filters) { - List<NamedFilter> toggledfilters = new LinkedList<NamedFilter>(); - if (filterbuttons == null) + for (JToggleButton button : filterbuttons) { - filterbuttons = new LinkedList<JToggleButton>(); + remove(button); } - else - { - for (JToggleButton button : filterbuttons) - { - if (button.isSelected()) - { - toggledfilters.add(((FilterAction)button.getAction()).getFilter()); - } - remove(button); - } - filterbuttons.clear(); - } + filterbuttons.clear(); - for (NamedFilter filter : filters) + boolean updateFilters = selectedFilters.retainAll(filters); + + for (NamedFilter<? super E> filter : filters) { JToggleButton button = new JToggleButton(new FilterAction(filter)); - button.setSelected(toggledfilters.contains(filter)); + button.setSelected(selectedFilters.contains(filter)); filterbuttons.add(button); add(button); } - } - private class FilterAction extends AbstractAction - { - - private NamedFilter filter; - - public FilterAction(NamedFilter filter) + if (updateFilters) { - this.filter = filter; - putValue(NAME, filter.getName()); - putValue(SHORT_DESCRIPTION, filter.getShortDescription()); - putValue(LONG_DESCRIPTION, filter.getLongDescription()); + fireApplyFilter(); } + } - public NamedFilter getFilter() - { - return filter; - } - - public void actionPerformed(ActionEvent e) - { - throw new UnsupportedOperationException("Not supported yet."); - } - + private void fireApplyFilter() + { + String text = textfield.getText(); + boolean qFilter = text != null && !text.equals(""); + listener.applyFilter(new ObjectFilter(text, qFilter), qFilter); } private void initComponents() @@ -162,17 +142,17 @@ public void insertUpdate(DocumentEvent e) { - updateFilter(); + fireApplyFilter(); } public void removeUpdate(DocumentEvent e) { - updateFilter(); + fireApplyFilter(); } public void changedUpdate(DocumentEvent e) { - updateFilter(); + fireApplyFilter(); } }); @@ -188,19 +168,63 @@ add(toolbar); } - private void updateFilter() + private class ObjectFilter implements Filter<E> { - String text = textfield.getText(); - if (text.length() == 0) + + private final boolean qFilter; + private final String text; + + public ObjectFilter(String text, boolean qFilter) { - listener.filtersChanged(); + this.qFilter = qFilter; + this.text = text; } - else + + public boolean accept(E object) { - listener.filtersChanged(); + boolean accept = qFilter && text.equals(object.toString()); + if (accept) + { + for (Filter<? super E> filter : selectedFilters) + { + if (!filter.accept(object)) + { + accept = false; + break; + } + } + } + return accept; } + } + private class FilterAction extends AbstractAction + { + + private NamedFilter<? super E> filter; + + public FilterAction(NamedFilter<? super E> filter) + { + this.filter = filter; + putValue(NAME, filter.getName()); + putValue(SHORT_DESCRIPTION, filter.getShortDescription()); + putValue(LONG_DESCRIPTION, filter.getLongDescription()); + } + + public NamedFilter getFilter() + { + return filter; + } + + public void actionPerformed(ActionEvent e) + { + selectedFilters.add(filter); + fireApplyFilter(); + } + + } + private class AdvancedAction extends AbstractAction { Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java 2008-06-22 04:46:58 UTC (rev 6816) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java 2008-06-22 04:51:24 UTC (rev 6817) @@ -25,6 +25,6 @@ * * @author Connor Petty <cpm...@us...> */ -public interface FilterPanelListener extends FilterListListener{ - public void filtersChanged(); +public interface FilterPanelListener<E>{ + public void applyFilter(Filter<E> filter, boolean quicksearch); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-23 01:55:57
|
Revision: 6834 http://pcgen.svn.sourceforge.net/pcgen/?rev=6834&view=rev Author: cpmeister Date: 2008-06-22 18:56:03 -0700 (Sun, 22 Jun 2008) Log Message: ----------- UI update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 00:34:28 UTC (rev 6833) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 01:56:03 UTC (rev 6834) @@ -20,6 +20,11 @@ */ package pcgen.gui.filter; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -77,41 +82,11 @@ setFilterButtons(filters.getFilters()); } - private void setFilterButtons(List<NamedFilter<? super E>> filters) + private void initComponents() { - for (JToggleButton button : filterbuttons) - { - remove(button); - } - filterbuttons.clear(); + setLayout(new FilterLayout()); - boolean updateFilters = selectedFilters.retainAll(filters); - - for (NamedFilter<? super E> filter : filters) - { - JToggleButton button = new JToggleButton(new FilterAction(filter)); - button.setSelected(selectedFilters.contains(filter)); - filterbuttons.add(button); - add(button); - } - - if (updateFilters) - { - fireApplyFilter(); - } - } - - private void fireApplyFilter() - { - String text = textfield.getText(); - boolean qFilter = text != null && !text.equals(""); - listener.applyFilter(new ObjectFilter(text, qFilter), qFilter); - } - - private void initComponents() - { JToolBar toolbar = new JToolBar(); - toolbar.setRollover(true); toolbar.setFloatable(false); @@ -168,6 +143,37 @@ add(toolbar); } + private void setFilterButtons(List<NamedFilter<? super E>> filters) + { + for (JToggleButton button : filterbuttons) + { + remove(button); + } + filterbuttons.clear(); + + boolean updateFilters = selectedFilters.retainAll(filters); + + for (NamedFilter<? super E> filter : filters) + { + JToggleButton button = new JToggleButton(new FilterAction(filter)); + button.setSelected(selectedFilters.contains(filter)); + filterbuttons.add(button); + add(button); + } + + if (updateFilters) + { + fireApplyFilter(); + } + } + + private void fireApplyFilter() + { + String text = textfield.getText(); + boolean qFilter = text != null && !text.equals(""); + listener.applyFilter(new ObjectFilter(text, qFilter), qFilter); + } + private class ObjectFilter implements Filter<E> { @@ -182,7 +188,7 @@ public boolean accept(E object) { - boolean accept = qFilter && text.equals(object.toString()); + boolean accept = !qFilter || text.equals(object.toString()); if (accept) { for (Filter<? super E> filter : selectedFilters) @@ -207,19 +213,20 @@ public FilterAction(NamedFilter<? super E> filter) { this.filter = filter; - putValue(NAME, filter.getName()); putValue(SHORT_DESCRIPTION, filter.getShortDescription()); putValue(LONG_DESCRIPTION, filter.getLongDescription()); } - public NamedFilter getFilter() - { - return filter; - } - public void actionPerformed(ActionEvent e) { - selectedFilters.add(filter); + if (selectedFilters.contains(filter)) + { + selectedFilters.remove(filter); + } + else + { + selectedFilters.add(filter); + } fireApplyFilter(); } @@ -239,4 +246,104 @@ } } + + private static class FilterLayout extends FlowLayout + { + + public FilterLayout() + { + super(FlowLayout.LEFT); + } + + @Override + public Dimension preferredLayoutSize(Container target) + { + synchronized (target.getTreeLock()) + { + Dimension dim = new Dimension(0, 0); + int nmembers = target.getComponentCount(); + + Insets insets = target.getInsets(); + int maxwidth = target.getWidth() - (insets.left + insets.right + + getHgap() * 2); + int width = 0; + int height = 0; + int component = 0; + for (int i = 0; i < nmembers; i++, component++) + { + Component m = target.getComponent(i); + if (m.isVisible()) + { + Dimension d = m.getPreferredSize(); + if (component > 0) + { + if (width + d.width > maxwidth) + { + dim.width = Math.max(dim.width, width); + dim.height += height + getVgap(); + width = 0; + height = 0; + component = 0; + } + width += getHgap(); + } + height = Math.max(height, d.height); + width += d.width; + } + } + dim.width = Math.max(dim.width, width); + dim.height += height; + + dim.width += insets.left + insets.right + getHgap() * 2; + dim.height += insets.top + insets.bottom + getVgap() * 2; + return dim; + } + } + + @Override + public Dimension minimumLayoutSize(Container target) + { + synchronized (target.getTreeLock()) + { + Dimension dim = new Dimension(0, 0); + int nmembers = target.getComponentCount(); + + Insets insets = target.getInsets(); + int maxwidth = target.getWidth() - (insets.left + insets.right + + getHgap() * 2); + int width = 0; + int height = 0; + int component = 0; + for (int i = 0; i < nmembers; i++, component++) + { + Component m = target.getComponent(i); + if (m.isVisible()) + { + Dimension d = m.getMinimumSize(); + if (component > 0) + { + if (width + d.width > maxwidth) + { + dim.width = Math.max(dim.width, width); + dim.height += height + getVgap(); + width = 0; + height = 0; + component = 0; + } + width += getHgap(); + } + height = Math.max(height, d.height); + width += d.width; + } + } + dim.width = Math.max(dim.width, width); + dim.height += height; + + dim.width += insets.left + insets.right + getHgap() * 2; + dim.height += insets.top + insets.bottom + getVgap() * 2; + return dim; + } + } + + } } Added: branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java 2008-06-23 01:56:03 UTC (rev 6834) @@ -0,0 +1,91 @@ +/* + * FilteredTreeViewDisplay.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 22, 2008, 3:55:32 PM + */ +package pcgen.gui.tools; + +import java.util.List; +import javax.swing.JPanel; +import javax.swing.SpringLayout; +import pcgen.gui.core.UIContext; +import pcgen.gui.filter.FilterPanel; +import pcgen.gui.util.treeview.AbstractTreeViewModel; +import pcgen.gui.util.treeview.DataView; +import pcgen.gui.util.treeview.TreeView; +import pcgen.gui.util.treeview.TreeViewModel; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class FilteredTreeViewDisplay extends JPanel +{ + + private FilterPanel filterPanel; + + public FilteredTreeViewDisplay(UIContext context) + { + initComponents(); + + } + + private void initComponents() + { + SpringLayout layout = new SpringLayout(); + setLayout(layout); + } + + private <T> void setFilterPanel(UIContext context, Class<T> c) + { + + } + + private class TreeViewDisplay<E> extends AbstractTreeViewModel<E> + { + + private TreeViewModel<E> model; + + public TreeViewDisplay(TreeViewModel<E> model) + { + super(model.getData()); + this.model = model; + } + + public List<? extends TreeView<E>> getTreeViews() + { + return model.getTreeViews(); + } + + public int getDefaultTreeViewIndex() + { + return model.getDefaultTreeViewIndex(); + } + + public DataView<E> getDataView() + { + return model.getDataView(); + } + + public int getQuickSearchTreeViewIndex() + { + return model.getQuickSearchTreeViewIndex(); + } + + } +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-23 00:34:28 UTC (rev 6833) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-23 01:56:03 UTC (rev 6834) @@ -97,7 +97,7 @@ treeviewMenu = new JPopupMenu(); ButtonGroup group = new ButtonGroup(); List<? extends TreeView<T>> views = viewModel.getTreeViews(); - TreeView<T> startingView = views.get(viewModel.getStartingIndex()); + TreeView<T> startingView = views.get(viewModel.getDefaultTreeViewIndex()); for (TreeView<?> treeview : views) { JMenuItem item = new JRadioButtonMenuItem(new ChangeViewAction(treeview)); Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-23 00:34:28 UTC (rev 6833) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-23 01:56:03 UTC (rev 6834) @@ -22,8 +22,10 @@ List<? extends TreeView<E>> getTreeViews(); - int getStartingIndex(); + int getDefaultTreeViewIndex(); + int getQuickSearchTreeViewIndex(); + DataView<E> getDataView(); Collection<E> getData(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-23 04:11:29
|
Revision: 6844 http://pcgen.svn.sourceforge.net/pcgen/?rev=6844&view=rev Author: cpmeister Date: 2008-06-22 21:11:37 -0700 (Sun, 22 Jun 2008) Log Message: ----------- UI update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java 2008-06-23 03:28:40 UTC (rev 6843) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterList.java 2008-06-23 04:11:37 UTC (rev 6844) @@ -61,7 +61,7 @@ listeners.add(listener); } - public void removeFilterListListener(FilterListListener<E> listener) + public void removeFilterListListener(FilterListListener<?> listener) { listeners.remove(listener); } Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 03:28:40 UTC (rev 6843) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 04:11:37 UTC (rev 6844) @@ -47,39 +47,39 @@ * * @author Connor Petty <cpm...@us...> */ -public class FilterPanel<E> extends JPanel +public class FilterPanel extends JPanel { private static final String filterString = PropertyFactory.getString("in_filter") + ":"; private static final String clearString = PropertyFactory.getString("in_clear"); private static final String advancedString = PropertyFactory.getString("in_demAdv"); - private final List<Filter<? super E>> selectedFilters; - private final List<JToggleButton> filterbuttons; - private final FilterPanelListener<E> listener; private final JTextField textfield; + private final UIContext context; + private List<JToggleButton> filterbuttons; + private List<Filter> selectedFilters; + private FilterPanelListener panelListener; + private FilterListListener<?> listListener; + private Class<?> filterClass; - public FilterPanel(UIContext context, Class<E> filterclass, - FilterPanelListener<E> listener) + public FilterPanel(UIContext context) { + this(null, null); + } + + public <T> FilterPanel(UIContext context, Class<T> filterclass) + { + this(context, filterclass, null); + } + + public <T> FilterPanel(UIContext context, Class<T> filterClass, + FilterPanelListener listener) + { + this.context = context; this.textfield = new JTextField(); - this.listener = listener; + this.panelListener = listener; initComponents(); - - FilterList<E> filters = context.getToggleFilters(filterclass); - filters.addFilterListListener( - new FilterListListener<E>() - { - - public void filtersChanged(FilterListEvent<E> event) - { - setFilterButtons(event.getNewFilters()); - } - - }); - this.selectedFilters = new ArrayList<Filter<? super E>>(); - this.filterbuttons = new LinkedList<JToggleButton>(); - setFilterButtons(filters.getFilters()); + setFilterClass(filterClass); } private void initComponents() @@ -143,8 +143,40 @@ add(toolbar); } - private void setFilterButtons(List<NamedFilter<? super E>> filters) + public <T> void setFilterClass(Class<T> filterClass) { + if (filterClass != null && !filterClass.equals(this.filterClass)) + { + if (this.filterClass != null) + { + context.getToggleFilters(this.filterClass).removeFilterListListener(listListener); + } + this.filterClass = filterClass; + FilterList<T> filters = context.getToggleFilters(filterClass); + FilterListListener<T> listener = new FilterListListener<T>() + { + + public void filtersChanged(FilterListEvent<T> event) + { + setFilterButtons(event.getNewFilters()); + } + + }; + filters.addFilterListListener(listener); + listListener = listener; + this.selectedFilters = new ArrayList<Filter>(); + this.filterbuttons = new LinkedList<JToggleButton>(); + setFilterButtons(filters.getFilters()); + } + } + + public void setFilterPanelListener(FilterPanelListener listener) + { + this.panelListener = listener; + } + + private <T> void setFilterButtons(List<NamedFilter<? super T>> filters) + { for (JToggleButton button : filterbuttons) { remove(button); @@ -153,7 +185,7 @@ boolean updateFilters = selectedFilters.retainAll(filters); - for (NamedFilter<? super E> filter : filters) + for (NamedFilter<? super T> filter : filters) { JToggleButton button = new JToggleButton(new FilterAction(filter)); button.setSelected(selectedFilters.contains(filter)); @@ -171,10 +203,13 @@ { String text = textfield.getText(); boolean qFilter = text != null && !text.equals(""); - listener.applyFilter(new ObjectFilter(text, qFilter), qFilter); + if (panelListener != null) + { + panelListener.applyFilter(new ObjectFilter(text, qFilter), qFilter); + } } - private class ObjectFilter implements Filter<E> + private class ObjectFilter implements Filter { private final boolean qFilter; @@ -186,12 +221,13 @@ this.text = text; } - public boolean accept(E object) + @SuppressWarnings("unchecked") + public boolean accept(Object object) { boolean accept = !qFilter || text.equals(object.toString()); if (accept) { - for (Filter<? super E> filter : selectedFilters) + for (Filter filter : selectedFilters) { if (!filter.accept(object)) { @@ -208,9 +244,9 @@ private class FilterAction extends AbstractAction { - private NamedFilter<? super E> filter; + private NamedFilter<?> filter; - public FilterAction(NamedFilter<? super E> filter) + public FilterAction(NamedFilter<?> filter) { this.filter = filter; putValue(SHORT_DESCRIPTION, filter.getShortDescription()); Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java 2008-06-23 03:28:40 UTC (rev 6843) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanelListener.java 2008-06-23 04:11:37 UTC (rev 6844) @@ -25,6 +25,6 @@ * * @author Connor Petty <cpm...@us...> */ -public interface FilterPanelListener<E>{ - public void applyFilter(Filter<E> filter, boolean quicksearch); +public interface FilterPanelListener{ + public void applyFilter(Filter filter, boolean quicksearch); } Modified: branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java 2008-06-23 03:28:40 UTC (rev 6843) +++ branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java 2008-06-23 04:11:37 UTC (rev 6844) @@ -20,11 +20,14 @@ */ package pcgen.gui.tools; +import java.awt.BorderLayout; import java.util.List; import javax.swing.JPanel; -import javax.swing.SpringLayout; import pcgen.gui.core.UIContext; +import pcgen.gui.filter.Filter; import pcgen.gui.filter.FilterPanel; +import pcgen.gui.filter.FilterPanelListener; +import pcgen.gui.util.JTreeViewPane; import pcgen.gui.util.treeview.AbstractTreeViewModel; import pcgen.gui.util.treeview.DataView; import pcgen.gui.util.treeview.TreeView; @@ -37,26 +40,39 @@ public class FilteredTreeViewDisplay extends JPanel { + private final UIContext context; private FilterPanel filterPanel; + private JTreeViewPane treeViewPane; public FilteredTreeViewDisplay(UIContext context) { + this.context = context; initComponents(); - } private void initComponents() { - SpringLayout layout = new SpringLayout(); - setLayout(layout); + setLayout(new BorderLayout()); + + filterPanel = new FilterPanel(context); + add(filterPanel, BorderLayout.PAGE_START); + + treeViewPane = new JTreeViewPane(); + add(treeViewPane, BorderLayout.CENTER); } - private <T> void setFilterPanel(UIContext context, Class<T> c) + public <T> void setTreeViewModel(Class<T> filterClass, + TreeViewModel<T> model) { + filterPanel.setFilterClass(filterClass); + TreeViewDisplay<T> displayModel = new TreeViewDisplay<T>(model); + treeViewPane.setTreeViewModel(displayModel); + filterPanel.setFilterPanelListener(displayModel); } - + private class TreeViewDisplay<E> extends AbstractTreeViewModel<E> + implements FilterPanelListener { private TreeViewModel<E> model; @@ -87,5 +103,10 @@ return model.getQuickSearchTreeViewIndex(); } + public void applyFilter(Filter filter, boolean quicksearch) + { + throw new UnsupportedOperationException("Not supported yet."); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-23 08:01:03
|
Revision: 6845 http://pcgen.svn.sourceforge.net/pcgen/?rev=6845&view=rev Author: cpmeister Date: 2008-06-23 01:01:12 -0700 (Mon, 23 Jun 2008) Log Message: ----------- UI update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 04:11:37 UTC (rev 6844) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 08:01:12 UTC (rev 6845) @@ -64,7 +64,7 @@ public FilterPanel(UIContext context) { - this(null, null); + this(context, null, null); } public <T> FilterPanel(UIContext context, Class<T> filterclass) Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-23 04:11:37 UTC (rev 6844) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-23 08:01:12 UTC (rev 6845) @@ -23,6 +23,7 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; +import java.util.Collections; import java.util.List; import javax.swing.AbstractAction; import javax.swing.ButtonGroup; @@ -37,6 +38,7 @@ import pcgen.gui.util.table.SortableTableModel; import pcgen.gui.util.treeview.TreeView; import pcgen.gui.util.treeview.TreeViewModel; +import pcgen.gui.util.treeview.TreeViewPath; import pcgen.gui.util.treeview.TreeViewTableModel; /** @@ -46,10 +48,27 @@ public class JTreeViewPane extends JTablePane { + private static final TreeView searchView = new TreeView() + { + + public String getViewName() + { + return "Search"; + } + + @SuppressWarnings("unchecked") + public List getPaths(Object pobj) + { + return Collections.singletonList(new TreeViewPath(pobj)); + } + + }; private TreeViewModelListener listener; private TreeViewTableModel<?> treetableModel; private TreeViewModel<?> viewModel; private JPopupMenu treeviewMenu; + private TreeView tempView; + private boolean searchMode = false; public JTreeViewPane() { @@ -110,6 +129,38 @@ getTable().setTreeTableModel(model); } + @SuppressWarnings("unchecked") + public void setQuickSearchMode(boolean searchMode) + { + if (this.searchMode != searchMode) + { + this.searchMode = searchMode; + if (searchMode) + { + tempView = treetableModel.getSelectedTreeView(); + setTreeView(searchView); + } + else + { + setTreeView(tempView); + } + } + } + + @SuppressWarnings("unchecked") + private void setTreeView(TreeView view) + { + //make sure that the original dynamictableModel is not changed + JTreeTable table = getTable(); + TableColumnModel old = table.getColumnModel(); + table.setColumnModel(new DefaultTableColumnModel()); + TableColumn viewColumn = old.getColumn(old.getColumnIndex(treetableModel.getSelectedTreeView().getViewName())); + treetableModel.setSelectedTreeView(view); + viewColumn.setHeaderValue(view.getViewName()); + table.setColumnModel(old); + table.sortModel(); + } + private class JTreeViewHeader extends JTableSortingHeader { @@ -144,7 +195,7 @@ private void maybeShowPopup(MouseEvent e) { - if (e.isPopupTrigger() && getTrackedColumn().getHeaderValue() == + if (!searchMode && e.isPopupTrigger() && getTrackedColumn().getHeaderValue() == treetableModel.getSelectedTreeView().getViewName()) { TableColumnModel columnmodel = getColumnModel(); @@ -158,7 +209,6 @@ } - @SuppressWarnings("unchecked") private class ChangeViewAction extends AbstractAction { @@ -172,15 +222,7 @@ public void actionPerformed(ActionEvent e) { - //make sure that the original dynamictableModel is not changed - JTreeTable table = getTable(); - TableColumnModel old = table.getColumnModel(); - table.setColumnModel(new DefaultTableColumnModel()); - TableColumn viewColumn = old.getColumn(old.getColumnIndex(treetableModel.getSelectedTreeView().getViewName())); - treetableModel.setSelectedTreeView(view); - viewColumn.setHeaderValue(view.getViewName()); - table.setColumnModel(old); - table.sortModel(); + setTreeView(view); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-23 23:58:42
|
Revision: 6863 http://pcgen.svn.sourceforge.net/pcgen/?rev=6863&view=rev Author: cpmeister Date: 2008-06-23 16:58:49 -0700 (Mon, 23 Jun 2008) Log Message: ----------- UI update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java branches/cdomui/code/src/java/pcgen/gui/util/SwingWorker.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 23:49:14 UTC (rev 6862) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -199,13 +199,19 @@ } } - private void fireApplyFilter() + public Filter getFilter() { String text = textfield.getText(); boolean qFilter = text != null && !text.equals(""); + return new ObjectFilter(text, qFilter); + } + + private void fireApplyFilter() + { if (panelListener != null) { - panelListener.applyFilter(new ObjectFilter(text, qFilter), qFilter); + ObjectFilter filter = (ObjectFilter) getFilter(); + panelListener.applyFilter(filter, filter.isQuickSearch()); } } @@ -221,6 +227,11 @@ this.text = text; } + public boolean isQuickSearch() + { + return qFilter; + } + @SuppressWarnings("unchecked") public boolean accept(Object object) { @@ -249,6 +260,7 @@ public FilterAction(NamedFilter<?> filter) { this.filter = filter; + putValue(NAME, filter.getName()); putValue(SHORT_DESCRIPTION, filter.getShortDescription()); putValue(LONG_DESCRIPTION, filter.getLongDescription()); } Modified: branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java 2008-06-23 23:49:14 UTC (rev 6862) +++ branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -21,6 +21,8 @@ package pcgen.gui.tools; import java.awt.BorderLayout; +import java.util.ArrayList; +import java.util.Collection; import java.util.List; import javax.swing.JPanel; import pcgen.gui.core.UIContext; @@ -28,10 +30,10 @@ import pcgen.gui.filter.FilterPanel; import pcgen.gui.filter.FilterPanelListener; import pcgen.gui.util.JTreeViewPane; -import pcgen.gui.util.treeview.AbstractTreeViewModel; -import pcgen.gui.util.treeview.DataView; -import pcgen.gui.util.treeview.TreeView; +import pcgen.gui.util.SwingWorker; +import pcgen.gui.util.event.TreeViewModelEvent; import pcgen.gui.util.treeview.TreeViewModel; +import pcgen.gui.util.treeview.TreeViewModelWrapper; /** * @@ -40,18 +42,11 @@ public class FilteredTreeViewDisplay extends JPanel { - private final UIContext context; private FilterPanel filterPanel; private JTreeViewPane treeViewPane; public FilteredTreeViewDisplay(UIContext context) { - this.context = context; - initComponents(); - } - - private void initComponents() - { setLayout(new BorderLayout()); filterPanel = new FilterPanel(context); @@ -61,52 +56,86 @@ add(treeViewPane, BorderLayout.CENTER); } + public JTreeViewPane getTreeViewPane() + { + return treeViewPane; + } + public <T> void setTreeViewModel(Class<T> filterClass, TreeViewModel<T> model) { filterPanel.setFilterClass(filterClass); - + TreeViewDisplay<T> displayModel = new TreeViewDisplay<T>(model); treeViewPane.setTreeViewModel(displayModel); filterPanel.setFilterPanelListener(displayModel); } - private class TreeViewDisplay<E> extends AbstractTreeViewModel<E> + private class TreeViewDisplay<E> extends TreeViewModelWrapper<E> implements FilterPanelListener { - private TreeViewModel<E> model; + private Filter oldfilter = null; public TreeViewDisplay(TreeViewModel<E> model) { - super(model.getData()); - this.model = model; + super(model); } - public List<? extends TreeView<E>> getTreeViews() + @SuppressWarnings("unchecked") + public void applyFilter(Filter filter, boolean quicksearch) { - return model.getTreeViews(); + new FilterUpdater(getModel().getData(), filter, quicksearch).start(); } - public int getDefaultTreeViewIndex() + @Override + public void dataChanged(TreeViewModelEvent<E> event) { - return model.getDefaultTreeViewIndex(); + if (oldfilter != null) + { + new FilterUpdater(event.getNewData(), oldfilter, + treeViewPane.getQuickSearchMode()).start(); + } } - public DataView<E> getDataView() + private class FilterUpdater extends SwingWorker<List<E>> { - return model.getDataView(); - } - public int getQuickSearchTreeViewIndex() - { - return model.getQuickSearchTreeViewIndex(); - } + private Collection<E> modelData; + private boolean quicksearch; + private Filter filter; - public void applyFilter(Filter filter, boolean quicksearch) - { - throw new UnsupportedOperationException("Not supported yet."); + public FilterUpdater(Collection<E> modelData, Filter filter, + boolean quicksearch) + { + this.modelData = modelData; + this.filter = filter; + this.quicksearch = quicksearch; + } + + @Override + @SuppressWarnings("unchecked") + public List<E> construct() + { + List<E> data = new ArrayList<E>(); + for (E element : modelData) + { + if (filter.accept(element)) + { + data.add(element); + } + } + return data; + } + + @Override + public void finished() + { + oldfilter = filter; + treeViewPane.setQuickSearchMode(quicksearch); + setData(getValue()); + } + } - } } Added: branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -0,0 +1,138 @@ +/* + * TreeViewSelectionPane.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 23, 2008, 11:52:27 AM + */ +package pcgen.gui.tools; + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import javax.swing.JComponent; +import javax.swing.JSplitPane; +import javax.swing.TransferHandler; +import pcgen.gui.core.UIContext; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class TreeViewSelectionPane extends JSplitPane +{ + + private FilteredTreeViewDisplay availableTreeView; + private FilteredTreeViewDisplay selectedTreeView; + + public TreeViewSelectionPane(UIContext context) + { + super(JSplitPane.VERTICAL_SPLIT, true); + availableTreeView = new FilteredTreeViewDisplay(context); + selectedTreeView = new FilteredTreeViewDisplay(context); + initComponents(); + } + + private void initComponents() + { + setTopComponent(selectedTreeView); + setBottomComponent(availableTreeView); + } + + private class ElementTransferHandler extends TransferHandler + { + + private Class<?> elementClass; + + public ElementTransferHandler(Class<?> elementClass) + { + this.elementClass = elementClass; + } + + @Override + public int getSourceActions(JComponent c) + { + return MOVE; + } + + @Override + protected Transferable createTransferable(JComponent c) + { + FilteredTreeViewDisplay view = (FilteredTreeViewDisplay) c; + List<?> data = view.getTreeViewPane().getSelectedData(); + Iterator<?> it = data.iterator(); + while (it.hasNext()) + { + if (!elementClass.isInstance(it.next())) + { + it.remove(); + } + } + return new ElementSelection(elementClass, data); + } + + @Override + protected void exportDone(JComponent source, Transferable data, + int action) + { + + } + + } + + private static class ElementSelection implements Transferable + { + + private final DataFlavor dataFlavor; + private final List<?> data; + + public ElementSelection(Class<?> elementClass, List<?> data) + { + String type = DataFlavor.javaJVMLocalObjectMimeType + ";class=" + + elementClass.getName(); + this.dataFlavor = new DataFlavor(type, null); + this.data = data; + } + + public DataFlavor[] getTransferDataFlavors() + { + return new DataFlavor[]{dataFlavor}; + } + + public boolean isDataFlavorSupported(DataFlavor flavor) + { + return dataFlavor.match(flavor); + } + + public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException + { + if (!isDataFlavorSupported(flavor)) + { + throw new UnsupportedFlavorException(flavor); + } + return data; + } + + public List<?> getData() + { + return data; + } + + } +} Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-06-23 23:49:14 UTC (rev 6862) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -31,11 +31,9 @@ import java.util.Vector; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; import pcgen.gui.util.table.DefaultSortableTableModel; -import pcgen.gui.util.table.DynamicTableColumnModel; import pcgen.gui.util.table.SortableTableModel; import pcgen.util.Comparators; Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-23 23:49:14 UTC (rev 6862) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -23,6 +23,7 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.swing.AbstractAction; @@ -33,6 +34,8 @@ import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreePath; import pcgen.gui.util.event.TreeViewModelEvent; import pcgen.gui.util.event.TreeViewModelListener; import pcgen.gui.util.table.SortableTableModel; @@ -91,9 +94,21 @@ @Override public void setModel(SortableTableModel model) { - //TODO: log something + throw new UnsupportedOperationException(); } + public List<Object> getSelectedData() + { + TreePath[] paths = getTable().getTree().getSelectionPaths(); + List<Object> data = new ArrayList<Object>(); + for (TreePath path : paths) + { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); + data.add(node.getUserObject()); + } + return data; + } + @SuppressWarnings("unchecked") public <T> void setTreeViewModel(TreeViewModel<T> viewModel) { @@ -129,6 +144,11 @@ getTable().setTreeTableModel(model); } + public boolean getQuickSearchMode() + { + return searchMode; + } + @SuppressWarnings("unchecked") public void setQuickSearchMode(boolean searchMode) { Modified: branches/cdomui/code/src/java/pcgen/gui/util/SwingWorker.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SwingWorker.java 2008-06-23 23:49:14 UTC (rev 6862) +++ branches/cdomui/code/src/java/pcgen/gui/util/SwingWorker.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -14,9 +14,9 @@ * You must now invoke start() on the SwingWorker after * creating it. */ -public abstract class SwingWorker +public abstract class SwingWorker<T> { - private Object value; // see getValue(), setValue() + private T value; // see getValue(), setValue() /** * Class to maintain reference to current worker thread @@ -49,7 +49,7 @@ * hasn't been constructed yet * @return value */ - protected synchronized Object getValue() + protected synchronized T getValue() { return value; } @@ -58,7 +58,7 @@ * Set the value produced by worker thread * @param x */ - private synchronized void setValue(Object x) + private synchronized void setValue(T x) { value = x; } @@ -67,7 +67,7 @@ * Compute the value to be returned by the <code>get</code> method * @return Object */ - public abstract Object construct(); + public abstract T construct(); /** * Called on the event dispatching thread (not on the worker thread) @@ -100,7 +100,7 @@ * * @return the value created by the <code>construct</code> method */ - public Object get() + public T get() { while (true) { Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java 2008-06-23 23:49:14 UTC (rev 6862) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -21,6 +21,7 @@ package pcgen.gui.util.treeview; import java.util.Collection; +import java.util.Collections; import javax.swing.event.EventListenerList; import pcgen.gui.util.event.TreeViewModelEvent; import pcgen.gui.util.event.TreeViewModelListener; @@ -32,6 +33,11 @@ public abstract class AbstractTreeViewModel<E> implements TreeViewModel<E> { + protected AbstractTreeViewModel() + { + this(null); + } + protected AbstractTreeViewModel(Collection<E> data) { this.data = data; @@ -51,7 +57,8 @@ } @SuppressWarnings("unchecked") - protected final void fireDataChanged(Collection<E> oldData, Collection<E> newData) + protected final void fireDataChanged(Collection<E> oldData, + Collection<E> newData) { TreeViewModelEvent<E> event = null; // Guaranteed to return a non-null array @@ -74,7 +81,14 @@ public final Collection<E> getData() { - return data; + if (data == null) + { + return Collections.emptySet(); + } + else + { + return data; + } } protected final void setData(Collection<E> data) Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-23 23:49:14 UTC (rev 6862) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -24,8 +24,6 @@ int getDefaultTreeViewIndex(); - int getQuickSearchTreeViewIndex(); - DataView<E> getDataView(); Collection<E> getData(); Added: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java 2008-06-23 23:58:49 UTC (rev 6863) @@ -0,0 +1,78 @@ +/* + * TreeViewModelWrapper.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 23, 2008, 3:53:14 PM + */ +package pcgen.gui.util.treeview; + +import java.util.List; +import pcgen.gui.util.event.TreeViewModelEvent; +import pcgen.gui.util.event.TreeViewModelListener; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class TreeViewModelWrapper<E> extends AbstractTreeViewModel<E> + implements TreeViewModelListener<E> +{ + + private TreeViewModel<E> model; + + public TreeViewModelWrapper(TreeViewModel<E> model) + { + setModel(model); + } + + public TreeViewModel<E> getModel() + { + return model; + } + + public void setModel(TreeViewModel<E> model) + { + if (this.model != null) + { + this.model.removeTreeViewModelListener(this); + } + this.model = model; + model.addTreeViewModelListener(this); + setData(model.getData()); + } + + public List<? extends TreeView<E>> getTreeViews() + { + return model.getTreeViews(); + } + + public int getDefaultTreeViewIndex() + { + return model.getDefaultTreeViewIndex(); + } + + public DataView<E> getDataView() + { + return model.getDataView(); + } + + public void dataChanged(TreeViewModelEvent<E> event) + { + setData(event.getNewData()); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-24 02:18:32
|
Revision: 6874 http://pcgen.svn.sourceforge.net/pcgen/?rev=6874&view=rev Author: cpmeister Date: 2008-06-23 19:18:41 -0700 (Mon, 23 Jun 2008) Log Message: ----------- UI update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java Modified: branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-24 01:53:32 UTC (rev 6873) +++ branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-24 02:18:41 UTC (rev 6874) @@ -24,12 +24,18 @@ import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; import javax.swing.JComponent; import javax.swing.JSplitPane; import javax.swing.TransferHandler; import pcgen.gui.core.UIContext; +import pcgen.gui.util.event.TreeViewModelEvent; +import pcgen.gui.util.event.TreeViewModelListener; +import pcgen.gui.util.treeview.TreeViewModel; +import pcgen.gui.util.treeview.TreeViewModelWrapper; /** * @@ -38,23 +44,101 @@ public class TreeViewSelectionPane extends JSplitPane { - private FilteredTreeViewDisplay availableTreeView; - private FilteredTreeViewDisplay selectedTreeView; - + private FilteredTreeViewDisplay availableView; + private FilteredTreeViewDisplay selectedView; + private ElementTreeViewModel<?> availableTreeView; + private ElementTreeViewModel<?> selectedTreeView; + private TreeViewModel<?> masterTreeView; + private TreeViewModelListener<?> masterTreeViewListener; + //private Collection<?> availableElements; public TreeViewSelectionPane(UIContext context) { super(JSplitPane.VERTICAL_SPLIT, true); - availableTreeView = new FilteredTreeViewDisplay(context); - selectedTreeView = new FilteredTreeViewDisplay(context); - initComponents(); + availableView = new FilteredTreeViewDisplay(context); + selectedView = new FilteredTreeViewDisplay(context); + + setTopComponent(selectedView); + setBottomComponent(availableView); } - private void initComponents() + public <T> void setSelectionModel(Class<T> elementClass, + TreeViewModel<T> masterModel, + Collection<T> selectedData) { - setTopComponent(selectedTreeView); - setBottomComponent(availableTreeView); + setTreeViewModels(masterModel, selectedData); + } + private <T> void setTreeViewModels(TreeViewModel<T> masterModel, + final Collection<T> selectedData) + { + List<T> availableElements = new ArrayList<T>(masterModel.getData()); + availableElements.removeAll(selectedData); + + final ElementTreeViewModel<T> availableModel = new ElementTreeViewModel<T>(masterModel, + availableElements); + final ElementTreeViewModel<T> selectedModel = new ElementTreeViewModel<T>(masterModel, + selectedData); + if (masterTreeView != null) + { + masterTreeView.removeTreeViewModelListener(masterTreeViewListener); + } + masterTreeView = masterModel; + + TreeViewModelListener<T> listener = new TreeViewModelListener<T>() + { + + public void dataChanged(TreeViewModelEvent<T> event) + { + setModelData(availableModel, selectedModel, + event.getNewData(), selectedModel.getData()); + } + + }; + masterTreeViewListener = listener; + masterModel.addTreeViewModelListener(listener); + + availableTreeView = availableModel; + selectedTreeView = selectedModel; + } + + private <T> void setModelData(ElementTreeViewModel<T> availableModel, + ElementTreeViewModel<T> selectedModel, + Collection<T> allData, + Collection<T> selectedData) + { + Collection<T> availableElements = new ArrayList<T>(allData); + Collection<T> selectedElements = new ArrayList<T>(selectedData); + selectedElements.retainAll(availableElements); + availableElements.removeAll(selectedElements); + + availableModel.setData(availableElements); + selectedModel.setData(availableElements); + } + + private class ElementTreeViewModel<E> extends TreeViewModelWrapper<E> + { + + public ElementTreeViewModel(TreeViewModel<E> model, Collection<E> data) + { + super(model); + setData(data); + } + + @Override + public void setModel(TreeViewModel<E> model) + { + this.model = model; + } + + @Override + public void setData(Collection<E> data) + { + super.setData(data); + } + + } + private class ElementTransferHandler extends TransferHandler { @@ -91,7 +175,7 @@ protected void exportDone(JComponent source, Transferable data, int action) { - + } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java 2008-06-24 01:53:32 UTC (rev 6873) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java 2008-06-24 02:18:41 UTC (rev 6874) @@ -51,7 +51,7 @@ listenerList.add(TreeViewModelListener.class, listener); } - public final void removeTreeViewModelListener(TreeViewModelListener<E> listener) + public final void removeTreeViewModelListener(TreeViewModelListener<?> listener) { listenerList.remove(TreeViewModelListener.class, listener); } @@ -79,7 +79,7 @@ } } - public final Collection<E> getData() + public Collection<E> getData() { if (data == null) { @@ -91,7 +91,7 @@ } } - protected final void setData(Collection<E> data) + protected void setData(Collection<E> data) { Collection<E> oldData = this.data; this.data = data; Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-24 01:53:32 UTC (rev 6873) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-24 02:18:41 UTC (rev 6874) @@ -18,7 +18,7 @@ void addTreeViewModelListener(TreeViewModelListener<E> listener); - void removeTreeViewModelListener(TreeViewModelListener<E> listener); + void removeTreeViewModelListener(TreeViewModelListener<?> listener); List<? extends TreeView<E>> getTreeViews(); Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java 2008-06-24 01:53:32 UTC (rev 6873) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModelWrapper.java 2008-06-24 02:18:41 UTC (rev 6874) @@ -32,7 +32,7 @@ implements TreeViewModelListener<E> { - private TreeViewModel<E> model; + protected TreeViewModel<E> model; public TreeViewModelWrapper(TreeViewModel<E> model) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-25 00:31:57
|
Revision: 6880 http://pcgen.svn.sourceforge.net/pcgen/?rev=6880&view=rev Author: cpmeister Date: 2008-06-24 17:32:06 -0700 (Tue, 24 Jun 2008) Log Message: ----------- selectionpanel dnd support completed Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java Modified: branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-24 22:47:04 UTC (rev 6879) +++ branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-25 00:32:06 UTC (rev 6880) @@ -31,7 +31,11 @@ import javax.swing.JComponent; import javax.swing.JSplitPane; import javax.swing.TransferHandler; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.TreePath; import pcgen.gui.core.UIContext; +import pcgen.gui.util.JTreeTable; +import pcgen.gui.util.JTreeViewPane; import pcgen.gui.util.event.TreeViewModelEvent; import pcgen.gui.util.event.TreeViewModelListener; import pcgen.gui.util.treeview.TreeViewModel; @@ -46,11 +50,9 @@ private FilteredTreeViewDisplay availableView; private FilteredTreeViewDisplay selectedView; - private ElementTreeViewModel<?> availableTreeView; - private ElementTreeViewModel<?> selectedTreeView; private TreeViewModel<?> masterTreeView; private TreeViewModelListener<?> masterTreeViewListener; - //private Collection<?> availableElements; + public TreeViewSelectionPane(UIContext context) { super(JSplitPane.VERTICAL_SPLIT, true); @@ -65,14 +67,7 @@ TreeViewModel<T> masterModel, Collection<T> selectedData) { - setTreeViewModels(masterModel, selectedData); - - } - - private <T> void setTreeViewModels(TreeViewModel<T> masterModel, - final Collection<T> selectedData) - { - List<T> availableElements = new ArrayList<T>(masterModel.getData()); + Collection<T> availableElements = masterModel.getData(); availableElements.removeAll(selectedData); final ElementTreeViewModel<T> availableModel = new ElementTreeViewModel<T>(masterModel, @@ -84,7 +79,7 @@ masterTreeView.removeTreeViewModelListener(masterTreeViewListener); } masterTreeView = masterModel; - + TreeViewModelListener<T> listener = new TreeViewModelListener<T>() { @@ -97,9 +92,18 @@ }; masterTreeViewListener = listener; masterModel.addTreeViewModelListener(listener); - - availableTreeView = availableModel; - selectedTreeView = selectedModel; + + availableView.setTreeViewModel(elementClass, availableModel); + selectedView.setTreeViewModel(elementClass, selectedModel); + + JTreeViewPane availablePane = availableView.getTreeViewPane(); + JTreeViewPane selectedPane = selectedView.getTreeViewPane(); + + ElementTransferHandler<T> handler = new ElementTransferHandler<T>(elementClass, + availablePane, + selectedPane); + availablePane.setTransferHandler(handler); + selectedPane.setTransferHandler(handler); } private <T> void setModelData(ElementTreeViewModel<T> availableModel, @@ -139,16 +143,38 @@ } - private class ElementTransferHandler extends TransferHandler + private static class ElementTransferHandler<E> extends TransferHandler { - private Class<?> elementClass; + private final DataFlavor dataFlavor; + private Class<E> elementClass; + private JTreeViewPane pane1; + private JTreeViewPane pane2; - public ElementTransferHandler(Class<?> elementClass) + public ElementTransferHandler(Class<E> elementClass, + JTreeViewPane pane1, + JTreeViewPane pane2) { this.elementClass = elementClass; + String type = DataFlavor.javaJVMLocalObjectMimeType + ";class=" + + elementClass.getName(); + this.dataFlavor = new DataFlavor(type, null); + this.pane1 = pane1; + this.pane2 = pane2; } + public List<Object> getSelectedData(JTreeTable table) + { + TreePath[] paths = table.getTree().getSelectionPaths(); + List<Object> data = new ArrayList<Object>(); + for (TreePath path : paths) + { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); + data.add(node.getUserObject()); + } + return data; + } + @Override public int getSourceActions(JComponent c) { @@ -156,11 +182,11 @@ } @Override + @SuppressWarnings("unchecked") protected Transferable createTransferable(JComponent c) { - FilteredTreeViewDisplay view = (FilteredTreeViewDisplay) c; - List<?> data = view.getTreeViewPane().getSelectedData(); - Iterator<?> it = data.iterator(); + List<Object> data = getSelectedData((JTreeTable) c); + Iterator<Object> it = data.iterator(); while (it.hasNext()) { if (!elementClass.isInstance(it.next())) @@ -168,55 +194,104 @@ it.remove(); } } - return new ElementSelection(elementClass, data); + return new ElementSelection(c, (List<E>) data); } @Override + @SuppressWarnings("unchecked") protected void exportDone(JComponent source, Transferable data, int action) { - + JTreeViewPane pane; + if (pane1.isAncestorOf(source)) + { + pane = pane1; + } + else + { + pane = pane2; + } + ElementSelection selection = (ElementSelection) data; + ElementTreeViewModel<E> model = (ElementTreeViewModel<E>) pane.getTreeViewModel(); + Collection<E> elements = model.getData(); + elements.removeAll(selection.getData()); + model.setData(elements); } - } - - private static class ElementSelection implements Transferable - { - - private final DataFlavor dataFlavor; - private final List<?> data; - - public ElementSelection(Class<?> elementClass, List<?> data) + @Override + public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) { - String type = DataFlavor.javaJVMLocalObjectMimeType + ";class=" + - elementClass.getName(); - this.dataFlavor = new DataFlavor(type, null); - this.data = data; + return dataFlavor == transferFlavors[0]; } - public DataFlavor[] getTransferDataFlavors() + @Override + public boolean importData(JComponent comp, Transferable t) { - return new DataFlavor[]{dataFlavor}; + ElementSelection selection = (ElementSelection) t; + if (comp == selection.getSource()) + { + return false; + } + + JTreeViewPane pane; + if (pane1.isAncestorOf(comp)) + { + pane = pane1; + } + else + { + pane = pane2; + } + @SuppressWarnings("unchecked") + ElementTreeViewModel<E> model = (ElementTreeViewModel<E>) pane.getTreeViewModel(); + Collection<E> elements = model.getData(); + elements.addAll(selection.getData()); + model.setData(elements); + + return true; } - public boolean isDataFlavorSupported(DataFlavor flavor) + private class ElementSelection implements Transferable { - return dataFlavor.match(flavor); - } - public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException - { - if (!isDataFlavorSupported(flavor)) + private final List<E> data; + private JComponent source; + + public ElementSelection(JComponent source, List<E> data) { - throw new UnsupportedFlavorException(flavor); + this.source = source; + this.data = data; } - return data; - } - public List<?> getData() - { - return data; + public DataFlavor[] getTransferDataFlavors() + { + return new DataFlavor[]{dataFlavor}; + } + + public boolean isDataFlavorSupported(DataFlavor flavor) + { + return dataFlavor == flavor; + } + + public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException + { + if (!isDataFlavorSupported(flavor)) + { + throw new UnsupportedFlavorException(flavor); + } + return data; + } + + public JComponent getSource() + { + return source; + } + + public List<E> getData() + { + return data; + } + } - } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-24 22:47:04 UTC (rev 6879) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-25 00:32:06 UTC (rev 6880) @@ -23,7 +23,6 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.swing.AbstractAction; @@ -31,11 +30,10 @@ import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JRadioButtonMenuItem; +import javax.swing.TransferHandler; import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreePath; import pcgen.gui.util.event.TreeViewModelEvent; import pcgen.gui.util.event.TreeViewModelListener; import pcgen.gui.util.table.SortableTableModel; @@ -97,18 +95,23 @@ throw new UnsupportedOperationException(); } - public List<Object> getSelectedData() + @Override + public void setTransferHandler(TransferHandler newHandler) { - TreePath[] paths = getTable().getTree().getSelectionPaths(); - List<Object> data = new ArrayList<Object>(); - for (TreePath path : paths) - { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - data.add(node.getUserObject()); - } - return data; + getTable().setTransferHandler(newHandler); } + @Override + public TransferHandler getTransferHandler() + { + return getTable().getTransferHandler(); + } + + public TreeViewModel<?> getTreeViewModel() + { + return viewModel; + } + @SuppressWarnings("unchecked") public <T> void setTreeViewModel(TreeViewModel<T> viewModel) { Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java 2008-06-24 22:47:04 UTC (rev 6879) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/AbstractTreeViewModel.java 2008-06-25 00:32:06 UTC (rev 6880) @@ -20,6 +20,7 @@ */ package pcgen.gui.util.treeview; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import javax.swing.event.EventListenerList; @@ -87,7 +88,7 @@ } else { - return data; + return new ArrayList<E>(data); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-25 01:42:33
|
Revision: 6881 http://pcgen.svn.sourceforge.net/pcgen/?rev=6881&view=rev Author: cpmeister Date: 2008-06-24 18:42:40 -0700 (Tue, 24 Jun 2008) Log Message: ----------- minor bug fix Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java Modified: branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-25 00:32:06 UTC (rev 6880) +++ branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-25 01:42:40 UTC (rev 6881) @@ -58,7 +58,10 @@ super(JSplitPane.VERTICAL_SPLIT, true); availableView = new FilteredTreeViewDisplay(context); selectedView = new FilteredTreeViewDisplay(context); - + + availableView.getTreeViewPane().setDragEnabled(true); + selectedView.getTreeViewPane().setDragEnabled(true); + setTopComponent(selectedView); setBottomComponent(availableView); } Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-06-25 00:32:06 UTC (rev 6880) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTableEx.java 2008-06-25 01:42:40 UTC (rev 6881) @@ -24,11 +24,13 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; import java.awt.Component; +import java.awt.Container; import java.math.BigDecimal; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Vector; +import javax.swing.JViewport; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.TableColumnModel; @@ -98,6 +100,23 @@ } @Override + public boolean getScrollableTracksViewportHeight() + { + // fetch the table's parent + Container viewport = getParent(); + + // if the parent is not a viewport, calling this isn't useful + if (!(viewport instanceof JViewport)) + { + return false; + } + + // return true if the table's preferred height is smaller + // than the viewport height, else false + return getPreferredSize().height < viewport.getHeight(); + } + + @Override public void setModel(TableModel model) { if (!(model instanceof SortableTableModel)) Modified: branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-25 00:32:06 UTC (rev 6880) +++ branches/cdomui/code/src/java/pcgen/gui/util/JTreeViewPane.java 2008-06-25 01:42:40 UTC (rev 6881) @@ -95,6 +95,11 @@ throw new UnsupportedOperationException(); } + public void setDragEnabled(boolean b) + { + getTable().setDragEnabled(b); + } + @Override public void setTransferHandler(TransferHandler newHandler) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-25 02:49:33
|
Revision: 6882 http://pcgen.svn.sourceforge.net/pcgen/?rev=6882&view=rev Author: cpmeister Date: 2008-06-24 19:49:42 -0700 (Tue, 24 Jun 2008) Log Message: ----------- improved drag features Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/util/MultiLineTextIcon.java branches/cdomui/code/src/java/pcgen/gui/util/SimpleTextIcon.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/util/TextIcon.java Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-25 01:42:40 UTC (rev 6881) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-25 02:49:42 UTC (rev 6882) @@ -40,7 +40,7 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import pcgen.gui.core.UIContext; -import pcgen.gui.util.TextIcon; +import pcgen.gui.util.SimpleTextIcon; import pcgen.util.PropertyFactory; /** @@ -93,10 +93,10 @@ JButton button = new JButton(); button.setFocusable(false); - Icon icon = new TextIcon(button, filterString); + Icon icon = new SimpleTextIcon(button, filterString); button.setIcon(icon); - icon = new TextIcon(button, clearString); + icon = new SimpleTextIcon(button, clearString); button.setRolloverIcon(icon); button.setPressedIcon(icon); Modified: branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-25 01:42:40 UTC (rev 6881) +++ branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-25 02:49:42 UTC (rev 6882) @@ -28,6 +28,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JSplitPane; import javax.swing.TransferHandler; @@ -36,6 +37,7 @@ import pcgen.gui.core.UIContext; import pcgen.gui.util.JTreeTable; import pcgen.gui.util.JTreeViewPane; +import pcgen.gui.util.MultiLineTextIcon; import pcgen.gui.util.event.TreeViewModelEvent; import pcgen.gui.util.event.TreeViewModelListener; import pcgen.gui.util.treeview.TreeViewModel; @@ -58,10 +60,10 @@ super(JSplitPane.VERTICAL_SPLIT, true); availableView = new FilteredTreeViewDisplay(context); selectedView = new FilteredTreeViewDisplay(context); - + availableView.getTreeViewPane().setDragEnabled(true); selectedView.getTreeViewPane().setDragEnabled(true); - + setTopComponent(selectedView); setBottomComponent(availableView); } @@ -254,6 +256,14 @@ return true; } + @Override + public Icon getVisualRepresentation(Transferable t) + { + ElementSelection selection = (ElementSelection) t; + return new MultiLineTextIcon(selection.getSource(), + selection.getData()); + } + private class ElementSelection implements Transferable { Added: branches/cdomui/code/src/java/pcgen/gui/util/MultiLineTextIcon.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/MultiLineTextIcon.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/MultiLineTextIcon.java 2008-06-25 02:49:42 UTC (rev 6882) @@ -0,0 +1,89 @@ +/* + * MultiLineTextIcon.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 24, 2008, 7:06:58 PM + */ +package pcgen.gui.util; + +import java.awt.Component; +import java.awt.Graphics; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; +import javax.swing.Icon; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class MultiLineTextIcon implements Icon +{ + + private final List<Icon> icons; + private int width; + private int height; + + public MultiLineTextIcon(Component c, String text) + { + StringTokenizer tokenizer = new StringTokenizer(text, "\n"); + this.icons = new ArrayList<Icon>(tokenizer.countTokens()); + this.width = 0; + this.height = 0; + while (tokenizer.hasMoreTokens()) + { + SimpleTextIcon icon = new SimpleTextIcon(c, tokenizer.nextToken()); + width = Math.max(width, icon.getIconWidth()); + height += icon.getIconHeight(); + icons.add(icon); + } + } + + public MultiLineTextIcon(Component c, List<?> lines) + { + this.icons = new ArrayList<Icon>(lines.size()); + this.width = 0; + this.height = 0; + for (Object line : lines) + { + SimpleTextIcon icon = new SimpleTextIcon(c, line.toString()); + width = Math.max(width, icon.getIconWidth()); + height += icon.getIconHeight(); + icons.add(icon); + } + } + + public void paintIcon(Component c, Graphics g, int x, int y) + { + for (Icon icon : icons) + { + icon.paintIcon(c, g, x, y); + y += icon.getIconHeight(); + } + } + + public int getIconWidth() + { + return width; + } + + public int getIconHeight() + { + return height; + } + +} Copied: branches/cdomui/code/src/java/pcgen/gui/util/SimpleTextIcon.java (from rev 6699, branches/cdomui/code/src/java/pcgen/gui/util/TextIcon.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/SimpleTextIcon.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/util/SimpleTextIcon.java 2008-06-25 02:49:42 UTC (rev 6882) @@ -0,0 +1,69 @@ +/* + * SimpleTextIcon.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 17, 2008, 4:24:42 PM + */ +package pcgen.gui.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.FontMetrics; +import java.awt.Graphics; +import javax.swing.Icon; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class SimpleTextIcon implements Icon +{ + + private final String text; + private final FontMetrics metrics; + private final Color color; + + public SimpleTextIcon(Component c, String text) + { + this(c, text, Color.BLACK); + } + + public SimpleTextIcon(Component c, String text, Color color) + { + this.text = text; + this.metrics = c.getFontMetrics(c.getFont()); + this.color = color; + } + + public void paintIcon(Component c, Graphics g, int x, int y) + { + g.setColor(color); + g.setFont(metrics.getFont()); + g.drawString(text, x, y + metrics.getAscent()); + } + + public int getIconWidth() + { + return metrics.stringWidth(text); + } + + public int getIconHeight() + { + return metrics.getHeight(); + } + +} Deleted: branches/cdomui/code/src/java/pcgen/gui/util/TextIcon.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/TextIcon.java 2008-06-25 01:42:40 UTC (rev 6881) +++ branches/cdomui/code/src/java/pcgen/gui/util/TextIcon.java 2008-06-25 02:49:42 UTC (rev 6882) @@ -1,69 +0,0 @@ -/* - * TextIcon.java - * Copyright 2008 Connor Petty <cpm...@us...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Jun 17, 2008, 4:24:42 PM - */ -package pcgen.gui.util; - -import java.awt.Color; -import java.awt.Component; -import java.awt.FontMetrics; -import java.awt.Graphics; -import javax.swing.Icon; - -/** - * - * @author Connor Petty <cpm...@us...> - */ -public class TextIcon implements Icon -{ - - private final String text; - private final FontMetrics metrics; - private final Color color; - - public TextIcon(Component c, String text) - { - this(c, text, Color.BLACK); - } - - public TextIcon(Component c, String text, Color color) - { - this.text = text; - this.metrics = c.getFontMetrics(c.getFont()); - this.color = color; - } - - public void paintIcon(Component c, Graphics g, int x, int y) - { - g.setColor(color); - g.setFont(metrics.getFont()); - g.drawString(text, x, y + metrics.getAscent()); - } - - public int getIconWidth() - { - return metrics.stringWidth(text); - } - - public int getIconHeight() - { - return metrics.getHeight(); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-27 04:51:41
|
Revision: 6903 http://pcgen.svn.sourceforge.net/pcgen/?rev=6903&view=rev Author: cpmeister Date: 2008-06-26 21:51:48 -0700 (Thu, 26 Jun 2008) Log Message: ----------- begin tab implementation Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/UIContext.java branches/cdomui/code/src/java/pcgen/gui/tabs/ branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java branches/cdomui/code/src/java/pcgen/gui/tools/InfoPanel.java Removed Paths: ------------- branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java Copied: branches/cdomui/code/src/java/pcgen/gui/UIContext.java (from rev 6817, branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java) =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/UIContext.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/UIContext.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -0,0 +1,32 @@ +/* + * UIContext.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 17, 2008, 3:52:41 PM + */ + +package pcgen.gui; + +import pcgen.gui.filter.FilterList; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public interface UIContext { + public <T> FilterList<T> getToggleFilters(Class<T> c); +} Deleted: branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java 2008-06-27 01:10:50 UTC (rev 6902) +++ branches/cdomui/code/src/java/pcgen/gui/core/UIContext.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -1,32 +0,0 @@ -/* - * UIContext.java - * Copyright 2008 Connor Petty <cpm...@us...> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Created on Jun 17, 2008, 3:52:41 PM - */ - -package pcgen.gui.core; - -import pcgen.gui.filter.FilterList; - -/** - * - * @author Connor Petty <cpm...@us...> - */ -public interface UIContext { - public <T> FilterList<T> getToggleFilters(Class<T> c); -} Modified: branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-27 01:10:50 UTC (rev 6902) +++ branches/cdomui/code/src/java/pcgen/gui/filter/FilterPanel.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -39,7 +39,7 @@ import javax.swing.JToolBar; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import pcgen.gui.core.UIContext; +import pcgen.gui.UIContext; import pcgen.gui.util.SimpleTextIcon; import pcgen.util.PropertyFactory; Added: branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form 2008-06-27 04:51:48 UTC (rev 6903) @@ -0,0 +1,171 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,80,0,0,1,-35"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane1"> + <Properties> + <Property name="dividerSize" type="int" value="7"/> + <Property name="continuousLayout" type="boolean" value="true"/> + <Property name="oneTouchExpandable" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane2"> + <Properties> + <Property name="dividerSize" type="int" value="7"/> + <Property name="orientation" type="int" value="0"/> + <Property name="continuousLayout" type="boolean" value="true"/> + <Property name="oneTouchExpandable" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="bottom"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="Add"/> + <Property name="defaultCapable" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 9]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 9]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="13" weightX="1.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSpinner" name="jSpinner1"> + <Properties> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 18]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 18]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="3" ipadX="12" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="text" type="java.lang.String" value="Remove"/> + <Property name="defaultCapable" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 23]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 23]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="17" weightX="1.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="pcgen.gui.util.JTablePane" name="jTablePane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="1.0" weightY="1.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder justification="2" title="Class Info"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="top"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + </Properties> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JEditorPane" name="jEditorPane1"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="left"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> Added: branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -0,0 +1,128 @@ +/* + * ClassTab.java + * + * Created on June 26, 2008, 4:20 PM + */ + +package pcgen.gui.tabs; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class ClassTab extends javax.swing.JPanel { + + /** Creates new form ClassTab */ + public ClassTab() { + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + flippingSplitPane1 = new pcgen.gui.util.panes.FlippingSplitPane(); + flippingSplitPane2 = new pcgen.gui.util.panes.FlippingSplitPane(); + jPanel1 = new javax.swing.JPanel(); + jButton1 = new javax.swing.JButton(); + jSpinner1 = new javax.swing.JSpinner(); + jButton2 = new javax.swing.JButton(); + jTablePane1 = new pcgen.gui.util.JTablePane(); + jPanel3 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jEditorPane1 = new javax.swing.JEditorPane(); + jPanel2 = new javax.swing.JPanel(); + + setLayout(new java.awt.BorderLayout()); + + flippingSplitPane1.setDividerSize(7); + flippingSplitPane1.setContinuousLayout(true); + flippingSplitPane1.setOneTouchExpandable(true); + + flippingSplitPane2.setDividerSize(7); + flippingSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + flippingSplitPane2.setContinuousLayout(true); + flippingSplitPane2.setOneTouchExpandable(true); + + jPanel1.setLayout(new java.awt.GridBagLayout()); + + jButton1.setText("Add"); + jButton1.setDefaultCapable(false); + jButton1.setMinimumSize(new java.awt.Dimension(100, 9)); + jButton1.setPreferredSize(new java.awt.Dimension(100, 9)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + jPanel1.add(jButton1, gridBagConstraints); + + jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1))); + jSpinner1.setMinimumSize(new java.awt.Dimension(50, 18)); + jSpinner1.setPreferredSize(new java.awt.Dimension(50, 18)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.ipadx = 12; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + jPanel1.add(jSpinner1, gridBagConstraints); + + jButton2.setText("Remove"); + jButton2.setDefaultCapable(false); + jButton2.setMinimumSize(new java.awt.Dimension(100, 23)); + jButton2.setPreferredSize(new java.awt.Dimension(100, 23)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + jPanel1.add(jButton2, gridBagConstraints); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + jPanel1.add(jTablePane1, gridBagConstraints); + + flippingSplitPane2.setBottomComponent(jPanel1); + + jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Class Info", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + jEditorPane1.setEditable(false); + jScrollPane1.setViewportView(jEditorPane1); + + jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + flippingSplitPane2.setTopComponent(jPanel3); + + flippingSplitPane1.setRightComponent(flippingSplitPane2); + flippingSplitPane1.setLeftComponent(jPanel2); + + add(flippingSplitPane1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane1; + private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane2; + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JEditorPane jEditorPane1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSpinner jSpinner1; + private pcgen.gui.util.JTablePane jTablePane1; + // End of variables declaration//GEN-END:variables + +} Added: branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form 2008-06-27 04:51:48 UTC (rev 6903) @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane1"> + <Properties> + <Property name="continuousLayout" type="boolean" value="true"/> + <Property name="oneTouchExpandable" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="left"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane2"> + <Properties> + <Property name="orientation" type="int" value="0"/> + <Property name="continuousLayout" type="boolean" value="true"/> + <Property name="oneTouchExpandable" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder justification="2" title="Skill Info"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="top"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JEditorPane" name="jEditorPane1"> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> Added: branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -0,0 +1,69 @@ +/* + * SkillsTab.java + * + * Created on June 26, 2008, 8:49 PM + */ + +package pcgen.gui.tabs; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class SkillsTab extends javax.swing.JPanel { + + /** Creates new form SkillsTab */ + public SkillsTab() { + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + flippingSplitPane1 = new pcgen.gui.util.panes.FlippingSplitPane(); + jPanel1 = new javax.swing.JPanel(); + flippingSplitPane2 = new pcgen.gui.util.panes.FlippingSplitPane(); + jPanel2 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jEditorPane1 = new javax.swing.JEditorPane(); + + setLayout(new java.awt.BorderLayout()); + + flippingSplitPane1.setContinuousLayout(true); + flippingSplitPane1.setOneTouchExpandable(true); + flippingSplitPane1.setLeftComponent(jPanel1); + + flippingSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + flippingSplitPane2.setContinuousLayout(true); + flippingSplitPane2.setOneTouchExpandable(true); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Skill Info", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setViewportView(jEditorPane1); + + jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + flippingSplitPane2.setTopComponent(jPanel2); + + flippingSplitPane1.setRightComponent(flippingSplitPane2); + + add(flippingSplitPane1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane1; + private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane2; + private javax.swing.JEditorPane jEditorPane1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane1; + // End of variables declaration//GEN-END:variables + +} Modified: branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java 2008-06-27 01:10:50 UTC (rev 6902) +++ branches/cdomui/code/src/java/pcgen/gui/test/UtilitiesTester.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -144,7 +144,7 @@ return views; } - public int getStartingIndex() + public int getDefaultTreeViewIndex() { return 0; } Modified: branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java 2008-06-27 01:10:50 UTC (rev 6902) +++ branches/cdomui/code/src/java/pcgen/gui/tools/FilteredTreeViewDisplay.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -25,7 +25,7 @@ import java.util.Collection; import java.util.List; import javax.swing.JPanel; -import pcgen.gui.core.UIContext; +import pcgen.gui.UIContext; import pcgen.gui.filter.Filter; import pcgen.gui.filter.FilterPanel; import pcgen.gui.filter.FilterPanelListener; Added: branches/cdomui/code/src/java/pcgen/gui/tools/InfoPanel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/InfoPanel.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tools/InfoPanel.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -0,0 +1,58 @@ +/* + * InfoPanel.java + * Copyright 2008 Connor Petty <cpm...@us...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Created on Jun 26, 2008, 9:32:04 PM + */ +package pcgen.gui.tools; + +import java.awt.BorderLayout; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class InfoPanel extends JPanel +{ + + private JTextPane textPane; + + public InfoPanel() + { + this("Info"); + } + + public InfoPanel(String title) + { + super(new BorderLayout()); + setBorder(BorderFactory.createTitledBorder(null, title, + TitledBorder.CENTER, + TitledBorder.DEFAULT_POSITION)); + this.textPane = new JTextPane(); + JScrollPane scrollPane = new JScrollPane(textPane, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + add(scrollPane, BorderLayout.CENTER); + } + +} Modified: branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-27 01:10:50 UTC (rev 6902) +++ branches/cdomui/code/src/java/pcgen/gui/tools/TreeViewSelectionPane.java 2008-06-27 04:51:48 UTC (rev 6903) @@ -34,12 +34,13 @@ import javax.swing.TransferHandler; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; -import pcgen.gui.core.UIContext; +import pcgen.gui.UIContext; import pcgen.gui.util.JTreeTable; import pcgen.gui.util.JTreeViewPane; import pcgen.gui.util.MultiLineTextIcon; import pcgen.gui.util.event.TreeViewModelEvent; import pcgen.gui.util.event.TreeViewModelListener; +import pcgen.gui.util.panes.FlippingSplitPane; import pcgen.gui.util.treeview.TreeViewModel; import pcgen.gui.util.treeview.TreeViewModelWrapper; @@ -47,7 +48,7 @@ * * @author Connor Petty <cpm...@us...> */ -public class TreeViewSelectionPane extends JSplitPane +public class TreeViewSelectionPane extends FlippingSplitPane { private FilteredTreeViewDisplay availableView; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2008-06-27 08:37:02
|
Revision: 6905 http://pcgen.svn.sourceforge.net/pcgen/?rev=6905&view=rev Author: cpmeister Date: 2008-06-27 01:37:10 -0700 (Fri, 27 Jun 2008) Log Message: ----------- UI update Modified Paths: -------------- branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java branches/cdomui/code/src/java/pcgen/gui/tools/InfoPane.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java Added Paths: ----------- branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.form branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.java Added: branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.form (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.form 2008-06-27 08:37:10 UTC (rev 6905) @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,26,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane1"> + <Properties> + <Property name="dividerSize" type="int" value="7"/> + <Property name="continuousLayout" type="boolean" value="true"/> + <Property name="oneTouchExpandable" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="left"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="205" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="280" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + </Container> + <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane2"> + <Properties> + <Property name="dividerSize" type="int" value="7"/> + <Property name="orientation" type="int" value="0"/> + <Property name="continuousLayout" type="boolean" value="true"/> + <Property name="oneTouchExpandable" type="boolean" value="true"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> + <SubComponents> + <Component class="pcgen.gui.tools.InfoPane" name="infoPane1"> + <Properties> + <Property name="title" type="java.lang.String" value="Feat Info"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="top"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="184" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="160" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> Added: branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.java (rev 0) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/AbilitiesTab.java 2008-06-27 08:37:10 UTC (rev 6905) @@ -0,0 +1,88 @@ +/* + * AbilitiesTab.java + * + * Created on June 26, 2008, 11:02 PM + */ + +package pcgen.gui.tabs; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class AbilitiesTab extends javax.swing.JPanel { + + /** Creates new form AbilitiesTab */ + public AbilitiesTab() { + initComponents(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + flippingSplitPane1 = new pcgen.gui.util.panes.FlippingSplitPane(); + jPanel1 = new javax.swing.JPanel(); + flippingSplitPane2 = new pcgen.gui.util.panes.FlippingSplitPane(); + infoPane1 = new pcgen.gui.tools.InfoPane(); + jPanel2 = new javax.swing.JPanel(); + + setLayout(new java.awt.BorderLayout()); + + flippingSplitPane1.setDividerSize(7); + flippingSplitPane1.setContinuousLayout(true); + flippingSplitPane1.setOneTouchExpandable(true); + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 205, Short.MAX_VALUE) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 280, Short.MAX_VALUE) + ); + + flippingSplitPane1.setLeftComponent(jPanel1); + + flippingSplitPane2.setDividerSize(7); + flippingSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); + flippingSplitPane2.setContinuousLayout(true); + flippingSplitPane2.setOneTouchExpandable(true); + + infoPane1.setTitle("Feat Info"); + flippingSplitPane2.setTopComponent(infoPane1); + + org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 184, Short.MAX_VALUE) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 160, Short.MAX_VALUE) + ); + + flippingSplitPane2.setRightComponent(jPanel2); + + flippingSplitPane1.setRightComponent(flippingSplitPane2); + + add(flippingSplitPane1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane1; + private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane2; + private pcgen.gui.tools.InfoPane infoPane1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + // End of variables declaration//GEN-END:variables + +} Modified: branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form 2008-06-27 05:18:13 UTC (rev 6904) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.form 2008-06-27 08:37:10 UTC (rev 6905) @@ -114,46 +114,16 @@ </Component> </SubComponents> </Container> - <Container class="javax.swing.JPanel" name="jPanel3"> + <Component class="pcgen.gui.tools.InfoPane" name="infoPane1"> <Properties> - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> - <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> - <TitledBorder justification="2" title="Class Info"/> - </Border> - </Property> + <Property name="title" type="java.lang.String" value="Class Info"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> - <JSplitPaneConstraints position="top"/> + <JSplitPaneConstraints position="left"/> </Constraint> </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> - <SubComponents> - <Container class="javax.swing.JScrollPane" name="jScrollPane1"> - <Properties> - <Property name="horizontalScrollBarPolicy" type="int" value="31"/> - </Properties> - <AuxValues> - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> - </AuxValues> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="Center"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> - <SubComponents> - <Component class="javax.swing.JEditorPane" name="jEditorPane1"> - <Properties> - <Property name="editable" type="boolean" value="false"/> - </Properties> - </Component> - </SubComponents> - </Container> - </SubComponents> - </Container> + </Component> </SubComponents> </Container> <Container class="javax.swing.JPanel" name="jPanel2"> Modified: branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java 2008-06-27 05:18:13 UTC (rev 6904) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/ClassTab.java 2008-06-27 08:37:10 UTC (rev 6905) @@ -33,9 +33,7 @@ jSpinner1 = new javax.swing.JSpinner(); jButton2 = new javax.swing.JButton(); jTablePane1 = new pcgen.gui.util.JTablePane(); - jPanel3 = new javax.swing.JPanel(); - jScrollPane1 = new javax.swing.JScrollPane(); - jEditorPane1 = new javax.swing.JEditorPane(); + infoPane1 = new pcgen.gui.tools.InfoPane(); jPanel2 = new javax.swing.JPanel(); setLayout(new java.awt.BorderLayout()); @@ -92,18 +90,9 @@ flippingSplitPane2.setBottomComponent(jPanel1); - jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Class Info", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); - jPanel3.setLayout(new java.awt.BorderLayout()); + infoPane1.setTitle("Class Info"); + flippingSplitPane2.setLeftComponent(infoPane1); - jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - - jEditorPane1.setEditable(false); - jScrollPane1.setViewportView(jEditorPane1); - - jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER); - - flippingSplitPane2.setTopComponent(jPanel3); - flippingSplitPane1.setRightComponent(flippingSplitPane2); flippingSplitPane1.setLeftComponent(jPanel2); @@ -114,13 +103,11 @@ // Variables declaration - do not modify//GEN-BEGIN:variables private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane1; private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane2; + private pcgen.gui.tools.InfoPane infoPane1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; - private javax.swing.JEditorPane jEditorPane1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; - private javax.swing.JPanel jPanel3; - private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSpinner jSpinner1; private pcgen.gui.util.JTablePane jTablePane1; // End of variables declaration//GEN-END:variables Modified: branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form 2008-06-27 05:18:13 UTC (rev 6904) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.form 2008-06-27 08:37:10 UTC (rev 6905) @@ -10,12 +10,14 @@ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,2,29"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> <SubComponents> <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane1"> <Properties> + <Property name="dividerSize" type="int" value="7"/> <Property name="continuousLayout" type="boolean" value="true"/> <Property name="oneTouchExpandable" type="boolean" value="true"/> </Properties> @@ -38,6 +40,7 @@ </Container> <Container class="pcgen.gui.util.panes.FlippingSplitPane" name="flippingSplitPane2"> <Properties> + <Property name="dividerSize" type="int" value="7"/> <Property name="orientation" type="int" value="0"/> <Property name="continuousLayout" type="boolean" value="true"/> <Property name="oneTouchExpandable" type="boolean" value="true"/> @@ -50,38 +53,45 @@ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/> <SubComponents> - <Container class="javax.swing.JPanel" name="jPanel2"> + <Component class="pcgen.gui.tools.InfoPane" name="infoPane1"> <Properties> - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> - <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> - <TitledBorder justification="2" title="Skill Info"/> - </Border> - </Property> + <Property name="title" type="java.lang.String" value="Skill Info"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> <JSplitPaneConstraints position="top"/> </Constraint> </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription"> + <JSplitPaneConstraints position="right"/> + </Constraint> + </Constraints> - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> - <Container class="javax.swing.JScrollPane" name="jScrollPane1"> - <AuxValues> - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> - </AuxValues> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> - <BorderConstraints direction="Center"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> - <SubComponents> - <Component class="javax.swing.JEditorPane" name="jEditorPane1"> - </Component> - </SubComponents> - </Container> + <Component class="javax.swing.JTable" name="jTable1"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="4"> + <Column editable="false" title="Level" type="java.lang.Integer"> + <Data value="1"/> + <Data value="2"/> + <Data value="3"/> + <Data value="4"/> + </Column> + <Column editable="false" title="Class" type="java.lang.Object"/> + <Column editable="false" title="Skill Points" type="java.lang.Integer"/> + <Column editable="false" title="Points Left" type="java.lang.Integer"/> + </Table> + </Property> + </Properties> + </Component> </SubComponents> </Container> </SubComponents> Modified: branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java 2008-06-27 05:18:13 UTC (rev 6904) +++ branches/cdomui/code/src/java/pcgen/gui/tabs/SkillsTab.java 2008-06-27 08:37:10 UTC (rev 6905) @@ -28,29 +28,55 @@ flippingSplitPane1 = new pcgen.gui.util.panes.FlippingSplitPane(); jPanel1 = new javax.swing.JPanel(); flippingSplitPane2 = new pcgen.gui.util.panes.FlippingSplitPane(); - jPanel2 = new javax.swing.JPanel(); + infoPane1 = new pcgen.gui.tools.InfoPane(); jScrollPane1 = new javax.swing.JScrollPane(); - jEditorPane1 = new javax.swing.JEditorPane(); + jTable1 = new javax.swing.JTable(); setLayout(new java.awt.BorderLayout()); + flippingSplitPane1.setDividerSize(7); flippingSplitPane1.setContinuousLayout(true); flippingSplitPane1.setOneTouchExpandable(true); flippingSplitPane1.setLeftComponent(jPanel1); + flippingSplitPane2.setDividerSize(7); flippingSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); flippingSplitPane2.setContinuousLayout(true); flippingSplitPane2.setOneTouchExpandable(true); - jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Skill Info", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); - jPanel2.setLayout(new java.awt.BorderLayout()); + infoPane1.setTitle("Skill Info"); + flippingSplitPane2.setTopComponent(infoPane1); - jScrollPane1.setViewportView(jEditorPane1); + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {new Integer(1), null, null, null}, + {new Integer(2), null, null, null}, + {new Integer(3), null, null, null}, + {new Integer(4), null, null, null} + }, + new String [] { + "Level", "Class", "Skill Points", "Points Left" + } + ) { + Class[] types = new Class [] { + java.lang.Integer.class, java.lang.Object.class, java.lang.Integer.class, java.lang.Integer.class + }; + boolean[] canEdit = new boolean [] { + false, false, false, false + }; - jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER); + public Class getColumnClass(int columnIndex) { + return types [columnIndex]; + } - flippingSplitPane2.setTopComponent(jPanel2); + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jScrollPane1.setViewportView(jTable1); + flippingSplitPane2.setRightComponent(jScrollPane1); + flippingSplitPane1.setRightComponent(flippingSplitPane2); add(flippingSplitPane1, java.awt.BorderLayout.CENTER); @@ -60,10 +86,10 @@ // Variables declaration - do not modify//GEN-BEGIN:variables private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane1; private pcgen.gui.util.panes.FlippingSplitPane flippingSplitPane2; - private javax.swing.JEditorPane jEditorPane1; + private pcgen.gui.tools.InfoPane infoPane1; private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable jTable1; // End of variables declaration//GEN-END:variables } Modified: branches/cdomui/code/src/java/pcgen/gui/tools/InfoPane.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/tools/InfoPane.java 2008-06-27 05:18:13 UTC (rev 6904) +++ branches/cdomui/code/src/java/pcgen/gui/tools/InfoPane.java 2008-06-27 08:37:10 UTC (rev 6905) @@ -20,11 +20,10 @@ */ package pcgen.gui.tools; -import java.awt.BorderLayout; import javax.swing.BorderFactory; -import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextPane; +import javax.swing.border.Border; import javax.swing.border.TitledBorder; /** @@ -35,7 +34,7 @@ { private JTextPane textPane; - private String title; + private TitledBorder titledBorder; public InfoPane() { @@ -46,22 +45,24 @@ { super(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - setTitle(title); + this.titledBorder = BorderFactory.createTitledBorder(null, title, + TitledBorder.CENTER, + TitledBorder.DEFAULT_POSITION); + setBorder(BorderFactory.createCompoundBorder(titledBorder, getBorder())); this.textPane = new JTextPane(); - this.setViewportView(textPane); + textPane.setEditable(false); + setViewportView(textPane); } public String getTitle() { - return title; + return titledBorder.getTitle(); } public void setTitle(String title) { - this.title = title; - setBorder(BorderFactory.createTitledBorder(null, title, - TitledBorder.CENTER, - TitledBorder.DEFAULT_POSITION)); + titledBorder.setTitle(title); + validate(); } } Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java 2008-06-27 05:18:13 UTC (rev 6904) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/DefaultDataViewColumn.java 2008-06-27 08:37:10 UTC (rev 6905) @@ -20,8 +20,6 @@ */ package pcgen.gui.util.treeview; -import java.util.Comparator; - /** * * @author Connor Petty <mis...@gm...> Modified: branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java =================================================================== --- branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-27 05:18:13 UTC (rev 6904) +++ branches/cdomui/code/src/java/pcgen/gui/util/treeview/TreeViewModel.java 2008-06-27 08:37:10 UTC (rev 6905) @@ -1,6 +1,21 @@ /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * TreeViewModel.java + * Copyright 2008 (C) Connor Petty <mis...@gm...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * * Created on Feb 16, 2008, 11:44:12 PM */ package pcgen.gui.util.treeview; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |