Search in sources :

Example 91 with TextVar

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

the class JobEntryMysqlBulkFileDialog 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, "JobMysqlBulkFile.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    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, "JobMysqlBulkFile.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, "JobMysqlBulkFile.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, "JobMysqlBulkFile.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, "JobMysqlBulkFile.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);
    // Filename line
    wlFilename = new Label(shell, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(wTablename, 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(wTablename, 0);
    // fdbFilename.height = 22;
    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(wTablename, 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[] { "*.txt", "*.csv", "*" });
            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());
            }
        }
    });
    // High Priority ?
    wlHighPriority = new Label(shell, SWT.RIGHT);
    wlHighPriority.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.HighPriority.Label"));
    props.setLook(wlHighPriority);
    fdlHighPriority = new FormData();
    fdlHighPriority.left = new FormAttachment(0, 0);
    fdlHighPriority.top = new FormAttachment(wFilename, margin);
    fdlHighPriority.right = new FormAttachment(middle, -margin);
    wlHighPriority.setLayoutData(fdlHighPriority);
    wHighPriority = new Button(shell, SWT.CHECK);
    props.setLook(wHighPriority);
    wHighPriority.setToolTipText(BaseMessages.getString(PKG, "JobMysqlBulkFile.HighPriority.Tooltip"));
    fdHighPriority = new FormData();
    fdHighPriority.left = new FormAttachment(middle, 0);
    fdHighPriority.top = new FormAttachment(wFilename, margin);
    fdHighPriority.right = new FormAttachment(100, 0);
    wHighPriority.setLayoutData(fdHighPriority);
    wHighPriority.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    // Out Dump
    wlOutDumpValue = new Label(shell, SWT.RIGHT);
    wlOutDumpValue.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.OutDumpValue.Label"));
    props.setLook(wlOutDumpValue);
    fdlOutDumpValue = new FormData();
    fdlOutDumpValue.left = new FormAttachment(0, 0);
    fdlOutDumpValue.right = new FormAttachment(middle, 0);
    fdlOutDumpValue.top = new FormAttachment(wHighPriority, margin);
    wlOutDumpValue.setLayoutData(fdlOutDumpValue);
    wOutDumpValue = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wOutDumpValue.add(BaseMessages.getString(PKG, "JobMysqlBulkFile.OutFileValue.Label"));
    wOutDumpValue.add(BaseMessages.getString(PKG, "JobMysqlBulkFile.DumpFileValue.Label"));
    // +1: starts at -1
    wOutDumpValue.select(0);
    props.setLook(wOutDumpValue);
    fdOutDumpValue = new FormData();
    fdOutDumpValue.left = new FormAttachment(middle, 0);
    fdOutDumpValue.top = new FormAttachment(wHighPriority, margin);
    fdOutDumpValue.right = new FormAttachment(100, 0);
    wOutDumpValue.setLayoutData(fdOutDumpValue);
    fdOutDumpValue = new FormData();
    fdOutDumpValue.left = new FormAttachment(middle, 0);
    fdOutDumpValue.top = new FormAttachment(wHighPriority, margin);
    fdOutDumpValue.right = new FormAttachment(100, 0);
    wOutDumpValue.setLayoutData(fdOutDumpValue);
    wOutDumpValue.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            DumpFile();
        }
    });
    // Separator
    wlSeparator = new Label(shell, SWT.RIGHT);
    wlSeparator.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.Separator.Label"));
    props.setLook(wlSeparator);
    fdlSeparator = new FormData();
    fdlSeparator.left = new FormAttachment(0, 0);
    fdlSeparator.right = new FormAttachment(middle, 0);
    fdlSeparator.top = new FormAttachment(wOutDumpValue, margin);
    wlSeparator.setLayoutData(fdlSeparator);
    wSeparator = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSeparator);
    wSeparator.addModifyListener(lsMod);
    fdSeparator = new FormData();
    fdSeparator.left = new FormAttachment(middle, 0);
    fdSeparator.top = new FormAttachment(wOutDumpValue, margin);
    fdSeparator.right = new FormAttachment(100, 0);
    wSeparator.setLayoutData(fdSeparator);
    // enclosed
    wlEnclosed = new Label(shell, SWT.RIGHT);
    wlEnclosed.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.Enclosed.Label"));
    props.setLook(wlEnclosed);
    fdlEnclosed = new FormData();
    fdlEnclosed.left = new FormAttachment(0, 0);
    fdlEnclosed.right = new FormAttachment(middle, 0);
    fdlEnclosed.top = new FormAttachment(wSeparator, margin);
    wlEnclosed.setLayoutData(fdlEnclosed);
    wEnclosed = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEnclosed);
    wEnclosed.addModifyListener(lsMod);
    fdEnclosed = new FormData();
    fdEnclosed.left = new FormAttachment(middle, 0);
    fdEnclosed.top = new FormAttachment(wSeparator, margin);
    fdEnclosed.right = new FormAttachment(100, 0);
    wEnclosed.setLayoutData(fdEnclosed);
    // Optionnally enclosed ?
    wlOptionEnclosed = new Label(shell, SWT.RIGHT);
    wlOptionEnclosed.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.OptionEnclosed.Label"));
    props.setLook(wlOptionEnclosed);
    fdlOptionEnclosed = new FormData();
    fdlOptionEnclosed.left = new FormAttachment(0, 0);
    fdlOptionEnclosed.top = new FormAttachment(wEnclosed, margin);
    fdlOptionEnclosed.right = new FormAttachment(middle, -margin);
    wlOptionEnclosed.setLayoutData(fdlOptionEnclosed);
    wOptionEnclosed = new Button(shell, SWT.CHECK);
    props.setLook(wOptionEnclosed);
    wOptionEnclosed.setToolTipText(BaseMessages.getString(PKG, "JobMysqlBulkFile.OptionEnclosed.Tooltip"));
    fdOptionEnclosed = new FormData();
    fdOptionEnclosed.left = new FormAttachment(middle, 0);
    fdOptionEnclosed.top = new FormAttachment(wEnclosed, margin);
    fdOptionEnclosed.right = new FormAttachment(100, 0);
    wOptionEnclosed.setLayoutData(fdOptionEnclosed);
    wOptionEnclosed.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    // Line terminated
    wlLineterminated = new Label(shell, SWT.RIGHT);
    wlLineterminated.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.Lineterminated.Label"));
    props.setLook(wlLineterminated);
    fdlLineterminated = new FormData();
    fdlLineterminated.left = new FormAttachment(0, 0);
    fdlLineterminated.right = new FormAttachment(middle, 0);
    fdlLineterminated.top = new FormAttachment(wOptionEnclosed, margin);
    wlLineterminated.setLayoutData(fdlLineterminated);
    wLineterminated = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLineterminated);
    wLineterminated.addModifyListener(lsMod);
    fdLineterminated = new FormData();
    fdLineterminated.left = new FormAttachment(middle, 0);
    fdLineterminated.top = new FormAttachment(wOptionEnclosed, margin);
    fdLineterminated.right = new FormAttachment(100, 0);
    wLineterminated.setLayoutData(fdLineterminated);
    // List of columns to set for
    wlListColumn = new Label(shell, SWT.RIGHT);
    wlListColumn.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.ListColumn.Label"));
    props.setLook(wlListColumn);
    fdlListColumn = new FormData();
    fdlListColumn.left = new FormAttachment(0, 0);
    fdlListColumn.right = new FormAttachment(middle, 0);
    fdlListColumn.top = new FormAttachment(wLineterminated, margin);
    wlListColumn.setLayoutData(fdlListColumn);
    wbListColumns = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbListColumns);
    wbListColumns.setText(BaseMessages.getString(PKG, "System.Button.Edit"));
    FormData fdbListColumns = new FormData();
    fdbListColumns.right = new FormAttachment(100, 0);
    fdbListColumns.top = new FormAttachment(wLineterminated, margin);
    wbListColumns.setLayoutData(fdbListColumns);
    wbListColumns.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getListColumns();
        }
    });
    wListColumn = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wListColumn);
    wListColumn.setToolTipText(BaseMessages.getString(PKG, "JobMysqlBulkFile.ListColumn.Tooltip"));
    wListColumn.addModifyListener(lsMod);
    fdListColumn = new FormData();
    fdListColumn.left = new FormAttachment(middle, 0);
    fdListColumn.top = new FormAttachment(wLineterminated, margin);
    fdListColumn.right = new FormAttachment(wbListColumns, -margin);
    wListColumn.setLayoutData(fdListColumn);
    // Nbr of lines to Limit
    wlLimitlines = new Label(shell, SWT.RIGHT);
    wlLimitlines.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.Limitlines.Label"));
    props.setLook(wlLimitlines);
    fdlLimitlines = new FormData();
    fdlLimitlines.left = new FormAttachment(0, 0);
    fdlLimitlines.right = new FormAttachment(middle, 0);
    fdlLimitlines.top = new FormAttachment(wListColumn, margin);
    wlLimitlines.setLayoutData(fdlLimitlines);
    wLimitlines = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLimitlines);
    wLimitlines.setToolTipText(BaseMessages.getString(PKG, "JobMysqlBulkFile.Limitlines.Tooltip"));
    wLimitlines.addModifyListener(lsMod);
    fdLimitlines = new FormData();
    fdLimitlines.left = new FormAttachment(middle, 0);
    fdLimitlines.top = new FormAttachment(wListColumn, margin);
    fdLimitlines.right = new FormAttachment(100, 0);
    wLimitlines.setLayoutData(fdLimitlines);
    // IF File Exists
    wlIfFileExists = new Label(shell, SWT.RIGHT);
    wlIfFileExists.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.IfFileExists.Label"));
    props.setLook(wlIfFileExists);
    fdlIfFileExists = new FormData();
    fdlIfFileExists.left = new FormAttachment(0, 0);
    fdlIfFileExists.right = new FormAttachment(middle, 0);
    fdlIfFileExists.top = new FormAttachment(wLimitlines, margin);
    wlIfFileExists.setLayoutData(fdlIfFileExists);
    wIfFileExists = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wIfFileExists.add(BaseMessages.getString(PKG, "JobMysqlBulkFile.Create_NewFile_IfFileExists.Label"));
    wIfFileExists.add(BaseMessages.getString(PKG, "JobMysqlBulkFile.Do_Nothing_IfFileExists.Label"));
    wIfFileExists.add(BaseMessages.getString(PKG, "JobMysqlBulkFile.Fail_IfFileExists.Label"));
    // +1: starts at -1
    wIfFileExists.select(2);
    props.setLook(wIfFileExists);
    fdIfFileExists = new FormData();
    fdIfFileExists.left = new FormAttachment(middle, 0);
    fdIfFileExists.top = new FormAttachment(wLimitlines, margin);
    fdIfFileExists.right = new FormAttachment(100, 0);
    wIfFileExists.setLayoutData(fdIfFileExists);
    fdIfFileExists = new FormData();
    fdIfFileExists.left = new FormAttachment(middle, 0);
    fdIfFileExists.top = new FormAttachment(wLimitlines, margin);
    fdIfFileExists.right = new FormAttachment(100, 0);
    wIfFileExists.setLayoutData(fdIfFileExists);
    // fileresult grouping?
    // ////////////////////////
    // START OF LOGGING GROUP///
    // /
    wFileResult = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wFileResult);
    wFileResult.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.FileResult.Group.Label"));
    FormLayout groupLayout = new FormLayout();
    groupLayout.marginWidth = 10;
    groupLayout.marginHeight = 10;
    wFileResult.setLayout(groupLayout);
    // Add file to result
    wlAddFileToResult = new Label(wFileResult, SWT.RIGHT);
    wlAddFileToResult.setText(BaseMessages.getString(PKG, "JobMysqlBulkFile.AddFileToResult.Label"));
    props.setLook(wlAddFileToResult);
    fdlAddFileToResult = new FormData();
    fdlAddFileToResult.left = new FormAttachment(0, 0);
    fdlAddFileToResult.top = new FormAttachment(wIfFileExists, margin);
    fdlAddFileToResult.right = new FormAttachment(middle, -margin);
    wlAddFileToResult.setLayoutData(fdlAddFileToResult);
    wAddFileToResult = new Button(wFileResult, SWT.CHECK);
    props.setLook(wAddFileToResult);
    wAddFileToResult.setToolTipText(BaseMessages.getString(PKG, "JobMysqlBulkFile.AddFileToResult.Tooltip"));
    fdAddFileToResult = new FormData();
    fdAddFileToResult.left = new FormAttachment(middle, 0);
    fdAddFileToResult.top = new FormAttachment(wIfFileExists, margin);
    fdAddFileToResult.right = new FormAttachment(100, 0);
    wAddFileToResult.setLayoutData(fdAddFileToResult);
    wAddFileToResult.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
        }
    });
    fdFileResult = new FormData();
    fdFileResult.left = new FormAttachment(0, margin);
    fdFileResult.top = new FormAttachment(wIfFileExists, margin);
    fdFileResult.right = new FormAttachment(100, -margin);
    wFileResult.setLayoutData(fdFileResult);
    // ///////////////////////////////////////////////////////////
    // / END OF LOGGING GROUP
    // ///////////////////////////////////////////////////////////
    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);
    // 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);
    wTablename.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, "JobMysqlBulkFileDialogSize");
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntry;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) 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) CCombo(org.eclipse.swt.custom.CCombo) 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 92 with TextVar

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

