Integration of a plug-in in the editor Protege version 3.4.1

classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Jennifer Vendetti
Administrator
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer


On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Timothy Redmond
On 04/05/2011 10:10 PM, chab nasri wrote:
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

What is giving you trouble?   If you are working with OWL I figure that your first challenge would be writing a simple OWL api based program.  I noticed that the programmers owl api documentation started with a relatively simple "hello world" example application:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

There are also examples of simple plugins at [2].

-Timothy

[1] http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide
[2] http://protege.stanford.edu/doc/pdk/plugins/overview.html


Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri

Hello,

I read the examples but I did not understand.
- For me what kind of plugin to choose from the six types of plug-ins :Tab widget or Slot widget or Back-end or Createproject or Export Project ?
- Can you tell me simplify,
for example through screenshots, the steps listed in the following link:
http://protege.stanford.edu/doc/pdk/plugins/overview.html

Thanks.

2011/4/8 Timothy Redmond <[hidden email]>
On 04/05/2011 10:10 PM, chab nasri wrote:
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

What is giving you trouble?   If you are working with OWL I figure that your first challenge would be writing a simple OWL api based program.  I noticed that the programmers owl api documentation started with a relatively simple "hello world" example application:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

There are also examples of simple plugins at [2].

-Timothy

[1] http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide
[2] http://protege.stanford.edu/doc/pdk/plugins/overview.html


Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Timothy Redmond
On 04/14/2011 10:47 PM, chab nasri wrote:

Hello,

I read the examples but I did not understand.
- For me what kind of plugin to choose from the six types of plug-ins :Tab widget or Slot widget or Back-end or Createproject or Export Project ?

It depends on what you are trying to do.  From what we have discussed so far I am not even sure if you are trying to write a plugin.

- Can you tell me simplify, for example through screenshots, the steps listed in the following link:
http://protege.stanford.edu/doc/pdk/plugins/overview.html

It would be easier to advise if I had some idea of the goal.

-Timothy



Thanks.

2011/4/8 Timothy Redmond <[hidden email]>
On 04/05/2011 10:10 PM, chab nasri wrote:
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

What is giving you trouble?   If you are working with OWL I figure that your first challenge would be writing a simple OWL api based program.  I noticed that the programmers owl api documentation started with a relatively simple "hello world" example application:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

There are also examples of simple plugins at [2].

-Timothy

[1] http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide
[2] http://protege.stanford.edu/doc/pdk/plugins/overview.html


Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03




_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
I tried but I did not understand. For now, I have to make a plugin in Eclipse (for example a small test code that shows the name of current ontology) and add this plugin to the tool "Protégé".

2011/4/15 Timothy Redmond <[hidden email]>
On 04/14/2011 10:47 PM, chab nasri wrote:

Hello,

I read the examples but I did not understand.
- For me what kind of plugin to choose from the six types of plug-ins :Tab widget or Slot widget or Back-end or Createproject or Export Project ?

It depends on what you are trying to do.  From what we have discussed so far I am not even sure if you are trying to write a plugin.


- Can you tell me simplify, for example through screenshots, the steps listed in the following link:
http://protege.stanford.edu/doc/pdk/plugins/overview.html

It would be easier to advise if I had some idea of the goal.

-Timothy




Thanks.

2011/4/8 Timothy Redmond <[hidden email]>
On 04/05/2011 10:10 PM, chab nasri wrote:
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

What is giving you trouble?   If you are working with OWL I figure that your first challenge would be writing a simple OWL api based program.  I noticed that the programmers owl api documentation started with a relatively simple "hello world" example application:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

There are also examples of simple plugins at [2].

-Timothy

[1] http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide
[2] http://protege.stanford.edu/doc/pdk/plugins/overview.html


Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03





_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Timothy Redmond
On 04/14/2011 11:06 PM, chab nasri wrote:
I tried but I did not understand. For now, I have to make a plugin in Eclipse (for example a small test code that shows the name of current ontology) and add this plugin to the tool "Protégé".

A tab widget [1] will work for this.  [1] comes with a link to download some code [2] - the frame counter in particular.  The abstract tab widget is a swing container so - if you know swing [3] - you will know how to display arbitrary text.  The only thing that you need on top of this is that you can get the readable name of the ontology (for an OWL ontology) with the call


    ((OWLModel) getKnowledgeBase()).getDefaultOntology().getBrowserText();

-Timothy

[1] http://protege.stanford.edu/doc/pdk/plugins/tab_widget.html
[2] http://protege.stanford.edu/doc/pdk/plugins/plugin-examples-src.zip
[3] http://download.oracle.com/javase/tutorial/uiswing/

2011/4/15 Timothy Redmond <[hidden email]>
On 04/14/2011 10:47 PM, chab nasri wrote:

Hello,

I read the examples but I did not understand.
- For me what kind of plugin to choose from the six types of plug-ins :Tab widget or Slot widget or Back-end or Createproject or Export Project ?

It depends on what you are trying to do.  From what we have discussed so far I am not even sure if you are trying to write a plugin.


- Can you tell me simplify, for example through screenshots, the steps listed in the following link:
http://protege.stanford.edu/doc/pdk/plugins/overview.html

It would be easier to advise if I had some idea of the goal.

-Timothy




Thanks.

2011/4/8 Timothy Redmond <[hidden email]>
On 04/05/2011 10:10 PM, chab nasri wrote:
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

What is giving you trouble?   If you are working with OWL I figure that your first challenge would be writing a simple OWL api based program.  I noticed that the programmers owl api documentation started with a relatively simple "hello world" example application:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

There are also examples of simple plugins at [2].

-Timothy

[1] http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide
[2] http://protege.stanford.edu/doc/pdk/plugins/overview.html


Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03






_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Tania Tudorache
In reply to this post by chab nasri
Hi Chabnasri,

Please upgrade to the latest version of Protege 3.4.5.

To develop code in Eclipse, please follow the step-by-step guide from here: http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

To find out more about the Protege-OWL API, please look at this guide: http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide

Tania

On 04/14/2011 11:06 PM, chab nasri wrote:
I tried but I did not understand. For now, I have to make a plugin in Eclipse (for example a small test code that shows the name of current ontology) and add this plugin to the tool "Protégé".

2011/4/15 Timothy Redmond <[hidden email]>
On 04/14/2011 10:47 PM, chab nasri wrote:

Hello,

I read the examples but I did not understand.
- For me what kind of plugin to choose from the six types of plug-ins :Tab widget or Slot widget or Back-end or Createproject or Export Project ?

It depends on what you are trying to do.  From what we have discussed so far I am not even sure if you are trying to write a plugin.


- Can you tell me simplify, for example through screenshots, the steps listed in the following link:
http://protege.stanford.edu/doc/pdk/plugins/overview.html

It would be easier to advise if I had some idea of the goal.

-Timothy




Thanks.

2011/4/8 Timothy Redmond <[hidden email]>
On 04/05/2011 10:10 PM, chab nasri wrote:
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

What is giving you trouble?   If you are working with OWL I figure that your first challenge would be writing a simple OWL api based program.  I noticed that the programmers owl api documentation started with a relatively simple "hello world" example application:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

There are also examples of simple plugins at [2].

-Timothy

[1] http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide
[2] http://protege.stanford.edu/doc/pdk/plugins/overview.html


Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03




_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Bonjour,

Merci beaucoup pour vos aides.
J'ai besoin de vos aides concernant les deux parties suivantes:

1)
J'ai fait un petit exemple de test "Hello World" sous eclipse comme il est indiqué dans le guide.
Je voulais modifier cet exemple de façon qu'il affiche le nom d'ontologie courante. Voici le code source:
"
package mytab;

import javax.swing.JLabel;

import edu.stanford.smi.protege.widget.AbstractTabWidget;
//import edu.stanford.smi.protegex.owl.model.OWLModel;

public class HelloWorldTab extends AbstractTabWidget {

    public void initialize() {
        setLabel("Hello World Tab");
        add(new JLabel("Hello World!"));
 
    }

    public static void main(String[] args) {
        edu.stanford.smi.protege.Application.main(args);
    }
   
}

"

- Quelles sont les modifications à faire sur ce code pour qu'il affiche le nom d'ontologie courante ?

2)
J'ai exporté le code cité au dessus comme un fichier JAR appelé "HelloWorldTab.jar". J'ai crée sous le répertoire plugin  dans le répertoire d'installation du protégé C:\Program Files\Protege_3.4.1\plugins un dossier appelé "mytab" dans lequel j'ai mis "HelloWorldTab.jar".

Je remarque lorsque j'exécute l'exemple de test "Hello World" à partir d'Eclipse alors il me lance la fenêtre de Protégé en m'indiquant de créer un nouveau projet ou d'ouvrir un projet existant. Dans les deux cas, je trouve mon nouveau plugin crée appelé  "HelloWorldTab" figurant dans a liste des plugins. Je coche "HelloWorldTab" pour être visible dans le projet.
Sachant que il a deux façons de rendre le plugin "HelloWorldTab" visible en accédant au :
Menu OWL --> Preferences --> sous l'onglet "Tabs" je coche le plugin "HelloWorldTab"
ou bien
Menu Project --> Configure--> sous l'onglet "Tab Widget" je coche le plugin "HelloWorldTab"

- Mais je ne sais pas laquelle de ces deux façons est juste pour rendre un plugin visible dans le projet ?

J'enregistre le projet et je ferme  Protégé et Eclispse.

Mais, lorsque je lance le protégé de nouveau et je ouvre le projet crée avant ou un autre projet alors je ne trouve pas le plugin "HelloWorldTab" parmi liste des plugins.

- Comment faire pour que le plugin "HelloWorldTab" soit figuré dans la liste des plugins une fois pour tout.
- Est ce que à chaque fois je dois lancer mon programe sous Eclipse ?
- Est ce que Protégé ne tient pas compte des nouveaux plugins crées ?

Bien Cordialement,
Chabnasri


2011/4/20 Tania Tudorache <[hidden email]>
Hi Chabnasri,

Please upgrade to the latest version of Protege 3.4.5.

To develop code in Eclipse, please follow the step-by-step guide from here: http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

To find out more about the Protege-OWL API, please look at this guide: http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide

Tania

On 04/14/2011 11:06 PM, chab nasri wrote:
I tried but I did not understand. For now, I have to make a plugin in Eclipse (for example a small test code that shows the name of current ontology) and add this plugin to the tool "Protégé".

2011/4/15 Timothy Redmond <[hidden email]>
On 04/14/2011 10:47 PM, chab nasri wrote:

Hello,

I read the examples but I did not understand.
- For me what kind of plugin to choose from the six types of plug-ins :Tab widget or Slot widget or Back-end or Createproject or Export Project ?

It depends on what you are trying to do.  From what we have discussed so far I am not even sure if you are trying to write a plugin.


- Can you tell me simplify, for example through screenshots, the steps listed in the following link:
http://protege.stanford.edu/doc/pdk/plugins/overview.html

It would be easier to advise if I had some idea of the goal.

-Timothy




Thanks.

2011/4/8 Timothy Redmond <[hidden email]>
On 04/05/2011 10:10 PM, chab nasri wrote:
Hello,

I read the documentaion but I do not how to create and integrate a plug-in tool Protege 3.4.1.
Please I am asking you to detail the steps of creating and integrating a plugin even on a small example.

What is giving you trouble?   If you are working with OWL I figure that your first challenge would be writing a simple OWL api based program.  I noticed that the programmers owl api documentation started with a relatively simple "hello world" example application:

package com.demo.application;

import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class OWLAPIDemoApplication {

    public static void main(String[] args) {
        OWLModel owlModel = ProtegeOWL.createJenaOWLModel();
        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");
        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");
        System.out.println("Class URI: " + worldClass.getURI());
    }
}

There are also examples of simple plugins at [2].

-Timothy

[1] http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide
[2] http://protege.stanford.edu/doc/pdk/plugins/overview.html


Thank you
.

2011/3/31 Jennifer Vendetti <[hidden email]>
There's documentation on the Protege website:

http://protege.stanford.edu/doc/dev.html

... and wiki:

http://protegewiki.stanford.edu/wiki/Protege3DevDocs#Plug-in_Development

... for developing plug-ins for the Protege 3.x series.

Jennifer



On 3/31/2011 11:29 AM, chab nasri wrote:
Hello,

How we integrate a plug-in in the editor Protege version 3.4.1?

Thank you.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03




_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Hello,

I created a project called "DisplayNameTab"to display the name of current ontology.
The source code of this project :

package myTab;

import javax.swing.JLabel;

import edu.stanford.smi.protegex.owl.ui.widget.AbstractTabWidget;

public class DisplayNameTab extends AbstractTabWidget {

    @Override
    public void initialize() {
        setLabel("Display Name Tab");
        add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));

    }
    public static void main(String[] args) {
        edu.stanford.smi.protege.Application.main(args);
    }
}

Here are the contents of the file "MANIFEST.MF".

Manifest-Version: 1.0

Name: myTab.DisplayNameTab.class
Tab-Widget: True

I have checked the steps to create and configure the project based on the following site:
http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

I created under the installation directory of the protected C: \ Program Files \ Protege_3.4.1 \ plugins a new directory named "myTabs"in which I exported the project as a file. This file is named "DisplayNameTab.jar".

After running the program will launch and then protected I have a new menu by clicking on this menu we will display the name of current ontology.
But when I close Eclipse and I run protected again so I can not find the plugin DisplayNameTab "among a list of plugins.


