@Override
  public void createControl(Composite parent) {
    main = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    main.setLayout(layout);

    searchText = new Text(main, SWT.SEARCH | SWT.CANCEL);
    searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    searchText.setMessage("Action type filter");

    message = new Label(main, SWT.NONE);
    message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    tableViewer = new TableViewer(main, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    Table table = tableViewer.getTable();
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setLabelProvider(new GeneratingFunctionLabelProvider());

    searchText.addSelectionListener(
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            if (e.detail == SWT.CANCEL) {
              tableViewer.resetFilters();
            } else {
              tableViewer.setFilters(new ViewerFilter[] {functionFilter});
            }
          }
        });
  }
示例#2
0
文件: Text_Test.java 项目: ciancu/rap
  @Test
  public void testAddSelectionListener() {
    Text text = new Text(shell, SWT.NONE);

    text.addSelectionListener(mock(SelectionListener.class));

    assertTrue(text.isListening(SWT.Selection));
    assertTrue(text.isListening(SWT.DefaultSelection));
  }
示例#3
0
  protected void createFilterText(Composite parent) {
    filterText = doCreateFilterText(parent);

    filterText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(ModifyEvent e) {
            if (filterText.getText().length() > 0) {
              updateToolbar(true);
            } else {
              updateToolbar(false);
            }
          }
        });

    filterText.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent e) {}

          public void focusLost(FocusEvent e) {
            if (filterText.getText().equals(initialText)) {
              setFilterText(""); // $NON-NLS-1$
            }
          }
        });

    filterText.addMouseListener(
        new MouseAdapter() {
          public void mouseDown(MouseEvent e) {
            if (filterText.getText().equals(initialText)) {
              // We cannot call clearText() due to
              // [url]https://bugs.eclipse.org/bugs/show_bug.cgi?id=260664[/url]
              setFilterText(""); // $NON-NLS-1$
            }
          }
        });

    // if we're using a field with built in cancel we need to listen for
    // default selection changes (which tell us the cancel button has been
    // pressed)
    if ((filterText.getStyle() & SWT.ICON_CANCEL) != 0) {
      filterText.addSelectionListener(
          new SelectionAdapter() {
            public void widgetDefaultSelected(SelectionEvent e) {
              if (e.detail == SWT.ICON_CANCEL) clearText();
            }
          });
    }

    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    // if the text widget supported cancel then it will have it's own
    // integrated button. We can take all of the space.
    if ((filterText.getStyle() & SWT.ICON_CANCEL) != 0) gridData.horizontalSpan = 2;
    filterText.setLayoutData(gridData);
  }
 private void addResetListener(final Text field) {
   // Does actually not work on windows... :-(
   field.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetDefaultSelected(final SelectionEvent e) {
           if (e.detail == SWT.ICON_CANCEL) field.setText(StringUtils.EMPTY);
         }
       });
 }
示例#5
0
文件: Text_Test.java 项目: ciancu/rap
  @Test
  public void testRemoveSelectionListener() {
    Text text = new Text(shell, SWT.NONE);
    SelectionListener listener = mock(SelectionListener.class);
    text.addSelectionListener(listener);

    text.removeSelectionListener(listener);

    assertFalse(text.isListening(SWT.Selection));
    assertFalse(text.isListening(SWT.DefaultSelection));
  }
示例#6
0
 NotesList(Composite parent) {
   super(parent, SWT.NONE);
   setLayout(new GridLayout());
   this.parent = parent;
   Composite cFilter = new Composite(this, SWT.NONE);
   cFilter.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
   cFilter.setLayout(new GridLayout(3, false));
   ImageHyperlink clearSearchFieldHyperlink = new ImageHyperlink(cFilter, SWT.NONE);
   clearSearchFieldHyperlink.setImage(Images.IMG_CLEAR.getImage());
   clearSearchFieldHyperlink.addHyperlinkListener(
       new HyperlinkAdapter() {
         @Override
         public void linkActivated(HyperlinkEvent e) {
           tFilter.setText(""); // $NON-NLS-1$
           filterExpr = ""; // $NON-NLS-1$
           matches.clear();
           tv.collapseAll();
           tv.removeFilter(notesFilter);
         }
       });
   new Label(cFilter, SWT.NONE).setText(Messages.NotesList_searchLabel);
   tFilter = new Text(cFilter, SWT.SINGLE);
   tFilter.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
   tFilter.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetDefaultSelected(SelectionEvent e) {
           filterExpr = tFilter.getText().toLowerCase();
           matches.clear();
           if (filterExpr.length() == 0) {
             tv.removeFilter(notesFilter);
             tv.collapseAll();
           } else {
             tv.addFilter(notesFilter);
             tv.expandAll();
           }
         }
       });
   tv = new TreeViewer(this, SWT.NONE);
   tv.getControl().setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
   tv.setContentProvider(new NotesContentProvider());
   tv.setLabelProvider(new DefaultLabelProvider());
   tv.setUseHashlookup(true);
   tv.setInput(parent);
   tv.addSelectionChangedListener(GlobalEventDispatcher.getInstance().getDefaultListener());
 }
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(2, false));

    final Text text = new Text(shell, SWT.SEARCH | SWT.ICON_CANCEL);
    Image image = null;
    if ((text.getStyle() & SWT.ICON_CANCEL) == 0) {
      image = display.getSystemImage(SWT.ICON_ERROR);
      ToolBar toolBar = new ToolBar(shell, SWT.FLAT);
      ToolItem item = new ToolItem(toolBar, SWT.PUSH);
      item.setImage(image);
      item.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              text.setText("");
              System.out.println("Search cancelled");
            }
          });
    }
    text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    text.setText("Search text");
    text.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            if (e.detail == SWT.CANCEL) {
              System.out.println("Search cancelled");
            } else {
              System.out.println("Searching for: " + text.getText() + "...");
            }
          }
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    if (image != null) image.dispose();
    display.dispose();
  }
  /**
   * Tests that the <code>SelectAllHandler</code> triggers a selection event. Creates a dialog with
   * a text widget, gives the text widget focus, and then calls the select all command. This should
   * then call the <code>SelectAllHandler</code> and trigger a selection event.
   *
   * @throws ExecutionException If the <code>SelectAllHandler</code> is broken in some way.
   * @throws NotHandledException If the dialog does not have focus, or if the <code>
   *     WorkbenchCommandSupport</code> class is broken in some way.
   */
  public final void testSelectAllHandlerSendsSelectionEvent()
      throws ExecutionException, NotHandledException {
    // Create a dialog with a text widget.
    final Shell dialog = new Shell(fWorkbench.getActiveWorkbenchWindow().getShell());
    dialog.setLayout(new GridLayout());
    final Text text = new Text(dialog, SWT.SINGLE);
    text.setText("Mooooooooooooooooooooooooooooo");
    text.setLayoutData(new GridData());
    text.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            selectionEventFired = true;
          }
        });

    // Open the dialog and give the text widget focus.
    dialog.pack();
    dialog.open();
    text.setFocus();

    // Spin the event loop to make sure focus is set-up properly.
    final Display display = fWorkbench.getDisplay();
    while (display.readAndDispatch()) {
      ((Workbench) fWorkbench).getContext().processWaiting();
    }

    // Get the select all command and execute it.
    final IWorkbenchCommandSupport commandSupport = fWorkbench.getCommandSupport();
    final ICommand selectAllCommand =
        commandSupport.getCommandManager().getCommand("org.eclipse.ui.edit.selectAll");
    selectAllCommand.execute(null);

    // Check to see if the selection event has been fired.
    assertTrue(
        "The selection event was not fired when the SelectAllHandler was used.",
        selectionEventFired);
  }
  public JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

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

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

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

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

    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobCheckDbConnections.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);

    wlFields = new Label(shell, SWT.NONE);
    wlFields.setText(BaseMessages.getString(PKG, "JobCheckDbConnections.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    // fdlFields.right= new FormAttachment(middle, -margin);
    fdlFields.top = new FormAttachment(wName, 2 * margin);
    wlFields.setLayoutData(fdlFields);

    // Buttons to the right of the screen...
    wbdSourceFileFolder = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbdSourceFileFolder);
    wbdSourceFileFolder.setText(BaseMessages.getString(PKG, "JobCheckDbConnections.DeleteEntry"));
    wbdSourceFileFolder.setToolTipText(
        BaseMessages.getString(PKG, "JobCheckDbConnections.DeleteSourceFileButton.Label"));
    fdbdSourceFileFolder = new FormData();
    fdbdSourceFileFolder.right = new FormAttachment(100, -margin);
    fdbdSourceFileFolder.top = new FormAttachment(wlFields, 50);
    wbdSourceFileFolder.setLayoutData(fdbdSourceFileFolder);

    // Buttons to the right of the screen...
    wbgetConnections = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbgetConnections);
    wbgetConnections.setText(BaseMessages.getString(PKG, "JobCheckDbConnections.GetConnections"));
    wbgetConnections.setToolTipText(
        BaseMessages.getString(PKG, "JobCheckDbConnections.GetConnections.Tooltip"));
    fdbgetConnections = new FormData();
    fdbgetConnections.right = new FormAttachment(100, -margin);
    fdbgetConnections.top = new FormAttachment(wlFields, 20);
    wbgetConnections.setLayoutData(fdbgetConnections);

    addDatabases();

    int rows =
        jobEntry.connections == null
            ? 1
            : (jobEntry.connections.length == 0 ? 0 : jobEntry.connections.length);

    final int FieldsRows = rows;

    ColumnInfo[] colinf =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "JobCheckDbConnections.Fields.Argument.Label"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              connections,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "JobCheckDbConnections.Fields.WaitFor.Label"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "JobCheckDbConnections.Fields.WaitForTime.Label"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              JobEntryCheckDbConnections.unitTimeDesc,
              false),
        };

    colinf[0].setToolTip(BaseMessages.getString(PKG, "JobCheckDbConnections.Fields.Column"));
    colinf[1].setUsingVariables(true);
    colinf[1].setToolTip(BaseMessages.getString(PKG, "JobCheckDbConnections.WaitFor.ToolTip"));

    wFields =
        new TableView(
            jobMeta,
            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(wbgetConnections, -margin);
    fdFields.bottom = new FormAttachment(100, -50);
    wFields.setLayoutData(fdFields);

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fd = new FormData();
    fd.right = new FormAttachment(50, -10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wOK.setLayoutData(fd);

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fd = new FormData();
    fd.left = new FormAttachment(50, 10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wCancel.setLayoutData(fd);

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

    // Add listeners
    lsCancel =
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        };
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };
    // Delete files from the list of files...
    wbdSourceFileFolder.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            int idx[] = wFields.getSelectionIndices();
            wFields.remove(idx);
            wFields.removeEmptyRows();
            wFields.setRowNums();
          }
        });

    // get connections...
    wbgetConnections.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            getDatabases();
          }
        });

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

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

    wName.addSelectionListener(lsDef);

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

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();
    props.setDialogSize(shell, "JobCheckDbConnectionsDialogSize");
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return jobEntry;
  }
 public void addSelectionListener(SelectionAdapter lsDef) {
   wText.addSelectionListener(lsDef);
 }