the class GPLoadDialog method addGPConfigTabItem.

private void addGPConfigTabItem(CTabFolder tabFolder, int margin, ModifyListener lsMod, FocusListener lsFocusLost) {
    Composite wGPConfigTabComp;
    CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
    tabItem.setText(BaseMessages.getString(PKG, "GPLoadDialog.GPConfiguratonTab.Title"));
    wGPConfigTabComp = new Composite(tabFolder, SWT.NONE);
    props.setLook(wGPConfigTabComp);
    int middle = props.getMiddlePct();
    FormLayout formlayout = new FormLayout();
    formlayout.marginWidth = 3;
    formlayout.marginHeight = 3;
    wGPConfigTabComp.setLayout(formlayout);
    // GPLoad line...
    Label wlGploadPath = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlGploadPath.setText(BaseMessages.getString(PKG, "GPLoadDialog.GPLoadPath.Label"));
    props.setLook(wlGploadPath);
    FormData fdlGploadPath = new FormData();
    fdlGploadPath.left = new FormAttachment(0, 0);
    fdlGploadPath.right = new FormAttachment(middle, -margin);
    fdlGploadPath.top = new FormAttachment(0, margin);
    wlGploadPath.setLayoutData(fdlGploadPath);
    Button wbGploadPath = new Button(wGPConfigTabComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbGploadPath);
    wbGploadPath.setText(BaseMessages.getString(PKG, "GPLoadDialog.Browse.Button"));
    FormData fdbGploadPath = new FormData();
    fdbGploadPath.right = new FormAttachment(75, 0);
    fdbGploadPath.top = new FormAttachment(0, margin);
    wbGploadPath.setLayoutData(fdbGploadPath);
    wGploadPath = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wGploadPath);
    wGploadPath.addModifyListener(lsMod);
    FormData fdGploadPath = new FormData();
    fdGploadPath.left = new FormAttachment(middle, 0);
    fdGploadPath.top = new FormAttachment(0, margin);
    fdGploadPath.right = new FormAttachment(wbGploadPath, -margin);
    wGploadPath.setLayoutData(fdGploadPath);
    Label wlControlFile = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlControlFile.setText(BaseMessages.getString(PKG, "GPLoadDialog.ControlFile.Label"));
    props.setLook(wlControlFile);
    FormData fdlControlFile = new FormData();
    fdlControlFile.left = new FormAttachment(0, 0);
    fdlControlFile.top = new FormAttachment(wGploadPath, margin);
    fdlControlFile.right = new FormAttachment(middle, -margin);
    wlControlFile.setLayoutData(fdlControlFile);
    Button wbControlFile = new Button(wGPConfigTabComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbControlFile);
    wbControlFile.setText(BaseMessages.getString(PKG, "GPLoadDialog.Browse.Button"));
    FormData fdbControlFile = new FormData();
    fdbControlFile.right = new FormAttachment(75, 0);
    fdbControlFile.top = new FormAttachment(wGploadPath, margin);
    wbControlFile.setLayoutData(fdbControlFile);
    wControlFile = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wControlFile);
    wControlFile.addModifyListener(lsMod);
    FormData fdControlFile = new FormData();
    fdControlFile.left = new FormAttachment(middle, 0);
    fdControlFile.top = new FormAttachment(wGploadPath, margin);
    fdControlFile.right = new FormAttachment(wbControlFile, -margin);
    wControlFile.setLayoutData(fdControlFile);
    // Error Table line...
    Label wlErrorTable = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlErrorTable.setText(BaseMessages.getString(PKG, "GPLoadDialog.ErrorTable.Label"));
    props.setLook(wlErrorTable);
    FormData fdlErrorTable = new FormData();
    fdlErrorTable.left = new FormAttachment(0, 0);
    fdlErrorTable.top = new FormAttachment(wControlFile, margin);
    fdlErrorTable.right = new FormAttachment(middle, -margin);
    wlErrorTable.setLayoutData(fdlErrorTable);
    Button wbErrorTable = new Button(wGPConfigTabComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbErrorTable);
    wbErrorTable.setText(BaseMessages.getString(PKG, "GPLoadDialog.Browse.Button"));
    FormData fdbErrorTable = new FormData();
    fdbErrorTable.right = new FormAttachment(75, 0);
    fdbErrorTable.top = new FormAttachment(wControlFile, margin);
    wbErrorTable.setLayoutData(fdbErrorTable);
    wErrorTable = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wErrorTable);
    wErrorTable.addModifyListener(lsMod);
    wErrorTable.addFocusListener(lsFocusLost);
    FormData fdErrorTable = new FormData();
    fdErrorTable.left = new FormAttachment(middle, 0);
    fdErrorTable.top = new FormAttachment(wControlFile, margin);
    fdErrorTable.right = new FormAttachment(wbErrorTable, -margin);
    wErrorTable.setLayoutData(fdErrorTable);
    // MaxErrors
    Label wlMaxErrors = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlMaxErrors.setText(BaseMessages.getString(PKG, "GPLoadDialog.MaxErrors.Label"));
    props.setLook(wlMaxErrors);
    FormData fdlMaxErrors = new FormData();
    fdlMaxErrors.left = new FormAttachment(wbErrorTable, margin);
    fdlMaxErrors.top = new FormAttachment(wControlFile, margin);
    // fdlMaxErrors.right = new FormAttachment(100, -margin);
    wlMaxErrors.setLayoutData(fdlMaxErrors);
    wMaxErrors = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wMaxErrors);
    wMaxErrors.addModifyListener(lsMod);
    FormData fdMaxErrors = new FormData();
    fdMaxErrors.left = new FormAttachment(wlMaxErrors, margin);
    fdMaxErrors.top = new FormAttachment(wControlFile, margin);
    fdMaxErrors.right = new FormAttachment(100, 0);
    wMaxErrors.setLayoutData(fdMaxErrors);
    // Log file line
    Label wlLogFile = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlLogFile.setText(BaseMessages.getString(PKG, "GPLoadDialog.LogFile.Label"));
    props.setLook(wlLogFile);
    FormData fdlLogFile = new FormData();
    fdlLogFile.left = new FormAttachment(0, 0);
    fdlLogFile.top = new FormAttachment(wErrorTable, margin);
    fdlLogFile.right = new FormAttachment(middle, -margin);
    wlLogFile.setLayoutData(fdlLogFile);
    Button wbLogFile = new Button(wGPConfigTabComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbLogFile);
    wbLogFile.setText(BaseMessages.getString(PKG, "GPLoadDialog.Browse.Button"));
    FormData fdbLogFile = new FormData();
    fdbLogFile.right = new FormAttachment(75, 0);
    fdbLogFile.top = new FormAttachment(wErrorTable, margin);
    wbLogFile.setLayoutData(fdbLogFile);
    wLogFile = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLogFile);
    wLogFile.addModifyListener(lsMod);
    FormData fdLogFile = new FormData();
    fdLogFile.left = new FormAttachment(middle, 0);
    fdLogFile.top = new FormAttachment(wErrorTable, margin);
    fdLogFile.right = new FormAttachment(wbLogFile, -margin);
    wLogFile.setLayoutData(fdLogFile);
    // Data file line
    Label wlDataFile = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlDataFile.setText(BaseMessages.getString(PKG, "GPLoadDialog.DataFile.Label"));
    props.setLook(wlDataFile);
    FormData fdlDataFile = new FormData();
    fdlDataFile.left = new FormAttachment(0, 0);
    fdlDataFile.top = new FormAttachment(wLogFile, margin);
    fdlDataFile.right = new FormAttachment(middle, -margin);
    wlDataFile.setLayoutData(fdlDataFile);
    Button wbDataFile = new Button(wGPConfigTabComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbDataFile);
    wbDataFile.setText(BaseMessages.getString(PKG, "GPLoadDialog.Browse.Button"));
    FormData fdbDataFile = new FormData();
    fdbDataFile.right = new FormAttachment(75, 0);
    fdbDataFile.top = new FormAttachment(wLogFile, margin);
    wbDataFile.setLayoutData(fdbDataFile);
    wDataFile = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wDataFile);
    wDataFile.addModifyListener(lsMod);
    FormData fdDataFile = new FormData();
    fdDataFile.left = new FormAttachment(middle, 0);
    fdDataFile.top = new FormAttachment(wLogFile, margin);
    fdDataFile.right = new FormAttachment(wbDataFile, -margin);
    wDataFile.setLayoutData(fdDataFile);
    Label wlDelimiter = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlDelimiter.setText(BaseMessages.getString(PKG, "GPLoadDialog.Delimiter.Label"));
    props.setLook(wlDelimiter);
    FormData fdlDelimiter = new FormData();
    fdlDelimiter.left = new FormAttachment(wbDataFile, margin);
    fdlDelimiter.top = new FormAttachment(wLogFile, margin);
    wlDelimiter.setLayoutData(fdlDelimiter);
    wDelimiter = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wMaxErrors);
    wDelimiter.addModifyListener(lsMod);
    FormData fdDelimiter = new FormData();
    fdDelimiter.left = new FormAttachment(wlDelimiter, margin);
    fdDelimiter.top = new FormAttachment(wLogFile, margin);
    fdDelimiter.right = new FormAttachment(100, 0);
    wDelimiter.setLayoutData(fdDelimiter);
    // NULL_AS parameter
    Label wlNullAs = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlNullAs.setText(BaseMessages.getString(PKG, "GPLoadDialog.NullAs.Label"));
    props.setLook(wlNullAs);
    FormData fdlNullAs = new FormData();
    fdlNullAs.left = new FormAttachment(0, 0);
    fdlNullAs.top = new FormAttachment(wDataFile, margin);
    fdlNullAs.right = new FormAttachment(middle, -margin);
    wlNullAs.setLayoutData(fdlNullAs);
    wNullAs = new TextVar(transMeta, wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wNullAs);
    wNullAs.addModifyListener(lsMod);
    FormData fdNullAs = new FormData();
    fdNullAs.left = new FormAttachment(middle, 0);
    fdNullAs.top = new FormAttachment(wDataFile, margin);
    wNullAs.setLayoutData(fdNullAs);
    // Control encoding line
    // 
    // The drop down is editable as it may happen an encoding may not be
    // present on one machine, but you may want to use it on your execution server
    // 
    Label wlEncoding = new Label(wGPConfigTabComp, SWT.RIGHT);
    wlEncoding.setText(BaseMessages.getString(PKG, "GPLoadDialog.Encoding.Label"));
    props.setLook(wlEncoding);
    FormData fdlEncoding = new FormData();
    fdlEncoding.left = new FormAttachment(0, 0);
    fdlEncoding.top = new FormAttachment(wNullAs, margin);
    fdlEncoding.right = new FormAttachment(middle, -margin);
    wlEncoding.setLayoutData(fdlEncoding);
    wEncoding = new Combo(wGPConfigTabComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wEncoding.setToolTipText(BaseMessages.getString(PKG, "GPLoadDialog.Encoding.Tooltip"));
    wEncoding.setItems(GPLoadMeta.SUPPORTED_ENCODINGS);
    props.setLook(wEncoding);
    FormData fdEncoding = new FormData();
    fdEncoding.left = new FormAttachment(middle, 0);
    fdEncoding.top = new FormAttachment(wNullAs, margin);
    fdEncoding.right = new FormAttachment(75, 0);
    wEncoding.setLayoutData(fdEncoding);
    wEncoding.addModifyListener(lsMod);
    wGPConfigTabComp.layout();
    tabItem.setControl(wGPConfigTabComp);
    wbErrorTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getTableName(wSchema, wErrorTable);
        }
    });
    wbGploadPath.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.OPEN);
            dialog.setFilterExtensions(new String[] { "*" });
            if (wGploadPath.getText() != null) {
                dialog.setFileName(wGploadPath.getText());
            }
            dialog.setFilterNames(ALL_FILETYPES);
            if (dialog.open() != null) {
                wGploadPath.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
        }
    });
    wbControlFile.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*" });
            if (wControlFile.getText() != null) {
                dialog.setFileName(wControlFile.getText());
            }
            dialog.setFilterNames(ALL_FILETYPES);
            if (dialog.open() != null) {
                wControlFile.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
        }
    });
    wbDataFile.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*" });
            if (wDataFile.getText() != null) {
                dialog.setFileName(wDataFile.getText());
            }
            dialog.setFilterNames(ALL_FILETYPES);
            if (dialog.open() != null) {
                wDataFile.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
        }
    });
    wbLogFile.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*" });
            if (wLogFile.getText() != null) {
                dialog.setFileName(wLogFile.getText());
            }
            dialog.setFilterNames(ALL_FILETYPES);
            if (dialog.open() != null) {
                wLogFile.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
        }
    });
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CCombo(org.eclipse.swt.custom.CCombo) Combo(org.eclipse.swt.widgets.Combo) CTabItem(org.eclipse.swt.custom.CTabItem) TextVar(org.pentaho.di.ui.core.widget.TextVar) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 93 with TextVar

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

