Search in sources :

Example 36 with EnterSelectionDialog

use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.

the class VariableButtonListenerFactory method getVariableName.

// Listen to the Variable... button
public static final String getVariableName(Shell shell, VariableSpace space) {
    String[] keys = space.listVariables();
    Arrays.sort(keys);
    int size = keys.length;
    String[] key = new String[size];
    String[] val = new String[size];
    String[] str = new String[size];
    for (int i = 0; i < keys.length; i++) {
        key[i] = keys[i];
        val[i] = space.getVariable(key[i]);
        str[i] = key[i] + "  [" + val[i] + "]";
    }
    EnterSelectionDialog esd = new EnterSelectionDialog(shell, str, BaseMessages.getString(PKG, "System.Dialog.SelectEnvironmentVar.Title"), BaseMessages.getString(PKG, "System.Dialog.SelectEnvironmentVar.Message"));
    esd.clearModal();
    if (esd.open() != null) {
        int nr = esd.getSelectionNr();
        String var = key[nr];
        return var;
    } else {
        return null;
    }
}
Also used : EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 37 with EnterSelectionDialog

use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.

the class GetXMLDataDialog method populateLoopPaths.

private void populateLoopPaths(GetXMLDataMeta meta, String XMLSource, boolean dynamicXMLSource, boolean useURL) {
    if (Utils.isEmpty(XMLSource)) {
        return;
    }
    String[] list_xpath = null;
    LoopNodesImportProgressDialog pd = null;
    if (dynamicXMLSource) {
        pd = new LoopNodesImportProgressDialog(shell, meta, XMLSource, useURL);
    } else {
        pd = new LoopNodesImportProgressDialog(shell, meta, XMLSource, meta.getEncoding() == null ? "UTF-8" : meta.getEncoding());
    }
    if (pd != null) {
        list_xpath = pd.open();
        if (list_xpath != null) {
            EnterSelectionDialog s = new EnterSelectionDialog(shell, list_xpath, BaseMessages.getString(PKG, "GetXMLDataDialog.Dialog.SelectALoopPath.Title"), BaseMessages.getString(PKG, "GetXMLDataDialog.Dialog.SelectALoopPath.Message"));
            String listxpaths = s.open();
            if (listxpaths != null) {
                wLoopXPath.setText(listxpaths);
            }
        }
    }
    this.XMLSource = XMLSource;
}
Also used : EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 38 with EnterSelectionDialog

use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.