示例#11
0
  /**
   * Create contents of the wizard.
   *
   * @param parent the parent widget
   */
  @Override
  @SuppressWarnings("unused") // Don't warn about unassigned "new Label(.)": has side-effect
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    setControl(container);
    GridLayout glContainer = new GridLayout(2, false);
    glContainer.marginWidth = 0;
    glContainer.horizontalSpacing = 0;
    glContainer.marginHeight = 0;
    glContainer.verticalSpacing = 0;
    container.setLayout(glContainer);

    ScrolledComposite configurationScrollArea = new ScrolledComposite(container, SWT.V_SCROLL);
    configurationScrollArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    configurationScrollArea.setExpandHorizontal(true);
    configurationScrollArea.setExpandVertical(true);

    mConfigurationArea = new Composite(configurationScrollArea, SWT.NONE);
    GridLayout glConfigurationArea = new GridLayout(3, false);
    glConfigurationArea.horizontalSpacing = 0;
    glConfigurationArea.marginRight = 15;
    glConfigurationArea.marginWidth = 0;
    glConfigurationArea.marginHeight = 0;
    mConfigurationArea.setLayout(glConfigurationArea);

    Label foregroundLabel = new Label(mConfigurationArea, SWT.NONE);
    foregroundLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    foregroundLabel.setText("Foreground:");

    Composite foregroundComposite = new Composite(mConfigurationArea, SWT.NONE);
    foregroundComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    GridLayout glForegroundComposite = new GridLayout(5, false);
    glForegroundComposite.horizontalSpacing = 0;
    foregroundComposite.setLayout(glForegroundComposite);

    mImageRadio = new Button(foregroundComposite, SWT.FLAT | SWT.TOGGLE);
    mImageRadio.setSelection(false);
    mImageRadio.addSelectionListener(this);
    mImageRadio.setText("Image");

    mClipartRadio = new Button(foregroundComposite, SWT.FLAT | SWT.TOGGLE);
    mClipartRadio.setText("Clipart");
    mClipartRadio.addSelectionListener(this);

    mTextRadio = new Button(foregroundComposite, SWT.FLAT | SWT.TOGGLE);
    mTextRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    mTextRadio.setText("Text");
    mTextRadio.addSelectionListener(this);
    new Label(mConfigurationArea, SWT.NONE);

    mForegroundArea = new Composite(mConfigurationArea, SWT.NONE);
    mForegroundArea.setLayout(new StackLayout());
    mForegroundArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));

    mImageForm = new Composite(mForegroundArea, SWT.NONE);
    mImageForm.setLayout(new GridLayout(3, false));

    Label fileLabel = new Label(mImageForm, SWT.NONE);
    fileLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    fileLabel.setText("Image File:");

    mImagePathText = new Text(mImageForm, SWT.BORDER);
    GridData pathLayoutData = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    pathLayoutData.widthHint = 200;
    mImagePathText.setLayoutData(pathLayoutData);
    mImagePathText.addSelectionListener(this);
    mImagePathText.addModifyListener(this);

    mPickImageButton = new Button(mImageForm, SWT.FLAT);
    mPickImageButton.setText("Browse...");
    mPickImageButton.addSelectionListener(this);

    mClipartForm = new Composite(mForegroundArea, SWT.NONE);
    mClipartForm.setLayout(new GridLayout(2, false));

    mChooseClipart = new Button(mClipartForm, SWT.FLAT);
    mChooseClipart.setText("Choose...");
    mChooseClipart.addSelectionListener(this);

    mClipartPreviewPanel = new Composite(mClipartForm, SWT.NONE);
    RowLayout rlClipartPreviewPanel = new RowLayout(SWT.HORIZONTAL);
    rlClipartPreviewPanel.marginBottom = 0;
    rlClipartPreviewPanel.marginTop = 0;
    rlClipartPreviewPanel.center = true;
    mClipartPreviewPanel.setLayout(rlClipartPreviewPanel);
    mClipartPreviewPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    mTextForm = new Composite(mForegroundArea, SWT.NONE);
    mTextForm.setLayout(new GridLayout(2, false));

    Label textLabel = new Label(mTextForm, SWT.NONE);
    textLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    textLabel.setText("Text:");

    mText = new Text(mTextForm, SWT.BORDER);
    mText.setText("Aa");
    mText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    mText.addModifyListener(this);

    Label fontLabel = new Label(mTextForm, SWT.NONE);
    fontLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    fontLabel.setText("Font:");

    mFontButton = new Button(mTextForm, SWT.FLAT);
    mFontButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    mFontButton.addSelectionListener(this);
    mFontButton.setText("Choose Font...");
    new Label(mConfigurationArea, SWT.NONE);

    mTrimCheckBox = new Button(mConfigurationArea, SWT.CHECK);
    mTrimCheckBox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    mTrimCheckBox.setSelection(false);
    mTrimCheckBox.setText("Trim Surrounding Blank Space");
    mTrimCheckBox.addSelectionListener(this);
    new Label(mConfigurationArea, SWT.NONE);

    Label paddingLabel = new Label(mConfigurationArea, SWT.NONE);
    paddingLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    paddingLabel.setText("Additional Padding:");
    new Label(mConfigurationArea, SWT.NONE);

    mPaddingSlider = new Slider(mConfigurationArea, SWT.NONE);
    mPaddingSlider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    // This doesn't work right -- not sure why. For now just use a plain slider
    // and subtract 10 from it to get the real range.
    // mPaddingSlider.setValues(0, -10, 50, 0, 1, 10);
    mPaddingSlider.setSelection(10 + 15);
    mPaddingSlider.addSelectionListener(this);

    mPercentLabel = new Label(mConfigurationArea, SWT.NONE);
    mPercentLabel.setText("  15%"); // Enough available space for -10%

    mScalingLabel = new Label(mConfigurationArea, SWT.NONE);
    mScalingLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mScalingLabel.setText("Foreground Scaling:");

    mScalingComposite = new Composite(mConfigurationArea, SWT.NONE);
    mScalingComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    GridLayout gl_mScalingComposite = new GridLayout(5, false);
    gl_mScalingComposite.horizontalSpacing = 0;
    mScalingComposite.setLayout(gl_mScalingComposite);

    mCropRadio = new Button(mScalingComposite, SWT.FLAT | SWT.TOGGLE);
    mCropRadio.setSelection(true);
    mCropRadio.setText("Crop");
    mCropRadio.addSelectionListener(this);

    mCenterRadio = new Button(mScalingComposite, SWT.FLAT | SWT.TOGGLE);
    mCenterRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
    mCenterRadio.setText("Center");
    mCenterRadio.addSelectionListener(this);

    mShapeLabel = new Label(mConfigurationArea, SWT.NONE);
    mShapeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mShapeLabel.setText("Shape");

    mShapeComposite = new Composite(mConfigurationArea, SWT.NONE);
    mShapeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
    GridLayout gl_mShapeComposite = new GridLayout(5, false);
    gl_mShapeComposite.horizontalSpacing = 0;
    mShapeComposite.setLayout(gl_mShapeComposite);

    mSquareRadio = new Button(mShapeComposite, SWT.FLAT | SWT.TOGGLE);
    mSquareRadio.setSelection(true);
    mSquareRadio.setText("Square");
    mSquareRadio.addSelectionListener(this);

    mCircleButton = new Button(mShapeComposite, SWT.FLAT | SWT.TOGGLE);
    mCircleButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
    mCircleButton.setText("Circle");
    mCircleButton.addSelectionListener(this);

    mThemeLabel = new Label(mConfigurationArea, SWT.NONE);
    mThemeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mThemeLabel.setText("Theme");

    mThemeComposite = new Composite(mConfigurationArea, SWT.NONE);
    mThemeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    GridLayout gl_mThemeComposite = new GridLayout(2, false);
    gl_mThemeComposite.horizontalSpacing = 0;
    mThemeComposite.setLayout(gl_mThemeComposite);

    mHoloLightRadio = new Button(mThemeComposite, SWT.FLAT | SWT.TOGGLE);
    mHoloLightRadio.setText("Holo Light");
    mHoloLightRadio.setSelection(true);
    mHoloLightRadio.addSelectionListener(this);

    mHoloDarkRadio = new Button(mThemeComposite, SWT.FLAT | SWT.TOGGLE);
    mHoloDarkRadio.setText("Holo Dark");
    mHoloDarkRadio.addSelectionListener(this);

    mBgColorLabel = new Label(mConfigurationArea, SWT.NONE);
    mBgColorLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mBgColorLabel.setText("Background Color:");

    mBgButton = new Button(mConfigurationArea, SWT.FLAT);
    mBgButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    mBgButton.addSelectionListener(this);
    mBgButton.setAlignment(SWT.CENTER);

    mFgColorLabel = new Label(mConfigurationArea, SWT.NONE);
    mFgColorLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    mFgColorLabel.setText("Foreground Color:");

    mFgButton = new Button(mConfigurationArea, SWT.FLAT);
    mFgButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    mFgButton.setAlignment(SWT.CENTER);
    mFgButton.addSelectionListener(this);

    if (SUPPORT_LAUNCHER_ICON_TYPES) {
      mEffectsLabel = new Label(mConfigurationArea, SWT.NONE);
      mEffectsLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
      mEffectsLabel.setText("Foreground Effects:");

      mEffectsComposite = new Composite(mConfigurationArea, SWT.NONE);
      mEffectsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
      GridLayout gl_mEffectsComposite = new GridLayout(5, false);
      gl_mEffectsComposite.horizontalSpacing = 0;
      mEffectsComposite.setLayout(gl_mEffectsComposite);

      mSimpleRadio = new Button(mEffectsComposite, SWT.FLAT | SWT.TOGGLE);
      mSimpleRadio.setSelection(true);
      mSimpleRadio.setText("Simple");
      mSimpleRadio.addSelectionListener(this);

      mFancyRadio = new Button(mEffectsComposite, SWT.FLAT | SWT.TOGGLE);
      mFancyRadio.setText("Fancy");
      mFancyRadio.addSelectionListener(this);

      mGlossyRadio = new Button(mEffectsComposite, SWT.FLAT | SWT.TOGGLE);
      mGlossyRadio.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
      mGlossyRadio.setText("Glossy");
      mGlossyRadio.addSelectionListener(this);
    }

    configurationScrollArea.setContent(mConfigurationArea);
    configurationScrollArea.setMinSize(mConfigurationArea.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    Label previewLabel = new Label(container, SWT.NONE);
    previewLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    previewLabel.setText("Preview:");

    mPreviewArea = new Composite(container, SWT.BORDER);

    RowLayout rlPreviewAreaPreviewArea = new RowLayout(SWT.HORIZONTAL);
    rlPreviewAreaPreviewArea.wrap = true;
    rlPreviewAreaPreviewArea.pack = true;
    rlPreviewAreaPreviewArea.center = true;
    rlPreviewAreaPreviewArea.spacing = 0;
    rlPreviewAreaPreviewArea.marginBottom = 0;
    rlPreviewAreaPreviewArea.marginTop = 0;
    rlPreviewAreaPreviewArea.marginRight = 0;
    rlPreviewAreaPreviewArea.marginLeft = 0;
    mPreviewArea.setLayout(rlPreviewAreaPreviewArea);
    GridData gdMPreviewArea = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
    gdMPreviewArea.widthHint = PREVIEW_AREA_WIDTH;
    mPreviewArea.setLayoutData(gdMPreviewArea);

    // Initial color
    Display display = parent.getDisplay();
    // updateColor(display, new RGB(0xa4, 0xc6, 0x39), true /*background*/);
    updateColor(display, new RGB(0xff, 0x00, 0x00), true /*background*/);
    updateColor(display, new RGB(0x00, 0x00, 0x00), false /*background*/);

    // Start out showing the image form
    // mImageRadio.setSelection(true);
    // chooseForegroundTab(mImageRadio, mImageForm);
    // No, start out showing the text, since the user doesn't have to enter anything
    // initially and we still get images
    mTextRadio.setSelection(true);
    chooseForegroundTab(mTextRadio, mTextForm);
    new Label(mConfigurationArea, SWT.NONE);
    new Label(mConfigurationArea, SWT.NONE);
    new Label(mConfigurationArea, SWT.NONE);

    validatePage();
  }
  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();
          }
        };
    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;
  }
