如何删除同步视图中的破坏性操作?

发布于 2024-08-05 07:51:54 字数 130 浏览 2 评论 0原文

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

感谢您的帮助。 JMD

I'm integrating Subversive 0.7.8 into an Eclipse Platform 3.4.2 RCP app.
I want to remove (or disable) the SVN "Commit" action in the popup menu of the "Synchronize" view.
How can I do ... ?

Thank you for your help.
JM.D

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

善良天后 2024-08-12 07:51:54

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

Why would you need to do that ?
Can't you simply make it that your users don't have the right to commit using svn rights ?

千秋岁 2024-08-12 07:51:54

有两种方法:要么更改 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) });
}

Two ways: Either alter the plugin.xml files inside the plugins from subversion to remove the contributions (which means that you have to keep your own version of the plugins), or you can remove specific contributions from the platform.

The removal normally takes place in the class that extends the IApplication interface, before you launch the actual Platform.

This is basically a hack, but it will allow you to do what you want without touching the subversion plugins. I don't know the names of the contributions (You would have to look them up in the source code from the plugins) but the code looks like:

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) });
}
染墨丶若流云 2024-08-12 07:51:54

您当然应该查看活动

You should certainly check out Activities.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文