Example usage for org.eclipse.jface.action SubToolBarManager getParent

List of usage examples for org.eclipse.jface.action SubToolBarManager getParent

Introduction

In this page you can find the example usage for org.eclipse.jface.action SubToolBarManager getParent.

Prototype

public IContributionManager getParent() 

Source Link

Document

Returns the parent manager.

Usage

From source file:com.nokia.tools.variant.carbidev.ApplicationActionBarAdvisor.java

License:Open Source License

private void hackProperties(IWorkbenchWindow window) {

    window.addPageListener(new IPageListener() {

        public void pageActivated(IWorkbenchPage page) {

            getAndHideProperties(page);//from  ww  w  .  j a v a 2  s . c  o  m

        }

        public void pageClosed(IWorkbenchPage page) {

        }

        public void pageOpened(IWorkbenchPage page) {
            getAndHideProperties(page);

        }

    });

    window.getPartService().addPartListener(new IPartListener() {

        public void partActivated(IWorkbenchPart part) {
            getAndHideProperties(part.getSite().getPage());
        }

        public void partBroughtToTop(IWorkbenchPart part) {
            getAndHideProperties(part.getSite().getPage());
        }

        public void partClosed(IWorkbenchPart part) {
            handlePropertiesVisibility(part);

        }

        private void handlePropertiesVisibility(IWorkbenchPart part) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                if (activeWorkbenchWindow != null) {
                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                    if (activePage != null) {
                        IEditorPart activeEditor = activePage.getActiveEditor();
                        if (activeEditor != null) {
                            return;
                        }
                    }
                }
            }
            if (propertiesControl != null && !propertiesControl.isDisposed()) {
                propertiesControl.setVisible(false);
            } else {
                getAndHideProperties(part.getSite().getPage());
            }
        }

        public void partDeactivated(IWorkbenchPart part) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                if (activeWorkbenchWindow != null) {
                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                    if (activePage != null) {
                        IEditorPart activeEditor = activePage.getActiveEditor();
                        if (activeEditor != null) {
                            return;
                        }
                    }
                }
            }
            if (propertiesControl != null && !propertiesControl.isDisposed()) {
                propertiesControl.setVisible(false);
            } else {
                getAndHideProperties(part.getSite().getPage());
            }
        }

        public void partOpened(IWorkbenchPart part) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                if (activeWorkbenchWindow != null) {
                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                    if (activePage != null) {
                        IEditorPart activeEditor = activePage.getActiveEditor();
                        if (activeEditor != null) {
                            return;
                        }
                    }
                }
            }
            if (part instanceof PropertySheet) {
                PageBookView findView = (PageBookView) part;
                if (findView.getCurrentPage() instanceof PropertySheetPage) {
                    PropertySheetPage currentPage = (PropertySheetPage) findView.getCurrentPage();
                    SubActionBars actionBars = (SubActionBars) currentPage.getSite().getActionBars();
                    SubToolBarManager toolBarManager = (SubToolBarManager) actionBars.getToolBarManager();
                    IContributionManager parent2 = toolBarManager.getParent();
                    parent2.removeAll();
                    parent2.update(true);
                    propertiesControl = (Composite) currentPage.getControl();
                    propertiesControl.setVisible(false);
                    propertiesControl.addPaintListener(new PaintListener() {

                        public void paintControl(PaintEvent e) {
                            propertiesControl.setVisible(false);

                        }

                    });
                }
            }
        }

    });

}

From source file:com.nokia.tools.variant.carbidev.ApplicationActionBarAdvisor.java

License:Open Source License

private void getAndHideProperties(IWorkbenchPage page) {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow != null) {
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        if (activePage != null) {
            IEditorPart activeEditor = activePage.getActiveEditor();
            if (activeEditor != null) {
                return;
            }/*from  w  w w.  j a  v  a 2 s .  c  om*/
        }
    }
    PageBookView findView = (PageBookView) page.findView("org.eclipse.ui.views.PropertySheet");
    if (findView != null && findView.getCurrentPage() instanceof PropertySheetPage) {
        PropertySheetPage currentPage = (PropertySheetPage) findView.getCurrentPage();
        SubActionBars actionBars = (SubActionBars) currentPage.getSite().getActionBars();
        SubToolBarManager toolBarManager = (SubToolBarManager) actionBars.getToolBarManager();
        IContributionManager parent2 = toolBarManager.getParent();
        parent2.removeAll();
        parent2.update(true);
        propertiesControl = (Composite) currentPage.getControl();
        propertiesControl.setVisible(false);
        propertiesControl.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                propertiesControl.setVisible(false);

            }

        });
    }
}