| /******************************************************************************* |
| * 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.preferences.ApogyEnvironmentSurfaceEarthUIPreferencesConstants; |
| import org.eclipse.apogy.core.environment.surface.ui.Activator; |
| 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 SunVector3DToolNodePresentationCustomImpl extends SunVector3DToolNodePresentationImpl { |
| |
| protected IPropertyChangeListener preferencesListener = null; |
| |
| protected SunVector3DToolNodePresentationCustomImpl() { |
| super(); |
| |
| // Register a listener to the preference store |
| Activator.getDefault().getPreferenceStore().addPropertyChangeListener(getPreferencesListener()); |
| } |
| |
| @Override |
| protected void applyPreferences() { |
| IPreferenceStore store = Activator.getDefault().getPreferenceStore(); |
| |
| // Change color. |
| RGB rgb = PreferenceConverter.getColor(store, |
| ApogyEnvironmentSurfaceEarthUIPreferencesConstants.DEFAULT_SUN_VECTOR_COLOR_ID); |
| if (rgb != null) |
| setColor(rgb); |
| |
| super.applyPreferences(); |
| } |
| |
| @Override |
| protected void finalize() throws Throwable { |
| Activator.getDefault().getPreferenceStore().removePropertyChangeListener(getPreferencesListener()); |
| super.finalize(); |
| } |
| |
| private IPropertyChangeListener getPreferencesListener() { |
| if (this.preferencesListener == null) { |
| this.preferencesListener = new IPropertyChangeListener() { |
| |
| @Override |
| public void propertyChange(PropertyChangeEvent event) { |
| applyPreferences(); |
| } |
| }; |
| } |
| |
| return this.preferencesListener; |
| } |
| } // SunVector3DToolNodePresentationImpl |