Search code examples
eclipseeclipse-plugineclipse-rcp

Hiding the tool bar entries from plugin


How can we hide the tool bar entries in eclipse from plugin as shown in the image. enter image description here

In the tool bar how can we hide only the perspective as shown in figure. enter image description here


Solution

  • this helped me in hiding perspective toolbar entries.

        IWorkbenchWindow window = PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow();
                if (window instanceof WorkbenchWindow) {
                    MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();
                for (MTrimElement element : topTrim.getChildren()) {
                    if ("PerspectiveSwitcher".equals(element.getElementId())) {                     
                        element.setVisible(false);
                        break;
                    }
                }