Search in sources :

Example 66 with IProcess2

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;
    }
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) FormData(org.eclipse.swt.layout.FormData) INode(org.talend.core.model.process.INode) Composite(org.eclipse.swt.widgets.Composite) Point(org.eclipse.swt.graphics.Point) Image(org.eclipse.swt.graphics.Image) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ImageData(org.eclipse.swt.graphics.ImageData) IProcess2(org.talend.core.model.process.IProcess2) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IProcess(org.talend.core.model.process.IProcess) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 67 with IProcess2

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());
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IProcess2(org.talend.core.model.process.IProcess2)

Example 68 with IProcess2

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);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IImage(org.talend.commons.ui.runtime.image.IImage) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) Image(org.eclipse.swt.graphics.Image) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property)

Example 69 with IProcess2

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);
}
Also used : IProcess2(org.talend.core.model.process.IProcess2) Property(org.talend.core.model.properties.Property)

Example 70 with IProcess2

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;
}
Also used : Graphics(org.eclipse.draw2d.Graphics) SWTGraphics(org.eclipse.draw2d.SWTGraphics) SWTGraphics(org.eclipse.draw2d.SWTGraphics) FreeformViewport(org.eclipse.draw2d.FreeformViewport) IProcess2(org.talend.core.model.process.IProcess2) Point(org.eclipse.draw2d.geometry.Point) Image(org.eclipse.swt.graphics.Image) GC(org.eclipse.swt.graphics.GC) LayerManager(org.eclipse.gef.editparts.LayerManager) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

IProcess2 (org.talend.core.model.process.IProcess2)115 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 ArrayList (java.util.ArrayList)30 ProcessItem (org.talend.core.model.properties.ProcessItem)30 Item (org.talend.core.model.properties.Item)28 IProcess (org.talend.core.model.process.IProcess)24 PersistenceException (org.talend.commons.exception.PersistenceException)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)19 List (java.util.List)17 IElementParameter (org.talend.core.model.process.IElementParameter)15 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)14 Property (org.talend.core.model.properties.Property)14 CoreException (org.eclipse.core.runtime.CoreException)12 IConnection (org.talend.core.model.process.IConnection)11 HashSet (java.util.HashSet)10 IEditorReference (org.eclipse.ui.IEditorReference)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)7