Exception and problems when using getSelectedObject()

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

Exception and problems when using getSelectedObject()

OntoBLW
Hi, I am developing a protege plugin and I want to get the selected object property from an owlobjectPropertySelectorPanel, So I introduced this line to check such requirement JLabel lab=new JLabel(objectPropPanel.getSelectedObject().asOWLObjectProperty().getIRI().getFragment()); An exception at this line was raised(captured from the console or log) NullPointerException: null .....(XYZ.java:81) Could you please help me, was my use of getSelectedObject is incorrect? Thank you in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Exception and problems when using getSelectedObject()

Lorenz B.
Ehm, a NullPointerException should be obvious...
if no property is selected resp. the last was unselected, the returned value will be NULL of course.
Hi, I am developing a protege plugin and I want to get the selected object property from an owlobjectPropertySelectorPanel, So I introduced this line to check such requirement JLabel lab=new JLabel(objectPropPanel.getSelectedObject().asOWLObjectProperty().getIRI().getFragment());An exception at this line was raised(captured from the console or log) NullPointerException: null .....(XYZ.java:81) Could you please help me, was my use of getSelectedObject is incorrect? Thank you in advance.

View this message in context: Exception and problems when using getSelectedObject()
Sent from the Protege Developer mailing list archive at Nabble.com.


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exception and problems when using getSelectedObject()

OntoBLW
In reply to this post by OntoBLW
But, I tried to select a property and the error remains the same.
--------------------------------------------
En date de : Dim 5.2.17, Lorenz B. <[hidden email]> a écrit :

 Objet: Re: [protege-dev] Exception and problems when using getSelectedObject()
 À: [hidden email]
 Date: Dimanche 5 février 2017, 11h44
 
 
   
 
     
   
   
     Ehm, a NullPointerException should be obvious...
 
     if no property is selected resp. the last was
 unselected, the
     returned value will be NULL of course.
 
     Hi,
       I am developing a protege plugin and I want to get the
 selected
       object property from an
 owlobjectPropertySelectorPanel, So I
       introduced this line to check such requirement
       JLabel lab=new
 JLabel(objectPropPanel.getSelectedObject().asOWLObjectProperty().getIRI().getFragment());An
       exception at this line was raised(captured from the
 console or
       log)
       NullPointerException: null ..... (XYZ.java:81)
         Could you please help me, was my use of
 getSelectedObject is
         incorrect?
         Thank you in advance.
 
         
         View this message in context: Exception
           and problems when using getSelectedObject()
 
         Sent from the Protege
           Developer mailing list archive at Nabble.com.
 
         
 
         
         
 
         _______________________________________________
 protege-dev mailing list
 [hidden email]
 https://mailman.stanford.edu/mailman/listinfo/protege-dev
 
       
     
       --
 Lorenz Bühmann
 AKSW group, University of Leipzig
 Group: http://aksw.org - semantic web
 research center
     
   
 
 
 -----La pièce jointe associée suit-----
 
 _______________________________________________
 protege-dev mailing list
 [hidden email]
 https://mailman.stanford.edu/mailman/listinfo/protege-dev
 
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exception and problems when using getSelectedObject()

Lorenz B.
That doesn't matter and it's not clear which view is asked for. You have to handle the case when the value can be NULL in any case.

