use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class UIManager method selectDataMapTableView.
/**
* Select a table view.
*
* @param dataMapTableView
* @param useNewCommand
* @param selectAllEntries TODO
*/
public void selectDataMapTableView(final DataMapTableView dataMapTableView, boolean useNewCommand, boolean selectAllEntries) {
// reject table readonly
IDataMapTable dataMapTable = dataMapTableView.getDataMapTable();
if (dataMapTable instanceof OutputTable && ((OutputTable) dataMapTable).isErrorRejectTable()) {
OutputTable table = (OutputTable) dataMapTable;
if (table.getMetadataTable() != null) {
for (IMetadataColumn column : table.getMetadataTable().getListColumns()) {
if (mapperManager.ERROR_REJECT_MESSAGE.equals(column.getLabel()) || mapperManager.ERROR_REJECT_STACK_TRACE.equals(column.getLabel())) {
column.setCustom(true);
}
}
}
CustomTableManager.addCustomManagementToTable(getOutputMetaEditorView(), true);
}
TabFolderEditors tabFolderEditors = mapperUI.getTabFolderEditors();
// tabFolderEditors.setSelection(TabFolderEditors.INDEX_TAB_METADATA_EDITOR);
MetadataTableEditorView metadataTableEditorView = null;
MetadataTableEditorView otherMetadataTableEditorView = null;
final Zone currentZone = dataMapTableView.getZone();
List<? extends AbstractDataMapTable> tables = null;
DataMapTableView previousSelectedTableView = null;
if (currentZone == Zone.INPUTS) {
metadataTableEditorView = tabFolderEditors.getInputMetaEditorView();
otherMetadataTableEditorView = tabFolderEditors.getOutputMetaEditorView();
tables = mapperManager.getInputTables();
previousSelectedTableView = this.currentSelectedInputTableView;
this.currentSelectedInputTableView = (InputDataMapTableView) dataMapTableView;
metadataTableEditorView.setReadOnly(this.currentSelectedInputTableView.getInputTable().hasReadOnlyMetadataColumns() || mapperManager.componentIsReadOnly() || this.currentSelectedInputTableView.getInputTable().isReadOnly());
} else if (currentZone == Zone.OUTPUTS) {
metadataTableEditorView = tabFolderEditors.getOutputMetaEditorView();
otherMetadataTableEditorView = tabFolderEditors.getInputMetaEditorView();
tables = mapperManager.getOutputTables();
previousSelectedTableView = this.currentSelectedOutputTableView;
this.currentSelectedOutputTableView = (OutputDataMapTableView) dataMapTableView;
metadataTableEditorView.setReadOnly(this.currentSelectedOutputTableView.getOutputTable().hasReadOnlyMetadataColumns() || mapperManager.componentIsReadOnly());
} else {
this.currentSelectedVarsTableView = (VarsDataMapTableView) dataMapTableView;
}
if (currentZone != Zone.VARS) {
updateToolbarButtonsStates(currentZone);
final AbstractInOutTable abstractDataMapTable = (AbstractInOutTable) mapperManager.retrieveAbstractDataMapTable(dataMapTableView);
MetadataTableEditor currentMetadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
final TableViewerCreator dataMapTVCreator = dataMapTableView.getTableViewerCreatorForColumns();
final TableViewer dataMapTableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
if (currentMetadataTableEditor == null || currentMetadataTableEditor != null && oldSelectedView != dataMapTableView) {
oldSelectedView = dataMapTableView;
if (useNewCommand) {
DataMapTableViewSelectedCommand command = new DataMapTableViewSelectedCommand(this, previousSelectedTableView, dataMapTableView);
mapperManager.executeCommand(command);
}
currentMetadataTableEditor = new MetadataTableEditor(abstractDataMapTable.getMetadataTable(), abstractDataMapTable.getName());
currentMetadataTableEditor.setModifiedBeanListenable(metadataTableEditorView.getTableViewerCreator());
final MetadataTableEditorView metadataTableEditorViewFinal = metadataTableEditorView;
final TableViewerCreator metadataTVCreator = metadataTableEditorViewFinal.getTableViewerCreator();
final MetadataTableEditor metadataTableEditor = currentMetadataTableEditor;
modifySelectionChangedListener(currentZone, metadataTableEditorViewFinal, metadataTVCreator, metadataTableEditor, dataMapTableView, previousSelectedTableView);
// init actions listeners for list which contains metadata
metadataTableEditor.addAfterOperationListListener(new IListenableListListener() {
/**
* DOC acer Comment method "handleEvent".
*
* @param event
*/
public void handleEvent(ListenableListEvent event) {
DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(abstractDataMapTable);
List<DataMapTableView> relatedOutputsTableView = getRelatedOutputsTableView(dataMapTableView);
if (event.type == TYPE.ADDED) {
// metadataEditorTableViewer.refresh();
List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.addedObjects;
lastCreatedInOutColumnEntries.clear();
if (event.index != null) {
int index = event.index;
for (IMetadataColumn metadataColumn : metadataColumns) {
lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, index));
// handle related table view
for (DataMapTableView tableView : relatedOutputsTableView) {
// changed for bug TDI-26551 in July 2,2013 by fwang, should use original
// expression for related table.
IMetadataColumn relatedMetadata = metadataColumn;
if (!oldMappingMap.isEmpty()) {
IDataMapTable retrieveAbstractDataMapTable = mapperManager.retrieveAbstractDataMapTable(tableView);
relatedMetadata = metadataColumn.clone();
String label = relatedMetadata.getLabel();
String expression = oldMappingMap.get(retrieveAbstractDataMapTable.getName() + "_" + label);
relatedMetadata.setExpression(expression == null ? "" : expression);
}
mapperManager.addNewColumnEntry(tableView, relatedMetadata, index);
}
index = index + 1;
}
} else if (event.indicesTarget != null) {
List<Integer> indicesTarget = event.indicesTarget;
int lstSize = indicesTarget.size();
for (int i = 0; i < lstSize; i++) {
Integer indice = indicesTarget.get(i);
IMetadataColumn metadataColumn = metadataColumns.get(i);
lastCreatedInOutColumnEntries.add(mapperManager.addNewColumnEntry(dataMapTableView, metadataColumn, indice));
// handle related table view
for (DataMapTableView tableView : relatedOutputsTableView) {
mapperManager.addNewColumnEntry(tableView, metadataColumn, indice);
}
}
} else {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("UIManager.1"));
}
refreshBackground(false, false);
if (event.index != null) {
dataMapTableViewer.refresh();
dataMapTVCreator.getSelectionHelper().setSelection(event.index);
if (dataMapTableView.canBeResizedAtPreferedSize()) {
dataMapTableView.changeSize(view.getPreferredSize(true, false, false), true, true);
}
// resize ralated table
for (DataMapTableView tableView : relatedOutputsTableView) {
if (tableView.canBeResizedAtPreferedSize()) {
tableView.changeSize(tableView.getPreferredSize(true, false, false), true, true);
}
}
} else if (event.indicesTarget != null) {
dataMapTableViewer.refresh();
dataMapTableView.changeSize(view.getPreferredSize(false, true, false), true, true);
int[] selection = ArrayUtils.toPrimitive((Integer[]) event.indicesTarget.toArray(new Integer[0]));
dataMapTVCreator.getSelectionHelper().setSelection(selection);
for (DataMapTableView tableView : relatedOutputsTableView) {
tableView.changeSize(tableView.getPreferredSize(false, true, false), true, true);
}
}
}
if (event.type == TYPE.REMOVED) {
// metadataEditorTableViewer.refresh();
List<IMetadataColumn> metadataColumns = (List<IMetadataColumn>) event.removedObjects;
for (IMetadataColumn metadataColumn : metadataColumns) {
ITableEntry metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(abstractDataMapTable.getName(), metadataColumn.getLabel()));
mapperManager.removeTableEntry(metadataTableEntry);
for (DataMapTableView tableView : relatedOutputsTableView) {
IDataMapTable retrieveAbstractDataMapTable = mapperManager.retrieveAbstractDataMapTable(tableView);
metadataTableEntry = mapperManager.retrieveTableEntry(new TableEntryLocation(retrieveAbstractDataMapTable.getName(), metadataColumn.getLabel()));
mapperManager.removeTableEntry(metadataTableEntry);
if (tableView.canBeResizedAtPreferedSize()) {
tableView.resizeAtExpandedSize();
}
}
}
dataMapTableViewer.refresh();
if (dataMapTableView.canBeResizedAtPreferedSize()) {
dataMapTableView.resizeAtExpandedSize();
}
resizeTablesZoneViewAtComputedSize(dataMapTableView.getZone());
moveScrollBarZoneAtSelectedTable(dataMapTableView.getZone());
refreshBackground(true, false);
}
if (event.type == TYPE.SWAPED) {
List<Integer> listIndexTarget = event.indicesTarget;
abstractDataMapTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
// handle related table view
for (DataMapTableView tableView : relatedOutputsTableView) {
AbstractDataMapTable relatedTable = (AbstractDataMapTable) tableView.getDataMapTable();
relatedTable.swapColumnElements(event.indicesOrigin, listIndexTarget);
}
// dataMapTableViewer.refresh();
refreshBackground(true, false);
}
}
});
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
metadataTableEditorView.setMetadataTableEditor(metadataTableEditor);
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
metadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(false);
metadataTableEditorView.getTableViewerCreator().getSelectionHelper().setSelection(dataMapTableViewer.getTable().getSelectionIndices());
dataMapTVCreator.getSelectionHelper().setActiveFireSelectionChanged(true);
// disable highlight for other DataMapTableView and highlight selected DataMapTableView
for (IDataMapTable table : tables) {
DataMapTableView otherDataMapTableView = mapperManager.retrieveAbstractDataMapTableView(table);
otherDataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
}
dataMapTableView.setBackground(dataMapTableView.getDisplay().getSystemColor(SWT.COLOR_YELLOW));
}
if (selectAllEntries) {
dataMapTVCreator.getTable().selectAll();
selectAllLinks(dataMapTableView);
if (currentZone != Zone.VARS) {
metadataTableEditorView.getTableViewerCreator().getTable().selectAll();
metadataTableEditorView.getToolBar().updateEnabledStateOfButtons();
}
if (currentZone == Zone.OUTPUTS) {
dataMapTableView.getTableViewerCreatorForFilters().getTable().selectAll();
}
}
boolean isMainSchemaRepository = false;
if (abstractDataMapTable instanceof OutputTable) {
OutputTable outputTable = (OutputTable) abstractDataMapTable;
if (outputTable.getIsJoinTableOf() != null || !"".equals(outputTable.getIsJoinTableOf())) {
final OutputTable outputTableByName = mapperManager.getOutputTableByName(outputTable.getIsJoinTableOf());
if (outputTableByName != null && outputTableByName.getId() != null) {
isMainSchemaRepository = true;
}
}
}
dataMapTableView.enableDiaplayViewer(abstractDataMapTable.isRepository() || isMainSchemaRepository);
}
if (selectAllEntries && currentZone == Zone.VARS) {
selectAllLinks(dataMapTableView);
mapperManager.getUiManager().getVarsTablesView().get(0).getTableViewerCreatorForColumns().getTable().selectAll();
}
if (otherMetadataTableEditorView != null) {
otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class UIManager method checkTargetInputKey.
/**
*
* DOC amaumont Comment method "checkTargetInputKey".
*
* @param currentModifiedTableEntry
* @param inputDataMapTableView
* @param checkInputKeyAutomatically
* @param appliedOrCanceled TODO
*/
private void checkTargetInputKey(ITableEntry currentModifiedTableEntry, boolean checkInputKeyAutomatically, boolean appliedOrCanceled) {
// check key
if (checkInputKeyAutomatically && currentModifiedTableEntry instanceof InputColumnTableEntry) {
IMetadataColumn metadataColumn = ((InputColumnTableEntry) currentModifiedTableEntry).getMetadataColumn();
if (!metadataColumn.isKey()) {
metadataColumn.setKey(true);
refreshInOutTableAndMetaTable((AbstractInOutTableEntry) currentModifiedTableEntry);
}
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class UIManager method setTraceFilterParaMapper.
/**
* DOC wzhang Comment method "setTraceFilterParaMapper".
*/
public void setTraceFilterParaMapper(Map<IConnection, Set<String>> preColumnSet, List<? extends AbstractInOutTable> curTables, Map<IConnection, Map<String, String>> changedColumnMap) {
for (IConnection curConn : preColumnSet.keySet()) {
Set<String> addedColumns = new HashSet<String>();
Set<String> preColSet = preColumnSet.get(curConn);
Map<String, String> changedColumns = changedColumnMap.get(curConn);
for (AbstractInOutTable table : curTables) {
String curTableName = table.getName();
if (curTableName.equals(curConn.getUniqueName())) {
if (changedColumns != null) {
for (String newName : changedColumns.keySet()) {
String oldName = changedColumns.get(newName);
if (preColSet.contains(oldName)) {
preColSet.remove(oldName);
preColSet.add(newName);
}
}
}
List<IMetadataColumn> curTableColumn = table.getMetadataTable().getListColumns();
for (IMetadataColumn curColumn : curTableColumn) {
if (!(preColSet.contains(curColumn.getLabel()))) {
addedColumns.add(curColumn.getLabel());
}
}
}
}
CorePlugin.getDefault().getDesignerCoreService().updateTraceColumnValues(curConn, changedColumns, addedColumns);
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class JobSettingsManager method getSchemaTablefromComponent.
private static IMetadataTable getSchemaTablefromComponent(final String componentName, final String tableName) {
IComponent tmpComponent = ComponentsFactoryProvider.getInstance().get(componentName, ComponentCategory.CATEGORY_4_DI.getName());
//$NON-NLS-1$
DataNode tmpNode = new DataNode(tmpComponent, "tmp");
for (int k = 0; k < tmpNode.getElementParameters().size(); k++) {
IElementParameter currentParam = tmpNode.getElementParameters().get(k);
if (currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || currentParam.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE)) {
Object value = currentParam.getValue();
if (value instanceof IMetadataTable) {
IMetadataTable table = null;
if (LanguageManager.getCurrentLanguage().equals(ECodeLanguage.JAVA)) {
table = ((IMetadataTable) value).clone(true);
} else {
table = ((IMetadataTable) value).clone();
}
table.setTableName(tableName);
table.setAttachedConnector(currentParam.getContext());
// fix for TUP-3972: set defult value
for (IMetadataColumn column : table.getListColumns()) {
column.setDefault("\"\"");
}
return table;
}
}
}
return null;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class MetadataEmfFactory method setMetadataTypeCommon.
@SuppressWarnings("unchecked")
private void setMetadataTypeCommon(final MetadataType metadataType) {
this.metadataType = metadataType;
IMetadataColumn metaCol;
ColumnType colType;
EList listColType;
List<IMetadataColumn> listMetadataColumn;
metadataTable.setComment(metadataType.getComment());
metadataTable.setTableName(metadataType.getName());
metadataTable.setLabel(metadataType.getLabel());
metadataTable.setTableType(metadataType.getType());
EMap<String, String> properties = metadataType.getAdditionalProperties();
if (properties != null) {
for (Map.Entry<String, String> entry : properties.entrySet()) {
metadataTable.getAdditionalProperties().put(entry.getKey(), entry.getValue());
}
}
if (metadataType.getConnector() != null) {
metadataTable.setAttachedConnector(metadataType.getConnector());
} else {
metadataTable.setAttachedConnector(EConnectionType.FLOW_MAIN.getName());
}
listColType = metadataType.getColumn();
listMetadataColumn = new ArrayList<IMetadataColumn>();
for (int i = 0; i < listColType.size(); i++) {
colType = (ColumnType) listColType.get(i);
metaCol = new MetadataColumn();
metaCol.setComment(colType.getComment());
metaCol.setKey(colType.isKey());
metaCol.setNullable(colType.isNullable());
if (colType.getLength() >= 0) {
metaCol.setLength(new Integer(colType.getLength()));
} else {
metaCol.setLength(null);
}
if (colType.getOriginalLength() >= 0) {
metaCol.setOriginalLength(new Integer(colType.getOriginalLength()));
} else {
metaCol.setOriginalLength(null);
}
if (colType.getAdditionalField().size() > 0) {
Iterator it = colType.getAdditionalField().keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
metaCol.getAdditionalField().put(key, (String) colType.getAdditionalField().get(key));
}
}
metaCol.setLabel(colType.getName());
if (colType.getPrecision() >= 0) {
metaCol.setPrecision(new Integer(colType.getPrecision()));
} else {
metaCol.setPrecision(null);
}
metaCol.setTalendType(colType.getType());
metaCol.setType(colType.getSourceType());
metaCol.setPattern(colType.getPattern());
metaCol.setDefault(colType.getDefaultValue());
metaCol.setRelatedEntity(colType.getRelatedEntity());
metaCol.setRelationshipType(colType.getRelationshipType());
if (colType.getOriginalDbColumnName() == null) {
metaCol.setOriginalDbColumnName(colType.getName());
} else {
metaCol.setOriginalDbColumnName(colType.getOriginalDbColumnName());
}
metaCol.setUsefulColumn(colType.isUsefulColumn());
listMetadataColumn.add(metaCol);
}
metadataTable.setListColumns(listMetadataColumn);
List<String> columnNames = new ArrayList<String>();
for (IMetadataColumn column : listMetadataColumn) {
columnNames.add(column.getLabel());
}
metadataTable.setOriginalColumns(columnNames);
}
Aggregations