Search in sources :

Example 1 with OutputType

use of org.pentaho.di.trans.steps.autodoc.KettleReportBuilder.OutputType in project pentaho-kettle by pentaho.

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

        public void modifyText(ModifyEvent e) {
            inputMeta.setChanged();
        }
    };
    changed = inputMeta.hasChanged();
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "AutoDoc.Step.Name"));
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;
    // Step name line
    // 
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "AutoDocDialog.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);
    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);
    Control lastControl = wStepname;
    RowMetaInterface previousFields;
    try {
        previousFields = transMeta.getPrevStepFields(stepMeta);
    } catch (KettleStepException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
        previousFields = new RowMeta();
    }
    // The filename field ...
    // 
    wFilenameField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Tooltip"));
    wFilenameField.setItems(previousFields.getFieldNames());
    props.setLook(wFilenameField);
    wFilenameField.addModifyListener(lsMod);
    FormData fdFilenameField = new FormData();
    fdFilenameField.top = new FormAttachment(lastControl, margin);
    fdFilenameField.left = new FormAttachment(0, 0);
    fdFilenameField.right = new FormAttachment(100, 0);
    wFilenameField.setLayoutData(fdFilenameField);
    lastControl = wFilenameField;
    // The FileType field ...
    // 
    wFileTypeField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Tooltip"));
    wFileTypeField.setItems(previousFields.getFieldNames());
    props.setLook(wFileTypeField);
    wFileTypeField.addModifyListener(lsMod);
    FormData fdFileTypeField = new FormData();
    fdFileTypeField.top = new FormAttachment(lastControl, margin);
    fdFileTypeField.left = new FormAttachment(0, 0);
    fdFileTypeField.right = new FormAttachment(100, 0);
    wFileTypeField.setLayoutData(fdFileTypeField);
    lastControl = wFileTypeField;
    // The target filename ...
    // 
    wTargetFilename = new LabelTextVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Label"), BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Tooltip"));
    props.setLook(wTargetFilename);
    wTargetFilename.addModifyListener(lsMod);
    FormData fdTargetFilename = new FormData();
    fdTargetFilename.top = new FormAttachment(lastControl, margin);
    fdTargetFilename.left = new FormAttachment(0, 0);
    fdTargetFilename.right = new FormAttachment(100, 0);
    wTargetFilename.setLayoutData(fdTargetFilename);
    lastControl = wTargetFilename;
    // The output type ...
    // 
    wOutputType = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Label"), BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Tooltip"));
    OutputType[] outputTypes = KettleReportBuilder.OutputType.values();
    String[] items = new String[outputTypes.length];
    for (int i = 0; i < outputTypes.length; i++) {
        items[i] = outputTypes[i].name();
    }
    wOutputType.setItems(items);
    props.setLook(wOutputType);
    wOutputType.addModifyListener(lsMod);
    wOutputType.getComboWidget().setEditable(false);
    FormData fdOutputType = new FormData();
    fdOutputType.top = new FormAttachment(lastControl, margin);
    fdOutputType.left = new FormAttachment(0, 0);
    fdOutputType.right = new FormAttachment(100, 0);
    wOutputType.setLayoutData(fdOutputType);
    wOutputType.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            setFlags();
        }
    });
    lastControl = wOutputType;
    // Include name check-box
    // 
    Label wlInclName = new Label(shell, SWT.RIGHT);
    wlInclName.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclName.Label"));
    props.setLook(wlInclName);
    FormData fdlInclName = new FormData();
    fdlInclName.left = new FormAttachment(0, 0);
    fdlInclName.right = new FormAttachment(middle, -margin);
    fdlInclName.top = new FormAttachment(lastControl, margin);
    wlInclName.setLayoutData(fdlInclName);
    wInclName = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclName);
    FormData fdInclName = new FormData();
    fdInclName.left = new FormAttachment(middle, 0);
    fdInclName.right = new FormAttachment(100, 0);
    fdInclName.top = new FormAttachment(lastControl, margin);
    wInclName.setLayoutData(fdInclName);
    lastControl = wInclName;
    // Include description check-box
    // 
    Label wlInclDesc = new Label(shell, SWT.RIGHT);
    wlInclDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclDesc.Label"));
    props.setLook(wlInclDesc);
    FormData fdlInclDesc = new FormData();
    fdlInclDesc.left = new FormAttachment(0, 0);
    fdlInclDesc.right = new FormAttachment(middle, -margin);
    fdlInclDesc.top = new FormAttachment(lastControl, margin);
    wlInclDesc.setLayoutData(fdlInclDesc);
    wInclDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclDesc);
    FormData fdInclDesc = new FormData();
    fdInclDesc.left = new FormAttachment(middle, 0);
    fdInclDesc.right = new FormAttachment(100, 0);
    fdInclDesc.top = new FormAttachment(lastControl, margin);
    wInclDesc.setLayoutData(fdInclDesc);
    lastControl = wInclDesc;
    // Include extended description check-box
    // 
    Label wlInclExtDesc = new Label(shell, SWT.RIGHT);
    wlInclExtDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclExtDesc.Label"));
    props.setLook(wlInclExtDesc);
    FormData fdlInclExtDesc = new FormData();
    fdlInclExtDesc.left = new FormAttachment(0, 0);
    fdlInclExtDesc.right = new FormAttachment(middle, -margin);
    fdlInclExtDesc.top = new FormAttachment(lastControl, margin);
    wlInclExtDesc.setLayoutData(fdlInclExtDesc);
    wInclExtDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclExtDesc);
    FormData fdInclExtDesc = new FormData();
    fdInclExtDesc.left = new FormAttachment(middle, 0);
    fdInclExtDesc.right = new FormAttachment(100, 0);
    fdInclExtDesc.top = new FormAttachment(lastControl, margin);
    wInclExtDesc.setLayoutData(fdInclExtDesc);
    lastControl = wInclExtDesc;
    // Include creation information (user/date) check-box
    // 
    Label wlInclCreated = new Label(shell, SWT.RIGHT);
    wlInclCreated.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclCreated.Label"));
    props.setLook(wlInclCreated);
    FormData fdlInclCreated = new FormData();
    fdlInclCreated.left = new FormAttachment(0, 0);
    fdlInclCreated.right = new FormAttachment(middle, -margin);
    fdlInclCreated.top = new FormAttachment(lastControl, margin);
    wlInclCreated.setLayoutData(fdlInclCreated);
    wInclCreated = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclCreated);
    FormData fdInclCreated = new FormData();
    fdInclCreated.left = new FormAttachment(middle, 0);
    fdInclCreated.right = new FormAttachment(100, 0);
    fdInclCreated.top = new FormAttachment(lastControl, margin);
    wInclCreated.setLayoutData(fdInclCreated);
    lastControl = wInclCreated;
    // Include modified information (user/date) check-box
    // 
    Label wlInclModified = new Label(shell, SWT.RIGHT);
    wlInclModified.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclModified.Label"));
    props.setLook(wlInclModified);
    FormData fdlInclModified = new FormData();
    fdlInclModified.left = new FormAttachment(0, 0);
    fdlInclModified.right = new FormAttachment(middle, -margin);
    fdlInclModified.top = new FormAttachment(lastControl, margin);
    wlInclModified.setLayoutData(fdlInclModified);
    wInclModified = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclModified);
    FormData fdInclModified = new FormData();
    fdInclModified.left = new FormAttachment(middle, 0);
    fdInclModified.right = new FormAttachment(100, 0);
    fdInclModified.top = new FormAttachment(lastControl, margin);
    wInclModified.setLayoutData(fdInclModified);
    lastControl = wInclModified;
    // Include image check-box
    // 
    Label wlInclImage = new Label(shell, SWT.RIGHT);
    wlInclImage.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclImage.Label"));
    props.setLook(wlInclImage);
    FormData fdlInclImage = new FormData();
    fdlInclImage.left = new FormAttachment(0, 0);
    fdlInclImage.right = new FormAttachment(middle, -margin);
    fdlInclImage.top = new FormAttachment(lastControl, margin);
    wlInclImage.setLayoutData(fdlInclImage);
    wInclImage = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclImage);
    FormData fdInclImage = new FormData();
    fdInclImage.left = new FormAttachment(middle, 0);
    fdInclImage.right = new FormAttachment(100, 0);
    fdInclImage.top = new FormAttachment(lastControl, margin);
    wInclImage.setLayoutData(fdInclImage);
    lastControl = wInclImage;
    // Include logging check-box
    // 
    Label wlInclLogging = new Label(shell, SWT.RIGHT);
    wlInclLogging.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLogging.Label"));
    props.setLook(wlInclLogging);
    FormData fdlInclLogging = new FormData();
    fdlInclLogging.left = new FormAttachment(0, 0);
    fdlInclLogging.right = new FormAttachment(middle, -margin);
    fdlInclLogging.top = new FormAttachment(lastControl, margin);
    wlInclLogging.setLayoutData(fdlInclLogging);
    wInclLogging = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclLogging);
    FormData fdInclLogging = new FormData();
    fdInclLogging.left = new FormAttachment(middle, 0);
    fdInclLogging.right = new FormAttachment(100, 0);
    fdInclLogging.top = new FormAttachment(lastControl, margin);
    wInclLogging.setLayoutData(fdInclLogging);
    lastControl = wInclLogging;
    // Include last execution date check-box
    // 
    Label wlInclLastExecResult = new Label(shell, SWT.RIGHT);
    wlInclLastExecResult.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLastExecResult.Label"));
    props.setLook(wlInclLastExecResult);
    FormData fdlInclLastExecResult = new FormData();
    fdlInclLastExecResult.left = new FormAttachment(0, 0);
    fdlInclLastExecResult.right = new FormAttachment(middle, -margin);
    fdlInclLastExecResult.top = new FormAttachment(lastControl, margin);
    wlInclLastExecResult.setLayoutData(fdlInclLastExecResult);
    wInclLastExecResult = new Button(shell, SWT.CHECK | SWT.LEFT);
    props.setLook(wInclLastExecResult);
    FormData fdInclLastExecResult = new FormData();
    fdInclLastExecResult.left = new FormAttachment(middle, 0);
    fdInclLastExecResult.right = new FormAttachment(100, 0);
    fdInclLastExecResult.top = new FormAttachment(lastControl, margin);
    wInclLastExecResult.setLayoutData(fdInclLastExecResult);
    lastControl = wInclLastExecResult;
    // Some buttons first, so that the dialog scales nicely...
    // 
    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, lastControl);
    // 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);
    wFilenameField.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();
    inputMeta.setChanged(changed);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return stepname;
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) RowMeta(org.pentaho.di.core.row.RowMeta) Label(org.eclipse.swt.widgets.Label) 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) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) LabelComboVar(org.pentaho.di.ui.core.widget.LabelComboVar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) OutputType(org.pentaho.di.trans.steps.autodoc.KettleReportBuilder.OutputType) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Text(org.eclipse.swt.widgets.Text) LabelTextVar(org.pentaho.di.ui.core.widget.LabelTextVar) 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)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 ShellAdapter (org.eclipse.swt.events.ShellAdapter)1 ShellEvent (org.eclipse.swt.events.ShellEvent)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Button (org.eclipse.swt.widgets.Button)1 Control (org.eclipse.swt.widgets.Control)1 Display (org.eclipse.swt.widgets.Display)1 Event (org.eclipse.swt.widgets.Event)1 Label (org.eclipse.swt.widgets.Label)1 Listener (org.eclipse.swt.widgets.Listener)1 Shell (org.eclipse.swt.widgets.Shell)1 Text (org.eclipse.swt.widgets.Text)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1