use of org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter in project tdi-studio-se by Talend.
the class VarsDataMapTableView method initColumnsOfTableColumns.
@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.expression"));
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.VARS }, false);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {
public String get(VarTableEntry bean) {
return bean.getExpression();
}
public void set(VarTableEntry bean, String value) {
bean.setExpression(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
}
});
column.setModifiable(!mapperManager.componentIsReadOnly());
//$NON-NLS-1$
column.setDefaultInternalValue("");
if (codeLanguage == ECodeLanguage.JAVA) {
column.setWeight(40);
} else {
column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
}
if (codeLanguage == ECodeLanguage.JAVA) {
String[] arrayTalendTypes = new String[0];
try {
arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
arrayTalendTypes = this.talendTypeFilter.filter(arrayTalendTypes);
} catch (NoClassDefFoundError e) {
// shouln't be happend
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (ExceptionInInitializerError e) {
// shouln't be happend
// e.printStackTrace();
ExceptionHandler.process(e);
}
IBeanPropertyAccessors<VarTableEntry, Boolean> nullableAccessors = new IBeanPropertyAccessors<VarTableEntry, Boolean>() {
public Boolean get(VarTableEntry bean) {
return bean.isNullable() ? Boolean.TRUE : Boolean.FALSE;
}
public void set(VarTableEntry bean, Boolean value) {
bean.setNullable(value.booleanValue());
}
};
CellEditorValueAdapter comboValueAdapter = new JavaTypeComboValueAdapter(JavaTypesManager.getDefaultJavaType(), nullableAccessors, this.talendTypeFilter);
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.type"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {
public String get(VarTableEntry bean) {
return bean.getType();
}
public void set(VarTableEntry bean, String value) {
bean.setType(value);
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
});
column.setModifiable(!mapperManager.componentIsReadOnly());
column.setWeight(18);
column.setCellEditor(new ComboBoxCellEditor(tableViewerCreatorForColumns.getTable(), arrayTalendTypes), comboValueAdapter);
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle("Nullable");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, Boolean>() {
public Boolean get(VarTableEntry bean) {
return bean.isNullable();
}
public void set(VarTableEntry bean, Boolean value) {
bean.setNullable(value);
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
}
});
column.setModifiable(!mapperManager.componentIsReadOnly());
column.setWidth(WindowSystem.isWIN32() ? 12 : 20);
//$NON-NLS-1$
column.setDisplayedValue("");
column.setResizable(false);
CheckboxTableEditorContent checkboxTableEditorContent = new CheckboxTableEditorContent();
//$NON-NLS-1$
String nullable = Messages.getString("VarsDataMapTableView.nullable");
checkboxTableEditorContent.setToolTipText(nullable);
column.setTableEditorContent(checkboxTableEditorContent);
column.setToolTipHeader(nullable);
}
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.variable"));
column.setId(DataMapTableView.ID_NAME_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {
public String get(VarTableEntry bean) {
return bean.getName();
}
public void set(VarTableEntry bean, String value) {
bean.setName(value);
}
});
column.setModifiable(!mapperManager.componentIsReadOnly());
if (codeLanguage == ECodeLanguage.JAVA) {
column.setWeight(25);
} else {
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
}
final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreatorForColumns.getTable());
cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {
@Override
public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
if (state == CELL_EDITOR_STATE.APPLYING) {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreatorForColumns.getModifiedObjectInfo();
String originalValue = (String) modifiedObjectInfo.getOriginalPropertyBeanValue();
Object currentModifiedBean = modifiedObjectInfo.getCurrentModifiedBean();
mapperManager.getUiManager().processColumnNameChanged(originalValue.toString(), newValue.toString(), VarsDataMapTableView.this, (ITableEntry) currentModifiedBean);
}
}
@Override
public String validateValue(String newValue, int beanPosition) {
return ((VarsTable) getDataMapTable()).validateColumnName(newValue, beanPosition);
}
});
column.setCellEditor(cellEditor);
}
use of org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter in project tdi-studio-se by Talend.
the class AutoConversionTypesEditorView method configureTypeColumn.
private void configureTypeColumn(TableViewerCreator<AutoConversionType> tableViewerCreator, TableViewerCreatorColumn column) {
IBeanPropertyAccessors<AutoConversionType, Boolean> nullableAccessors = new IBeanPropertyAccessors<AutoConversionType, Boolean>() {
@Override
public Boolean get(AutoConversionType bean) {
return Boolean.TRUE;
}
@Override
public void set(AutoConversionType bean, Boolean value) {
return;
}
};
CellEditorValueAdapter comboValueAdapter = new JavaTypeComboValueAdapter(JavaTypesManager.getDefaultJavaType(), nullableAccessors);
String[] arrayTalendTypes = new String[0];
try {
arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
} catch (NoClassDefFoundError e) {
// shouln't be happend
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (ExceptionInInitializerError e) {
// shouln't be happend
// e.printStackTrace();
ExceptionHandler.process(e);
}
ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayTalendTypes, SWT.READ_ONLY);
CCombo typeCombo = (CCombo) typeComboEditor.getControl();
typeCombo.setEditable(false);
column.setCellEditor(typeComboEditor, comboValueAdapter);
}
Aggregations