blob: 08f957021129f34be1ab1fd8ae1029b1e7e8e0dc [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.jface.action.Action;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.viatra2.framework.FrameworkManager;
import org.eclipse.viatra2.framework.IFramework;
public class QuickParseVTMLAction extends Action
{
public QuickParseVTMLAction()
{
setActionDefinitionId("viatra_editor_fast_r2.parseCommand");
}
@Override
public void run() {
VTMLEditor iEditor = Activator.getDefault().getCurrentVTMLEditor();
if (FrameworkManager.getInstance().getAllFrameWorks().length<1)
return;
String iFrameworkID = FrameworkManager.getInstance().getAllFrameWorks()[0];
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());
}
}
}
}