use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class TableController method updateConnectionList.
private void updateConnectionList(IElementParameter param) {
// update table values
TableViewerCreator tableViewerCreator = (TableViewerCreator) hashCurControls.get(param.getName());
Object[] itemsValue = param.getListItemsValue();
if (tableViewerCreator != 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.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class VarsDataMapTableView method createToolItems.
@Override
protected void createToolItems() {
// /////////////////////////////////////////////////////////////////
ToolItem addEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
addEntryItem.setEnabled(!getMapperManager().componentIsReadOnly());
//$NON-NLS-1$
addEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.addVariable"));
addEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
addEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
TableViewerCreator<IColumnEntry> tableViewerCreator = getExtendedTableViewerForColumns().getTableViewerCreator();
tableViewerCreator.applyActivatedCellEditor();
Table table = getExtendedTableViewerForColumns().getTable();
int[] indices = table.getSelectionIndices();
int indexInsert = table.getItemCount();
if (indices.length > 0) {
indexInsert = indices[indices.length - 1] + 1;
}
IDataMapTable dataMapTable = VarsDataMapTableView.this.getDataMapTable();
String varName = null;
if (dataMapTable instanceof VarsTable) {
//$NON-NLS-1$
varName = ((VarsTable) dataMapTable).findUniqueColumnName("var");
} else {
throw new UnsupportedOperationException(Messages.getString(//$NON-NLS-1$
"VarsDataMapTableView.exceptionMessage.caseNotFound"));
}
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
String type = null;
if (currentLanguage.getCodeLanguage() == ECodeLanguage.JAVA) {
type = JavaTypesManager.STRING.getId();
} else {
// fix bug 0018996 ,when add a var row,there is no default type,this bug exsit for long time
type = PerlTypesManager.STRING;
}
mapperManager.addNewVarEntry(VarsDataMapTableView.this, varName, indexInsert, type);
tableViewerCreatorForColumns.getTableViewer().refresh();
if (canBeResizedAtPreferedSize()) {
VarsDataMapTableView.this.changeSize(VarsDataMapTableView.this.getPreferredSize(true, true, false), true, true);
changeMinimizeState(false);
}
mapperManager.getUiManager().refreshBackground(true, false);
table.setSelection(indexInsert);
removeEntryItem.setEnabled(true);
moveUpEntryItem.setEnabled(true);
moveDownEntryItem.setEnabled(true);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
removeEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
removeEntryItem.setEnabled(false);
removeEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.MINUS_ICON)));
//$NON-NLS-1$
removeEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.removeVariable"));
removeEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) tableViewerCreatorForColumns.getTableViewer().getSelection();
List<ITableEntry> selectedBeans = selection.toList();
for (ITableEntry entry : selectedBeans) {
mapperManager.removeTableEntry(entry);
}
if (selectedBeans.size() > 0) {
tableViewerCreatorForColumns.getTableViewer().refresh();
mapperManager.getUiManager().refreshBackground(true, false);
if (canBeResizedAtPreferedSize()) {
resizeAtExpandedSize();
}
}
removeEntryItem.setEnabled(false);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
moveUpEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
moveUpEntryItem.setEnabled(false);
moveUpEntryItem.setImage(ImageProvider.getImage(EImage.UP_ICON));
//$NON-NLS-1$
moveUpEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.moveUpVariable"));
moveUpEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), true, viewer.getTableViewerCreator().getTable().getSelectionIndices());
viewer.getTableViewerCreator().applyActivatedCellEditor();
viewer.executeCommand(moveCommand);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
moveDownEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
moveDownEntryItem.setEnabled(false);
moveDownEntryItem.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
//$NON-NLS-1$
moveDownEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.movedownVariable"));
moveDownEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), false, viewer.getTableViewerCreator().getTable().getSelectionIndices());
viewer.getTableViewerCreator().applyActivatedCellEditor();
viewer.executeCommand(moveCommand);
}
});
// /////////////////////////////////////////////////////////////////
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator in project tdi-studio-se by Talend.
the class TabFolderEditors method addListenersToOutputButtons.
/**
* DOC amaumont Comment method "addListenersToInputButtons".
*/
private void addListenersToOutputButtons() {
MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
outputToolBarButtons = toolBar.getButtons();
beforeCommandListenerForOutputButtons = new IExtendedButtonListener() {
public void handleEvent(ExtendedButtonEvent event) {
TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
if (tableViewerCreator != null) {
tableViewerCreator.applyActivatedCellEditor();
}
}
};
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
}
}
if (removeButton != null) {
final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
public void handle(LineSelectionEvent e) {
for (TableItem item : tableViewerCreator.getTable().getSelection()) {
if (item.getData() instanceof MetadataColumn) {
MetadataColumn column = (MetadataColumn) item.getData();
removeButton.getButton().setEnabled(!column.isCustom());
break;
}
}
}
});
}
this.addDisposeListener(new DisposeListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
*/
public void widgetDisposed(DisposeEvent e) {
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
}
}
});
}
use of org.talend.commons.ui.swt.tableviewer.TableViewerCreator 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.swt.tableviewer.TableViewerCreator 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);
}
}
}
}
}
}
}
}
Aggregations