/** @param form2 */
  private Composite getPageHeader(Composite parent) {
    final Composite header = new Composite(parent, SWT.FILL);
    final FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    header.setLayout(layout);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(header);

    header.setBackground(parent.getBackground());

    final Label titleImage = new Label(header, SWT.FILL);
    final ImageDescriptor imageDescriptor =
        ImageDescriptor.createFromURL(
            Activator.getDefault().getBundle().getResource("icons/view.png")); // $NON-NLS-1$
    titleImage.setImage(new Image(parent.getDisplay(), imageDescriptor.getImageData()));
    final FormData titleImageData = new FormData();
    final int imageOffset = -titleImage.computeSize(SWT.DEFAULT, SWT.DEFAULT).y / 2;
    titleImageData.top = new FormAttachment(50, imageOffset);
    titleImageData.left = new FormAttachment(0, 10);
    titleImage.setLayoutData(titleImageData);

    final Label title = new Label(header, SWT.WRAP);
    title.setText("View Editor"); // $NON-NLS-1$
    titleFont = new Font(title.getDisplay(), getDefaultFontName(title), 12, SWT.BOLD);
    title.setFont(titleFont);
    title.setForeground(getTitleColor(parent));
    final FormData titleData = new FormData();
    title.setLayoutData(titleData);
    titleData.left = new FormAttachment(titleImage, 5, SWT.DEFAULT);

    return header;
  }
  public void createControl(Composite parent) {
    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);

    FormLayout compLayout = new FormLayout();
    compLayout.marginHeight = Const.FORM_MARGIN;
    compLayout.marginWidth = Const.FORM_MARGIN;
    composite.setLayout(compLayout);

    MouseAdapter lsMouse =
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            int s = getSize();
            // System.out.println("size = "+s);
            setPageComplete(s > 0);
          }
        };

    wTable = new FixedTableDraw(composite, props, this, fields);
    wTable.setRows(rows);
    props.setLook(wTable);
    wTable.setFields(fields);
    fdTable = new FormData();
    fdTable.left = new FormAttachment(0, 0);
    fdTable.right = new FormAttachment(100, 0);
    fdTable.top = new FormAttachment(0, 0);
    fdTable.bottom = new FormAttachment(100, 0);
    wTable.setLayoutData(fdTable);
    wTable.addMouseListener(lsMouse);

    // set the composite as the control for this page
    setControl(composite);
  }
Ejemplo n.º 3
0
  /**
   * Provide layout and listeners for the controls.
   *
   * @param parent
   */
  private void addLayout(Composite parent) {
    FormData data;

    // http://www.eclipse.org/forums/index.php/t/202738/
    final FormLayout layout = new FormLayout();
    layout.marginWidth = 4;
    layout.marginHeight = 0;
    layout.spacing = 10; // 100;
    parent.setLayout(layout);

    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(nameTextVal, 0, SWT.CENTER);
    valueLabel.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(valueLabel, 0);
    // data.right = new FormAttachment(100, 0);
    // data.right = new FormAttachment(50, 0);
    data.width = 200;
    data.top = new FormAttachment(0, VSPACE);
    // data.width = SWT.BORDER;
    nameTextVal.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.width = 200;
    // data.right = new FormAttachment(100, 0);
    // data.right = new FormAttachment(50, 0);
    data.top = new FormAttachment(nameTextVal, VSPACE);
    // data.width = SWT.BORDER;
    allowedModes.setLayoutData(data);
  }
Ejemplo n.º 4
0
  protected void createControl(Composite parent, int treeStyle) {
    super.createControl(parent, treeStyle);

    // add 2px margin around filter text

    FormLayout layout = new FormLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    setLayout(layout);

    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    if (showFilterControls) {
      FormData filterData = new FormData();
      filterData.top = new FormAttachment(0, 2);
      filterData.left = new FormAttachment(0, 2);
      filterData.right = new FormAttachment(100, -2);
      filterComposite.setLayoutData(filterData);
      data.top = new FormAttachment(filterComposite, 2);
    } else {
      data.top = new FormAttachment(0, 0);
    }
    treeComposite.setLayoutData(data);
  }
  /**
   * Constructor for TabbedPropertyTitle.
   *
   * @param parent the parent composite.
   * @param factory the widget factory for the tabbed property sheet
   */
  public TabbedPropertyTitle(Composite parent, TabbedPropertySheetWidgetFactory factory) {
    super(parent, SWT.NO_FOCUS);
    this.factory = factory;

    // RAP not suppported
    //		this.addPaintListener(new PaintListener() {
    //
    //			public void paintControl(PaintEvent e) {
    //				if (image == null && (text == null || text.equals(BLANK))) {
    //					label.setVisible(false);
    //				} else {
    //					label.setVisible(true);
    //					drawTitleBackground(e);
    //				}
    //			}
    //		});
    // /RAP

    factory.getColors().initializeSectionToolBarColors();
    setBackground(factory.getColors().getBackground());
    setForeground(factory.getColors().getForeground());

    FormLayout layout = new FormLayout();
    layout.marginWidth = 1;
    layout.marginHeight = 2;
    setLayout(layout);

    Font font;
    if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
      FontData[] fontData =
          JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT).getFontData();
      /* title font is 2pt larger than that used in the tabs. */
      fontData[0].setHeight(fontData[0].getHeight() + 2);
      JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
    }
    font = JFaceResources.getFont(TITLE_FONT);

    label = factory.createCLabel(this, BLANK);
    //		label.setBackground(new Color[] {
    //				factory.getColors().getColor(IFormColors.H_GRADIENT_END),
    //				factory.getColors().getColor(IFormColors.H_GRADIENT_START) },
    //				new int[] { 100 }, true);
    label.setFont(font);
    label.setForeground(factory.getColors().getColor(IFormColors.TITLE));
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    label.setLayoutData(data);

    /*
     * setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
     * ISharedImages.IMG_OBJ_ELEMENT));
     */
  }
Ejemplo n.º 6
0
  public TextVarWarning(VariableSpace space, Composite composite, int flags) {
    super(composite, SWT.NONE);

    warningInterfaces = new ArrayList<WarningInterface>();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 0;
    formLayout.marginHeight = 0;
    formLayout.marginTop = 0;
    formLayout.marginBottom = 0;

    this.setLayout(formLayout);

    // add a text field on it...
    wText = new TextVar(space, this, flags);

    warningControlDecoration = new ControlDecoration(wText, SWT.CENTER | SWT.RIGHT);
    Image warningImage = GUIResource.getInstance().getImageWarning();
    warningControlDecoration.setImage(warningImage);
    warningControlDecoration.setDescriptionText(
        BaseMessages.getString(PKG, "TextVar.tooltip.FieldIsInUse"));
    warningControlDecoration.hide();

    // If something has changed, check the warning interfaces
    //
    wText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent arg0) {

            // Verify all the warning interfaces.
            // Show the first that has a warning to show...
            //
            boolean foundOne = false;
            for (WarningInterface warningInterface : warningInterfaces) {
              WarningMessageInterface warningSituation =
                  warningInterface.getWarningSituation(wText.getText(), wText, this);
              if (warningSituation.isWarning()) {
                foundOne = true;
                warningControlDecoration.show();
                warningControlDecoration.setDescriptionText(warningSituation.getWarningMessage());
                break;
              }
            }
            if (!foundOne) {
              warningControlDecoration.hide();
            }
          }
        });

    FormData fdText = new FormData();
    fdText.top = new FormAttachment(0, 0);
    fdText.left = new FormAttachment(0, 0);
    fdText.right = new FormAttachment(100, -warningImage.getBounds().width);
    wText.setLayoutData(fdText);
  }
Ejemplo n.º 7
0
  public void createControl(Composite parent) {
    int margin = Const.MARGIN;

    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);

    FormLayout compLayout = new FormLayout();
    compLayout.marginHeight = Const.FORM_MARGIN;
    compLayout.marginWidth = Const.FORM_MARGIN;
    composite.setLayout(compLayout);

    wSourceDB = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wSourceDB);
    for (int i = 0; i < databases.size(); i++) {
      DatabaseMeta dbInfo = databases.get(i);
      wSourceDB.add(dbInfo.getName());
    }
    fdSourceDB = new FormData();
    fdSourceDB.top = new FormAttachment(0, 0);
    fdSourceDB.left = new FormAttachment(0, 0);
    fdSourceDB.bottom = new FormAttachment(100, 0);
    fdSourceDB.right = new FormAttachment(50, 0);
    wSourceDB.setLayoutData(fdSourceDB);
    wSourceDB.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            setPageComplete(false);
          }
        });

    wTargetDB = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wTargetDB);
    for (int i = 0; i < databases.size(); i++) {
      DatabaseMeta dbInfo = databases.get(i);
      wTargetDB.add(dbInfo.getName());
    }
    fdTargetDB = new FormData();
    fdTargetDB.top = new FormAttachment(0, 0);
    fdTargetDB.left = new FormAttachment(50, margin);
    fdTargetDB.bottom = new FormAttachment(100, 0);
    fdTargetDB.right = new FormAttachment(100, 0);
    wTargetDB.setLayoutData(fdTargetDB);
    wTargetDB.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            setPageComplete(false);
          }
        });

    // set the composite as the control for this page
    setControl(composite);
  }
  public LabelTimeComposite(Composite composite, String labelText, String toolTipText) {
    super(composite, SWT.NONE);
    props.setLook(this);

    int middle = props.getMiddlePct();
    int threeQuarters = (middle + 100) / 2;
    int margin = Const.MARGIN;

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 0;
    formLayout.marginHeight = 0;
    formLayout.marginTop = 0;
    formLayout.marginBottom = 0;

    this.setLayout(formLayout);

    wText = new Text(this, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    FormData fdText = new FormData();
    fdText.left = new FormAttachment(middle, margin);
    fdText.right = new FormAttachment(threeQuarters, 0);
    wText.setLayoutData(fdText);
    wText.setToolTipText(toolTipText);

    wTimeUnit = new CCombo(this, SWT.SINGLE | SWT.DROP_DOWN | SWT.BORDER | SWT.LEFT);
    FormData fdCombo = new FormData();
    fdCombo.left = new FormAttachment(threeQuarters, margin);
    fdCombo.right = new FormAttachment(100, 0);
    wTimeUnit.setEditable(false);
    wTimeUnit.setLayoutData(fdCombo);
    wTimeUnit.setItems(getTimeUnits());
    wTimeUnit.setToolTipText(toolTipText);

    wLabel = new Label(this, SWT.RIGHT);
    props.setLook(wLabel);
    wLabel.setText(labelText);
    FormData fdLabel = new FormData();
    fdLabel.left = new FormAttachment(0, 0);
    fdLabel.right = new FormAttachment(middle, 0);
    fdLabel.top = new FormAttachment(wText, 0, SWT.CENTER);
    wLabel.setLayoutData(fdLabel);
    wLabel.setToolTipText(toolTipText);

    wText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            if (!StringUtils.isNumeric(wText.getText())) {
              wText.setText(lastValidValue);
            } else lastValidValue = wText.getText();
          }
        });
  }
  protected void createCalculatedMeasureComposite() {
    calculatedMeasureComposite = new CalculatedMeasureComposite(mainPanel);
    calculatedMeasureComposite.setLocalizationPkg(PKG);
    calculatedMeasureComposite.createWidgets();

    // take up the entire space of the main panel
    FormLayout layout = new FormLayout();
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.marginBottom = 0;
    layout.marginTop = 5; // minor adjustment
    layout.marginHeight = 0;
    calculatedMeasureComposite.setLayout(layout);
  }
  /**
   * Creates the wizard's title area.
   *
   * @param parent the SWT parent for the title area composite.
   * @return the created title area composite.
   */
  protected Composite createTitleArea(Composite parent) {
    // Create the title area which will contain
    // a title, message, and image.
    int margins = 2;
    titleArea = new Composite(parent, SWT.NONE);
    FormLayout layout = new FormLayout();
    layout.marginHeight = 0;
    layout.marginWidth = margins;
    titleArea.setLayout(layout);

    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.verticalAlignment = SWT.TOP;
    titleArea.setLayoutData(layoutData);

    // Message label
    messageArea = new DialogMessageArea();
    messageArea.createContents(titleArea);

    titleArea.addControlListener(
        new ControlAdapter() {
          @Override
          public void controlResized(ControlEvent e) {
            updateMessage();
          }
        });

    final IPropertyChangeListener fontListener =
        event -> {
          if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
            updateMessage();
          }
          if (JFaceResources.DIALOG_FONT.equals(event.getProperty())) {
            updateMessage();
            Font dialogFont = JFaceResources.getDialogFont();
            updateTreeFont(dialogFont);
            Control[] children = ((Composite) buttonBar).getChildren();
            for (int i = 0; i < children.length; i++) {
              children[i].setFont(dialogFont);
            }
          }
        };

    titleArea.addDisposeListener(
        event -> JFaceResources.getFontRegistry().removeListener(fontListener));
    JFaceResources.getFontRegistry().addListener(fontListener);
    messageArea.setTitleLayoutData(createMessageAreaData());
    messageArea.setMessageLayoutData(createMessageAreaData());
    return titleArea;
  }
