Search in sources :

Example 1 with JobletUtil

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

the class SubjobContainer method refreshNodesLocation.

public void refreshNodesLocation(boolean jobletCollapsed, AbstractJobletContainer nc, int rightChangewidth, int downChangeheight, int leftChangewidth, int upChangeheight) {
    JobletUtil util = new JobletUtil();
    Node node = nc.getNode();
    Rectangle jobletRec = new Rectangle(node.getLocation(), node.getSize());
    boolean isJobletSubjob = nc.getSubjobContainer() == this;
    for (NodeContainer container : nodeContainers) {
        if (container.getNode().getUniqueName().equals(nc.getNode().getUniqueName())) {
            continue;
        }
        Point nodePoint = container.getNode().getLocation().getCopy();
        Rectangle jRec = util.getExpandRectangle(jobletRec);
        // Rectangle jNodeConRec = util.getExpandRectangle(nodeConRec);
        // Rectangle pointrec = util.getExpandRectangle(container.getNodeContainerRectangle());
        jRec.width = jRec.width + rightChangewidth + leftChangewidth;
        jRec.height = jRec.height + downChangeheight + upChangeheight;
        // jNodeConRec.height = jNodeConRec.height + changeheight;
        if (!jobletCollapsed) {
            if (!nc.isUpdate()) {
                Point origPoint = new Point(nodePoint.x, nodePoint.y);
                pointMap.put(container.getNode().getUniqueName(), origPoint);
                if (isJobletSubjob) {
                    if (nodePoint.x > jobletRec.x) {
                        nodePoint.x = nodePoint.x + rightChangewidth;
                    }
                    if (nodePoint.y > jobletRec.y) {
                        nodePoint.y = nodePoint.y + downChangeheight;
                    }
                    if (nodePoint.x < jobletRec.x) {
                        nodePoint.x = nodePoint.x - leftChangewidth;
                    }
                    if (nodePoint.y < jobletRec.y) {
                        nodePoint.y = nodePoint.y - upChangeheight;
                    }
                } else {
                    Rectangle jobletSubRec = nc.getSubjobContainer().getSubjobContainerRectangle();
                    Rectangle currentRec = this.getSubjobContainerRectangle();
                    if (nodePoint.x > jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
                        nodePoint.x = nodePoint.x + rightChangewidth;
                    }
                    if (nodePoint.y > jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
                        nodePoint.y = nodePoint.y + downChangeheight;
                    }
                    if (nodePoint.x < jobletRec.x && !(currentRec.y < jobletSubRec.y && currentRec.y + currentRec.height <= jobletSubRec.y + upChangeheight + node.getSize().height || jobletSubRec.y + jobletSubRec.height <= currentRec.y + downChangeheight + node.getSize().height && currentRec.y > jobletSubRec.y)) {
                        nodePoint.x = nodePoint.x - leftChangewidth;
                    }
                    if (nodePoint.y < jobletRec.y && !(currentRec.x < jobletSubRec.x && currentRec.x + currentRec.width <= jobletSubRec.x + leftChangewidth + node.getSize().width || jobletSubRec.x + jobletSubRec.width <= currentRec.x + rightChangewidth + node.getSize().width && currentRec.x > jobletSubRec.x)) {
                        nodePoint.y = nodePoint.y - upChangeheight;
                    }
                }
            }
        } else {
            nodePoint = pointMap.get(container.getNode().getUniqueName());
        // if (nodePoint.x > nodeRec.x && nodePoint.x > rightChangewidth) {
        // nodePoint.x = nodePoint.x - rightChangewidth;
        // }
        // if (nodePoint.x < nodeRec.x) {
        // nodePoint.x = nodePoint.x + leftChangewidth;
        // }
        // if (nodePoint.y > nodeRec.y && nodePoint.y > downChangeheight) {
        // if ((nodePoint.y - downChangeheight) > (nodeRec.y + 64)) {
        // nodePoint.y = nodePoint.y - downChangeheight;
        // } else {
        // nodePoint.y = nodeRec.y + 64;
        // }
        //
        // }
        }
        container.getNode().setLocation(nodePoint);
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) JobletUtil(org.talend.designer.core.ui.editor.jobletcontainer.JobletUtil)

Example 2 with JobletUtil

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

the class AbstractMultiPageTalendEditor method dispose.

/**
     * The <code>MultiPageEditorPart</code> implementation of this <code>IWorkbenchPart</code> method disposes all
     * nested editors. Subclasses may extend.
     */
@Override
public void dispose() {
    getSite().setSelectionProvider(null);
    getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
    /* after the release of eclipse3.6,this parameter can't be null */
    // setInput(null);
    ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
    getSite().getWorkbenchWindow().getPartService().removePartListener(partListener);
    if (this.lockService != null) {
        this.lockService.unregister();
    }
    super.dispose();
    if (getProcess() != null && !getProcess().isReadOnly()) {
        if (isKeepPropertyLocked()) {
            return;
        }
        // Unlock the process :
        IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
        IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
        try {
            getProcess().getProperty().eAdapters().remove(dirtyListener);
            Property property = getProcess().getProperty();
            if (property.eResource() == null || property.getItem().eResource() == null) {
                property = repFactory.getUptodateProperty(property);
            }
            // fix for bug 12524 for db repository
            // property = repFactory.reload(property);
            JobletUtil jUtil = new JobletUtil();
            jUtil.makeSureUnlockJoblet(getProcess());
            Item item = getProcess().getProperty().getItem();
            boolean keep = jUtil.keepLockJoblet(item);
            if (keep) {
                repFactory.unlock(property.getItem());
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        } catch (LoginException e) {
            ExceptionHandler.process(e);
        }
    }
    if (processEditorInput != null) {
        processEditorInput.dispose();
        processEditorInput = null;
    }
    designerEditor = null;
    codeEditor = null;
    if (processor instanceof IJavaBreakpointListener) {
        JDIDebugModel.removeJavaBreakpointListener((IJavaBreakpointListener) processor);
    }
    processor = null;
    dirtyListener = null;
    NodeTransferDragSourceListener.getInstance().setEditPart(null);
}
Also used : JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IJavaBreakpointListener(org.eclipse.jdt.debug.core.IJavaBreakpointListener) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IRepositoryService(org.talend.repository.model.IRepositoryService) JobletUtil(org.talend.designer.core.ui.editor.jobletcontainer.JobletUtil)

Aggregations

JobletUtil (org.talend.designer.core.ui.editor.jobletcontainer.JobletUtil)2 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 IJavaBreakpointListener (org.eclipse.jdt.debug.core.IJavaBreakpointListener)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 INode (org.talend.core.model.process.INode)1 Item (org.talend.core.model.properties.Item)1 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 Property (org.talend.core.model.properties.Property)1 IDynamicProperty (org.talend.core.ui.properties.tab.IDynamicProperty)1 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1 IRepositoryService (org.talend.repository.model.IRepositoryService)1