Search in sources :

Example 1 with SnapToHelper

use of org.eclipse.gef.SnapToHelper 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 SnapToHelper

use of org.eclipse.gef.SnapToHelper 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 SnapToHelper

use of org.eclipse.gef.SnapToHelper in project tdi-studio-se by Talend.

the class ProcessPart method getAdapter.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
     */
@Override
public Object getAdapter(final Class adapter) {
    if (adapter.equals(RepositoryNode.class)) {
        if (node == null) {
            RootEditPart rootEditPart = getRoot();
            if (rootEditPart instanceof TalendScalableFreeformRootEditPart) {
                TalendScalableFreeformRootEditPart rootEditPart2 = (TalendScalableFreeformRootEditPart) rootEditPart;
                IEditorInput editorInput = rootEditPart2.getEditorInput();
                if (editorInput instanceof ProcessEditorInput) {
                    ProcessEditorInput processEditorInput = (ProcessEditorInput) editorInput;
                    node = processEditorInput.getRepositoryNode();
                }
            }
        }
        return node;
    }
    if (adapter == 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(adapter);
}
Also used : SnapToHelper(org.eclipse.gef.SnapToHelper) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) ArrayList(java.util.ArrayList) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) SnapToGrid(org.eclipse.gef.SnapToGrid) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) IEditorInput(org.eclipse.ui.IEditorInput) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart)

Example 4 with SnapToHelper

use of org.eclipse.gef.SnapToHelper in project cubrid-manager by CUBRID.

the class ERSchemaEditor method getAdapter.

/**
	 * Adaptable implementation for Editor
	 */
public Object getAdapter(Class adapter) {
    if (adapter == GraphicalViewer.class || adapter == EditPartViewer.class)
        return getGraphicalViewer();
    else if (adapter == CommandStack.class)
        return getCommandStack();
    else if (adapter == EditDomain.class)
        return getEditDomain();
    else if (adapter == ActionRegistry.class)
        return getActionRegistry();
    else if (adapter == IPropertySheetPage.class)
        return getPropertySheetPage();
    if (adapter == SnapToHelper.class) {
        List snapStrategies = new ArrayList();
        Boolean val = (Boolean) getGraphicalViewer().getProperty(RulerProvider.PROPERTY_RULER_VISIBILITY);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGuides((GraphicalEditPart) this));
        }
        val = (Boolean) getGraphicalViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGeometry((GraphicalEditPart) this));
        }
        val = (Boolean) getGraphicalViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
        if (val != null && val.booleanValue()) {
            snapStrategies.add(new SnapToGrid((GraphicalEditPart) this));
        }
        if (snapStrategies.size() == 0) {
            return null;
        }
        if (snapStrategies.size() == 1) {
            return (SnapToHelper) snapStrategies.get(0);
        }
        SnapToHelper[] sth = new SnapToHelper[snapStrategies.size()];
        for (int i = 0; i < snapStrategies.size(); i++) {
            sth[i] = (SnapToHelper) snapStrategies.get(i);
        }
        return new CompoundSnapToHelper(sth);
    }
    return super.getAdapter(adapter);
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) GraphicalViewer(org.eclipse.gef.GraphicalViewer) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ValidationGraphicalViewer(com.cubrid.common.ui.er.ValidationGraphicalViewer) SnapToHelper(org.eclipse.gef.SnapToHelper) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) ArrayList(java.util.ArrayList) EditPartViewer(org.eclipse.gef.EditPartViewer) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry) SnapToGeometry(org.eclipse.gef.SnapToGeometry) Point(org.eclipse.draw2d.geometry.Point) SnapToGrid(org.eclipse.gef.SnapToGrid) ArrayList(java.util.ArrayList) List(java.util.List) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) CompoundSnapToHelper(org.eclipse.gef.CompoundSnapToHelper) SnapToGuides(org.eclipse.gef.SnapToGuides)

Example 5 with SnapToHelper

use of org.eclipse.gef.SnapToHelper 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)5 CompoundSnapToHelper (org.eclipse.gef.CompoundSnapToHelper)5 SnapToGrid (org.eclipse.gef.SnapToGrid)5 SnapToHelper (org.eclipse.gef.SnapToHelper)5 NodeSnapToGeometry (org.talend.designer.core.ui.editor.process.NodeSnapToGeometry)3 Point (org.eclipse.draw2d.geometry.Point)2 ValidationGraphicalViewer (com.cubrid.common.ui.er.ValidationGraphicalViewer)1 List (java.util.List)1 EditPartViewer (org.eclipse.gef.EditPartViewer)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 RootEditPart (org.eclipse.gef.RootEditPart)1 SnapToGeometry (org.eclipse.gef.SnapToGeometry)1 SnapToGuides (org.eclipse.gef.SnapToGuides)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)1 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)1 IEditorInput (org.eclipse.ui.IEditorInput)1 ProcessEditorInput (org.talend.designer.core.ui.editor.ProcessEditorInput)1 TalendScalableFreeformRootEditPart (org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart)1