Search in sources :

Example 1 with IExtremityLink

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

the class Schema2XMLLinker method updateLinksStyleAndControlsSelection.

@SuppressWarnings("unchecked")
public void updateLinksStyleAndControlsSelection(Control currentControl) {
    // 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());
}
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 2 with IExtremityLink

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

the class JSONToXPathLinker method updateLinksStyleAndControlsSelection.

@Override
@SuppressWarnings("unchecked")
public void updateLinksStyleAndControlsSelection(Control currentControl, Boolean flag) {
    boolean selectedControlIsTable = false;
    if (currentControl instanceof Table) {
        selectedControlIsTable = true;
    } else if (currentControl instanceof Tree) {
        selectedControlIsTable = false;
    } else {
        throw new IllegalArgumentException("This type of currentControl is unsupported");
    }
    HashSet selectedItems = new HashSet();
    Map itemsToSelect = new HashMap();
    if (selectedControlIsTable) {
        for (Table table : getTables()) {
            if (table != currentControl) {
                table.deselectAll();
                if (isFieldsTable(table)) {
                    fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
                }
            }
        }
        TableItem[] selection = ((Table) currentControl).getSelection();
        for (TableItem tableItem : selection) {
            selectedItems.add(tableItem.getData());
        }
    } else {
        TreeItem[] selection = getTree().getSelection();
        for (TreeItem treeItem : selection) {
            selectedItems.add(treeItem.getData());
        }
    }
    List<LinkDescriptor<TreeItem, Object, Table, Object>> links = linksManager.getLinks();
    for (LinkDescriptor<TreeItem, Object, Table, Object> link : links) {
        IStyleLink styleLink = null;
        IExtremityLink extremity = null;
        IExtremityLink otherExtremity = null;
        if (selectedControlIsTable) {
            extremity = link.getExtremity2();
            otherExtremity = link.getExtremity1();
        } else {
            extremity = link.getExtremity1();
            otherExtremity = link.getExtremity2();
        }
        boolean currentItemIsSelected = selectedItems.contains(extremity.getDataItem());
        if (extremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable() || otherExtremity.getGraphicalObject() == loopTableEditorView.getTableViewerCreator().getTable()) {
            styleLink = getSelectedLoopStyleLink();
        } else {
            if (currentItemIsSelected) {
                styleLink = getSelectedStyleLink();
                if (selectedControlIsTable) {
                    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 (selectedControlIsTable) {
        TreeItem[] treeItems = (TreeItem[]) itemsToSelect.keySet().toArray(new TreeItem[0]);
        if (treeItems.length > 0) {
            if (!treeItems[0].isDisposed()) {
                (getTree()).setSelection(treeItems);
            }
        }
    } 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 {
            loopTableEditorView.getTable().deselectAll();
            fieldsTableEditorView.getTable().deselectAll();
        }
        fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
    if (flag) {
        getLinksManager().sortLinks(getDrawingLinksComparator());
        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) IExtremityLink(org.talend.commons.ui.swt.drawing.link.IExtremityLink) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink) Tree(org.eclipse.swt.widgets.Tree) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkDescriptor(org.talend.commons.ui.swt.drawing.link.LinkDescriptor) HashSet(java.util.HashSet)

Example 3 with IExtremityLink

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

the class HL7Tree2SchemaLinker method updateLinksStyleAndControlsSelection.

// private void getSelectedRelativeStyleLink() {
// StyleLink selectedStyleLink = new StyleLink();
// selectedStyleLink.setDrawableLink(new BezierHorizontalLink(selectedStyleLink));
// selectedStyleLink.setForegroundColor(selectedRelativeLinkColor);
// selectedStyleLink.setLineWidth(2);
// int xOffset = WindowSystem.isGTK() ? 2 : -2;
// int yOffset = WindowSystem.isGTK() ? -1 : 0;
// selectedStyleLink.setExtremity2(new ExtremityEastArrow(selectedStyleLink, -ExtremityEastArrow.WIDTH_ARROW +
// xOffset,
// yOffset));
// setSelectedStyleLink(selectedStyleLink);
// }
public void updateLinksStyleAndControlsSelection(Control currentControl, Boolean flag) {
    boolean selectedControlIsTable = false;
    if (currentControl instanceof Table) {
        selectedControlIsTable = true;
    } else if (currentControl instanceof Tree) {
        selectedControlIsTable = false;
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("XmlToXPathLinker.illegalArgumentException"));
    }
    HashSet selectedItems = new HashSet();
    Map itemsToSelect = new HashMap();
    if (selectedControlIsTable) {
        // for (Table table : getTables()) {
        // if (table != currentControl) {
        // table.deselectAll();
        // if (isFieldsTable(table)) {
        // fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
        // }
        // }
        // }
        TableItem[] selection = ((Table) currentControl).getSelection();
        for (int i = 0; i < selection.length; i++) {
            TableItem tableItem = selection[i];
            selectedItems.add(tableItem.getData());
        }
    } else {
        TreeItem[] selection = getTree().getSelection();
        for (int i = 0; i < selection.length; i++) {
            TreeItem treeItem = selection[i];
            selectedItems.add(treeItem.getData());
        }
    }
    List<LinkDescriptor<TreeItem, Object, Table, Object>> links = linksManager.getLinks();
    for (LinkDescriptor<TreeItem, Object, Table, Object> link : links) {
        IStyleLink styleLink = null;
        IExtremityLink extremity = null;
        IExtremityLink otherExtremity = null;
        if (selectedControlIsTable) {
            extremity = link.getExtremity2();
            otherExtremity = link.getExtremity1();
        } else {
            extremity = link.getExtremity1();
            otherExtremity = link.getExtremity2();
        }
        boolean currentItemIsSelected = selectedItems.contains(extremity.getDataItem());
        // }
        if (styleLink == null) {
            styleLink = createStandardLink(new Color(getBgDrawableComposite().getDisplay(), 255, 102, 102));
        }
        link.setStyleLink(styleLink);
    }
    if (selectedControlIsTable) {
        (getTree()).setSelection((TreeItem[]) itemsToSelect.keySet().toArray(new TreeItem[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 {
        // loopTableEditorView.getTable().deselectAll();
        // fieldsTableEditorView.getTable().deselectAll();
        }
    // fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
    getLinksManager().sortLinks(getDrawingLinksComparator());
    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) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList) IExtremityLink(org.talend.commons.ui.swt.drawing.link.IExtremityLink) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink) Tree(org.eclipse.swt.widgets.Tree) HashMap(java.util.HashMap) Map(java.util.Map) LinkDescriptor(org.talend.commons.ui.swt.drawing.link.LinkDescriptor) HashSet(java.util.HashSet)

Example 4 with IExtremityLink

use of org.talend.commons.ui.swt.drawing.link.IExtremityLink 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 5 with IExtremityLink

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

the class WebServiceTableLiner method updateLinksStyleAndControlsSelection.

@Override
public void updateLinksStyleAndControlsSelection(Control currentControl, Boolean flag) {
    boolean isTarget = false;
    if (this.getTargets().contains(currentControl)) {
        isTarget = true;
    } else if (currentControl == this.getSource()) {
        isTarget = false;
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException("This type of currentControl is unsupported");
    }
    HashSet selectedItems = new HashSet();
    Map itemsToSelect = new HashMap();
    if (isTarget) {
        for (Table table : targets) {
            if (table != currentControl) {
                table.deselectAll();
            }
        }
        TableItem[] selection = ((Table) currentControl).getSelection();
        for (int i = 0; i < selection.length; i++) {
            TableItem tableItem = selection[i];
            selectedItems.add(tableItem.getData());
        }
    } else {
        // source.deselectAll();
        TableItem[] selection = source.getSelection();
        for (int i = 0; i < selection.length; i++) {
            TableItem treeItem = selection[i];
            selectedItems.add(treeItem.getData());
        }
    }
    List<LinkDescriptor<TableItem, Object, Table, Object>> links = linksManager.getLinks();
    for (LinkDescriptor<TableItem, Object, Table, 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 (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]);
                if (tableItems[0] != null) {
                    table.setSelection(tableItems);
                }
            }
        } else {
        // loopTableEditorView.getTable().deselectAll();
        // fieldsTableEditorView.getTable().deselectAll();
        }
    // fieldsTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
    getLinksManager().sortLinks(getDrawingLinksComparator());
    getBackgroundRefresher().refreshBackground();
}
Also used : Table(org.eclipse.swt.widgets.Table) HashMap(java.util.HashMap) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) IExtremityLink(org.talend.commons.ui.swt.drawing.link.IExtremityLink) IStyleLink(org.talend.commons.ui.swt.drawing.link.IStyleLink) 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

ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Table (org.eclipse.swt.widgets.Table)6 TableItem (org.eclipse.swt.widgets.TableItem)6 IExtremityLink (org.talend.commons.ui.swt.drawing.link.IExtremityLink)6 IStyleLink (org.talend.commons.ui.swt.drawing.link.IStyleLink)6 LinkDescriptor (org.talend.commons.ui.swt.drawing.link.LinkDescriptor)6 List (java.util.List)5 Tree (org.eclipse.swt.widgets.Tree)5 TreeItem (org.eclipse.swt.widgets.TreeItem)5 Item (org.eclipse.swt.widgets.Item)3 Color (org.eclipse.swt.graphics.Color)1 Point (org.eclipse.swt.graphics.Point)1