Ejemplo n.º 11
0
  public static Group createFormGroup(final Composite parent) {

    Group group = new Group(parent, SWT.NONE);

    FormLayout layout = new FormLayout();
    layout.marginTop = -5; // Adjust. UX Recommendation for Top Margin of Group: 15
    layout.marginWidth = 0;
    layout.marginHeight = GROUP_MARGIN_HEIGHT;
    group.setLayout(layout);

    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);

    group.setLayoutData(fd);
    return group;
  }
Ejemplo n.º 12
0
  public static Composite createFormComposite(final Composite parent) {

    Composite composite = new Composite(parent, SWT.NONE);

    FormLayout layout = new FormLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);

    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);

    composite.setLayoutData(fd);

    return composite;
  }
Ejemplo n.º 13
0
  @Override
  public void createControl(Composite parent) {
    Composite topLevel = new Composite(parent, SWT.NONE);
    FormLayout layout = new FormLayout();
    layout.marginWidth = layout.marginHeight = 5;
    topLevel.setLayout(layout);

    Label textLabel = new Label(topLevel, SWT.NONE);
    textLabel.setText("Wait Duration (ms): ");

    durationText = new Text(topLevel, SWT.SINGLE | SWT.BORDER);
    durationText.setText("" + xmlWait.getWaitForMilliseconds());
    durationText.addListener(
        SWT.Verify,
        new Listener() {
          public void handleEvent(Event e) {
            String string = e.text;
            char[] chars = string.toCharArray();
            for (char c : chars) {
              if (!('0' <= c && c <= '9')) {
                e.doit = false;
                return;
              }
            }
          }
        });
    durationText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validateInput();
          }
        });

    GC gc = new GC(durationText);
    FontMetrics fm = gc.getFontMetrics();
    int charWidth = fm.getAverageCharWidth();
    int width = durationText.computeSize(charWidth * 8, SWT.DEFAULT).x;
    gc.dispose();
    FormData data = new FormData(width, SWT.DEFAULT);
    durationText.setLayoutData(data);
    data.left = new FormAttachment(textLabel, 5);
    data.top = new FormAttachment(textLabel, 0, SWT.CENTER);

    setControl(topLevel);
    validateInput();
  }
Ejemplo n.º 14
0
  public Application() {
    display = new Display();
    shell = new Shell(display);
    shell.setText("Pic's Tagger");

    // registry
    loadPlacesFromRegistry();

    FormLayout formLayout = new FormLayout();
    formLayout.marginHeight = 2;
    formLayout.marginWidth = 2;
    shell.setLayout(formLayout);

    shell.setSize(1024, 768);
    shell.setMaximized(false);

    this.initUI();

    shell.pack();
    shell.open();
  }
Ejemplo n.º 15
0
 /** This method initializes sShell */
 private void createSShell() {
   //	sShell = new Shell(/*XXX getParent(),*/ SWT.MODELESS | SWT.DIALOG_TRIM);
   sShell = new Shell(getParent(), SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
   sShell.setText("Go to location");
   FormLayout formLayout = new FormLayout();
   formLayout.marginHeight = 3;
   formLayout.marginWidth = 3;
   sShell.setLayout(formLayout);
   label = new Label(sShell, SWT.NONE);
   FormData formData = new FormData();
   formData.left = new FormAttachment(0, 5);
   formData.right = new FormAttachment(100);
   label.setLayoutData(formData);
   createComposite1();
   createComposite2();
   label2 = new Label(sShell, SWT.CENTER);
   FormData formData2 = new FormData();
   formData2.left = new FormAttachment(0);
   formData2.right = new FormAttachment(100);
   formData2.top = new FormAttachment(composite1);
   formData2.bottom = new FormAttachment(100, -10);
   label2.setLayoutData(formData2);
 }
  public SAPFunction open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    int middle = Const.MIDDLE_PCT;
    int margin = Const.MARGIN;

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "SapFunctionBrowser.Title"));

    // Function
    //
    wlFunction = new Label(shell, SWT.RIGHT);
    wlFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.Function.Label"));
    props.setLook(wlFunction);
    FormData fdlFunction = new FormData();
    fdlFunction.left = new FormAttachment(0, 0);
    fdlFunction.right = new FormAttachment(middle, -margin);
    fdlFunction.top = new FormAttachment(0, 0);
    wlFunction.setLayoutData(fdlFunction);
    wbFunction = new Button(shell, SWT.PUSH);
    props.setLook(wbFunction);

    wbFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.FindFunctionButton.Label"));
    FormData fdbFunction = new FormData();
    fdbFunction.right = new FormAttachment(100, 0);
    fdbFunction.top = new FormAttachment(0, 0);
    wbFunction.setLayoutData(fdbFunction);
    wbFunction.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            searchString = wFunction.getText();
            getData();
          }
        });

    wFunction = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFunction);
    FormData fdFunction = new FormData();
    fdFunction.left = new FormAttachment(middle, 0);
    fdFunction.right = new FormAttachment(wbFunction, -margin);
    fdFunction.top = new FormAttachment(0, margin);
    wFunction.setLayoutData(fdFunction);
    Control lastControl = wFunction;

    // The buttons at the bottom of the dialog
    //
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOK.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        });
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        });

    // Position the buttons...
    //
    BaseStepDialog.positionBottomButtons(
        shell,
        new Button[] {
          wOK, wCancel,
        },
        Const.MARGIN,
        null);

    // The search results...
    //
    ColumnInfo[] columns =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Name.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Groupname.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Application.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapFunctionBrowser.ResultView.Description.Column"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
        };

    wResult =
        new TableView(
            space, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columns, 0, null, props);
    wResult.setSortable(true);

    FormData fdResults = new FormData();
    fdResults.left = new FormAttachment(0, 0);
    fdResults.top = new FormAttachment(lastControl, margin);
    fdResults.right = new FormAttachment(100, 0);
    fdResults.bottom = new FormAttachment(wOK, -3 * margin);
    wResult.setLayoutData(fdResults);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    getData();

    // Set the shell size, based upon previous time...
    BaseStepDialog.setSize(shell);

    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    return function;
  }
Ejemplo n.º 17
0
  private void showInputBox() {
    Display display = Display.getDefault();
    final Shell dialog = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    dialog.setText("Add a row");
    dialog.setLocation(
        shlTypeDocument.getBounds().x / 2 + shlTypeDocument.getBounds().width / 2,
        shlTypeDocument.getBounds().y / 2 + shlTypeDocument.getBounds().height / 2);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = 10;
    formLayout.marginHeight = 10;
    formLayout.spacing = 10;
    dialog.setLayout(formLayout);

    Label label = new Label(dialog, SWT.NONE);
    label.setText("Type an identifier:");
    FormData data = new FormData();
    label.setLayoutData(data);

    Button cancel = new Button(dialog, SWT.PUSH);
    cancel.setText("Cancel");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    cancel.setLayoutData(data);
    cancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            dialog.close();
          }
        });

    final Text text = new Text(dialog, SWT.BORDER);
    data = new FormData();
    data.width = 200;
    data.left = new FormAttachment(label, 0, SWT.DEFAULT);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(label, 0, SWT.CENTER);
    data.bottom = new FormAttachment(cancel, 0, SWT.DEFAULT);
    text.setLayoutData(data);

    Button ok = new Button(dialog, SWT.PUSH);
    ok.setText("OK");
    data = new FormData();
    data.width = 60;
    data.right = new FormAttachment(cancel, 0, SWT.DEFAULT);
    data.bottom = new FormAttachment(100, 0);
    ok.setLayoutData(data);
    ok.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            identifier = text.getText();
            dialog.close();
          }
        });

    dialog.setDefaultButton(ok);
    dialog.pack();
    dialog.open();
    while (!dialog.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
  public void open() {
    shell = new Shell(parentShell, style);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    if (title == null) title = BaseMessages.getString(PKG, "PreviewRowsDialog.Title");
    if (message == null)
      message = BaseMessages.getString(PKG, "PreviewRowsDialog.Header", stepname);

    if (buffer != null)
      message += " " + BaseMessages.getString(PKG, "PreviewRowsDialog.NrRows", "" + buffer.size());

    shell.setLayout(formLayout);
    shell.setText(title);

    if (addFields()) {
      return;
    }

    List<Button> buttons = new ArrayList<Button>();

    wClose = new Button(shell, SWT.PUSH);
    wClose.setText(BaseMessages.getString(PKG, "System.Button.Close"));
    wClose.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            close();
          }
        });
    buttons.add(wClose);

    if (!Const.isEmpty(loggingText)) {
      wLog = new Button(shell, SWT.PUSH);
      wLog.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.ShowLog"));
      wLog.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              log();
            }
          });
      buttons.add(wLog);
    }

    if (proposingToStop) {
      wStop = new Button(shell, SWT.PUSH);
      wStop.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Stop.Label"));
      wStop.setToolTipText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Stop.ToolTip"));
      wStop.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              askingToStop = true;
              close();
            }
          });
      buttons.add(wStop);
    }

    if (proposingToGetMoreRows) {
      wNext = new Button(shell, SWT.PUSH);
      wNext.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Next.Label"));
      wNext.setToolTipText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Next.ToolTip"));
      wNext.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              askingForMoreRows = true;
              close();
            }
          });
      buttons.add(wNext);
    }

    if (proposingToGetMoreRows || proposingToStop) {
      wClose.setText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Close.Label"));
      wClose.setToolTipText(BaseMessages.getString(PKG, "PreviewRowsDialog.Button.Close.ToolTip"));
    }

    // Position the buttons...
    //
    BaseStepDialog.positionBottomButtons(
        shell, buttons.toArray(new Button[buttons.size()]), Const.MARGIN, null);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            close();
          }
        });

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();

    if (!waitingForRows) {
      while (!shell.isDisposed()) {
        if (!shell.getDisplay().readAndDispatch()) shell.getDisplay().sleep();
      }
    }
  }