the class XMLOutputDialog 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, "XMLOutputDialog.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.top = new FormAttachment(0, margin);
    fdlStepname.right = new FormAttachment(middle, -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, Props.WIDGET_STYLE_TAB);
    // ////////////////////////
    // START OF FILE TAB///
    // /
    wFileTab = new CTabItem(wTabFolder, SWT.NONE);
    wFileTab.setText(BaseMessages.getString(PKG, "XMLOutputDialog.FileTab.Tab"));
    Composite wFileComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wFileComp);
    FormLayout fileLayout = new FormLayout();
    fileLayout.marginWidth = 3;
    fileLayout.marginHeight = 3;
    wFileComp.setLayout(fileLayout);
    // Filename line
    wlFilename = new Label(wFileComp, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "XMLOutputDialog.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(0, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);
    wbFilename = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "XMLOutputDialog.Browse.Button"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(0, 0);
    wbFilename.setLayoutData(fdbFilename);
    wFilename = new TextVar(transMeta, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(0, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);
    // Open new File at Init
    wlDoNotOpenNewFileInit = new Label(wFileComp, SWT.RIGHT);
    wlDoNotOpenNewFileInit.setText(BaseMessages.getString(PKG, "XMLOutputDialog.DoNotOpenNewFileInit.Label"));
    props.setLook(wlDoNotOpenNewFileInit);
    fdlDoNotOpenNewFileInit = new FormData();
    fdlDoNotOpenNewFileInit.left = new FormAttachment(0, 0);
    fdlDoNotOpenNewFileInit.top = new FormAttachment(wFilename, margin);
    fdlDoNotOpenNewFileInit.right = new FormAttachment(middle, -margin);
    wlDoNotOpenNewFileInit.setLayoutData(fdlDoNotOpenNewFileInit);
    wDoNotOpenNewFileInit = new Button(wFileComp, SWT.CHECK);
    wDoNotOpenNewFileInit.setToolTipText(BaseMessages.getString(PKG, "XMLOutputDialog.DoNotOpenNewFileInit.Tooltip"));
    props.setLook(wDoNotOpenNewFileInit);
    fdDoNotOpenNewFileInit = new FormData();
    fdDoNotOpenNewFileInit.left = new FormAttachment(middle, 0);
    fdDoNotOpenNewFileInit.top = new FormAttachment(wFilename, margin);
    fdDoNotOpenNewFileInit.right = new FormAttachment(100, 0);
    wDoNotOpenNewFileInit.setLayoutData(fdDoNotOpenNewFileInit);
    wDoNotOpenNewFileInit.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // Run this as a command instead?
    wlServletOutput = new Label(wFileComp, SWT.RIGHT);
    wlServletOutput.setText(BaseMessages.getString(PKG, "XMLOutputDialog.ServletOutput.Label"));
    props.setLook(wlServletOutput);
    fdlServletOutput = new FormData();
    fdlServletOutput.left = new FormAttachment(0, 0);
    fdlServletOutput.top = new FormAttachment(wDoNotOpenNewFileInit, margin);
    fdlServletOutput.right = new FormAttachment(middle, -margin);
    wlServletOutput.setLayoutData(fdlServletOutput);
    wServletOutput = new Button(wFileComp, SWT.CHECK);
    wServletOutput.setToolTipText(BaseMessages.getString(PKG, "XMLOutputDialog.ServletOutput.Tooltip"));
    props.setLook(wServletOutput);
    fdServletOutput = new FormData();
    fdServletOutput.left = new FormAttachment(middle, 0);
    fdServletOutput.top = new FormAttachment(wDoNotOpenNewFileInit, margin);
    fdServletOutput.right = new FormAttachment(100, 0);
    wServletOutput.setLayoutData(fdServletOutput);
    wServletOutput.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            setFlagsServletOption();
        }
    });
    // Extension line
    wlExtension = new Label(wFileComp, SWT.RIGHT);
    wlExtension.setText(BaseMessages.getString(PKG, "XMLOutputDialog.Extension.Label"));
    props.setLook(wlExtension);
    fdlExtension = new FormData();
    fdlExtension.left = new FormAttachment(0, 0);
    fdlExtension.top = new FormAttachment(wServletOutput, margin);
    fdlExtension.right = new FormAttachment(middle, -margin);
    wlExtension.setLayoutData(fdlExtension);
    wExtension = new TextVar(transMeta, wFileComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wExtension.setText("");
    props.setLook(wExtension);
    wExtension.addModifyListener(lsMod);
    fdExtension = new FormData();
    fdExtension.left = new FormAttachment(middle, 0);
    fdExtension.top = new FormAttachment(wServletOutput, margin);
    fdExtension.right = new FormAttachment(100, 0);
    wExtension.setLayoutData(fdExtension);
    // Create multi-part file?
    wlAddStepnr = new Label(wFileComp, SWT.RIGHT);
    wlAddStepnr.setText(BaseMessages.getString(PKG, "XMLOutputDialog.AddStepNr.Label"));
    props.setLook(wlAddStepnr);
    fdlAddStepnr = new FormData();
    fdlAddStepnr.left = new FormAttachment(0, 0);
    fdlAddStepnr.top = new FormAttachment(wExtension, margin);
    fdlAddStepnr.right = new FormAttachment(middle, -margin);
    wlAddStepnr.setLayoutData(fdlAddStepnr);
    wAddStepnr = new Button(wFileComp, SWT.CHECK);
    props.setLook(wAddStepnr);
    fdAddStepnr = new FormData();
    fdAddStepnr.left = new FormAttachment(middle, 0);
    fdAddStepnr.top = new FormAttachment(wExtension, margin);
    fdAddStepnr.right = new FormAttachment(100, 0);
    wAddStepnr.setLayoutData(fdAddStepnr);
    wAddStepnr.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // Create multi-part file?
    wlAddDate = new Label(wFileComp, SWT.RIGHT);
    wlAddDate.setText(BaseMessages.getString(PKG, "XMLOutputDialog.AddDate.Label"));
    props.setLook(wlAddDate);
    fdlAddDate = new FormData();
    fdlAddDate.left = new FormAttachment(0, 0);
    fdlAddDate.top = new FormAttachment(wAddStepnr, margin);
    fdlAddDate.right = new FormAttachment(middle, -margin);
    wlAddDate.setLayoutData(fdlAddDate);
    wAddDate = new Button(wFileComp, SWT.CHECK);
    props.setLook(wAddDate);
    fdAddDate = new FormData();
    fdAddDate.left = new FormAttachment(middle, 0);
    fdAddDate.top = new FormAttachment(wAddStepnr, margin);
    fdAddDate.right = new FormAttachment(100, 0);
    wAddDate.setLayoutData(fdAddDate);
    wAddDate.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // Create multi-part file?
    wlAddTime = new Label(wFileComp, SWT.RIGHT);
    wlAddTime.setText(BaseMessages.getString(PKG, "XMLOutputDialog.AddTime.Label"));
    props.setLook(wlAddTime);
    fdlAddTime = new FormData();
    fdlAddTime.left = new FormAttachment(0, 0);
    fdlAddTime.top = new FormAttachment(wAddDate, margin);
    fdlAddTime.right = new FormAttachment(middle, -margin);
    wlAddTime.setLayoutData(fdlAddTime);
    wAddTime = new Button(wFileComp, SWT.CHECK);
    props.setLook(wAddTime);
    fdAddTime = new FormData();
    fdAddTime.left = new FormAttachment(middle, 0);
    fdAddTime.top = new FormAttachment(wAddDate, margin);
    fdAddTime.right = new FormAttachment(100, 0);
    wAddTime.setLayoutData(fdAddTime);
    wAddTime.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    // Specify date time format?
    wlSpecifyFormat = new Label(wFileComp, SWT.RIGHT);
    wlSpecifyFormat.setText(BaseMessages.getString(PKG, "XMLOutputDialog.SpecifyFormat.Label"));
    props.setLook(wlSpecifyFormat);
    fdlSpecifyFormat = new FormData();
    fdlSpecifyFormat.left = new FormAttachment(0, 0);
    fdlSpecifyFormat.top = new FormAttachment(wAddTime, margin);
    fdlSpecifyFormat.right = new FormAttachment(middle, -margin);
    wlSpecifyFormat.setLayoutData(fdlSpecifyFormat);
    wSpecifyFormat = new Button(wFileComp, SWT.CHECK);
    props.setLook(wSpecifyFormat);
    wSpecifyFormat.setToolTipText(BaseMessages.getString(PKG, "XMLOutputDialog.SpecifyFormat.Tooltip"));
    fdSpecifyFormat = new FormData();
    fdSpecifyFormat.left = new FormAttachment(middle, 0);
    fdSpecifyFormat.top = new FormAttachment(wAddTime, margin);
    fdSpecifyFormat.right = new FormAttachment(100, 0);
    wSpecifyFormat.setLayoutData(fdSpecifyFormat);
    wSpecifyFormat.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            setDateTimeFormat();
        }
    });
    // Prepare a list of possible DateTimeFormats...
    String[] dats = Const.getDateFormats();
    // DateTimeFormat
    wlDateTimeFormat = new Label(wFileComp, SWT.RIGHT);
    wlDateTimeFormat.setText(BaseMessages.getString(PKG, "XMLOutputDialog.DateTimeFormat.Label"));
    props.setLook(wlDateTimeFormat);
    fdlDateTimeFormat = new FormData();
    fdlDateTimeFormat.left = new FormAttachment(0, 0);
    fdlDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
    fdlDateTimeFormat.right = new FormAttachment(middle, -margin);
    wlDateTimeFormat.setLayoutData(fdlDateTimeFormat);
    wDateTimeFormat = new CCombo(wFileComp, SWT.BORDER | SWT.READ_ONLY);
    wDateTimeFormat.setEditable(true);
    props.setLook(wDateTimeFormat);
    wDateTimeFormat.addModifyListener(lsMod);
    fdDateTimeFormat = new FormData();
    fdDateTimeFormat.left = new FormAttachment(middle, 0);
    fdDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
    fdDateTimeFormat.right = new FormAttachment(100, 0);
    wDateTimeFormat.setLayoutData(fdDateTimeFormat);
    for (int x = 0; x < dats.length; x++) {
        wDateTimeFormat.add(dats[x]);
    }
    wbShowFiles = new Button(wFileComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbShowFiles);
    wbShowFiles.setText(BaseMessages.getString(PKG, "XMLOutputDialog.ShowFiles.Button"));
    fdbShowFiles = new FormData();
    fdbShowFiles.left = new FormAttachment(middle, 0);
    fdbShowFiles.top = new FormAttachment(wDateTimeFormat, margin * 2);
    wbShowFiles.setLayoutData(fdbShowFiles);
    wbShowFiles.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            XMLOutputMeta tfoi = new XMLOutputMeta();
            getInfo(tfoi);
            String[] files = tfoi.getFiles(transMeta);
            if (files != null && files.length > 0) {
                EnterSelectionDialog esd = new EnterSelectionDialog(shell, files, BaseMessages.getString(PKG, "XMLOutputDialog.OutputFiles.DialogTitle"), BaseMessages.getString(PKG, "XMLOutputDialog.OutputFiles.DialogMessage"));
                esd.setViewOnly();
                esd.open();
            } else {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "XMLOutputDialog.NoFilesFound.DialogMessage"));
                mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
                mb.open();
            }
        }
    });
    // Add File to the result files name
    wlAddToResult = new Label(wFileComp, SWT.RIGHT);
    wlAddToResult.setText(BaseMessages.getString(PKG, "XMLOutputDialog.AddFileToResult.Label"));
    props.setLook(wlAddToResult);
    fdlAddToResult = new FormData();
    fdlAddToResult.left = new FormAttachment(0, 0);
    fdlAddToResult.top = new FormAttachment(wbShowFiles, 2 * margin);
    fdlAddToResult.right = new FormAttachment(middle, -margin);
    wlAddToResult.setLayoutData(fdlAddToResult);
    wAddToResult = new Button(wFileComp, SWT.CHECK);
    wAddToResult.setToolTipText(BaseMessages.getString(PKG, "XMLOutputDialog.AddFileToResult.Tooltip"));
    props.setLook(wAddToResult);
    fdAddToResult = new FormData();
    fdAddToResult.left = new FormAttachment(middle, 0);
    fdAddToResult.top = new FormAttachment(wbShowFiles, 2 * margin);
    fdAddToResult.right = new FormAttachment(100, 0);
    wAddToResult.setLayoutData(fdAddToResult);
    SelectionAdapter lsSelR = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            input.setChanged();
        }
    };
    wAddToResult.addSelectionListener(lsSelR);
    fdFileComp = new FormData();
    fdFileComp.left = new FormAttachment(0, 0);
    fdFileComp.top = new FormAttachment(0, 0);
    fdFileComp.right = new FormAttachment(100, 0);
    fdFileComp.bottom = new FormAttachment(100, 0);
    wFileComp.setLayoutData(fdFileComp);
    wFileComp.layout();
    wFileTab.setControl(wFileComp);
    // ///////////////////////////////////////////////////////////
    // / END OF FILE TAB
    // ///////////////////////////////////////////////////////////
    // ////////////////////////
    // START OF CONTENT TAB///
    // /
    wContentTab = new CTabItem(wTabFolder, SWT.NONE);
    wContentTab.setText(BaseMessages.getString(PKG, "XMLOutputDialog.ContentTab.TabTitle"));
    FormLayout contentLayout = new FormLayout();
    contentLayout.marginWidth = 3;
    contentLayout.marginHeight = 3;
    Composite wContentComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wContentComp);
    wContentComp.setLayout(contentLayout);
    wlZipped = new Label(wContentComp, SWT.RIGHT);
    wlZipped.setText(BaseMessages.getString(PKG, "XMLOutputDialog.Zipped.Label"));
    props.setLook(wlZipped);
    fdlZipped = new FormData();
    fdlZipped.left = new FormAttachment(0, 0);
    fdlZipped.top = new FormAttachment(0, 0);
    fdlZipped.right = new FormAttachment(middle, -margin);
    wlZipped.setLayoutData(fdlZipped);
    wZipped = new Button(wContentComp, SWT.CHECK);
    props.setLook(wZipped);
    fdZipped = new FormData();
    fdZipped.left = new FormAttachment(middle, 0);
    fdZipped.top = new FormAttachment(0, 0);
    fdZipped.right = new FormAttachment(100, 0);
    wZipped.setLayoutData(fdZipped);
    wZipped.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    wlEncoding = new Label(wContentComp, SWT.RIGHT);
    wlEncoding.setText(BaseMessages.getString(PKG, "XMLOutputDialog.Encoding.Label"));
    props.setLook(wlEncoding);
    fdlEncoding = new FormData();
    fdlEncoding.left = new FormAttachment(0, 0);
    fdlEncoding.top = new FormAttachment(wZipped, margin);
    fdlEncoding.right = new FormAttachment(middle, -margin);
    wlEncoding.setLayoutData(fdlEncoding);
    wEncoding = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wEncoding.setEditable(true);
    props.setLook(wEncoding);
    wEncoding.addModifyListener(lsMod);
    fdEncoding = new FormData();
    fdEncoding.left = new FormAttachment(middle, 0);
    fdEncoding.top = new FormAttachment(wZipped, margin);
    fdEncoding.right = new FormAttachment(100, 0);
    wEncoding.setLayoutData(fdEncoding);
    wEncoding.addFocusListener(new FocusListener() {

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

        public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            setEncodings();
            shell.setCursor(null);
            busy.dispose();
        }
    });
    wlNameSpace = new Label(wContentComp, SWT.RIGHT);
    wlNameSpace.setText(BaseMessages.getString(PKG, "XMLOutputDialog.NameSpace.Label"));
    props.setLook(wlNameSpace);
    fdlNameSpace = new FormData();
    fdlNameSpace.left = new FormAttachment(0, 0);
    fdlNameSpace.top = new FormAttachment(wEncoding, margin);
    fdlNameSpace.right = new FormAttachment(middle, -margin);
    wlNameSpace.setLayoutData(fdlNameSpace);
    wNameSpace = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wNameSpace);
    wNameSpace.addModifyListener(lsMod);
    fdNameSpace = new FormData();
    fdNameSpace.left = new FormAttachment(middle, 0);
    fdNameSpace.top = new FormAttachment(wEncoding, margin);
    fdNameSpace.right = new FormAttachment(100, 0);
    wNameSpace.setLayoutData(fdNameSpace);
    wlMainElement = new Label(wContentComp, SWT.RIGHT);
    wlMainElement.setText(BaseMessages.getString(PKG, "XMLOutputDialog.MainElement.Label"));
    props.setLook(wlMainElement);
    fdlMainElement = new FormData();
    fdlMainElement.left = new FormAttachment(0, 0);
    fdlMainElement.top = new FormAttachment(wNameSpace, margin);
    fdlMainElement.right = new FormAttachment(middle, -margin);
    wlMainElement.setLayoutData(fdlMainElement);
    wMainElement = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wMainElement.setEditable(true);
    props.setLook(wMainElement);
    wMainElement.addModifyListener(lsMod);
    fdMainElement = new FormData();
    fdMainElement.left = new FormAttachment(middle, 0);
    fdMainElement.top = new FormAttachment(wNameSpace, margin);
    fdMainElement.right = new FormAttachment(100, 0);
    wMainElement.setLayoutData(fdMainElement);
    wlRepeatElement = new Label(wContentComp, SWT.RIGHT);
    wlRepeatElement.setText(BaseMessages.getString(PKG, "XMLOutputDialog.RepeatElement.Label"));
    props.setLook(wlRepeatElement);
    fdlRepeatElement = new FormData();
    fdlRepeatElement.left = new FormAttachment(0, 0);
    fdlRepeatElement.top = new FormAttachment(wMainElement, margin);
    fdlRepeatElement.right = new FormAttachment(middle, -margin);
    wlRepeatElement.setLayoutData(fdlRepeatElement);
    wRepeatElement = new CCombo(wContentComp, SWT.BORDER | SWT.READ_ONLY);
    wRepeatElement.setEditable(true);
    props.setLook(wRepeatElement);
    wRepeatElement.addModifyListener(lsMod);
    fdRepeatElement = new FormData();
    fdRepeatElement.left = new FormAttachment(middle, 0);
    fdRepeatElement.top = new FormAttachment(wMainElement, margin);
    fdRepeatElement.right = new FormAttachment(100, 0);
    wRepeatElement.setLayoutData(fdRepeatElement);
    wlSplitEvery = new Label(wContentComp, SWT.RIGHT);
    wlSplitEvery.setText(BaseMessages.getString(PKG, "XMLOutputDialog.SplitEvery.Label"));
    props.setLook(wlSplitEvery);
    fdlSplitEvery = new FormData();
    fdlSplitEvery.left = new FormAttachment(0, 0);
    fdlSplitEvery.top = new FormAttachment(wRepeatElement, margin);
    fdlSplitEvery.right = new FormAttachment(middle, -margin);
    wlSplitEvery.setLayoutData(fdlSplitEvery);
    wSplitEvery = new Text(wContentComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSplitEvery);
    wSplitEvery.addModifyListener(lsMod);
    fdSplitEvery = new FormData();
    fdSplitEvery.left = new FormAttachment(middle, 0);
    fdSplitEvery.top = new FormAttachment(wRepeatElement, margin);
    fdSplitEvery.right = new FormAttachment(100, 0);
    wSplitEvery.setLayoutData(fdSplitEvery);
    wlOmitNullValues = new Label(wContentComp, SWT.RIGHT);
    wlOmitNullValues.setText(BaseMessages.getString(PKG, "XMLOutputDialog.OmitNullValues.Label"));
    props.setLook(wlOmitNullValues);
    fdlOmitNullValues = new FormData();
    fdlOmitNullValues.left = new FormAttachment(0, 0);
    fdlOmitNullValues.top = new FormAttachment(wSplitEvery, margin);
    fdlOmitNullValues.right = new FormAttachment(middle, -margin);
    wlOmitNullValues.setLayoutData(fdlOmitNullValues);
    wOmitNullValues = new Button(wContentComp, SWT.CHECK);
    props.setLook(wOmitNullValues);
    fdOmitNullValues = new FormData();
    fdOmitNullValues.left = new FormAttachment(middle, 0);
    fdOmitNullValues.top = new FormAttachment(wSplitEvery, margin);
    fdOmitNullValues.right = new FormAttachment(100, 0);
    wOmitNullValues.setLayoutData(fdOmitNullValues);
    wOmitNullValues.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            input.setChanged();
        }
    });
    fdContentComp = new FormData();
    fdContentComp.left = new FormAttachment(0, 0);
    fdContentComp.top = new FormAttachment(0, 0);
    fdContentComp.right = new FormAttachment(100, 0);
    fdContentComp.bottom = new FormAttachment(100, 0);
    wContentComp.setLayoutData(fdContentComp);
    wContentComp.layout();
    wContentTab.setControl(wContentComp);
    // ///////////////////////////////////////////////////////////
    // / END OF CONTENT TAB
    // ///////////////////////////////////////////////////////////
    // Fields tab...
    // 
    wFieldsTab = new CTabItem(wTabFolder, SWT.NONE);
    wFieldsTab.setText(BaseMessages.getString(PKG, "XMLOutputDialog.FieldsTab.TabTitle"));
    FormLayout fieldsLayout = new FormLayout();
    fieldsLayout.marginWidth = Const.FORM_MARGIN;
    fieldsLayout.marginHeight = Const.FORM_MARGIN;
    Composite wFieldsComp = new Composite(wTabFolder, SWT.NONE);
    wFieldsComp.setLayout(fieldsLayout);
    props.setLook(wFieldsComp);
    wGet = new Button(wFieldsComp, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "XMLOutputDialog.Get.Button"));
    wGet.setToolTipText(BaseMessages.getString(PKG, "XMLOutputDialog.Get.Tooltip"));
    wMinWidth = new Button(wFieldsComp, SWT.PUSH);
    wMinWidth.setText(BaseMessages.getString(PKG, "XMLOutputDialog.MinWidth.Label"));
    wMinWidth.setToolTipText(BaseMessages.getString(PKG, "XMLOutputDialog.MinWidth.Tooltip"));
    setButtonPositions(new Button[] { wGet, wMinWidth }, margin, null);
    final int FieldsRows = input.getOutputFields().length;
    // Prepare a list of possible formats...
    String[] nums = Const.getNumberFormats();
    int totsize = dats.length + nums.length;
    String[] formats = new String[totsize];
    for (int x = 0; x < dats.length; x++) {
        formats[x] = dats[x];
    }
    for (int x = 0; x < nums.length; x++) {
        formats[dats.length + x] = nums[x];
    }
    colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Fieldname.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.ElementName.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.ContentType.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "Element", "Attribute" }, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Type.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMeta.getTypes()), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Format.Column"), ColumnInfo.COLUMN_TYPE_CCOMBO, formats), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Length.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Precision.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Currency.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Decimal.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Group.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "XMLOutputDialog.Null.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    wFields = new TableView(transMeta, wFieldsComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(0, 0);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(wGet, -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();
    fdFieldsComp = new FormData();
    fdFieldsComp.left = new FormAttachment(0, 0);
    fdFieldsComp.top = new FormAttachment(0, 0);
    fdFieldsComp.right = new FormAttachment(100, 0);
    fdFieldsComp.bottom = new FormAttachment(100, 0);
    wFieldsComp.setLayoutData(fdFieldsComp);
    wFieldsComp.layout();
    wFieldsTab.setControl(wFieldsComp);
    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);
    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, wTabFolder);
    // Add listeners
    lsOK = new Listener() {

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

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

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

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

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wStepname.addSelectionListener(lsDef);
    wFilename.addSelectionListener(lsDef);
    // Whenever something changes, set the tooltip to the expanded version:
    wFilename.addModifyListener(new ModifyListener() {

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

        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.SAVE);
            dialog.setFilterExtensions(new String[] { "*.xml", "*.txt", "*.csv", "*" });
            if (wFilename.getText() != null) {
                dialog.setFileName(transMeta.environmentSubstitute(wFilename.getText()));
            }
            dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "System.FileType.XMLFiles"), BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
            if (dialog.open() != null) {
                wFilename.setText(dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName());
            }
        }
    });
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    lsResize = new Listener() {

        public void handleEvent(Event event) {
            Point size = shell.getSize();
            wFields.setSize(size.x - 10, size.y - 50);
            wFields.table.setSize(size.x - 10, size.y - 50);
            wFields.redraw();
        }
    };
    shell.addListener(SWT.Resize, lsResize);
    wTabFolder.setSelection(0);
    // Set the shell size, based upon previous time...
    setSize();
    getData();
    setDateTimeFormat();
    input.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XMLOutputMeta(org.pentaho.di.trans.steps.xmloutput.XMLOutputMeta) CTabFolder(org.eclipse.swt.custom.CTabFolder) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) ShellEvent(org.eclipse.swt.events.ShellEvent) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) Cursor(org.eclipse.swt.graphics.Cursor) 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) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) 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) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Point(org.eclipse.swt.graphics.Point) TextVar(org.pentaho.di.ui.core.widget.TextVar) MessageBox(org.eclipse.swt.widgets.MessageBox) CCombo(org.eclipse.swt.custom.CCombo) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) FileDialog(org.eclipse.swt.widgets.FileDialog) Display(org.eclipse.swt.widgets.Display)

