Search in sources :

Example 26 with ImageDescriptor

use of org.eclipse.jface.resource.ImageDescriptor in project tdi-studio-se by Talend.

the class JobletUtil method cloneNode.

public Node cloneNode(Node node, IProcess process, Map<String, List<? extends IElementParameter>> paraMap, boolean lockByOther) {
    NodePart nodePart = new NodePart();
    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    boolean isInOut = false;
    if (service != null) {
        isInOut = service.isJobletInOutComponent(node);
    }
    Node cloneNode = new Node(node.getComponent(), (IProcess2) process, node.getUniqueName());
    nodePart.setModel(cloneNode);
    if (lockByOther) {
        cloneNode.setReadOnly(true);
    } else {
        cloneNode.setReadOnly(false);
    }
    cloneNode.setDummy(node.isDummy());
    cloneNode.setActivate(node.isActivate());
    List<? extends IElementParameter> elementParas = null;
    if (paraMap.containsKey(node.getUniqueName())) {
        elementParas = paraMap.get(node.getUniqueName());
    } else {
        elementParas = node.getElementParameters();
    }
    for (IElementParameter elementPara : elementParas) {
        if (elementPara.getName() != null && !elementPara.getName().equals("UNIQUE_NAME")) {
            IElementParameter cloneElement = cloneNode.getElementParameter(elementPara.getName());
            Object paValue = elementPara.getValue();
            if (paValue instanceof List) {
                List list = new ArrayList();
                list.addAll((List) paValue);
                cloneElement.setValue(list);
            } else {
                // TDI-25599
                cloneElement.setContextMode(elementPara.isContextMode());
                cloneElement.setValue(elementPara.getValue());
            }
            if (lockByOther) {
                cloneElement.setReadOnly(true);
            } else {
                cloneElement.setReadOnly(elementPara.isReadOnly());
            }
            if (elementPara.getChildParameters() != null) {
                Map<String, IElementParameter> elementParaChild = elementPara.getChildParameters();
                Map<String, IElementParameter> cloneElementChild = cloneElement.getChildParameters();
                Iterator<Entry<String, IElementParameter>> ite = elementParaChild.entrySet().iterator();
                while (ite.hasNext()) {
                    Entry<String, IElementParameter> entry = ite.next();
                    String key = entry.getKey();
                    IElementParameter c = entry.getValue();
                    if (key != null && c != null) {
                        IElementParameter cloneC = cloneElementChild.get(key);
                        if (cloneC != null) {
                            cloneC.setValue(c.getValue());
                            if (lockByOther) {
                                cloneC.setReadOnly(true);
                            } else {
                                cloneC.setReadOnly(c.isReadOnly());
                            }
                        }
                    }
                }
            }
        }
    }
    for (IElementParameter param : cloneNode.getElementParameters()) {
        String repositoryValue = param.getRepositoryValue();
        if (param.isShow(cloneNode.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && param.getFieldType() != EParameterFieldType.MEMO_SQL) {
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        }
    }
    cloneNode.setMetadataList(node.getMetadataList());
    cloneNode.setListConnector(node.getListConnector());
    cloneNode.setConnectionName(node.getConnectionName());
    cloneNode.setLocation(node.getLocation());
    IExternalNode externalNode = cloneNode.getExternalNode();
    if (externalNode != null) {
        if (node.getExternalData() != null) {
            try {
                externalNode.setExternalData(node.getExternalData().clone());
            } catch (CloneNotSupportedException e) {
                ExceptionHandler.process(e);
            }
            cloneNode.setExternalData(externalNode.getExternalData());
        }
        if (node.getExternalNode().getExternalEmfData() != null) {
            externalNode.setExternalEmfData(EcoreUtil.copy(node.getExternalNode().getExternalEmfData()));
        }
        // when copy a external node, should also copy screeshot
        if (node.getExternalNode() != null) {
            ImageDescriptor screenshot = node.getExternalNode().getScreenshot();
            if (screenshot != null) {
                externalNode.setScreenshot(screenshot);
            }
        }
    }
    if (node.getElementParameter(EParameterName.LABEL.getName()) != null) {
        cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getElementParameter(EParameterName.LABEL.getName()).getValue());
    } else {
        cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getLabel());
    }
    boolean found = false;
    for (INode inode : process.getGraphicalNodes()) {
        if (inode.getUniqueName().equals(cloneNode.getUniqueName())) {
            found = true;
        }
    }
    if (!found) {
        ((IProcess2) process).removeUniqueNodeName(cloneNode.getUniqueName());
    }
    return cloneNode;
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) JobletNode(org.talend.designer.joblet.model.JobletNode) ArrayList(java.util.ArrayList) IJobletProviderService(org.talend.core.ui.IJobletProviderService) Entry(java.util.Map.Entry) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) IExternalNode(org.talend.core.model.process.IExternalNode)

Example 27 with ImageDescriptor

use of org.eclipse.jface.resource.ImageDescriptor in project tdi-studio-se by Talend.

the class IconSelectionController method createCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
     */
