Search in sources :

Example 11 with SimpleHtmlFigure

use of org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure in project tdi-studio-se by Talend.

the class NodeProgressBarFigure method setProgressData.

public void setProgressData(Double extent) {
    List childs = this.getChildren();
    childs.clear();
    if (extent == 0) {
        return;
    }
    Figure baseFigure = new Figure();
    baseFigure.setLayoutManager(new ToolbarLayout(true));
    baseFigure.setVisible(true);
    Double extentString = Math.floor(extent / 10);
    Double extentFlag = Math.floor(extent);
    Figure progressBarFigure = new Figure();
    progressBarFigure.setBorder(new LineBorder(ColorConstants.black, 1));
    progressBarFigure.setLayoutManager(new ToolbarLayout(true));
    progressBarFigure.setSize(60, 10);
    progressBarFigure.setPreferredSize(60, 10);
    progressBarFigure.setVisible(true);
    SimpleHtmlFigure dataFigure = new SimpleHtmlFigure();
    dataFigure.setVisible(true);
    // Font font = new Font(Display.getDefault(), "Arial", 9, SWT.ITALIC);
    // dataFigure.setFont(font);
    //
    //        dataFigure.setText(extentFlag.intValue() + "%");//$NON-NLS-1$
    dataFigure.setText(//$NON-NLS-1$
    "<font color='#000000'> <b> " + extentFlag.intValue() + "%" + //$NON-NLS-1$ //$NON-NLS-2$
    "</b></font>");
    // dataFigure.setSize(27, 12);
    // dataFigure.setPreferredSize(27, 12);
    int nodeX = progressBarFigure.getLocation().x;
    int nodeY = progressBarFigure.getLocation().y;
    if (extentString == 0) {
        if (extent > 0 && extent < 1) {
            ImageFigure progressDataFigure = new ImageFigure();
            Image image = ImageProvider.getImage(ECoreImage.PROGRESSGRAYBAR);
            progressDataFigure.setImage(image);
            progressDataFigure.setVisible(true);
            progressBarFigure.add(progressDataFigure);
        } else if (extent >= 1 && extent < 10) {
            ImageFigure progressDataFigure = new ImageFigure();
            Image image = ImageProvider.getImage(ECoreImage.PROGRESSGRAYGEBAR);
            progressDataFigure.setImage(image);
            progressDataFigure.setVisible(true);
            progressBarFigure.add(progressDataFigure);
        }
    } else if (extentString == 10) {
        ImageFigure progressDataFigure = new ImageFigure();
        Image image = ImageProvider.getImage(ECoreImage.PROGRESSGREEBAR);
        progressDataFigure.setImage(image);
        progressDataFigure.setVisible(true);
        progressBarFigure.add(progressDataFigure);
    } else if (extentString > 0 && extentString < 10) {
        for (int i = 0; i < extentString; i++) {
            ImageFigure progressDataFigure = new ImageFigure();
            Image image = ImageProvider.getImage(ECoreImage.PROGRESSBAR);
            progressDataFigure.setImage(image);
            progressDataFigure.setVisible(true);
            progressBarFigure.add(progressDataFigure);
            int imageWith = image.getImageData().width;
            if (i != 0) {
                Point point = new Point(nodeX + i * imageWith, nodeY);
                progressDataFigure.setLocation(point);
            }
        }
        for (int j = 0; j < (10 - extentString); j++) {
            ImageFigure progressDataFigure = new ImageFigure();
            Image image = ImageProvider.getImage(ECoreImage.PROGRESSBARBlACK);
            progressDataFigure.setImage(image);
            progressDataFigure.setVisible(true);
            progressBarFigure.add(progressDataFigure);
            int imageWith = image.getImageData().width;
            if (j != 0) {
                Point point = new Point(nodeX + extentString * imageWith + j * imageWith, nodeY);
                progressDataFigure.setLocation(point);
            }
        }
    }
    baseFigure.setSize(dataFigure.getPreferredSize().width + progressBarFigure.getPreferredSize().width, dataFigure.getPreferredSize().height);
    baseFigure.setPreferredSize(dataFigure.getPreferredSize().width + progressBarFigure.getPreferredSize().width, dataFigure.getPreferredSize().height);
    baseFigure.add(progressBarFigure);
    baseFigure.add(dataFigure);
    this.add(baseFigure);
    this.setSize(baseFigure.getSize());
}
Also used : ToolbarLayout(org.eclipse.draw2d.ToolbarLayout) LineBorder(org.eclipse.draw2d.LineBorder) List(java.util.List) ImageFigure(org.eclipse.draw2d.ImageFigure) Point(org.eclipse.draw2d.geometry.Point) Image(org.eclipse.swt.graphics.Image) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) Point(org.eclipse.draw2d.geometry.Point) Figure(org.eclipse.draw2d.Figure) ImageFigure(org.eclipse.draw2d.ImageFigure) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 12 with SimpleHtmlFigure

