コード例 #1
0
  public void createControl(Composite parent) {
    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);

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

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

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

    // set the composite as the control for this page
    setControl(composite);
  }
コード例 #2
0
  public void createControl(Composite parent) {
    int margin = Const.MARGIN;

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

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

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

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

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

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

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

    this.setLayout(formLayout);

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

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

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

    wText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            if (!StringUtils.isNumeric(wText.getText())) {
              wText.setText(lastValidValue);
            } else lastValidValue = wText.getText();
          }
        });
  }
コード例 #4
0
 protected void mainLayout(Class<?> PKG, String prefix, Image img) {
   display = parent.getDisplay();
   shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.APPLICATION_MODAL);
   props.setLook(shell);
   shell.setImage(img);
   shell.setLayout(new FormLayout());
   shell.setText(BaseMessages.getString(PKG, prefix + ".Shell.Title"));
 }
コード例 #5
0
  protected void localOptionsComposite(Class<?> PKG, String prefix) {

    Label localDescriptionLabel = new Label(localOptionsComposite, SWT.NONE);
    props.setLook(localDescriptionLabel);
    localDescriptionLabel.setText(BaseMessages.getString(PKG, prefix + ".LocalHost.Label"));
    FormData fd_localDescriptionLabel = new FormData();
    fd_localDescriptionLabel.left = new FormAttachment(environmentSeparator, 5);
    fd_localDescriptionLabel.top = new FormAttachment(0, 12);
    localDescriptionLabel.setLayoutData(fd_localDescriptionLabel);
  }
コード例 #6
0
  protected void optionsSectionLayout(Class<?> PKG, String prefix) {
    gDetails = new Group(shell, SWT.SHADOW_ETCHED_IN);
    fdLocal.bottom = new FormAttachment(100, -510);
    gDetails.setText(BaseMessages.getString(PKG, prefix + ".DetailsGroup.Label"));
    props.setLook(gDetails);

    // The layout
    gDetails.setLayout(new FormLayout());
    fdDetails = new FormData();
    fdDetails.top = new FormAttachment(gLocal, 15);
    fdDetails.right = new FormAttachment(100, -15);
    fdDetails.left = new FormAttachment(0, 15);
    gDetails.setBackground(shell.getBackground()); // the default looks ugly
    gDetails.setLayoutData(fdDetails);

    optionsSectionControls();
  }
コード例 #7
0
  protected void parametersSectionLayout(Class<?> PKG, String prefix) {

    tabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(tabFolder, Props.WIDGET_STYLE_TAB);
    fdDetails.bottom = new FormAttachment(tabFolder, -16);
    fd_tabFolder = new FormData();
    fd_tabFolder.right = new FormAttachment(100, -15);
    fd_tabFolder.left = new FormAttachment(0, 15);
    fd_tabFolder.top = new FormAttachment(0, 276);
    tabFolder.setLayoutData(fd_tabFolder);

    // Parameters
    CTabItem tbtmParameters = new CTabItem(tabFolder, SWT.NONE);
    tbtmParameters.setText(BaseMessages.getString(PKG, prefix + ".Params.Label"));
    Composite parametersComposite = new Composite(tabFolder, SWT.NONE);
    props.setLook(parametersComposite);

    parametersComposite.setLayout(new FormLayout());
    tbtmParameters.setControl(parametersComposite);

    ColumnInfo[] cParams = {
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Argument"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          126), // Stepname
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Default"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          138), // Preview size
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Value"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          142), // Preview size
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Description"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          181), // Preview size
    };

    String[] namedParams = abstractMeta.listParameters();
    int nrParams = namedParams.length;
    wParams =
        new TableView(
            abstractMeta,
            parametersComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            cParams,
            nrParams,
            false,
            null,
            props,
            false);
    FormData fdParams = new FormData();
    fdParams.top = new FormAttachment(0, 10);
    fdParams.left = new FormAttachment(0, 10);
    wParams.setLayoutData(fdParams);

    tabFolder.setSelection(0);

    Button argsButton = new Button(parametersComposite, SWT.NONE);
    fdParams.right = new FormAttachment(argsButton, 0, SWT.RIGHT);
    fdParams.bottom = new FormAttachment(argsButton, -6);
    FormData fd_argsButton = new FormData();
    fd_argsButton.right = new FormAttachment(100, -10);
    fd_argsButton.bottom = new FormAttachment(100, -10);
    argsButton.setLayoutData(fd_argsButton);
    argsButton.setText(BaseMessages.getString(PKG, prefix + ".Arguments.Label"));

    argsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            new ArgumentsDialog(shell, configuration, abstractMeta);
          }
        });

    // Variables
    CTabItem tbtmVariables = new CTabItem(tabFolder, SWT.NONE);
    tbtmVariables.setText(BaseMessages.getString(PKG, prefix + ".Variables.Label"));

    Composite variablesComposite = new Composite(tabFolder, SWT.NONE);
    props.setLook(variablesComposite);
    variablesComposite.setLayout(new FormLayout());
    tbtmVariables.setControl(variablesComposite);

    ColumnInfo[] cVariables = {
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".VariablesColumn.Argument"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          287), // Stepname
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".VariablesColumn.Value"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          300), // Preview size
    };

    int nrVariables =
        configuration.getVariables() != null ? configuration.getVariables().size() : 0;
    wVariables =
        new TableView(
            abstractMeta,
            variablesComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            cVariables,
            nrVariables,
            false,
            null,
            props,
            false);

    FormData fdVariables = new FormData();
    fdVariables.top = new FormAttachment(0, 10);
    fdVariables.left = new FormAttachment(0, 10);
    fdVariables.bottom = new FormAttachment(0, 221);
    fdVariables.right = new FormAttachment(100, -10);

    wVariables.setLayoutData(fdVariables);
  }
コード例 #8
0
  public Object open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

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

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

    shell.setLayout(formLayout);
    shell.setText(
        BaseMessages.getString(
            PKG, "EnterPreviewRowsDialog.Dialog.PreviewStep.Title")); // Select the preview step:
    shell.setImage(GUIResource.getInstance().getImageLogoSmall());

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

    // Filename line
    wlStepList = new Label(shell, SWT.NONE);
    wlStepList.setText(
        BaseMessages.getString(
            PKG, "EnterPreviewRowsDialog.Dialog.PreviewStep.Message")); // Step name :
    props.setLook(wlStepList);
    fdlStepList = new FormData();
    fdlStepList.left = new FormAttachment(0, 0);
    fdlStepList.top = new FormAttachment(0, margin);
    wlStepList.setLayoutData(fdlStepList);
    wStepList =
        new List(
            shell,
            SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    for (int i = 0; i < stepNames.size(); i++) {
      wStepList.add((String) stepNames.get(i));
    }
    wStepList.select(0);
    props.setLook(wStepList);
    fdStepList = new FormData();
    fdStepList.left = new FormAttachment(middle, 0);
    fdStepList.top = new FormAttachment(0, margin);
    fdStepList.bottom = new FormAttachment(100, -60);
    fdStepList.right = new FormAttachment(100, 0);
    wStepList.setLayoutData(fdStepList);
    wStepList.addSelectionListener(
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent arg0) {
            show();
          }
        });

    wShow = new Button(shell, SWT.PUSH);
    wShow.setText(BaseMessages.getString(PKG, "System.Button.Show"));

    wClose = new Button(shell, SWT.PUSH);
    wClose.setText(BaseMessages.getString(PKG, "System.Button.Close"));

    BaseStepDialog.positionBottomButtons(shell, new Button[] {wShow, wClose}, margin, null);
    // Add listeners
    lsShow =
        new Listener() {
          public void handleEvent(Event e) {
            show();
          }
        };
    lsClose =
        new Listener() {
          public void handleEvent(Event e) {
            close();
          }
        };

    wShow.addListener(SWT.Selection, lsShow);
    wClose.addListener(SWT.Selection, lsClose);

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

    getData();

    BaseStepDialog.setSize(shell);

    // Immediately show the only preview entry
    if (stepNames.size() == 1) {
      wStepList.select(0);
      show();
    }

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    return stepname;
  }
