Search in sources :

Example 1 with AbstractColleague

use of net.parostroj.timetable.mediator.AbstractColleague in project grafikon by jub77.

the class FloatingWindowsFactory method createEventsViewerDialog.

private static FloatingWindow createEventsViewerDialog(final Frame frame, final Mediator mediator, final ApplicationModel model) {
    final EventsViewerPanel panel = new EventsViewerPanel();
    panel.addConverter(new GTEventTypeConverter());
    panel.addConverter(new ApplicationEventTypeConverter());
    final FloatingDialog dialog = new FloatingDialog(frame, panel, "dialog.eventsviewer.title", "events.viewer") {

        private static final long serialVersionUID = 1L;

        @Override
        public IniConfigSection saveToPreferences(IniConfig prefs) {
            IniConfigSection section = super.saveToPreferences(prefs);
            section.put("divider", panel.getDividerLocation());
            section.put("limit", panel.getLimit());
            section.put("show.time", panel.isShowTime());
            section.put("write.to.log", panel.isWriteToLog());
            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);
            int limit = section.get("limit", Integer.class, panel.getLimit());
            panel.setLimit(limit);
            panel.setShowTime(section.get("show.time", Boolean.class, false));
            panel.setWriteToLog(section.get("write.to.log", Boolean.class, false));
            return section;
        }
    };
    mediator.addColleague(new AbstractColleague() {

        @Override
        public void receiveMessage(Object message) {
            // do not process messages when the dialog is not visible ...
            if (!dialog.isVisible())
                return;
            panel.addEvent(message);
        }
    });
    return dialog;
}
Also used : IniConfig(net.parostroj.timetable.gui.ini.IniConfig) AbstractColleague(net.parostroj.timetable.mediator.AbstractColleague) IniConfigSection(net.parostroj.timetable.gui.ini.IniConfigSection)

Aggregations

IniConfig (net.parostroj.timetable.gui.ini.IniConfig)1 IniConfigSection (net.parostroj.timetable.gui.ini.IniConfigSection)1 AbstractColleague (net.parostroj.timetable.mediator.AbstractColleague)1