إزالة Popupmenus من CNF (Framework Common Navigator) في الكسوف
-
18-09-2019 - |
سؤال
لقد نجحت جزئيا في إزالة جميع القوائم المنبثقة تقريبا من إطار المستكشف العموم ببساطة عن طريق تكوين plugin.xml
ملف.
هناك 2 قوائم ترفض الذهاب:
group.edit
وgroup.reorganize
.
لي plugin.xml
التكوين يشبه هذا:
<extension
point="org.eclipse.ui.navigator.viewer">
<viewer
viewerId="org.eclipse.ui.example.navigator.view">
<popupMenu allowsPlatformContributions="false">
<insertionPoint
name="group.edit" />
<insertionPoint
name="group.reorganize" />
</popupMenu>
</viewer>
<viewerContentBinding
viewerId="org.eclipse.ui.thermo.navigator.view">
<includes>
<contentExtension
pattern="org.eclipse.ui.navigator.resourceContent"/>
</includes>
</viewerContentBinding>
</extension>
وضع allowsPlatformContribution
إلى False يقوم بإيقاف المساهمات التي سيتم إضافتها إلى قائمة السياق إلا بالنسبة group.edit
و group.reorganize
... بدأ هذا في البحث عن خطأ لي.
الحل الواضح هو إزالة نقاط الإدراج من بلدي <popUpMenu>
ولكن بدونهم يلقي التطبيق استثناء:
Throwable: java.lang.IllegalArgumentException: Group not found: group.edit
java.lang.IllegalArgumentException: Group not found: group.edit
at org.eclipse.jface.action.ContributionManager.addToGroup(ContributionManager.java:131)
at org.eclipse.jface.action.ContributionManager.appendToGroup(ContributionManager.java:138)
at org.eclipse.ui.internal.navigator.resources.actions.EditActionGroup.fillContextMenu(EditActionGroup.java:74)
at org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider.fillContextMenu(EditActionProvider.java:50)
at org.eclipse.ui.navigator.NavigatorActionService.addCommonActionProviderMenu(NavigatorActionService.java:205)
at org.eclipse.ui.navigator.NavigatorActionService.fillContextMenu(NavigatorActionService.java:172)
at org.eclipse.ui.internal.navigator.CommonNavigatorManager.fillContextMenu(CommonNavigatorManager.java:258)
at org.eclipse.ui.internal.navigator.CommonNavigatorManager$4.menuAboutToShow(CommonNavigatorManager.java:273)
at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:335)
at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:463)
at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:459)
at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:485)
إنه يلقي نفس الاستثناء لمجموعة إعادة تنظيم.
المحلول
لقد نجحت في إزالة إجراءات "Group.Edit" (نسخ / لصق) وقد فعلت ذلك بهذه الطريقة، باستخدام نقاط تمديد المستكشف المشتركة:
<extension
point="org.eclipse.ui.navigator.viewer">
<viewerActionBinding
viewerId="org.eclipse.ui.navigator.ProjectExplorer">
<includes>
<actionExtension
pattern="my.app.client.actions.MyAppEditActionExtension">
</actionExtension>
</includes>
</viewerActionBinding>
</extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<actionProvider
class="my.app.client.workshop.MyPasteActionProvider"
id="my.app.client.actions.MyAppEditActionExtension"
overrides="org.eclipse.ui.navigator.resources.actions.EditActions"
priority="highest">
<enablement>
<!-- A hack to allways be enabled -->
<not>
<systemTest
property="MyApp"
value="WONT-EVER-BE-SET">
</systemTest>
</not>
</enablement>
</actionProvider>
</extension>
وإضافة "Org.eclipse.ui.navigator.Resources" في تبعيات البرنامج المساعد الخاص بي، قمت بتنفيذ "mypasteactionprovider" مثل هذا:
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider;
/**
* Create the Edit actions (Cut/Copy/Paste)
* and register then globally in the workbench using EditActionProvider.
* <p/>
* Then, removes the Copy/Paste contributions in the pop-up menu.
*/
public class MyPasteActionProvider extends EditActionProvider {
public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu);
// remove Copy/Paste contributions
IContributionItem copyItemRemoved = menu.remove("org.eclipse.ui.CopyAction");
IContributionItem pasteItemRemoved = menu.remove("org.eclipse.ui.PasteAction");
}
}
حسنا، هذا "إمكانية إحباط"، لكنني كنت أحصل على مثبطاتي ؛-) JM.D
نصائح أخرى
عموما يجب أن تستخدم إطار القيادة مع أي إصدار حديث من الكسوف (3.3 أو أعلى)، يستبدل هذا الآلية لتوفير القوائم المنبثقة في المستكشف المشترك.
هذه يوحي الموضوع لإزالة الأشياء التي تسبب في ظهور عناصر القائمة في المقام الأول:
ربما تكون في مجموعات عمل، لذلك إذا كنت تستطيع تحديد مجموعة الإجراءات التي تسبب المساهمة الهجومية، يمكنك القيام بشيء مثل هذا في WorkbenchAdvisor
:
ActionSetRegistry reg = WorkbenchPlugin.getDefault()
.getActionSetRegistry();
IActionSetDescriptor[] actionSets = reg.getActionSets();
String[] removeActionSets = new String[] {
"org.eclipse.ui.cheatsheets.actionSet",
"org.eclipse.ui.edit.text.actionSet.annotationNavigation",
"org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
"org.eclipse.ui.WorkingSetActionSet",
"org.eclipse.update.ui.softwareUpdates", };
for (int i = 0; i < actionSets.length; i++)
{
boolean found = false;
for (int j = 0; j < removeActionSets.length; j++)
{
if (removeActionSets[j].equals(actionSets[i].getId()))
found = true;
}
if (!found)
continue;
IExtension ext = actionSets[i].getConfigurationElement()
.getDeclaringExtension();
reg.removeExtension(ext, new Object[] { actionSets[i] });
}
أقرب خطأ وجدته هو 145233: اجعل طريقة أكثر وضوحا لتحديد المدخلات (لتطبيقات RCP), ، مع اختراق مماثل.
حشرة 143430 (يتطلب CommonNavigator التهيئة أن تكون قابلة للتكيف) هو أكثر عمومية، وسيشير إلى أنه تم تحسين CNF بعد ذلك مع ECLIPSE3.5 (جاليليو).
لذلك لديك أيضا هذه المشكلة مع 3.5 وطبقة CNF مخصصة؟
كما ذكر في المقال "Eclipse CNF: ملحقات المحتوى المستكشف"، تطورت CNF مع ECLIPSE3.5، ويبدو أن هذه المقالة تحتوي على بعض الأشجار مع إدخالات القائمة السياقية العظيمة الحقيقية.