Search in sources :

Example 11 with IniConfigSection

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

the class FloatingFrame method loadFromPreferences.

@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
    IniConfigSection section = prefs.getSection(storageKeyPrefix);
    String positionStr = section.get("position");
    if (positionStr != null) {
        // set position
        GuiUtils.setPosition(positionStr, this);
    }
    if (section.get("maximized", Boolean.class, false)) {
        // setting maximized state
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
    }
    // set visibility
    if (section.get("visible", Boolean.class, false)) {
        this.visibleOnInit = true;
    }
    return section;
}
Also used : IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Example 12 with IniConfigSection

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

the class FileChooserFactory method loadFromPreferences.

@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
    IniConfigSection section = prefs.getSection("main");
    Set<String> keys = new HashSet<>();
    for (Type type : Type.values()) {
        keys.add(type.getKey());
    }
    for (String key : keys) {
        String value = section.get(key);
        if (value != null) {
            locations.put(key, new File(value));
        }
    }
    return section;
}
Also used : IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection) File(java.io.File) HashSet(java.util.HashSet)

Example 13 with IniConfigSection

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

the class TrainViewColumns method loadFromPreferences.

@Override
public IniConfigSection loadFromPreferences(IniConfig prefs) {
    IniConfigSection section = getTrainsSection(prefs);
    // set displayed columns (if the prefs are empty - show all)
    String cs = section.get(CURRENT_COLUMNS_KEY);
    cs = ObjectsUtil.checkAndTrim(cs);
    applyColumnConfiguration(cs);
    List<String> keysWithConfig = section.getAll(STORED_COLUMNS_KEY);
    if (keysWithConfig != null) {
        keysWithConfig.forEach(keyWithConfig -> {
            String[] items = keyWithConfig.split(DELIMITER);
            if (items.length == 2) {
                columnConfigurations.put(items[0], items[1]);
            }
        });
    }
    return section;
}
Also used : IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Example 14 with IniConfigSection

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

the class FloatingFrame method saveToPreferences.

@Override
public IniConfigSection saveToPreferences(IniConfig prefs) {
    prefs.removeSection(storageKeyPrefix);
    IniConfigSection section = prefs.getSection(storageKeyPrefix);
    boolean maximized = (this.getExtendedState() & JFrame.MAXIMIZED_BOTH) != 0;
    section.put("maximized", maximized);
    section.put("position", GuiUtils.getPositionFrame(this, maximized));
    section.put("visible", this.isVisible());
    return section;
}
Also used : IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Example 15 with IniConfigSection

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

the class FloatingWindowsFactory method createChangesTrackedDialog.

private static FloatingWindow createChangesTrackedDialog(Frame frame, Mediator mediator, ApplicationModel model) {
    final ChangesTrackerPanel panel = new ChangesTrackerPanel();
    model.addListener(new ApplicationModelListener() {

        @Override
        public void modelChanged(ApplicationModelEvent event) {
            if (event.getType() == ApplicationModelEventType.SET_DIAGRAM_CHANGED)
                panel.setTrainDiagram(event.getModel().getDiagram());
        }
    });
    FloatingWindow dialog = new FloatingDialog(frame, panel, "dialog.changestracker.title", "changes.tracker") {

        private static final long serialVersionUID = 1L;

        @Override
        public IniConfigSection saveToPreferences(IniConfig prefs) {
            IniConfigSection section = super.saveToPreferences(prefs);
            section.put("divider", panel.getDividerLocation());
            section.put("divider2", panel.getDivider2Location());
            return section;
        }

        @Override
        public IniConfigSection loadFromPreferences(IniConfig prefs) {
            IniConfigSection section = super.loadFromPreferences(prefs);
            int divider = section.get("divider", Integer.class, panel.getDividerLocation());
            panel.setDividerLocation(divider);
            divider = section.get("divider2", Integer.class, panel.getDivider2Location());
            panel.setDivider2Location(divider);
            return section;
        }
    };
    return dialog;
}
Also used : IniConfig(net.parostroj.timetable.gui.ini.IniConfig) 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