コード例 #9
0
  public String open() {
    this.props = PropsUI.getInstance();
    Display display = shellParent.getDisplay();
    int margin = Const.MARGIN;

    shell = new Shell(shellParent, SWT.DIALOG_TRIM | SWT.CLOSE | SWT.ICON | SWT.APPLICATION_MODAL);

    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());

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

    shell.setText(BaseMessages.getString(PKG, "MissingTransDialog.MissingPlugins"));
    shell.setLayout(formLayout);

    Label image = new Label(shell, SWT.NONE);
    props.setLook(image);
    Image icon = display.getSystemImage(SWT.ICON_QUESTION);
    image.setImage(icon);
    FormData imageData = new FormData();
    imageData.left = new FormAttachment(0, 5);
    imageData.right = new FormAttachment(11, 0);
    imageData.top = new FormAttachment(0, 10);
    image.setLayoutData(imageData);

    Label error = new Label(shell, SWT.WRAP);
    props.setLook(error);
    error.setText(getErrorMessage(missingTrans, mode));
    FormData errorData = new FormData();
    errorData.left = new FormAttachment(image, 5);
    errorData.right = new FormAttachment(100, -5);
    errorData.top = new FormAttachment(0, 10);
    error.setLayoutData(errorData);

    Label separator = new Label(shell, SWT.WRAP);
    props.setLook(separator);
    FormData separatorData = new FormData();
    separatorData.top = new FormAttachment(error, 10);
    separator.setLayoutData(separatorData);

    Button closeButton = new Button(shell, SWT.PUSH);
    props.setLook(closeButton);
    FormData fdClose = new FormData();
    fdClose.right = new FormAttachment(98);
    fdClose.top = new FormAttachment(separator);
    closeButton.setLayoutData(fdClose);
    closeButton.setText(BaseMessages.getString(PKG, "MissingTransDialog.Close"));
    closeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            shell.dispose();
            stepResult = null;
          }
        });

    FormData fdSearch = new FormData();
    if (this.mode == MISSING_TRANS_STEPS) {
      Button openButton = new Button(shell, SWT.PUSH);
      props.setLook(openButton);
      FormData fdOpen = new FormData();
      fdOpen.right = new FormAttachment(closeButton, -5);
      fdOpen.bottom = new FormAttachment(closeButton, 0, SWT.BOTTOM);
      openButton.setLayoutData(fdOpen);
      openButton.setText(BaseMessages.getString(PKG, "MissingTransDialog.OpenFile"));
      openButton.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              shell.dispose();
              stepResult = stepname;
            }
          });
      fdSearch.right = new FormAttachment(openButton, -5);
      fdSearch.bottom = new FormAttachment(openButton, 0, SWT.BOTTOM);
    } else {
      fdSearch.right = new FormAttachment(closeButton, -5);
      fdSearch.bottom = new FormAttachment(closeButton, 0, SWT.BOTTOM);
    }

    Button searchButton = new Button(shell, SWT.PUSH);
    props.setLook(searchButton);
    searchButton.setText(BaseMessages.getString(PKG, "MissingTransDialog.SearchMarketplace"));
    searchButton.setLayoutData(fdSearch);
    searchButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            try {
              shell.dispose();
              Spoon.getInstance().openMarketplace();
            } catch (Exception ex) {
              ex.printStackTrace();
            }
          }
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepResult;
  }
コード例 #10
0
  public boolean open() {
    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSlave());

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

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

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

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

    // First, add the buttons...

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

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

    // The rest stays above the buttons...

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

    addServiceTab();
    addProxyTab();

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

    // Add listeners
    wOK.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        });
    wCancel.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        });

    SelectionAdapter selAdapter =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };
    wUsername.addSelectionListener(selAdapter);
    wPassword.addSelectionListener(selAdapter);
    wHostname.addSelectionListener(selAdapter);
    wPort.addSelectionListener(selAdapter);
    wWebAppName.addSelectionListener(selAdapter);
    wProxyHost.addSelectionListener(selAdapter);
    wProxyPort.addSelectionListener(selAdapter);
    wNonProxyHosts.addSelectionListener(selAdapter);

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

    wTabFolder.setSelection(0);

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();
    Display display = parent.getDisplay();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return ok;
  }
コード例 #11
0
  public RepositoryDirectoryInterface open() {
    dircolor = GUIResource.getInstance().getColorDirectory();

    Shell parent = getParent();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    shell.setText(BaseMessages.getString(PKG, "SelectDirectoryDialog.Dialog.Main.Title"));

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

    shell.setLayout(formLayout);

    // Tree
    wTree = new Tree(shell, SWT.SINGLE | SWT.BORDER);
    props.setLook(wTree);

    try {
      // We're terrible and load the entire repository, disable lazy loading if set
      if (rep instanceof RepositoryExtended) {
        RepositoryExtended repositoryExtended = (RepositoryExtended) this.rep;
        repositoryTree = repositoryExtended.loadRepositoryDirectoryTree(true);
      } else {
        repositoryTree = this.rep.loadRepositoryDirectoryTree();
      }
    } catch (KettleException e) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(
              PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Title"),
          BaseMessages.getString(
              PKG, "SelectDirectoryDialog.Dialog.ErrorRefreshingDirectoryTree.Message"),
          e);
      return null;
    }

    if (!getData()) {
      return null;
    }

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

    wRefresh = new Button(shell, SWT.PUSH);
    wRefresh.setText(BaseMessages.getString(PKG, "System.Button.Refresh"));

    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));

    FormData fdTree = new FormData();
    FormData fdOK = new FormData();
    FormData fdRefresh = new FormData();
    FormData fdCancel = new FormData();

    int margin = 10;

    fdTree.left = new FormAttachment(0, 0); // To the right of the label
    fdTree.top = new FormAttachment(0, 0);
    fdTree.right = new FormAttachment(100, 0);
    fdTree.bottom = new FormAttachment(100, -50);
    wTree.setLayoutData(fdTree);

    fdOK.left = new FormAttachment(wTree, 0, SWT.CENTER);
    fdOK.bottom = new FormAttachment(100, -margin);
    wOK.setLayoutData(fdOK);

    fdRefresh.left = new FormAttachment(wOK, 10);
    fdRefresh.bottom = new FormAttachment(100, -margin);
    wRefresh.setLayoutData(fdRefresh);

    fdCancel.left = new FormAttachment(wRefresh, 10);
    fdCancel.bottom = new FormAttachment(100, -margin);
    wCancel.setLayoutData(fdCancel);

    // Add listeners
    wCancel.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            dispose();
          }
        });

    // Add listeners
    wOK.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            handleOK();
          }
        });

    wTree.addSelectionListener(
        new SelectionAdapter() {
          private String getSelectedPath(SelectionEvent selectionEvent) {
            TreeItem treeItem = (TreeItem) selectionEvent.item;
            String path;
            if (treeItem.getParentItem() == null) {
              path = treeItem.getText();
            } else {
              path = ConstUI.getTreePath(treeItem, 0);
            }
            return path;
          }

          private boolean isSelectedPathRestricted(SelectionEvent selectionEvent) {
            String path = getSelectedPath(selectionEvent);
            boolean isRestricted = isRestrictedPath(path);
            return isRestricted;
          }

          public void widgetDefaultSelected(SelectionEvent selectionEvent) {
            if (isSelectedPathRestricted(selectionEvent)) {
              return;
            }
            handleOK();
          }

          public void widgetSelected(SelectionEvent selectionEvent) {
            boolean restricted = isSelectedPathRestricted(selectionEvent);
            wOK.setEnabled(!restricted);
          }
        });

    wRefresh.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            getData();
          }
        });

    wTree.addMenuDetectListener(
        new MenuDetectListener() {
          public void menuDetected(MenuDetectEvent e) {
            setTreeMenu();
          }
        });

    BaseStepDialog.setSize(shell);

    shell.open();
    Display display = parent.getDisplay();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return selection;
  }
