blob: b38a40f2bc748337f36c7a1f607738bda2b53029 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Istvan Rath and Daniel Varro
* 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:
* Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.editor.text.light.vtml;
import org.eclipse.viatra2.editor.text.Activator;
import org.eclipse.viatra2.editor.text.light.VTMLEditor;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.viatra2.framework.FrameworkManager;
import org.eclipse.viatra2.framework.IFramework;
public class ParseVTMLAction extends RetargetAction {
protected VTMLEditor iEditor = null;
protected String iFrameworkID;
public ParseVTMLAction updateSelf(VTMLEditor e)
{
iEditor = e;
return this;
}
public ParseVTMLAction(String fwid) {
super("parseVTML", "Parse VTML");
iFrameworkID = fwid;
setImageDescriptor(Activator.getImageDescriptor("icons/parse.png"));
}
public ParseVTMLAction(String actionID, String text) {
super(actionID, text);
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public void runWithEvent(Event event) {
run();
}
@Override
public void run() {
if (iEditor!=null && iFrameworkID!=null)
{
IFramework fw = FrameworkManager.getInstance().getFramework(iFrameworkID);
if (fw==null)
return;
if (iEditor.isDirty())
iEditor.doSave(null);
try {
fw.nativeImport(((IFileEditorInput)iEditor.getEditorInput()).getFile().getContents(),
fw.getNativeImportersForExtension("vtml").iterator().next());
} catch (Exception e)
{
fw.getLogger().fatal(e.getMessage());
}
}
}
}