add more preference options

This commit is contained in:
josch 2011-02-01 12:21:35 +01:00
parent 9785ea7bda
commit 77546e5690
2 changed files with 169 additions and 27 deletions

View file

@ -8,11 +8,18 @@ public class HetsPreferences {
private static final String KEY = "de.unibremen.informatik.hets"; 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_HETS_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_HETS_WINDOWS_PATH = "C:\\Program Files\\Hets\\bin\\hets";
private static final String DEFAULT_LINUX_PATH = "/usr/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 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() { public static synchronized HetsPreferences getInstance() {
if(instance == null) { if(instance == null) {
@ -25,25 +32,63 @@ public class HetsPreferences {
return PreferencesManager.getInstance().getApplicationPreferences(KEY); return PreferencesManager.getInstance().getApplicationPreferences(KEY);
} }
private static String getDefaultPath() { private static String getDefaultHetsPath() {
String platform = System.getProperty("os.name"); String platform = System.getProperty("os.name");
if(platform.indexOf("OS X") != -1) { if(platform.indexOf("OS X") != -1) {
return DEFAULT_MAC_PATH; return DEFAULT_HETS_MAC_PATH;
} }
else if(platform.indexOf("Windows") != -1) { else if(platform.indexOf("Windows") != -1) {
return DEFAULT_WINDOWS_PATH; return DEFAULT_HETS_WINDOWS_PATH;
} }
else { else {
return DEFAULT_LINUX_PATH; return DEFAULT_HETS_LINUX_PATH;
}
}
private static String getDefaultDotPath() {
String platform = System.getProperty("os.name");
if(platform.indexOf("OS X") != -1) {
return DEFAULT_DOT_MAC_PATH;
}
else if(platform.indexOf("Windows") != -1) {
return DEFAULT_DOT_WINDOWS_PATH;
}
else {
return DEFAULT_DOT_LINUX_PATH;
} }
} }
public String getHetsPath() { public String getHetsPath() {
return getPrefs().getString(HETSPATH, getDefaultPath()); return getPrefs().getString(HETSPATH, getDefaultHetsPath());
} }
public void setHetsPath(String path) { public void setHetsPath(String path) {
getPrefs().putString(HETSPATH, 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);
}
} }

View file

@ -23,29 +23,38 @@ public class HetsPreferencesPane extends OWLPreferencesPanel {
public void initialise() throws Exception { public void initialise() throws Exception {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
OWLPreferencesPanel foo = new Foobar(); OWLPreferencesPanel dotpath = new DotPath();
OWLPreferencesPanel bar = new Foobar(); OWLPreferencesPanel hetspath = new HetsPath();
OWLPreferencesPanel baz = new Foobar(); OWLPreferencesPanel cgiurl = new CGIUrl();
OWLPreferencesPanel restfulhets = new RestFulHets();
JTabbedPane tabPane = new JTabbedPane(); JTabbedPane tabPane = new JTabbedPane();
Box box = new Box(BoxLayout.Y_AXIS); Box box1 = new Box(BoxLayout.Y_AXIS);
box.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); box1.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
box.add(foo); box1.add(dotpath);
box.add(Box.createVerticalStrut(7)); box1.add(Box.createVerticalStrut(7));
box.add(bar); box1.add(hetspath);
box.add(Box.createVerticalStrut(7)); box1.add(Box.createVerticalStrut(7));
box.add(baz); 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(dotpath);
optionPages.add(bar); optionPages.add(hetspath);
optionPages.add(baz); optionPages.add(cgiurl);
optionPages.add(restfulhets);
foo.initialise(); dotpath.initialise();
bar.initialise(); hetspath.initialise();
baz.initialise(); cgiurl.initialise();
restfulhets.initialise();
Box box2 = new Box(BoxLayout.Y_AXIS);
tabPane.add("Graph Options", box2);
add(tabPane, BorderLayout.NORTH); add(tabPane, BorderLayout.NORTH);
} }
@ -56,7 +65,40 @@ public class HetsPreferencesPane extends OWLPreferencesPanel {
} }
} }
class Foobar extends OWLPreferencesPanel { class DotPath extends OWLPreferencesPanel {
private JTextField pathField;
public void applyChanges() {
HetsPreferences.getInstance().setDotPath(pathField.getText());
}
public void initialise() throws Exception {
setLayout(new BorderLayout(12, 12));
setBorder(BorderFactory.createTitledBorder("Dot Application Path"));
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; private JTextField pathField;
public void applyChanges() { public void applyChanges() {
@ -66,7 +108,7 @@ public class HetsPreferencesPane extends OWLPreferencesPanel {
public void initialise() throws Exception { public void initialise() throws Exception {
setLayout(new BorderLayout(12, 12)); setLayout(new BorderLayout(12, 12));
setBorder(BorderFactory.createTitledBorder("Dot Application Path")); setBorder(BorderFactory.createTitledBorder("Hets Application Path"));
Box panel = new Box(BoxLayout.LINE_AXIS); Box panel = new Box(BoxLayout.LINE_AXIS);
@ -88,4 +130,59 @@ public class HetsPreferencesPane extends OWLPreferencesPanel {
public void dispose() throws Exception { 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 {
}
}
} }