Hello.
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
Hello.
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
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 ?
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) });
}
really cool stuff man! this reflection trick allowed me to remove the unwanted popup menus from org.eclipse.team.ui und org.eclipse.compare in my rcp thanks so much!