Search in sources :

Example 1 with IImage

use of org.talend.commons.ui.runtime.image.IImage in project tdi-studio-se by Talend.

the class ItemRecord method getImage.

public Image getImage() {
    // MOD sizhaoliu 2011-12-05
    // In ImportItemWizard, enable custom icons depending on file extension.
    Image img = null;
    boolean isExtensionPoint = false;
    for (IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
        isExtensionPoint = handler.isRepObjType(getType());
        if (isExtensionPoint == true) {
            IImage icon = handler.getIcon(getItem());
            if (icon != null) {
                img = ImageProvider.getImage(icon);
                break;
            }
        }
    }
    if (isExtensionPoint == false || img == null) {
        img = CoreImageProvider.getImage(getType());
    }
    return img;
}
Also used : IImage(org.talend.commons.ui.runtime.image.IImage) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) IRepositoryContentHandler(org.talend.core.model.repository.IRepositoryContentHandler)

Example 2 with IImage

use of org.talend.commons.ui.runtime.image.IImage in project tdi-studio-se by Talend.

the class StatusBar method setValues.

public void setValues(STATUS status, String text) {
    Image image = null;
    //$NON-NLS-1$
    String content = "";
    if (status != STATUS.EMPTY) {
        //            if (status != STATUS.INFO) {
        //$NON-NLS-1$
        content = " : " + text;
        IImage iimage = status.getImage();
        if (iimage == null) {
            image = null;
        } else {
            image = org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(iimage));
        }
    //            } else {
    //                content = text;
    //            }
    }
    statusBarLabel.setText(content);
    statusBarImage.setImage(image);
    setSize(computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
Also used : IImage(org.talend.commons.ui.runtime.image.IImage) EImage(org.talend.commons.ui.runtime.image.EImage) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image)

Example 3 with IImage

use of org.talend.commons.ui.runtime.image.IImage in project tdi-studio-se by Talend.

the class UpdateLabelProvider method getColumnImage.

@Override
public Image getColumnImage(Object element, int columnIndex) {
    // try to use extension first.
    Object image = UpdateManagerProviderDetector.INSTANCE.getDisplayImage(element, columnIndex);
    if (image == null && columnIndex == 0) {
        if (element instanceof Job) {
            Job job = (Job) element;
            if (job.isJoblet()) {
                image = ECoreImage.JOBLET_ICON;
            } else if (job.isSparkJoblet()) {
                image = ECoreImage.PROCESS_BATCH_SPARK_ICON;
            } else if (job.isSparkStreamingJoblet()) {
                image = ECoreImage.PROCESS_STREAMING_SPARK_ICON;
            } else {
                org.talend.core.model.properties.Item item = job.getModelItem();
                if (item != null) {
                    image = CoreImageProvider.getIcon(item);
                } else {
                    if (job.isMR() || job.isStreaming()) {
                        for (ERepositoryObjectType type : (ERepositoryObjectType[]) ERepositoryObjectType.values()) {
                            String alias = type.getAlias();
                            if (alias != null && alias.equals("HC")) {
                                image = CoreImageProvider.getIcon(type);
                            }
                        }
                    } else {
                        image = ECoreImage.PROCESS_ICON;
                    }
                }
            }
        } else if (element instanceof Category) {
            Category category = (Category) element;
            IUpdateItemType type = category.getType();
            if (type != null) {
                if (type instanceof EUpdateItemType) {
                    switch((EUpdateItemType) type) {
                        case JOB_PROPERTY_EXTRA:
                        case JOB_PROPERTY_STATS_LOGS:
                        case JOB_PROPERTY_HEADERFOOTER:
                            image = ECoreImage.PROCESS_ICON;
                            break;
                        case CONTEXT:
                        case CONTEXT_GROUP:
                            // case JOBLET_CONTEXT:
                            image = ECoreImage.CONTEXT_ICON;
                            break;
                        case NODE_PROPERTY:
                        case NODE_SCHEMA:
                        case NODE_QUERY:
                        case NODE_SAP_IDOC:
                        case NODE_SAP_FUNCTION:
                        case NODE_VALIDATION_RULE:
                        case JOBLET_SCHEMA:
                        case JOBLET_RENAMED:
                        case JUNIT_RELOAD:
                        case RELOAD:
                        case MAP_PATH:
                            image = getImageFromNode(category.getNode());
                            break;
                        case JOB_PROPERTY_STORM:
                        case JOB_PROPERTY_MAPREDUCE:
                            for (ERepositoryObjectType etype : (ERepositoryObjectType[]) ERepositoryObjectType.values()) {
                                String alias = etype.getAlias();
                                if (alias != null && alias.equals("HC")) {
                                    image = CoreImageProvider.getImage(etype);
                                }
                            }
                            break;
                        default:
                    }
                } else {
                    // try to git image via type
                    image = UpdateManagerProviderDetector.INSTANCE.getDisplayImage(type, columnIndex);
                }
            }
        } else if (element instanceof Item) {
            Item item = (Item) element;
            IUpdateItemType updateType = item.getResultObject().getUpdateType();
            if (updateType instanceof EUpdateItemType) {
                switch((EUpdateItemType) updateType) {
                    case NODE_QUERY:
                        image = ECoreImage.METADATA_QUERY_ICON;
                        break;
                    case NODE_SCHEMA:
                    case JOBLET_SCHEMA:
                        image = ECoreImage.METADATA_TABLE_ICON;
                        break;
                    case NODE_PROPERTY:
                    case NODE_VALIDATION_RULE:
                    case JOB_PROPERTY_EXTRA:
                    case JOB_PROPERTY_STATS_LOGS:
                    case JOB_PROPERTY_STORM:
                    case JOB_PROPERTY_MAPREDUCE:
                        ERepositoryObjectType type = RepositoryUpdateManager.getTypeFromSource(item.getRemark());
                        if (type != null) {
                            image = CoreImageProvider.getIcon(type);
                        }
                    case JOBLET_RENAMED:
                    case RELOAD:
                    // return ImageProvider.getImage(ECoreImage.TALEND_PICTO);
                    case CONTEXT:
                    case CONTEXT_GROUP:
                    // return ImageProvider.getImage(ECoreImage.CONTEXT_ICON);
                    default:
                }
            } else {
                // try to git image via type
                image = UpdateManagerProviderDetector.INSTANCE.getDisplayImage(updateType, columnIndex);
            }
        }
    }
    if (image != null) {
        ECoreImage warnOverlay = ECoreImage.WARN_OVERLAY;
        EPosition position = EPosition.BOTTOM_RIGHT;
        if (image instanceof IImage) {
            if (checkElementForUpdate(element)) {
                return OverlayImageProvider.getImageForOverlay((IImage) image, warnOverlay, position);
            }
            return ImageProvider.getImage((IImage) image);
        } else if (image instanceof Image) {
            if (checkElementForUpdate(element)) {
                return OverlayImageProvider.getImageForOverlay((Image) image, warnOverlay, position);
            }
            return (Image) image;
        }
    }
    return null;
}
Also used : EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) EPosition(org.talend.commons.ui.runtime.image.OverlayImage.EPosition) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) IImage(org.talend.commons.ui.runtime.image.IImage) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 4 with IImage

