use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator 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.TableViewerCreator in project tdi-studio-se by Talend.
the class DataMapTableView method addTablesListeners.
/**
* DOC amaumont Comment method "addTableForColumnsListeners".
*/
private void addTablesListeners() {
tableViewerCreatorForColumns.addCellValueModifiedListener(new ITableCellValueModifiedListener() {
@Override
public void cellValueModified(TableCellValueModifiedEvent e) {
unselectAllEntriesIfErrorDetected(e);
}
});
abstractDataMapTable.getTableColumnsEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {
@Override
public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
mapperManager.getUiManager().refreshSqlExpression();
}
});
final TableViewer tableViewerForEntries = tableViewerCreatorForColumns.getTableViewer();
tableViewerForEntries.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int[] selectionIndices = tableViewerForEntries.getTable().getSelectionIndices();
if (selectionIndices.length > 0) {
selectThisDataMapTableView();
onSelectedEntries(event.getSelection(), selectionIndices);
// bug 18414
MetadataTableEditorView metadataTableEditorView = null;
if (getZone() == Zone.INPUTS) {
metadataTableEditorView = mapperManager.getUiManager().getInputMetaEditorView();
} else if (getZone() == Zone.OUTPUTS) {
metadataTableEditorView = mapperManager.getUiManager().getOutputMetaEditorView();
}
if (metadataTableEditorView != null) {
metadataTableEditorView.getTableViewerCreator().refresh();
}
}
}
});
tableForEntries.addListener(SWT.DragDetect, new Listener() {
@Override
public void handleEvent(Event event) {
onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
}
});
tableViewerCreatorForColumns.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
@Override
public void handle(LineSelectionEvent e) {
if (forceExecuteSelectionEvent) {
forceExecuteSelectionEvent = false;
onSelectedEntries(tableViewerForEntries.getSelection(), tableViewerForEntries.getTable().getSelectionIndices());
}
}
});
tableForEntries.addListener(SWT.KeyDown, new Listener() {
@Override
public void handleEvent(Event event) {
processEnterKeyDown(tableViewerCreatorForColumns, event);
}
});
abstractDataMapTable.getTableColumnsEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<IColumnEntry>() {
@Override
public void handleEvent(ModifiedBeanEvent<IColumnEntry> event) {
TableViewerCreator tableViewerCreator = tableViewerCreatorForColumns;
ITableEntry tableEntry = event.bean;
parseExpressionIfNeeded(event, tableViewerCreator, tableEntry);
mapperManager.getUiManager().refreshSqlExpression();
}
});
if (abstractDataMapTable instanceof OutputTable) {
OutputTable outputTable = (OutputTable) abstractDataMapTable;
outputTable.getWhereTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {
@Override
public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
resizeAtExpandedSize();
mapperManager.getUiManager().refreshSqlExpression();
}
});
outputTable.getWhereTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {
@Override
public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
onOutputTableFiltersModified(event, extendedTableViewerForFilters);
mapperManager.getUiManager().refreshSqlExpression();
}
});
outputTable.getOtherTableFiltersEntriesModel().addAfterOperationListListener(new IListenableListListener<FilterTableEntry>() {
@Override
public void handleEvent(ListenableListEvent<FilterTableEntry> event) {
resizeAtExpandedSize();
mapperManager.getUiManager().refreshSqlExpression();
}
});
outputTable.getOtherTableFiltersEntriesModel().addModifiedBeanListener(new IModifiedBeanListener<FilterTableEntry>() {
@Override
public void handleEvent(ModifiedBeanEvent<FilterTableEntry> event) {
onOutputTableFiltersModified(event, entendedTableViewerForOtherClauses);
mapperManager.getUiManager().refreshSqlExpression();
}
});
}
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class DataMapTableView method onOutputTableFiltersModified.
protected void onOutputTableFiltersModified(ModifiedBeanEvent<FilterTableEntry> event, AbstractExtendedTableViewer<FilterTableEntry> _extendedTableViewerForFilters) {
TableViewerCreator tableViewerCreator = _extendedTableViewerForFilters.getTableViewerCreator();
ITableEntry tableEntry = event.bean;
parseExpressionIfNeeded(event, tableViewerCreator, tableEntry);
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class OutputDataMapTableView method initTableFilters.
/*
* (non-Javadoc)
*
* @see org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView#initTableConstraints()
*/
@Override
protected void initTableFilters(Composite parent) {
/**
* create whereFiltersTable
*/
// createFiltersTable(parent);
//$NON-NLS-1$
filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalWhereClauses");
extendedTableViewerForFilters = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getWhereTableFiltersEntriesModel(), parent) {
/*
* (non-Javadoc)
*
* @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
* getTableConstraintSize()
*/
@Override
protected int getTableConstraintSize() {
int retSize = 0;
if (abstractDataMapTable instanceof OutputTable) {
retSize = ((OutputTable) abstractDataMapTable).getWhereFilterEntries().size();
}
return retSize;
}
@Override
protected void setTextCellEditor(TextCellEditor textEditor) {
if (textEditor != null) {
whereConstraintExpressionTextEditor = (Text) textEditor.getControl();
}
}
};
// correct partially layout problem with GTK when cell editor value is applied
((ExtendedTableViewerForFilters) extendedTableViewerForFilters).createFiltersTable();
TableViewerCreator tableViewerCreatorForWhereClauses = extendedTableViewerForFilters.getTableViewerCreator();
tableViewerCreatorForWhereClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
List<FilterTableEntry> whereEntries = ((OutputTable) getDataMapTable()).getWhereFilterEntries();
tableViewerCreatorForWhereClauses.init(whereEntries);
/**
* create otherFiltersTable
*/
IComponent component = getMapperManager().getComponent().getComponent();
if (component != null && "tELTOracleMap".equals(component.getName())) {
//$NON-NLS-1$
//$NON-NLS-1$
filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses.oracle");
} else {
//$NON-NLS-1$
filterColumnLabel = Messages.getString("OutputDataMapTableView.columnTitle.AdditionalOtherClauses");
}
entendedTableViewerForOtherClauses = new ExtendedTableViewerForFilters(((OutputTable) abstractDataMapTable).getOtherTableFiltersEntriesModel(), parent) {
/*
* (non-Javadoc)
*
* @see org.talend.designer.dbmap.ui.visualmap.table.OutputDataMapTableView.ExtendedTableViewerForFilters#
* getTableConstraintSize()
*/
@Override
public int getTableConstraintSize() {
int retSize = 0;
if (abstractDataMapTable instanceof OutputTable) {
retSize = ((OutputTable) abstractDataMapTable).getOtherFilterEntries().size();
}
return retSize;
}
@Override
protected void setTextCellEditor(TextCellEditor textEditor) {
if (textEditor != null) {
otherConstraintExpressionTextEditor = (Text) textEditor.getControl();
}
}
};
((ExtendedTableViewerForFilters) entendedTableViewerForOtherClauses).createFiltersTable();
TableViewerCreator tableViewerCreatorForOtherClauses = entendedTableViewerForOtherClauses.getTableViewerCreator();
tableViewerCreatorForOtherClauses.setAdjustWidthValue(WindowSystem.isGTK() ? -20 : ADJUST_WIDTH_VALUE);
List<FilterTableEntry> otherEntries = ((OutputTable) getDataMapTable()).getOtherFilterEntries();
tableViewerCreatorForOtherClauses.init(otherEntries);
// updateGridDataHeightForTableConstraints(entendedTableViewerForOtherClauses.getTable());
updateGridDataHeightForTableConstraints();
if (WindowSystem.isGTK()) {
tableViewerCreatorForWhereClauses.layout();
entendedTableViewerForOtherClauses.getTableViewerCreator().layout();
}
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class MapperManager method retrieveTableViewerCreator.
public TableViewerCreator retrieveTableViewerCreator(ITableEntry dataMapTableEntry) {
DataMapTableView view = retrieveDataMapTableView(dataMapTableEntry);
TableViewerCreator tableViewerCreator = null;
if (view != null) {
if (dataMapTableEntry instanceof AbstractInOutTableEntry || dataMapTableEntry instanceof VarTableEntry) {
tableViewerCreator = view.getTableViewerCreatorForColumns();
} else if (dataMapTableEntry instanceof FilterTableEntry) {
tableViewerCreator = view.getTableViewerCreatorForFilters();
}
}
return tableViewerCreator;
}
Aggregations