Search in sources :

Example 6 with StyledTextComp

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

the class OlapInputDialog 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();
        }
    };
    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, "OlapInputDialog.OlapInput"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    // 
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "OlapInputDialog.StepName"));
    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);
    // The URL
    // 
    wlUrl = new Label(shell, SWT.RIGHT);
    wlUrl.setText(BaseMessages.getString(PKG, "OlapInputDialog.Url"));
    props.setLook(wlUrl);
    fdlUrl = new FormData();
    fdlUrl.left = new FormAttachment(0, 0);
    fdlUrl.right = new FormAttachment(middle, -margin);
    fdlUrl.top = new FormAttachment(wStepname, margin);
    wlUrl.setLayoutData(fdlUrl);
    wUrl = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wUrl);
    wUrl.addModifyListener(lsMod);
    fdUrl = new FormData();
    fdUrl.left = new FormAttachment(middle, 0);
    fdUrl.right = new FormAttachment(100, 0);
    fdUrl.top = new FormAttachment(wStepname, margin);
    wUrl.setLayoutData(fdUrl);
    // Username
    // 
    wlUsername = new Label(shell, SWT.RIGHT);
    wlUsername.setText(BaseMessages.getString(PKG, "OlapInputDialog.Username"));
    props.setLook(wlUsername);
    fdlUsername = new FormData();
    fdlUsername.left = new FormAttachment(0, 0);
    fdlUsername.right = new FormAttachment(middle, -margin);
    fdlUsername.top = new FormAttachment(wUrl, margin);
    wlUsername.setLayoutData(fdlUsername);
    wUsername = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wUsername);
    wUsername.addModifyListener(lsMod);
    fdUsername = new FormData();
    fdUsername.left = new FormAttachment(middle, 0);
    fdUsername.right = new FormAttachment(100, 0);
    fdUsername.top = new FormAttachment(wUrl, margin);
    wUsername.setLayoutData(fdUsername);
    // Password
    // 
    wlPassword = new Label(shell, SWT.RIGHT);
    wlPassword.setText(BaseMessages.getString(PKG, "OlapInputDialog.Password"));
    props.setLook(wlPassword);
    fdlPassword = new FormData();
    fdlPassword.left = new FormAttachment(0, 0);
    fdlPassword.right = new FormAttachment(middle, -margin);
    fdlPassword.top = new FormAttachment(wUsername, margin);
    wlPassword.setLayoutData(fdlPassword);
    wPassword = new PasswordTextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPassword);
    wPassword.addModifyListener(lsMod);
    fdPassword = new FormData();
    fdPassword.left = new FormAttachment(middle, 0);
    fdPassword.right = new FormAttachment(100, 0);
    fdPassword.top = new FormAttachment(wUsername, margin);
    wPassword.setLayoutData(fdPassword);
    // Some 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, "System.Button.Preview"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wAbout = new Button(shell, SWT.PUSH);
    wAbout.setText(BaseMessages.getString(PKG, "OlapInputDialog.About.Button"));
    setButtonPositions(new Button[] { wOK, wPreview, wAbout, wCancel }, margin, null);
    // Catalog location...
    // 
    wlCatalog = new Label(shell, SWT.RIGHT);
    wlCatalog.setText(BaseMessages.getString(PKG, "OlapInputDialog.Catalog"));
    props.setLook(wlCatalog);
    fdlCatalog = new FormData();
    fdlCatalog.left = new FormAttachment(0, 0);
    fdlCatalog.right = new FormAttachment(middle, -margin);
    fdlCatalog.bottom = new FormAttachment(wOK, -8 * margin);
    wlCatalog.setLayoutData(fdlCatalog);
    wCatalog = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCatalog);
    wCatalog.addModifyListener(lsMod);
    fdCatalog = new FormData();
    fdCatalog.left = new FormAttachment(middle, 0);
    fdCatalog.right = new FormAttachment(100, 0);
    fdCatalog.bottom = new FormAttachment(wOK, -8 * margin);
    wCatalog.setLayoutData(fdCatalog);
    // Replace variables in MDX?
    // 
    wlVariables = new Label(shell, SWT.RIGHT);
    wlVariables.setText(BaseMessages.getString(PKG, "OlapInputDialog.ReplaceVariables"));
    props.setLook(wlVariables);
    fdlVariables = new FormData();
    fdlVariables.left = new FormAttachment(0, 0);
    fdlVariables.right = new FormAttachment(middle, -margin);
    fdlVariables.bottom = new FormAttachment(wCatalog, -margin);
    wlVariables.setLayoutData(fdlVariables);
    wVariables = new Button(shell, SWT.CHECK);
    props.setLook(wVariables);
    wVariables.setToolTipText(BaseMessages.getString(PKG, "OlapInputDialog.ReplaceVariables.Tooltip"));
    fdVariables = new FormData();
    fdVariables.left = new FormAttachment(middle, 0);
    fdVariables.right = new FormAttachment(100, 0);
    fdVariables.bottom = new FormAttachment(wCatalog, -margin);
    wVariables.setLayoutData(fdVariables);
    wVariables.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            setSQLToolTip();
            input.setChanged();
        }
    });
    wlPosition = new Label(shell, SWT.NONE);
    props.setLook(wlPosition);
    fdlPosition = new FormData();
    fdlPosition.left = new FormAttachment(0, 0);
    fdlPosition.right = new FormAttachment(50, 0);
    fdlPosition.bottom = new FormAttachment(wVariables, -2 * margin);
    wlPosition.setLayoutData(fdlPosition);
    // asc link
    this.wAscLink = new Link(this.shell, SWT.NONE);
    FormData fdAscLink = new FormData();
    fdAscLink.left = new FormAttachment(0, 5);
    fdAscLink.right = new FormAttachment(100, 0);
    fdAscLink.bottom = new FormAttachment(wlPosition, -2 * margin);
    // fdAscLink.top = new FormAttachment();
    wAscLink.setLayoutData(fdAscLink);
    this.wAscLink.setText(BaseMessages.getString(PKG, "OlapInputDialog.Provided.Info"));
    // Table line...
    // 
    wlMDX = new Label(shell, SWT.NONE);
    wlMDX.setText(BaseMessages.getString(PKG, "OlapInputDialog.SQL"));
    props.setLook(wlMDX);
    fdlMDX = new FormData();
    fdlMDX.left = new FormAttachment(0, 0);
    fdlMDX.top = new FormAttachment(wPassword, 2 * margin);
    wlMDX.setLayoutData(fdlMDX);
    wMDX = new StyledTextComp(transMeta, shell, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
    props.setLook(wMDX, Props.WIDGET_STYLE_FIXED);
    wMDX.addModifyListener(lsMod);
    fdMDX = new FormData();
    fdMDX.left = new FormAttachment(0, 0);
    fdMDX.top = new FormAttachment(wlMDX, margin);
    fdMDX.right = new FormAttachment(100, -2 * margin);
    fdMDX.bottom = new FormAttachment(this.wAscLink, -margin);
    wMDX.setLayoutData(fdMDX);
    Listener lsAbout = new Listener() {

        public void handleEvent(Event e) {
            new OlapInputAboutDialog(OlapInputDialog.this.shell).open();
        }
    };
    this.wAbout.addListener(SWT.Selection, lsAbout);
    this.wAscLink.addListener(SWT.Selection, new Listener() {

        public void handleEvent(final Event event) {
            Program.launch(event.text);
        }
    });
    wMDX.addModifyListener(new ModifyListener() {

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

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

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

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

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

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

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

        public void mouseUp(MouseEvent e) {
            setPosition();
        }
    });
    // Text Higlighting
    lineStyler = new MDXValuesHighlight();
    wMDX.addLineStyleListener(lineStyler);
    // Add listeners
    lsCancel = new Listener() {

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

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

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

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

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    getData();
    input.setChanged(changed);
    // Set the shell size, based upon previous time...
    setSize();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) 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) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) PasswordTextVar(org.pentaho.di.ui.core.widget.PasswordTextVar) 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) Link(org.eclipse.swt.widgets.Link) Display(org.eclipse.swt.widgets.Display)