Ejemplo n.º 19
0
  protected void createElements() {
    super.createElements();
    shell.setText(BaseMessages.getString(PKG, "JobTrans.Header"));

    wlPath.setText(BaseMessages.getString(PKG, "JobTrans.JobStep.Transformation.Label"));
    wlDescription.setText(BaseMessages.getString(PKG, "JobTrans.Local.Label"));
    wPassParams.setText(BaseMessages.getString(PKG, "JobTrans.PassAllParameters.Label"));

    wCluster = new Button(typeComposite, SWT.RADIO);
    props.setLook(wCluster);
    wCluster.setText(BaseMessages.getString(PKG, "JobTrans.Clustered.Option.Label"));
    FormData fdbClustered = new FormData();
    fdbClustered.left = new FormAttachment(0, 0);
    fdbClustered.top = new FormAttachment(wbServer, 10);
    wCluster.setLayoutData(fdbClustered);
    wCluster.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            setRadioButtons();
          }
        });

    // Start Server Section
    wWaitingToFinish = new Button(wServer, SWT.CHECK);
    props.setLook(wWaitingToFinish);
    wWaitingToFinish.setText(BaseMessages.getString(PKG, "JobTrans.WaitToFinish.Label"));
    FormData fdWait = new FormData();
    fdWait.top = new FormAttachment(wSlaveServer, 10);
    fdWait.left = new FormAttachment(0, 0);
    wWaitingToFinish.setLayoutData(fdWait);

    wFollowingAbortRemotely = new Button(wServer, SWT.CHECK);
    props.setLook(wFollowingAbortRemotely);
    wFollowingAbortRemotely.setText(BaseMessages.getString(PKG, "JobTrans.AbortRemote.Label"));
    FormData fdFollow = new FormData();
    fdFollow.top = new FormAttachment(wWaitingToFinish, 10);
    fdFollow.left = new FormAttachment(0, 0);
    wFollowingAbortRemotely.setLayoutData(fdFollow);
    // End Server Section

    // Start Clustered Section
    wClustered = new Composite(gEnvironmentType, SWT.NONE);
    props.setLook(wClustered);
    wClustered.setVisible(false);
    FormLayout flwClustered = new FormLayout();
    flwClustered.marginWidth = 0;
    flwClustered.marginHeight = 0;
    wClustered.setLayout(flwClustered);

    FormData fdwClustered = new FormData();
    fdwClustered.left = new FormAttachment(vSpacer, 30);
    fdwClustered.top = new FormAttachment(0, 0);
    wClustered.setLayoutData(fdwClustered);

    Label wlClusteredDescription = new Label(wClustered, SWT.LEFT);
    props.setLook(wlClusteredDescription);
    wlClusteredDescription.setText(BaseMessages.getString(PKG, "JobTrans.Clustered.Label"));
    wlClusteredDescription.setVisible(true);
    FormData fdlCusteredDescription = new FormData();
    fdlCusteredDescription.top = new FormAttachment(0, 0);
    fdlCusteredDescription.left = new FormAttachment(0, 0);
    wlClusteredDescription.setLayoutData(fdlCusteredDescription);

    wClearRows = new Button(gExecution, SWT.CHECK);
    props.setLook(wClearRows);
    wClearRows.setText(BaseMessages.getString(PKG, "JobTrans.ClearResultList.Label"));
    FormData fdbClearRows = new FormData();
    fdbClearRows.left = new FormAttachment(0, 0);
    fdbClearRows.top = new FormAttachment(wEveryRow, 10);
    wClearRows.setLayoutData(fdbClearRows);

    wClearFiles = new Button(gExecution, SWT.CHECK);
    props.setLook(wClearFiles);
    wClearFiles.setText(BaseMessages.getString(PKG, "JobTrans.ClearResultFiles.Label"));
    FormData fdbClearFiles = new FormData();
    fdbClearFiles.left = new FormAttachment(0, 0);
    fdbClearFiles.top = new FormAttachment(wClearRows, 10);
    wClearFiles.setLayoutData(fdbClearFiles);

    wLogRemoteWork = new Button(wClustered, SWT.CHECK);
    props.setLook(wLogRemoteWork);
    wLogRemoteWork.setText(BaseMessages.getString(PKG, "JobTrans.LogRemoteWork.Label"));
    FormData fdLogRemote = new FormData();
    fdLogRemote.top = new FormAttachment(wlClusteredDescription, 10);
    fdLogRemote.left = new FormAttachment(0, 0);
    wLogRemoteWork.setLayoutData(fdLogRemote);
    // End Clustered Section

    wbGetParams.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            getParameters(null); // force reload from file specification
          }
        });

    wbBrowse.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (rep != null) {
              selectTransformation();
            } else {
              pickFileVFS();
            }
          }
        });

    wbLogFilename.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            selectLogFile(FILE_FILTERLOGNAMES);
          }
        });
  }
