|
From: jistrawn <jis...@us...> - 2006-10-24 21:41:45
|
Update of /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/popup/actions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2330/src/net/sourceforge/modelWizard/popup/actions Modified Files: AddModelAction.java Log Message: removed unused imports or reformatted import order (ctrl-shift-o) Index: AddModelAction.java =================================================================== RCS file: /cvsroot/modelwizard/source/Model Wizard Plugin/src/net/sourceforge/modelWizard/popup/actions/AddModelAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AddModelAction.java 6 Oct 2005 15:59:05 -0000 1.1 --- AddModelAction.java 24 Oct 2006 21:41:41 -0000 1.2 *************** *** 1,76 **** ! package net.sourceforge.modelWizard.popup.actions; ! ! import java.io.IOException; ! ! import net.sourceforge.modelWizard.modelAbstraction.ModelAccess; ! import net.sourceforge.modelWizard.utilities.PathUtilties; ! ! import org.eclipse.core.resources.IFile; ! import org.eclipse.core.resources.IProject; ! import org.eclipse.core.resources.IResource; ! import org.eclipse.emf.common.util.URI; ! 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.IWorkbenchWindow; ! import org.eclipse.ui.IWorkbenchWindowActionDelegate; ! import org.eclipse.jface.dialogs.MessageDialog; ! import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; ! ! ! ! /** ! * Our sample action implements workbench action delegate. ! * The action proxy will be created by the workbench and ! * shown in the UI. When the user tries to use the action, ! * this delegate will be created and execution will be ! * delegated to it. ! * @see IWorkbenchWindowActionDelegate ! */ ! public class AddModelAction implements IObjectActionDelegate { ! private ISelection selection; ! ! private Shell shell=null; ! ! /** ! * The action has been activated. The argument of the ! * method represents the 'real' action sitting ! * in the workbench UI. ! * @see IWorkbenchWindowActionDelegate#run ! */ ! public void run(IAction action) { ! if (selection!=null && selection.isEmpty()==false && selection instanceof IStructuredSelection) { ! IStructuredSelection ssel = (IStructuredSelection)selection; ! Object obj = ssel.getFirstElement(); ! if (obj instanceof IResource){ ! IProject proj = (IProject) obj; ! CopyFilesAndFoldersOperation cp = new CopyFilesAndFoldersOperation(shell); ! URI fUri = ModelAccess.INSTANCE.getCurrentModelFile(); ! String f = PathUtilties.convertLocalURItoFile(fUri); ! cp.copyFiles(new String[] {f},proj); ! } ! } ! } ! ! /** ! * Selection in the workbench has been changed. We ! * can change the state of the 'real' action here ! * if we want, but this can only happen after ! * the delegate has been created. ! * @see IWorkbenchWindowActionDelegate#selectionChanged ! */ ! public void selectionChanged(IAction action, ISelection selection) { ! this.selection = selection; ! } ! ! ! /* (non-Javadoc) ! * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) ! */ ! public void setActivePart(IAction action, IWorkbenchPart targetPart) { ! shell = targetPart.getSite().getShell(); ! } } \ No newline at end of file --- 1,71 ---- ! package net.sourceforge.modelWizard.popup.actions; ! ! import net.sourceforge.modelWizard.modelAbstraction.ModelAccess; ! import net.sourceforge.modelWizard.utilities.PathUtilties; ! ! import org.eclipse.core.resources.IProject; ! import org.eclipse.core.resources.IResource; ! import org.eclipse.emf.common.util.URI; ! 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.IWorkbenchWindowActionDelegate; ! import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; ! ! ! ! /** ! * Our sample action implements workbench action delegate. ! * The action proxy will be created by the workbench and ! * shown in the UI. When the user tries to use the action, ! * this delegate will be created and execution will be ! * delegated to it. ! * @see IWorkbenchWindowActionDelegate ! */ ! public class AddModelAction implements IObjectActionDelegate { ! private ISelection selection; ! ! private Shell shell=null; ! ! /** ! * The action has been activated. The argument of the ! * method represents the 'real' action sitting ! * in the workbench UI. ! * @see IWorkbenchWindowActionDelegate#run ! */ ! public void run(IAction action) { ! if (selection!=null && selection.isEmpty()==false && selection instanceof IStructuredSelection) { ! IStructuredSelection ssel = (IStructuredSelection)selection; ! Object obj = ssel.getFirstElement(); ! if (obj instanceof IResource){ ! IProject proj = (IProject) obj; ! CopyFilesAndFoldersOperation cp = new CopyFilesAndFoldersOperation(shell); ! URI fUri = ModelAccess.INSTANCE.getCurrentModelFile(); ! String f = PathUtilties.convertLocalURItoFile(fUri); ! cp.copyFiles(new String[] {f},proj); ! } ! } ! } ! ! /** ! * Selection in the workbench has been changed. We ! * can change the state of the 'real' action here ! * if we want, but this can only happen after ! * the delegate has been created. ! * @see IWorkbenchWindowActionDelegate#selectionChanged ! */ ! public void selectionChanged(IAction action, ISelection selection) { ! this.selection = selection; ! } ! ! ! /* (non-Javadoc) ! * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) ! */ ! public void setActivePart(IAction action, IWorkbenchPart targetPart) { ! shell = targetPart.getSite().getShell(); ! } } \ No newline at end of file |