use of org.talend.commons.ui.runtime.image.IImage in project tdi-studio-se by Talend.

the class StatusConfirmSettingDialog method getItemsImage.

private Image getItemsImage(IImage iImage) {
    if (iImage == null) {
        iImage = EImage.DEFAULT_IMAGE;
    }
    Image image = cacheItemImages.get(iImage);
    if (image == null) {
        Image oImage = ImageProvider.getImage(iImage);
        ImageData imageData = oImage.getImageData();
        // enlarge image
        final int larger = 4;
        ImageData newData = imageData.scaledTo(imageData.width + larger, imageData.height + larger);
        image = new Image(oImage.getDevice(), newData);
        cacheItemImages.put(iImage, image);
    }
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage)

Example 5 with IImage

use of org.talend.commons.ui.runtime.image.IImage in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method getItemsImage.

protected Image getItemsImage(IImage iImage) {
    if (iImage == null) {
        iImage = EImage.DEFAULT_IMAGE;
    }
    Image image = cacheItemImages.get(iImage);
    if (image == null) {
        Image oImage = ImageProvider.getImage(iImage);
        ImageData imageData = oImage.getImageData();
        // enlarge image
        final int larger = 4;
        ImageData newData = imageData.scaledTo(imageData.width + larger, imageData.height + larger);
        image = new Image(oImage.getDevice(), newData);
        cacheItemImages.put(iImage, image);
    }
    return image;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) IImage(org.talend.commons.ui.runtime.image.IImage) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage)

Aggregations

Image (org.eclipse.swt.graphics.Image)7 IImage (org.talend.commons.ui.runtime.image.IImage)7 EImage (org.talend.commons.ui.runtime.image.EImage)5 ImageData (org.eclipse.swt.graphics.ImageData)3 ECoreImage (org.talend.commons.ui.runtime.image.ECoreImage)1 EPosition (org.talend.commons.ui.runtime.image.OverlayImage.EPosition)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 IRepositoryContentHandler (org.talend.core.model.repository.IRepositoryContentHandler)1 EUpdateItemType (org.talend.core.model.update.EUpdateItemType)1 IUpdateItemType (org.talend.core.model.update.IUpdateItemType)1