Here is the message that appears in the console after running the program:
Protege 3.4.1 Build 537, JVM 1.6.0_20-b02, memory=259M, Windows XP, encoding=UTF-8, language=fr, country=FR
Loaded plugin edu.stanford.smi.protegex.owl - OWL Plugin
Loaded plugin ca.uvic.cs.chisel.jambalaya - Jambalaya
Loaded plugin dfki.protege.ontoviz
Loaded plugin edu.stanford.smi.protegex.rdf_backend - RDF Backend
Loaded plugin edu.stanford.smi.protegex.changes - Changes tab
Loaded plugin edu.stanford.smi.protegex.standard_extensions - Graph Widget, Table Widget
Loaded plugin edu.stanford.smi.protegex.chatPlugin - Chat
Loaded plugin edu.stanford.smi.protege.collab - Collaborative Protege
Loaded plugin edu.stanford.smi.protege.script - Script Plugin
Loaded plugin edu.stanford.smi.protege.stringsearch - String Search Tab
Loaded plugin edu.stanford.smi.protegex.datamaster - DataMaster Tab
Loaded plugin edu.stanford.smi.protegex.pal_tabs - PAL Tabs
Loaded plugin edu.stanford.smi.protegex.ezpal - EZPal Tab
Loaded plugin edu.stanford.smi.protegex.facets_tab
Loaded plugin edu.stanford.smi.protegex.instance_tree
Loaded plugin edu.stanford.smi.protegex.prompt - PROMPT Tab
Loaded plugin edu.stanford.smi.protegex.metaanalysis - MetaAnalysis Tab
Loaded plugin edu.stanford.smi.protegex.owl.inference.pellet - Protege Pellet Reasoner
Loaded plugin edu.stanford.smi.protegex.umls_tab - UMLS Tab
Loaded plugin edu.stanford.smi.protegex.wordnet - WordNet Tab
Loaded plugin edu.stanford.smi.protegex.xml_tab - XML Tab
Loaded plugin myTab
WARNING: Duplicate plugin: myTab.DisplayNameTab -- PluginUtilities.checkPlugin()
Loaded plugin mytab0
Loaded plugin org.algernon - Algernon
Loaded plugin se.liu.ida.JessTab - JessTab Plugin
Loaded plugin uk.ac.iam.soton.akt.tgviztab - TGVizTab
Loaded plugin uk.ac.man.cs.mig.coode.debugger
Loaded plugin uk.ac.man.cs.mig.coode.manchesterowlsyntaxeditor
Loaded plugin uk.ac.man.cs.mig.coode.owldoc
Loaded plugin uk.ac.man.cs.mig.coode.owlindividualstab
Loaded plugin uk.ac.man.cs.mig.coode.owlviz
Loaded plugin uk.ac.man.cs.mig.coode.protege.wizard - Basic Wizards
Loaded plugin uk.ac.man.cs.mig.coode.protege.wizard.owl - OWL Wizards
Loading triples from: file:/C:/Program%20Files/Protege_3.4.1/testDisplay.owl
    Completed triple loading after 250 ms
Postprocess: Process entities with incorrect Java type (0 entities) ... 0 ms
Postprocess: Process metaclasses (3 metaclasses) ... 0 ms
Postprocess: Process subclasses of rdf:List (1 classes) ... 0 ms
Postprocess: Instances with multiple types (0 instances) ... 0 ms
Postprocess: Add inferred superclasses ... 0 ms
Postprocess: Process orphan classes (0 classes) ... 0 ms
Postprocess: Generalized Concept Inclusion (0 axioms) ... 0 ms
Postprocess: Abstract classes... 15 ms
Postprocess: Domain and range of properties... 0 ms
Postprocess: Possibly typed entities (0 resources) ... 0 ms
Updating underlying frames model in 0 ms
Protege Wizards v1.0 beta build 15
Loaded OWL wizards library
Load time for file:\C:\Program%20Files\Protege_3.4.1\testDisplay.pprj = 2 sec (project) + 5 sec (ui)

When
I run the program I only following warning:

-Description :  The serializable class DisplayNameTab does not declare a static final serialVersionUID field of type long
-Resource :  DisplayNameTab.java
-Path:  DisplayNameTab/src/myTab 
-Location: line 7
-Type:  Java Problem


Here are the contents of my file "plugin.properties" :

plugin.component.count=1
plugin.component.name.0=DisplayNameTab Tab
plugin.dependency.count=1
plugin.dependency.0=edu.stanford.smi.protegex.owl

I do not know is that content is correct or not ?
why we add this file ?
It is necessary to add the file "plugin.properties" such as that my plugin does not depend on other plugins ?

But, I have the same problem when I run Protégé I can not find my plugin "DisplayNameTab" among the list of existing plugin.

I inform you that I made a simple export my project into a jar file named "DisplayNameTab" without any additional configuration as described in the following link :
http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

Are there any other configuration to do in my project and which are not shown in this link ?

Thanks.


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Thomas Russ

On May 3, 2011, at 1:37 AM, chab nasri wrote:

> Hello,
>
> I created a project called "DisplayNameTab"to display the name of  
> current ontology.
> The source code of this project :
> package myTab;
>
> import javax.swing.JLabel;
>
> import edu.stanford.smi.protegex.owl.ui.widget.AbstractTabWidget;
>
> public class DisplayNameTab extends AbstractTabWidget {
>
>     @Override
>     public void initialize() {
>         setLabel("Display Name Tab");
>         add(new  
> JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));
>
>     }
>     public static void main(String[] args) {
>         edu.stanford.smi.protege.Application.main(args);
>     }
> }

You also need to implement the isSuitable method, perhaps something  
like this:

   public static boolean isSuitable(Project project, Collection  
errors) {
     if (project.getKnowledgeBase() instanceof OWLModel) {
       return true;
     } else {
       errors.add("The " + TAB_NAME + " tab only works with OWL  
models.");
       return false;
     }
   }


>
> Here are the contents of the file "MANIFEST.MF".
>
> Manifest-Version: 1.0
>
> Name: myTab.DisplayNameTab.class
> Tab-Widget: True
>
> I have checked the steps to create and configure the project based  
> on the following site:
> http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin
>
> I created under the installation directory of the protected C: \  
> Program Files \ Protege_3.4.1 \ plugins a new directory named  
> "myTabs"in which I exported the project as a file. This file is  
> named "DisplayNameTab.jar".
>
> After running the program will launch and then protected I have a  
> new menu by clicking on this menu we will display the name of  
> current ontology.
> But when I close Eclipse and I run protected again so I can not find  
> the plugin DisplayNameTab "among a list of plugins.
>
>
> Here is the message that appears in the console after running the  
> program:
> Protege 3.4.1 Build 537, JVM 1.6.0_20-b02, memory=259M, Windows XP,  
> encoding=UTF-8, language=fr, country=FR
> Loaded plugin edu.stanford.smi.protegex.owl - OWL Plugin
> Loaded plugin ca.uvic.cs.chisel.jambalaya - Jambalaya
> Loaded plugin dfki.protege.ontoviz
> Loaded plugin edu.stanford.smi.protegex.rdf_backend - RDF Backend
> Loaded plugin edu.stanford.smi.protegex.changes - Changes tab
> Loaded plugin edu.stanford.smi.protegex.standard_extensions - Graph  
> Widget, Table Widget
> Loaded plugin edu.stanford.smi.protegex.chatPlugin - Chat
> Loaded plugin edu.stanford.smi.protege.collab - Collaborative Protege
> Loaded plugin edu.stanford.smi.protege.script - Script Plugin
> Loaded plugin edu.stanford.smi.protege.stringsearch - String Search  
> Tab
> Loaded plugin edu.stanford.smi.protegex.datamaster - DataMaster Tab
> Loaded plugin edu.stanford.smi.protegex.pal_tabs - PAL Tabs
> Loaded plugin edu.stanford.smi.protegex.ezpal - EZPal Tab
> Loaded plugin edu.stanford.smi.protegex.facets_tab
> Loaded plugin edu.stanford.smi.protegex.instance_tree
> Loaded plugin edu.stanford.smi.protegex.prompt - PROMPT Tab
> Loaded plugin edu.stanford.smi.protegex.metaanalysis - MetaAnalysis  
> Tab
> Loaded plugin edu.stanford.smi.protegex.owl.inference.pellet -  
> Protege Pellet Reasoner
> Loaded plugin edu.stanford.smi.protegex.umls_tab - UMLS Tab
> Loaded plugin edu.stanford.smi.protegex.wordnet - WordNet Tab
> Loaded plugin edu.stanford.smi.protegex.xml_tab - XML Tab
> Loaded plugin myTab
> WARNING: Duplicate plugin: myTab.DisplayNameTab --  
> PluginUtilities.checkPlugin()
> Loaded plugin mytab0
> Loaded plugin org.algernon - Algernon
> Loaded plugin se.liu.ida.JessTab - JessTab Plugin
> Loaded plugin uk.ac.iam.soton.akt.tgviztab - TGVizTab
> Loaded plugin uk.ac.man.cs.mig.coode.debugger
> Loaded plugin uk.ac.man.cs.mig.coode.manchesterowlsyntaxeditor
> Loaded plugin uk.ac.man.cs.mig.coode.owldoc
> Loaded plugin uk.ac.man.cs.mig.coode.owlindividualstab
> Loaded plugin uk.ac.man.cs.mig.coode.owlviz
> Loaded plugin uk.ac.man.cs.mig.coode.protege.wizard - Basic Wizards
> Loaded plugin uk.ac.man.cs.mig.coode.protege.wizard.owl - OWL Wizards
> Loading triples from: file:/C:/Program%20Files/Protege_3.4.1/
> testDisplay.owl
>     Completed triple loading after 250 ms
> Postprocess: Process entities with incorrect Java type (0  
> entities) ... 0 ms
> Postprocess: Process metaclasses (3 metaclasses) ... 0 ms
> Postprocess: Process subclasses of rdf:List (1 classes) ... 0 ms
> Postprocess: Instances with multiple types (0 instances) ... 0 ms
> Postprocess: Add inferred superclasses ... 0 ms
> Postprocess: Process orphan classes (0 classes) ... 0 ms
> Postprocess: Generalized Concept Inclusion (0 axioms) ... 0 ms
> Postprocess: Abstract classes... 15 ms
> Postprocess: Domain and range of properties... 0 ms
> Postprocess: Possibly typed entities (0 resources) ... 0 ms
> Updating underlying frames model in 0 ms
> Protege Wizards v1.0 beta build 15
> Loaded OWL wizards library
> Load time for file:\C:\Program%20Files
> \Protege_3.4.1\testDisplay.pprj = 2 sec (project) + 5 sec (ui)
>
> When I run the program I only following warning:
> -Description :  The serializable class DisplayNameTab does not  
> declare a static final serialVersionUID field of type long
> -Resource :  DisplayNameTab.java
> -Path:  DisplayNameTab/src/myTab
> -Location: line 7
> -Type:  Java Problem
>
>
> Here are the contents of my file "plugin.properties" :
>
> plugin.component.count=1
> plugin.component.name.0=DisplayNameTab Tab
> plugin.dependency.count=1
> plugin.dependency.0=edu.stanford.smi.protegex.owl
>
> I do not know is that content is correct or not ?
> why we add this file ?
> It is necessary to add the file "plugin.properties" such as that my  
> plugin does not depend on other plugins ?
>
> But, I have the same problem when I run Protégé I can not find my  
> plugin "DisplayNameTab" among the list of existing plugin.
>
> I inform you that I made a simple export my project into a jar file  
> named "DisplayNameTab" without any additional configuration as  
> described in the following link :
> http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin
>
> Are there any other configuration to do in my project and which are  
> not shown in this link ?
>
> Thanks.
>
> _______________________________________________
> protege-owl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Hello,

You say:
"I'm wondering if you did the extra step in the Protege user interface of going to Project | Configure... and enabling your tab by checking the DisplayNameTab box on the Tab Widgets tab?
"
I did but the same problem persists: when I run Protégé I can not find my plugin "DisplayNameTab" among the list of existing plugin.
I remember when I export my project as a jar file so I have the following message at the end:
"JAR export finished  with warning. See datails for additional information.
Exported with compile warnings"

- While my plugin dont appear in the list of plugins ?

You say:
"You also need to implement the isSuitable method, perhaps something like this:

 public static boolean isSuitable(Project project, Collection errors) {
   if (project.getKnowledgeBase() instanceof OWLModel) {
     return true;
   } else {
     errors.add("The " + TAB_NAME + " tab only works with OWL models.");
     return false;
   }
 }
"
- What is this method ?

- I used this method as it is ? exactly where I put it in my program ?

This is my program :
"   
package myTab;

    import javax.swing.JLabel;

    import edu.stanford.smi.protegex.owl.ui.widget.AbstractTabWidget;

    public class DisplayNameTab extends AbstractTabWidget {

       @Override
       public void initialize() {
           setLabel("Display Name Tab");
           add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));

       }
       public static void main(String[] args) {
           edu.stanford.smi.protege.Application.main(args);
       }
    }
"

I wanted to make a graphical user interface (labels, text boxes and a button) through which user enter the number of nodes, number of leaves, the number of ontology building etc. and when he clicks on the create button then it will create files (*. owl) and each file contains a description of the ontology created.

- What changes to make in my program ?


Thanks.

2011/5/3 Thomas Russ <[hidden email]>

