Package es.iiia.sgi.handlers

Source Code of es.iiia.sgi.handlers.SaveAsHandler

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;
  }
}
TOP

Related Classes of es.iiia.sgi.handlers.SaveAsHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.