1717 */
1818package scouter .client ;
1919
20+ import org .eclipse .core .runtime .IExtension ;
2021import org .eclipse .core .runtime .Platform ;
22+ import org .eclipse .jface .action .IContributionItem ;
23+ import org .eclipse .jface .action .MenuManager ;
2124import org .eclipse .swt .graphics .Point ;
2225import org .eclipse .swt .widgets .Display ;
26+ import org .eclipse .ui .IWorkbenchWindow ;
2327import org .eclipse .ui .WorkbenchException ;
2428import org .eclipse .ui .application .ActionBarAdvisor ;
2529import org .eclipse .ui .application .IActionBarConfigurer ;
2630import org .eclipse .ui .application .IWorkbenchWindowConfigurer ;
2731import org .eclipse .ui .application .WorkbenchWindowAdvisor ;
32+ import org .eclipse .ui .internal .WorkbenchPlugin ;
33+ import org .eclipse .ui .internal .WorkbenchWindow ;
34+ import org .eclipse .ui .internal .registry .ActionSetRegistry ;
35+ import org .eclipse .ui .internal .registry .IActionSetDescriptor ;
2836import scouter .Version ;
2937import scouter .client .misc .UpdateCheckScheduler ;
3038import scouter .client .notice .NoticeCheckScheduler ;
@@ -65,7 +73,10 @@ public ActionBarAdvisor createActionBarAdvisor(
6573
6674 IWorkbenchWindowConfigurer configurer ;
6775
76+ @ SuppressWarnings ("restriction" )
6877 public void preWindowOpen () {
78+ removeUnwantedActionSets ();
79+
6980 configurer = getWindowConfigurer ();
7081 configurer .setInitialSize (new Point (1440 , 900 ));
7182 configurer .setShowMenuBar (true );
@@ -79,8 +90,53 @@ public void preWindowOpen() {
7990 configurer .setTitle ("Version - " +Version .getClientFullVersion () + "(" + TimeZone .getDefault ().getDisplayName () + ")" );
8091 }
8192
93+ @ SuppressWarnings ("restriction" )
8294 public void postWindowOpen () {
8395 super .postWindowOpen ();
96+ removeUnwantedMenus ();
97+ }
98+
99+ @ SuppressWarnings ("restriction" )
100+ private void removeUnwantedMenus () {
101+ IWorkbenchWindow window = getWindowConfigurer ().getWindow ();
102+ if (window instanceof WorkbenchWindow ) {
103+ MenuManager menuManager = ((WorkbenchWindow ) window ).getMenuManager ();
104+ String [] idsToRemove = {
105+ "org.eclipse.search.menu" ,
106+ "org.eclipse.ui.run"
107+ };
108+ for (String id : idsToRemove ) {
109+ IContributionItem item = menuManager .find (id );
110+ if (item != null ) {
111+ menuManager .remove (item );
112+ }
113+ }
114+ // Also remove by label for any remaining items
115+ for (IContributionItem item : menuManager .getItems ()) {
116+ if (item instanceof MenuManager ) {
117+ String label = ((MenuManager ) item ).getMenuText ();
118+ if (label != null && (label .equals ("Search" ) || label .equals ("Run" )
119+ || label .equals ("&Search" ) || label .equals ("&Run" ))) {
120+ menuManager .remove (item );
121+ }
122+ }
123+ }
124+ menuManager .update (true );
125+ }
126+ }
127+
128+ @ SuppressWarnings ("restriction" )
129+ private void removeUnwantedActionSets () {
130+ ActionSetRegistry reg = WorkbenchPlugin .getDefault ().getActionSetRegistry ();
131+ IActionSetDescriptor [] actionSets = reg .getActionSets ();
132+ for (IActionSetDescriptor actionSet : actionSets ) {
133+ String id = actionSet .getId ();
134+ if (id .startsWith ("org.eclipse.search" ) || id .startsWith ("org.eclipse.ui.run" )
135+ || id .startsWith ("org.eclipse.debug" ) || id .startsWith ("org.eclipse.ui.externaltools" )) {
136+ IExtension ext = actionSet .getConfigurationElement ().getDeclaringExtension ();
137+ reg .removeExtension (ext , new Object []{actionSet });
138+ }
139+ }
84140 }
85141
86142 public void dispose () {
0 commit comments