public Command createCommand(Button button) {
    Object data = button.getData(NAME);
    if (data != null) {
        if (ICON_SELECTION.equals(data)) {
            FileDialog dial = new FileDialog(composite.getShell(), SWT.NONE);
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            dial.setFilterExtensions(new String[] { "*.jpg", "*.png", "*.gif" });
            String propertyName = (String) button.getData(PARAMETER_NAME);
            String file = dial.open();
            if (file != null) {
                if (!file.equals("")) {
                    //$NON-NLS-1$
                    if (!elem.getPropertyValue(propertyName).equals(file)) {
                        ImageData imageData = new ImageData(file);
                        if (ImageUtils.checkSize(ImageDescriptor.createFromImageData(imageData), ImageUtils.ICON_SIZE.ICON_32)) {
                            if (elem instanceof IProcess2) {
                                refreshIcon(imageData);
                                return new IconSelectionCommand((IProcess2) elem, ImageDescriptor.createFromImageData(imageData), file);
                            }
                        } else {
                            MessageDialog.openError(composite.getShell(), //$NON-NLS-1$ 
                            Messages.getString("IconSelectionController.MessageTitle"), //$NON-NLS-1$ 
                            Messages.getString("IconSelectionController.Messages"));
                        }
                    }
                }
            }
        } else if (ICON_REVERT.equals(data)) {
            if (elem instanceof IProcess2) {
                Image defaultIcon = RepositoryLabelProvider.getDefaultJobletImage(((IProcess2) elem).getProperty().getItem());
                ImageDescriptor imageData = ImageDescriptor.createFromImage(defaultIcon);
                refreshIcon(defaultIcon.getImageData());
                return new IconSelectionCommand((IProcess2) elem, imageData, null);
            }
        }
    }
    return null;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) IProcess2(org.talend.core.model.process.IProcess2) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 28 with ImageDescriptor

use of org.eclipse.jface.resource.ImageDescriptor in project tdi-studio-se by Talend.

the class TalendEditorPaletteFactory method createEntryFrom.

public static TalendCombinedTemplateCreationEntry createEntryFrom(IComponent component) {
    if (component == null) {
        return null;
    }
    String name = component.getName();
    ImageDescriptor imageSmall = component.getIcon16();
    IPreferenceStore store = DesignerPlugin.getDefault().getPreferenceStore();
    ImageDescriptor imageLarge;
    final String string = store.getString(TalendDesignerPrefConstants.LARGE_ICONS_SIZE);
    if (string.equals("24")) {
        //$NON-NLS-1$
        imageLarge = component.getIcon24();
    } else {
        imageLarge = component.getIcon32();
    }
    TalendCombinedTemplateCreationEntry newEntry = new TalendCombinedTemplateCreationEntry(name, name, Node.class, component, imageSmall, imageLarge);
    newEntry.setDescription(component.getLongName());
    return newEntry;
}
Also used : ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) TalendCombinedTemplateCreationEntry(org.talend.designer.core.ui.editor.palette.TalendCombinedTemplateCreationEntry)

Example 29 with ImageDescriptor

use of org.eclipse.jface.resource.ImageDescriptor in project tdi-studio-se by Talend.

the class TalendDrawerEditPart method refreshVisuals.

@Override
protected void refreshVisuals() {
    getDrawerFigure().setToolTip(createToolTip());
    if (cssStyleSetting.isShowFolderImage()) {
        ImageDescriptor img = getDrawer().getSmallIcon();
        if (img == null && getDrawer().showDefaultIcon()) {
            img = InternalImages.DESC_FOLDER_OPEN;
        }
        setImageDescriptor(img);
    }
    getDrawerFigure().setTitle(getPaletteEntry().getLabel());
    getDrawerFigure().setLayoutMode(getLayoutSetting());
    boolean showPin = getPreferenceSource().getAutoCollapseSetting() == PaletteViewerPreferences.COLLAPSE_AS_NEEDED;
    getDrawerFigure().showPin(showPin);
    Color background = getDrawer().getDrawerType().equals(PaletteTemplateEntry.PALETTE_TYPE_TEMPLATE) ? PaletteColorUtil.WIDGET_LIST_BACKGROUND : null;
    getDrawerFigure().getScrollpane().setBackgroundColor(background);
}
Also used : Color(org.eclipse.swt.graphics.Color) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 30 with ImageDescriptor

use of org.eclipse.jface.resource.ImageDescriptor in project tdi-studio-se by Talend.

the class IconSelectionController method refresh.

@Override
public void refresh(IElementParameter param, boolean checkErrorsWhenViewRefreshed) {
    IElement element = param.getElement();
    if (element instanceof IProcess2) {
        if (findProcessProvider != null) {
            ImageDescriptor icon = findProcessProvider.getIcons((IProcess2) element);
            if (icon != null) {
                Image image = icon.createImage();
                addResourceDisposeListener(filePathText, image);
                filePathText.setImage(image);
            }
        }
    }
}
Also used : IElement(org.talend.core.model.process.IElement) IProcess2(org.talend.core.model.process.IProcess2) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image)

Aggregations

ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)106 Image (org.eclipse.swt.graphics.Image)25 ArrayList (java.util.ArrayList)21 List (java.util.List)18 ToolEntry (org.eclipse.gef.palette.ToolEntry)14 URL (java.net.URL)12 ImageData (org.eclipse.swt.graphics.ImageData)11 ResourceImageDescriptor (de.jaret.util.ui.ResourceImageDescriptor)9 Point (org.eclipse.swt.graphics.Point)6 Node (org.talend.designer.core.ui.editor.nodes.Node)6 Path (org.eclipse.core.runtime.Path)5 JavaElementImageDescriptor (org.eclipse.jdt.ui.JavaElementImageDescriptor)5 File (java.io.File)4 HashMap (java.util.HashMap)4 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 IComponent (org.talend.core.model.components.IComponent)4 INode (org.talend.core.model.process.INode)4 MalformedURLException (java.net.MalformedURLException)3 Set (java.util.Set)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3