blob: 84d7a58789cfcdcb9fc7ede4d2b118c96c39bcdf [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 - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.environment.earth.ui.impl;
import org.eclipse.apogy.core.environment.earth.ui.AbstractWorldWindLayer;
import org.eclipse.apogy.core.environment.earth.ui.ApogyEarthEnvironmentUIPackage;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.jface.viewers.ISelection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EarthViewConfigurationCustomImpl extends EarthViewConfigurationImpl {
private static final Logger Logger = LoggerFactory.getLogger(EarthViewConfigurationImpl.class);
private Adapter adapter = null;
protected EarthViewConfigurationCustomImpl() {
super();
eAdapters().add(getAdapter());
}
public void selectionChanged(ISelection selection) {
for (AbstractWorldWindLayer layer : getLayers()) {
try {
layer.selectionChanged(selection);
} catch (Throwable t) {
Logger.error(t.getMessage(), t);
}
}
}
protected Adapter getAdapter() {
if (this.adapter == null) {
this.adapter = new AdapterImpl() {
@Override
public void notifyChanged(Notification msg) {
if (msg.getNotifier() instanceof EarthViewConfigurationCustomImpl) {
int featureId = msg.getFeatureID(EarthViewConfigurationCustomImpl.class);
switch (featureId) {
case ApogyEarthEnvironmentUIPackage.EARTH_VIEW_CONFIGURATION__LAYERS:
int eventType = msg.getEventType();
switch (eventType) {
case Notification.REMOVE:
if (msg.getOldValue() instanceof AbstractWorldWindLayer) {
// AbstractWorldWindLayer layer = (AbstractWorldWindLayer) msg.getOldValue();
// layer.dispose();
}
break;
case Notification.REMOVE_MANY:
// @SuppressWarnings("unchecked")
// List<AbstractWorldWindLayer> removed = (List<AbstractWorldWindLayer>) msg.getOldValue();
// for(AbstractWorldWindLayer layer : removed)
// {
// // layer.dispose();
// }
break;
default:
break;
}
break;
default:
break;
}
}
}
};
}
return this.adapter;
}
} // EarthViewConfigurationImpl