package es.iiia.sgi.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.ui.handlers.HandlerUtil;
import es.iiia.shapeeditor.ShapeEditor;
import es.iiia.shapegrammar.model.ShapeGrammarModel;
public class SaveAsHandler extends AbstractHandler implements IHandler {
public static final String ID = "es.iiia.sgi.handlers.saveas";
public Object execute(ExecutionEvent event) throws ExecutionException {
// save depending on active editor
if (HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor() != null) {
ShapeEditor se = (ShapeEditor) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor();
se.doSaveAs();
LoadHandler.addRecentFile(ShapeGrammarModel.ACTIVE_SHAPE_GRAMMAR.getCurrentFileName());
} else {
// TODO: Be sure this does not happen!!!
}
// Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();
// ShapeGrammarModel.ACTIVE_SHAPE_GRAMMAR.saveAs(shell, null);
//
// for (IEditorReference editor : HandlerUtil.getActiveWorkbenchWindow(
// event).getActivePage().getEditorReferences()) {
// //TODO: save all editors
// }
return null;
}
}