use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class WebServiceTableLiner method onXPathValueChanged.
public void onXPathValueChanged(Table sourceTable, Table targetTable, String oldValue, String newValue, String inComeName, int itemIndex) {
TableItem tabletraItem = targetTable.getItem(itemIndex);
boolean needAddLink = true;
TableItem[] items = sourceTable.getItems();
List<TableItem> itemList = new ArrayList<TableItem>();
for (int i = 0; i < items.length; i++) {
String columnLabel = null;
IMetadataColumn column = null;
ParameterInfo parame = null;
if (items[i].getData() instanceof IMetadataColumn) {
column = (IMetadataColumn) items[i].getData();
columnLabel = column.getLabel();
} else // }
if (items[i].getData() instanceof OutPutMappingData) {
parame = ((OutPutMappingData) items[i].getData()).getParameter();
if (!parame.getParameterInfos().isEmpty()) {
continue;
}
// columnLabel = parame.getName();
columnLabel = ((OutPutMappingData) items[i].getData()).getParameterName();
int m = columnLabel.lastIndexOf(".");
columnLabel = columnLabel.substring(m + 1);
}
if (newValue.contains(columnLabel)) {
// if (!pattern(columnLabel, newValue)) {
if (inComeName != null) {
WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
Map<String, String> itemNamemap = webParser.parseInTableEntryLocations(newValue);
Set<Entry<String, String>> set = itemNamemap.entrySet();
Iterator<Entry<String, String>> ite = set.iterator();
while (ite.hasNext()) {
Entry<String, String> entry = ite.next();
String columnValue = entry.getKey();
String rowValue = entry.getValue();
if (!isPatternWord(inComeName + "." + columnLabel, rowValue + "." + columnValue)) {
linksManager.removeLinksFromDataItem2(tabletraItem.getData());
if (tabletraItem.getData() instanceof InputMappingData) {
InputMappingData data = (InputMappingData) tabletraItem.getData();
List<IMetadataColumn> list = data.getMetadataColumnList();
if (column != null) {
list.remove(column);
}
}
needAddLink = false;
for (TableItem item : itemList) {
addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
}
getBackgroundRefresher().refreshBackground();
// return;
}
}
} else {
WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*\\w+(\\[\\d+?\\])?\\s*");
Set<String> set = webParser.parseOutTableEntryLocations(newValue);
Iterator<String> ite = set.iterator();
while (ite.hasNext()) {
String columnValue = ite.next();
// if (columnValue.equals(columnLabel)) {
if (!isPatternWord(columnLabel, columnValue)) {
linksManager.removeLinksFromDataItem2(tabletraItem.getData());
OutPutMappingData data = (OutPutMappingData) tabletraItem.getData();
if (parame != null) {
data.getParameterList().remove(parame);
}
needAddLink = false;
for (TableItem item : itemList) {
addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
}
getBackgroundRefresher().refreshBackground();
// return;
// }
}
}
}
if (true) {
// if (!mark) {
if (inComeName != null) {
WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
Map<String, String> itemNamemap = webParser.parseInTableEntryLocations(newValue);
Set<Entry<String, String>> set = itemNamemap.entrySet();
Iterator<Entry<String, String>> ite = set.iterator();
while (ite.hasNext()) {
Entry<String, String> entry = ite.next();
String columnValue = entry.getKey();
String rowValue = entry.getValue();
if (isPatternWord(inComeName + "." + columnLabel, rowValue + "." + columnValue)) {
itemList.add(items[i]);
addLinks(items[i], items[i].getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
getBackgroundRefresher().refreshBackground();
if (tabletraItem.getData() instanceof InputMappingData) {
InputMappingData data = (InputMappingData) tabletraItem.getData();
List<IMetadataColumn> list = data.getMetadataColumnList();
if (column != null && !list.contains(column)) {
list.add(column);
}
}
}
}
} else {
WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*\\w+(\\[\\d+?\\])?\\s*");
Set<String> set = webParser.parseOutTableEntryLocations(newValue);
Iterator<String> ite = set.iterator();
while (ite.hasNext()) {
String columnValue = ite.next();
if (isPatternWord(columnLabel, columnValue)) {
itemList.add(items[i]);
addLinks(items[i], items[i].getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
getBackgroundRefresher().refreshBackground();
}
}
}
}
} else if (oldValue.contains(columnLabel)) {
linksManager.removeLinksFromDataItem2(tabletraItem.getData());
if (tabletraItem.getData() instanceof InputMappingData) {
InputMappingData data = (InputMappingData) tabletraItem.getData();
List<IMetadataColumn> list = data.getMetadataColumnList();
if (column != null) {
list.remove(column);
}
} else if (tabletraItem.getData() instanceof OutPutMappingData) {
OutPutMappingData data = (OutPutMappingData) tabletraItem.getData();
if (parame != null) {
data.getParameterList().remove(parame);
}
}
for (TableItem item : itemList) {
if (inComeName != null) {
addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
} else {
addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
}
}
getBackgroundRefresher().refreshBackground();
}
}
// createFieldLinks(newValue, tableItem, null);
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class WebServiceTableLiner method addLinks.
public void addLinks(TableItem itemSource, Object data1, Table tableTarget, Object data2, String mark) {
LinkDescriptor<TableItem, Object, Table, Object> link = new LinkDescriptor<TableItem, Object, Table, Object>(new TableExtremityDescriptor(itemSource, data1), new ExtremityLink<Table, Object>(tableTarget, data2));
link.setStyleLink(createStandardLink(new Color(getBgDrawableComposite().getDisplay(), 255, 102, 102)));
getLinksManager().addLink(link);
if (mark.equals("INPUTMAPPING")) {
sourceInList.add(((IMetadataColumn) itemSource.getData()).getLabel());
} else if (mark.equals("OUTPUTMAPPING")) {
if (((OutPutMappingData) itemSource.getData()).getParameterName() != null) {
String sourseName = ((OutPutMappingData) itemSource.getData()).getParameterName();
// int m = sourseName.lastIndexOf(".");
// sourseName = sourseName.substring(m + 1);
sourceOutList.add(sourseName);
} else {
sourceOutList.add(((OutPutMappingData) itemSource.getData()).getParameter().getName());
}
}
}
use of org.eclipse.swt.widgets.TableItem in project tesb-studio-se by Talend.
the class XmlTableForm method addFieldsListeners.
private void addFieldsListeners() {
nameFilter.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String pattern = nameFilter.getText();
SearchPattern matcher = new SearchPattern();
matcher.setPattern(pattern);
final List<Item> newList = new ArrayList<Item>();
for (Item item : items) {
if (matcher.matches(item.getLabel())) {
newList.add(item);
}
}
reftesTableContent(newList);
completeListener.setComplete(!getSelectionItems().isEmpty());
}
});
// Event checkBox action
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (e.detail == SWT.CHECK) {
((Item) e.item.getData()).setCheck(((TableItem) e.item).getChecked());
if (null != completeListener) {
completeListener.setComplete(!getSelectionItems().isEmpty());
}
}
}
});
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
table.getColumns()[0].setWidth(table.getClientArea().width - 2 * table.getBorderWidth());
}
});
selectAllTablesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
setChecked(true);
}
});
selectNoneTablesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
setChecked(false);
}
});
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class DataSetTableKeyListener method keyPressed.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
*/
public void keyPressed(KeyEvent e) {
switch(e.character) {
case CTRL_C:
try {
Clipboard clipBoard = new Clipboard(Display.getCurrent());
TextTransfer textTransfer = TextTransfer.getInstance();
TableItem[] items = ptable.getSelection();
if (items == null || items.length == 0) {
return;
}
int columnIndex = pcursor.getColumn();
clipBoard.setContents(new Object[] { items[0].getText(columnIndex) }, new Transfer[] { textTransfer });
} catch (Exception ex) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DataSetTableKeyListener.logMessage1"), ex);
}
break;
case CTRL_F:
// column name typeahead
createPopup();
break;
default:
return;
}
}
use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.
the class SQLPatternComposite method createCodeControl.
/**
* DOC bqian Comment method "createCodeControl".
*
* @param panel
* @param
*/
private void createCodeControl(Composite panel, Control reference) {
codeText = new Text(panel, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
codeText.setEditable(false);
FormData fd = new FormData();
fd.left = new FormAttachment(10, 0);
fd.right = new FormAttachment(90, 0);
fd.top = new FormAttachment(reference, 2);
fd.bottom = new FormAttachment(95, 0);
codeText.setLayoutData(fd);
codeText.addMouseListener(new MouseListener() {
@Override
public void mouseUp(MouseEvent e) {
if (tableViewer.getTable().getSelection().length == 0) {
return;
}
TableItem item = tableViewer.getTable().getSelection()[0];
if (item == null || item.getText() == null) {
return;
}
String sqlpatternName = item.getText();
SQLPatternItem patternItem = SQLPatternUtils.getSQLPatternItem(SQLPatternComposite.this.element, sqlpatternName);
if (patternItem.isSystem()) {
boolean answer = //$NON-NLS-1$
MessageDialog.openQuestion(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.TOS"), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.forbidModification"));
if (!answer) {
return;
}
IRepositoryService repositoryService = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IElementParameter parameter = element.getElementParameter(EParameterName.SQLPATTERN_DB_NAME.getName());
String dbName = (String) parameter.getValue();
//$NON-NLS-1$
String path = dbName + "/" + RepositoryConstants.USER_DEFINED;
repositoryService.createSqlpattern(path, true);
} else if (sqlPatternAndProject.get(patternItem) != null) {
MessageDialog.openInformation(getShell(), "Information", "Forbid modification on sql template from reference project");
} else {
boolean answer = //$NON-NLS-1$
MessageDialog.openQuestion(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.TOS"), //$NON-NLS-1$
Messages.getString("SQLPatternComposite.modifySQLPattern"));
if (!answer) {
return;
}
IRepositoryService repositoryService = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
repositoryService.openSQLPatternEditor(patternItem, false);
}
}
@Override
public void mouseDown(MouseEvent e) {
// do nothing
}
@Override
public void mouseDoubleClick(MouseEvent e) {
mouseUp(e);
}
});
}
Aggregations