use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE in project tdi-studio-se by Talend.
the class ExtractionLoopWithJSONXPathEditorView method createColumns.
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.advanced.macrotable.AbstractExtendedTableViewer#createColumns(org.talend.commons.ui
* .swt.tableviewer.TableViewerCreator, org.eclipse.swt.widgets.Table)
*/
@Override
protected void createColumns(TableViewerCreator<JSONXPathLoopDescriptor> tableViewerCreator, final Table table) {
CellEditorValueAdapter intValueAdapter = new CellEditorValueAdapter() {
@Override
public Object getOriginalTypedValue(final CellEditor cellEditor, Object value) {
try {
return new Integer(value.toString());
} catch (Exception ex) {
return null;
}
}
@Override
public Object getCellEditorTypedValue(final CellEditor cellEditor, Object value) {
if (value != null) {
return String.valueOf(value);
}
//$NON-NLS-1$
return "";
}
};
// //////////////////////////////////////////////////////////////////////////////////////
// column for mouse selection
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle("");
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWidth(15);
// //////////////////////////////////////////////////////////////////////////////////////
// X Path Query
column = new TableViewerCreatorColumn(tableViewerCreator);
xPathColumn = column;
column.setTitle("Absolute path expression");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<JSONXPathLoopDescriptor, String>() {
@Override
public String get(JSONXPathLoopDescriptor bean) {
return bean.getAbsoluteXPathQuery();
}
@Override
public void set(JSONXPathLoopDescriptor bean, String value) {
String currentFlag = ConvertJSONString.getCurrentFlag();
bean.setAbsoluteXPathQuery(value);
bean.setFlag(currentFlag);
}
});
xPathCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.NONE, column);
column.setCellEditor(xPathCellEditor);
xPathCellEditor.addListener(new DialogErrorForCellEditorListener(xPathCellEditor, column) {
@Override
public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
if (state == CELL_EDITOR_STATE.APPLYING) {
// linker.onXPathValueChanged(table, newValue.toString(), itemIndex);
}
}
@Override
public String validateValue(String newValue, int beanPosition) {
return linker.validateXPathExpression(newValue);
}
});
column.setModifiable(true);
column.setWeight(30);
column.setMinimumWidth(50);
//$NON-NLS-1$
column.setDefaultInternalValue("");
// //////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////
// Loop limit
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Loop limit");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<JSONXPathLoopDescriptor, Integer>() {
@Override
public Integer get(JSONXPathLoopDescriptor bean) {
return bean.getLimitBoucle();
}
@Override
public void set(JSONXPathLoopDescriptor bean, Integer value) {
if (value != null) {
bean.setLimitBoucle(value.intValue());
} else {
bean.setLimitBoucle(0);
}
}
});
column.setModifiable(true);
column.setWidth(59);
column.setCellEditor(new TextCellEditor(table), intValueAdapter);
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE in project tdi-studio-se by Talend.
the class AbstractHL7MetadataTableEditorView method configureNameColumn.
/**
* DOC amaumont Comment method "configureNameColumn".
*
* @param tableViewerCreator
*/
protected void configureNameColumn(TableViewerCreator<B> tableViewerCreator) {
TableViewerCreatorColumn column;
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setId(ID_COLUMN_NAME);
//$NON-NLS-1$
column.setTitle("User Column(Click to edit)");
//$NON-NLS-1$
column.setToolTipHeader(Messages.getString("MetadataTableEditorView.ColumnTitle"));
column.setBeanPropertyAccessors(getLabelAccessor());
final Image imageKey = ImageProvider.getImage(EImage.KEY_ICON);
final Image imageEmpty = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.EMPTY);
final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
column.setCellEditor(cellEditor);
cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {
@Override
public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
}
@Override
public String validateValue(String newValue, int beanPosition) {
return validateColumnName(newValue, beanPosition);
}
});
column.setImageProvider(new IColumnImageProvider() {
public Image getImage(Object element) {
if (getKeyAccesor().get((B) element)) {
return imageKey;
} else {
return imageEmpty;
}
}
});
column.setWeight(25);
column.setModifiable(!isReadOnly());
column.setMinimumWidth(45);
// final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
// cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {
//
// @Override
// public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state)
// {
// }
//
// @Override
// public String validateValue(String newValue, int beanPosition) {
// return validateColumnName(newValue, beanPosition);
// }
//
// });
// column.setCellEditor(cellEditor);
nameColumn = column;
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE in project tdi-studio-se by Talend.
the class XmlTreeSchemaTableView method createColumns.
@Override
protected void createColumns(final TableViewerCreator<TreeNode> tableViewerCreator, Table table) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("XPath");
column.setId(ID_COLUMN_XPATH);
column.setWeight(20);
column.setModifiable(true);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeNode, Object>() {
@Override
public Object get(TreeNode bean) {
return bean.getXpath();
}
@Override
public void set(TreeNode bean, Object value) {
if (isValidName) {
bean.setName((String) value);
// String xPath = bean.getXPath();
// xPath = xPath.substring(0, xPath.lastIndexOf(XmlMapUtil.XPATH_SEPARATOR) + 1);
// NodeType nodeType = bean.getTreeNode().getNodeType();
// String typedValue = null;
// if (NodeType.ATTRIBUT.equals(nodeType)) {
// typedValue = xPath + XmlMapUtil.XPATH_ATTRIBUTE + bean.getName();
// } else if (NodeType.NAME_SPACE.equals(nodeType)) {
// typedValue = xPath + XmlMapUtil.XPATH_NAMESPACE + bean.getName();
// } else {
// typedValue = xPath + bean.getName();
// }
// bean.setXPath(typedValue);
XmlMapData mapperData = XmlMapUtil.getXmlMapData(bean);
XmlMapExpressionManager expressionManager = new XmlMapExpressionManager();
XmlMapUtil.updateXPathAndExpression(mapperData, expressionManager, bean, bean.getName(), XmlMapUtil.getXPathLength(bean.getXpath()), true);
if (!bean.getChildren().isEmpty()) {
refresh();
}
}
}
});
final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {
@Override
public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
}
@Override
public String validateValue(String newValue, int beanPosition) {
return validateXPath(newValue, beanPosition);
}
});
column.setCellEditor(cellEditor);
column.setColumnCellModifier(new ColumnCellModifier(column) {
@Override
public Object getValue(Object bean) {
TreeNode entry = (TreeNode) bean;
return entry.getName();
}
@Override
public boolean modify(Object bean, Object value) {
return false;
}
});
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Key");
column.setToolTipHeader("Key");
column.setId(ID_COLUMN_KEY);
//$NON-NLS-1$
column.setDisplayedValue("");
column.setWeight(10);
column.setModifiable(true);
CheckboxTableEditorContent checkbox = new CheckboxTableEditorContent();
column.setTableEditorContent(checkbox);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeNode, Boolean>() {
@Override
public Boolean get(TreeNode bean) {
return bean.isKey();
}
@Override
public void set(TreeNode bean, Boolean value) {
bean.setKey(value);
}
});
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Type");
column.setToolTipHeader("Type");
column.setId(ID_COLUMN_TYPE);
column.setBeanPropertyAccessors(getTalendTypeAccessor());
column.setModifiable(true);
column.setWeight(20);
TreeSchemaJavaTypeComboValueAdapter comboValueAdapter = new TreeSchemaJavaTypeComboValueAdapter<TreeNode>(JavaTypesManager.getDefaultJavaType(), getNullableAccessor());
ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), comboValueAdapter.getTalendTypesLabels(), SWT.READ_ONLY);
CCombo typeCombo = (CCombo) typeComboEditor.getControl();
typeCombo.setEditable(false);
column.setCellEditor(typeComboEditor, comboValueAdapter);
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Nullable");
column.setToolTipHeader("Nullable");
column.setId(ID_COLUMN_NULLABLE);
column.setBeanPropertyAccessors(getNullableAccessor());
column.setWeight(20);
//$NON-NLS-1$
column.setDisplayedValue("");
column.setModifiable(true);
column.setTableColumnSelectionListener(new CheckColumnSelectionListener(column, tableViewerCreator));
column.setImageHeader(ImageProvider.getImage(EImage.CHECKED_ICON));
CheckboxTableEditorContent nullableCheckbox = new CheckboxTableEditorContent();
column.setTableEditorContent(nullableCheckbox);
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Pattern");
column.setId(ID_COLUMN_PATTERN);
column.setWeight(20);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeNode, String>() {
@Override
public String get(TreeNode bean) {
return bean.getPattern();
}
@Override
public void set(TreeNode bean, String value) {
bean.setPattern(value);
}
});
final ColumnCellModifier columnCellModifier = new ColumnCellModifier(column) {
@Override
public boolean canModify(Object bean) {
boolean typeIsDate = currentBeanHasJavaDateType(bean) && !isReadOnly();
return typeIsDate;
}
};
column.setColorProvider(new IColumnColorProvider() {
@Override
public Color getBackgroundColor(Object bean) {
if (!columnCellModifier.canModify(bean)) {
return READONLY_CELL_BG_COLOR;
}
return null;
}
@Override
public Color getForegroundColor(Object bean) {
return null;
}
});
column.setLabelProvider(new IColumnLabelProvider() {
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.swt.tableviewer.behavior.IColumnLabelProvider#getLabel(java.lang.Object)
*/
@Override
public String getLabel(Object bean) {
if (!currentBeanHasJavaDateType(bean)) {
//$NON-NLS-1$
return "";
}
return null;
}
});
column.setColumnCellModifier(columnCellModifier);
JavaSimpleDateFormatProposalProvider proposalProvider = new JavaSimpleDateFormatProposalProvider();
TextCellEditorWithProposal patternCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), column);
ContentProposalAdapterExtended contentProposalAdapter = patternCellEditor.getContentProposalAdapter();
contentProposalAdapter.setFilterStyle(ContentProposalAdapterExtended.FILTER_NONE);
contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapterExtended.PROPOSAL_INSERT);
patternCellEditor.setContentProposalProvider(proposalProvider);
column.setCellEditor(patternCellEditor, CellEditorValueAdapterFactory.getNullToEmptyStringTextAdapater());
tableViewerCreator.setCellModifier(new XmlCellModifier(tableViewerCreator));
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE 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.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE in project tdi-studio-se by Talend.
the class ExtractionFieldsWithJSONXPathEditorView method createColumns.
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.advanced.macrotable.AbstractExtendedTableViewer#createColumns(org.talend.commons.ui
* .swt.tableviewer.TableViewerCreator, org.eclipse.swt.widgets.Table)
*/
@Override
protected void createColumns(TableViewerCreator<SchemaTarget> tableViewerCreator, final Table table) {
CellEditorValueAdapter intValueAdapter = new CellEditorValueAdapter() {
@Override
public Object getOriginalTypedValue(final CellEditor cellEditor, Object value) {
try {
return new Integer(value.toString());
} catch (Exception ex) {
return null;
}
}
@Override
public Object getCellEditorTypedValue(final CellEditor cellEditor, Object value) {
if (value != null) {
return String.valueOf(value);
}
//$NON-NLS-1$
return "";
}
};
// //////////////////////////////////////////////////////////////////////////////////////
// column for mouse selection
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle("");
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWidth(15);
// //////////////////////////////////////////////////////////////////////////////////////
// X Path Query
column = new TableViewerCreatorColumn(tableViewerCreator);
xPathColumn = column;
//$NON-NLS-1$
column.setTitle("Relative or absolute path expression");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<SchemaTarget, String>() {
@Override
public String get(SchemaTarget bean) {
return bean.getRelativeXPathQuery();
}
@Override
public void set(SchemaTarget bean, String value) {
bean.setRelativeXPathQuery(value);
}
});
xPathCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.NONE, column);
column.setCellEditor(xPathCellEditor);
xPathCellEditor.addListener(new DialogErrorForCellEditorListener(xPathCellEditor, column) {
@Override
public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
if (state == CELL_EDITOR_STATE.EDITING) {
linker.onXPathValueChanged(table, newValue.toString(), itemIndex);
}
}
@Override
public String validateValue(String newValue, int beanPosition) {
String currentLoopXPath = linker.getCurrentLoopXPath();
String value = null;
if (newValue.trim().length() == 0) {
return null;
} else if (newValue.trim().startsWith(linker.getRootSeperator())) {
value = newValue;
} else {
value = currentLoopXPath + linker.getFieldSeperator() + newValue;
}
return linker.validateXPathExpression(value);
}
});
column.setModifiable(true);
column.setWeight(30);
column.setMinimumWidth(50);
//$NON-NLS-1$
column.setDefaultInternalValue("");
// //////////////////////////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////////////////////////
// Tag Name
column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle("Column Name");
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<SchemaTarget, String>() {
@Override
public String get(SchemaTarget bean) {
return bean.getTagName();
}
@Override
public void set(SchemaTarget bean, String value) {
bean.setTagName(value);
}
});
column.setModifiable(true);
column.setWeight(10);
column.setMinimumWidth(50);
// column.setCellEditor(new TextCellEditor(table));
//$NON-NLS-1$
column.setDefaultInternalValue("");
final TextCellEditorWithProposal tagNameCellEditor = createTagNameEditor(tableViewerCreator, column);
column.setCellEditor(tagNameCellEditor);
}
Aggregations