示例#14
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;
  }
  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, "RandomCCNumberGeneratorDialog.DialogTitle"));

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

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

    // ///////////////////////////////
    // START OF OutputFields GROUP  //
    /////////////////////////////////

    wOutputFields = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wOutputFields);
    wOutputFields.setText(
        BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.wOutputFields.Label"));

    FormLayout OutputFieldsgroupLayout = new FormLayout();
    OutputFieldsgroupLayout.marginWidth = 10;
    OutputFieldsgroupLayout.marginHeight = 10;
    wOutputFields.setLayout(OutputFieldsgroupLayout);

    // CCNumberField fieldname ...
    wlCCNumberField = new Label(wOutputFields, SWT.RIGHT);
    wlCCNumberField.setText(
        BaseMessages.getString(
            PKG, "RandomCCNumberGeneratorDialog.CCNumberFieldName.Label")); // $NON-NLS-1$
    props.setLook(wlCCNumberField);
    fdlCCNumberField = new FormData();
    fdlCCNumberField.left = new FormAttachment(0, 0);
    fdlCCNumberField.right = new FormAttachment(middle, -margin);
    fdlCCNumberField.top = new FormAttachment(wStepname, margin * 2);
    wlCCNumberField.setLayoutData(fdlCCNumberField);
    wCCNumberField = new Text(wOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wCCNumberField.setToolTipText(
        BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCNumberFieldName.Tooltip"));
    props.setLook(wCCNumberField);
    wCCNumberField.addModifyListener(lsMod);
    fdCCNumberField = new FormData();
    fdCCNumberField.left = new FormAttachment(middle, 0);
    fdCCNumberField.top = new FormAttachment(wStepname, margin * 2);
    fdCCNumberField.right = new FormAttachment(100, 0);
    wCCNumberField.setLayoutData(fdCCNumberField);

    // CCTypeField fieldname ...
    wlCCTypeField = new Label(wOutputFields, SWT.RIGHT);
    wlCCTypeField.setText(
        BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCType.Label")); // $NON-NLS-1$
    props.setLook(wlCCTypeField);
    fdlCCTypeField = new FormData();
    fdlCCTypeField.left = new FormAttachment(0, 0);
    fdlCCTypeField.right = new FormAttachment(middle, -margin);
    fdlCCTypeField.top = new FormAttachment(wCCNumberField, margin);
    wlCCTypeField.setLayoutData(fdlCCTypeField);
    wCCTypeField = new Text(wOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wCCTypeField.setToolTipText(
        BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCType.Tooltip"));
    props.setLook(wCCTypeField);
    wCCTypeField.addModifyListener(lsMod);
    fdCCTypeField = new FormData();
    fdCCTypeField.left = new FormAttachment(middle, 0);
    fdCCTypeField.top = new FormAttachment(wCCNumberField, margin);
    fdCCTypeField.right = new FormAttachment(100, 0);
    wCCTypeField.setLayoutData(fdCCTypeField);

    // CCLengthField fieldname ...
    wlCCLengthField = new Label(wOutputFields, SWT.RIGHT);
    wlCCLengthField.setText(
        BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCLength.Label")); // $NON-NLS-1$
    props.setLook(wlCCLengthField);
    fdlCCLengthField = new FormData();
    fdlCCLengthField.left = new FormAttachment(0, 0);
    fdlCCLengthField.right = new FormAttachment(middle, -margin);
    fdlCCLengthField.top = new FormAttachment(wCCTypeField, margin);
    wlCCLengthField.setLayoutData(fdlCCLengthField);
    wCCLengthField = new Text(wOutputFields, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wCCLengthField.setToolTipText(
        BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCLength.Tooltip"));
    props.setLook(wCCLengthField);
    wCCLengthField.addModifyListener(lsMod);
    fdCCLengthField = new FormData();
    fdCCLengthField.left = new FormAttachment(middle, 0);
    fdCCLengthField.top = new FormAttachment(wCCTypeField, margin);
    fdCCLengthField.right = new FormAttachment(100, 0);
    wCCLengthField.setLayoutData(fdCCLengthField);

    FormData fdOutputFields = new FormData();
    fdOutputFields.left = new FormAttachment(0, margin);
    fdOutputFields.top = new FormAttachment(wStepname, 2 * margin);
    fdOutputFields.right = new FormAttachment(100, -margin);
    wOutputFields.setLayoutData(fdOutputFields);

    // ///////////////////////////////////////////////////////////
    // / END OF OutputFields GROUP
    // ///////////////////////////////////////////////////////////

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

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

    ColumnInfo[] colinf = new ColumnInfo[FieldsCols];
    colinf[0] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCTypeColumn.Column"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            RandomCreditCardNumberGenerator.cardTypes);
    colinf[0].setReadOnly(true);
    colinf[1] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCLengthColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false);
    colinf[1].setUsingVariables(true);
    colinf[2] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.CCSizeColumn.Column"),
            ColumnInfo.COLUMN_TYPE_TEXT,
            false);
    colinf[2].setUsingVariables(true);

    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(100, -50);
    wFields.setLayoutData(fdFields);

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

    wPreview = new Button(shell, SWT.PUSH);
    wPreview.setText(
        BaseMessages.getString(PKG, "RandomCCNumberGeneratorDialog.Button.PreviewRows"));

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

    // 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);
    lsPreview =
        new Listener() {
          public void handleEvent(Event e) {
            preview();
          }
        };
    lsDef =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };
    wPreview.addListener(SWT.Selection, lsPreview);
    wStepname.addSelectionListener(lsDef);

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

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

    getData();
    input.setChanged(changed);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return stepname;
  }
示例#16
0
  /**
   * server/password dialog
   *
   * @param loginData server login data
   * @return true iff login data ok, false otherwise
   */
  private boolean getLoginData(final LoginData loginData) {
    TableLayout tableLayout;
    TableLayoutData tableLayoutData;
    Composite composite;
    Label label;
    Button button;

    final Shell dialog = Dialogs.open(new Shell(), "Login BAR server", 250, SWT.DEFAULT);

    // password
    final Text widgetServerName;
    final Text widgetPassword;
    final Button widgetLoginButton;
    composite = new Composite(dialog, SWT.NONE);
    tableLayout = new TableLayout(null, new double[] {0.0, 1.0}, 2);
    composite.setLayout(tableLayout);
    composite.setLayoutData(new TableLayoutData(0, 0, TableLayoutData.WE));
    {
      label = new Label(composite, SWT.LEFT);
      label.setText("Server:");
      label.setLayoutData(new TableLayoutData(0, 0, TableLayoutData.W));

      widgetServerName = new Text(composite, SWT.LEFT | SWT.BORDER);
      if (loginData.serverName != null) widgetServerName.setText(loginData.serverName);
      widgetServerName.setLayoutData(new TableLayoutData(0, 1, TableLayoutData.WE));

      label = new Label(composite, SWT.LEFT);
      label.setText("Password:"******"Login");
      widgetLoginButton.setLayoutData(
          new TableLayoutData(0, 0, TableLayoutData.W, 0, 0, 0, 0, 60, SWT.DEFAULT));
      widgetLoginButton.addSelectionListener(
          new SelectionListener() {
            public void widgetSelected(SelectionEvent selectionEvent) {
              Button widget = (Button) selectionEvent.widget;
              loginData.serverName = widgetServerName.getText();
              loginData.password = widgetPassword.getText();
              Dialogs.close(dialog, true);
            }

            public void widgetDefaultSelected(SelectionEvent selectionEvent) {}
          });

      button = new Button(composite, SWT.CENTER);
      button.setText("Cancel");
      button.setLayoutData(
          new TableLayoutData(0, 1, TableLayoutData.E, 0, 0, 0, 0, 60, SWT.DEFAULT));
      button.addSelectionListener(
          new SelectionListener() {
            public void widgetSelected(SelectionEvent selectionEvent) {
              Button widget = (Button) selectionEvent.widget;
              Dialogs.close(dialog, false);
            }

            public void widgetDefaultSelected(SelectionEvent selectionEvent) {}
          });
    }

    // install handlers
    widgetServerName.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent selectionEvent) {}

          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            Text widget = (Text) selectionEvent.widget;
            widgetPassword.forceFocus();
          }
        });
    widgetPassword.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent selectionEvent) {}

          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            Text widget = (Text) selectionEvent.widget;
            widgetLoginButton.forceFocus();
          }
        });

    if ((loginData.serverName != null) && (loginData.serverName.length() != 0))
      widgetPassword.forceFocus();

    Boolean result = (Boolean) Dialogs.run(dialog);

    return (result != null) ? result : false;
  }
  public JobEntryInterface open() {
    Shell parent = getParent();
    display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

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

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

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

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

    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, margin);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);

    // eMail address
    wMailAddress =
        new LabelTextVar(
            jobMeta,
            shell,
            BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.MailAddress.Label"),
            BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.MailAddress.Tooltip"));
    wMailAddress.addModifyListener(lsMod);
    fdMailAddress = new FormData();
    fdMailAddress.left = new FormAttachment(0, 0);
    fdMailAddress.top = new FormAttachment(wName, margin);
    fdMailAddress.right = new FormAttachment(100, 0);
    wMailAddress.setLayoutData(fdMailAddress);

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

    wSettingsGroup = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wSettingsGroup);
    wSettingsGroup.setText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.Group.SettingsAddress.Label"));

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

    // perform SMTP check?
    wlSMTPCheck = new Label(wSettingsGroup, SWT.RIGHT);
    wlSMTPCheck.setText(BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.SMTPCheck.Label"));
    props.setLook(wlSMTPCheck);
    fdlSMTPCheck = new FormData();
    fdlSMTPCheck.left = new FormAttachment(0, 0);
    fdlSMTPCheck.top = new FormAttachment(wMailAddress, margin);
    fdlSMTPCheck.right = new FormAttachment(middle, -2 * margin);
    wlSMTPCheck.setLayoutData(fdlSMTPCheck);
    wSMTPCheck = new Button(wSettingsGroup, SWT.CHECK);
    props.setLook(wSMTPCheck);
    wSMTPCheck.setToolTipText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.SMTPCheck.Tooltip"));
    fdSMTPCheck = new FormData();
    fdSMTPCheck.left = new FormAttachment(middle, -margin);
    fdSMTPCheck.top = new FormAttachment(wMailAddress, margin);
    wSMTPCheck.setLayoutData(fdSMTPCheck);
    wSMTPCheck.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            activeSMTPCheck();
          }
        });

    // TimeOut fieldname ...
    wlTimeOut = new Label(wSettingsGroup, SWT.RIGHT);
    wlTimeOut.setText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.TimeOutField.Label"));
    props.setLook(wlTimeOut);
    fdlTimeOut = new FormData();
    fdlTimeOut.left = new FormAttachment(0, 0);
    fdlTimeOut.right = new FormAttachment(middle, -2 * margin);
    fdlTimeOut.top = new FormAttachment(wSMTPCheck, margin);
    wlTimeOut.setLayoutData(fdlTimeOut);

    wTimeOut = new TextVar(jobMeta, wSettingsGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wTimeOut.setToolTipText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.TimeOutField.Tooltip"));
    props.setLook(wTimeOut);
    wTimeOut.addModifyListener(lsMod);
    fdTimeOut = new FormData();
    fdTimeOut.left = new FormAttachment(middle, -margin);
    fdTimeOut.top = new FormAttachment(wSMTPCheck, margin);
    fdTimeOut.right = new FormAttachment(100, 0);
    wTimeOut.setLayoutData(fdTimeOut);

    // eMailSender fieldname ...
    wleMailSender = new Label(wSettingsGroup, SWT.RIGHT);
    wleMailSender.setText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.eMailSenderField.Label"));
    props.setLook(wleMailSender);
    fdleMailSender = new FormData();
    fdleMailSender.left = new FormAttachment(0, 0);
    fdleMailSender.right = new FormAttachment(middle, -2 * margin);
    fdleMailSender.top = new FormAttachment(wTimeOut, margin);
    wleMailSender.setLayoutData(fdleMailSender);

    weMailSender = new TextVar(jobMeta, wSettingsGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    weMailSender.setToolTipText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.eMailSenderField.Tooltip"));
    props.setLook(weMailSender);
    weMailSender.addModifyListener(lsMod);
    fdeMailSender = new FormData();
    fdeMailSender.left = new FormAttachment(middle, -margin);
    fdeMailSender.top = new FormAttachment(wTimeOut, margin);
    fdeMailSender.right = new FormAttachment(100, 0);
    weMailSender.setLayoutData(fdeMailSender);

    // DefaultSMTP fieldname ...
    wlDefaultSMTP = new Label(wSettingsGroup, SWT.RIGHT);
    wlDefaultSMTP.setText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.DefaultSMTPField.Label"));
    props.setLook(wlDefaultSMTP);
    fdlDefaultSMTP = new FormData();
    fdlDefaultSMTP.left = new FormAttachment(0, 0);
    fdlDefaultSMTP.right = new FormAttachment(middle, -2 * margin);
    fdlDefaultSMTP.top = new FormAttachment(weMailSender, margin);
    wlDefaultSMTP.setLayoutData(fdlDefaultSMTP);

    wDefaultSMTP = new TextVar(jobMeta, wSettingsGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wDefaultSMTP.setToolTipText(
        BaseMessages.getString(PKG, "JobEntryMailValidatorDialog.DefaultSMTPField.Tooltip"));
    props.setLook(wDefaultSMTP);
    wDefaultSMTP.addModifyListener(lsMod);
    fdDefaultSMTP = new FormData();
    fdDefaultSMTP.left = new FormAttachment(middle, -margin);
    fdDefaultSMTP.top = new FormAttachment(weMailSender, margin);
    fdDefaultSMTP.right = new FormAttachment(100, 0);
    wDefaultSMTP.setLayoutData(fdDefaultSMTP);

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

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

    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"));
    // at the bottom
    BaseStepDialog.positionBottomButtons(
        shell, new Button[] {wOK, wCancel}, margin, wSettingsGroup);

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

    wName.addSelectionListener(lsDef);

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

    getData();
    activeSMTPCheck();
    BaseStepDialog.setSize(shell);

    shell.open();
    props.setDialogSize(shell, "JobSuccessDialogSize");
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return jobEntry;
  }
示例#18
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, "NullIfDialog.Shell.Label"));

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

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

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

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

    colinf = new ColumnInfo[FieldsCols];
    colinf[0] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "NullIfDialog.ColumnInfo.Name"),
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            new String[] {""},
            false);
    colinf[1] =
        new ColumnInfo(
            BaseMessages.getString(PKG, "NullIfDialog.ColumnInfo.ValueToNull"),
            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(100, -50);
    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();

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

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

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

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

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

    wStepname.addSelectionListener(lsDef);

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

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

    getData();
    input.setChanged(changed);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return stepname;
  }
  public JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

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

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

    shell.setLayout(formLayout);
    shell.setText(Messages.getString("JobXMLWellFormed.Title"));

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

    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(Messages.getString("JobXMLWellFormed.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);

    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);

    //////////////////////////
    // START OF GENERAL TAB   ///
    //////////////////////////

    wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
    wGeneralTab.setText(Messages.getString("JobXMLWellFormed.Tab.General.Label"));

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

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

    // SETTINGS grouping?
    // ////////////////////////
    // START OF SETTINGS GROUP
    //

    wSettings = new Group(wGeneralComp, SWT.SHADOW_NONE);
    props.setLook(wSettings);
    wSettings.setText(Messages.getString("JobXMLWellFormed.Settings.Label"));

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

    wlIncludeSubfolders = new Label(wSettings, SWT.RIGHT);
    wlIncludeSubfolders.setText(Messages.getString("JobXMLWellFormed.IncludeSubfolders.Label"));
    props.setLook(wlIncludeSubfolders);
    fdlIncludeSubfolders = new FormData();
    fdlIncludeSubfolders.left = new FormAttachment(0, 0);
    fdlIncludeSubfolders.top = new FormAttachment(wName, margin);
    fdlIncludeSubfolders.right = new FormAttachment(middle, -margin);
    wlIncludeSubfolders.setLayoutData(fdlIncludeSubfolders);
    wIncludeSubfolders = new Button(wSettings, SWT.CHECK);
    props.setLook(wIncludeSubfolders);
    wIncludeSubfolders.setToolTipText(
        Messages.getString("JobXMLWellFormed.IncludeSubfolders.Tooltip"));
    fdIncludeSubfolders = new FormData();
    fdIncludeSubfolders.left = new FormAttachment(middle, 0);
    fdIncludeSubfolders.top = new FormAttachment(wName, margin);
    fdIncludeSubfolders.right = new FormAttachment(100, 0);
    wIncludeSubfolders.setLayoutData(fdIncludeSubfolders);
    wIncludeSubfolders.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
          }
        });

    // previous
    wlPrevious = new Label(wSettings, SWT.RIGHT);
    wlPrevious.setText(Messages.getString("JobXMLWellFormed.Previous.Label"));
    props.setLook(wlPrevious);
    fdlPrevious = new FormData();
    fdlPrevious.left = new FormAttachment(0, 0);
    fdlPrevious.top = new FormAttachment(wIncludeSubfolders, margin);
    fdlPrevious.right = new FormAttachment(middle, -margin);
    wlPrevious.setLayoutData(fdlPrevious);
    wPrevious = new Button(wSettings, SWT.CHECK);
    props.setLook(wPrevious);
    wPrevious.setSelection(jobEntry.arg_from_previous);
    wPrevious.setToolTipText(Messages.getString("JobXMLWellFormed.Previous.Tooltip"));
    fdPrevious = new FormData();
    fdPrevious.left = new FormAttachment(middle, 0);
    fdPrevious.top = new FormAttachment(wIncludeSubfolders, margin);
    fdPrevious.right = new FormAttachment(100, 0);
    wPrevious.setLayoutData(fdPrevious);
    wPrevious.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {

            RefreshArgFromPrevious();
          }
        });
    fdSettings = new FormData();
    fdSettings.left = new FormAttachment(0, margin);
    fdSettings.top = new FormAttachment(wName, margin);
    fdSettings.right = new FormAttachment(100, -margin);
    wSettings.setLayoutData(fdSettings);

    // ///////////////////////////////////////////////////////////
    // / END OF SETTINGS GROUP
    // ///////////////////////////////////////////////////////////

    // SourceFileFolder line
    wlSourceFileFolder = new Label(wGeneralComp, SWT.RIGHT);
    wlSourceFileFolder.setText(Messages.getString("JobXMLWellFormed.SourceFileFolder.Label"));
    props.setLook(wlSourceFileFolder);
    fdlSourceFileFolder = new FormData();
    fdlSourceFileFolder.left = new FormAttachment(0, 0);
    fdlSourceFileFolder.top = new FormAttachment(wSettings, 2 * margin);
    fdlSourceFileFolder.right = new FormAttachment(middle, -margin);
    wlSourceFileFolder.setLayoutData(fdlSourceFileFolder);

    // Browse Source folders button ...
    wbSourceDirectory = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSourceDirectory);
    wbSourceDirectory.setText(Messages.getString("JobXMLWellFormed.BrowseFolders.Label"));
    fdbSourceDirectory = new FormData();
    fdbSourceDirectory.right = new FormAttachment(100, 0);
    fdbSourceDirectory.top = new FormAttachment(wSettings, margin);
    wbSourceDirectory.setLayoutData(fdbSourceDirectory);

    wbSourceDirectory.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            DirectoryDialog ddialog = new DirectoryDialog(shell, SWT.OPEN);
            if (wSourceFileFolder.getText() != null) {
              ddialog.setFilterPath(jobMeta.environmentSubstitute(wSourceFileFolder.getText()));
            }

            // Calling open() will open and run the dialog.
            // It will return the selected directory, or
            // null if user cancels
            String dir = ddialog.open();
            if (dir != null) {
              // Set the text box to the new selection
              wSourceFileFolder.setText(dir);
            }
          }
        });

    // Browse Source files button ...
    wbSourceFileFolder = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbSourceFileFolder);
    wbSourceFileFolder.setText(Messages.getString("JobXMLWellFormed.BrowseFiles.Label"));
    fdbSourceFileFolder = new FormData();
    fdbSourceFileFolder.right = new FormAttachment(wbSourceDirectory, -margin);
    fdbSourceFileFolder.top = new FormAttachment(wSettings, margin);
    wbSourceFileFolder.setLayoutData(fdbSourceFileFolder);

    // Browse Destination file add button ...
    wbaSourceFileFolder = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbaSourceFileFolder);
    wbaSourceFileFolder.setText(Messages.getString("JobXMLWellFormed.FilenameAdd.Button"));
    fdbaSourceFileFolder = new FormData();
    fdbaSourceFileFolder.right = new FormAttachment(wbSourceFileFolder, -margin);
    fdbaSourceFileFolder.top = new FormAttachment(wSettings, margin);
    wbaSourceFileFolder.setLayoutData(fdbaSourceFileFolder);

    wSourceFileFolder = new TextVar(jobMeta, wGeneralComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wSourceFileFolder.setToolTipText(
        Messages.getString("JobXMLWellFormed.SourceFileFolder.Tooltip"));

    props.setLook(wSourceFileFolder);
    wSourceFileFolder.addModifyListener(lsMod);
    fdSourceFileFolder = new FormData();
    fdSourceFileFolder.left = new FormAttachment(middle, 0);
    fdSourceFileFolder.top = new FormAttachment(wSettings, 2 * margin);
    fdSourceFileFolder.right = new FormAttachment(wbSourceFileFolder, -55);
    wSourceFileFolder.setLayoutData(fdSourceFileFolder);

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

    wbSourceFileFolder.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.OPEN);
            dialog.setFilterExtensions(new String[] {"*.xml;*.XML", "*"});
            if (wSourceFileFolder.getText() != null) {
              dialog.setFileName(jobMeta.environmentSubstitute(wSourceFileFolder.getText()));
            }
            dialog.setFilterNames(FILETYPES);
            if (dialog.open() != null) {
              wSourceFileFolder.setText(
                  dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
          }
        });

    // Buttons to the right of the screen...
    wbdSourceFileFolder = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbdSourceFileFolder);
    wbdSourceFileFolder.setText(Messages.getString("JobXMLWellFormed.FilenameDelete.Button"));
    wbdSourceFileFolder.setToolTipText(
        Messages.getString("JobXMLWellFormed.FilenameDelete.Tooltip"));
    fdbdSourceFileFolder = new FormData();
    fdbdSourceFileFolder.right = new FormAttachment(100, 0);
    fdbdSourceFileFolder.top = new FormAttachment(wSourceFileFolder, 40);
    wbdSourceFileFolder.setLayoutData(fdbdSourceFileFolder);

    wbeSourceFileFolder = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
    props.setLook(wbeSourceFileFolder);
    wbeSourceFileFolder.setText(Messages.getString("JobXMLWellFormed.FilenameEdit.Button"));
    wbeSourceFileFolder.setToolTipText(Messages.getString("JobXMLWellFormed.FilenameEdit.Tooltip"));
    fdbeSourceFileFolder = new FormData();
    fdbeSourceFileFolder.right = new FormAttachment(100, 0);
    fdbeSourceFileFolder.left = new FormAttachment(wbdSourceFileFolder, 0, SWT.LEFT);
    fdbeSourceFileFolder.top = new FormAttachment(wbdSourceFileFolder, margin);
    wbeSourceFileFolder.setLayoutData(fdbeSourceFileFolder);

    // Wildcard
    wlWildcard = new Label(wGeneralComp, SWT.RIGHT);
    wlWildcard.setText(Messages.getString("JobXMLWellFormed.Wildcard.Label"));
    props.setLook(wlWildcard);
    fdlWildcard = new FormData();
    fdlWildcard.left = new FormAttachment(0, 0);
    fdlWildcard.top = new FormAttachment(wSourceFileFolder, margin);
    fdlWildcard.right = new FormAttachment(middle, -margin);
    wlWildcard.setLayoutData(fdlWildcard);

    wWildcard = new TextVar(jobMeta, wGeneralComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wWildcard.setToolTipText(Messages.getString("JobXMLWellFormed.Wildcard.Tooltip"));
    props.setLook(wWildcard);
    wWildcard.addModifyListener(lsMod);
    fdWildcard = new FormData();
    fdWildcard.left = new FormAttachment(middle, 0);
    fdWildcard.top = new FormAttachment(wSourceFileFolder, margin);
    fdWildcard.right = new FormAttachment(wbSourceFileFolder, -55);
    wWildcard.setLayoutData(fdWildcard);

    wlFields = new Label(wGeneralComp, SWT.NONE);
    wlFields.setText(Messages.getString("JobXMLWellFormed.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.right = new FormAttachment(middle, -margin);
    fdlFields.top = new FormAttachment(wWildcard, margin);
    wlFields.setLayoutData(fdlFields);

    int rows =
        jobEntry.source_filefolder == null
            ? 1
            : (jobEntry.source_filefolder.length == 0 ? 0 : jobEntry.source_filefolder.length);
    final int FieldsRows = rows;

    ColumnInfo[] colinf =
        new ColumnInfo[] {
          new ColumnInfo(
              Messages.getString("JobXMLWellFormed.Fields.SourceFileFolder.Label"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              Messages.getString("JobXMLWellFormed.Fields.Wildcard.Label"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
        };

    colinf[0].setUsingVariables(true);
    colinf[0].setToolTip(Messages.getString("JobXMLWellFormed.Fields.SourceFileFolder.Tooltip"));
    colinf[1].setUsingVariables(true);
    colinf[1].setToolTip(Messages.getString("JobXMLWellFormed.Fields.Wildcard.Tooltip"));

    wFields =
        new TableView(
            jobMeta,
            wGeneralComp,
            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, -75);
    fdFields.bottom = new FormAttachment(100, -margin);
    wFields.setLayoutData(fdFields);

    RefreshArgFromPrevious();

    // Add the file to the list of files...
    SelectionAdapter selA =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            wFields.add(new String[] {wSourceFileFolder.getText(), wWildcard.getText()});
            wSourceFileFolder.setText("");

            wWildcard.setText("");
            wFields.removeEmptyRows();
            wFields.setRowNums();
            wFields.optWidth(true);
          }
        };
    wbaSourceFileFolder.addSelectionListener(selA);
    wSourceFileFolder.addSelectionListener(selA);

    // Delete files from the list of files...
    wbdSourceFileFolder.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            int idx[] = wFields.getSelectionIndices();
            wFields.remove(idx);
            wFields.removeEmptyRows();
            wFields.setRowNums();
          }
        });

    // Edit the selected file & remove from the list...
    wbeSourceFileFolder.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            int idx = wFields.getSelectionIndex();
            if (idx >= 0) {
              String string[] = wFields.getItem(idx);
              wSourceFileFolder.setText(string[0]);
              wWildcard.setText(string[1]);
              wFields.remove(idx);
            }
            wFields.removeEmptyRows();
            wFields.setRowNums();
          }
        });

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

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

    /////////////////////////////////////////////////////////////
    /// END OF GENERAL TAB
    /////////////////////////////////////////////////////////////

    //////////////////////////////////////
    // START OF ADVANCED  TAB   ///
    /////////////////////////////////////

    wAdvancedTab = new CTabItem(wTabFolder, SWT.NONE);
    wAdvancedTab.setText(Messages.getString("JobXMLWellFormed.Tab.Advanced.Label"));

    FormLayout contentLayout = new FormLayout();
    contentLayout.marginWidth = 3;
    contentLayout.marginHeight = 3;

    wAdvancedComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wAdvancedComp);
    wAdvancedComp.setLayout(contentLayout);

    // SuccessOngrouping?
    // ////////////////////////
    // START OF SUCCESS ON GROUP///
    // /
    wSuccessOn = new Group(wAdvancedComp, SWT.SHADOW_NONE);
    props.setLook(wSuccessOn);
    wSuccessOn.setText(Messages.getString("JobXMLWellFormed.SuccessOn.Group.Label"));

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

    wSuccessOn.setLayout(successongroupLayout);

    // Success Condition
    wlSuccessCondition = new Label(wSuccessOn, SWT.RIGHT);
    wlSuccessCondition.setText(Messages.getString("JobXMLWellFormed.SuccessCondition.Label"));
    props.setLook(wlSuccessCondition);
    fdlSuccessCondition = new FormData();
    fdlSuccessCondition.left = new FormAttachment(0, 0);
    fdlSuccessCondition.right = new FormAttachment(middle, 0);
    fdlSuccessCondition.top = new FormAttachment(0, margin);
    wlSuccessCondition.setLayoutData(fdlSuccessCondition);
    wSuccessCondition = new CCombo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wSuccessCondition.add(Messages.getString("JobXMLWellFormed.SuccessWhenAllWorksFine.Label"));
    wSuccessCondition.add(Messages.getString("JobXMLWellFormed.SuccessWhenAtLeat.Label"));
    wSuccessCondition.add(
        Messages.getString("JobXMLWellFormed.SuccessWhenBadFormedLessThan.Label"));
    wSuccessCondition.select(0); // +1: starts at -1

    props.setLook(wSuccessCondition);
    fdSuccessCondition = new FormData();
    fdSuccessCondition.left = new FormAttachment(middle, 0);
    fdSuccessCondition.top = new FormAttachment(0, margin);
    fdSuccessCondition.right = new FormAttachment(100, 0);
    wSuccessCondition.setLayoutData(fdSuccessCondition);
    wSuccessCondition.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            activeSuccessCondition();
          }
        });

    // Success when number of errors less than
    wlNrErrorsLessThan = new Label(wSuccessOn, SWT.RIGHT);
    wlNrErrorsLessThan.setText(Messages.getString("JobXMLWellFormed.NrBadFormedLessThan.Label"));
    props.setLook(wlNrErrorsLessThan);
    fdlNrErrorsLessThan = new FormData();
    fdlNrErrorsLessThan.left = new FormAttachment(0, 0);
    fdlNrErrorsLessThan.top = new FormAttachment(wSuccessCondition, margin);
    fdlNrErrorsLessThan.right = new FormAttachment(middle, -margin);
    wlNrErrorsLessThan.setLayoutData(fdlNrErrorsLessThan);

    wNrErrorsLessThan =
        new TextVar(
            jobMeta,
            wSuccessOn,
            SWT.SINGLE | SWT.LEFT | SWT.BORDER,
            Messages.getString("JobXMLWellFormed.NrBadFormedLessThan.Tooltip"));
    props.setLook(wNrErrorsLessThan);
    wNrErrorsLessThan.addModifyListener(lsMod);
    fdNrErrorsLessThan = new FormData();
    fdNrErrorsLessThan.left = new FormAttachment(middle, 0);
    fdNrErrorsLessThan.top = new FormAttachment(wSuccessCondition, margin);
    fdNrErrorsLessThan.right = new FormAttachment(100, -margin);
    wNrErrorsLessThan.setLayoutData(fdNrErrorsLessThan);

    fdSuccessOn = new FormData();
    fdSuccessOn.left = new FormAttachment(0, margin);
    fdSuccessOn.top = new FormAttachment(0, margin);
    fdSuccessOn.right = new FormAttachment(100, -margin);
    wSuccessOn.setLayoutData(fdSuccessOn);
    // ///////////////////////////////////////////////////////////
    // / END OF Success ON GROUP
    // ///////////////////////////////////////////////////////////

    // fileresult grouping?
    // ////////////////////////
    // START OF LOGGING GROUP///
    // /
    wFileResult = new Group(wAdvancedComp, SWT.SHADOW_NONE);
    props.setLook(wFileResult);
    wFileResult.setText(Messages.getString("JobXMLWellFormed.FileResult.Group.Label"));

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

    wFileResult.setLayout(fileresultgroupLayout);

    // Add Filenames to result filenames?
    wlAddFilenameToResult = new Label(wFileResult, SWT.RIGHT);
    wlAddFilenameToResult.setText(Messages.getString("JobXMLWellFormed.AddFilenameToResult.Label"));
    props.setLook(wlAddFilenameToResult);
    fdlAddFilenameToResult = new FormData();
    fdlAddFilenameToResult.left = new FormAttachment(0, 0);
    fdlAddFilenameToResult.right = new FormAttachment(middle, 0);
    fdlAddFilenameToResult.top = new FormAttachment(0, margin);
    wlAddFilenameToResult.setLayoutData(fdlAddFilenameToResult);
    wAddFilenameToResult = new CCombo(wFileResult, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wAddFilenameToResult.add(Messages.getString("JobXMLWellFormed.AddAllFilenamesToResult.Label"));
    wAddFilenameToResult.add(
        Messages.getString("JobXMLWellFormed.AddOnlyWellFormedFilenames.Label"));
    wAddFilenameToResult.add(
        Messages.getString("JobXMLWellFormed.AddOnlyBadFormedFilenames.Label"));
    wAddFilenameToResult.select(0); // +1: starts at -1

    props.setLook(wAddFilenameToResult);
    fdAddFilenameToResult = new FormData();
    fdAddFilenameToResult.left = new FormAttachment(middle, 0);
    fdAddFilenameToResult.top = new FormAttachment(0, margin);
    fdAddFilenameToResult.right = new FormAttachment(100, 0);
    wAddFilenameToResult.setLayoutData(fdAddFilenameToResult);
    wAddFilenameToResult.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {}
        });

    fdFileResult = new FormData();
    fdFileResult.left = new FormAttachment(0, margin);
    fdFileResult.top = new FormAttachment(wSuccessOn, margin);
    fdFileResult.right = new FormAttachment(100, -margin);
    wFileResult.setLayoutData(fdFileResult);
    // ///////////////////////////////////////////////////////////
    // / END OF FilesResult GROUP
    // ///////////////////////////////////////////////////////////

    fdAdvancedComp = new FormData();
    fdAdvancedComp.left = new FormAttachment(0, 0);
    fdAdvancedComp.top = new FormAttachment(0, 0);
    fdAdvancedComp.right = new FormAttachment(100, 0);
    fdAdvancedComp.bottom = new FormAttachment(100, 0);
    wAdvancedComp.setLayoutData(wAdvancedComp);

    wAdvancedComp.layout();
    wAdvancedTab.setControl(wAdvancedComp);

    /////////////////////////////////////////////////////////////
    /// END OF ADVANCED TAB
    /////////////////////////////////////////////////////////////

    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(wName, margin);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);

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

    wName.addSelectionListener(lsDef);
    wSourceFileFolder.addSelectionListener(lsDef);

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

    getData();
    activeSuccessCondition();

    activeSuccessCondition();

    wTabFolder.setSelection(0);
    BaseStepDialog.setSize(shell);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return jobEntry;
  }
  public JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

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

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

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

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

    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, 0);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);

    // Connection line
    wConnection = addConnectionLine(shell, wName, middle, margin);
    if (jobEntry.getDatabase() == null && jobMeta.nrDatabases() == 1) {
      wConnection.select(0);
    }
    wConnection.addModifyListener(lsMod);

    // Schema name line
    wlSchemaname = new Label(shell, SWT.RIGHT);
    wlSchemaname.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Schemaname.Label"));
    props.setLook(wlSchemaname);
    fdlSchemaname = new FormData();
    fdlSchemaname.left = new FormAttachment(0, 0);
    fdlSchemaname.right = new FormAttachment(middle, 0);
    fdlSchemaname.top = new FormAttachment(wConnection, margin);
    wlSchemaname.setLayoutData(fdlSchemaname);

    wSchemaname = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSchemaname);
    wSchemaname.setToolTipText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Schemaname.Tooltip"));
    wSchemaname.addModifyListener(lsMod);
    fdSchemaname = new FormData();
    fdSchemaname.left = new FormAttachment(middle, 0);
    fdSchemaname.top = new FormAttachment(wConnection, margin);
    fdSchemaname.right = new FormAttachment(100, 0);
    wSchemaname.setLayoutData(fdSchemaname);

    // Table name line
    wlTablename = new Label(shell, SWT.RIGHT);
    wlTablename.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Tablename.Label"));
    props.setLook(wlTablename);
    fdlTablename = new FormData();
    fdlTablename.left = new FormAttachment(0, 0);
    fdlTablename.right = new FormAttachment(middle, 0);
    fdlTablename.top = new FormAttachment(wSchemaname, margin);
    wlTablename.setLayoutData(fdlTablename);

    wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbTable);
    wbTable.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    FormData fdbTable = new FormData();
    fdbTable.right = new FormAttachment(100, 0);
    fdbTable.top = new FormAttachment(wSchemaname, margin / 2);
    wbTable.setLayoutData(fdbTable);
    wbTable.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            getTableName();
          }
        });

    wTablename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTablename);
    wTablename.addModifyListener(lsMod);
    fdTablename = new FormData();
    fdTablename.left = new FormAttachment(middle, 0);
    fdTablename.top = new FormAttachment(wSchemaname, margin);
    fdTablename.right = new FormAttachment(wbTable, -margin);
    wTablename.setLayoutData(fdTablename);

    // Filename line
    wlFilename = new Label(shell, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(wTablename, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);

    wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(wTablename, 0);
    wbFilename.setLayoutData(fdbFilename);

    wFilename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(wTablename, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);

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

    wbFilename.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.OPEN);
            dialog.setFilterExtensions(new String[] {"*.txt", "*.csv", "*"});
            if (wFilename.getText() != null) {
              dialog.setFileName(jobMeta.environmentSubstitute(wFilename.getText()));
            }
            dialog.setFilterNames(FILETYPES);
            if (dialog.open() != null) {
              wFilename.setText(
                  dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
          }
        });

    // Local
    wlLocalInfile = new Label(shell, SWT.RIGHT);
    wlLocalInfile.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.LocalInfile.Label"));
    props.setLook(wlLocalInfile);
    fdlLocalInfile = new FormData();
    fdlLocalInfile.left = new FormAttachment(0, 0);
    fdlLocalInfile.top = new FormAttachment(wFilename, margin);
    fdlLocalInfile.right = new FormAttachment(middle, -margin);
    wlLocalInfile.setLayoutData(fdlLocalInfile);
    wLocalInfile = new Button(shell, SWT.CHECK);
    props.setLook(wLocalInfile);
    wLocalInfile.setToolTipText(
        BaseMessages.getString(PKG, "JobMysqlBulkLoad.LocalInfile.Tooltip"));
    fdLocalInfile = new FormData();
    fdLocalInfile.left = new FormAttachment(middle, 0);
    fdLocalInfile.top = new FormAttachment(wFilename, margin);
    fdLocalInfile.right = new FormAttachment(100, 0);
    wLocalInfile.setLayoutData(fdLocalInfile);
    wLocalInfile.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
          }
        });

    // Priority
    wlProrityValue = new Label(shell, SWT.RIGHT);
    wlProrityValue.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.ProrityValue.Label"));
    props.setLook(wlProrityValue);
    fdlProrityValue = new FormData();
    fdlProrityValue.left = new FormAttachment(0, 0);
    fdlProrityValue.right = new FormAttachment(middle, 0);
    fdlProrityValue.top = new FormAttachment(wLocalInfile, margin);
    wlProrityValue.setLayoutData(fdlProrityValue);
    wProrityValue = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wProrityValue.add(BaseMessages.getString(PKG, "JobMysqlBulkLoad.NorProrityValue.Label"));
    wProrityValue.add(BaseMessages.getString(PKG, "JobMysqlBulkLoad.LowProrityValue.Label"));
    wProrityValue.add(BaseMessages.getString(PKG, "JobMysqlBulkLoad.ConProrityValue.Label"));
    wProrityValue.select(0); // +1: starts at -1

    props.setLook(wProrityValue);
    fdProrityValue = new FormData();
    fdProrityValue.left = new FormAttachment(middle, 0);
    fdProrityValue.top = new FormAttachment(wLocalInfile, margin);
    fdProrityValue.right = new FormAttachment(100, 0);
    wProrityValue.setLayoutData(fdProrityValue);

    fdProrityValue = new FormData();
    fdProrityValue.left = new FormAttachment(middle, 0);
    fdProrityValue.top = new FormAttachment(wLocalInfile, margin);
    fdProrityValue.right = new FormAttachment(100, 0);
    wProrityValue.setLayoutData(fdProrityValue);

    // Separator
    wlSeparator = new Label(shell, SWT.RIGHT);
    wlSeparator.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Separator.Label"));
    props.setLook(wlSeparator);
    fdlSeparator = new FormData();
    fdlSeparator.left = new FormAttachment(0, 0);
    fdlSeparator.right = new FormAttachment(middle, 0);
    fdlSeparator.top = new FormAttachment(wProrityValue, margin);
    wlSeparator.setLayoutData(fdlSeparator);

    wSeparator = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wSeparator);
    wSeparator.addModifyListener(lsMod);
    fdSeparator = new FormData();
    fdSeparator.left = new FormAttachment(middle, 0);
    fdSeparator.top = new FormAttachment(wProrityValue, margin);
    fdSeparator.right = new FormAttachment(100, 0);
    wSeparator.setLayoutData(fdSeparator);

    // enclosed
    wlEnclosed = new Label(shell, SWT.RIGHT);
    wlEnclosed.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Enclosed.Label"));
    props.setLook(wlEnclosed);
    fdlEnclosed = new FormData();
    fdlEnclosed.left = new FormAttachment(0, 0);
    fdlEnclosed.right = new FormAttachment(middle, 0);
    fdlEnclosed.top = new FormAttachment(wSeparator, margin);
    wlEnclosed.setLayoutData(fdlEnclosed);

    wEnclosed = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEnclosed);
    wEnclosed.addModifyListener(lsMod);
    fdEnclosed = new FormData();
    fdEnclosed.left = new FormAttachment(middle, 0);
    fdEnclosed.top = new FormAttachment(wSeparator, margin);
    fdEnclosed.right = new FormAttachment(100, 0);
    wEnclosed.setLayoutData(fdEnclosed);

    // escaped
    wlEscaped = new Label(shell, SWT.RIGHT);
    wlEscaped.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Escaped.Label"));
    props.setLook(wlEscaped);
    fdlEscaped = new FormData();
    fdlEscaped.left = new FormAttachment(0, 0);
    fdlEscaped.right = new FormAttachment(middle, 0);
    fdlEscaped.top = new FormAttachment(wEnclosed, margin);
    wlEscaped.setLayoutData(fdlEscaped);

    wEscaped = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wEscaped);
    wEscaped.setToolTipText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Escaped.Tooltip"));
    wEscaped.addModifyListener(lsMod);
    fdEscaped = new FormData();
    fdEscaped.left = new FormAttachment(middle, 0);
    fdEscaped.top = new FormAttachment(wEnclosed, margin);
    fdEscaped.right = new FormAttachment(100, 0);
    wEscaped.setLayoutData(fdEscaped);

    // Line started
    wlLinestarted = new Label(shell, SWT.RIGHT);
    wlLinestarted.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Linestarted.Label"));
    props.setLook(wlLinestarted);
    fdlLinestarted = new FormData();
    fdlLinestarted.left = new FormAttachment(0, 0);
    fdlLinestarted.right = new FormAttachment(middle, 0);
    fdlLinestarted.top = new FormAttachment(wEscaped, margin);
    wlLinestarted.setLayoutData(fdlLinestarted);

    wLinestarted = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLinestarted);
    wLinestarted.addModifyListener(lsMod);
    fdLinestarted = new FormData();
    fdLinestarted.left = new FormAttachment(middle, 0);
    fdLinestarted.top = new FormAttachment(wEscaped, margin);
    fdLinestarted.right = new FormAttachment(100, 0);
    wLinestarted.setLayoutData(fdLinestarted);

    // Line terminated
    wlLineterminated = new Label(shell, SWT.RIGHT);
    wlLineterminated.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Lineterminated.Label"));
    props.setLook(wlLineterminated);
    fdlLineterminated = new FormData();
    fdlLineterminated.left = new FormAttachment(0, 0);
    fdlLineterminated.right = new FormAttachment(middle, 0);
    fdlLineterminated.top = new FormAttachment(wLinestarted, margin);
    wlLineterminated.setLayoutData(fdlLineterminated);

    wLineterminated = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wLineterminated);
    wLineterminated.addModifyListener(lsMod);
    fdLineterminated = new FormData();
    fdLineterminated.left = new FormAttachment(middle, 0);
    fdLineterminated.top = new FormAttachment(wLinestarted, margin);
    fdLineterminated.right = new FormAttachment(100, 0);
    wLineterminated.setLayoutData(fdLineterminated);

    // List of columns to set for
    wlListattribut = new Label(shell, SWT.RIGHT);
    wlListattribut.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Listattribut.Label"));
    props.setLook(wlListattribut);
    fdlListattribut = new FormData();
    fdlListattribut.left = new FormAttachment(0, 0);
    fdlListattribut.right = new FormAttachment(middle, 0);
    fdlListattribut.top = new FormAttachment(wLineterminated, margin);
    wlListattribut.setLayoutData(fdlListattribut);

    wbListattribut = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbListattribut);
    wbListattribut.setText(BaseMessages.getString(PKG, "System.Button.Edit"));
    FormData fdbListattribut = new FormData();
    fdbListattribut.right = new FormAttachment(100, 0);
    fdbListattribut.top = new FormAttachment(wLineterminated, margin);
    wbListattribut.setLayoutData(fdbListattribut);
    wbListattribut.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            getListColumns();
          }
        });

    wListattribut = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wListattribut);
    wListattribut.setToolTipText(
        BaseMessages.getString(PKG, "JobMysqlBulkLoad.Listattribut.Tooltip"));
    wListattribut.addModifyListener(lsMod);
    fdListattribut = new FormData();
    fdListattribut.left = new FormAttachment(middle, 0);
    fdListattribut.top = new FormAttachment(wLineterminated, margin);
    fdListattribut.right = new FormAttachment(wbListattribut, -margin);
    wListattribut.setLayoutData(fdListattribut);

    // Replace data
    wlReplacedata = new Label(shell, SWT.RIGHT);
    wlReplacedata.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Replacedata.Label"));
    props.setLook(wlReplacedata);
    fdlReplacedata = new FormData();
    fdlReplacedata.left = new FormAttachment(0, 0);
    fdlReplacedata.top = new FormAttachment(wListattribut, margin);
    fdlReplacedata.right = new FormAttachment(middle, -margin);
    wlReplacedata.setLayoutData(fdlReplacedata);
    wReplacedata = new Button(shell, SWT.CHECK);
    props.setLook(wReplacedata);
    wReplacedata.setToolTipText(
        BaseMessages.getString(PKG, "JobMysqlBulkLoad.Replacedata.Tooltip"));
    fdReplacedata = new FormData();
    fdReplacedata.left = new FormAttachment(middle, 0);
    fdReplacedata.top = new FormAttachment(wListattribut, margin);
    fdReplacedata.right = new FormAttachment(100, 0);
    wReplacedata.setLayoutData(fdReplacedata);
    wReplacedata.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
          }
        });

    // Nbr of lines to ignore
    wlIgnorelines = new Label(shell, SWT.RIGHT);
    wlIgnorelines.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.Ignorelines.Label"));
    props.setLook(wlIgnorelines);
    fdlIgnorelines = new FormData();
    fdlIgnorelines.left = new FormAttachment(0, 0);
    fdlIgnorelines.right = new FormAttachment(middle, 0);
    fdlIgnorelines.top = new FormAttachment(wReplacedata, margin);
    wlIgnorelines.setLayoutData(fdlIgnorelines);

    wIgnorelines = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wIgnorelines);
    wIgnorelines.addModifyListener(lsMod);
    fdIgnorelines = new FormData();
    fdIgnorelines.left = new FormAttachment(middle, 0);
    fdIgnorelines.top = new FormAttachment(wReplacedata, margin);
    fdIgnorelines.right = new FormAttachment(100, 0);
    wIgnorelines.setLayoutData(fdIgnorelines);

    // fileresult grouping?
    // ////////////////////////
    // START OF FileResult GROUP///
    // /
    wFileResult = new Group(shell, SWT.SHADOW_NONE);
    props.setLook(wFileResult);
    wFileResult.setText(BaseMessages.getString(PKG, "JobMysqlBulkLoad.FileResult.Group.Label"));

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

    wFileResult.setLayout(groupLayout);

    // Add file to result
    wlAddFileToResult = new Label(wFileResult, SWT.RIGHT);
    wlAddFileToResult.setText(
        BaseMessages.getString(PKG, "JobMysqlBulkLoad.AddFileToResult.Label"));
    props.setLook(wlAddFileToResult);
    fdlAddFileToResult = new FormData();
    fdlAddFileToResult.left = new FormAttachment(0, 0);
    fdlAddFileToResult.top = new FormAttachment(wIgnorelines, margin);
    fdlAddFileToResult.right = new FormAttachment(middle, -margin);
    wlAddFileToResult.setLayoutData(fdlAddFileToResult);
    wAddFileToResult = new Button(wFileResult, SWT.CHECK);
    props.setLook(wAddFileToResult);
    wAddFileToResult.setToolTipText(
        BaseMessages.getString(PKG, "JobMysqlBulkLoad.AddFileToResult.Tooltip"));
    fdAddFileToResult = new FormData();
    fdAddFileToResult.left = new FormAttachment(middle, 0);
    fdAddFileToResult.top = new FormAttachment(wIgnorelines, margin);
    fdAddFileToResult.right = new FormAttachment(100, 0);
    wAddFileToResult.setLayoutData(fdAddFileToResult);
    wAddFileToResult.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
          }
        });

    fdFileResult = new FormData();
    fdFileResult.left = new FormAttachment(0, margin);
    fdFileResult.top = new FormAttachment(wIgnorelines, margin);
    fdFileResult.right = new FormAttachment(100, -margin);
    wFileResult.setLayoutData(fdFileResult);
    // ///////////////////////////////////////////////////////////
    // / END OF FilesRsult GROUP
    // ///////////////////////////////////////////////////////////

    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    FormData fd = new FormData();
    fd.right = new FormAttachment(50, -10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wOK.setLayoutData(fd);

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    fd = new FormData();
    fd.left = new FormAttachment(50, 10);
    fd.bottom = new FormAttachment(100, 0);
    fd.width = 100;
    wCancel.setLayoutData(fd);

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

    wName.addSelectionListener(lsDef);
    wTablename.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();
    props.setDialogSize(shell, "JobMysqlBulkLoadDialogSize");
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return jobEntry;
  }
