Search in sources :

Example 16 with GraphicalEditPart

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

the class RowSelectionEditPolicy method getLocatorFigure.

private IFigure getLocatorFigure(GraphicalEditPart owner) {
    IFigure figure = owner.getFigure();
    if (owner instanceof TableEntityPart) {
        TableEntityFigure treeNodeFigure = (TableEntityFigure) figure;
        // table figure to restrict the width
        MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) owner);
        IFigure parentFigure = ((GraphicalEditPart) abstractInOutTreePart).getFigure();
        Rectangle treeBounds = parentFigure.getBounds();
        Rectangle rowBounds = treeNodeFigure.getElement().getBounds();
        Rectangle treeNodeBounds = figure.getBounds();
        figure = new Figure();
        if (treeBounds.x + 1 != treeNodeBounds.x || treeNodeBounds.width > treeBounds.width) {
            figure.setBounds(new Rectangle(treeBounds.x + 1, treeNodeBounds.y, treeBounds.width - 2, rowBounds.height));
            return figure;
        } else {
            figure.setBounds(owner.getFigure().getBounds().getCopy());
            figure.getBounds().height = rowBounds.height;
            return figure;
        }
    } else if (figure instanceof VarEntityFigure) {
        Rectangle copy = figure.getBounds().getCopy();
        figure = new Figure();
        figure.setBounds(copy);
        return figure;
    }
    return owner.getFigure();
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) IFigure(org.eclipse.draw2d.IFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure)

Example 17 with GraphicalEditPart

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

the class TablePart method refreshVisuals.

@Override
protected void refreshVisuals() {
    Table table = (Table) getModel();
    Point loc = table.getLocation();
    Dimension size = table.getSize();
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) 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)

Example 18 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart 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 19 with GraphicalEditPart

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

the class AbstractBasicPart method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    String property = evt.getPropertyName();
    if (PropertyChangeProvider.CHILD_CHANGE.equals(property)) {
        handleChildChange(evt);
    } else if (PropertyChangeProvider.REORDER_CHANGE.equals(property)) {
        handleReorderChange(evt);
    } else if (PropertyChangeProvider.OUTPUT_CHANGE.equals(property)) {
        handleOutputChange(evt);
    } else if (PropertyChangeProvider.INPUT_CHANGE.equals(property)) {
        handleInputChange(evt);
    } else if (PropertyChangeProvider.TEXT_CHANGE.equals(property)) {
        handleLabelChange(evt);
    } else if (PropertyChangeProvider.BOUNDS_CHANGE.equals(property)) {
        handleBoundsChange(evt);
    } else if (PropertyChangeProvider.LAYOUT_CHANGE.equals(property)) {
        handleLayoutChange(evt);
    } else if (PropertyChangeProvider.AUTO_LAYOUT_TEMP.equals(property)) {
        handleTmpAutoLayout(evt);
    } else if (PropertyChangeProvider.VIEW_MODEL_CHANGE.equals(property)) {
        handleViewModelChange(evt);
    } else if (PropertyChangeProvider.RELATION_MAP_CHANGE.equals(property)) {
        handleRelationMapChange(evt);
    }
    if (PropertyChangeProvider.TEXT_CHANGE.equals(property)) {
        GraphicalEditPart graphicalEditPart = (GraphicalEditPart) (getViewer().getContents());
        IFigure partFigure = graphicalEditPart.getFigure();
        partFigure.getUpdateManager().performUpdate();
    }
    postSchemaDataChanged(evt);
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 20 with GraphicalEditPart

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

the class GefViewerKeyHandler method keyPressed.

/**
	 * @see org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler.keyPressed
	 * @param event KeyEvent
	 * @return true or false.
	 */
public boolean keyPressed(KeyEvent event) {
    GraphicalEditPart editPart = getFocusEditPart();
    if (editPart instanceof HANodePart) {
        if (moveHANodesByKey(event)) {
            return true;
        }
        if (deleteHANodeByKey(event)) {
            return true;
        }
    }
    if (editPart instanceof DashboardPart && event.keyCode == SWT.F5) {
        DashboardPart dp = (DashboardPart) editPart;
        dp.refresh();
        List<?> childEditPart = dp.getChildren();
        for (Object child : childEditPart) {
            ((EditPart) child).refresh();
        }
    }
    return super.keyPressed(event);
}
Also used : DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) HANodePart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)

Aggregations

GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)36 ArrayList (java.util.ArrayList)14 List (java.util.List)14 Command (org.eclipse.gef.commands.Command)13 Request (org.eclipse.gef.Request)12 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)11 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)11 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)11 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)11 LabelDirectEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy)11 IFigure (org.eclipse.draw2d.IFigure)10 Point (org.eclipse.draw2d.geometry.Point)10 Dimension (org.eclipse.draw2d.geometry.Dimension)6 EditPart (org.eclipse.gef.EditPart)3 HANode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode)2 HANodePart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)2 Iterator (java.util.Iterator)2 UnexecutableCommand (org.eclipse.gef.commands.UnexecutableCommand)2 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)2