コード例 #12
0
  public Object open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

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

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

    shell.setLayout(formLayout);
    shell.setImage(GUIResource.getInstance().getImageTransGraph());
    shell.setText(shellText);

    int margin = Const.MARGIN;

    // Filename line
    wlStepname = new Label(shell, SWT.NONE);
    wlStepname.setText(originText);
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.READ_ONLY);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(wlStepname, margin);
    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, "StepFieldsDialog.Fields.Label"));
    props.setLook(wlFields);
    fdlFields = new FormData();
    fdlFields.left = new FormAttachment(0, 0);
    fdlFields.top = new FormAttachment(wlStepname, margin);
    wlFields.setLayoutData(fdlFields);

    final int FieldsRows = input.size();

    ColumnInfo[] colinf =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Fieldname"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Type"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Length"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Precision"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Origin"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.StorageType"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.ConversionMask"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Currency"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Decimal"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Group"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.TrimType"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
          new ColumnInfo(
              BaseMessages.getString(PKG, "StepFieldsDialog.TableCol.Comments"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              true),
        };

    wFields =
        new TableView(
            variables,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            colinf,
            FieldsRows,
            true, // read-only
            null,
            props);
    wFields.optWidth(true);

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

    // Add listeners
    lsCancel =
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        };
    lsEdit =
        new Listener() {
          public void handleEvent(Event e) {
            edit();
          }
        };

    Button[] buttons;
    if (showEditButton) {
      wEdit = new Button(shell, SWT.PUSH);
      wEdit.setText(BaseMessages.getString(PKG, "StepFieldsDialog.Buttons.EditOrigin"));
      wEdit.addListener(SWT.Selection, lsEdit);
      wCancel = new Button(shell, SWT.PUSH);
      wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
      wCancel.addListener(SWT.Selection, lsCancel);

      buttons = new Button[] {wEdit, wCancel};
    } else {
      wClose = new Button(shell, SWT.PUSH);
      wClose.setText(BaseMessages.getString(PKG, "System.Button.Close"));
      wClose.addListener(SWT.Selection, lsCancel);
      buttons = new Button[] {wClose};
    }

    BaseStepDialog.positionBottomButtons(shell, buttons, margin, wFields);

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

    wStepname.addSelectionListener(lsDef);

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

    wFields.table.addMouseListener(
        new MouseListener() {
          public void mouseDoubleClick(MouseEvent arg0) {
            edit();
          }

          public void mouseDown(MouseEvent arg0) {}

          public void mouseUp(MouseEvent arg0) {}
        });

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepname;
  }
コード例 #13
0
  protected void environmentTypeSectionLayout(Class<?> PKG, String prefix) {

    gLocal = new Group(shell, SWT.SHADOW_ETCHED_IN);
    gLocal.setText(BaseMessages.getString(PKG, prefix + ".LocalGroup.Label"));
    gLocal.setLayout(new FormLayout());
    props.setLook(gLocal);
    fdLocal = new FormData();
    fdLocal.top = new FormAttachment(0, 15);
    fdLocal.right = new FormAttachment(100, -15);
    fdLocal.left = new FormAttachment(0, 15);

    gLocal.setBackground(shell.getBackground()); // the default looks ugly
    gLocal.setLayoutData(fdLocal);

    wExecLocal = new Button(gLocal, SWT.RADIO);
    wExecLocal.setText(BaseMessages.getString(PKG, prefix + ".ExecLocal.Label"));
    wExecLocal.setToolTipText(BaseMessages.getString(PKG, prefix + ".ExecLocal.Tooltip"));
    props.setLook(wExecLocal);
    fdExecLocal = new FormData();
    fdExecLocal.top = new FormAttachment(11);
    wExecLocal.setLayoutData(fdExecLocal);
    wExecLocal.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            stackedLayout.topControl = localOptionsComposite;
            stackedLayoutComposite.layout();
          }
        });

    wExecRemote = new Button(gLocal, SWT.RADIO);
    wExecRemote.setText(BaseMessages.getString(PKG, prefix + ".ExecRemote.Label"));
    wExecRemote.setToolTipText(BaseMessages.getString(PKG, prefix + ".ExecRemote.Tooltip"));
    props.setLook(wExecRemote);
    fdExecLocal.left = new FormAttachment(wExecRemote, 0, SWT.LEFT);
    fdExecRemote = new FormData();
    fdExecRemote.left = new FormAttachment(0, 10);
    fdExecRemote.top = new FormAttachment(wExecLocal, 7);
    wExecRemote.setLayoutData(fdExecRemote);
    wExecRemote.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            stackedLayout.topControl = serverOptionsComposite;
            stackedLayoutComposite.layout();
          }
        });

    // separator
    environmentSeparator = new Label(gLocal, SWT.SEPARATOR | SWT.VERTICAL);
    FormData fd_environmentSeparator = new FormData();
    fd_environmentSeparator.height = 83;
    fd_environmentSeparator.top = new FormAttachment(wExecLocal, 0, SWT.TOP);
    fd_environmentSeparator.left = new FormAttachment(0, 113);
    environmentSeparator.setLayoutData(fd_environmentSeparator);

    // stacked layout composite
    stackedLayoutComposite = new Composite(gLocal, SWT.NONE);
    props.setLook(stackedLayoutComposite);
    stackedLayout = new StackLayout();
    stackedLayoutComposite.setLayout(stackedLayout);
    FormData fd_stackedLayoutComposite = new FormData();
    fd_stackedLayoutComposite.top = new FormAttachment(0);
    fd_stackedLayoutComposite.left = new FormAttachment(environmentSeparator, 7);
    fd_stackedLayoutComposite.bottom = new FormAttachment(100, -5);
    fd_stackedLayoutComposite.right = new FormAttachment(100, -7);
    stackedLayoutComposite.setLayoutData(fd_stackedLayoutComposite);

    localOptionsComposite = new Composite(stackedLayoutComposite, SWT.NONE);
    localOptionsComposite.setLayout(new FormLayout());
    props.setLook(localOptionsComposite);

    serverOptionsComposite = new Composite(stackedLayoutComposite, SWT.NONE);
    serverOptionsComposite.setLayout(new FormLayout());
    props.setLook(serverOptionsComposite);

    stackedLayout.topControl = localOptionsComposite;

    localOptionsComposite(PKG, prefix);
    serverOptionsComposite(PKG, prefix);
  }