use of org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure in project tdi-studio-se by Talend.

the class JobletContainerFigure method initMRFigures.

private void initMRFigures() {
    Node node = this.jobletContainer.getNode();
    if (!node.isMapReduceStart()) {
        return;
    }
    if (node.getMrGroupId() == null) {
        return;
    }
    if (dispose) {
        return;
    }
    Integer mrCount = node.getMrJobInGroupCount();
    if (mrCount == null) {
        mrCount = 1;
    }
    Image image = ImageProvider.getImage(ECoreImage.MRGREEBAR);
    // Image map = ImageProvider.getImage(ECoreImage.MRMAP);
    // Image reduce = ImageProvider.getImage(ECoreImage.MRREDUCE);
    int progressHeight = image.getBounds().height;
    int progressWidth = image.getBounds().width;
    for (int i = 0; i < mrCount; i++) {
        SimpleHtmlFigure progressMap = new SimpleHtmlFigure();
        // progressMap.setOutline(false);
        progressMap.setOpaque(false);
        Label mapTip = new Label();
        mapTip.setText("Map ");
        progressMap.setToolTip(mapTip);
        progressMap.setLayoutManager(new ToolbarLayout(true));
        progressMap.setVisible(false);
        SimpleHtmlFigure mapTitle = new SimpleHtmlFigure();
        mapTitle.setText("<b>Map</b> ");
        mapTitle.setSize(mapTitle.getPreferredSize());
        mapTitle.setOpaque(false);
        RectangleFigure mapGreen = new RectangleFigure();
        mapGreen.setSize(progressWidth, progressHeight);
        mapGreen.setPreferredSize(progressWidth, progressHeight + 5);
        mapGreen.setBorder(new LineBorder(ColorConstants.black, 1));
        mapGreen.setLayoutManager(new ToolbarLayout(true));
        mapGreen.setLocation(new Point(progressMap.getLocation().x + mapTitle.getPreferredSize().width, progressMap.getLocation().y));
        mapGreen.setOpaque(true);
        mapGreen.setAlpha(255);
        mapGreen.setVisible(true);
        progressMap.add(mapTitle, 0);
        progressMap.add(mapGreen, 1);
        progressMap.setSize(mapTitle.getPreferredSize().width + mapGreen.getPreferredSize().width, progressHeight + 2);
        progressMap.setPreferredSize(mapTitle.getPreferredSize().width + mapGreen.getPreferredSize().width, progressHeight + 2);
        mrFigures.put(KEY_MAP + i, progressMap);
        // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        SimpleHtmlFigure progressReduce = new SimpleHtmlFigure();
        // progressReduce.setOutline(false);
        progressReduce.setOpaque(false);
        Label reduceTip = new Label();
        reduceTip.setText("Reduce ");
        progressReduce.setToolTip(reduceTip);
        progressReduce.setLayoutManager(new ToolbarLayout(true));
        progressReduce.setVisible(false);
        SimpleHtmlFigure reduceTitle = new SimpleHtmlFigure();
        reduceTitle.setText("<b>Reduce</b> ");
        reduceTitle.setSize(reduceTitle.getPreferredSize());
        reduceTitle.setOpaque(false);
        RectangleFigure reduceGreen = new RectangleFigure();
        reduceGreen.setSize(progressWidth, progressHeight);
        reduceGreen.setPreferredSize(progressWidth, progressHeight + 5);
        reduceGreen.setBorder(new LineBorder(ColorConstants.black, 1));
        reduceGreen.setLayoutManager(new ToolbarLayout(true));
        reduceGreen.setLocation(new Point(progressReduce.getLocation().x + reduceTitle.getPreferredSize().width, progressReduce.getLocation().y));
        reduceGreen.setOpaque(true);
        reduceGreen.setAlpha(255);
        reduceGreen.setVisible(true);
        progressReduce.add(reduceTitle, 0);
        progressReduce.add(reduceGreen, 1);
        progressReduce.setSize(reduceTitle.getPreferredSize().width + reduceGreen.getPreferredSize().width, progressHeight + 2);
        progressReduce.setPreferredSize(reduceTitle.getPreferredSize().width + reduceGreen.getPreferredSize().width, progressHeight + 2);
        mrFigures.put(KEY_REDUCE + i, progressReduce);
    }
}
Also used : ToolbarLayout(org.eclipse.draw2d.ToolbarLayout) RectangleFigure(org.eclipse.draw2d.RectangleFigure) Node(org.talend.designer.core.ui.editor.nodes.Node) LineBorder(org.eclipse.draw2d.LineBorder) Label(org.eclipse.draw2d.Label) Point(org.eclipse.draw2d.geometry.Point) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) Point(org.eclipse.draw2d.geometry.Point) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 13 with SimpleHtmlFigure

