use of org.talend.designer.mapper.model.table.IUIMatchingMode in project tdi-studio-se by Talend.
the class InputDataMapTableView method initColumnsOfTableColumns.
@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
boolean isMainConnection = ((InputTable) getDataMapTable()).isMainConnection();
TableViewerCreatorColumn column = null;
if (!isMainConnection) {
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("InputDataMapTableView.columnTitle.Expr"));
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS }, false);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {
public String get(InputColumnTableEntry bean) {
return bean.getExpression();
}
public void set(InputColumnTableEntry bean, String value) {
// System.out.println("value='" + value + "'");
bean.setExpression(value);
InputTable inputTable = getInputTable();
boolean tableHasAtLeastOneHashKey = mapperManager.isTableHasAtLeastOneHashKey(inputTable);
if (!tableHasAtLeastOneHashKey) {
IUIMatchingMode matchingMode = inputTable.getMatchingMode();
if (matchingMode != TMAP_MATCHING_MODE.ALL_ROWS) {
inputTable.setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
}
} else {
IUIMatchingMode matchingMode = inputTable.getMatchingMode();
if (matchingMode == TMAP_MATCHING_MODE.ALL_ROWS) {
IUIMatchingMode newMatchModel = previousMatchingModeSelected == null || previousMatchingModeSelected == TMAP_MATCHING_MODE.ALL_ROWS ? TMAP_MATCHING_MODE.UNIQUE_MATCH : previousMatchingModeSelected;
inputTable.setMatchingMode(newMatchModel);
refreshCondensedImage(inputTable, MATCH_MODEL_SETTING);
}
mapperManager.getUiManager().setStatusBarValues(STATUS.EMPTY, null);
}
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true, true);
if (!mapperManager.isCheckSyntaxEnabled()) {
mapperManager.getUiManager().applyActivatedCellEditors(tableViewerCreatorForColumns);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
mapperManager.getProblemsManager().checkLookupExpressionProblem();
}
});
}
}
});
column.setModifiable(!mapperManager.componentIsReadOnly());
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
column.setImageProvider(new IColumnImageProvider<InputColumnTableEntry>() {
public Image getImage(InputColumnTableEntry bean) {
if (bean.getExpression() != null && !bean.getExpression().trim().equals("")) {
//$NON-NLS-1$
if (mapperManager.isAdvancedMap()) {
return ImageProviderMapper.getImage(ImageInfo.LOOKUP_KEY_ICON);
} else {
return null;
}
} else {
return null;
}
}
});
}
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle(DataMapTableView.COLUMN_NAME);
column.setId(DataMapTableView.ID_NAME_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {
public String get(InputColumnTableEntry bean) {
return bean.getMetadataColumn().getLabel();
}
public void set(InputColumnTableEntry bean, String value) {
bean.getMetadataColumn().setLabel(value);
}
});
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
if (isMainConnection && PluginChecker.isTraceDebugPluginLoaded() && mapperManager.isTracesActive()) {
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle("Preview");
column.setId(DataMapTableView.PREVIEW_COLUMN);
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {
public String get(InputColumnTableEntry bean) {
IMetadataColumn metadataColumn = bean.getMetadataColumn();
if (metadataColumn != null) {
String label = metadataColumn.getLabel();
TraceData preview = bean.getPreviewValue();
if (preview != null && preview.getData() != null) {
return preview.getData().get(label);
}
}
return "";
}
public void set(InputColumnTableEntry bean, String value) {
// do nothing
}
});
}
}
use of org.talend.designer.mapper.model.table.IUIMatchingMode in project tdi-studio-se by Talend.
the class InputDataMapTableView method getMatchModel.
private IUIMatchingMode[] getMatchModel() {
IUIMatchingMode[] allMatchingModel = TMAP_MATCHING_MODE.values();
List<IUIMatchingMode> avilable = new ArrayList<IUIMatchingMode>();
for (IUIMatchingMode matchingMode : allMatchingModel) {
final String text = matchingMode.getLabel();
if (matchingMode == TMAP_MATCHING_MODE.LAST_MATCH) {
continue;
}
if (getMapperManager().isBigDataProcess() && matchingMode == TMAP_MATCHING_MODE.FIRST_MATCH) {
continue;
}
if (text.length() != 0) {
if (getMapperManager().isMRProcess() && matchingMode == TMAP_MATCHING_MODE.ALL_MATCHES) {
// set ALL_MATCHES as default value for m/r process
avilable.add(0, matchingMode);
} else {
avilable.add(matchingMode);
}
}
}
return avilable.toArray(new IUIMatchingMode[avilable.size()]);
}
use of org.talend.designer.mapper.model.table.IUIMatchingMode in project tdi-studio-se by Talend.
the class InputDataMapTableView method openCustomCellDialog.
@Override
protected Object openCustomCellDialog(Shell shell, CellValueType type) {
if (type == CellValueType.LOOKUP_MODEL) {
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());
}
ListStringValueDialog<String> dialog = new ListStringValueDialog<String>(shell, names);
if (dialog.open() == IDialogConstants.OK_ID) {
return dialog.getSelectStr();
}
} else if (type == CellValueType.MATCH_MODEL) {
IUIMatchingMode[] matchModel = getMatchModel();
List<String> names = new ArrayList<String>();
for (IUIMatchingMode element : matchModel) {
names.add(element.getLabel());
}
ListStringValueDialog<String> dialog = new ListStringValueDialog<String>(shell, names);
if (dialog.open() == IDialogConstants.OK_ID) {
return dialog.getSelectStr();
}
} else if (type == CellValueType.JOIN_MODEL) {
String[] items = new String[] { INNER_JOIN, LEFT_OUTER_JOIN };
ListStringValueDialog<String> dialog = new ListStringValueDialog<String>(shell, items);
if (dialog.open() == IDialogConstants.OK_ID) {
return dialog.getSelectStr();
}
}
return null;
}
use of org.talend.designer.mapper.model.table.IUIMatchingMode in project tdi-studio-se by Talend.
the class InputDataMapTableView method checkChangementsAfterEntryModifiedOrAdded.
/*
* (non-Javadoc)
*
* @see org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView#checkChangementsAfterNewExpressionApplied()
*/
@Override
public void checkChangementsAfterEntryModifiedOrAdded(boolean forceEvaluation) {
super.checkChangementsAfterEntryModifiedOrAdded(forceEvaluation);
if (!getInputTable().isMainConnection() && mapperManager.isAdvancedMap()) {
boolean stateAtLeastOneHashKey = mapperManager.isTableHasAtLeastOneHashKey(getInputTable());
if (forceEvaluation || previousStateAtLeastOneHashKey != stateAtLeastOneHashKey) {
if (stateAtLeastOneHashKey) {
IUIMatchingMode matchingMode = getInputTable().getMatchingMode();
if (matchingMode == TMAP_MATCHING_MODE.ALL_ROWS) {
IUIMatchingMode newMatchModel = previousMatchingModeSelected == null || previousMatchingModeSelected == TMAP_MATCHING_MODE.ALL_ROWS ? TMAP_MATCHING_MODE.UNIQUE_MATCH : previousMatchingModeSelected;
getInputTable().setMatchingMode(newMatchModel);
refreshCondensedImage(getInputTable(), MATCH_MODEL_SETTING);
}
} else {
if (getInputTable().getLookupMode() == TMAP_LOOKUP_MODE.CACHE_OR_RELOAD) {
String errorMessage = Messages.getString("InputDataMapTableView.invalidConfiguration", //$NON-NLS-1$
getInputTable().getName());
mapperManager.getUiManager().setStatusBarValues(STATUS.ERROR, errorMessage);
} else {
mapperManager.getUiManager().setStatusBarValues(STATUS.EMPTY, null);
// selectMatchingModeMenuItem(matchingMode);
}
IUIMatchingMode matchingMode = getInputTable().getMatchingMode();
if (matchingMode != TMAP_MATCHING_MODE.ALL_ROWS) {
getInputTable().setMatchingMode(TMAP_MATCHING_MODE.ALL_ROWS);
refreshCondensedImage(getInputTable(), MATCH_MODEL_SETTING);
}
innerJoinCheckItemEditable = false;
}
previousStateAtLeastOneHashKey = stateAtLeastOneHashKey;
}
checkLookupTableProblems(stateAtLeastOneHashKey);
mapSettingViewerCreator.refresh();
}
}
use of org.talend.designer.mapper.model.table.IUIMatchingMode 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