On May 3, 2011, at 1:37 AM, chab nasri wrote:

Hello,

I created a project called "DisplayNameTab"to display the name of current ontology.
The source code of this project :
package myTab;

import javax.swing.JLabel;

import edu.stanford.smi.protegex.owl.ui.widget.AbstractTabWidget;

public class DisplayNameTab extends AbstractTabWidget {

   @Override
   public void initialize() {
       setLabel("Display Name Tab");
       add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));

   }
   public static void main(String[] args) {
       edu.stanford.smi.protege.Application.main(args);
   }
}

You also need to implement the isSuitable method, perhaps something like this:

 public static boolean isSuitable(Project project, Collection errors) {
   if (project.getKnowledgeBase() instanceof OWLModel) {
     return true;
   } else {
     errors.add("The " + TAB_NAME + " tab only works with OWL models.");
     return false;
   }
 }



Here are the contents of the file "MANIFEST.MF".

Manifest-Version: 1.0

Name: myTab.DisplayNameTab.class
Tab-Widget: True

I have checked the steps to create and configure the project based on the following site:
http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

I created under the installation directory of the protected C: \ Program Files \ Protege_3.4.1 \ plugins a new directory named "myTabs"in which I exported the project as a file. This file is named "DisplayNameTab.jar".

After running the program will launch and then protected I have a new menu by clicking on this menu we will display the name of current ontology.
But when I close Eclipse and I run protected again so I can not find the plugin DisplayNameTab "among a list of plugins.


Here is the message that appears in the console after running the program:
Protege 3.4.1 Build 537, JVM 1.6.0_20-b02, memory=259M, Windows XP, encoding=UTF-8, language=fr, country=FR
Loaded plugin edu.stanford.smi.protegex.owl - OWL Plugin
Loaded plugin ca.uvic.cs.chisel.jambalaya - Jambalaya
Loaded plugin dfki.protege.ontoviz
Loaded plugin edu.stanford.smi.protegex.rdf_backend - RDF Backend
Loaded plugin edu.stanford.smi.protegex.changes - Changes tab
Loaded plugin edu.stanford.smi.protegex.standard_extensions - Graph Widget, Table Widget
Loaded plugin edu.stanford.smi.protegex.chatPlugin - Chat
Loaded plugin edu.stanford.smi.protege.collab - Collaborative Protege
Loaded plugin edu.stanford.smi.protege.script - Script Plugin
Loaded plugin edu.stanford.smi.protege.stringsearch - String Search Tab
Loaded plugin edu.stanford.smi.protegex.datamaster - DataMaster Tab
Loaded plugin edu.stanford.smi.protegex.pal_tabs - PAL Tabs
Loaded plugin edu.stanford.smi.protegex.ezpal - EZPal Tab
Loaded plugin edu.stanford.smi.protegex.facets_tab
Loaded plugin edu.stanford.smi.protegex.instance_tree
Loaded plugin edu.stanford.smi.protegex.prompt - PROMPT Tab
Loaded plugin edu.stanford.smi.protegex.metaanalysis - MetaAnalysis Tab
Loaded plugin edu.stanford.smi.protegex.owl.inference.pellet - Protege Pellet Reasoner
Loaded plugin edu.stanford.smi.protegex.umls_tab - UMLS Tab
Loaded plugin edu.stanford.smi.protegex.wordnet - WordNet Tab
Loaded plugin edu.stanford.smi.protegex.xml_tab - XML Tab
Loaded plugin myTab
WARNING: Duplicate plugin: myTab.DisplayNameTab -- PluginUtilities.checkPlugin()
Loaded plugin mytab0
Loaded plugin org.algernon - Algernon
Loaded plugin se.liu.ida.JessTab - JessTab Plugin
Loaded plugin uk.ac.iam.soton.akt.tgviztab - TGVizTab
Loaded plugin uk.ac.man.cs.mig.coode.debugger
Loaded plugin uk.ac.man.cs.mig.coode.manchesterowlsyntaxeditor
Loaded plugin uk.ac.man.cs.mig.coode.owldoc
Loaded plugin uk.ac.man.cs.mig.coode.owlindividualstab
Loaded plugin uk.ac.man.cs.mig.coode.owlviz
Loaded plugin uk.ac.man.cs.mig.coode.protege.wizard - Basic Wizards
Loaded plugin uk.ac.man.cs.mig.coode.protege.wizard.owl - OWL Wizards
Loading triples from: file:/C:/Program%20Files/Protege_3.4.1/testDisplay.owl
   Completed triple loading after 250 ms
Postprocess: Process entities with incorrect Java type (0 entities) ... 0 ms
Postprocess: Process metaclasses (3 metaclasses) ... 0 ms
Postprocess: Process subclasses of rdf:List (1 classes) ... 0 ms
Postprocess: Instances with multiple types (0 instances) ... 0 ms
Postprocess: Add inferred superclasses ... 0 ms
Postprocess: Process orphan classes (0 classes) ... 0 ms
Postprocess: Generalized Concept Inclusion (0 axioms) ... 0 ms
Postprocess: Abstract classes... 15 ms
Postprocess: Domain and range of properties... 0 ms
Postprocess: Possibly typed entities (0 resources) ... 0 ms
Updating underlying frames model in 0 ms
Protege Wizards v1.0 beta build 15
Loaded OWL wizards library
Load time for file:\C:\Program%20Files\Protege_3.4.1\testDisplay.pprj = 2 sec (project) + 5 sec (ui)

When I run the program I only following warning:
-Description :  The serializable class DisplayNameTab does not declare a static final serialVersionUID field of type long
-Resource :  DisplayNameTab.java
-Path:  DisplayNameTab/src/myTab
-Location: line 7
-Type:  Java Problem


Here are the contents of my file "plugin.properties" :

plugin.component.count=1
plugin.component.name.0=DisplayNameTab Tab
plugin.dependency.count=1
plugin.dependency.0=edu.stanford.smi.protegex.owl

I do not know is that content is correct or not ?
why we add this file ?
It is necessary to add the file "plugin.properties" such as that my plugin does not depend on other plugins ?

But, I have the same problem when I run Protégé I can not find my plugin "DisplayNameTab" among the list of existing plugin.

I inform you that I made a simple export my project into a jar file named "DisplayNameTab" without any additional configuration as described in the following link :
http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

Are there any other configuration to do in my project and which are not shown in this link ?

Thanks.

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Jennifer Vendetti
Administrator
On 5/10/2011 1:42 AM, chab nasri wrote:

You say:
"You also need to implement the isSuitable method, perhaps something like this:

 public static boolean isSuitable(Project project, Collection errors) {
   if (project.getKnowledgeBase() instanceof OWLModel) {
     return true;
   } else {
     errors.add("The " + TAB_NAME + " tab only works with OWL models.");
     return false;
   }
 }
"
- What is this method ?

The isSuitable method is a method you override and implement to tell Protege the circumstances under which your plug-in is available to be loaded.  For example, if you build a tab plug-in that only works with OWL ontologies, you need to implement the isSuitable method as demonstrated above by Thomas Russ.  If you run your code with this method added, you see something like the dialog below if you open a Frames ontology like the newspaper example and go to Project | Configure to try to load your tab:






- I used this method as it is ?

You would use it as it is if you want your tab plug-in to only work with OWL ontologies.

exactly where I put it in my program ?

This is my program :
"   
package myTab;

    import javax.swing.JLabel;

    import edu.stanford.smi.protegex.owl.ui.widget.AbstractTabWidget;

    public class DisplayNameTab extends AbstractTabWidget {

       @Override
       public void initialize() {
           setLabel("Display Name Tab");
           add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));

       }
       public static void main(String[] args) {
           edu.stanford.smi.protege.Application.main(args);
       }
    }
"

You can add the method to your existing DisplayNameTab class, e.g.:

public class DisplayNameTab extends AbstractTabWidget {

    public void initialize() {
        setLabel("Display Name Tab");
        add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));
    }

    public static boolean isSuitable(Project project, Collection errors) {
        if (project.getKnowledgeBase() instanceof OWLModel) {
            return true;
        } else {
            errors.add("This tab can only be used with OWL projects.");
            return false;
        }
    }

    public static void main(String[] args) {
        edu.stanford.smi.protege.Application.main(args);
    }
}



I wanted to make a graphical user interface (labels, text boxes and a button) through which user enter the number of nodes, number of leaves, the number of ontology building etc. and when he clicks on the create button then it will create files (*. owl) and each file contains a description of the ontology created.

- What changes to make in my program ?



That's a pretty broad question.  You can read the Java Swing tutorials for learning to build user interfaces with labels, buttons, etc.  In terms of creating/manipulating an ontology, you could use the Protege-OWL API, which is documented on our wiki:

http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide

The guide has coding examples for doing things like creating OWL files and adding classes, properties, etc.

Jennifer


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Hello,

I created a program called "Generation" in Eclipse that allows interface through introducing parameters and then create an OWL ontology based on these parameters.
My program contains four classes ("constructeur.java", "arbre.java", "noeud.java" and "lien.java") where "constructeur.java" contains the "main.java" and the interface elements (Labels, TextFields and Button).

I found in the following link how to run Protégé from Eclipse through the simple example "HelloWordTab" :
http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

Here is an example of "HelloWordTab" :

"
package myTab;

    import javax.swing.JLabel;

    import edu.stanford.smi.protegex.owl.
ui.widget.AbstractTabWidget;

    public class DisplayNameTab extends AbstractTabWidget {

       @Override
       public void initialize() {
           setLabel("Display Name Tab");
           add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));

       }
       public static void main(String[] args) {
           edu.stanford.smi.protege.Application.main(args);
       }
    }
"
My problem how to modify this program "HelloWordTab" to get the result of my program "Generation".

Where I'll put the four classes with different methods and the interface elements ?

In the following link, I have not found my need :
http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide

Please, you can put the different changes necessary in the program HelloWordTab" to get the result of the program " Generation ".

Here is the code for each class :

1)
Class "constructeur.java" :
"
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class constructeur extends JFrame implements ActionListener {
    private Vector arbres;
    int profondeur;
    int nbreNoeud;
    int nbreF;
    int moy;

    private static JTextField textFieldNd;
    private static JTextField textFieldPr;
    private static JTextField textFieldF;
    private static JTextField textFieldBr;
    private static JTextField textFieldEc;

    private JLabel labelNd, labelPr, labelF, labelBr, labelEc;

    private JButton bouton;

    public constructeur() {
        super();
        build();// On initialise notre fenêtre
    }

    private void build() {
        setTitle("Création"); // On donne un titre à l'application
        setSize(500, 500); // On donne une taille à notre fenêtre
        setLocationRelativeTo(null); // On centre la fenêtre sur l'écran
        setResizable(true); // On permet le redimensionnement
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // On dit à
                                                        // l'application de se
                                                        // fermer lors du clic
                                                        // sur la croix
        setContentPane(buildContentPane());
    }

    private JPanel buildContentPane() {
        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout());

        labelNd = new JLabel("nombre de noeud");
        panel.add(labelNd);

        textFieldNd = new JTextField();
        textFieldNd.setColumns(10);
        panel.add(textFieldNd);

        labelPr = new JLabel("la profondeur");
        panel.add(labelPr);

        textFieldPr = new JTextField();
        textFieldPr.setColumns(10);
        panel.add(textFieldPr);

        labelF = new JLabel("le nombre de feuilles");
        panel.add(labelF);

        textFieldF = new JTextField();
        textFieldF.setColumns(10);
        panel.add(textFieldF);

        labelBr = new JLabel("le nombre de branches");
        panel.add(labelBr);

        textFieldBr = new JTextField();
        textFieldBr.setColumns(10);
        panel.add(textFieldBr);

        labelEc = new JLabel("ecart");
        panel.add(labelEc);

        textFieldEc = new JTextField();
        textFieldEc.setColumns(10);
        panel.add(textFieldEc);

        bouton = new JButton("Créer");
        panel.add(bouton);

        bouton.setActionCommand("action_créer");
        bouton.addActionListener(this);
        return panel;
    }

    public void actionPerformed(ActionEvent ae) {
        if (ae.getActionCommand().equals("action_créer")) {
            int n = Integer.parseInt(textFieldNd.getText());
            int p = Integer.parseInt(textFieldPr.getText());
            int nf = Integer.parseInt(textFieldF.getText());
            int nbbr = Integer.parseInt(textFieldBr.getText());
            int ec = Integer.parseInt(textFieldEc.getText());

            int moy = (n - 1) / (n - nf);
            System.out.println("la moyenne des fils par noeud est : " + moy);
            System.out.println("rapport=" + (float) p / (nf * nf));

            constructeur ex1 = new constructeur(n, p, nf, moy);
            if (ex1.verification(n, nf, p) == false) {
                System.out.println("pas de possibilité de construction");
            } else {
                for (int i = 0; i < 10; i++) {
                    Arbre a = new Arbre();
                    a.remplirnoeuds(n);
                    a.arbrepartiel(p);
                    a.remplirFI(p, nf);
                    a.remplirLiensNI(p, ec, nbbr);
                    a.remplirLiensNF(p, ec);
                    a.export(i);
                    a.export_caracteristiques(i, p, n, nf);

                }
            }
        }
    }

    public constructeur(int n, int p, int nf, int moy) {
        this.arbres = new Vector<Arbre>();
        this.profondeur = p;
        this.nbreF = nf;
        this.nbreNoeud = n;
        this.moy = moy;

    }

    public boolean verification(int n, int nf, int p) {
        boolean ok = false;
        if ((p <= (n - nf))) {
            ok = true;
        } else {
            ok = false;
        }
        return ok;

    }

    public static void main(String[] args) {

        constructeur fenetre = new constructeur();
        fenetre.setVisible(true);// On la rend visible

    }
}
"

