Search in sources :

Example 1 with DBindingEdge

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge in project InformationSystem by ObeoNetwork.

the class BindingTreeEditor method createPartControl.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createPartControl(Composite parent) {
    setUpUndoRedoActionHandler();
    sashForm = new SashForm(parent, SWT.VERTICAL);
    sashForm.setSashWidth(3);
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    editorManager = new BindingTreeEditorManager(getEditingDomain(), accessor);
    BindingTreeSemanticSupport treeSemanticSupport = new BindingTreeSemanticSupport(getBindingInfo(), editorManager);
    treeMapper = new BindingTreeMapper(sashForm, treeSemanticSupport);
    getSite().setSelectionProvider(treeMapper);
    treeMapper.getLeftTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection() instanceof StructuredSelection) {
                StructuredSelection strSelection = (StructuredSelection) event.getSelection();
                @SuppressWarnings("unchecked") Collection<DBoundElement> selectedElements = (Collection<DBoundElement>) strSelection.toList();
                populateLTRMappingDetails(selectedElements);
            }
        }
    });
    treeMapper.getRightTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection() instanceof StructuredSelection) {
                StructuredSelection strSelection = (StructuredSelection) event.getSelection();
                @SuppressWarnings("unchecked") Collection<DBoundElement> selectedElements = (Collection<DBoundElement>) strSelection.toList();
                populateRTLMappingDetails(selectedElements);
            }
        }
    });
    TreeDataProvider treeDataProvider = new TreeDataProvider(getBindingInfo());
    DBoundElement left = treeDataProvider.getLeftRoot();
    DBoundElement right = treeDataProvider.getRightRoot();
    List<DBindingEdge> edges = treeDataProvider.getEdges();
    treeMapper.setInput(new TreeRoot(left), new TreeRoot(right), edges);
    createBindingGroupDetails(sashForm);
    grpDetailsLTR.setText(getBindingDetailsLabel(left, right));
    grpDetailsRTL.setText(getBindingDetailsLabel(right, left));
    sashForm.setWeights(new int[] { 70, 30 });
    // Expand the first levels on the two trees
    treeMapper.getLeftTreeViewer().expandToLevel(2);
    treeMapper.getRightTreeViewer().expandToLevel(2);
    revealBoundElements(edges);
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) BindingTreeMapper(org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.BindingTreeMapper) DBindingEdge(org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge) DBoundElement(org.obeonetwork.dsl.environment.bindingdialect.DBoundElement) SashForm(org.eclipse.swt.custom.SashForm) TreeDataProvider(org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.provider.TreeDataProvider) GridData(org.eclipse.swt.layout.GridData) TreeRoot(org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.TreeRoot) Collection(java.util.Collection) BindingTreeSemanticSupport(org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.BindingTreeSemanticSupport)

Example 2 with DBindingEdge

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge in project InformationSystem by ObeoNetwork.

the class BindingTreeEditor method revealBoundElements.

private void revealBoundElements(List<DBindingEdge> edges) {
    for (DBindingEdge dBindingEdge : edges) {
        treeMapper.getLeftTreeViewer().reveal(dBindingEdge.getLeft());
        treeMapper.getRightTreeViewer().reveal(dBindingEdge.getRight());
    }
}
Also used : DBindingEdge(org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge)

Example 3 with DBindingEdge

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge in project InformationSystem by ObeoNetwork.

the class BindingTreeEditor method doRefresh.

public void doRefresh() {
    TreeDataProvider treeDataProvider = new TreeDataProvider(getBindingInfo());
    DBoundElement left = treeDataProvider.getLeftRoot();
    DBoundElement right = treeDataProvider.getRightRoot();
    List<DBindingEdge> edges = treeDataProvider.getEdges();
    treeMapper.setInput(new TreeRoot(left), new TreeRoot(right), edges);
    treeMapper.refresh();
    treeMapper.getLeftTreeViewer().expandToLevel(2);
    treeMapper.getRightTreeViewer().expandToLevel(2);
}
Also used : TreeDataProvider(org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.provider.TreeDataProvider) TreeRoot(org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.TreeRoot) DBindingEdge(org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge) DBoundElement(org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)

