@SuppressWarnings("restriction")
protected void switchPackageExplorerToWorksetMode(
List<String> workingSetNames) {
IWorkbenchPage page = getActivePage();
String viewId = "org.eclipse.jdt.ui.PackageExplorer"; // defined by you
IViewReference ref = page.findViewReference(viewId);
if (ref != null) {
IWorkbenchPart part = ref.getPart(true);
if (part instanceof PackageExplorerPart) {
PackageExplorerPart explorer = (PackageExplorerPart) part;
explorer.rootModeChanged(PackageExplorerPart.WORKING_SETS_AS_ROOTS);