use of org.talend.designer.mapper.model.table.IUILookupMode 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.IUILookupMode 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.IUILookupMode 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