Example 4 with DBindingEdge

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge in project InformationSystem by ObeoNetwork.

the class BindingTreeMapper method selectEdges.

private void selectEdges(List<DBindingEdge> edges) {
    if (edgesLeftSelectionComputed == false) {
        leftSelectedElements.clear();
        for (DBindingEdge bindingEdge : edges) {
            leftSelectedElements.add(bindingEdge.getLeft());
        }
        leftSelectionComputed = true;
        getLeftTreeViewer().setSelection(new StructuredSelection(new ArrayList<DBoundElement>(leftSelectedElements)));
    } else {
        edgesLeftSelectionComputed = false;
    }
    if (edgesRightSelectionComputed == false) {
        rightSelectedElements.clear();
        for (DBindingEdge bindingEdge : edges) {
            rightSelectedElements.add(bindingEdge.getRight());
        }
        rightSelectionComputed = true;
        getRightTreeViewer().setSelection(new StructuredSelection(new ArrayList<DBoundElement>(rightSelectedElements)));
    } else {
        edgesRightSelectionComputed = false;
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) DBindingEdge(org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge)

Example 5 with DBindingEdge

use of org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge in project InformationSystem by ObeoNetwork.

the class TreeDataProvider method computeData.

public void computeData() {
    edges = new ArrayList<DBindingEdge>();
    leftRoot = BindingdialectFactory.eINSTANCE.createDBoundElement();
    leftRoot.setTarget(bindingInfo.getLeft());
    rightRoot = BindingdialectFactory.eINSTANCE.createDBoundElement();
    rightRoot.setTarget(bindingInfo.getRight());
    for (BindingReference bindingReference : bindingInfo.getReferences()) {
        BindingElement leftBindingElement = bindingReference.getLeft();
        BindingElement rightBindingElement = bindingReference.getRight();
        List<BoundableElement> leftPathReferences = new ArrayList<BoundableElement>(leftBindingElement.getPathReferences());
        leftPathReferences.add(leftBindingElement.getBoundElement());
        DBoundElement leftBoundElement = getBoundElement(leftRoot, leftPathReferences);
        List<BoundableElement> rightPathReferences = new ArrayList<BoundableElement>(rightBindingElement.getPathReferences());
        rightPathReferences.add(rightBindingElement.getBoundElement());
        DBoundElement rightBoundElement = getBoundElement(rightRoot, rightPathReferences);
        DBindingEdge edge = BindingdialectFactory.eINSTANCE.createDBindingEdge();
        edge.setTarget(bindingReference);
        edge.setLeft(leftBoundElement);
        edge.setRight(rightBoundElement);
        edges.add(edge);
    }
}
Also used : BindingElement(org.obeonetwork.dsl.environment.BindingElement) BindingReference(org.obeonetwork.dsl.environment.BindingReference) BoundableElement(org.obeonetwork.dsl.environment.BoundableElement) ArrayList(java.util.ArrayList) DBindingEdge(org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge) DBoundElement(org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)

Aggregations

DBindingEdge (org.obeonetwork.dsl.environment.bindingdialect.DBindingEdge)5 DBoundElement (org.obeonetwork.dsl.environment.bindingdialect.DBoundElement)3 ArrayList (java.util.ArrayList)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 TreeRoot (org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.TreeRoot)2 TreeDataProvider (org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.provider.TreeDataProvider)2 Collection (java.util.Collection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 SashForm (org.eclipse.swt.custom.SashForm)1 GridData (org.eclipse.swt.layout.GridData)1 BindingElement (org.obeonetwork.dsl.environment.BindingElement)1 BindingReference (org.obeonetwork.dsl.environment.BindingReference)1 BoundableElement (org.obeonetwork.dsl.environment.BoundableElement)1 BindingTreeMapper (org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.BindingTreeMapper)1 BindingTreeSemanticSupport (org.obeonetwork.dsl.environment.binding.dialect.ui.treemapper.BindingTreeSemanticSupport)1