initialization with a URI

Esse commit está contido em:
Rafael Goncalves
2015-04-03 15:37:50 -07:00
commit cd91c4ed3f
8 arquivos alterados com 67 adições e 8 exclusões
@@ -366,13 +366,15 @@ public class ProtegeApplication implements BundleActivator {
private void startApplication() throws Exception { private void startApplication() throws Exception {
createAndSetupDefaultEditorKit();
if (commandLineURIs != null && !commandLineURIs.isEmpty()) { if (commandLineURIs != null && !commandLineURIs.isEmpty()) {
// Open any command line URIs // Open any command line URIs
for (URI uri : commandLineURIs) { for (URI uri : commandLineURIs) {
editURI(uri); createAndSetupDefaultEditorKit(uri);
} }
} }
else {
createAndSetupDefaultEditorKit();
}
checkForUpdates(); checkForUpdates();
} }
@@ -431,6 +433,25 @@ public class ProtegeApplication implements BundleActivator {
} }
} }
private void createAndSetupDefaultEditorKit(URI uri) {
try {
ProtegeManager pm = ProtegeManager.getInstance();
List<EditorKitFactoryPlugin> editorKitFactoryPlugins = pm.getEditorKitFactoryPlugins();
if (!editorKitFactoryPlugins.isEmpty()) {
EditorKitFactoryPlugin defaultPlugin = editorKitFactoryPlugins.get(0);
pm.createAndSetupNewEditorKit(defaultPlugin, uri);
}
else {
throw new RuntimeException("No editor kit factory plugins available");
}
}
catch (Exception e) {
ErrorLogPanel.showErrorDialog(e);
}
}
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Visible Application Interfaces // Visible Application Interfaces
@@ -158,6 +158,44 @@ public class ProtegeManager {
} }
/**
* Creates and sets up a new <code>EditorKit</code> with an ontology specified by a given <code>URI</code>.
*
* @param plugin The <code>EditorKitFactoryPlugin</code> that describes the <code>EditorKitFactory</code> which will
* be used to create the <code>EditorKit</code>.
* @param uri The ontology <code>URI</code> with which the new <code>EditorKit</code> will be instantiated
*/
public EditorKit createAndSetupNewEditorKit(EditorKitFactory editorKitFactory, URI uri) throws Exception {
if (editorKitFactory != null) {
boolean success = false;
EditorKit editorKit = editorKitFactory.createEditorKit();
try {
if (editorKit.handleLoadFrom(uri)) {
getEditorKitManager().addEditorKit(editorKit);
success = true;
if(getEditorKitManager().getEditorKitCount() == 1) {
firstEditorKit = new WeakReference<EditorKit>(editorKit);
}
return editorKit;
}
}
finally {
if (!success) {
editorKit.dispose();
}
}
}
return null;
}
public boolean createAndSetupNewEditorKit(EditorKitFactoryPlugin plugin, URI uri) throws Exception {
EditorKitFactory editorKitFactory = getEditorKitFactory(plugin);
return createAndSetupNewEditorKit(editorKitFactory, uri) != null;
}
/** /**
* Opens an <code>EditorKit</code> using the <code>EditorKitFactory</code> specified by the given Id. * Opens an <code>EditorKit</code> using the <code>EditorKitFactory</code> specified by the given Id.
* *
+1 -1
Ver Arquivo
@@ -7,7 +7,7 @@ jre/bin/java -Xmx500M -Xms250M \
-DentityExpansionLimit=100000000 \ -DentityExpansionLimit=100000000 \
-Dfile.encoding=UTF-8 \ -Dfile.encoding=UTF-8 \
-classpath bin/org.apache.felix.main.jar:bin/ProtegeLauncher.jar \ -classpath bin/org.apache.felix.main.jar:bin/ProtegeLauncher.jar \
$CMD_OPTIONS org.protege.osgi.framework.Launcher $CMD_OPTIONS org.protege.osgi.framework.Launcher $1
+1 -1
Ver Arquivo
@@ -7,7 +7,7 @@ jre/bin/java -Xmx500M -Xms250M \
-DentityExpansionLimit=100000000 \ -DentityExpansionLimit=100000000 \
-Dfile.encoding=UTF-8 \ -Dfile.encoding=UTF-8 \
-classpath bin/org.apache.felix.main.jar:bin/ProtegeLauncher.jar \ -classpath bin/org.apache.felix.main.jar:bin/ProtegeLauncher.jar \
$CMD_OPTIONS org.protege.osgi.framework.Launcher $CMD_OPTIONS org.protege.osgi.framework.Launcher $1
@@ -1,2 +1,2 @@
java -Dlog4j.configuration=file:log4j.xml -DentityExpansionLimit=100000000 -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bin/org.apache.felix.main.jar;bin/ProtegeLauncher.jar org.protege.osgi.framework.Launcher java -Dlog4j.configuration=file:log4j.xml -DentityExpansionLimit=100000000 -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bin/org.apache.felix.main.jar;bin/ProtegeLauncher.jar org.protege.osgi.framework.Launcher %1
@@ -1,6 +1,6 @@
cd "$(dirname "$0")" cd "$(dirname "$0")"
CMD_OPTIONS="-Dapple.laf.useScreenMenuBar=true -Dcom.apple.mrj.application.apple.menu.about.name=Protege -Xdock:name=Protege -Xdock:icon=Protege.icns" sh run.sh CMD_OPTIONS="-Dapple.laf.useScreenMenuBar=true -Dcom.apple.mrj.application.apple.menu.about.name=Protege -Xdock:name=Protege -Xdock:icon=Protege.icns" sh run.sh $1
@@ -7,7 +7,7 @@ java -Xmx500M -Xms250M \
-DentityExpansionLimit=100000000 \ -DentityExpansionLimit=100000000 \
-Dfile.encoding=UTF-8 \ -Dfile.encoding=UTF-8 \
-classpath bin/org.apache.felix.main.jar:bin/ProtegeLauncher.jar \ -classpath bin/org.apache.felix.main.jar:bin/ProtegeLauncher.jar \
$CMD_OPTIONS org.protege.osgi.framework.Launcher $CMD_OPTIONS org.protege.osgi.framework.Launcher $1
+1 -1
Ver Arquivo
@@ -1,2 +1,2 @@
jre\bin\java -Dlog4j.configuration=file:log4j.xml -DentityExpansionLimit=100000000 -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bin/org.apache.felix.main.jar;bin/ProtegeLauncher.jar org.protege.osgi.framework.Launcher jre\bin\java -Dlog4j.configuration=file:log4j.xml -DentityExpansionLimit=100000000 -Dfile.encoding=utf-8 -Dorg.protege.plugin.dir=plugins -classpath bin/org.apache.felix.main.jar;bin/ProtegeLauncher.jar org.protege.osgi.framework.Launcher %1