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