2

I am using Eclipse RCP and EMF models. I have created my own property tabbed sheets than refreshes when an Object is selected in a view. Until here, everything works fine. Then, I wanted to refresh the property tab when I make a change in my model. I added a Model change listener to my main Property sheet page

public class MyTabbedPropertySheet extends TabbedPropertySheet{...}


private void init(){
try{ 
  MyModelChangeListener = new MyModelChangeListener(){
  @Override
  public void refreshUI(){
  try{
    UMLModeler.getTransactionHelper().getEditingDomain().runExclusive(new Runnable() {
      @Override
      public void run(){
      refresh() //This is the eclipse TabbedPropertySheet refresh method
     }
    });
  }catch(){..}
   UMLModeler.getTransactionHelper().getEditingDomain().addResourceSetListener(MyModelChangeListener);
}catch{...}

After that, when I change my object, my property sheet does actually refreshes but I have a NullPointerException in the eclipse class as the currenttab is null.

Method in org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage

public void refresh(){
  currentTab.refresh();
}

So I was wondering how can I get the current tab while this tab is not active (I am doing the modifications in another view). Or is there another way to refresh the property sheet page?

greg-449
  • 109,219
  • 232
  • 102
  • 145
vanvana
  • 128
  • 7
  • Thank you for your answer :) I probably should change the question title as my main question is "How can I get the current tab while this tab is not active" – vanvana Apr 25 '17 at 09:35

1 Answers1

0

You probably need to use the addTabSelectionListener method of TabbedPropertySheetPage to wait for the tab you are interested in to be selected and then update the tab in the selection listener.

You can also call getCurrentTab to find out if there is a current tab (it will return null if there isn't).

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • I did call the getCurrentTab() and it returns null. What I can't understand is how come the refresh is well done if I get the nullPointerException. I see my property view refreshing with the right value and everything seems to go well untill I check the console and see that the current tab has a null value. I am using the selectionchanged method to fill the property tab, but As I see the TabSelectionListener in to check whether a tab selected or not. In this case, I need to do the refresh whiel another element is selected... – vanvana Apr 25 '17 at 12:53