Search in sources :

Example 1 with PackageInfoRef

use of org.jboss.tools.hibernate.jpt.core.internal.context.persistence.PackageInfoRef in project jbosstools-hibernate by jbosstools.

the class HibernatePersistenceUnitClassesComposite method buildLabelProvider.

private ILabelProvider buildLabelProvider() {
    return new LabelProvider() {

        @Override
        public Image getImage(Object element) {
            Image image = null;
            if (element instanceof ClassRef) {
                ClassRef classRef = (ClassRef) element;
                JavaPersistentType persistentType = classRef.getJavaPersistentType();
                if (persistentType != null) {
                    image = this.getImage(persistentType);
                // image = JpaMappingImageHelper.imageForTypeMapping(persistentType.getMappingKey());
                } else if (classRef instanceof PackageInfoRef) {
                    PackageInfoRef packageInfoRef = (PackageInfoRef) classRef;
                    if (packageInfoRef.getJavaPackageInfo() != null) {
                        image = JavaPlugin.getImageDescriptorRegistry().get(JavaPluginImages.DESC_OBJS_PACKAGE);
                    }
                }
            }
            if (image != null) {
                return image;
            }
            return HibernateJptUIPlugin.getDefault().getImage("warning");
        }

        @Override
        public String getText(Object element) {
            ClassRef classRef = (ClassRef) element;
            String name = classRef.getClassName();
            if (name == null) {
                name = JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_CLASS_REF_NO_NAME;
            }
            return name;
        }
    };
}
Also used : PackageInfoRef(org.jboss.tools.hibernate.jpt.core.internal.context.persistence.PackageInfoRef) ClassRef(org.eclipse.jpt.jpa.core.context.persistence.ClassRef) JavaPersistentType(org.eclipse.jpt.jpa.core.context.java.JavaPersistentType) Image(org.eclipse.swt.graphics.Image) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 JavaPersistentType (org.eclipse.jpt.jpa.core.context.java.JavaPersistentType)1 ClassRef (org.eclipse.jpt.jpa.core.context.persistence.ClassRef)1 Image (org.eclipse.swt.graphics.Image)1 PackageInfoRef (org.jboss.tools.hibernate.jpt.core.internal.context.persistence.PackageInfoRef)1