Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

java - How to remove a Category from Import wizard in Eclipse-RCP?

I need to add an import wizard into my eclipse-rcp app. For that I would like to use existing wizard with only my categories. I found couple of examples in the Internet, but they didn't help much.

My problem is that I have not only my category, but also the General category. I would like to remove it, if possible. Actually I have found one solution here, but it seems, that it is not working. I've tried to put provided code snippet in WorkbrenchWindowAdvisor and in ActionBarAdvisor and even execute it before my wizard is created, but General category with 5 possible wizards is still there. Any suggestions, how to remove it or at least hide?

BR, AlexG.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can choose which contributions are visible in your RCP application by using org.eclipse.ui.activities extension point with appropriate activityPatternBinding (despite of what they say at the page that you linked).

Using this extension point you can define one activity with a pattern that matches anything but your own contributions (e.g. pattern="[^.]++.(?!myplugin).*" matches contributions wiht ID-s not starting with com.myplugin). This activity, when not being enabled, will exclude all the contributions from UI except your own.

With another acitvity you will define a pattern that includes the contributions that you'd like to include from other plugins (e.g. pattern=".*file.import" matches the Import... menu item in File menu). This is the activity that you will enable in your WorkbenchAdvisor using

PlatformUI.getWorkbench().getActivitySupport().setEnabledActivityIds(...);

Please note that this particular solution will disable (almost) all of the Eclipse contributions except File > Import... It will take quite a bit of digging if you want to have a lot of functionality enabled and only small parts disabled. But it's mostly possible to figure out correct patterns to achieve this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...