How to opt out of viewing in the Eclipse plugin

I have an Eclipse plugin that is used to make a presentation. However, in the next version of my plugin, I no longer want to contribute to this view, because the functionality is different. So how do I delete a view?

If I simply delete the view declaration from the plugin.xml file, it will appear as an error after the update “Failed to create view com.foobar.view.id” - this is because the view is still displayed in their workspace.xml and therefore Eclipse is trying to create it upon reboot.

If I register this view identifier with the dummy view I created, I have to register it in the plugin.xml file, so it will appear in the Windows list, Show View, Other ...

Any idea how I could easily get rid of this old view when I don't want to reuse this identifier with another view?

+4
source share
3 answers

In the end, I pulled the old trick out of the bag and got an acceptable solution. Documenting it here for posterity, but love hearing if someone comes up with a better way.

First, create an empty ViewPage from the call that does nothing but says “This view is intentionally left blank” or some other useful information for the user to let them know that the update was successful, just so that the view can be closed. In our case, we will explain where to find the equivalent functionality now and have a link that they can click on, which will lead them to that part of the application.

Secondly, register this view class as the implementation of the old view identifier and mark it as unrecoverable, 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 get the trick out of the bag. Create a new action and put your view on it. This will filter out your old view from the Show View, Other ... dialog box so that new users do not see it again. For instance:

 <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 interface is that after the update, if the old view was visible, the user receives a good message explaining why and what they should tell what to do (i.e. close the old view and move). In any case, when they close Eclipse and restart this view, they no longer appear in perspective. New users never see the view or any hints of it in the Show View dialog box, so after several releases, when I'm sure everything has been updated, I can remove the obsolete view registration from the plugin.xml file, etc.

This is the best experience I could come up with - but I'm glad to hear if people think about the best. If you want to learn more about Eclipse filtering actions , then look here - this is the only way to find filtering of the registered view when I went through the ViewRegistry and ShowViewDialog code.

+1
source

I don't think it's easy to ignore views in Eclipse. As you stated this in the question, you can either delete it or not.

Perhaps in the next version you can include a dummy view that has documentation on where to look for functionality the next time, set the restored property in the plugin.xml file to false to prevent Eclipse from opening this dummy view again the next time.

And then later, you can completely remove the view.

+1
source

What happens if you register a new view with the same identifier? In addition, the error will come only for the first time, it will not appear after subsequent restarts.

-1
source

Source: https://habr.com/ru/post/1412882/


All Articles