use of org.eclipse.swt.widgets.TableItem 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());
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class DropContextAnalyzer method dropVarsEntryIsValid.
private boolean dropVarsEntryIsValid(TableItem tableItemTarget) {
Table table = tableItemTarget.getParent();
TableItem[] tableItems = table.getItems();
for (TableItem tableItem : tableItems) {
if (tableItemTarget == tableItem) {
break;
}
if (tableItemSource == tableItem) {
return true;
}
}
return false;
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkDropIsValid.
/**
* DOC amaumont Comment method "checkDropHasValidTarget".
*/
private boolean checkDropIsValid() {
isInputToInput = false;
mapOneToOneAuthorized = true;
if (targetIsExpressionFilterText() || (targetTableIsFiltersTable() || targetTableIsGlobalMapTable() || draggedData.getTransferableEntryList().size() <= 1)) {
mapOneToOneAuthorized = false;
}
if (invalidKeyPressed) {
return false;
}
/*
* INPUT => INPUT
*/
if (zoneSource == Zone.INPUTS && zoneTarget == Zone.INPUTS) {
isInputToInput = true;
mapOneToOneAuthorized = false;
List<InputTable> inputTables = mapperManager.getInputTables();
int indexTableSource = inputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTableTarget = inputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (currentTableTarget != null) {
if (indexTableSource >= indexTableTarget) {
/*
* INPUT => INPUT && index of table source >= index of table target
*/
return false;
} else {
return true;
}
} else if (currentStyledTextTarget != null) {
if (indexTableSource > indexTableTarget) {
/*
* INPUT => INPUT && index of table source > index of table target
*/
return false;
} else {
return true;
}
} else {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("DropContextAnalyzer.notFound"));
}
}
/*
* OUTPUT => OUTPUT
*/
if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
isOutputToOutput = true;
mapOneToOneAuthorized = true;
List<OutputTable> outputTables = mapperManager.getOutputTables();
int indexSourceOutputTable = outputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTargetOutputTable = outputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (indexSourceOutputTable == indexTargetOutputTable) {
/*
* INPUT => INPUT && index of table source >= index of table target
*/
return false;
} else {
// OUTPUT => OUTPUT
return checkZoonTarget();
}
}
if (currentTableTarget != null) {
TableItem tableItemTarget = getTableItemFromPosition(new Point(event.x, event.y));
if (zoneSource == Zone.VARS && zoneTarget == Zone.VARS && tableItemTarget != null) {
if (tableItemSource == tableItemTarget || !dropVarsEntryIsValid(tableItemTarget)) {
/*
* VAR => VAR && (item source == item target || item target is invalid)
*/
return false;
}
}
}
if (zoneSource == Zone.VARS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
/*
* VAR => INPUT OUTPUT => OUTPUT OUTPUT => INPUT OUTPUT => VAR
*/
return false;
}
return checkZoonTarget();
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkZoonTarget.
private boolean checkZoonTarget() {
IDataMapTable dataMapTable = dataMapTableViewTarget.getDataMapTable();
if (zoneTarget == Zone.OUTPUTS) {
OutputTable outputTable = (OutputTable) dataMapTable;
if (outputTable.isErrorRejectTable()) {
if (currentTableTarget != null && event != null) {
if (event.item instanceof TableItem) {
Object data = event.item.getData();
if (data instanceof OutputColumnTableEntry) {
String label = ((OutputColumnTableEntry) data).getName();
if (mapperManager.ERROR_REJECT_MESSAGE.equals(label) || mapperManager.ERROR_REJECT_STACK_TRACE.equals(label)) {
return false;
}
}
}
}
}
boolean useRepositoryMeta = (outputTable.isRepository()) || (outputTable.getId() != null && !"".equals(outputTable.getId()));
// for join table if main table use repository metadata
if (!useRepositoryMeta && outputTable.getIsJoinTableOf() != null && !"".equals(outputTable.getIsJoinTableOf())) {
OutputTable mainTable = mapperManager.getOutputTableByName(outputTable.getIsJoinTableOf());
if (mainTable != null) {
useRepositoryMeta = mainTable.getId() != null && !"".equals(mainTable.getId());
}
}
if (useRepositoryMeta && currentStyledTextTarget != null) {
return true;
}
if (useRepositoryMeta && isCursorOverHeader || useRepositoryMeta && !isCursorOverExpressionCell) {
return false;
}
}
return true;
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class JSONToXPathLinker method createFieldsLinkWithProgressMonitor.
/**
* DOC amaumont Comment method "createFieldsLinkWithProgressDialog".
*
* @param monitorWrap
* @param fieldsTableItems
* @param totalWork
* @param schemaTargetList
*/
private void createFieldsLinkWithProgressMonitor(IProgressMonitor monitorWrap, int totalWork, List<SchemaTarget> schemaTargetList, int startTableItem, int tableItemLength) {
monitorWrap.beginTask("Fields links creation ...", totalWork);
TableItem[] fieldsTableItems = fieldsTableEditorView.getTable().getItems();
for (int i = startTableItem, indexShemaTarget = 0; i < startTableItem + tableItemLength; i++, indexShemaTarget++) {
if (monitorWrap.isCanceled()) {
for (int j = startTableItem + tableItemLength - 2; j >= 0; j--) {
// fieldsTableEditorView.getTable().remove(j);
fieldsTableEditorView.getTable().redraw();
JSONExtractorFieldModel schemaModel = this.fieldsTableEditorView.getModel();
schemaModel.remove(j);
}
return;
}
TableItem tableItem = fieldsTableItems[i];
SchemaTarget schemaTarget = schemaTargetList.get(indexShemaTarget);
String relativeXpathQuery = schemaTarget.getRelativeXPathQuery();
createFieldLinks(relativeXpathQuery, tableItem, monitorWrap, schemaTarget);
monitorWrap.worked(1);
}
getLinksManager().sortLinks(getDrawingLinksComparator());
getBackgroundRefresher().refreshBackground();
}
Aggregations