Search in sources :

Example 6 with SimpleHtmlFigure

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

the class MonitorConnectionLabelConstraint method relocate.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
     */
public void relocate(IFigure figure) {
    if (!(figure instanceof SimpleHtmlFigure)) {
        this.minimum = FigureUtilities.getTextExtents(text, figure.getFont());
    }
    figure.setSize(minimum);
    Point location;
    if (position.equals("start")) {
        //$NON-NLS-1$
        location = connFigure.getStart();
    } else if (position.equals("end")) {
        //$NON-NLS-1$
        location = connFigure.getEnd();
    } else {
        location = connFigure.getPoints().getMidpoint();
    }
    if (offset == null) {
        offset = new Point();
    }
    Point offsetCopy = offset.getCopy();
    offsetCopy.translate(location);
    offsetCopy.translate(0, -yOffset);
    figure.setLocation(offsetCopy);
}
Also used : Point(org.eclipse.draw2d.geometry.Point) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 7 with SimpleHtmlFigure

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

the class ConnLabelConstraint method relocate.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
     */
public void relocate(IFigure figure) {
    if (!(figure instanceof SimpleHtmlFigure)) {
        this.minimum = FigureUtilities.getTextExtents(text, figure.getFont());
    }
    figure.setSize(minimum);
    Point location;
    if (position.equals("start")) {
        //$NON-NLS-1$
        location = connFigure.getStart();
    } else if (position.equals("end")) {
        //$NON-NLS-1$
        location = connFigure.getEnd();
    } else {
        location = connFigure.getPoints().getMidpoint();
    }
    Point offsetCopy = offset.getCopy();
    offsetCopy.translate(location);
    offsetCopy.translate(-(minimum.width / 2), 0);
    figure.setLocation(offsetCopy);
}
Also used : Point(org.eclipse.draw2d.geometry.Point) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 8 with SimpleHtmlFigure

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

the class SubjobContainerFigure method initFigure.

/**
     * DOC rdubois Comment method "initFigure".
     */
protected void initFigure() {
    outlineFigure = new RoundedRectangle();
    rectFig = new RoundedRectangle();
    titleFigure = new SimpleHtmlFigure();
    titleFigure.setOpaque(true);
    collapseFigure = new SubjobCollapseFigure();
    collapseFigure.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            IProcess2 process = subjobContainer.getProcess();
            if (!process.isReadOnly()) {
                PropertyChangeCommand ppc = new PropertyChangeCommand(subjobContainer, EParameterName.COLLAPSED.getName(), !subjobContainer.isCollapsed());
                boolean executed = false;
                if (process instanceof IGEFProcess) {
                    IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
                    if (designerCoreUIService != null) {
                        executed = designerCoreUIService.executeCommand((IGEFProcess) process, ppc);
                    }
                }
                if (!executed) {
                    ppc.execute();
                }
                reSelection();
            }
        }
    });
}
Also used : PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ActionListener(org.eclipse.draw2d.ActionListener) ActionEvent(org.eclipse.draw2d.ActionEvent) IProcess2(org.talend.core.model.process.IProcess2) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Example 9 with SimpleHtmlFigure

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

the class NodeLabelEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    Node node = ((NodeLabel) getModel()).getNode();
    // Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
    String text = ((NodeLabel) getModel()).getLabelText();
    SimpleHtmlFigure htmlFig = (SimpleHtmlFigure) this.getFigure();
    htmlFig.setText(text);
    Point loc = node.getLocation().getCopy();
    Point offset = ((NodeLabel) getModel()).getOffset();
    Point textOffset = new Point();
    Dimension size = htmlFig.getPreferredSize();
    textOffset.y = node.getSize().height;
    textOffset.x = (node.getSize().width - size.width) / 2;
    ((NodeLabel) getModel()).setTextOffset(textOffset);
    loc.translate(textOffset.x + offset.x, textOffset.y + offset.y);
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 10 with SimpleHtmlFigure

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

the class NodeLabelEditPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
public void propertyChange(final PropertyChangeEvent evt) {
    String request = evt.getPropertyName();
    if (request.equals(NodeLabel.OFFSET_CHANGE)) {
        //$NON-NLS-1$ //$NON-NLS-2$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(NodeLabel.TEXT_CHANGE)) {
        refreshVisuals();
        // set the new size to update the node container
        ((NodeLabel) getModel()).setLabelSize(((SimpleHtmlFigure) figure).getPreferredSize());
        NodeLabel label = (NodeLabel) getModel();
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ISQLBuilderService.class)) {
            ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
            service.updateSqlBuilderDialogTitle(label.getLabelText(), label.getNode().getProcess().getName(), label.getNode().getUniqueName());
        }
        getParent().refresh();
        // refresh the title of component setting view.
        ComponentSettingsView viewer = (ComponentSettingsView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ComponentSettingsView.ID);
        if (viewer != null) {
            viewer.updatePropertiesViewerTitle();
        }
    }
    if (request.equals(NodeLabel.LOCATION)) {
        //$NON-NLS-1$
        refreshVisuals();
        getParent().refresh();
    }
    if (request.equals(EParameterName.ACTIVATE.getName())) {
        if (((NodeLabel) getModel()).isActivate()) {
            ((SimpleHtmlFigure) figure).setAlpha(-1);
            ((SimpleHtmlFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((SimpleHtmlFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((SimpleHtmlFigure) figure).repaint();
            refreshVisuals();
        }
    }
    EditPart editPart = getParent();
    if (editPart != null) {
        while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
            editPart = editPart.getParent();
        }
        if (editPart instanceof SubjobContainerPart) {
            editPart.refresh();
        }
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ComponentSettingsView(org.talend.designer.core.ui.views.properties.ComponentSettingsView) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ISQLBuilderService(org.talend.core.ui.services.ISQLBuilderService) 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