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;
}
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;
}
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;
}
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);
}
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);
}
}
}
}
Aggregations