blob: e8c486bbbc237b9bf482b9c82df6467756b2dd03 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2007 IBM Corporation and others.
// 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:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
/*
* Copyright (c) 2005, 2006 IBM Corporation and others.
* 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:
* IBM Corporation - initial implementation
*
*/
package org.eclipse.epf.diagramming.part;
import org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog;
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.epf.diagramming.edit.parts.ActivityEditPart;
/**
* @generated
*/
public class UMLLoadResourceAction implements IObjectActionDelegate {
/**
* @generated
*/
private ActivityEditPart mySelectedElement;
/**
* @generated
*/
private Shell myShell;
/**
* @generated
*/
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
myShell = targetPart.getSite().getShell();
}
/**
* @generated
*/
public void run(IAction action) {
LoadResourceDialog loadResourceDialog = new LoadResourceDialog(myShell,
mySelectedElement.getEditingDomain());
loadResourceDialog.open();
}
/**
* @generated
*/
public void selectionChanged(IAction action, ISelection selection) {
mySelectedElement = null;
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
if (structuredSelection.size() == 1
&& structuredSelection.getFirstElement() instanceof ActivityEditPart) {
mySelectedElement = (ActivityEditPart) structuredSelection
.getFirstElement();
}
}
action.setEnabled(isEnabled());
}
/**
* @generated
*/
private boolean isEnabled() {
return mySelectedElement != null;
}
}