blob: 8178ece867166224accf29a7056af5f942e2f5b4 [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.earth.surface.ui.impl;
import org.eclipse.apogy.core.environment.earth.surface.ui.Activator;
import org.eclipse.apogy.core.environment.earth.surface.ui.ApogyCoreEnvironmentSurfaceEarthUIPackage;
import org.eclipse.apogy.core.environment.earth.surface.ui.EarthSurfaceWorksitePresentation;
import org.eclipse.apogy.core.environment.earth.surface.ui.scene_objects.EarthSkySceneObject;
import org.eclipse.apogy.core.environment.surface.ui.preferences.ApogyEnvironmentSurfaceUIPreferencesConstants;
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 EarthSkyPresentationCustomImpl extends EarthSkyPresentationImpl {
protected IPropertyChangeListener preferencesListener = null;
protected EarthSkyPresentationCustomImpl() {
super();
// Initializes values from preferences
applyPreferences();
// Register a listener to the preference store
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(getPreferencesListener());
}
@Override
public boolean isUseInBoundingCalculation() {
return false;
}
@Override
protected void updateSceneObject(Notification notification) {
if (this.sceneObject != null) {
EarthSkySceneObject earthSkySceneObject = (EarthSkySceneObject) this.sceneObject;
int featureID = notification.getFeatureID(EarthSurfaceWorksitePresentation.class);
switch (featureID) {
// TODO
case ApogyCoreEnvironmentSurfaceEarthUIPackage.EARTH_SURFACE_WORKSITE_PRESENTATION__AXIS_VISIBLE:
earthSkySceneObject.setHorizonVisible(notification.getNewBooleanValue());
break;
default:
break;
}
}
super.updateSceneObject(notification);
}
@Override
protected void initialSceneObject() {
EarthSkySceneObject earthSkySceneObject = (EarthSkySceneObject) this.sceneObject;
// Horizon
earthSkySceneObject.setHorizonVisible(isHorizonVisible());
super.initialSceneObject();
}
@Override
protected void applyPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
// Set the axis visibility and length.
setHorizonVisible(
store.getBoolean(ApogyEnvironmentSurfaceUIPreferencesConstants.DEFAULT_SKY_HORIZON_VISIBLE_ID));
super.applyPreferences();
}
private IPropertyChangeListener getPreferencesListener() {
if (this.preferencesListener == null) {
this.preferencesListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
applyPreferences();
}
};
}
return this.preferencesListener;
}
} // EarthSkyPresentationImpl