Example 7 with StyledTextComp

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

the class JavaFilterDialog 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();
        }
    };
    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, "JavaFilterDialog.DialogTitle"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "System.Label.StepName"));
    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);
    // 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"));
    setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
    // /////////////////////////////////
    // START OF Settings GROUP
    // /////////////////////////////////
    wSettingsGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wSettingsGroup);
    wSettingsGroup.setText(BaseMessages.getString(PKG, "JavaFIlterDialog.Settings.Label"));
    FormLayout settingsLayout = new FormLayout();
    settingsLayout.marginWidth = 10;
    settingsLayout.marginHeight = 10;
    wSettingsGroup.setLayout(settingsLayout);
    // Send 'True' data to...
    Label wlTrueTo = new Label(wSettingsGroup, SWT.RIGHT);
    wlTrueTo.setText(BaseMessages.getString(PKG, "JavaFilterDialog.SendTrueTo.Label"));
    props.setLook(wlTrueTo);
    FormData fdlTrueTo = new FormData();
    fdlTrueTo.left = new FormAttachment(0, 0);
    fdlTrueTo.right = new FormAttachment(middle, -margin);
    fdlTrueTo.top = new FormAttachment(wStepname, margin);
    wlTrueTo.setLayoutData(fdlTrueTo);
    wTrueTo = new CCombo(wSettingsGroup, SWT.BORDER);
    props.setLook(wTrueTo);
    StepMeta stepinfo = transMeta.findStep(stepname);
    if (stepinfo != null) {
        List<StepMeta> nextSteps = transMeta.findNextSteps(stepinfo);
        for (int i = 0; i < nextSteps.size(); i++) {
            StepMeta stepMeta = nextSteps.get(i);
            wTrueTo.add(stepMeta.getName());
        }
    }
    wTrueTo.addModifyListener(lsMod);
    FormData fdTrueTo = new FormData();
    fdTrueTo.left = new FormAttachment(middle, 0);
    fdTrueTo.top = new FormAttachment(wStepname, margin);
    fdTrueTo.right = new FormAttachment(100, 0);
    wTrueTo.setLayoutData(fdTrueTo);
    // Send 'False' data to...
    Label wlFalseTo = new Label(wSettingsGroup, SWT.RIGHT);
    wlFalseTo.setText(BaseMessages.getString(PKG, "JavaFilterDialog.SendFalseTo.Label"));
    props.setLook(wlFalseTo);
    FormData fdlFalseTo = new FormData();
    fdlFalseTo.left = new FormAttachment(0, 0);
    fdlFalseTo.right = new FormAttachment(middle, -margin);
    fdlFalseTo.top = new FormAttachment(wTrueTo, margin);
    wlFalseTo.setLayoutData(fdlFalseTo);
    wFalseTo = new CCombo(wSettingsGroup, SWT.BORDER);
    props.setLook(wFalseTo);
    stepinfo = transMeta.findStep(stepname);
    if (stepinfo != null) {
        List<StepMeta> nextSteps = transMeta.findNextSteps(stepinfo);
        for (int i = 0; i < nextSteps.size(); i++) {
            StepMeta stepMeta = nextSteps.get(i);
            wFalseTo.add(stepMeta.getName());
        }
    }
    wFalseTo.addModifyListener(lsMod);
    FormData fdFalseFrom = new FormData();
    fdFalseFrom.left = new FormAttachment(middle, 0);
    fdFalseFrom.top = new FormAttachment(wTrueTo, margin);
    fdFalseFrom.right = new FormAttachment(100, 0);
    wFalseTo.setLayoutData(fdFalseFrom);
    // bufferSize
    // 
    Label wlCondition = new Label(wSettingsGroup, SWT.RIGHT);
    wlCondition.setText(BaseMessages.getString(PKG, "JavaFIlterDialog.Condition.Label"));
    props.setLook(wlCondition);
    FormData fdlCondition = new FormData();
    fdlCondition.top = new FormAttachment(wFalseTo, margin);
    fdlCondition.left = new FormAttachment(0, 0);
    fdlCondition.right = new FormAttachment(middle, -margin);
    wlCondition.setLayoutData(fdlCondition);
    wCondition = new StyledTextComp(transMeta, wSettingsGroup, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
    props.setLook(wCondition);
    wCondition.addModifyListener(lsMod);
    FormData fdCondition = new FormData();
    fdCondition.top = new FormAttachment(wFalseTo, margin);
    fdCondition.left = new FormAttachment(middle, 0);
    fdCondition.right = new FormAttachment(100, 0);
    fdCondition.bottom = new FormAttachment(100, -margin);
    wCondition.setLayoutData(fdCondition);
    fdSettingsGroup = new FormData();
    fdSettingsGroup.left = new FormAttachment(0, margin);
    fdSettingsGroup.top = new FormAttachment(wStepname, margin);
    fdSettingsGroup.right = new FormAttachment(100, -margin);
    fdSettingsGroup.bottom = new FormAttachment(wOK, -margin);
    wSettingsGroup.setLayoutData(fdSettingsGroup);
    // ///////////////////////////////////////////////////////////
    // / END OF Settings GROUP
    // ///////////////////////////////////////////////////////////
    // Add listeners
    lsCancel = new Listener() {

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

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

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    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 : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) 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) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) 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) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 8 with StyledTextComp

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

