diff --git a/framework/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/ui/model/AbstractModelElement.java b/framework/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/ui/model/AbstractModelElement.java index ced5321465..b416f963cc 100644 --- a/framework/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/ui/model/AbstractModelElement.java +++ b/framework/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/ui/model/AbstractModelElement.java @@ -25,6 +25,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; +import org.eclipse.vorto.core.api.model.model.Model; import org.eclipse.vorto.core.api.model.model.ModelId; import org.eclipse.vorto.core.api.model.model.ModelIdFactory; import org.eclipse.vorto.core.api.model.model.ModelReference; @@ -67,7 +68,11 @@ private Image getImage(String urlStr) { @Override public ModelId getId() { - return ModelIdFactory.newInstance(getModel()); + Model model = getModel(); + if(model != null) { + return ModelIdFactory.newInstance(model); + } + return null; } @Override @@ -77,7 +82,11 @@ public String getDescription() { public Set getReferences() { Set references = new TreeSet<>(); - for (ModelReference modelReference : getModel().getReferences()) { + Model model = getModel(); + if(model == null) { + return references; + } + for (ModelReference modelReference : model.getReferences()) { for(ModelType possibleType : getPossibleReferenceTypes()) { ModelId modelId = ModelIdFactory.newInstance(possibleType, modelReference); IModelElement modelElementReference = this.modelProject.getModelElementById(modelId); diff --git a/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/labelprovider/DefaultTreeModelLabelProvider.java b/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/labelprovider/DefaultTreeModelLabelProvider.java index 4852085da9..fe8442b032 100644 --- a/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/labelprovider/DefaultTreeModelLabelProvider.java +++ b/framework/org.eclipse.vorto.perspective/src/org/eclipse/vorto/perspective/labelprovider/DefaultTreeModelLabelProvider.java @@ -17,6 +17,7 @@ import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.swt.graphics.Image; +import org.eclipse.vorto.core.api.model.model.ModelId; import org.eclipse.vorto.core.ui.model.IModelElement; public class DefaultTreeModelLabelProvider extends ColumnLabelProvider { @@ -54,7 +55,9 @@ public Image getImage(Object element) { @Override public String getText(Object element) { IModelElement modelElement = (IModelElement) element; - return modelElement.getId().getName(); + ModelId modelId = modelElement.getId(); + // return filename if model is invalid + return modelId != null ? modelId.getName() : modelElement.getModelFile().getName(); } @Override