Search in sources :

Example 1 with IModelInput

use of org.whole.lang.ui.input.IModelInput in project whole by wholeplatform.

the class EntityLocationHyperlink method linkActivated.

public void linkActivated() {
    try {
        IEclipseContext context = (IEclipseContext) PlatformUI.getWorkbench().getService(IEclipseContext.class);
        EPartService partService = context.get(EPartService.class);
        Collection<MPart> parts = partService.getParts();
        for (MPart part : parts) {
            IEclipseContext partContext = part.getContext();
            if (partContext == null)
                continue;
            IModelInput modelInput = partContext.get(IModelInput.class);
            if (modelInput != null && ((IFilePersistenceProvider) modelInput.getPersistenceProvider()).getStore().equals(file)) {
                partService.activate(part, true);
                IEntityPartViewer viewer = partContext.get(IEntityPartViewer.class);
                IEntity entityContents = viewer.getEntityContents();
                final IEntity entity = EntityUtils.getEntity(entityContents, location);
                viewer.selectAndReveal(entity);
            }
        }
    } catch (Exception e) {
        E4CompatibilityPlugin.log(e);
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IModelInput(org.whole.lang.ui.input.IModelInput) IEntity(org.whole.lang.model.IEntity) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) IEntityPartViewer(org.whole.lang.ui.viewers.IEntityPartViewer)

Example 2 with IModelInput

use of org.whole.lang.ui.input.IModelInput in project whole by wholeplatform.

the class E4GraphicalViewer method setContents.

public void setContents(IModelInput modelInput, IEntity defaultContents) {
    if (modelInput != null) {
        IModelInput oldModelInput = this.modelInput;
        this.modelInput = modelInput;
        try {
            setEntityContents(this.modelInput.readModel());
            fireModelInputChanged(oldModelInput, this.modelInput);
        } catch (Exception e) {
            String errorMessage = String.format("Unable to open \"%s\" using \"%s\" persistence kit", modelInput.getName(), modelInput.getPersistenceKit().getDescription());
            setEntityContents(E4Utils.createErrorStatusContents(errorMessage, e.getLocalizedMessage()));
        }
    } else
        setEntityContents(defaultContents);
}
Also used : IModelInput(org.whole.lang.ui.input.IModelInput)

Example 3 with IModelInput

use of org.whole.lang.ui.input.IModelInput in project whole by wholeplatform.

the class E4TreeViewer method setContents.

public void setContents(IModelInput modelInput, IEntity defaultContents) {
    if (modelInput != null) {
        IModelInput oldModelInput = this.modelInput;
        this.modelInput = modelInput;
        try {
            setEntityContents(this.modelInput.readModel());
            fireModelInputChanged(oldModelInput, this.modelInput);
        } catch (Exception e) {
            String errorMessage = String.format("Unable to open \"%s\" using \"%s\" persistence kit", modelInput.getName(), modelInput.getPersistenceKit().getDescription());
            setEntityContents(E4Utils.createErrorStatusContents(errorMessage, e.getLocalizedMessage()));
        }
    } else
        setEntityContents(defaultContents);
}
Also used : IModelInput(org.whole.lang.ui.input.IModelInput)

Example 4 with IModelInput

use of org.whole.lang.ui.input.IModelInput in project whole by wholeplatform.

the class AbstractE4Part method restoreState.

protected void restoreState() {
    if (part.getPersistedState().containsKey("basePersistenceKitId")) {
        String basePersistenceKitId = part.getPersistedState().get("basePersistenceKitId");
        IModelInput modelInput = new ModelInput(context, part.getPersistedState().get("filePath"), basePersistenceKitId);
        modelInput.setOverridePersistenceKitId(part.getPersistedState().get("overridePersistenceKitId"));
        updateModelInput(modelInput);
    }
}
Also used : ModelInput(org.whole.lang.e4.ui.input.ModelInput) IModelInput(org.whole.lang.ui.input.IModelInput) IModelInput(org.whole.lang.ui.input.IModelInput)

Aggregations

IModelInput (org.whole.lang.ui.input.IModelInput)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)1 EPartService (org.eclipse.e4.ui.workbench.modeling.EPartService)1 IFilePersistenceProvider (org.whole.lang.codebase.IFilePersistenceProvider)1 ModelInput (org.whole.lang.e4.ui.input.ModelInput)1 IEntity (org.whole.lang.model.IEntity)1 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)1