the class DynamicSQLRowDialog 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();
        }
    };
    backupChanged = input.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.Shell.Title"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.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);
    // SQLFieldName field
    wlSQLFieldName = new Label(shell, SWT.RIGHT);
    wlSQLFieldName.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.SQLFieldName.Label"));
    props.setLook(wlSQLFieldName);
    fdlSQLFieldName = new FormData();
    fdlSQLFieldName.left = new FormAttachment(0, 0);
    fdlSQLFieldName.right = new FormAttachment(middle, -margin);
    fdlSQLFieldName.top = new FormAttachment(wConnection, 2 * margin);
    wlSQLFieldName.setLayoutData(fdlSQLFieldName);
    wSQLFieldName = new CCombo(shell, SWT.BORDER | SWT.READ_ONLY);
    wSQLFieldName.setEditable(true);
    props.setLook(wSQLFieldName);
    wSQLFieldName.addModifyListener(lsMod);
    fdSQLFieldName = new FormData();
    fdSQLFieldName.left = new FormAttachment(middle, 0);
    fdSQLFieldName.top = new FormAttachment(wConnection, 2 * margin);
    fdSQLFieldName.right = new FormAttachment(100, -margin);
    wSQLFieldName.setLayoutData(fdSQLFieldName);
    wSQLFieldName.addFocusListener(new FocusListener() {

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

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            get();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    // THE 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"));
    setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
    // Limit the number of lines returns
    wlLimit = new Label(shell, SWT.RIGHT);
    wlLimit.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.Limit.Label"));
    props.setLook(wlLimit);
    fdlLimit = new FormData();
    fdlLimit.left = new FormAttachment(0, 0);
    fdlLimit.right = new FormAttachment(middle, -margin);
    fdlLimit.top = new FormAttachment(wSQLFieldName, margin);
    wlLimit.setLayoutData(fdlLimit);
    wLimit = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLimit);
    wLimit.addModifyListener(lsMod);
    fdLimit = new FormData();
    fdLimit.left = new FormAttachment(middle, 0);
    fdLimit.right = new FormAttachment(100, 0);
    fdLimit.top = new FormAttachment(wSQLFieldName, margin);
    wLimit.setLayoutData(fdLimit);
    // Outer join?
    wlOuter = new Label(shell, SWT.RIGHT);
    wlOuter.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.Outerjoin.Label"));
    wlOuter.setToolTipText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.Outerjoin.Tooltip"));
    props.setLook(wlOuter);
    fdlOuter = new FormData();
    fdlOuter.left = new FormAttachment(0, 0);
    fdlOuter.right = new FormAttachment(middle, -margin);
    fdlOuter.top = new FormAttachment(wLimit, margin);
    wlOuter.setLayoutData(fdlOuter);
    wOuter = new Button(shell, SWT.CHECK);
    props.setLook(wOuter);
    wOuter.setToolTipText(wlOuter.getToolTipText());
    fdOuter = new FormData();
    fdOuter.left = new FormAttachment(middle, 0);
    fdOuter.top = new FormAttachment(wLimit, margin);
    wOuter.setLayoutData(fdOuter);
    wOuter.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // useVars ?
    wluseVars = new Label(shell, SWT.RIGHT);
    wluseVars.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.useVarsjoin.Label"));
    wluseVars.setToolTipText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.useVarsjoin.Tooltip"));
    props.setLook(wluseVars);
    fdluseVars = new FormData();
    fdluseVars.left = new FormAttachment(0, 0);
    fdluseVars.right = new FormAttachment(middle, -margin);
    fdluseVars.top = new FormAttachment(wOuter, margin);
    wluseVars.setLayoutData(fdluseVars);
    wuseVars = new Button(shell, SWT.CHECK);
    props.setLook(wuseVars);
    wuseVars.setToolTipText(wluseVars.getToolTipText());
    fduseVars = new FormData();
    fduseVars.left = new FormAttachment(middle, 0);
    fduseVars.top = new FormAttachment(wOuter, margin);
    wuseVars.setLayoutData(fduseVars);
    wuseVars.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // queryOnlyOnChange ?
    wlqueryOnlyOnChange = new Label(shell, SWT.RIGHT);
    wlqueryOnlyOnChange.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.queryOnlyOnChangejoin.Label"));
    wlqueryOnlyOnChange.setToolTipText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.queryOnlyOnChangejoin.Tooltip"));
    props.setLook(wlqueryOnlyOnChange);
    fdlqueryOnlyOnChange = new FormData();
    fdlqueryOnlyOnChange.left = new FormAttachment(0, 0);
    fdlqueryOnlyOnChange.right = new FormAttachment(middle, -margin);
    fdlqueryOnlyOnChange.top = new FormAttachment(wuseVars, margin);
    wlqueryOnlyOnChange.setLayoutData(fdlqueryOnlyOnChange);
    wqueryOnlyOnChange = new Button(shell, SWT.CHECK);
    props.setLook(wqueryOnlyOnChange);
    wqueryOnlyOnChange.setToolTipText(wlqueryOnlyOnChange.getToolTipText());
    fdqueryOnlyOnChange = new FormData();
    fdqueryOnlyOnChange.left = new FormAttachment(middle, 0);
    fdqueryOnlyOnChange.top = new FormAttachment(wuseVars, margin);
    wqueryOnlyOnChange.setLayoutData(fdqueryOnlyOnChange);
    wqueryOnlyOnChange.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // SQL editor...
    wlSQL = new Label(shell, SWT.NONE);
    wlSQL.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.SQL.Label"));
    props.setLook(wlSQL);
    fdlSQL = new FormData();
    fdlSQL.left = new FormAttachment(0, 0);
    fdlSQL.top = new FormAttachment(wqueryOnlyOnChange, margin);
    wlSQL.setLayoutData(fdlSQL);
    wSQL = new StyledTextComp(transMeta, shell, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
    props.setLook(wSQL, Props.WIDGET_STYLE_FIXED);
    fdSQL = new FormData();
    fdSQL.left = new FormAttachment(0, 0);
    fdSQL.top = new FormAttachment(wlSQL, margin);
    fdSQL.right = new FormAttachment(100, -2 * margin);
    fdSQL.bottom = new FormAttachment(wOK, -4 * 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());
    wlPosition = new Label(shell, SWT.NONE);
    // wlPosition.setText(BaseMessages.getString(PKG, "DynamicSQLRowDialog.Position.Label"));
    props.setLook(wlPosition);
    fdlPosition = new FormData();
    fdlPosition.left = new FormAttachment(0, 0);
    fdlPosition.top = new FormAttachment(wSQL, margin);
    fdlPosition.right = new FormAttachment(100, 0);
    wlPosition.setLayoutData(fdlPosition);
    // Add listeners
    lsOK = new Listener() {

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

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

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    wLimit.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(backupChanged);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) FocusAdapter(org.eclipse.swt.events.FocusAdapter) FocusListener(org.eclipse.swt.events.FocusListener) 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) Cursor(org.eclipse.swt.graphics.Cursor) 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) 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) FocusListener(org.eclipse.swt.events.FocusListener) Display(org.eclipse.swt.widgets.Display)

