|
From: <jde...@us...> - 2010-06-30 03:26:06
|
Revision: 12383
http://pcgen.svn.sourceforge.net/pcgen/?rev=12383&view=rev
Author: jdempsey
Date: 2010-06-30 03:26:00 +0000 (Wed, 30 Jun 2010)
Log Message:
-----------
Source Editor: Errors in console on save
Issue#: CODE-146
Modified Paths:
--------------
Trunk/pcgen/code/src/java/pcgen/core/Globals.java
Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java
Trunk/pcgen/code/src/java/pcgen/gui/editor/SourceBasePanel.java
Modified: Trunk/pcgen/code/src/java/pcgen/core/Globals.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2010-06-30 02:53:14 UTC (rev 12382)
+++ Trunk/pcgen/code/src/java/pcgen/core/Globals.java 2010-06-30 03:26:00 UTC (rev 12383)
@@ -323,6 +323,23 @@
*/
public static Campaign getCampaignKeyed(final String aKey)
{
+
+ Campaign campaign = getCampaignKeyedSilently(aKey);
+ if (campaign == null)
+ {
+ Logging.errorPrint("Could not find campaign: " + aKey);
+ }
+
+ return campaign;
+ }
+
+ /**
+ * Get campaign by key
+ * @param aKey
+ * @return Campaign
+ */
+ public static Campaign getCampaignKeyedSilently(final String aKey)
+ {
for ( Campaign campaign : getCampaignList() )
{
if (campaign.getKeyName().equalsIgnoreCase(aKey))
@@ -331,8 +348,6 @@
}
}
- Logging.errorPrint("Could not find campaign: " + aKey);
-
return null;
}
@@ -2720,6 +2735,9 @@
return SettingsHandler.getGame().getContext();
}
+ /**
+ * @return The class instance controlling the association lists for the current game mode.
+ */
public static MasterListInterface getMasterLists()
{
return SettingsHandler.getGame().getMasterLists();
Modified: Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java 2010-06-30 02:53:14 UTC (rev 12382)
+++ Trunk/pcgen/code/src/java/pcgen/gui/LstEditorMain.java 2010-06-30 03:26:00 UTC (rev 12383)
@@ -396,7 +396,7 @@
return Globals.getContext().ref.silentlyGetConstructedCDOMObject(PCTemplate.class, aName);
case EditorConstants.EDIT_CAMPAIGN:
- return Globals.getCampaignKeyed(aName);
+ return Globals.getCampaignKeyedSilently(aName);
default:
break;
Modified: Trunk/pcgen/code/src/java/pcgen/gui/editor/SourceBasePanel.java
===================================================================
--- Trunk/pcgen/code/src/java/pcgen/gui/editor/SourceBasePanel.java 2010-06-30 02:53:14 UTC (rev 12382)
+++ Trunk/pcgen/code/src/java/pcgen/gui/editor/SourceBasePanel.java 2010-06-30 03:26:00 UTC (rev 12383)
@@ -133,20 +133,20 @@
{
theCampaign.addToListFor(ListKey.GAME_MODE, "Sidewinder");
}
- theCampaign.put(StringKey.SOURCE_LONG, pubNameLong.getText().trim());
- theCampaign.put(StringKey.SOURCE_SHORT, pubNameShort.getText().trim());
- theCampaign.put(StringKey.SOURCE_WEB, pubNameWeb.getText().trim());
+ setStringValue(StringKey.SOURCE_LONG, pubNameLong.getText());
+ setStringValue(StringKey.SOURCE_SHORT, pubNameShort.getText());
+ setStringValue(StringKey.SOURCE_WEB, pubNameWeb.getText());
theCampaign.put(ObjectKey.IS_OGL, isOGL.getSelectedObjects() != null);
theCampaign.put(ObjectKey.IS_D20, isD20.getSelectedObjects() != null);
theCampaign.put(ObjectKey.SHOW_IN_MENU, showInMenu.getSelectedObjects() != null);
theCampaign.put(ObjectKey.IS_LICENSED, isLicensed.getSelectedObjects() != null);
- theCampaign.put(StringKey.INFO_TEXT, infoText.getText().trim());
- theCampaign.put(StringKey.BOOK_TYPE, bookType.getSelectedItem().toString());
+ setStringValue(StringKey.INFO_TEXT, infoText.getText());
+ setStringValue(StringKey.BOOK_TYPE, bookType.getSelectedItem().toString());
theCampaign.put(StringKey.DESTINATION, destination.getText().trim());
theCampaign.removeListFor(ListKey.LICENSE);
theCampaign.removeListFor(ListKey.SECTION_15);
- theCampaign.put(StringKey.SETTING, setting.getText().trim());
- theCampaign.put(StringKey.GENRE, genre.getText().trim());
+ setStringValue(StringKey.SETTING, setting.getText());
+ setStringValue(StringKey.GENRE, genre.getText());
for (int i = 0; i < sourceModel.getOptionList().size(); i++)
{
@@ -166,6 +166,26 @@
}
}
+ /**
+ * Set a string value for the current campaign. Will remove the value if
+ * the value is null or empty.
+ *
+ * @param stringKey The StringKey to be updated
+ * @param value The new value.
+ *
+ */
+ private void setStringValue(StringKey stringKey, String value)
+ {
+ if (value == null || value.trim().length()==0)
+ {
+ theCampaign.remove(stringKey);
+ }
+ else
+ {
+ theCampaign.put(StringKey.SETTING, value.trim());
+ }
+ }
+
public void updateView(PObject thisPObject)
{
if (!(thisPObject instanceof Campaign))
@@ -233,6 +253,11 @@
{
a = a.substring(b.length() + 1);
}
+ else if (a.substring(1).startsWith(b))
+ {
+ // The / after file:/ can remain here, so account for it.
+ a = a.substring(b.length() + 2);
+ }
destination.setText(a);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|