2)
Class "arbre.java" :
"
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Random;
import java.util.Scanner;
import java.util.Vector;
import java.util.Iterator;
//import java.util.*;
//import javax.swing.*;
//import edu.stanford.smi.protege.model.Instance;

public class Arbre {
    public Vector<noeud> noeuds;
    public Vector<lien> liens;
    public Vector<noeud> noeudsI;
    public Vector<noeud> noeudsF;

    public Arbre() {
        this.noeuds = new Vector<noeud>();
        this.liens = new Vector<lien>();
        this.noeudsI = new Vector<noeud>();
        this.noeudsF = new Vector<noeud>();

    }

    /**
     * @return the noeuds
     */
    public Vector<noeud> getNoeuds() {
        return noeuds;
    }

    /**
     * @param noeuds
     *            the noeuds to set
     */
    public void setNoeuds(Vector<noeud> noeuds) {
        this.noeuds = noeuds;
    }

    /**
     * @return the liens
     */
    public Vector<lien> getLiens() {
        return liens;
    }

    /**
     * @param liens
     *            the liens to set
     */
    public void setLiens(Vector<lien> liens) {
        this.liens = liens;
    }

    // permet de remplir la partie de l'arbre qui satisfait la profondeur p
    public void arbrepartiel(int p) {
        for (int i = 0; i < p; i++) {
            noeud n = noeuds.elementAt(i);
            n.setProfondeur(i + 1);
            if (i != 0) {
                this.ajouterLien(this.noeuds.elementAt(i - 1), n);
            }

            if (i != p - 1) {
                this.noeudsI.addElement(this.noeuds.elementAt(i));
            } else {
                this.noeudsF.addElement(this.noeuds.elementAt(i));
            }
        }
    }

    // remplir le vecteur noeuds
    public void remplirnoeuds(int N) {
        for (int i = 0; i < N - 1; i++) {
            noeud n = new noeud("c" + i, 1);
            this.noeuds.addElement(n);
        }
    }

    // remplir les deux ensembles noeudI et noeudF
    public void remplirFI(int p, int nf) {
        for (int j = p; j <= this.noeuds.size() - nf; j++) {
            this.noeudsI.addElement(this.noeuds.elementAt(j));
        }
        for (int k = this.noeuds.size() - nf + 1; k <= this.noeuds.size() - 1; k++) {
            this.noeudsF.addElement(this.noeuds.elementAt(k));
        }
    }

    public void ajouterNoeud(Vector<noeud> v, noeud n) {
        v.addElement(n);
    }

    public void ajouterLien(noeud Np, noeud Nf) {
        this.liens.addElement(new lien(Np, Nf));
    }

    // cette fonction permet de remplir les liens des noeuds internes
    public void remplirLiensNI(int p, int ec, int nbbr) {
        Vector<noeud> I1 = new Vector<noeud>();
        Vector<noeud> I2 = new Vector<noeud>();

        for (int j = p - 1; j < this.noeudsI.size(); j++) {
            noeud n = this.noeudsI.elementAt(j);
            I1.addElement(n);
            this.noeudsI.removeElementAt(j);
            j = j - 1;
        }

        for (int l = 0; l < nbbr - 1; l++) {
            noeud nfils = (noeud) I1.elementAt(l);
            this.noeudsI.addElement(nfils);
            I1.removeElementAt(l);

        }
        for (int k = 0; k < I1.size(); k++) {
            noeud nfils = (noeud) I1.elementAt(k);
            Vector<noeud> Ipere1 = new Vector<noeud>();
            for (int i = 0; i < this.noeudsI.size(); i++) {
                noeud nps = (noeud) this.noeudsI.elementAt(i);

                if ((nps.getProfondeur() < p - ec - 1)
                        && (nps.getNbreFils() == 0)) {
                    System.out.println("noeud:" + nps.getNom()
                            + " a comme profondeur:" + nps.getProfondeur());
                    Ipere1.addElement(nps);
                }
            }
            if (Ipere1.size() != 0) {
                if (Ipere1.size() == 1) {
                    noeud npere = (noeud) Ipere1.elementAt(0);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }

                else {
                    Random rand = new Random();
                    int a = rand.nextInt(Ipere1.size() - 1);
                    noeud npere = (noeud) Ipere1.elementAt(a);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }
            } else {
                Vector<noeud> Ipere2 = new Vector<noeud>();
                for (int h = 0; h < this.noeudsI.size(); h++) {
                    noeud nps1 = (noeud) this.noeudsI.elementAt(h);
                    if ((nps1.getProfondeur() >= p - ec - 1)
                            && (nps1.getProfondeur() < p - 1)) {
                        Ipere2.addElement(nps1);
                    }
                }
                if (Ipere2.size() != 0) {
                    Random rand = new Random();
                    int a = rand.nextInt(Ipere2.size() - 1);
                    noeud npere = (noeud) Ipere2.elementAt(a);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }
            }
        }
    }

    // permet de remplir les liens des noeuds feuilles avec les noeuds internes
    public void remplirLiensNF(int p, int ec) {
        Vector I2 = new Vector(0);
        int a = 0;
        int r1 = 0;
        Vector<noeud> v = new Vector(0);
        v.addElement(this.noeudsF.elementAt(0));

        if (ec == p - 1) {
            this.noeudsI.addElement((noeud) this.noeudsF.elementAt(1));
            v.addElement(this.noeudsF.elementAt(1));
        }
        for (int i = 0; i < this.noeudsI.size(); i++) {
            noeud npere = this.noeudsI.elementAt(i);
            if (npere.getNbreFils() == 0) {
                I2.addElement(npere);
            }

        }

        for (int j = 0; j < I2.size(); j++) {
            noeud npere = (noeud) I2.elementAt(j);
            boolean ok = false;

            while (ok == false) {
                Random rand = new Random();
                a = rand.nextInt(this.noeudsF.size() - 1);

                noeud nfils = this.noeudsF.elementAt(a);
                if (!v.contains(nfils)) {
                    v.addElement(nfils);
                    this.ajouterLien(npere, nfils);
                    ok = true;
                }

            }
        }

        Vector<noeud> vselect = new Vector(0);
        for (int t = 0; t < this.noeudsI.size(); t++) {
            noeud np = this.noeudsI.elementAt(t);
            if (np.getProfondeur() >= p - ec - 1) {
                vselect.addElement(np);
            }
        }
        for (int k = 1; k < this.noeudsF.size(); k++) {
            noeud nfils = this.noeudsF.elementAt(k);

            if (!v.contains(nfils)) {
                if (vselect.size() != 0) {
                    if (vselect.size() == 1) {
                        noeud npere = vselect.elementAt(0);
                        this.ajouterLien(npere, nfils);
                    } else {
                        Random rand = new Random();
                        r1 = rand.nextInt(vselect.size() - 1);
                        noeud npere = vselect.elementAt(r1);
                        this.ajouterLien(npere, nfils);

                    }
                }

            }
        }

    }

    /*
     * // retourne un vecteur des fils du noeud passé en parametre public Vector
     * prendreListeFils (noeud n){ Vector v = new Vector(0); Iterator it =
     * liens.iterator(); while (it.hasNext()) { lien l = (lien) it.next(); if
     * (l.getPere().equals(n)) v.addElement(l.getFils()); } return v; }
     */

    // retourne la liste des pere
    public noeud prendrePere(noeud n) {
        Iterator it = liens.iterator();
        while (it.hasNext()) {
            lien l = (lien) it.next();
            if (l.getFils().equals(n)) {
                return (l.getPere());
            }
        }
        return null;

    }

    public int ecart(int p, Vector<noeud> v) {
        Iterator it = v.iterator();
        noeud n = (noeud) it.next();
        int min = n.getProfondeur();
        while (it.hasNext()) {
            noeud m = (noeud) it.next();
            if (m.getProfondeur() < min) {
                min = m.getProfondeur();
            }
        }
        return (p - min);

    }

    float calcul_rapport2(Vector<noeud> NI, Vector<noeud> NF, Vector<lien> L) {
        Iterator it = NI.iterator();
        float min;
        float max = 0;
        noeud n0 = (noeud) NI.elementAt(1);
        min = (float) n0.getNbreFils();

        while (it.hasNext()) {
            noeud ni = (noeud) it.next();
            Iterator it1 = L.iterator();
            int cpt = 0;
            while (it1.hasNext()) {
                lien l = (lien) it1.next();
                if (l.getPere().getNom() == ni.getNom()) {
                    Iterator it2 = NF.iterator();
                    boolean trouve = false;
                    while ((it2.hasNext()) && (trouve == false)) {
                        noeud nf = (noeud) it2.next();
                        if (nf.getNom() == l.getFils().getNom()) {
                            trouve = true;
                        }
                    }
                    if (trouve == false) {
                        cpt++;
                    }
                }

            }

            if (cpt > max) {
                max = cpt;
            }
            if ((cpt < min) && (cpt != 0)) {
                min = cpt;
            }

        }
        int cpt1 = 0;
        for (int i = 0; i < NI.size(); i++) {
            noeud ni = (noeud) NI.elementAt(i);
            if (ni.getProfondeur() == 1) {
                cpt1++;
            }
        }
        if (cpt1 < min) {
            min = cpt1;
        }
        if (cpt1 > max) {
            max = cpt1;
        }

        return (max / min);
    }

    public void export_caracteristiques(int i, int p, int n, int nf) {
        StringWriter sw = new StringWriter();
        sw.write("carectériqtique de l'ontologie:" + i + "\n");
        sw.write("nombre noeud :" + n + "\n");
        sw.write("nombre feuilles :" + nf + "\n");
        sw.write("Profondeur :" + p + "\n");
        int moy = (n - 1) / (n - nf);
        sw.write("moyenne des fils par noeud :" + moy + "\n");
        sw.write("ecart profondeur moins minimum prof des feuilles :"
                + ecart(p, this.noeudsF) + "\n");
        sw.write("Max(nbre de noeud par fils(ss feuilles))/Min(nbre de noeud par fils(ss feuilles)):"
                + calcul_rapport2(this.noeudsI, this.noeudsF, this.liens)
                + "\n");
        System.out.println(sw.toString());
        try {
            FileOutputStream fos = new FileOutputStream(new File(
                    "E:\\WorkPFA\\caractO" + i + ".txt"));
            fos.write(sw.toString().getBytes());
            fos.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }

    }

    public void export(int i) {
        StringWriter sw = new StringWriter();
        sw.write("<?xml version=\"1.0\"?>\n");
        sw.write("<rdf:RDF\n");
        sw.write("xmlns:xsp=\"http://www.owl-ontologies.com/2005/08/07/xsp.owl#\"\n");
        sw.write("xmlns:swrlb=\"http://www.w3.org/2003/11/swrlb#\"\n");
        sw.write("xmlns=\"http://www.owl-ontologies.com/Ontology" + i
                + ".owl#\"\n");
        sw.write("xmlns:swrl=\"http://www.w3.org/2003/11/swrl#\" \n");
        sw.write("xmlns:protege=\"http://protege.stanford.edu/plugins/owl/protege#\"\n");
        sw.write("xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n");
        sw.write("xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\n");
        sw.write("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\"\n");
        sw.write("xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n");
        sw.write("xml:base=\"http://www.owl-ontologies.com/Ontology" + i
                + ".owl\">");
        Vector v = new Vector(0);
        for (int j = 0; j < this.noeudsF.size(); j++) {
            noeud nouv = this.noeudsF.elementAt(j);
            sw.write("<owl:Class rdf:ID=\"" + nouv.getNom() + "\">\n");
            noeud npere = this.prendrePere(nouv);
            sw.write("<rdfs:subClassOf>\n");
            if (!v.contains(npere)) {
                sw.write("<owl:Class rdf:ID=\"" + npere.getNom() + "\"/>\n");
                sw.write("</rdfs:subClassOf>\n");
                v.addElement(npere);
            } else {
                sw.write("<owl:Class rdf:about=\"#" + npere.getNom() + "\"/>\n");
                sw.write("</rdfs:subClassOf>\n");
            }
            sw.write("</owl:Class>\n");
        }

        for (int k = 0; k < this.noeudsI.size(); k++) {
            noeud nouvI = this.noeudsI.elementAt(k);
            System.out.println("concept : " + nouvI.getNom() + "profondeur:"
                    + nouvI.getProfondeur());
            if (nouvI.getProfondeur() != 1) {
                if (!v.contains(nouvI)) {
                    sw.write("<owl:Class rdf:ID=\"" + nouvI.getNom() + "\">\n");
                } else {
                    sw.write("<owl:Class rdf:about=\"#" + nouvI.getNom()
                            + "\">\n");
                }
                noeud npereI = this.prendrePere(nouvI);

                sw.write("<rdfs:subClassOf>\n");
                if (!v.contains(npereI)) {
                    sw.write("<owl:Class rdf:ID=\"" + npereI.getNom()
                            + "\"/>\n");
                    sw.write("</rdfs:subClassOf>\n");
                    v.addElement(npereI);
                } else {
                    sw.write("<owl:Class rdf:about=\"#" + npereI.getNom()
                            + "\"/>\n");
                    sw.write("</rdfs:subClassOf>\n");
                }
                sw.write("</owl:Class>\n");
            }
        }
        sw.write("</rdf:RDF>");
        System.out.println(sw.toString());
        try {
            FileOutputStream fos = new FileOutputStream(new File(
                    "E:\\WorkPFA\\O" + i + ".owl"));
            fos.write(sw.toString().getBytes());
            fos.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }

    }

