use of org.talend.commons.ui.swt.drawing.link.IStyleLink in project tdi-studio-se by Talend.
the class StyleLinkFactory method getUnselectedSameZoneStyle.
/**
* DOC amaumont Comment method "getNotSelectedSameZoneStyle".
*
* @return
*/
private IStyleLink getUnselectedSameZoneStyle() {
StyleLink style = new StyleLink();
setCommonsStyleProperties(style);
style.setDrawableLink(getSameZoneLink(style));
ExtremityEastArrow eastArrowTarget = new ExtremityEastArrow(style);
eastArrowTarget.setXOffset(-eastArrowTarget.getSize().x);
style.setExtremity2(eastArrowTarget);
style.setForegroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_UNSELECTED_LOOKUP_LINKS));
return style;
}
use of org.talend.commons.ui.swt.drawing.link.IStyleLink 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();
}
}
use of org.talend.commons.ui.swt.drawing.link.IStyleLink 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();
}
use of org.talend.commons.ui.swt.drawing.link.IStyleLink in project tdi-studio-se by Talend.
the class StyleLinkFactory method getStyleLink.
// public static DrawableLinkFactory getInstance() {
// if (instance == null) {
// instance = new DrawableLinkFactory();
// }
// return instance;
// }
//
// public IDrawableLink getDrawableLink(IMapperLink link) {
// IDrawableLink drawableLink = null;
// PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptorSource();
// PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptorTarget();
// if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
// drawableLink = new HorizontalBezierLink();
// } else if (pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
// drawableLink = new VerticalRoundedCornerLink();
// }
// return drawableLink;
// }
//
public IStyleLink getStyleLink(IMapperLink link) {
ILinkState linkState = link.getState();
PointLinkDescriptor pointLinkDescriptorSource = link.getPointLinkDescriptor1();
PointLinkDescriptor pointLinkDescriptorTarget = link.getPointLinkDescriptor2();
ITableEntry targetTableEntry = pointLinkDescriptorTarget.getTableEntry();
boolean targetIsConstraint = false;
if (targetTableEntry instanceof FilterTableEntry || targetTableEntry instanceof ExpressionFilterEntry) {
targetIsConstraint = true;
}
boolean targetIsGlobalMap = false;
if (targetTableEntry instanceof GlobalMapEntry) {
targetIsGlobalMap = true;
}
IStyleLink style = null;
if (pointLinkDescriptorSource.getZone() != pointLinkDescriptorTarget.getZone()) {
if (linkState == LinkState.SELECTED) {
if (targetIsConstraint) {
style = selectedZoneToZoneFilterStyle;
} else {
style = selectedZoneToZoneStyle;
}
} else if (linkState == LinkState.UNSELECTED) {
if (targetIsConstraint) {
style = unselectedZoneToZoneFilterStyle;
} else {
style = unselectedZoneToZoneStyle;
}
}
} else if (pointLinkDescriptorSource.getZone() == Zone.INPUTS && pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
if (linkState == LinkState.SELECTED) {
if (pointLinkDescriptorTarget.getTableEntry() instanceof ExpressionFilterEntry) {
style = selectedSameZoneFilterStyle;
} else if (pointLinkDescriptorTarget.getTableEntry() instanceof GlobalMapEntry) {
style = selectedSameZoneGlobalMapStyle;
} else {
style = selectedSameInputZoneStyle;
}
} else if (linkState == LinkState.UNSELECTED) {
if (pointLinkDescriptorTarget.getTableEntry() instanceof ExpressionFilterEntry) {
style = unselectedSameZoneFilterStyle;
} else if (pointLinkDescriptorTarget.getTableEntry() instanceof GlobalMapEntry) {
style = unselectedSameZoneGlobalMapStyle;
} else {
style = unselectedSameInputZoneStyle;
}
}
} else if (pointLinkDescriptorSource.getZone() == Zone.VARS && pointLinkDescriptorSource.getZone() == pointLinkDescriptorTarget.getZone()) {
if (linkState == LinkState.SELECTED) {
style = selectedSameVarsZoneStyle;
} else if (linkState == LinkState.UNSELECTED) {
style = unselectedSameVarsZoneStyle;
}
}
return style;
}
use of org.talend.commons.ui.swt.drawing.link.IStyleLink in project tdi-studio-se by Talend.
the class StyleLinkFactory method getSelectedSameVarsZoneStyle.
/**
* DOC amaumont Comment method "getSelectedSameZoneStyle".
*
* @param foregroundColor
* @return
*/
public IStyleLink getSelectedSameVarsZoneStyle() {
StyleLink style = new StyleLink();
setCommonsStyleProperties(style);
IDrawableLink sameZoneLink = getSameZoneLink(style);
style.setDrawableLink(sameZoneLink);
ExtremityWestArrow westArrow = new ExtremityWestArrow(style);
style.setExtremity1(westArrow);
ExtremityEastArrow eastArrowTarget = new ExtremityEastArrow(style);
eastArrowTarget.setXOffset(-eastArrowTarget.getSize().x);
style.setExtremity2(eastArrowTarget);
style.setForegroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_SELECTED_LOOKUP_LINKS));
return style;
}
Aggregations