use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class UIManager method closeMapper.
/**
* DOC amaumont Comment method "closeMapperDialog".
*
* @param ok
*/
public void closeMapper(int response) {
boolean save = true;
for (DataMapTableView dataMapTableView : getInputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : getVarsTablesView()) {
dataMapTableView.notifyFocusLost();
}
if ((response == SWT.OK || response == SWT.APPLICATION_MODAL) && mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(false)) {
save = MessageDialog.openConfirm(getMapperContainer().getShell(), //$NON-NLS-1$
Messages.getString("UIManager.SaveDespiteErrors.Title"), //$NON-NLS-1$
Messages.getString("UIManager.SaveDespiteErrors.Message"));
}
if (save) {
Composite parent = mapperUI.getMapperUIParent();
prepareClosing(response);
if (parent instanceof Shell) {
if (response == SWT.OK || response == SWT.CANCEL) {
((Shell) parent).close();
} else {
IExternalNode externalNode = mapperManager.getAbstractMapComponent().getExternalNode();
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
INode node = externalNode.getOriginalNode();
if (node != null && node instanceof Node) {
Command cmd = new ExternalNodeChangeCommand((Node) node, externalNode);
CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
cmdStack.execute(cmd);
}
}
}
}
}
}
use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class ProblemsManager method checkLookupExpressionProblem.
public boolean checkLookupExpressionProblem() {
if (mapperManager.isBigDataProcess()) {
List<DataMapTableView> inputsTablesView = mapperManager.getUiManager().getInputsTablesView();
List<DataMapTableView> lookupTables = new ArrayList<DataMapTableView>();
List<IColumnEntry> entityWithoutProblem = new ArrayList<IColumnEntry>();
DataMapTableView firstLookup = null;
for (int i = 0; i < inputsTablesView.size(); i++) {
DataMapTableView inputTableView = inputsTablesView.get(i);
InputTable dataMapTable = (InputTable) inputTableView.getDataMapTable();
boolean mainConnection = dataMapTable.isMainConnection();
if (mainConnection) {
continue;
}
if (firstLookup == null) {
firstLookup = inputTableView;
} else {
lookupTables.add(inputTableView);
}
}
if (firstLookup == null || lookupTables.isEmpty()) {
return false;
}
List<List<IColumnEntry>> otherLookupEntities = new ArrayList<List<IColumnEntry>>();
for (DataMapTableView otherLookup : lookupTables) {
otherLookupEntities.add(new ArrayList<IColumnEntry>(otherLookup.getDataMapTable().getColumnEntries()));
}
List<IColumnEntry> lookupEntity = firstLookup.getDataMapTable().getColumnEntries();
for (IColumnEntry firstLookupEntity : lookupEntity) {
String expression = firstLookupEntity.getExpression();
if (expression == null || expression.trim().equals("")) {
continue;
}
//$NON-NLS-1$//$NON-NLS-2$
expression = expression.replaceAll("\\s*", "").trim();
Map<List<IColumnEntry>, IColumnEntry> entitiesFound = new HashMap<List<IColumnEntry>, IColumnEntry>();
for (List<IColumnEntry> tableEntities : otherLookupEntities) {
for (IColumnEntry entityInOtherLookup : tableEntities) {
String expressionInOtherLookup = entityInOtherLookup.getExpression();
if (expressionInOtherLookup == null || expressionInOtherLookup.trim().equals("")) {
continue;
}
//$NON-NLS-1$//$NON-NLS-2$
expressionInOtherLookup = expressionInOtherLookup.replaceAll("\\s*", "").trim();
// only match the first one
if (expression.equals(expressionInOtherLookup)) {
entitiesFound.put(tableEntities, entityInOtherLookup);
break;
}
}
}
if (entitiesFound.size() == otherLookupEntities.size()) {
for (List<IColumnEntry> tableEntities : entitiesFound.keySet()) {
entityWithoutProblem.add(entitiesFound.get(tableEntities));
entityWithoutProblem.add(firstLookupEntity);
tableEntities.remove(entitiesFound.get(tableEntities));
}
}
}
// add back the first lookup table
lookupTables.add(firstLookup);
if (entityWithoutProblem.isEmpty()) {
// no common expressions in lookup tables , then show red background color for all
for (DataMapTableView lookupTable : lookupTables) {
List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
for (IColumnEntry entity : columnEntries) {
if (entity.getExpression() == null || entity.getExpression().trim().equals("")) {
continue;
}
addLookupProblem(entity);
}
lookupTable.getTableViewerCreatorForColumns().refresh();
}
} else {
for (DataMapTableView lookupTable : lookupTables) {
boolean needRefresh = false;
List<IColumnEntry> columnEntries = lookupTable.getDataMapTable().getColumnEntries();
for (IColumnEntry entity : columnEntries) {
if (entity.getExpression() == null || entity.getExpression().trim().equals("") || entityWithoutProblem.contains(entity)) {
if (entity.getProblems() != null) {
needRefresh = entity.getProblems().remove(lookupProblem);
if (entity.getProblems().isEmpty()) {
entity.setProblems(null);
}
}
} else {
addLookupProblem(entity);
needRefresh = true;
}
}
if (needRefresh) {
lookupTable.getTableViewerCreatorForColumns().refresh();
}
}
}
return true;
}
return false;
}
use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class UIManager method selectLinks.
/**
* Highlight links and linked cells which have are referenced by the selected items.
*
* @param dataMapTableView
* @param forceResetHighlightLinksForOtherTables TODO
* @param selectAllTableLinks TODO
* @param selectedMetadataTableEntries, source or targets entries which must be highlighted, can be null to select
* all links of a same DataMapTableView
*/
@SuppressWarnings("unchecked")
public void selectLinks(DataMapTableView dataMapTableView, List<ITableEntry> selectedTableEntries, boolean forceResetHighlightLinksForOtherTables, boolean selectAllTableLinks) {
if (!selectAllTableLinks && selectedTableEntries == null || selectedTableEntries != null && selectedTableEntries.size() == 0) {
return;
}
UIManager uiManager = mapperManager.getUiManager();
TableViewerCreator<ITableEntry> currentTableViewer = null;
boolean isFilterTableSelected = false;
boolean isGlobalMapTableSelected = false;
if (!selectAllTableLinks) {
ITableEntry firstEntry = selectedTableEntries.get(0);
if (firstEntry.isTableEntry()) {
if (firstEntry instanceof FilterTableEntry) {
isFilterTableSelected = true;
currentTableViewer = dataMapTableView.getTableViewerCreatorForFilters();
} else if (firstEntry instanceof GlobalMapEntry) {
isGlobalMapTableSelected = true;
currentTableViewer = dataMapTableView.getTableViewerCreatorForGlobalMap();
} else {
currentTableViewer = dataMapTableView.getTableViewerCreatorForColumns();
}
}
}
// Color selectedColor = dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW);
Color unselectedColor = dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WHITE);
Zone currentZone = dataMapTableView.getZone();
Set<ITableEntry> hashSelectedMetadataTableEntries = new HashSet<ITableEntry>();
if (selectAllTableLinks) {
if (currentZone == Zone.INPUTS || currentZone == Zone.OUTPUTS) {
hashSelectedMetadataTableEntries.add(((AbstractInOutTable) dataMapTableView.getDataMapTable()).getExpressionFilter());
}
hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForColumns().getInputList());
if (currentZone == Zone.INPUTS) {
hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForGlobalMap().getInputList());
}
if (currentZone == Zone.OUTPUTS) {
hashSelectedMetadataTableEntries.addAll(dataMapTableView.getTableViewerCreatorForFilters().getInputList());
}
} else {
hashSelectedMetadataTableEntries.addAll(selectedTableEntries);
}
// ////////////////////////////////////////////////////////////////////////
// Unselect all links and tableEntries if Ctrl or Shift keys are not pressed or if zone different of last
// selection
boolean zoneHasChanged = (previousSelectedZone == Zone.INPUTS || previousSelectedZone == Zone.VARS) && currentZone == Zone.OUTPUTS || (currentZone == Zone.INPUTS || currentZone == Zone.VARS) && previousSelectedZone == Zone.OUTPUTS;
boolean tableTypeHasChanged = previousSelectedTableIsConstraint != isFilterTableSelected && currentZone == Zone.OUTPUTS || previousSelectedTableIsGlobalMap != isGlobalMapTableSelected && currentZone == Zone.INPUTS;
boolean resetHighlightObjectsForOtherTables = !uiManager.isDragging() && (!uiManager.isCtrlPressed() && !uiManager.isShiftPressed() || zoneHasChanged);
if (resetHighlightObjectsForOtherTables || forceResetHighlightLinksForOtherTables) {
for (IMapperLink link : mapperManager.getLinks()) {
if (!hashSelectedMetadataTableEntries.contains(link.getPointLinkDescriptor1().getTableEntry()) && !hashSelectedMetadataTableEntries.contains(link.getPointLinkDescriptor2().getTableEntry())) {
link.setState(LinkState.UNSELECTED);
ITableEntry sourceITableEntry = link.getPointLinkDescriptor1().getTableEntry();
TableItem tableItem = mapperManager.retrieveTableItem(sourceITableEntry);
if (tableItem != null) {
tableItem.setBackground(unselectedColor);
}
ITableEntry targetITableEntry = link.getPointLinkDescriptor2().getTableEntry();
if (tableItem != null) {
tableItem = mapperManager.retrieveTableItem(targetITableEntry);
}
if (tableItem != null) {
tableItem.setBackground(unselectedColor);
}
}
}
if (currentZone == Zone.INPUTS || currentZone == Zone.VARS) {
unselectAllOutputMetaDataEntries();
} else if (currentZone == Zone.OUTPUTS) {
unselectAllInputMetaDataEntries();
}
Collection<DataMapTableView> tablesToDeselectEntries = mapperManager.getTablesView();
for (DataMapTableView viewToDeselectEntries : tablesToDeselectEntries) {
if (viewToDeselectEntries != dataMapTableView) {
viewToDeselectEntries.unselectAllEntries();
} else if (viewToDeselectEntries == dataMapTableView && tableTypeHasChanged) {
if (isFilterTableSelected) {
viewToDeselectEntries.unselectAllColumnEntries();
viewToDeselectEntries.unselectAllGlobalMapEntries();
} else if (isGlobalMapTableSelected) {
viewToDeselectEntries.unselectAllColumnEntries();
viewToDeselectEntries.unselectAllConstraintEntries();
} else {
viewToDeselectEntries.unselectAllGlobalMapEntries();
viewToDeselectEntries.unselectAllConstraintEntries();
}
}
}
}
// ////////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////
// Select or unselect links and tableEntries
List<ITableEntry> allEntriesOfCurrentTableView = new ArrayList<ITableEntry>();
if (currentZone == Zone.INPUTS || currentZone == Zone.OUTPUTS) {
allEntriesOfCurrentTableView.add(((AbstractInOutTable) dataMapTableView.getDataMapTable()).getExpressionFilter());
}
if (selectAllTableLinks || currentTableViewer != null) {
allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForColumns().getInputList());
if (selectAllTableLinks && currentZone == Zone.OUTPUTS) {
allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForFilters().getInputList());
}
// if (selectAllTableLinks && currentZone == Zone.INPUTS) {
if (currentZone == Zone.INPUTS) {
allEntriesOfCurrentTableView.addAll(dataMapTableView.getTableViewerCreatorForGlobalMap().getInputList());
}
}
int lstSize = allEntriesOfCurrentTableView.size();
Set<IMapperLink> linksAlreadySelected = new HashSet<IMapperLink>();
for (int i = 0; i < lstSize; i++) {
ITableEntry entry = allEntriesOfCurrentTableView.get(i);
Set<IMapperLink> linksFromSource = mapperManager.getGraphicalLinksFromSource(entry);
Set<IMapperLink> linksFromTarget = mapperManager.getGraphicalLinksFromTarget(entry);
LinkState linkState = null;
if (hashSelectedMetadataTableEntries.contains(entry)) {
linkState = LinkState.SELECTED;
} else {
linkState = LinkState.UNSELECTED;
}
for (IMapperLink link : linksFromSource) {
ITableEntry targetITableEntry = link.getPointLinkDescriptor2().getTableEntry();
if (linkState == LinkState.SELECTED || !linksAlreadySelected.contains(link) && linkState == LinkState.UNSELECTED) {
link.setState(linkState);
if (linkState == LinkState.SELECTED) {
linksAlreadySelected.add(link);
}
}
EntryState entryState = (link.getState() == LinkState.SELECTED ? EntryState.HIGHLIGHT : EntryState.NONE);
setEntryState(mapperManager, entryState, targetITableEntry);
}
for (IMapperLink link : linksFromTarget) {
ITableEntry sourceITableEntry = link.getPointLinkDescriptor1().getTableEntry();
if (linkState == LinkState.SELECTED || !linksAlreadySelected.contains(link) && linkState == LinkState.UNSELECTED) {
link.setState(linkState);
if (linkState == LinkState.SELECTED) {
linksAlreadySelected.add(link);
}
}
EntryState entryState = (link.getState() == LinkState.SELECTED ? EntryState.HIGHLIGHT : EntryState.NONE);
setEntryState(mapperManager, entryState, sourceITableEntry);
}
}
// ////////////////////////////////////////////////////////////////////////
// order links to place selected links at last position (last drawn)
mapperManager.orderLinks();
uiManager.refreshBackground(false, false);
previousSelectedZone = dataMapTableView.getZone();
previousSelectedTableIsConstraint = isFilterTableSelected;
previousSelectedTableIsGlobalMap = isGlobalMapTableSelected;
}
use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class UIManager method refreshInOutTableAndMetaTable.
/**
* DOC amaumont Comment method "refreshInOutTableAndMetaTable".
*
* @param currentModifiedTableEntry can be null
*/
private void refreshInOutTableAndMetaTable(AbstractInOutTableEntry currentModifiedTableEntry) {
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedTableEntry);
IMetadataTable metadataTableTarget = ((AbstractInOutTable) dataMapTableView.getDataMapTable()).getMetadataTable();
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedTableEntry);
MetadataTableEditorView metadataEditorView = getMetadataEditorView(dataMapTableView.getZone());
if (metadataEditorView != null && metadataEditorView.getMetadataTableEditor() != null && metadataEditorView.getMetadataTableEditor().getMetadataTable() == metadataTableTarget) {
metadataEditorView.getTableViewerCreator().getTableViewer().refresh(currentModifiedTableEntry.getMetadataColumn());
metadataEditorView.getTableViewerCreator().refreshTableEditorControls();
}
}
use of org.talend.designer.mapper.ui.visualmap.table.DataMapTableView in project tdi-studio-se by Talend.
the class UIManager method minimizeAllTables.
public void minimizeAllTables(Zone zone, boolean minimize, ToolItem minimizeButton) {
List<DataMapTableView> tablesView = null;
TablesZoneView tablesZoneView = null;
if (zone == Zone.INPUTS) {
tablesView = mapperManager.getUiManager().getInputsTablesView();
tablesZoneView = getTablesZoneViewInputs();
} else if (zone == Zone.OUTPUTS) {
tablesZoneView = getTablesZoneViewOutputs();
tablesView = mapperManager.getUiManager().getOutputsTablesView();
} else {
//$NON-NLS-1$
throw new RuntimeException("Case not found:" + zone);
}
Layout layout = tablesZoneView.getLayout();
try {
tablesZoneView.setLayout(null);
for (DataMapTableView view : tablesView) {
view.minimizeTable(minimize);
}
} catch (RuntimeException e) {
ExceptionHandler.process(e);
} finally {
tablesZoneView.setLayout(layout);
}
tablesZoneView.layout();
for (DataMapTableView view : tablesView) {
view.layout();
}
resizeTablesZoneViewAtComputedSize(zone);
moveScrollBarZoneAtSelectedTable(zone);
}
Aggregations