use of org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable in project tdi-studio-se by Talend.
the class DataMapTableView method createTableForColumns.
/**
* DOC amaumont Comment method "createTableForColumns".
*
* @param parent
*/
private void createTableForColumns(Composite parent) {
this.extendedTableViewerForColumns = new AbstractExtendedTableViewer<IColumnEntry>(abstractDataMapTable.getTableColumnsEntriesModel(), parent) {
@Override
protected void createColumns(TableViewerCreator<IColumnEntry> tableViewerCreator, Table table) {
initColumnsOfTableColumns(tableViewerCreator);
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer#initTableListeners()
*/
@Override
protected void initTableListeners() {
super.initTableListeners();
getTableViewerCreator().addCellValueModifiedListener(new ITableCellValueModifiedListener() {
@Override
public void cellValueModified(TableCellValueModifiedEvent e) {
// System.out.println();
// System.out.println(getTable().hashCode());
// System.out.println(e.tableItem.getParent().hashCode());
// if (e.tableItem.getParent().isFocusControl()) {
// only if table of item is actually the focus control
getTableViewerCreator().getSelectionHelper().deselectAll();
getTable().forceFocus();
// }
}
});
}
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.extended.macrotable.AbstractExtendedTableViewer#setTableViewerCreatorOptions
* (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)
*/
@Override
protected void setTableViewerCreatorOptions(final TableViewerCreator<IColumnEntry> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setColumnsResizableByDefault(true);
newTableViewerCreator.setBorderVisible(false);
newTableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
newTableViewerCreator.setKeyboardManagementForCellEdition(false);
// tableViewerCreatorForColumns.setUseCustomItemColoring(this.getDataMapTable() instanceof
// AbstractInOutTable);
newTableViewerCreator.setFirstColumnMasked(true);
if (getDataMapTable() instanceof AbstractInOutTable) {
if (imageKey == null) {
imageKey = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.KEY_ICON);
}
if (imageEmpty == null) {
imageEmpty = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.EMPTY);
}
}
newTableViewerCreator.setLabelProvider(new DefaultTableLabelProvider(newTableViewerCreator) {
@Override
public Color getBackground(Object element, int columnIndex) {
Color backgroundCellColor = getBackgroundCellColor(newTableViewerCreator, element, columnIndex);
if (backgroundCellColor != null) {
return backgroundCellColor;
}
return super.getBackground(element, columnIndex);
}
@Override
public Color getForeground(Object element, int columnIndex) {
Color foregroundCellColor = getForegroundCellColor(newTableViewerCreator, element, columnIndex);
if (foregroundCellColor != null) {
return foregroundCellColor;
}
return getForegroundCellColor(newTableViewerCreator, element, columnIndex);
}
@Override
public Image getColumnImage(Object element, int columnIndex) {
return getColumnImageExecute(element, columnIndex);
}
/**
* DOC amaumont Comment method "getColumnImageExecute".
*
* @param element
* @param columnIndex
* @return
*/
private Image getColumnImageExecute(Object element, int columnIndex) {
if (getDataMapTable() instanceof AbstractInOutTable) {
AbstractInOutTableEntry entry = (AbstractInOutTableEntry) element;
TableViewerCreatorColumnNotModifiable column = newTableViewerCreator.getColumns().get(columnIndex);
if (column.getId().equals(ID_NAME_COLUMN)) {
if (entry.getMetadataColumn().isKey()) {
return imageKey;
} else {
return imageEmpty;
}
}
}
return null;
}
});
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.swt.extended.table.AbstractExtendedTableViewer#initModelListeners()
*/
@Override
protected void initModelListeners() {
super.initModelListeners();
getExtendedTableModel().addAfterOperationListListener(100, new IListenableListListener<IColumnEntry>() {
@Override
public void handleEvent(ListenableListEvent<IColumnEntry> event) {
if (tableViewerCreator.getTable() != null && !tableViewerCreator.getTable().isDisposed()) {
if (event.type == TYPE.ADDED) {
Collection<IColumnEntry> addedObjects = event.addedObjects;
for (IColumnEntry tableEntry : addedObjects) {
mapperManager.getProblemsManager().checkProblemsForTableEntry(tableEntry, false);
}
}
}
}
});
}
};
tableViewerCreatorForColumns = this.extendedTableViewerForColumns.getTableViewerCreator();
this.extendedTableViewerForColumns.setCommandStack(mapperManager.getCommandStack());
tableForEntries = tableViewerCreatorForColumns.getTable();
GridData tableEntriesGridData = new GridData(GridData.FILL_BOTH);
tableEntriesGridData.grabExcessVerticalSpace = true;
tableEntriesGridData.minimumHeight = tableForEntries.getHeaderHeight() + tableForEntries.getItemHeight();
// tableEntriesGridData.heightHint = 50;
// tableEntriesGridData.grabExcessVerticalSpace = false;
tableForEntries.setLayoutData(tableEntriesGridData);
addTablesListeners();
}
use of org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable in project tdi-studio-se by Talend.
the class MetadataTableEditorViewExt method updateHeader.
public void updateHeader(String id, String currTitle, boolean isHide) {
final TableViewerCreatorColumnNotModifiable funColumn = getTableViewerCreator().getColumn(id);
if (isHide) {
final TableEditorContentNotModifiable tableEditorContent = funColumn.getTableEditorContent();
if (tableEditorContent != null && tableEditorContent instanceof CheckboxTableEditorContent) {
funColumn.setTableEditorContent(null);
}
//$NON-NLS-1$
funColumn.getTableColumn().setText("");
funColumn.getTableColumn().setWidth(0);
funColumn.setWidth(0);
funColumn.getTableColumn().setResizable(false);
funColumn.setMoveable(false);
if ((id.equals(ID_COLUMN_FUNCTION) && getTableViewerCreator().getColumn(ID_COLUMN_PARAMETER).getTableColumn().getWidth() == 0) || ((id.equals(ID_COLUMN_PARAMETER)) && getTableViewerCreator().getColumn(ID_COLUMN_FUNCTION).getTableColumn().getWidth() == 0)) {
funCom.setVisible(false);
}
if (id.equals(ID_COLUMN_PREVIEW)) {
preCom.setVisible(false);
}
getTableViewerCreator().refreshTableEditorControls();
} else {
final TableEditorContentNotModifiable tableEditorContent = funColumn.getTableEditorContent();
if (tableEditorContent == null && (funColumn.getId().equals(ID_COLUMN_KEY) || funColumn.getId().equals(ID_COLUMN_NULLABLE))) {
final CheckboxTableEditorContent checkboxTableEditorContent = new CheckboxTableEditorContent();
checkboxTableEditorContent.setToolTipText(currTitle);
checkboxTableEditorContent.createTableEditor(getTable());
funColumn.setTableEditorContent(checkboxTableEditorContent);
}
funColumn.setModifiable(!isReadOnly());
funColumn.setMinimumWidth(35);
funColumn.getTableColumn().setWidth(65);
funColumn.getTableColumn().setText(currTitle);
funColumn.getTableColumn().setResizable(true);
funColumn.setTitle(currTitle);
funColumn.setMoveable(true);
if (id.equals(ID_COLUMN_FUNCTION) || id.equals(ID_COLUMN_PARAMETER)) {
funCom.setVisible(true);
}
if (id.equals(ID_COLUMN_PREVIEW)) {
preCom.setVisible(true);
}
getTableViewerCreator().refreshTableEditorControls();
}
attachLabelPosition();
}
use of org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable in project tdi-studio-se by Talend.
the class TableByRowController method updateConnectionList.
private void updateConnectionList(IElementParameter param) {
// update table values
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
Object[] itemsValue = param.getListItemsValue();
if (tableViewerCreator != null && itemsValue != null) {
List colList = tableViewerCreator.getColumns();
for (int j = 0; j < itemsValue.length; j++) {
if ((j + 1) >= colList.size()) {
break;
}
if (itemsValue[j] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[j];
if (tmpParam.getFieldType() == EParameterFieldType.CONNECTION_LIST) {
String[] contextParameterNames = null;
ConnectionListController.updateConnectionList(elem, tmpParam);
contextParameterNames = tmpParam.getListItemsDisplayName();
tmpParam.setListItemsDisplayCodeName(contextParameterNames);
// tmpParam.setListItemsValue(contextParameterNames);
if (contextParameterNames.length > 0) {
tmpParam.setDefaultClosedListValue(contextParameterNames[0]);
} else {
//$NON-NLS-1$
tmpParam.setDefaultClosedListValue("");
}
// j + 1 because first column is masked
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
CCombo combo = (CCombo) column.getCellEditor().getControl();
String[] oldItems = combo.getItems();
combo.setItems(contextParameterNames);
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
String[] items = param.getListItemsDisplayCodeName();
for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
Map<String, Object> currentLine = paramValues.get(currentIndex);
Object o = currentLine.get(items[j]);
if (o instanceof Integer) {
Integer nb = (Integer) o;
if ((nb >= oldItems.length) || (nb == -1)) {
nb = new Integer(tmpParam.getIndexOfItemFromList((String) tmpParam.getDefaultClosedListValue()));
currentLine.put(items[j], nb);
} else {
nb = new Integer(tmpParam.getIndexOfItemFromList(oldItems[nb]));
currentLine.put(items[j], nb);
}
}
}
}
}
}
}
}
use of org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable in project tdi-studio-se by Talend.
the class TableByRowController method updateColumnList.
private void updateColumnList(IElementParameter param) {
if (elem instanceof Node) {
ColumnListController.updateColumnList((Node) elem, null);
} else if (elem instanceof Connection) {
ColumnListController.updateColumnList(((Connection) elem).getSource(), null);
}
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
Object[] itemsValue = param.getListItemsValue();
if (tableViewerCreator != null && itemsValue != null) {
List colList = tableViewerCreator.getColumns();
for (int j = 0; j < itemsValue.length; j++) {
if (itemsValue[j] instanceof IElementParameter) {
IElementParameter tmpParam = (IElementParameter) itemsValue[j];
if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
if ((j + 1) >= colList.size()) {
break;
}
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) colList.get(j + 1);
CellEditor cellEditor = column.getCellEditor();
String[] oldItems = null;
if (cellEditor instanceof ComboBoxCellEditor) {
CCombo combo = (CCombo) cellEditor.getControl();
oldItems = combo.getItems();
combo.setItems(tmpParam.getListItemsDisplayName());
}
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) param.getValue();
String[] items = param.getListItemsDisplayCodeName();
for (int currentIndex = 0; currentIndex < paramValues.size(); currentIndex++) {
Map<String, Object> currentLine = paramValues.get(currentIndex);
Object o = currentLine.get(items[j]);
if (o instanceof Integer) {
Integer nb = (Integer) o;
if ((nb >= oldItems.length) || (nb == -1)) {
nb = new Integer(tmpParam.getIndexOfItemFromList((String) tmpParam.getDefaultClosedListValue()));
currentLine.put(items[j], nb);
} else {
nb = new Integer(tmpParam.getIndexOfItemFromList(oldItems[nb]));
currentLine.put(items[j], nb);
}
}
}
}
}
}
}
}
use of org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable in project tdi-studio-se by Talend.
the class DropContextAnalyzer method analyzeCursorOverExpressionCell.
/**
* .
*/
@SuppressWarnings("unchecked")
private void analyzeCursorOverExpressionCell() {
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentTableTarget);
TableViewerCreator tableViewerCreatorForColumns = dataMapTableView.getTableViewerCreatorForColumns();
Point pointCursor = currentTableTarget.toControl(event.x, event.y);
if (tableViewerCreatorForColumns.getTable() != currentTableTarget) {
isCursorOverExpressionCell = false;
return;
}
int maxY = (WindowSystem.isWIN32() && currentTableTarget.getHeaderVisible() ? currentTableTarget.getHeaderHeight() : 0) + (currentTableTarget.getItemCount() * (currentTableTarget.getItemHeight() + currentTableTarget.getBorderWidth() + (WindowSystem.isGTK() ? 2 : 0)));
if (pointCursor.y < 0 || pointCursor.y >= maxY) {
isCursorOverExpressionCell = false;
return;
}
// searching current column index
int currentColumnIndex = 0;
TableColumn[] columns = currentTableTarget.getColumns();
for (int i = 0, width = 0; i < columns.length; i++) {
TableColumn column = columns[i];
int widthColumn = column.getWidth();
if (pointCursor.x >= width && pointCursor.x <= width + widthColumn) {
currentColumnIndex = i;
break;
}
width += widthColumn;
}
List<TableViewerCreatorColumnNotModifiable> viewerColumns = tableViewerCreatorForColumns.getColumns();
TableViewerCreatorColumnNotModifiable viewerColumn = viewerColumns.get(currentColumnIndex);
if (DataMapTableView.ID_EXPRESSION_COLUMN.equals(viewerColumn.getId())) {
isCursorOverExpressionCell = true;
} else {
isCursorOverExpressionCell = false;
}
}
Aggregations