Example 39 with EnterSelectionDialog

use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.

the class SingleThreaderDialog 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, singleThreaderMeta);
    lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            singleThreaderMeta.setChanged();
        }
    };
    changed = singleThreaderMeta.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 15;
    formLayout.marginHeight = 15;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Shell.Title"));
    Label wicon = new Label(shell, SWT.RIGHT);
    wicon.setImage(getImage());
    FormData fdlicon = new FormData();
    fdlicon.top = new FormAttachment(0, 0);
    fdlicon.right = new FormAttachment(100, 0);
    wicon.setLayoutData(fdlicon);
    props.setLook(wicon);
    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.top = new FormAttachment(0, 0);
    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.width = 250;
    fdStepname.left = new FormAttachment(0, 0);
    fdStepname.top = new FormAttachment(wlStepname, 5);
    wStepname.setLayoutData(fdStepname);
    Label spacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdSpacer = new FormData();
    fdSpacer.left = new FormAttachment(0, 0);
    fdSpacer.top = new FormAttachment(wStepname, 15);
    fdSpacer.right = new FormAttachment(100, 0);
    spacer.setLayoutData(fdSpacer);
    wlPath = new Label(shell, SWT.LEFT);
    props.setLook(wlPath);
    wlPath.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Transformation.Label"));
    FormData fdlTransformation = new FormData();
    fdlTransformation.left = new FormAttachment(0, 0);
    fdlTransformation.top = new FormAttachment(spacer, 20);
    fdlTransformation.right = new FormAttachment(50, 0);
    wlPath.setLayoutData(fdlTransformation);
    wPath = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPath);
    FormData fdTransformation = new FormData();
    fdTransformation.left = new FormAttachment(0, 0);
    fdTransformation.top = new FormAttachment(wlPath, 5);
    fdTransformation.width = 350;
    wPath.setLayoutData(fdTransformation);
    wbBrowse = new Button(shell, SWT.PUSH);
    props.setLook(wbBrowse);
    wbBrowse.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Browse.Label"));
    FormData fdBrowse = new FormData();
    fdBrowse.left = new FormAttachment(wPath, 5);
    fdBrowse.top = new FormAttachment(wlPath, Const.isOSX() ? 0 : 5);
    wbBrowse.setLayoutData(fdBrowse);
    wbBrowse.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (repository != null) {
                selectRepositoryTrans();
            } else {
                selectFileTrans(true);
            }
        }
    });
    CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    // Options Tab Start
    CTabItem wOptionsTab = new CTabItem(wTabFolder, SWT.NONE);
    wOptionsTab.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Options.Group.Label"));
    Composite wOptions = new Composite(wTabFolder, SWT.SHADOW_NONE);
    props.setLook(wOptions);
    FormLayout specLayout = new FormLayout();
    specLayout.marginWidth = 15;
    specLayout.marginHeight = 15;
    wOptions.setLayout(specLayout);
    // Inject step
    // 
    Label wlInjectStep = new Label(wOptions, SWT.LEFT);
    wlInjectStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.InjectStep.Label"));
    props.setLook(wlInjectStep);
    FormData fdlInjectStep = new FormData();
    fdlInjectStep.top = new FormAttachment(0, 0);
    fdlInjectStep.left = new FormAttachment(0, 0);
    wlInjectStep.setLayoutData(fdlInjectStep);
    wInjectStep = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wInjectStep);
    wInjectStep.addModifyListener(lsMod);
    FormData fdInjectStep = new FormData();
    fdInjectStep.width = 250;
    fdInjectStep.left = new FormAttachment(0, 0);
    fdInjectStep.top = new FormAttachment(wlInjectStep, 5);
    wInjectStep.setLayoutData(fdInjectStep);
    wGetInjectStep = new Button(wOptions, SWT.PUSH);
    wGetInjectStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Button.Get"));
    FormData fdGetInjectStep = new FormData();
    fdGetInjectStep.top = new FormAttachment(wlInjectStep, Const.isOSX() ? 0 : 5);
    fdGetInjectStep.left = new FormAttachment(wInjectStep, 5);
    wGetInjectStep.setLayoutData(fdGetInjectStep);
    wGetInjectStep.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                loadTransformation();
                String stepname = mappingTransMeta == null ? "" : Const.NVL(getInjectorStep(mappingTransMeta), "");
                wInjectStep.setText(stepname);
            } catch (Exception e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"), e);
            }
        }
    });
    // Retrieve step...
    // 
    Label wlRetrieveStep = new Label(wOptions, SWT.LEFT);
    wlRetrieveStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.RetrieveStep.Label"));
    props.setLook(wlRetrieveStep);
    FormData fdlRetrieveStep = new FormData();
    fdlRetrieveStep.top = new FormAttachment(wInjectStep, 10);
    fdlRetrieveStep.left = new FormAttachment(0, 0);
    wlRetrieveStep.setLayoutData(fdlRetrieveStep);
    wRetrieveStep = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wRetrieveStep);
    wRetrieveStep.addModifyListener(lsMod);
    FormData fdRetrieveStep = new FormData();
    fdRetrieveStep.width = 250;
    fdRetrieveStep.left = new FormAttachment(0, 0);
    fdRetrieveStep.top = new FormAttachment(wlRetrieveStep, 5);
    wRetrieveStep.setLayoutData(fdRetrieveStep);
    wGetRetrieveStep = new Button(wOptions, SWT.PUSH);
    wGetRetrieveStep.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Button.Get"));
    FormData fdGetRetrieveStep = new FormData();
    fdGetRetrieveStep.top = new FormAttachment(wlRetrieveStep, Const.isOSX() ? 0 : 5);
    fdGetRetrieveStep.left = new FormAttachment(wRetrieveStep, 5);
    wGetRetrieveStep.setLayoutData(fdGetRetrieveStep);
    wGetRetrieveStep.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            try {
                loadTransformation();
                if (mappingTransMeta != null) {
                    String[] stepNames = mappingTransMeta.getStepNames();
                    EnterSelectionDialog d = new EnterSelectionDialog(shell, stepNames, BaseMessages.getString(PKG, "SingleThreaderDialog.SelectStep.Title"), BaseMessages.getString(PKG, "SingleThreaderDialog.SelectStep.Message"));
                    String step = d.open();
                    if (step != null) {
                        wRetrieveStep.setText(step);
                    }
                }
            } catch (Exception e) {
                new ErrorDialog(shell, BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "SingleThreaderDialog.ErrorLoadingTransformation.DialogMessage"), e);
            }
        }
    });
    // Here come the batch size, inject and retrieve fields...
    // 
    Label wlBatchSize = new Label(wOptions, SWT.LEFT);
    wlBatchSize.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.BatchSize.Label"));
    props.setLook(wlBatchSize);
    FormData fdlBatchSize = new FormData();
    fdlBatchSize.top = new FormAttachment(wRetrieveStep, 10);
    fdlBatchSize.left = new FormAttachment(0, 0);
    wlBatchSize.setLayoutData(fdlBatchSize);
    wBatchSize = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    FormData fdBatchSize = new FormData();
    fdBatchSize.left = new FormAttachment(0, 0);
    fdBatchSize.top = new FormAttachment(wlBatchSize, 5);
    wBatchSize.setLayoutData(fdBatchSize);
    Label wlBatchTime = new Label(wOptions, SWT.LEFT);
    wlBatchTime.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.BatchTime.Label"));
    props.setLook(wlBatchTime);
    FormData fdlBatchTime = new FormData();
    fdlBatchTime.top = new FormAttachment(wBatchSize, 10);
    fdlBatchTime.left = new FormAttachment(0, 0);
    wlBatchTime.setLayoutData(fdlBatchTime);
    wBatchTime = new TextVar(transMeta, wOptions, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wBatchTime.addModifyListener(lsMod);
    FormData fdBatchTime = new FormData();
    fdBatchTime.left = new FormAttachment(0, 0);
    fdBatchTime.top = new FormAttachment(wlBatchTime, 5);
    wBatchTime.setLayoutData(fdBatchTime);
    wOptionsTab.setControl(wOptions);
    FormData fdOptions = new FormData();
    fdOptions.left = new FormAttachment(0, 0);
    fdOptions.top = new FormAttachment(0, 0);
    fdOptions.right = new FormAttachment(100, 0);
    fdOptions.bottom = new FormAttachment(100, 0);
    wOptions.setLayoutData(fdOptions);
    // Options Tab End
    // Parameters Tab Start
    CTabItem wParametersTab = new CTabItem(wTabFolder, SWT.NONE);
    wParametersTab.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.Fields.Parameters.Label"));
    FormLayout fieldLayout = new FormLayout();
    fieldLayout.marginWidth = 15;
    fieldLayout.marginHeight = 15;
    Composite wParameterComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wParameterComp);
    wParameterComp.setLayout(fieldLayout);
    // Pass all parameters down
    // 
    wPassParams = new Button(wParameterComp, SWT.CHECK);
    props.setLook(wPassParams);
    wPassParams.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.PassAllParameters.Label"));
    FormData fdPassParams = new FormData();
    fdPassParams.left = new FormAttachment(0, 0);
    fdPassParams.top = new FormAttachment(0, 0);
    wPassParams.setLayoutData(fdPassParams);
    wPassParams.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            changed = true;
        }
    });
    wbGetParams = new Button(wParameterComp, SWT.PUSH);
    wbGetParams.setText(BaseMessages.getString(PKG, "SingleThreaderDialog.GetParameters.Button.Label"));
    FormData fdGetParams = new FormData();
    fdGetParams.bottom = new FormAttachment(100, 0);
    fdGetParams.right = new FormAttachment(100, 0);
    wbGetParams.setLayoutData(fdGetParams);
    wbGetParams.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent arg0) {
            // null: force reload of file from specification
            getParameters(null);
        }
    });
    final int parameterRows = singleThreaderMeta.getParameters() != null ? singleThreaderMeta.getParameters().length : 0;
    ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "SingleThreaderDialog.Parameters.Parameter.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "SingleThreaderDialog.Parameters.Value.Label"), ColumnInfo.COLUMN_TYPE_TEXT, false) };
    colinf[1].setUsingVariables(true);
    wParameters = new TableView(transMeta, wParameterComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, parameterRows, false, lsMod, props, false);
    FormData fdParameters = new FormData();
    fdParameters.left = new FormAttachment(0, 0);
    fdParameters.top = new FormAttachment(wPassParams, 10);
    fdParameters.right = new FormAttachment(100);
    fdParameters.bottom = new FormAttachment(wbGetParams, -10);
    wParameters.setLayoutData(fdParameters);
    wParameters.getTable().addListener(SWT.Resize, new ColumnsResizer(0, 50, 50));
    FormData fdParametersComp = new FormData();
    fdParametersComp.left = new FormAttachment(0, 0);
    fdParametersComp.top = new FormAttachment(0, 0);
    fdParametersComp.right = new FormAttachment(100, 0);
    fdParametersComp.bottom = new FormAttachment(100, 0);
    wParameterComp.setLayoutData(fdParametersComp);
    wParameterComp.layout();
    wParametersTab.setControl(wParameterComp);
    wTabFolder.setSelection(0);
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    FormData fdCancel = new FormData();
    fdCancel.right = new FormAttachment(100, 0);
    fdCancel.bottom = new FormAttachment(100, 0);
    wCancel.setLayoutData(fdCancel);
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fdOk = new FormData();
    fdOk.right = new FormAttachment(wCancel, -5);
    fdOk.bottom = new FormAttachment(100, 0);
    wOK.setLayoutData(fdOk);
    Label hSpacer = new Label(shell, SWT.HORIZONTAL | SWT.SEPARATOR);
    FormData fdhSpacer = new FormData();
    fdhSpacer.left = new FormAttachment(0, 0);
    fdhSpacer.bottom = new FormAttachment(wCancel, -15);
    fdhSpacer.right = new FormAttachment(100, 0);
    hSpacer.setLayoutData(fdhSpacer);
    FormData fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wPath, 20);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(hSpacer, -15);
    wTabFolder.setLayoutData(fdTabFolder);
    // 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);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wPath.addSelectionListener(lsDef);
    wStepname.addSelectionListener(lsDef);
    wBatchSize.addSelectionListener(lsDef);
    wBatchTime.addSelectionListener(lsDef);
    wInjectStep.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();
    singleThreaderMeta.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ColumnsResizer(org.pentaho.di.ui.core.widget.ColumnsResizer) Label(org.eclipse.swt.widgets.Label) ColumnInfo(org.pentaho.di.ui.core.widget.ColumnInfo) 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) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) 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) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Text(org.eclipse.swt.widgets.Text) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException) TextVar(org.pentaho.di.ui.core.widget.TextVar) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display)

