Search in sources :

Example 81 with EditPart

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

the class HostMonitorEditPolicy method createDeleteCommand.

/**
	 * create a command of delete figure
	 * 
	 * @param deleteRequest to delete figure
	 * @return command of delete figure
	 */
protected Command createDeleteCommand(GroupRequest deleteRequest) {
    DeleteHostMonitorCommand deleteCommand = new DeleteHostMonitorCommand();
    EditPart host = getHost();
    deleteCommand.setNodeToDelete((HostNode) host.getModel());
    deleteCommand.setDashboard((Dashboard) host.getParent().getModel());
    return deleteCommand;
}
Also used : EditPart(org.eclipse.gef.EditPart) DeleteHostMonitorCommand(com.cubrid.cubridmanager.ui.mondashboard.editor.command.DeleteHostMonitorCommand)

Example 82 with EditPart

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

the class TalendPaletteViewer method addRecentlyUsedComponent.

public void addRecentlyUsedComponent(IComponent component) {
    EComponentType componentType = component.getComponentType();
    if (componentType == EComponentType.JOBLET_INPUT_OUTPUT || componentType == EComponentType.JOBLET_TRIGGER) {
        return;
    }
    if (recentlyUsedEditPart != null) {
        List children = recentlyUsedEditPart.getChildren();
        int insertIndex = 0;
        boolean alreadyExist = false;
        if (children != null) {
            for (; insertIndex < children.size(); insertIndex++) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                int compareResult = entryModule.getLabel().compareTo(component.getName());
                if (0 == compareResult) {
                    alreadyExist = true;
                    break;
                }
            // if (0 < compareResult) {
            // break;
            // }
            }
        }
        // if already exist, remove first
        if (alreadyExist) {
            if (0 == insertIndex) {
                return;
            }
            TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(insertIndex);
            CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
            removeRecentlyUsedComponent(entryModule);
        }
        // if (!alreadyExist) {
        TalendCombinedTemplateCreationEntry newRecently = TalendEditorPaletteFactory.createEntryFrom(component);
        newRecently.setTimestemp(new Date());
        newRecently.setParent(recentlyUsedEditPart.getDrawer());
        EditPart child = recentlyUsedEditPart.createChild(newRecently);
        PaletteDrawer paletteDrawer = recentlyUsedEditPart.getDrawer();
        if (paletteDrawer != null) {
            // paletteDrawer.add(insertIndex, newRecently);
            paletteDrawer.add(0, newRecently);
        }
        // reobtain
        children = recentlyUsedEditPart.getChildren();
        if (children != null) {
            int size = children.size();
            final int recentlyUsedSize = PaletteSettingsPreferencePage.getPaletteRencentlyUsedListSize();
            if (recentlyUsedSize < size) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) children.get(recentlyUsedSize);
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                removeRecentlyUsedComponent(entryModule);
            }
        }
        // needn't use this, or will cause problem
        // recentlyUsedEditPart.addChild(child, insertIndex);
        // }
        refreshRecentlyUsedComponentToReference();
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) List(java.util.List) ArrayList(java.util.ArrayList) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) EComponentType(org.talend.core.model.components.EComponentType) Date(java.util.Date)

Example 83 with EditPart

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

the class FindAssignmentAction method zoomFitSelection.

// PTODO mhelleboid bug for org.eclipse.gmf.runtime.diagram.ui.internal.actions.ZoomContributionItem
private void zoomFitSelection(ZoomManager zoomManager, List editParts, DiagramEditPart diagramEditPart, boolean zoomOutOnly) {
    Rectangle rectangle = null;
    for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
        EditPart editPart = (EditPart) iter.next();
        IFigure f = ((GraphicalEditPart) editPart).getFigure();
        rectangle = rectangle == null ? f.getBounds().getCopy() : rectangle.getUnion(f.getBounds());
    }
    // IF nothing to Zoom...
    if (rectangle == null) {
        // do nothing
        return;
    }
    // Translate the region into pixels
    MapModeUtil.getMapMode(diagramEditPart.getFigure()).LPtoDP(rectangle);
    Viewport viewport = zoomManager.getViewport();
    float xratio = viewport.getHorizontalRangeModel().getExtent() / (float) rectangle.width;
    float yratio = viewport.getVerticalRangeModel().getExtent() / (float) rectangle.height;
    double zoom = 1.0;
    zoom = (yratio < xratio) ? Math.floor(yratio * 100) : Math.floor(xratio * 100);
    if (zoomOutOnly && zoom >= 100) {
        // we should always continue in order to set the viewport
        // location
        zoom = 100;
    }
    // apply thresholds
    zoom = Math.min((int) (zoomManager.getMaxZoom() * 100), Math.max((int) (zoomManager.getMinZoom() * 100), zoom));
    int viewX = Math.round(rectangle.getTopLeft().x * (float) zoom / 100.0f);
    int viewY = Math.round(rectangle.getTopLeft().y * (float) zoom / 100.0f);
    zoomManager.setZoom(zoom / 100);
    viewport.setHorizontalLocation(viewX);
    viewport.setVerticalLocation(viewY);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Iterator(java.util.Iterator) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) Viewport(org.eclipse.draw2d.Viewport) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 84 with EditPart

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