    /**
     * @param args
     */
}

"

3)
Class "noeud.java":
"
public class noeud {
    // private static int numero;
    private boolean feuille;
    private String nom;
    private int nbreFils;
    private int profondeur;

    /*
     * Constructeur
     */
    public noeud(String ch, int p) {
        // this.numero++;
        this.nom = ch;
        this.profondeur = p;
        this.feuille = true;
        this.nbreFils = 0;
    }

    /**
     * @return the nom
     */
    public String getNom() {
        return nom;
    }

    /**
     * @param nom
     *            the nom to set
     */
    public void setNom(String nom) {
        this.nom = nom;
    }

    public boolean isFeuille() {
        return feuille;
    }

    public void setFeuille(boolean feuille) {
        this.feuille = feuille;
    }

    /**
     * @return the nbreFils
     */
    public int getNbreFils() {
        return nbreFils;
    }

    /**
     * @param nbreFils
     *            the nbreFils to set
     */
    public void setNbreFils(int nbreFils) {
        this.nbreFils = nbreFils;
    }

    /**
     * @return the profondeur
     */
    public int getProfondeur() {
        return profondeur;
    }

    /**
     * @param profondeur
     *            the profondeur to set
     */
    public void setProfondeur(int profondeur) {
        this.profondeur = profondeur;
    }

}

"

4)
Class "lien.java" :
"
public class lien {
    private noeud pere;
    private noeud fils;

    /*
     * Constructeur
     */
    public lien(noeud Npere, noeud Nfils) {
        this.pere = Npere;
        this.fils = Nfils;
        Npere.setNbreFils(Npere.getNbreFils() + 1);
        Nfils.setProfondeur(Npere.getProfondeur() + 1);
        Npere.setFeuille(false);

    }

    public noeud getPere() {
        return pere;
    }

    public void setPere(noeud pere) {
        this.pere = pere;
    }

    public noeud getFils() {
        return fils;
    }

    public void setFils(noeud fils) {
        this.fils = fils;
    }
}

"

Best regards.

_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Tania Tudorache
Call constructeur() in the initialize() method.

Tania

On 05/29/2011 09:56 AM, chab nasri wrote:
Hello,

I created a program called "Generation" in Eclipse that allows interface through introducing parameters and then create an OWL ontology based on these parameters.
My program contains four classes ("constructeur.java", "arbre.java", "noeud.java" and "lien.java") where "constructeur.java" contains the "main.java" and the interface elements (Labels, TextFields and Button).

I found in the following link how to run Protégé from Eclipse through the simple example "HelloWordTab" :
http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

Here is an example of "HelloWordTab" :

"
package myTab;

    import javax.swing.JLabel;

    import edu.stanford.smi.protegex.owl.
ui.widget.AbstractTabWidget;

    public class DisplayNameTab extends AbstractTabWidget {

       @Override
       public void initialize() {
           setLabel("Display Name Tab");
           add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));

       }
       public static void main(String[] args) {
           edu.stanford.smi.protege.Application.main(args);
       }
    }
"
My problem how to modify this program "HelloWordTab" to get the result of my program "Generation".

Where I'll put the four classes with different methods and the interface elements ?

In the following link, I have not found my need :
http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide

Please, you can put the different changes necessary in the program HelloWordTab" to get the result of the program " Generation ".

Here is the code for each class :

1)
Class "constructeur.java" :
"
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class constructeur extends JFrame implements ActionListener {
    private Vector arbres;
    int profondeur;
    int nbreNoeud;
    int nbreF;
    int moy;

    private static JTextField textFieldNd;
    private static JTextField textFieldPr;
    private static JTextField textFieldF;
    private static JTextField textFieldBr;
    private static JTextField textFieldEc;

    private JLabel labelNd, labelPr, labelF, labelBr, labelEc;

    private JButton bouton;

    public constructeur() {
        super();
        build();// On initialise notre fenêtre
    }

    private void build() {
        setTitle("Création"); // On donne un titre à l'application
        setSize(500, 500); // On donne une taille à notre fenêtre
        setLocationRelativeTo(null); // On centre la fenêtre sur l'écran
        setResizable(true); // On permet le redimensionnement
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // On dit à
                                                        // l'application de se
                                                        // fermer lors du clic
                                                        // sur la croix
        setContentPane(buildContentPane());
    }

    private JPanel buildContentPane() {
        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout());

        labelNd = new JLabel("nombre de noeud");
        panel.add(labelNd);

        textFieldNd = new JTextField();
        textFieldNd.setColumns(10);
        panel.add(textFieldNd);

        labelPr = new JLabel("la profondeur");
        panel.add(labelPr);

        textFieldPr = new JTextField();
        textFieldPr.setColumns(10);
        panel.add(textFieldPr);

        labelF = new JLabel("le nombre de feuilles");
        panel.add(labelF);

        textFieldF = new JTextField();
        textFieldF.setColumns(10);
        panel.add(textFieldF);

        labelBr = new JLabel("le nombre de branches");
        panel.add(labelBr);

        textFieldBr = new JTextField();
        textFieldBr.setColumns(10);
        panel.add(textFieldBr);

        labelEc = new JLabel("ecart");
        panel.add(labelEc);

        textFieldEc = new JTextField();
        textFieldEc.setColumns(10);
        panel.add(textFieldEc);

        bouton = new JButton("Créer");
        panel.add(bouton);

        bouton.setActionCommand("action_créer");
        bouton.addActionListener(this);
        return panel;
    }

    public void actionPerformed(ActionEvent ae) {
        if (ae.getActionCommand().equals("action_créer")) {
            int n = Integer.parseInt(textFieldNd.getText());
            int p = Integer.parseInt(textFieldPr.getText());
            int nf = Integer.parseInt(textFieldF.getText());
            int nbbr = Integer.parseInt(textFieldBr.getText());
            int ec = Integer.parseInt(textFieldEc.getText());

            int moy = (n - 1) / (n - nf);
            System.out.println("la moyenne des fils par noeud est : " + moy);
            System.out.println("rapport=" + (float) p / (nf * nf));

            constructeur ex1 = new constructeur(n, p, nf, moy);
            if (ex1.verification(n, nf, p) == false) {
                System.out.println("pas de possibilité de construction");
            } else {
                for (int i = 0; i < 10; i++) {
                    Arbre a = new Arbre();
                    a.remplirnoeuds(n);
                    a.arbrepartiel(p);
                    a.remplirFI(p, nf);
                    a.remplirLiensNI(p, ec, nbbr);
                    a.remplirLiensNF(p, ec);
                    a.export(i);
                    a.export_caracteristiques(i, p, n, nf);

                }
            }
        }
    }

    public constructeur(int n, int p, int nf, int moy) {
        this.arbres = new Vector<Arbre>();
        this.profondeur = p;
        this.nbreF = nf;
        this.nbreNoeud = n;
        this.moy = moy;

    }

    public boolean verification(int n, int nf, int p) {
        boolean ok = false;
        if ((p <= (n - nf))) {
            ok = true;
        } else {
            ok = false;
        }
        return ok;

    }

    public static void main(String[] args) {

        constructeur fenetre = new constructeur();
        fenetre.setVisible(true);// On la rend visible

    }
}
"

2)
Class "arbre.java" :
"
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Random;
import java.util.Scanner;
import java.util.Vector;
import java.util.Iterator;
//import java.util.*;
//import javax.swing.*;
//import edu.stanford.smi.protege.model.Instance;

public class Arbre {
    public Vector<noeud> noeuds;
    public Vector<lien> liens;
    public Vector<noeud> noeudsI;
    public Vector<noeud> noeudsF;

    public Arbre() {
        this.noeuds = new Vector<noeud>();
        this.liens = new Vector<lien>();
        this.noeudsI = new Vector<noeud>();
        this.noeudsF = new Vector<noeud>();

    }

    /**
     * @return the noeuds
     */
    public Vector<noeud> getNoeuds() {
        return noeuds;
    }

    /**
     * @param noeuds
     *            the noeuds to set
     */
    public void setNoeuds(Vector<noeud> noeuds) {
        this.noeuds = noeuds;
    }

    /**
     * @return the liens
     */
    public Vector<lien> getLiens() {
        return liens;
    }

    /**
     * @param liens
     *            the liens to set
     */
    public void setLiens(Vector<lien> liens) {
        this.liens = liens;
    }

    // permet de remplir la partie de l'arbre qui satisfait la profondeur p
    public void arbrepartiel(int p) {
        for (int i = 0; i < p; i++) {
            noeud n = noeuds.elementAt(i);
            n.setProfondeur(i + 1);
            if (i != 0) {
                this.ajouterLien(this.noeuds.elementAt(i - 1), n);
            }

            if (i != p - 1) {
                this.noeudsI.addElement(this.noeuds.elementAt(i));
            } else {
                this.noeudsF.addElement(this.noeuds.elementAt(i));
            }
        }
    }

    // remplir le vecteur noeuds
    public void remplirnoeuds(int N) {
        for (int i = 0; i < N - 1; i++) {
            noeud n = new noeud("c" + i, 1);
            this.noeuds.addElement(n);
        }
    }

    // remplir les deux ensembles noeudI et noeudF
    public void remplirFI(int p, int nf) {
        for (int j = p; j <= this.noeuds.size() - nf; j++) {
            this.noeudsI.addElement(this.noeuds.elementAt(j));
        }
        for (int k = this.noeuds.size() - nf + 1; k <= this.noeuds.size() - 1; k++) {
            this.noeudsF.addElement(this.noeuds.elementAt(k));
        }
    }

    public void ajouterNoeud(Vector<noeud> v, noeud n) {
        v.addElement(n);
    }

    public void ajouterLien(noeud Np, noeud Nf) {
        this.liens.addElement(new lien(Np, Nf));
    }

    // cette fonction permet de remplir les liens des noeuds internes
    public void remplirLiensNI(int p, int ec, int nbbr) {
        Vector<noeud> I1 = new Vector<noeud>();
        Vector<noeud> I2 = new Vector<noeud>();

        for (int j = p - 1; j < this.noeudsI.size(); j++) {
            noeud n = this.noeudsI.elementAt(j);
            I1.addElement(n);
            this.noeudsI.removeElementAt(j);
            j = j - 1;
        }

        for (int l = 0; l < nbbr - 1; l++) {
            noeud nfils = (noeud) I1.elementAt(l);
            this.noeudsI.addElement(nfils);
            I1.removeElementAt(l);

        }
        for (int k = 0; k < I1.size(); k++) {
            noeud nfils = (noeud) I1.elementAt(k);
            Vector<noeud> Ipere1 = new Vector<noeud>();
            for (int i = 0; i < this.noeudsI.size(); i++) {
                noeud nps = (noeud) this.noeudsI.elementAt(i);

                if ((nps.getProfondeur() < p - ec - 1)
                        && (nps.getNbreFils() == 0)) {
                    System.out.println("noeud:" + nps.getNom()
                            + " a comme profondeur:" + nps.getProfondeur());
                    Ipere1.addElement(nps);
                }
            }
            if (Ipere1.size() != 0) {
                if (Ipere1.size() == 1) {
                    noeud npere = (noeud) Ipere1.elementAt(0);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }

                else {
                    Random rand = new Random();
                    int a = rand.nextInt(Ipere1.size() - 1);
                    noeud npere = (noeud) Ipere1.elementAt(a);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }
            } else {
                Vector<noeud> Ipere2 = new Vector<noeud>();
                for (int h = 0; h < this.noeudsI.size(); h++) {
                    noeud nps1 = (noeud) this.noeudsI.elementAt(h);
                    if ((nps1.getProfondeur() >= p - ec - 1)
                            && (nps1.getProfondeur() < p - 1)) {
                        Ipere2.addElement(nps1);
                    }
                }
                if (Ipere2.size() != 0) {
                    Random rand = new Random();
                    int a = rand.nextInt(Ipere2.size() - 1);
                    noeud npere = (noeud) Ipere2.elementAt(a);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }
            }
        }
    }

