Search in sources :

Example 81 with TextVar

use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.

the class JobEntryWaitForFileDialog method open.

public JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
        }
    };
    changed = jobEntry.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobWaitForFile.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobWaitForFile.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    // Filename line
    wlFilename = new Label(shell, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobWaitForFile.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(wName, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);
    wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(wName, 0);
    wbFilename.setLayoutData(fdbFilename);
    wFilename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(wName, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);
    // Whenever something changes, set the tooltip to the expanded version:
    wFilename.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            wFilename.setToolTipText(jobMeta.environmentSubstitute(wFilename.getText()));
        }
    });
    wbFilename.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.OPEN);
            dialog.setFilterExtensions(new String[] { "*" });
            if (wFilename.getText() != null) {
                dialog.setFileName(jobMeta.environmentSubstitute(wFilename.getText()));
            }
            dialog.setFilterNames(FILETYPES);
            if (dialog.open() != null) {
                wFilename.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
        }
    });
    // Maximum timeout
    wlMaximumTimeout = new Label(shell, SWT.RIGHT);
    wlMaximumTimeout.setText(BaseMessages.getString(PKG, "JobWaitForFile.MaximumTimeout.Label"));
    props.setLook(wlMaximumTimeout);
    fdlMaximumTimeout = new FormData();
    fdlMaximumTimeout.left = new FormAttachment(0, 0);
    fdlMaximumTimeout.top = new FormAttachment(wFilename, margin);
    fdlMaximumTimeout.right = new FormAttachment(middle, -margin);
    wlMaximumTimeout.setLayoutData(fdlMaximumTimeout);
    wMaximumTimeout = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wMaximumTimeout);
    wMaximumTimeout.setToolTipText(BaseMessages.getString(PKG, "JobWaitForFile.MaximumTimeout.Tooltip"));
    wMaximumTimeout.addModifyListener(lsMod);
    fdMaximumTimeout = new FormData();
    fdMaximumTimeout.left = new FormAttachment(middle, 0);
    fdMaximumTimeout.top = new FormAttachment(wFilename, margin);
    fdMaximumTimeout.right = new FormAttachment(100, 0);
    wMaximumTimeout.setLayoutData(fdMaximumTimeout);
    // Cycle time
    wlCheckCycleTime = new Label(shell, SWT.RIGHT);
    wlCheckCycleTime.setText(BaseMessages.getString(PKG, "JobWaitForFile.CheckCycleTime.Label"));
    props.setLook(wlCheckCycleTime);
    fdlCheckCycleTime = new FormData();
    fdlCheckCycleTime.left = new FormAttachment(0, 0);
    fdlCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
    fdlCheckCycleTime.right = new FormAttachment(middle, -margin);
    wlCheckCycleTime.setLayoutData(fdlCheckCycleTime);
    wCheckCycleTime = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCheckCycleTime);
    wCheckCycleTime.setToolTipText(BaseMessages.getString(PKG, "JobWaitForFile.CheckCycleTime.Tooltip"));
    wCheckCycleTime.addModifyListener(lsMod);
    fdCheckCycleTime = new FormData();
    fdCheckCycleTime.left = new FormAttachment(middle, 0);
    fdCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
    fdCheckCycleTime.right = new FormAttachment(100, 0);
    wCheckCycleTime.setLayoutData(fdCheckCycleTime);
    // Success on timeout
    wlSuccesOnTimeout = new Label(shell, SWT.RIGHT);
    wlSuccesOnTimeout.setText(BaseMessages.getString(PKG, "JobWaitForFile.SuccessOnTimeout.Label"));
    props.setLook(wlSuccesOnTimeout);
    fdlSuccesOnTimeout = new FormData();
    fdlSuccesOnTimeout.left = new FormAttachment(0, 0);
    fdlSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
    fdlSuccesOnTimeout.right = new FormAttachment(middle, -margin);
    wlSuccesOnTimeout.setLayoutData(fdlSuccesOnTimeout);
    wSuccesOnTimeout = new Button(shell, SWT.CHECK);
    props.setLook(wSuccesOnTimeout);
    wSuccesOnTimeout.setToolTipText(BaseMessages.getString(PKG, "JobWaitForFile.SuccessOnTimeout.Tooltip"));
    fdSuccesOnTimeout = new FormData();
    fdSuccesOnTimeout.left = new FormAttachment(middle, 0);
    fdSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
    fdSuccesOnTimeout.right = new FormAttachment(100, 0);
    wSuccesOnTimeout.setLayoutData(fdSuccesOnTimeout);
    wSuccesOnTimeout.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    // Check file size
    wlFileSizeCheck = new Label(shell, SWT.RIGHT);
    wlFileSizeCheck.setText(BaseMessages.getString(PKG, "JobWaitForFile.FileSizeCheck.Label"));
    props.setLook(wlFileSizeCheck);
    fdlFileSizeCheck = new FormData();
    fdlFileSizeCheck.left = new FormAttachment(0, 0);
    fdlFileSizeCheck.top = new FormAttachment(wSuccesOnTimeout, margin);
    fdlFileSizeCheck.right = new FormAttachment(middle, -margin);
    wlFileSizeCheck.setLayoutData(fdlFileSizeCheck);
    wFileSizeCheck = new Button(shell, SWT.CHECK);
    props.setLook(wFileSizeCheck);
    wFileSizeCheck.setToolTipText(BaseMessages.getString(PKG, "JobWaitForFile.FileSizeCheck.Tooltip"));
    fdFileSizeCheck = new FormData();
    fdFileSizeCheck.left = new FormAttachment(middle, 0);
    fdFileSizeCheck.top = new FormAttachment(wSuccesOnTimeout, margin);
    fdFileSizeCheck.right = new FormAttachment(100, 0);
    wFileSizeCheck.setLayoutData(fdFileSizeCheck);
    wFileSizeCheck.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    // Add filename to result filenames
    wlAddFilenameResult = new Label(shell, SWT.RIGHT);
    wlAddFilenameResult.setText(BaseMessages.getString(PKG, "JobWaitForFile.AddFilenameResult.Label"));
    props.setLook(wlAddFilenameResult);
    fdlAddFilenameResult = new FormData();
    fdlAddFilenameResult.left = new FormAttachment(0, 0);
    fdlAddFilenameResult.top = new FormAttachment(wFileSizeCheck, margin);
    fdlAddFilenameResult.right = new FormAttachment(middle, -margin);
    wlAddFilenameResult.setLayoutData(fdlAddFilenameResult);
    wAddFilenameResult = new Button(shell, SWT.CHECK);
    props.setLook(wAddFilenameResult);
    wAddFilenameResult.setToolTipText(BaseMessages.getString(PKG, "JobWaitForFile.AddFilenameResult.Tooltip"));
    fdAddFilenameResult = new FormData();
    fdAddFilenameResult.left = new FormAttachment(middle, 0);
    fdAddFilenameResult.top = new FormAttachment(wFileSizeCheck, margin);
    fdAddFilenameResult.right = new FormAttachment(100, 0);
    wAddFilenameResult.setLayoutData(fdAddFilenameResult);
    wAddFilenameResult.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wAddFilenameResult);
    // Add listeners
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wName.addSelectionListener(lsDef);
    wFilename.addSelectionListener(lsDef);
    wMaximumTimeout.addSelectionListener(lsDef);
    wCheckCycleTime.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    getData();
    BaseStepDialog.setSize(shell);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) Text(org.eclipse.swt.widgets.Text) TextVar(org.pentaho.di.ui.core.widget.TextVar) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 82 with TextVar

use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.

the class JobEntryWaitForSQLDialog method open.

public JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
        }
    };
    changed = jobEntry.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fd = new FormData();
    fd.right = new FormAttachment(50, -10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wOK.setLayoutData(fd);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fd = new FormData();
    fd.left = new FormAttachment(50, 10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wCancel.setLayoutData(fd);
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, null);
    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    // Connection line
    wConnection = addConnectionLine(shell, wName, middle, margin);
    if (jobEntry.getDatabase() == null && jobMeta.nrDatabases() == 1) {
        wConnection.select(0);
    }
    wConnection.addModifyListener(lsMod);
    // Schema name line
    wlSchemaname = new Label(shell, SWT.RIGHT);
    wlSchemaname.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Schemaname.Label"));
    props.setLook(wlSchemaname);
    fdlSchemaname = new FormData();
    fdlSchemaname.left = new FormAttachment(0, 0);
    fdlSchemaname.right = new FormAttachment(middle, 0);
    fdlSchemaname.top = new FormAttachment(wConnection, margin);
    wlSchemaname.setLayoutData(fdlSchemaname);
    wSchemaname = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSchemaname);
    wSchemaname.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Schemaname.Tooltip"));
    wSchemaname.addModifyListener(lsMod);
    fdSchemaname = new FormData();
    fdSchemaname.left = new FormAttachment(middle, 0);
    fdSchemaname.top = new FormAttachment(wConnection, margin);
    fdSchemaname.right = new FormAttachment(100, 0);
    wSchemaname.setLayoutData(fdSchemaname);
    // Table name line
    wlTablename = new Label(shell, SWT.RIGHT);
    wlTablename.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Tablename.Label"));
    props.setLook(wlTablename);
    fdlTablename = new FormData();
    fdlTablename.left = new FormAttachment(0, 0);
    fdlTablename.right = new FormAttachment(middle, 0);
    fdlTablename.top = new FormAttachment(wSchemaname, margin);
    wlTablename.setLayoutData(fdlTablename);
    wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbTable);
    wbTable.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    FormData fdbTable = new FormData();
    fdbTable.right = new FormAttachment(100, 0);
    fdbTable.top = new FormAttachment(wSchemaname, margin / 2);
    wbTable.setLayoutData(fdbTable);
    wbTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getTableName();
        }
    });
    wTablename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTablename);
    wTablename.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Tablename.Tooltip"));
    wTablename.addModifyListener(lsMod);
    fdTablename = new FormData();
    fdTablename.left = new FormAttachment(middle, 0);
    fdTablename.top = new FormAttachment(wSchemaname, margin);
    fdTablename.right = new FormAttachment(wbTable, -margin);
    wTablename.setLayoutData(fdTablename);
    // ////////////////////////
    // START OF Success GROUP///
    // ///////////////////////////////
    wSuccessGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wSuccessGroup);
    wSuccessGroup.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessGroup.Group.Label"));
    FormLayout SuccessGroupLayout = new FormLayout();
    SuccessGroupLayout.marginWidth = 10;
    SuccessGroupLayout.marginHeight = 10;
    wSuccessGroup.setLayout(SuccessGroupLayout);
    // Success Condition
    wlSuccessCondition = new Label(wSuccessGroup, SWT.RIGHT);
    wlSuccessCondition.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessCondition.Label"));
    props.setLook(wlSuccessCondition);
    fdlSuccessCondition = new FormData();
    fdlSuccessCondition.left = new FormAttachment(0, -margin);
    fdlSuccessCondition.right = new FormAttachment(middle, -2 * margin);
    fdlSuccessCondition.top = new FormAttachment(0, margin);
    wlSuccessCondition.setLayoutData(fdlSuccessCondition);
    wSuccessCondition = new CCombo(wSuccessGroup, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wSuccessCondition.setItems(JobEntryWaitForSQL.successConditionsDesc);
    // +1: starts at -1
    wSuccessCondition.select(0);
    props.setLook(wSuccessCondition);
    fdSuccessCondition = new FormData();
    fdSuccessCondition.left = new FormAttachment(middle, -margin);
    fdSuccessCondition.top = new FormAttachment(0, margin);
    fdSuccessCondition.right = new FormAttachment(100, 0);
    wSuccessCondition.setLayoutData(fdSuccessCondition);
    wSuccessCondition.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
        // activeSuccessCondition();
        }
    });
    // Success when number of errors less than
    wlRowsCountValue = new Label(wSuccessGroup, SWT.RIGHT);
    wlRowsCountValue.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.RowsCountValue.Label"));
    props.setLook(wlRowsCountValue);
    fdlRowsCountValue = new FormData();
    fdlRowsCountValue.left = new FormAttachment(0, -margin);
    fdlRowsCountValue.top = new FormAttachment(wSuccessCondition, margin);
    fdlRowsCountValue.right = new FormAttachment(middle, -2 * margin);
    wlRowsCountValue.setLayoutData(fdlRowsCountValue);
    wRowsCountValue = new TextVar(jobMeta, wSuccessGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobEntryWaitForSQL.RowsCountValue.Tooltip"));
    props.setLook(wRowsCountValue);
    wRowsCountValue.addModifyListener(lsMod);
    fdRowsCountValue = new FormData();
    fdRowsCountValue.left = new FormAttachment(middle, -margin);
    fdRowsCountValue.top = new FormAttachment(wSuccessCondition, margin);
    fdRowsCountValue.right = new FormAttachment(100, 0);
    wRowsCountValue.setLayoutData(fdRowsCountValue);
    // Maximum timeout
    wlMaximumTimeout = new Label(wSuccessGroup, SWT.RIGHT);
    wlMaximumTimeout.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.MaximumTimeout.Label"));
    props.setLook(wlMaximumTimeout);
    fdlMaximumTimeout = new FormData();
    fdlMaximumTimeout.left = new FormAttachment(0, -margin);
    fdlMaximumTimeout.top = new FormAttachment(wRowsCountValue, margin);
    fdlMaximumTimeout.right = new FormAttachment(middle, -2 * margin);
    wlMaximumTimeout.setLayoutData(fdlMaximumTimeout);
    wMaximumTimeout = new TextVar(jobMeta, wSuccessGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wMaximumTimeout);
    wMaximumTimeout.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.MaximumTimeout.Tooltip"));
    wMaximumTimeout.addModifyListener(lsMod);
    fdMaximumTimeout = new FormData();
    fdMaximumTimeout.left = new FormAttachment(middle, -margin);
    fdMaximumTimeout.top = new FormAttachment(wRowsCountValue, margin);
    fdMaximumTimeout.right = new FormAttachment(100, 0);
    wMaximumTimeout.setLayoutData(fdMaximumTimeout);
    // Cycle time
    wlCheckCycleTime = new Label(wSuccessGroup, SWT.RIGHT);
    wlCheckCycleTime.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.CheckCycleTime.Label"));
    props.setLook(wlCheckCycleTime);
    fdlCheckCycleTime = new FormData();
    fdlCheckCycleTime.left = new FormAttachment(0, -margin);
    fdlCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
    fdlCheckCycleTime.right = new FormAttachment(middle, -2 * margin);
    wlCheckCycleTime.setLayoutData(fdlCheckCycleTime);
    wCheckCycleTime = new TextVar(jobMeta, wSuccessGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCheckCycleTime);
    wCheckCycleTime.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.CheckCycleTime.Tooltip"));
    wCheckCycleTime.addModifyListener(lsMod);
    fdCheckCycleTime = new FormData();
    fdCheckCycleTime.left = new FormAttachment(middle, -margin);
    fdCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
    fdCheckCycleTime.right = new FormAttachment(100, 0);
    wCheckCycleTime.setLayoutData(fdCheckCycleTime);
    // Success on timeout
    wlSuccesOnTimeout = new Label(wSuccessGroup, SWT.RIGHT);
    wlSuccesOnTimeout.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessOnTimeout.Label"));
    props.setLook(wlSuccesOnTimeout);
    fdlSuccesOnTimeout = new FormData();
    fdlSuccesOnTimeout.left = new FormAttachment(0, -margin);
    fdlSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
    fdlSuccesOnTimeout.right = new FormAttachment(middle, -2 * margin);
    wlSuccesOnTimeout.setLayoutData(fdlSuccesOnTimeout);
    wSuccesOnTimeout = new Button(wSuccessGroup, SWT.CHECK);
    props.setLook(wSuccesOnTimeout);
    wSuccesOnTimeout.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessOnTimeout.Tooltip"));
    fdSuccesOnTimeout = new FormData();
    fdSuccesOnTimeout.left = new FormAttachment(middle, -margin);
    fdSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
    fdSuccesOnTimeout.right = new FormAttachment(100, -margin);
    wSuccesOnTimeout.setLayoutData(fdSuccesOnTimeout);
    wSuccesOnTimeout.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    fdSuccessGroup = new FormData();
    fdSuccessGroup.left = new FormAttachment(0, margin);
    fdSuccessGroup.top = new FormAttachment(wbTable, margin);
    fdSuccessGroup.right = new FormAttachment(100, -margin);
    wSuccessGroup.setLayoutData(fdSuccessGroup);
    // ///////////////////////////////////////////////////////////
    // / END OF SuccessGroup GROUP
    // ///////////////////////////////////////////////////////////
    // ////////////////////////
    // START OF Custom GROUP///
    // ///////////////////////////////
    wCustomGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wCustomGroup);
    wCustomGroup.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.CustomGroup.Group.Label"));
    FormLayout CustomGroupLayout = new FormLayout();
    CustomGroupLayout.marginWidth = 10;
    CustomGroupLayout.marginHeight = 10;
    wCustomGroup.setLayout(CustomGroupLayout);
    // custom SQL?
    wlcustomSQL = new Label(wCustomGroup, SWT.RIGHT);
    wlcustomSQL.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.customSQL.Label"));
    props.setLook(wlcustomSQL);
    fdlcustomSQL = new FormData();
    fdlcustomSQL.left = new FormAttachment(0, -margin);
    fdlcustomSQL.top = new FormAttachment(wSuccessGroup, margin);
    fdlcustomSQL.right = new FormAttachment(middle, -2 * margin);
    wlcustomSQL.setLayoutData(fdlcustomSQL);
    wcustomSQL = new Button(wCustomGroup, SWT.CHECK);
    props.setLook(wcustomSQL);
    wcustomSQL.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.customSQL.Tooltip"));
    fdcustomSQL = new FormData();
    fdcustomSQL.left = new FormAttachment(middle, -margin);
    fdcustomSQL.top = new FormAttachment(wSuccessGroup, margin);
    fdcustomSQL.right = new FormAttachment(100, 0);
    wcustomSQL.setLayoutData(fdcustomSQL);
    wcustomSQL.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            setCustomerSQL();
            jobEntry.setChanged();
        }
    });
    // use Variable substitution?
    wlUseSubs = new Label(wCustomGroup, SWT.RIGHT);
    wlUseSubs.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.UseVariableSubst.Label"));
    props.setLook(wlUseSubs);
    fdlUseSubs = new FormData();
    fdlUseSubs.left = new FormAttachment(0, -margin);
    fdlUseSubs.top = new FormAttachment(wcustomSQL, margin);
    fdlUseSubs.right = new FormAttachment(middle, -2 * margin);
    wlUseSubs.setLayoutData(fdlUseSubs);
    wUseSubs = new Button(wCustomGroup, SWT.CHECK);
    props.setLook(wUseSubs);
    wUseSubs.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.UseVariableSubst.Tooltip"));
    fdUseSubs = new FormData();
    fdUseSubs.left = new FormAttachment(middle, -margin);
    fdUseSubs.top = new FormAttachment(wcustomSQL, margin);
    fdUseSubs.right = new FormAttachment(100, 0);
    wUseSubs.setLayoutData(fdUseSubs);
    wUseSubs.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    // clear result rows ?
    wlClearResultList = new Label(wCustomGroup, SWT.RIGHT);
    wlClearResultList.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.ClearResultList.Label"));
    props.setLook(wlClearResultList);
    fdlClearResultList = new FormData();
    fdlClearResultList.left = new FormAttachment(0, -margin);
    fdlClearResultList.top = new FormAttachment(wUseSubs, margin);
    fdlClearResultList.right = new FormAttachment(middle, -2 * margin);
    wlClearResultList.setLayoutData(fdlClearResultList);
    wClearResultList = new Button(wCustomGroup, SWT.CHECK);
    props.setLook(wClearResultList);
    wClearResultList.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.ClearResultList.Tooltip"));
    fdClearResultList = new FormData();
    fdClearResultList.left = new FormAttachment(middle, -margin);
    fdClearResultList.top = new FormAttachment(wUseSubs, margin);
    fdClearResultList.right = new FormAttachment(100, 0);
    wClearResultList.setLayoutData(fdClearResultList);
    wClearResultList.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    // add rows to result?
    wlAddRowsToResult = new Label(wCustomGroup, SWT.RIGHT);
    wlAddRowsToResult.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.AddRowsToResult.Label"));
    props.setLook(wlAddRowsToResult);
    fdlAddRowsToResult = new FormData();
    fdlAddRowsToResult.left = new FormAttachment(0, -margin);
    fdlAddRowsToResult.top = new FormAttachment(wClearResultList, margin);
    fdlAddRowsToResult.right = new FormAttachment(middle, -2 * margin);
    wlAddRowsToResult.setLayoutData(fdlAddRowsToResult);
    wAddRowsToResult = new Button(wCustomGroup, SWT.CHECK);
    props.setLook(wAddRowsToResult);
    wAddRowsToResult.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.AddRowsToResult.Tooltip"));
    fdAddRowsToResult = new FormData();
    fdAddRowsToResult.left = new FormAttachment(middle, -margin);
    fdAddRowsToResult.top = new FormAttachment(wClearResultList, margin);
    fdAddRowsToResult.right = new FormAttachment(100, 0);
    wAddRowsToResult.setLayoutData(fdAddRowsToResult);
    wAddRowsToResult.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    wlPosition = new Label(wCustomGroup, SWT.NONE);
    props.setLook(wlPosition);
    fdlPosition = new FormData();
    fdlPosition.left = new FormAttachment(0, 0);
    fdlPosition.right = new FormAttachment(100, 0);
    // fdlPosition.top= new FormAttachment(wSQL , 0);
    fdlPosition.bottom = new FormAttachment(100, -margin);
    wlPosition.setLayoutData(fdlPosition);
    // Script line
    wlSQL = new Label(wCustomGroup, SWT.NONE);
    wlSQL.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Script.Label"));
    props.setLook(wlSQL);
    fdlSQL = new FormData();
    fdlSQL.left = new FormAttachment(0, 0);
    fdlSQL.top = new FormAttachment(wAddRowsToResult, margin);
    wlSQL.setLayoutData(fdlSQL);
    wbSQLTable = new Button(wCustomGroup, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSQLTable);
    wbSQLTable.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.GetSQLAndSelectStatement"));
    FormData fdbSQLTable = new FormData();
    fdbSQLTable.right = new FormAttachment(100, 0);
    fdbSQLTable.top = new FormAttachment(wAddRowsToResult, margin);
    wbSQLTable.setLayoutData(fdbSQLTable);
    wSQL = new StyledTextComp(jobEntry, wCustomGroup, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
    props.setLook(wSQL, Props.WIDGET_STYLE_FIXED);
    wSQL.addModifyListener(lsMod);
    fdSQL = new FormData();
    fdSQL.left = new FormAttachment(0, 0);
    fdSQL.top = new FormAttachment(wbSQLTable, margin);
    fdSQL.right = new FormAttachment(100, -10);
    fdSQL.bottom = new FormAttachment(wlPosition, -margin);
    wSQL.setLayoutData(fdSQL);
    wSQL.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent arg0) {
            setPosition();
        }
    });
    wSQL.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            setPosition();
        }

        public void keyReleased(KeyEvent e) {
            setPosition();
        }
    });
    wSQL.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent e) {
            setPosition();
        }

        public void focusLost(FocusEvent e) {
            setPosition();
        }
    });
    wSQL.addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent e) {
            setPosition();
        }

        public void mouseDown(MouseEvent e) {
            setPosition();
        }

        public void mouseUp(MouseEvent e) {
            setPosition();
        }
    });
    wSQL.addModifyListener(lsMod);
    // Text Higlighting
    wSQL.addLineStyleListener(new SQLValuesHighlight());
    fdCustomGroup = new FormData();
    fdCustomGroup.left = new FormAttachment(0, margin);
    fdCustomGroup.top = new FormAttachment(wSuccessGroup, margin);
    fdCustomGroup.right = new FormAttachment(100, -margin);
    fdCustomGroup.bottom = new FormAttachment(wOK, -margin);
    wCustomGroup.setLayoutData(fdCustomGroup);
    // ///////////////////////////////////////////////////////////
    // / END OF CustomGroup GROUP
    // ///////////////////////////////////////////////////////////
    // Add listeners
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    lsbSQLTable = new Listener() {

        public void handleEvent(Event e) {
            getSQL();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wbSQLTable.addListener(SWT.Selection, lsbSQLTable);
    wName.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    getData();
    setCustomerSQL();
    BaseStepDialog.setSize(shell);
    shell.open();
    props.setDialogSize(shell, "JobEntryWaitForSQLDialogSize");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) TextVar(org.pentaho.di.ui.core.widget.TextVar) CCombo(org.eclipse.swt.custom.CCombo) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SQLValuesHighlight(org.pentaho.di.ui.trans.steps.tableinput.SQLValuesHighlight) Display(org.eclipse.swt.widgets.Display)

Example 83 with TextVar

use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.

the class JobEntryWebServiceAvailableDialog method open.

public JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
        }
    };
    changed = jobEntry.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobEntryWebServiceAvailable.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobEntryWebServiceAvailable.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    // URL line
    wlURL = new Label(shell, SWT.RIGHT);
    wlURL.setText(BaseMessages.getString(PKG, "JobEntryWebServiceAvailable.URL.Label"));
    props.setLook(wlURL);
    fdlURL = new FormData();
    fdlURL.left = new FormAttachment(0, 0);
    fdlURL.top = new FormAttachment(wName, margin);
    fdlURL.right = new FormAttachment(middle, -margin);
    wlURL.setLayoutData(fdlURL);
    wURL = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wURL);
    wURL.addModifyListener(lsMod);
    fdURL = new FormData();
    fdURL.left = new FormAttachment(middle, 0);
    fdURL.top = new FormAttachment(wName, margin);
    fdURL.right = new FormAttachment(100, -margin);
    wURL.setLayoutData(fdURL);
    // Whenever something changes, set the tooltip to the expanded version:
    wURL.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            wURL.setToolTipText(jobMeta.environmentSubstitute(wURL.getText()));
        }
    });
    // connect timeout line
    wlConnectTimeOut = new Label(shell, SWT.RIGHT);
    wlConnectTimeOut.setText(BaseMessages.getString(PKG, "JobEntryWebServiceAvailable.ConnectTimeOut.Label"));
    props.setLook(wlConnectTimeOut);
    fdlConnectTimeOut = new FormData();
    fdlConnectTimeOut.left = new FormAttachment(0, 0);
    fdlConnectTimeOut.top = new FormAttachment(wURL, margin);
    fdlConnectTimeOut.right = new FormAttachment(middle, -margin);
    wlConnectTimeOut.setLayoutData(fdlConnectTimeOut);
    wConnectTimeOut = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wConnectTimeOut.setToolTipText(BaseMessages.getString(PKG, "JobEntryWebServiceAvailable.ConnectTimeOut.Tooltip"));
    props.setLook(wConnectTimeOut);
    wConnectTimeOut.addModifyListener(lsMod);
    fdConnectTimeOut = new FormData();
    fdConnectTimeOut.left = new FormAttachment(middle, 0);
    fdConnectTimeOut.top = new FormAttachment(wURL, margin);
    fdConnectTimeOut.right = new FormAttachment(100, -margin);
    wConnectTimeOut.setLayoutData(fdConnectTimeOut);
    // Whenever something changes, set the tooltip to the expanded version:
    wConnectTimeOut.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            wConnectTimeOut.setToolTipText(jobMeta.environmentSubstitute(wConnectTimeOut.getText()));
        }
    });
    // Read timeout line
    wlReadTimeOut = new Label(shell, SWT.RIGHT);
    wlReadTimeOut.setText(BaseMessages.getString(PKG, "JobEntryWebServiceAvailable.ReadTimeOut.Label"));
    props.setLook(wlReadTimeOut);
    fdlReadTimeOut = new FormData();
    fdlReadTimeOut.left = new FormAttachment(0, 0);
    fdlReadTimeOut.top = new FormAttachment(wConnectTimeOut, margin);
    fdlReadTimeOut.right = new FormAttachment(middle, -margin);
    wlReadTimeOut.setLayoutData(fdlReadTimeOut);
    wReadTimeOut = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wReadTimeOut.setToolTipText(BaseMessages.getString(PKG, "JobEntryWebServiceAvailable.ReadTimeOut.Tooltip"));
    props.setLook(wReadTimeOut);
    wReadTimeOut.addModifyListener(lsMod);
    fdReadTimeOut = new FormData();
    fdReadTimeOut.left = new FormAttachment(middle, 0);
    fdReadTimeOut.top = new FormAttachment(wConnectTimeOut, margin);
    fdReadTimeOut.right = new FormAttachment(100, -margin);
    wReadTimeOut.setLayoutData(fdReadTimeOut);
    // Whenever something changes, set the tooltip to the expanded version:
    wReadTimeOut.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            wReadTimeOut.setToolTipText(jobMeta.environmentSubstitute(wReadTimeOut.getText()));
        }
    });
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fd = new FormData();
    fd.right = new FormAttachment(50, -10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wOK.setLayoutData(fd);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fd = new FormData();
    fd.left = new FormAttachment(50, 10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wCancel.setLayoutData(fd);
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wReadTimeOut);
    // Add listeners
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wName.addSelectionListener(lsDef);
    wURL.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    getData();
    BaseStepDialog.setSize(shell);
    shell.open();
    props.setDialogSize(shell, "JobEntryWebServiceAvailableDialogSize");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) Text(org.eclipse.swt.widgets.Text) TextVar(org.pentaho.di.ui.core.widget.TextVar) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 84 with TextVar

use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.

the class JobEntryWriteToFileDialog method open.

public JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
        }
    };
    changed = jobEntry.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobWriteToFile.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobWriteToFile.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, null);
    // ////////////////////////
    // START OF File GROUP
    // ////////////////////////
    wFileGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wFileGroup);
    wFileGroup.setText(BaseMessages.getString(PKG, "JobWriteToFile.Group.File.Label"));
    FormLayout FileGroupLayout = new FormLayout();
    FileGroupLayout.marginWidth = 10;
    FileGroupLayout.marginHeight = 10;
    wFileGroup.setLayout(FileGroupLayout);
    // Filename line
    wlFilename = new Label(wFileGroup, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobWriteToFile.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(wName, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);
    wbFilename = new Button(wFileGroup, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(wName, 0);
    wbFilename.setLayoutData(fdbFilename);
    wFilename = new TextVar(jobMeta, wFileGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(wName, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);
    // Whenever something changes, set the tooltip to the expanded version:
    wFilename.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            wFilename.setToolTipText(jobMeta.environmentSubstitute(wFilename.getText()));
        }
    });
    wbFilename.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*" });
            if (wFilename.getText() != null) {
                dialog.setFileName(jobMeta.environmentSubstitute(wFilename.getText()));
            }
            dialog.setFilterNames(FILETYPES);
            if (dialog.open() != null) {
                wFilename.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
        }
    });
    wlCreateParentFolder = new Label(wFileGroup, SWT.RIGHT);
    wlCreateParentFolder.setText(BaseMessages.getString(PKG, "JobWriteToFile.CreateParentFolder.Label"));
    props.setLook(wlCreateParentFolder);
    fdlCreateParentFolder = new FormData();
    fdlCreateParentFolder.left = new FormAttachment(0, 0);
    fdlCreateParentFolder.top = new FormAttachment(wFilename, margin);
    fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
    wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
    wCreateParentFolder = new Button(wFileGroup, SWT.CHECK);
    props.setLook(wCreateParentFolder);
    wCreateParentFolder.setToolTipText(BaseMessages.getString(PKG, "JobWriteToFile.CreateParentFolder.Tooltip"));
    fdCreateParentFolder = new FormData();
    fdCreateParentFolder.left = new FormAttachment(middle, 0);
    fdCreateParentFolder.top = new FormAttachment(wFilename, margin);
    fdCreateParentFolder.right = new FormAttachment(100, 0);
    wCreateParentFolder.setLayoutData(fdCreateParentFolder);
    wCreateParentFolder.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    wlAppendFile = new Label(wFileGroup, SWT.RIGHT);
    wlAppendFile.setText(BaseMessages.getString(PKG, "JobWriteToFile.AppendFile.Label"));
    props.setLook(wlAppendFile);
    fdlAppendFile = new FormData();
    fdlAppendFile.left = new FormAttachment(0, 0);
    fdlAppendFile.top = new FormAttachment(wCreateParentFolder, margin);
    fdlAppendFile.right = new FormAttachment(middle, -margin);
    wlAppendFile.setLayoutData(fdlAppendFile);
    wAppendFile = new Button(wFileGroup, SWT.CHECK);
    props.setLook(wAppendFile);
    wAppendFile.setToolTipText(BaseMessages.getString(PKG, "JobWriteToFile.AppendFile.Tooltip"));
    fdAppendFile = new FormData();
    fdAppendFile.left = new FormAttachment(middle, 0);
    fdAppendFile.top = new FormAttachment(wCreateParentFolder, margin);
    fdAppendFile.right = new FormAttachment(100, 0);
    wAppendFile.setLayoutData(fdAppendFile);
    wAppendFile.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    fdFileGroup = new FormData();
    fdFileGroup.left = new FormAttachment(0, margin);
    fdFileGroup.top = new FormAttachment(wName, margin);
    fdFileGroup.right = new FormAttachment(100, -margin);
    wFileGroup.setLayoutData(fdFileGroup);
    // ///////////////////////////////////////////////////////////
    // / END OF File GROUP
    // ///////////////////////////////////////////////////////////
    // /////////////////////////
    // START OF Content GROUP
    // ////////////////////////
    wContentGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wContentGroup);
    wContentGroup.setText(BaseMessages.getString(PKG, "JobWriteToFile.Group.Content.Label"));
    FormLayout ContentGroupLayout = new FormLayout();
    ContentGroupLayout.marginWidth = 10;
    ContentGroupLayout.marginHeight = 10;
    wContentGroup.setLayout(ContentGroupLayout);
    // Encoding
    wlEncoding = new Label(wContentGroup, SWT.RIGHT);
    wlEncoding.setText(BaseMessages.getString(PKG, "JobWriteToFile.Encoding.Label"));
    props.setLook(wlEncoding);
    fdlEncoding = new FormData();
    fdlEncoding.left = new FormAttachment(0, -margin);
    fdlEncoding.top = new FormAttachment(wAppendFile, margin);
    fdlEncoding.right = new FormAttachment(middle, -margin);
    wlEncoding.setLayoutData(fdlEncoding);
    wEncoding = new ComboVar(jobMeta, wContentGroup, SWT.BORDER | SWT.READ_ONLY);
    wEncoding.setEditable(true);
    props.setLook(wEncoding);
    wEncoding.addModifyListener(lsMod);
    fdEncoding = new FormData();
    fdEncoding.left = new FormAttachment(middle, 0);
    fdEncoding.top = new FormAttachment(wAppendFile, margin);
    fdEncoding.right = new FormAttachment(100, 0);
    wEncoding.setLayoutData(fdEncoding);
    wEncoding.addFocusListener(new FocusListener() {

        public void focusLost(org.eclipse.swt.events.FocusEvent e) {
        }

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            setEncodings();
        }
    });
    wlContent = new Label(wContentGroup, SWT.RIGHT);
    wlContent.setText(BaseMessages.getString(PKG, "JobWriteToFile.Content.Label"));
    props.setLook(wlContent);
    fdlContent = new FormData();
    fdlContent.left = new FormAttachment(0, 0);
    fdlContent.top = new FormAttachment(wEncoding, margin);
    fdlContent.right = new FormAttachment(middle, -margin);
    wlContent.setLayoutData(fdlContent);
    wContent = new Text(wContentGroup, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    props.setLook(wContent, PropsUI.WIDGET_STYLE_FIXED);
    wContent.addModifyListener(lsMod);
    fdContent = new FormData();
    fdContent.left = new FormAttachment(middle, 0);
    fdContent.top = new FormAttachment(wEncoding, margin);
    fdContent.right = new FormAttachment(100, 0);
    fdContent.bottom = new FormAttachment(100, -margin);
    wContent.setLayoutData(fdContent);
    fdContentGroup = new FormData();
    fdContentGroup.left = new FormAttachment(0, margin);
    fdContentGroup.top = new FormAttachment(wFileGroup, margin);
    fdContentGroup.right = new FormAttachment(100, -margin);
    fdContentGroup.bottom = new FormAttachment(wOK, -margin);
    wContentGroup.setLayoutData(fdContentGroup);
    // ///////////////////////////////////////////////////////////
    // / END OF Content GROUP
    // ///////////////////////////////////////////////////////////
    // Add listeners
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wName.addSelectionListener(lsDef);
    wFilename.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    getData();
    BaseStepDialog.setSize(shell);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}
