Search in sources :

Example 31 with StyledTextComp

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

the class JobEntryEvalTableContentDialog 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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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(JobEntryEvalTableContent.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
    wlLimit = new Label(wSuccessGroup, SWT.RIGHT);
    wlLimit.setText(BaseMessages.getString(PKG, "JobEntryEvalTableContent.Limit.Label"));
    props.setLook(wlLimit);
    fdlLimit = new FormData();
    fdlLimit.left = new FormAttachment(0, -margin);
    fdlLimit.top = new FormAttachment(wSuccessCondition, margin);
    fdlLimit.right = new FormAttachment(middle, -2 * margin);
    wlLimit.setLayoutData(fdlLimit);
    wLimit = new TextVar(jobMeta, wSuccessGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobEntryEvalTableContent.Limit.Tooltip"));
    props.setLook(wLimit);
    wLimit.addModifyListener(lsMod);
    fdLimit = new FormData();
    fdLimit.left = new FormAttachment(middle, -margin);
    fdLimit.top = new FormAttachment(wSuccessCondition, margin);
    fdLimit.right = new FormAttachment(100, -margin);
    wLimit.setLayoutData(fdLimit);
    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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContent.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, "JobEntryEvalTableContentDialogSize");
    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 32 with StyledTextComp

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

the class SalesforceInputDialog method setQueryToolTip.

protected void setQueryToolTip() {
    StyledTextComp control = wCondition;
    if (wspecifyQuery.getSelection()) {
        control = wQuery;
    }
    control.setToolTipText(transMeta.environmentSubstitute(control.getText()));
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp)

Example 33 with StyledTextComp

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

the class NotePadDialog method open.

public NotePadMeta open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.NONE);
    props.setLook(shell);
    shell.setImage(guiresource.getImageNoteSmall());
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(title);
    int margin = Const.MARGIN;
    int middle = 30;
    wNoteFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wNoteFolder, PropsUI.WIDGET_STYLE_TAB);
    // ////////////////////////
    // START OF NOTE CONTENT TAB///
    // /
    wNoteContentTab = new CTabItem(wNoteFolder, SWT.NONE);
    wNoteContentTab.setText(BaseMessages.getString(PKG, "NotePadDialog.ContentTab.Note"));
    Composite wNoteContentComp = new Composite(wNoteFolder, SWT.NONE);
    props.setLook(wNoteContentComp);
    FormLayout fileLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wNoteContentComp.setLayout(fileLayout);
    // From step line
    wlDesc = new Label(wNoteContentComp, SWT.NONE);
    wlDesc.setText(BaseMessages.getString(PKG, "NotePadDialog.ContentTab.Note.Label"));
    props.setLook(wlDesc);
    fdlDesc = new FormData();
    fdlDesc.left = new FormAttachment(0, 0);
    fdlDesc.top = new FormAttachment(0, margin);
    wlDesc.setLayoutData(fdlDesc);
    wDesc = new StyledTextComp(variables, wNoteContentComp, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
    wDesc.setText("");
    // props.setLook(wDesc, PropsUI.WIDGET_STYLE_FIXED);
    // props.setLook(wDesc);
    fdDesc = new FormData();
    fdDesc.left = new FormAttachment(0, 0);
    fdDesc.top = new FormAttachment(wlDesc, margin);
    fdDesc.right = new FormAttachment(100, -10);
    fdDesc.bottom = new FormAttachment(100, -margin);
    wDesc.setLayoutData(fdDesc);
    fdNoteContentComp = new FormData();
    fdNoteContentComp.left = new FormAttachment(0, 0);
    fdNoteContentComp.top = new FormAttachment(0, 0);
    fdNoteContentComp.right = new FormAttachment(100, 0);
    fdNoteContentComp.bottom = new FormAttachment(100, 0);
    wNoteContentComp.setLayoutData(fdNoteContentComp);
    wNoteContentComp.layout();
    wNoteContentTab.setControl(wNoteContentComp);
    // ///////////////////////////////////////////////////////////
    // / END OF NOTE CONTENT TAB
    // ///////////////////////////////////////////////////////////
    // ////////////////////////
    // START OF NOTE FONT TAB///
    // /
    wNoteFontTab = new CTabItem(wNoteFolder, SWT.NONE);
    wNoteFontTab.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Label"));
    Composite wNoteFontComp = new Composite(wNoteFolder, SWT.NONE);
    props.setLook(wNoteFontComp);
    FormLayout notefontLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wNoteFontComp.setLayout(notefontLayout);
    // Font name
    wlFontName = new Label(wNoteFontComp, SWT.RIGHT);
    wlFontName.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Name.Label"));
    props.setLook(wlFontName);
    fdlFontName = new FormData();
    fdlFontName.left = new FormAttachment(margin, margin);
    fdlFontName.top = new FormAttachment(0, 3 * margin);
    fdlFontName.right = new FormAttachment(middle, -margin);
    wlFontName.setLayoutData(fdlFontName);
    wFontName = new CCombo(wNoteFontComp, SWT.BORDER | SWT.READ_ONLY);
    wFontName.setItems(Const.GetAvailableFontNames());
    props.setLook(wFontName);
    fdFontName = new FormData();
    fdFontName.left = new FormAttachment(middle, 0);
    fdFontName.top = new FormAttachment(0, 3 * margin);
    fdFontName.right = new FormAttachment(100, -margin);
    wFontName.setLayoutData(fdFontName);
    wFontName.select(0);
    wFontName.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            refreshTextNote();
        }
    });
    // FontSize line
    wlFontSize = new Label(wNoteFontComp, SWT.RIGHT);
    wlFontSize.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Size.Label"));
    props.setLook(wlFontSize);
    fdlFontSize = new FormData();
    fdlFontSize.left = new FormAttachment(margin, margin);
    fdlFontSize.top = new FormAttachment(wFontName, margin);
    fdlFontSize.right = new FormAttachment(middle, -margin);
    wlFontSize.setLayoutData(fdlFontSize);
    wFontSize = new Spinner(wNoteFontComp, SWT.BORDER);
    wFontSize.setMinimum(0);
    wFontSize.setMaximum(70);
    wFontSize.setIncrement(1);
    fdFontSize = new FormData();
    fdFontSize.left = new FormAttachment(middle, 0);
    fdFontSize.top = new FormAttachment(wFontName, margin);
    fdFontSize.right = new FormAttachment(100, -margin);
    wFontSize.setLayoutData(fdFontSize);
    wFontSize.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            refreshTextNote();
        }
    });
    // Font bold?
    wlFontBold = new Label(wNoteFontComp, SWT.RIGHT);
    wlFontBold.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Bold.Label"));
    props.setLook(wlFontBold);
    fdlFontBold = new FormData();
    fdlFontBold.left = new FormAttachment(margin, margin);
    fdlFontBold.top = new FormAttachment(wFontSize, margin);
    fdlFontBold.right = new FormAttachment(middle, -margin);
    wlFontBold.setLayoutData(fdlFontBold);
    wFontBold = new Button(wNoteFontComp, SWT.CHECK);
    props.setLook(wFontBold);
    fdFontBold = new FormData();
    fdFontBold.left = new FormAttachment(middle, 0);
    fdFontBold.top = new FormAttachment(wFontSize, margin);
    fdFontBold.right = new FormAttachment(100, -margin);
    wFontBold.setLayoutData(fdFontBold);
    wFontBold.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            refreshTextNote();
        }
    });
    // Font Italic?
    wlFontItalic = new Label(wNoteFontComp, SWT.RIGHT);
    wlFontItalic.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Italic.Label"));
    props.setLook(wlFontItalic);
    fdlFontItalic = new FormData();
    fdlFontItalic.left = new FormAttachment(margin, margin);
    fdlFontItalic.top = new FormAttachment(wFontBold, margin);
    fdlFontItalic.right = new FormAttachment(middle, -margin);
    wlFontItalic.setLayoutData(fdlFontItalic);
    wFontItalic = new Button(wNoteFontComp, SWT.CHECK);
    props.setLook(wFontItalic);
    fdFontItalic = new FormData();
    fdFontItalic.left = new FormAttachment(middle, 0);
    fdFontItalic.top = new FormAttachment(wFontBold, margin);
    fdFontItalic.right = new FormAttachment(100, -margin);
    wFontItalic.setLayoutData(fdFontItalic);
    wFontItalic.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            refreshTextNote();
        }
    });
    // Font color line
    wlFontColor = new Label(wNoteFontComp, SWT.RIGHT);
    wlFontColor.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Color.Label"));
    props.setLook(wlFontColor);
    fdlFontColor = new FormData();
    fdlFontColor.left = new FormAttachment(margin, margin);
    fdlFontColor.top = new FormAttachment(wFontItalic, 2 * margin);
    fdlFontColor.right = new FormAttachment(middle, -margin);
    wlFontColor.setLayoutData(fdlFontColor);
    // Change font color
    wbFontColorChange = new Button(wNoteFontComp, SWT.PUSH);
    wbFontColorChange.setImage(guiresource.getImageColor());
    wbFontColorChange.setToolTipText(BaseMessages.getString(PKG, "NotePadDialog.Font.Color.Change.Tooltip"));
    props.setLook(wbFontColorChange);
    fdFontColorChange = new FormData();
    fdFontColorChange.top = new FormAttachment(wFontItalic, 2 * margin);
    fdFontColorChange.right = new FormAttachment(100, -margin);
    wbFontColorChange.setLayoutData(fdFontColorChange);
    wbFontColorChange.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ColorDialog cd = new ColorDialog(shell);
            cd.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Color.Dialog.Label"));
            cd.setRGB(wFontColor.getBackground().getRGB());
            RGB newColor = cd.open();
            if (newColor == null) {
                return;
            }
            fontColor.dispose();
            fontColor = new Color(shell.getDisplay(), newColor);
            wFontColor.setBackground(fontColor);
            refreshTextNote();
        }
    });
    // Font color
    wFontColor = new Label(wNoteFontComp, SWT.NONE);
    wFontColor.setToolTipText(BaseMessages.getString(PKG, "NotePadDialog.Font.Color.Tooltip"));
    props.setLook(wFontColor);
    wFontColor.setEnabled(false);
    fdFontColor = new FormData();
    fdFontColor.left = new FormAttachment(wlFontColor, margin);
    fdFontColor.top = new FormAttachment(wFontItalic, 2 * margin);
    fdFontColor.right = new FormAttachment(wbFontColorChange, -margin);
    wFontColor.setLayoutData(fdFontColor);
    // Background color line
    wlBackGroundColor = new Label(wNoteFontComp, SWT.RIGHT);
    wlBackGroundColor.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.BackGroundColor.Label"));
    props.setLook(wlBackGroundColor);
    fdlBackGroundColor = new FormData();
    fdlBackGroundColor.left = new FormAttachment(margin, margin);
    fdlBackGroundColor.top = new FormAttachment(wFontColor, 2 * margin);
    fdlBackGroundColor.right = new FormAttachment(middle, -margin);
    wlBackGroundColor.setLayoutData(fdlBackGroundColor);
    // Change Background color
    wbBackGroundColorChange = new Button(wNoteFontComp, SWT.PUSH);
    wbBackGroundColorChange.setImage(guiresource.getImageColor());
    wbBackGroundColorChange.setToolTipText(BaseMessages.getString(PKG, "NotePadDialog.Font.BackGroundColor.Change.Tooltip"));
    props.setLook(wbBackGroundColorChange);
    fdBackGroundColorChange = new FormData();
    fdBackGroundColorChange.top = new FormAttachment(wFontColor, 2 * margin);
    fdBackGroundColorChange.right = new FormAttachment(100, -margin);
    fdBackGroundColorChange.right = new FormAttachment(100, -margin);
    wbBackGroundColorChange.setLayoutData(fdBackGroundColorChange);
    wbBackGroundColorChange.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ColorDialog cd = new ColorDialog(shell);
            cd.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Color.Dialog.Label"));
            cd.setRGB(wBackGroundColor.getBackground().getRGB());
            RGB newColor = cd.open();
            if (newColor == null) {
                return;
            }
            bgColor.dispose();
            bgColor = new Color(shell.getDisplay(), newColor);
            wBackGroundColor.setBackground(bgColor);
            refreshTextNote();
        }
    });
    // Background color
    wBackGroundColor = new Label(wNoteFontComp, SWT.BORDER);
    wBackGroundColor.setToolTipText(BaseMessages.getString(PKG, "NotePadDialog.Font.BackGroundColor.Tooltip"));
    props.setLook(wBackGroundColor);
    wBackGroundColor.setEnabled(false);
    fdBackGroundColor = new FormData();
    fdBackGroundColor.left = new FormAttachment(wlBackGroundColor, margin);
    fdBackGroundColor.top = new FormAttachment(wFontColor, 2 * margin);
    fdBackGroundColor.right = new FormAttachment(wbBackGroundColorChange, -margin);
    wBackGroundColor.setLayoutData(fdBackGroundColor);
    // Border color line
    wlBorderColor = new Label(wNoteFontComp, SWT.RIGHT);
    wlBorderColor.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.BorderColor.Label"));
    props.setLook(wlBorderColor);
    fdlBorderColor = new FormData();
    fdlBorderColor.left = new FormAttachment(margin, margin);
    fdlBorderColor.top = new FormAttachment(wBackGroundColor, 2 * margin);
    fdlBorderColor.right = new FormAttachment(middle, -margin);
    wlBorderColor.setLayoutData(fdlBorderColor);
    // Change border color
    wbBorderColorChange = new Button(wNoteFontComp, SWT.PUSH);
    wbBorderColorChange.setImage(guiresource.getImageColor());
    wbBorderColorChange.setToolTipText(BaseMessages.getString(PKG, "NotePadDialog.Font.BorderColor.Change.Tooltip"));
    props.setLook(wbBorderColorChange);
    fdBorderColorChange = new FormData();
    fdBorderColorChange.top = new FormAttachment(wBackGroundColor, 2 * margin);
    fdBorderColorChange.right = new FormAttachment(100, -margin);
    wbBorderColorChange.setLayoutData(fdBorderColorChange);
    wbBorderColorChange.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ColorDialog cd = new ColorDialog(shell);
            cd.setText(BaseMessages.getString(PKG, "NotePadDialog.Font.Color.Dialog.Label"));
            cd.setRGB(wBorderColor.getBackground().getRGB());
            RGB newColor = cd.open();
            if (newColor == null) {
                return;
            }
            borderColor.dispose();
            borderColor = new Color(shell.getDisplay(), newColor);
            wBorderColor.setBackground(borderColor);
        }
    });
    // border color
    wBorderColor = new Label(wNoteFontComp, SWT.BORDER);
    wBorderColor.setToolTipText(BaseMessages.getString(PKG, "NotePadDialog.Font.BorderColor.Tooltip"));
    props.setLook(wBorderColor);
    wBorderColor.setEnabled(false);
    fdBorderColor = new FormData();
    fdBorderColor.left = new FormAttachment(wlBorderColor, margin);
    fdBorderColor.top = new FormAttachment(wBackGroundColor, 2 * margin);
    fdBorderColor.right = new FormAttachment(wbBorderColorChange, -margin);
    wBorderColor.setLayoutData(fdBorderColor);
    // Draw note?
    wlDrawShadow = new Label(wNoteFontComp, SWT.RIGHT);
    wlDrawShadow.setText(BaseMessages.getString(PKG, "NotePadDialog.DrawShadow.Label"));
    props.setLook(wlDrawShadow);
    fdlDrawShadow = new FormData();
    fdlDrawShadow.left = new FormAttachment(margin, margin);
    fdlDrawShadow.top = new FormAttachment(wBorderColor, margin);
    fdlDrawShadow.right = new FormAttachment(middle, -margin);
    wlDrawShadow.setLayoutData(fdlDrawShadow);
    wDrawShadow = new Button(wNoteFontComp, SWT.CHECK);
    wDrawShadow.setToolTipText(BaseMessages.getString(PKG, "NotePadDialog.DrawShadow.Tooltip"));
    props.setLook(wDrawShadow);
    fdDrawShadow = new FormData();
    fdDrawShadow.left = new FormAttachment(middle, 0);
    fdDrawShadow.top = new FormAttachment(wBorderColor, margin);
    fdDrawShadow.right = new FormAttachment(100, -margin);
    wDrawShadow.setLayoutData(fdDrawShadow);
    fdNoteFontComp = new FormData();
    fdNoteFontComp.left = new FormAttachment(0, 0);
    fdNoteFontComp.top = new FormAttachment(0, 0);
    fdNoteFontComp.right = new FormAttachment(100, 0);
    fdNoteFontComp.bottom = new FormAttachment(100, 0);
    wNoteFontComp.setLayoutData(fdNoteFontComp);
    wNoteFontComp.layout();
    wNoteFontTab.setControl(wNoteFontComp);
    // ///////////////////////////////////////////////////////////
    // / END OF NOTE FONT TAB
    // ///////////////////////////////////////////////////////////
    fdNoteFolder = new FormData();
    fdNoteFolder.left = new FormAttachment(0, 0);
    fdNoteFolder.top = new FormAttachment(0, margin);
    fdNoteFolder.right = new FormAttachment(100, 0);
    fdNoteFolder.bottom = new FormAttachment(100, -50);
    wNoteFolder.setLayoutData(fdNoteFolder);
    // Some buttons
    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, wNoteFolder);
    // Add listeners
    lsCancel = new Listener() {

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

        public void handleEvent(Event e) {
            ok();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    // 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 notePadMeta;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) ShellAdapter(org.eclipse.swt.events.ShellAdapter) CTabFolder(org.eclipse.swt.custom.CTabFolder) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) RGB(org.eclipse.swt.graphics.RGB) CTabItem(org.eclipse.swt.custom.CTabItem) Shell(org.eclipse.swt.widgets.Shell) ColorDialog(org.eclipse.swt.widgets.ColorDialog) CCombo(org.eclipse.swt.custom.CCombo) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) 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 34 with StyledTextComp

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

the class WriteToLogDialog method open.

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

        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    SelectionAdapter lsSelMod = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    };
    SelectionAdapter lsLimitRows = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            enableFields();
        }
    };
    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, "WriteToLogDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "WriteToLogDialog.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);
    // Log Level
    wlLoglevel = new Label(shell, SWT.RIGHT);
    wlLoglevel.setText(BaseMessages.getString(PKG, "WriteToLogDialog.Loglevel.Label"));
    props.setLook(wlLoglevel);
    fdlLoglevel = new FormData();
    fdlLoglevel.left = new FormAttachment(0, 0);
    fdlLoglevel.right = new FormAttachment(middle, -margin);
    fdlLoglevel.top = new FormAttachment(wStepname, margin);
    wlLoglevel.setLayoutData(fdlLoglevel);
    wLoglevel = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wLoglevel.setItems(LogLevel.getLogLevelDescriptions());
    props.setLook(wLoglevel);
    fdLoglevel = new FormData();
    fdLoglevel.left = new FormAttachment(middle, 0);
    fdLoglevel.top = new FormAttachment(wStepname, margin);
    fdLoglevel.right = new FormAttachment(100, 0);
    wLoglevel.setLayoutData(fdLoglevel);
    wLoglevel.addSelectionListener(lsSelMod);
    // print header?
    wlPrintHeader = new Label(shell, SWT.RIGHT);
    wlPrintHeader.setText(BaseMessages.getString(PKG, "WriteToLogDialog.PrintHeader.Label"));
    props.setLook(wlPrintHeader);
    fdlPrintHeader = new FormData();
    fdlPrintHeader.left = new FormAttachment(0, 0);
    fdlPrintHeader.top = new FormAttachment(wLoglevel, margin);
    fdlPrintHeader.right = new FormAttachment(middle, -margin);
    wlPrintHeader.setLayoutData(fdlPrintHeader);
    wPrintHeader = new Button(shell, SWT.CHECK);
    wPrintHeader.setToolTipText(BaseMessages.getString(PKG, "WriteToLogDialog.PrintHeader.Tooltip"));
    props.setLook(wPrintHeader);
    fdPrintHeader = new FormData();
    fdPrintHeader.left = new FormAttachment(middle, 0);
    fdPrintHeader.top = new FormAttachment(wLoglevel, margin);
    fdPrintHeader.right = new FormAttachment(100, 0);
    wPrintHeader.setLayoutData(fdPrintHeader);
    wPrintHeader.addSelectionListener(lsSelMod);
    // Limit output?
    // Cache?
    wlLimitRows = new Label(shell, SWT.RIGHT);
    wlLimitRows.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.LimitRows.Label"));
    props.setLook(wlLimitRows);
    fdlLimitRows = new FormData();
    fdlLimitRows.left = new FormAttachment(0, 0);
    fdlLimitRows.right = new FormAttachment(middle, -margin);
    fdlLimitRows.top = new FormAttachment(wPrintHeader, margin);
    wlLimitRows.setLayoutData(fdlLimitRows);
    wLimitRows = new Button(shell, SWT.CHECK);
    props.setLook(wLimitRows);
    fdLimitRows = new FormData();
    fdLimitRows.left = new FormAttachment(middle, 0);
    fdLimitRows.top = new FormAttachment(wPrintHeader, margin);
    wLimitRows.setLayoutData(fdLimitRows);
    wLimitRows.addSelectionListener(lsLimitRows);
    // LimitRows size line
    wlLimitRowsNumber = new Label(shell, SWT.RIGHT);
    wlLimitRowsNumber.setText(BaseMessages.getString(PKG, "DatabaseLookupDialog.LimitRowsNumber.Label"));
    props.setLook(wlLimitRowsNumber);
    wlLimitRowsNumber.setEnabled(input.isLimitRows());
    fdlLimitRowsNumber = new FormData();
    fdlLimitRowsNumber.left = new FormAttachment(0, 0);
    fdlLimitRowsNumber.right = new FormAttachment(middle, -margin);
    fdlLimitRowsNumber.top = new FormAttachment(wLimitRows, margin);
    wlLimitRowsNumber.setLayoutData(fdlLimitRowsNumber);
    wLimitRowsNumber = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLimitRowsNumber);
    wLimitRowsNumber.setEnabled(input.isLimitRows());
    wLimitRowsNumber.addModifyListener(lsMod);
    fdLimitRowsNumber = new FormData();
    fdLimitRowsNumber.left = new FormAttachment(middle, 0);
    fdLimitRowsNumber.right = new FormAttachment(100, 0);
    fdLimitRowsNumber.top = new FormAttachment(wLimitRows, margin);
    wLimitRowsNumber.setLayoutData(fdLimitRowsNumber);
    // Log message to display
    wlLogMessage = new Label(shell, SWT.RIGHT);
    wlLogMessage.setText(BaseMessages.getString(PKG, "WriteToLogDialog.Shell.Title"));
    props.setLook(wlLogMessage);
    fdlLogMessage = new FormData();
    fdlLogMessage.left = new FormAttachment(0, 0);
    fdlLogMessage.top = new FormAttachment(wLimitRowsNumber, margin);
    fdlLogMessage.right = new FormAttachment(middle, -margin);
    wlLogMessage.setLayoutData(fdlLogMessage);
    wLogMessage = new StyledTextComp(transMeta, shell, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
    props.setLook(wLogMessage, Props.WIDGET_STYLE_FIXED);
    wLogMessage.addModifyListener(lsMod);
    fdLogMessage = new FormData();
    fdLogMessage.left = new FormAttachment(middle, 0);
    fdLogMessage.top = new FormAttachment(wLimitRowsNumber, margin);
    fdLogMessage.right = new FormAttachment(100, -2 * margin);
    fdLogMessage.height = 125;
    wLogMessage.setLayoutData(fdLogMessage);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "System.Button.GetFields"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wGet, wCancel }, margin, null);
    // Table with fields
    wlFields = new Label(shell, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "WriteToLogDialog.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.top = new FormAttachment(wLogMessage, margin);
    wlFields.setLayoutData(fdlFields);
    final int FieldsCols = 1;
    final int FieldsRows = input.getFieldName().length;
    colinf = new ColumnInfo[FieldsCols];
    colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "WriteToLogDialog.Fieldname.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
    wFields = new TableView(transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(wOK, -2 * margin);
    wFields.setLayoutData(fdFields);
    // 
    // 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(), Integer.valueOf(i));
                    }
                    setComboBoxes();
                } catch (KettleException e) {
                    logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
                }
            }
        }
    };
    new Thread(runnable).start();
    // Add listeners
    lsCancel = new Listener() {

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

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

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

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

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) 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) TableView(org.pentaho.di.ui.core.widget.TableView) 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) CCombo(org.eclipse.swt.custom.CCombo) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display)

