use of org.talend.designer.dbmap.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class MapperManager method findUniqueLocation.
public TableEntryLocation findUniqueLocation(final TableEntryLocation proposedLocation, IDataMapTable table) {
TableEntryLocation tableEntryLocation = new TableEntryLocation(proposedLocation);
int counter = 1;
boolean exists = true;
while (exists) {
boolean found = false;
if (table != null) {
for (IColumnEntry entry : table.getColumnEntries()) {
// TDI-26953: drag-and-drop column name should case-sensitive
if (entry.getName().equalsIgnoreCase(tableEntryLocation.columnName)) {
found = true;
break;
}
}
}
exists = found;
if (!exists) {
break;
}
//$NON-NLS-1$
tableEntryLocation.columnName = proposedLocation.columnName + "_" + counter++;
}
return tableEntryLocation;
}
use of org.talend.designer.dbmap.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class DataMapExpressionParserTest method verifyParseResult.
private void verifyParseResult(String expression) {
String expectColumnName = expression.substring(expression.lastIndexOf(".") + 1).trim();
String expectTableName = expression.substring(0, expression.lastIndexOf("."));
String[] fragments = expectTableName.split("\\.");
expectTableName = "";
for (int i = 0; i < fragments.length; i++) {
String fragment = fragments[i].trim();
if (i < fragments.length - 1) {
fragment = fragment + ".";
}
expectTableName = expectTableName + fragment;
}
TableEntryLocation[] locations = parser.parseTableEntryLocations(expression);
for (TableEntryLocation location : locations) {
assertEquals(expectTableName, location.tableName);
assertEquals(expectColumnName, location.columnName);
}
}
use of org.talend.designer.dbmap.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class DbMapComponent method renameInputConnection.
@Override
public void renameInputConnection(String oldConnectionName, String newConnectionName) {
if (oldConnectionName == null || newConnectionName == null) {
throw new NullPointerException();
}
if (externalData != null) {
List<ExternalDbMapTable> inputTables = externalData.getInputTables();
for (ExternalDbMapTable table : inputTables) {
if (table.getTableName() != null && (table.getTableName().equals(oldConnectionName) || table.getName().equals(oldConnectionName))) {
table.setTableName(newConnectionName);
table.setName(newConnectionName);
TableEntryLocation oldLocation = new TableEntryLocation(oldConnectionName, null);
TableEntryLocation newLocation = new TableEntryLocation(newConnectionName, null);
replaceLocationsInAllExpressions(oldLocation, newLocation, true);
}
}
}
}
use of org.talend.designer.dbmap.model.tableentry.TableEntryLocation in project tdi-studio-se by Talend.
the class DbMapComponent method replaceLocation.
public void replaceLocation(TableEntryLocation oldLocation, TableEntryLocation newLocation, ExternalDbMapEntry entry, DataMapExpressionParser dataMapExpressionParser, boolean tableRenamed) {
String currentExpression = entry.getExpression();
if (currentExpression == null || currentExpression.length() == 0) {
return;
}
TableEntryLocation[] tableEntryLocations = dataMapExpressionParser.parseTableEntryLocations(currentExpression);
// loop on all locations of current expression
for (TableEntryLocation currentLocation : tableEntryLocations) {
if (tableRenamed && oldLocation.tableName.equals(currentLocation.tableName)) {
oldLocation.columnName = currentLocation.columnName;
newLocation.columnName = currentLocation.columnName;
}
if (currentLocation.equals(oldLocation)) {
currentExpression = dataMapExpressionParser.replaceLocation(currentExpression, currentLocation, newLocation);
}
}
// for (int i = 0; i < tableEntryLocations.length; i++) {
entry.setExpression(currentExpression);
}
use of org.talend.designer.dbmap.model.tableentry.TableEntryLocation 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) {
TabFolderEditors tabFolderEditors = mapperUI.getTabFolderEditors();
// tabFolderEditors.setSelection(TabFolderEditors.INDEX_TAB_METADATA_EDITOR);
MetadataTableEditorView metadataTableEditorView = null;
MetadataTableEditorView otherMetadataTableEditorView = null;
final Zone currentZone = dataMapTableView.getZone();
List<? extends IDataMapTable> tables = null;
DataMapTableView previousSelectedTableView = null;
DataMapTableView newSelectedTableView = null;
if (currentZone == Zone.INPUTS) {
metadataTableEditorView = tabFolderEditors.getInputMetaEditor();
otherMetadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
tables = mapperManager.getInputTables();
previousSelectedTableView = this.currentSelectedInputTableView;
setCurrentSelectedInputTableView((InputDataMapTableView) dataMapTableView);
newSelectedTableView = dataMapTableView;
} else if (currentZone == Zone.OUTPUTS) {
metadataTableEditorView = tabFolderEditors.getOutputMetaEditor();
otherMetadataTableEditorView = tabFolderEditors.getInputMetaEditor();
tables = mapperManager.getOutputTables();
previousSelectedTableView = this.currentSelectedOutputTableView;
newSelectedTableView = dataMapTableView;
setCurrentSelectedOutputTableView((OutputDataMapTableView) dataMapTableView);
}
updateToolbarButtonsStates(currentZone);
final AbstractInOutTable abstractDataMapTable = (AbstractInOutTable) mapperManager.retrieveIDataMapTable(dataMapTableView);
MetadataTableEditor currentMetadataTableEditor = metadataTableEditorView.getMetadataTableEditor();
final TableViewerCreator dataMapTVCreator = dataMapTableView.getTableViewerCreatorForColumns();
final TableViewer dataMapTableViewer = dataMapTableView.getTableViewerCreatorForColumns().getTableViewer();
if (currentMetadataTableEditor == null || currentMetadataTableEditor != null && newSelectedTableView != previousSelectedTableView) {
if (useNewCommand) {
DataMapTableViewSelectedCommand command = new DataMapTableViewSelectedCommand(this, previousSelectedTableView, dataMapTableView);
mapperManager.executeCommand(command);
}
currentMetadataTableEditor = new MetadataTableEditor(abstractDataMapTable.getMetadataTable(), abstractDataMapTable.getTitle());
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
*/
@Override
public void handleEvent(ListenableListEvent event) {
DataMapTableView view = mapperManager.retrieveIDataMapTableView(abstractDataMapTable);
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++));
}
} 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));
}
} else {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("UIManager.1"));
}
refreshBackground(false, false);
if (event.index != null) {
dataMapTableView.changeSize(view.getPreferredSize(true, false, false), true, true);
dataMapTableViewer.refresh();
dataMapTVCreator.getSelectionHelper().setSelection(event.index);
} 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);
}
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(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);
}
dataMapTableViewer.refresh();
dataMapTableView.resizeAtExpandedSize();
resizeTablesZoneViewAtComputedSize(dataMapTableView.getZone());
moveScrollBarZoneAtSelectedTable(dataMapTableView.getZone());
refreshBackground(true, false);
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
if (event.type == TYPE.SWAPED) {
List<Integer> listIndexTarget = event.indicesTarget;
abstractDataMapTable.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.retrieveIDataMapTableView(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);
metadataTableEditorView.getTableViewerCreator().getTable().selectAll();
metadataTableEditorView.getToolBar().updateEnabledStateOfButtons();
if (currentZone == Zone.OUTPUTS) {
dataMapTableView.getTableViewerCreatorForWhereFilters().getTable().selectAll();
dataMapTableView.getTableViewerCreatorForOtherFilters().getTable().selectAll();
}
}
if (otherMetadataTableEditorView != null) {
otherMetadataTableEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
}
}
Aggregations