use of org.talend.designer.abstractmap.model.tableentry.ITableEntry in project tdi-studio-se by Talend.
the class SearchZoneMapper method search.
public void search(Map<Integer, Map<Integer, ITableEntry>> searchMaps, String searchValue) {
if (searchValue.equals("")) {
uiManager.unselectAllEntriesOfAllTables();
return;
}
// SearchPattern
matcher.setPattern("*" + searchValue.trim() + "*");
List<InputTable> inputTables = mapperManager.getInputTables();
List<OutputTable> outputTables = mapperManager.getOutputTables();
int index = -1;
// for the InputTables
for (InputTable inputTable : inputTables) {
for (IColumnEntry column : inputTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
}
// for the OutputTables
for (OutputTable outputTable : outputTables) {
// OutputTable Filters
for (FilterTableEntry entry : outputTable.getWhereFilterEntries()) {
if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
map.put(0, entry);
index++;
searchMaps.put(index, map);
}
}
for (FilterTableEntry entry : outputTable.getOtherFilterEntries()) {
if (entry.getExpression() != null && matcher.matches(entry.getExpression())) {
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
map.put(0, entry);
index++;
searchMaps.put(index, map);
}
}
// OutputTable Columns
for (IColumnEntry column : outputTable.getColumnEntries()) {
int i = -1;
Map<Integer, ITableEntry> map = new HashMap<Integer, ITableEntry>();
boolean modified = false;
if (column.getExpression() != null && matcher.matches(column.getExpression())) {
i++;
map.put(i, column);
modified = true;
}
if (column.getName() != null && matcher.matches(column.getName())) {
i++;
map.put(i, column);
modified = true;
}
if (modified) {
index++;
searchMaps.put(index, map);
}
}
}
}
use of org.talend.designer.abstractmap.model.tableentry.ITableEntry 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.designer.abstractmap.model.tableentry.ITableEntry 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);
}
use of org.talend.designer.abstractmap.model.tableentry.ITableEntry in project tdi-studio-se by Talend.
the class VarsTable method checkValidColumnName.
/**
* Check if the given name will be unique in the process. If another link already exists with that name, false will
* be returned.
*
* @param uniqueName
* @return true if the name is unique
*/
public boolean checkValidColumnName(String connectionName) {
for (ITableEntry entry : dataMapTableEntries) {
if (entry.getName().equals(connectionName)) {
return false;
}
}
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern;
try {
//$NON-NLS-1$
pattern = compiler.compile("^[A-Za-z_][A-Za-z0-9_]*$");
if (!matcher.matches(connectionName, pattern)) {
return false;
}
} catch (MalformedPatternException e) {
throw new RuntimeException(e);
}
return true;
}
use of org.talend.designer.abstractmap.model.tableentry.ITableEntry in project tdi-studio-se by Talend.
the class CompleteDropTargetTableListener method insertNewGlobalMapEntryFromInputEntry.
private int insertNewGlobalMapEntryFromInputEntry(ILanguage currentLanguage, DataMapTableView dataMapTableViewTarget, int currentIndex, ITableEntry tableEntrySource) {
ITableEntry dataMapTableEntry;
dataMapTableEntry = getMapperManager().addNewGlobalMapEntry(dataMapTableViewTarget, tableEntrySource, currentIndex++);
String location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
//$NON-NLS-1$
dataMapTableEntry.setExpression(location + " ");
return currentIndex;
}
Aggregations