use of org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure in project tdi-studio-se by Talend.

the class JobletContainerFigure method addToParentMRFigure.

private void addToParentMRFigure() {
    if (this.parentMRFigure == null) {
        return;
    }
    if (!this.jobletContainer.getNode().isMapReduceStart()) {
        return;
    }
    if (dispose) {
        return;
    }
    Iterator<Entry<String, SimpleHtmlFigure>> ite = mrFigures.entrySet().iterator();
    while (ite.hasNext()) {
        Entry<String, SimpleHtmlFigure> entry = ite.next();
        SimpleHtmlFigure value = entry.getValue();
        if (!this.parentMRFigure.getChildren().contains(value)) {
            this.parentMRFigure.add(value);
        }
    }
}
Also used : Entry(java.util.Map.Entry) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 14 with SimpleHtmlFigure

use of org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure in project tdi-studio-se by Talend.

the class SparkStreamingSubjobContainerFigure method initFigure.

@Override
protected void initFigure() {
    super.initFigure();
    timeoutFigureRect = new RoundedRectangle();
    timeoutFigureText = new SimpleHtmlFigure();
    timeoutFigureText.setOpaque(false);
    statsFigureRect = new RoundedRectangle();
    statsFigureText = new SimpleHtmlFigure();
    statsFigureText.setOpaque(false);
    //$NON-NLS-1$ 
    String text = "<b>Batch started</b>: <br>";
    //$NON-NLS-1$
    text += "<b>Batch completed</b>: <br><br><br>";
    //$NON-NLS-1$ 
    text += "<b>Last scheduling delay</b>: <br>";
    //$NON-NLS-1$ 
    text += "<b>Last processing delay</b>: <br>";
    //$NON-NLS-1$ 
    text += "<b>Last total delay</b>: <br>";
    statsFigureText.setText(text);
}
Also used : RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 15 with SimpleHtmlFigure

use of org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure in project tdi-studio-se by Talend.

the class JobletContainer method getJobletContainerRectangle.

/**
     * DOC hwang Comment method "getJobletContainerRectangle".
     * 
     * @return
     */
