use of org.talend.designer.core.ui.editor.properties.controllers.uidialog.tns.TnsInfo in project tdi-studio-se by Talend.
the class TNSEditorController method createCommand.
public Command createCommand(Button button) {
IElementParameter elementParameter = this.curParameter.getElement().getElementParameter("TNS_FILE");
Command command = null;
if (elementParameter != null) {
String filePath = new Path(PathExtractor.extractPath(elementParameter.getValue().toString())).toOSString();
if (filePath != null && new File(filePath).exists()) {
boolean flag = false;
try {
TnsParser tnsparser = new TnsParser(new File(filePath));
if (tnsparser.getTree().getChildren().size() == 0) {
flag = true;
}
} catch (Exception e) {
flag = true;
}
if (flag) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(composite.getShell(), "WARNING", "this file is invalid,please recheck!");
}
});
} else {
TnsEditorDialog tnsDialog = new TnsEditorDialog(composite.getShell(), new File(filePath));
if (tnsDialog.open() == Window.OK) {
TnsInfo tnsInfo = tnsDialog.getTnsInfo();
command = new TnsPropertyCommand(tnsInfo, this.elem);
}
}
} else {
MessageBox mBox = new MessageBox(composite.getShell(), SWT.ICON_ERROR);
//$NON-NLS-1$
mBox.setText("Error");
//$NON-NLS-1$
mBox.setMessage("TNS File Not Found");
mBox.open();
}
}
return command;
}
Aggregations