Example 35 with StyledTextComp

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

the class SSHDialog method open.

@Override
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() {

        @Override
        public void modifyText(ModifyEvent e) {
            input.setChanged();
        }
    };
    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, "SSHDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "SSHDialog.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);
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, PropsUI.WIDGET_STYLE_TAB);
    // ////////////////////////
    // START OF GENERAL TAB ///
    // ////////////////////////
    wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
    wGeneralTab.setText(BaseMessages.getString(PKG, "SSHDialog.General.Tab"));
    wGeneralComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wGeneralComp);
    FormLayout fileLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wGeneralComp.setLayout(fileLayout);
    // ///////////////////////////////
    // START OF Settings GROUP //
    // ///////////////////////////////
    wSettingsGroup = new Group(wGeneralComp, SWT.SHADOW_NONE);
    props.setLook(wSettingsGroup);
    wSettingsGroup.setText(BaseMessages.getString(PKG, "SSHDialog.wSettingsGroup.Label"));
    FormLayout settingGroupLayout = new FormLayout();
    settingGroupLayout.marginWidth = 10;
    settingGroupLayout.marginHeight = 10;
    wSettingsGroup.setLayout(settingGroupLayout);
    // Server port line
    wServerName = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.Server.Label"), BaseMessages.getString(PKG, "SSHDialog.Server.Tooltip"));
    props.setLook(wServerName);
    wServerName.addModifyListener(lsMod);
    fdServerName = new FormData();
    fdServerName.left = new FormAttachment(0, 0);
    fdServerName.top = new FormAttachment(wStepname, margin);
    fdServerName.right = new FormAttachment(100, 0);
    wServerName.setLayoutData(fdServerName);
    // Server port line
    wPort = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.Port.Label"), BaseMessages.getString(PKG, "SSHDialog.Port.Tooltip"));
    props.setLook(wPort);
    wPort.addModifyListener(lsMod);
    fdPort = new FormData();
    fdPort.left = new FormAttachment(0, 0);
    fdPort.top = new FormAttachment(wServerName, margin);
    fdPort.right = new FormAttachment(100, 0);
    wPort.setLayoutData(fdPort);
    // Server TimeOut line
    wTimeOut = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.TimeOut.Label"), BaseMessages.getString(PKG, "SSHDialog.TimeOut.Tooltip"));
    props.setLook(wTimeOut);
    wTimeOut.addModifyListener(lsMod);
    fdTimeOut = new FormData();
    fdTimeOut.left = new FormAttachment(0, 0);
    fdTimeOut.top = new FormAttachment(wPort, margin);
    fdTimeOut.right = new FormAttachment(100, 0);
    wTimeOut.setLayoutData(fdTimeOut);
    // Usernameline
    wUserName = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.UserName.Label"), BaseMessages.getString(PKG, "SSHDialog.UserName.Tooltip"));
    props.setLook(wUserName);
    wUserName.addModifyListener(lsMod);
    fdUserName = new FormData();
    fdUserName.left = new FormAttachment(0, 0);
    fdUserName.top = new FormAttachment(wTimeOut, margin);
    fdUserName.right = new FormAttachment(100, 0);
    wUserName.setLayoutData(fdUserName);
    // Passwordline
    wPassword = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.Password.Label"), BaseMessages.getString(PKG, "SSHDialog.Password.Tooltip"), true);
    props.setLook(wPassword);
    wPassword.addModifyListener(lsMod);
    fdPassword = new FormData();
    fdPassword.left = new FormAttachment(0, 0);
    fdPassword.top = new FormAttachment(wUserName, margin);
    fdPassword.right = new FormAttachment(100, 0);
    wPassword.setLayoutData(fdPassword);
    // Use key?
    wlUseKey = new Label(wSettingsGroup, SWT.RIGHT);
    wlUseKey.setText(BaseMessages.getString(PKG, "SSHDialog.UseKey.Label"));
    props.setLook(wlUseKey);
    fdlUseKey = new FormData();
    fdlUseKey.left = new FormAttachment(0, 0);
    fdlUseKey.top = new FormAttachment(wPassword, margin);
    fdlUseKey.right = new FormAttachment(middle, -margin);
    wlUseKey.setLayoutData(fdlUseKey);
    wUseKey = new Button(wSettingsGroup, SWT.CHECK);
    props.setLook(wUseKey);
    wUseKey.setToolTipText(BaseMessages.getString(PKG, "SSHDialog.UseKey.Tooltip"));
    fdUseKey = new FormData();
    fdUseKey.left = new FormAttachment(middle, margin);
    fdUseKey.top = new FormAttachment(wPassword, margin);
    fdUseKey.right = new FormAttachment(100, 0);
    wUseKey.setLayoutData(fdUseKey);
    wUseKey.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            activateKey();
        }
    });
    wbFilename = new Button(wSettingsGroup, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, -margin);
    fdbFilename.top = new FormAttachment(wUseKey, margin);
    wbFilename.setLayoutData(fdbFilename);
    wbFilename.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*.pem", "*" });
            if (wPrivateKey.getText() != null) {
                dialog.setFileName(transMeta.environmentSubstitute(wPrivateKey.getText()));
            }
            dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.PEMFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
            if (dialog.open() != null) {
                wPrivateKey.setText(dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName());
            }
        }
    });
    // Private key
    wPrivateKey = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.PrivateKey.Label"), BaseMessages.getString(PKG, "SSHDialog.PrivateKey.Tooltip"));
    props.setLook(wPassword);
    wPrivateKey.addModifyListener(lsMod);
    fdPrivateKey = new FormData();
    fdPrivateKey.left = new FormAttachment(0, 5 * margin);
    fdPrivateKey.top = new FormAttachment(wUseKey, margin);
    fdPrivateKey.right = new FormAttachment(wbFilename, -margin);
    wPrivateKey.setLayoutData(fdPrivateKey);
    // Passphraseline
    wPassphrase = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.Passphrase.Label"), BaseMessages.getString(PKG, "SSHDialog.Passphrase.Tooltip"), true);
    props.setLook(wPassphrase);
    wPassphrase.addModifyListener(lsMod);
    fdPassphrase = new FormData();
    fdPassphrase.left = new FormAttachment(0, 0);
    fdPassphrase.top = new FormAttachment(wbFilename, margin);
    fdPassphrase.right = new FormAttachment(100, 0);
    wPassphrase.setLayoutData(fdPassphrase);
    // ProxyHostline
    wProxyHost = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.ProxyHost.Label"), BaseMessages.getString(PKG, "SSHDialog.ProxyHost.Tooltip"));
    props.setLook(wProxyHost);
    wProxyHost.addModifyListener(lsMod);
    fdProxyHost = new FormData();
    fdProxyHost.left = new FormAttachment(0, 0);
    fdProxyHost.top = new FormAttachment(wPassphrase, 2 * margin);
    fdProxyHost.right = new FormAttachment(100, 0);
    wProxyHost.setLayoutData(fdProxyHost);
    // ProxyPortline
    wProxyPort = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.ProxyPort.Label"), BaseMessages.getString(PKG, "SSHDialog.ProxyPort.Tooltip"));
    props.setLook(wProxyPort);
    wProxyPort.addModifyListener(lsMod);
    fdProxyPort = new FormData();
    fdProxyPort.left = new FormAttachment(0, 0);
    fdProxyPort.top = new FormAttachment(wProxyHost, margin);
    fdProxyPort.right = new FormAttachment(100, 0);
    wProxyPort.setLayoutData(fdProxyPort);
    // ProxyUsernameline
    wProxyUsername = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.ProxyUsername.Label"), BaseMessages.getString(PKG, "SSHDialog.ProxyUsername.Tooltip"));
    props.setLook(wProxyUsername);
    wProxyUsername.addModifyListener(lsMod);
    fdProxyUsername = new FormData();
    fdProxyUsername.left = new FormAttachment(0, 0);
    fdProxyUsername.top = new FormAttachment(wProxyPort, margin);
    fdProxyUsername.right = new FormAttachment(100, 0);
    wProxyUsername.setLayoutData(fdProxyUsername);
    // ProxyUsernameline
    wProxyPassword = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SSHDialog.ProxyPassword.Label"), BaseMessages.getString(PKG, "SSHDialog.ProxyPassword.Tooltip"), true);
    props.setLook(wProxyUsername);
    wProxyPassword.addModifyListener(lsMod);
    fdProxyPassword = new FormData();
    fdProxyPassword.left = new FormAttachment(0, 0);
    fdProxyPassword.top = new FormAttachment(wProxyUsername, margin);
    fdProxyPassword.right = new FormAttachment(100, 0);
    wProxyPassword.setLayoutData(fdProxyPassword);
    // Test connection button
    wTest = new Button(wSettingsGroup, SWT.PUSH);
    wTest.setText(BaseMessages.getString(PKG, "SSHDialog.TestConnection.Label"));
    props.setLook(wTest);
    fdTest = new FormData();
    wTest.setToolTipText(BaseMessages.getString(PKG, "SSHDialog.TestConnection.Tooltip"));
    fdTest.top = new FormAttachment(wProxyPassword, 2 * margin);
    fdTest.right = new FormAttachment(100, 0);
    wTest.setLayoutData(fdTest);
    fdSettingsGroup = new FormData();
    fdSettingsGroup.left = new FormAttachment(0, margin);
    fdSettingsGroup.top = new FormAttachment(wStepname, margin);
    fdSettingsGroup.right = new FormAttachment(100, -margin);
    wSettingsGroup.setLayoutData(fdSettingsGroup);
    // ///////////////////////////////
    // END OF Settings Fields GROUP //
    fdGeneralComp = new FormData();
    fdGeneralComp.left = new FormAttachment(0, 0);
    fdGeneralComp.top = new FormAttachment(0, 0);
    fdGeneralComp.right = new FormAttachment(100, 0);
    fdGeneralComp.bottom = new FormAttachment(100, 0);
    wGeneralComp.setLayoutData(fdGeneralComp);
    wGeneralComp.layout();
    wGeneralTab.setControl(wGeneralComp);
    // ///////////////////////////////////////////////////////////
    // / END OF GENERAL TAB
    // ///////////////////////////////////////////////////////////
    // ////////////////////////
    // START OF Settings TAB///
    // /
    wSettingsTab = new CTabItem(wTabFolder, SWT.NONE);
    wSettingsTab.setText(BaseMessages.getString(PKG, "SSHDialog.Settings.Tab"));
    FormLayout SettingsLayout = new FormLayout();
    SettingsLayout.marginWidth = 3;
    SettingsLayout.marginHeight = 3;
    wSettingsComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wSettingsComp);
    wSettingsComp.setLayout(SettingsLayout);
    // ///////////////////////////////
    // START OF Output GROUP //
    // ///////////////////////////////
    wOutput = new Group(wSettingsComp, SWT.SHADOW_NONE);
    props.setLook(wOutput);
    wOutput.setText(BaseMessages.getString(PKG, "SSHDialog.wOutput.Label"));
    FormLayout outputGroupLayout = new FormLayout();
    outputGroupLayout.marginWidth = 10;
    outputGroupLayout.marginHeight = 10;
    wOutput.setLayout(outputGroupLayout);
    // ResultOutFieldNameline
    wResultOutFieldName = new LabelTextVar(transMeta, wOutput, BaseMessages.getString(PKG, "SSHDialog.ResultOutFieldName.Label"), BaseMessages.getString(PKG, "SSHDialog.ResultOutFieldName.Tooltip"));
    props.setLook(wResultOutFieldName);
    wResultOutFieldName.addModifyListener(lsMod);
    fdResultOutFieldName = new FormData();
    fdResultOutFieldName.left = new FormAttachment(0, 0);
    fdResultOutFieldName.top = new FormAttachment(wStepname, margin);
    fdResultOutFieldName.right = new FormAttachment(100, 0);
    wResultOutFieldName.setLayoutData(fdResultOutFieldName);
    // ResultErrFieldNameline
    wResultErrFieldName = new LabelTextVar(transMeta, wOutput, BaseMessages.getString(PKG, "SSHDialog.ResultErrFieldName.Label"), BaseMessages.getString(PKG, "SSHDialog.ResultErrFieldName.Tooltip"));
    props.setLook(wResultErrFieldName);
    wResultErrFieldName.addModifyListener(lsMod);
    fdResultErrFieldName = new FormData();
    fdResultErrFieldName.left = new FormAttachment(0, 0);
    fdResultErrFieldName.top = new FormAttachment(wResultOutFieldName, margin);
    fdResultErrFieldName.right = new FormAttachment(100, 0);
    wResultErrFieldName.setLayoutData(fdResultErrFieldName);
    fdOutput = new FormData();
    fdOutput.left = new FormAttachment(0, margin);
    fdOutput.top = new FormAttachment(wStepname, margin);
    fdOutput.right = new FormAttachment(100, -margin);
    wOutput.setLayoutData(fdOutput);
    // ///////////////////////////////
    // END OF Output Fields GROUP //
    // ////////////////////////
    // START OF Commands SETTINGS GROUP///
    // /
    wCommands = new Group(wSettingsComp, SWT.SHADOW_NONE);
    props.setLook(wCommands);
    wCommands.setText(BaseMessages.getString(PKG, "SSHDialog.LogSettings.Group.Label"));
    FormLayout LogSettingsgroupLayout = new FormLayout();
    LogSettingsgroupLayout.marginWidth = 10;
    LogSettingsgroupLayout.marginHeight = 10;
    wCommands.setLayout(LogSettingsgroupLayout);
    // Is command defined in a Field
    wldynamicCommand = new Label(wCommands, SWT.RIGHT);
    wldynamicCommand.setText(BaseMessages.getString(PKG, "SSHDialog.dynamicCommand.Label"));
    props.setLook(wldynamicCommand);
    fdlynamicBase = new FormData();
    fdlynamicBase.left = new FormAttachment(0, margin);
    fdlynamicBase.top = new FormAttachment(wOutput, margin);
    fdlynamicBase.right = new FormAttachment(middle, -margin);
    wldynamicCommand.setLayoutData(fdlynamicBase);
    wdynamicCommand = new Button(wCommands, SWT.CHECK);
    props.setLook(wdynamicCommand);
    wdynamicCommand.setToolTipText(BaseMessages.getString(PKG, "SSHDialog.dynamicCommand.Tooltip"));
    fdynamicCommand = new FormData();
    fdynamicCommand.left = new FormAttachment(middle, margin);
    fdynamicCommand.top = new FormAttachment(wOutput, margin);
    wdynamicCommand.setLayoutData(fdynamicCommand);
    SelectionAdapter ldynamicCommand = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            activateDynamicCommand();
            input.setChanged();
        }
    };
    wdynamicCommand.addSelectionListener(ldynamicCommand);
    // CommandField field
    wlCommandField = new Label(wCommands, SWT.RIGHT);
    wlCommandField.setText(BaseMessages.getString(PKG, "SSHDialog.MessageNameField.Label"));
    props.setLook(wlCommandField);
    fdlCommandField = new FormData();
    fdlCommandField.left = new FormAttachment(0, margin);
    fdlCommandField.right = new FormAttachment(middle, -margin);
    fdlCommandField.top = new FormAttachment(wdynamicCommand, margin);
    wlCommandField.setLayoutData(fdlCommandField);
    wCommandField = new CCombo(wCommands, SWT.BORDER | SWT.READ_ONLY);
    props.setLook(wCommandField);
    wCommandField.setEditable(true);
    wCommandField.addModifyListener(lsMod);
    fdCommandField = new FormData();
    fdCommandField.left = new FormAttachment(middle, margin);
    fdCommandField.top = new FormAttachment(wdynamicCommand, margin);
    fdCommandField.right = new FormAttachment(100, 0);
    wCommandField.setLayoutData(fdCommandField);
    wCommandField.addFocusListener(new FocusListener() {

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

        @Override
        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            get();
        }
    });
    // Command String
    wlCommand = new Label(wCommands, SWT.RIGHT);
    wlCommand.setText(BaseMessages.getString(PKG, "SSHDialog.Command.Label"));
    props.setLook(wlCommand);
    fdlCommand = new FormData();
    fdlCommand.left = new FormAttachment(0, margin);
    fdlCommand.top = new FormAttachment(wCommandField, margin);
    fdlCommand.right = new FormAttachment(middle, -2 * margin);
    wlCommand.setLayoutData(fdlCommand);
    wCommand = new StyledTextComp(transMeta, wCommands, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
    wCommand.setToolTipText(BaseMessages.getString(PKG, "SSHDialog.Command.Tooltip"));
    props.setLook(wCommand);
    wCommand.addModifyListener(lsMod);
    fdCommand = new FormData();
    fdCommand.left = new FormAttachment(middle, margin);
    fdCommand.top = new FormAttachment(wCommandField, margin);
    fdCommand.right = new FormAttachment(100, -2 * margin);
    fdCommand.bottom = new FormAttachment(100, -margin);
    wCommand.setLayoutData(fdCommand);
    fdLogSettings = new FormData();
    fdLogSettings.left = new FormAttachment(0, margin);
    fdLogSettings.top = new FormAttachment(wOutput, margin);
    fdLogSettings.right = new FormAttachment(100, -margin);
    fdLogSettings.bottom = new FormAttachment(100, -margin);
    wCommands.setLayoutData(fdLogSettings);
    // ///////////////////////////////////////////////////////////
    // / END OF Log SETTINGS GROUP
    // ///////////////////////////////////////////////////////////
    fdSettingsComp = new FormData();
    fdSettingsComp.left = new FormAttachment(0, 0);
    fdSettingsComp.top = new FormAttachment(0, 0);
    fdSettingsComp.right = new FormAttachment(100, 0);
    fdSettingsComp.bottom = new FormAttachment(100, 0);
    wSettingsComp.setLayoutData(fdSettingsComp);
    wSettingsComp.layout();
    wSettingsTab.setControl(wSettingsComp);
    // ///////////////////////////////////////////////////////////
    // / END OF Settings TAB
    // ///////////////////////////////////////////////////////////
    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wStepname, margin);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);
    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wPreview = new Button(shell, SWT.PUSH);
    wPreview.setText(BaseMessages.getString(PKG, "SSHDialog.Button.PreviewRows"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    setButtonPositions(new Button[] { wOK, wPreview, wCancel }, margin, wTabFolder);
    // Add listeners
    lsOK = new Listener() {

        @Override
        public void handleEvent(Event e) {
            ok();
        }
    };
    lsPreview = new Listener() {

        @Override
        public void handleEvent(Event e) {
            preview();
        }
    };
    lsCancel = new Listener() {

        @Override
        public void handleEvent(Event e) {
            cancel();
        }
    };
    lsTest = new Listener() {

        @Override
        public void handleEvent(Event e) {
            test();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wCancel.addListener(SWT.Selection, lsCancel);
    wPreview.addListener(SWT.Selection, lsPreview);
    wTest.addListener(SWT.Selection, lsTest);
    lsDef = new SelectionAdapter() {

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

        @Override
        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    wTabFolder.setSelection(0);
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    activateKey();
    activateDynamicCommand();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) Group(org.eclipse.swt.widgets.Group) CTabFolder(org.eclipse.swt.custom.CTabFolder) 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) CTabItem(org.eclipse.swt.custom.CTabItem) 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) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) LabelTextVar(org.pentaho.di.ui.core.widget.LabelTextVar) CCombo(org.eclipse.swt.custom.CCombo) 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)

Aggregations

StyledTextComp (org.pentaho.di.ui.core.widget.StyledTextComp)41 Event (org.eclipse.swt.widgets.Event)28 Listener (org.eclipse.swt.widgets.Listener)28 ModifyEvent (org.eclipse.swt.events.ModifyEvent)27 ModifyListener (org.eclipse.swt.events.ModifyListener)27 ShellEvent (org.eclipse.swt.events.ShellEvent)27 SelectionEvent (org.eclipse.swt.events.SelectionEvent)26 FormAttachment (org.eclipse.swt.layout.FormAttachment)25 FormData (org.eclipse.swt.layout.FormData)25 FormLayout (org.eclipse.swt.layout.FormLayout)25 Button (org.eclipse.swt.widgets.Button)25 Label (org.eclipse.swt.widgets.Label)25 Shell (org.eclipse.swt.widgets.Shell)25 ShellAdapter (org.eclipse.swt.events.ShellAdapter)24 Display (org.eclipse.swt.widgets.Display)24 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)23 FocusEvent (org.eclipse.swt.events.FocusEvent)19 KeyEvent (org.eclipse.swt.events.KeyEvent)19 MouseEvent (org.eclipse.swt.events.MouseEvent)19 Text (org.eclipse.swt.widgets.Text)19