Search in sources :

Example 1 with LoadConfigReport

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();
    }
}
Also used : LoadConfigReport(com.glitchcog.fontificator.config.loadreport.LoadConfigReport) IOException(java.io.IOException)

Example 2 with LoadConfigReport

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);
    }
}
Also used : LoadConfigReport(com.glitchcog.fontificator.config.loadreport.LoadConfigReport) IOException(java.io.IOException)

Example 3 with LoadConfigReport

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;
}
Also used : LoadConfigReport(com.glitchcog.fontificator.config.loadreport.LoadConfigReport)

Example 4 with LoadConfigReport

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);
            }
        }
    }
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) LoadConfigReport(com.glitchcog.fontificator.config.loadreport.LoadConfigReport)

Example 5 with LoadConfigReport

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;
}
Also used : LoadConfigReport(com.glitchcog.fontificator.config.loadreport.LoadConfigReport)

Aggregations

LoadConfigReport (com.glitchcog.fontificator.config.loadreport.LoadConfigReport)16 IOException (java.io.IOException)4 LabeledInput (com.glitchcog.fontificator.gui.component.LabeledInput)3 GridBagLayout (java.awt.GridBagLayout)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 JButton (javax.swing.JButton)3 JCheckBox (javax.swing.JCheckBox)3 JPanel (javax.swing.JPanel)3 TitledBorder (javax.swing.border.TitledBorder)3 LabeledSlider (com.glitchcog.fontificator.gui.component.LabeledSlider)2 GridBagConstraints (java.awt.GridBagConstraints)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ChangeEvent (javax.swing.event.ChangeEvent)2 ChangeListener (javax.swing.event.ChangeListener)2 DocumentEvent (javax.swing.event.DocumentEvent)2 DocumentListener (javax.swing.event.DocumentListener)2 MessageCasing (com.glitchcog.fontificator.config.MessageCasing)1