コード例 #14
0
  public void open() {
    shell = new Shell(parentShell, style);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());

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

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

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

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

    if (addFields()) {
      return;
    }

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

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

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

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

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

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

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

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

    getData();

    BaseStepDialog.setSize(shell);

    shell.open();

    if (!waitingForRows) {
      while (!shell.isDisposed()) {
        if (!shell.getDisplay().readAndDispatch()) shell.getDisplay().sleep();
      }
    }
  }
コード例 #15
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public ArgumentsDialog(
      final Shell parent, ExecutionConfiguration configuration, AbstractMeta abstractMeta) {
    super(parent);
    this.configuration = configuration;

    display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.APPLICATION_MODAL);
    props = PropsUI.getInstance();
    props.setLook(shell);
    shell.setImage(parent.getImage());
    shell.setLayout(new FormLayout());
    shell.setText(BaseMessages.getString(PKG, "ArgumentsDialog.Arguments.Label"));

    ColumnInfo[] cArguments = {
      new ColumnInfo(
          BaseMessages.getString(PKG, "ArgumentsDialog.ArgumentsColumn.Argument"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          180), // Argument name
      new ColumnInfo(
          BaseMessages.getString(PKG, "ArgumentsDialog.ArgumentsColumn.Value"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          172), // Actual value
    };

    int nrArguments =
        configuration.getArguments() != null ? configuration.getArguments().size() : 0;

    wArguments =
        new TableView(
            abstractMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            cArguments,
            nrArguments,
            false,
            null,
            props,
            false);

    FormData fd_argumentsTable = new FormData();
    fd_argumentsTable.top = new FormAttachment(0, 15);
    fd_argumentsTable.left = new FormAttachment(0, 15);
    fd_argumentsTable.bottom = new FormAttachment(0, 221);
    fd_argumentsTable.right = new FormAttachment(0, 371);
    wArguments.setLayoutData(fd_argumentsTable);

    Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    FormData fd_separator = new FormData();
    fd_separator.top = new FormAttachment(wArguments, 15);
    fd_separator.right = new FormAttachment(wArguments, 0, SWT.RIGHT);
    fd_separator.left = new FormAttachment(0, 15);
    separator.setLayoutData(fd_separator);

    Button okButton = new Button(shell, SWT.NONE);
    okButton.setText("OK");
    FormData fd_okButton = new FormData();
    fd_okButton.left = new FormAttachment(0, 269);
    okButton.setLayoutData(fd_okButton);
    okButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            ok();
          }
        });

    Button cancelButton = new Button(shell, SWT.NONE);
    fd_okButton.top = new FormAttachment(cancelButton, 0, SWT.TOP);
    fd_okButton.right = new FormAttachment(cancelButton, -4);
    cancelButton.setText("Cancel");
    FormData fd_cancelButton = new FormData();
    fd_cancelButton.top = new FormAttachment(separator, 13);
    fd_cancelButton.right = new FormAttachment(wArguments, 0, SWT.RIGHT);
    cancelButton.setLayoutData(fd_cancelButton);
    cancelButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });

    Button btnHelp = new Button(shell, SWT.NONE);
    btnHelp.setImage(GUIResource.getInstance().getImageHelpWeb());
    btnHelp.setText(BaseMessages.getString(PKG, "System.Button.Help"));
    btnHelp.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.Help"));
    FormData fd_btnHelp = new FormData();
    fd_btnHelp.top = new FormAttachment(separator, 13);
    fd_btnHelp.left = new FormAttachment(separator, 0, SWT.LEFT);
    btnHelp.setLayoutData(fd_btnHelp);
    btnHelp.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent evt) {
            String docUrl = BaseMessages.getString(Spoon.class, "Spoon.ArgumentsDialog.Help");
            String docTitle = BaseMessages.getString(PKG, "ArgumentsDialog.docTitle");
            String docHeader = BaseMessages.getString(PKG, "ArgumentsDialog.docHeader");
            HelpUtils.openHelpDialog(parent.getShell(), docTitle, docUrl, docHeader);
          }
        });

    shell.setSize(394, 319);
    getArgumentsData();
    shell.open();

    Rectangle shellBounds = getParent().getBounds();
    Point dialogSize = shell.getSize();

    shell.setLocation(
        shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
        shellBounds.y + (shellBounds.height - dialogSize.y) / 2);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
