From 57a5772d4ef5b722cd55263ea238a1a97c9d477c Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 1 Feb 2011 13:26:22 +0100 Subject: [PATCH] append to new import stubs --- .../hets/protege/CGIImportHetsAction.java | 17 ++++++++ .../hets/protege/LocalImportHetsAction.java | 40 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/src/de/unibremen/informatik/hets/protege/CGIImportHetsAction.java b/src/de/unibremen/informatik/hets/protege/CGIImportHetsAction.java index da234d8..b95bc56 100644 --- a/src/de/unibremen/informatik/hets/protege/CGIImportHetsAction.java +++ b/src/de/unibremen/informatik/hets/protege/CGIImportHetsAction.java @@ -1,8 +1,15 @@ package de.unibremen.informatik.hets.protege; +import java.io.File; +import java.util.Set; +import java.util.HashSet; + +import javax.swing.*; import java.awt.event.ActionEvent; +import java.awt.HeadlessException; import org.protege.editor.owl.ui.action.ProtegeOWLAction; +import org.protege.editor.core.ui.util.UIUtil; public class CGIImportHetsAction extends ProtegeOWLAction { @@ -18,5 +25,15 @@ public class CGIImportHetsAction extends ProtegeOWLAction { @Override public void actionPerformed(ActionEvent event) { + Set exts = new HashSet(); + exts.add("het"); + exts.add("owl"); + File file = null; + try { + file = UIUtil.openFile(new JFrame(), "HetCASL", "Please select a *.het file", exts); + } catch (HeadlessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } diff --git a/src/de/unibremen/informatik/hets/protege/LocalImportHetsAction.java b/src/de/unibremen/informatik/hets/protege/LocalImportHetsAction.java index 140eb8e..c45a8aa 100644 --- a/src/de/unibremen/informatik/hets/protege/LocalImportHetsAction.java +++ b/src/de/unibremen/informatik/hets/protege/LocalImportHetsAction.java @@ -1,13 +1,23 @@ package de.unibremen.informatik.hets.protege; +import javax.swing.*; import java.awt.event.ActionEvent; +import java.awt.HeadlessException; + +import java.io.File; +import java.io.IOException; +import java.util.Set; +import java.util.HashSet; import org.protege.editor.owl.ui.action.ProtegeOWLAction; +import org.protege.editor.core.ui.util.UIUtil; public class LocalImportHetsAction extends ProtegeOWLAction { private static final long serialVersionUID = -4056096587762591108L; + private Process process; + @Override public void initialise() throws Exception { } @@ -18,5 +28,35 @@ public class LocalImportHetsAction extends ProtegeOWLAction { @Override public void actionPerformed(ActionEvent event) { + Set exts = new HashSet(); + exts.add("het"); + exts.add("owl"); + File file = null; + try { + file = UIUtil.openFile(new JFrame(), "HetCASL", "Please select a *.het file", exts); + } catch (HeadlessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + if(process != null) { + process.destroy(); + process = null; + } + + Runtime r = Runtime.getRuntime(); + + try { + process = r.exec("/usr/bin/hets" + " " + file.getAbsolutePath() + " -o pp.xml"); + + try { + process.waitFor(); + } catch(InterruptedException irEx) { + irEx.printStackTrace(); + } + } catch(IOException ioEx) { + ioEx.printStackTrace(); + } } }