How to remove subversive action in Synchronize view?

I am integrating Subversive 0.7.8 into an Eclipse Platform 3.4.2 RCP application. I want to remove (or disable) the SVN "Commit" action in the Sync popup menu. How can I do ??

Thank you for your help. JM.D

+2


source to share


3 answers


Why do you need this? Can't you just make it so that your users are not allowed to commit svn use?



0


source


There are two ways: either modify the plugin.xml files inside the plugins from the subversion to remove the contributions (which means you have to keep your own version of the plugins), or remove certain contributions from the platform.

Disposal usually happens in a class that extends the IApplication interface before launching the real platform.



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

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) });
}

      

0


source


You should definitely check Activities .

0


source







All Articles