コード例 #16
0
  private void addServiceTab() {
    // ////////////////////////
    // START OF DB TAB ///
    // ////////////////////////
    wServiceTab = new CTabItem(wTabFolder, SWT.NONE);
    wServiceTab.setText(BaseMessages.getString(PKG, "SlaveServerDialog.USER_TAB_SERVICE"));

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

    FormLayout GenLayout = new FormLayout();
    GenLayout.marginWidth = Const.FORM_MARGIN;
    GenLayout.marginHeight = Const.FORM_MARGIN;
    wServiceComp.setLayout(GenLayout);

    // What's the name
    Label wlName = new Label(wServiceComp, SWT.RIGHT);
    props.setLook(wlName);
    wlName.setText(BaseMessages.getString(PKG, "SlaveServerDialog.ServerName.Label"));
    FormData fdlName = new FormData();
    fdlName.top = new FormAttachment(0, 0);
    fdlName.left = new FormAttachment(0, 0); // First one in the left top corner
    fdlName.right = new FormAttachment(middle, -margin);
    wlName.setLayoutData(fdlName);

    wName = new Text(wServiceComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wName);
    wName.addModifyListener(lsMod);
    FormData fdName = new FormData();
    fdName.top = new FormAttachment(0, 0);
    fdName.left = new FormAttachment(middle, 0); // To the right of the label
    fdName.right = new FormAttachment(95, 0);
    wName.setLayoutData(fdName);

    // What's the hostname
    Label wlHostname = new Label(wServiceComp, SWT.RIGHT);
    props.setLook(wlHostname);
    wlHostname.setText(BaseMessages.getString(PKG, "SlaveServerDialog.HostIP.Label"));
    FormData fdlHostname = new FormData();
    fdlHostname.top = new FormAttachment(wName, margin * 2);
    fdlHostname.left = new FormAttachment(0, 0); // First one in the left top corner
    fdlHostname.right = new FormAttachment(middle, -margin);
    wlHostname.setLayoutData(fdlHostname);

    wHostname = new TextVar(slaveServer, wServiceComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wHostname);
    wHostname.addModifyListener(lsMod);
    FormData fdHostname = new FormData();
    fdHostname.top = new FormAttachment(wName, margin * 2);
    fdHostname.left = new FormAttachment(middle, 0); // To the right of the label
    fdHostname.right = new FormAttachment(95, 0);
    wHostname.setLayoutData(fdHostname);

    // What's the service URL?
    Label wlPort = new Label(wServiceComp, SWT.RIGHT);
    props.setLook(wlPort);
    wlPort.setText(BaseMessages.getString(PKG, "SlaveServerDialog.Port.Label"));
    FormData fdlPort = new FormData();
    fdlPort.top = new FormAttachment(wHostname, margin);
    fdlPort.left = new FormAttachment(0, 0); // First one in the left top corner
    fdlPort.right = new FormAttachment(middle, -margin);
    wlPort.setLayoutData(fdlPort);

    wPort = new TextVar(slaveServer, wServiceComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPort);
    wPort.addModifyListener(lsMod);
    FormData fdPort = new FormData();
    fdPort.top = new FormAttachment(wHostname, margin);
    fdPort.left = new FormAttachment(middle, 0); // To the right of the label
    fdPort.right = new FormAttachment(95, 0);
    wPort.setLayoutData(fdPort);

    // webapp name (optional)
    Label wlWebAppName = new Label(wServiceComp, SWT.RIGHT);
    wlWebAppName.setText(BaseMessages.getString(PKG, "SlaveServerDialog.WebAppName.Label"));
    props.setLook(wlWebAppName);
    FormData fdlWebAppName = new FormData();
    fdlWebAppName.top = new FormAttachment(wPort, margin);
    fdlWebAppName.left = new FormAttachment(0, 0);
    fdlWebAppName.right = new FormAttachment(middle, -margin);
    wlWebAppName.setLayoutData(fdlWebAppName);

    wWebAppName = new TextVar(slaveServer, wServiceComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wWebAppName);
    wWebAppName.addModifyListener(lsMod);
    FormData fdWebAppName = new FormData();
    fdWebAppName.top = new FormAttachment(wPort, margin);
    fdWebAppName.left = new FormAttachment(middle, 0);
    fdWebAppName.right = new FormAttachment(95, 0);
    wWebAppName.setLayoutData(fdWebAppName);

    // Username
    Label wlUsername = new Label(wServiceComp, SWT.RIGHT);
    wlUsername.setText(BaseMessages.getString(PKG, "SlaveServerDialog.UserName.Label"));
    props.setLook(wlUsername);
    FormData fdlUsername = new FormData();
    fdlUsername.top = new FormAttachment(wWebAppName, margin);
    fdlUsername.left = new FormAttachment(0, 0);
    fdlUsername.right = new FormAttachment(middle, -margin);
    wlUsername.setLayoutData(fdlUsername);

    wUsername = new TextVar(slaveServer, wServiceComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wUsername);
    wUsername.addModifyListener(lsMod);
    FormData fdUsername = new FormData();
    fdUsername.top = new FormAttachment(wWebAppName, margin);
    fdUsername.left = new FormAttachment(middle, 0);
    fdUsername.right = new FormAttachment(95, 0);
    wUsername.setLayoutData(fdUsername);

    // Password
    Label wlPassword = new Label(wServiceComp, SWT.RIGHT);
    wlPassword.setText(BaseMessages.getString(PKG, "SlaveServerDialog.Password.Label"));
    props.setLook(wlPassword);
    FormData fdlPassword = new FormData();
    fdlPassword.top = new FormAttachment(wUsername, margin);
    fdlPassword.left = new FormAttachment(0, 0);
    fdlPassword.right = new FormAttachment(middle, -margin);
    wlPassword.setLayoutData(fdlPassword);

    wPassword = new PasswordTextVar(slaveServer, wServiceComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wPassword);
    wPassword.addModifyListener(lsMod);
    FormData fdPassword = new FormData();
    fdPassword.top = new FormAttachment(wUsername, margin);
    fdPassword.left = new FormAttachment(middle, 0);
    fdPassword.right = new FormAttachment(95, 0);
    wPassword.setLayoutData(fdPassword);

    // Master
    Label wlMaster = new Label(wServiceComp, SWT.RIGHT);
    wlMaster.setText(BaseMessages.getString(PKG, "SlaveServerDialog.IsTheMaster.Label"));
    props.setLook(wlMaster);
    FormData fdlMaster = new FormData();
    fdlMaster.top = new FormAttachment(wPassword, margin);
    fdlMaster.left = new FormAttachment(0, 0);
    fdlMaster.right = new FormAttachment(middle, -margin);
    wlMaster.setLayoutData(fdlMaster);

    wMaster = new Button(wServiceComp, SWT.CHECK);
    props.setLook(wMaster);
    FormData fdMaster = new FormData();
    fdMaster.top = new FormAttachment(wPassword, margin);
    fdMaster.left = new FormAttachment(middle, 0);
    fdMaster.right = new FormAttachment(95, 0);
    wMaster.setLayoutData(fdMaster);

    // Https
    Control lastControl = wMaster;
    Label wlSSL = new Label(wServiceComp, SWT.RIGHT);
    wlSSL.setText(BaseMessages.getString(PKG, "SlaveServerDialog.UseSsl.Label"));
    props.setLook(wlSSL);
    FormData fd = new FormData();
    fd.top = new FormAttachment(lastControl, margin);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    wlSSL.setLayoutData(fd);
    wlSSL.setVisible(false); // future functional

    wSSL = new Button(wServiceComp, SWT.CHECK);
    props.setLook(wSSL);
    FormData bfd = new FormData();
    bfd.top = new FormAttachment(lastControl, margin);
    bfd.left = new FormAttachment(middle, 0);
    bfd.right = new FormAttachment(95, 0);
    wSSL.setLayoutData(bfd);
    wSSL.setVisible(false); // future functional

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

    wServiceComp.layout();
    wServiceTab.setControl(wServiceComp);

    // ///////////////////////////////////////////////////////////
    // / END OF GEN TAB
    // ///////////////////////////////////////////////////////////
  }
