Search in sources :

Example 1 with IniConfigSection

use of net.parostroj.timetable.gui.ini.IniConfigSection in project grafikon by jub77.

the class TrainViewColumns method saveToPreferences.

@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
    IniConfigSection section = getTrainsSection(prefs);
    // get displayed columns and save theirs order
    prefs.removeSection(CURRENT_COLUMNS_KEY);
    String order = createColumnConfiguration();
    if (order != null) {
        section.put(CURRENT_COLUMNS_KEY, order);
    }
    // stored columns
    section.remove(STORED_COLUMNS_KEY);
    columnConfigurations.forEach((key, config) -> section.add(STORED_COLUMNS_KEY, key + DELIMITER + config));
    return section;
}
Also used : IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Example 2 with IniConfigSection

use of net.parostroj.timetable.gui.ini.IniConfigSection in project grafikon by jub77.

the class FreightNetPane2 method loadFromPreferences.

@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
    IniConfigSection section = prefs.getSection("freigh.net");
    GTViewSettings gtvs = null;
    try {
        gtvs = GTViewSettings.parseStorageString(section.get("gtv"));
    } catch (Exception e) {
        // use default values
        log.warn("Wrong GTView settings - using default values.");
    }
    if (gtvs != null) {
        graphicalTimetableView.setSettings(graphicalTimetableView.getSettings().merge(gtvs));
    }
    return section;
}
Also used : GTViewSettings(net.parostroj.timetable.gui.components.GTViewSettings) IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Example 3 with IniConfigSection

use of net.parostroj.timetable.gui.ini.IniConfigSection in project grafikon by jub77.

the class TrainsCyclesPane method saveToPreferences.

@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
    IniConfigSection section = prefs.getSection(getKey());
    section.put("divider", splitPane.getDividerLocation());
    section.put("gtv", graphicalTimetableView.getSettings().getStorageString());
    return section;
}
Also used : IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Example 4 with IniConfigSection

use of net.parostroj.timetable.gui.ini.IniConfigSection in project grafikon by jub77.

the class TrainsPane method loadFromPreferences.

@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
    IniConfigSection section = prefs.getSection("trains");
    int dividerLoc = section.get("divider", Integer.class, splitPane.getDividerLocation());
    int div = section.get("divider.2", Integer.class, trainsSplitPane.getDividerLocation());
    int preferredWidth = trainListView.getPreferredSize().width;
    if (preferredWidth < div) {
        trainsSplitPane.setDividerLocation(div);
    }
    GTViewSettings gtvs = null;
    try {
        gtvs = GTViewSettings.parseStorageString(section.get("gtv"));
    } catch (Exception e) {
        // use default values
        log.warn("Wrong GTView settings - using default values.");
    }
    if (gtvs != null) {
        graphicalTimetableView.setSettings(graphicalTimetableView.getSettings().merge(gtvs));
    }
    scrollPane.setVisible(section.get("show.gtview", Boolean.class, true));
    if (scrollPane.isVisible()) {
        splitPane.setDividerLocation(dividerLoc);
    } else {
        splitPane.setLastDividerLocation(dividerLoc);
    }
    String treeType = section.get("listtype", "TYPES");
    TreeType treeTypeEnum = TreeType.TYPES;
    try {
        treeTypeEnum = TreeType.valueOf(treeType);
    } catch (IllegalArgumentException e) {
    // ignore unknown value
    }
    trainListView.setTreeType(treeTypeEnum);
    trainView.loadFromPreferences(prefs);
    return section;
}
Also used : TreeType(net.parostroj.timetable.gui.views.TrainListView.TreeType) GTViewSettings(net.parostroj.timetable.gui.components.GTViewSettings) IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Example 5 with IniConfigSection

use of net.parostroj.timetable.gui.ini.IniConfigSection in project grafikon by jub77.

the class TrainsPane method saveToPreferences.

@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
    IniConfigSection section = prefs.getSection("trains");
    section.put("divider", scrollPane.isVisible() ? splitPane.getDividerLocation() : splitPane.getLastDividerLocation());
    section.put("divider.2", trainsSplitPane.getDividerLocation());
    // save if the gtview in trains pane is visible
    section.put("show.gtview", scrollPane.isVisible());
    section.put("gtv", graphicalTimetableView.getSettings().getStorageString());
    section.put("listtype", trainListView.getTreeType().name());
    trainView.saveToPreferences(prefs);
    return section;
}
Also used : IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Aggregations

IniConfigSection (net.parostroj.timetable.gui.ini.IniConfigSection)24 IniConfig (net.parostroj.timetable.gui.ini.IniConfig)4 File (java.io.File)3 GTViewSettings (net.parostroj.timetable.gui.components.GTViewSettings)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1 ScriptAction (net.parostroj.timetable.actions.scripts.ScriptAction)1 NormalHTS (net.parostroj.timetable.gui.utils.NormalHTS)1 DriverCycleDelegate (net.parostroj.timetable.gui.views.DriverCycleDelegate)1 EngineCycleDelegate (net.parostroj.timetable.gui.views.EngineCycleDelegate)1 TreeType (net.parostroj.timetable.gui.views.TrainListView.TreeType)1 TrainUnitCycleDelegate (net.parostroj.timetable.gui.views.TrainUnitCycleDelegate)1 AbstractColleague (net.parostroj.timetable.mediator.AbstractColleague)1 LengthUnit (net.parostroj.timetable.model.units.LengthUnit)1 SpeedUnit (net.parostroj.timetable.model.units.SpeedUnit)1