blob: 53729b973c9dafb04f5398ea5ac5eb6325b6c2aa [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.core.environment.surface.ui.impl;
import org.eclipse.apogy.core.environment.surface.ui.Activator;
import org.eclipse.apogy.core.environment.surface.ui.ApogySurfaceEnvironmentUIPackage;
import org.eclipse.apogy.core.environment.surface.ui.preferences.ApogyEnvironmentSurfaceUIPreferencesConstants;
import org.eclipse.apogy.core.environment.surface.ui.scene_objects.FeatureOfInterestSceneObject;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
public class FeatureOfInterestNodePresentationCustomImpl extends FeatureOfInterestNodePresentationImpl {
protected IPropertyChangeListener preferencesListener = null;
protected FeatureOfInterestNodePresentationCustomImpl() {
super();
// Initializes values from preferences
applyPreferences();
// Register a listener to the preference store
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(getPreferencesListener());
}
@Override
protected void updateSceneObject(Notification notification) {
if (this.sceneObject != null) {
FeatureOfInterestSceneObject featureOfInterestSceneObject = (FeatureOfInterestSceneObject) this.sceneObject;
if (notification.getNotifier() instanceof FeatureOfInterestNodePresentationCustomImpl) {
int featureID = notification.getFeatureID(FeatureOfInterestNodePresentationCustomImpl.class);
switch (featureID) {
case ApogySurfaceEnvironmentUIPackage.FEATURE_OF_INTEREST_NODE_PRESENTATION__POLE_HEIGHT:
double newPoleHeight = notification.getNewDoubleValue();
featureOfInterestSceneObject.setFlagPoleHeight((float) newPoleHeight);
break;
case ApogySurfaceEnvironmentUIPackage.FEATURE_OF_INTEREST_NODE_PRESENTATION__FLAG_VISIBLE:
boolean newFlagVisible = notification.getNewBooleanValue();
featureOfInterestSceneObject.setFlagVisible(newFlagVisible);
break;
case ApogySurfaceEnvironmentUIPackage.FEATURE_OF_INTEREST_NODE_PRESENTATION__FONT_SIZE:
int newFontSize = notification.getNewIntValue();
featureOfInterestSceneObject.setFontSize(newFontSize);
break;
default:
break;
}
}
}
super.updateSceneObject(notification);
}
@Override
protected void initialSceneObject() {
FeatureOfInterestSceneObject featureOfInterestSceneObject = (FeatureOfInterestSceneObject) this.sceneObject;
featureOfInterestSceneObject.setFlagPoleHeight((float) getPoleHeight());
featureOfInterestSceneObject.setFlagVisible(isFlagVisible());
super.initialSceneObject();
}
@Override
protected void applyPreferences() {
super.applyPreferences();
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
setPoleHeight(store.getDouble(ApogyEnvironmentSurfaceUIPreferencesConstants.DEFAULT_FOI_FLAG_POLE_HEIGHT_ID));
setFlagVisible(store.getBoolean(ApogyEnvironmentSurfaceUIPreferencesConstants.DEFAULT_FOI_FLAG_VISIBLE_ID));
setFontSize(store.getInt(ApogyEnvironmentSurfaceUIPreferencesConstants.DEFAULT_FOI_FONT_SIZE_ID));
}
protected IPropertyChangeListener getPreferencesListener() {
if (this.preferencesListener == null) {
this.preferencesListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
applyPreferences();
}
};
}
return this.preferencesListener;
}
} // FeatureOfInterestNodePresentationImpl