    // permet de remplir les liens des noeuds feuilles avec les noeuds internes
    public void remplirLiensNF(int p, int ec) {
        Vector I2 = new Vector(0);
        int a = 0;
        int r1 = 0;
        Vector<noeud> v = new Vector(0);
        v.addElement(this.noeudsF.elementAt(0));

        if (ec == p - 1) {
            this.noeudsI.addElement((noeud) this.noeudsF.elementAt(1));
            v.addElement(this.noeudsF.elementAt(1));
        }
        for (int i = 0; i < this.noeudsI.size(); i++) {
            noeud npere = this.noeudsI.elementAt(i);
            if (npere.getNbreFils() == 0) {
                I2.addElement(npere);
            }

        }

        for (int j = 0; j < I2.size(); j++) {
            noeud npere = (noeud) I2.elementAt(j);
            boolean ok = false;

            while (ok == false) {
                Random rand = new Random();
                a = rand.nextInt(this.noeudsF.size() - 1);

                noeud nfils = this.noeudsF.elementAt(a);
                if (!v.contains(nfils)) {
                    v.addElement(nfils);
                    this.ajouterLien(npere, nfils);
                    ok = true;
                }

            }
        }

        Vector<noeud> vselect = new Vector(0);
        for (int t = 0; t < this.noeudsI.size(); t++) {
            noeud np = this.noeudsI.elementAt(t);
            if (np.getProfondeur() >= p - ec - 1) {
                vselect.addElement(np);
            }
        }
        for (int k = 1; k < this.noeudsF.size(); k++) {
            noeud nfils = this.noeudsF.elementAt(k);

            if (!v.contains(nfils)) {
                if (vselect.size() != 0) {
                    if (vselect.size() == 1) {
                        noeud npere = vselect.elementAt(0);
                        this.ajouterLien(npere, nfils);
                    } else {
                        Random rand = new Random();
                        r1 = rand.nextInt(vselect.size() - 1);
                        noeud npere = vselect.elementAt(r1);
                        this.ajouterLien(npere, nfils);

                    }
                }

            }
        }

    }

    /*
     * // retourne un vecteur des fils du noeud passé en parametre public Vector
     * prendreListeFils (noeud n){ Vector v = new Vector(0); Iterator it =
     * liens.iterator(); while (it.hasNext()) { lien l = (lien) it.next(); if
     * (l.getPere().equals(n)) v.addElement(l.getFils()); } return v; }
     */

    // retourne la liste des pere
    public noeud prendrePere(noeud n) {
        Iterator it = liens.iterator();
        while (it.hasNext()) {
            lien l = (lien) it.next();
            if (l.getFils().equals(n)) {
                return (l.getPere());
            }
        }
        return null;

    }

    public int ecart(int p, Vector<noeud> v) {
        Iterator it = v.iterator();
        noeud n = (noeud) it.next();
        int min = n.getProfondeur();
        while (it.hasNext()) {
            noeud m = (noeud) it.next();
            if (m.getProfondeur() < min) {
                min = m.getProfondeur();
            }
        }
        return (p - min);

    }

    float calcul_rapport2(Vector<noeud> NI, Vector<noeud> NF, Vector<lien> L) {
        Iterator it = NI.iterator();
        float min;
        float max = 0;
        noeud n0 = (noeud) NI.elementAt(1);
        min = (float) n0.getNbreFils();

        while (it.hasNext()) {
            noeud ni = (noeud) it.next();
            Iterator it1 = L.iterator();
            int cpt = 0;
            while (it1.hasNext()) {
                lien l = (lien) it1.next();
                if (l.getPere().getNom() == ni.getNom()) {
                    Iterator it2 = NF.iterator();
                    boolean trouve = false;
                    while ((it2.hasNext()) && (trouve == false)) {
                        noeud nf = (noeud) it2.next();
                        if (nf.getNom() == l.getFils().getNom()) {
                            trouve = true;
                        }
                    }
                    if (trouve == false) {
                        cpt++;
                    }
                }

            }

            if (cpt > max) {
                max = cpt;
            }
            if ((cpt < min) && (cpt != 0)) {
                min = cpt;
            }

        }
        int cpt1 = 0;
        for (int i = 0; i < NI.size(); i++) {
            noeud ni = (noeud) NI.elementAt(i);
            if (ni.getProfondeur() == 1) {
                cpt1++;
            }
        }
        if (cpt1 < min) {
            min = cpt1;
        }
        if (cpt1 > max) {
            max = cpt1;
        }

        return (max / min);
    }

    public void export_caracteristiques(int i, int p, int n, int nf) {
        StringWriter sw = new StringWriter();
        sw.write("carectériqtique de l'ontologie:" + i + "\n");
        sw.write("nombre noeud :" + n + "\n");
        sw.write("nombre feuilles :" + nf + "\n");
        sw.write("Profondeur :" + p + "\n");
        int moy = (n - 1) / (n - nf);
        sw.write("moyenne des fils par noeud :" + moy + "\n");
        sw.write("ecart profondeur moins minimum prof des feuilles :"
                + ecart(p, this.noeudsF) + "\n");
        sw.write("Max(nbre de noeud par fils(ss feuilles))/Min(nbre de noeud par fils(ss feuilles)):"
                + calcul_rapport2(this.noeudsI, this.noeudsF, this.liens)
                + "\n");
        System.out.println(sw.toString());
        try {
            FileOutputStream fos = new FileOutputStream(new File(
                    "E:\\WorkPFA\\caractO" + i + ".txt"));
            fos.write(sw.toString().getBytes());
            fos.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }

    }

    public void export(int i) {
        StringWriter sw = new StringWriter();
        sw.write("<?xml version=\"1.0\"?>\n");
        sw.write("<rdf:RDF\n");
        sw.write("xmlns:xsp=\"http://www.owl-ontologies.com/2005/08/07/xsp.owl#\"\n");
        sw.write("xmlns:swrlb=\"http://www.w3.org/2003/11/swrlb#\"\n");
        sw.write("xmlns=\"http://www.owl-ontologies.com/Ontology" + i
                + ".owl#\"\n");
        sw.write("xmlns:swrl=\"http://www.w3.org/2003/11/swrl#\" \n");
        sw.write("xmlns:protege=\"http://protege.stanford.edu/plugins/owl/protege#\"\n");
        sw.write("xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n");
        sw.write("xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\n");
        sw.write("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\"\n");
        sw.write("xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n");
        sw.write("xml:base=\"http://www.owl-ontologies.com/Ontology" + i
                + ".owl\">");
        Vector v = new Vector(0);
        for (int j = 0; j < this.noeudsF.size(); j++) {
            noeud nouv = this.noeudsF.elementAt(j);
            sw.write("<owl:Class rdf:ID=\"" + nouv.getNom() + "\">\n");
            noeud npere = this.prendrePere(nouv);
            sw.write("<rdfs:subClassOf>\n");
            if (!v.contains(npere)) {
                sw.write("<owl:Class rdf:ID=\"" + npere.getNom() + "\"/>\n");
                sw.write("</rdfs:subClassOf>\n");
                v.addElement(npere);
            } else {
                sw.write("<owl:Class rdf:about=\"#" + npere.getNom() + "\"/>\n");
                sw.write("</rdfs:subClassOf>\n");
            }
            sw.write("</owl:Class>\n");
        }

        for (int k = 0; k < this.noeudsI.size(); k++) {
            noeud nouvI = this.noeudsI.elementAt(k);
            System.out.println("concept : " + nouvI.getNom() + "profondeur:"
                    + nouvI.getProfondeur());
            if (nouvI.getProfondeur() != 1) {
                if (!v.contains(nouvI)) {
                    sw.write("<owl:Class rdf:ID=\"" + nouvI.getNom() + "\">\n");
                } else {
                    sw.write("<owl:Class rdf:about=\"#" + nouvI.getNom()
                            + "\">\n");
                }
                noeud npereI = this.prendrePere(nouvI);

                sw.write("<rdfs:subClassOf>\n");
                if (!v.contains(npereI)) {
                    sw.write("<owl:Class rdf:ID=\"" + npereI.getNom()
                            + "\"/>\n");
                    sw.write("</rdfs:subClassOf>\n");
                    v.addElement(npereI);
                } else {
                    sw.write("<owl:Class rdf:about=\"#" + npereI.getNom()
                            + "\"/>\n");
                    sw.write("</rdfs:subClassOf>\n");
                }
                sw.write("</owl:Class>\n");
            }
        }
        sw.write("</rdf:RDF>");
        System.out.println(sw.toString());
        try {
            FileOutputStream fos = new FileOutputStream(new File(
                    "E:\\WorkPFA\\O" + i + ".owl"));
            fos.write(sw.toString().getBytes());
            fos.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }

    }

    /**
     * @param args
     */
}

"

3)
Class "noeud.java":
"
public class noeud {
    // private static int numero;
    private boolean feuille;
    private String nom;
    private int nbreFils;
    private int profondeur;

    /*
     * Constructeur
     */
    public noeud(String ch, int p) {
        // this.numero++;
        this.nom = ch;
        this.profondeur = p;
        this.feuille = true;
        this.nbreFils = 0;
    }

    /**
     * @return the nom
     */
    public String getNom() {
        return nom;
    }

    /**
     * @param nom
     *            the nom to set
     */
    public void setNom(String nom) {
        this.nom = nom;
    }

    public boolean isFeuille() {
        return feuille;
    }

    public void setFeuille(boolean feuille) {
        this.feuille = feuille;
    }

    /**
     * @return the nbreFils
     */
    public int getNbreFils() {
        return nbreFils;
    }

    /**
     * @param nbreFils
     *            the nbreFils to set
     */
    public void setNbreFils(int nbreFils) {
        this.nbreFils = nbreFils;
    }

    /**
     * @return the profondeur
     */
    public int getProfondeur() {
        return profondeur;
    }

    /**
     * @param profondeur
     *            the profondeur to set
     */
    public void setProfondeur(int profondeur) {
        this.profondeur = profondeur;
    }

}

"

4)
Class "lien.java" :
"
public class lien {
    private noeud pere;
    private noeud fils;

    /*
     * Constructeur
     */
    public lien(noeud Npere, noeud Nfils) {
        this.pere = Npere;
        this.fils = Nfils;
        Npere.setNbreFils(Npere.getNbreFils() + 1);
        Nfils.setProfondeur(Npere.getProfondeur() + 1);
        Npere.setFeuille(false);

    }

    public noeud getPere() {
        return pere;
    }

    public void setPere(noeud pere) {
        this.pere = pere;
    }

    public noeud getFils() {
        return fils;
    }

    public void setFils(noeud fils) {
        this.fils = fils;
    }
}

"

Best regards.
_______________________________________________ protege-owl mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-owl Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Hello,

2011/6/1 Tania Tudorache <[hidden email]>
Call constructeur() in the initialize() method.


- Do I have to add the four classes ("constructeur.java", "arbre.java", "noeud.java" and "lien.java") in the project that contains the class "DisplayNameTab.java " ?

- How do you call "constructeur()" in the "initialize()" method ?

- The class "constructeur.java" already contains a "main" this does not pose a problem because the class "DisplayNameTab.java" also contains a "main" ?

- Please, can you put the different changes necessary in the program "HelloWordTab" to get the same result of the program "Generation"  ?

The desired result is to display  in Protégé an interface to the user who will fill certain fields and when he clicks on the button (see the method "actionPerformed()" in the class "constructeur.java") then it will be the creation of ontologies according to information filled. These ontologies will be saved somewhere (see méthode "export_caracteristiques()" in the class  "arbre.java" ).

Thinks.

Tania


On 05/29/2011 09:56 AM, chab nasri wrote:
Hello,

I created a program called "Generation" in Eclipse that allows interface through introducing parameters and then create an OWL ontology based on these parameters.
My program contains four classes ("constructeur.java", "arbre.java", "noeud.java" and "lien.java") where "constructeur.java" contains the "main.java" and the interface elements (Labels, TextFields and Button).

I found in the following link how to run Protégé from Eclipse through the simple example "HelloWordTab" :
http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin

Here is an example of "HelloWordTab" :

"
package myTab;

    import javax.swing.JLabel;

    import edu.stanford.smi.protegex.owl.
ui.widget.AbstractTabWidget;

    public class DisplayNameTab extends AbstractTabWidget {

       @Override
       public void initialize() {
           setLabel("Display Name Tab");
           add(new JLabel(getOWLModel().getDefaultOWLOntology().getBrowserText()));

       }
       public static void main(String[] args) {
           edu.stanford.smi.protege.Application.main(args);
       }
    }
"
My problem how to modify this program "HelloWordTab" to get the result of my program "Generation".

Where I'll put the four classes with different methods and the interface elements ?

In the following link, I have not found my need :
http://protegewiki.stanford.edu/wiki/ProtegeOWL_API_Programmers_Guide

Please, you can put the different changes necessary in the program HelloWordTab" to get the result of the program " Generation ".

Here is the code for each class :