コード例 #17
0
  public MappingEditor(
      Shell shell,
      Composite parent,
      ConfigurationProducer configProducer,
      FieldProducer fieldProducer,
      int tableViewStyle,
      boolean allowTableCreate,
      PropsUI props,
      TransMeta transMeta) {
    //    super(parent, SWT.NO_BACKGROUND | SWT.NO_FOCUS | SWT.NO_MERGE_PAINTS);
    super(parent, SWT.NONE);

    m_shell = shell;
    m_parent = parent;
    m_transMeta = transMeta;
    boolean showConnectWidgets = false;
    m_configProducer = configProducer;
    if (m_configProducer != null) {
      m_currentConfiguration = m_configProducer.getCurrentConfiguration();
    } else {
      showConnectWidgets = true;
      m_configProducer = this;
    }

    m_incomingFieldsProducer = fieldProducer;

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

    FormLayout controlLayout = new FormLayout();
    /*controlLayout.marginLeft = 0;
    controlLayout.marginRight = 0;
    controlLayout.marginTop = 0;
    controlLayout.marginBottom = 0; */
    controlLayout.marginWidth = 3;
    controlLayout.marginHeight = 3;

    setLayout(controlLayout);
    props.setLook(this);

    if (showConnectWidgets) {
      Label zooHostLab = new Label(this, SWT.RIGHT);
      zooHostLab.setText("Zookeeper host");
      props.setLook(zooHostLab);
      FormData fd = new FormData();
      fd.left = new FormAttachment(0, 0);
      fd.top = new FormAttachment(0, margin);
      fd.right = new FormAttachment(middle, -margin);
      zooHostLab.setLayoutData(fd);

      m_zookeeperHostText = new TextVar(transMeta, this, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
      props.setLook(m_zookeeperHostText);
      fd = new FormData();
      fd.left = new FormAttachment(middle, 0);
      fd.top = new FormAttachment(0, margin);
      fd.right = new FormAttachment(100, 0);
      m_zookeeperHostText.setLayoutData(fd);

      Label zooPortLab = new Label(this, SWT.RIGHT);
      zooPortLab.setText("Zookeeper port");
      props.setLook(zooPortLab);
      fd = new FormData();
      fd.left = new FormAttachment(0, 0);
      fd.top = new FormAttachment(m_zookeeperHostText, margin);
      fd.right = new FormAttachment(middle, -margin);
      zooPortLab.setLayoutData(fd);

      m_zookeeperPortText = new TextVar(transMeta, this, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
      props.setLook(m_zookeeperPortText);
      fd = new FormData();
      fd.left = new FormAttachment(middle, 0);
      fd.top = new FormAttachment(m_zookeeperHostText, margin);
      fd.right = new FormAttachment(100, 0);
      m_zookeeperPortText.setLayoutData(fd);

      m_currentConfiguration = m_configProducer.getCurrentConfiguration();
    }

    // table names
    Label tableNameLab = new Label(this, SWT.RIGHT);
    tableNameLab.setText(Messages.getString("MappingDialog.TableName.Label"));
    props.setLook(tableNameLab);
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    if (showConnectWidgets) {
      fd.top = new FormAttachment(m_zookeeperPortText, margin);
    } else {
      fd.top = new FormAttachment(0, margin);
    }
    fd.right = new FormAttachment(middle, -margin);
    tableNameLab.setLayoutData(fd);

    /*    m_existingTableNamesBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_existingTableNamesBut);
    m_existingTableNamesBut.setText("Get existing table names");
    fd = new FormData();
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(0, 0);
    m_existingTableNamesBut.setLayoutData(fd); */

    m_existingTableNamesCombo = new CCombo(this, SWT.BORDER);
    props.setLook(m_existingTableNamesCombo);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    if (showConnectWidgets) {
      fd.top = new FormAttachment(m_zookeeperPortText, margin);
    } else {
      fd.top = new FormAttachment(0, margin);
    }
    fd.right = new FormAttachment(100, 0);
    m_existingTableNamesCombo.setLayoutData(fd);

    // allow or disallow table creation by enabling/disabling the ability
    // to type into this combo
    m_existingTableNamesCombo.setEditable(m_allowTableCreate);

    // mapping names
    Label mappingNameLab = new Label(this, SWT.RIGHT);
    mappingNameLab.setText(Messages.getString("MappingDialog.MappingName.Label"));
    props.setLook(tableNameLab);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(m_existingTableNamesCombo, margin);
    fd.right = new FormAttachment(middle, -margin);
    mappingNameLab.setLayoutData(fd);

    /*m_existingMappingNamesBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_existingMappingNamesBut);
    m_existingMappingNamesBut.setText("Get mapping names");
    fd = new FormData();
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(m_existingTableNamesCombo, 0);
    m_existingMappingNamesBut.setLayoutData(fd); */

    m_existingMappingNamesCombo = new CCombo(this, SWT.BORDER);
    props.setLook(m_existingMappingNamesCombo);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.top = new FormAttachment(m_existingTableNamesCombo, margin);
    // fd.right = new FormAttachment(m_existingMappingNamesBut, -margin);
    fd.right = new FormAttachment(100, 0);
    m_existingMappingNamesCombo.setLayoutData(fd);

    m_existingTableNamesCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            m_familiesInvalidated = true;
            populateMappingComboAndFamilyStuff();
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            m_familiesInvalidated = true;
            populateMappingComboAndFamilyStuff();
          }
        });

    m_existingTableNamesCombo.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            m_familiesInvalidated = true;
          }
        });

    m_existingTableNamesCombo.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            populateTableCombo(false);
          }

          public void focusLost(FocusEvent e) {
            m_familiesInvalidated = true;
            populateMappingComboAndFamilyStuff();
          }
        });

    m_existingMappingNamesCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            loadTableViewFromMapping();
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            loadTableViewFromMapping();
          }
        });

    // fields
    ColumnInfo[] colinf =
        new ColumnInfo[] {
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_ALIAS"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_KEY"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              true),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_FAMILY"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              true),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_NAME"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_TYPE"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              true),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_INDEXED"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
        };

    m_keyCI = colinf[1];
    m_keyCI.setComboValues(new String[] {"N", "Y"});
    m_familyCI = colinf[2];
    m_familyCI.setComboValues(new String[] {""});
    m_typeCI = colinf[4];
    // default types for non-key fields
    m_typeCI.setComboValues(
        new String[] {
          "String",
          "Integer",
          "Long",
          "Float",
          "Double",
          "Date",
          "BigNumber",
          "Serializable",
          "Binary"
        });

    m_keyCI.setComboValuesSelectionListener(
        new ComboValuesSelectionListener() {
          public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {

            tableItem.setText(5, "");
            return m_keyCI.getComboValues();
          }
        });

    m_typeCI.setComboValuesSelectionListener(
        new ComboValuesSelectionListener() {
          public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {
            String[] comboValues = null;

            String keyOrNot = tableItem.getText(2);
            if (Const.isEmpty(keyOrNot) || keyOrNot.equalsIgnoreCase("N")) {
              comboValues =
                  new String[] {
                    "String",
                    "Integer",
                    "Long",
                    "Float",
                    "Double",
                    "Boolean",
                    "Date",
                    "BigNumber",
                    "Serializable",
                    "Binary"
                  };
            } else {
              comboValues =
                  new String[] {
                    "String",
                    "Integer",
                    "UnsignedInteger",
                    "Long",
                    "UnsignedLong",
                    "Date",
                    "UnsignedDate",
                    "Binary"
                  };
            }

            return comboValues;
          }
        });

    m_saveBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_saveBut);
    m_saveBut.setText(Messages.getString("MappingDialog.SaveMapping"));
    fd = new FormData();
    fd.left = new FormAttachment(0, margin);
    fd.bottom = new FormAttachment(100, -margin * 2);
    m_saveBut.setLayoutData(fd);

    m_saveBut.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            saveMapping();
          }
        });

    m_deleteBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_deleteBut);
    m_deleteBut.setText(Messages.getString("MappingDialog.DeleteMapping"));
    fd = new FormData();
    fd.left = new FormAttachment(m_saveBut, margin);
    fd.bottom = new FormAttachment(100, -margin * 2);
    m_deleteBut.setLayoutData(fd);
    m_deleteBut.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            deleteMapping();
          }
        });

    if (m_allowTableCreate) {
      m_getFieldsBut = new Button(this, SWT.PUSH | SWT.CENTER);
      props.setLook(m_getFieldsBut);
      m_getFieldsBut.setText(Messages.getString("MappingDialog.GetIncomingFields"));
      fd = new FormData();
      // fd.left = new FormAttachment(0, margin);
      fd.right = new FormAttachment(100, 0);
      fd.bottom = new FormAttachment(100, -margin * 2);
      m_getFieldsBut.setLayoutData(fd);

      m_getFieldsBut.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              populateTableWithIncomingFields();
            }
          });
    } else {

      m_keyValueTupleBut = new Button(this, SWT.PUSH | SWT.CENTER);
      props.setLook(m_keyValueTupleBut);
      m_keyValueTupleBut.setText(Messages.getString("MappingDialog.KeyValueTemplate"));
      m_keyValueTupleBut.setToolTipText(
          Messages.getString("MappingDialog.KeyValueTemplate.TipText"));
      fd = new FormData();
      // fd.left = new FormAttachment(0, margin);
      fd.right = new FormAttachment(100, 0);
      fd.bottom = new FormAttachment(100, -margin * 2);
      m_keyValueTupleBut.setLayoutData(fd);

      m_keyValueTupleBut.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              populateTableWithTupleTemplate();
            }
          });

      /*      colinf[0].setReadOnly(true);
      colinf[1].setReadOnly(true);
      colinf[2].setReadOnly(true);
      colinf[4].setReadOnly(true); */
    }

    m_fieldsView = new TableView(transMeta, this, tableViewStyle, colinf, 1, null, props);

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

    // --
    // layout();
    // pack();
  }