Example 40 with EnterSelectionDialog

use of org.pentaho.di.ui.core.dialog.EnterSelectionDialog in project pentaho-kettle by pentaho.

the class SynchronizeAfterMergeDialog method getSchemaNames.

private void getSchemaNames() {
    DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
    if (databaseMeta != null) {
        Database database = new Database(loggingObject, databaseMeta);
        try {
            database.connect();
            String[] schemas = database.getSchemas();
            if (null != schemas && schemas.length > 0) {
                schemas = Const.sortStrings(schemas);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, schemas, BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.AvailableSchemas.Title", wConnection.getText()), BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.AvailableSchemas.Message", wConnection.getText()));
                String d = dialog.open();
                if (d != null) {
                    wSchema.setText(Const.NVL(d, ""));
                    setTableFieldCombo();
                }
            } else {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.NoSchema.Error"));
                mb.setText(BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.GetSchemas.Error"));
                mb.open();
            }
        } catch (Exception e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "SynchronizeAfterMergeDialog.ErrorGettingSchemas"), e);
        } finally {
            database.disconnect();
        }
    }
}
Also used : Database(org.pentaho.di.core.database.Database) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) KettleException(org.pentaho.di.core.exception.KettleException) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

EnterSelectionDialog (org.pentaho.di.ui.core.dialog.EnterSelectionDialog)75 MessageBox (org.eclipse.swt.widgets.MessageBox)42 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)42 KettleException (org.pentaho.di.core.exception.KettleException)41 SelectionEvent (org.eclipse.swt.events.SelectionEvent)30 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)29 ModifyEvent (org.eclipse.swt.events.ModifyEvent)28 ModifyListener (org.eclipse.swt.events.ModifyListener)28 ShellEvent (org.eclipse.swt.events.ShellEvent)28 FormAttachment (org.eclipse.swt.layout.FormAttachment)28 FormData (org.eclipse.swt.layout.FormData)28 FormLayout (org.eclipse.swt.layout.FormLayout)28 Event (org.eclipse.swt.widgets.Event)28 Listener (org.eclipse.swt.widgets.Listener)28 Shell (org.eclipse.swt.widgets.Shell)28 ShellAdapter (org.eclipse.swt.events.ShellAdapter)27 Button (org.eclipse.swt.widgets.Button)27 Display (org.eclipse.swt.widgets.Display)27 Label (org.eclipse.swt.widgets.Label)27 Text (org.eclipse.swt.widgets.Text)27