1)
Class "constructeur.java" :
"
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class constructeur extends JFrame implements ActionListener {
    private Vector arbres;
    int profondeur;
    int nbreNoeud;
    int nbreF;
    int moy;

    private static JTextField textFieldNd;
    private static JTextField textFieldPr;
    private static JTextField textFieldF;
    private static JTextField textFieldBr;
    private static JTextField textFieldEc;

    private JLabel labelNd, labelPr, labelF, labelBr, labelEc;

    private JButton bouton;

    public constructeur() {
        super();
        build();// On initialise notre fenêtre
    }

    private void build() {
        setTitle("Création"); // On donne un titre à l'application
        setSize(500, 500); // On donne une taille à notre fenêtre
        setLocationRelativeTo(null); // On centre la fenêtre sur l'écran
        setResizable(true); // On permet le redimensionnement
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // On dit à
                                                        // l'application de se
                                                        // fermer lors du clic
                                                        // sur la croix
        setContentPane(buildContentPane());
    }

    private JPanel buildContentPane() {
        JPanel panel = new JPanel();
        panel.setLayout(new FlowLayout());

        labelNd = new JLabel("nombre de noeud");
        panel.add(labelNd);

        textFieldNd = new JTextField();
        textFieldNd.setColumns(10);
        panel.add(textFieldNd);

        labelPr = new JLabel("la profondeur");
        panel.add(labelPr);

        textFieldPr = new JTextField();
        textFieldPr.setColumns(10);
        panel.add(textFieldPr);

        labelF = new JLabel("le nombre de feuilles");
        panel.add(labelF);

        textFieldF = new JTextField();
        textFieldF.setColumns(10);
        panel.add(textFieldF);

        labelBr = new JLabel("le nombre de branches");
        panel.add(labelBr);

        textFieldBr = new JTextField();
        textFieldBr.setColumns(10);
        panel.add(textFieldBr);

        labelEc = new JLabel("ecart");
        panel.add(labelEc);

        textFieldEc = new JTextField();
        textFieldEc.setColumns(10);
        panel.add(textFieldEc);

        bouton = new JButton("Créer");
        panel.add(bouton);

        bouton.setActionCommand("action_créer");
        bouton.addActionListener(this);
        return panel;
    }

    public void actionPerformed(ActionEvent ae) {
        if (ae.getActionCommand().equals("action_créer")) {
            int n = Integer.parseInt(textFieldNd.getText());
            int p = Integer.parseInt(textFieldPr.getText());
            int nf = Integer.parseInt(textFieldF.getText());
            int nbbr = Integer.parseInt(textFieldBr.getText());
            int ec = Integer.parseInt(textFieldEc.getText());

            int moy = (n - 1) / (n - nf);
            System.out.println("la moyenne des fils par noeud est : " + moy);
            System.out.println("rapport=" + (float) p / (nf * nf));

            constructeur ex1 = new constructeur(n, p, nf, moy);
            if (ex1.verification(n, nf, p) == false) {
                System.out.println("pas de possibilité de construction");
            } else {
                for (int i = 0; i < 10; i++) {
                    Arbre a = new Arbre();
                    a.remplirnoeuds(n);
                    a.arbrepartiel(p);
                    a.remplirFI(p, nf);
                    a.remplirLiensNI(p, ec, nbbr);
                    a.remplirLiensNF(p, ec);
                    a.export(i);
                    a.export_caracteristiques(i, p, n, nf);

                }
            }
        }
    }

    public constructeur(int n, int p, int nf, int moy) {
        this.arbres = new Vector<Arbre>();
        this.profondeur = p;
        this.nbreF = nf;
        this.nbreNoeud = n;
        this.moy = moy;

    }

    public boolean verification(int n, int nf, int p) {
        boolean ok = false;
        if ((p <= (n - nf))) {
            ok = true;
        } else {
            ok = false;
        }
        return ok;

    }

    public static void main(String[] args) {

        constructeur fenetre = new constructeur();
        fenetre.setVisible(true);// On la rend visible

    }
}
"

2)
Class "arbre.java" :
"
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Random;
import java.util.Scanner;
import java.util.Vector;
import java.util.Iterator;
//import java.util.*;
//import javax.swing.*;
//import edu.stanford.smi.protege.model.Instance;

public class Arbre {
    public Vector<noeud> noeuds;
    public Vector<lien> liens;
    public Vector<noeud> noeudsI;
    public Vector<noeud> noeudsF;

    public Arbre() {
        this.noeuds = new Vector<noeud>();
        this.liens = new Vector<lien>();
        this.noeudsI = new Vector<noeud>();
        this.noeudsF = new Vector<noeud>();

    }

    /**
     * @return the noeuds
     */
    public Vector<noeud> getNoeuds() {
        return noeuds;
    }

    /**
     * @param noeuds
     *            the noeuds to set
     */
    public void setNoeuds(Vector<noeud> noeuds) {
        this.noeuds = noeuds;
    }

    /**
     * @return the liens
     */
    public Vector<lien> getLiens() {
        return liens;
    }

    /**
     * @param liens
     *            the liens to set
     */
    public void setLiens(Vector<lien> liens) {
        this.liens = liens;
    }

    // permet de remplir la partie de l'arbre qui satisfait la profondeur p
    public void arbrepartiel(int p) {
        for (int i = 0; i < p; i++) {
            noeud n = noeuds.elementAt(i);
            n.setProfondeur(i + 1);
            if (i != 0) {
                this.ajouterLien(this.noeuds.elementAt(i - 1), n);
            }

            if (i != p - 1) {
                this.noeudsI.addElement(this.noeuds.elementAt(i));
            } else {
                this.noeudsF.addElement(this.noeuds.elementAt(i));
            }
        }
    }

    // remplir le vecteur noeuds
    public void remplirnoeuds(int N) {
        for (int i = 0; i < N - 1; i++) {
            noeud n = new noeud("c" + i, 1);
            this.noeuds.addElement(n);
        }
    }

    // remplir les deux ensembles noeudI et noeudF
    public void remplirFI(int p, int nf) {
        for (int j = p; j <= this.noeuds.size() - nf; j++) {
            this.noeudsI.addElement(this.noeuds.elementAt(j));
        }
        for (int k = this.noeuds.size() - nf + 1; k <= this.noeuds.size() - 1; k++) {
            this.noeudsF.addElement(this.noeuds.elementAt(k));
        }
    }

    public void ajouterNoeud(Vector<noeud> v, noeud n) {
        v.addElement(n);
    }

    public void ajouterLien(noeud Np, noeud Nf) {
        this.liens.addElement(new lien(Np, Nf));
    }

    // cette fonction permet de remplir les liens des noeuds internes
    public void remplirLiensNI(int p, int ec, int nbbr) {
        Vector<noeud> I1 = new Vector<noeud>();
        Vector<noeud> I2 = new Vector<noeud>();

        for (int j = p - 1; j < this.noeudsI.size(); j++) {
            noeud n = this.noeudsI.elementAt(j);
            I1.addElement(n);
            this.noeudsI.removeElementAt(j);
            j = j - 1;
        }

        for (int l = 0; l < nbbr - 1; l++) {
            noeud nfils = (noeud) I1.elementAt(l);
            this.noeudsI.addElement(nfils);
            I1.removeElementAt(l);

        }
        for (int k = 0; k < I1.size(); k++) {
            noeud nfils = (noeud) I1.elementAt(k);
            Vector<noeud> Ipere1 = new Vector<noeud>();
            for (int i = 0; i < this.noeudsI.size(); i++) {
                noeud nps = (noeud) this.noeudsI.elementAt(i);

                if ((nps.getProfondeur() < p - ec - 1)
                        && (nps.getNbreFils() == 0)) {
                    System.out.println("noeud:" + nps.getNom()
                            + " a comme profondeur:" + nps.getProfondeur());
                    Ipere1.addElement(nps);
                }
            }
            if (Ipere1.size() != 0) {
                if (Ipere1.size() == 1) {
                    noeud npere = (noeud) Ipere1.elementAt(0);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }

                else {
                    Random rand = new Random();
                    int a = rand.nextInt(Ipere1.size() - 1);
                    noeud npere = (noeud) Ipere1.elementAt(a);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }
            } else {
                Vector<noeud> Ipere2 = new Vector<noeud>();
                for (int h = 0; h < this.noeudsI.size(); h++) {
                    noeud nps1 = (noeud) this.noeudsI.elementAt(h);
                    if ((nps1.getProfondeur() >= p - ec - 1)
                            && (nps1.getProfondeur() < p - 1)) {
                        Ipere2.addElement(nps1);
                    }
                }
                if (Ipere2.size() != 0) {
                    Random rand = new Random();
                    int a = rand.nextInt(Ipere2.size() - 1);
                    noeud npere = (noeud) Ipere2.elementAt(a);
                    this.liens.addElement(new lien(npere, nfils));
                    this.noeudsI.addElement(nfils);
                }
            }
        }
    }

    // permet de remplir les liens des noeuds feuilles avec les noeuds internes
    public void remplirLiensNF(int p, int ec) {
        Vector I2 = new Vector(0);
        int a = 0;
        int r1 = 0;
        Vector<noeud> v = new Vector(0);
        v.addElement(this.noeudsF.elementAt(0));

        if (ec == p - 1) {
            this.noeudsI.addElement((noeud) this.noeudsF.elementAt(1));
            v.addElement(this.noeudsF.elementAt(1));
        }
        for (int i = 0; i < this.noeudsI.size(); i++) {
            noeud npere = this.noeudsI.elementAt(i);
            if (npere.getNbreFils() == 0) {
                I2.addElement(npere);
            }

        }

        for (int j = 0; j < I2.size(); j++) {
            noeud npere = (noeud) I2.elementAt(j);
            boolean ok = false;

            while (ok == false) {
                Random rand = new Random();
                a = rand.nextInt(this.noeudsF.size() - 1);

                noeud nfils = this.noeudsF.elementAt(a);
                if (!v.contains(nfils)) {
                    v.addElement(nfils);
                    this.ajouterLien(npere, nfils);
                    ok = true;
                }

            }
        }

        Vector<noeud> vselect = new Vector(0);
        for (int t = 0; t < this.noeudsI.size(); t++) {
            noeud np = this.noeudsI.elementAt(t);
            if (np.getProfondeur() >= p - ec - 1) {
                vselect.addElement(np);
            }
        }
        for (int k = 1; k < this.noeudsF.size(); k++) {
            noeud nfils = this.noeudsF.elementAt(k);

            if (!v.contains(nfils)) {
                if (vselect.size() != 0) {
                    if (vselect.size() == 1) {
                        noeud npere = vselect.elementAt(0);
                        this.ajouterLien(npere, nfils);
                    } else {
                        Random rand = new Random();
                        r1 = rand.nextInt(vselect.size() - 1);
                        noeud npere = vselect.elementAt(r1);
                        this.ajouterLien(npere, nfils);

                    }
                }

            }
        }

    }

    /*
     * // retourne un vecteur des fils du noeud passé en parametre public Vector
     * prendreListeFils (noeud n){ Vector v = new Vector(0); Iterator it =
     * liens.iterator(); while (it.hasNext()) { lien l = (lien) it.next(); if
     * (l.getPere().equals(n)) v.addElement(l.getFils()); } return v; }
     */

    // retourne la liste des pere
    public noeud prendrePere(noeud n) {
        Iterator it = liens.iterator();
        while (it.hasNext()) {
            lien l = (lien) it.next();
            if (l.getFils().equals(n)) {
                return (l.getPere());
            }
        }
        return null;

    }

    public int ecart(int p, Vector<noeud> v) {
        Iterator it = v.iterator();
        noeud n = (noeud) it.next();
        int min = n.getProfondeur();
        while (it.hasNext()) {
            noeud m = (noeud) it.next();
            if (m.getProfondeur() < min) {
                min = m.getProfondeur();
            }
        }
        return (p - min);

    }

    float calcul_rapport2(Vector<noeud> NI, Vector<noeud> NF, Vector<lien> L) {
        Iterator it = NI.iterator();
        float min;
        float max = 0;
        noeud n0 = (noeud) NI.elementAt(1);
        min = (float) n0.getNbreFils();

        while (it.hasNext()) {
            noeud ni = (noeud) it.next();
            Iterator it1 = L.iterator();
            int cpt = 0;
            while (it1.hasNext()) {
                lien l = (lien) it1.next();
                if (l.getPere().getNom() == ni.getNom()) {
                    Iterator it2 = NF.iterator();
                    boolean trouve = false;
                    while ((it2.hasNext()) && (trouve == false)) {
                        noeud nf = (noeud) it2.next();
                        if (nf.getNom() == l.getFils().getNom()) {
                            trouve = true;
                        }
                    }
                    if (trouve == false) {
                        cpt++;
                    }
                }

            }

            if (cpt > max) {
                max = cpt;
            }
            if ((cpt < min) && (cpt != 0)) {
                min = cpt;
            }

        }
        int cpt1 = 0;
        for (int i = 0; i < NI.size(); i++) {
            noeud ni = (noeud) NI.elementAt(i);
            if (ni.getProfondeur() == 1) {
                cpt1++;
            }
        }
        if (cpt1 < min) {
            min = cpt1;
        }
        if (cpt1 > max) {
            max = cpt1;
        }

        return (max / min);
    }

    public void export_caracteristiques(int i, int p, int n, int nf) {
        StringWriter sw = new StringWriter();
        sw.write("carectériqtique de l'ontologie:" + i + "\n");
        sw.write("nombre noeud :" + n + "\n");
        sw.write("nombre feuilles :" + nf + "\n");
        sw.write("Profondeur :" + p + "\n");
        int moy = (n - 1) / (n - nf);
        sw.write("moyenne des fils par noeud :" + moy + "\n");
        sw.write("ecart profondeur moins minimum prof des feuilles :"
                + ecart(p, this.noeudsF) + "\n");
        sw.write("Max(nbre de noeud par fils(ss feuilles))/Min(nbre de noeud par fils(ss feuilles)):"
                + calcul_rapport2(this.noeudsI, this.noeudsF, this.liens)
                + "\n");
        System.out.println(sw.toString());
        try {
            FileOutputStream fos = new FileOutputStream(new File(
                    "E:\\WorkPFA\\caractO" + i + ".txt"));
            fos.write(sw.toString().getBytes());
            fos.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }

    }