示例#21
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);

    if (!SAPLibraryTester.isJCoLibAvailable()) {
      int style = SWT.ICON_ERROR;
      MessageBox messageBox = new MessageBox(shell, style);
      messageBox.setMessage(BaseMessages.getString(PKG, "SapInputDialog.JCoLibNotFound"));
      messageBox.open();
      // dispose();
      // return stepname;
    }

    if (!SAPLibraryTester.isJCoImplAvailable()) {
      int style = SWT.ICON_ERROR;
      MessageBox messageBox = new MessageBox(shell, style);
      messageBox.setMessage(BaseMessages.getString(PKG, "SapInputDialog.JCoImplNotFound"));
      messageBox.open();
      // dispose();
      // return stepname;
    }

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

    ModifyListener lsConnectionMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            input.setChanged();
          }
        };
    backupChanged = input.hasChanged();

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

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

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

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

    // Connection line
    //
    wConnection = addConnectionLine(shell, lastControl, middle, margin);
    List<String> items = new ArrayList<String>();
    for (DatabaseMeta dbMeta : transMeta.getDatabases()) {
      if (dbMeta.getDatabaseInterface() instanceof SAPR3DatabaseMeta) {
        items.add(dbMeta.getName());
      }
    }
    wConnection.setItems(items.toArray(new String[items.size()]));
    if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
      wConnection.select(0);
    }
    wConnection.addModifyListener(lsConnectionMod);
    lastControl = wConnection;

    // 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(lastControl, margin);
    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(lastControl, margin);
    wbFunction.setLayoutData(fdbFunction);
    wbFunction.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            getFunction();
          }
        });

    wFunction = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFunction);
    wFunction.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            function = new SAPFunction(((Text) e.widget).getText());
            input.setChanged();
          }
        });
    FormData fdFunction = new FormData();
    fdFunction.left = new FormAttachment(middle, 0);
    fdFunction.right = new FormAttachment(wbFunction, -margin);
    fdFunction.top = new FormAttachment(lastControl, margin);
    wFunction.setLayoutData(fdFunction);
    lastControl = wFunction;

    // The parameter input fields...
    //
    wlInput = new Label(shell, SWT.NONE);
    wlInput.setText(BaseMessages.getString(PKG, "SapInputDialog.Input.Label"));
    props.setLook(wlInput);
    FormData fdlInput = new FormData();
    fdlInput.left = new FormAttachment(0, 0);
    fdlInput.top = new FormAttachment(lastControl, margin);
    wlInput.setLayoutData(fdlInput);

    ColumnInfo[] ciKey =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.Field"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              new String[] {""},
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              SapType.getDescriptions()),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TableOrStruct"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPParameterName"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TargetType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              ValueMeta.getTypes()),
        };
    inputFieldColumns.add(ciKey[0]);

    wInput =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciKey,
            input.getParameters().size(),
            lsMod,
            props);

    FormData fdInput = new FormData();
    fdInput.left = new FormAttachment(0, 0);
    fdInput.top = new FormAttachment(wlInput, margin);
    fdInput.right = new FormAttachment(100, 0);
    fdInput.bottom = new FormAttachment(40, 0);
    wInput.setLayoutData(fdInput);
    lastControl = wInput;

    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    // wPreview = new Button(shell, SWT.PUSH);
    // wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "SapInputDialog.GetFields.Button"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wAbout = new Button(shell, SWT.PUSH);
    wAbout.setText(BaseMessages.getString(PKG, "SapInputDialog.About.Button"));
    // Preview not possible without inputRowSets in BaseStep.getRow()
    // setButtonPositions(new Button[] { wOK, wPreview, wAbout , wGet, wCancel}, margin, null);
    setButtonPositions(new Button[] {wOK, wAbout, wGet, wCancel}, margin, null);

    // The output fields...
    //
    wlOutput = new Label(shell, SWT.NONE);
    wlOutput.setText(BaseMessages.getString(PKG, "SapInputDialog.Output.Label"));
    props.setLook(wlOutput);
    FormData fdlOutput = new FormData();
    fdlOutput.left = new FormAttachment(0, 0);
    fdlOutput.top = new FormAttachment(wInput, margin);
    wlOutput.setLayoutData(fdlOutput);

    ColumnInfo[] ciReturn =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPField"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              new String[] {},
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              SapType.getDescriptions(),
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TableOrStruct"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.NewName"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TargetType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              ValueMeta.getTypes()),
        };
    outputFieldColumns.add(ciReturn[0]);

    wOutput =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciReturn,
            input.getOutputFields().size(),
            lsMod,
            props);

    FormData fdOutput = new FormData();
    fdOutput.left = new FormAttachment(0, 0);
    fdOutput.top = new FormAttachment(wlOutput, margin);
    fdOutput.right = new FormAttachment(100, 0);
    fdOutput.bottom = new FormAttachment(wOK, -8 * margin);
    wOutput.setLayoutData(fdOutput);
    lastControl = wOutput;

    this.wAscLink = new Link(this.shell, SWT.NONE);
    FormData fdAscLink = new FormData();
    fdAscLink.left = new FormAttachment(0, 0);
    fdAscLink.top = new FormAttachment(wOutput, margin);
    wAscLink.setLayoutData(fdAscLink);
    this.wAscLink.setText(BaseMessages.getString(PKG, "SapInputDialog.Provided.Info"));
    lastControl = wAscLink;

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

    wOK.addListener(SWT.Selection, lsOK);
    // wPreview.addListener(SWT.Selection, lsPreview);
    wGet.addListener(SWT.Selection, lsGet);
    wCancel.addListener(SWT.Selection, lsCancel);
    this.wAbout.addListener(SWT.Selection, lsAbout);

    this.wAscLink.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(final Event event) {
            Program.launch(event.text);
          }
        });

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

    wStepname.addSelectionListener(lsDef);
    wFunction.addSelectionListener(lsDef);

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

    input.setChanged(backupChanged);

    setComboValues();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepname;
  }
示例#22
0
  @Override
  public void createPartControl(final Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = layout.horizontalSpacing = 0;
    layout.marginBottom =
        layout.marginHeight =
            layout.marginLeft = layout.marginRight = layout.marginTop = layout.marginWidth = 0;
    parent.setLayout(layout);

    Composite dbSelection = new Composite(parent, SWT.NULL);
    GridLayout innerLayout = new GridLayout();
    innerLayout.numColumns = 3;
    innerLayout.makeColumnsEqualWidth = true;
    GridData innerData = new GridData();
    innerData.horizontalAlignment = SWT.FILL;
    innerData.grabExcessHorizontalSpace = true;
    dbSelection.setLayoutData(innerData);
    dbSelection.setLayout(innerLayout);

    Label searchInLabel = new Label(dbSelection, SWT.NULL);
    searchInLabel.setText(UITexts.browser_hoogleSearchIn);

    BrowserPlugin.getDefault().addDatabaseLoadedListener(this);

    localDb = new Button(dbSelection, SWT.CHECK);
    localDb.setText(UITexts.browser_localDatabase);
    localDb.setSelection(true);
    localDb.setEnabled(BrowserPlugin.getDefault().isLocalDatabaseLoaded());
    localDb.setBackground(dbSelection.getBackground());

    hackageDb = new Button(dbSelection, SWT.CHECK);
    hackageDb.setText(UITexts.browser_hackageDatabase);
    hackageDb.setSelection(false);
    hackageDb.setEnabled(BrowserPlugin.getDefault().isHackageDatabaseLoaded());
    hackageDb.setBackground(dbSelection.getBackground());

    text = new Text(parent, SWT.SINGLE | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    GridData textData = new GridData();
    textData.horizontalAlignment = SWT.FILL;
    textData.grabExcessHorizontalSpace = true;
    text.setLayoutData(textData);
    text.addSelectionListener(this);
    text.setEnabled(false);

    SashForm form = new SashForm(parent, SWT.VERTICAL);
    GridData formData = new GridData();
    formData.horizontalAlignment = SWT.FILL;
    formData.verticalAlignment = SWT.FILL;
    formData.grabExcessVerticalSpace = true;
    formData.grabExcessHorizontalSpace = true;
    form.setLayoutData(formData);
    viewer = new TreeViewer(form);
    viewer.setLabelProvider(new HoogleLabelProvider());
    // Load if needed
    if (BrowserPlugin.getDefault().isHoogleLoaded()) {
      hoogleLoaded(null);
    } else {
      hoogleUnloaded(null);
    }

    doc = new Browser(form, SWT.NONE);
    form.setWeights(new int[] {70, 30});
    // Hook for double clicking
    viewer.addDoubleClickListener(this);
    // Hook for changes in selection
    viewer.addPostSelectionChangedListener(this);
    // Wait the Hoogle database to be ready
    BrowserPlugin.getDefault().addHoogleLoadedListener(this);
  }
示例#23
0
  protected void createComposite(Composite parent, ArticleContainerID articleContainerID) {
    //		getArticleContainerEdit().setShowHeader(false);
    getArticleContainerEdit().createComposite(parent);
    getArticleContainerEdit().setShowHeader(false);
    XComposite wrapper = new XComposite(parent, SWT.NONE, LayoutDataMode.GRID_DATA_HORIZONTAL);

    buttonComp = new XComposite(wrapper, SWT.NONE);
    buttonComp.setLayout(new GridLayout(8, false));
    buttonComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    deleteAllButton = new Button(buttonComp, SWT.FLAT);
    deleteAllButton.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.quicksale.ui.ArticleContainerQuickSaleEditorPage.deleteAllButton.text")); //$NON-NLS-1$
    deleteAllButton.setImage(SharedImages.DELETE_16x16.createImage());
    deleteAllButton.addSelectionListener(deleteAllListener);

    deleteSelectionButton = new Button(buttonComp, SWT.FLAT);
    deleteSelectionButton.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.quicksale.ui.ArticleContainerQuickSaleEditorPage.button.deleteSelection.text")); //$NON-NLS-1$
    deleteSelectionButton.setImage(SharedImages.DELETE_16x16.createImage());
    deleteSelectionButton.addSelectionListener(deleteSelectionListener);
    deleteSelectionButton.setEnabled(false);

    // need to add listeners for activeSegmentEdit by this listener, because at this time
    // activeSegementEdit is null
    getArticleContainerEdit()
        .addActiveSegmentEditSelectionListener(
            new ActiveSegmentEditSelectionListener() {
              @Override
              public void selected(ActiveSegmentEditSelectionEvent event) {
                // add listener to check for articleSelection to set enable state for
                // deleteSelectionButton
                event
                    .getActiveSegmentEdit()
                    .addSegmentEditArticleSelectionListener(segmentEditArticleSelectionListener);
              }
            });

    Label spacerLabel = new Label(buttonComp, SWT.NONE);
    spacerLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label customerSearchLabel = new Label(buttonComp, SWT.NONE);
    customerSearchLabel.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.quicksale.ui.ArticleContainerQuickSaleEditorPage.customerSearchLabel.text")); //$NON-NLS-1$
    customerSearchText = new Text(buttonComp, wrapper.getBorderStyle());
    GridData textData = new GridData();
    textData.widthHint = 100;
    textData.heightHint = 15;
    textData.minimumWidth = 100;
    customerSearchText.setLayoutData(textData);
    customerSearchText.addSelectionListener(okListenerCustomer);

    okButtonCustomer = new Button(buttonComp, SWT.FLAT);
    okButtonCustomer.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.quicksale.ui.ArticleContainerQuickSaleEditorPage.okButtonCustomer.text")); //$NON-NLS-1$
    okButtonCustomer.setImage(
        SharedImages.getSharedImage(TradePlugin.getDefault(), LegalEntityEditorView.class));
    okButtonCustomer.addSelectionListener(okListenerCustomer);

    //		Label separator = new Label(buttonComp, SWT.SEPARATOR);

    okButtonAnonymous = new Button(buttonComp, SWT.FLAT);
    okButtonAnonymous.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.quicksale.ui.ArticleContainerQuickSaleEditorPage.okButtonAnonymous.text")); //$NON-NLS-1$
    okButtonAnonymous.setImage(
        SharedImages.getSharedImage(TradePlugin.getDefault(), SelectAnonymousViewAction.class));
    okButtonAnonymous.addSelectionListener(okListenerAnonymous);

    getArticleContainerEdit().addArticleChangeListener(articleChangeListener);
    getArticleContainerEdit().addArticleCreateListener(articleCreateListener);

    buttonComp.setEnabled(false);
  }
示例#24
0
  /**
   * view command
   *
   * @param shell shell
   * @param repositoryTab repository tab
   * @param fileData file to view
   * @param revision revision to view
   */
  CommandView(
      final Shell shell,
      final RepositoryTab repositoryTab,
      final FileData fileData,
      final String revision) {
    Composite composite, subComposite;
    Label label;
    Button button;
    Listener listener;

    // initialize variables
    this.repositoryTab = repositoryTab;
    this.fileData = fileData;

    // get display
    display = shell.getDisplay();
    clipboard = new Clipboard(display);

    // add files dialog
    dialog = Dialogs.open(shell, "View: " + fileData.getFileName(), new double[] {1.0, 0.0}, 1.0);

    composite = Widgets.newComposite(dialog);
    composite.setLayout(new TableLayout(new double[] {0.0, 1.0, 0.0}, 1.0, 4));
    Widgets.layout(composite, 0, 0, TableLayoutData.NSWE, 0, 0, 4);
    {
      subComposite = Widgets.newComposite(composite);
      subComposite.setLayout(new TableLayout(1.0, new double[] {0.0, 1.0}));
      Widgets.layout(subComposite, 0, 0, TableLayoutData.WE);
      {
        label = Widgets.newLabel(subComposite, "Revision:");
        Widgets.layout(label, 0, 0, TableLayoutData.W);

        widgetRevision = Widgets.newSelect(subComposite);
        widgetRevision.setEnabled(false);
        Widgets.layout(widgetRevision, 0, 1, TableLayoutData.WE);
        Widgets.addModifyListener(
            new WidgetListener(widgetRevision, data) {
              public void modified(Control control) {
                Widgets.setEnabled(control, (data.revisionNames != null));
              }
            });
        widgetRevision.setToolTipText("Revision to view.");

        widgetRevisionPrev = Widgets.newButton(subComposite, Onzen.IMAGE_ARROW_LEFT);
        widgetRevisionPrev.setEnabled(false);
        Widgets.layout(widgetRevisionPrev, 0, 2, TableLayoutData.NSW);
        Widgets.addModifyListener(
            new WidgetListener(widgetRevisionPrev, data) {
              public void modified(Control control) {
                Widgets.setEnabled(
                    control,
                    (data.revisionNames != null) && (widgetRevision.getSelectionIndex() > 0));
              }
            });
        widgetRevisionPrev.setToolTipText("Show previous revision.");

        widgetRevisionNext = Widgets.newButton(subComposite, Onzen.IMAGE_ARROW_RIGHT);
        widgetRevisionNext.setEnabled(false);
        Widgets.layout(widgetRevisionNext, 0, 3, TableLayoutData.NSW);
        Widgets.addModifyListener(
            new WidgetListener(widgetRevisionNext, data) {
              public void modified(Control control) {

                Widgets.setEnabled(
                    control,
                    (data.revisionNames != null)
                        && (widgetRevision.getSelectionIndex() < data.revisionNames.length - 1));
              }
            });
        widgetRevisionNext.setToolTipText("Show next revision.");
      }

      subComposite = Widgets.newComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
      subComposite.setLayout(new TableLayout(1.0, new double[] {0.0, 1.0}));
      Widgets.layout(subComposite, 1, 0, TableLayoutData.NSWE);
      {
        widgetLineNumbers = Widgets.newTextView(subComposite, SWT.RIGHT | SWT.BORDER | SWT.MULTI);
        widgetLineNumbers.setForeground(Onzen.COLOR_GRAY);
        Widgets.layout(widgetLineNumbers, 0, 0, TableLayoutData.NS, 0, 0, 0, 0, 60, SWT.DEFAULT);
        Widgets.addModifyListener(
            new WidgetListener(widgetLineNumbers, data) {
              public void modified(Control control) {
                control.setForeground((data.lines != null) ? null : Onzen.COLOR_GRAY);
              }
            });

        widgetText = Widgets.newTextView(subComposite, SWT.LEFT | SWT.BORDER | SWT.MULTI);
        widgetText.setForeground(Onzen.COLOR_GRAY);
        Widgets.layout(widgetText, 0, 1, TableLayoutData.NSWE);
        Widgets.addModifyListener(
            new WidgetListener(widgetText, data) {
              public void modified(Control control) {
                control.setForeground((data.lines != null) ? null : Onzen.COLOR_GRAY);
              }
            });
      }
      widgetHorizontalScrollBar = subComposite.getHorizontalBar();
      widgetVerticalScrollBar = subComposite.getVerticalBar();

      subComposite = Widgets.newComposite(composite);
      subComposite.setLayout(new TableLayout(1.0, new double[] {0.0, 1.0}));
      Widgets.layout(subComposite, 2, 0, TableLayoutData.NSWE);
      {
        label = Widgets.newLabel(subComposite, "Find:", SWT.NONE, Settings.keyFind);
        Widgets.layout(label, 0, 0, TableLayoutData.W);

        widgetFind = Widgets.newText(subComposite, SWT.SEARCH | SWT.ICON_CANCEL);
        widgetFind.setMessage("Enter text to find");
        Widgets.layout(widgetFind, 0, 1, TableLayoutData.WE);

        widgetFindPrev = Widgets.newButton(subComposite, Onzen.IMAGE_ARROW_UP);
        widgetFindPrev.setEnabled(false);
        Widgets.layout(widgetFindPrev, 0, 2, TableLayoutData.NSW);
        Widgets.addModifyListener(
            new WidgetListener(widgetFindPrev, data) {
              public void modified(Control control) {
                Widgets.setEnabled(control, (data.lines != null));
              }
            });
        widgetFindPrev.setToolTipText(
            "Find previous occurrence of text ["
                + Widgets.acceleratorToText(Settings.keyFindPrev)
                + "].");

        widgetFindNext = Widgets.newButton(subComposite, Onzen.IMAGE_ARROW_DOWN);
        widgetFindNext.setEnabled(false);
        Widgets.layout(widgetFindNext, 0, 3, TableLayoutData.NSW);
        Widgets.addModifyListener(
            new WidgetListener(widgetFindNext, data) {
              public void modified(Control control) {
                Widgets.setEnabled(control, (data.lines != null));
              }
            });
        widgetFindNext.setToolTipText(
            "Find next occurrence of text  ["
                + Widgets.acceleratorToText(Settings.keyFindNext)
                + "].");
      }
    }

    // buttons
    composite = Widgets.newComposite(dialog);
    composite.setLayout(new TableLayout(0.0, 1.0));
    Widgets.layout(composite, 1, 0, TableLayoutData.WE, 0, 0, 4);
    {
      button = Widgets.newButton(composite, "Save as...");
      Widgets.layout(
          button, 0, 0, TableLayoutData.W, 0, 0, 0, 0, SWT.DEFAULT, SWT.DEFAULT, 70, SWT.DEFAULT);
      button.addSelectionListener(
          new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

            public void widgetSelected(SelectionEvent selectionEvent) {
              // get file name
              String fileName = Dialogs.fileSave(dialog, "Save file", "", new String[] {"*"});
              if (fileName == null) {
                return;
              }

              // check if file exists: overwrite or append
              File file = new File(fileName);
              if (file.exists()) {
                switch (Dialogs.select(
                    dialog,
                    "Confirmation",
                    String.format("File '%s' already exists.", fileName),
                    new String[] {"Overwrite", "Append", "Cancel"},
                    2)) {
                  case 0:
                    if (!file.delete()) {
                      Dialogs.error(dialog, "Cannot delete file!");
                      return;
                    }
                  case 1:
                    break;
                  case 2:
                    return;
                }
              }

              PrintWriter output = null;
              try {
                // open file
                output = new PrintWriter(new FileWriter(file, true));

                // write/append file
                for (String line : data.lines) {
                  output.println(line);
                }

                // close file
                output.close();
              } catch (IOException exception) {
                Dialogs.error(
                    dialog,
                    "Cannot write file '" + file.getName() + "' (error: " + exception.getMessage());
                return;
              } finally {
                if (output != null) output.close();
              }
            }
          });

      widgetClose = Widgets.newButton(composite, "Close");
      Widgets.layout(
          widgetClose,
          0,
          1,
          TableLayoutData.E,
          0,
          0,
          0,
          0,
          SWT.DEFAULT,
          SWT.DEFAULT,
          70,
          SWT.DEFAULT);
      widgetClose.addSelectionListener(
          new SelectionListener() {
            public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

            public void widgetSelected(SelectionEvent selectionEvent) {
              Settings.geometryView = dialog.getSize();

              Dialogs.close(dialog, false);
            }
          });
    }

    // listeners
    widgetRevision.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

          public void widgetSelected(SelectionEvent selectionEvent) {
            Combo widget = (Combo) selectionEvent.widget;

            int index = widget.getSelectionIndex();
            if ((data.revisionNames != null)
                && (index >= 0)
                && (index < data.revisionNames.length)) {
              show(data.revisionNames[index]);
            }
          }
        });
    widgetRevisionPrev.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

          public void widgetSelected(SelectionEvent selectionEvent) {
            int index = widgetRevision.getSelectionIndex();
            if (index > 0) {
              show(data.revisionNames[index - 1]);
            }
          }
        });
    widgetRevisionNext.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

          public void widgetSelected(SelectionEvent selectionEvent) {
            int index = widgetRevision.getSelectionIndex();
            if ((data.revisionNames != null) && (index < data.revisionNames.length - 1)) {
              show(data.revisionNames[index + 1]);
            }
          }
        });

    listener =
        new Listener() {
          public void handleEvent(Event event) {
            StyledText widget = (StyledText) event.widget;
            int topIndex = widget.getTopIndex();
            // Dprintf.dprintf("%d %d",widget.getTopPixel(),widgetText.getTopPixel());

            widgetText.setTopIndex(topIndex);
            widgetText.setCaretOffset(widgetText.getOffsetAtLine(topIndex));
          }
        };
    widgetLineNumbers.addListener(SWT.KeyDown, listener);
    widgetLineNumbers.addListener(SWT.KeyUp, listener);
    widgetLineNumbers.addListener(SWT.MouseDown, listener);
    widgetLineNumbers.addListener(SWT.MouseUp, listener);
    widgetLineNumbers.addListener(SWT.MouseMove, listener);
    widgetLineNumbers.addListener(SWT.Resize, listener);

    listener =
        new Listener() {
          public void handleEvent(Event event) {
            StyledText widget = (StyledText) event.widget;
            int topIndex = widget.getTopIndex();
            // Dprintf.dprintf("widget=%s: %d",widget,widget.getTopIndex());

            widgetLineNumbers.setTopIndex(topIndex);
            widgetVerticalScrollBar.setSelection(topIndex);
          }
        };
    widgetText.addListener(SWT.KeyDown, listener);
    widgetText.addListener(SWT.KeyUp, listener);
    widgetText.addListener(SWT.MouseDown, listener);
    widgetText.addListener(SWT.MouseUp, listener);
    widgetText.addListener(SWT.MouseMove, listener);
    widgetText.addListener(SWT.Resize, listener);
    widgetText.addLineStyleListener(
        new LineStyleListener() {
          public void lineGetStyle(LineStyleEvent lineStyleEvent) {
            // Dprintf.dprintf("x %d %s",lineStyleEvent.lineOffset,lineStyleEvent.lineText);
            String findText = widgetFind.getText().toLowerCase();
            int findTextLength = findText.length();
            if (findTextLength > 0) {
              ArrayList<StyleRange> styleRangeList = new ArrayList<StyleRange>();
              int index = 0;
              while ((index = lineStyleEvent.lineText.toLowerCase().indexOf(findText, index))
                  >= 0) {
                styleRangeList.add(
                    new StyleRange(
                        lineStyleEvent.lineOffset + index,
                        findTextLength,
                        COLOR_VIEW_SEARCH_TEXT,
                        COLOR_VIEW_SEARCH_BACKGROUND));
                index += findTextLength;
              }
              lineStyleEvent.styles = styleRangeList.toArray(new StyleRange[styleRangeList.size()]);
              // Dprintf.dprintf("lineStyleEvent.styles=%d",lineStyleEvent.styles.length);
            } else {
              lineStyleEvent.styles = null;
            }
          }
        });
    widgetText.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent keyEvent) {
            if (Widgets.isAccelerator(keyEvent, SWT.CTRL + 'c')) {
              Widgets.setClipboard(clipboard, widgetText.getSelectionText());
            }
          }

          public void keyReleased(KeyEvent keyEvent) {}
        });
    widgetHorizontalScrollBar.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

          public void widgetSelected(SelectionEvent selectionEvent) {
            ScrollBar widget = (ScrollBar) selectionEvent.widget;
            int index = widget.getSelection();

            // sync text widget
            widgetText.setHorizontalIndex(index);
          }
        });
    widgetVerticalScrollBar.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

          public void widgetSelected(SelectionEvent selectionEvent) {
            ScrollBar widget = (ScrollBar) selectionEvent.widget;
            int index = widget.getSelection();
            // Dprintf.dprintf("widget=%s: %d %d
            // %d",widget,widget.getSelection(),widget.getMinimum(),widget.getMaximum());

            // sync  number text widget, text widget
            widgetLineNumbers.setTopIndex(index);
            widgetText.setTopIndex(index);
          }
        });

    widgetFind.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            findNext(widgetText, widgetFind);
          }

          public void widgetSelected(SelectionEvent selectionEvent) {}
        });
    widgetFind.addKeyListener(
        new KeyListener() {
          public void keyPressed(KeyEvent keyEvent) {}

          public void keyReleased(KeyEvent keyEvent) {
            updateViewFindText(widgetText, widgetFind);
          }
        });
    widgetFindPrev.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

          public void widgetSelected(SelectionEvent selectionEvent) {
            findPrev(widgetText, widgetFind);
          }
        });
    widgetFindNext.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent selectionEvent) {}

          public void widgetSelected(SelectionEvent selectionEvent) {
            findNext(widgetText, widgetFind);
          }
        });

    KeyListener keyListener =
        new KeyListener() {
          public void keyPressed(KeyEvent keyEvent) {
            if (Widgets.isAccelerator(keyEvent, Settings.keyFind)) {
              widgetFind.forceFocus();
            } else if (Widgets.isAccelerator(keyEvent, Settings.keyFindPrev)) {
              Widgets.invoke(widgetFindPrev);
            } else if (Widgets.isAccelerator(keyEvent, Settings.keyFindNext)) {
              Widgets.invoke(widgetFindNext);
            }
          }

          public void keyReleased(KeyEvent keyEvent) {}
        };
    widgetText.addKeyListener(keyListener);
    widgetFind.addKeyListener(keyListener);
    widgetFindPrev.addKeyListener(keyListener);
    widgetFindNext.addKeyListener(keyListener);

    dialog.addListener(
        USER_EVENT_NEW_REVISION,
        new Listener() {
          public void handleEvent(Event event) {}
        });

    // show dialog
    Dialogs.show(dialog, Settings.geometryView, Settings.setWindowLocation);

    // start show file
    show(revision);

    // start add revisions (only if single file is seleccted)
    Background.run(
        new BackgroundRunnable(fileData, revision) {
          public void run(FileData fileData, final String revision) {
            // get revisions
            repositoryTab.setStatusText("Get revisions for '%s'...", fileData.getFileName());
            try {
              data.revisionNames = repositoryTab.repository.getRevisionNames(fileData);
            } catch (RepositoryException exception) {
              final String exceptionMessage = exception.getMessage();
              display.syncExec(
                  new Runnable() {
                    public void run() {
                      Dialogs.error(
                          dialog, String.format("Getting revisions fail: %s", exceptionMessage));
                    }
                  });
              return;
            } finally {
              repositoryTab.clearStatusText();
            }

            if (data.revisionNames.length > 0) {
              // add revisions
              if (!dialog.isDisposed()) {
                display.syncExec(
                    new Runnable() {
                      public void run() {
                        if (!widgetRevision.isDisposed()) {
                          int selectIndex = -1;
                          for (int z = 0; z < data.revisionNames.length; z++) {
                            widgetRevision.add(data.revisionNames[z]);
                            if ((revision != null) && revision.equals(data.revisionNames[z])) {
                              selectIndex = z;
                            }
                          }
                          widgetRevision.add(repositoryTab.repository.getLastRevision());
                          if ((revision != null)
                              && revision.equals(repositoryTab.repository.getLastRevision()))
                            selectIndex = data.revisionNames.length;
                          if (selectIndex == -1) selectIndex = data.revisionNames.length;
                          widgetRevision.select(selectIndex);
                        }

                        // notify modification
                        Widgets.modified(data);
                      }
                    });
              }
            }
          }
        });
  }
  /*
   * 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;
  }
示例#26
0
  @Override
  public void createPartControl(Composite aParent) {
    label = new Label(aParent, SWT.NONE);
    label.setText(Messages.LocationView_prompt);

    text = new Text(aParent, SWT.BORDER);
    text.setText(Messages.LocationView_default);
    text.setEditable(true);
    text.addSelectionListener(
        new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent e) {
            search(createQuery()); // search according to filter
          }

          public void widgetSelected(SelectionEvent e) {
            quick(text.getText());
          }
        });

    // Create bbox button
    bbox = new Button(aParent, SWT.CHECK);
    bbox.setText(Messages.LocationView_bbox);
    bbox.setToolTipText(Messages.LocationView_bboxTooltip);

    super.createPartControl(aParent);

    // Layout using Form Layout (+ indicates FormAttachment)
    // +
    // +label+text+bbox+
    // +
    // contents
    // +
    FormLayout layout = new FormLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.spacing = 0;
    aParent.setLayout(layout);

    FormData dLabel = new FormData(); // bind to left & text
    dLabel.left = new FormAttachment(0);
    dLabel.top = new FormAttachment(text, 5, SWT.CENTER);
    label.setLayoutData(dLabel);

    FormData dText = new FormData(); // bind to top, label, bbox
    dText.top = new FormAttachment(1);
    dText.left = new FormAttachment(label, 5);
    dText.right = new FormAttachment(bbox, -5);
    text.setLayoutData(dText);

    FormData dBbox = new FormData(); // text & right
    dBbox.right = new FormAttachment(100);
    dBbox.top = new FormAttachment(text, 0, SWT.CENTER);
    bbox.setLayoutData(dBbox);

    FormData dsashForm = new FormData(100, 100); // text & bottom
    dsashForm.right = new FormAttachment(100); // bind to right of form
    dsashForm.left = new FormAttachment(0); // bind to left of form
    dsashForm.top = new FormAttachment(text, 2); // attach with 5 pixel offset
    dsashForm.bottom = new FormAttachment(100); // bind to bottom of form

    splitter.setWeights(new int[] {60, 40});
    splitter.setLayoutData(dsashForm);
    createContextMenu();
  }
示例#27
0
  /**
   * Used internally
   *
   * @param parent
   * @param plottingSystem
   * @param style
   * @param xyGraph
   * @param defaultRegion
   * @param isImplicit Flag to tell whether the RegionComposite is used in a specific window with an
   *     apply button or part of a view where the changes are implicit
   */
  public RegionEditComposite(
      final Composite parent,
      final IPlottingSystem<?> plottingSystem,
      final int style,
      final XYRegionGraph xyGraph,
      final RegionType defaultRegion,
      final boolean isImplicit) {

    super(parent, SWT.NONE);

    this.setImplicit(isImplicit);

    this.xyGraph = xyGraph;
    this.plottingSystem = plottingSystem;

    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    setLayout(new org.eclipse.swt.layout.GridLayout(2, false));

    final Label nameLabel = new Label(this, SWT.NONE);
    nameLabel.setText("Name   ");
    nameLabel.setLayoutData(new GridData());

    nameText = new Text(this, SWT.BORDER | SWT.SINGLE);
    nameText.setToolTipText("Region name");
    nameText.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    if (isImplicit()) {
      nameText.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label horiz = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    horiz.setLayoutData(new GridData(SWT.FILL, 0, true, false, 2, 1));

    final Label typeLabel = new Label(this, SWT.NONE);
    typeLabel.setText("Type");
    typeLabel.setLayoutData(new GridData());

    regionType = new CCombo(this, SWT.BORDER | SWT.NONE);
    regionType.setEditable(false);
    regionType.setToolTipText("Region type");
    regionType.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    for (RegionType type : RegionType.ALL_TYPES) {
      regionType.add(type.getName());
    }
    regionType.select(defaultRegion.getIndex());

    xCombo = createAxisChooser(this, "X Axis", xyGraph.getXAxisList());
    yCombo = createAxisChooser(this, "Y Axis", xyGraph.getYAxisList());

    Label colorLabel = new Label(this, 0);
    colorLabel.setText("Selection Color");
    colorLabel.setLayoutData(new GridData());

    colorSelector = new ColorSelector(this);
    colorSelector.getButton().setLayoutData(new GridData());
    colorSelector.setColorValue(defaultRegion.getDefaultColor().getRGB());
    if (isImplicit()) {
      colorSelector.addListener(
          new IPropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent event) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label horiz2 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    horiz2.setLayoutData(new GridData(SWT.FILL, 0, true, false, 2, 1));

    Label alphaLabel = new Label(this, 0);
    alphaLabel.setText("Alpha level");
    alphaLabel.setLayoutData(new GridData());

    alpha = new Spinner(this, SWT.NONE);
    alpha.setToolTipText("Alpha transparency level of the shaded shape");
    alpha.setLayoutData(new GridData());
    alpha.setMinimum(0);
    alpha.setMaximum(255);
    alpha.setSelection(80);
    if (isImplicit()) {
      alpha.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.mobile = new Button(this, SWT.CHECK);
    mobile.setText("   Mobile   ");
    mobile.setToolTipText("When true, this selection can be resized and moved around the graph.");
    mobile.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    mobile.setSelection(true);
    if (isImplicit()) {
      mobile.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.showPoints = new Button(this, SWT.CHECK);
    showPoints.setText("   Show vertex values");
    showPoints.setToolTipText(
        "When on this will show the actual value of the point in the axes it was added.");
    showPoints.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    if (isImplicit()) {
      showPoints.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.visible = new Button(this, SWT.CHECK);
    visible.setText("   Show region");
    visible.setToolTipText("You may turn off the visibility of this region.");
    visible.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    visible.setSelection(true);
    if (isImplicit()) {
      visible.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.showLabel = new Button(this, SWT.CHECK);
    showLabel.setText("   Show name");
    showLabel.setToolTipText("Turn on to show the name of a selection region.");
    showLabel.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    showLabel.setSelection(true);
    if (isImplicit()) {
      showLabel.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.fillRegion = new Button(this, SWT.CHECK);
    fillRegion.setText("   Fill region");
    fillRegion.setToolTipText("Fill the body of an area region");
    fillRegion.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    fillRegion.setSelection(true);
    if (isImplicit()) {
      fillRegion.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label spacer = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    spacer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    // We add a composite for setting the region location programmatically.
    final Label location = new Label(this, SWT.NONE);
    location.setText("Region Location");
    location.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    this.roiViewer = new ROIEditTable();
    roiViewer.createPartControl(this);

    // Should be last
    nameText.setText(getDefaultName(defaultRegion.getIndex()));
  }
示例#28
0
  public boolean createTable(
      int lenX, int lenY, String[][] dataArray, typeOfCell[][] type, Object[][] extra) {
    int[] widthArr = new int[lenX];
    for (int i = 0; i < lenX; i++) widthArr[i] = normalWidth;
    widthArr[0] = Width0;
    Table varTable = new Table(_parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    if (lenY > 30) {
      if (debug) System.out.println("lenY=" + lenY);
      varTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    }
    // else varTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 10));

    varTable.setHeaderVisible(true);
    TableColumn tableColumn[] = new TableColumn[lenX];
    for (int i = 0; i < lenX; i++) {
      tableColumn[i] = new TableColumn(varTable, SWT.LEFT);
      tableColumn[i].setText(_columnName[i]);
      tableColumn[i].setWidth(widthArr[i]);
    }
    TableItem Sp[] = new TableItem[lenY];
    String[] value = new String[lenX];
    for (int j = 0; j < lenY; j++) {
      for (int i = 0; i < lenX; i++) value[i] = dataArray[i][j];
      Sp[j] = new TableItem(varTable, SWT.NONE);
      Sp[j].setText(value);

      for (int i = 0; i < lenX; i++) {
        switch (type[i][j]) {
          case Combo:
            int current = -1;
            combo = new CCombo(varTable, SWT.NONE);
            Object valueArr = extra[i][j];
            if (valueArr instanceof String[]) {
              String[] valueAsString = (String[]) valueArr;
              for (int k = 0; k < valueAsString.length; k++) {
                combo.add(valueAsString[k]);
                if (valueAsString[k].compareTo(dataArray[i][j]) == 0) current = k;
              }
              if (current == -1) {
                // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong comboSelect");
                System.out.println("Wrong comboSelect");
              } else combo.select(current);

              TableEditor editor = new TableEditor(varTable);
              editor.grabHorizontal = editor.grabVertical = true;
              editor.setEditor(combo, Sp[j], i);
              if (dataArray[0][j].compareTo(ssRunCtrlStr) == 0) {
                comboSsRunCtrl = combo;
                comboSsRunCtrl.addSelectionListener(
                    new SelectionAdapter() {
                      public void widgetSelected(SelectionEvent e) {
                        overwriteSS();
                      }
                    });
              } else if (dataArray[0][j].compareTo(this.currentStateStr) == 0) {
                comboCurrentState = combo;
                comboCurrentState.addSelectionListener(
                    new SelectionAdapter() {
                      public void widgetSelected(SelectionEvent e) {
                        overwriteCS();
                      }
                    });
              }

            } else {
              // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong instance");
              System.out.println("Wrong instance");
            }
            break;

          case EditableText:
            Text txt = new Text(varTable, SWT.SINGLE | SWT.BORDER);
            txt.setText(dataArray[i][j]);
            txt.addSelectionListener(
                new SelectionAdapter() {
                  public void widgetDefaultSelected(SelectionEvent e) {
                    Text t = (Text) e.widget;
                    valueChanged(t.getText());
                    System.out.println("DummyListenerText");
                  }
                });
            TableEditor editor = new TableEditor(varTable);
            editor.grabHorizontal = editor.grabVertical = true;
            editor.setEditor(txt, Sp[j], i);
            break;
            //				TODO jhatje: implement new datatypes
            //				case MB3_member:
            //					ListViewer listMB3 = new ListViewer(varTable, SWT.NONE);
            //					final String[] arr = new String[1];
            //					arr[0]=dataArray[i][j];
            //					listMB3.setContentProvider(new IStructuredContentProvider() {
            //					public void dispose() {
            //					}
            //					public Object[] getElements(Object inputElement) {
            //					IProcessVariable[] ipv = new IProcessVariable[1];
            //					ipv[0] = CentralItemFactory.createProcessVariable(arr[0]);
            //					return ipv;
            //					}
            //					public void inputChanged(Viewer viewer,Object oldInput, Object newInput) {
            //					}
            //					});
            //
            //					listMB3.setLabelProvider(new ILabelProvider() {
            //					public Image getImage(Object element) {
            //					return null;
            //					}
            //					public String getText(Object element) {
            //					IProcessVariable ipv = (IProcessVariable) element;
            //					return ipv.getName();
            //					}
            //					public void addListener(ILabelProviderListener listener) {
            //					}
            //					public void dispose() {
            //					}
            //					public boolean isLabelProperty(Object element,String property) {
            //					return false;
            //					}
            //					public void removeListener(
            //						ILabelProviderListener listener) {
            //					}
            //					});
            //					listMB3.setInput(arr);
            //					editor = new TableEditor(varTable);
            //					editor.grabHorizontal = editor.grabVertical = true;
            //
            //					List list =  listMB3.getList();
            //					list.setForeground(_display.getSystemColor(SWT.COLOR_BLUE));
            //					editor.setEditor( list, Sp[j], 1);
            //					new ProcessVariableDragSource (listMB3.getControl(), listMB3);
            //					makeContextMenu(listMB3);
            //				break;

          case Message:
            Group textGroup = new Group(_parent, SWT.NONE);
            GridLayout gridLayout = new GridLayout();
            textGroup.setLayout(gridLayout);
            gridLayout.numColumns = 1;
            textGroup.setLayoutData(
                new GridData(
                    /*GridData.GRAB_HORIZONTAL|GridData.HORIZONTAL_ALIGN_FILL|*/ GridData
                        .VERTICAL_ALIGN_FILL));
            textGroup.setText("Message:");
            Label labelWrap = new Label(textGroup, SWT.WRAP | SWT.BORDER);
            labelWrap.setText(dataArray[i][j]);
            labelWrap.setSize(20, 50);
            break;

          case String:
            break;
          default:
            // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("Wrong switch");
            System.out.println("Wrong switch");
            break;
        }
      }
    }

    if (_warning) {
      varTable.setForeground(_display.getSystemColor(SWT.COLOR_RED));
      varTable.setBackground(_display.getSystemColor(SWT.COLOR_YELLOW));
    }

    if (debug) System.out.println("result is OK");
    // org.csstudio.diag.IOCremoteManagement.Activator.errorPrint ("result is OK");
    return true;
  }
  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 JobEntryInterface open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, props.getJobsDialogStyle());
    props.setLook(shell);
    JobDialog.setShellImage(shell, jobEntry);

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

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

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

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

    // Filename line
    wlName = new Label(shell, SWT.RIGHT);
    wlName.setText(BaseMessages.getString(PKG, "JobWaitForFile.Name.Label"));
    props.setLook(wlName);
    fdlName = new FormData();
    fdlName.left = new FormAttachment(0, 0);
    fdlName.right = new FormAttachment(middle, -margin);
    fdlName.top = new FormAttachment(0, margin);
    wlName.setLayoutData(fdlName);
    wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    fdName = new FormData();
    fdName.left = new FormAttachment(middle, 0);
    fdName.top = new FormAttachment(0, margin);
    fdName.right = new FormAttachment(100, 0);
    wName.setLayoutData(fdName);

    // Filename line
    wlFilename = new Label(shell, SWT.RIGHT);
    wlFilename.setText(BaseMessages.getString(PKG, "JobWaitForFile.Filename.Label"));
    props.setLook(wlFilename);
    fdlFilename = new FormData();
    fdlFilename.left = new FormAttachment(0, 0);
    fdlFilename.top = new FormAttachment(wName, margin);
    fdlFilename.right = new FormAttachment(middle, -margin);
    wlFilename.setLayoutData(fdlFilename);

    wbFilename = new Button(shell, SWT.PUSH | SWT.CENTER);
    props.setLook(wbFilename);
    wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
    fdbFilename = new FormData();
    fdbFilename.right = new FormAttachment(100, 0);
    fdbFilename.top = new FormAttachment(wName, 0);
    wbFilename.setLayoutData(fdbFilename);

    wFilename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFilename);
    wFilename.addModifyListener(lsMod);
    fdFilename = new FormData();
    fdFilename.left = new FormAttachment(middle, 0);
    fdFilename.top = new FormAttachment(wName, margin);
    fdFilename.right = new FormAttachment(wbFilename, -margin);
    wFilename.setLayoutData(fdFilename);

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

    wbFilename.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.OPEN);
            dialog.setFilterExtensions(new String[] {"*"});
            if (wFilename.getText() != null) {
              dialog.setFileName(jobMeta.environmentSubstitute(wFilename.getText()));
            }
            dialog.setFilterNames(FILETYPES);
            if (dialog.open() != null) {
              wFilename.setText(
                  dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
            }
          }
        });

    // Maximum timeout
    wlMaximumTimeout = new Label(shell, SWT.RIGHT);
    wlMaximumTimeout.setText(BaseMessages.getString(PKG, "JobWaitForFile.MaximumTimeout.Label"));
    props.setLook(wlMaximumTimeout);
    fdlMaximumTimeout = new FormData();
    fdlMaximumTimeout.left = new FormAttachment(0, 0);
    fdlMaximumTimeout.top = new FormAttachment(wFilename, margin);
    fdlMaximumTimeout.right = new FormAttachment(middle, -margin);
    wlMaximumTimeout.setLayoutData(fdlMaximumTimeout);
    wMaximumTimeout = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wMaximumTimeout);
    wMaximumTimeout.setToolTipText(
        BaseMessages.getString(PKG, "JobWaitForFile.MaximumTimeout.Tooltip"));
    wMaximumTimeout.addModifyListener(lsMod);
    fdMaximumTimeout = new FormData();
    fdMaximumTimeout.left = new FormAttachment(middle, 0);
    fdMaximumTimeout.top = new FormAttachment(wFilename, margin);
    fdMaximumTimeout.right = new FormAttachment(100, 0);
    wMaximumTimeout.setLayoutData(fdMaximumTimeout);

    // Cycle time
    wlCheckCycleTime = new Label(shell, SWT.RIGHT);
    wlCheckCycleTime.setText(BaseMessages.getString(PKG, "JobWaitForFile.CheckCycleTime.Label"));
    props.setLook(wlCheckCycleTime);
    fdlCheckCycleTime = new FormData();
    fdlCheckCycleTime.left = new FormAttachment(0, 0);
    fdlCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
    fdlCheckCycleTime.right = new FormAttachment(middle, -margin);
    wlCheckCycleTime.setLayoutData(fdlCheckCycleTime);
    wCheckCycleTime = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCheckCycleTime);
    wCheckCycleTime.setToolTipText(
        BaseMessages.getString(PKG, "JobWaitForFile.CheckCycleTime.Tooltip"));
    wCheckCycleTime.addModifyListener(lsMod);
    fdCheckCycleTime = new FormData();
    fdCheckCycleTime.left = new FormAttachment(middle, 0);
    fdCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
    fdCheckCycleTime.right = new FormAttachment(100, 0);
    wCheckCycleTime.setLayoutData(fdCheckCycleTime);

    // Success on timeout
    wlSuccesOnTimeout = new Label(shell, SWT.RIGHT);
    wlSuccesOnTimeout.setText(BaseMessages.getString(PKG, "JobWaitForFile.SuccessOnTimeout.Label"));
    props.setLook(wlSuccesOnTimeout);
    fdlSuccesOnTimeout = new FormData();
    fdlSuccesOnTimeout.left = new FormAttachment(0, 0);
    fdlSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
    fdlSuccesOnTimeout.right = new FormAttachment(middle, -margin);
    wlSuccesOnTimeout.setLayoutData(fdlSuccesOnTimeout);
    wSuccesOnTimeout = new Button(shell, SWT.CHECK);
    props.setLook(wSuccesOnTimeout);
    wSuccesOnTimeout.setToolTipText(
        BaseMessages.getString(PKG, "JobWaitForFile.SuccessOnTimeout.Tooltip"));
    fdSuccesOnTimeout = new FormData();
    fdSuccesOnTimeout.left = new FormAttachment(middle, 0);
    fdSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
    fdSuccesOnTimeout.right = new FormAttachment(100, 0);
    wSuccesOnTimeout.setLayoutData(fdSuccesOnTimeout);
    wSuccesOnTimeout.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
          }
        });

    // Check file size
    wlFileSizeCheck = new Label(shell, SWT.RIGHT);
    wlFileSizeCheck.setText(BaseMessages.getString(PKG, "JobWaitForFile.FileSizeCheck.Label"));
    props.setLook(wlFileSizeCheck);
    fdlFileSizeCheck = new FormData();
    fdlFileSizeCheck.left = new FormAttachment(0, 0);
    fdlFileSizeCheck.top = new FormAttachment(wSuccesOnTimeout, margin);
    fdlFileSizeCheck.right = new FormAttachment(middle, -margin);
    wlFileSizeCheck.setLayoutData(fdlFileSizeCheck);
    wFileSizeCheck = new Button(shell, SWT.CHECK);
    props.setLook(wFileSizeCheck);
    wFileSizeCheck.setToolTipText(
        BaseMessages.getString(PKG, "JobWaitForFile.FileSizeCheck.Tooltip"));
    fdFileSizeCheck = new FormData();
    fdFileSizeCheck.left = new FormAttachment(middle, 0);
    fdFileSizeCheck.top = new FormAttachment(wSuccesOnTimeout, margin);
    fdFileSizeCheck.right = new FormAttachment(100, 0);
    wFileSizeCheck.setLayoutData(fdFileSizeCheck);
    wFileSizeCheck.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
          }
        });
    // Add filename to result filenames
    wlAddFilenameResult = new Label(shell, SWT.RIGHT);
    wlAddFilenameResult.setText(
        BaseMessages.getString(PKG, "JobWaitForFile.AddFilenameResult.Label"));
    props.setLook(wlAddFilenameResult);
    fdlAddFilenameResult = new FormData();
    fdlAddFilenameResult.left = new FormAttachment(0, 0);
    fdlAddFilenameResult.top = new FormAttachment(wFileSizeCheck, margin);
    fdlAddFilenameResult.right = new FormAttachment(middle, -margin);
    wlAddFilenameResult.setLayoutData(fdlAddFilenameResult);
    wAddFilenameResult = new Button(shell, SWT.CHECK);
    props.setLook(wAddFilenameResult);
    wAddFilenameResult.setToolTipText(
        BaseMessages.getString(PKG, "JobWaitForFile.AddFilenameResult.Tooltip"));
    fdAddFilenameResult = new FormData();
    fdAddFilenameResult.left = new FormAttachment(middle, 0);
    fdAddFilenameResult.top = new FormAttachment(wFileSizeCheck, margin);
    fdAddFilenameResult.right = new FormAttachment(100, 0);
    wAddFilenameResult.setLayoutData(fdAddFilenameResult);
    wAddFilenameResult.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            jobEntry.setChanged();
          }
        });
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));

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

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

    wName.addSelectionListener(lsDef);
    wFilename.addSelectionListener(lsDef);
    wMaximumTimeout.addSelectionListener(lsDef);
    wCheckCycleTime.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 jobEntry;
  }