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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations