Search in sources :

Example 1 with NodeSnapToGeometry

use of org.talend.designer.core.ui.editor.process.NodeSnapToGeometry in project tdi-studio-se by Talend.

the class NodeContainerPart method getAdapter.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
     */
@Override
public Object getAdapter(Class key) {
    if (key == SnapToHelper.class) {
        List<Object> snapStrategies = new ArrayList<Object>();
        Boolean val = (Boolean) getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
        val = (Boolean) getViewer().getProperty(NodeSnapToGeometry.PROPERTY_SNAP_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new NodeSnapToGeometry(this));
        }
        val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGrid(this));
        }
        if (snapStrategies.size() == 0) {
            return null;
        }
        if (snapStrategies.size() == 1) {
            return snapStrategies.get(0);
        }
        SnapToHelper[] ss = new SnapToHelper[snapStrategies.size()];
        for (int i = 0; i < snapStrategies.size(); i++) {
            ss[i] = (SnapToHelper) snapStrategies.get(i);
        }
        return new CompoundSnapToHelper(ss);
    }
    return super.getAdapter(key);
}
Also used : SnapToGrid(org.eclipse.gef.SnapToGrid) SnapToHelper(org.eclipse.gef.SnapToHelper) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) ArrayList(java.util.ArrayList) NodeSnapToGeometry(org.talend.designer.core.ui.editor.process.NodeSnapToGeometry) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper)

Example 2 with NodeSnapToGeometry

use of org.talend.designer.core.ui.editor.process.NodeSnapToGeometry in project tdi-studio-se by Talend.

the class SubjobContainerPart method getAdapter.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
     */
@Override
public Object getAdapter(Class key) {
    if (key == SnapToHelper.class) {
        List<Object> snapStrategies = new ArrayList<Object>();
        Boolean val = (Boolean) getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
        val = (Boolean) getViewer().getProperty(NodeSnapToGeometry.PROPERTY_SNAP_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new NodeSnapToGeometry(this));
        }
        val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGrid(this));
        }
        if (snapStrategies.size() == 0) {
            return null;
        }
        if (snapStrategies.size() == 1) {
            return snapStrategies.get(0);
        }
        SnapToHelper[] ss = new SnapToHelper[snapStrategies.size()];
        for (int i = 0; i < snapStrategies.size(); i++) {
            ss[i] = (SnapToHelper) snapStrategies.get(i);
        }
        return new CompoundSnapToHelper(ss);
    }
    return super.getAdapter(key);
}
Also used : SnapToGrid(org.eclipse.gef.SnapToGrid) SnapToHelper(org.eclipse.gef.SnapToHelper) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) ArrayList(java.util.ArrayList) NodeSnapToGeometry(org.talend.designer.core.ui.editor.process.NodeSnapToGeometry) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with NodeSnapToGeometry

use of org.talend.designer.core.ui.editor.process.NodeSnapToGeometry in project tdi-studio-se by Talend.

the class JobletContainerPart method getAdapter.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
     */
@Override
public Object getAdapter(Class key) {
    if (key == SnapToHelper.class) {
        List<Object> snapStrategies = new ArrayList<Object>();
        Boolean val = (Boolean) getViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
        val = (Boolean) getViewer().getProperty(NodeSnapToGeometry.PROPERTY_SNAP_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new NodeSnapToGeometry(this));
        }
        val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGrid(this));
        }
        if (snapStrategies.size() == 0) {
            return null;
        }
        if (snapStrategies.size() == 1) {
            return snapStrategies.get(0);
        }
        SnapToHelper[] ss = new SnapToHelper[snapStrategies.size()];
        for (int i = 0; i < snapStrategies.size(); i++) {
            ss[i] = (SnapToHelper) snapStrategies.get(i);
        }
        return new CompoundSnapToHelper(ss);
    }
    return super.getAdapter(key);
}
Also used : SnapToGrid(org.eclipse.gef.SnapToGrid) SnapToHelper(org.eclipse.gef.SnapToHelper) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) ArrayList(java.util.ArrayList) NodeSnapToGeometry(org.talend.designer.core.ui.editor.process.NodeSnapToGeometry) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper)

Aggregations

ArrayList (java.util.ArrayList)3 CompoundSnapToHelper (org.eclipse.gef.CompoundSnapToHelper)3 SnapToGrid (org.eclipse.gef.SnapToGrid)3 SnapToHelper (org.eclipse.gef.SnapToHelper)3 NodeSnapToGeometry (org.talend.designer.core.ui.editor.process.NodeSnapToGeometry)3 Point (org.eclipse.draw2d.geometry.Point)1