add more preference options
This commit is contained in:
parent
9785ea7bda
commit
77546e5690
2 changed files with 169 additions and 27 deletions
|
@ -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_MAC_PATH;
|
||||
return DEFAULT_HETS_MAC_PATH;
|
||||
}
|
||||
else if(platform.indexOf("Windows") != -1) {
|
||||
return DEFAULT_WINDOWS_PATH;
|
||||
return DEFAULT_HETS_WINDOWS_PATH;
|
||||
}
|
||||
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() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,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;
|
||||
|
||||
public void applyChanges() {
|
||||
|
@ -66,7 +108,7 @@ public class HetsPreferencesPane extends OWLPreferencesPanel {
|
|||
public void initialise() throws Exception {
|
||||
setLayout(new BorderLayout(12, 12));
|
||||
|
||||
setBorder(BorderFactory.createTitledBorder("Dot Application Path"));
|
||||
setBorder(BorderFactory.createTitledBorder("Hets Application Path"));
|
||||
|
||||
Box panel = new Box(BoxLayout.LINE_AXIS);
|
||||
|
||||
|
@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue