use of org.talend.designer.core.ui.editor.properties.ConfigureConnParamDialog in project tdi-studio-se by Talend.
the class OpenSQLBuilderDialogJob method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected IStatus run(IProgressMonitor monitor) {
loginProgress = new OpenSQLBuilderDialogProgress(connectionParameters, manager, composite);
Object obj = controller.getDynamicProperty().getPart();
Process p = null;
if (obj instanceof IMultiPageTalendEditor) {
p = (Process) ((IMultiPageTalendEditor) obj).getProcess();
} else {
//$NON-NLS-1$
throw new RuntimeException(Messages.getString("OpenSQLBuilderDialogJob.typeRequried"));
}
final Process process = p;
try {
loginProgress.run(monitor);
if (EDatabaseTypeName.ACCESS.getDisplayName().equals(connectionParameters.getDbType()) || connectionParameters.isStatus()) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Shell parentShell = new Shell(composite.getShell().getDisplay());
if (elem instanceof Node) {
TextUtil.setDialogTitle(process.getName(), (String) //$NON-NLS-1$
((Node) elem).getElementParameter("LABEL").getValue(), elem.getElementName());
} else {
TextUtil.setDialogTitle(process.getName(), null, null);
}
SQLBuilderDialog dial = new SQLBuilderDialog(parentShell);
UIUtils.addSqlBuilderDialog(process.getName(), dial);
dial.setConnParameters(connectionParameters);
if (Window.OK == dial.open()) {
if (!composite.isDisposed() && !connectionParameters.isNodeReadOnly()) {
if (EParameterFieldType.DBTABLE.equals(connectionParameters.getFieldType())) {
// final String selectDBTable = connectionParameters.getSelectDBTable();
// if (selectDBTable != null) {
// Command cmd = new PropertyChangeCommand(elem, propertyName, TalendTextUtils
// .addSQLQuotes(selectDBTable));
// commandStack.execute(cmd);
// }
} else {
String sql = connectionParameters.getQuery();
sql = QueryUtil.checkAndAddQuotes(sql);
PropertyChangeCommand cmd = new PropertyChangeCommand(elem, propertyName, sql);
cmd.setUpdate(true);
commandStack.execute(cmd);
}
}
}
}
});
} else {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
String pid = SqlBuilderPlugin.PLUGIN_ID;
//$NON-NLS-1$
String mainMsg = Messages.getString("ConnectionError.Message");
if (new ErrorDialogWithDetailAreaAndContinueButton(composite.getShell(), pid, mainMsg, connectionParameters.getConnectionComment()).getCodeOfButton() == Dialog.OK) {
ConfigureConnParamDialog paramDialog = new ConfigureConnParamDialog(composite.getShell(), connectionParameters, process.getContextManager(), elem);
if (paramDialog.open() == Window.OK) {
controller.openSqlBuilderBuildIn(connectionParameters, propertyName);
}
}
}
});
}
} catch (InterruptedException ie) {
loginProgress.cleanUp();
//$NON-NLS-1$
return new Status(IStatus.CANCEL, id, IStatus.CANCEL, "Progress.OpenSqlBuilderDialog.Cancelled", null);
} catch (Exception e) {
loginProgress.cleanUp();
//$NON-NLS-1$
return new Status(IStatus.ERROR, id, IStatus.CANCEL, "Progress.OpenSqlBuilderDialog.Error", e);
}
//$NON-NLS-1$
return new Status(IStatus.OK, id, IStatus.OK, "tested ok ", null);
}
Aggregations