use of org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableRemoveCommand in project tdi-studio-se by Talend.
the class OutputDataMapTableView method createFiltersColumns.
public void createFiltersColumns(final TableViewerCreator<FilterTableEntry> tableViewerCreatorForFilters) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForFilters);
//$NON-NLS-1$
column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.filterCondition"));
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
final ExtendedTextCellEditor expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForFilters, column, new Zone[] { Zone.INPUTS, Zone.VARS }, true);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<FilterTableEntry, String>() {
public String get(FilterTableEntry bean) {
return bean.getExpression();
}
public void set(FilterTableEntry bean, String value) {
bean.setExpression(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
}
});
column.setModifiable(true);
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWeight(99);
column.setMoveable(false);
column.setResizable(false);
// Column with remove button
column = new TableViewerCreatorColumn(tableViewerCreatorForFilters);
//$NON-NLS-1$
column.setTitle("");
//$NON-NLS-1$
column.setDefaultDisplayedValue("");
column.setWidth(16);
column.setMoveable(false);
column.setResizable(false);
ButtonPushImageTableEditorContent buttonImage = new ButtonPushImageTableEditorContent() {
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.tableviewer.tableeditor.ButtonImageTableEditorContent#selectionEvent(org.talend
* .commons.ui.swt.tableviewer.TableViewerCreatorColumn, java.lang.Object)
*/
@Override
protected void selectionEvent(TableViewerCreatorColumnNotModifiable column, Object bean) {
ExtendedTableRemoveCommand removeCommand = new ExtendedTableRemoveCommand(bean, extendedTableViewerForFilters.getExtendedTableModel());
mapperManager.removeTableEntry((ITableEntry) bean);
mapperManager.executeCommand(removeCommand);
tableViewerCreatorForFilters.getTableViewer().refresh();
List list = tableViewerCreatorForFilters.getInputList();
updateGridDataHeightForTableConstraints();
if (list != null && list.size() == 0) {
showTableConstraints(false);
} else {
showTableConstraints(true);
}
}
};
buttonImage.setImage(ImageProvider.getImage(EImage.MINUS_ICON));
column.setTableEditorContent(buttonImage);
}
use of org.talend.commons.ui.swt.advanced.dataeditor.commands.ExtendedTableRemoveCommand in project tdi-studio-se by Talend.
the class InputDataMapTableView method createGlobalMapColumns.
public void createGlobalMapColumns(final TableViewerCreator<GlobalMapEntry> tableViewerCreatorForGlobalMap) {
TableViewerCreatorColumn<GlobalMapEntry, String> column = new TableViewerCreatorColumn<GlobalMapEntry, String>(tableViewerCreatorForGlobalMap);
// column.setTitle(Messages.getString("InputDataMapTableView.columnTitle.globalMapVar")); //$NON-NLS-1$
//$NON-NLS-1$
column.setTitle("Expr.");
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
final ExtendedTextCellEditor expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForGlobalMap, column, new Zone[] { Zone.INPUTS }, false);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<GlobalMapEntry, String>() {
public String get(GlobalMapEntry bean) {
return bean.getExpression();
}
public void set(GlobalMapEntry bean, String value) {
bean.setExpression(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
}
});
column.setModifiable(true);
//$NON-NLS-1$
column.setDefaultInternalValue("");
column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
column.setMoveable(false);
column.setResizable(true);
column = new TableViewerCreatorColumn<GlobalMapEntry, String>(tableViewerCreatorForGlobalMap);
//$NON-NLS-1$
column.setTitle(Messages.getString("InputDataMapTableView.globalMapKey"));
column.setId(DataMapTableView.ID_NAME_COLUMN);
column.setModifiable(true);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<GlobalMapEntry, String>() {
public String get(GlobalMapEntry bean) {
return bean.getName();
}
public void set(GlobalMapEntry bean, String value) {
bean.setName(value);
}
});
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreatorForGlobalMap.getTable());
column.setCellEditor(cellEditor);
// Column with remove button
column = new TableViewerCreatorColumn(tableViewerCreatorForGlobalMap);
//$NON-NLS-1$
column.setTitle("");
//$NON-NLS-1$
column.setDefaultDisplayedValue("");
//$NON-NLS-1$
column.setToolTipHeader(Messages.getString("InputDataMapTableView.addNewGlobalMapVar.tooltip"));
column.setWeight(10);
column.setWidth(25);
column.setMoveable(false);
column.setResizable(true);
column.setImageHeader(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
column.setTableColumnSelectionListener(new DefaultHeaderColumnSelectionListener(column, tableViewerCreatorForGlobalMap) {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent arg0) {
if (!mapperManager.componentIsReadOnly()) {
getInputTable().addGlobalMapEntry(//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
new GlobalMapEntry(getInputTable(), "\"" + findUniqueName("myKey") + "\"", ""));
updateGridDataHeightForTableGlobalMap();
resizeAtExpandedSize();
}
}
});
ButtonPushImageTableEditorContent buttonImage = new ButtonPushImageTableEditorContent() {
/*
* (non-Javadoc)
*
* @see
* org.talend.commons.ui.swt.tableviewer.tableeditor.ButtonImageTableEditorContent#selectionEvent(org.talend
* .commons.ui.swt.tableviewer.TableViewerCreatorColumn, java.lang.Object)
*/
@Override
protected void selectionEvent(TableViewerCreatorColumnNotModifiable column, Object bean) {
ITableEntry tableEntry = (ITableEntry) bean;
if (!mapperManager.componentIsReadOnly()) {
boolean removeEntry = MessageDialog.openConfirm(getShell(), //$NON-NLS-1$
Messages.getString("InputDataMapTableView.removeGlobalMapVar.Title"), //$NON-NLS-1$
Messages.getString("InputDataMapTableView.removeGlobalMapVar.Message", tableEntry.getName()));
if (removeEntry) {
ExtendedTableRemoveCommand removeCommand = new ExtendedTableRemoveCommand(bean, extendedTableViewerForGlobalMap.getExtendedTableModel());
mapperManager.removeTableEntry((ITableEntry) bean);
mapperManager.executeCommand(removeCommand);
tableViewerCreatorForGlobalMap.getTableViewer().refresh();
List list = tableViewerCreatorForGlobalMap.getInputList();
updateGridDataHeightForTableGlobalMap();
resizeAtExpandedSize();
}
}
}
};
buttonImage.setImage(ImageProvider.getImage(EImage.MINUS_ICON));
column.setTableEditorContent(buttonImage);
}
Aggregations