use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.
public void moveScrollBarZoneAtSelectedTableItem(ITableEntry entry) {
if (entry != null) {
DataMapTableView dataMapTableView = mapperManager.retrieveAbstractDataMapTableView(entry.getParent());
Rectangle tableViewBounds = dataMapTableView.getBounds();
IDataMapTable table = entry.getParent();
TableItem tableItem = mapperManager.retrieveTableItem(entry);
if (table != null && tableItem != null) {
Rectangle tableItemBounds = tableItem.getBounds();
int selection = tableViewBounds.y + tableItemBounds.y;
ScrolledComposite scrollComposite = null;
if (table instanceof InputTable) {
scrollComposite = uiManager.getScrolledCompositeViewInputs();
} else if (table instanceof VarsTable) {
scrollComposite = uiManager.getScrolledCompositeViewVars();
} else if (table instanceof OutputTable) {
scrollComposite = uiManager.getScrolledCompositeViewOutputs();
}
if (scrollComposite != null) {
setPositionOfVerticalScrollBarZone(scrollComposite, selection);
}
}
}
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class SearchZoneMapper method search.
public void search(Map<Integer, Map<Integer, ITableEntry>> searchMaps, String searchValue) {
if (searchValue.equals("")) {
uiManager.unselectAllEntriesOfAllTables();
return;
}
// SearchPattern
matcher.setPattern("*" + searchValue.trim() + "*");
List<InputTable> inputTables = mapperManager.getInputTables();
List<VarsTable> varsTables = mapperManager.getVarsTables();
List<OutputTable> outputTables = mapperManager.getOutputTables();
int index = -1;
// for the InputTables
for (InputTable inputTable : inputTables) {
for (IColumnEntry column : inputTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
// ExpressionFilter
ExpressionFilterEntry expressionFilterEntry = inputTable.getExpressionFilter();
if (expressionFilterEntry.getExpression() != null && matcher.matches(expressionFilterEntry.getExpression())) {
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
map.put(0, expressionFilterEntry);
index++;
searchMaps.put(index, map);
}
}
// for the VarsTables
for (VarsTable varsTable : varsTables) {
for (IColumnEntry column : varsTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
}
// for the OutputTables
for (OutputTable outputTable : outputTables) {
for (IColumnEntry column : outputTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
// ExpressionFilter
ExpressionFilterEntry expressionFilterEntry = outputTable.getExpressionFilter();
if (expressionFilterEntry.getExpression() != null && matcher.matches(expressionFilterEntry.getExpression())) {
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
map.put(0, expressionFilterEntry);
index++;
searchMaps.put(index, map);
}
}
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class InputDataMapTableView method createGlobalMapTable.
protected void createGlobalMapTable() {
this.extendedTableViewerForGlobalMap = new AbstractExtendedTableViewer<GlobalMapEntry>(((InputTable) abstractDataMapTable).getTableGlobalMapEntriesModel(), centerComposite) {
@Override
protected void createColumns(TableViewerCreator<GlobalMapEntry> tableViewerCreator, Table table) {
createGlobalMapColumns(tableViewerCreator);
}
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
* (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
*/
@Override
protected void setTableViewerCreatorOptions(TableViewerCreator<GlobalMapEntry> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setColumnsResizableByDefault(true);
newTableViewerCreator.setShowLineSelection(SHOW_ROW_SELECTION.FULL);
newTableViewerCreator.setBorderVisible(false);
newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
newTableViewerCreator.setKeyboardManagementForCellEdition(true);
newTableViewerCreator.setHorizontalScroll(false);
newTableViewerCreator.setVerticalScroll(false);
// tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable()
// instanceof
// AbstractInOutTable);
newTableViewerCreator.setFirstColumnMasked(true);
}
};
tableViewerCreatorForGlobalMap = this.extendedTableViewerForGlobalMap.getTableViewerCreator();
if (mapperManager.componentIsReadOnly()) {
tableViewerCreatorForGlobalMap.setReadOnly(true);
}
this.extendedTableViewerForGlobalMap.setCommandStack(mapperManager.getCommandStack());
tableForGlobalMap = tableViewerCreatorForGlobalMap.getTable();
tableForGlobalMapGridData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
tableForGlobalMap.setLayoutData(tableForGlobalMapGridData);
boolean tableGlobalMapVisible = false;
if (abstractDataMapTable instanceof InputTable) {
IUILookupMode lookupMode = ((InputTable) abstractDataMapTable).getLookupMode();
tableGlobalMapVisible = lookupMode == TMAP_LOOKUP_MODE.RELOAD || lookupMode == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD;
}
tableForGlobalMapGridData.exclude = !tableGlobalMapVisible;
tableForGlobalMap.setVisible(tableGlobalMapVisible);
if (!mapperManager.componentIsReadOnly()) {
new DragNDrop(mapperManager, tableForGlobalMap, false, true);
}
tableViewerCreatorForGlobalMap.addCellValueModifiedListener(new ITableCellValueModifiedListener() {
public void cellValueModified(TableCellValueModifiedEvent e) {
unselectAllEntriesIfErrorDetected(e);
}
});
final TableViewer tableViewer = tableViewerCreatorForGlobalMap.getTableViewer();
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
selectThisDataMapTableView();
UIManager uiManager = mapperManager.getUiManager();
uiManager.selectLinks(InputDataMapTableView.this, uiManager.extractSelectedTableEntries(selection), false, false);
}
});
tableForGlobalMap.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event event) {
processEnterKeyDown(tableViewerCreatorForGlobalMap, event);
}
});
tableViewerCreatorForGlobalMap.setLabelProvider(new DefaultTableLabelProvider(tableViewerCreatorForGlobalMap) {
@Override
public Color getBackground(Object element, int columnIndex) {
return getBackgroundCellColor(tableViewerCreator, element, columnIndex);
}
@Override
public Color getForeground(Object element, int columnIndex) {
return getForegroundCellColor(tableViewerCreator, element, columnIndex);
}
});
initShowMessageErrorListener(tableForGlobalMap);
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class InputDataMapTableView method refreshCondensedImage.
@Override
protected void refreshCondensedImage(AbstractInOutTable absTable, String option) {
InputTable table = (InputTable) absTable;
if (LOOKUP_MODEL_SETTING.equals(option)) {
if (table.getLookupMode().equals(mapperManager.getDefaultSetting().get(LOOKUP_MODEL_SETTING))) {
if (changedOptions > 0) {
changedOptions--;
}
} else {
if (changedOptions < 6) {
changedOptions++;
}
}
} else if (MATCH_MODEL_SETTING.equals(option)) {
if (table.getMatchingMode().equals(mapperManager.getDefaultSetting().get(MATCH_MODEL_SETTING))) {
if (changedOptions > 0) {
changedOptions--;
}
} else {
if (changedOptions < 6) {
changedOptions++;
}
}
} else if (JOIN_MODEL_SETTING.equals(option)) {
if (Boolean.valueOf(table.isInnerJoin()).equals(mapperManager.getDefaultSetting().get(JOIN_MODEL_SETTING))) {
if (changedOptions > 0) {
changedOptions--;
}
} else {
if (changedOptions < 6) {
changedOptions++;
}
}
} else if (PERSISTENCE_MODEL_SETTING.equals(option)) {
if (Boolean.valueOf(table.isPersistent()).equals(mapperManager.getDefaultSetting().get(PERSISTENCE_MODEL_SETTING))) {
if (changedOptions > 0) {
changedOptions--;
}
} else {
if (changedOptions < 6) {
changedOptions++;
}
}
} else if (SCHEMA_TYPE.equals(option)) {
if (mapperManager.getDefaultSetting().get(SCHEMA_TYPE).equals(table.isRepository())) {
if (changedOptions > 0) {
changedOptions--;
}
} else {
if (changedOptions < 6) {
changedOptions++;
}
}
} else if (SCHEMA_ID.equals(option)) {
if (mapperManager.getDefaultSetting().get(SCHEMA_ID) == table.getId()) {
if (changedOptions > 0) {
changedOptions--;
}
} else {
if (changedOptions < 6) {
changedOptions++;
}
}
}
condensedItem.setImage(ImageProviderMapper.getImage(getCondencedItemImage(changedOptions)));
if (!getInputTable().isMainConnection()) {
checkLookupTableProblems(mapperManager.isTableHasAtLeastOneHashKey(table));
}
}
use of org.talend.designer.mapper.model.table.InputTable in project tdi-studio-se by Talend.
the class InputDataMapTableView method getMapSettingValueAccess.
@Override
protected IBeanPropertyAccessors<GlobalMapEntry, Object> getMapSettingValueAccess(final CellEditor cellEditor) {
return new IBeanPropertyAccessors<GlobalMapEntry, Object>() {
public Object get(GlobalMapEntry bean) {
IDataMapTable parent = bean.getParent();
InputTable inputTable = (InputTable) parent;
if (cellEditor instanceof ComboBoxCellEditor) {
ComboBoxCellEditor functComboBox = (ComboBoxCellEditor) cellEditor;
if (LOOKUP_MODEL_SETTING.equals(bean.getName())) {
IUILookupMode[] availableJoins = { TMAP_LOOKUP_MODE.LOAD_ONCE, TMAP_LOOKUP_MODE.RELOAD, TMAP_LOOKUP_MODE.CACHE_OR_RELOAD };
List<String> names = new ArrayList<String>();
for (IUILookupMode availableJoin : availableJoins) {
names.add(availableJoin.getLabel());
}
functComboBox.setItems(names.toArray(new String[names.size()]));
final IUILookupMode lookupMode = ((InputTable) parent).getLookupMode();
if (lookupMode != null) {
return lookupMode.getLabel();
}
} else if (MATCH_MODEL_SETTING.equals(bean.getName())) {
IUIMatchingMode[] matchModel = getMatchModel();
List<String> names = new ArrayList<String>();
for (IUIMatchingMode element : matchModel) {
names.add(element.getLabel());
}
functComboBox.setItems(names.toArray(new String[names.size()]));
IUIMatchingMode matchingMode = ((InputTable) parent).getMatchingMode();
if (names.contains(matchingMode.getLabel())) {
return matchingMode.getLabel();
}
} else if (JOIN_MODEL_SETTING.equals(bean.getName())) {
String[] items = new String[] { INNER_JOIN, LEFT_OUTER_JOIN };
functComboBox.setItems(items);
boolean innerJoin = ((InputTable) parent).isInnerJoin();
if (innerJoin) {
return items[0];
}
return items[1];
} else if (PERSISTENCE_MODEL_SETTING.equals(bean.getName())) {
functComboBox.setItems(new String[] { "true", "false" });
boolean persistent = ((InputTable) parent).isPersistent();
return String.valueOf(persistent);
}
} else if (cellEditor instanceof CustomDialogCellEditor) {
CustomDialogCellEditor customDialogCellEditor = (CustomDialogCellEditor) cellEditor;
if (LOOKUP_MODEL_SETTING.equals(bean.getName())) {
customDialogCellEditor.setType(CellValueType.LOOKUP_MODEL);
final IUILookupMode lookupMode = inputTable.getLookupMode();
if (lookupMode != null) {
return lookupMode.getLabel();
}
} else if (MATCH_MODEL_SETTING.equals(bean.getName())) {
customDialogCellEditor.setType(CellValueType.MATCH_MODEL);
IUIMatchingMode matchingMode = inputTable.getMatchingMode();
if (matchingMode != null) {
return matchingMode.getLabel();
}
} else if (JOIN_MODEL_SETTING.equals(bean.getName())) {
customDialogCellEditor.setType(CellValueType.JOIN_MODEL);
boolean innerJoin = inputTable.isInnerJoin();
return innerJoin ? INNER_JOIN : LEFT_OUTER_JOIN;
} else if (PERSISTENCE_MODEL_SETTING.equals(bean.getName())) {
customDialogCellEditor.setType(CellValueType.BOOL);
boolean persistent = inputTable.isPersistent();
return String.valueOf(persistent);
} else if (SCHEMA_TYPE.equals(bean.getName())) {
customDialogCellEditor.setType(CellValueType.SCHEMA_TYPE);
enableDiaplayViewer(inputTable.isRepository());
return inputTable.isRepository() ? REPOSITORY : BUILT_IN;
} else if (SCHEMA_ID.equals(bean.getName())) {
customDialogCellEditor.setType(CellValueType.SCHEMA_ID);
return getSchemaDisplayName(inputTable.getId());
}
}
return "";
}
public void set(GlobalMapEntry bean, Object value) {
IDataMapTable parent = bean.getParent();
InputTable inputTable = (InputTable) parent;
if (LOOKUP_MODEL_SETTING.equals(bean.getName())) {
IUILookupMode[] availableJoins = { TMAP_LOOKUP_MODE.LOAD_ONCE, TMAP_LOOKUP_MODE.RELOAD, TMAP_LOOKUP_MODE.CACHE_OR_RELOAD };
for (final IUILookupMode lookupMode : availableJoins) {
if (value != null && value.equals(lookupMode.getLabel())) {
inputTable.setLookupMode(lookupMode);
if (TMAP_LOOKUP_MODE.CACHE_OR_RELOAD == lookupMode) {
persistentCheckEditable = false;
} else {
persistentCheckEditable = true;
}
if (lookupMode == TMAP_LOOKUP_MODE.RELOAD || lookupMode == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD) {
showTableGlobalMap(true);
} else {
showTableGlobalMap(false);
}
enableDisablePersistentMode((TMAP_LOOKUP_MODE) lookupMode);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
checkChangementsAfterEntryModifiedOrAdded(true);
}
}
} else if (MATCH_MODEL_SETTING.equals(bean.getName())) {
for (IUIMatchingMode model : TMAP_MATCHING_MODE.values()) {
if (value != null && value.equals(model.getLabel())) {
inputTable.setMatchingMode(model);
previousMatchingModeSelected = model;
}
}
} else if (JOIN_MODEL_SETTING.equals(bean.getName())) {
if (LEFT_OUTER_JOIN.equals(value)) {
((InputTable) parent).setInnerJoin(false);
previousInnerJoinSelection = false;
} else {
((InputTable) parent).setInnerJoin(true);
previousInnerJoinSelection = true;
}
} else if (PERSISTENCE_MODEL_SETTING.equals(bean.getName())) {
if ("true".equals(value) || "false".equals(value)) {
((InputTable) parent).setPersistent(Boolean.valueOf(value.toString()));
previousValidPersistentMode = Boolean.valueOf(value.toString());
}
} else if (SCHEMA_TYPE.equals(bean.getName())) {
inputTable.setRepository(REPOSITORY.equals(value));
showSchemaIDSetting(REPOSITORY.equals(value));
enableDiaplayViewer(REPOSITORY.equals(value));
} else if (SCHEMA_ID.equals(bean.getName())) {
inputTable.setId(String.valueOf(value));
}
refreshCondensedImage((InputTable) bean.getParent(), bean.getName());
}
};
}
Aggregations