blob: cfda0159bb029a7b46ed08cc1643c0d077759159 [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,
* Olivier L. Larouche - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.topology.ui.handlers;
import org.eclipse.apogy.common.topology.AbstractViewPoint;
import org.eclipse.apogy.core.invocator.ApogyCoreInvocatorFacade;
import org.eclipse.apogy.core.topology.ui.parts.AbstractApogy3dPart;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem;
public class SetActiveViewPointHandler {
@CanExecute
public boolean canExecute(MPart part) {
return ApogyCoreInvocatorFacade.INSTANCE.getActiveInvocatorSession() != null;
}
@Execute
public void execute(MDirectMenuItem selectedItem, MPart part) {
if (part.getObject() instanceof AbstractApogy3dPart) {
AbstractApogy3dPart apogy3dPart = (AbstractApogy3dPart) part.getObject();
AbstractViewPoint avp = (AbstractViewPoint) selectedItem.getTransientData().get("viewpoint");
if (avp != null) {
apogy3dPart.setActiveViewPoint(avp);
}
}
}
}