From: <cpm...@us...> - 2009-08-27 04:44:52
|
Revision: 10308 http://pcgen.svn.sourceforge.net/pcgen/?rev=10308&view=rev Author: cpmeister Date: 2009-08-27 04:44:45 +0000 (Thu, 27 Aug 2009) Log Message: ----------- Fixed errors introduced in SVN[10307] Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java 2009-08-26 11:07:39 UTC (rev 10307) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java 2009-08-27 04:44:45 UTC (rev 10308) @@ -74,481 +74,485 @@ public class ClassInfoTab extends ChooserPane implements CharacterStateEditable { - private final FilteredTreeViewPanel treeviewPanel; - private final JTable classTable; - private final JButton addButton; - private final JButton removeButton; - private ClassFacade selectedClass; - private int spinnerValue; + private final FilteredTreeViewPanel treeviewPanel; + private final JTable classTable; + private final JButton addButton; + private final JButton removeButton; + private ClassFacade selectedClass; + private int spinnerValue; - public ClassInfoTab() - { - this.treeviewPanel = new FilteredTreeViewPanel(); - this.classTable = new JTable(); - this.addButton = new JButton(); - this.removeButton = new JButton(); - initComponents(); - } + public ClassInfoTab() + { + this.treeviewPanel = new FilteredTreeViewPanel(); + this.classTable = new JTable(); + this.addButton = new JButton(); + this.removeButton = new JButton(); + initComponents(); + } - private void initComponents() - { - JPanel panel = new JPanel(new GridBagLayout()); - GridBagConstraints constraints = new GridBagConstraints(); + private void initComponents() + { + JPanel panel = new JPanel(new GridBagLayout()); + GridBagConstraints constraints = new GridBagConstraints(); - Dimension buttonSize = new Dimension(100, 23); + Dimension buttonSize = new Dimension(100, 23); - addButton.setDefaultCapable(false); - addButton.setMinimumSize(buttonSize); - addButton.setPreferredSize(buttonSize); + addButton.setDefaultCapable(false); + addButton.setMinimumSize(buttonSize); + addButton.setPreferredSize(buttonSize); - constraints.fill = GridBagConstraints.VERTICAL; - constraints.anchor = GridBagConstraints.EAST; - constraints.weightx = 1.0; - constraints.insets = new java.awt.Insets(2, 2, 2, 2); - panel.add(addButton, constraints); + constraints.fill = GridBagConstraints.VERTICAL; + constraints.anchor = GridBagConstraints.EAST; + constraints.weightx = 1.0; + constraints.insets = new java.awt.Insets(2, 2, 2, 2); + panel.add(addButton, constraints); - Dimension spinnerSize = new Dimension(50, 18); - final JSpinner spinner = new JSpinner(new SpinnerNumberModel(1, 1, null, - 1)); - spinner.addChangeListener( - new ChangeListener() - { + Dimension spinnerSize = new Dimension(50, 18); + final JSpinner spinner = new JSpinner(new SpinnerNumberModel(1, 1, null, + 1)); + spinner.addChangeListener( + new ChangeListener() + { - public void stateChanged(ChangeEvent e) - { - spinnerValue = (Integer) spinner.getValue(); - } + public void stateChanged(ChangeEvent e) + { + spinnerValue = (Integer) spinner.getValue(); + } - }); - spinner.setMinimumSize(spinnerSize); - spinner.setPreferredSize(spinnerSize); + }); + spinner.setMinimumSize(spinnerSize); + spinner.setPreferredSize(spinnerSize); - constraints.anchor = GridBagConstraints.CENTER; - constraints.weightx = 0.0; - panel.add(spinner, constraints); + constraints.anchor = GridBagConstraints.CENTER; + constraints.weightx = 0.0; + panel.add(spinner, constraints); - removeButton.setDefaultCapable(false); - removeButton.setMinimumSize(buttonSize); - removeButton.setPreferredSize(buttonSize); + removeButton.setDefaultCapable(false); + removeButton.setMinimumSize(buttonSize); + removeButton.setPreferredSize(buttonSize); - constraints.anchor = GridBagConstraints.WEST; - constraints.weightx = 1.0; - constraints.gridwidth = GridBagConstraints.REMAINDER; - panel.add(removeButton, constraints); + constraints.anchor = GridBagConstraints.WEST; + constraints.weightx = 1.0; + constraints.gridwidth = GridBagConstraints.REMAINDER; + panel.add(removeButton, constraints); - ListSelectionModel selectionModel = classTable.getSelectionModel(); - selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - selectionModel.addListSelectionListener( - new ListSelectionListener() - { + ListSelectionModel selectionModel = classTable.getSelectionModel(); + selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + selectionModel.addListSelectionListener( + new ListSelectionListener() + { - public void valueChanged(ListSelectionEvent e) - { - if (!e.getValueIsAdjusting()) - { + public void valueChanged(ListSelectionEvent e) + { + if (!e.getValueIsAdjusting()) + { + } + } - } - } + }); + JScrollPane tablePane = new JScrollPane(classTable); - }); - JScrollPane tablePane = new JScrollPane(classTable); + constraints.fill = GridBagConstraints.BOTH; + constraints.anchor = GridBagConstraints.CENTER; + constraints.weighty = 1.0; + panel.add(tablePane, constraints); - constraints.fill = GridBagConstraints.BOTH; - constraints.anchor = GridBagConstraints.CENTER; - constraints.weighty = 1.0; - panel.add(tablePane, constraints); + TransferHandler handler = new ClassTransferHandler(); + classTable.setDragEnabled(true); + classTable.setTransferHandler(handler); - TransferHandler handler = new ClassTransferHandler(); - classTable.setDragEnabled(true); - classTable.setTransferHandler(handler); + treeviewPanel.setDragEnabled(true); + treeviewPanel.setTransferHandler(handler); - treeviewPanel.setDragEnabled(true); - treeviewPanel.setTransferHandler(handler); + setPrimaryChooserComponent(treeviewPanel); + setSecondaryChooserComponent(panel); + } - setPrimaryChooserComponent(treeviewPanel); - setSecondaryChooserComponent(panel); - } + private void setSelectedClass(ClassFacade c) + { + } - private void setSelectedClass(ClassFacade c) - { + private ClassFacade[] createFacadeArray(ClassFacade c) + { + ClassFacade[] classes = new ClassFacade[spinnerValue]; + for (int x = 0; x < spinnerValue; x++) + { + classes[x] = c; + } + return classes; + } - } + public Hashtable<Object, Object> createState(CharacterFacade character) + { + ClassTreeViewModel treeviewModel = new ClassTreeViewModel(character); + ClassTableModel classModel = new ClassTableModel(character); - private ClassFacade[] createFacadeArray(ClassFacade c) - { - ClassFacade[] classes = new ClassFacade[spinnerValue]; - for (int x = 0; x < spinnerValue; x++) - { - classes[x] = c; - } - return classes; - } + Hashtable<Object, Object> state = treeviewPanel.createState(character, + treeviewModel); + state.put(ClassTableModel.class, classModel); + state.put(AddClassAction.class, new AddClassAction(character)); + state.put(RemoveClassAction.class, new RemoveClassAction(character)); + return state; + } - public Hashtable<Object, Object> createState(CharacterFacade character) - { - ClassTreeViewModel treeviewModel = new ClassTreeViewModel(character); - ClassTableModel classModel = new ClassTableModel(character); + public void storeState(Hashtable<Object, Object> state) + { + throw new UnsupportedOperationException("Not supported yet."); + } - Hashtable<Object, Object> state = treeviewPanel.createState(character, - treeviewModel); - state.put(ClassTableModel.class, classModel); - state.put(AddClassAction.class, new AddClassAction(character)); - state.put(RemoveClassAction.class, new RemoveClassAction(character)); - return state; - } + public void restoreState(Hashtable<?, ?> state) + { + classTable.setModel((ClassTableModel) state.get(ClassTableModel.class)); + addButton.setAction((AddClassAction) state.get(AddClassAction.class)); + removeButton.setAction((RemoveClassAction) state.get(RemoveClassAction.class)); + treeviewPanel.restoreState(state); + } - public void storeState(Hashtable<Object, Object> state) - { - throw new UnsupportedOperationException("Not supported yet."); - } + private class AddClassAction extends AbstractAction + { - public void restoreState(Hashtable<?, ?> state) - { - classTable.setModel((ClassTableModel) state.get(ClassTableModel.class)); - addButton.setAction((AddClassAction) state.get(AddClassAction.class)); - removeButton.setAction((RemoveClassAction) state.get(RemoveClassAction.class)); - treeviewPanel.restoreState(state); - } + private CharacterFacade character; - private class AddClassAction extends AbstractAction - { + public AddClassAction(CharacterFacade character) + { + super(PropertyFactory.getString("in_add")); + this.character = character; + } - private CharacterFacade character; + public void actionPerformed(ActionEvent e) + { + character.addCharacterLevels(createFacadeArray(selectedClass)); + } - public AddClassAction(CharacterFacade character) - { - super(PropertyFactory.getString("in_add")); - this.character = character; - } + } - public void actionPerformed(ActionEvent e) - { - character.addCharacterLevels(createFacadeArray(selectedClass)); - } + private class RemoveClassAction extends AbstractAction + { - } + private CharacterFacade character; - private class RemoveClassAction extends AbstractAction - { + public RemoveClassAction(CharacterFacade character) + { + super(PropertyFactory.getString("in_remove")); + this.character = character; + } - private CharacterFacade character; + public void actionPerformed(ActionEvent e) + { + character.removeCharacterLevels(spinnerValue); + } - public RemoveClassAction(CharacterFacade character) - { - super(PropertyFactory.getString("in_remove")); - this.character = character; - } + } - public void actionPerformed(ActionEvent e) - { - character.removeCharacterLevels(spinnerValue); - } + private final class ClassTransferHandler extends TransferHandler + { - } + private final DataFlavor classFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + + ";class=" + + ClassFacade.class.getName(), + null); - private final class ClassTransferHandler extends TransferHandler - { + @Override + public int getSourceActions(JComponent c) + { + if (c == classTable) + { + return NONE; + } + else + { + return COPY; + } + } - private final DataFlavor classFlavor = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType + - ";class=" + - ClassFacade.class.getName(), - null); + @Override + protected Transferable createTransferable(JComponent c) + { + List<Object> data = treeviewPanel.getSelectedData(); + if (data.isEmpty()) + { + return null; + } + Object obj = data.get(0); + if (!(obj instanceof ClassFacade)) + { + return null; + } - @Override - public int getSourceActions(JComponent c) - { - if (c == classTable) - { - return NONE; - } - else - { - return COPY; - } - } + final ClassFacade selectedClass = (ClassFacade) obj; - @Override - protected Transferable createTransferable(JComponent c) - { - List<Object> data = treeviewPanel.getSelectedData(); - if (data.isEmpty()) - { - return null; - } - Object obj = data.get(0); - if (!(obj instanceof ClassFacade)) - { - return null; - } + return new Transferable() + { - final ClassFacade selectedClass = (ClassFacade) obj; + public DataFlavor[] getTransferDataFlavors() + { + return new DataFlavor[] + { + classFlavor + }; + } - return new Transferable() - { + public boolean isDataFlavorSupported(DataFlavor flavor) + { + return classFlavor == flavor; + } - public DataFlavor[] getTransferDataFlavors() - { - return new DataFlavor[]{classFlavor}; - } + public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException + { + if (!isDataFlavorSupported(flavor)) + { + throw new UnsupportedFlavorException(flavor); + } + return selectedClass; + } - public boolean isDataFlavorSupported(DataFlavor flavor) - { - return classFlavor == flavor; - } + }; + } - public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException - { - if (!isDataFlavorSupported(flavor)) - { - throw new UnsupportedFlavorException(flavor); - } - return selectedClass; - } + @Override + public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) + { + return transferFlavors[0] == classFlavor; + } - }; - } + @Override + public boolean importData(JComponent comp, Transferable t) + { + if (comp == classTable) + { + try + { + ClassFacade c = (ClassFacade) t.getTransferData(classFlavor); + ClassTableModel model = (ClassTableModel) classTable.getModel(); + ClassFacade[] classes = new ClassFacade[spinnerValue]; - @Override - public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) - { - return transferFlavors[0] == classFlavor; - } + for (int x = 0; x < spinnerValue; x++) + { + classes[x] = c; + } - @Override - public boolean importData(JComponent comp, Transferable t) - { - if (comp == classTable) - { - try - { - ClassFacade c = (ClassFacade) t.getTransferData(classFlavor); - ClassTableModel model = (ClassTableModel) classTable.getModel(); - ClassFacade[] classes = new ClassFacade[spinnerValue]; + //selectionModel.addRows(classes); + return true; + } + catch (UnsupportedFlavorException ex) + { + Logger.getLogger(ClassInfoTab.class.getName()).log(Level.SEVERE, + null, + ex); + } + catch (IOException ex) + { + Logger.getLogger(ClassInfoTab.class.getName()).log(Level.SEVERE, + null, + ex); + } + return false; + } + return true; + } - for (int x = 0; x < spinnerValue; x++) - { - classes[x] = c; - } + } - //selectionModel.addRows(classes); - return true; - } - catch (UnsupportedFlavorException ex) - { - Logger.getLogger(ClassInfoTab.class.getName()).log(Level.SEVERE, - null, - ex); - } - catch (IOException ex) - { - Logger.getLogger(ClassInfoTab.class.getName()).log(Level.SEVERE, - null, - ex); - } - return false; - } - return true; - } + private static class ClassTreeViewModel implements FilterableTreeViewModel<ClassFacade>, + DataView<ClassFacade> + { - } + private static final List<DefaultDataViewColumn> columns = + Arrays.asList(new DefaultDataViewColumn("HD", String.class), + new DefaultDataViewColumn("Type", String.class), + new DefaultDataViewColumn("Base Stat", + String.class), + new DefaultDataViewColumn("Spell Type", + String.class)); + private CharacterFacade character; - private static class ClassTreeViewModel implements FilterableTreeViewModel<ClassFacade>, - DataView<ClassFacade> - { + public ClassTreeViewModel(CharacterFacade character) + { + this.character = character; + } - private static final List<DefaultDataViewColumn> columns = - Arrays.asList(new DefaultDataViewColumn("HD", String.class), - new DefaultDataViewColumn("Type", String.class), - new DefaultDataViewColumn("Base Stat", - String.class), - new DefaultDataViewColumn("Spell Type", - String.class)); - private CharacterFacade character; + public Class<ClassFacade> getFilterClass() + { + return ClassFacade.class; + } - public ClassTreeViewModel(CharacterFacade character) - { - this.character = character; - } + public List<? extends TreeView<ClassFacade>> getTreeViews() + { + return Arrays.asList(ClassTreeView.values()); + } - public Class<ClassFacade> getFilterClass() - { - return ClassFacade.class; - } + public int getDefaultTreeViewIndex() + { + return 0; + } - public List<? extends TreeView<ClassFacade>> getTreeViews() - { - return Arrays.asList(ClassTreeView.values()); - } + public DataView<ClassFacade> getDataView() + { + return this; + } - public int getDefaultTreeViewIndex() - { - return 0; - } + public GenericListModel<ClassFacade> getDataModel() + { + throw new UnsupportedOperationException("Not supported yet."); + } - public DataView<ClassFacade> getDataView() - { - return this; - } + public List<?> getData(ClassFacade obj) + { + return Arrays.asList(obj.getHD(), getTypes(obj), obj.getBaseStat(), + obj.getSpellType()); + } - public GenericListModel<ClassFacade> getDataModel() - { - throw new UnsupportedOperationException("Not supported yet."); - } + private String getTypes(ClassFacade obj) + { + String ret = ""; + String[] types = obj.getTypes(); + if (types != null && types.length > 0) + { + ret += types[0]; + for (int x = 1; x < types.length; x++) + { + ret += ", " + types[x]; + } + } + return ret; + } - public List<?> getData(ClassFacade obj) - { - return Arrays.asList(obj.getHD(), getTypes(obj), obj.getBaseStat(), - obj.getSpellType()); - } + public List<? extends DataViewColumn> getDataColumns() + { + return columns; + } - private String getTypes(ClassFacade obj) - { - String ret = ""; - String[] types = obj.getTypes(); - if (types != null && types.length > 0) - { - ret += types[0]; - for (int x = 1; x < types.length; x++) - { - ret += ", " + types[x]; - } - } - return ret; - } + private static enum ClassTreeView implements TreeView<ClassFacade> + { - public List<? extends DataViewColumn> getDataColumns() - { - return columns; - } + NAME("Name"), + TYPE_NAME("Type/Name"), + SOURCE_NAME("Source/Name"); + private String name; - private static enum ClassTreeView implements TreeView<ClassFacade> - { + private ClassTreeView(String name) + { + this.name = name; + } - NAME("Name"), - TYPE_NAME("Type/Name"), - SOURCE_NAME("Source/Name"); - private String name; + public String getViewName() + { + return name; + } - private ClassTreeView(String name) - { - this.name = name; - } + public List<TreeViewPath<ClassFacade>> getPaths(ClassFacade pobj) + { + switch (this) + { + case TYPE_NAME: + String[] types = pobj.getTypes(); + if (types != null && types.length > 0) + { + List<TreeViewPath<ClassFacade>> paths = new ArrayList<TreeViewPath<ClassFacade>>( + types.length); + for (String type : types) + { + paths.add(new TreeViewPath<ClassFacade>(pobj, + type)); + } + return paths; + } + case NAME: + return Collections.singletonList(new TreeViewPath<ClassFacade>(pobj)); + case SOURCE_NAME: + return Collections.singletonList( + new TreeViewPath<ClassFacade>(pobj, + pobj.getSource())); + default: + throw new InternalError(); + } - public String getViewName() - { - return name; - } + } - public List<TreeViewPath<ClassFacade>> getPaths(ClassFacade pobj) - { - switch (this) - { - case TYPE_NAME: - String[] types = pobj.getTypes(); - if (types != null && types.length > 0) - { - List<TreeViewPath<ClassFacade>> paths = new ArrayList<TreeViewPath<ClassFacade>>(types.length); - for (String type : types) - { - paths.add(new TreeViewPath<ClassFacade>(pobj, - type)); - } - return paths; - } - case NAME: - return Collections.singletonList(new TreeViewPath<ClassFacade>(pobj)); - case SOURCE_NAME: - return Collections.singletonList(new TreeViewPath<ClassFacade>(pobj, - pobj.getSource())); - default: - throw new InternalError(); - } + } + } - } + private static class ClassTableModel extends AbstractTableModel implements ListDataListener + { - } - } + private static final String[] columns = + { + "Level", + "Class", + "Source" + }; + private GenericListModel<CharacterLevelFacade> model; - private static class ClassTableModel extends AbstractTableModel - implements ListDataListener - { + public ClassTableModel(CharacterFacade character) + { + this.model = character.getLevels(); + model.addListDataListener(this); + } - private static final String[] columns = {"Level", - "Class", - "Source" - }; - private GenericListModel<CharacterLevelFacade> model; + public int getRowCount() + { + return model.getSize(); + } - public ClassTableModel(CharacterFacade character) - { - this.model = character.getLevels(); - model.addListDataListener(this); - } + public int getColumnCount() + { + return 3; + } - public int getRowCount() - { - return model.getSize(); - } + @Override + public String getColumnName(int column) + { + return columns[column]; + } - public int getColumnCount() - { - return 3; - } + @Override + public Class<?> getColumnClass(int columnIndex) + { + switch (columnIndex) + { + case 0: + return Integer.class; + case 1: + return Object.class; + case 2: + return String.class; + } + return null; + } - @Override - public String getColumnName(int column) - { - return columns[column]; - } + public Object getValueAt(int rowIndex, int columnIndex) + { + if (columnIndex == 0) + { + return rowIndex + 1; + } + ClassFacade c = model.getElementAt(rowIndex).getSelectedClass(); + switch (columnIndex) + { + case 1: + return c; + case 2: + return c.getSource(); + default: + return null; + } + } - @Override - public Class<?> getColumnClass(int columnIndex) - { - switch (columnIndex) - { - case 0: - return Integer.class; - case 1: - return Object.class; - case 2: - return String.class; - } - return null; - } + public void intervalAdded(ListDataEvent e) + { + fireTableRowsInserted(e.getIndex0(), e.getIndex1()); + } - public Object getValueAt(int rowIndex, int columnIndex) - { - if (columnIndex == 0) - { - return rowIndex + 1; - } - ClassFacade c = model.getElementAt(rowIndex).getSelectedClass(); - switch (columnIndex) - { - case 1: - return c; - case 2: - return c.getSource(); - default: - return null; - } - } + public void intervalRemoved(ListDataEvent e) + { + fireTableRowsDeleted(e.getIndex0(), e.getIndex1()); + } - public void intervalAdded(ListDataEvent e) - { - fireTableRowsInserted(e.getIndex0(), e.getIndex1()); - } + public void contentsChanged(ListDataEvent e) + { + fireTableRowsUpdated(e.getIndex0(), e.getIndex1()); + } - public void intervalRemoved(ListDataEvent e) - { - fireTableRowsDeleted(e.getIndex0(), e.getIndex1()); - } - - public void contentsChanged(ListDataEvent e) - { - fireTableRowsUpdated(e.getIndex0(), e.getIndex1()); - } - - } - } + } +} Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java 2009-08-26 11:07:39 UTC (rev 10307) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java 2009-08-27 04:44:45 UTC (rev 10308) @@ -1,640 +1,642 @@ -/* - * SkillInfoTab.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 Jul 10, 2008, 8:03:21 PM - */ -package pcgen.gui2.tabs; - -import pcgen.gui2.tools.CharacterStateEditable; -import java.awt.Component; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.List; -import javax.swing.AbstractSpinnerModel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListDataEvent; -import javax.swing.event.ListDataListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.AbstractTableModel; -import pcgen.cdom.enumeration.SkillCost; -import pcgen.gui2.PCGenUIManager; -import pcgen.gui2.PCGenUIManager.HouseRule; -import pcgen.core.facade.CharacterFacade; -import pcgen.core.facade.CharacterLevelFacade; -import pcgen.core.facade.ClassFacade; -import pcgen.core.facade.SkillFacade; -import pcgen.gui2.filter.FilterableTreeViewModel; -import pcgen.gui2.filter.FilteredTreeViewPanel; -import pcgen.gui2.tools.ChooserPane; -import pcgen.gui2.util.GenericListModel; -import pcgen.gui2.util.JTableEx; -import pcgen.gui2.util.table.TableCellUtilities.SpinnerEditor; -import pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer; -import pcgen.gui2.util.treeview.DataView; -import pcgen.gui2.util.treeview.DataViewColumn; -import pcgen.gui2.util.treeview.DefaultDataViewColumn; -import pcgen.gui2.util.treeview.TreeView; -import pcgen.gui2.util.treeview.TreeViewPath; - -/** - * - * @author Connor Petty <cpm...@us...> - */ -public class SkillInfoTab extends ChooserPane implements CharacterStateEditable -{ - - private final FilteredTreeViewPanel skillPanel; - private final JTable skillcostTable; - private final JTable skillpointTable; - private SkillTreeViewModel treeviewModel; - private SkillPointTableModel skillpointModel; - private SkillCostTableModel skillcostModel; - private CharacterLevelFacade selectedLevel; - private SkillFacade selectedSkill; - - public SkillInfoTab() - { - this.skillPanel = new FilteredTreeViewPanel(); - this.skillcostTable = new JTableEx(); - this.skillpointTable = new JTableEx(); - initComponents(); - } - - private void initComponents() - { - skillPanel.setDefaultRenderer(Float.class, new SpinnerRenderer()); - ListSelectionModel selectionModel = skillPanel.getSelectionModel(); - selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - selectionModel.addListSelectionListener( - new ListSelectionListener() - { - - public void valueChanged(ListSelectionEvent e) - { - if (!e.getValueIsAdjusting()) - { - List<Object> data = skillPanel.getSelectedData(); - SkillFacade skill = null; - if (!data.isEmpty() && - data.get(0) instanceof SkillFacade) - { - skill = (SkillFacade) data.get(0); - } - setSelectedSkill(skill); - } - } - - }); - setPrimaryChooserComponent(skillPanel); - - JScrollPane tableScrollPane; - JPanel tablePanel = new JPanel(new GridBagLayout()); - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; - constraints.fill = java.awt.GridBagConstraints.BOTH; - constraints.ipady = 60; - constraints.weightx = 1.0; - - tableScrollPane = new JScrollPane(skillcostTable, - JScrollPane.VERTICAL_SCROLLBAR_NEVER, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - tablePanel.add(tableScrollPane, constraints); - - constraints.ipady = 0; - constraints.weighty = 1.0; - - tableScrollPane = new JScrollPane(skillpointTable); - tablePanel.add(tableScrollPane, constraints); - setSecondaryChooserComponent(tablePanel); - } - - private void setSelectedSkill(SkillFacade skill) - { - this.selectedSkill = skill; - if (skill != null) - { - setInfoPaneText(skill.getInfo()); - } - } - - private void setSelectedLevel(CharacterLevelFacade selectedLevel) - { - this.selectedLevel = selectedLevel; - skillcostModel.setCharacterLevel(selectedLevel); - treeviewModel.setCharacterLevel(selectedLevel); - } - - public Hashtable<Object, Object> createState(CharacterFacade character) - { - SkillTreeViewModel viewModel = new SkillTreeViewModel(character); - SkillCostTableModel costModel = new SkillCostTableModel(character); - SkillPointTableModel pointModel = new SkillPointTableModel(character); - SkillRankSpinnerEditor rankEditor = new SkillRankSpinnerEditor(character); - - Hashtable<Object, Object> state = skillPanel.createState(character, - viewModel); - state.put(SkillTreeViewModel.class, viewModel); - state.put(SkillCostTableModel.class, costModel); - state.put(SkillPointTableModel.class, pointModel); - state.put(SkillRankSpinnerEditor.class, rankEditor); - state.put("SelectedCharacterLevel", - character.getLevels().getElementAt(0)); - return state; - } - - public void storeState(Hashtable<Object, Object> state) - { - state.put("SelectedCharacterLevel", selectedLevel); - state.put("SelectedSkill", selectedSkill); - } - - public void restoreState(Hashtable<?, ?> state) - { - treeviewModel = (SkillTreeViewModel) state.get(SkillTreeViewModel.class); - skillcostModel = (SkillCostTableModel) state.get(SkillCostTableModel.class); - skillpointModel = (SkillPointTableModel) state.get(SkillPointTableModel.class); - - skillcostTable.setModel(skillcostModel); - skillpointTable.setModel(skillpointModel); - - setSelectedLevel((CharacterLevelFacade) state.get("SelectedCharacterLevel")); - - skillPanel.restoreState(state); - skillPanel.setDefaultEditor(Float.class, (SkillRankSpinnerEditor) state.get( - SkillRankSpinnerEditor.class)); - - setSelectedSkill((SkillFacade) state.get("SelectedSkill")); - } - - private class SkillRankSpinnerEditor extends SpinnerEditor - { - - private final SkillRankSpinnerModel model; - - public SkillRankSpinnerEditor(CharacterFacade character) - { - this(new SkillRankSpinnerModel(character)); - } - - private SkillRankSpinnerEditor(SkillRankSpinnerModel model) - { - super(model); - this.model = model; - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, - int row, - int column) - { - model.setSkill(selectedSkill); - model.setLevel(selectedLevel); - return spinner; - } - - } - - private static final class SkillTreeViewModel implements FilterableTreeViewModel<SkillFacade>, - DataView<SkillFacade> - { - - private enum SkillTreeView implements TreeView<SkillFacade> - { - - NAME("Name"), - TYPE_NAME("Type/Name"), - KEYSTAT_NAME("Key Stat/Name"), - KEYSTAT_TYPE_NAME("Key Stat/Type/Name"); - private String name; - - private SkillTreeView(String name) - { - this.name = name; - } - - public String getViewName() - { - return name; - } - - @SuppressWarnings("unchecked") - public List<TreeViewPath<SkillFacade>> getPaths(SkillFacade pobj) - { - TreeViewPath<SkillFacade> path; - switch (this) - { - case NAME: - path = new TreeViewPath<SkillFacade>(pobj); - break; - case TYPE_NAME: - path = new TreeViewPath<SkillFacade>(pobj, - pobj.getType()); - break; - case KEYSTAT_NAME: - path = new TreeViewPath<SkillFacade>(pobj, - pobj.getKeyStat()); - break; - case KEYSTAT_TYPE_NAME: - path = new TreeViewPath<SkillFacade>(pobj, - pobj.getKeyStat(), - pobj.getType()); - break; - default: - throw new InternalError(); - } - return Arrays.asList(path); - } - - } - private final TreeView<SkillFacade> COST_NAME = new TreeView<SkillFacade>() - { - - public String getViewName() - { - return "Cost/Name"; - } - - @SuppressWarnings("unchecked") - public List<TreeViewPath<SkillFacade>> getPaths(SkillFacade pobj) - { - return Arrays.asList(new TreeViewPath<SkillFacade>(pobj, - level.getSkillCost( - pobj))); - } - - }; - private final TreeView<SkillFacade> COST_TYPE_NAME = new TreeView<SkillFacade>() - { - - public String getViewName() - { - return "Cost/Type/Name"; - } - - @SuppressWarnings("unchecked") - public List<TreeViewPath<SkillFacade>> getPaths(SkillFacade pobj) - { - return Arrays.asList( - new TreeViewPath<SkillFacade>(pobj, - level.getSkillCost(pobj), - pobj.getType())); - } - - }; - private static final List<? extends DataViewColumn> columns = Arrays.asList( - new DefaultDataViewColumn("Total", Integer.class, true), - new DefaultDataViewColumn("Modifier", Integer.class, true), - new DefaultDataViewColumn("Ranks", Float.class, true, true), - new DefaultDataViewColumn("Skill Cost", SkillCost.class, true), - new DefaultDataViewColumn("Source", String.class)); - private CharacterFacade character; - private CharacterLevelFacade level; - - public SkillTreeViewModel(CharacterFacade character) - { - this.character = character; - } - - public void setCharacterLevel(CharacterLevelFacade level) - { - this.level = level; - } - - public Class<SkillFacade> getFilterClass() - { - return SkillFacade.class; - } - - public List<?> getData(SkillFacade obj) - { - return Arrays.asList( - character.getSkillTotal(obj), - character.getSkillModifier(obj), - Float.valueOf(character.getSkillRanks(obj)), - level.getSkillCost(obj), - obj.getSource()); - } - - public List<? extends DataViewColumn> getDataColumns() - { - return columns; - } - - public DataView<SkillFacade> getDataView() - { - return this; - } - - @SuppressWarnings("unchecked") - public List<? extends TreeView<SkillFacade>> getTreeViews() - { - return Arrays.asList(SkillTreeView.NAME, SkillTreeView.TYPE_NAME, - SkillTreeView.KEYSTAT_NAME, - SkillTreeView.KEYSTAT_TYPE_NAME, COST_NAME, - COST_TYPE_NAME); - } - - public int getDefaultTreeViewIndex() - { - return 0; - } - - public GenericListModel<SkillFacade> getDataModel() - { - return character.getDataSet().getSkills(); - } - - } - - private static class SkillCostTableModel extends AbstractTableModel - { - - private CharacterLevelFacade level; - private CharacterFacade character; - - public SkillCostTableModel(CharacterFacade character) - { - this.character = character; - } - - public void setCharacterLevel(CharacterLevelFacade level) - { - this.level = level; - fireTableRowsUpdated(0, 2); - } - - public int getRowCount() - { - return 3; - } - - public int getColumnCount() - { - return 3; - } - - @Override - public Class<?> getColumnClass(int columnIndex) - { - switch (columnIndex) - { - case 0: - return String.class; - case 1: - return Integer.class; - case 2: - return Float.class; - default: - return Object.class; - } - } - - @Override - public String getColumnName(int column) - { - switch (column) - { - case 0: - return "Skill Cost"; - case 1: - return "Rank Cost"; - case 2: - return "Max Ranks"; - default: - throw new IndexOutOfBoundsException(); - } - } - - public Object getValueAt(int rowIndex, int columnIndex) - { - if (level == null) - { - return null; - } - SkillCost cost = SkillCost.values()[rowIndex]; - switch (columnIndex) - { - case 0: - return cost; - case 1: - return level.getRankCost(cost); - case 2: - return character.getMaxRanks(cost, level); - default: - throw new IndexOutOfBoundsException(); - } - } - - } - - private static class SkillPointTableModel extends AbstractTableModel - implements ListDataListener - { - - private static final String[] columns = - { - "Level", - "Class", - "Spent", - "Gained" - }; - private final GenericListModel<CharacterLevelFacade> model; - - public SkillPointTableModel(CharacterFacade character) - { - model = character.getLevels(); - model.addListDataListener(this); - } - - public int getRowCount() - { - return model.getSize(); - } - - public int getColumnCount() - { - return columns.length; - } - - @Override - public String getColumnName(int column) - { - return columns[column]; - } - - public Object getValueAt(int rowIndex, int columnIndex) - { - if (columnIndex == 0) - { - return rowIndex + 1; - } - CharacterLevelFacade level = model.getElementAt(rowIndex); - switch (columnIndex) - { - case 1: - return level.getSelectedClass(); - case 2: - return level.getSpentSkillPoints(); - case 3: - return level.getGainedSkillPoints(); - default: - throw new IndexOutOfBoundsException(); - } - } - - @Override - public Class<?> getColumnClass(int columnIndex) - { - switch (columnIndex) - { - case 1: - return ClassFacade.class; - case 0: - case 2: - case 3: - return Integer.class; - default: - return Object.class; - } - } - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) - { - if (columnIndex == 3) - { - return true; - } - return false; - } - - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) - { - CharacterLevelFacade level = model.getElementAt(rowIndex); - level.setGainedSkillPoints((Integer) aValue); - } - - public void intervalAdded(ListDataEvent e) - { - fireTableRowsInserted(e.getIndex0(), e.getIndex1()); - } - - public void intervalRemoved(ListDataEvent e) - { - fireTableRowsDeleted(e.getIndex0(), e.getIndex1()); - } - - public void contentsChanged(ListDataEvent e) - { - fireTableRowsUpdated(e.getIndex0(), e.getIndex1()); - } - - } - - private static class SkillRankSpinnerModel extends AbstractSpinnerModel - { - - private final CharacterFacade character; - private CharacterLevelFacade level; - private SkillFacade skill; - - public SkillRankSpinnerModel(CharacterFacade character) - { - this.character = character; - } - - public Float getValue() - { - return character.getSkillRanks(skill); - } - - public void setSkill(SkillFacade skill) - { - this.skill = skill; - } - - public void setLevel(CharacterLevelFacade level) - { - this.level = level; - } - - public void setValue(Object value) - { - if (value instanceof Float) - { - setValue((Float) value); - } - } - - public void setValue(Float value) - { - SkillCost cost = level.getSkillCost(skill); - if (value < 0) - { - value = Float.valueOf(0); - } - else if (!PCGenUIManager.isHouseRuleSelected(HouseRule.SKILLMAX)) - { - float max = character.getMaxRanks(cost, level); - if (value > max) - { - value = max; - } - } - int points = (int) ((value - getValue()) * level.getRankCost(cost)); - - if (level.investSkillPoints(skill, points)) - { - fireStateChanged(); - } - } - - public Float getNextValue() - { - float value = getValue(); - SkillCost cost = level.getSkillCost(skill); - if (!PCGenUIManager.isHouseRuleSelected(HouseRule.SKILLMAX) && - value == character.getMaxRanks(cost,level)) - { - return null; - } - return value + 1f / level.getRankCost(cost); - } - - public Float getPreviousValue() - { - float value = getValue(); - SkillCost cost = level.getSkillCost(skill); - if (value == 0) - { - return null; - } - return value - 1f / level.getRankCost(cost); - } - - } -} +/* + * SkillInfoTab.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 Jul 10, 2008, 8:03:21 PM + */ +package pcgen.gui2.tabs; + +import pcgen.gui2.tools.CharacterStateEditable; +import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.util.Arrays; +import java.util.Hashtable; +import java.util.List; +import javax.swing.AbstractSpinnerModel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.AbstractTableModel; +import pcgen.cdom.enumeration.SkillCost; +import pcgen.gui2.PCGenUIManager; +import pcgen.gui2.PCGenUIManager.HouseRule; +import pcgen.core.facade.CharacterFacade; +import pcgen.core.facade.CharacterLevelFacade; +import pcgen.core.facade.ClassFacade; +import pcgen.core.facade.SkillFacade; +import pcgen.gui2.filter.FilterableTreeViewModel; +import pcgen.gui2.filter.FilteredTreeViewPanel; +import pcgen.gui2.tools.ChooserPane; +import pcgen.gui2.util.GenericListModel; +import pcgen.gui2.util.JTableEx; +import pcgen.gui2.util.table.TableCellUtilities.SpinnerEditor; +import pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer; +import pcgen.gui2.util.treeview.DataView; +import pcgen.gui2.util.treeview.DataViewColumn; +import pcgen.gui2.util.treeview.DefaultDataViewColumn; +import pcgen.gui2.util.treeview.TreeView; +import pcgen.gui2.util.treeview.TreeViewPath; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class SkillInfoTab extends ChooserPane implements CharacterStateEditable +{ + + private final FilteredTreeViewPanel skillPanel; + private final JTable skillcostTable; + private final JTable skillpointTable; + private SkillTreeViewModel treeviewModel; + private SkillPointTableModel skillpointModel; + private SkillCostTableModel skillcostModel; + private CharacterLevelFacade selectedLevel; + private SkillFacade selectedSkill; + + public SkillInfoTab() + { + this.skillPanel = new FilteredTreeViewPanel(); + this.skillcostTable = new JTableEx(); + this.skillpointTable = new JTableEx(); + initComponents(); + } + + private void initComponents() + { + skillPanel.setDefaultRenderer(Float.class, new SpinnerRenderer()); + ListSelectionModel selectionModel = skillPanel.getSelectionModel(); + selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + selectionModel.addListSelectionListener( + new ListSelectionListener() + { + + public void valueChanged(ListSelectionEvent e) + { + if (!e.getValueIsAdjusting()) + { + List<Object> data = skillPanel.getSelectedData(); + SkillFacade skill = null; + if (!data.isEmpty() && + data.get(0) instanceof SkillFacade) + { + skill = (SkillFacade) data.get(0); + } + setSelectedSkill(skill); + } + } + + }); + setPrimaryChooserComponent(skillPanel); + + JScrollPane tableScrollPane; + JPanel tablePanel = new JPanel(new GridBagLayout()); + GridBagConstraints constraints = new GridBagConstraints(); + + constraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + constraints.fill = java.awt.GridBagConstraints.BOTH; + constraints.ipady = 60; + constraints.weightx = 1.0; + + tableScrollPane = new JScrollPane(skillcostTable, + JScrollPane.VERTICAL_SCROLLBAR_NEVER, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + tablePanel.add(tableScrollPane, constraints); + + constraints.ipady = 0; + constraints.weighty = 1.0; + + tableScrollPane = new JScrollPane(skillpointTable); + tablePanel.add(tableScrollPane, constraints); + setSecondaryChooserComponent(tablePanel); + } + + private void setSelectedSkill(SkillFacade skill) + { + this.selectedSkill = skill; + if (skill != null) + { + setInfoPaneText(skill.getInfo()); + } + } + + private void setSelectedLevel(CharacterLevelFacade selectedLevel) + { + this.selectedLevel = selectedLevel; + skillcostModel.setCharacterLevel(selectedLevel); + treeviewModel.setCharacterLevel(selectedLevel); + } + + public Hashtable<Object, Object> createState(CharacterFacade character) + { + SkillTreeViewModel viewModel = new SkillTreeViewModel(character); + SkillCostTableModel costModel = new SkillCostTableModel(character); + SkillPointTableModel pointModel = new SkillPointTableModel(character); + SkillRankSpinnerEditor rankEditor = new SkillRankSpinnerEditor(character); + + Hashtable<Object, Object> state = skillPanel.createState(character, + viewModel); + state.put(SkillTreeViewModel.class, viewModel); + state.put(SkillCostTableModel.class, costModel); + state.put(SkillPointTableModel.class, pointModel); + state.put(SkillRankSpinnerEditor.class, rankEditor); + state.put("SelectedCharacterLevel", + character.getLevels().getElementAt(0)); + return state; + } + + public void storeState(Hashtable<Object, Object> state) + { + state.put("SelectedCharacterLevel", selectedLevel); + state.put("SelectedSkill", selectedSkill); + } + + public void restoreState(Hashtable<?, ?> state) + { + treeviewModel = (SkillTreeViewModel) state.get(SkillTreeViewModel.class); + skillcostModel = (SkillCostTableModel) state.get(SkillCostTableModel.class); + skillpointModel = (SkillPointTableModel) state.get(SkillPointTableModel.class); + + skillcostTable.setModel(skillcostModel); + skillpointTable.setModel(skillpointModel); + + setSelectedLevel((CharacterLevelFacade) state.get("SelectedCharacterLevel")); + + skillPanel.restoreState(state); + skillPanel.setDefaultEditor(Float.class, (SkillRankSpinnerEditor) state.get( + SkillRankSpinnerEditor.class)); + + setSelectedSkill((SkillFacade) state.get("SelectedSkill")); + } + + private class SkillRankSpinnerEditor extends SpinnerEditor + { + + private final SkillRankSpinnerModel model; + + public SkillRankSpinnerEditor(CharacterFacade character) + { + this(new SkillRankSpinnerModel(character)); + } + + private SkillRankSpinnerEditor(SkillRankSpinnerModel model) + { + super(model); + this.model = model; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, + int row, + int column) + { + model.setSkill(selectedSkill); + model.setLevel(selectedLevel); + return spinner; + } + + } + + private static final class SkillTreeViewModel implements FilterableTreeViewModel<SkillFacade>, + DataView<SkillFacade> + { + + private enum SkillTreeView implements TreeView<SkillFacade> + { + + NAME("Name"), + TYPE_NAME("Type/Name"), + KEYSTAT_NAME("Key Stat/Name"), + KEYSTAT_TYPE_NAME("Key Stat/Type/Name"); + private String name; + + private SkillTreeView(String name) + { + this.name = name; + } + + public String getViewName() + { + return name; + } + + @SuppressWarnings("unchecked") + public List<TreeViewPath<SkillFacade>> getPaths(SkillFacade pobj) + { + TreeViewPath<SkillFacade> path; + switch (this) + { + case NAME: + path = new TreeViewPath<SkillFacade>(pobj); + break; + case TYPE_NAME: + path = new TreeViewPath<SkillFacade>(pobj, + pobj.getType()); + break; + case KEYSTAT_NAME: + path = new TreeViewPath<SkillFacade>(pobj, + pobj.getKeyStat()); + break; + case KEYSTAT_TYPE_NAME: + path = new TreeViewPath<SkillFacade>(pobj, + pobj.getKeyStat(), + pobj.getType()); + break; + default: + throw new InternalError(); + } + return Arrays.asList(path); + } + + } + private final TreeView<SkillFacade> COST_NAME = new TreeView<SkillFacade>() + { + + public String getViewName() + { + return "Cost/Name"; + } + + @SuppressWarnings("unchecked") + public List<TreeViewPath<SkillFacade>> getPaths(SkillFacade pobj) + { + return Arrays.asList(new TreeViewPath<SkillFacade>(pobj, + level.getSkillCost( + pobj))); + } + + }; + private final TreeView<SkillFacade> COST_TYPE_NAME = new TreeView<SkillFacade>() + { + + public String getViewName() + { + return "Cost/Type/Name"; + } + + @SuppressWarnings("unchecked") + public List<TreeViewPath<SkillFacade>> getPaths(SkillFacade pobj) + { + return Arrays.asList( + new TreeViewPath<SkillFacade>(pobj, + level.getSkillCost(pobj), + pobj.getType())); + } + + }; + private static final List<? extends DataViewColumn> columns = Arrays.asList( + new DefaultDataViewColumn("Total", Integer.class, true), + new DefaultDataViewColumn("Modifier", Integer.class, true), + new DefaultDataViewColumn("Ranks", Float.class, true, true), + new DefaultDataViewColumn("Skill Cost", SkillCost.class, true), + new DefaultDataViewColumn("Source", String.class)); + private CharacterFacade character; + private CharacterLevelFacade level; + + public SkillTreeViewModel(CharacterFacade character) + { + this.character = character; + } + + public void setCharacterLevel(CharacterLevelFacade level) + { + this.level = level; + } + + public Class<SkillFacade> getFilterClass() + { + return SkillFacade.class; + } + + public List<?> getData(SkillFacade obj) + { + return Arrays.asList( + character.getSkillTotal(obj), + character.getSkillModifier(obj), + Float.valueOf(character.getSkillRanks(obj)), + level.getSkillCost(obj), + obj.getSource()); + } + + public List<? extends DataViewColumn> getDataColumns() + { + return columns; + } + + public DataView<SkillFacade> getDataView() + { + return this; + } + + @SuppressWarnings("unchecked") + public List<? extends TreeView<SkillFacade>> getTreeViews() + { + return Arrays.asList(SkillTreeView.NAME, + SkillTreeView.TYPE_NAME, + SkillTreeView.KEYSTAT_NAME, + SkillTreeView.KEYSTAT_TYPE_NAME, + COST_NAME, + COST_TYPE_NAME); + } + + public int getDefaultTreeViewIndex() + { + return 0; + } + + public GenericListModel<SkillFacade> getDataModel() + { + return character.getDataSet().getSkills(); + } + + } + + private static class SkillCostTableModel extends AbstractTableModel + { + + private CharacterLevelFacade level; + private CharacterFacade character; + + public SkillCostTableModel(CharacterFacade character) + { + this.character = character; + } + + public void setCharacterLevel(CharacterLevelFacade level) + { + this.level = level; + fireTableRowsUpdated(0, 2); + } + + public int getRowCount() + { + return 3; + } + + public int getColumnCount() + { + return 3; + } + + @Override + public Class<?> getColumnClass(int columnIndex) + { + switch (columnIndex) + { + case 0: + return String.class; + case 1: + return Integer.class; + case 2: + return Float.class; + default: + return Object.class; + } + } + + @Override + public String getColumnName(int column) + { + switch (column) + { + case 0: + return "Skill Cost"; + case 1: + return "Rank Cost"; + case 2: + return "Max Ranks"; + default: + throw new IndexOutOfBoundsException(); + } + } + + public Object getValueAt(int rowIndex, int columnIndex) + { + if (level == null) + { + return null; + } + SkillCost cost = SkillCost.values()[rowIndex]; + switch (columnIndex) + { + case 0: + return cost; + case 1: + return level.getRankCost(cost); + case 2: + return character.getMaxRanks(cost, level); + default: + throw new IndexOutOfBoundsException(); + } + } + + } + + private static class SkillPointTableModel extends AbstractTableModel + implements ListDataListener + { + + private static final String[] columns = + { + "Level", + "Class", + "Spent", + "Gained" + }; + private final GenericListModel<CharacterLevelFacade> model; + + public SkillPointTableModel(CharacterFacade character) + { + model = character.getLevels(); + model.addListDataListener(this); + } + + public int getRowCount() + { + return model.getSize(); + } + + public int getColumnCount() + { + return columns.length; + } + + @Override + public String getColumnName(int column) + { + return columns[column]; + } + + public Object getValueAt(int rowIndex, int columnIndex) + { + if (columnIndex == 0) + { + return rowIndex + 1; + } + CharacterLevelFacade level = model.getElementAt(rowIndex); + switch (columnIndex) + { + case 1: + return level.getSelectedClass(); + case 2: + return level.getSpentSkillPoints(); + case 3: + return level.getGainedSkillPoints(); + default: + throw new IndexOutOfBoundsException(); + } + } + + @Override + public Class<?> getColumnClass(int columnIndex) + { + switch (columnIndex) + { + case 1: + return ClassFacade.class; + case 0: + case 2: + case 3: + return Integer.class; + default: + return Object.class; + } + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) + { + if (columnIndex == 3) + { + return true; + } + return false; + } + + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) + { + CharacterLevelFacade level = model.getElementAt(rowIndex); + level.setGainedSkillPoints((Integer) aValue); + } + + public void intervalAdded(ListDataEvent e) + { + fireTableRowsInserted(e.getIndex0(), e.getIndex1()); + } + + public void intervalRemoved(ListDataEvent e) + { + fireTableRowsDeleted(e.getIndex0(), e.getIndex1()); + } + + public void contentsChanged(ListDataEvent e) + { + fireTableRowsUpdated(e.getIndex0(), e.getIndex1()); + } + + } + + private static class SkillRankSpinnerModel extends AbstractSpinnerModel + { + + private final CharacterFacade character; + private CharacterLevelFacade level; + private SkillFacade skill; + + public SkillRankSpinnerModel(CharacterFacade character) + { + this.character = character; + } + + public Float getValue() + { + return character.getSkillRanks(skill); + } + + public void setSkill(SkillFacade skill) + { + this.skill = skill; + } + + public void setLevel(CharacterLevelFacade level) + { + this.level = level; + } + + public void setValue(Object value) + { + if (value instanceof Float) + { + setValue((Float) value); + } + } + + public void setValue(Float value) + { + SkillCost cost = level.getSkillCost(skill); + if (value < 0) + { + value = Float.valueOf(0); + } + else if (!PCGenUIManager.isHouseRuleSelected(HouseRule.SKILLMAX)) + { + float max = character.getMaxRanks(cost, level); + if (value > max) + { + value = max; + } + } + int points = (int) ((value - getValue()) * level.getRankCost(cost)); + + if (level.investSkillPoints(skill, points)) + { + fireStateChanged(); + } + } + + public Float getNextValue() + { + float value = getValue(); + SkillCost cost = level.getSkillCost(skill); + if (!PCGenUIManager.isHouseRuleSelected(HouseRule.SKILLMAX) && + value == character.getMaxRanks(cost, level)) + { + return null; + } + return value + 1f / level.getRankCost(cost... [truncated message content] |
From: <cpm...@us...> - 2010-03-26 21:48:49
|
Revision: 11541 http://pcgen.svn.sourceforge.net/pcgen/?rev=11541&view=rev Author: cpmeister Date: 2010-03-26 21:48:42 +0000 (Fri, 26 Mar 2010) Log Message: ----------- SummaryInfoTab update, added to current demo Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2010-03-26 03:26:00 UTC (rev 11540) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2010-03-26 21:48:42 UTC (rev 11541) @@ -47,6 +47,7 @@ { setTabPlacement(JTabbedPane.TOP); //TODO: Revise this be more dynamic + addTab("Summary", new SummaryInfoTab()); addTab("Classes", new ClassInfoTab()); addTab("Skills", new SkillInfoTab()); addTab("Feats and Abilities", new AbilitiesInfoTab()); Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-03-26 03:26:00 UTC (rev 11540) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-03-26 21:48:42 UTC (rev 11541) @@ -121,13 +121,21 @@ private void initComponents() { + languageTabButton.setText("Open Language, Wpn Prof & SA Tab"); + raceTabButton.setText("Open Race Tab"); + classTabButton.setText("Open Class Tab"); + descTabButton.setText("Open Description Tab"); + sheetTabButton.setText("Open Character Sheet Tab"); + createMonsterButton.setText("Create Monster Character"); + expaddButton.setText("+"); + expsubtractButton.setText("-"); setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); setPanelTitle(basicsPanel, "Character Basics"); basicsPanel.setLayout(new GridBagLayout()); gbc.fill = GridBagConstraints.BOTH; - gbc.weightx = 0.5; + gbc.weightx = 0.2; add(basicsPanel, gbc); setPanelTitle(todoPanel, "Things To Be Done"); @@ -137,14 +145,14 @@ setPanelTitle(scoresPanel, "Ability Scores"); gbc.gridy = GridBagConstraints.RELATIVE; - gbc.weightx = 1.0; + gbc.weightx = 0.5; add(scoresPanel, gbc); JPanel rightPanel = new JPanel(); setPanelTitle(racePanel, "Race"); setPanelTitle(classPanel, "Class & Level"); initRightPanel(rightPanel); - gbc.weightx = 0.5; + gbc.weightx = 1; add(rightPanel, gbc); } @@ -164,6 +172,8 @@ /* * initialize Components */ + racePanel.setOpaque(false); + classPanel.setOpaque(false); JPanel levelPanel = new JPanel(); JLabel raceLabel = createLabel("Race:"); JLabel ageLabel = createLabel("Age:"); @@ -203,70 +213,35 @@ layout.putConstraint(SpringLayout.SOUTH, racePanel, racePanelInsets.bottom, SpringLayout.SOUTH, createMonsterButton); - /* - * raceLabel constraints - */ - layout.putConstraint(SpringLayout.WEST, raceLabel, - racePanelInsets.left, - SpringLayout.WEST, racePanel); - layout.putConstraint(SpringLayout.NORTH, raceLabel, - racePanelInsets.top, - SpringLayout.NORTH, racePanel); - /* - * raceComboBox constraints - */ - layout.putConstraint(SpringLayout.EAST, raceComboBox, - -racePanelInsets.right, - SpringLayout.EAST, racePanel); + + + setSpringLayerConstraints(layout, racePanel, racePanelInsets, comboBoxSpring, + raceLabel, raceComboBox, null); layout.putConstraint(SpringLayout.NORTH, raceComboBox, racePanelInsets.top, SpringLayout.NORTH, racePanel); - layout.putConstraint(SpringLayout.WEST, raceComboBox, - comboBoxSpring, - SpringLayout.WEST, racePanel); - /* - * ageLabel constraints - */ - layout.putConstraint(SpringLayout.WEST, ageLabel, - racePanelInsets.left, - SpringLayout.WEST, racePanel); - layout.putConstraint(SpringLayout.NORTH, ageLabel, - 0, - SpringLayout.SOUTH, raceComboBox); + setSpringLayerConstraints(layout, racePanel, racePanelInsets, comboBoxSpring, + ageLabel, ageComboBox, raceComboBox); + /* * ageField constraints */ layout.putConstraint(SpringLayout.WEST, ageField, 0, SpringLayout.EAST, ageLabel); + layout.putConstraint(SpringLayout.EAST, ageField, + 0, + SpringLayout.WEST, ageComboBox); layout.putConstraint(SpringLayout.NORTH, ageField, - racePanelInsets.top, - SpringLayout.SOUTH, raceComboBox); - /* - * ageComboBox constraints - */ - layout.putConstraint(SpringLayout.EAST, ageComboBox, - -racePanelInsets.right, - SpringLayout.EAST, racePanel); - layout.putConstraint(SpringLayout.NORTH, ageComboBox, 0, - SpringLayout.SOUTH, raceComboBox); - layout.putConstraint(SpringLayout.WEST, ageComboBox, - comboBoxSpring, - SpringLayout.WEST, racePanel); - /* - * createMonsterButton - */ - layout.putConstraint(SpringLayout.WEST, createMonsterButton, - racePanelInsets.left, - SpringLayout.WEST, racePanel); - layout.putConstraint(SpringLayout.NORTH, createMonsterButton, + SpringLayout.NORTH, ageComboBox); + layout.putConstraint(SpringLayout.SOUTH, ageField, 0, SpringLayout.SOUTH, ageComboBox); - layout.putConstraint(SpringLayout.EAST, createMonsterButton, - -racePanelInsets.right, - SpringLayout.EAST, racePanel); + + setSpringLayerConstraints(layout, racePanel, racePanelInsets, + createMonsterButton, ageComboBox, 0); /* * classPanel */ @@ -282,130 +257,44 @@ layout.putConstraint(SpringLayout.SOUTH, classPanel, 0, SpringLayout.SOUTH, springPanel); - /* - * classLabel - */ - layout.putConstraint(SpringLayout.WEST, classLabel, - classPanelInsets.left, - SpringLayout.WEST, classPanel); - layout.putConstraint(SpringLayout.NORTH, classLabel, - classPanelInsets.top, - SpringLayout.NORTH, classPanel); - /* - * classComboBox - */ - layout.putConstraint(SpringLayout.WEST, classComboBox, - comboBoxSpring, - SpringLayout.WEST, classPanel); + + setSpringLayerConstraints(layout, classPanel, classPanelInsets, comboBoxSpring, + classLabel, classComboBox, null); layout.putConstraint(SpringLayout.NORTH, classComboBox, classPanelInsets.top, SpringLayout.NORTH, classPanel); - layout.putConstraint(SpringLayout.EAST, classComboBox, - -classPanelInsets.right, - SpringLayout.EAST, classPanel); - /* - * levelPanel - */ - layout.putConstraint(SpringLayout.NORTH, levelPanel, - 10, - SpringLayout.SOUTH, classComboBox); - layout.putConstraint(SpringLayout.WEST, levelPanel, - classPanelInsets.left, - SpringLayout.WEST, classPanel); - layout.putConstraint(SpringLayout.EAST, levelPanel, - -classPanelInsets.right, - SpringLayout.EAST, classPanel); - /* - * expLabel - */ - layout.putConstraint(SpringLayout.NORTH, expLabel, + + setSpringLayerConstraints(layout, classPanel, classPanelInsets, + levelPanel, classComboBox, 10); + + setSpringLayerConstraints(layout, classPanel, classPanelInsets, comboBoxSpring, + expLabel, expField, levelPanel); + + setSpringLayerConstraints(layout, classPanel, classPanelInsets, comboBoxSpring, + nextlevelLabel, nextlevelField, expField); + + setSpringLayerConstraints(layout, classPanel, classPanelInsets, + expmodLabel, nextlevelField, 10); + + + + JPanel panel = new JPanel(new GridBagLayout()); + { + GridBagConstraints gbc = new GridBagConstraints(); + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.weightx = 1.0; + panel.add(expaddButton, gbc); + panel.add(expsubtractButton, gbc); + } + setSpringLayerConstraints(layout, classPanel, classPanelInsets, comboBoxSpring, + panel, expmodField, expmodLabel); + layout.putConstraint(SpringLayout.EAST, panel, 0, - SpringLayout.SOUTH, levelPanel); - layout.putConstraint(SpringLayout.WEST, expLabel, - classPanelInsets.left, - SpringLayout.WEST, classPanel); - /* - * expField - */ - layout.putConstraint(SpringLayout.NORTH, expField, - 0, - SpringLayout.SOUTH, levelPanel); - layout.putConstraint(SpringLayout.WEST, expField, - comboBoxSpring, - SpringLayout.WEST, classPanel); - layout.putConstraint(SpringLayout.EAST, expField, - -classPanelInsets.right, - SpringLayout.EAST, classPanel); - /* - * nextlevelLabel - */ - layout.putConstraint(SpringLayout.NORTH, nextlevelLabel, - 0, - SpringLayout.SOUTH, expField); - layout.putConstraint(SpringLayout.WEST, nextlevelLabel, - classPanelInsets.left, - SpringLayout.WEST, classPanel); - /* - * nextlevelField - */ - layout.putConstraint(SpringLayout.NORTH, nextlevelField, - 0, - SpringLayout.SOUTH, expField); - layout.putConstraint(SpringLayout.WEST, nextlevelField, - comboBoxSpring, - SpringLayout.WEST, classPanel); - layout.putConstraint(SpringLayout.EAST, nextlevelField, - -classPanelInsets.right, - SpringLayout.EAST, classPanel); - /* - * expmodLabel - */ - layout.putConstraint(SpringLayout.NORTH, expmodLabel, - 10, - SpringLayout.SOUTH, nextlevelField); - layout.putConstraint(SpringLayout.WEST, expmodLabel, - classPanelInsets.left, - SpringLayout.WEST, classPanel); - layout.putConstraint(SpringLayout.EAST, expmodLabel, - -classPanelInsets.right, - SpringLayout.EAST, classPanel); - /* - * expaddButton - */ - layout.putConstraint(SpringLayout.NORTH, expaddButton, - 0, - SpringLayout.SOUTH, expmodLabel); - layout.putConstraint(SpringLayout.WEST, expaddButton, - classPanelInsets.left, - SpringLayout.WEST, classPanel); - /* - * expsubtractButton - */ - layout.putConstraint(SpringLayout.NORTH, expsubtractButton, - 0, - SpringLayout.SOUTH, expmodLabel); - layout.putConstraint(SpringLayout.WEST, expsubtractButton, - 0, - SpringLayout.EAST, expaddButton); - layout.putConstraint(SpringLayout.EAST, expsubtractButton, - 0, SpringLayout.WEST, expmodField); - /* - * expmodField - */ - layout.putConstraint(SpringLayout.NORTH, expmodField, - 0, - SpringLayout.SOUTH, expmodLabel); - layout.putConstraint(SpringLayout.WEST, expmodField, - comboBoxSpring, - SpringLayout.WEST, classPanel); - layout.putConstraint(SpringLayout.EAST, expmodField, - -classPanelInsets.right, - SpringLayout.EAST, classPanel); layout.putConstraint(SpringLayout.SOUTH, expmodField, -classPanelInsets.bottom, SpringLayout.SOUTH, classPanel); - + springPanel.add(panel); springPanel.add(racePanel); springPanel.add(raceLabel); springPanel.add(raceComboBox); @@ -423,11 +312,50 @@ springPanel.add(nextlevelLabel); springPanel.add(nextlevelField); springPanel.add(expmodLabel); - springPanel.add(expaddButton); - springPanel.add(expsubtractButton); springPanel.add(expmodField); } + private static void setSpringLayerConstraints(SpringLayout layout, JPanel panel, Insets insets, + JComponent comp, JComponent above, int pad) + { + layout.putConstraint(SpringLayout.NORTH, comp, + pad, + SpringLayout.SOUTH, above); + layout.putConstraint(SpringLayout.WEST, comp, + insets.left, + SpringLayout.WEST, panel); + layout.putConstraint(SpringLayout.EAST, comp, + -insets.right, + SpringLayout.EAST, panel); + } + + private static void setSpringLayerConstraints(SpringLayout layout, JPanel panel, Insets insets, Spring compSpring, + JComponent label, JComponent comp, JComponent above) + { + layout.putConstraint(SpringLayout.WEST, label, + insets.left, + SpringLayout.WEST, panel); + layout.putConstraint(SpringLayout.NORTH, label, + 0, + SpringLayout.NORTH, comp); + layout.putConstraint(SpringLayout.SOUTH, label, + 0, + SpringLayout.SOUTH, comp); + + layout.putConstraint(SpringLayout.WEST, comp, + compSpring, + SpringLayout.WEST, panel); + layout.putConstraint(SpringLayout.EAST, comp, + -insets.right, + SpringLayout.EAST, panel); + if (above != null) + { + layout.putConstraint(SpringLayout.NORTH, comp, + 0, + SpringLayout.SOUTH, above); + } + } + private static Spring maxSpring(Spring... springs) { if (springs.length > 0) @@ -443,8 +371,12 @@ throw new IllegalArgumentException(); } - private JLabel createLabel(String text) + private void initLevelPanel(JPanel panel) { + } + + private static JLabel createLabel(String text) + { JLabel label = new JLabel(text); label.setFont(labelFont); return label; @@ -512,8 +444,11 @@ gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; - gbc.insets = insets; - panel.add(comp); + if (insets != null) + { + gbc.insets = insets; + } + panel.add(comp, gbc); } private void addGridBagLayer(JPanel panel, Font font, JComponent comp) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2010-05-12 01:36:42
|
Revision: 11817 http://pcgen.svn.sourceforge.net/pcgen/?rev=11817&view=rev Author: cpmeister Date: 2010-05-12 01:36:28 +0000 (Wed, 12 May 2010) Log Message: ----------- Summary Tab update Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/ClassLevelTableModel.java Added Paths: ----------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-12 01:31:14 UTC (rev 11816) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-12 01:36:28 UTC (rev 11817) @@ -20,8 +20,8 @@ */ package pcgen.gui2.tabs; +import pcgen.gui2.tabs.summary.StatTableModel; import pcgen.gui2.tabs.summary.ClassLevelTableModel; -import java.awt.Component; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -48,10 +48,6 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListDataEvent; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.DefaultTableColumnModel; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.TableModel; import pcgen.core.facade.AlignmentFacade; import pcgen.core.facade.CharacterFacade; import pcgen.core.facade.ClassFacade; @@ -61,15 +57,10 @@ import pcgen.core.facade.RaceFacade; import pcgen.core.facade.ReferenceFacade; import pcgen.core.facade.SimpleFacade; -import pcgen.core.facade.StatFacade; -import pcgen.core.facade.event.ListEvent; -import pcgen.core.facade.event.ListListener; import pcgen.core.facade.event.ReferenceEvent; import pcgen.core.facade.event.ReferenceListener; import pcgen.core.facade.util.DefaultListFacade; -import pcgen.core.facade.util.ListFacade; import pcgen.gui2.tabs.summary.LanguageTableModel; -import pcgen.gui2.tabs.summary.Utilities; import pcgen.gui2.tools.CharacterStateEditable; import pcgen.gui2.util.FacadeComboBoxModel; import pcgen.gui2.util.SignIcon; @@ -197,25 +188,8 @@ private void initMiddlePanel(JPanel middlePanel) { middlePanel.setLayout(new GridBagLayout()); + StatTableModel.initializeTable(statsTable); - statsTable.setAutoCreateColumnsFromModel(false); - DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); - { - columnModel.addColumn(Utilities.createTableColumn(0, "Ability", null, true)); - columnModel.addColumn(Utilities.createTableColumn(1, "Score", null, true)); - String htmlText = "<html><p align=\"center\">Ability<br>Mod</p></html>"; - columnModel.addColumn(Utilities.createTableColumn(2, htmlText, - new FixedHeaderCellRenderer(htmlText), true)); - columnModel.addColumn(Utilities.createTableColumn(3, "Editable Score", null, true)); - htmlText = "<html><p align=\"center\">Race<br>Mod</p></html>"; - columnModel.addColumn(Utilities.createTableColumn(4, htmlText, - new FixedHeaderCellRenderer(htmlText), true)); - htmlText = "<html><p align=\"center\">Misc<br>Mod</p></html>"; - columnModel.addColumn(Utilities.createTableColumn(5, htmlText, - new FixedHeaderCellRenderer(htmlText), true)); - } - statsTable.setColumnModel(columnModel); - statsTable.setShowVerticalLines(false); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1; @@ -224,25 +198,6 @@ middlePanel.add(new JScrollPane(statsTable), gbc); } - /* - * This class is a hack that gives the TableHeaderUI a dummy component to - * so that it can be used when calculating the height of the JTableHeader. - */ - private static class FixedHeaderCellRenderer extends JLabel implements TableCellRenderer - { - - public FixedHeaderCellRenderer(String text) - { - setText(text); - } - - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) - { - return table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - } - - } - private void initRightPanel(JPanel rightPanel) { rightPanel.setLayout(new GridBagLayout()); @@ -644,6 +599,7 @@ ((PlayerNameHandler) state.get(Models.PlayerNameHandler)).install(); ((TabNameHandler) state.get(Models.TabNameHandler)).install(); ((LanguageTableModel) state.get(Models.LanguageTableModel)).install(languageTable); + ((StatTableModel) state.get(Models.StatTableModel)).install(statsTable); ((ClassLevelTableModel) state.get(Models.ClassLevelTableModel)).install(classLevelTable, classComboBox); genderComboBox.setModel((ComboBoxModel) state.get(Models.GenderComboBoxModel)); handsComboBox.setModel((ComboBoxModel) state.get(Models.HandsComboBoxModel)); @@ -653,7 +609,6 @@ classComboBox.setModel((ComboBoxModel) state.get(Models.ClassComboBoxModel)); addLevelsButton.setAction((Action) state.get(Models.AddLevelsAction)); removeLevelsButton.setAction((Action) state.get(Models.RemoveLevelsAction)); - statsTable.setModel((TableModel) state.get(Models.StatTableModel)); resetBasicsPanel(); } @@ -841,77 +796,4 @@ } - private static class StatTableModel extends AbstractTableModel - implements ListListener, ReferenceListener<Integer> - { - - private CharacterFacade character; - private ListFacade<StatFacade> stats; - - public StatTableModel(CharacterFacade character) - { - this.character = character; - this.stats = character.getDataSet().getStats(); - } - - public int getRowCount() - { - return stats.getSize(); - } - - @Override - public Class<?> getColumnClass(int columnIndex) - { - if (columnIndex == 0) - { - return Object.class; - } - return Integer.class; - } - - public int getColumnCount() - { - return 6; - } - - public Object getValueAt(int rowIndex, int columnIndex) - { - StatFacade stat = stats.getElementAt(rowIndex); - switch (columnIndex) - { - case 0: - return stat; - case 2: - return character.getMod(stat); - case 4: - return 0; - case 5: - return 0; - default: - return character.getScore(stat).getReference(); - } - } - - public void elementAdded(ListEvent e) - { - fireTableRowsInserted(e.getIndex(), e.getIndex()); - } - - public void elementRemoved(ListEvent e) - { - fireTableRowsDeleted(e.getIndex(), e.getIndex()); - } - - public void elementsChanged(ListEvent e) - { - fireTableDataChanged(); - } - - public void referenceChanged(ReferenceEvent<Integer> e) - { - fireTableDataChanged(); - } - - } - } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/ClassLevelTableModel.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/ClassLevelTableModel.java 2010-05-12 01:31:14 UTC (rev 11816) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/ClassLevelTableModel.java 2010-05-12 01:36:28 UTC (rev 11817) @@ -52,7 +52,6 @@ public static void initializeTable(JTable classLevelTable) { JTableHeader tableHeader = classLevelTable.getTableHeader(); - tableHeader.setFont(new Font("Tahoma", Font.PLAIN, 12)); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); TableColumnModel columnModel = new DefaultTableColumnModel(); @@ -69,8 +68,6 @@ classLevelTable.setRowHeight(20); } - - public void install(JTable table, JComboBox classComboBox) { this.classComboBox = classComboBox; Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java 2010-05-12 01:36:28 UTC (rev 11817) @@ -0,0 +1,165 @@ +package pcgen.gui2.tabs.summary; + +import java.awt.Component; +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SpinnerNumberModel; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import pcgen.core.facade.CharacterFacade; +import pcgen.core.facade.StatFacade; +import pcgen.core.facade.event.ListEvent; +import pcgen.core.facade.event.ListListener; +import pcgen.core.facade.event.ReferenceEvent; +import pcgen.core.facade.event.ReferenceListener; +import pcgen.core.facade.util.ListFacade; +import pcgen.gui2.util.table.TableCellUtilities; + +public class StatTableModel extends AbstractTableModel implements ListListener, ReferenceListener<Integer> +{ + + private CharacterFacade character; + private ListFacade<StatFacade> stats; + + public StatTableModel(CharacterFacade character) + { + this.character = character; + this.stats = character.getDataSet().getStats(); + } + + public int getRowCount() + { + return stats.getSize(); + } + + public static void initializeTable(JTable statsTable) + { + statsTable.setAutoCreateColumnsFromModel(false); + DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); + { + columnModel.addColumn(Utilities.createTableColumn(0, "Ability", null, true)); + columnModel.addColumn(Utilities.createTableColumn(1, "Score", + new FixedHeaderCellRenderer("Score"), false)); + String htmlText = "<html><p align=\"center\">Ability<br>Mod</p></html>"; + columnModel.addColumn(Utilities.createTableColumn(2, htmlText, + new FixedHeaderCellRenderer(htmlText), false)); + + TableColumn column = Utilities.createTableColumn(3, "Editable Score", null, true); + column.setIdentifier("EDITABLE"); + columnModel.addColumn(column); + + htmlText = "<html><p align=\"center\">Race<br>Mod</p></html>"; + columnModel.addColumn(Utilities.createTableColumn(4, htmlText, + new FixedHeaderCellRenderer(htmlText), false)); + htmlText = "<html><p align=\"center\">Misc<br>Mod</p></html>"; + columnModel.addColumn(Utilities.createTableColumn(5, htmlText, + new FixedHeaderCellRenderer(htmlText), false)); + } + statsTable.setColumnModel(columnModel); + statsTable.setShowVerticalLines(false); + statsTable.setRowHeight(22); + } + + /* + * This class is a hack that gives the TableHeaderUI a dummy component + * so that it can be used when calculating the height of the JTableHeader. + */ + private static class FixedHeaderCellRenderer extends JLabel implements TableCellRenderer + { + + public FixedHeaderCellRenderer(String text) + { + setText(text); + setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 5)); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) + { + if (table == null) + { + return this; + } + return table.getTableHeader().getDefaultRenderer().getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } + + } + + public void install(JTable table) + { + table.setModel(this); + TableColumn column = table.getColumn("EDITABLE"); + column.setCellRenderer(new TableCellUtilities.SpinnerRenderer()); + column.setCellEditor(new TableCellUtilities.SpinnerEditor(new SpinnerNumberModel(0, 0, null, 1))); + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) + { + return columnIndex == 3; + } + + @Override + public Class<?> getColumnClass(int columnIndex) + { + if (columnIndex == 0) + { + return Object.class; + } + return Integer.class; + } + + public int getColumnCount() + { + return 6; + } + + public Object getValueAt(int rowIndex, int columnIndex) + { + StatFacade stat = stats.getElementAt(rowIndex); + switch (columnIndex) + { + case 0: + return stat; + case 2: + return character.getMod(stat); + case 4: + return 0; + case 5: + return 0; + default: + return character.getScore(stat).getReference(); + } + } + + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) + { + Number number = (Number) aValue; + character.setScore(stats.getElementAt(rowIndex), number.intValue()); + fireTableRowsUpdated(rowIndex, rowIndex); + } + + public void elementAdded(ListEvent e) + { + fireTableRowsInserted(e.getIndex(), e.getIndex()); + } + + public void elementRemoved(ListEvent e) + { + fireTableRowsDeleted(e.getIndex(), e.getIndex()); + } + + public void elementsChanged(ListEvent e) + { + fireTableDataChanged(); + } + + public void referenceChanged(ReferenceEvent<Integer> e) + { + fireTableDataChanged(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2010-05-22 23:31:28
|
Revision: 11942 http://pcgen.svn.sourceforge.net/pcgen/?rev=11942&view=rev Author: cpmeister Date: 2010-05-22 23:31:22 +0000 (Sat, 22 May 2010) Log Message: ----------- Corrected display issue on Summary Tab Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java 2010-05-22 23:27:38 UTC (rev 11941) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java 2010-05-22 23:31:22 UTC (rev 11942) @@ -26,6 +26,36 @@ import pcgen.core.facade.CharacterFacade; /** + * This interface must be implemented by all tabs that display character + * information, i.c. summary tab, classes tab, abilities tab, inventory tab. + * The goal of this class is to create a separation of UI models and the UI components + * that use them. By doing this, knowledge of the CharacterFacade can be isolated from + * the tab itself and stored solely within the models that use the CharacterFacade. + * These models can then be cached so that new models are not created each time a + * charcter is selected. Reusing models, although it increases overhead, can make + * swiching between character tabs several times faster than if a new model was created + * each time. A fast UI greatly enhances a user's experience when using a program. + * <br> + * To achieve this speed goal this interface defines the following methods:<br> + * <code> + * createState(Character)<br> + * restoreState(Hashtable)<br> + * storeState(Hashtable)<br> + * </code> + * These methods are used by the character tab handler to allow each + * tab to independently store and manage its own UI models within a + * hashtable of its own creation. + * Each of these methods are used in a defined order. When a new character is created + * the <code>createState</code> is called by the tab handler to create the models + * for this tab. Whenever characters selection occurs, the tab handler calls + * <code>storeState</code> with the old selected character's state hashtable followed by + * a call to <code>restoreState</code> with the new selected character's state hashtable. + * It is guaranteed that any call to <code>restoreState</code> will be preceded by a + * call to <code>storeState</code> if a character is currently displayed on this tab. + * <br> + * Note: The states crated by the a tab's <code>createState</code> are guaranteed to not + * be modified in anyway by the tab handler. The only changes that would occur to any + * state would be in a call to <code>storeState</code>. * * @author Connor Petty <cpm...@us...> */ @@ -37,12 +67,36 @@ * it will use for a given character into a Hashtable. This * returned Hashtable will be used as arguments in storeState(Hashtable) * and restoreState(Hashtable). + * <br> + * Note: Character tabs implementing this method should <b>NOT</b> make + * any changes to its UI components, this method is purely meant to create + * models and making changes to the UI components could produce undesirable + * side effects. * @param character the character that this state is for. - * @return + * @return a hashtable containing the UI models created for this character */ public Hashtable<Object, Object> createState(CharacterFacade character); /** + * This restores this character tab to a state that contains + * the models for some given character. The models in question were + * created during the call to <code>createState(CharacterFacade)</code> + * When this is called the tab should attach the models contained within + * this state to the UI components of this tab. + * @param state a hashtable containing the models for this character + */ + public void restoreState(Hashtable<?, ?> state); + + /** + * This is called to save any character specific info that might + * have changed since <code>restoreState</code> was called. Implementors + * might also use this method to detach non swappable models from the UI + * components, i.e. listeners. + * @param state a hashtable that contains the models for some character + */ + public void storeState(Hashtable<Object,Object> state); + + /** * this returns an Action that will be used by the InfoTabbedPane * to render the tab's title. Any changes in the Action's properties * will be immediately rendered onto the tab's title space. Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-22 23:27:38 UTC (rev 11941) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-22 23:31:22 UTC (rev 11942) @@ -41,6 +41,7 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; +import javax.swing.JEditorPane; import javax.swing.JFormattedTextField; import javax.swing.JLabel; import javax.swing.JPanel; @@ -52,11 +53,8 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListDataEvent; +import javax.swing.text.html.HTMLDocument; -import org.lobobrowser.html.HtmlRendererContext; -import org.lobobrowser.html.gui.HtmlPanel; -import org.lobobrowser.html.test.SimpleHtmlRendererContext; - import pcgen.core.facade.AlignmentFacade; import pcgen.core.facade.CharacterFacade; import pcgen.core.facade.ClassFacade; @@ -120,9 +118,8 @@ private final JButton expsubtractButton; private final JButton addLevelsButton; private final JButton removeLevelsButton; - private final HtmlPanel infoHtmlPanel; - private String currentInfoTemplateFile; - + private final JEditorPane infoHtmlPanel; + public SummaryInfoTab() { this.basicsPanel = new JPanel(); @@ -155,14 +152,14 @@ this.removeLevelsButton = new JButton(); this.expaddButton = createSignButton(Sign.Plus); this.expsubtractButton = createSignButton(Sign.Minus); - this.infoHtmlPanel = new HtmlPanel(); + this.infoHtmlPanel = new JEditorPane(); initComponents(); } private void initComponents() { setFont(textFont); - + createMonsterButton.setText("Create Monster Character"); LanguageTableModel.initializeTable(languageTable); @@ -203,7 +200,7 @@ } infoHtmlPanel.setMinimumSize(size); add(infoHtmlPanel, gbc); - + JPanel rightPanel = new JPanel(); setPanelTitle(racePanel, "Race"); setPanelTitle(classPanel, "Class & Level"); @@ -237,13 +234,11 @@ middlePanel.add(new JScrollPane(statsTable), gbc); } - private void initLowerMiddlePanel() { infoHtmlPanel.setOpaque(false); - currentInfoTemplateFile = "preview/summary/35e_info.html"; - refreshInfoPanel(currentInfoTemplateFile, null); + //refreshInfoPanel(currentInfoTemplateFile, null); } /** @@ -259,28 +254,28 @@ { return; } - + File templateFile = new File(infoTemplateFile); ExportHandler theHandler = new ExportHandler(templateFile); final StringWriter out = new StringWriter(); final BufferedWriter buf = new BufferedWriter(out); character.export(theHandler, buf); - - HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(infoHtmlPanel); - + infoHtmlPanel.setContentType("text/html"); + HTMLDocument doc = new HTMLDocument(); + try { - String base = templateFile.getParentFile().toURL().toString(); - infoHtmlPanel.setHtml(out.toString(), base, theRendererContext); + doc.setBase(templateFile.getParentFile().toURL()); + infoHtmlPanel.setDocument(doc); + infoHtmlPanel.setText(out.toString()); } catch (MalformedURLException e) { - Logging.errorPrint("Could not get parent of load template file " - + "for info panel.", e); + Logging.errorPrint("Could not get parent of load template file " + "for info panel.", e); } } - + private void initRightPanel(JPanel rightPanel) { rightPanel.setLayout(new GridBagLayout()); @@ -541,6 +536,7 @@ deityModel = new FacadeComboBoxModel<DeityFacade>(); raceModel = new FacadeComboBoxModel<RaceFacade>(); classModel = new FacadeComboBoxModel<ClassFacade>(); + DataSetFacade dataset = character.getDataSet(); //initialize alignment model alignmentModel.setListFacade(dataset.getAlignments()); @@ -570,7 +566,6 @@ genderModel.setListFacade(new DefaultListFacade<GenderFacade>()); handsModel.setListFacade(new DefaultListFacade<SimpleFacade>()); } - refreshInfoPanel(currentInfoTemplateFile, character); } }; @@ -584,7 +579,8 @@ @Override public void listDataChanged(ListDataEvent e) { - if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && e.getIndex1() == -1) + if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && + e.getIndex1() == -1) { character.setRace((RaceFacade) raceModel.getSelectedItem()); } @@ -598,7 +594,8 @@ @Override public void listDataChanged(ListDataEvent e) { - if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && e.getIndex1() == -1) + if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && + e.getIndex1() == -1) { character.setGender((GenderFacade) genderModel.getSelectedItem()); } @@ -612,7 +609,8 @@ @Override public void listDataChanged(ListDataEvent e) { - if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && e.getIndex1() == -1) + if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && + e.getIndex1() == -1) { character.setAlignment((AlignmentFacade) alignmentModel.getSelectedItem()); } @@ -625,14 +623,14 @@ @Override public void listDataChanged(ListDataEvent e) { - if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && e.getIndex1() == -1) + if (e.getType() == ListDataEvent.CONTENTS_CHANGED && e.getIndex0() == -1 && + e.getIndex1() == -1) { character.setDeity((DeityFacade) deityModel.getSelectedItem()); } } }); - refreshInfoPanel(currentInfoTemplateFile, character); Hashtable<Object, Object> stateTable = new Hashtable<Object, Object>(); stateTable.put(Models.CharacterNameHandler, new CharacterNameHandler(character)); stateTable.put(Models.PlayerNameHandler, new PlayerNameHandler(character)); @@ -648,6 +646,7 @@ stateTable.put(Models.RemoveLevelsAction, new RemoveLevelsAction(character)); stateTable.put(Models.StatTableModel, new StatTableModel(character)); stateTable.put(Models.LanguageTableModel, new LanguageTableModel(character)); + stateTable.put(Models.InfoPaneModel, new InfoPaneHandler(character)); return stateTable; } @@ -682,7 +681,8 @@ AddLevelsAction, RemoveLevelsAction, StatTableModel, - LanguageTableModel + LanguageTableModel, + InfoPaneModel } public void storeState(Hashtable<Object, Object> state) @@ -699,9 +699,11 @@ ((CharacterNameHandler) state.get(Models.CharacterNameHandler)).install(); ((PlayerNameHandler) state.get(Models.PlayerNameHandler)).install(); ((TabNameHandler) state.get(Models.TabNameHandler)).install(); + ((InfoPaneHandler) state.get(Models.InfoPaneModel)).install(); ((LanguageTableModel) state.get(Models.LanguageTableModel)).install(languageTable); ((StatTableModel) state.get(Models.StatTableModel)).install(statsTable); ((ClassLevelTableModel) state.get(Models.ClassLevelTableModel)).install(classLevelTable, classComboBox); + genderComboBox.setModel((ComboBoxModel) state.get(Models.GenderComboBoxModel)); handsComboBox.setModel((ComboBoxModel) state.get(Models.HandsComboBoxModel)); alignmentComboBox.setModel((ComboBoxModel) state.get(Models.AlignmentComboBoxModel)); @@ -757,6 +759,25 @@ } + private class InfoPaneHandler + { + + private String currentInfoTemplateFile; + private CharacterFacade character; + + public InfoPaneHandler(CharacterFacade character) + { + this.character = character; + currentInfoTemplateFile = "preview/summary/35e_info.html"; + } + + public void install() + { + refreshInfoPanel(currentInfoTemplateFile, character); + } + + } + private class CharacterNameHandler implements DocumentListener, ReferenceListener<String> { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2010-05-23 07:52:37
|
Revision: 11952 http://pcgen.svn.sourceforge.net/pcgen/?rev=11952&view=rev Author: cpmeister Date: 2010-05-23 07:52:28 +0000 (Sun, 23 May 2010) Log Message: ----------- Summary Tab UI update Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-23 04:41:25 UTC (rev 11951) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-23 07:52:28 UTC (rev 11952) @@ -30,8 +30,6 @@ import java.io.IOException; import java.io.PipedReader; import java.io.PipedWriter; -import java.io.StringReader; -import java.io.StringWriter; import java.text.NumberFormat; import java.util.Arrays; import java.util.Hashtable; @@ -209,8 +207,6 @@ { middlePanel.setLayout(new GridBagLayout()); StatTableModel.initializeTable(statsTable); - //TODO: make this update during calls to updateUI() - statsTable.setBackground(middlePanel.getBackground()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; @@ -224,6 +220,7 @@ infoHtmlPanel.setOpaque(false); infoHtmlPanel.setContentType("text/html"); + gbc = new GridBagConstraints(); gbc.weightx = 1; gbc.weighty = 1; @@ -233,42 +230,6 @@ middlePanel.add(pane, gbc); } - /** - * Refresh the contents of the info panel by processing the export template sheet - * for the character. - * - * @param infoTemplateFile The export template file - * @param character The character to be displayed - */ - private void refreshInfoPanel(String infoTemplateFile, CharacterFacade character) - { - if (infoTemplateFile == null || character == null) - { - return; - } -// - File templateFile = new File(infoTemplateFile); - ExportHandler theHandler = new ExportHandler(templateFile); - final StringWriter out = new StringWriter(); - final BufferedWriter buf = new BufferedWriter(out); - character.export(theHandler, buf); - infoHtmlPanel.setContentType("text/html"); - HTMLDocument doc = new HTMLDocument(); - - try - { - doc.setBase(templateFile.getParentFile().toURL()); - EditorKit kit = infoHtmlPanel.getEditorKit(); - StringReader r = new StringReader(out.toString()); - kit.read(r, doc, 0); - infoHtmlPanel.setDocument(doc); - } - catch (Exception e) - { - Logging.errorPrint("Could not get parent of load template file " + "for info panel.", e); - } - } - private void initRightPanel(JPanel rightPanel) { rightPanel.setLayout(new GridBagLayout()); @@ -639,7 +600,7 @@ stateTable.put(Models.RemoveLevelsAction, new RemoveLevelsAction(character)); stateTable.put(Models.StatTableModel, new StatTableModel(character)); stateTable.put(Models.LanguageTableModel, new LanguageTableModel(character)); - stateTable.put(Models.InfoPaneModel, new InfoPaneHandler(character)); + stateTable.put(Models.InfoPaneHandler, new InfoPaneHandler(character)); return stateTable; } @@ -675,7 +636,7 @@ RemoveLevelsAction, StatTableModel, LanguageTableModel, - InfoPaneModel + InfoPaneHandler } public void storeState(Hashtable<Object, Object> state) @@ -685,7 +646,8 @@ ((TabNameHandler) state.get(Models.TabNameHandler)).uninstall(); ((LanguageTableModel) state.get(Models.LanguageTableModel)).uninstall(); ((ClassLevelTableModel) state.get(Models.ClassLevelTableModel)).uninstall(); - ((InfoPaneHandler) state.get(Models.InfoPaneModel)).uninstall(); + ((InfoPaneHandler) state.get(Models.InfoPaneHandler)).uninstall(); + ((StatTableModel) state.get(Models.StatTableModel)).uninstall(); } public void restoreState(Hashtable<?, ?> state) @@ -693,7 +655,7 @@ ((CharacterNameHandler) state.get(Models.CharacterNameHandler)).install(); ((PlayerNameHandler) state.get(Models.PlayerNameHandler)).install(); ((TabNameHandler) state.get(Models.TabNameHandler)).install(); - ((InfoPaneHandler) state.get(Models.InfoPaneModel)).install(); + ((InfoPaneHandler) state.get(Models.InfoPaneHandler)).install(); ((LanguageTableModel) state.get(Models.LanguageTableModel)).install(languageTable); ((StatTableModel) state.get(Models.StatTableModel)).install(statsTable); ((ClassLevelTableModel) state.get(Models.ClassLevelTableModel)).install(classLevelTable, classComboBox); @@ -770,7 +732,7 @@ public void install() { installed = true; - if(refresher == null || !refresher.isAlive()) + if (refresher == null || !refresher.isAlive()) { refresher = new Thread(new InfoPaneRefresher()); refresher.start(); @@ -782,6 +744,10 @@ installed = false; } + /** + * Refreshes the contents of the info panel by processing the export template sheet + * for the character. + */ private class InfoPaneRefresher extends SwingWorker<HTMLDocument> implements Runnable { @@ -790,18 +756,16 @@ public void run() { - ExportHandler theHandler = new ExportHandler(templateFile); try { PipedWriter writer = new PipedWriter(reader); start(); - character.export(theHandler, new BufferedWriter(writer, 1)); + character.export(new ExportHandler(templateFile), new BufferedWriter(writer, 1)); writer.close(); } catch (IOException ex) { - Logging.errorPrint("Could not get parent of load template file " + - "for info panel.", ex); + Logging.errorPrint("Unable to construct piped writer", ex); } } @@ -823,8 +787,7 @@ } catch (BadLocationException ex) { - Logging.errorPrint("Could not get parent of load template file " + - "for info panel.", ex); + //This should never happen } return doc; } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java 2010-05-23 04:41:25 UTC (rev 11951) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java 2010-05-23 07:52:28 UTC (rev 11952) @@ -31,7 +31,9 @@ import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.SpinnerNumberModel; +import javax.swing.SwingConstants; import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; @@ -57,6 +59,7 @@ private CharacterFacade character; private ListFacade<StatFacade> stats; private StatRenderer renderer = new StatRenderer(); + private JTable table; public StatTableModel(CharacterFacade character) { @@ -92,12 +95,18 @@ column.setIdentifier("EDITABLE"); columnModel.addColumn(column); + DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); + renderer.setOpaque(false); + renderer.setHorizontalAlignment(SwingConstants.TRAILING); htmlText = "<html><p align=\"center\"><b>Race<br>Mod</b></p></html>"; - columnModel.addColumn(Utilities.createTableColumn(3, htmlText, - new FixedHeaderCellRenderer(htmlText), false)); + column = Utilities.createTableColumn(3, htmlText, new FixedHeaderCellRenderer(htmlText), false); + column.setCellRenderer(renderer); + columnModel.addColumn(column); + htmlText = "<html><p align=\"center\"><b>Misc<br>Mod</b></p></html>"; - columnModel.addColumn(Utilities.createTableColumn(4, htmlText, - new FixedHeaderCellRenderer(htmlText), false)); + column = Utilities.createTableColumn(4, htmlText, new FixedHeaderCellRenderer(htmlText), false); + column.setCellRenderer(renderer); + columnModel.addColumn(column); } statsTable.setColumnModel(columnModel); statsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); @@ -106,6 +115,7 @@ statsTable.setFocusable(false); statsTable.setRowHeight(28); statsTable.setFont(tableFont); + statsTable.setOpaque(false); tableHeader.setFont(headerFont); } @@ -136,6 +146,7 @@ public void install(JTable table) { + this.table = table; table.setModel(this); table.setDefaultRenderer(Object.class, renderer); TableColumn column = table.getColumn("EDITABLE"); @@ -143,6 +154,10 @@ column.setCellEditor(new TableCellUtilities.SpinnerEditor(new SpinnerNumberModel(0, 0, null, 1))); } + public void uninstall() + { + } + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { @@ -247,7 +262,7 @@ public StatRenderer() { - setOpaque(true); + setOpaque(false); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(statLabel); add(Box.createHorizontalGlue()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2010-05-23 23:20:59
|
Revision: 11958 http://pcgen.svn.sourceforge.net/pcgen/?rev=11958&view=rev Author: cpmeister Date: 2010-05-23 23:20:53 +0000 (Sun, 23 May 2010) Log Message: ----------- Summary Tab refactoring Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java Added Paths: ----------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/InfoPaneHandler.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-23 21:19:31 UTC (rev 11957) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-05-23 23:20:53 UTC (rev 11958) @@ -25,11 +25,6 @@ import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; -import java.io.BufferedWriter; -import java.io.File; -import java.io.IOException; -import java.io.PipedReader; -import java.io.PipedWriter; import java.text.NumberFormat; import java.util.Arrays; import java.util.Hashtable; @@ -53,9 +48,6 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListDataEvent; -import javax.swing.text.BadLocationException; -import javax.swing.text.EditorKit; -import javax.swing.text.html.HTMLDocument; import pcgen.core.facade.AlignmentFacade; import pcgen.core.facade.CharacterFacade; @@ -69,17 +61,12 @@ import pcgen.core.facade.event.ReferenceEvent; import pcgen.core.facade.event.ReferenceListener; import pcgen.core.facade.util.DefaultListFacade; -import pcgen.gui2.tabs.summary.ClassLevelTableModel; -import pcgen.gui2.tabs.summary.LanguageTableModel; -import pcgen.gui2.tabs.summary.StatTableModel; +import pcgen.gui2.tabs.summary.*; import pcgen.gui2.tools.Icons; import pcgen.gui2.util.FacadeComboBoxModel; import pcgen.gui2.util.SignIcon; import pcgen.gui2.util.SignIcon.Sign; -import pcgen.gui2.util.SwingWorker; import pcgen.gui2.util.event.ListDataAdapter; -import pcgen.io.ExportHandler; -import pcgen.util.Logging; /** * @@ -120,7 +107,7 @@ private final JButton expsubtractButton; private final JButton addLevelsButton; private final JButton removeLevelsButton; - private final JEditorPane infoHtmlPanel; + private final JEditorPane infoPane; public SummaryInfoTab() { @@ -153,7 +140,7 @@ this.removeLevelsButton = new JButton(); this.expaddButton = createSignButton(Sign.Plus); this.expsubtractButton = createSignButton(Sign.Minus); - this.infoHtmlPanel = new JEditorPane(); + this.infoPane = new JEditorPane(); initComponents(); } @@ -218,16 +205,13 @@ pane.setBorder(BorderFactory.createEmptyBorder()); middlePanel.add(pane, gbc); - infoHtmlPanel.setOpaque(false); - infoHtmlPanel.setContentType("text/html"); - infoHtmlPanel.setEditable(false); - infoHtmlPanel.setFocusable(false); + InfoPaneHandler.initializeEditorPane(infoPane); gbc = new GridBagConstraints(); gbc.weightx = 1; gbc.weighty = 1; gbc.fill = GridBagConstraints.BOTH; - pane = new JScrollPane(infoHtmlPanel); + pane = new JScrollPane(infoPane); pane.setBorder(BorderFactory.createEmptyBorder()); middlePanel.add(pane, gbc); } @@ -440,11 +424,6 @@ gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1; -// basicsPanel.add(languageTabButton, gbc); -// basicsPanel.add(raceTabButton, gbc); -// basicsPanel.add(classTabButton, gbc); -// basicsPanel.add(descTabButton, gbc); -// basicsPanel.add(sheetTabButton, gbc); basicsPanel.add(new JScrollPane(languageTable), gbc); addGridBagLayer(basicsPanel, labelFont, new Insets(7, 0, 7, 0), "Tab Label:", tabLabelField); basicsPanel.revalidate(); @@ -657,7 +636,7 @@ ((CharacterNameHandler) state.get(Models.CharacterNameHandler)).install(); ((PlayerNameHandler) state.get(Models.PlayerNameHandler)).install(); ((TabNameHandler) state.get(Models.TabNameHandler)).install(); - ((InfoPaneHandler) state.get(Models.InfoPaneHandler)).install(); + ((InfoPaneHandler) state.get(Models.InfoPaneHandler)).install(infoPane); ((LanguageTableModel) state.get(Models.LanguageTableModel)).install(languageTable); ((StatTableModel) state.get(Models.StatTableModel)).install(statsTable); ((ClassLevelTableModel) state.get(Models.ClassLevelTableModel)).install(classLevelTable, classComboBox); @@ -717,96 +696,6 @@ } - private class InfoPaneHandler - { - - private String currentInfoTemplateFile; - private CharacterFacade character; - private boolean installed = false; - private Thread refresher = null; - - public InfoPaneHandler(CharacterFacade character) - { - this.character = character; - currentInfoTemplateFile = "preview/summary/35e_info.html"; - } - - public void install() - { - installed = true; - if (refresher == null || !refresher.isAlive()) - { - refresher = new Thread(new InfoPaneRefresher()); - refresher.start(); - } - } - - public void uninstall() - { - installed = false; - } - - /** - * Refreshes the contents of the info panel by processing the export template sheet - * for the character. - */ - private class InfoPaneRefresher extends SwingWorker<HTMLDocument> implements Runnable - { - - private File templateFile = new File(currentInfoTemplateFile); - private PipedReader reader = new PipedReader(); - - public void run() - { - try - { - PipedWriter writer = new PipedWriter(reader); - start(); - character.export(new ExportHandler(templateFile), new BufferedWriter(writer, 1)); - writer.close(); - } - catch (IOException ex) - { - Logging.errorPrint("Unable to construct piped writer", ex); - } - } - - @Override - public HTMLDocument construct() - { - EditorKit kit = infoHtmlPanel.getEditorKit(); - HTMLDocument doc = new HTMLDocument(); - try - { - doc.setBase(templateFile.getParentFile().toURL()); - kit.read(reader, doc, 0); - reader.close(); - } - catch (IOException ex) - { - Logging.errorPrint("Could not get parent of load template file " + - "for info panel.", ex); - } - catch (BadLocationException ex) - { - //This should never happen - } - return doc; - } - - @Override - public void finished() - { - if (installed) - { - infoHtmlPanel.setDocument(getValue()); - } - } - - } - - } - private class CharacterNameHandler implements DocumentListener, ReferenceListener<String> { Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/InfoPaneHandler.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/InfoPaneHandler.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/InfoPaneHandler.java 2010-05-23 23:20:53 UTC (rev 11958) @@ -0,0 +1,140 @@ +/* + * InfoPaneHandler.java + * Copyright 2010 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 May 23, 2010, 3:16:32 PM + */ +package pcgen.gui2.tabs.summary; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.IOException; +import java.io.PipedReader; +import java.io.PipedWriter; +import javax.swing.JEditorPane; +import javax.swing.text.BadLocationException; +import javax.swing.text.EditorKit; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLEditorKit; +import pcgen.core.facade.CharacterFacade; +import pcgen.gui2.util.SwingWorker; +import pcgen.io.ExportHandler; +import pcgen.util.Logging; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class InfoPaneHandler +{ + + private String currentInfoTemplateFile; + private CharacterFacade character; + private boolean installed = false; + private Thread refresher = null; + private JEditorPane htmlPane; + + public InfoPaneHandler(CharacterFacade character) + { + this.character = character; + currentInfoTemplateFile = "preview/summary/35e_info.html"; + } + + public static void initializeEditorPane(JEditorPane htmlPane) + { + htmlPane.setOpaque(false); + htmlPane.setEditable(false); + htmlPane.setFocusable(false); + htmlPane.setContentType("text/html"); + } + + public void install(JEditorPane htmlPane) + { + this.htmlPane = htmlPane; + installed = true; + if (refresher == null || !refresher.isAlive()) + { + refresher = new Thread(new InfoPaneRefresher()); + refresher.start(); + } + } + + public void uninstall() + { + installed = false; + } + + /** + * Refreshes the contents of the info panel by processing the export template sheet + * for the character. + */ + private class InfoPaneRefresher extends SwingWorker<HTMLDocument> implements Runnable + { + + private File templateFile = new File(currentInfoTemplateFile); + private PipedReader reader = new PipedReader(); + + public void run() + { + try + { + PipedWriter writer = new PipedWriter(reader); + start(); + character.export(new ExportHandler(templateFile), new BufferedWriter(writer, 1)); + writer.close(); + } + catch (IOException ex) + { + Logging.errorPrint("Unable to construct piped writer", ex); + } + } + + @Override + public HTMLDocument construct() + { + EditorKit kit = new HTMLEditorKit(); + HTMLDocument doc = new HTMLDocument(); + try + { + doc.setBase(templateFile.getParentFile().toURL()); + kit.read(reader, doc, 0); + reader.close(); + } + catch (IOException ex) + { + Logging.errorPrint("Could not get parent of load template file " + + "for info panel.", ex); + } + catch (BadLocationException ex) + { + //This should never happen + } + return doc; + } + + @Override + public void finished() + { + if (installed) + { + htmlPane.setDocument(getValue()); + } + } + + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2010-06-15 02:57:53
|
Revision: 12158 http://pcgen.svn.sourceforge.net/pcgen/?rev=12158&view=rev Author: cpmeister Date: 2010-06-15 00:29:09 +0000 (Tue, 15 Jun 2010) Log Message: ----------- SummaryInfoTab layout issue fix Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-06-14 11:29:46 UTC (rev 12157) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-06-15 00:29:09 UTC (rev 12158) @@ -22,9 +22,12 @@ import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.beans.PropertyChangeEvent; @@ -36,6 +39,7 @@ import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.BorderFactory; +import javax.swing.BoxLayout; import javax.swing.ComboBoxModel; import javax.swing.DefaultListCellRenderer; import javax.swing.JButton; @@ -125,8 +129,8 @@ private final JButton addLevelsButton; private final JButton removeLevelsButton; private final JEditorPane infoPane; - private final JLabel statTotalLabel; - private final JLabel statTotal; + private final JLabel statTotalLabel; + private final JLabel statTotal; private final JEditorPane todoPane; public SummaryInfoTab() @@ -225,8 +229,7 @@ todoPane.setOpaque(false); todoPane.setContentType("text/html"); //$NON-NLS-1$ String bodyRule = - "body { font-family: " + textFont.getFamily() + "; " - + "font-size: " + textFont.getSize() + "pt; }"; + "body { font-family: " + textFont.getFamily() + "; " + "font-size: " + textFont.getSize() + "pt; }"; ((HTMLDocument) todoPane.getDocument()).getStyleSheet().addRule( bodyRule); StringBuffer todoText = new StringBuffer("<html><body></body></html>"); //$NON-NLS-1$ @@ -238,41 +241,45 @@ panel.add(scroll, BorderLayout.CENTER); } - + private void initMiddlePanel(JPanel middlePanel) { - middlePanel.setLayout(new GridBagLayout()); + middlePanel.setLayout(new GridLayout(2, 1)); + + JPanel statsPanel = new JPanel(); + statsPanel.setLayout(new BoxLayout(statsPanel, BoxLayout.Y_AXIS)); + StatTableModel.initializeTable(statsTable); + JScrollPane pane = new JScrollPane(statsTable) + { - GridBagConstraints gbc = new GridBagConstraints(); - gbc.gridwidth = GridBagConstraints.REMAINDER; + @Override + public Dimension getMaximumSize() + { + //This prevents the scroll pane from taking up more space than it needs. + return super.getPreferredSize(); + } - gbc.weighty = 1; - gbc.fill = GridBagConstraints.VERTICAL; - gbc.ipadx = 370; - JScrollPane pane = new JScrollPane(statsTable); + }; pane.setBorder(BorderFactory.createEmptyBorder()); - middlePanel.add(pane, gbc); + statsPanel.add(pane); - JPanel statTotalPanel = new JPanel(); + JPanel statTotalPanel = new JPanel(new FlowLayout()); + //this makes box layout use the statTotalPanel to distribute extra space + statTotalPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); + statTotalLabel.setFont(labelFont); statTotalPanel.add(statTotalLabel); - Font f = statTotal.getFont(); - statTotal.setFont(f.deriveFont(f.getStyle() ^ Font.BOLD)); + statTotal.setFont(textFont); statTotalPanel.add(statTotal); - gbc.weighty = 0; - gbc.fill = GridBagConstraints.NONE; - middlePanel.add(statTotalPanel, gbc); - - + statsPanel.add(statTotalPanel); + + middlePanel.add(statsPanel); + InfoPaneHandler.initializeEditorPane(infoPane); - gbc = new GridBagConstraints(); - gbc.weightx = 1; - gbc.weighty = 1; - gbc.fill = GridBagConstraints.BOTH; pane = new JScrollPane(infoPane); pane.setBorder(BorderFactory.createEmptyBorder()); - middlePanel.add(pane, gbc); + middlePanel.add(pane); } private void initRightPanel(JPanel rightPanel) @@ -587,7 +594,7 @@ LabelHandler statTotalLabelHandler = new LabelHandler(statTotalLabel); LabelHandler statTotalHandler = new LabelHandler(statTotal); - + DataSetFacade dataset = character.getDataSet(); //initialize alignment model alignmentModel.setListFacade(dataset.getAlignments()); @@ -608,7 +615,7 @@ statTotalLabelHandler.setReference(character.getStatTotalLabelTextRef()); statTotalHandler.setReference(character.getStatTotalTextRef()); - + ReferenceFacade<RaceFacade> raceRef = character.getRaceRef(); ReferenceListener<Object> raceListener = new ReferenceListener<Object>() { @@ -806,7 +813,7 @@ } private abstract class CharacterComboBoxModel<E> extends FacadeListModel<E> - implements ComboBoxModel, ReferenceListener<E> + implements ComboBoxModel, ReferenceListener<E> { private ReferenceFacade<E> reference = null; @@ -1265,20 +1272,19 @@ public void actionPerformed(ActionEvent e) { int modVal = ((Number) expmodField.getValue()).intValue(); - character.adjustXP(modVal*-1); + character.adjustXP(modVal * -1); } } - /** * The Class <code>LabelHandler</code> manages the text displayed in a * JLabel field for a character. The text will be updated each time a * reference is updated. The handler also knows how to react to install and * uninstall actions when the displayed character changes. */ - private class LabelHandler - implements ReferenceListener<String> + private class LabelHandler + implements ReferenceListener<String> { private ReferenceFacade<String> reference = null; @@ -1292,7 +1298,7 @@ { this.label = label; } - + /** * @param ref The new reference to be watched */ @@ -1342,11 +1348,11 @@ /** * The Class <code>TodoListHandler</code> manages the text displayed in the * things to be done panel for the character. The text will be updated each - * time the character's todo list changes. The handler also knows how to react - * to install and uninstall actions when the displayed character changes. + * time the character's todo list changes. The handler also knows how to react + * to install and uninstall actions when the displayed character changes. */ - private class TodoListHandler - implements ListListener<TodoFacade> + private class TodoListHandler + implements ListListener<TodoFacade> { private CharacterFacade character; @@ -1431,5 +1437,4 @@ } } - } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java 2010-06-14 11:29:46 UTC (rev 12157) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java 2010-06-15 00:29:09 UTC (rev 12158) @@ -22,6 +22,7 @@ import pcgen.gui2.tabs.Utilities; import java.awt.Component; +import java.awt.Dimension; import java.awt.Font; import java.text.DecimalFormat; import javax.swing.BorderFactory; @@ -57,13 +58,11 @@ private static final Font tableFont = new Font("Verdana", Font.BOLD, 14); private static final Font headerFont = new Font("Verdana", Font.BOLD, 12); - private static final int FINAL_ABILITY_SCORE = 0; private static final int ABILITY_MOD = 1; private static final int EDITABLE_SCORE = 2; private static final int RACE_MOD = 3; private static final int MISC_MOD = 4; - private CharacterFacade character; private ListFacade<StatFacade> stats; private StatRenderer renderer = new StatRenderer(); @@ -89,8 +88,8 @@ statsTable.setAutoCreateColumnsFromModel(false); DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); { - String htmlText = "<html><b>Final Ability Score</b></html>"; - columnModel.addColumn(Utilities.createTableColumn(0, htmlText, null, true)); + String htmlText = "Final Ability Score"; + columnModel.addColumn(Utilities.createTableColumn(0, htmlText, new FixedHeaderCellRenderer(htmlText), false)); htmlText = "<html><p align=\"center\"><b>Ability<br>Mod</b></p></html>"; TableColumn column = Utilities.createTableColumn(1, htmlText, @@ -98,8 +97,8 @@ column.setCellRenderer(new ModRenderer()); columnModel.addColumn(column); - htmlText = "<html><b>Editable Score</b></html>"; - column = Utilities.createTableColumn(2, htmlText, null, true); + htmlText = "Editable Score"; + column = Utilities.createTableColumn(2, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setIdentifier("EDITABLE"); columnModel.addColumn(column); @@ -160,6 +159,9 @@ TableColumn column = table.getColumn("EDITABLE"); column.setCellRenderer(new TableCellUtilities.SpinnerRenderer()); column.setCellEditor(new TableCellUtilities.SpinnerEditor(new SpinnerNumberModel(0, 0, null, 1))); + Dimension size = table.getPreferredSize(); + size.width = table.getTableHeader().getPreferredSize().width; + table.setPreferredScrollableViewportSize(size); } public void uninstall() @@ -303,5 +305,4 @@ } } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2010-06-16 07:33:56
|
Revision: 12174 http://pcgen.svn.sourceforge.net/pcgen/?rev=12174&view=rev Author: cpmeister Date: 2010-06-16 07:33:47 +0000 (Wed, 16 Jun 2010) Log Message: ----------- more code cleanup Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-06-16 05:00:35 UTC (rev 12173) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-06-16 07:33:47 UTC (rev 12174) @@ -401,17 +401,13 @@ panel.setLayout(new GridBagLayout()); JLabel addLabel = createLabel("Add Levels:"); JLabel removeLabel = createLabel("Remove Levels:"); - //JButton addLevelsButton = createSignButton(Sign.Plus); - //JButton removeLevelsButton = createSignButton(Sign.Minus); JLabel darrowLabel = new JLabel(Icons.createImageIcon("button_arrow_down.png")); JLabel uarrowLabel = new JLabel(Icons.createImageIcon("button_arrow_up.png")); addLevelsButton.setMargin(new Insets(0, 8, 0, 8)); - //addLevelsField.setColumns(3); addLevelsField.setValue(1); addLevelsField.setHorizontalAlignment(SwingConstants.RIGHT); removeLevelsButton.setMargin(new Insets(0, 8, 0, 8)); - //removeLevelsField.setColumns(3); removeLevelsField.setValue(1); removeLevelsField.setHorizontalAlignment(SwingConstants.RIGHT); @@ -459,7 +455,6 @@ random.setMargin(new Insets(0, 0, 0, 0)); basicsPanel.add(random, new GridBagConstraints()); - //TODO: init characterNameField gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; @@ -510,15 +505,6 @@ panel.add(comp, gbc); } - private void addGridBagLayer(JPanel panel, Font font, JComponent comp) - { - GridBagConstraints gbc = new GridBagConstraints(); - comp.setFont(font); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.fill = GridBagConstraints.BOTH; - panel.add(comp, gbc); - } - public Hashtable<Object, Object> createState(final CharacterFacade character) { final CharacterComboBoxModel<GenderFacade> genderModel; @@ -601,7 +587,7 @@ raceModel.setListFacade(dataset.getRaces()); ageCatModel.setListFacade(character.getAgeCategories()); classModel.setListFacade(dataset.getClasses()); - //classModel.setReference(character.); + //initialize gender and hands models handsModel.setReference(character.getHandedRef()); ageCatModel.setReference(character.getAgeCategoryRef()); Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java 2010-06-16 05:00:35 UTC (rev 12173) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/summary/StatTableModel.java 2010-06-16 07:33:47 UTC (rev 12174) @@ -89,16 +89,16 @@ DefaultTableColumnModel columnModel = new DefaultTableColumnModel(); { String htmlText = "Final Ability Score"; - columnModel.addColumn(Utilities.createTableColumn(0, htmlText, new FixedHeaderCellRenderer(htmlText), false)); + columnModel.addColumn(Utilities.createTableColumn(FINAL_ABILITY_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false)); htmlText = "<html><p align=\"center\"><b>Ability<br>Mod</b></p></html>"; - TableColumn column = Utilities.createTableColumn(1, htmlText, + TableColumn column = Utilities.createTableColumn(ABILITY_MOD, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(new ModRenderer()); columnModel.addColumn(column); htmlText = "Editable Score"; - column = Utilities.createTableColumn(2, htmlText, new FixedHeaderCellRenderer(htmlText), false); + column = Utilities.createTableColumn(EDITABLE_SCORE, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setIdentifier("EDITABLE"); columnModel.addColumn(column); @@ -106,12 +106,12 @@ renderer.setOpaque(false); renderer.setHorizontalAlignment(SwingConstants.TRAILING); htmlText = "<html><p align=\"center\"><b>Race<br>Mod</b></p></html>"; - column = Utilities.createTableColumn(3, htmlText, new FixedHeaderCellRenderer(htmlText), false); + column = Utilities.createTableColumn(RACE_MOD, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); htmlText = "<html><p align=\"center\"><b>Misc<br>Mod</b></p></html>"; - column = Utilities.createTableColumn(4, htmlText, new FixedHeaderCellRenderer(htmlText), false); + column = Utilities.createTableColumn(MISC_MOD, htmlText, new FixedHeaderCellRenderer(htmlText), false); column.setCellRenderer(renderer); columnModel.addColumn(column); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2010-08-06 06:54:18
|
Revision: 12747 http://pcgen.svn.sourceforge.net/pcgen/?rev=12747&view=rev Author: cpmeister Date: 2010-08-06 06:54:11 +0000 (Fri, 06 Aug 2010) Log Message: ----------- UI update Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/AbilitiesInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java Added Paths: ----------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/TabTitle.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/AbilitiesInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/AbilitiesInfoTab.java 2010-08-06 01:16:57 UTC (rev 12746) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/AbilitiesInfoTab.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -20,7 +20,6 @@ */ package pcgen.gui2.tabs; -import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -29,8 +28,6 @@ import java.util.List; import java.util.Map; -import javax.swing.AbstractAction; -import javax.swing.Action; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -50,10 +47,11 @@ { private final AbilityChooserTab abilityTab; - +private final TabTitle tabTitle; public AbilitiesInfoTab() { this.abilityTab = new AbilityChooserTab(); + this.tabTitle = new TabTitle("Feats and Abilities"); setSharedComponent(abilityTab); } @@ -77,17 +75,9 @@ tabsModel.install(); } - public Action getTabTitleAction() + public TabTitle getTabTitle() { - return new AbstractAction("Feats and Abilities") - { - - public void actionPerformed(ActionEvent e) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - }; + return tabTitle; } private class AbilityTabsModel implements ListListener<AbilityCategoryFacade>, ChangeListener Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java 2010-08-06 01:16:57 UTC (rev 12746) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -102,6 +102,6 @@ * will be immediately rendered onto the tab's title space. * @return an Action for the tab title */ - public Action getTabTitleAction(); + public TabTitle getTabTitle(); } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java 2010-08-06 01:16:57 UTC (rev 12746) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/ClassInfoTab.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -21,7 +21,6 @@ package pcgen.gui2.tabs; import java.awt.Container; -import javax.swing.Action; import pcgen.core.facade.event.ListEvent; import pcgen.gui2.tools.ChooserPane; import java.awt.Dimension; @@ -84,6 +83,7 @@ private final JTable classTable; private final JButton addButton; private final JButton removeButton; + private final TabTitle tabTitle; private AddClassAction addClassAction; private RemoveClassAction removeClassAction; private ClassFacade selectedClass; @@ -115,6 +115,7 @@ }; this.addButton = new JButton(); this.removeButton = new JButton(); + this.tabTitle = new TabTitle("Classes"); initComponents(); } @@ -284,17 +285,9 @@ setSelectedClass((ClassFacade) state.get("SelectedClass")); } - public Action getTabTitleAction() + public TabTitle getTabTitle() { - return new AbstractAction("Classes") - { - - public void actionPerformed(ActionEvent e) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - }; + return tabTitle; } private class AddClassAction extends AbstractAction Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java 2010-08-06 01:16:57 UTC (rev 12746) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -23,7 +23,6 @@ import java.awt.BorderLayout; import java.awt.FlowLayout; import java.util.Hashtable; -import javax.swing.Action; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComboBox; @@ -117,7 +116,7 @@ throw new UnsupportedOperationException("Not supported yet."); } - public Action getTabTitleAction() + public TabTitle getTabTitle() { throw new UnsupportedOperationException("Not supported yet."); } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2010-08-06 01:16:57 UTC (rev 12746) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -26,7 +26,6 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.Map; -import javax.swing.Action; import javax.swing.Icon; import javax.swing.JTabbedPane; import pcgen.base.util.DoubleKeyMap; @@ -105,12 +104,12 @@ private <T extends Component & CharacterInfoTab> void addTab(T tab) { - Action action = tab.getTabTitleAction(); - String title = (String) action.getValue(Action.NAME); - String tooltip = (String) action.getValue(Action.SHORT_DESCRIPTION); - Icon icon = (Icon) action.getValue(Action.SMALL_ICON); + TabTitle tabTitle = tab.getTabTitle(); + String title = (String) tabTitle.getValue(TabTitle.TITLE); + String tooltip = (String) tabTitle.getValue(TabTitle.TOOLTIP); + Icon icon = (Icon) tabTitle.getValue(TabTitle.ICON); addTab(title, icon, tab, tooltip); - action.addPropertyChangeListener(new TabActionListener(tab)); + tabTitle.addPropertyChangeListener(new TabActionListener(tab)); } private class TabActionListener implements PropertyChangeListener @@ -127,19 +126,19 @@ { int index = indexOfComponent(component); String propName = evt.getPropertyName(); - if (Action.NAME.equals(propName)) + if (TabTitle.TITLE.equals(propName)) { InfoTabbedPane.this.setTitleAt(index, (String) evt.getNewValue()); } - else if (Action.SMALL_ICON.equals(propName)) + else if (TabTitle.ICON.equals(propName)) { InfoTabbedPane.this.setIconAt(index, (Icon) evt.getNewValue()); } - else if (Action.SHORT_DESCRIPTION.equals(propName)) + else if (TabTitle.TOOLTIP.equals(propName)) { InfoTabbedPane.this.setToolTipTextAt(index, (String) evt.getNewValue()); } - else if ("enabled".equals(propName)) + else if (TabTitle.ENABLED.equals(propName)) { InfoTabbedPane.this.setEnabledAt(index, (Boolean) evt.getNewValue()); } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java 2010-08-06 01:16:57 UTC (rev 12746) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -21,19 +21,16 @@ package pcgen.gui2.tabs; import java.awt.event.MouseEvent; -import javax.swing.Action; import javax.swing.event.ChangeEvent; import pcgen.core.facade.event.ListEvent; import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; -import java.awt.event.ActionEvent; import java.awt.event.MouseListener; import java.text.DecimalFormat; import java.util.Arrays; import java.util.Hashtable; import java.util.List; -import javax.swing.AbstractAction; import javax.swing.AbstractSpinnerModel; import javax.swing.JButton; import javax.swing.JFormattedTextField; @@ -91,7 +88,7 @@ private final FilteredTreeViewTable skillTable; private final JTable skillcostTable; private final JTable skillpointTable; - private final Action tabAction; + private final TabTitle tabTitle; private SkillTreeViewModel treeviewModel; private SkillPointTableModel skillpointModel; private SkillCostTableModel skillcostModel; @@ -103,15 +100,7 @@ this.skillTable = new FilteredTreeViewTable(); this.skillcostTable = new JTable(); this.skillpointTable = new JTable(); - this.tabAction = new AbstractAction("Skills") - { - - public void actionPerformed(ActionEvent e) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - }; + this.tabTitle = new TabTitle("Skills"); initComponents(); } @@ -291,9 +280,9 @@ ((FilterTableHandler) state.get(FilterTableHandler.class)).install(); } - public Action getTabTitleAction() + public TabTitle getTabTitle() { - return tabAction; + return tabTitle; } private class LevelSelectionHandler implements ListSelectionListener @@ -369,7 +358,7 @@ public void install() { - tabAction.setEnabled(!levels.isEmpty()); + tabTitle.setEnabled(!levels.isEmpty()); } public void elementAdded(ListEvent e) @@ -863,7 +852,7 @@ public void setValue(Float value) { CharacterLevelsFacade levels = character.getCharacterLevelsFacade(); - SkillCost cost = levels.getSkillCost(level, skill);; + SkillCost cost = levels.getSkillCost(level, skill); if (value < 0) { value = Float.valueOf(0); @@ -902,7 +891,7 @@ return null; } CharacterLevelsFacade levels = character.getCharacterLevelsFacade(); - SkillCost cost = levels.getSkillCost(level, skill);; + SkillCost cost = levels.getSkillCost(level, skill); if (!PCGenUIManager.isHouseRuleSelected(HouseRule.SKILLMAX) && value == character.getMaxRanks(cost, level)) { @@ -919,7 +908,7 @@ return null; } CharacterLevelsFacade levels = character.getCharacterLevelsFacade(); - SkillCost cost = levels.getSkillCost(level, skill);; + SkillCost cost = levels.getSkillCost(level, skill); return value - 1f / cost.getCost(); } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-08-06 01:16:57 UTC (rev 12746) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SummaryInfoTab.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -105,6 +105,7 @@ private static final Font titleFont = new Font("Verdana", Font.BOLD, 15); private static final Font labelFont = new Font("Verdana", Font.BOLD, 12); private static final Font textFont = new Font("Verdana", Font.PLAIN, 12); + private final TabTitle tabTitle; private final JPanel basicsPanel; private final JPanel todoPanel; private final JPanel scoresPanel; @@ -146,6 +147,7 @@ public SummaryInfoTab() { + this.tabTitle = new TabTitle("Summary"); this.basicsPanel = new JPanel(); this.todoPanel = new JPanel(); this.scoresPanel = new JPanel(); @@ -768,19 +770,9 @@ return stateTable; } - public Action getTabTitleAction() + public TabTitle getTabTitle() { - //TODO: this is a temporary implementation - Action action = new AbstractAction("Summary") - { - - public void actionPerformed(ActionEvent e) - { - throw new UnsupportedOperationException("Not supported yet."); - } - - }; - return action; + return tabTitle; } private enum Models Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/TabTitle.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/TabTitle.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/TabTitle.java 2010-08-06 06:54:11 UTC (rev 12747) @@ -0,0 +1,85 @@ +/* + * TabTitle.java + * Copyright 2010 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 Aug 3, 2010, 5:36:10 PM + */ +package pcgen.gui2.tabs; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.util.Hashtable; + +/** + * + * @author Connor Petty <cpm...@us...> + */ +public class TabTitle +{ + + public static final String FOREGROUND = "foreground"; + public static final String BACKGROUND = "background"; + public static final String ENABLED = "enabled"; + public static final String TITLE = "title"; + public static final String ICON = "icon"; + public static final String TOOLTIP = "tooltip"; + private PropertyChangeSupport support; + private Hashtable table; + + public TabTitle(String title) + { + this(); + putValue(TITLE, title); + } + + public TabTitle() + { + support = new PropertyChangeSupport(this); + table = new Hashtable(); + } + + public void addPropertyChangeListener(PropertyChangeListener l) + { + support.addPropertyChangeListener(l); + } + + public void removePropertyChangeListener(PropertyChangeListener l) + { + support.removePropertyChangeListener(l); + } + + public Object getValue(String prop) + { + return table.get(prop); + } + + public void putValue(String prop, Object value) + { + support.firePropertyChange(prop, table.put(prop, value), value); + } + + public void setEnabled(boolean enable) + { + putValue(ENABLED, enable); + } + + public boolean isEnabled() + { + return (Boolean) getValue(ENABLED); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2010-09-29 12:59:50
|
Revision: 13208 http://pcgen.svn.sourceforge.net/pcgen/?rev=13208&view=rev Author: jdempsey Date: 2010-09-29 12:59:43 +0000 (Wed, 29 Sep 2010) Log Message: ----------- Add placeholders for the unimplemented tabs Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java Added Paths: ----------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterSheetInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DescriptionInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InventoryInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SpellsInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/UnimplementedTab.java Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterSheetInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterSheetInfoTab.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterSheetInfoTab.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -0,0 +1,44 @@ +/** + * CharacterSheetInfoTab.java + * Copyright James Dempsey, 2010 + * + * 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 29/09/2010 7:16:42 PM + * + * $Id$ + */ +package pcgen.gui2.tabs; + +/** + * The Class <code>CharacterSheetInfoTab</code> is a placeholder for the character + * sheet tab. + * + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class CharacterSheetInfoTab extends UnimplementedTab +{ + @Override + String getTabName() + { + return "Character Sheet"; + } + +} Property changes on: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterSheetInfoTab.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DescriptionInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DescriptionInfoTab.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DescriptionInfoTab.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -0,0 +1,44 @@ +/** + * DescriptionInfoTab.java + * Copyright James Dempsey, 2010 + * + * 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 29/09/2010 7:16:42 PM + * + * $Id$ + */ +package pcgen.gui2.tabs; + +/** + * The Class <code>DescriptionInfoTab</code> is a placeholder for the yet to + * be implemented description tab. + * + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class DescriptionInfoTab extends UnimplementedTab +{ + @Override + String getTabName() + { + return "Description"; + } + +} Property changes on: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DescriptionInfoTab.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java 2010-09-29 08:55:33 UTC (rev 13207) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -21,6 +21,9 @@ package pcgen.gui2.tabs; import java.util.Hashtable; + +import javax.swing.JPanel; + import pcgen.core.facade.CharacterFacade; import pcgen.core.facade.DeityFacade; import pcgen.core.facade.util.ListFacade; @@ -34,7 +37,7 @@ * * @author Connor Petty <cpm...@us...> */ -public class DomainInfoTab implements CharacterInfoTab +public class DomainInfoTab extends JPanel implements CharacterInfoTab { private final JTreeViewSelectionPane deityPane; @@ -49,22 +52,22 @@ public Hashtable<Object, Object> createModels(CharacterFacade character) { - throw new UnsupportedOperationException("Not supported yet."); + return new Hashtable<Object, Object>(); } public void restoreModels(Hashtable<?, ?> state) { - throw new UnsupportedOperationException("Not supported yet."); + //throw new UnsupportedOperationException("Not supported yet."); } public void storeModels(Hashtable<Object, Object> state) { - throw new UnsupportedOperationException("Not supported yet."); + //throw new UnsupportedOperationException("Not supported yet."); } public TabTitle getTabTitle() { - throw new UnsupportedOperationException("Not supported yet."); + return new TabTitle("Domains"); } private class DeityModel implements TreeViewModel<DeityFacade> Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2010-09-29 08:55:33 UTC (rev 13207) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -63,9 +63,15 @@ setTabPlacement(JTabbedPane.TOP); addTab(new SummaryInfoTab()); + addTab(new RaceInfoTab()); addTab(new ClassInfoTab()); addTab(new SkillInfoTab()); addTab(new AbilitiesInfoTab()); + addTab(new DomainInfoTab()); + addTab(new SpellsInfoTab()); + addTab(new InventoryInfoTab()); + addTab(new DescriptionInfoTab()); + addTab(new CharacterSheetInfoTab()); } public void setCharacter(CharacterFacade character) Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InventoryInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InventoryInfoTab.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InventoryInfoTab.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -0,0 +1,43 @@ +/** + * InventoryInfoTab.java + * Copyright James Dempsey, 2010 + * + * 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 29/09/2010 7:16:42 PM + * + * $Id$ + */ +package pcgen.gui2.tabs; + +/** + * The Class <code>InventoryInfoTab</code> is a placeholder for the yet + * to be implemented Inventory tab. + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class InventoryInfoTab extends UnimplementedTab +{ + @Override + String getTabName() + { + return "Inventiry"; + } + +} Property changes on: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InventoryInfoTab.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -0,0 +1,43 @@ +/** + * RaceInfoTab.java + * Copyright James Dempsey, 2010 + * + * 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 29/09/2010 7:16:42 PM + * + * $Id$ + */ +package pcgen.gui2.tabs; + +/** + * The Class <code>RaceInfoTab</code> is a placeholder for the yet + * to be implemented Race tab. + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class RaceInfoTab extends UnimplementedTab +{ + @Override + String getTabName() + { + return "Race"; + } + +} Property changes on: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SpellsInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SpellsInfoTab.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SpellsInfoTab.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -0,0 +1,43 @@ +/** + * SpellsInfoTab.java + * Copyright James Dempsey, 2010 + * + * 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 29/09/2010 7:16:42 PM + * + * $Id$ + */ +package pcgen.gui2.tabs; + +/** + * The Class <code>SpellsInfoTab</code> is a placeholder for the yet + * to be implemented Seplls tab. + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public class SpellsInfoTab extends UnimplementedTab +{ + @Override + String getTabName() + { + return "Spells"; + } + +} Property changes on: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SpellsInfoTab.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native Added: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/UnimplementedTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/UnimplementedTab.java (rev 0) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/UnimplementedTab.java 2010-09-29 12:59:43 UTC (rev 13208) @@ -0,0 +1,90 @@ +/** + * UnimplementedTab.java + * Copyright James Dempsey, 2010 + * + * 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 29/09/2010 7:06:55 PM + * + * $Id$ + */ +package pcgen.gui2.tabs; + +import java.util.Hashtable; + +import javax.swing.JLabel; +import javax.swing.JPanel; + +import pcgen.core.facade.CharacterFacade; + +/** + * The Class <code>UnimplementedTab</code> is a general implementation of + 8 the display of a tab that has not yet been implemented. + * + * <br/> + * Last Editor: $Author$ + * Last Edited: $Date$ + * + * @author James Dempsey <jde...@us...> + * @version $Revision$ + */ +public abstract class UnimplementedTab extends JPanel implements CharacterInfoTab +{ + + public UnimplementedTab() + { + add(new JLabel("This tab has not yet been implemented.")); + } + + /* (non-Javadoc) + * @see pcgen.gui2.tabs.CharacterInfoTab#getTabTitle() + */ + public TabTitle getTabTitle() + { + TabTitle title = new TabTitle(getTabName()); + title.putValue(TabTitle.TOOLTIP, "This tab has not yet been implemented."); + return title; + } + + /** + * @return The name of the tab that has not been implemented. + */ + abstract String getTabName(); + + /* (non-Javadoc) + * @see pcgen.gui2.tabs.CharacterInfoTab#createModels(pcgen.core.facade.CharacterFacade) + */ + public Hashtable<Object, Object> createModels(CharacterFacade character) + { + return new Hashtable<Object, Object>(); + } + + /* (non-Javadoc) + * @see pcgen.gui2.tabs.CharacterInfoTab#restoreModels(java.util.Hashtable) + */ + public void restoreModels(Hashtable<?, ?> state) + { + //No action + } + + /* (non-Javadoc) + * @see pcgen.gui2.tabs.CharacterInfoTab#storeModels(java.util.Hashtable) + */ + public void storeModels(Hashtable<Object, Object> state) + { + //No action + } + +} Property changes on: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/UnimplementedTab.java ___________________________________________________________________ Added: svn:keywords + Date Author Revision Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2011-01-24 23:19:18
|
Revision: 14435 http://pcgen.svn.sourceforge.net/pcgen/?rev=14435&view=rev Author: cpmeister Date: 2011-01-24 23:19:11 +0000 (Mon, 24 Jan 2011) Log Message: ----------- made switching between characters faster Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java 2011-01-24 22:56:55 UTC (rev 14434) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/CharacterInfoTab.java 2011-01-24 23:19:11 UTC (rev 14435) @@ -21,8 +21,6 @@ package pcgen.gui2.tabs; import java.util.Hashtable; -import javax.swing.Action; -import javax.swing.undo.StateEditable; import pcgen.core.facade.CharacterFacade; /** Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java 2011-01-24 22:56:55 UTC (rev 14434) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java 2011-01-24 23:19:11 UTC (rev 14435) @@ -25,8 +25,6 @@ import java.awt.Insets; import java.awt.event.ActionEvent; import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Hashtable; import java.util.List; Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2011-01-24 22:56:55 UTC (rev 14434) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/InfoTabbedPane.java 2011-01-24 23:19:11 UTC (rev 14435) @@ -28,6 +28,7 @@ import java.util.Map; import javax.swing.Icon; import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; import pcgen.base.util.DoubleKeyMap; import pcgen.core.facade.CharacterFacade; import pcgen.gui2.tools.CharacterSelectionListener; @@ -99,13 +100,30 @@ } currentCharacter = character; //TODO: change this to use a SwingWorker - //revisited: hmm, this might not actually be necessary... - Map<CharacterInfoTab, Hashtable<Object, Object>> states = stateMap.getMapFor(character); - for (CharacterInfoTab tab : states.keySet()) + //it might be possible to do this better + final Map<CharacterInfoTab, Hashtable<Object, Object>> states = stateMap.getMapFor(character); + int selectedIndex = tabSelectionMap.get(character); + + final CharacterInfoTab tab = (CharacterInfoTab) getComponentAt(selectedIndex); + tab.restoreModels(states.get(tab)); + setSelectedIndex(selectedIndex); + + SwingUtilities.invokeLater(new Runnable() { - tab.restoreModels(states.get(tab)); - } - setSelectedIndex(tabSelectionMap.get(character)); + + public void run() + { + for (CharacterInfoTab infoTab : states.keySet()) + { + if (tab == infoTab) + { + continue; + } + infoTab.restoreModels(states.get(infoTab)); + } + } + + }); } private <T extends Component & CharacterInfoTab> void addTab(T tab) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2011-02-10 00:58:53
|
Revision: 14541 http://pcgen.svn.sourceforge.net/pcgen/?rev=14541&view=rev Author: cpmeister Date: 2011-02-10 00:58:46 +0000 (Thu, 10 Feb 2011) Log Message: ----------- added default sorting to domain, race, and skill tabs Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java 2011-02-09 23:59:00 UTC (rev 14540) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java 2011-02-10 00:58:46 UTC (rev 14541) @@ -21,7 +21,6 @@ package pcgen.gui2.tabs; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; @@ -65,6 +64,8 @@ import pcgen.gui2.tools.FlippingSplitPane; import pcgen.gui2.tools.InfoPane; import pcgen.gui2.util.JDynamicTable; +import pcgen.gui2.util.SortMode; +import pcgen.gui2.util.SortingPriority; import pcgen.gui2.util.table.TableCellUtilities; import pcgen.gui2.util.treeview.DataView; import pcgen.gui2.util.treeview.DataViewColumn; @@ -113,6 +114,9 @@ bar.addDisplayableFilter(new SearchFilterPanel()); deityTable.setDisplayableFilter(bar); panel.add(bar, BorderLayout.NORTH); + + deityTable.setSortingPriority(Collections.singletonList(new SortingPriority(0, SortMode.ASCENDING))); + deityTable.sortModel(); ListSelectionModel selectionModel = deityTable.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); panel.add(new JScrollPane(deityTable), BorderLayout.CENTER); Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java 2011-02-09 23:59:00 UTC (rev 14540) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java 2011-02-10 00:58:46 UTC (rev 14541) @@ -51,6 +51,8 @@ import pcgen.gui2.filter2.SearchFilterPanel; import pcgen.gui2.tools.FlippingSplitPane; import pcgen.gui2.tools.InfoPane; +import pcgen.gui2.util.SortMode; +import pcgen.gui2.util.SortingPriority; import pcgen.gui2.util.treeview.DataView; import pcgen.gui2.util.treeview.DataViewColumn; import pcgen.gui2.util.treeview.DefaultDataViewColumn; @@ -94,6 +96,9 @@ bar.addDisplayableFilter(new SearchFilterPanel()); raceTable.setDisplayableFilter(bar); panel.add(bar, BorderLayout.NORTH); + + raceTable.setSortingPriority(Collections.singletonList(new SortingPriority(0, SortMode.ASCENDING))); + raceTable.sortModel(); panel.add(new JScrollPane(raceTable), BorderLayout.CENTER); Box box = Box.createHorizontalBox(); @@ -239,13 +244,13 @@ private static final DefaultListFacade<? extends TreeView<RaceFacade>> treeViews = new DefaultListFacade<TreeView<RaceFacade>>(Arrays.asList(RaceTreeView.values())); private static final List<DefaultDataViewColumn> columns = - Arrays.asList(new DefaultDataViewColumn("Stat Adjustments", String.class), + Arrays.asList(new DefaultDataViewColumn("Stat Adjustments", String.class, true), new DefaultDataViewColumn("Pre-Reqs", String.class), - new DefaultDataViewColumn("Size", String.class), - new DefaultDataViewColumn("Movement", String.class), + new DefaultDataViewColumn("Size", String.class, true), + new DefaultDataViewColumn("Movement", String.class, true), new DefaultDataViewColumn("Vision", String.class), - new DefaultDataViewColumn("Favored Class", String.class), - new DefaultDataViewColumn("Lvl Adj", String.class)); + new DefaultDataViewColumn("Favored Class", String.class, true), + new DefaultDataViewColumn("Lvl Adj", String.class, true)); private final CharacterFacade character; private final InfoFactory infoFactory; Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java 2011-02-09 23:59:00 UTC (rev 14540) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/SkillInfoTab.java 2011-02-10 00:58:46 UTC (rev 14541) @@ -29,6 +29,7 @@ import java.awt.event.MouseListener; import java.text.DecimalFormat; import java.util.Arrays; +import java.util.Collections; import java.util.Hashtable; import java.util.List; import javax.swing.AbstractSpinnerModel; @@ -69,6 +70,8 @@ import pcgen.gui2.filter2.FilteredTreeViewTable; import pcgen.gui2.filter2.SearchFilterPanel; import pcgen.gui2.tools.ChooserPane; +import pcgen.gui2.util.SortMode; +import pcgen.gui2.util.SortingPriority; import pcgen.gui2.util.table.TableCellUtilities.SpinnerEditor; import pcgen.gui2.util.table.TableCellUtilities.SpinnerRenderer; import pcgen.gui2.util.treeview.DataView; @@ -111,6 +114,8 @@ JSpinner spinner = new JSpinner(); spinner.setEditor(new JSpinner.NumberEditor(spinner, "#0.0")); + skillTable.setSortingPriority(Collections.singletonList(new SortingPriority(0, SortMode.ASCENDING))); + skillTable.sortModel(); skillTable.setDefaultRenderer(Float.class, new SpinnerRenderer(spinner)); skillTable.setRowHeight(20); ListSelectionModel selectionModel = skillTable.getSelectionModel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cpm...@us...> - 2011-02-12 01:58:38
|
Revision: 14555 http://pcgen.svn.sourceforge.net/pcgen/?rev=14555&view=rev Author: cpmeister Date: 2011-02-12 01:58:31 +0000 (Sat, 12 Feb 2011) Log Message: ----------- fixed keyboard selection issue on domain and race tabs Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java 2011-02-12 00:39:47 UTC (rev 14554) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/DomainInfoTab.java 2011-02-12 01:58:31 UTC (rev 14555) @@ -42,6 +42,7 @@ import javax.swing.table.DefaultTableCellRenderer; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreePath; import org.apache.commons.lang.StringUtils; import pcgen.core.facade.CharacterFacade; import pcgen.core.facade.DeityFacade; @@ -288,13 +289,13 @@ { if (!e.getValueIsAdjusting()) { - List<Object> data = deityTable.getSelectedData(); - for (Object object : data) + int selectedRow = deityTable.getSelectedRow(); + if (selectedRow != -1) { - if (object instanceof DeityFacade) + Object obj = deityTable.getModel().getValueAt(selectedRow, 0); + if (obj instanceof DeityFacade) { - deityInfo.setText(character.getInfoFactory().getHTMLInfo((DeityFacade) object)); - return; + deityInfo.setText(character.getInfoFactory().getHTMLInfo((DeityFacade) obj)); } } } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java 2011-02-12 00:39:47 UTC (rev 14554) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/RaceInfoTab.java 2011-02-12 01:58:31 UTC (rev 14555) @@ -208,13 +208,13 @@ { if (!e.getValueIsAdjusting()) { - List<Object> list = raceTable.getSelectedData(); - for (Object object : list) + int selectedRow = raceTable.getSelectedRow(); + if (selectedRow != -1) { - if (object instanceof RaceFacade) + Object obj = raceTable.getModel().getValueAt(selectedRow, 0); + if (obj instanceof RaceFacade) { - infoPane.setText(character.getInfoFactory().getHTMLInfo((RaceFacade) object)); - return; + infoPane.setText(character.getInfoFactory().getHTMLInfo((RaceFacade) obj)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jde...@us...> - 2011-02-12 03:28:02
|
Revision: 14557 http://pcgen.svn.sourceforge.net/pcgen/?rev=14557&view=rev Author: jdempsey Date: 2011-02-12 03:27:52 +0000 (Sat, 12 Feb 2011) Log Message: ----------- Display violated prereqs on equipping screen * Color any equipment items which the character is not qualified for * Add styling for empty slots. Issue#: CODE-520 Modified Paths: -------------- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentModel.java sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentTreeTableModel.java Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java 2011-02-12 02:17:42 UTC (rev 14556) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/EquipInfoTab.java 2011-02-12 03:27:52 UTC (rev 14557) @@ -21,6 +21,7 @@ package pcgen.gui2.tabs; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Font; import java.awt.Insets; import java.awt.event.ActionEvent; @@ -36,8 +37,10 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTable; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; import pcgen.core.facade.CharacterFacade; @@ -46,6 +49,7 @@ import pcgen.core.facade.ReferenceFacade; import pcgen.core.facade.event.ReferenceEvent; import pcgen.core.facade.event.ReferenceListener; +import pcgen.gui2.UIPropertyContext; import pcgen.gui2.filter2.DisplayableFilter; import pcgen.gui2.filter2.SearchFilterPanel; import pcgen.gui2.tabs.equip.EquipmentModel; @@ -257,6 +261,7 @@ state.put(RemoveSetAction.class, new RemoveSetAction(character)); state.put(LabelsUpdater.class, new LabelsUpdater(character)); state.put(EquipInfoHandler.class, new EquipInfoHandler(character)); + state.put(EquipmentRenderer.class, new EquipmentRenderer(character)); return state; } @@ -268,6 +273,7 @@ equipButton, unequipButton); ((LabelsUpdater) state.get(LabelsUpdater.class)).install(); ((EquipInfoHandler) state.get(EquipInfoHandler.class)).install(); + ((EquipmentRenderer) state.get(EquipmentRenderer.class)).install(); unequipAllButton.setAction((UnequipAllAction) state.get(UnequipAllAction.class)); newSetButton.setAction((AddSetAction) state.get(AddSetAction.class)); @@ -467,4 +473,36 @@ } + private class EquipmentRenderer extends DefaultTableCellRenderer + { + + private CharacterFacade character; + + public EquipmentRenderer(CharacterFacade character) + { + this.character = character; + } + + public void install() + { + equipmentTable.setDefaultRenderer(Object.class, this); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) + { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + if (value instanceof EquipmentFacade && !character.isQualifiedFor((EquipmentFacade) value)) + { + setForeground(UIPropertyContext.getNotQualifiedColor()); + } + else + { + setForeground(UIPropertyContext.getQualifiedColor()); + } + return this; + } + + } + } Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentModel.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentModel.java 2011-02-12 02:17:42 UTC (rev 14556) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentModel.java 2011-02-12 03:27:52 UTC (rev 14557) @@ -26,6 +26,7 @@ import java.awt.Rectangle; import java.util.HashMap; import java.util.Map; + import javax.swing.BorderFactory; import javax.swing.JTable; import javax.swing.JTree; @@ -40,14 +41,18 @@ import javax.swing.table.TableColumn; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeCellRenderer; + import pcgen.core.facade.CharacterFacade; +import pcgen.core.facade.EquipmentFacade; import pcgen.core.facade.EquipmentSetFacade; import pcgen.core.facade.EquipmentSetFacade.EquipNode; +import pcgen.core.facade.EquipmentSetFacade.EquipNode.NodeType; import pcgen.core.facade.event.ListEvent; import pcgen.core.facade.event.ListListener; import pcgen.core.facade.event.ReferenceEvent; import pcgen.core.facade.event.ReferenceListener; import pcgen.core.facade.util.ListFacade; +import pcgen.gui2.UIPropertyContext; import pcgen.gui2.util.JTreeTable; /** @@ -61,6 +66,7 @@ private static Font largeFont = new Font("Verdana", Font.BOLD, 20); private static Font headerFont = new Font("Verdana", Font.BOLD, 12); private static Font normFont = new Font("Verdana", Font.PLAIN, 12); + private static Font italicFont = new Font("Verdana", Font.ITALIC, 12); private final CharacterFacade character; private TreeCellRenderer treeRenderer = new TreeRenderer(); private Map<EquipmentSetFacade, EquipmentTreeTableModel> equipsetMap; @@ -244,19 +250,39 @@ @Override public Component getTreeCellRendererComponent(final JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, final int row, boolean hasFocus) { - super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + String text = String.valueOf(value); + boolean isEquipNode = value instanceof EquipNode; + boolean isPhantomSlot = isEquipNode && ((EquipNode) value).getNodeType()==NodeType.PHANTOM_SLOT; + if (isPhantomSlot) + { + text = "Empty slot"; + } + super.getTreeCellRendererComponent(tree, text, sel, expanded, leaf, row, hasFocus); - //DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; - //EquipPath path = (EquipPath) node.getUserObject(); - //if(node.) - if (value instanceof EquipNode && ((EquipNode) value).getParent() == null) + if (isEquipNode && ((EquipNode) value).getParent() == null) { setFont(largeFont); setIcon(null); } + else if (isPhantomSlot) + { + setFont(italicFont); + setForeground(Color.GRAY); + setIcon(null); + } else { setFont(normFont); + EquipmentFacade equip = null; + setForeground(UIPropertyContext.getQualifiedColor()); + if (isEquipNode && ((EquipNode) value).getNodeType()==NodeType.EQUIPMENT) + { + equip = ((EquipNode) value).getEquipment(); + if (!character.isQualifiedFor(equip)) + { + setForeground(UIPropertyContext.getNotQualifiedColor()); + } + } } if (row != -1) Modified: sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentTreeTableModel.java =================================================================== --- sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentTreeTableModel.java 2011-02-12 02:17:42 UTC (rev 14556) +++ sandbox/cdomui/code/src/java/pcgen/gui2/tabs/equip/EquipmentTreeTableModel.java 2011-02-12 03:27:52 UTC (rev 14557) @@ -150,7 +150,13 @@ return "Wgt"; } case PHANTOM_SLOT: - return null; + switch (column) + { + case 2: + return equipSet.getLocation(pathNode); + default: + return null; + } case EQUIPMENT: switch (column) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |