use of org.talend.designer.mapper.language.ILanguage in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkKeysProblems.
/**
* DOC amaumont Comment method "checkKeysProblems".
*
* @param incomingConnections
* @param inputTables
*/
private void checkKeysProblems(ArrayList<InputTable> inputTables) {
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
if (!mapperManager.isAdvancedMap()) {
for (InputTable table : inputTables) {
if (table.isMainConnection()) {
continue;
}
String tableName = table.getName();
List<IColumnEntry> columnEntries = table.getColumnEntries();
for (IColumnEntry entry : columnEntries) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
String columnName = entry.getName();
if (mapperManager.checkEntryHasInvalidUncheckedKey(inputEntry)) {
String description = //$NON-NLS-1$
"Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
" input entry should be checked or expression should be removed. ";
addProblem(new Problem(null, description, ProblemStatus.WARNING));
}
if (mapperManager.checkEntryHasInvalidCheckedKey(inputEntry)) {
String description = //$NON-NLS-1$
"Key of " + currentLanguage.getLocation(tableName, columnName) + //$NON-NLS-1$
" input entry should be unchecked or expression should be filled. ";
addProblem(new Problem(null, description, ProblemStatus.WARNING));
}
}
}
}
}
use of org.talend.designer.mapper.language.ILanguage in project tdi-studio-se by Talend.
the class VarsDataMapTableView method createToolItems.
@Override
protected void createToolItems() {
// /////////////////////////////////////////////////////////////////
ToolItem addEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
addEntryItem.setEnabled(!getMapperManager().componentIsReadOnly());
//$NON-NLS-1$
addEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.addVariable"));
addEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
addEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
TableViewerCreator<IColumnEntry> tableViewerCreator = getExtendedTableViewerForColumns().getTableViewerCreator();
tableViewerCreator.applyActivatedCellEditor();
Table table = getExtendedTableViewerForColumns().getTable();
int[] indices = table.getSelectionIndices();
int indexInsert = table.getItemCount();
if (indices.length > 0) {
indexInsert = indices[indices.length - 1] + 1;
}
IDataMapTable dataMapTable = VarsDataMapTableView.this.getDataMapTable();
String varName = null;
if (dataMapTable instanceof VarsTable) {
//$NON-NLS-1$
varName = ((VarsTable) dataMapTable).findUniqueColumnName("var");
} else {
throw new UnsupportedOperationException(Messages.getString(//$NON-NLS-1$
"VarsDataMapTableView.exceptionMessage.caseNotFound"));
}
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
String type = null;
if (currentLanguage.getCodeLanguage() == ECodeLanguage.JAVA) {
type = JavaTypesManager.STRING.getId();
} else {
// fix bug 0018996 ,when add a var row,there is no default type,this bug exsit for long time
type = PerlTypesManager.STRING;
}
mapperManager.addNewVarEntry(VarsDataMapTableView.this, varName, indexInsert, type);
tableViewerCreatorForColumns.getTableViewer().refresh();
if (canBeResizedAtPreferedSize()) {
VarsDataMapTableView.this.changeSize(VarsDataMapTableView.this.getPreferredSize(true, true, false), true, true);
changeMinimizeState(false);
}
mapperManager.getUiManager().refreshBackground(true, false);
table.setSelection(indexInsert);
removeEntryItem.setEnabled(true);
moveUpEntryItem.setEnabled(true);
moveDownEntryItem.setEnabled(true);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
removeEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
removeEntryItem.setEnabled(false);
removeEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.MINUS_ICON)));
//$NON-NLS-1$
removeEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.removeVariable"));
removeEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) tableViewerCreatorForColumns.getTableViewer().getSelection();
List<ITableEntry> selectedBeans = selection.toList();
for (ITableEntry entry : selectedBeans) {
mapperManager.removeTableEntry(entry);
}
if (selectedBeans.size() > 0) {
tableViewerCreatorForColumns.getTableViewer().refresh();
mapperManager.getUiManager().refreshBackground(true, false);
if (canBeResizedAtPreferedSize()) {
resizeAtExpandedSize();
}
}
removeEntryItem.setEnabled(false);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
moveUpEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
moveUpEntryItem.setEnabled(false);
moveUpEntryItem.setImage(ImageProvider.getImage(EImage.UP_ICON));
//$NON-NLS-1$
moveUpEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.moveUpVariable"));
moveUpEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), true, viewer.getTableViewerCreator().getTable().getSelectionIndices());
viewer.getTableViewerCreator().applyActivatedCellEditor();
viewer.executeCommand(moveCommand);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
moveDownEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
moveDownEntryItem.setEnabled(false);
moveDownEntryItem.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
//$NON-NLS-1$
moveDownEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.movedownVariable"));
moveDownEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), false, viewer.getTableViewerCreator().getTable().getSelectionIndices());
viewer.getTableViewerCreator().applyActivatedCellEditor();
viewer.executeCommand(moveCommand);
}
});
// /////////////////////////////////////////////////////////////////
}
use of org.talend.designer.mapper.language.ILanguage in project tdi-studio-se by Talend.
the class OutputTable method initFromExternalData.
public void initFromExternalData(ExternalMapperTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
if (externalMapperTable != null) {
this.reject = externalMapperTable.isReject();
this.rejectInnerJoin = externalMapperTable.isRejectInnerJoin();
this.isJoinTableOf = externalMapperTable.getIsJoinTableOf();
this.isErrorRejectTable = externalMapperTable.isErrorRejectTable();
List<ExternalMapperTableEntry> externalConstraintTableEntries = externalMapperTable.getConstraintTableEntries();
if (externalConstraintTableEntries != null) {
if (!mapperManager.isAdvancedMap()) {
for (ExternalMapperTableEntry entry : externalConstraintTableEntries) {
FilterTableEntry filterTableEntry = new FilterTableEntry(this, entry.getName(), entry.getExpression());
// mapperManager.getProblemsManager().checkProblemsForTableEntry(filterTableEntry, false);
addFilterEntry(filterTableEntry);
}
} else {
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
JavaGenerationManager javaGenerationManager = new JavaGenerationManager(currentLanguage);
DataMapExpressionParser expressionParser = new DataMapExpressionParser(currentLanguage);
String expressionFilter = javaGenerationManager.buildConditions(externalConstraintTableEntries, expressionParser);
if (!expressionFilter.trim().equals("")) {
//$NON-NLS-1$
this.getExpressionFilter().setExpression(expressionFilter);
this.setActivateExpressionFilter(true);
}
}
}
}
}
use of org.talend.designer.mapper.language.ILanguage in project tdi-studio-se by Talend.
the class ProblemsAnalyser method checkExpressionSyntaxProblems.
/**
* DOC amaumont Comment method "checkExpressionSyntaxProblems".
*
* @param tables
* @param codeChecker
*/
private void checkExpressionSyntaxProblems(List<ExternalMapperTable> tables, ICodeProblemsChecker codeChecker) {
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
boolean keyLanguageCheckerIsUsed = currentLanguage.getCodeLanguage() == ECodeLanguage.JAVA;
for (ExternalMapperTable table : tables) {
List<ExternalMapperTableEntry> metadataTableEntries = table.getMetadataTableEntries();
// loop on all entries of current table
if (metadataTableEntries != null) {
checkExpressionSyntaxProblems(codeChecker, currentLanguage, keyLanguageCheckerIsUsed, table, metadataTableEntries, JavaGenerationManager.PROBLEM_KEY_FIELD.METADATA_COLUMN);
}
List<ExternalMapperTableEntry> globalMapKeysValues = table.getGlobalMapKeysValues();
// loop on all entries of current table
if (globalMapKeysValues != null) {
checkExpressionSyntaxProblems(codeChecker, currentLanguage, keyLanguageCheckerIsUsed, table, globalMapKeysValues, JavaGenerationManager.PROBLEM_KEY_FIELD.GLOBAL_MAP);
}
if (table.getConstraintTableEntries() != null || table.isActivateExpressionFilter() && table.getExpressionFilter() != null && !table.getExpressionFilter().trim().equals("")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
String prefix = "Filter invalid in table " + table.getName() + " : ";
if (table.getConstraintTableEntries() != null) {
for (ExternalMapperTableEntry entry : table.getConstraintTableEntries()) {
checkFilterEntry(codeChecker, keyLanguageCheckerIsUsed, table, prefix, entry.getExpression());
}
}
if (table.isActivateExpressionFilter() && table.getExpressionFilter() != null && !table.getExpressionFilter().trim().equals("")) {
//$NON-NLS-1$
checkFilterEntry(codeChecker, keyLanguageCheckerIsUsed, table, prefix, table.getExpressionFilter());
}
}
}
// for (ExternalMapperTable table : tables) {
}
use of org.talend.designer.mapper.language.ILanguage in project tdi-studio-se by Talend.
the class CompleteDropTargetTableListener method drop.
// private void showInfos(DropTargetEvent event) {
// System.out.println(event);
// System.out.println("event.feedback=" + event.feedback);
// System.out.println("event.detail=" + event.detail);
// System.out.println("event.operations=" + event.operations);
//
// System.out.println("DND.DROP_DEFAULT=" + DND.DROP_DEFAULT);
// System.out.println("DND.DROP_COPY=" + DND.DROP_COPY);
// System.out.println("DND.DROP_MOVE=" + DND.DROP_MOVE);
// System.out.println("DND.DROP_LINK=" + DND.DROP_LINK);
// System.out.println("DND.DROP_TARGET_MOVE=" + DND.DROP_TARGET_MOVE);
// }
//
@Override
public void drop(DropTargetEvent event) {
super.drop(event);
retrieveInsertionIndicator().setVisible(false);
UIManager uiManager = getUiManager();
DraggedData draggedData = TableEntriesTransfer.getInstance().getDraggedData();
DropContextAnalyzer analyzer = analyzeDropTarget(event, draggedData);
// System.out.println("\n>>drop");
// System.out.println(event);
Point cursorPosition = new Point(event.x, event.y);
// int startInsertAtThisIndex = getItemIndexWhereInsertFromPosition(cursorPosition);
int startInsertAtThisIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTargetControl, cursorPosition);
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
DataMapTableView dataMapTableViewTarget = getMapperManager().retrieveDataMapTableView(draggableTargetControl);
Zone zoneTarget = dataMapTableViewTarget.getZone();
uiManager.selectDataMapTableView(dataMapTableViewTarget, true, false);
MetadataTableEditorView metadataEditorView = getUiManager().getMetadataEditorView(dataMapTableViewTarget.getZone());
List<TransferableEntry> transferableEntryList = draggedData.getTransferableEntryList();
int currentIndex = startInsertAtThisIndex;
uiManager.clearLastCreatedInOutColumnEntries();
draggableTargetControl.deselectAll();
ITableEntry currentEntryTarget = getEntryFromPosition(cursorPosition);
ArrayList<String> columnsBeingAdded = new ArrayList<String>();
ArrayList<Integer> columnIndicesToSelect = new ArrayList<Integer>();
ArrayList<ITableEntry> sourceEntriesOfEntriesBeingAdded = new ArrayList<ITableEntry>();
ArrayList<IMetadataColumn> metadataColumnsBeingAdded = new ArrayList<IMetadataColumn>();
boolean targetTableIsFiltersTable = analyzer.targetTableIsFiltersTable();
boolean targetTableIsGlobalMapTable = analyzer.targetTableIsGlobalMapTable();
boolean atLeastOneEntryInserted = false;
boolean insertionEntryMode = analyzer.isInsertionEntryMode();
boolean mapEachSourceToNextTargets = analyzer.isMapOneToOneMode();
TableViewerCreator tableViewerCreatorTarget = null;
if (!analyzer.targetIsExpressionFilterText()) {
if (targetTableIsFiltersTable) {
tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForFilters();
} else if (targetTableIsGlobalMapTable) {
tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForGlobalMap();
} else {
tableViewerCreatorTarget = dataMapTableViewTarget.getTableViewerCreatorForColumns();
}
}
uiManager.applyActivatedCellEditors(tableViewerCreatorTarget);
// MapperDropCommand dropCommand = new MapperDropCommand();
// MetadataEditorEvent metadataEditorEvent = new MetadataEditorEvent(MetadataEditorEvent.TYPE.ADD);
ITableEntry lastEntryTarget = null;
for (TransferableEntry transferableEntry : transferableEntryList) {
ITableEntry tableEntrySource = transferableEntry.getTableEntrySource();
IMetadataColumn metadataColumnDragged = transferableEntry.getMetadataColumn();
Zone zoneSourceEntry = (Zone) transferableEntry.getZoneSourceEntry();
TableEntryLocation tableEntryLocationTarget = new TableEntryLocation(dataMapTableViewTarget.getDataMapTable().getName(), tableEntrySource.getName());
if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.INPUTS && tableEntrySource.getParentName().equals(tableEntryLocationTarget.tableName)) {
continue;
} else if (currentEntryTarget != null && !insertionEntryMode) {
// set the default operator.
if (currentEntryTarget instanceof InputColumnTableEntry) {
((InputColumnTableEntry) currentEntryTarget).setOperator(Operator.EQUALS.getLiteral());
}
boolean overwrite = (lastEntryTarget != currentEntryTarget && analyzer.isOverwriteExpression());
modifyExistingExpression(currentLanguage, currentEntryTarget, tableEntrySource, overwrite, zoneSourceEntry);
uiManager.parseExpression(currentEntryTarget.getExpression(), currentEntryTarget, false, true, true);
int indexOfEntry = tableViewerCreatorTarget.getInputList().indexOf(currentEntryTarget);
columnIndicesToSelect.add(indexOfEntry);
} else {
String columnName = transferableEntry.getTableEntrySource().getName();
tableEntryLocationTarget = getMapperManager().findUniqueLocation(tableEntryLocationTarget, dataMapTableViewTarget.getDataMapTable());
columnName = tableEntryLocationTarget.columnName;
if (currentEntryTarget == null && analyzer.isMapOneToOneMode()) {
currentIndex = tableViewerCreatorTarget.getInputList().size();
columnIndicesToSelect.add(currentIndex);
}
if (zoneSourceEntry == Zone.INPUTS && zoneTarget == Zone.VARS || zoneSourceEntry == Zone.VARS && zoneTarget == Zone.VARS) {
columnIndicesToSelect.add(currentIndex);
currentIndex = insertNewVarEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource, columnName);
atLeastOneEntryInserted = true;
} else if (zoneSourceEntry == Zone.VARS && zoneTarget == Zone.OUTPUTS) {
insertNewOutputEntryFromVarEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
tableEntrySource, columnName);
atLeastOneEntryInserted = true;
} else if (zoneSourceEntry == Zone.INPUTS && targetTableIsGlobalMapTable) {
insertNewGlobalMapEntryFromInputEntry(currentLanguage, dataMapTableViewTarget, currentIndex, tableEntrySource);
atLeastOneEntryInserted = true;
} else if (zoneSourceEntry == Zone.INPUTS && zoneTarget != Zone.VARS) {
insertNewInOutEntryFromInputEntry(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
tableEntrySource, metadataColumnDragged, columnName);
atLeastOneEntryInserted = true;
} else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
// nothing
} else if (zoneSourceEntry == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
insertOutpuEntryCopyToOtherOutput(sourceEntriesOfEntriesBeingAdded, metadataColumnsBeingAdded, // metadataEditorEvent,
tableEntrySource, metadataColumnDragged, columnName);
atLeastOneEntryInserted = true;
} else {
// throw new IllegalStateException("Drop case not found !");
}
columnsBeingAdded.add(columnName);
}
lastEntryTarget = currentEntryTarget;
if (mapEachSourceToNextTargets && currentEntryTarget != null) {
currentEntryTarget = getNextEntryTarget(currentEntryTarget, tableViewerCreatorTarget);
}
}
if (!atLeastOneEntryInserted) {
tableViewerCreatorTarget.getTableViewer().refresh();
} else {
updateExpressionsOfInsertedEntries(currentLanguage, metadataEditorView, currentIndex, sourceEntriesOfEntriesBeingAdded, targetTableIsFiltersTable, tableViewerCreatorTarget, // , metadataEditorEvent
metadataColumnsBeingAdded);
for (int i = currentIndex; i < currentIndex + sourceEntriesOfEntriesBeingAdded.size(); i++) {
columnIndicesToSelect.add(i);
}
}
if (zoneTarget == Zone.VARS) {
dataMapTableViewTarget.resizeAtExpandedSize();
}
if (targetTableIsGlobalMapTable) {
dataMapTableViewTarget.updateGridDataHeightForTableGlobalMap();
dataMapTableViewTarget.resizeAtExpandedSize();
}
uiManager.unselectAllEntriesOfAllTables();
uiManager.refreshBackground(true, false);
if (metadataEditorView != null && !targetTableIsFiltersTable) {
metadataEditorView.getTableViewerCreator().getTableViewer().refresh();
}
int[] selection = ArrayUtils.toPrimitive(columnIndicesToSelect.toArray(new Integer[0]));
tableViewerCreatorTarget.getSelectionHelper().setSelection(selection);
ISelection iselection = tableViewerCreatorTarget.getTableViewer().getSelection();
List<ITableEntry> selectedEntries = uiManager.extractSelectedTableEntries(iselection);
tableViewerCreatorTarget.getTable().deselectAll();
uiManager.unselectAllOutputMetaDataEntries();
uiManager.unselectAllInputMetaDataEntries();
uiManager.parseAllExpressionsForAllTables();
getMapperManager().getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
getMapperManager().getProblemsManager().checkLookupExpressionProblem();
uiManager.selectLinks(dataMapTableViewTarget, selectedEntries, true, false);
dataMapTableViewTarget.checkChangementsAfterEntryModifiedOrAdded(false);
tableViewerCreatorTarget.getTable().setFocus();
uiManager.setDragging(false);
}
Aggregations