the class GPLoadDialog method open.

public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);
    ModifyListener lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    FocusListener lsFocusLost = new FocusAdapter() {

        public void focusLost(FocusEvent arg0) {
            setTableFieldCombo();
        }
    };
    changed = input.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "GPLoadDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "GPLoadDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.right = new FormAttachment(middle, -margin);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);
    // Connection line
    wConnection = addConnectionLine(shell, wStepname, middle, margin);
    if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
        wConnection.select(0);
    }
    wConnection.addModifyListener(lsMod);
    // Schema line...
    Label wlSchema = new Label(shell, SWT.RIGHT);
    wlSchema.setText(BaseMessages.getString(PKG, "GPLoadDialog.TargetSchema.Label"));
    props.setLook(wlSchema);
    FormData fdlSchema = new FormData();
    fdlSchema.left = new FormAttachment(0, 0);
    fdlSchema.right = new FormAttachment(middle, -margin);
    fdlSchema.top = new FormAttachment(wConnection, margin * 2);
    wlSchema.setLayoutData(fdlSchema);
    wSchema = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSchema);
    wSchema.addModifyListener(lsMod);
    wSchema.addFocusListener(lsFocusLost);
    FormData fdSchema = new FormData();
    fdSchema.left = new FormAttachment(middle, 0);
    fdSchema.top = new FormAttachment(wConnection, margin * 2);
    fdSchema.right = new FormAttachment(100, 0);
    wSchema.setLayoutData(fdSchema);
    // Table line...
    Label wlTable = new Label(shell, SWT.RIGHT);
    wlTable.setText(BaseMessages.getString(PKG, "GPLoadDialog.TargetTable.Label"));
    props.setLook(wlTable);
    FormData fdlTable = new FormData();
    fdlTable.left = new FormAttachment(0, 0);
    fdlTable.right = new FormAttachment(middle, -margin);
    fdlTable.top = new FormAttachment(wSchema, margin);
    wlTable.setLayoutData(fdlTable);
    Button wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbTable);
    wbTable.setText(BaseMessages.getString(PKG, "GPLoadDialog.Browse.Button"));
    FormData fdbTable = new FormData();
    fdbTable.right = new FormAttachment(100, 0);
    fdbTable.top = new FormAttachment(wSchema, margin);
    wbTable.setLayoutData(fdbTable);
    wTable = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTable);
    wTable.addModifyListener(lsMod);
    wTable.addFocusListener(lsFocusLost);
    FormData fdTable = new FormData();
    fdTable.left = new FormAttachment(middle, 0);
    fdTable.top = new FormAttachment(wSchema, margin);
    fdTable.right = new FormAttachment(wbTable, -margin);
    wTable.setLayoutData(fdTable);
    // Load Method line
    Label wlLoadMethod = new Label(shell, SWT.RIGHT);
    wlLoadMethod.setText(BaseMessages.getString(PKG, "GPLoadDialog.LoadMethod.Label"));
    props.setLook(wlLoadMethod);
    FormData fdlLoadMethod = new FormData();
    fdlLoadMethod.left = new FormAttachment(0, 0);
    fdlLoadMethod.right = new FormAttachment(middle, -margin);
    fdlLoadMethod.top = new FormAttachment(wTable, margin);
    wlLoadMethod.setLayoutData(fdlLoadMethod);
    wLoadMethod = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    // wLoadMethod.add(BaseMessages.getString(PKG,
    // "GPLoadDialog.AutoConcLoadMethod.Label"));
    wLoadMethod.add(BaseMessages.getString(PKG, "GPLoadDialog.AutoEndLoadMethod.Label"));
    wLoadMethod.add(BaseMessages.getString(PKG, "GPLoadDialog.ManualLoadMethod.Label"));
    // +1: starts at -1
    wLoadMethod.select(0);
    wLoadMethod.addModifyListener(lsMod);
    props.setLook(wLoadMethod);
    FormData fdLoadMethod = new FormData();
    fdLoadMethod.left = new FormAttachment(middle, 0);
    fdLoadMethod.top = new FormAttachment(wTable, margin);
    fdLoadMethod.right = new FormAttachment(100, 0);
    wLoadMethod.setLayoutData(fdLoadMethod);
    // Erase files line
    Label wlEraseFiles = new Label(shell, SWT.RIGHT);
    wlEraseFiles.setText(BaseMessages.getString(PKG, "GPLoadDialog.EraseFiles.Label"));
    props.setLook(wlEraseFiles);
    FormData fdlEraseFiles = new FormData();
    fdlEraseFiles.left = new FormAttachment(0, 0);
    fdlEraseFiles.top = new FormAttachment(wLoadMethod, margin);
    fdlEraseFiles.right = new FormAttachment(middle, -margin);
    wlEraseFiles.setLayoutData(fdlEraseFiles);
    wEraseFiles = new Button(shell, SWT.CHECK);
    props.setLook(wEraseFiles);
    FormData fdEraseFiles = new FormData();
    fdEraseFiles.left = new FormAttachment(middle, 0);
    fdEraseFiles.top = new FormAttachment(wLoadMethod, margin);
    fdEraseFiles.right = new FormAttachment(100, 0);
    wEraseFiles.setLayoutData(fdEraseFiles);
    wEraseFiles.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // The Tab folder for field/columns, localhosts and Greenplum configuration
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, PropsUI.WIDGET_STYLE_TAB);
    // we have a method to add each tabs' widgets
    addFieldTabItem(wTabFolder, margin, lsMod);
    addLocalHostsTabItem(wTabFolder, margin, lsMod, lsFocusLost);
    addGPConfigTabItem(wTabFolder, margin, lsMod, lsFocusLost);
    // ///////////////////////////////////////////////////////////
    // End of Tab Folder
    // ///////////////////////////////////////////////////////////
    FormData fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wEraseFiles, margin);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);
    // set the selection to the first tab
    wTabFolder.setSelection(0);
    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wSQL = new Button(shell, SWT.PUSH);
    wSQL.setText(BaseMessages.getString(PKG, "GPLoadDialog.SQL.Button"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wSQL, wCancel }, margin, wTabFolder);
    // 
    // Search the fields in the background
    // 
    final Runnable runnable = new Runnable() {

        public void run() {
            StepMeta stepMeta = transMeta.findStep(stepname);
            if (stepMeta != null) {
                try {
                    RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);
                    // Remember these fields...
                    for (int i = 0; i < row.size(); i++) {
                        inputFields.put(row.getValueMeta(i).getName(), i);
                    }
                    setComboBoxes();
                } catch (KettleException e) {
                    logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
                }
            }
        }
    };
    new Thread(runnable).start();
    // Add listeners
    lsOK = new Listener() {

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

        public void handleEvent(Event e) {
            create();
        }
    };
    lsCancel = new Listener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    wSchema.addSelectionListener(lsDef);
    wTable.addSelectionListener(lsDef);
    wMaxErrors.addSelectionListener(lsDef);
    wControlFile.addSelectionListener(lsDef);
    wDataFile.addSelectionListener(lsDef);
    wLogFile.addSelectionListener(lsDef);
    wNullAs.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    wbTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getTableName(wSchema, wTable);
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    setTableFieldCombo();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) KettleException(org.pentaho.di.core.exception.KettleException) CTabFolder(org.eclipse.swt.custom.CTabFolder) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) 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) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) FocusEvent(org.eclipse.swt.events.FocusEvent) 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) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) TextVar(org.pentaho.di.ui.core.widget.TextVar) CCombo(org.eclipse.swt.custom.CCombo) FocusEvent(org.eclipse.swt.events.FocusEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) Display(org.eclipse.swt.widgets.Display)

Example 94 with TextVar

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

the class GPLoadDialog method addLocalHostsTabItem.

private void addLocalHostsTabItem(CTabFolder tabFolder, int margin, ModifyListener lsMod, FocusListener lsFocusLost) {
    CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
    tabItem.setText(BaseMessages.getString(PKG, "GPLoadDialog.LocalHostsTab.Title"));
    Composite wLocalHostsComp = new Composite(tabFolder, SWT.NONE);
    props.setLook(wLocalHostsComp);
    int middle = props.getMiddlePct();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 3;
    formLayout.marginHeight = 3;
    wLocalHostsComp.setLayout(formLayout);
    // Master Port line...
    Label wlLocalhostPort = new Label(wLocalHostsComp, SWT.NONE);
    wlLocalhostPort.setText(BaseMessages.getString(PKG, "GPLoadDialog.Port.Label"));
    props.setLook(wlLocalhostPort);
    FormData fdlLocalhostPort = new FormData();
    fdlLocalhostPort.left = new FormAttachment(0, 0);
    fdlLocalhostPort.top = new FormAttachment(0, margin * 2);
    wlLocalhostPort.setLayoutData(fdlLocalhostPort);
    wLocalhostPort = new TextVar(transMeta, wLocalHostsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLocalhostPort);
    wLocalhostPort.addModifyListener(lsMod);
    wLocalhostPort.addFocusListener(lsFocusLost);
    FormData fdLocalhostPort = new FormData();
    fdLocalhostPort.left = new FormAttachment(wlLocalhostPort, margin);
    fdLocalhostPort.top = new FormAttachment(0, margin * 2);
    fdLocalhostPort.right = new FormAttachment(middle, 0);
    wLocalhostPort.setLayoutData(fdLocalhostPort);
    wLocalhostPort.addModifyListener(lsMod);
    // Local Hosts Label
    Label wlLocalHosts = new Label(wLocalHostsComp, SWT.NONE);
    wlLocalHosts.setText(BaseMessages.getString(PKG, "GPLoadDialog.LocalHosts.Label"));
    props.setLook(wlLocalHosts);
    FormData fdlLocalHosts = new FormData();
    fdlLocalHosts.left = new FormAttachment(0, 0);
    fdlLocalHosts.top = new FormAttachment(wLocalhostPort, margin);
    wlLocalHosts.setLayoutData(fdlLocalHosts);
    // Local Hosts Table
    int LocalHostsColumns = 1;
    int LocalHostsRows = (input.getLocalHosts() != null ? input.getLocalHosts().length : 1);
    ciLocalHosts = new ColumnInfo[LocalHostsColumns];
    ciLocalHosts[0] = new ColumnInfo(BaseMessages.getString(PKG, "GPLoadDialog.ColumnInfo.LocalHosts"), ColumnInfo.COLUMN_TYPE_TEXT, new String[] { "" }, false);
    localHostsColumns.add(ciReturn[0]);
    wLocalHosts = new TableView(transMeta, wLocalHostsComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciLocalHosts, LocalHostsRows, lsMod, props);
    FormData fdLocalHostsComp = new FormData();
    fdLocalHostsComp.left = new FormAttachment(0, 0);
    fdLocalHostsComp.top = new FormAttachment(wlLocalHosts, margin);
    fdLocalHostsComp.right = new FormAttachment(75, 0);
    fdLocalHostsComp.bottom = new FormAttachment(100, -margin);
    wLocalHosts.setLayoutData(fdLocalHostsComp);
    wLocalHostsComp.layout();
    tabItem.setControl(wLocalHostsComp);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment) TextVar(org.pentaho.di.ui.core.widget.TextVar) TableView(org.pentaho.di.ui.core.widget.TableView)

Example 95 with TextVar

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

the class AccessInputDialog method addAdditionalFieldsTab.

private void addAdditionalFieldsTab() {
    // ////////////////////////
    // START OF ADDITIONAL FIELDS TAB ///
    // ////////////////////////
    wAdditionalFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
    wAdditionalFieldsTab.setText(BaseMessages.getString(PKG, "AccessInputDialog.AdditionalFieldsTab.TabTitle"));
    wAdditionalFieldsComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wAdditionalFieldsComp);
    FormLayout fieldsLayout = new FormLayout();
    fieldsLayout.marginWidth = 3;
    fieldsLayout.marginHeight = 3;
    wAdditionalFieldsComp.setLayout(fieldsLayout);
    // ShortFileFieldName line
    wlShortFileFieldName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlShortFileFieldName.setText(BaseMessages.getString(PKG, "AccessInputDialog.ShortFileFieldName.Label"));
    props.setLook(wlShortFileFieldName);
    fdlShortFileFieldName = new FormData();
    fdlShortFileFieldName.left = new FormAttachment(0, 0);
    fdlShortFileFieldName.top = new FormAttachment(wInclRownumField, margin);
    fdlShortFileFieldName.right = new FormAttachment(middle, -margin);
    wlShortFileFieldName.setLayoutData(fdlShortFileFieldName);
    wShortFileFieldName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wShortFileFieldName);
    wShortFileFieldName.addModifyListener(lsMod);
    fdShortFileFieldName = new FormData();
    fdShortFileFieldName.left = new FormAttachment(middle, 0);
    fdShortFileFieldName.right = new FormAttachment(100, -margin);
    fdShortFileFieldName.top = new FormAttachment(wInclRownumField, margin);
    wShortFileFieldName.setLayoutData(fdShortFileFieldName);
    // ExtensionFieldName line
    wlExtensionFieldName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlExtensionFieldName.setText(BaseMessages.getString(PKG, "AccessInputDialog.ExtensionFieldName.Label"));
    props.setLook(wlExtensionFieldName);
    fdlExtensionFieldName = new FormData();
    fdlExtensionFieldName.left = new FormAttachment(0, 0);
    fdlExtensionFieldName.top = new FormAttachment(wShortFileFieldName, margin);
    fdlExtensionFieldName.right = new FormAttachment(middle, -margin);
    wlExtensionFieldName.setLayoutData(fdlExtensionFieldName);
    wExtensionFieldName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wExtensionFieldName);
    wExtensionFieldName.addModifyListener(lsMod);
    fdExtensionFieldName = new FormData();
    fdExtensionFieldName.left = new FormAttachment(middle, 0);
    fdExtensionFieldName.right = new FormAttachment(100, -margin);
    fdExtensionFieldName.top = new FormAttachment(wShortFileFieldName, margin);
    wExtensionFieldName.setLayoutData(fdExtensionFieldName);
    // PathFieldName line
    wlPathFieldName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlPathFieldName.setText(BaseMessages.getString(PKG, "AccessInputDialog.PathFieldName.Label"));
    props.setLook(wlPathFieldName);
    fdlPathFieldName = new FormData();
    fdlPathFieldName.left = new FormAttachment(0, 0);
    fdlPathFieldName.top = new FormAttachment(wExtensionFieldName, margin);
    fdlPathFieldName.right = new FormAttachment(middle, -margin);
    wlPathFieldName.setLayoutData(fdlPathFieldName);
    wPathFieldName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPathFieldName);
    wPathFieldName.addModifyListener(lsMod);
    fdPathFieldName = new FormData();
    fdPathFieldName.left = new FormAttachment(middle, 0);
    fdPathFieldName.right = new FormAttachment(100, -margin);
    fdPathFieldName.top = new FormAttachment(wExtensionFieldName, margin);
    wPathFieldName.setLayoutData(fdPathFieldName);
    // SizeFieldName line
    wlSizeFieldName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlSizeFieldName.setText(BaseMessages.getString(PKG, "AccessInputDialog.SizeFieldName.Label"));
    props.setLook(wlSizeFieldName);
    fdlSizeFieldName = new FormData();
    fdlSizeFieldName.left = new FormAttachment(0, 0);
    fdlSizeFieldName.top = new FormAttachment(wPathFieldName, margin);
    fdlSizeFieldName.right = new FormAttachment(middle, -margin);
    wlSizeFieldName.setLayoutData(fdlSizeFieldName);
    wSizeFieldName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSizeFieldName);
    wSizeFieldName.addModifyListener(lsMod);
    fdSizeFieldName = new FormData();
    fdSizeFieldName.left = new FormAttachment(middle, 0);
    fdSizeFieldName.right = new FormAttachment(100, -margin);
    fdSizeFieldName.top = new FormAttachment(wPathFieldName, margin);
    wSizeFieldName.setLayoutData(fdSizeFieldName);
    // IsHiddenName line
    wlIsHiddenName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlIsHiddenName.setText(BaseMessages.getString(PKG, "AccessInputDialog.IsHiddenName.Label"));
    props.setLook(wlIsHiddenName);
    fdlIsHiddenName = new FormData();
    fdlIsHiddenName.left = new FormAttachment(0, 0);
    fdlIsHiddenName.top = new FormAttachment(wSizeFieldName, margin);
    fdlIsHiddenName.right = new FormAttachment(middle, -margin);
    wlIsHiddenName.setLayoutData(fdlIsHiddenName);
    wIsHiddenName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wIsHiddenName);
    wIsHiddenName.addModifyListener(lsMod);
    fdIsHiddenName = new FormData();
    fdIsHiddenName.left = new FormAttachment(middle, 0);
    fdIsHiddenName.right = new FormAttachment(100, -margin);
    fdIsHiddenName.top = new FormAttachment(wSizeFieldName, margin);
    wIsHiddenName.setLayoutData(fdIsHiddenName);
    // LastModificationTimeName line
    wlLastModificationTimeName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlLastModificationTimeName.setText(BaseMessages.getString(PKG, "AccessInputDialog.LastModificationTimeName.Label"));
    props.setLook(wlLastModificationTimeName);
    fdlLastModificationTimeName = new FormData();
    fdlLastModificationTimeName.left = new FormAttachment(0, 0);
    fdlLastModificationTimeName.top = new FormAttachment(wIsHiddenName, margin);
    fdlLastModificationTimeName.right = new FormAttachment(middle, -margin);
    wlLastModificationTimeName.setLayoutData(fdlLastModificationTimeName);
    wLastModificationTimeName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLastModificationTimeName);
    wLastModificationTimeName.addModifyListener(lsMod);
    fdLastModificationTimeName = new FormData();
    fdLastModificationTimeName.left = new FormAttachment(middle, 0);
    fdLastModificationTimeName.right = new FormAttachment(100, -margin);
    fdLastModificationTimeName.top = new FormAttachment(wIsHiddenName, margin);
    wLastModificationTimeName.setLayoutData(fdLastModificationTimeName);
    // UriName line
    wlUriName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlUriName.setText(BaseMessages.getString(PKG, "AccessInputDialog.UriName.Label"));
    props.setLook(wlUriName);
    fdlUriName = new FormData();
    fdlUriName.left = new FormAttachment(0, 0);
    fdlUriName.top = new FormAttachment(wLastModificationTimeName, margin);
    fdlUriName.right = new FormAttachment(middle, -margin);
    wlUriName.setLayoutData(fdlUriName);
    wUriName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wUriName);
    wUriName.addModifyListener(lsMod);
    fdUriName = new FormData();
    fdUriName.left = new FormAttachment(middle, 0);
    fdUriName.right = new FormAttachment(100, -margin);
    fdUriName.top = new FormAttachment(wLastModificationTimeName, margin);
    wUriName.setLayoutData(fdUriName);
    // RootUriName line
    wlRootUriName = new Label(wAdditionalFieldsComp, SWT.RIGHT);
    wlRootUriName.setText(BaseMessages.getString(PKG, "AccessInputDialog.RootUriName.Label"));
    props.setLook(wlRootUriName);
    fdlRootUriName = new FormData();
    fdlRootUriName.left = new FormAttachment(0, 0);
    fdlRootUriName.top = new FormAttachment(wUriName, margin);
    fdlRootUriName.right = new FormAttachment(middle, -margin);
    wlRootUriName.setLayoutData(fdlRootUriName);
    wRootUriName = new TextVar(transMeta, wAdditionalFieldsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wRootUriName);
    wRootUriName.addModifyListener(lsMod);
    fdRootUriName = new FormData();
    fdRootUriName.left = new FormAttachment(middle, 0);
    fdRootUriName.right = new FormAttachment(100, -margin);
    fdRootUriName.top = new FormAttachment(wUriName, margin);
    wRootUriName.setLayoutData(fdRootUriName);
    fdAdditionalFieldsComp = new FormData();
    fdAdditionalFieldsComp.left = new FormAttachment(0, 0);
    fdAdditionalFieldsComp.top = new FormAttachment(wStepname, margin);
    fdAdditionalFieldsComp.right = new FormAttachment(100, 0);
    fdAdditionalFieldsComp.bottom = new FormAttachment(100, 0);
    wAdditionalFieldsComp.setLayoutData(fdAdditionalFieldsComp);
    wAdditionalFieldsComp.layout();
    wAdditionalFieldsTab.setControl(wAdditionalFieldsComp);
// ///////////////////////////////////////////////////////////
// / END OF ADDITIONAL FIELDS TAB
// ///////////////////////////////////////////////////////////
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment) TextVar(org.pentaho.di.ui.core.widget.TextVar)

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