Search in sources :

Example 1 with MPlaceholder

use of org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder in project yamcs-studio by yamcs.

the class OPIView method findMementoFromPlaceholder.

/**
 * Retrieve memento persisted in MPlaceholder if present.
 *
 * @return memento persisted in the placeholder.
 */
private IMemento findMementoFromPlaceholder() {
    IMemento memento = null;
    MPlaceholder placeholder = findPlaceholder();
    if (placeholder != null) {
        if (placeholder.getPersistedState().containsKey(TAG_MEMENTO)) {
            String mementoString = placeholder.getPersistedState().get(TAG_MEMENTO);
            memento = loadMemento(mementoString);
        }
    }
    return memento;
}
Also used : MPlaceholder(org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder) IMemento(org.eclipse.ui.IMemento)

Example 2 with MPlaceholder

use of org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder in project yamcs-studio by yamcs.

the class OPIView method findPlaceholder.

/**
 * Find the MPlaceholder corresponding to this MPart in the MPerspective. This may have persisted information
 * relevant to loading this OPIView.
 *
 * @return corresponding placeholder
 */
private MPlaceholder findPlaceholder() {
    // do not remove casting - RAP 3.0 still needs it
    final IEclipseContext localContext = (IEclipseContext) getViewSite().getService(IEclipseContext.class);
    final MPart part = localContext.get(MPart.class);
    final EModelService service = (EModelService) PlatformUI.getWorkbench().getService(EModelService.class);
    final IEclipseContext globalContext = (IEclipseContext) PlatformUI.getWorkbench().getService(IEclipseContext.class);
    final MApplication app = globalContext.get(MApplication.class);
    final List<MPlaceholder> phs = service.findElements(app, null, MPlaceholder.class, null);
    for (MPlaceholder ph : phs) {
        if (ph.getRef() == part) {
            return ph;
        }
    }
    return null;
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) MPlaceholder(org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) MApplication(org.eclipse.e4.ui.model.application.MApplication)

Aggregations

MPlaceholder (org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder)2 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 MApplication (org.eclipse.e4.ui.model.application.MApplication)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 EModelService (org.eclipse.e4.ui.workbench.modeling.EModelService)1 IMemento (org.eclipse.ui.IMemento)1