use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.
the class MergeOrderDialog method createDialogArea.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Composite tableComposite = new Composite(composite, SWT.None);
tableComposite.setLayout(new GridLayout());
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = WIDTH;
gridData.minimumWidth = WIDTH;
gridData.heightHint = HEIGHT;
gridData.minimumHeight = HEIGHT;
tableComposite.setLayoutData(gridData);
final TableViewerCreator tableViewerCreator = new TableViewerCreator(tableComposite);
tableViewerCreator.setBorderVisible(true);
tableViewerCreator.setCheckboxInFirstColumn(false);
tableViewerCreator.setColumnsResizableByDefault(true);
tableViewerCreator.setColumnsSortableByDefault(true);
tableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
Table table = tableViewerCreator.createTable();
table.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("MergeOrderDialog.Order"));
column.setModifiable(true);
column.setWidth(50);
//$NON-NLS-1$
column.setToolTipHeader(Messages.getString("MergeOrderDialog.CurrentOrderConnection"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {
public String get(Connection bean) {
return String.valueOf(connectionList.indexOf(bean) + 1);
}
public void set(Connection bean, String value) {
// bean.setName(value);
}
});
column = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
column.setTitle(Messages.getString("MergeOrderDialog.ConnectionName"));
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {
public String get(Connection bean) {
return getDisplayStr(bean);
}
public void set(Connection bean, String value) {
// bean.setName(value);
}
});
column.setModifiable(false);
column.setWidth(200);
tableViewerCreator.init(connectionList);
Composite buttonComposite = new Composite(composite, SWT.None);
buttonComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
Button moveUp = new Button(buttonComposite, SWT.PUSH);
//$NON-NLS-1$
moveUp.setToolTipText(Messages.getString("MergeOrderDialog.MoveUp"));
moveUp.setImage(ImageProvider.getImage(EImage.UP_ICON));
moveUp.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
Connection connection = (Connection) selection.getFirstElement();
int connId = connectionList.indexOf(connection);
if (connId > 0) {
Collections.swap(connectionList, connId - 1, connId);
tableViewerCreator.getTableViewer().refresh();
}
}
});
Button moveDown = new Button(buttonComposite, SWT.PUSH);
//$NON-NLS-1$
moveDown.setToolTipText(Messages.getString("MergeOrderDialog.MoveDown"));
moveDown.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
if (getMergeNode() != null && getMergeNode().isReadOnly()) {
moveUp.setEnabled(false);
moveDown.setEnabled(false);
}
final int nbConn = getConnectionQty();
moveDown.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
if (selection.size() > 0) {
Connection connection = (Connection) selection.getFirstElement();
int connId = connectionList.indexOf(connection);
if (connId < (nbConn - 1)) {
Collections.swap(connectionList, connId + 1, connId);
tableViewerCreator.getTableViewer().refresh();
}
}
}
});
return composite;
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.
the class OutputDataMapTableView method initColumnsOfTableColumns.
@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
@Override
public String get(OutputColumnTableEntry bean) {
return bean.getExpression();
}
@Override
public void set(OutputColumnTableEntry bean, String value) {
bean.setExpression(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
tableViewerCreatorForColumns.getTableViewer().refresh(bean);
}
});
column.setModifiable(true);
//$NON-NLS-1$
column.setDefaultInternalValue("");
createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.OUTPUTS }, false);
column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle(DataMapTableView.COLUMN_NAME);
column.setId(DataMapTableView.ID_NAME_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
@Override
public String get(OutputColumnTableEntry bean) {
return bean.getMetadataColumn().getLabel();
}
@Override
public void set(OutputColumnTableEntry bean, String value) {
bean.getMetadataColumn().setLabel(value);
}
});
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.
the class MetadataTableEditorViewExt method configurePreviewColumns.
/**
* qzhang Comment method "configurePreviewColumns".
*
* @param tableViewerCreator
*/
private void configurePreviewColumns(TableViewerCreator<IMetadataColumn> tableViewerCreator) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
column.setId(ID_COLUMN_PREVIEW);
//$NON-NLS-1$
column.setTitle(Messages.getString("RowGenTableEditor2.Preview.TitleText"));
column.setBeanPropertyAccessors(getPreviewAccessor());
column.setModifiable(false);
column.setWeight(10);
column.setMinimumWidth(110);
column.setWidth(120);
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.
the class MetadataTableEditorViewExt method configureFunctionColumns.
/**
* qzhang Comment method "configureFunctionColumns".
*
* @param tableViewerCreator
*/
private void configureFunctionColumns(TableViewerCreator<IMetadataColumn> tableViewerCreator) {
//$NON-NLS-1$
CellEditorValueAdapter comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor("String");
final TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
final ComboBoxCellEditor functComboBox = new ComboBoxCellEditor();
functComboBox.create(tableViewerCreator.getTable());
CCombo functCombo = (CCombo) functComboBox.getControl();
functCombo.setEditable(false);
column.setCellEditor(functComboBox, comboValueAdapter);
// if (functComboBox.getControl() instanceof CCombo) {
// final CCombo combo = (CCombo) functComboBox.getControl();
// combo.addSelectionListener(new SelectionAdapter() {
//
// /*
// * (non-Javadoc)
// *
// * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
// */
// @Override
// public void widgetSelected(SelectionEvent e) {
// if (getTable() != null) {
// generatorUI.updateFunParameter(getTable());
// }
// }
// });
// }
column.setId(ID_COLUMN_FUNCTION);
//$NON-NLS-1$
column.setTitle(Messages.getString("RowGenTableEditor2.Fuctions.TitleText"));
column.setBeanPropertyAccessors(getFunctionAccessor(functComboBox));
column.setModifiable(true);
column.setWeight(10);
column.setWidth(45);
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn 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);
}
Aggregations