| /******************************************************************************* |
| * 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 |
| * Regent L'Archeveque |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************/ |
| package org.eclipse.apogy.addons.sensors.imaging.camera.handlers; |
| |
| import org.eclipse.apogy.addons.sensors.imaging.camera.ApogyAddonsSensorsImagingCameraPackage; |
| import org.eclipse.apogy.addons.sensors.imaging.camera.CameraViewConfigurationList; |
| import org.eclipse.apogy.addons.sensors.imaging.camera.CameraViewUtilities; |
| import org.eclipse.apogy.addons.sensors.imaging.camera.parts.CameraViewPart; |
| import org.eclipse.apogy.common.emf.ui.ApogyCommonEMFUIFactory; |
| import org.eclipse.apogy.common.emf.ui.NamedSetting; |
| import org.eclipse.apogy.common.emf.ui.wizards.ApogyEObjectWizard; |
| 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.MToolItem; |
| import org.eclipse.jface.wizard.WizardDialog; |
| import org.eclipse.swt.widgets.Display; |
| |
| public class AddCameraViewConfigurationHandler { |
| |
| @CanExecute |
| public boolean canExecute(MPart part) { |
| if (part.getObject() instanceof CameraViewPart) { |
| CameraViewConfigurationList cameraViewConfigurationList = CameraViewUtilities.INSTANCE |
| .getActiveCameraViewConfigurationList(); |
| return cameraViewConfigurationList != null; |
| } |
| return false; |
| } |
| |
| @Execute |
| public void execute(MPart part, final MToolItem item) { |
| if (part.getObject() instanceof CameraViewPart) { |
| CameraViewConfigurationList cameraViewConfigurationList = CameraViewUtilities.INSTANCE |
| .getActiveCameraViewConfigurationList(); |
| if (cameraViewConfigurationList != null) { |
| NamedSetting namedSettings = ApogyCommonEMFUIFactory.eINSTANCE.createNamedSetting(); |
| namedSettings.setParent(cameraViewConfigurationList); |
| namedSettings.setContainingFeature( |
| ApogyAddonsSensorsImagingCameraPackage.Literals.CAMERA_VIEW_CONFIGURATION_LIST__CAMERA_VIEW_CONFIGURATIONS); |
| ApogyEObjectWizard wizard = new ApogyEObjectWizard( |
| ApogyAddonsSensorsImagingCameraPackage.Literals.CAMERA_VIEW_CONFIGURATION_LIST__CAMERA_VIEW_CONFIGURATIONS, |
| cameraViewConfigurationList, namedSettings, null) { |
| @Override |
| public boolean performFinish() { |
| boolean value = super.performFinish(); |
| return value; |
| } |
| }; |
| WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard); |
| dialog.open(); |
| } |
| |
| } |
| } |
| } |