/******************************************************************************* | |
* Copyright (c) 2004, 2007 Boeing. | |
* 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: | |
* Boeing - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.osee.framework.ui.skynet.commandHandlers; | |
import java.util.List; | |
import org.eclipse.core.commands.AbstractHandler; | |
import org.eclipse.core.commands.ExecutionEvent; | |
import org.eclipse.core.commands.ExecutionException; | |
import org.eclipse.jface.viewers.ISelectionProvider; | |
import org.eclipse.jface.viewers.IStructuredSelection; | |
import org.eclipse.osee.framework.skynet.core.artifact.Artifact; | |
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench; | |
import org.eclipse.osee.framework.ui.skynet.skywalker.SkyWalkerView; | |
/** | |
* @author Jeff C. Phillips | |
*/ | |
public class OpenSkywalkerEditorHandler extends AbstractHandler { | |
/* (non-Javadoc) | |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) | |
*/ | |
@Override | |
public Object execute(ExecutionEvent arg0) throws ExecutionException { | |
ISelectionProvider selectionProvider = | |
AWorkbench.getActivePage().getActivePart().getSite().getSelectionProvider(); | |
if (selectionProvider != null && selectionProvider.getSelection() instanceof IStructuredSelection) { | |
IStructuredSelection structuredSelection = (IStructuredSelection) selectionProvider.getSelection(); | |
List<Artifact> artifacts = Handlers.getArtifactsFromStructuredSelection(structuredSelection); | |
if (!artifacts.isEmpty()) { | |
SkyWalkerView.exploreArtifact(artifacts.iterator().next()); | |
} | |
} | |
return null; | |
} | |
@Override | |
public boolean isEnabled() { | |
return true; | |
} | |
} |