Difference between revisions of "Protege4DevDocs"

From Protege Wiki
Jump to: navigation, search
(Protege 4 OWL editor in Eclipse)
 
(25 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<div class="orangeBox">
 
<div class="orangeBox">
 
<span class="orangeBoxTitle">Protege 4 Developer Documentation</span><br /><br />
 
<span class="orangeBoxTitle">Protege 4 Developer Documentation</span><br /><br />
Pointers for developers of plugins and understanding the core APIs of Protege 4.
+
Pointers for developers of plugins and understanding the core APIs of Protege 4. '''If you are interested in the Protege 5 Developer Documentation, please go to [[Protege5DevDocs|this page]].'''
 
</div><br /><br />
 
</div><br /><br />
  
Line 9: Line 9:
 
== Guidelines ==
 
== Guidelines ==
  
Protege 4.1 will be compatible with both Java 5 and Java 6.  Unfortunately we need to continue supporting Java 5 because of problems with Java on the older Apple platforms (the PowerPC and 32 bit Macs).  If you are writing a plugin and you want to be available on all OS X platforms, then you must use Java 5.  Otherwise Java 6 works as long  as you understand that you are  excluding a  subset of the Apple  platforms.
+
Protege 4.1 and higher will be compatible with both Java 5 and Java 6.  Unfortunately we need to continue supporting Java 5 because of problems with Java on the older Apple platforms (the PowerPC and 32 bit Macs).  If you are writing a plugin and you want to be available on all OS X platforms, then you must use Java 5.  Otherwise Java 6 works as long  as you understand that you are  excluding a  subset of the Apple  platforms.
  
 
'''Please consider writing any P4 code as a plugin'''.<br />
 
'''Please consider writing any P4 code as a plugin'''.<br />
 
If you cannot do this for various reasons, please let us
 
If you cannot do this for various reasons, please let us
 
know as we may be able to improve the core design in order to support you.<br />
 
know as we may be able to improve the core design in order to support you.<br />
Protege 4.0 has been written specifically to be modular. It uses '''equinox''', one implementation of an '''OSGi framework''' to allow
+
Protege 4.0 has been written specifically to be modular. It uses the [http://www.osgi.org/About/Technology '''OSGi framework'''] as a plugin infrastructure.
plugins to be created easily.
+
 
  
 
'''Please share.'''<br />
 
'''Please share.'''<br />
Line 26: Line 26:
  
  
=== Protege 4 OWL editor in Eclipse  ===
+
=== Protege 4 OWL editor in Eclipse or IntelliJ ===
  
* [[CompileProtege4InEclipseFromSvn|Setting up eclipse with Protege 4.1]] '''(Recommended for Protege 4.1)'''<br/>This page gives directions for compiling and running Protege 4.1 using Eclipse's plugin development framework.  It includes the OS X workaround  as well.
+
* [[CompileProtege4InEclipseFromSvn|Setting up eclipse with Protege 4.1 and higher]] '''(Recommended for Protege 4.1+)'''<br/>This page gives directions for compiling and running Protege 4.1 and higher using Eclipse's plugin development framework.  It includes the OS X workaround  as well.
* [[CompileProtege4InIntelliJFromSvn|Setting up IntelliJ IDEA with Protege 4.1]] '''(Recommended for Protege 4.1)'''<br/>This page gives directions for compiling and running Protege 4.1 using IDEA's Osmorc plug-in.
+
* [https://github.com/protegeproject/protege/wiki/Setup-in-Eclipse Setting up eclipse with Protege 4.1-5 using maven] ''' <br/>This page shows how to use maven for compiling and running Protege 4.1-5 using  Eclipse's plugin development framework. <br/>
 +
* [[CompileProtege4InIntelliJFromSvn|Setting up IntelliJ IDEA with Protege 4.1 and higher]] '''(Recommended for Protege 4.1+)'''<br/>This page gives directions for compiling and running Protege 4.1 and higher using IDEA's Osmorc plug-in.
  
=== Protege 4 OWL editor in a Generic IDE ===
+
=== Protege 4 OWL editor in a Other IDEs ===
  
This section describes how to set up an IDE for plugin development.  While we have used eclipse to illustrate these pages, we have tried to
+
There is no longer a page that describes how to set up an IDE other than eclipse or IntelliJ.  We welcome contributions from the community for directions on how to set up other developement environmentsIn particular NetBeans  seems to have a following and it would be useful to have a page describing how to set up for that IDE.
describe an approach that is generic and will work for all IDE platforms.  We welcome others to add pages above to describe how to get Protege 4 running in their favorite IDEWe describe this in two steps - first the core Protege sources are downloaded and compiled and then a plugin project is created. 
+
For an experienced Java developer, the [[#Building_Protege4.1_from_scratch_using_ant|ant build steps]] will probably provide enough hints to put together an arbitrary IDE environment for Protege 4.1 and higher.
 
 
* Downloading, compiling and running the core Protege sources.  The following links cover much the same ground.
 
** [[CompileProtege4InEclipseOneProject|Compile and run the Protege-OWL editor in a Generic IDE]] - this page gives directions for compiling Protege 4.0 sources in Eclipse where ''all bundles are encapsulated in one Eclipse project''.  These directions are specific to Protege 4.0 and are not applicable to Protege 4.1.  However the [[#Building_Protege4.1_from_scratch_using_ant|ant build steps]] will probably provide enough hints to put together a generic ide environment for Protege 4.1.
 
  
 
== Writing A Plugin ==
 
== Writing A Plugin ==
Line 58: Line 56:
 
Here is a summary of the main parts of the [[P4APIOverview|Protege 4 API]] for gaining access to the model and various utilities.  
 
Here is a summary of the main parts of the [[P4APIOverview|Protege 4 API]] for gaining access to the model and various utilities.  
  
Also see the [http://protege.stanford.edu/protege/4.0/docs/api/ javadoc for Protege 4.0 code].
+
Also see the [http://protege.stanford.edu/protege/4.1/docs/api/ javadoc for Protege 4.1 code].
  
 
=== UI components ===
 
=== UI components ===
Line 66: Line 64:
 
=== Updating to Protege 4.1 ===
 
=== Updating to Protege 4.1 ===
  
A short [[P4_1PortingGuide|guide]] to migrating plugins from Protege4.0 to Protege4.1 (in progress).
+
A short [[P4_1PortingGuide|guide]] to migrating plugins from Protege 4.0 to Protege 4.1 (in progress).
  
=== Building Protege4.1 from scratch using ant ===
+
=== Building Protege 4.1 and higher from scratch using Ant ===
  
The Protege 4.1 build process has been refactored since Protege 4.0.  This means that the locations of the various Protege 4.1 plugins is different than the corresponding locations in Protege 4.0.  There are several advantages of the new scheme:
+
The Protege 4.1 and higher build process has been refactored since Protege 4.0.  This means that the locations of the various Protege 4.1 and higher plug-ins are different than the corresponding locations in Protege 4.0.  There are several advantages of the new scheme:
* the build files are independent so that changes to one plugin can be propageted to the distribution by compiling just the plugin rather than the redoing an entire Protege build.
+
* the build files are independent so that changes to one plugin can be propagated to the distribution by compiling just the plugin rather than the redoing an entire Protege build.
 
* the build files autodetect the format of the protege distribution.  This means that a single build file for the os x application bundle (Protege.app) and a felix based distribution.
 
* the build files autodetect the format of the protege distribution.  This means that a single build file for the os x application bundle (Protege.app) and a felix based distribution.
 
* the new build process is much simpler allowing us to more easily update the various components.
 
* the new build process is much simpler allowing us to more easily update the various components.
Although many readers of this section will not be planning on doing an ant build, these directions clarify the location of the various Protege 4.1 plugins in svn.
+
Although many readers of this section will not be planning on doing an Ant build, these directions clarify the location of the various Protege 4.1 and higher plug-ins in svn.
 +
 
 +
A very quick build (40 seconds) can be done with the following steps:
 +
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/misc/composite/protege4/trunk protege4''
 +
# cd protege4
 +
# ant install
 +
# cd build/Protege
 +
# run protege (e.g. sh run.sh)
  
First  you must set the PROTEGE_HOME environment variable which is described [[ConfiguringAntBuildFiles|here]].  Then you can build Protege 4.1 by  following the following steps.
+
The manual steps are as follows.
 +
First  you must set the PROTEGE_HOME environment variable which is described [[ConfiguringAntBuildFiles|here]].  Then you can build Protege 4.1 and higher by  following the following steps.
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/protege-base/trunk protege-base''
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/protege-base/trunk protege-base''
 
# ''cd protege-base'' and ''ant install'' and ''cd ..''.  '''Warning:''' this step deletes the existing contents of ${PROTEGE_HOME}.
 
# ''cd protege-base'' and ''ant install'' and ''cd ..''.  '''Warning:''' this step deletes the existing contents of ${PROTEGE_HOME}.
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.common/trunk org.protege.common''
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.common/trunk org.protege.common''
 
# ''cd org.protege.common'' and ''ant install' and ''cd ..'''
 
# ''cd org.protege.common'' and ''ant install' and ''cd ..'''
 +
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.jaxb/trunk org.protege.jaxb''
 +
# ''cd org.protege.jaxb'' and ''ant install'' and ''cd ..''
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.editor.core.application/trunk org.protege.editor.core.application''
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.editor.core.application/trunk org.protege.editor.core.application''
 
# ''cd org.protege.editor.core.application'' and ''ant install'' and ''cd ..''
 
# ''cd org.protege.editor.core.application'' and ''ant install'' and ''cd ..''
Line 87: Line 95:
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.editor.owl/trunk org.protege.editor.owl''
 
# ''svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.editor.owl/trunk org.protege.editor.owl''
 
# ''cd org.protege.editor.owl'' and ''ant install'' and ''cd ..''
 
# ''cd org.protege.editor.owl'' and ''ant install'' and ''cd ..''
This will give a minimal installation and other  plugins can be added as desired.  Source plugins can be created by adding ''ant add.source'' before the ''ant install'' step.  A full run on an extremely slow machine is shown [[Protege41FullBuild|here]].
+
This will give a minimal installation and other  plugins can be added as desired.  In addition, protege-base comes with a run target that can be  used to run Protege and a debug target that can be used to debug Protege using java's remote debugging support.  Source plugins can be created by adding ''ant add.source'' before the ''ant install'' step.  A full run on an extremely slow machine is shown [[Protege41FullBuild|here]].
  
 
===Embedded OSGi===
 
===Embedded OSGi===
Line 95: Line 103:
 
===Database Backends===
 
===Database Backends===
  
There are now two database backends for the OWL API.  Very soon we expect to have a Protege plugin that enables both backend mechanisms.  We have put together a [[Loading A DatabaseProject|document]] describing how both database backends can be used with the owl api.
+
There are now three database backends for the OWL API.  Very soon we expect to have a Protege plugin that enables all three backend mechanisms.  We have put together a [[Loading A DatabaseProject|document]] describing how two of the database backends can be used with the owl api.
  
 
== Troubleshooting ==
 
== Troubleshooting ==
 
* [[SolvingClassLoaderProblems|Troubleshooting class loader issues]]
 
* [[SolvingClassLoaderProblems|Troubleshooting class loader issues]]
 
* [[DealingWithJava5CompilerIssues|Troubleshooting and fixing problems with the Java 5 compiler]]
 
* [[DealingWithJava5CompilerIssues|Troubleshooting and fixing problems with the Java 5 compiler]]

Latest revision as of 22:08, May 23, 2016

Protege 4 Developer Documentation

Pointers for developers of plugins and understanding the core APIs of Protege 4. If you are interested in the Protege 5 Developer Documentation, please go to this page.




Guidelines

Protege 4.1 and higher will be compatible with both Java 5 and Java 6. Unfortunately we need to continue supporting Java 5 because of problems with Java on the older Apple platforms (the PowerPC and 32 bit Macs). If you are writing a plugin and you want to be available on all OS X platforms, then you must use Java 5. Otherwise Java 6 works as long as you understand that you are excluding a subset of the Apple platforms.

Please consider writing any P4 code as a plugin.
If you cannot do this for various reasons, please let us know as we may be able to improve the core design in order to support you.
Protege 4.0 has been written specifically to be modular. It uses the OSGi framework as a plugin infrastructure.


Please share.
It is surprising how many people have written plugins for P4 that we just don't hear about.
If you wish to publish to the community, please see our notes on code contributions.

Using an Integrated Development Environment

Protege 4 OWL editor in Eclipse or IntelliJ

Protege 4 OWL editor in a Other IDEs

There is no longer a page that describes how to set up an IDE other than eclipse or IntelliJ. We welcome contributions from the community for directions on how to set up other developement environments. In particular NetBeans seems to have a following and it would be useful to have a page describing how to set up for that IDE. For an experienced Java developer, the ant build steps will probably provide enough hints to put together an arbitrary IDE environment for Protege 4.1 and higher.

Writing A Plugin

The following links are focussed on the problems of writing a plugin and are not focused on how your build environment should be configured. For information about configuring your build environment go to Using an IDE.

This page gives a quick start to writing a plugin for Protege 4. It starts with a guide to writing the empty (trivial) plugin in five minutes. Then it describes how some additional content can be added to the plugin.

Additional Information

In addition to this there are some other useful sources on plugin development:

  • plugin types provides a list of plugin types that you can implement in Protege 4.
  • Once you have written a plugin you want people to use it. Some very simple steps allow you to advertise your plugin and enable auto-update.
  • A short guide to writing a plug-in to show the class hierarchy. This page is not supported by the Protege team and may indeed not be actively updated any more. It has some very useful information but will quite likely slowly go out of date.

Misc

Protege APIs

Here is a summary of the main parts of the Protege 4 API for gaining access to the model and various utilities.

Also see the javadoc for Protege 4.1 code.

UI components

The Protege core and the OWL editor kit both provide a large number of reuseable components and utilities for generating user interfaces for ontologies.

Updating to Protege 4.1

A short guide to migrating plugins from Protege 4.0 to Protege 4.1 (in progress).

Building Protege 4.1 and higher from scratch using Ant

The Protege 4.1 and higher build process has been refactored since Protege 4.0. This means that the locations of the various Protege 4.1 and higher plug-ins are different than the corresponding locations in Protege 4.0. There are several advantages of the new scheme:

  • the build files are independent so that changes to one plugin can be propagated to the distribution by compiling just the plugin rather than the redoing an entire Protege build.
  • the build files autodetect the format of the protege distribution. This means that a single build file for the os x application bundle (Protege.app) and a felix based distribution.
  • the new build process is much simpler allowing us to more easily update the various components.

Although many readers of this section will not be planning on doing an Ant build, these directions clarify the location of the various Protege 4.1 and higher plug-ins in svn.

A very quick build (40 seconds) can be done with the following steps:

  1. svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/misc/composite/protege4/trunk protege4
  2. cd protege4
  3. ant install
  4. cd build/Protege
  5. run protege (e.g. sh run.sh)

The manual steps are as follows. First you must set the PROTEGE_HOME environment variable which is described here. Then you can build Protege 4.1 and higher by following the following steps.

  1. svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/protege-base/trunk protege-base
  2. cd protege-base and ant install and cd ... Warning: this step deletes the existing contents of ${PROTEGE_HOME}.
  3. svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.common/trunk org.protege.common
  4. cd org.protege.common and ant install' and cd ..
  5. svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.jaxb/trunk org.protege.jaxb
  6. cd org.protege.jaxb and ant install and cd ..
  7. svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.editor.core.application/trunk org.protege.editor.core.application
  8. cd org.protege.editor.core.application and ant install and cd ..
  9. svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.semanticweb.owl.owlapi/trunk org.semanticweb.owl.owlapi
  10. cd org.semanticweb.owl.owlapi and ant install and cd ..
  11. svn checkout http://smi-protege.stanford.edu/repos/protege/protege4/plugins/org.protege.editor.owl/trunk org.protege.editor.owl
  12. cd org.protege.editor.owl and ant install and cd ..

This will give a minimal installation and other plugins can be added as desired. In addition, protege-base comes with a run target that can be used to run Protege and a debug target that can be used to debug Protege using java's remote debugging support. Source plugins can be created by adding ant add.source before the ant install step. A full run on an extremely slow machine is shown here.

Embedded OSGi

For people embedding Protege 4 services inside a non-OSGi based applications here is a short example showing how this can work.

Database Backends

There are now three database backends for the OWL API. Very soon we expect to have a Protege plugin that enables all three backend mechanisms. We have put together a document describing how two of the database backends can be used with the owl api.

Troubleshooting