Example 9 with StyledTextComp

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

the class UserDefinedJavaClassDialog method treeDblClick.

// Adds the Current item to the current Position
private void treeDblClick(Event event) {
    StyledTextComp wScript = getStyledTextComp();
    Point point = new Point(event.x, event.y);
    TreeItem item = wTree.getItem(point);
    // Qualification where the Click comes from
    if (item != null && item.getParentItem() != null) {
        if (item.getParentItem().equals(wTreeClassesItem)) {
            setActiveCtab(item.getText());
        } else if (!item.getData().equals("Snippit")) {
            int iStart = wScript.getCaretOffset();
            // this selection
            int selCount = wScript.getSelectionCount();
            // will be replaced
            // by wScript.insert
            // when a selection is already there
            iStart = iStart - selCount;
            // we need to subtract the position
            if (iStart < 0) {
                // just safety
                iStart = 0;
            }
            String strInsert = (String) item.getData();
            wScript.insert(strInsert);
            wScript.setSelection(iStart, iStart + strInsert.length());
        }
    }
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) TreeItem(org.eclipse.swt.widgets.TreeItem) Point(org.eclipse.swt.graphics.Point)

Example 10 with StyledTextComp

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

the class UserDefinedJavaClassDialog method setPosition.

public void setPosition() {
    StyledTextComp wScript = getStyledTextComp();
    String scr = wScript.getText();
    int linenr = wScript.getLineAtOffset(wScript.getCaretOffset()) + 1;
    int posnr = wScript.getCaretOffset();
    // Go back from position to last CR: how many positions?
    int colnr = 0;
    while (posnr > 0 && scr.charAt(posnr - 1) != '\n' && scr.charAt(posnr - 1) != '\r') {
        posnr--;
        colnr++;
    }
    wlPosition.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Position.Label2") + linenr + ", " + colnr);
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) Point(org.eclipse.swt.graphics.Point)

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