package es.iiia.sgi.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import es.iiia.shapeeditor.ShapeEditor;
import es.iiia.shapegrammar.model.GeometryModel;
public class PasteAction extends Action implements IWorkbenchAction {
private IWorkbenchWindow workbenchWindow;
private ShapeEditor editor;
public PasteAction(IWorkbenchWindow window) {
workbenchWindow = window;
}
@Override
public void dispose() {
}
@Override
public void run() {
try {
if (ShapeClipboard.get() != null) {
ShapeEditor editor = (ShapeEditor) workbenchWindow
.getActivePage().getActiveEditor();
for (GeometryModel mdl : ShapeClipboard.get()) {
editor.getModel().addChild(mdl.clone());
}
}
} catch (Exception ex) {
}
}
}