Ejemplo n.º 20
0
  public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
    props.setLook(shell);

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(shellText);
    int length = Const.LENGTH;
    int margin = Const.MARGIN;

    // The String line...
    wlString = new Label(shell, SWT.NONE);
    wlString.setText(lineText);
    props.setLook(wlString);
    fdlString = new FormData();
    fdlString.left = new FormAttachment(0, 0);
    fdlString.top = new FormAttachment(0, margin);
    wlString.setLayoutData(fdlString);
    wString = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wString.setText(string);
    props.setLook(wString);
    fdString = new FormData();
    fdString.left = new FormAttachment(0, 0);
    fdString.top = new FormAttachment(wlString, margin);
    fdString.right = new FormAttachment(0, length);
    wString.setLayoutData(fdString);

    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(Messages.getString("System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(Messages.getString("System.Button.Cancel"));

    BaseStepDialog.positionBottomButtons(shell, new Button[] {wOK, wCancel}, margin, wString);

    // 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();
          }
        };
    wString.addSelectionListener(lsDef);

    // Detect [X] or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return string;
  }
  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, m_currentMeta);

    // used to listen to a text field (m_wStepname)
    ModifyListener lsMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            m_currentMeta.setChanged();
          }
        };

    changed = m_currentMeta.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "HBaseRowDecoderDialog.Shell.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    m_stepnameLabel = new Label(shell, SWT.RIGHT);
    m_stepnameLabel.setText(BaseMessages.getString(PKG, "HBaseRowDecoderDialog.StepName.Label"));
    props.setLook(m_stepnameLabel);

    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(0, margin);
    m_stepnameLabel.setLayoutData(fd);
    m_stepnameText = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    m_stepnameText.setText(stepname);
    props.setLook(m_stepnameText);
    m_stepnameText.addModifyListener(lsMod);

    // format the text field
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.top = new FormAttachment(0, margin);
    fd.right = new FormAttachment(100, 0);
    m_stepnameText.setLayoutData(fd);

    m_wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(m_wTabFolder, Props.WIDGET_STYLE_TAB);
    m_wTabFolder.setSimple(false);

    // Start of the config tab
    m_wConfigTab = new CTabItem(m_wTabFolder, SWT.NONE);
    m_wConfigTab.setText(BaseMessages.getString(PKG, "HBaseRowDecoderDialog.ConfigTab.TabTitle"));

    Composite wConfigComp = new Composite(m_wTabFolder, SWT.NONE);
    props.setLook(wConfigComp);

    FormLayout configLayout = new FormLayout();
    configLayout.marginWidth = 3;
    configLayout.marginHeight = 3;
    wConfigComp.setLayout(configLayout);

    // incoming key field line
    Label inKeyLab = new Label(wConfigComp, SWT.RIGHT);
    inKeyLab.setText(BaseMessages.getString(PKG, "HBaseRowDecoderDialog.KeyField.Label"));
    props.setLook(inKeyLab);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(0, margin);
    fd.right = new FormAttachment(middle, -margin);
    inKeyLab.setLayoutData(fd);

    m_incomingKeyCombo = new CCombo(wConfigComp, SWT.BORDER);
    props.setLook(m_incomingKeyCombo);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.top = new FormAttachment(0, margin);
    fd.right = new FormAttachment(100, 0);
    m_incomingKeyCombo.setLayoutData(fd);

    m_incomingKeyCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            m_currentMeta.setChanged();
            m_incomingKeyCombo.setToolTipText(
                transMeta.environmentSubstitute(m_incomingKeyCombo.getText()));
          }
        });

    // incoming result line
    Label inResultLab = new Label(wConfigComp, SWT.RIGHT);
    inResultLab.setText(BaseMessages.getString(PKG, "HBaseRowDecoderDialog.ResultField.Label"));
    props.setLook(inResultLab);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(m_incomingKeyCombo, margin);
    fd.right = new FormAttachment(middle, -margin);
    inResultLab.setLayoutData(fd);

    m_incomingResultCombo = new CCombo(wConfigComp, SWT.BORDER);
    props.setLook(m_incomingResultCombo);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.top = new FormAttachment(m_incomingKeyCombo, margin);
    fd.right = new FormAttachment(100, 0);
    m_incomingResultCombo.setLayoutData(fd);

    m_incomingResultCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            m_currentMeta.setChanged();
            m_incomingResultCombo.setToolTipText(
                transMeta.environmentSubstitute(m_incomingResultCombo.getText()));
          }
        });

    populateFieldsCombo();

    wConfigComp.layout();
    m_wConfigTab.setControl(wConfigComp);

    // --- mapping editor tab
    m_editorTab = new CTabItem(m_wTabFolder, SWT.NONE);
    m_editorTab.setText(
        BaseMessages.getString(PKG, "HBaseRowDecoderDialog.MappingEditorTab.TabTitle"));

    m_mappingEditor =
        new MappingEditor(
            shell,
            m_wTabFolder,
            null,
            null,
            SWT.FULL_SELECTION | SWT.MULTI,
            false,
            props,
            transMeta);

    fd = new FormData();
    fd.top = new FormAttachment(0, 0);
    fd.left = new FormAttachment(0, 0);
    fd.bottom = new FormAttachment(100, -margin * 2);
    fd.right = new FormAttachment(100, 0);
    m_mappingEditor.setLayoutData(fd);

    m_mappingEditor.layout();
    m_editorTab.setControl(m_mappingEditor);

    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(m_stepnameText, margin);
    fd.right = new FormAttachment(100, 0);
    fd.bottom = new FormAttachment(100, -50);
    m_wTabFolder.setLayoutData(fd);

    // Buttons inherited from BaseStepDialog
    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, m_wTabFolder);

    // 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() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };

    m_stepnameText.addSelectionListener(lsDef);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          @Override
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    m_wTabFolder.setSelection(0);
    setSize();

    getData();

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    return stepname;
  }
  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();
          }
        };
    ModifyListener lsTableMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent arg0) {
            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, "SalesforceDeleteDialog.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 ///
    // ////////////////////////
    wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
    wGeneralTab.setText(BaseMessages.getString(PKG, "SalesforceDeleteDialog.General.Tab"));

    wGeneralComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wGeneralComp);

    FormLayout generalLayout = new FormLayout();
    generalLayout.marginWidth = 3;
    generalLayout.marginHeight = 3;
    wGeneralComp.setLayout(generalLayout);

    // ///////////////////////////////
    // START OF Connection GROUP //
    // ///////////////////////////////

    wConnectionGroup = new Group(wGeneralComp, SWT.SHADOW_NONE);
    props.setLook(wConnectionGroup);
    wConnectionGroup.setText(
        BaseMessages.getString(PKG, "SalesforceDeleteDialog.ConnectionGroup.Label"));

    FormLayout connectionGroupLayout = new FormLayout();
    connectionGroupLayout.marginWidth = 10;
    connectionGroupLayout.marginHeight = 10;
    wConnectionGroup.setLayout(connectionGroupLayout);

    // Webservice URL
    wURL =
        new LabelTextVar(
            transMeta,
            wConnectionGroup,
            BaseMessages.getString(PKG, "SalesforceDeleteDialog.URL.Label"),
            BaseMessages.getString(PKG, "SalesforceDeleteDialog.URL.Tooltip"));
    props.setLook(wURL);
    wURL.addModifyListener(lsMod);
    fdURL = new FormData();
    fdURL.left = new FormAttachment(0, 0);
    fdURL.top = new FormAttachment(wStepname, margin);
    fdURL.right = new FormAttachment(100, 0);
    wURL.setLayoutData(fdURL);

    // UserName line
    wUserName =
        new LabelTextVar(
            transMeta,
            wConnectionGroup,
            BaseMessages.getString(PKG, "SalesforceDeleteDialog.User.Label"),
            BaseMessages.getString(PKG, "SalesforceDeleteDialog.User.Tooltip"));
    props.setLook(wUserName);
    wUserName.addModifyListener(lsMod);
    fdUserName = new FormData();
    fdUserName.left = new FormAttachment(0, 0);
    fdUserName.top = new FormAttachment(wURL, margin);
    fdUserName.right = new FormAttachment(100, 0);
    wUserName.setLayoutData(fdUserName);

    // Password line
    wPassword =
        new LabelTextVar(
            transMeta,
            wConnectionGroup,
            BaseMessages.getString(PKG, "SalesforceDeleteDialog.Password.Label"),
            BaseMessages.getString(PKG, "SalesforceDeleteDialog.Password.Tooltip"),
            true);
    props.setLook(wPassword);
    wPassword.addModifyListener(lsMod);
    fdPassword = new FormData();
    fdPassword.left = new FormAttachment(0, 0);
    fdPassword.top = new FormAttachment(wUserName, margin);
    fdPassword.right = new FormAttachment(100, 0);
    wPassword.setLayoutData(fdPassword);

    // Test Salesforce connection button
    wTest = new Button(wConnectionGroup, SWT.PUSH);
    wTest.setText(BaseMessages.getString(PKG, "SalesforceDeleteDialog.TestConnection.Label"));
    props.setLook(wTest);
    fdTest = new FormData();
    wTest.setToolTipText(
        BaseMessages.getString(PKG, "SalesforceDeleteDialog.TestConnection.Tooltip"));
    fdTest.top = new FormAttachment(wPassword, margin);
    fdTest.right = new FormAttachment(100, 0);
    wTest.setLayoutData(fdTest);

    fdConnectionGroup = new FormData();
    fdConnectionGroup.left = new FormAttachment(0, margin);
    fdConnectionGroup.top = new FormAttachment(wStepname, margin);
    fdConnectionGroup.right = new FormAttachment(100, -margin);
    wConnectionGroup.setLayoutData(fdConnectionGroup);

    // ///////////////////////////////
    // END OF Connection GROUP //
    // ///////////////////////////////

    // ///////////////////////////////
    // START OF Settings GROUP //
    // ///////////////////////////////

    wSettingsGroup = new Group(wGeneralComp, SWT.SHADOW_NONE);
    props.setLook(wSettingsGroup);
    wSettingsGroup.setText(
        BaseMessages.getString(PKG, "SalesforceDeleteDialog.SettingsGroup.Label"));

    FormLayout settingGroupLayout = new FormLayout();
    settingGroupLayout.marginWidth = 10;
    settingGroupLayout.marginHeight = 10;
    wSettingsGroup.setLayout(settingGroupLayout);

    // Timeout
    wlTimeOut = new Label(wSettingsGroup, SWT.RIGHT);
    wlTimeOut.setText(BaseMessages.getString(PKG, "SalesforceDeleteDialog.TimeOut.Label"));
    props.setLook(wlTimeOut);
    fdlTimeOut = new FormData();
    fdlTimeOut.left = new FormAttachment(0, 0);
    fdlTimeOut.top = new FormAttachment(wSettingsGroup, margin);
    fdlTimeOut.right = new FormAttachment(middle, -margin);
    wlTimeOut.setLayoutData(fdlTimeOut);
    wTimeOut = new TextVar(transMeta, wSettingsGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTimeOut);
    wTimeOut.addModifyListener(lsMod);
    fdTimeOut = new FormData();
    fdTimeOut.left = new FormAttachment(middle, 0);
    fdTimeOut.top = new FormAttachment(wSettingsGroup, margin);
    fdTimeOut.right = new FormAttachment(100, 0);
    wTimeOut.setLayoutData(fdTimeOut);

    // Use compression?
    wlUseCompression = new Label(wSettingsGroup, SWT.RIGHT);
    wlUseCompression.setText(
        BaseMessages.getString(PKG, "SalesforceDeleteDialog.UseCompression.Label"));
    props.setLook(wlUseCompression);
    fdlUseCompression = new FormData();
    fdlUseCompression.left = new FormAttachment(0, 0);
    fdlUseCompression.top = new FormAttachment(wTimeOut, margin);
    fdlUseCompression.right = new FormAttachment(middle, -margin);
    wlUseCompression.setLayoutData(fdlUseCompression);
    wUseCompression = new Button(wSettingsGroup, SWT.CHECK);
    props.setLook(wUseCompression);
    wUseCompression.setToolTipText(
        BaseMessages.getString(PKG, "SalesforceDeleteDialog.UseCompression.Tooltip"));
    fdUseCompression = new FormData();
    fdUseCompression.left = new FormAttachment(middle, 0);
    fdUseCompression.top = new FormAttachment(wTimeOut, margin);
    wUseCompression.setLayoutData(fdUseCompression);

    // Rollback all changes on error?
    wlRollbackAllChangesOnError = new Label(wSettingsGroup, SWT.RIGHT);
    wlRollbackAllChangesOnError.setText(
        BaseMessages.getString(PKG, "SalesforceDeleteDialog.RollbackAllChangesOnError.Label"));
    props.setLook(wlRollbackAllChangesOnError);
    fdlRollbackAllChangesOnError = new FormData();
    fdlRollbackAllChangesOnError.left = new FormAttachment(0, 0);
    fdlRollbackAllChangesOnError.top = new FormAttachment(wUseCompression, margin);
    fdlRollbackAllChangesOnError.right = new FormAttachment(middle, -margin);
    wlRollbackAllChangesOnError.setLayoutData(fdlRollbackAllChangesOnError);
    wRollbackAllChangesOnError = new Button(wSettingsGroup, SWT.CHECK);
    props.setLook(wRollbackAllChangesOnError);
    wRollbackAllChangesOnError.setToolTipText(
        BaseMessages.getString(PKG, "SalesforceDeleteDialog.RollbackAllChangesOnError.Tooltip"));
    fdRollbackAllChangesOnError = new FormData();
    fdRollbackAllChangesOnError.left = new FormAttachment(middle, 0);
    fdRollbackAllChangesOnError.top = new FormAttachment(wUseCompression, margin);
    wRollbackAllChangesOnError.setLayoutData(fdRollbackAllChangesOnError);

    // BatchSize value
    wlBatchSize = new Label(wSettingsGroup, SWT.RIGHT);
    wlBatchSize.setText(BaseMessages.getString(PKG, "SalesforceDeleteDialog.Limit.Label"));
    props.setLook(wlBatchSize);
    fdlBatchSize = new FormData();
    fdlBatchSize.left = new FormAttachment(0, 0);
    fdlBatchSize.top = new FormAttachment(wRollbackAllChangesOnError, margin);
    fdlBatchSize.right = new FormAttachment(middle, -margin);
    wlBatchSize.setLayoutData(fdlBatchSize);
    wBatchSize = new TextVar(transMeta, wSettingsGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wBatchSize);
    wBatchSize.addModifyListener(lsMod);
    fdBatchSize = new FormData();
    fdBatchSize.left = new FormAttachment(middle, 0);
    fdBatchSize.top = new FormAttachment(wRollbackAllChangesOnError, margin);
    fdBatchSize.right = new FormAttachment(100, 0);
    wBatchSize.setLayoutData(fdBatchSize);

    // Module
    wlModule = new Label(wSettingsGroup, SWT.RIGHT);
    wlModule.setText(BaseMessages.getString(PKG, "SalesforceDeleteDialog.Module.Label"));
    props.setLook(wlModule);
    fdlModule = new FormData();
    fdlModule.left = new FormAttachment(0, 0);
    fdlModule.top = new FormAttachment(wBatchSize, margin);
    fdlModule.right = new FormAttachment(middle, -margin);
    wlModule.setLayoutData(fdlModule);
    wModule = new ComboVar(transMeta, wSettingsGroup, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wModule.setEditable(true);
    props.setLook(wModule);
    wModule.addModifyListener(lsTableMod);
    fdModule = new FormData();
    fdModule.left = new FormAttachment(middle, 0);
    fdModule.top = new FormAttachment(wBatchSize, margin);
    fdModule.right = new FormAttachment(100, -margin);
    wModule.setLayoutData(fdModule);
    wModule.addFocusListener(
        new FocusListener() {
          public void focusLost(org.eclipse.swt.events.FocusEvent e) {
            getModulesListError = false;
          }

          public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            // check if the URL and login credentials passed and not just had error
            if (Utils.isEmpty(wURL.getText())
                || Utils.isEmpty(wUserName.getText())
                || Utils.isEmpty(wPassword.getText())
                || (getModulesListError)) {
              return;
            }

            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            getModulesList();
            shell.setCursor(null);
            busy.dispose();
          }
        });

    // Salesforce Id Field
    wlDeleteField = new Label(wSettingsGroup, SWT.RIGHT);
    wlDeleteField.setText(BaseMessages.getString(PKG, "SalesforceDeleteDialog.KeyField.Label"));
    props.setLook(wlDeleteField);
    fdlDeleteField = new FormData();
    fdlDeleteField.left = new FormAttachment(0, 0);
    fdlDeleteField.top = new FormAttachment(wModule, margin);
    fdlDeleteField.right = new FormAttachment(middle, -margin);
    wlDeleteField.setLayoutData(fdlDeleteField);
    wDeleteField = new ComboVar(transMeta, wSettingsGroup, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wDeleteField.setEditable(true);
    props.setLook(wDeleteField);
    wDeleteField.addModifyListener(lsMod);
    fdDeleteField = new FormData();
    fdDeleteField.left = new FormAttachment(middle, 0);
    fdDeleteField.top = new FormAttachment(wModule, margin);
    fdDeleteField.right = new FormAttachment(100, -margin);
    wDeleteField.setLayoutData(fdDeleteField);
    wDeleteField.addFocusListener(
        new FocusListener() {
          public void focusLost(org.eclipse.swt.events.FocusEvent e) {}

          public void focusGained(org.eclipse.swt.events.FocusEvent e) {
            getPreviousFields();
          }
        });

    fdSettingsGroup = new FormData();
    fdSettingsGroup.left = new FormAttachment(0, margin);
    fdSettingsGroup.top = new FormAttachment(wConnectionGroup, margin);
    fdSettingsGroup.right = new FormAttachment(100, -margin);
    wSettingsGroup.setLayoutData(fdSettingsGroup);

    // ///////////////////////////////
    // END OF Settings GROUP //
    // ///////////////////////////////

    fdGeneralComp = new FormData();
    fdGeneralComp.left = new FormAttachment(0, 0);
    fdGeneralComp.top = new FormAttachment(wStepname, margin);
    fdGeneralComp.right = new FormAttachment(100, 0);
    fdGeneralComp.bottom = new FormAttachment(100, 0);
    wGeneralComp.setLayoutData(fdGeneralComp);

    wGeneralComp.layout();
    wGeneralTab.setControl(wGeneralComp);

    // 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);

    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(wOK, -margin);
    wTabFolder.setLayoutData(fdTabFolder);

    // Add listeners
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };
    lsTest =
        new Listener() {
          public void handleEvent(Event e) {
            test();
          }
        };

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

    wOK.addListener(SWT.Selection, lsOK);
    wTest.addListener(SWT.Selection, lsTest);
    wCancel.addListener(SWT.Selection, lsCancel);

    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();
          }
        });

    wTabFolder.setSelection(0);

    // Set the shell size, based upon previous time...
    setSize();
    getData(input);
    input.setChanged(changed);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepname;
  }
