blob: bd6345ba598d0f2cc88c4e8c6118272d15950e84 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pierre Allard,
* Regent L'Archeveque - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.addons.sensors.fov.ui.impl;
import org.eclipse.apogy.addons.sensors.fov.ui.Activator;
import org.eclipse.apogy.addons.sensors.fov.ui.ApogyAddonsSensorsFOVUIPackage;
import org.eclipse.apogy.addons.sensors.fov.ui.FieldOfViewPresentation;
import org.eclipse.apogy.addons.sensors.fov.ui.scene_objects.FieldOfViewSceneObject;
import org.eclipse.apogy.common.topology.ui.MeshPresentationMode;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
public class FieldOfViewPresentationCustomImpl extends FieldOfViewPresentationImpl {
protected IPropertyChangeListener preferencesListener = null;
protected FieldOfViewPresentationCustomImpl() {
super();
// Register a listener to the preference store
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(getPreferencesListener());
}
@Override
public void setPresentationMode(MeshPresentationMode newPresentationMode) {
super.setPresentationMode(newPresentationMode);
}
@Override
protected void initialSceneObject() {
FieldOfViewSceneObject fieldOfViewSceneObject = (FieldOfViewSceneObject) getSceneObject();
fieldOfViewSceneObject.setPresentationMode(this.getPresentationMode());
fieldOfViewSceneObject.setTransparency(this.getTransparency());
fieldOfViewSceneObject.setShowOutlineOnly(this.isShowOutlineOnly());
fieldOfViewSceneObject.setShowProjection(this.isShowProjection());
fieldOfViewSceneObject.setProjectionColor(this.getProjectionColor());
fieldOfViewSceneObject.setAxisVisible(this.axisVisible);
fieldOfViewSceneObject.setAxisLength(this.getAxisLength());
super.initialSceneObject();
}
@Override
protected void updateSceneObject(Notification notification) {
FieldOfViewSceneObject fieldOfViewSceneObject = (FieldOfViewSceneObject) getSceneObject();
if (notification.getNotifier() instanceof FieldOfViewPresentation) {
int featureId = notification.getFeatureID(FieldOfViewPresentation.class);
switch (featureId) {
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__PRESENTATION_MODE:
fieldOfViewSceneObject.setPresentationMode(this.getPresentationMode());
break;
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__TRANSPARENCY:
fieldOfViewSceneObject.setTransparency(this.getTransparency());
break;
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__SHOW_OUTLINE_ONLY:
fieldOfViewSceneObject.setShowOutlineOnly(this.isShowOutlineOnly());
break;
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__SHOW_PROJECTION:
fieldOfViewSceneObject.setShowProjection(this.isShowProjection());
break;
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__PROJECTION_COLOR:
fieldOfViewSceneObject.setProjectionColor(this.getProjectionColor());
break;
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__AXIS_VISIBLE:
fieldOfViewSceneObject.setAxisVisible(this.isAxisVisible());
break;
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__AXIS_LENGTH:
fieldOfViewSceneObject.setAxisLength(this.getAxisLength());
break;
case ApogyAddonsSensorsFOVUIPackage.FIELD_OF_VIEW_PRESENTATION__FOV_VISIBLE:
fieldOfViewSceneObject.setFOVVisible(this.isFovVisible());
break;
default:
break;
}
}
super.updateSceneObject(notification);
}
private IPropertyChangeListener getPreferencesListener() {
if (this.preferencesListener == null) {
this.preferencesListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
applyPreferences();
}
};
}
return this.preferencesListener;
}
@Override
protected void applyPreferences() {
// Must be overidden.
super.applyPreferences();
}
@Override
protected void finalize() throws Throwable {
Activator.getDefault().getPreferenceStore().removePropertyChangeListener(getPreferencesListener());
super.finalize();
}
} // FieldOfViewPresentationImpl