But, I tried to select a property and the error remains the same.
--------------------------------------------
En date de : Dim 5.2.17, Lorenz B. [hidden email] a écrit :

 Objet: Re: [protege-dev] Exception and problems when using getSelectedObject()
 À: [hidden email]
 Date: Dimanche 5 février 2017, 11h44
 
 
   
 
     
   
   
     Ehm, a NullPointerException should be obvious...
 
     if no property is selected resp. the last was
 unselected, the
     returned value will be NULL of course. 
 
     Hi,
       I am developing a protege plugin and I want to get the
 selected
       object property from an
 owlobjectPropertySelectorPanel, So I
       introduced this line to check such requirement
       JLabel lab=new
 JLabel(objectPropPanel.getSelectedObject().asOWLObjectProperty().getIRI().getFragment());An
       exception at this line was raised(captured from the
 console or
       log)
       NullPointerException: null ..... (XYZ.java:81)
         Could you please help me, was my use of
 getSelectedObject is
         incorrect?
         Thank you in advance. 
 
         
         View this message in context: Exception
           and problems when using getSelectedObject()
 
         Sent from the Protege
           Developer mailing list archive at Nabble.com.
 
         
 
         
         
 
         _______________________________________________
 protege-dev mailing list
 [hidden email]
 https://mailman.stanford.edu/mailman/listinfo/protege-dev
 
        
     
       -- 
 Lorenz Bühmann
 AKSW group, University of Leipzig
 Group: http://aksw.org - semantic web
 research center
     
   
 
 
 -----La pièce jointe associée suit-----
 
 _______________________________________________
 protege-dev mailing list
 [hidden email]
 https://mailman.stanford.edu/mailman/listinfo/protege-dev
 
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev


-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exception and problems when using getSelectedObject()

OntoBLW
Hi,
The problem does not disappear though many tries to fix it.
What I want is to display the object properrty selector panel.Once I select an object property, the main panel will add a panel that contains the list of domains of the selected object property(mainPanel.add(panel)).
I tried to check if the property is different to null before by raising an error window dialog(to say that the slected property is null), so my plugin directly shows this window before even showing the object property selector panel.
Any hints please to repond to my needs: updating my panel with domains list only on selecting a property(for me, even I select, the panel does not add the list)
Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Exception and problems when using getSelectedObject()

Lorenz B.
And you registered a listener to the property selector panel?

Without seeing the code, it's almost impossible to see what you're doing resp. what's going wrong.
If possible, share you're code.

Hi,
The problem does not disappear though many tries to fix it.
What I want is to display the object properrty selector panel.*Once* I
select an object property, the main panel will add a panel that contains the
list of domains of the selected object property(mainPanel.add(panel)).
I tried to check if the property is different to null before by raising an
error window dialog(to say that the slected property is null), so my plugin
directly shows this window before even showing the object property selector
panel.
Any hints please to repond to my needs: updating my panel with domains list
only on selecting a property(for me, even I select, the panel does not add
the list)
Thanks in advance.



--
View this message in context: http://protege-project.136.n4.nabble.com/Exception-and-problems-when-using-getSelectedObject-tp4667421p4667499.html
Sent from the Protege Developer mailing list archive at Nabble.com.
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev

-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Exception and problems when using getSelectedObject()

OntoBLW
Hi,
First, I thank you very much for your interest.
I could not attach a listener to the OWLObjectSelectorPanel. I think that it would relsove the problem. But, how could I attach a listener.
I tried the code by replacing objectPropPanel.getSelectedObject() by getOWLWorkspace.getSelectedModel.getLastSelectedObjectPropery. So, it worked but not as wanted(it should receive as object property that I selected from my own objectPropPanel
here is the code
private JPanel createPrincipalPanel() {
         JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
         objectPropertySelector  = new JPanel(new BorderLayout(10, 10));
          objectPropPanel = new OWLObjectPropertySelectorPanel(editorKit, false);
           objectPropertySelector.add(objectPropPanel);
          mainPanel.add(objectPropertySelector);
     
           JPanel    objectPropertyDomainsPanel  = new JPanel(new BorderLayout(10, 10));
            PreviewDomains prevDom = new PreviewDomains(objectPropPanel.getSelectedObject().getDomains(editorKit.getOWLModelManager().getActiveOntology()), editorKit);//At this line the problem is
          objectPropertyDomainsPanel.add(prevDom);
           mainPanel.add(objectPropertyDomainsPanel);
                        //JOptionPaneEx.showConfirmDialog(editorKit.getOWLWorkspace(), "error : you have selected no properties", null, JOptionPane.ERROR_MESSAGE, JOptionPane.OK_OPTION, null); This is for test  
        return mainPanel;
          
          
      }
  Thank you again
Reply | Threaded
Open this post in threaded view
|

Re: Exception and problems when using getSelectedObject()

OntoBLW
Hi again,
Could you tell me please are there any problems in my code that prevent what I would like to do.
 thanks in advance.