コード例 #18
0
  private void addProxyTab() {
    // ////////////////////////
    // START OF POOL TAB///
    // /
    wProxyTab = new CTabItem(wTabFolder, SWT.NONE);
    wProxyTab.setText(BaseMessages.getString(PKG, "SlaveServerDialog.USER_TAB_PROXY"));

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

    wProxyComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wProxyComp);
    wProxyComp.setLayout(poolLayout);

    // What's the data tablespace name?
    Label wlProxyHost = new Label(wProxyComp, SWT.RIGHT);
    props.setLook(wlProxyHost);
    wlProxyHost.setText(BaseMessages.getString(PKG, "SlaveServerDialog.ProxyServerName.Label"));
    FormData fdlProxyHost = new FormData();
    fdlProxyHost.top = new FormAttachment(0, 0);
    fdlProxyHost.left = new FormAttachment(0, 0); // First one in the left top corner
    fdlProxyHost.right = new FormAttachment(middle, -margin);
    wlProxyHost.setLayoutData(fdlProxyHost);

    wProxyHost = new TextVar(slaveServer, wProxyComp, SWT.BORDER | SWT.LEFT | SWT.SINGLE);
    props.setLook(wProxyHost);
    wProxyHost.addModifyListener(lsMod);
    FormData fdProxyHost = new FormData();
    fdProxyHost.top = new FormAttachment(0, 0);
    fdProxyHost.left = new FormAttachment(middle, 0); // To the right of the label
    fdProxyHost.right = new FormAttachment(95, 0);
    wProxyHost.setLayoutData(fdProxyHost);

    // What's the initial pool size
    Label wlProxyPort = new Label(wProxyComp, SWT.RIGHT);
    props.setLook(wlProxyPort);
    wlProxyPort.setText(BaseMessages.getString(PKG, "SlaveServerDialog.ProxyServerPort.Label"));
    FormData fdlProxyPort = new FormData();
    fdlProxyPort.top = new FormAttachment(wProxyHost, margin);
    fdlProxyPort.left = new FormAttachment(0, 0); // First one in the left top corner
    fdlProxyPort.right = new FormAttachment(middle, -margin);
    wlProxyPort.setLayoutData(fdlProxyPort);

    wProxyPort = new TextVar(slaveServer, wProxyComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wProxyPort);
    wProxyPort.addModifyListener(lsMod);
    FormData fdProxyPort = new FormData();
    fdProxyPort.top = new FormAttachment(wProxyHost, margin);
    fdProxyPort.left = new FormAttachment(middle, 0); // To the right of the label
    fdProxyPort.right = new FormAttachment(95, 0);
    wProxyPort.setLayoutData(fdProxyPort);

    // What's the maximum pool size
    Label wlNonProxyHosts = new Label(wProxyComp, SWT.RIGHT);
    props.setLook(wlNonProxyHosts);
    wlNonProxyHosts.setText(
        BaseMessages.getString(PKG, "SlaveServerDialog.IgnoreProxyForHosts.Label"));
    FormData fdlNonProxyHosts = new FormData();
    fdlNonProxyHosts.top = new FormAttachment(wProxyPort, margin);
    fdlNonProxyHosts.left = new FormAttachment(0, 0); // First one in the left top corner
    fdlNonProxyHosts.right = new FormAttachment(middle, -margin);
    wlNonProxyHosts.setLayoutData(fdlNonProxyHosts);

    wNonProxyHosts = new TextVar(slaveServer, wProxyComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wNonProxyHosts);
    wNonProxyHosts.addModifyListener(lsMod);
    FormData fdNonProxyHosts = new FormData();
    fdNonProxyHosts.top = new FormAttachment(wProxyPort, margin);
    fdNonProxyHosts.left = new FormAttachment(middle, 0); // To the right of the label
    fdNonProxyHosts.right = new FormAttachment(95, 0);
    wNonProxyHosts.setLayoutData(fdNonProxyHosts);

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

    wProxyComp.layout();
    wProxyTab.setControl(wProxyComp);
  }
コード例 #19
0
  public SAPFunction open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    int middle = Const.MIDDLE_PCT;
    int margin = Const.MARGIN;

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

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

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

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

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

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

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

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

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

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

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

    getData();

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

    shell.open();

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

    return function;
  }
コード例 #20
0
  protected void buttonsSectionLayout(
      Class<?> PKG,
      String prefix,
      final String docTitle,
      final String docUrl,
      final String docHeader) {

    // Bottom buttons and separator

    Button alwaysShowOption = new Button(shell, SWT.CHECK);
    props.setLook(alwaysShowOption);
    fd_tabFolder.bottom = new FormAttachment(100, -106);
    alwaysShowOption.setSelection(abstractMeta.isAlwaysShowRunOptions());

    alwaysShowOption.setToolTipText(BaseMessages.getString(PKG, prefix + ".alwaysShowOption"));

    alwaysShowOption.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Button btn = (Button) e.getSource();
            alwaysShowRunOptions = btn.getSelection();
          }
        });

    FormData fd_alwaysShowOption = new FormData();
    fd_alwaysShowOption.left = new FormAttachment(0, 15);
    fd_alwaysShowOption.top = new FormAttachment(tabFolder, 15);
    alwaysShowOption.setLayoutData(fd_alwaysShowOption);
    alwaysShowOption.setText(BaseMessages.getString(PKG, prefix + ".AlwaysOption.Value"));

    wCancel = new Button(shell, SWT.PUSH);
    FormData fd_wCancel = new FormData();
    wCancel.setLayoutData(fd_wCancel);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            cancel();
          }
        });

    wOK = new Button(shell, SWT.PUSH);
    FormData fd_wOK = new FormData();
    fd_wOK.top = new FormAttachment(wCancel, 0, SWT.TOP);
    fd_wOK.right = new FormAttachment(wCancel, -5);
    wOK.setLayoutData(fd_wOK);
    wOK.setText(BaseMessages.getString(PKG, prefix + ".Button.Launch"));
    wOK.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            ok();
          }
        });

    Button btnHelp = new Button(shell, SWT.NONE);
    btnHelp.setImage(GUIResource.getInstance().getImageHelpWeb());
    btnHelp.setText(BaseMessages.getString(PKG, "System.Button.Help"));
    btnHelp.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.Help"));
    FormData fd_btnHelp = new FormData();
    fd_btnHelp.left = new FormAttachment(0, 15);
    btnHelp.setLayoutData(fd_btnHelp);
    btnHelp.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent evt) {
            HelpUtils.openHelpDialog(parent.getShell(), docTitle, docUrl, docHeader);
          }
        });

    Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    fd_wCancel.top = new FormAttachment(separator, 15);
    fd_btnHelp.top = new FormAttachment(separator, 15);
    fd_wCancel.right = new FormAttachment(separator, 0, SWT.RIGHT);
    FormData fd_separator = new FormData();
    fd_separator.right = new FormAttachment(100, -15);
    fd_separator.left = new FormAttachment(0, 15);
    fd_separator.top = new FormAttachment(alwaysShowOption, 15);
    fd_separator.bottom = new FormAttachment(alwaysShowOption, 17, SWT.BOTTOM);
    separator.setLayoutData(fd_separator);
  }
