4

I have an Eclipse plug-in which used to contribute a view. However, in the next version of my plug-in I no longer want to contribute this view as the functionality is being done in a different way. So how do I go about removing the view?

If I simply remove the view declaration from the plugin.xml then it will show up as an error after they upgrade of "Could not create the view com.foobar.view.id" - this is because the view is still listed in their workspace.xml and so Eclipse tries to create it on restart.

If I register that view ID against a dummy view I have created then I have to register this in the plugin.xml, so it will appear in the Windows, Show View, Other list...

Any idea how I could get rid of this old view in a nice way when I don't want to re-use that ID with another view?

Martin Woodward
  • 11,770
  • 31
  • 45

3 Answers3

1

I don't think it is easy to deprecate views in Eclipse. As you have stated it in the question, you could either remove it or not.

Maybe in the next version you could include a dummy view that has some documentation where to look for the functionality next time, set the restorable property in the plugin.xml to false to prevent Eclipse reopening this dummy view next time.

And then a version later you could entirely remove the view.

Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37
  • Yeah, that's one of the options right now but I really hate to leave a view in the Window, Show View, Other list that is basically a "This view intentionally left blank" view :-) Going to keep playing but glad I'm not just being dumb. – Martin Woodward May 17 '12 at 08:55
  • 1
    Yes, I know that is not a real solution. You could either completely remove it, or fake its removal, but AFAIK there is nothing in the middle ground. – Zoltán Ujhelyi May 17 '12 at 11:49
1

In the end I pulled the old activity trick out the bag and have a solution that is acceptable. Documenting it here for posterity, but love to hear if someone comes up with a better way.

First of call, create a blank ViewPage that does nothing much but says "This view intentionally left blank" or some other useful information for the user so they know that the upgrade was successful, just that the view can be closed. In our case we explain where to find the equivalent functionality now and have a link that they can click on that will take them to that part of the application.

Second, register this view class as the implementation of the old view ID, and mark it as not restorable, i.e.

<view
  allowMultiple="false"
  category="com.foobar.category"
  class="com.foobar.ui.views.DeprecatedView"
  id="com.foobar.ui.views.OldView"
  name="My Old View"
  restorable="false"/>

Finally, we need to pull the activity trick out of the bag. Create a new activity and put your view into it. This will filter your old view out of the Show View, Other... Dialog so that new users won't see it again. For example:

<extension 
  point="org.eclipse.ui.activities">

  <activity
    name="Deprecated"
    description="Supress old views that are no longer used."
    id="com.foobar.hidden">
  </activity>

  <activityPatternBinding
    activityId="com.foobar.hidden"
    pattern="com.foorbar.plugin/com.foobar.ui.views.OldView"
    isEqualityPattern="true">
  </activityPatternBinding>

</extension>

The user experience is that after upgrade, if the old view was visible then the user gets a nice message explaining why and telling them what to do (i.e. close the old view and move along). Either way, when they close Eclipse and restart that view is no longer displayed in the perspective. New users never see the view or any hints of it in the Show View dialog so after a couple of releases when I'm confident everyone has upgraded I can remove the deprecated view registration from the plugin.xml etc.

It's the best experience I could come up with - but happy to hear if people think of a better one. If you want to read more about Eclipse activity filtering then take a look here - it's the only way I could find for filtering a registered view when I stepped through the ViewRegistry and ShowViewDialog code.

Martin Woodward
  • 11,770
  • 31
  • 45
  • This doesn't work in Juno. Looks like this is because Views and ViewCategories are not IPluginContribution's :-( I don't think there is anyway in the current build of Juno to filter a view from the Show View dialog. – Martin Woodward Jul 17 '12 at 18:00
-1

What happens if you register your new view with same ID? Also, the error would come only for the first time, it wouldn't come on subsequent restarts.

Ravi
  • 545
  • 3
  • 5