add preferences pane
This commit is contained in:
parent
7ce8ac92f7
commit
9785ea7bda
4 changed files with 153 additions and 10 deletions
|
@ -10,7 +10,8 @@ Import-Package: org.osgi.framework;version="1.3.0",
|
|||
org.protege.owlapi.apibinding,
|
||||
org.protege.owlapi.model,
|
||||
org.semanticweb.owlapi.model,
|
||||
javax.swing
|
||||
javax.swing,
|
||||
javax.swing.border
|
||||
Require-Bundle: org.eclipse.equinox.registry,
|
||||
org.eclipse.equinox.common,
|
||||
org.protege.common;bundle-version="4.1.0",
|
||||
|
|
14
plugin.xml
14
plugin.xml
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" ?>
|
||||
<plugin>
|
||||
|
||||
<extension
|
||||
id="HetsImportAction"
|
||||
<extension id="HetsImportAction"
|
||||
point="org.protege.editor.core.application.EditorKitMenuAction">
|
||||
<name value="Import HetCASL" />
|
||||
<path value="org.protege.editor.owl.menu.tools/SlotH-A" />
|
||||
|
@ -11,8 +10,7 @@
|
|||
<toolTip value="import OWL from HetCASL files" />
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
id="HetsExportAction"
|
||||
<extension id="HetsExportAction"
|
||||
point="org.protege.editor.core.application.EditorKitMenuAction">
|
||||
<name value="Export HetCASL" />
|
||||
<path value="org.protege.editor.owl.menu.tools/SlotH-B" />
|
||||
|
@ -21,8 +19,7 @@
|
|||
<toolTip value="export OWL to HetCASL file" />
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
id="HetCASL"
|
||||
<extension id="HetCASL"
|
||||
point="org.protege.editor.core.application.ViewComponent">
|
||||
<label value="HetCASL rendering" />
|
||||
<class value="de.unibremen.informatik.hets.protege.HetCASLRenderingViewComponent" />
|
||||
|
@ -30,4 +27,9 @@
|
|||
<category value="@org.protege.ontologycategory" />
|
||||
</extension>
|
||||
|
||||
<extension id="HetsPrefs"
|
||||
point="org.protege.editor.core.application.preferencespanel">
|
||||
<label value="Hets"/>
|
||||
<class value="de.unibremen.informatik.hets.protege.HetsPreferencesPane"/>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package de.unibremen.informatik.hets.protege;
|
||||
|
||||
import org.protege.editor.core.prefs.Preferences;
|
||||
import org.protege.editor.core.prefs.PreferencesManager;
|
||||
|
||||
public class HetsPreferences {
|
||||
private static HetsPreferences instance;
|
||||
|
||||
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 HETSPATH = "HETSPATH";
|
||||
|
||||
public static synchronized HetsPreferences getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new HetsPreferences();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Preferences getPrefs() {
|
||||
return PreferencesManager.getInstance().getApplicationPreferences(KEY);
|
||||
}
|
||||
|
||||
private static String getDefaultPath() {
|
||||
String platform = System.getProperty("os.name");
|
||||
|
||||
if(platform.indexOf("OS X") != -1) {
|
||||
return DEFAULT_MAC_PATH;
|
||||
}
|
||||
else if(platform.indexOf("Windows") != -1) {
|
||||
return DEFAULT_WINDOWS_PATH;
|
||||
}
|
||||
else {
|
||||
return DEFAULT_LINUX_PATH;
|
||||
}
|
||||
}
|
||||
|
||||
public String getHetsPath() {
|
||||
return getPrefs().getString(HETSPATH, getDefaultPath());
|
||||
}
|
||||
|
||||
public void setHetsPath(String path) {
|
||||
getPrefs().putString(HETSPATH, path);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package de.unibremen.informatik.hets.protege;
|
||||
|
||||
import de.unibremen.informatik.hets.protege.HetsPreferences;
|
||||
|
||||
import org.protege.editor.core.ui.util.UIUtil;
|
||||
import org.protege.editor.owl.ui.preferences.OWLPreferencesPanel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class HetsPreferencesPane extends OWLPreferencesPanel {
|
||||
|
||||
private java.util.List<OWLPreferencesPanel> optionPages = new ArrayList<OWLPreferencesPanel>();
|
||||
|
||||
public void applyChanges() {
|
||||
for (OWLPreferencesPanel optionPage : optionPages) {
|
||||
optionPage.applyChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void initialise() throws Exception {
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
OWLPreferencesPanel foo = new Foobar();
|
||||
OWLPreferencesPanel bar = new Foobar();
|
||||
OWLPreferencesPanel baz = new Foobar();
|
||||
|
||||
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);
|
||||
|
||||
tabPane.add("General Options", box);
|
||||
|
||||
optionPages.add(foo);
|
||||
optionPages.add(bar);
|
||||
optionPages.add(baz);
|
||||
|
||||
foo.initialise();
|
||||
bar.initialise();
|
||||
baz.initialise();
|
||||
|
||||
add(tabPane, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
public void dispose() throws Exception {
|
||||
for (OWLPreferencesPanel optionPage : optionPages) {
|
||||
optionPage.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class Foobar 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("Dot Application Path"));
|
||||
|
||||
Box panel = new Box(BoxLayout.LINE_AXIS);
|
||||
|
||||
pathField = new JTextField(15);
|
||||
pathField.setText(HetsPreferences.getInstance().getHetsPath());
|
||||
|
||||
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 {
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue