use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class MapperManager method addNewColumnEntry.
/**
* This method is called when "addMetadataTableEditorEntry" is called (event on list of MetadataEditor) , so if you
* want keep synchronisation between inputs/outputs DataMaps and MetadataEditors don't call this method.
*
* @param dataMapTableView
* @param metadataColumn, can be null if added in VarsTable
* @param index
*/
public IColumnEntry addNewColumnEntry(DataMapTableView dataMapTableView, IMetadataColumn metadataColumn, Integer index) {
IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
IColumnEntry dataMapTableEntry = null;
if (dataMapTableView.getZone() == Zone.INPUTS) {
dataMapTableEntry = new InputColumnTableEntry(abstractDataMapTable, metadataColumn);
} else if (dataMapTableView.getZone() == Zone.OUTPUTS) {
dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn);
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
}
tableEntriesManager.addTableEntry(dataMapTableEntry, index);
return dataMapTableEntry;
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class InputDataMapTableView method initColumnsOfTableColumns.
@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
TableViewerCreatorColumn column = null;
//$NON-NLS-1$
String useInJoinTitle = Messages.getString("InputDataMapTableView.columnTitle.ExplicitJoin");
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle(useInJoinTitle);
column.setId(ID_EXPLICIT_JOIN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, Boolean>() {
public Boolean get(InputColumnTableEntry bean) {
return bean.isJoin();
}
public void set(InputColumnTableEntry bean, Boolean value) {
bean.setJoin(value);
boolean enable = true;
if (dropDownItem != null && !dropDownItem.isDisposed()) {
enable = dropDownItem.isEnabled();
}
if (enable && value && mapperManager.getCurrentLanguage().unuseWithExplicitJoin().contains(getInputTable().getJoinType())) {
if (menu != null) {
MenuItem[] menuItems = menu.getItems();
for (MenuItem mi : menuItems) {
if (mi.getImage() == null) {
continue;
}
if (mi.getText().equals(getInputTable().getJoinType().getLabel())) {
mi.setImage(null);
}
}
menuItems[1].setImage(ImageProviderMapper.getImage(ImageInfo.CHECKED_ICON));
}
getInputTable().setJoinType(JOIN.INNER_JOIN);
refreshLabelForJoinDropDown();
mapperManager.getUiManager().refreshSqlExpression();
}
}
});
column.setModifiable(true);
// column.setWidth(12);
column.setWidth(65);
//$NON-NLS-1$
column.setDisplayedValue("");
// column.setResizable(false);
CheckboxTableEditorContent checkboxTableEditorContent = new CheckboxTableEditorContent();
checkboxTableEditorContent.setToolTipText(useInJoinTitle);
column.setTableEditorContent(checkboxTableEditorContent);
column.setToolTipHeader(useInJoinTitle);
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);
final TableViewerCreatorColumn columnOperator = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
columnOperator.setTitle(Messages.getString("InputDataMapTableView.columnTitle.Operator"));
columnOperator.setId(DataMapTableView.ID_OPERATOR);
//$NON-NLS-1$
columnOperator.setToolTipHeader(Messages.getString("InputDataMapTableView.Operator"));
columnOperator.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {
public String get(InputColumnTableEntry bean) {
return bean.getOperator();
}
public void set(InputColumnTableEntry bean, String value) {
bean.setOperator(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
}
});
columnOperator.setModifiable(true);
columnOperator.setWidth(85);
final IDbOperatorManager operatorsManager = mapperManager.getCurrentLanguage().getOperatorsManager();
IDbOperator[] operators = operatorsManager.getOperators();
String[] arrayOperators = new String[operators.length + 1];
//$NON-NLS-1$
arrayOperators[0] = "";
for (int i = 0; i < operators.length; i++) {
arrayOperators[i + 1] = operators[i].getOperator();
}
final ComboxCellEditorImproved typeComboEditor = new ComboxCellEditorImproved(tableViewerCreatorForColumns.getTable(), arrayOperators, SWT.NONE);
typeComboEditor.addListener(new ICellEditorListener() {
public void applyEditorValue() {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreatorForColumns.getModifiedObjectInfo();
InputColumnTableEntry currentInputEntry = (InputColumnTableEntry) modifiedObjectInfo.getCurrentModifiedBean();
currentInputEntry.setOriginalExpression(null);
Combo combo = (Combo) typeComboEditor.getControl();
String selectedText = combo.getText();
IDbOperator operatorFromValue = operatorsManager.getOperatorFromValue(selectedText);
if (operatorFromValue != null && operatorFromValue.isMonoOperand()) {
//$NON-NLS-1$
currentInputEntry.setExpression("");
}
}
public void cancelEditor() {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreatorForColumns.getModifiedObjectInfo();
InputColumnTableEntry currentInputEntry = (InputColumnTableEntry) modifiedObjectInfo.getCurrentModifiedBean();
// currentInputEntry.setExpression(currentInputEntry.getOriginalExpression());
}
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreatorForColumns.getModifiedObjectInfo();
InputColumnTableEntry currentInputEntry = (InputColumnTableEntry) modifiedObjectInfo.getCurrentModifiedBean();
if (modifiedObjectInfo.getCurrentModifiedColumn() == columnOperator) {
if (currentInputEntry != modifiedObjectInfo.getPreviousModifiedBean()) {
currentInputEntry.setOriginalExpression(currentInputEntry.getExpression());
}
Combo combo = (Combo) typeComboEditor.getControl();
String selectedText = combo.getText();
if (//$NON-NLS-1$
!selectedText.equals("") && (currentInputEntry.getExpression() == null || currentInputEntry.getExpression().trim().length() == 0)) {
IDbOperator operatorFromValue = operatorsManager.getOperatorFromValue(selectedText);
if (operatorFromValue.getAssociatedExpression() != null) {
currentInputEntry.setExpression(operatorFromValue.getAssociatedExpression());
}
}
}
}
});
Combo typeCombo = (Combo) typeComboEditor.getControl();
// typeCombo.setEditable(true);
columnOperator.setCellEditor(typeComboEditor, CellEditorValueAdapterFactory.getComboAdapterForComboCellEditorImproved());
columnOperator.setAlignment(ALIGNMENT.CENTER);
final TableViewerCreatorColumn columnExpression = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
columnExpression.setTitle(Messages.getString("InputDataMapTableView.columnTitle.Expr"));
columnExpression.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
columnExpression.setBeanPropertyAccessors(new IBeanPropertyAccessors<InputColumnTableEntry, String>() {
public String get(InputColumnTableEntry bean) {
return bean.getExpression();
}
public void set(InputColumnTableEntry bean, String value) {
bean.setExpression(value);
// mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
}
});
columnExpression.setModifiable(true);
//$NON-NLS-1$
columnExpression.setDefaultInternalValue("");
createExpressionCellEditor(tableViewerCreatorForColumns, columnExpression, new Zone[] { Zone.INPUTS }, false);
columnExpression.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
columnExpression.setColorProvider(new IColumnColorProvider() {
public Color getBackgroundColor(Object bean) {
if (!cellModifier.canModify(bean, columnExpression.getId())) {
return READONLY_CELL_BG_COLOR;
}
return null;
}
public Color getForegroundColor(Object bean) {
return null;
}
});
configureCellModifier(tableViewerCreatorForColumns);
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class EntryContentProposal method getDescription.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.fieldassist.IContentProposal#getDescription()
*/
public String getDescription() {
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
String separator = " - ";
if (entry instanceof InputColumnTableEntry) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
IMetadataColumn metadataColumn = inputEntry.getMetadataColumn();
//$NON-NLS-1$ //$NON-NLS-2$
sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(metadataColumn.getLabel()).append(//$NON-NLS-1$
"' ");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append(Messages.getString("EntryContentProposal.properties"));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(metadataColumn.getLabel());
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(metadataColumn.isKey());
if (!MapperMain.isStandAloneMode()) {
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(//$NON-NLS-1$
format(metadataColumn.getTalendType()));
}
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.dbType")).append(//$NON-NLS-1$
format(metadataColumn.getType()));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.length"));
if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) {
sb.append(format(metadataColumn.getLength()));
}
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.precision"));
if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) {
sb.append(format(metadataColumn.getPrecision()));
}
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
format(metadataColumn.getDefault()));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
format(metadataColumn.getComment()));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
} else if (entry instanceof VarTableEntry) {
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
}
return sb.toString();
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class DataMapTableView method parseExpressionIfNeeded.
/**
* DOC amaumont Comment method "parseExpression".
*
* @param event
* @param tableViewerCreator
* @param tableEntry
*/
protected void parseExpressionIfNeeded(ModifiedBeanEvent event, TableViewerCreator tableViewerCreator, ITableEntry tableEntry) {
if (ID_EXPRESSION_COLUMN.equals(event.column.getId())) {
mapperManager.getUiManager().parseExpression(tableEntry.getExpression(), tableEntry, false, false, false);
mapperManager.getUiManager().refreshBackground(false, false);
if (tableEntry instanceof InputColumnTableEntry) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) tableEntry;
if (inputEntry.getExpression() == null || inputEntry.getExpression().trim().length() == 0) {
//$NON-NLS-1$
inputEntry.setOperator("");
} else if (inputEntry.getOperator() == null || inputEntry.getOperator().trim().length() == 0) {
//$NON-NLS-1$
inputEntry.setOperator("=");
}
mapperManager.getProblemsManager().checkProblemsForTableEntry(tableEntry, true);
tableViewerCreator.getTableViewer().refresh(tableEntry);
}
}
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class TableEntriesManager method addInternal.
/**
* DOC amaumont Comment method "add".
*
* @param dataMapTableEntry
*/
private void addInternal(ITableEntry dataMapTableEntry) {
tableEntries.put(TableEntryLocation.getNewInstance(dataMapTableEntry), dataMapTableEntry);
IDataMapTable dataMapTable = dataMapTableEntry.getParent();
InputTable inputTable = isPhysicalTable(dataMapTable);
if (inputTable != null) {
IMetadataColumn metadataColumn = ((InputColumnTableEntry) dataMapTableEntry).getMetadataColumn();
addMetadataColumnFromDbTable(inputTable.getTableName(), metadataColumn.getLabel(), metadataColumn);
}
}
Aggregations