Ejemplo n.º 23
0
  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, "NormaliserDialog.Shell.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "NormaliserDialog.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);

    // Typefield line
    wlTypefield = new Label(shell, SWT.RIGHT);
    wlTypefield.setText(BaseMessages.getString(PKG, "NormaliserDialog.TypeField.Label"));
    props.setLook(wlTypefield);
    fdlTypefield = new FormData();
    fdlTypefield.left = new FormAttachment(0, 0);
    fdlTypefield.right = new FormAttachment(middle, -margin);
    fdlTypefield.top = new FormAttachment(wStepname, margin);
    wlTypefield.setLayoutData(fdlTypefield);
    wTypefield = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wTypefield.setText("");
    props.setLook(wTypefield);
    wTypefield.addModifyListener(lsMod);
    fdTypefield = new FormData();
    fdTypefield.left = new FormAttachment(middle, 0);
    fdTypefield.top = new FormAttachment(wStepname, margin);
    fdTypefield.right = new FormAttachment(100, 0);
    wTypefield.setLayoutData(fdTypefield);

    wlFields = new Label(shell, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "NormaliserDialog.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.top = new FormAttachment(wTypefield, margin);
    wlFields.setLayoutData(fdlFields);

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "NormaliserDialog.GetFields.Button"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));

    setButtonPositions(new Button[] {wOK, wCancel, wGet}, margin, null);

    final int FieldsCols = 3;
    final int FieldsRows = input.getFieldName().length;

    colinf = new ColumnInfo[FieldsCols];
    colinf[0] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.Fieldname"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {""},
            false);
    colinf[1] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.Type"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false);
    colinf[2] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "NormaliserDialog.ColumnInfo.NewField"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false);

    wFields =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            colinf,
            FieldsRows,
            lsMod,
            props);

    fdFields = new FormData();
    fdFields.left = new FormAttachment(0, 0);
    fdFields.top = new FormAttachment(wlFields, margin);
    fdFields.right = new FormAttachment(100, 0);
    fdFields.bottom = new FormAttachment(wOK, -2 * margin);
    wFields.setLayoutData(fdFields);

    //
    // Search the fields in the background

    final Runnable runnable =
        new Runnable() {
          public void run() {
            StepMeta stepMeta = transMeta.findStep(stepname);
            if (stepMeta != null) {
              try {
                RowMetaInterface row = transMeta.getPrevStepFields(stepMeta);

                // Remember these fields...
                for (int i = 0; i < row.size(); i++) {
                  inputFields.put(row.getValueMeta(i).getName(), Integer.valueOf(i));
                }
                setComboBoxes();
              } catch (KettleException e) {
                logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"));
              }
            }
          }
        };
    new Thread(runnable).start();

    // Add listeners
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };
    lsGet =
        new Listener() {
          public void handleEvent(Event e) {
            get();
          }
        };
    lsCancel =
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        };

    wOK.addListener(SWT.Selection, lsOK);
    wGet.addListener(SWT.Selection, lsGet);
    wCancel.addListener(SWT.Selection, lsCancel);

    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();

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return stepname;
  }
  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, stepMeta.getStepMetaInterface());

    ModifyListener lsMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            partitioningMeta.hasChanged(true);
          }
        };
    changed = partitioningMeta.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(partitioner.getDescription()); // $NON-NLS-1$

    int margin = Const.MARGIN;

    int middle = props.getMiddlePct();

    wlFieldname = new Label(shell, SWT.RIGHT);
    wlFieldname.setText("Fieldname"); // $NON-NLS-1$
    props.setLook(wlFieldname);
    fdlFieldname = new FormData();
    fdlFieldname.left = new FormAttachment(0, 0);
    fdlFieldname.right = new FormAttachment(middle, -margin);
    fdlFieldname.top = new FormAttachment(0, margin);
    wlFieldname.setLayoutData(fdlFieldname);
    wFieldname = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wFieldname.setText(fieldName == null ? "" : fieldName);
    props.setLook(wFieldname);
    wFieldname.addModifyListener(lsMod);
    fdFieldname = new FormData();
    fdFieldname.left = new FormAttachment(middle, 0);
    fdFieldname.top = new FormAttachment(0, margin);
    fdFieldname.right = new FormAttachment(100, 0);
    wFieldname.setLayoutData(fdFieldname);

    try {
      RowMetaInterface inputFields = transMeta.getPrevStepFields(stepMeta);
      if (inputFields != null) {
        String[] fieldNames = inputFields.getFieldNames();
        Arrays.sort(fieldNames);
        wFieldname.setItems(fieldNames);
      }
    } catch (KettleStepException e) {
      new ErrorDialog(shell, "Error", "Error obtaining list of input fields:", e);
    }

    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); // $NON-NLS-1$
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); // $NON-NLS-1$
    fdOK = new FormData();

    setButtonPositions(new Button[] {wOK, wCancel}, margin, null);

    // 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();
          }
        };

    // 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();
    partitioningMeta.hasChanged(changed);

    setSize();

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepname;
  }
  private void drawWindow() {
    shell =
        new Shell(SWT.ON_TOP | SWT.APPLICATION_MODAL | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);

    // Setup Title
    shell.setText("Artifact Information");

    // Setup Icon
    Image image = ArtifactImageManager.getImage(CoreArtifactTypes.Artifact);
    shell.setImage(image);

    // Setup Form Layout
    FormLayout layout = new FormLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    shell.setLayout(layout);

    SashForm sashForm = new SashForm(shell, SWT.VERTICAL);

    // Create valid artifact fields
    FormLayout validLayout = new FormLayout();
    validLayout.spacing = 5;

    Composite validComposite = new Composite(sashForm, SWT.NONE);
    validComposite.setLayout(validLayout);

    Label validLabel = new Label(validComposite, SWT.LEFT);
    validLabel.setText("Valid artifacts - will be added");

    Table validTable =
        new Table(
            validComposite,
            SWT.MULTI
                | SWT.BORDER
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.FULL_SELECTION
                | SWT.HIDE_SELECTION);
    validTable.setLinesVisible(true);
    validTable.setHeaderVisible(true);

    // Create invalid artifacts fields
    FormLayout invalidLayout = new FormLayout();
    invalidLayout.spacing = 5;

    Composite invalidComposite = new Composite(sashForm, SWT.NONE);
    invalidComposite.setLayout(invalidLayout);

    Label invalidLabel = new Label(invalidComposite, SWT.LEFT);
    invalidLabel.setText("Invalid artifacts - will not be added");

    Table invalidTable =
        new Table(
            invalidComposite,
            SWT.MULTI
                | SWT.BORDER
                | SWT.H_SCROLL
                | SWT.V_SCROLL
                | SWT.FULL_SELECTION
                | SWT.HIDE_SELECTION);
    invalidTable.setLinesVisible(true);
    invalidTable.setHeaderVisible(true);

    // Create the Buttons
    Button okButton = new Button(invalidComposite, SWT.PUSH);
    okButton.setText("OK");

    Button cancelButton = new Button(invalidComposite, SWT.PUSH);
    cancelButton.setText("Cancel");

    // Attach validLabel to top-left corner
    FormData data = new FormData();
    data.top = new FormAttachment(0);
    data.left = new FormAttachment(0);
    validLabel.setLayoutData(data);

    // Attach validTable to bottom of validLabel
    data = new FormData();
    data.top = new FormAttachment(validLabel);
    data.bottom = new FormAttachment(100);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.height = validTable.getItemHeight() * 10;
    validTable.setLayoutData(data);

    // Attach invalidLabel to top-left corner
    data = new FormData();
    data.top = new FormAttachment(0);
    data.left = new FormAttachment(0);
    invalidLabel.setLayoutData(data);

    // Attach invalidTable to bottom of invalidLabel
    data = new FormData();
    data.top = new FormAttachment(invalidLabel);
    data.bottom = new FormAttachment(okButton);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    data.height = validTable.getItemHeight() * 10;
    invalidTable.setLayoutData(data);

    // Attach sashForm to top-left corner of shell
    data = new FormData();
    data.top = new FormAttachment(0);
    data.bottom = new FormAttachment(100);
    data.left = new FormAttachment(0);
    data.right = new FormAttachment(100);
    sashForm.setLayoutData(data);

    // Attach buttons to bottom of sashForm
    data = new FormData();
    data.bottom = new FormAttachment(100);
    data.right = new FormAttachment(100);
    cancelButton.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100);
    data.right = new FormAttachment(cancelButton);
    okButton.setLayoutData(data);

    // Populate Tables
    relationTableViewer = new RelationTableViewer(validTable, invalidTable, branch);
    for (int i = 0; i < validArtifacts.size(); i++) {
      relationTableViewer.addValidItem(validArtifacts.get(i));
    }
    for (int i = 0; i < invalidName.size(); i++) {
      relationTableViewer.addInvalidItem(invalidName.get(i), invalidReason.get(i));
    }

    // Add Listeners to buttons
    okButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            okSelected();
          }
        });

    cancelButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            cancelSelected();
          }
        });

    // Add shell resize listener
    shell.addControlListener(
        new ControlListener() {

          @Override
          public void controlMoved(ControlEvent e) {
            // do nothing
          }

          @Override
          public void controlResized(ControlEvent e) {
            relationTableViewer.resizeTable(((Shell) e.widget).getClientArea().width);
            shell.layout();
          }
        });

    if (needWindow) {
      shell.pack();
      shell.open();
    } else {
      okSelected();
    }
  }
  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();
    backupCondition = (Condition) condition.clone();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Shell.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "JoinRowsDialog.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
    wlSortDir = new Label(shell, SWT.RIGHT);
    wlSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempDir.Label"));
    props.setLook(wlSortDir);
    fdlSortDir = new FormData();
    fdlSortDir.left = new FormAttachment(0, 0);
    fdlSortDir.right = new FormAttachment(middle, -margin);
    fdlSortDir.top = new FormAttachment(wStepname, margin);
    wlSortDir.setLayoutData(fdlSortDir);

    wbSortDir = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSortDir);
    wbSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Browse.Button"));
    fdbSortDir = new FormData();
    fdbSortDir.right = new FormAttachment(100, 0);
    fdbSortDir.top = new FormAttachment(wStepname, margin);
    wbSortDir.setLayoutData(fdbSortDir);

    wSortDir = new TextVar(transMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wSortDir.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Temp.Label"));
    props.setLook(wSortDir);
    wSortDir.addModifyListener(lsMod);
    fdSortDir = new FormData();
    fdSortDir.left = new FormAttachment(middle, 0);
    fdSortDir.top = new FormAttachment(wStepname, margin);
    fdSortDir.right = new FormAttachment(wbSortDir, -margin);
    wSortDir.setLayoutData(fdSortDir);

    wbSortDir.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            DirectoryDialog dd = new DirectoryDialog(shell, SWT.NONE);
            dd.setFilterPath(wSortDir.getText());
            String dir = dd.open();
            if (dir != null) {
              wSortDir.setText(dir);
            }
          }
        });

    // Whenever something changes, set the tooltip to the expanded version:
    wSortDir.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            wSortDir.setToolTipText(transMeta.environmentSubstitute(wSortDir.getText()));
          }
        });

    // Table line...
    wlPrefix = new Label(shell, SWT.RIGHT);
    wlPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.TempFilePrefix.Label"));
    props.setLook(wlPrefix);
    fdlPrefix = new FormData();
    fdlPrefix.left = new FormAttachment(0, 0);
    fdlPrefix.right = new FormAttachment(middle, -margin);
    fdlPrefix.top = new FormAttachment(wbSortDir, margin * 2);
    wlPrefix.setLayoutData(fdlPrefix);
    wPrefix = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPrefix);
    wPrefix.addModifyListener(lsMod);
    fdPrefix = new FormData();
    fdPrefix.left = new FormAttachment(middle, 0);
    fdPrefix.top = new FormAttachment(wbSortDir, margin * 2);
    fdPrefix.right = new FormAttachment(100, 0);
    wPrefix.setLayoutData(fdPrefix);
    wPrefix.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Prefix.Label"));

    // Cache size...
    wlCache = new Label(shell, SWT.RIGHT);
    wlCache.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Cache.Label"));
    props.setLook(wlCache);
    fdlCache = new FormData();
    fdlCache.left = new FormAttachment(0, 0);
    fdlCache.right = new FormAttachment(middle, -margin);
    fdlCache.top = new FormAttachment(wPrefix, margin * 2);
    wlCache.setLayoutData(fdlCache);
    wCache = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCache);
    wCache.addModifyListener(lsMod);
    fdCache = new FormData();
    fdCache.left = new FormAttachment(middle, 0);
    fdCache.top = new FormAttachment(wPrefix, margin * 2);
    fdCache.right = new FormAttachment(100, 0);
    wCache.setLayoutData(fdCache);

    // Read date from...
    wlMainStep = new Label(shell, SWT.RIGHT);
    wlMainStep.setText(BaseMessages.getString(PKG, "JoinRowsDialog.MainStep.Label"));
    props.setLook(wlMainStep);
    fdlMainStep = new FormData();
    fdlMainStep.left = new FormAttachment(0, 0);
    fdlMainStep.right = new FormAttachment(middle, -margin);
    fdlMainStep.top = new FormAttachment(wCache, margin);
    wlMainStep.setLayoutData(fdlMainStep);
    wMainStep = new CCombo(shell, SWT.BORDER);
    props.setLook(wMainStep);

    List<StepMeta> prevSteps = transMeta.findPreviousSteps(transMeta.findStep(stepname));
    for (StepMeta stepMeta : prevSteps) {
      wMainStep.add(stepMeta.getName());
    }

    wMainStep.addModifyListener(lsMod);
    fdMainStep = new FormData();
    fdMainStep.left = new FormAttachment(middle, 0);
    fdMainStep.top = new FormAttachment(wCache, margin);
    fdMainStep.right = new FormAttachment(100, 0);
    wMainStep.setLayoutData(fdMainStep);

    // Condition widget...
    wlCondition = new Label(shell, SWT.NONE);
    wlCondition.setText(BaseMessages.getString(PKG, "JoinRowsDialog.Condition.Label"));
    props.setLook(wlCondition);
    fdlCondition = new FormData();
    fdlCondition.left = new FormAttachment(0, 0);
    fdlCondition.top = new FormAttachment(wMainStep, margin);
    wlCondition.setLayoutData(fdlCondition);

    RowMetaInterface inputfields = null;
    try {
      inputfields = transMeta.getPrevStepFields(stepname);
    } catch (KettleException ke) {
      inputfields = new RowMeta();
      new ErrorDialog(
          shell,
          BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogTitle"),
          BaseMessages.getString(PKG, "JoinRowsDialog.FailedToGetFields.DialogMessage"),
          ke);
    }

    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);

    wCondition = new ConditionEditor(shell, SWT.BORDER, condition, inputfields);

    fdCondition = new FormData();
    fdCondition.left = new FormAttachment(0, 0);
    fdCondition.top = new FormAttachment(wlCondition, margin);
    fdCondition.right = new FormAttachment(100, 0);
    fdCondition.bottom = new FormAttachment(wOK, -2 * margin);
    wCondition.setLayoutData(fdCondition);
    wCondition.addModifyListener(lsMod);

    // 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);
    wSortDir.addSelectionListener(lsDef);
    wPrefix.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;
  }
  /*
   * Constructing all Dialog widgets Return the (possibly new) name of the
   * step. If it returns null, Kettle assumes that the dialog was cancelled
   * (done by Cancel handler).
   */
  public String open() {
    String t = super.open();
    shell.setText(BaseMessages.getString(PKG, "LoadSatDialog.Shell.Title"));

    // Stepname line
    wlStepname.setText(BaseMessages.getString(PKG, "LoadDialog.Stepname.Label"));

    // Connection line
    wConnection.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            // We have new content: change ci connection:
            dbMeta = transMeta.findDatabase(wConnection.getText());
            inputMeta.setChanged();
            resetColumnsCache();
          }
        });

    // Schema line...
    wlSchema.setText(BaseMessages.getString(PKG, "LoadDialog.TargetSchema.Label"));

    // Sat Table line...
    wlTargetTable.setText(BaseMessages.getString(PKG, "LoadSatDialog.Target.Label"));

    // Batch size ...

    // Idempotent ?
    wlIsIdempotentSat = new Label(shell, SWT.RIGHT);
    wlIsIdempotentSat.setText(BaseMessages.getString(PKG, "LoadSatDialog.IdempotentTransf.Label"));
    props.setLook(wlIsIdempotentSat);
    FormData fdlIdempotent = new FormData();
    fdlIdempotent.left = new FormAttachment(0, 0);
    fdlIdempotent.right = new FormAttachment(middle, -margin);
    fdlIdempotent.top = new FormAttachment(wBatchSize, margin);
    wlIsIdempotentSat.setLayoutData(fdlIdempotent);

    wbIsIdempotentSat = new Button(shell, SWT.CHECK);
    props.setLook(wbIsIdempotentSat);
    FormData fdbExtNatkeyTable = new FormData();
    fdbExtNatkeyTable.left = new FormAttachment(middle, 0);
    fdbExtNatkeyTable.right = new FormAttachment(middle + (100 - middle) / 3, -margin);
    fdbExtNatkeyTable.top = new FormAttachment(wBatchSize, margin);
    wbIsIdempotentSat.setLayoutData(fdbExtNatkeyTable);
    wbIsIdempotentSat.setToolTipText(
        BaseMessages.getString(PKG, "LoadSatDialog.IdempotentTransf.Tooltip"));

    //
    // The fields mapping
    //
    wlKey = new Label(shell, SWT.NONE);
    wlKey.setText(BaseMessages.getString(PKG, "LoadSatDialog.Attfields.Label"));
    props.setLook(wlKey);
    FormData fdlKey = new FormData();
    fdlKey.left = new FormAttachment(0, 0);
    fdlKey.top = new FormAttachment(wbIsIdempotentSat, margin * 3);
    fdlKey.right = new FormAttachment(100, 0);
    wlKey.setLayoutData(fdlKey);

    int nrKeyCols = 3;
    int nrRows = (inputMeta.getFields() != null ? inputMeta.getFields().length : 1);

    ciKey = new ColumnInfo[nrKeyCols];
    ciKey[0] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "LoadSatDialog.ColumnInfo.TableColumn"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {""},
            false);
    ciKey[1] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "LoadSatDialog.ColumnInfo.FieldInStream"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {""},
            false);
    ciKey[2] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "LoadSatDialog.ColumnInfo.Type"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {
              LoadSatMeta.ATTRIBUTE_NORMAL,
              LoadSatMeta.ATTRIBUTE_FK,
              LoadSatMeta.ATTRIBUTE_TEMPORAL,
              LoadSatMeta.ATTRIBUTE_META
            });

    // attach the tableFieldColumns List to the widget
    tableFieldColumns.add(ciKey[0]);
    wKey =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciKey,
            nrRows,
            lsMod,
            props);

    ciKey[2].setSelectionAdapter(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            hasOneTemporalField = false;
            // iterate mapping list and "activate" temporal or not...
            for (int i = 0; i < wKey.nrNonEmpty(); i++) {
              TableItem item = wKey.getNonEmpty(i);
              if (item.getText(3).equals(LoadSatMeta.ATTRIBUTE_TEMPORAL)) {
                hasOneTemporalField = true;
                break;
              }
            }
            enableFields();
          }
        });

    // The optional Group for closing "ToDate"
    Group wClosingDateFields = new Group(shell, SWT.SHADOW_ETCHED_IN);
    wClosingDateFields.setText(BaseMessages.getString(PKG, "LoadSatDialog.UsingOptToDate.Label"));

    FormLayout closingDateGroupLayout = new FormLayout();
    closingDateGroupLayout.marginWidth = 3;
    closingDateGroupLayout.marginHeight = 3;
    wClosingDateFields.setLayout(closingDateGroupLayout);
    props.setLook(wClosingDateFields);

    // ToDate Expire Column name...
    wlToDateCol = new Label(wClosingDateFields, SWT.RIGHT);
    wlToDateCol.setText(BaseMessages.getString(PKG, "LoadSatDialog.ToDateExpCol.Label"));
    props.setLook(wlToDateCol);
    FormData fdlNatTable = new FormData();
    fdlNatTable.left = new FormAttachment(0, 0);
    fdlNatTable.right = new FormAttachment(middle, -margin);
    fdlNatTable.top = new FormAttachment(wClosingDateFields, margin);
    wlToDateCol.setLayoutData(fdlNatTable);

    wcbToDateCol = new CCombo(wClosingDateFields, SWT.BORDER);
    props.setLook(wcbToDateCol);
    wcbToDateCol.addModifyListener(lsMod);
    FormData fdToDate = new FormData();
    fdToDate.left = new FormAttachment(middle, 0);
    fdToDate.right = new FormAttachment(middle + (100 - middle) / 2, -margin);
    fdToDate.top = new FormAttachment(wClosingDateFields, margin);
    wcbToDateCol.setLayoutData(fdToDate);
    wcbToDateCol.addFocusListener(
        new FocusListener() {
          public void focusLost(FocusEvent arg0) {}

          public void focusGained(FocusEvent arg0) {
            Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
            shell.setCursor(busy);
            setToDateColumns();
            shell.setCursor(null);
            busy.dispose();
          }
        });

    // Expire toDate MAX flag value
    wlToDateMax = new Label(wClosingDateFields, SWT.RIGHT);
    String flagText = BaseMessages.getString(PKG, "LoadSatDialog.ExpRecFlag.Label");
    wlToDateMax.setText(flagText);
    props.setLook(wlToDateMax);
    FormData fdlToDateMax = new FormData();
    fdlToDateMax.left = new FormAttachment(0, 0);
    fdlToDateMax.right = new FormAttachment(middle, -margin);
    fdlToDateMax.top = new FormAttachment(wcbToDateCol, margin);
    wlToDateMax.setLayoutData(fdlToDateMax);

    wToDateMax = new Text(wClosingDateFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wToDateMax);
    wToDateMax.addModifyListener(lsMod);
    FormData fdToDateMax = new FormData();
    fdToDateMax.left = new FormAttachment(middle, 0);
    fdToDateMax.right = new FormAttachment(middle + (100 - middle) / 2, -margin);
    fdToDateMax.top = new FormAttachment(wcbToDateCol, margin);
    wToDateMax.setLayoutData(fdToDateMax);

    Label wlToDateFlag = new Label(wClosingDateFields, SWT.RIGHT);
    wlToDateFlag.setText("(" + LoadSatMeta.DATE_FORMAT + ")");
    props.setLook(wlToDateFlag);
    FormData fdlToDateFlag = new FormData();
    fdlToDateFlag.left = new FormAttachment(wToDateMax, margin);
    fdlToDateFlag.top = new FormAttachment(wcbToDateCol, 2 * margin);
    wlToDateFlag.setLayoutData(fdlToDateFlag);

    // Fixing the "ClosingDate" group
    FormData fdOptGroup = new FormData();
    fdOptGroup.left = new FormAttachment(0, 0);
    fdOptGroup.right = new FormAttachment(100, 0);
    fdOptGroup.bottom = new FormAttachment(wAuditFields, -2 * margin);
    wClosingDateFields.setLayoutData(fdOptGroup);
    wClosingDateFields.setTabList(new Control[] {wcbToDateCol, wToDateMax});

    // to fix the Mapping Grid
    FormData fdKey = new FormData();
    fdKey.left = new FormAttachment(0, 0);
    fdKey.top = new FormAttachment(wlKey, margin);
    fdKey.right = new FormAttachment(100, 0);
    fdKey.bottom = new FormAttachment(wClosingDateFields, -2 * margin);
    wKey.setLayoutData(fdKey);

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

    wbIsIdempotentSat.addSelectionListener(lsDef);
    wcbToDateCol.addSelectionListener(lsDef);
    wToDateMax.addSelectionListener(lsDef);

    getData();
    setTableFieldCombo();
    inputMeta.setChanged(backupChanged);

    // Set the shell size, based upon previous time...
    setSize();

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepname;
  }
