use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.
the class SetLoopFunctionDialog method createDialogArea.
public Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.BORDER);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(data);
tableViwer = new AbstractDataTableEditorView<TreeSchemaTableEntry>(composite, SWT.NONE, tableModel, false, true, false) {
@Override
protected void createColumns(TableViewerCreator<TreeSchemaTableEntry> tableViewerCreator, Table table) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Sequence");
column.setWeight(40);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeSchemaTableEntry, Object>() {
public Object get(TreeSchemaTableEntry bean) {
int index = getExtendedTableModel().getBeansList().indexOf(bean);
return getExtendedTableModel().getBeansList().indexOf(bean);
}
public void set(TreeSchemaTableEntry bean, Object value) {
// do nothing
}
});
column = new TableViewerCreatorColumn(tableViewerCreator);
column.setTitle("Xpath");
column.setWeight(60);
String[] items = new String[inputLoops.size()];
for (int i = 0; i < inputLoops.size(); i++) {
items[i] = inputLoops.get(i).getXpath();
}
CellEditorValueAdapter comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor("String");
ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), items, SWT.READ_ONLY);
column.setModifiable(true);
column.setCellEditor(cellEditor, comboValueAdapter);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<TreeSchemaTableEntry, Object>() {
public Object get(TreeSchemaTableEntry bean) {
return bean.getXPath();
}
public void set(TreeSchemaTableEntry bean, Object value) {
for (TreeNode loopNode : inputLoops) {
if (loopNode.getXpath().equals(value)) {
bean.setTreeNode(loopNode);
}
}
}
});
}
@Override
protected ExtendedToolbarView initToolBar() {
ExtendedToolbarView toolbarView = new ExtendedToolbarView(getMainComposite(), SWT.NONE, this.getExtendedTableViewer()) {
@Override
protected CopyPushButton createCopyPushButton() {
return null;
}
@Override
protected AddPushButton createAddPushButton() {
return new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
public boolean getEnabledState() {
return super.getEnabledState();
}
@Override
protected Object getObjectToAdd() {
TreeNode loopNodetoAdd = null;
for (TreeNode loopNode : inputLoops) {
boolean found = false;
for (TreeSchemaTableEntry extendedModel : getExtendedTableModel().getBeansList()) {
if (loopNode.getXpath().equals(extendedModel.getXPath())) {
found = true;
break;
}
}
if (!found) {
loopNodetoAdd = loopNode;
break;
}
}
if (loopNodetoAdd == null && !inputLoops.isEmpty()) {
loopNodetoAdd = inputLoops.get(0);
}
if (loopNodetoAdd != null) {
TreeSchemaTableEntry entry = new TreeSchemaTableEntry(loopNodetoAdd);
return entry;
}
return null;
}
};
}
};
return super.initToolBar();
}
};
tableViwer.setGridDataSize(400, 120);
statusLabel = new Label(composite, SWT.NONE);
statusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tableModel.addAfterOperationListListener(new IListenableListListener<TreeSchemaTableEntry>() {
public void handleEvent(ListenableListEvent<TreeSchemaTableEntry> event) {
updateStatus(true);
}
});
tableModel.setModifiedBeanListenable(tableViwer.getTableViewerCreator());
tableModel.addModifiedBeanListener(new IModifiedBeanListener<TreeSchemaTableEntry>() {
public void handleEvent(ModifiedBeanEvent<TreeSchemaTableEntry> event) {
updateStatus(false);
}
});
return composite;
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.
the class AutoConversionTypesEditorView method createSourceDataTypeColumn.
private TableViewerCreatorColumn createSourceDataTypeColumn(TableViewerCreator<AutoConversionType> tableViewerCreator) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("AutoConversionTypesEditor.table.column.sourceDataType"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<AutoConversionType, String>() {
@Override
public String get(AutoConversionType bean) {
return bean.getSourceDataType();
}
@Override
public void set(AutoConversionType bean, String value) {
bean.setSourceDataType(value);
}
});
column.setModifiable(true);
column.setWeight(30);
column.setMinimumWidth(50);
configureTypeColumn(tableViewerCreator, column);
return column;
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.
the class AutoConversionTypesEditorView method createConversionFunctionColumn.
private TableViewerCreatorColumn createConversionFunctionColumn(TableViewerCreator<AutoConversionType> tableViewerCreator) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("AutoConversionTypesEditor.table.column.conversionFunction"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<AutoConversionType, String>() {
@Override
public String get(AutoConversionType bean) {
return bean.getConversionFunction();
}
@Override
public void set(AutoConversionType bean, String value) {
bean.setConversionFunction(value);
}
});
column.setModifiable(true);
column.setWeight(60);
column.setMinimumWidth(50);
//$NON-NLS-1$
column.setDefaultInternalValue("");
AutoConversionProposalProvider functionProposalProvider = new AutoConversionProposalProvider();
TextCellEditorWithProposal textCellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), column);
textCellEditor.setContentProposalProvider(functionProposalProvider);
column.setCellEditor(textCellEditor);
return column;
}
Aggregations