use of com.glitchcog.fontificator.config.loadreport.LoadConfigReport in project ChatGameFontificator by GlitchCog.
the class ControlWindow method loadPreset.
private void loadPreset(String presetName, String presetFilename) {
boolean okayToProceed = fProps.checkForUnsavedProps(this, this);
if (okayToProceed) {
try {
LoadConfigReport report = fProps.loadFile(presetFilename);
if (report.isProblem()) {
logger.error("Unsuccessful call to FontificatorProperties.loadFile(String)");
throw new Exception();
}
} catch (Exception ex) {
logger.error(ex.toString(), ex);
ChatWindow.popup.handleProblem("Unable to load preset " + presetName + " (" + presetFilename + ")");
}
controlTabs.refreshUiFromConfig(fProps);
chatWindow.getChatPanel().repaint();
}
}
use of com.glitchcog.fontificator.config.loadreport.LoadConfigReport in project ChatGameFontificator by GlitchCog.
the class ControlWindow method loadLastData.
public void loadLastData(ChatWindow chatWindow) {
this.chatWindow = chatWindow;
ChatWindow.setupHideOnEscape(this);
LoadConfigReport report = new LoadConfigReport();
fProps.clear();
try {
report = fProps.loadLast();
} catch (Exception e) {
final String errorMsg = "Unknown error loading last config file";
logger.error(errorMsg, e);
report.addError(errorMsg, LoadConfigErrorType.UNKNOWN_ERROR);
}
if (!report.isErrorFree()) {
final boolean overwriteExistingValues = report.isProblem();
if (overwriteExistingValues) {
fProps.forgetLastConfigFile();
}
fProps.loadDefaultValues(overwriteExistingValues);
}
}
use of com.glitchcog.fontificator.config.loadreport.LoadConfigReport in project ChatGameFontificator by GlitchCog.
the class FontificatorProperties method loadFile.
/**
* Load file from InputStream. Does not close InputStream
*
* @param is
* @param filename
* @param isPreset
* @return report
* @throws Exception
*/
private LoadConfigReport loadFile(InputStream is, String filename, boolean isPreset) throws Exception {
final String prevAuth = getProperty(KEY_IRC_AUTH);
super.load(is);
final String currAuth = getProperty(KEY_IRC_AUTH);
// wasn't loaded and there's no need to decrypt.
if (prevAuth == null || !prevAuth.equals(currAuth)) {
decryptProperty(KEY_IRC_AUTH);
}
LoadConfigReport report = loadConfigs(!isPreset);
if (report.isErrorFree() && !isPreset) {
rememberLastConfigFile(filename);
}
return report;
}
use of com.glitchcog.fontificator.config.loadreport.LoadConfigReport in project ChatGameFontificator by GlitchCog.
the class FontificatorProperties method loadLast.
/**
* Try to load the configuration file stored i the last config file location conf file.
*
* @return report
* @throws Exception
*/
public LoadConfigReport loadLast() throws Exception {
logger.trace("Load last");
final String previousConfigNotFound = "Previous configuration not found.";
final String previousConfigError = "Error loading previous configuration.";
BufferedReader reader = null;
try {
File lastFile = new File(CONFIG_FILE_LAST_LOCATION);
if (!lastFile.exists()) {
LoadConfigReport errorReport = new LoadConfigReport();
errorReport.addError(previousConfigNotFound, LoadConfigErrorType.FILE_NOT_FOUND);
return errorReport;
}
reader = new BufferedReader(new FileReader(lastFile));
final String lastConfigFilename = reader.readLine();
reader.close();
LoadConfigReport report = loadFile(lastConfigFilename);
if (report.isProblem()) {
report.setMainMessage(previousConfigError);
}
return report;
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {
logger.error(e.toString(), e);
}
}
}
}
use of com.glitchcog.fontificator.config.loadreport.LoadConfigReport in project ChatGameFontificator by GlitchCog.
the class ControlPanelMessage method validateInput.
@Override
protected LoadConfigReport validateInput() {
LoadConfigReport report = new LoadConfigReport();
config.validateStrings(report, timeFormatInput.getText(), Integer.toString(queueSizeSlider.getValue()), Integer.toString(messageSpeedSlider.getValue()), Integer.toString(expirationTimeSlider.getValue()));
return report;
}
Aggregations