blob: a362a67d2328f056e8a49123534053828ac5d7ca [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.vehicle.ui.impl;
import org.eclipse.apogy.addons.vehicle.ui.Activator;
import org.eclipse.apogy.addons.vehicle.ui.preferences.VehicleUIPreferencesConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.graphics.RGB;
public class LanderSphericalFootPresentationCustomImpl extends LanderSphericalFootPresentationImpl {
protected IPropertyChangeListener preferencesListener = null;
protected LanderSphericalFootPresentationCustomImpl() {
super();
applyPreferences();
// Register a listener to the preference store
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(getPreferencesListener());
}
@Override
protected void applyPreferences() {
// Applies preferences.
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
// Change color.
RGB rgb = PreferenceConverter.getColor(store,
VehicleUIPreferencesConstants.DEFAULT_LANDER_SPHERICAL_FOOT_COLOR_ID);
if (rgb != null)
setColor(rgb);
// Visibility
setVisible(store.getBoolean(VehicleUIPreferencesConstants.DEFAULT_LANDER_SPHERICAL_FOOT_VISIBILITY_ID));
super.applyPreferences();
}
private IPropertyChangeListener getPreferencesListener() {
if (this.preferencesListener == null) {
this.preferencesListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
applyPreferences();
}
};
}
return this.preferencesListener;
}
} // LanderSphericalFootPresentationImpl