@Descriptor(ConsoleMsg.CONSOLE_HELP_DISABLE_COMMAND_DESCRIPTION) public void disableBundle(@Descriptor(ConsoleMsg.CONSOLE_HELP_DISABLE_COMMAND_ARGUMENT_DESCRIPTION) long[] bundleIds) throws Exception { if (bundleIds.length == 0) { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } PlatformAdmin platformAdmin = activator.getPlatformAdmin(); if (platformAdmin == null) { System.out.println(ConsoleMsg.CONSOLE_CANNOT_DISABLE_NO_PLATFORM_ADMIN_MESSAGE); return; } State systemState = platformAdmin.getState(false); for (long bundleId : bundleIds) { BundleDescription bundle = systemState.getBundle(bundleId); if (bundle == null) { System.out.println(NLS.bind(ConsoleMsg.CONSOLE_CANNOT_FIND_BUNDLE_ERROR, bundleId)); continue; } DisabledInfo info = new DisabledInfo(POLICY_CONSOLE, ConsoleMsg.CONSOLE_CONSOLE_BUNDLE_DISABLED_MESSAGE, bundle); platformAdmin.addDisabledInfo(info); } }
public void _disableBundle(CommandInterpreter ci) throws Exception { String nextArg = ci.nextArgument(); if (nextArg == null) { ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } try { State systemState = getPlatformAdmin(ci).getState(false); while (nextArg != null) { BundleDescription bundleDesc = getBundleDescriptionFromToken(systemState, nextArg); if (bundleDesc == null) { ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR, nextArg)); nextArg = ci.nextArgument(); continue; } DisabledInfo info = new DisabledInfo(POLICY_CONSOLE, EclipseAdaptorMsg.ECLIPSE_CONSOLE_BUNDLE_DISABLED_MESSAGE, bundleDesc); getPlatformAdmin(ci).addDisabledInfo(info); nextArg = ci.nextArgument(); } } finally { ungetPlatformAdmin(); } }
public void _disableBundle(CommandInterpreter ci) throws Exception { String nextArg = ci.nextArgument(); if (nextArg == null) { ci.println(EclipseAdaptorMsg.ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } try { State systemState = getPlatformAdmin(ci).getState(false); while (nextArg != null) { BundleDescription bundleDesc = getBundleDescriptionFromToken(systemState, nextArg); if (bundleDesc == null) { ci.println(NLS.bind(EclipseAdaptorMsg.ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR, nextArg)); nextArg = ci.nextArgument(); continue; } DisabledInfo info = new DisabledInfo(POLICY_CONSOLE, EclipseAdaptorMsg.ECLIPSE_CONSOLE_BUNDLE_DISABLED_MESSAGE, bundleDesc); getPlatformAdmin(ci).addDisabledInfo(info); nextArg = ci.nextArgument(); } } finally { ungetPlatformAdmin(); } }
@Override public void setEnabled(long id, boolean enabled) { State state = PDERuntimePlugin.getDefault().getState(); BundleDescription desc = state.getBundle(id); if (enabled) { DisabledInfo[] infos = state.getDisabledInfos(desc); for (DisabledInfo info : infos) { PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); platformAdmin.removeDisabledInfo(info); } } else { DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$ PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin(); platformAdmin.addDisabledInfo(info); } org.osgi.framework.Bundle b = PDERuntimePlugin.getDefault().getBundleContext().getBundle(id); PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin(); packageAdmin.refreshPackages(new org.osgi.framework.Bundle[] {b}); } }