From: <sou...@us...> - 2006-03-04 02:03:19
|
Revision: 93 Author: soulcatcher Date: 2006-03-03 18:03:12 -0800 (Fri, 03 Mar 2006) ViewCVS: http://svn.sourceforge.net/pcgen/?rev=93&view=rev Log Message: ----------- added column tweaking, fixed layout issues. Modified Paths: -------------- Trunk/pcgen/code/src/java/pcgen/gui/TableColumnManager.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoKnownSpells.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoSpellBooks.java Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java Modified: Trunk/pcgen/code/src/java/pcgen/gui/TableColumnManager.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/TableColumnManager.java 2006-03-04 01:56:27 UTC (rev 92) +++ Trunk/pcgen/code/src/java/pcgen/gui/TableColumnManager.java 2006-03-04 02:03:12 UTC (rev 93) @@ -14,21 +14,19 @@ import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; +import pcgen.TableColumnManagerModel; + public class TableColumnManager implements MouseListener { private JPopupMenu tablePopup; private List checkBoxList; - private List columnList; - private List settingList; - private int columnOffset = 0; private JTable table; private JComponent tableButton; + private TableColumnManagerModel model; - public TableColumnManager(JTable table, JComponent tableButton, List columnList, List settingList, int columnOffset) { + public TableColumnManager(JTable table, JComponent tableButton, TableColumnManagerModel model) { this.table = table; this.tableButton = tableButton; - this.columnList = columnList; - this.settingList = settingList; - this.columnOffset = columnOffset; + this.model = model; initContents(); } @@ -37,17 +35,18 @@ checkBoxList = new ArrayList(); tablePopup = new javax.swing.JPopupMenu(); - for(int i = 0; i < columnList.size(); i++) { - String name = (String)columnList.get(i); - boolean selected = ((Boolean)settingList.get(i)).booleanValue(); + for(int i = 0; i < model.getMColumnList().size(); i++) { + String name = (String)model.getMColumnList().get(i); + boolean selected = model.isMColumnDisplayed(i); JCheckBoxMenuItem popupCb = new JCheckBoxMenuItem(); tablePopup.add(popupCb); popupCb.setText(name); popupCb.setSelected(selected); - popupCb.addActionListener(new PopupActionListener(popupCb, i + columnOffset)); + popupCb.addActionListener(new PopupActionListener(popupCb, i + model.getMColumnOffset())); checkBoxList.add(popupCb); } tableButton.addMouseListener(this); + TablePopupActionPerformed(); } public void tableDisplay(java.awt.event.MouseEvent evt) { @@ -62,8 +61,9 @@ } for(int i = 0; i < checkBoxList.size(); i++) { JCheckBoxMenuItem cb = (JCheckBoxMenuItem)checkBoxList.get(i); + model.setMColumnDisplayed(i, cb.isSelected()); if(cb.isSelected()) { - TableColumn col = new TableColumn(i + columnOffset); + TableColumn col = new TableColumn(i + model.getMColumnOffset()); col.setHeaderValue(cb.getText()); colModel.addColumn(col); } Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoKnownSpells.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoKnownSpells.java 2006-03-04 01:56:27 UTC (rev 92) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoKnownSpells.java 2006-03-04 02:03:12 UTC (rev 93) @@ -72,6 +72,7 @@ import pcgen.core.utils.ShowMessageDelegate; import pcgen.gui.GuiConstants; import pcgen.gui.PCGen_Frame1; +import pcgen.gui.TableColumnManager; import pcgen.gui.filter.FilterFactory; import pcgen.gui.panes.FlippingSplitPane; import pcgen.gui.utils.IconUtilitities; @@ -508,12 +509,10 @@ { topPane.setLayout(new BorderLayout()); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); JPanel leftPane = new JPanel(); JPanel rightPane = new JPanel(); - leftPane.setLayout(gridbag); - rightPane.setLayout(gridbag); + leftPane.setLayout(new BorderLayout()); + rightPane.setLayout(new BorderLayout()); splitPane = new FlippingSplitPane(splitOrientation, leftPane, rightPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerSize(10); @@ -524,92 +523,79 @@ // first build the left pane // for the availabe spells table and info // - Utility.buildConstraints(c, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - JPanel aPanel = new JPanel(); - gridbag.setConstraints(aPanel, c); aPanel.add(avaLabel); aPanel.add(primaryViewComboBox); aPanel.add(secondaryViewComboBox); - Utility.setDescription(addSpellButton, PropertyFactory - .getString("InfoSpells.add.selected")); //$NON-NLS-1$ - addSpellButton.setEnabled(false); - aPanel.add(addSpellButton); + leftPane.add(aPanel, BorderLayout.NORTH); - Utility.setDescription(aPanel, PropertyFactory - .getString("InfoSpells.rightclick.add.to.spellbooks")); //$NON-NLS-1$ - leftPane.add(aPanel); - // the available spells panel - Utility.buildConstraints(c, 0, 1, 1, 1, 10, 10, - GridBagConstraints.BOTH, GridBagConstraints.NORTH); - c.ipadx = 1; + JScrollPane scrollPane = new JScrollPane(availableTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + leftPane.add(scrollPane, BorderLayout.CENTER); - JScrollPane scrollPane = new JScrollPane(availableTable); - gridbag.setConstraints(scrollPane, c); - leftPane.add(scrollPane); + JButton columnButton = new JButton(); + scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, columnButton); + columnButton.setText("^"); + new TableColumnManager(availableTable, columnButton, availableModel); // Auto add known option - Utility.buildConstraints(c, 0, 2, 1, 1, 0, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); + leftPane.add(buildAddSpellPanel(), BorderLayout.SOUTH); - JPanel bPanel = new JPanel(); - gridbag.setConstraints(bPanel, c); - shouldAutoSpells.setSelected(pc.getAutoSpells()); - bPanel.add(shouldAutoSpells); - leftPane.add(bPanel); - // // now build the right pane // for the selected (SpellBooks) table // - gridbag = new GridBagLayout(); - c = new GridBagConstraints(); - rightPane.setLayout(gridbag); - // Buttons above spellbooks and known spells - Utility.buildConstraints(c, 0, 0, 1, 1, 2, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - - JPanel iPanel = new JPanel(); - gridbag.setConstraints(iPanel, c); - Utility.setDescription(delSpellButton, PropertyFactory - .getString("InfoSpells.remove.selected")); //$NON-NLS-1$ - delSpellButton.setEnabled(false); - iPanel.add(delSpellButton); - rightPane.add(iPanel); - - Utility.buildConstraints(c, 1, 0, 1, 1, 1, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - JPanel sPanel = new JPanel(); - gridbag.setConstraints(sPanel, c); sPanel.add(selLabel); sPanel.add(primaryViewSelectComboBox); sPanel.add(secondaryViewSelectComboBox); - rightPane.add(sPanel); + rightPane.add(sPanel, BorderLayout.NORTH); // List of known spells Panel - Utility.buildConstraints(c, 0, 1, 3, 1, 10, 10, - GridBagConstraints.BOTH, GridBagConstraints.NORTH); - c.ipadx = 1; - scrollPane = new JScrollPane(selectedTable); - gridbag.setConstraints(scrollPane, c); + scrollPane = new JScrollPane(selectedTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); selectedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); selectedTable.setShowHorizontalLines(true); - rightPane.add(scrollPane); + rightPane.add(scrollPane, BorderLayout.CENTER); - JPanel ssPanel = buildOutputSpellsPanel(); - Utility.buildConstraints(c, 0, 2, 3, 1, 1, 0, - GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); - gridbag.setConstraints(ssPanel, c); - rightPane.add(ssPanel); + JButton columnButton2 = new JButton(); + scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, columnButton2); + columnButton2.setText("^"); + new TableColumnManager(selectedTable, columnButton2, selectedModel); + + rightPane.add(buildOutputSpellsPanel(), BorderLayout.SOUTH); } /** + * Build the panel with the controls to add a spell to a + * prepared list. + * + * @return The panel. + */ + private JPanel buildAddSpellPanel() + { + GridBagConstraints c = new GridBagConstraints(); + + JPanel asPanel = new JPanel(new GridBagLayout()); + shouldAutoSpells.setSelected(pc.getAutoSpells()); + c = new GridBagConstraints(); + Utility.buildConstraints(c, 0, 0, 1, 1, 0.0, 0.0); + c.insets = new Insets(2, 2, 2, 2); + asPanel.add(shouldAutoSpells, c); + + c = new GridBagConstraints(); + Utility.buildConstraints(c, 3, 0, 1, 1, 0.0, 0.0); + c.insets = new Insets(2, 2, 2, 2); + Utility.setDescription(addSpellButton, PropertyFactory.getString("InfoSpells.add.selected")); //$NON-NLS-1$ + addSpellButton.setEnabled(false); + asPanel.add(addSpellButton, c); + + return asPanel; + } + + /** * Build the Spell sheet selection and output panel * * @return The panel. @@ -642,18 +628,28 @@ c = new GridBagConstraints(); Utility.buildConstraints(c, 0, 0, 1, 1, 0.0, 0.0); c.insets = new Insets(2, 2, 2, 2); + Utility.setDescription(delSpellButton, PropertyFactory.getString("InfoSpells.remove.selected")); //$NON-NLS-1$ + delSpellButton.setEnabled(false); + ssPanel.add(delSpellButton, c); + + c = new GridBagConstraints(); + Utility.buildConstraints(c, 1, 0, 1, 1, 0.0, 0.0); + c.insets = new Insets(2, 2, 2, 2); ssPanel.add(selectSpellSheetButton, c); + c = new GridBagConstraints(); - Utility.buildConstraints(c, 1, 0, 1, 1, 1.0, 0.0); + Utility.buildConstraints(c, 2, 0, 1, 1, 1.0, 0.0); c.insets = new Insets(2, 2, 2, 2); c.fill = GridBagConstraints.HORIZONTAL; ssPanel.add(selectSpellSheetField, c); + c = new GridBagConstraints(); - Utility.buildConstraints(c, 2, 0, 1, 1, 0.0, 0.0); + Utility.buildConstraints(c, 3, 0, 1, 1, 0.0, 0.0); c.insets = new Insets(2, 2, 2, 2); ssPanel.add(printHtml, c); + c = new GridBagConstraints(); - Utility.buildConstraints(c, 3, 0, 1, 1, 0.0, 0.0); + Utility.buildConstraints(c, 4, 0, 1, 1, 0.0, 0.0); c.insets = new Insets(2, 2, 2, 2); ssPanel.add(printPdf, c); return ssPanel; Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java 2006-03-04 01:56:27 UTC (rev 92) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoPreparedSpells.java 2006-03-04 02:03:12 UTC (rev 93) @@ -70,6 +70,7 @@ import pcgen.core.utils.ShowMessageDelegate; import pcgen.gui.GuiConstants; import pcgen.gui.PCGen_Frame1; +import pcgen.gui.TableColumnManager; import pcgen.gui.filter.FilterFactory; import pcgen.gui.panes.FlippingSplitPane; import pcgen.gui.utils.IconUtilitities; @@ -514,12 +515,10 @@ { topPane.setLayout(new BorderLayout()); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); JPanel leftPane = new JPanel(); JPanel rightPane = new JPanel(); - leftPane.setLayout(gridbag); - rightPane.setLayout(gridbag); + leftPane.setLayout(new BorderLayout()); + rightPane.setLayout(new BorderLayout()); splitPane = new FlippingSplitPane(splitOrientation, leftPane, rightPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerSize(10); @@ -530,82 +529,56 @@ // first build the left pane // for the availabe spells table and info // - Utility.buildConstraints(c, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); JPanel aPanel = new JPanel(); - gridbag.setConstraints(aPanel, c); aPanel.add(avaLabel); aPanel.add(primaryViewComboBox); aPanel.add(secondaryViewComboBox); Utility.setDescription(aPanel, PropertyFactory .getString("InfoSpells.rightclick.add.to.spellbooks")); //$NON-NLS-1$ - leftPane.add(aPanel); + leftPane.add(aPanel, BorderLayout.NORTH); // the available spells panel - Utility.buildConstraints(c, 0, 1, 1, 1, 10, 10, - GridBagConstraints.BOTH, GridBagConstraints.NORTH); - c.ipadx = 1; + JScrollPane scrollPane = new JScrollPane(availableTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + leftPane.add(scrollPane, BorderLayout.CENTER); - JScrollPane scrollPane = new JScrollPane(availableTable); - gridbag.setConstraints(scrollPane, c); - leftPane.add(scrollPane); + JButton columnButton = new JButton(); + scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, columnButton); + columnButton.setText("^"); + new TableColumnManager(availableTable, columnButton, availableModel); - JPanel addSpellPanel = buildAddSpellPanel(); - Utility.buildConstraints(c, 0, 2, 1, 1, 1, 0, - GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); - gridbag.setConstraints(addSpellPanel, c); - leftPane.add(addSpellPanel); + leftPane.add(buildAddSpellPanel(), BorderLayout.SOUTH); // // now build the right pane // for the selected (SpellBooks) table // - gridbag = new GridBagLayout(); - c = new GridBagConstraints(); - rightPane.setLayout(gridbag); - // Buttons above spellbooks and known spells - Utility.buildConstraints(c, 0, 0, 1, 1, 2, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - - JPanel iPanel = new JPanel(); - gridbag.setConstraints(iPanel, c); - Utility.setDescription(delSpellButton, PropertyFactory - .getString("InfoSpells.remove.selected")); //$NON-NLS-1$ - delSpellButton.setEnabled(false); - iPanel.add(delSpellButton); - rightPane.add(iPanel); - - Utility.buildConstraints(c, 1, 0, 1, 1, 1, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - JPanel sPanel = new JPanel(); - gridbag.setConstraints(sPanel, c); sPanel.add(selLabel); sPanel.add(primaryViewSelectComboBox); sPanel.add(secondaryViewSelectComboBox); - rightPane.add(sPanel); + rightPane.add(sPanel, BorderLayout.NORTH); // Prepared spell lists panel JPanel slPanel = buildSpellListPanel(); - Utility.buildConstraints(c, 0, 1, 2, 1, 1, 0, GridBagConstraints.HORIZONTAL, - GridBagConstraints.NORTH); - gridbag.setConstraints(slPanel, c); rightPane.add(slPanel); // List of known spells Panel - Utility.buildConstraints(c, 0, 2, 3, 1, 10, 10, - GridBagConstraints.BOTH, GridBagConstraints.NORTH); - c.ipadx = 1; - scrollPane = new JScrollPane(selectedTable); - gridbag.setConstraints(scrollPane, c); - scrollPane - .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane = new JScrollPane(selectedTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); selectedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); selectedTable.setShowHorizontalLines(true); - rightPane.add(scrollPane); + rightPane.add(scrollPane, BorderLayout.CENTER); + + JButton columnButton2 = new JButton(); + scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, columnButton2); + columnButton2.setText("^"); + new TableColumnManager(selectedTable, columnButton2, selectedModel); + + // Buttons above spellbooks and known spells + rightPane.add(buildSpellListPanel(), BorderLayout.SOUTH); } /** @@ -618,13 +591,9 @@ { GridBagConstraints c = new GridBagConstraints(); - // JPanel asPanel = new JPanel(new GridBagLayout()); - addSpellMMButton = new JButton(addSpellWithMetaMagicTitle); - createFeatList(); - c = new GridBagConstraints(); Utility.buildConstraints(c, 0, 0, 1, 1, 0.0, 0.0); c.insets = new Insets(2, 2, 2, 2); @@ -633,8 +602,7 @@ c = new GridBagConstraints(); Utility.buildConstraints(c, 3, 0, 1, 1, 0.0, 0.0); c.insets = new Insets(2, 2, 2, 2); - Utility.setDescription(addSpellButton, PropertyFactory - .getString("InfoSpells.add.selected")); //$NON-NLS-1$ + Utility.setDescription(addSpellButton, PropertyFactory.getString("InfoSpells.add.selected")); //$NON-NLS-1$ addSpellButton.setEnabled(false); asPanel.add(addSpellButton, c); @@ -654,30 +622,33 @@ c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTH; - // JPanel slPanel = new JPanel(new GridBagLayout()); + Utility.buildConstraints(c, 0, 0, 1, 1, 0.0, 0.0); + Utility.setDescription(delSpellButton, PropertyFactory.getString("InfoSpells.add.selected")); //$NON-NLS-1$ + delSpellButton.setEnabled(false); + slPanel.add(delSpellButton, c); + JLabel prepListLabel = new JLabel(PropertyFactory .getString("InfoPreparedSpells.preparedList")); //$NON-NLS-1$ - Utility.buildConstraints(c, 0, 0, 1, 1, 0.0, 0.0); + Utility.buildConstraints(c, 1, 0, 1, 1, 0.0, 0.0); slPanel.add(prepListLabel, c); spellBookNameText.setEditable(true); - spellBookNameText.setPreferredSize(new Dimension(100, 20)); - Utility.buildConstraints(c, 1, 0, 1, 1, 1.0, 0.0); + Utility.buildConstraints(c, 2, 0, 1, 1, 1.0, 0.0); c.fill = GridBagConstraints.HORIZONTAL; slPanel.add(spellBookNameText, c); addSpellListButton = new JButton(PropertyFactory.getString("InfoSpells.add")); //$NON-NLS-1$ Utility.setDescription(addSpellListButton, PropertyFactory .getString("InfoPreparedSpells.add.list")); //$NON-NLS-1$ - Utility.buildConstraints(c, 2, 0, 1, 1, 0.0, 0.0); + Utility.buildConstraints(c, 3, 0, 1, 1, 0.0, 0.0); c.fill = GridBagConstraints.NONE; slPanel.add(addSpellListButton, c); delSpellListButton = new JButton(PropertyFactory.getString("InfoSpells.delete")); //$NON-NLS-1$ Utility.setDescription(delSpellListButton, PropertyFactory .getString("InfoPreparedSpells.del.list")); //$NON-NLS-1$ - Utility.buildConstraints(c, 3, 0, 1, 1, 0.0, 0.0); + Utility.buildConstraints(c, 4, 0, 1, 1, 0.0, 0.0); slPanel.add(delSpellListButton, c); return slPanel; Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoSpellBooks.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoSpellBooks.java 2006-03-04 01:56:27 UTC (rev 92) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/InfoSpellBooks.java 2006-03-04 02:03:12 UTC (rev 93) @@ -467,142 +467,54 @@ { topPane.setLayout(new BorderLayout()); - GridBagLayout gridbag = new GridBagLayout(); - GridBagConstraints c = new GridBagConstraints(); JPanel leftPane = new JPanel(); JPanel rightPane = new JPanel(); - leftPane.setLayout(gridbag); - rightPane.setLayout(gridbag); + leftPane.setLayout(new BorderLayout()); + rightPane.setLayout(new BorderLayout()); splitPane = new FlippingSplitPane(splitOrientation, leftPane, rightPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerSize(10); topPane.add(splitPane, BorderLayout.CENTER); - // - // first build the left pane - // for the availabe spells table and info - // - Utility.buildConstraints(c, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - JPanel aPanel = new JPanel(); - gridbag.setConstraints(aPanel, c); aPanel.add(avaLabel); aPanel.add(primaryViewComboBox); aPanel.add(secondaryViewComboBox); Utility.setDescription(aPanel, PropertyFactory .getString("InfoSpells.rightclick.add.to.spellbooks")); //$NON-NLS-1$ - leftPane.add(aPanel); + leftPane.add(aPanel, BorderLayout.NORTH); - // the available spells panel - Utility.buildConstraints(c, 0, 1, 1, 1, 10, 10, - GridBagConstraints.BOTH, GridBagConstraints.NORTH); - c.ipadx = 1; - JScrollPane scrollPane = new JScrollPane(availableTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - gridbag.setConstraints(scrollPane, c); - leftPane.add(scrollPane); + leftPane.add(scrollPane, BorderLayout.CENTER); JButton columnButton = new JButton(); scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, columnButton); columnButton.setText("^"); - List colNameList = new ArrayList(); - colNameList.add("School"); - colNameList.add("Descriptor"); - colNameList.add("Source File"); - List colActiveList = new ArrayList(); - colActiveList.add(new Boolean(false)); - colActiveList.add(new Boolean(false)); - colActiveList.add(new Boolean(false)); - TableColumnManager manager = new TableColumnManager(availableTable, columnButton, colNameList, colActiveList, 1); + new TableColumnManager(availableTable, columnButton, availableModel); - JPanel addSpellPanel = buildAddSpellPanel(); - Utility.buildConstraints(c, 0, 2, 1, 1, 1, 0, - GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); - gridbag.setConstraints(addSpellPanel, c); - leftPane.add(addSpellPanel); + leftPane.add(buildModSpellPanel(addSpellButton, "InfoSpells.add.selected"), BorderLayout.SOUTH); - // - // now build the right pane - // for the selected (SpellBooks) table - // - gridbag = new GridBagLayout(); - c = new GridBagConstraints(); - rightPane.setLayout(gridbag); - - // Buttons above spellbooks and known spells - Utility.buildConstraints(c, 0, 0, 1, 1, 2, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - - JPanel iPanel = new JPanel(); - gridbag.setConstraints(iPanel, c); - Utility.setDescription(delSpellButton, PropertyFactory - .getString("InfoSpells.remove.selected")); //$NON-NLS-1$ - delSpellButton.setEnabled(false); - iPanel.add(delSpellButton); - rightPane.add(iPanel); - - Utility.buildConstraints(c, 1, 0, 1, 1, 1, 0, GridBagConstraints.NONE, - GridBagConstraints.NORTH); - JPanel sPanel = new JPanel(); - gridbag.setConstraints(sPanel, c); sPanel.add(selLabel); sPanel.add(primaryViewSelectComboBox); sPanel.add(secondaryViewSelectComboBox); - rightPane.add(sPanel); + rightPane.add(sPanel, BorderLayout.NORTH); - // Prepared spell lists panel -// JPanel slPanel = buildSpellListPanel(); -// Utility.buildConstraints(c, 0, 1, 2, 1, 1, 0, GridBagConstraints.HORIZONTAL, -// GridBagConstraints.NORTH); -// gridbag.setConstraints(slPanel, c); -// rightPane.add(slPanel); - - // List of spell books Panel - Utility.buildConstraints(c, 0, 2, 3, 1, 10, 10, - GridBagConstraints.BOTH, GridBagConstraints.NORTH); - c.ipadx = 1; scrollPane = new JScrollPane(selectedTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - gridbag.setConstraints(scrollPane, c); scrollPane .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); selectedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); selectedTable.setShowHorizontalLines(true); - rightPane.add(scrollPane); + rightPane.add(scrollPane, BorderLayout.CENTER); JButton columnButton2 = new JButton(); scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, columnButton2); - columnButton.setText("^"); - List colNameList2 = new ArrayList(); - colNameList2.add("School"); - colNameList2.add("Subschool"); - colNameList2.add("Descriptor"); - colNameList2.add("Components"); - colNameList2.add("Casting Time"); - colNameList2.add("Range"); - colNameList2.add("Description"); - colNameList2.add("Target Area"); - colNameList2.add("Duration"); - colNameList2.add("Save Info"); - colNameList2.add("SR"); - colNameList2.add("Source File"); - List colActiveList2 = new ArrayList(); - colActiveList2.add(new Boolean(true)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(true)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(false)); - colActiveList2.add(new Boolean(true)); - new TableColumnManager(selectedTable, columnButton2, colNameList2, colActiveList2, 1); + columnButton2.setText("^"); + new TableColumnManager(selectedTable, columnButton2, selectedModel); + + rightPane.add(buildModSpellPanel(delSpellButton, "InfoSpells.remove.selected"), BorderLayout.SOUTH); } /** @@ -611,22 +523,18 @@ * * @return The panel. */ - private JPanel buildAddSpellPanel() + private JPanel buildModSpellPanel(JButton button, String title) { GridBagConstraints c = new GridBagConstraints(); - - // - JPanel asPanel = new JPanel(new GridBagLayout()); - + JPanel panel = new JPanel(new GridBagLayout()); c = new GridBagConstraints(); Utility.buildConstraints(c, 3, 0, 1, 1, 0.0, 0.0); c.insets = new Insets(2, 2, 2, 2); - Utility.setDescription(addSpellButton, PropertyFactory - .getString("InfoSpells.add.selected")); //$NON-NLS-1$ - addSpellButton.setEnabled(false); - asPanel.add(addSpellButton, c); + Utility.setDescription(button, PropertyFactory.getString(title)); //$NON-NLS-1$ + button.setEnabled(false); + panel.add(button, c); - return asPanel; + return panel; } /** Modified: Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java =================================================================== --- Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java 2006-03-04 01:56:27 UTC (rev 92) +++ Trunk/pcgen/code/src/java/pcgen/gui/tabs/spells/SpellModel.java 2006-03-04 02:03:12 UTC (rev 93) @@ -28,8 +28,18 @@ import javax.swing.tree.TreePath; -import pcgen.core.*; -import pcgen.core.character.*; +import pcgen.TableColumnManagerModel; +import pcgen.core.CharacterDomain; +import pcgen.core.Constants; +import pcgen.core.Domain; +import pcgen.core.Globals; +import pcgen.core.PCClass; +import pcgen.core.PObject; +import pcgen.core.PlayerCharacter; +import pcgen.core.Race; +import pcgen.core.SettingsHandler; +import pcgen.core.character.CharacterSpell; +import pcgen.core.character.SpellInfo; import pcgen.core.spell.Spell; import pcgen.gui.GuiConstants; import pcgen.gui.utils.AbstractTreeTableModel; @@ -49,7 +59,7 @@ * Leafs are like files and non-leafs are like directories. * The leafs contain an Object that we want to know about (Spells) **/ -public final class SpellModel extends AbstractTreeTableModel +public final class SpellModel extends AbstractTreeTableModel implements TableColumnManagerModel { //column positions for tables // if you change these, you also need to change @@ -77,6 +87,7 @@ private String[] colNameList = { "" }; private int[] colTranslateList = { 0 }; + private List displayList; // Types of the columns. private boolean includeRace = false; @@ -111,28 +122,15 @@ if (Spell.hasPPCost()) { - if (available) - { - colTranslateList = new int[]{COL_NAME, COL_SCHOOL, COL_DESCRIPTOR, COL_PPCOST, COL_SRC}; - } - else - { - colTranslateList = new int[]{COL_NAME, COL_SCHOOL, COL_SUBSCHOOL, COL_DESCRIPTOR, COL_PPCOST, COL_COMPONENT, COL_CASTTIME, COL_RANGE, COL_DESCRIPTION, COL_TARGET, COL_DURATION, COL_SAVE, COL_SR, COL_SRC}; - } + colTranslateList = new int[]{COL_NAME, COL_SCHOOL, COL_SUBSCHOOL, COL_DESCRIPTOR, COL_PPCOST, COL_COMPONENT, COL_CASTTIME, COL_RANGE, COL_DESCRIPTION, COL_TARGET, COL_DURATION, COL_SAVE, COL_SR, COL_SRC}; } else { - if (available) - { - colTranslateList = new int[]{COL_NAME, COL_SCHOOL, COL_DESCRIPTOR, COL_SRC }; - } - else - { - colTranslateList = new int[]{COL_NAME, COL_SCHOOL, COL_SUBSCHOOL, COL_DESCRIPTOR, COL_COMPONENT, COL_CASTTIME, COL_RANGE, COL_DESCRIPTION, COL_TARGET, COL_DURATION, COL_SAVE, COL_SR, COL_SRC}; - } + colTranslateList = new int[]{COL_NAME, COL_SCHOOL, COL_SUBSCHOOL, COL_DESCRIPTOR, COL_COMPONENT, COL_CASTTIME, COL_RANGE, COL_DESCRIPTION, COL_TARGET, COL_DURATION, COL_SAVE, COL_SR, COL_SRC}; } colNameList = makeHeaderList(colTranslateList); + displayList = makeDisplayList(available); resetModel(primaryMode, secondaryMode, available, bookList, currSpellBook, fullSpellList, spellTab, emptyMessage); @@ -217,6 +215,51 @@ return aList; } + private List makeDisplayList(boolean available) + { + List retList = new ArrayList(); + if(available) + { + retList.add(new Boolean(false)); //COL_SCHOOL + retList.add(new Boolean(false)); //COL_SUBSCHOOL + retList.add(new Boolean(false)); //COL_DESCRIPTOR + if (Spell.hasPPCost()) + { + retList.add(new Boolean(true)); //COL_PPCOST + } + retList.add(new Boolean(false)); //COL_COMPONENT + retList.add(new Boolean(false)); //COL_CASTTIME + retList.add(new Boolean(false)); //COL_RANGE + retList.add(new Boolean(false)); //COL_DESCRIPTION + retList.add(new Boolean(false)); //COL_TARGET + retList.add(new Boolean(false)); //COL_DURATION + retList.add(new Boolean(false)); //COL_SAVE + retList.add(new Boolean(false)); //COL_SR + retList.add(new Boolean(false)); //COL_SRC + } + else + { + retList.add(new Boolean(true)); //COL_SCHOOL + retList.add(new Boolean(true)); //COL_SUBSCHOOL + retList.add(new Boolean(true)); //COL_DESCRIPTOR + if (Spell.hasPPCost()) + { + retList.add(new Boolean(true)); //COL_PPCOST + } + retList.add(new Boolean(false)); //COL_COMPONENT + retList.add(new Boolean(false)); //COL_CASTTIME + retList.add(new Boolean(false)); //COL_RANGE + retList.add(new Boolean(false)); //COL_DESCRIPTION + retList.add(new Boolean(false)); //COL_TARGET + retList.add(new Boolean(false)); //COL_DURATION + retList.add(new Boolean(false)); //COL_SAVE + retList.add(new Boolean(false)); //COL_SR + retList.add(new Boolean(true)); //COL_SRC + } + + return retList; + } + /** * Translate a column index into a column id. * @param column The column index @@ -1046,4 +1089,29 @@ this.pc = pc; } + + public List getMColumnList() + { + List retList = new ArrayList(); + for(int i = 1; i < colNameList.length; i++) { + retList.add(colNameList[i]); + } + return retList; + } + + + public boolean isMColumnDisplayed(int col) + { + return ((Boolean)displayList.get(col)).booleanValue(); + } + + public int getMColumnOffset() + { + return 1; + } + + + public void setMColumnDisplayed(int col, boolean disp) { + displayList.set(col, new Boolean(disp)); + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |