Search in sources :

Example 6 with LinkDescriptor

use of org.talend.commons.ui.swt.drawing.link.LinkDescriptor in project tdi-studio-se by Talend.

the class WebServiceTableLiner method addLinks.

public void addLinks(TableItem itemSource, Object data1, Table tableTarget, Object data2, String mark) {
    LinkDescriptor<TableItem, Object, Table, Object> link = new LinkDescriptor<TableItem, Object, Table, Object>(new TableExtremityDescriptor(itemSource, data1), new ExtremityLink<Table, Object>(tableTarget, data2));
    link.setStyleLink(createStandardLink(new Color(getBgDrawableComposite().getDisplay(), 255, 102, 102)));
    getLinksManager().addLink(link);
    if (mark.equals("INPUTMAPPING")) {
        sourceInList.add(((IMetadataColumn) itemSource.getData()).getLabel());
    } else if (mark.equals("OUTPUTMAPPING")) {
        if (((OutPutMappingData) itemSource.getData()).getParameterName() != null) {
            String sourseName = ((OutPutMappingData) itemSource.getData()).getParameterName();
            // int m = sourseName.lastIndexOf(".");
            // sourseName = sourseName.substring(m + 1);
            sourceOutList.add(sourseName);
        } else {
            sourceOutList.add(((OutPutMappingData) itemSource.getData()).getParameter().getName());
        }
    }
}
Also used : TableExtremityDescriptor(org.talend.commons.ui.swt.drawing.link.TableExtremityDescriptor) Table(org.eclipse.swt.widgets.Table) OutPutMappingData(org.talend.designer.webservice.data.OutPutMappingData) TableItem(org.eclipse.swt.widgets.TableItem) Color(org.eclipse.swt.graphics.Color) LinkDescriptor(org.talend.commons.ui.swt.drawing.link.LinkDescriptor)

Example 7 with LinkDescriptor

use of org.talend.commons.ui.swt.drawing.link.LinkDescriptor in project tdi-studio-se by Talend.

the class Schema2XMLLinker method addLink.

/**
     * amaumont Comment method "addLink".
     * 
     * @param tableItem
     * @param dataItem1
     * @param tree
     * @param dataItem2
     */
private LinkDescriptor<Item, Object, Tree, Object> addLink(Item tableItem, Object dataItem1, Tree tree, Object dataItem2) {
    LinkDescriptor<Item, Object, Tree, Object> link = new LinkDescriptor<Item, Object, Tree, Object>(new ItemExtremityDescriptor(tableItem, dataItem1), new ExtremityLink<Tree, Object>(tree, dataItem2));
    link.setStyleLink(getUnselectedStyleLink());
    getLinksManager().addLink(link);
    updateLinksStyleAndControlsSelection(tree);
    return link;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) TreeItem(org.eclipse.swt.widgets.TreeItem) Item(org.eclipse.swt.widgets.Item) ItemExtremityDescriptor(org.talend.commons.ui.swt.drawing.link.ItemExtremityDescriptor) Tree(org.eclipse.swt.widgets.Tree) LinkDescriptor(org.talend.commons.ui.swt.drawing.link.LinkDescriptor)

Example 8 with LinkDescriptor

use of org.talend.commons.ui.swt.drawing.link.LinkDescriptor in project tdi-studio-se by Talend.

the class HL7Tree2SchemaLinker method addLinks.

public void addLinks(TreeItem itemSource, Object data1, Table tableTarget, Object data2) {
    LinkDescriptor<TreeItem, Object, Table, Object> link = new LinkDescriptor<TreeItem, Object, Table, Object>(new TreeExtremityDescriptor(itemSource, data1), new ExtremityLink<Table, Object>(tableTarget, data2));
    link.setStyleLink(createStandardLink(new Color(getBgDrawableComposite().getDisplay(), 255, 102, 102)));
    getLinksManager().addLink(link);
}
Also used : Table(org.eclipse.swt.widgets.Table) TreeItem(org.eclipse.swt.widgets.TreeItem) Color(org.eclipse.swt.graphics.Color) TreeExtremityDescriptor(org.talend.commons.ui.swt.drawing.link.TreeExtremityDescriptor) LinkDescriptor(org.talend.commons.ui.swt.drawing.link.LinkDescriptor)

Example 9 with LinkDescriptor

use of org.talend.commons.ui.swt.drawing.link.LinkDescriptor in project tdi-studio-se by Talend.

the class SchemaXMLLinker method updateLinksStyleAndControlsSelection.