コード例 #21
0
  private boolean addFields() {
    // int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    if (wlFields == null) {
      wlFields = new Label(shell, SWT.LEFT);
      wlFields.setText(message);
      props.setLook(wlFields);
      fdlFields = new FormData();
      fdlFields.left = new FormAttachment(0, 0);
      fdlFields.right = new FormAttachment(100, 0);
      fdlFields.top = new FormAttachment(0, margin);
      wlFields.setLayoutData(fdlFields);
    } else {
      wFields.dispose();
    }

    if (dynamic && rowMeta == null) {
      rowMeta = new RowMeta();
      rowMeta.addValueMeta(new ValueMeta("<waiting for rows>", ValueMetaInterface.TYPE_STRING));
      waitingForRows = true;
    }
    if (!dynamic) {
      // Mmm, if we don't get any rows in the buffer: show a dialog box.
      if (buffer == null || buffer.size() == 0) {
        ShowMessageDialog dialog =
            new ShowMessageDialog(
                shell,
                SWT.OK | SWT.ICON_WARNING,
                BaseMessages.getString(PKG, "PreviewRowsDialog.NoRows.Text"),
                BaseMessages.getString(PKG, "PreviewRowsDialog.NoRows.Message"));
        dialog.open();
        shell.dispose();
        return true;
      }
    }

    // ColumnInfo[] colinf = new ColumnInfo[rowMeta==null ? 0 : rowMeta.size()];
    ColumnInfo[] colinf = new ColumnInfo[rowMeta.size()];
    for (int i = 0; i < rowMeta.size(); i++) {
      ValueMetaInterface v = rowMeta.getValueMeta(i);
      colinf[i] = new ColumnInfo(v.getName(), ColumnInfo.COLUMN_TYPE_TEXT, v.isNumeric());
      colinf[i].setToolTip(v.toStringMeta());
      colinf[i].setValueMeta(v);
    }

    wFields =
        new TableView(
            variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 0, null, 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);

    if (dynamic) {
      shell.layout(true, true);
    }

    return false;
  }
コード例 #22
0
  public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell =
        new Shell(
            parent,
            SWT.DIALOG_TRIM
                | (modal ? SWT.APPLICATION_MODAL | SWT.SHEET : SWT.NONE)
                | SWT.RESIZE
                | SWT.MIN
                | SWT.MAX);
    props.setLook(shell);

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

    shell.setLayout(formLayout);
    shell.setText(shellText);
    shell.setImage(GUIResource.getInstance().getImageSpoon());

    int margin = Const.MARGIN;

    if (quickSearch) {
      ToolBar treeTb = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT);
      props.setLook(treeTb);

      ToolItem wtfilter = new ToolItem(treeTb, SWT.SEPARATOR);
      Label wlfilter = new Label(treeTb, SWT.SEARCH);
      props.setLook(wlfilter);
      wlfilter.setText(BaseMessages.getString(PKG, "EnterSelectionDialog.FilterString.Label"));
      wtfilter.setControl(wlfilter);
      if (Const.isOSX()) {
        wtfilter.setWidth(100);
      } else {
        wtfilter.setWidth(70);
      }

      wfilter = new ToolItem(treeTb, SWT.SEPARATOR);
      searchText = new Text(treeTb, SWT.SEARCH | SWT.CANCEL);
      props.setLook(searchText);
      searchText.setToolTipText(
          BaseMessages.getString(PKG, "EnterSelectionDialog.FilterString.ToolTip"));
      wfilter.setControl(searchText);
      wfilter.setWidth(120);

      wbRegex = new ToolItem(treeTb, SWT.CHECK);
      wbRegex.setImage(GUIResource.getInstance().getImageRegexSmall());
      wbRegex.setToolTipText(BaseMessages.getString(PKG, "EnterSelectionDialog.useRegEx.Tooltip"));

      goSearch = new ToolItem(treeTb, SWT.PUSH);
      goSearch.setImage(GUIResource.getInstance().getImageSearchSmall());
      goSearch.setToolTipText(BaseMessages.getString(PKG, "EnterSelectionDialog.refresh.Label"));

      goSearch.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent event) {
              updateFilter();
            }
          });

      if (this.databasesInterface != null) {
        addConnection = new ToolItem(treeTb, SWT.PUSH);
        addConnection.setImage(GUIResource.getInstance().getImageAdd());
        addConnection.setToolTipText(BaseMessages.getString(PKG, "Add.Datasource.Label"));

        addConnection.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent event) {
                addDataSource();
              }
            });
      }

      FormData fd = new FormData();
      fd.right = new FormAttachment(100, -margin);
      fd.top = new FormAttachment(0, margin);
      treeTb.setLayoutData(fd);

      searchText.addSelectionListener(
          new SelectionAdapter() {
            public void widgetDefaultSelected(SelectionEvent e) {
              updateFilter();
            }
          });

      // From step line
      wlSelection = new Label(shell, SWT.NONE);
      wlSelection.setText(lineText);
      props.setLook(wlSelection);
      fdlSelection = new FormData();
      fdlSelection.left = new FormAttachment(0, 0);
      fdlSelection.top = new FormAttachment(treeTb, margin);
      wlSelection.setLayoutData(fdlSelection);
    } else {
      // From step line
      wlSelection = new Label(shell, SWT.NONE);
      wlSelection.setText(lineText);
      props.setLook(wlSelection);
      fdlSelection = new FormData();
      fdlSelection.left = new FormAttachment(0, 0);
      wlSelection.setLayoutData(fdlSelection);
    }

    int options = SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
    if (multi) {
      options |= SWT.MULTI;
    } else {
      options |= SWT.SINGLE;
    }

    wSelection = new List(shell, options);
    for (int i = 0; i < choices.length; i++) {
      wSelection.add(choices[i]);
    }
    if (selectedNrs != null) {
      wSelection.select(selectedNrs);
      wSelection.showSelection();
    }
    if (fixed) {
      props.setLook(wSelection, Props.WIDGET_STYLE_FIXED);
    } else {
      props.setLook(wSelection);
    }

    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    if (viewOnly) {
      wOK.setText(BaseMessages.getString(PKG, "System.Button.Close"));
    } else {
      wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    }
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };
    wOK.addListener(SWT.Selection, lsOK);

    Button[] buttons = new Button[] {wOK};

    if (!viewOnly) {
      wCancel = new Button(shell, SWT.PUSH);
      wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
      lsCancel =
          new Listener() {
            public void handleEvent(Event e) {
              cancel();
            }
          };
      wCancel.addListener(SWT.Selection, lsCancel);

      buttons = new Button[] {wOK, wCancel};
    }

    BaseStepDialog.positionBottomButtons(shell, buttons, margin, null);

    fdSelection = new FormData();
    fdSelection.left = new FormAttachment(0, 0);
    fdSelection.right = new FormAttachment(100, 0);
    fdSelection.top = new FormAttachment(wlSelection, margin);
    fdSelection.bottom = new FormAttachment(wOK, -margin * 3);
    wSelection.setLayoutData(fdSelection);

    // Add listeners

    lsDef =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };
    wSelection.addSelectionListener(lsDef);
    wSelection.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
              ok();
            }
          }
        });
    // 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);

    wOK.setFocus();

    shell.open();

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