/**
* Copyright (c) 2010-2012 ISBAN S.L
*
* 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:
* Ruben De Dios (ISBAN S.L)
* Andrez Alvarez Mattos (ISBAN S.L)
*/
package org.eclipse.gmf.tooling.simplemap.migrate.ui;
import org.eclipse.gmf.tooling.simplemap.diagram.part.SimpleMapEditorDiagramEditorUtil;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
public class MigrateToSimpleMapAction implements IObjectActionDelegate {
/**
* @generated
*/
private IWorkbenchPart targetPart;
private IStructuredSelection sselection;
/**
* @generated
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
this.targetPart = targetPart;
}
/**
* @generated
*/
public void selectionChanged(IAction action, ISelection selection) {
action.setEnabled(false);
if (selection instanceof IStructuredSelection == false || selection.isEmpty()) {
return;
}
final IStructuredSelection structuredSelection = ((IStructuredSelection) selection);
sselection = structuredSelection;
action.setEnabled(true);
}
@Override
public void run(IAction action) {
TransformToSimpleMappingWizard wizard = new TransformToSimpleMappingWizard();
wizard.init(PlatformUI.getWorkbench(), sselection);
SimpleMapEditorDiagramEditorUtil.runWizard(getShell(), wizard, "InitDiagramFile"); //$NON-NLS-1$
}
/**
* @generated
*/
private Shell getShell() {
return targetPart.getSite().getShell();
}
}