Ejemplo n.º 28
0
  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(Messages.getString("UpdateDialog.Shell.Title")); // $NON-NLS-1$

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(Messages.getString("UpdateDialog.Stepname.Label")); // $NON-NLS-1$
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.right = new FormAttachment(middle, -margin);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);

    // Connection line
    wConnection = addConnectionLine(shell, wStepname, middle, margin);
    if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) wConnection.select(0);
    wConnection.addModifyListener(lsMod);

    // Schema line...
    wlSchema = new Label(shell, SWT.RIGHT);
    wlSchema.setText(Messages.getString("UpdateDialog.TargetSchema.Label")); // $NON-NLS-1$
    props.setLook(wlSchema);
    fdlSchema = new FormData();
    fdlSchema.left = new FormAttachment(0, 0);
    fdlSchema.right = new FormAttachment(middle, -margin);
    fdlSchema.top = new FormAttachment(wConnection, margin * 2);
    wlSchema.setLayoutData(fdlSchema);

    wSchema = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSchema);
    wSchema.addModifyListener(lsMod);
    fdSchema = new FormData();
    fdSchema.left = new FormAttachment(middle, 0);
    fdSchema.top = new FormAttachment(wConnection, margin * 2);
    fdSchema.right = new FormAttachment(100, 0);
    wSchema.setLayoutData(fdSchema);

    // Table line...
    wlTable = new Label(shell, SWT.RIGHT);
    wlTable.setText(Messages.getString("UpdateDialog.TargetTable.Label")); // $NON-NLS-1$
    props.setLook(wlTable);
    fdlTable = new FormData();
    fdlTable.left = new FormAttachment(0, 0);
    fdlTable.right = new FormAttachment(middle, -margin);
    fdlTable.top = new FormAttachment(wSchema, margin);
    wlTable.setLayoutData(fdlTable);

    wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbTable);
    wbTable.setText(Messages.getString("UpdateDialog.Browse.Button")); // $NON-NLS-1$
    fdbTable = new FormData();
    fdbTable.right = new FormAttachment(100, 0);
    fdbTable.top = new FormAttachment(wSchema, margin);
    wbTable.setLayoutData(fdbTable);

    wTable = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTable);
    wTable.addModifyListener(lsMod);
    fdTable = new FormData();
    fdTable.left = new FormAttachment(middle, 0);
    fdTable.top = new FormAttachment(wSchema, margin);
    fdTable.right = new FormAttachment(wbTable, -margin);
    wTable.setLayoutData(fdTable);

    // Commit line
    wlCommit = new Label(shell, SWT.RIGHT);
    wlCommit.setText(Messages.getString("UpdateDialog..Commit.Label")); // $NON-NLS-1$
    props.setLook(wlCommit);
    fdlCommit = new FormData();
    fdlCommit.left = new FormAttachment(0, 0);
    fdlCommit.top = new FormAttachment(wTable, margin);
    fdlCommit.right = new FormAttachment(middle, -margin);
    wlCommit.setLayoutData(fdlCommit);
    wCommit = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCommit);
    wCommit.addModifyListener(lsMod);
    fdCommit = new FormData();
    fdCommit.left = new FormAttachment(middle, 0);
    fdCommit.top = new FormAttachment(wTable, margin);
    fdCommit.right = new FormAttachment(100, 0);
    wCommit.setLayoutData(fdCommit);

    wlErrorIgnored = new Label(shell, SWT.RIGHT);
    wlErrorIgnored.setText(Messages.getString("UpdateDialog.ErrorIgnored.Label")); // $NON-NLS-1$
    props.setLook(wlErrorIgnored);
    fdlErrorIgnored = new FormData();
    fdlErrorIgnored.left = new FormAttachment(0, 0);
    fdlErrorIgnored.top = new FormAttachment(wCommit, margin);
    fdlErrorIgnored.right = new FormAttachment(middle, -margin);
    wlErrorIgnored.setLayoutData(fdlErrorIgnored);

    wErrorIgnored = new Button(shell, SWT.CHECK);
    props.setLook(wErrorIgnored);
    wErrorIgnored.setToolTipText(
        Messages.getString("UpdateDialog.ErrorIgnored.ToolTip")); // $NON-NLS-1$
    fdErrorIgnored = new FormData();
    fdErrorIgnored.left = new FormAttachment(middle, 0);
    fdErrorIgnored.top = new FormAttachment(wCommit, margin);
    wErrorIgnored.setLayoutData(fdErrorIgnored);
    wErrorIgnored.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            input.setChanged();
            setFlags();
          }
        });

    wlIgnoreFlagField = new Label(shell, SWT.LEFT);
    wlIgnoreFlagField.setText(Messages.getString("UpdateDialog.FlagField.Label")); // $NON-NLS-1$
    props.setLook(wlIgnoreFlagField);
    fdlIgnoreFlagField = new FormData();
    fdlIgnoreFlagField.left = new FormAttachment(wErrorIgnored, margin);
    fdlIgnoreFlagField.top = new FormAttachment(wCommit, margin);
    wlIgnoreFlagField.setLayoutData(fdlIgnoreFlagField);
    wIgnoreFlagField = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wIgnoreFlagField);
    wIgnoreFlagField.addModifyListener(lsMod);
    fdIgnoreFlagField = new FormData();
    fdIgnoreFlagField.left = new FormAttachment(wlIgnoreFlagField, margin);
    fdIgnoreFlagField.top = new FormAttachment(wCommit, margin);
    fdIgnoreFlagField.right = new FormAttachment(100, 0);
    wIgnoreFlagField.setLayoutData(fdIgnoreFlagField);

    wlKey = new Label(shell, SWT.NONE);
    wlKey.setText(Messages.getString("UpdateDialog.Key.Label")); // $NON-NLS-1$
    props.setLook(wlKey);
    fdlKey = new FormData();
    fdlKey.left = new FormAttachment(0, 0);
    fdlKey.top = new FormAttachment(wIgnoreFlagField, margin);
    wlKey.setLayoutData(fdlKey);

    int nrKeyCols = 4;
    int nrKeyRows = (input.getKeyStream() != null ? input.getKeyStream().length : 1);

    ColumnInfo[] ciKey = new ColumnInfo[nrKeyCols];
    ciKey[0] =
        new ColumnInfo(
            Messages.getString("UpdateDialog.ColumnInfo.TableField"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false); //$NON-NLS-1$
    ciKey[1] =
        new ColumnInfo(
            Messages.getString("UpdateDialog.ColumnInfo.Comparator"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {
              "=", "<>", "<", "<=", ">", ">=", "LIKE", "BETWEEN", "IS NULL", "IS NOT NULL"
            }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
                // //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
    ciKey[2] =
        new ColumnInfo(
            Messages.getString("UpdateDialog.ColumnInfo.StreamField1"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false); //$NON-NLS-1$
    ciKey[3] =
        new ColumnInfo(
            Messages.getString("UpdateDialog.ColumnInfo.StreamField2"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false); //$NON-NLS-1$

    wKey =
        new TableView(
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciKey,
            nrKeyRows,
            lsMod,
            props);

    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(Messages.getString("UpdateDialog.GetFields.Button")); // $NON-NLS-1$
    fdGet = new FormData();
    fdGet.right = new FormAttachment(100, 0);
    fdGet.top = new FormAttachment(wlKey, margin);
    wGet.setLayoutData(fdGet);

    fdKey = new FormData();
    fdKey.left = new FormAttachment(0, 0);
    fdKey.top = new FormAttachment(wlKey, margin);
    fdKey.right = new FormAttachment(wGet, -margin);
    fdKey.bottom = new FormAttachment(wlKey, 190);
    wKey.setLayoutData(fdKey);

    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(Messages.getString("System.Button.OK")); // $NON-NLS-1$
    wSQL = new Button(shell, SWT.PUSH);
    wSQL.setText(Messages.getString("UpdateDialog.SQL.Button")); // $NON-NLS-1$
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(Messages.getString("System.Button.Cancel")); // $NON-NLS-1$

    setButtonPositions(new Button[] {wOK, wSQL, wCancel}, margin, null);

    // THE UPDATE/INSERT TABLE
    wlReturn = new Label(shell, SWT.NONE);
    wlReturn.setText(Messages.getString("UpdateDialog.Return.Label")); // $NON-NLS-1$
    props.setLook(wlReturn);
    fdlReturn = new FormData();
    fdlReturn.left = new FormAttachment(0, 0);
    fdlReturn.top = new FormAttachment(wKey, margin);
    wlReturn.setLayoutData(fdlReturn);

    int UpInsCols = 2;
    int UpInsRows = (input.getUpdateLookup() != null ? input.getUpdateLookup().length : 1);

    ColumnInfo[] ciReturn = new ColumnInfo[UpInsCols];
    ciReturn[0] =
        new ColumnInfo(
            Messages.getString("UpdateDialog.ColumnInfo.TableField"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false); //$NON-NLS-1$
    ciReturn[1] =
        new ColumnInfo(
            Messages.getString("UpdateDialog.ColumnInfo.StreamField"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false); //$NON-NLS-1$

    wReturn =
        new TableView(
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciReturn,
            UpInsRows,
            lsMod,
            props);

    wGetLU = new Button(shell, SWT.PUSH);
    wGetLU.setText(Messages.getString("UpdateDialog.GetAndUpdateFields")); // $NON-NLS-1$
    fdGetLU = new FormData();
    fdGetLU.top = new FormAttachment(wlReturn, margin);
    fdGetLU.right = new FormAttachment(100, 0);
    wGetLU.setLayoutData(fdGetLU);

    fdReturn = new FormData();
    fdReturn.left = new FormAttachment(0, 0);
    fdReturn.top = new FormAttachment(wlReturn, margin);
    fdReturn.right = new FormAttachment(wGetLU, -margin);
    fdReturn.bottom = new FormAttachment(wOK, -2 * margin);
    wReturn.setLayoutData(fdReturn);

    // Add listeners
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };
    lsGet =
        new Listener() {
          public void handleEvent(Event e) {
            get();
          }
        };
    lsGetLU =
        new Listener() {
          public void handleEvent(Event e) {
            getUpdate();
          }
        };
    lsSQL =
        new Listener() {
          public void handleEvent(Event e) {
            create();
          }
        };
    lsCancel =
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        };

    wOK.addListener(SWT.Selection, lsOK);
    wGet.addListener(SWT.Selection, lsGet);
    wGetLU.addListener(SWT.Selection, lsGetLU);
    wSQL.addListener(SWT.Selection, lsSQL);
    wCancel.addListener(SWT.Selection, lsCancel);

    lsDef =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };

    wStepname.addSelectionListener(lsDef);
    wSchema.addSelectionListener(lsDef);
    wTable.addSelectionListener(lsDef);
    wCommit.addSelectionListener(lsDef);
    wIgnoreFlagField.addSelectionListener(lsDef);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    wbTable.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            getTableName();
          }
        });

    // 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;
  }
  @Override
  public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, input);

    ModifyListener lsMod =
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            input.setChanged();
          }
        };
    SelectionListener lsSel =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            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, "MemoryGroupByDialog.Shell.Title"));

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "MemoryGroupByDialog.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);

    // Always pass a result rows as output
    //
    wlAlwaysAddResult = new Label(shell, SWT.RIGHT);
    wlAlwaysAddResult.setText(
        BaseMessages.getString(PKG, "MemoryGroupByDialog.AlwaysAddResult.Label"));
    wlAlwaysAddResult.setToolTipText(
        BaseMessages.getString(PKG, "MemoryGroupByDialog.AlwaysAddResult.ToolTip"));
    props.setLook(wlAlwaysAddResult);
    fdlAlwaysAddResult = new FormData();
    fdlAlwaysAddResult.left = new FormAttachment(0, 0);
    fdlAlwaysAddResult.top = new FormAttachment(wStepname, margin);
    fdlAlwaysAddResult.right = new FormAttachment(middle, -margin);
    wlAlwaysAddResult.setLayoutData(fdlAlwaysAddResult);
    wAlwaysAddResult = new Button(shell, SWT.CHECK);
    wAlwaysAddResult.setToolTipText(
        BaseMessages.getString(PKG, "MemoryGroupByDialog.AlwaysAddResult.ToolTip"));
    props.setLook(wAlwaysAddResult);
    fdAlwaysAddResult = new FormData();
    fdAlwaysAddResult.left = new FormAttachment(middle, 0);
    fdAlwaysAddResult.top = new FormAttachment(wStepname, margin);
    fdAlwaysAddResult.right = new FormAttachment(100, 0);
    wAlwaysAddResult.setLayoutData(fdAlwaysAddResult);
    wAlwaysAddResult.addSelectionListener(lsSel);

    wlGroup = new Label(shell, SWT.NONE);
    wlGroup.setText(BaseMessages.getString(PKG, "MemoryGroupByDialog.Group.Label"));
    props.setLook(wlGroup);
    fdlGroup = new FormData();
    fdlGroup.left = new FormAttachment(0, 0);
    fdlGroup.top = new FormAttachment(wAlwaysAddResult, margin);
    wlGroup.setLayoutData(fdlGroup);

    int nrKeyCols = 1;
    int nrKeyRows = (input.getGroupField() != null ? input.getGroupField().length : 1);

    ciKey = new ColumnInfo[nrKeyCols];
    ciKey[0] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "MemoryGroupByDialog.ColumnInfo.GroupField"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {""},
            false);

    wGroup =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciKey,
            nrKeyRows,
            lsMod,
            props);

    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "MemoryGroupByDialog.GetFields.Button"));
    fdGet = new FormData();
    fdGet.top = new FormAttachment(wlGroup, margin);
    fdGet.right = new FormAttachment(100, 0);
    wGet.setLayoutData(fdGet);

    fdGroup = new FormData();
    fdGroup.left = new FormAttachment(0, 0);
    fdGroup.top = new FormAttachment(wlGroup, margin);
    fdGroup.right = new FormAttachment(wGet, -margin);
    fdGroup.bottom = new FormAttachment(45, 0);
    wGroup.setLayoutData(fdGroup);

    // THE Aggregate fields
    wlAgg = new Label(shell, SWT.NONE);
    wlAgg.setText(BaseMessages.getString(PKG, "MemoryGroupByDialog.Aggregates.Label"));
    props.setLook(wlAgg);
    fdlAgg = new FormData();
    fdlAgg.left = new FormAttachment(0, 0);
    fdlAgg.top = new FormAttachment(wGroup, margin);
    wlAgg.setLayoutData(fdlAgg);

    int UpInsCols = 4;
    int UpInsRows = (input.getAggregateField() != null ? input.getAggregateField().length : 1);

    ciReturn = new ColumnInfo[UpInsCols];
    ciReturn[0] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "MemoryGroupByDialog.ColumnInfo.Name"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false);
    ciReturn[1] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "MemoryGroupByDialog.ColumnInfo.Subject"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {""},
            false);
    ciReturn[2] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "MemoryGroupByDialog.ColumnInfo.Type"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            MemoryGroupByMeta.typeGroupLongDesc);
    ciReturn[3] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "MemoryGroupByDialog.ColumnInfo.Value"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false);
    ciReturn[3].setToolTip(
        BaseMessages.getString(PKG, "MemoryGroupByDialog.ColumnInfo.Value.Tooltip"));
    ciReturn[3].setUsingVariables(true);

    wAgg =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciReturn,
            UpInsRows,
            lsMod,
            props);

    wGetAgg = new Button(shell, SWT.PUSH);
    wGetAgg.setText(BaseMessages.getString(PKG, "MemoryGroupByDialog.GetLookupFields.Button"));
    fdGetAgg = new FormData();
    fdGetAgg.top = new FormAttachment(wlAgg, margin);
    fdGetAgg.right = new FormAttachment(100, 0);
    wGetAgg.setLayoutData(fdGetAgg);

    //
    // Search the fields in the background

    final Runnable runnable =
        new Runnable() {
          @Override
          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();

    // 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);

    fdAgg = new FormData();
    fdAgg.left = new FormAttachment(0, 0);
    fdAgg.top = new FormAttachment(wlAgg, margin);
    fdAgg.right = new FormAttachment(wGetAgg, -margin);
    fdAgg.bottom = new FormAttachment(wOK, -margin);
    wAgg.setLayoutData(fdAgg);

    // Add listeners
    lsOK =
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            ok();
          }
        };
    lsGet =
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            get();
          }
        };
    lsGetAgg =
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            getAgg();
          }
        };
    lsCancel =
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            cancel();
          }
        };

    wOK.addListener(SWT.Selection, lsOK);
    wGet.addListener(SWT.Selection, lsGet);
    wGetAgg.addListener(SWT.Selection, lsGetAgg);
    wCancel.addListener(SWT.Selection, lsCancel);

    lsDef =
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };

    wStepname.addSelectionListener(lsDef);

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          @Override
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    // 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;
  }
