use of org.csstudio.trends.databrowser3.model.ModelListenerAdapter in project org.csstudio.display.builder by kasemir.
the class DataBrowserEditor method init.
/**
* Initialize model from editor input
* {@inheritDoc}
*/
@Override
public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
setSite(site);
if (input instanceof DataBrowserModelEditorInput) {
// Received model with input
model = ((DataBrowserModelEditorInput) input).getModel();
setInput(input);
} else {
// Create new model
model = new Model();
setInput(new DataBrowserModelEditorInput(input, model));
// Load model content from file
try (final InputStream stream = SingleSourcePlugin.getResourceHelper().getInputStream(input)) {
if (stream != null)
new XMLPersistence().load(model, stream);
} catch (Exception ex) {
throw new PartInitException(NLS.bind(Messages.ConfigFileErrorFmt, input.getName()), ex);
}
}
// Update the editor's name from "Data Browser" to title of model or file name
// See DataBrowserModelEditorInput.getName()
setPartName(getEditorInput().getName());
model_listener = new ModelListenerAdapter() {
@Override
public void changedSaveChangesBehavior(final boolean save_changes) {
is_dirty = save_changes;
firePropertyChange(IEditorPart.PROP_DIRTY);
}
@Override
public void changedTitle() {
setDirty(true);
}
@Override
public void changedLayout() {
setDirty(true);
}
@Override
public void changedTiming() {
setDirty(true);
}
@Override
public void changedArchiveRescale() {
setDirty(true);
}
@Override
public void changedColorsOrFonts() {
setDirty(true);
}
@Override
public void changedTimerange() {
setDirty(true);
}
@Override
public void changeTimeAxisConfig() {
setDirty(true);
}
@Override
public void changedAxis(final Optional<AxisConfig> axis) {
setDirty(true);
}
@Override
public void itemAdded(final ModelItem item) {
setDirty(true);
}
@Override
public void itemRemoved(final ModelItem item) {
setDirty(true);
}
@Override
public void changedItemVisibility(final ModelItem item) {
setDirty(true);
}
@Override
public void changedItemLook(final ModelItem item) {
site.getShell().getDisplay().asyncExec(() -> setDirty(true));
}
@Override
public void changedItemDataConfig(PVItem item) {
setDirty(true);
}
@Override
public void scrollEnabled(final boolean scroll_enabled) {
setDirty(true);
}
@Override
public void changedAnnotations() {
setDirty(true);
}
};
model.addListener(model_listener);
}
Aggregations