public Rectangle getJobletContainerRectangle() {
    Rectangle totalRectangle = null;
    boolean collapsed = isCollapsed();
    boolean mapStart = this.getNode().isMapReduceStart();
    boolean noNeedExpend = false;
    if ((!collapsed || mapStart) && nodeContainers.size() > 0) {
        for (NodeContainer container : nodeContainers) {
            Rectangle curRect = container.getNodeContainerRectangle();
            if (container.getSubjobContainer() != null && container.getSubjobContainer().isCollapsed() && this.getNode().isMapReduce()) {
                if (container.getNode().isMapReduceStart()) {
                    totalRectangle = curRect.getCopy();
                    noNeedExpend = true;
                    break;
                } else {
                    continue;
                }
            }
            if (node.getNodeContainer() instanceof JobletContainer) {
                String title = (String) node.getNodeContainer().getPropertyValue(EParameterName.SUBJOB_TITLE.getName());
                SimpleHtmlFigure titleFigure = new SimpleHtmlFigure();
                //$NON-NLS-1$ //$NON-NLS-2$
                titleFigure.setText("<b> " + title + "</b>");
                Dimension preferedSize = titleFigure.getPreferredSize();
                if (preferedSize.width > curRect.width) {
                    curRect.setSize(preferedSize.width + 6, curRect.height);
                }
            }
            if (this.getNode().isMapReduceStart()) {
                Integer count = this.getNode().getMrJobInGroupCount();
                Image image = ImageProvider.getImage(ECoreImage.MRGREEBAR);
                int progressHeight = image.getBounds().height + 1;
                if (count != null) {
                    if (count == 1) {
                        curRect.setSize(curRect.width, curRect.height + 6);
                    } else if (count > 1) {
                        curRect.setSize(curRect.width, curRect.height + progressHeight * (count - 1) + 10);
                    }
                }
            }
            if (totalRectangle == null) {
                totalRectangle = curRect.getCopy();
            } else {
                totalRectangle = totalRectangle.getUnion(curRect);
            }
        // }
        }
        // totalRectangle.setLocation(jobletNodeRec.getLocation());
        // totalRectangle.x = totalRectangle.x - EXPEND_SIZE * 2;
        totalRectangle.y = totalRectangle.y - EXPEND_SIZE * 2;
        totalRectangle.height = totalRectangle.height + EXPEND_SIZE * 4;
    } else if (node != null) {
        NodeContainer container = node.getNodeContainer();
        Rectangle curRect = container.getNodeContainerRectangle();
        if (collapsed) {
            totalRectangle = curRect.getCopy();
        } else {
            if (totalRectangle == null) {
                totalRectangle = curRect.getCopy();
            } else {
                totalRectangle = totalRectangle.getUnion(curRect);
            }
        }
    }
    if (totalRectangle == null) {
        return null;
    }
    if (jobletRectangle != null) {
        if ((Math.abs(jobletRectangle.width - totalRectangle.width) != 0) || this.nodeContainers.size() == 1) {
            if (jobletRectangle.x > totalRectangle.x) {
                leftChangeWidth = jobletRectangle.x - totalRectangle.x;
            }
            rightChangeWidth = Math.abs(jobletRectangle.width - totalRectangle.width);
            if (rightChangeWidth > leftChangeWidth) {
                rightChangeWidth = rightChangeWidth - leftChangeWidth;
            }
        }
        if ((Math.abs(jobletRectangle.height - totalRectangle.height) != 0) || this.nodeContainers.size() == 1) {
            if (jobletRectangle.y > totalRectangle.y) {
                upChangeHeight = jobletRectangle.y - totalRectangle.y;
            }
            downChangeHeight = Math.abs(jobletRectangle.height - totalRectangle.height);
            if (downChangeHeight > upChangeHeight) {
                downChangeHeight = downChangeHeight - upChangeHeight;
            }
        }
    }
    if (!noNeedExpend) {
        changeWidth(totalRectangle);
    }
    jobletRectangle = totalRectangle.getCopy();
    return totalRectangle;
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Dimension(org.eclipse.draw2d.geometry.Dimension) Image(org.eclipse.swt.graphics.Image) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) Point(org.eclipse.draw2d.geometry.Point) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Aggregations

SimpleHtmlFigure (org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)16 Point (org.eclipse.draw2d.geometry.Point)8 Entry (java.util.Map.Entry)4 Dimension (org.eclipse.draw2d.geometry.Dimension)4 Image (org.eclipse.swt.graphics.Image)4 ECoreImage (org.talend.commons.ui.runtime.image.ECoreImage)4 Figure (org.eclipse.draw2d.Figure)3 ImageFigure (org.eclipse.draw2d.ImageFigure)3 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)3 List (java.util.List)2 ActionEvent (org.eclipse.draw2d.ActionEvent)2 ActionListener (org.eclipse.draw2d.ActionListener)2 IFigure (org.eclipse.draw2d.IFigure)2 LineBorder (org.eclipse.draw2d.LineBorder)2 RectangleFigure (org.eclipse.draw2d.RectangleFigure)2 RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)2 EImage (org.talend.commons.ui.runtime.image.EImage)2