Ejemplo n.º 30
0
  public JobEntryInterface open() {
    Shell parentShell = getParent();
    Display display = parentShell.getDisplay();

    shell = new Shell(parentShell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);

    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

    ModifyListener lsMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            jobEntry.setChanged();
          }
        };

    String datasets[] = null;
    AutoPopulate ap = new AutoPopulate();
    try {

      datasets = ap.parseDatasetsRecordsets(this.jobMeta.getJobCopies());

    } catch (Exception e) {
      System.out.println("Error Parsing existing Datasets");
      System.out.println(e.toString());
      datasets = new String[] {""};
    }

    backupChanged = jobEntry.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText("Limit");

    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    shell.setLayout(formLayout);
    shell.setText("Define an ECL Limit");

    FormLayout groupLayout = new FormLayout();
    groupLayout.marginWidth = 10;
    groupLayout.marginHeight = 10;

    // Stepname line
    Group generalGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(generalGroup);
    generalGroup.setText("General Details");
    generalGroup.setLayout(groupLayout);
    FormData generalGroupFormat = new FormData();
    generalGroupFormat.top = new FormAttachment(0, margin);
    generalGroupFormat.width = 400;
    generalGroupFormat.height = 100;
    generalGroupFormat.left = new FormAttachment(middle, 0);
    generalGroup.setLayoutData(generalGroupFormat);

    jobEntryName = buildText("Job Entry Name", null, lsMod, middle, margin, generalGroup);

    // All other contols
    Group limitGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(limitGroup);
    limitGroup.setText("Limit Details");
    limitGroup.setLayout(groupLayout);
    FormData limitGroupFormat = new FormData();
    limitGroupFormat.top = new FormAttachment(generalGroup, margin);
    limitGroupFormat.width = 400;
    limitGroupFormat.height = 300;
    limitGroupFormat.left = new FormAttachment(middle, 0);
    limitGroup.setLayoutData(limitGroupFormat);

    recordsetName = buildText("Result Recordset", null, lsMod, middle, margin, limitGroup);
    recordset = buildCombo("Recordset", recordsetName, lsMod, middle, margin, limitGroup, datasets);
    maxRecs = buildText("Maximum Records", recordset, lsMod, middle, margin, limitGroup);
    errorMessage = buildText("Error Message", maxRecs, lsMod, middle, margin, limitGroup);
    errorCode = buildText("Error Code", errorMessage, lsMod, middle, margin, limitGroup);
    // failClause = buildText("FAIL(<clause>)", maxRecs, lsMod, middle, margin, limitGroup);
    keyed =
        buildCombo(
            "KEYED", errorCode, lsMod, middle, margin, limitGroup, new String[] {"false", "true"});
    count =
        buildCombo(
            "COUNT", keyed, lsMod, middle, margin, limitGroup, new String[] {"false", "true"});
    skip =
        buildCombo(
            "SKIP", count, lsMod, middle, margin, limitGroup, new String[] {"false", "true"});
    // 	onFailTransform = buildText("ONFAIL(<transform>)", skip, lsMod, middle, margin, limitGroup);

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText("OK");
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText("Cancel");

    BaseStepDialog.positionBottomButtons(shell, new Button[] {wOK, wCancel}, margin, limitGroup);

    // Add listeners
    Listener cancelListener =
        new Listener() {

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

          public void handleEvent(Event e) {
            ok();
          }
        };
    wCancel.addListener(SWT.Selection, cancelListener);
    wOK.addListener(SWT.Selection, okListener);

    lsDef =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    if (jobEntry.getName() != null) {
      jobEntryName.setText(jobEntry.getName());
    }
    if (jobEntry.getRecordsetName() != null) {
      recordsetName.setText(jobEntry.getRecordsetName());
    }
    if (jobEntry.getRecordset() != null) {
      recordset.setText(jobEntry.getRecordset());
    }
    if (jobEntry.getMaxRecs() != null) {
      maxRecs.setText(jobEntry.getMaxRecs());
    }
    // if (jobEntry.getFailClause() != null) {
    //    failClause.setText(jobEntry.getFailClause());
    // }
    if (jobEntry.getErrorCode() != null) {
      errorCode.setText(jobEntry.getErrorCode());
    }
    if (jobEntry.getErrorMessage() != null) {
      errorMessage.setText(jobEntry.getErrorMessage());
    }

    if (jobEntry.getKeyedString() != null) {
      keyed.setText(jobEntry.getKeyedString());
    }
    if (jobEntry.getCountString() != null) {
      count.setText(jobEntry.getCountString());
    }
    if (jobEntry.getSkipString() != null) {
      skip.setText(jobEntry.getSkipString());
    }
    // if (jobEntry.getOnFailTransform() != null) {
    //     onFailTransform.setText(jobEntry.getOnFailTransform());
    //  }

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    return jobEntry;
  }