/* * (non-Javadoc) * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) */ @Override public Image getImage(Object element) { Image result; result = null; if (element instanceof IModel) { IMetamodel aMetaModel; IModel aModel; aModel = (IModel) element; aMetaModel = aModel.getMetamodel(); /* * Check if the model instance type has been added and configured via the * modelInstanceTypes extension point. */ if (aMetaModel instanceof IMetamodelDescriptor) { IMetamodelDescriptor mmDescriptor; mmDescriptor = (IMetamodelDescriptor) aMetaModel; ImageDescriptor imageDescriptor; imageDescriptor = ImageDescriptor.createFromURL(mmDescriptor.getIconURL()); if (imageDescriptor == null) { imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); } // no else. result = this.resources.createImage(imageDescriptor); } // no else. } // no else. return result; }
/** * Simply returns the name of the given {@link IModel}. * * @param element The element which name should be returned. <strong>Should be an instance of * {@link IModel}!</strong> * @return The name of the given {@link IModel}. */ @Override public String getText(Object element) { String result; IModel model; result = null; if (element instanceof IModel) { model = (IModel) element; result = model.getDisplayName(); /* Eventually shorten the description. */ if (result.length() > MAX_NAME_LENGTH) { result = result.substring(result.length() - MAX_NAME_LENGTH); result = "..." + result; } // no else. } // no else return result; }