use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ImageController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
*/
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
// String fileName = (String) param.getValue();
// IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
// String filePath = service.getPathFileName(RepositoryConstants.IMG_DIRECTORY, fileName).toPortableString();
boolean hasScreenshots = false;
byte[] screenshot = null;
if (param.getElement() instanceof INode && ((INode) param.getElement()).getExternalNode() != null) {
String componentType = ((INode) param.getElement()).getComponent().getName();
if ("tMap".equals(componentType)) {
IProcess process = ((INode) param.getElement()).getProcess();
if (process instanceof IProcess2) {
IProcess2 processtmp = (IProcess2) process;
Item item = processtmp.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
screenshot = (byte[]) processItem.getProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
if (screenshot != null) {
hasScreenshots = true;
}
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
screenshot = (byte[]) jobletItem.getJobletProcess().getScreenshots().get(((INode) param.getElement()).getUniqueName());
if (screenshot != null) {
hasScreenshots = true;
}
}
}
}
}
if (hasScreenshots) {
ImageDescriptor imageDesc = ImageUtils.createImageFromData(screenshot);
((INode) param.getElement()).getExternalNode().setScreenshot(imageDesc);
// ImageDescriptor imageDesc = ((INode) param.getElement()).getExternalNode().getScreenshot();
// File fileOrFolder = new java.io.File(filePath);
// if (!fileOrFolder.isFile() || !fileOrFolder.canRead()) {
// return lastControl;
// }
final Composite compositeImage = new Composite(subComposite, SWT.BORDER);
final Image image = imageDesc.createImage();
addResourceDisposeListener(compositeImage, image);
//$NON-NLS-1$
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName() + " :");
FormData formDataLabel = new FormData();
labelLabel.setVisible(true);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
if (lastControl != null) {
formDataLabel.left = new FormAttachment(lastControl, 0);
} else {
formDataLabel.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
formDataLabel.top = new FormAttachment(0, top);
}
labelLabel.setLayoutData(formDataLabel);
compositeImage.setToolTipText(param.getDisplayName());
Point size = new Point(image.getImageData().width, image.getImageData().height);
FormData formData = new FormData((int) (size.x * 0.8), (int) (size.y * 0.8));
formData.top = new FormAttachment(0, top);
formData.left = new FormAttachment(labelLabel);
ImageData data = image.getImageData();
compositeImage.setLayoutData(formData);
data = data.scaledTo((int) (size.x * 0.8), (int) (size.y * 0.8));
Image im = new Image(image.getDevice(), data);
compositeImage.setBackgroundImage(im);
return compositeImage;
} else {
return lastControl;
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class ContextsView method setCompositeReadonly.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.context.view.AbstractContextView#setCompositeReadonly(org.eclipse.ui.IEditorInput)
*/
@Override
protected void setCompositeReadonly(IEditorInput editorInput) {
if (editorInput != null && editorInput instanceof JobEditorInput) {
JobEditorInput jobInput = (JobEditorInput) editorInput;
IProcess2 process = jobInput.getLoadedProcess();
if (process != null) {
contextComposite.setReadOnly(process.isReadOnly());
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class JobSettingsView method onPropertiesChanged.
@Override
public void onPropertiesChanged(Map<String, Object> maps) {
if (maps == null || maps.isEmpty()) {
return;
}
Object obj = maps.get(IJobSettingsView.JOBTYPE_CHANGED);
if (obj instanceof IRepositoryViewObject) {
String type = null;
IRepositoryViewObject repositoryObject = (IRepositoryViewObject) obj;
// opened job needn't to change the title
if (!(obj instanceof IProcess2)) {
Property property = repositoryObject.getProperty();
if (property != null) {
Item item = property.getItem();
if (item != null) {
ERepositoryObjectType repositoryObjectType = ERepositoryObjectType.getItemType(item);
if (repositoryObjectType == ERepositoryObjectType.PROCESS) {
type = getViewNameLable();
} else if (repositoryObjectType != null) {
type = repositoryObjectType.getLabel();
}
}
}
}
Image image = getImage(repositoryObject);
if (image != null && image.isDisposed()) {
image = null;
}
if (type == null) {
super.setTitleImage(image);
tabFactory.setTitleImage(image);
} else {
String title = repositoryObject.getLabel();
if (allowVerchange) {
if (repositoryObject.getVersion() != null) {
//$NON-NLS-1$
title = repositoryObject.getLabel() + " " + repositoryObject.getVersion();
}
}
setPartName(type + SEPARATOR + title, image);
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class RowGenProcessMain method getProcess.
private void getProcess() {
initPerlArray();
this.component.setNumber(number);
if (component.getProcess() instanceof IProcess2) {
// get current job context manager.
jobContextManager = component.getProcess().getContextManager();
}
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setLabel(PREVIEW + "_RowGenerator2");
//$NON-NLS-1$
property.setId(PREVIEW + "_RowGenerator2");
proc = new RowGenProcess(property, component);
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class AbstractTalendEditor method saveOutlinePicture.
/**
* Save the outline picture for this editor.
*
* @param viewer
*/
protected void saveOutlinePicture(ScrollingGraphicalViewer viewer) {
GlobalConstant.generatingScreenShoot = true;
LayerManager layerManager = (LayerManager) viewer.getEditPartRegistry().get(LayerManager.ID);
// save image using swt
// get root figure
IFigure backgroundLayer = layerManager.getLayer(LayerConstants.GRID_LAYER);
IFigure contentLayer = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
// create image from root figure
FreeformViewport viewport = (FreeformViewport) ((TalendScalableFreeformRootEditPart) layerManager).getFigure();
viewport.getUpdateManager().performUpdate();
int width = contentLayer.getBounds().width;
int height = contentLayer.getBounds().height;
Image img = new Image(null, width, height);
GC gc = new GC(img);
Graphics graphics = new SWTGraphics(gc);
Point point = contentLayer.getBounds().getTopLeft();
graphics.translate(-point.x, -point.y);
IProcess2 process = getProcess();
process.setPropertyValue(IProcess.SCREEN_OFFSET_X, String.valueOf(-point.x));
process.setPropertyValue(IProcess.SCREEN_OFFSET_Y, String.valueOf(-point.y));
backgroundLayer.paint(graphics);
contentLayer.paint(graphics);
graphics.dispose();
gc.dispose();
process.getScreenshots().put("process", ImageUtils.saveImageToData(img));
img.dispose();
// service.getProxyRepositoryFactory().refreshJobPictureFolder(outlinePicturePath);
GlobalConstant.generatingScreenShoot = false;
}
Aggregations