Skip to content
Snippets Groups Projects
Commit b0672730 authored by Falilou Thiam's avatar Falilou Thiam
Browse files

- Some code refactoring/cleaning

- Better error management (includes TANGOARCH-576)
parent a7198d9b
Branches
Tags
No related merge requests found
......@@ -208,8 +208,7 @@ public class Bensikin {
LOGGER.debug(msg);
} catch (final Exception e) {
final String msg = Messages.getLogMessage("APPLICATION_WILL_START_LOAD_OPTIONS_KO");
LOGGER.error(msg, e);
treatError(e, splash);
treatError(e, msg, splash);
}
}
......@@ -237,8 +236,8 @@ public class Bensikin {
private static void initResolutionMode() {
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension dim = toolkit.getScreenSize();
System.out.println("Resolution-------------------------------------------------------------");
System.out.println("Resolution: " + dim.width + "*" + dim.height);
// System.out.println("Resolution-------------------------------------------------------------");
// System.out.println("Resolution: " + dim.width + "*" + dim.height);
hires = !(dim.width <= 1024);
}
......
......@@ -54,6 +54,7 @@
package fr.soleil.bensikin.lifecycle;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Locale;
import org.slf4j.Logger;
......@@ -124,10 +125,10 @@ public class DefaultLifeCycleManager implements LifeCycleManager {
} catch (final Exception e) {
throw ArchivingException.toArchivingException(e);
}
// No exception can be raised
// treatError is already done in this method
loadOptions(splash);
// No exception can be raised
// treatError is already done in this method
loadFavorites(splash);
if (hasHistorySave) {
......@@ -193,7 +194,7 @@ public class DefaultLifeCycleManager implements LifeCycleManager {
// } catch (final FileNotFoundException fnfe) {
// final String msg = Messages.getLogMessage("APPLICATION_WILL_START_LOAD_FAVORITES_WARNING");
// LOGGER.warn(msg, fnfe);
} catch (final ArchivingException e) {
} catch (final Exception e) {
final String msg = Messages.getLogMessage("APPLICATION_WILL_START_LOAD_FAVORITES_KO");
Bensikin.treatError(e, msg, splash);
}
......@@ -252,23 +253,25 @@ public class DefaultLifeCycleManager implements LifeCycleManager {
splash.progress(12);
splash.setMessage("loading history...");
final History history = historyManager.loadHistory(historyPath);
if (history != null) {
splash.progress(13);
splash.setMessage("applying history");
History.setHistory(history);
splash.progress(14);
history.setLoadProperties(loadProperties);
}
splash.progress(15);
splash.setMessage("history fully loaded");
final String msg = Messages.getLogMessage("APPLICATION_WILL_START_LOAD_HISTORY_OK");
LOGGER.debug(msg);
// } catch (final FileNotFoundException fnfe) {
// final String msg = Messages.getLogMessage("APPLICATION_WILL_START_LOAD_HISTORY_WARNING");
// splash.progress(15);
// splash.setMessage(msg);
// LOGGER.warn(msg, fnfe);
// return;
} catch (final FileNotFoundException fnfe) {
final String msg = Messages.getLogMessage("APPLICATION_WILL_START_LOAD_HISTORY_WARNING");
splash.progress(15);
splash.setMessage(msg);
LOGGER.warn(msg, fnfe);
Bensikin.treatError(fnfe, msg, splash);
} catch (final Exception e) {
final String msg = Messages.getLogMessage("APPLICATION_WILL_START_LOAD_HISTORY_KO");
splash.progress(15);
......
......@@ -29,6 +29,7 @@
//-======================================================================
package fr.soleil.bensikin.options.manager;
import fr.soleil.archiving.common.api.exception.ArchivingException;
import fr.soleil.bensikin.options.Options;
/**
......@@ -45,8 +46,8 @@ public class DummyOptionsManager implements IOptionsManager {
* bensikin.bensikin.options.manager.IOptionsManager#saveOptions(bensikin
* .bensikin.options.Options, java.lang.String)
*/
public void saveOptions(Options options, String optionsResourceLocation)
throws Exception {
@Override
public void saveOptions(Options options, String optionsResourceLocation) throws ArchivingException {
// TODO Auto-generated method stub
}
......@@ -58,7 +59,8 @@ public class DummyOptionsManager implements IOptionsManager {
* bensikin.bensikin.options.manager.IOptionsManager#loadOptions(java.lang
* .String)
*/
public Options loadOptions(String optionsResourceLocation) throws Exception {
@Override
public Options loadOptions(String optionsResourceLocation) throws ArchivingException {
// TODO Auto-generated method stub
// Options ret = Options.getInstance();
......
......@@ -26,6 +26,7 @@
//-======================================================================
package fr.soleil.bensikin.options.manager;
import fr.soleil.archiving.common.api.exception.ArchivingException;
import fr.soleil.bensikin.options.Options;
/**
......@@ -43,8 +44,7 @@ public interface IOptionsManager {
* The Options save location
* @throws Exception
*/
public void saveOptions(Options options, String optionsResourceLocation)
throws Exception;
public void saveOptions(Options options, String optionsResourceLocation) throws ArchivingException;
/**
* Loads options from the desired location.
......@@ -54,5 +54,5 @@ public interface IOptionsManager {
* @return The loaded Options
* @throws Exception
*/
public Options loadOptions(String optionsResourceLocation) throws Exception;
public Options loadOptions(String optionsResourceLocation) throws ArchivingException;
}
......@@ -70,8 +70,12 @@ public class XMLOptionsManager extends XMLDataManager<Options, Map<String, List<
* .bensikin.options.Options, java.lang.String)
*/
@Override
public void saveOptions(Options options, String optionsResourceLocation) throws Exception {
public void saveOptions(Options options, String optionsResourceLocation) throws ArchivingException {
try {
XMLUtils.save(options.toString(), optionsResourceLocation);
} catch (Exception e) {
throw ArchivingException.toArchivingException(e);
}
}
/*
......@@ -82,7 +86,7 @@ public class XMLOptionsManager extends XMLDataManager<Options, Map<String, List<
* .String)
*/
@Override
public Options loadOptions(String optionsResourceLocation) throws Exception {
public Options loadOptions(String optionsResourceLocation) throws ArchivingException {
Options ret = Options.getInstance();
Map<String, List<Map<String, String>>> optionsHt = loadDataIntoHash(optionsResourceLocation);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment