From 77546e5690e2fe4dff771547aa0045122496c72f Mon Sep 17 00:00:00 2001 From: josch Date: Tue, 1 Feb 2011 12:21:35 +0100 Subject: [PATCH] add more preference options --- .../hets/protege/HetsPreferences.java | 61 ++++++-- .../hets/protege/HetsPreferencesPane.java | 135 +++++++++++++++--- 2 files changed, 169 insertions(+), 27 deletions(-) diff --git a/src/de/unibremen/informatik/hets/protege/HetsPreferences.java b/src/de/unibremen/informatik/hets/protege/HetsPreferences.java index bc6f400..d59dcbd 100644 --- a/src/de/unibremen/informatik/hets/protege/HetsPreferences.java +++ b/src/de/unibremen/informatik/hets/protege/HetsPreferences.java @@ -8,11 +8,18 @@ public class HetsPreferences { private static final String KEY = "de.unibremen.informatik.hets"; - private static final String DEFAULT_MAC_PATH = "/usr/local/Hets/bin/hets"; - private static final String DEFAULT_WINDOWS_PATH = "C:\\Program Files\\Hets\\bin\\hets"; - private static final String DEFAULT_LINUX_PATH = "/usr/bin/hets"; + private static final String DEFAULT_HETS_MAC_PATH = "/usr/local/Hets/bin/hets"; + private static final String DEFAULT_HETS_WINDOWS_PATH = "C:\\Program Files\\Hets\\bin\\hets"; + private static final String DEFAULT_HETS_LINUX_PATH = "/usr/bin/hets"; + + private static final String DEFAULT_DOT_MAC_PATH = "/usr/local/graphviz-2.14/bin/dot"; + private static final String DEFAULT_DOT_WINDOWS_PATH = "C:\\Program Files\\GraphViz\\bin\\Dot"; + private static final String DEFAULT_DOT_LINUX_PATH = "/usr/bin/dot"; private static final String HETSPATH = "HETSPATH"; + private static final String DOTPATH = "DOTPATH"; + private static final String CGIURL = "CGIURL"; + private static final String RESTFUL = "RESTFUL"; public static synchronized HetsPreferences getInstance() { if(instance == null) { @@ -25,25 +32,63 @@ public class HetsPreferences { return PreferencesManager.getInstance().getApplicationPreferences(KEY); } - private static String getDefaultPath() { + private static String getDefaultHetsPath() { + String platform = System.getProperty("os.name"); + + if(platform.indexOf("OS X") != -1) { + return DEFAULT_HETS_MAC_PATH; + } + else if(platform.indexOf("Windows") != -1) { + return DEFAULT_HETS_WINDOWS_PATH; + } + else { + return DEFAULT_HETS_LINUX_PATH; + } + } + + private static String getDefaultDotPath() { String platform = System.getProperty("os.name"); if(platform.indexOf("OS X") != -1) { - return DEFAULT_MAC_PATH; + return DEFAULT_DOT_MAC_PATH; } else if(platform.indexOf("Windows") != -1) { - return DEFAULT_WINDOWS_PATH; + return DEFAULT_DOT_WINDOWS_PATH; } else { - return DEFAULT_LINUX_PATH; + return DEFAULT_DOT_LINUX_PATH; } } public String getHetsPath() { - return getPrefs().getString(HETSPATH, getDefaultPath()); + return getPrefs().getString(HETSPATH, getDefaultHetsPath()); } public void setHetsPath(String path) { getPrefs().putString(HETSPATH, path); } + + public String getDotPath() { + return getPrefs().getString(DOTPATH, getDefaultDotPath()); + } + + public void setDotPath(String path) { + getPrefs().putString(DOTPATH, path); + } + + public String getCGIUrl() { + return getPrefs().getString(CGIURL, "http://www.informatik.uni-bremen.de/cgi-bin/cgiwrap/maeder/hets.cgi"); + } + + public void setCGIUrl(String path) { + getPrefs().putString(CGIURL, path); + } + + public String getRestFulUrl() { + return getPrefs().getString(RESTFUL, "http://pollux.informatik.uni-bremen.de:8000"); + } + + public void setRestFulUrl(String path) { + getPrefs().putString(RESTFUL, path); + } } diff --git a/src/de/unibremen/informatik/hets/protege/HetsPreferencesPane.java b/src/de/unibremen/informatik/hets/protege/HetsPreferencesPane.java index 46f6f06..86325f0 100644 --- a/src/de/unibremen/informatik/hets/protege/HetsPreferencesPane.java +++ b/src/de/unibremen/informatik/hets/protege/HetsPreferencesPane.java @@ -23,29 +23,38 @@ public class HetsPreferencesPane extends OWLPreferencesPanel { public void initialise() throws Exception { setLayout(new BorderLayout()); - OWLPreferencesPanel foo = new Foobar(); - OWLPreferencesPanel bar = new Foobar(); - OWLPreferencesPanel baz = new Foobar(); + OWLPreferencesPanel dotpath = new DotPath(); + OWLPreferencesPanel hetspath = new HetsPath(); + OWLPreferencesPanel cgiurl = new CGIUrl(); + OWLPreferencesPanel restfulhets = new RestFulHets(); JTabbedPane tabPane = new JTabbedPane(); - Box box = new Box(BoxLayout.Y_AXIS); - box.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); - box.add(foo); - box.add(Box.createVerticalStrut(7)); - box.add(bar); - box.add(Box.createVerticalStrut(7)); - box.add(baz); + Box box1 = new Box(BoxLayout.Y_AXIS); + box1.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); + box1.add(dotpath); + box1.add(Box.createVerticalStrut(7)); + box1.add(hetspath); + box1.add(Box.createVerticalStrut(7)); + box1.add(cgiurl); + box1.add(Box.createVerticalStrut(7)); + box1.add(restfulhets); - tabPane.add("General Options", box); + tabPane.add("General Options", box1); - optionPages.add(foo); - optionPages.add(bar); - optionPages.add(baz); + optionPages.add(dotpath); + optionPages.add(hetspath); + optionPages.add(cgiurl); + optionPages.add(restfulhets); - foo.initialise(); - bar.initialise(); - baz.initialise(); + dotpath.initialise(); + hetspath.initialise(); + cgiurl.initialise(); + restfulhets.initialise(); + + Box box2 = new Box(BoxLayout.Y_AXIS); + + tabPane.add("Graph Options", box2); add(tabPane, BorderLayout.NORTH); } @@ -56,11 +65,11 @@ public class HetsPreferencesPane extends OWLPreferencesPanel { } } - class Foobar extends OWLPreferencesPanel { + class DotPath extends OWLPreferencesPanel { private JTextField pathField; public void applyChanges() { - HetsPreferences.getInstance().setHetsPath(pathField.getText()); + HetsPreferences.getInstance().setDotPath(pathField.getText()); } public void initialise() throws Exception { @@ -70,6 +79,39 @@ public class HetsPreferencesPane extends OWLPreferencesPanel { Box panel = new Box(BoxLayout.LINE_AXIS); + pathField = new JTextField(15); + pathField.setText(HetsPreferences.getInstance().getDotPath()); + + JButton browseButton = new JButton(new AbstractAction("Browse") { + public void actionPerformed(ActionEvent e) { + } + }); + + panel.add(new JLabel("Path:")); + panel.add(pathField); + panel.add(browseButton); + + add(panel); + } + + public void dispose() throws Exception { + } + } + + class HetsPath extends OWLPreferencesPanel { + private JTextField pathField; + + public void applyChanges() { + HetsPreferences.getInstance().setHetsPath(pathField.getText()); + } + + public void initialise() throws Exception { + setLayout(new BorderLayout(12, 12)); + + setBorder(BorderFactory.createTitledBorder("Hets Application Path")); + + Box panel = new Box(BoxLayout.LINE_AXIS); + pathField = new JTextField(15); pathField.setText(HetsPreferences.getInstance().getHetsPath()); @@ -88,4 +130,59 @@ public class HetsPreferencesPane extends OWLPreferencesPanel { public void dispose() throws Exception { } } + + + class CGIUrl extends OWLPreferencesPanel { + private JTextField pathField; + + public void applyChanges() { + HetsPreferences.getInstance().setCGIUrl(pathField.getText()); + } + + public void initialise() throws Exception { + setLayout(new BorderLayout(12, 12)); + + setBorder(BorderFactory.createTitledBorder("CGI Url")); + + Box panel = new Box(BoxLayout.LINE_AXIS); + + pathField = new JTextField(15); + pathField.setText(HetsPreferences.getInstance().getCGIUrl()); + + panel.add(new JLabel("Url:")); + panel.add(pathField); + + add(panel); + } + + public void dispose() throws Exception { + } + } + + class RestFulHets extends OWLPreferencesPanel { + private JTextField pathField; + + public void applyChanges() { + HetsPreferences.getInstance().setRestFulUrl(pathField.getText()); + } + + public void initialise() throws Exception { + setLayout(new BorderLayout(12, 12)); + + setBorder(BorderFactory.createTitledBorder("Hets RestFul Url")); + + Box panel = new Box(BoxLayout.LINE_AXIS); + + pathField = new JTextField(15); + pathField.setText(HetsPreferences.getInstance().getRestFulUrl()); + + panel.add(new JLabel("Url:")); + panel.add(pathField); + + add(panel); + } + + public void dispose() throws Exception { + } + } }