|
From: <jde...@us...> - 2012-02-28 10:05:22
|
Revision: 16345
http://pcgen.svn.sourceforge.net/pcgen/?rev=16345&view=rev
Author: jdempsey
Date: 2012-02-28 10:05:14 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
Fix bug: Unload Button - Does not seem to do anything. Pressing load, nothing loads.
* Add loaded column.
* Allow add and remove of multiple rows
* il8n work
Issue#: CODE-1316,
Modified Paths:
--------------
Trunk/pcgen/code/src/java/pcgen/gui2/PCGenFrame.java
Trunk/pcgen/code/src/java/pcgen/gui2/sources/AdvancedSourceSelectionPanel.java
Trunk/pcgen/code/src/java/pcgen/gui2/sources/SourceSelectionDialog.java
Trunk/pcgen/code/src/java/pcgen/resources/lang/LanguageBundle.properties
Modified: Trunk/pcgen/code/src/java/pcgen/gui2/PCGenFrame.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui2/PCGenFrame.java 2012-02-28 07:37:23 UTC (rev 16344)
+++ Trunk/pcgen/code/src/java/pcgen/gui2/PCGenFrame.java 2012-02-28 10:05:14 UTC (rev 16345)
@@ -109,6 +109,7 @@
import pcgen.gui2.util.SwingWorker;
import pcgen.gui2.util.table.TableCellUtilities;
import pcgen.io.PCGFile;
+import pcgen.persistence.PersistenceManager;
import pcgen.persistence.SourceFileLoader;
import pcgen.system.CharacterManager;
import pcgen.system.ConfigurationSettings;
@@ -461,6 +462,9 @@
}
}
+ /**
+ * @return A reference to the currently loaded sources.
+ */
public ReferenceFacade<SourceSelectionFacade> getCurrentSourceSelectionRef()
{
return currentSourceSelection;
@@ -485,6 +489,17 @@
}
/**
+ * Unload any currently loaded sources.
+ */
+ public void unloadSources()
+ {
+ currentSourceSelection.setReference(null);
+ Globals.emptyLists();
+ PersistenceManager pManager = PersistenceManager.getInstance();
+ pManager.clear();
+ }
+
+ /**
* Loads a selection of sources into PCGen asynchronously and
* tracks the load progress on the status bar. While sources
* are being loaded any calls to this method are ignored until
Modified: Trunk/pcgen/code/src/java/pcgen/gui2/sources/AdvancedSourceSelectionPanel.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui2/sources/AdvancedSourceSelectionPanel.java 2012-02-28 07:37:23 UTC (rev 16344)
+++ Trunk/pcgen/code/src/java/pcgen/gui2/sources/AdvancedSourceSelectionPanel.java 2012-02-28 10:05:14 UTC (rev 16345)
@@ -45,7 +45,6 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
-import pcgen.core.Globals;
import pcgen.core.facade.CampaignFacade;
import pcgen.core.facade.GameModeFacade;
import pcgen.core.facade.SourceSelectionFacade;
@@ -54,6 +53,7 @@
import pcgen.core.facade.util.DefaultListFacade;
import pcgen.core.facade.util.ListFacade;
import pcgen.core.facade.util.ListFacades;
+import pcgen.gui2.PCGenFrame;
import pcgen.gui2.UIPropertyContext;
import pcgen.gui2.filter.FilterBar;
import pcgen.gui2.filter.FilteredTreeViewTable;
@@ -62,13 +62,14 @@
import pcgen.gui2.tools.Icons;
import pcgen.gui2.tools.InfoPane;
import pcgen.gui2.util.FacadeComboBoxModel;
+import pcgen.gui2.util.table.DynamicTableColumnModel;
+import pcgen.gui2.util.table.TableCellUtilities;
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.TreeViewModel;
import pcgen.gui2.util.treeview.TreeViewPath;
-import pcgen.persistence.PersistenceManager;
import pcgen.system.FacadeFactory;
import pcgen.system.LanguageBundle;
@@ -91,9 +92,11 @@
private final JButton addButton;
private final JButton removeButton;
private DefaultListFacade<CampaignFacade> selectedCampaigns;
+ private final PCGenFrame frame;
- public AdvancedSourceSelectionPanel()
+ public AdvancedSourceSelectionPanel(PCGenFrame frame)
{
+ this.frame = frame;
this.availableTable = new FilteredTreeViewTable();
this.selectedTable = new FilteredTreeViewTable();
this.selectedCampaigns = new DefaultListFacade<CampaignFacade>();
@@ -133,6 +136,11 @@
availableTable.setTreeViewModel(availTreeViewModel);
availableTable.getSelectionModel().addListSelectionListener(this);
availableTable.setTreeCellRenderer(new CampaignRenderer());
+ ((DynamicTableColumnModel) availableTable.getColumnModel())
+ .getAvailableColumns()
+ .get(2)
+ .setCellRenderer(
+ new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
JScrollPane pane = new JScrollPane(availableTable);
pane.setPreferredSize(new Dimension(600, 310));
@@ -159,6 +167,11 @@
selectedTable.setTreeViewModel(selTreeViewModel);
selectedTable.getSelectionModel().addListSelectionListener(this);
selectedTable.setTreeCellRenderer(new CampaignRenderer());
+ ((DynamicTableColumnModel) selectedTable.getColumnModel())
+ .getAvailableColumns()
+ .get(2)
+ .setCellRenderer(
+ new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
JScrollPane scrollPane = new JScrollPane(selectedTable);
scrollPane.setPreferredSize(new Dimension(300,350));
selPanel.add(scrollPane, BorderLayout.CENTER);
@@ -247,6 +260,12 @@
}
}
+ void refreshDisplay()
+ {
+ availableTable.refreshModelData();
+ selectedTable.refreshModelData();
+ }
+
/**
* {@inheritDoc}
*/
@@ -302,15 +321,17 @@
List<CampaignFacade> list = availableTable.getSelectedData();
if (list != null && !list.isEmpty())
{
- CampaignFacade camp = list.get(0);
- selectedCampaigns.addElement(camp);
- if (!FacadeFactory.passesPrereqs(gameMode, selectedCampaigns.getContents()))
+ for (CampaignFacade camp : list)
{
- JOptionPane.showMessageDialog(AdvancedSourceSelectionPanel.this,
- LanguageBundle.getString("in_src_badComboMsg"), //$NON-NLS-1$
- LanguageBundle.getString("in_src_badComboTitle"), //$NON-NLS-1$
- JOptionPane.INFORMATION_MESSAGE);
- selectedCampaigns.removeElement(camp);
+ selectedCampaigns.addElement(camp);
+ if (!FacadeFactory.passesPrereqs(gameMode, selectedCampaigns.getContents()))
+ {
+ JOptionPane.showMessageDialog(AdvancedSourceSelectionPanel.this,
+ LanguageBundle.getString("in_src_badComboMsg"), //$NON-NLS-1$
+ LanguageBundle.getString("in_src_badComboTitle"), //$NON-NLS-1$
+ JOptionPane.INFORMATION_MESSAGE);
+ selectedCampaigns.removeElement(camp);
+ }
}
}
}
@@ -331,8 +352,10 @@
List<CampaignFacade> list = selectedTable.getSelectedData();
if (list != null && !list.isEmpty())
{
- CampaignFacade camp = list.get(0);
- selectedCampaigns.removeElement(camp);
+ for (CampaignFacade camp : list)
+ {
+ selectedCampaigns.removeElement(camp);
+ }
}
}
}
@@ -347,17 +370,17 @@
public void actionPerformed(ActionEvent e)
{
- Globals.emptyLists();
- PersistenceManager pManager = PersistenceManager.getInstance();
- pManager.clear();
+ frame.unloadSources();
+ availableTable.refreshModelData();
+ selectedTable.refreshModelData();
}
}
- private static class SourceTreeViewModel
+ private class SourceTreeViewModel
implements TreeViewModel<CampaignFacade>, DataView<CampaignFacade>, ListListener<CampaignFacade>
{
- private static ListFacade<TreeView<CampaignFacade>> views =
+ private ListFacade<TreeView<CampaignFacade>> views =
new DefaultListFacade<TreeView<CampaignFacade>>(Arrays.asList(SourceTreeView.values()));
private DefaultListFacade<CampaignFacade> model;
private ListFacade<CampaignFacade> baseModel = null;
@@ -370,7 +393,8 @@
this.isAvailModel = true;
columns =
Arrays.asList(new DefaultDataViewColumn("in_src_bookType", String.class, true),
- new DefaultDataViewColumn("in_src_status", String.class, true));
+ new DefaultDataViewColumn("in_src_status", String.class, true),
+ new DefaultDataViewColumn("in_src_loaded", String.class, false));
}
public SourceTreeViewModel( DefaultListFacade<CampaignFacade> model)
@@ -379,7 +403,8 @@
this.isAvailModel = false;
columns =
Arrays.asList(new DefaultDataViewColumn("in_src_bookType", String.class, false),
- new DefaultDataViewColumn("in_src_status", String.class, false));
+ new DefaultDataViewColumn("in_src_status", String.class, false),
+ new DefaultDataViewColumn("in_src_loaded", String.class, false));
}
public ListFacade<? extends TreeView<CampaignFacade>> getTreeViews()
@@ -404,7 +429,16 @@
public List<?> getData(CampaignFacade obj)
{
- return Arrays.asList(obj.getBookType(), obj.getStatus());
+ SourceSelectionFacade sourceFacade =
+ frame.getCurrentSourceSelectionRef().getReference();
+ boolean isLoaded =
+ sourceFacade != null
+ && sourceFacade.getCampaigns().containsElement(obj);
+ return Arrays.asList(
+ obj.getBookType(),
+ obj.getStatus(),
+ isLoaded ? LanguageBundle.getString("in_yes") : LanguageBundle
+ .getString("in_no"));
}
public List<? extends DataViewColumn> getDataColumns()
@@ -438,67 +472,70 @@
model.setContents(ListFacades.wrap(baseModel));
}
- private static enum SourceTreeView implements
- TreeView<CampaignFacade>
+ }
+
+ private static enum SourceTreeView implements TreeView<CampaignFacade>
+ {
+
+ NAME("in_nameLabel"), //$NON-NLS-1$
+ PUBLISHER_NAME("in_src_pubName"), //$NON-NLS-1$
+ PUBLISHER_SETTING_NAME("in_src_pubSetName"), //$NON-NLS-1$
+ PUBLISHER_FORMAT_SETTING_NAME("in_src_pubFmtSetName"); //$NON-NLS-1$
+ private String name;
+
+ private SourceTreeView(String name)
{
-
- NAME("in_nameLabel"), //$NON-NLS-1$
- PUBLISHER_NAME("in_src_pubName"), //$NON-NLS-1$
- PUBLISHER_SETTING_NAME("in_src_pubSetName"), //$NON-NLS-1$
- PUBLISHER_FORMAT_SETTING_NAME("in_src_pubFmtSetName"); //$NON-NLS-1$
- private String name;
-
- private SourceTreeView(String name)
+ this.name = LanguageBundle.getString(name);
+ }
+
+ public String getViewName()
+ {
+ return name;
+ }
+
+ public List<TreeViewPath<CampaignFacade>> getPaths(CampaignFacade pobj)
+ {
+ String publisher = pobj.getPublisher();
+ if (publisher == null)
{
- this.name = LanguageBundle.getString(name);
+ publisher = LanguageBundle.getString("in_other"); //$NON-NLS-1$
}
-
- public String getViewName()
+ String setting = pobj.getSetting();
+ String format = pobj.getFormat();
+ switch (this)
{
- return name;
+ case NAME:
+ return Collections
+ .singletonList(new TreeViewPath<CampaignFacade>(pobj));
+ case PUBLISHER_FORMAT_SETTING_NAME:
+ if (format != null && setting != null)
+ {
+ return Collections
+ .singletonList(new TreeViewPath<CampaignFacade>(
+ pobj, publisher, format, setting));
+ }
+ if (format != null)
+ {
+ return Collections
+ .singletonList(new TreeViewPath<CampaignFacade>(
+ pobj, publisher, format));
+ }
+ case PUBLISHER_SETTING_NAME:
+ if (setting != null)
+ {
+ return Collections
+ .singletonList(new TreeViewPath<CampaignFacade>(
+ pobj, publisher, setting));
+ }
+ case PUBLISHER_NAME:
+ return Collections
+ .singletonList(new TreeViewPath<CampaignFacade>(pobj,
+ publisher));
+ default:
+ throw new InternalError();
}
-
- public List<TreeViewPath<CampaignFacade>> getPaths(CampaignFacade pobj)
- {
- String publisher = pobj.getPublisher();
- if (publisher == null)
- {
- publisher = LanguageBundle.getString("in_other"); //$NON-NLS-1$
- }
- String setting = pobj.getSetting();
- String format = pobj.getFormat();
- switch (this)
- {
- case NAME:
- return Collections.singletonList(new TreeViewPath<CampaignFacade>(
- pobj));
- case PUBLISHER_FORMAT_SETTING_NAME:
- if (format != null && setting != null)
- {
- return Collections.singletonList(new TreeViewPath<CampaignFacade>(
- pobj, publisher, format, setting));
- }
- if (format != null)
- {
- return Collections.singletonList(new TreeViewPath<CampaignFacade>(
- pobj, publisher, format));
- }
- case PUBLISHER_SETTING_NAME:
- if (setting != null)
- {
- return Collections.singletonList(new TreeViewPath<CampaignFacade>(
- pobj, publisher, setting));
- }
- case PUBLISHER_NAME:
- return Collections.singletonList(new TreeViewPath<CampaignFacade>(
- pobj, publisher));
- default:
- throw new InternalError();
- }
- }
-
}
-
+
}
/**
Modified: Trunk/pcgen/code/src/java/pcgen/gui2/sources/SourceSelectionDialog.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui2/sources/SourceSelectionDialog.java 2012-02-28 07:37:23 UTC (rev 16344)
+++ Trunk/pcgen/code/src/java/pcgen/gui2/sources/SourceSelectionDialog.java 2012-02-28 10:05:14 UTC (rev 16345)
@@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
@@ -54,12 +55,13 @@
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+
import pcgen.core.facade.CampaignFacade;
import pcgen.core.facade.GameModeFacade;
import pcgen.core.facade.LoadableFacade.LoadingState;
+import pcgen.core.facade.SourceSelectionFacade;
import pcgen.core.facade.util.ListFacade;
import pcgen.core.facade.util.ListFacades;
-import pcgen.core.facade.SourceSelectionFacade;
import pcgen.gui.DataInstaller;
import pcgen.gui2.PCGenFrame;
import pcgen.gui2.UIPropertyContext;
@@ -79,14 +81,14 @@
implements ActionListener, ChangeListener, ListSelectionListener
{
- private static final UIPropertyContext context = UIPropertyContext.createContext("SourceSelectionDialog");
- private static final String PROP_SELECTED_SOURCE = "selectedSource";
- private static final String LOAD_COMMAND = "Load";
- private static final String CANCEL_COMMAND = "Cancel";
- private static final String SAVE_COMMAND = "Save";
- private static final String DELETE_COMMAND = "Delete";
- private static final String HIDEUNHIDE_COMMAND = "Hide";
- private static final String INSTALLDATA_COMMAND = "Install";
+ private static final UIPropertyContext context = UIPropertyContext.createContext("SourceSelectionDialog"); //$NON-NLS-1$
+ private static final String PROP_SELECTED_SOURCE = "selectedSource"; //$NON-NLS-1$
+ private static final String LOAD_COMMAND = "Load"; //$NON-NLS-1$
+ private static final String CANCEL_COMMAND = "Cancel"; //$NON-NLS-1$
+ private static final String SAVE_COMMAND = "Save"; //$NON-NLS-1$
+ private static final String DELETE_COMMAND = "Delete"; //$NON-NLS-1$
+ private static final String HIDEUNHIDE_COMMAND = "Hide"; //$NON-NLS-1$
+ private static final String INSTALLDATA_COMMAND = "Install"; //$NON-NLS-1$
private final PCGenFrame frame;
private QuickSourceSelectionPanel basicPanel;
private AdvancedSourceSelectionPanel advancedPanel;
@@ -106,7 +108,7 @@
setTitle(LanguageBundle.getString("in_mnuSourcesLoadSelect")); //$NON-NLS-1$
this.tabs = new JTabbedPane();
this.basicPanel = new QuickSourceSelectionPanel();
- this.advancedPanel = new AdvancedSourceSelectionPanel();
+ this.advancedPanel = new AdvancedSourceSelectionPanel(frame);
this.buttonPanel = new JPanel();
this.loadButton = new JButton(LanguageBundle.getString("in_load")); //$NON-NLS-1$
this.cancelButton = new JButton(LanguageBundle.getString("in_cancel")); //$NON-NLS-1$
@@ -125,8 +127,8 @@
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
- tabs.add("Basic", basicPanel);
- tabs.add("Advanced", advancedPanel);
+ tabs.add(LanguageBundle.getString("in_basic"), basicPanel); //$NON-NLS-1$
+ tabs.add(LanguageBundle.getString("in_advanced"), advancedPanel); //$NON-NLS-1$
tabs.addChangeListener(this);
pane.add(tabs, BorderLayout.CENTER);
@@ -355,6 +357,19 @@
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setVisible(boolean visible)
+ {
+ if (visible)
+ {
+ advancedPanel.refreshDisplay();
+ }
+ super.setVisible(visible);
+ }
+
private static class SourcesTableModel extends FilteredListFacadeTableModel<SourceSelectionFacade>
{
Modified: Trunk/pcgen/code/src/java/pcgen/resources/lang/LanguageBundle.properties
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/resources/lang/LanguageBundle.properties 2012-02-28 07:37:23 UTC (rev 16344)
+++ Trunk/pcgen/code/src/java/pcgen/resources/lang/LanguageBundle.properties 2012-02-28 10:05:14 UTC (rev 16345)
@@ -4417,6 +4417,7 @@
in_src_bookType=Book Type
in_src_status=Status
+in_src_loaded=Loaded
in_src_info=Campaign Info
in_src_pubName=Publisher/Name
@@ -4466,6 +4467,7 @@
in_hideunhide=Hide/Unhide
in_saveSelection=Save Source Selection
+in_basic=Basic
in_advanced=Advanced
in_source_gamemode={0} Mode
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|