use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.
the class RepositoryWebService method ctrate.
public void ctrate() {
wsdlComposite = new Composite(uiParent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginWidth = 20;
layout.marginHeight = 20;
wsdlComposite.setLayout(layout);
wsdlComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
// WSDL URL
Composite wsdlUrlcomposite = new Composite(wsdlComposite, SWT.NONE);
GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
layoutData.verticalIndent = 2;
layoutData.verticalSpan = 1;
wsdlUrlcomposite.setLayoutData(layoutData);
layout = new GridLayout(4, false);
wsdlUrlcomposite.setLayout(layout);
wsdlField = new LabelledFileField(wsdlUrlcomposite, ExternalWebServiceUIProperties.FILE_LABEL, ExternalWebServiceUIProperties.FILE_EXTENSIONS, 1, SWT.BORDER) {
@Override
protected void setFileFieldValue(String result) {
if (result != null) {
getTextControl().setText(TalendTextUtils.addQuotes(PathUtils.getPortablePath(result)));
getDataFromNet();
isFirst = false;
}
}
};
wsdlField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
// TODO Auto-generated method stub
URLValue = wsdlField.getText();
connection.setWSDL(URLValue);
}
});
// add a listener for ctrl+space.
TalendProposalUtils.installOn(wsdlField.getTextControl(), connector.getProcess(), connector);
//$NON-NLS-1$
String wsdlUrl = (String) connector.getElementParameter("ENDPOINT").getValue();
if (wsdlUrl != null) {
wsdlField.setText(wsdlUrl);
}
refreshbut = new Button(wsdlUrlcomposite, SWT.PUSH | SWT.CENTER);
refreshbut.setImage(ImageProvider.getImage(EImage.REFRESH_ICON));
GridData butData = new GridData();
butData.verticalSpan = 1;
refreshbut.setLayoutData(butData);
// add port name UI
Composite wsdlPortcomposite = new Composite(wsdlComposite, SWT.NONE);
GridData portlayoutData = new GridData(GridData.FILL_HORIZONTAL);
portlayoutData.verticalIndent = 2;
portlayoutData.verticalSpan = 3;
wsdlPortcomposite.setLayoutData(portlayoutData);
layout = new GridLayout(2, false);
layout.verticalSpacing = 1;
wsdlPortcomposite.setLayout(layout);
portNameLabel = new Label(wsdlPortcomposite, SWT.NONE);
//$NON-NLS-1$
portNameLabel.setText(Messages.getString("WebServiceUI.Port"));
GridData portLabelGridData = new GridData();
portLabelGridData.verticalAlignment = SWT.TOP;
portNameLabel.setLayoutData(portLabelGridData);
Composite portTabComposite = new Composite(wsdlPortcomposite, SWT.BORDER);
portTabComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
portTabComposite.setLayout(new FillLayout());
//$NON-NLS-1$
ExtendedTableModel<PortNames> portModel = new ExtendedTableModel<PortNames>("PORTNAMELIST", allPortNames);
portListTableView = new AbstractDataTableEditorView<PortNames>(portTabComposite, SWT.NONE, portModel, false, true, false) {
@Override
protected void setTableViewerCreatorOptions(TableViewerCreator<PortNames> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setHeaderVisible(false);
newTableViewerCreator.setVerticalScroll(true);
newTableViewerCreator.setReadOnly(true);
}
@Override
protected void createColumns(TableViewerCreator<PortNames> tableViewerCreator, Table table) {
TableViewerCreatorColumn rowColumn = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
rowColumn.setTitle(Messages.getString("WebServiceUI.COLUMN"));
rowColumn.setBeanPropertyAccessors(new IBeanPropertyAccessors<PortNames, String>() {
public String get(PortNames bean) {
return bean.getPortName();
}
public void set(PortNames bean, String value) {
bean.setPortName(value);
}
});
rowColumn.setWeight(60);
rowColumn.setModifiable(true);
rowColumn.setMinimumWidth(60);
rowColumn.setCellEditor(new TextCellEditor(tableViewerCreator.getTable()));
}
};
// WSDL Operation
Composite wsdlOperationcomposite = new Composite(wsdlComposite, SWT.NONE);
GridData operationlayoutData = new GridData(GridData.FILL_BOTH);
operationlayoutData.verticalIndent = 2;
operationlayoutData.verticalSpan = 5;
wsdlOperationcomposite.setLayoutData(operationlayoutData);
layout = new GridLayout(2, false);
layout.verticalSpacing = 3;
wsdlOperationcomposite.setLayout(layout);
// wsdlOperationcomposite.setLayoutData(new GridData(GridData.FILL_BOTH));
operationLabel = new Label(wsdlOperationcomposite, SWT.NONE);
//$NON-NLS-1$
operationLabel.setText(Messages.getString("WebServiceUI.Operation"));
GridData opertionLabelGridData = new GridData();
opertionLabelGridData.verticalAlignment = SWT.TOP;
operationLabel.setLayoutData(opertionLabelGridData);
Composite tabComposite = new Composite(wsdlOperationcomposite, SWT.BORDER);
GridData tabGridData = new GridData(GridData.FILL_BOTH);
// tabGridData.verticalSpan = 3;
tabComposite.setLayoutData(tabGridData);
tabComposite.setLayout(new FillLayout());
//$NON-NLS-1$
ExtendedTableModel<Function> funModel = new ExtendedTableModel<Function>("FUNCTIONLIST", allfunList);
listTableView = new AbstractDataTableEditorView<Function>(tabComposite, SWT.NONE, funModel, false, true, false) {
@Override
protected void setTableViewerCreatorOptions(TableViewerCreator<Function> newTableViewerCreator) {
super.setTableViewerCreatorOptions(newTableViewerCreator);
newTableViewerCreator.setHeaderVisible(false);
newTableViewerCreator.setVerticalScroll(true);
newTableViewerCreator.setReadOnly(true);
}
@Override
protected void createColumns(TableViewerCreator<Function> tableViewerCreator, Table table) {
TableViewerCreatorColumn rowColumn = new TableViewerCreatorColumn(tableViewerCreator);
//$NON-NLS-1$
rowColumn.setTitle(Messages.getString("WebServiceUI.COLUMN"));
rowColumn.setBeanPropertyAccessors(new IBeanPropertyAccessors<Function, String>() {
public String get(Function bean) {
return bean.getName();
}
public void set(Function bean, String value) {
bean.setName(value);
}
});
rowColumn.setWeight(60);
rowColumn.setModifiable(true);
rowColumn.setMinimumWidth(60);
rowColumn.setCellEditor(new TextCellEditor(tableViewerCreator.getTable()));
}
};
addListenerForWSDLCom();
}
use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.
the class DropTargetListenerForWebService method drop.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
*/
public void drop(DropTargetEvent event) {
if (getTransfer().isSupportedType(event.currentDataType)) {
// boolean canRemove = true;
// Parameter pa = TableEntriesTransfer.getInstance().getParameter();
Table draggableTable = (Table) draggableControl;
Point point = new Point(event.x, event.y);
int selevIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTable, point);
if (selevIndex < 0) {
return;
}
TableItem tabitem = TableEntriesTransfer.getInstance().getTableItem();
if (tabitem == null) {
return;
}
ExtendedTableModel tabelModel = draggableControlView.getExtendedTableModel();
if (tabelModel.getBeansList().size() == 0 || tabelModel.getBeansList().size() == selevIndex) {
// }
return;
} else if (tabelModel.getBeansList().size() > 0) {
if (tabelModel.getBeansList().size() < selevIndex) {
return;
}
Object objData = tabelModel.getBeansList().get(selevIndex);
if (objData instanceof InputMappingData) {
InputMappingData inData = (InputMappingData) objData;
IMetadataColumn inputColumn = null;
if (tabitem.getData() instanceof IMetadataColumn) {
inputColumn = (IMetadataColumn) tabitem.getData();
List<IMetadataColumn> columnList = inData.getMetadataColumnList();
if (inData.getInputColumnValue() == null || "".equals(inData.getInputColumnValue())) {
inData.setInputColumnValue(connector.initInRoWName() + "." + inputColumn.getLabel());
columnList.add(inputColumn);
} else {
inData.setInputColumnValue(inData.getInputColumnValue() + " " + connector.initInRoWName() + "." + inputColumn.getLabel());
columnList.add(inputColumn);
}
}
tabelModel.remove(selevIndex);
tabelModel.add(inData, selevIndex);
} else if (objData instanceof OutPutMappingData) {
OutPutMappingData outData = (OutPutMappingData) objData;
if (tabitem.getData() instanceof ParameterInfo) {
ParameterInfo para = (ParameterInfo) tabitem.getData();
if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
if (para.getParent() != null) {
String name = new ParameterInfoUtil().getParentName(para);
outData.setParameterName(name);
} else {
outData.setParameterName(para.getName());
}
} else {
outData.setParameterName(outData.getParameterName() + " " + para.getName());
}
outData.getParameterList().add(para);
// outData.setParameter(para);
} else if (tabitem.getData() instanceof OutPutMappingData) {
if (((OutPutMappingData) tabitem.getData()).getParameter() instanceof ParameterInfo) {
ParameterInfo para = ((OutPutMappingData) tabitem.getData()).getParameter();
if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
if (para.getParent() != null) {
String name = "";
if (((OutPutMappingData) tabitem.getData()).getParameterName() != null) {
name = ((OutPutMappingData) tabitem.getData()).getParameterName();
} else {
name = new ParameterInfoUtil().getParentName(para);
}
outData.setParameterName(name);
} else {
outData.setParameterName(para.getName());
}
} else {
outData.setParameterName(outData.getParameterName() + " " + para.getName());
}
outData.getParameterList().add(para);
// outData.setParameter(para);
}
}
tabelModel.remove(selevIndex);
tabelModel.add(outData, selevIndex);
}
}
TableItem[] items = draggableTable.getSelection();
if (items.length <= 0) {
return;
}
TableItem itemTarget = items[0];
itemTarget.setChecked(true);
createLinks(itemTarget, tabitem, tabelModel.getName());
}
}
use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.
the class PropertiesTableToolbarEditorView method createPastePushButton.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createPastButton()
*/
@Override
public PastePushButton createPastePushButton() {
PastePushButton pastePushButton = new PastePushButtonForExtendedTable(toolbar, extendedTableViewer) {
@Override
public boolean getEnabledState() {
PropertiesTableEditorModel tableEditorModel = (PropertiesTableEditorModel) getExtendedTableViewer().getExtendedControlModel();
Object data = SimpleClipboard.getInstance().getData();
if (data == null || !(data instanceof List) || tableEditorModel.getElemParameter() == null || tableEditorModel.getElemParameter().getListItemsDisplayCodeName() == null) {
return false;
}
@SuppressWarnings("rawtypes") List dataList = (List) data;
boolean sameNumberOfParamAssSourceTable = true;
if (dataList.isEmpty() || !(dataList.get(0) instanceof HashMap)) {
// only accept data from another property (list of HashMap)
return false;
}
@SuppressWarnings("rawtypes") HashMap sourceMap = (HashMap) dataList.get(0);
int sourceColumnNumber = sourceMap.size();
Object[] sourceArray = sourceMap.keySet().toArray();
ArrayList<Object> sourceList = new ArrayList<Object>(Arrays.asList(sourceArray));
String[] listItemsDisplayCodeName = tableEditorModel.getElemParameter().getListItemsDisplayCodeName();
List<String> itemDisCodeNameList = null;
int colNum = 0;
if (listItemsDisplayCodeName != null) {
itemDisCodeNameList = Arrays.asList(listItemsDisplayCodeName);
colNum = listItemsDisplayCodeName.length;
}
ArrayList<String> list = new ArrayList<String>(itemDisCodeNameList);
list.removeAll(sourceList);
if (data != null) {
if (colNum <= sourceColumnNumber && list.size() == 0) {
sameNumberOfParamAssSourceTable = true;
} else {
sameNumberOfParamAssSourceTable = false;
}
}
return super.getEnabledState() && (model == null || !model.getElemParameter().isBasedOnSubjobStarts()) && sameNumberOfParamAssSourceTable;
}
@Override
protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, Integer indexWhereInsert) {
return new PropertyTablePasteCommand<Map<String, Object>>(extendedTableModel, indexWhereInsert);
}
};
// TDI-6568, after paste, fire change
pastePushButton.addListener(getPropertyChangeListener(), false);
return pastePushButton;
}
use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.
the class HL7MetadataEmfToolbarEditor method createPastePushButton.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createPastButton()
*/
@Override
public PastePushButton createPastePushButton() {
return new PastePushButtonForExtendedTable(toolbar, extendedTableViewer) {
@Override
protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, Integer indexWhereInsert) {
return new MetadataEmfPasteCommand(extendedTableModel, indexWhereInsert);
}
@Override
public boolean getEnabledState() {
// 13749
return super.getEnabledState() && !isRepository;
}
@Override
protected void afterCommandExecution(Command executedCommand) {
MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
String key = ((IModel) selectedObj).getDisplayName();
List<MetadataColumn> metadataColumnList = tableEditorModel.getMetadataColumnList();
Map<String, List<MetadataColumn>> schemaRelationMap = linker.getManager().getSchemaRelationMap();
if (schemaRelationMap != null) {
List<MetadataColumn> schemas = new ArrayList<MetadataColumn>();
schemas.addAll(metadataColumnList);
schemaRelationMap.put(key, schemas);
}
}
}
};
}
use of org.talend.commons.ui.swt.extended.table.ExtendedTableModel in project tdi-studio-se by Talend.
the class HL7MetadataEmfToolbarEditor method createImportPushButton.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createPastButton()
*/
@Override
public ImportPushButton createImportPushButton() {
return new ImportPushButtonForExtendedTable(toolbar, extendedTableViewer) {
@Override
protected Command getCommandToExecute(ExtendedTableModel extendedTableModel, File file) {
return new MetadataEmfImportXmlCommand(extendedTableModel, file);
}
@Override
public boolean getEnabledState() {
// 13749
return super.getEnabledState() && !isRepository;
}
@Override
protected void beforeCommandExecution() {
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
super.beforeCommandExecution();
} else {
MessageDialog.openError(HL7MetadataEmfToolbarEditor.this.getParentComposite().getShell(), "Can't import xml file", "Need to init a schema by choosing a file at first");
}
}
protected void afterCommandExecution(Command executedCommand) {
MetadataEmfTableEditor tableEditorModel = (MetadataEmfTableEditor) getExtendedTableViewer().getExtendedControlModel();
IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
Object selectedObj = selection.getFirstElement();
if (selectedObj != null) {
String key = ((IModel) selectedObj).getDisplayName();
for (MetadataColumn col : tableEditorModel.getMetadataColumnList()) {
linker.getManager().updateRelationMapping(key, col, true);
}
}
linker.getMainui().redrawLinkers();
linker.getBackgroundRefresher().refreshBackground();
}
};
}
Aggregations