Also used : Group(org.eclipse.swt.widgets.Group) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) TextVar(org.pentaho.di.ui.core.widget.TextVar) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) FocusListener(org.eclipse.swt.events.FocusListener) Display(org.eclipse.swt.widgets.Display)

Example 85 with TextVar

use of org.pentaho.di.ui.core.widget.TextVar in project pentaho-kettle by pentaho.

the class PartitionSchemaDialog method open.

public boolean open() {
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            partitionSchema.setChanged();
        }
    };
    middle = props.getMiddlePct();
    margin = Const.MARGIN;
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setText(BaseMessages.getString(PKG, "PartitionSchemaDialog.Shell.Title"));
    shell.setLayout(formLayout);
    // First, add the buttons...
    // Buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(" &OK ");
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "PartitionSchema.ImportPartitions"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(" &Cancel ");
    Button[] buttons = new Button[] { wOK, wGet, wCancel };
    BaseStepDialog.positionBottomButtons(shell, buttons, margin, null);
    // The rest stays above the buttons, so we added those first...
    // What's the schema name??
    // 
    Label wlName = new Label(shell, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "PartitionSchemaDialog.PartitionName.Label"));
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, 0);
    // First one in the left top corner
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    FormData fdName = new FormData();
    fdName.top = new FormAttachment(0, 0);
    // To the right of the label
    fdName.left = new FormAttachment(middle, margin);
    fdName.right = new FormAttachment(95, 0);
    wName.setLayoutData(fdName);
    // is the schema defined dynamically using the number of slave servers in the used cluster.
    // 
    Label wlDynamic = new Label(shell, SWT.RIGHT);
    props.setLook(wlDynamic);
    wlDynamic.setText(BaseMessages.getString(PKG, "PartitionSchemaDialog.Dynamic.Label"));
    FormData fdlDynamic = new FormData();
    fdlDynamic.top = new FormAttachment(wName, margin);
    // First one in the left top corner
    fdlDynamic.left = new FormAttachment(0, 0);
    fdlDynamic.right = new FormAttachment(middle, 0);
    wlDynamic.setLayoutData(fdlDynamic);
    wDynamic = new Button(shell, SWT.CHECK);
    props.setLook(wDynamic);
    wDynamic.setToolTipText(BaseMessages.getString(PKG, "PartitionSchemaDialog.Dynamic.Tooltip"));
    FormData fdDynamic = new FormData();
    fdDynamic.top = new FormAttachment(wName, margin);
    // To the right of the label
    fdDynamic.left = new FormAttachment(middle, margin);
    fdDynamic.right = new FormAttachment(95, 0);
    wDynamic.setLayoutData(fdDynamic);
    // The number of partitions per cluster schema
    // 
    Label wlNumber = new Label(shell, SWT.RIGHT);
    props.setLook(wlNumber);
    wlNumber.setText(BaseMessages.getString(PKG, "PartitionSchemaDialog.Number.Label"));
    FormData fdlNumber = new FormData();
    fdlNumber.top = new FormAttachment(wDynamic, margin);
    // First one in the left top corner
    fdlNumber.left = new FormAttachment(0, 0);
    fdlNumber.right = new FormAttachment(middle, 0);
    wlNumber.setLayoutData(fdlNumber);
    wNumber = new TextVar(variableSpace, shell, SWT.LEFT | SWT.BORDER | SWT.SINGLE, BaseMessages.getString(PKG, "PartitionSchemaDialog.Number.Tooltip"));
    props.setLook(wNumber);
    FormData fdNumber = new FormData();
    fdNumber.top = new FormAttachment(wDynamic, margin);
    // To the right of the label
    fdNumber.left = new FormAttachment(middle, margin);
    fdNumber.right = new FormAttachment(95, 0);
    wNumber.setLayoutData(fdNumber);
    // Schema list:
    Label wlPartitions = new Label(shell, SWT.RIGHT);
    wlPartitions.setText(BaseMessages.getString(PKG, "PartitionSchemaDialog.Partitions.Label"));
    props.setLook(wlPartitions);
    FormData fdlPartitions = new FormData();
    fdlPartitions.left = new FormAttachment(0, 0);
    fdlPartitions.right = new FormAttachment(middle, 0);
    fdlPartitions.top = new FormAttachment(wNumber, margin);
    wlPartitions.setLayoutData(fdlPartitions);
    ColumnInfo[] partitionColumns = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "PartitionSchemaDialog.PartitionID.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false, false) };
    wPartitions = new // probably better push this up. TODO
    TableView(// probably better push this up. TODO
    Variables.getADefaultVariableSpace(), shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, partitionColumns, 1, lsMod, props);
    props.setLook(wPartitions);
    FormData fdPartitions = new FormData();
    fdPartitions.left = new FormAttachment(middle, margin);
    fdPartitions.right = new FormAttachment(100, 0);
    fdPartitions.top = new FormAttachment(wNumber, margin);
    fdPartitions.bottom = new FormAttachment(wOK, -margin * 2);
    wPartitions.setLayoutData(fdPartitions);
    // Add listeners
    wOK.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    });
    wGet.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            importPartitions();
        }
    });
    wCancel.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    });
    SelectionAdapter selAdapter = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wName.addSelectionListener(selAdapter);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    getData();
    BaseStepDialog.setSize(shell);
    shell.open();
    Display display = parent.getDisplay();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return ok;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) Text(org.eclipse.swt.widgets.Text) TextVar(org.pentaho.di.ui.core.widget.TextVar) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Aggregations

TextVar (org.pentaho.di.ui.core.widget.TextVar)240 Label (org.eclipse.swt.widgets.Label)237 FormAttachment (org.eclipse.swt.layout.FormAttachment)236 FormData (org.eclipse.swt.layout.FormData)236 FormLayout (org.eclipse.swt.layout.FormLayout)220 Button (org.eclipse.swt.widgets.Button)207 SelectionEvent (org.eclipse.swt.events.SelectionEvent)196 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)194 Text (org.eclipse.swt.widgets.Text)189 ModifyListener (org.eclipse.swt.events.ModifyListener)186 ModifyEvent (org.eclipse.swt.events.ModifyEvent)184 Listener (org.eclipse.swt.widgets.Listener)184 Shell (org.eclipse.swt.widgets.Shell)184 Event (org.eclipse.swt.widgets.Event)183 ShellAdapter (org.eclipse.swt.events.ShellAdapter)181 ShellEvent (org.eclipse.swt.events.ShellEvent)181 Display (org.eclipse.swt.widgets.Display)181 CCombo (org.eclipse.swt.custom.CCombo)113 Composite (org.eclipse.swt.widgets.Composite)112 CTabItem (org.eclipse.swt.custom.CTabItem)108