如何在Synchronize视图中删除颠覆性操作?

时间:2009-09-25 13:32:17

标签: eclipse eclipse-rcp eclipse-3.4 subversive

我正在将Subversive 0.7.8集成到Eclipse Platform 3.4.2 RCP应用程序中。 我想在“同步”视图的弹出菜单中删除(或禁用)SVN“提交”操作。 我怎么办......?

感谢您的帮助。 JM.D

3 个答案:

答案 0 :(得分:0)

你为什么要这样做? 难道你不能简单地说你的用户没有权利使用svn权限提交吗?

答案 1 :(得分:0)

两种方法:从subversion更改插件内的plugin.xml文件以删除贡献(这意味着您必须保留自己的插件版本),或者您可以从平台中删除特定的贡献。

在启动实际平台之前,删除通常发生在扩展IApplication接口的类中。

这基本上是一个黑客攻击,但它可以让你在不触及颠覆插件的情况下做你想做的事。我不知道贡献的名称(您必须在插件的源代码中查找它们),但代码如下:

IExtensionRegistry extensionRegistry = InternalPlatform.getDefault().getRegistry();

List uiExtensionsToRemove = Arrays.toList(new String[] {"org.eclipse.ui.views.ProgressView" });  // Removing the progress view in this example


String[] tmpNamespaces = extensionRegistry.getNamespaces();
    for (int i = 0; i < tmpNamespaces.length; i++) {
        String tmpNamespace = tmpNamespaces[i];
            try {
                IExtension[] tmpExtensions = extensionRegistry.getExtensions(tmpNamespace);
                for (int j = 0; j < tmpExtensions.length; j++) {
                    IExtension tmpExtension = tmpExtensions[j];
                    ExtensionHandle tmpEHandle = (ExtensionHandle)tmpExtension;
                    String tmpEPUID = tmpEHandle.getExtensionPointUniqueIdentifier();

                    if ("org.eclipse.search.searchPages".equals(tmpEPUID) || "org.eclipse.ui.preferencePages".equals(tmpEPUID) || "org.eclipse.ui.popupMenus".equals(tmpEPUID) || "org.eclipse.ui.actionSets".equals(tmpEPUID)
                            || "org.eclipse.ui.views".equals(tmpEPUID) || "org.eclipse.ui.perspectives".equals(tmpEPUID)) {
                        // only remove part of ui extensions
                        if (tmpEHandle.getNamespace().startsWith("org.eclipse.ui")) {
                            String idOfFirstExtension = tmpEHandle.getConfigurationElements()[0].getAttribute("id");
                            if (!uiExtensionsToRemove.contains(idOfFirstExtension)) {
                                continue;
                            }
                        }
                        removeExtension(tmpEHandle);
                }
            } catch (InvalidRegistryObjectException iroe) {

            }
            //System.out.println("Namespace: " + tmpNamespace);
        }

private void removeExtension(ExtensionHandle extensionHandle) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException {
    if (removeExtensionMethod == null) {
        removeExtensionMethod = extensionRegistry.getClass().getDeclaredMethod("removeExtension", new Class[] { int.class });
        removeExtensionMethod.setAccessible(true);
    }
    // well, this is some magic:
    int tmpExtId = extensionHandle.hashCode();
    removeExtensionMethod.invoke(extensionRegistry, new Object[] { new Integer(tmpExtId) });
}

答案 2 :(得分:0)

你当然应该看看Activities

相关问题