Search in sources :

Example 1 with ConfigureConnParamDialog

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);
}
Also used : ErrorDialogWithDetailAreaAndContinueButton(org.talend.commons.ui.swt.dialogs.ErrorDialogWithDetailAreaAndContinueButton) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) IMultiPageTalendEditor(org.talend.designer.core.IMultiPageTalendEditor) Shell(org.eclipse.swt.widgets.Shell) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) ConfigureConnParamDialog(org.talend.designer.core.ui.editor.properties.ConfigureConnParamDialog) OpenSQLBuilderDialogProgress(org.talend.sqlbuilder.ui.progress.OpenSQLBuilderDialogProgress)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Shell (org.eclipse.swt.widgets.Shell)1 ErrorDialogWithDetailAreaAndContinueButton (org.talend.commons.ui.swt.dialogs.ErrorDialogWithDetailAreaAndContinueButton)1 IMultiPageTalendEditor (org.talend.designer.core.IMultiPageTalendEditor)1 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1 Process (org.talend.designer.core.ui.editor.process.Process)1 ConfigureConnParamDialog (org.talend.designer.core.ui.editor.properties.ConfigureConnParamDialog)1 OpenSQLBuilderDialogProgress (org.talend.sqlbuilder.ui.progress.OpenSQLBuilderDialogProgress)1