    public void export(int i) {
        StringWriter sw = new StringWriter();
        sw.write("<?xml version=\"1.0\"?>\n");
        sw.write("<rdf:RDF\n");
        sw.write("xmlns:xsp=\"http://www.owl-ontologies.com/2005/08/07/xsp.owl#\"\n");
        sw.write("xmlns:swrlb=\"http://www.w3.org/2003/11/swrlb#\"\n");
        sw.write("xmlns=\"http://www.owl-ontologies.com/Ontology" + i
                + ".owl#\"\n");
        sw.write("xmlns:swrl=\"http://www.w3.org/2003/11/swrl#\" \n");
        sw.write("xmlns:protege=\"http://protege.stanford.edu/plugins/owl/protege#\"\n");
        sw.write("xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n");
        sw.write("xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\n");
        sw.write("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\"\n");
        sw.write("xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n");
        sw.write("xml:base=\"http://www.owl-ontologies.com/Ontology" + i
                + ".owl\">");
        Vector v = new Vector(0);
        for (int j = 0; j < this.noeudsF.size(); j++) {
            noeud nouv = this.noeudsF.elementAt(j);
            sw.write("<owl:Class rdf:ID=\"" + nouv.getNom() + "\">\n");
            noeud npere = this.prendrePere(nouv);
            sw.write("<rdfs:subClassOf>\n");
            if (!v.contains(npere)) {
                sw.write("<owl:Class rdf:ID=\"" + npere.getNom() + "\"/>\n");
                sw.write("</rdfs:subClassOf>\n");
                v.addElement(npere);
            } else {
                sw.write("<owl:Class rdf:about=\"#" + npere.getNom() + "\"/>\n");
                sw.write("</rdfs:subClassOf>\n");
            }
            sw.write("</owl:Class>\n");
        }

        for (int k = 0; k < this.noeudsI.size(); k++) {
            noeud nouvI = this.noeudsI.elementAt(k);
            System.out.println("concept : " + nouvI.getNom() + "profondeur:"
                    + nouvI.getProfondeur());
            if (nouvI.getProfondeur() != 1) {
                if (!v.contains(nouvI)) {
                    sw.write("<owl:Class rdf:ID=\"" + nouvI.getNom() + "\">\n");
                } else {
                    sw.write("<owl:Class rdf:about=\"#" + nouvI.getNom()
                            + "\">\n");
                }
                noeud npereI = this.prendrePere(nouvI);

                sw.write("<rdfs:subClassOf>\n");
                if (!v.contains(npereI)) {
                    sw.write("<owl:Class rdf:ID=\"" + npereI.getNom()
                            + "\"/>\n");
                    sw.write("</rdfs:subClassOf>\n");
                    v.addElement(npereI);
                } else {
                    sw.write("<owl:Class rdf:about=\"#" + npereI.getNom()
                            + "\"/>\n");
                    sw.write("</rdfs:subClassOf>\n");
                }
                sw.write("</owl:Class>\n");
            }
        }
        sw.write("</rdf:RDF>");
        System.out.println(sw.toString());
        try {
            FileOutputStream fos = new FileOutputStream(new File(
                    "E:\\WorkPFA\\O" + i + ".owl"));
            fos.write(sw.toString().getBytes());
            fos.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }

    }

    /**
     * @param args
     */
}

"

3)
Class "noeud.java":
"
public class noeud {
    // private static int numero;
    private boolean feuille;
    private String nom;
    private int nbreFils;
    private int profondeur;

    /*
     * Constructeur
     */
    public noeud(String ch, int p) {
        // this.numero++;
        this.nom = ch;
        this.profondeur = p;
        this.feuille = true;
        this.nbreFils = 0;
    }

    /**
     * @return the nom
     */
    public String getNom() {
        return nom;
    }

    /**
     * @param nom
     *            the nom to set
     */
    public void setNom(String nom) {
        this.nom = nom;
    }

    public boolean isFeuille() {
        return feuille;
    }

    public void setFeuille(boolean feuille) {
        this.feuille = feuille;
    }

    /**
     * @return the nbreFils
     */
    public int getNbreFils() {
        return nbreFils;
    }

    /**
     * @param nbreFils
     *            the nbreFils to set
     */
    public void setNbreFils(int nbreFils) {
        this.nbreFils = nbreFils;
    }

    /**
     * @return the profondeur
     */
    public int getProfondeur() {
        return profondeur;
    }

    /**
     * @param profondeur
     *            the profondeur to set
     */
    public void setProfondeur(int profondeur) {
        this.profondeur = profondeur;
    }

}

"

4)
Class "lien.java" :
"
public class lien {
    private noeud pere;
    private noeud fils;

    /*
     * Constructeur
     */
    public lien(noeud Npere, noeud Nfils) {
        this.pere = Npere;
        this.fils = Nfils;
        Npere.setNbreFils(Npere.getNbreFils() + 1);
        Nfils.setProfondeur(Npere.getProfondeur() + 1);
        Npere.setFeuille(false);

    }

    public noeud getPere() {
        return pere;
    }

    public void setPere(noeud pere) {
        this.pere = pere;
    }

    public noeud getFils() {
        return fils;
    }

    public void setFils(noeud fils) {
        this.fils = fils;
    }
}

"

Best regards.
_______________________________________________ protege-owl mailing list


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

Jennifer Vendetti
Administrator
Hello Chab,

On 6/1/2011 9:37 PM, chab nasri wrote:
Call constructeur() in the initialize() method.


- Do I have to add the four classes ("constructeur.java", "arbre.java", "noeud.java" and "lien.java") in the project that contains the class "DisplayNameTab.java " ?


I assume your intention is to build a tab widget plug-in to display your "Generation" program from within Protege?

You are not required to use the source code provided in the example on our wiki (http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin).  The intention of the wiki page is simply to provide step-by-step instructions for building an example tab widget plug-in in the Eclipse development environment.  Once you've successfully built an example and understand the process, the assumption is that you would then move on to creating a new Eclipse project to build your own plug-in following similar steps.

You can create whatever package name/structure you want for your plug-in.  Building on the example provided on the wiki page, your package structure might look something like:

mytab.generation
    Arbre.java
    Constructeur.java
    Lien.java
    Noeud.java
META-INF
    MANIFEST.MF

Screen shot of what this might look like in Eclipse:

Generation project in Protege

Note that I used the code you provided for this example, but you should consider changing your code to capitalize type names, i.e., "Constructeur.java", etc.

If you look at the Protege source code, the AbstractTabWidget class extends JPanel and provides an initialize() method in which you typically call your code for building your user interface.  You could modify your constructeur class to extend AbstractTabWidget instead of JFrame and call your buildContentPane() method from the initialize() method.  If the way I've stated this is unclear, I've attached a modified version of your constructeur class with the implementation.



- The class "constructeur.java" already contains a "main" this does not pose a problem because the class "DisplayNameTab.java" also contains a "main" ?

It doesn't matter how many main methods there are in your code.  Eclipse will choose the main method to call based on what you specified in your run configuration (see "Step 5.  Run the plug-in" on the wiki page mentioned above).

You could change the main method in constructeur to launch Protege, i.e.:

public static void main(String[] args) {
        edu.stanford.smi.protege.Application.main(args);
}

Your run configuration would look like this:

Generation plug-in run configuration

Screen shot of your Generation plug-in running in Protege:

Generation Tab in Protege


You may also want to refer to the Eclipse documentation for creating Java projects if you have questions on how to organize your source code, etc.

Jennifer


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

MANIFEST.MF (92 bytes) Download Attachment
constructeur.java (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri
Hello,

Yes, I would like to build a tab widget plug-in to display my "Generation" program from within Protege. I want to work with OWL ontologies.

I created a new project named "GenerationExample" as you said but the same problem persists : when I run Protégé I don't find my plugin "Generation" among the list of existing plugin and then the desired interface is not displayed.

Also, I remember when I export my project as a jar file so I have the following message at the end:  "JAR export finished with warnings. See details for additional information.   Exported with compile warnings: GenerationExample/src/mytab/generation/Arbre.java "

Why my plugin dont appear in the list of plug-in ?
 
I have attached the final version of my project to check it. You can send me the project again after the checking.
Please, you send me also the jar file with the file "plugin.properties" if it is necessary in order to avoid each time to launch the program from Eclipse  to view my plug-in.

Best regards.



2011/6/2 Jennifer Vendetti <[hidden email]>
Hello Chab,


On 6/1/2011 9:37 PM, chab nasri wrote:
Call constructeur() in the initialize() method.


- Do I have to add the four classes ("constructeur.java", "arbre.java", "noeud.java" and "lien.java") in the project that contains the class "DisplayNameTab.java " ?


I assume your intention is to build a tab widget plug-in to display your "Generation" program from within Protege?

You are not required to use the source code provided in the example on our wiki (http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin).  The intention of the wiki page is simply to provide step-by-step instructions for building an example tab widget plug-in in the Eclipse development environment.  Once you've successfully built an example and understand the process, the assumption is that you would then move on to creating a new Eclipse project to build your own plug-in following similar steps.

You can create whatever package name/structure you want for your plug-in.  Building on the example provided on the wiki page, your package structure might look something like:

mytab.generation
    Arbre.java
    Constructeur.java
    Lien.java
    Noeud.java
META-INF
    MANIFEST.MF

Screen shot of what this might look like in Eclipse:

Generation project in Protege

Note that I used the code you provided for this example, but you should consider changing your code to capitalize type names, i.e., "Constructeur.java", etc.

If you look at the Protege source code, the AbstractTabWidget class extends JPanel and provides an initialize() method in which you typically call your code for building your user interface.  You could modify your constructeur class to extend AbstractTabWidget instead of JFrame and call your buildContentPane() method from the initialize() method.  If the way I've stated this is unclear, I've attached a modified version of your constructeur class with the implementation.




- The class "constructeur.java" already contains a "main" this does not pose a problem because the class "DisplayNameTab.java" also contains a "main" ?

It doesn't matter how many main methods there are in your code.  Eclipse will choose the main method to call based on what you specified in your run configuration (see "Step 5.  Run the plug-in" on the wiki page mentioned above).

You could change the main method in constructeur to launch Protege, i.e.:


public static void main(String[] args) {
        edu.stanford.smi.protege.Application.main(args);
}

Your run configuration would look like this:

Generation plug-in run configuration

Screen shot of your Generation plug-in running in Protege:

Generation Tab in Protege


You may also want to refer to the Eclipse documentation for creating Java projects if you have questions on how to organize your source code, etc.

Jennifer


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03



_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

GenerationExample.rar (24K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Integration of a plug-in in the editor Protege version 3.4.1

chab nasri

Hello,

Sorry, it is urgent I do not have time yet. I must have a solution to my problem before the deadlines.

Thank you for your understanding.

Best regards.

2011/6/5 chab nasri <[hidden email]>
Hello,

Yes, I would like to build a tab widget plug-in to display my "Generation" program from within Protege. I want to work with OWL ontologies.

I created a new project named "GenerationExample" as you said but the same problem persists : when I run Protégé I don't find my plugin "Generation" among the list of existing plugin and then the desired interface is not displayed.

Also, I remember when I export my project as a jar file so I have the following message at the end:  "JAR export finished with warnings. See details for additional information.   Exported with compile warnings: GenerationExample/src/mytab/generation/Arbre.java "

Why my plugin dont appear in the list of plug-in ?
 
I have attached the final version of my project to check it. You can send me the project again after the checking.
Please, you send me also the jar file with the file "plugin.properties" if it is necessary in order to avoid each time to launch the program from Eclipse  to view my plug-in.

Best regards.



2011/6/2 Jennifer Vendetti <[hidden email]>
Hello Chab,


On 6/1/2011 9:37 PM, chab nasri wrote:
Call constructeur() in the initialize() method.


- Do I have to add the four classes ("constructeur.java", "arbre.java", "noeud.java" and "lien.java") in the project that contains the class "DisplayNameTab.java " ?


I assume your intention is to build a tab widget plug-in to display your "Generation" program from within Protege?

You are not required to use the source code provided in the example on our wiki (http://protegewiki.stanford.edu/wiki/SetUpEclipseForPlugin).  The intention of the wiki page is simply to provide step-by-step instructions for building an example tab widget plug-in in the Eclipse development environment.  Once you've successfully built an example and understand the process, the assumption is that you would then move on to creating a new Eclipse project to build your own plug-in following similar steps.

You can create whatever package name/structure you want for your plug-in.  Building on the example provided on the wiki page, your package structure might look something like:

mytab.generation
    Arbre.java
    Constructeur.java
    Lien.java
    Noeud.java
META-INF
    MANIFEST.MF

Screen shot of what this might look like in Eclipse:

Generation project in Protege

Note that I used the code you provided for this example, but you should consider changing your code to capitalize type names, i.e., "Constructeur.java", etc.

If you look at the Protege source code, the AbstractTabWidget class extends JPanel and provides an initialize() method in which you typically call your code for building your user interface.  You could modify your constructeur class to extend AbstractTabWidget instead of JFrame and call your buildContentPane() method from the initialize() method.  If the way I've stated this is unclear, I've attached a modified version of your constructeur class with the implementation.




- The class "constructeur.java" already contains a "main" this does not pose a problem because the class "DisplayNameTab.java" also contains a "main" ?

It doesn't matter how many main methods there are in your code.  Eclipse will choose the main method to call based on what you specified in your run configuration (see "Step 5.  Run the plug-in" on the wiki page mentioned above).

You could change the main method in constructeur to launch Protege, i.e.:


public static void main(String[] args) {
        edu.stanford.smi.protege.Application.main(args);
}

Your run configuration would look like this:

Generation plug-in run configuration

Screen shot of your Generation plug-in running in Protege:

Generation Tab in Protege


You may also want to refer to the Eclipse documentation for creating Java projects if you have questions on how to organize your source code, etc.

Jennifer


_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03




_______________________________________________
protege-owl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-owl

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
12