1 11 package org.eclipse.jdt.internal.ui.packageview; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.action.IMenuManager; 16 import org.eclipse.jface.action.MenuManager; 17 import org.eclipse.jface.action.Separator; 18 19 import org.eclipse.ui.IActionBars; 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.actions.ActionGroup; 22 23 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 24 import org.eclipse.jdt.internal.ui.JavaPluginImages; 25 26 31 class LayoutActionGroup extends ActionGroup { 32 33 public static final String VIEWMENU_LAYOUT_GROUP= "layout"; 35 private IAction fFlatLayoutAction; 36 private IAction fHierarchicalLayoutAction; 37 private IAction fShowLibrariesNode; 38 39 LayoutActionGroup(PackageExplorerPart packageExplorer) { 40 fFlatLayoutAction= new LayoutAction(packageExplorer, true); 41 fHierarchicalLayoutAction= new LayoutAction(packageExplorer, false); 42 fShowLibrariesNode= new ShowLibrariesNodeAction(packageExplorer); 43 } 44 45 48 public void fillActionBars(IActionBars actionBars) { 49 super.fillActionBars(actionBars); 50 contributeToViewMenu(actionBars.getMenuManager()); 51 } 52 53 private void contributeToViewMenu(IMenuManager viewMenu) { 54 viewMenu.add(new Separator(VIEWMENU_LAYOUT_GROUP)); 55 56 58 IMenuManager layoutSubMenu= new MenuManager(PackagesMessages.LayoutActionGroup_label); 59 layoutSubMenu.add(fFlatLayoutAction); 60 layoutSubMenu.add(fHierarchicalLayoutAction); 61 62 viewMenu.add(layoutSubMenu); 63 viewMenu.add(fShowLibrariesNode); 64 } 65 } 66 67 class LayoutAction extends Action implements IAction { 68 69 private boolean fIsFlatLayout; 70 private PackageExplorerPart fPackageExplorer; 71 72 public LayoutAction(PackageExplorerPart packageExplorer, boolean flat) { 73 super("", AS_RADIO_BUTTON); 75 fIsFlatLayout= flat; 76 fPackageExplorer= packageExplorer; 77 if (fIsFlatLayout) { 78 setText(PackagesMessages.LayoutActionGroup_flatLayoutAction_label); 79 JavaPluginImages.setLocalImageDescriptors(this, "flatLayout.gif"); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_FLAT_ACTION); 81 } else { 82 setText(PackagesMessages.LayoutActionGroup_hierarchicalLayoutAction_label); 83 JavaPluginImages.setLocalImageDescriptors(this, "hierarchicalLayout.gif"); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.LAYOUT_HIERARCHICAL_ACTION); 85 } 86 setChecked(packageExplorer.isFlatLayout() == fIsFlatLayout); 87 } 88 89 92 public void run() { 93 if (fPackageExplorer.isFlatLayout() != fIsFlatLayout) 94 fPackageExplorer.setFlatLayout(fIsFlatLayout); 95 } 96 } 97 98 class ShowLibrariesNodeAction extends Action implements IAction { 99 100 private PackageExplorerPart fPackageExplorer; 101 102 public ShowLibrariesNodeAction(PackageExplorerPart packageExplorer) { 103 super(PackagesMessages.LayoutActionGroup_show_libraries_in_group, AS_CHECK_BOX); 104 fPackageExplorer= packageExplorer; 105 setChecked(packageExplorer.isLibrariesNodeShown()); 106 } 107 108 111 public void run() { 112 fPackageExplorer.setShowLibrariesNode(isChecked()); 113 } 114 } 115 | Popular Tags |