loading user settings before generating executable jar, added debugging output

This commit is contained in:
fros4943 2010-03-19 11:32:59 +00:00
parent c5c6c3b775
commit aa41f9218a
2 changed files with 13 additions and 12 deletions

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: GUI.java,v 1.164 2010/03/15 11:04:37 fros4943 Exp $ * $Id: GUI.java,v 1.165 2010/03/19 11:32:59 fros4943 Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -2734,8 +2734,6 @@ public class GUI extends Observable {
filename = GUI.EXTERNAL_TOOLS_LINUX_SETTINGS_FILENAME; filename = GUI.EXTERNAL_TOOLS_LINUX_SETTINGS_FILENAME;
} }
logger.info("Loading external tools user settings from: " + filename);
try { try {
InputStream in = GUI.class.getResourceAsStream(filename); InputStream in = GUI.class.getResourceAsStream(filename);
if (in == null) { if (in == null) {
@ -2747,10 +2745,9 @@ public class GUI extends Observable {
currentExternalToolsSettings = settings; currentExternalToolsSettings = settings;
defaultExternalToolsSettings = (Properties) currentExternalToolsSettings.clone(); defaultExternalToolsSettings = (Properties) currentExternalToolsSettings.clone();
logger.info("External tools default settings: " + filename);
} catch (IOException e) { } catch (IOException e) {
// Error while importing default properties logger.warn("Error when reading external tools settings from " + filename, e);
logger.warn(
"Error when reading external tools settings from " + filename, e);
} finally { } finally {
if (currentExternalToolsSettings == null) { if (currentExternalToolsSettings == null) {
defaultExternalToolsSettings = new Properties(); defaultExternalToolsSettings = new Properties();
@ -2773,17 +2770,16 @@ public class GUI extends Observable {
settings.load(in); settings.load(in);
in.close(); in.close();
Enumeration en = settings.keys(); Enumeration<Object> en = settings.keys();
while (en.hasMoreElements()) { while (en.hasMoreElements()) {
String key = (String) en.nextElement(); String key = (String) en.nextElement();
setExternalToolsSetting(key, settings.getProperty(key)); setExternalToolsSetting(key, settings.getProperty(key));
} }
logger.info("External tools user settings: " + externalToolsUserSettingsFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// No default configuration file found, using default logger.warn("Error when reading user settings from: " + externalToolsUserSettingsFile);
} catch (IOException e) { } catch (IOException e) {
// Error while importing saved properties, using default logger.warn("Error when reading user settings from: " + externalToolsUserSettingsFile);
logger.warn("Error when reading default settings from " + externalToolsUserSettingsFile);
} }
} }

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: ExecuteJAR.java,v 1.7 2010/03/19 09:08:38 fros4943 Exp $ * $Id: ExecuteJAR.java,v 1.8 2010/03/19 11:32:59 fros4943 Exp $
*/ */
package se.sics.cooja.util; package se.sics.cooja.util;
@ -97,6 +97,9 @@ public class ExecuteJAR {
/* Load simulation */ /* Load simulation */
logger.info("Loading " + config); logger.info("Loading " + config);
GUI.externalToolsUserSettingsFile = new File(
System.getProperty("user.home"),
GUI.EXTERNAL_TOOLS_USER_SETTINGS_FILENAME);
Simulation s = GUI.quickStartSimulationConfig(config, false); Simulation s = GUI.quickStartSimulationConfig(config, false);
if (s == null) { if (s == null) {
throw new RuntimeException( throw new RuntimeException(
@ -108,6 +111,8 @@ public class ExecuteJAR {
try { try {
buildExecutableJAR(s.getGUI(), jar); buildExecutableJAR(s.getGUI(), jar);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.fatal(e.getMessage());
System.exit(1);
} }
System.exit(0); System.exit(0);
} }