Search in sources :

Example 1 with Selector

use of org.eclipse.e4.ui.workbench.Selector in project portfolio by buchen.

the class LifeCycleManager method removePortfolioPartsWithoutPersistedFile.

private void removePortfolioPartsWithoutPersistedFile(MApplication app, EPartService partService, EModelService modelService) {
    List<MPart> parts = modelService.findElements(app, MPart.class, EModelService.IN_ACTIVE_PERSPECTIVE, new Selector() {

        @Override
        public boolean select(MApplicationElement element) {
            if (// $NON-NLS-1$
            !"name.abuchen.portfolio.ui.part.portfolio".equals(element.getElementId()))
                return false;
            // $NON-NLS-1$
            return element.getPersistedState().get("file") == null;
        }
    });
    for (MPart part : parts) {
        MElementContainer<MUIElement> parent = part.getParent();
        if (parent.getSelectedElement().equals(part))
            parent.setSelectedElement(null);
        parent.getChildren().remove(part);
    }
}
Also used : MApplicationElement(org.eclipse.e4.ui.model.application.MApplicationElement) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MUIElement(org.eclipse.e4.ui.model.application.ui.MUIElement) Selector(org.eclipse.e4.ui.workbench.Selector)

Aggregations

MApplicationElement (org.eclipse.e4.ui.model.application.MApplicationElement)1 MUIElement (org.eclipse.e4.ui.model.application.ui.MUIElement)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 Selector (org.eclipse.e4.ui.workbench.Selector)1