@SuppressWarnings("unchecked")
public void updateLinksStyleAndControlsSelection(Control currentControl, boolean lastOne) {
    // super.updateLinksStyleAndControlsSelection(currentControl);
    boolean isTarget = false;
    if (getSource() != currentControl) {
        isTarget = true;
    } else {
        isTarget = false;
    }
    HashSet selectedItems = new HashSet();
    Map itemsToSelect = new HashMap();
    if (isTarget) {
        getTarget().deselectAll();
        TreeItem[] selection = getTarget().getSelection();
        for (TreeItem tableItem : selection) {
            selectedItems.add(tableItem.getData());
        }
    } else {
        TableItem[] selection = getSource().getSelection();
        for (TableItem treeItem : selection) {
            selectedItems.add(treeItem.getData());
        }
    }
    List<LinkDescriptor<Item, Object, Tree, Object>> links = linksManager.getLinks();
    for (LinkDescriptor<Item, Object, Tree, Object> link : links) {
        IStyleLink styleLink = null;
        IExtremityLink extremity = null;
        IExtremityLink otherExtremity = null;
        if (isTarget) {
            extremity = link.getExtremity2();
            otherExtremity = link.getExtremity1();
        } else {
            extremity = link.getExtremity1();
            otherExtremity = link.getExtremity2();
        }
        boolean currentItemIsSelected = selectedItems.contains(extremity.getDataItem());
        if (extremity.getGraphicalObject() == xmlViewer.getTree() || otherExtremity.getGraphicalObject() == xmlViewer.getTree()) {
            styleLink = getSelectedLoopStyleLink();
        } else {
            if (currentItemIsSelected) {
                styleLink = getSelectedStyleLink();
                if (isTarget) {
                    itemsToSelect.put(otherExtremity.getGraphicalObject(), null);
                } else {
                    Table currentTable = (Table) otherExtremity.getGraphicalObject();
                    List<TableItem> tableItemsToSelect = (List<TableItem>) itemsToSelect.get(currentTable);
                    if (tableItemsToSelect == null) {
                        tableItemsToSelect = new ArrayList<TableItem>();
                        itemsToSelect.put(currentTable, tableItemsToSelect);
                    }
                    TableItem tableItem = TableUtils.getTableItem(currentTable, otherExtremity.getDataItem());
                    tableItemsToSelect.add(tableItem);
                }
            } else {
                styleLink = getUnselectedStyleLink();
            }
        }
        if (styleLink == null) {
            styleLink = getDefaultStyleLink();
        }
        link.setStyleLink(styleLink);
    }
    if (isTarget) {
        (getSource()).setSelection((TableItem[]) itemsToSelect.keySet().toArray(new TableItem[0]));
    } else {
        Set<Table> set = itemsToSelect.keySet();
        if (set.size() > 0) {
            for (Table table : set) {
                ArrayList<TableItem> tableItemsToSelect = (ArrayList<TableItem>) itemsToSelect.get(table);
                table.deselectAll();
                TableItem[] tableItems = tableItemsToSelect.toArray(new TableItem[0]);
                table.setSelection(tableItems);
            }
        } else {
            xmlViewer.getTree().deselectAll();
        }
    }
    getLinksManager().sortLinks(getDrawingLinksComparator());
    // for bug 9279
    if (lastOne) {
        getBackgroundRefresher().refreshBackground();
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) HashMap(java.util.HashMap) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) TableItem(org.eclipse.swt.widgets.TableItem) TreeItem(org.eclipse.swt.widgets.TreeItem) Item(org.eclipse.swt.widgets.Item) IExtremityLink(org.talend.commons.ui.swt.drawing.link.IExtremityLink) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink) Tree(org.eclipse.swt.widgets.Tree) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) LinkDescriptor(org.talend.commons.ui.swt.drawing.link.LinkDescriptor) HashSet(java.util.HashSet)

Example 10 with LinkDescriptor

use of org.talend.commons.ui.swt.drawing.link.LinkDescriptor in project tdi-studio-se by Talend.

the class JSONFileSchema2TreeLinker method updateLinksStyleAndControlsSelection.

