use of org.eclipse.swt.events.ModifyListener 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.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class AddArrayIndexDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite createDialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.horizontalSpacing = 1;
layout.numColumns = 2;
createDialogArea.setLayout(layout);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
layoutData.horizontalSpan = 2;
arrayButton = new Button(createDialogArea, SWT.RADIO);
arrayButton.setText("Get all the list element.");
arrayButton.setLayoutData(layoutData);
arrayButton.setSelection(true);
arrayButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
text.setEnabled(false);
}
});
arrayToItemButton = new Button(createDialogArea, SWT.RADIO);
arrayToItemButton.setText("Get one element of the list.");
arrayToItemButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
text.setEnabled(true);
}
});
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 1;
text = new Text(createDialogArea, SWT.BORDER);
text.setLayoutData(data);
text.setEnabled(false);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
indexText = text.getText();
// String com = text.getText();
// int index = Integer.valueOf(com);
// if(index<0||index>arraySize){
//
// }
}
});
return createDialogArea;
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class TableEditorManager method createTextEditor.
public TableEditor createTextEditor(TableEditor editor, Table table, String displayText, TableItem item, int column, final IPropertySetter<String> accessor) {
if (editor == null) {
return createTextEditor(table, displayText, item, column, accessor);
}
final Text text = new Text(table, SWT.NONE);
if (displayText != null) {
text.setText(displayText);
}
// update model when ui input has changed
if (accessor != null) {
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
accessor.set(text.getText());
}
});
}
editor.setEditor(text, item, column);
return editor;
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class NameSpaceDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
super.createDialogArea(parent);
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(6, true));
//$NON-NLS-1$
nsValueLabel = new LabelledText(composite, "Namespace", 5);
nsValueLabel.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
nsValue = nsValueLabel.getText();
validateField();
}
});
prefixBtn = new Button(composite, SWT.CHECK | SWT.RIGHT);
prefixBtn.setText("Prefix");
prefixBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (prefixText != null) {
if (prefixBtn.getSelection()) {
prefixText.setVisible(true);
} else {
prefixText.setVisible(false);
prefixText.setText("");
}
validateField();
}
}
});
//$NON-NLS-1$
prefixText = new Text(composite, SWT.BORDER);
GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
gridData.horizontalSpan = 5;
prefixText.setLayoutData(gridData);
prefixText.setVisible(false);
prefixText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
prefixValue = prefixText.getText();
validateField();
}
});
if (currentNode != null) {
nsValueLabel.setText(currentNode.getDefaultValue());
String prefix = currentNode.getName();
if (prefix != null && !"".equals(prefix) && !XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX.equals(prefix)) {
prefixBtn.setSelection(true);
prefixText.setVisible(true);
prefixText.setText(prefix);
}
}
nsValue = nsValueLabel.getText();
if (prefixText.isVisible()) {
prefixValue = prefixText.getText();
}
return parent;
}
use of org.eclipse.swt.events.ModifyListener in project tdi-studio-se by Talend.
the class JSONFileStep1Form method addFieldsListeners.
/**
* Main Fields addControls.
*/
@Override
protected void addFieldsListeners() {
// fileFieldXsd : Event modifyText
// fileFieldXsd.addModifyListener(new ModifyListener() {
//
// public void modifyText(final ModifyEvent e) {
// getConnection().setXsdFilePath(fileFieldXsd.getText());
// treePopulator.populateTree(fileFieldXsd.getText(), treeNode);
// checkFieldsValue();
// }
// });
// fileFieldJSON.addSelectionListener(new SelectionListener() {
//
// public void widgetSelected(SelectionEvent event) {
// if (fileFieldJSON.getResult() == null) {
// return;
// }
// String text = fileFieldJSON.getText();
// if (isContextMode()) {
// ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(
// connectionItem.getConnection(), true);
// text = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, text));
// }
// // getConnection().setJSONFilePath(PathUtils.getPortablePath(JSONXsdFilePath.getText()));
// File file = new File(text);
// if (file.exists()) {
// if (file.exists()) {
// String tempxml = JSONUtil.changeJsonToXml(text);
// JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
// valid = treePopulator.populateTree(tempxml, treeNode);
// }
// // add for bug TDI-20432
// checkFieldsValue();
// }
//
// }
//
// public void widgetDefaultSelected(SelectionEvent e) {
//
// }
// });
readbyCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
EJsonReadbyMode eJsonReadbyMode = EJsonReadbyMode.getEJsonReadbyModeByDisplayName(readbyCombo.getText());
if (eJsonReadbyMode == null) {
eJsonReadbyMode = getDefaultJsonReadbyMode();
}
String readbyMode = eJsonReadbyMode.getValue();
JSONFileStep1Form.this.wizard.setReadbyMode(readbyMode);
String jsonPath = fileFieldJSON.getText();
String text = validateJsonFilePath(jsonPath);
if (text == null || text.isEmpty()) {
return;
}
String tempxml = null;
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
tempxml = text;
} else {
tempxml = JSONUtil.changeJsonToXml(text);
}
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
switchPopulator(readbyMode, tempxml);
}
});
// fileFieldJSON : Event modifyText
fileFieldJSON.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
String jsonPath = fileFieldJSON.getText();
String _jsonPath = jsonPath;
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(), connectionItem.getConnection().getContextName());
jsonPath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, jsonPath));
}
String text = validateJsonFilePath(jsonPath);
if (text == null || text.isEmpty()) {
return;
}
String tempxml = null;
String readbyMode = JSONFileStep1Form.this.wizard.getReadbyMode();
if (EJsonReadbyMode.JSONPATH.getValue().equals(readbyMode)) {
tempxml = text;
} else {
tempxml = JSONUtil.changeJsonToXml(text);
}
File file = new File(text);
if (!file.exists()) {
file = new File(JSONUtil.tempJSONXsdPath);
}
JSONFileStep1Form.this.wizard.setTempJsonPath(tempxml);
String limitString = commonNodesLimitation.getText();
try {
limit = Integer.valueOf(limitString);
labelLimitation.setToolTipText(MessageFormat.format(Messages.JSONLimitToolTip, limit));
} catch (Exception excpt) {
// nothing need to do
}
switchPopulator(readbyMode, tempxml);
// }
// add for bug TDI-20432
checkFieldsValue();
if (getConnection().getJSONFilePath() != null && !getConnection().getJSONFilePath().equals(text)) {
getConnection().getLoop().clear();
xsdPathChanged = true;
} else {
xsdPathChanged = false;
}
if (isContextMode()) {
jsonPath = _jsonPath;
}
if (Path.fromOSString(jsonPath).toFile().isFile()) {
getConnection().setJSONFilePath(PathUtils.getPortablePath(jsonPath));
} else {
getConnection().setJSONFilePath(jsonPath);
}
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
wizard.setTreeRootNode(treeNode);
BufferedReader in = null;
try {
Charset guessedCharset = CharsetToolkit.guessEncoding(file, 4096);
String str;
in = new BufferedReader(new InputStreamReader(new FileInputStream(file), guessedCharset.displayName()));
while ((str = in.readLine()) != null) {
if (str.contains("encoding")) {
//$NON-NLS-1$
//$NON-NLS-1$
String regex = "^<\\?JSON\\s*version=\\\"[^\\\"]*\\\"\\s*encoding=\\\"([^\\\"]*)\\\"\\?>$";
Perl5Compiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
Pattern pattern = null;
try {
pattern = compiler.compile(regex);
if (matcher.contains(str, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult != null) {
encoding = matchResult.group(1);
}
}
} catch (MalformedPatternException malE) {
ExceptionHandler.process(malE);
}
}
}
} catch (Exception ex) {
String fileStr = text;
String msgError = //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"JSON" + " \"" + fileStr.replace("\\\\", "\\") + //$NON-NLS-1$
"\"\n";
if (ex instanceof FileNotFoundException) {
msgError = msgError + "is not found";
} else if (ex instanceof EOFException) {
msgError = msgError + "have an incorrect character EOF";
} else if (ex instanceof IOException) {
msgError = msgError + "is locked by another soft";
} else {
msgError = msgError + "doesn't exist";
}
if (!isReadOnly()) {
updateStatus(IStatus.ERROR, msgError);
}
// ExceptionHandler.process(ex);
} finally {
try {
if (in != null) {
in.close();
}
} catch (Exception ex2) {
ExceptionHandler.process(ex2);
}
}
if (getConnection().getEncoding() == null || "".equals(getConnection().getEncoding())) {
//$NON-NLS-1$
getConnection().setEncoding(encoding);
if (encoding != null && !("").equals(encoding)) {
//$NON-NLS-1$
encodingCombo.setText(encoding);
} else {
//$NON-NLS-1$
encodingCombo.setText("UTF-8");
}
}
// if (tempJSONXsdPath != null && getConnection().getFileContent() != null
// && getConnection().getFileContent().length > 0 && !isModifing) {
// valid = treePopulator.populateTree(tempJSONXsdPath, treeNode);
// } else {
// valid = treePopulator.populateTree(text, treeNode);
// }
checkFieldsValue();
isModifing = true;
}
});
// Event encodingCombo
encodingCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
getConnection().setEncoding(encodingCombo.getText());
checkFieldsValue();
}
});
}
Aggregations