the class TalendConnectionCreationTool method handleCreateConnection.

/*
     * override this method for issue 1253.
     * 
     * @see org.eclipse.gef.tools.AbstractConnectionCreationTool#handleCreateConnection()
     */
@Override
protected boolean handleCreateConnection() {
    Command endCommand = getCommand();
    if (endCommand != null) {
        return super.handleCreateConnection();
    }
    if (getTargetEditPart() == null) {
        EditPart processPart = getProcessPart(this.sourcePart);
        if (processPart != null) {
            this.setTargetEditPart(getProcessPart(this.sourcePart));
            this.getTargetRequest().setType(RequestConstants.REQ_CONNECTION_END);
        }
        return handleConnection();
    }
    if (isInState(STATE_TERMINAL)) {
        // Fake a drag to cause feedback to be displayed immediately on mouse down.
        setState(STATE_CONNECTION_STARTED);
        handleDrag();
    }
    return true;
}
Also used : CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart)

Example 85 with EditPart

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

the class SubjobContainerPart method propertyChange.

/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
@Override
public void propertyChange(PropertyChangeEvent evt) {
    String prop = evt.getPropertyName();
    if (SubjobContainer.UPDATE_SUBJOB_CONTENT.equals(prop)) {
        refresh();
        List<AbstractGraphicalEditPart> childrens = getChildren();
        for (AbstractGraphicalEditPart part : childrens) {
            part.refresh();
        }
    } else if (SubjobContainer.UPDATE_SUBJOB_CONNECTIONS.equals(prop)) {
        refreshSourceConnections();
    } else if (SubjobContainer.UPDATE_SUBJOB_TITLE_COLOR.equals(prop)) {
        if (getFigure() instanceof SubjobContainerFigure) {
            ((SubjobContainerFigure) getFigure()).updateSubJobTitleColor();
            refreshVisuals();
        }
    } else if (SubjobContainer.UPDATE_SUBJOB_DISPLAY.equals(prop)) {
        List<NodeContainer> tmpList = new ArrayList<NodeContainer>(((SubjobContainer) getModel()).getNodeContainers());
        ((SubjobContainer) getModel()).getNodeContainers().clear();
        refreshChildren();
        List elems = ((Process) getParent().getModel()).getElements();
        elems.remove(getModel());
        EditPart parent = getParent();
        parent.refresh();
        ((SubjobContainer) getModel()).getNodeContainers().addAll(tmpList);
        elems.add(getModel());
        parent.refresh();
    } else if ("UPDATE_SPARKSTREAMING_STATUS".equals(prop)) {
        if (getFigure() instanceof SparkStreamingSubjobContainerFigure) {
            ((SparkStreamingSubjobContainerFigure) getFigure()).updateData();
            refreshVisuals();
        }
    } else {
        // can only be UPDATE_SUBJOB_DATA, need to modify if some others are added
        if (getFigure() instanceof SubjobContainerFigure) {
            ((SubjobContainerFigure) getFigure()).updateData();
            refreshVisuals();
        }
    }
}
Also used : SparkStreamingSubjobContainerFigure(org.talend.designer.core.ui.editor.subjobcontainer.sparkstreaming.SparkStreamingSubjobContainerFigure) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) SparkStreamingSubjobContainerFigure(org.talend.designer.core.ui.editor.subjobcontainer.sparkstreaming.SparkStreamingSubjobContainerFigure) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

EditPart (org.eclipse.gef.EditPart)132 List (java.util.List)50 ArrayList (java.util.ArrayList)37 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)26 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)20 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)19 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)18 Point (org.eclipse.draw2d.geometry.Point)17 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)17 Command (org.eclipse.gef.commands.Command)16 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)16 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)15 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)14 Node (org.talend.designer.core.ui.editor.nodes.Node)13 RootEditPart (org.eclipse.gef.RootEditPart)11 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)11 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)11 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)10 INode (org.talend.core.model.process.INode)10