public void updateLinksStyleAndControlsSelection(Control currentControl, boolean lastOne) {
    // super.updateLinksStyleAndControlsSelection(currentControl);
    boolean isTarget = false;
    if (getSource() != currentControl) {
        isTarget = true;
    } else {
        isTarget = false;
    }
    HashSet selectedItems = new HashSet();
    Map itemsToSelect = new HashMap();
    if (isTarget) {
        getTarget().deselectAll();
        TreeItem[] selection = getTarget().getSelection();
        for (int i = 0; i < selection.length; i++) {
            TreeItem tableItem = selection[i];
            selectedItems.add(tableItem.getData());
        }
    } else {
        TableItem[] selection = getSource().getSelection();
        for (int i = 0; i < selection.length; i++) {
            TableItem treeItem = selection[i];
            selectedItems.add(treeItem.getData());
        }
    }
    List<LinkDescriptor<Item, Object, Tree, Object>> links = linksManager.getLinks();
    for (LinkDescriptor<Item, Object, Tree, Object> link : links) {
        IStyleLink styleLink = null;
        IExtremityLink extremity = null;
        IExtremityLink otherExtremity = null;
        if (isTarget) {
            extremity = link.getExtremity2();
            otherExtremity = link.getExtremity1();
        } else {
            extremity = link.getExtremity1();
            otherExtremity = link.getExtremity2();
        }
        boolean currentItemIsSelected = selectedItems.contains(extremity.getDataItem());
        if (extremity.getGraphicalObject() == jsonViewer.getTree() || otherExtremity.getGraphicalObject() == jsonViewer.getTree()) {
            styleLink = getSelectedLoopStyleLink();
        } else {
            if (currentItemIsSelected) {
                styleLink = getSelectedStyleLink();
                if (isTarget) {
                    itemsToSelect.put((TableItem) otherExtremity.getGraphicalObject(), null);
                } else {
                    Table currentTable = (Table) otherExtremity.getGraphicalObject();
                    List<TableItem> tableItemsToSelect = (List<TableItem>) itemsToSelect.get(currentTable);
                    if (tableItemsToSelect == null) {
                        tableItemsToSelect = new ArrayList<TableItem>();
                        itemsToSelect.put(currentTable, tableItemsToSelect);
                    }
                    TableItem tableItem = TableUtils.getTableItem(currentTable, otherExtremity.getDataItem());
                    tableItemsToSelect.add(tableItem);
                }
            } else {
                styleLink = getUnselectedStyleLink();
            }
        }
        if (styleLink == null) {
            styleLink = getDefaultStyleLink();
        }
        link.setStyleLink(styleLink);
    }
    if (isTarget) {
        (getSource()).setSelection((TableItem[]) itemsToSelect.keySet().toArray(new TableItem[0]));
    } else {
        Set<Table> set = itemsToSelect.keySet();
        if (set.size() > 0) {
            for (Table table : set) {
                ArrayList<TableItem> tableItemsToSelect = (ArrayList<TableItem>) itemsToSelect.get(table);
                table.deselectAll();
                TableItem[] tableItems = (TableItem[]) tableItemsToSelect.toArray(new TableItem[0]);
                table.setSelection(tableItems);
            }
        } else {
            jsonViewer.getTree().deselectAll();
        }
    }
    getLinksManager().sortLinks(getDrawingLinksComparator());
    // for bug 9279
    if (lastOne) {
        getBackgroundRefresher().refreshBackground();
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) HashMap(java.util.HashMap) TreeItem(org.eclipse.swt.widgets.TreeItem) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) TableItem(org.eclipse.swt.widgets.TableItem) TreeItem(org.eclipse.swt.widgets.TreeItem) Item(org.eclipse.swt.widgets.Item) IExtremityLink(org.talend.commons.ui.swt.drawing.link.IExtremityLink) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink) Tree(org.eclipse.swt.widgets.Tree) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) LinkDescriptor(org.talend.commons.ui.swt.drawing.link.LinkDescriptor) HashSet(java.util.HashSet)

Aggregations

LinkDescriptor (org.talend.commons.ui.swt.drawing.link.LinkDescriptor)14 TableItem (org.eclipse.swt.widgets.TableItem)12 TreeItem (org.eclipse.swt.widgets.TreeItem)11 Table (org.eclipse.swt.widgets.Table)10 Tree (org.eclipse.swt.widgets.Tree)9 Item (org.eclipse.swt.widgets.Item)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 IExtremityLink (org.talend.commons.ui.swt.drawing.link.IExtremityLink)6 IStyleLink (org.talend.commons.ui.swt.drawing.link.IStyleLink)6 List (java.util.List)5 Color (org.eclipse.swt.graphics.Color)3 ItemExtremityDescriptor (org.talend.commons.ui.swt.drawing.link.ItemExtremityDescriptor)3 Point (org.eclipse.swt.graphics.Point)2 TreeExtremityDescriptor (org.talend.commons.ui.swt.drawing.link.TreeExtremityDescriptor)2 Rectangle (org.eclipse.swt.graphics.Rectangle)1 IDrawableLink (org.talend.commons.ui.swt.drawing.link.IDrawableLink)1 TableExtremityDescriptor (org.talend.commons.ui.swt.drawing.link.TableExtremityDescriptor)1