Search in sources :

Example 1 with SchemaCategory

use of eu.esdihumboldt.hale.common.schema.presets.extension.SchemaCategory in project hale by halestudio.

the class SchemaPresetLabelProvider method update.

@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    StyledString text = new StyledString();
    if (element instanceof SchemaPreset) {
        SchemaPreset schema = (SchemaPreset) element;
        text.append(schema.getName());
    }
    if (element instanceof SchemaCategory) {
        text.append(((SchemaCategory) element).getName());
    }
    if (element instanceof SchemaPreset) {
        SchemaPreset preset = (SchemaPreset) element;
        String version = preset.getVersion();
        if (version != null) {
            text.append(" " + version, StyledString.COUNTER_STYLER);
        }
        String tag = preset.getTag();
        if (tag != null) {
            text.append(" (" + tag + ")", StyledString.DECORATIONS_STYLER);
        }
    }
    // NoObject.NONE)
    if (element != null && (text.getString() == null || text.getString().isEmpty())) {
        text.append(getText(element));
    }
    cell.setImage(getImage(element));
    cell.setText(text.toString());
    cell.setStyleRanges(text.getStyleRanges());
    super.update(cell);
}
Also used : SchemaPreset(eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset) SchemaCategory(eu.esdihumboldt.hale.common.schema.presets.extension.SchemaCategory) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 2 with SchemaCategory

use of eu.esdihumboldt.hale.common.schema.presets.extension.SchemaCategory in project hale by halestudio.

the class SchemaPresetLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    if (element instanceof SchemaPreset) {
        SchemaPreset schema = (SchemaPreset) element;
        URL iconURL = schema.getIconURL();
        if (iconURL != null) {
            String key = iconURL.toString();
            Image image = urlImages.get(key);
            if (image == null) {
                image = ImageDescriptor.createFromURL(iconURL).createImage();
                urlImages.put(key, image);
            }
            return image;
        }
        return defImage;
    }
    if (element instanceof SchemaCategory) {
        return categoryImage;
    }
    return null;
}
Also used : SchemaPreset(eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset) SchemaCategory(eu.esdihumboldt.hale.common.schema.presets.extension.SchemaCategory) StyledString(org.eclipse.jface.viewers.StyledString) Image(org.eclipse.swt.graphics.Image) URL(java.net.URL)

Example 3 with SchemaCategory

use of eu.esdihumboldt.hale.common.schema.presets.extension.SchemaCategory in project hale by halestudio.

the class PredefinedSchemaImpl method getCategoryId.

@Override
public String getCategoryId() {
    String catId = element.getAttribute("category");
    // check if category actually exists
    SchemaCategory cat = SchemaCategoryExtension.getInstance().get(catId);
    if (cat != null) {
        return catId;
    } else {
        return null;
    }
}
Also used : SchemaCategory(eu.esdihumboldt.hale.common.schema.presets.extension.SchemaCategory)

Aggregations

SchemaCategory (eu.esdihumboldt.hale.common.schema.presets.extension.SchemaCategory)3 SchemaPreset (eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset)2 StyledString (org.eclipse.jface.viewers.StyledString)2 URL (java.net.URL)1 Image (org.eclipse.swt.graphics.Image)1