2

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

谢谢您的帮助。医学博士

4

3 回答 3

0

您当然应该查看活动

于 2010-02-10T11:31:31.383 回答
0

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

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

这基本上是一个 hack,但它可以让你做你想做的事,而无需触及 subversion 插件。我不知道贡献的名称(您必须在插件的源代码中查找它们),但代码如下所示:

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) });
}
于 2009-09-28T09:13:03.160 回答
0

为什么你需要这样做?您不能简单地让您的用户无权使用 svn 权限提交吗?

于 2009-09-25T16:14:16.997 回答