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);
  }
  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();
          }
        });
  }
 public void dispose() {
   props.setScreen(new WindowProperty(shell));
   bounds = shell.getBounds();
   hscroll = wFields.getHorizontalBar().getSelection();
   vscroll = wFields.getVerticalBar().getSelection();
   shell.dispose();
 }
  public PreviewRowsDialog(
      Shell parent,
      VariableSpace space,
      int style,
      String stepName,
      RowMetaInterface rowMeta,
      List<Object[]> rowBuffer,
      String loggingText) {
    this.stepname = stepName;
    this.buffer = rowBuffer;
    this.loggingText = loggingText;
    this.rowMeta = rowMeta;
    this.variables = space;
    this.parentShell = parent;
    this.style = (style != SWT.None) ? style : this.style;
    this.dialogClosedListeners = new ArrayList<DialogClosedListener>();

    props = PropsUI.getInstance();
    bounds = null;
    hscroll = -1;
    vscroll = -1;
    title = null;
    message = null;

    this.log = new LogChannel("Row Preview");
  }
Пример #6
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"));
 }
  public SelectDirectoryDialog(Shell parent, int style, Repository rep) {
    super(parent, style);
    this.props = PropsUI.getInstance();
    this.rep = rep;

    selection = null;

    readOnly = rep.getSecurityProvider().isReadOnly();
  }
Пример #8
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);
  }
Пример #9
0
  public CopyTableWizardPage1(String arg, java.util.List<DatabaseMeta> databases) {
    super(arg);
    this.props = PropsUI.getInstance();
    this.databases = databases;

    setTitle(BaseMessages.getString(PKG, "CopyTableWizardPage1.Dialog.Title"));
    setDescription(BaseMessages.getString(PKG, "CopyTableWizardPage1.Dialog.Description"));

    setPageComplete(false);
  }
 public SlaveServerDialog(
     Shell par, SlaveServer slaveServer, Collection<SlaveServer> existingServers) {
   super(par, SWT.NONE);
   this.slaveServer = (SlaveServer) slaveServer.clone();
   this.slaveServer.shareVariablesWith(slaveServer);
   this.originalServer = slaveServer;
   this.existingServers = existingServers;
   props = PropsUI.getInstance();
   ok = false;
 }
  public StepFieldsDialog(
      Shell parent, VariableSpace space, int style, String stepname, RowMetaInterface input) {
    super(parent, style);
    this.stepname = stepname;
    this.input = input;
    this.variables = space;
    props = PropsUI.getInstance();

    shellText = BaseMessages.getString(PKG, "StepFieldsDialog.Title");
    originText = BaseMessages.getString(PKG, "StepFieldsDialog.Name.Label");
    showEditButton = true;
  }
Пример #12
0
 public EnterPreviewRowsDialog(
     Shell parent,
     int style,
     java.util.List<String> stepNames,
     java.util.List<RowMetaInterface> rowMetas,
     java.util.List<java.util.List<Object[]>> rowBuffers) {
   super(parent, style);
   this.stepNames = stepNames;
   this.rowDatas = rowBuffers;
   this.rowMetas = rowMetas;
   props = PropsUI.getInstance();
 }
 public SapFunctionBrowser(
     Shell parent,
     VariableSpace space,
     int style,
     DatabaseMeta sapConnection,
     String searchString) {
   super(parent, style);
   this.space = space;
   this.sapConnection = sapConnection;
   this.searchString = searchString;
   props = PropsUI.getInstance();
   functionList = new ArrayList<SAPFunction>(); // Empty by default...
 }
  /**
   * Create a new dialog allow someone to pick one value out of a list of values
   *
   * @param parent the parent shell.
   * @param choices The available list of options
   * @param shellText The shell text
   * @param message the message to display as extra information about the possible choices
   */
  public EnterSelectionDialog(Shell parent, String[] choices, String shellText, String message) {
    super(parent, SWT.NONE);

    this.choices = choices;
    this.shellText = shellText;
    this.lineText = message;

    props = PropsUI.getInstance();
    selection = null;
    viewOnly = false;
    modal = true;
    selectedNrs = new int[] {};
    multi = false;
    fixed = false;
    quickSearch = true;
  }
Пример #15
0
  @Override
  public void hide() {

    if (closing
        || dialog.getMainArea().isDisposed()
        || getParentShell(getParent()).isDisposed()
        || (getParent() instanceof SwtDialog && ((SwtDialog) getParent()).isDisposing())) {
      return;
    }

    // Save the window location & size in the Kettle world...
    //
    WindowProperty windowProperty = new WindowProperty(getShell());
    PropsUI.getInstance().setScreen(windowProperty);

    super.hide();
  }
Пример #16
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();
  }
Пример #17
0
  public ConfigurationDialog(
      Shell parent, ExecutionConfiguration configuration, AbstractMeta meta) {
    super(parent);
    this.parent = parent;
    this.configuration = configuration;
    this.abstractMeta = meta;
    initCheckboxFlag();

    // Fill the parameters, maybe do this in another place?
    Map<String, String> params = configuration.getParams();
    params.clear();
    String[] paramNames = meta.listParameters();
    for (String name : paramNames) {
      params.put(name, "");
    }

    props = PropsUI.getInstance();
  }
/** Label, numeric text input and drop down time unit selector */
public class LabelTimeComposite extends Composite {
  private static final PropsUI props = PropsUI.getInstance();

  private Label wLabel;
  private Text wText;
  private CCombo wTimeUnit;

  private String lastValidValue = "";

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

  private String[] getTimeUnits() {
    ArrayList<String> timeUnits = new ArrayList<String>();
    for (TimeUnit timeUnit : TimeUnit.values()) {
      timeUnits.add(timeUnit.toString());
    }
    return timeUnits.toArray(new String[timeUnits.size()]);
  }

  public TimeUnit getTimeUnit() {
    return TimeUnit.valueOf(wTimeUnit.getItem(wTimeUnit.getSelectionIndex()));
  }

  public void setTimeUnit(TimeUnit tu) {
    for (int i = 0; i < wTimeUnit.getItemCount(); i++) {
      if (tu.toString().equals(wTimeUnit.getItem(i))) {
        wTimeUnit.select(i);
        break;
      }
    }
  }

  public void addModifyListener(ModifyListener lsMod) {
    wText.addModifyListener(lsMod);
  }

  public void addSelectionListener(SelectionAdapter lsDef) {
    wText.addSelectionListener(lsDef);
  }

  public void setText(String name) {
    wText.setText(name);
  }

  public String getText() {
    return wText.getText();
  }

  public void setEchoChar(char c) {
    wText.setEchoChar(c);
  }

  public void setEnabled(boolean flag) {
    wText.setEnabled(flag);
    wLabel.setEnabled(flag);
  }

  public boolean setFocus() {
    return wText.setFocus();
  }

  public void addTraverseListener(TraverseListener tl) {
    wText.addTraverseListener(tl);
  }

  public Text getTextWidget() {
    return wText;
  }

  public Label getLabelWidget() {
    return wLabel;
  }
}
  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;
  }
  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();
      }
    }
  }
 private void dispose() {
   WindowProperty winprop = new WindowProperty(shell);
   props.setScreen(winprop);
   shell.dispose();
 }
  public void executeTransformation(
      final TransMeta transMeta,
      final boolean local,
      final boolean remote,
      final boolean cluster,
      final boolean preview,
      final boolean debug,
      final Date replayDate,
      final boolean safe)
      throws KettleException {

    if (transMeta == null) {
      return;
    }

    // See if we need to ask for debugging information...
    //
    TransDebugMeta transDebugMeta = null;
    TransExecutionConfiguration executionConfiguration = null;

    if (preview) {
      executionConfiguration = spoon.getTransPreviewExecutionConfiguration();
    } else if (debug) {
      executionConfiguration = spoon.getTransDebugExecutionConfiguration();
    } else {
      executionConfiguration = spoon.getTransExecutionConfiguration();
    }

    if (debug) {
      // See if we have debugging information stored somewhere?
      //
      transDebugMeta = transDebugMetaMap.get(transMeta);
      if (transDebugMeta == null) {
        transDebugMeta = new TransDebugMeta(transMeta);
        transDebugMetaMap.put(transMeta, transDebugMeta);
      }

      // Set the default number of rows to retrieve on all selected steps...
      //
      StepMeta[] selectedSteps = transMeta.getSelectedSteps();
      if (selectedSteps != null && selectedSteps.length > 0) {
        transDebugMeta.getStepDebugMetaMap().clear();
        for (StepMeta stepMeta : transMeta.getSelectedSteps()) {
          StepDebugMeta stepDebugMeta = new StepDebugMeta(stepMeta);
          stepDebugMeta.setRowCount(PropsUI.getInstance().getDefaultPreviewSize());
          stepDebugMeta.setPausingOnBreakPoint(true);
          stepDebugMeta.setReadingFirstRows(false);
          transDebugMeta.getStepDebugMetaMap().put(stepMeta, stepDebugMeta);
        }
      }

    } else if (preview) {
      // See if we have preview information stored somewhere?
      //
      transDebugMeta = transPreviewMetaMap.get(transMeta);
      if (transDebugMeta == null) {
        transDebugMeta = new TransDebugMeta(transMeta);

        transPreviewMetaMap.put(transMeta, transDebugMeta);
      }

      // Set the default number of preview rows on all selected steps...
      //
      StepMeta[] selectedSteps = transMeta.getSelectedSteps();
      if (selectedSteps != null && selectedSteps.length > 0) {
        transDebugMeta.getStepDebugMetaMap().clear();
        for (StepMeta stepMeta : transMeta.getSelectedSteps()) {
          StepDebugMeta stepDebugMeta = new StepDebugMeta(stepMeta);
          stepDebugMeta.setRowCount(PropsUI.getInstance().getDefaultPreviewSize());
          stepDebugMeta.setPausingOnBreakPoint(false);
          stepDebugMeta.setReadingFirstRows(true);
          transDebugMeta.getStepDebugMetaMap().put(stepMeta, stepDebugMeta);
        }
      }
    }

    executionConfiguration.setRepository(spoon.rep);
    executionConfiguration.setSafeModeEnabled(safe);

    int debugAnswer = TransDebugDialog.DEBUG_CONFIG;

    if (debug || preview) {
      transDebugMeta.getTransMeta().setRepository(spoon.rep); // pass repository for mappings
      TransDebugDialog transDebugDialog = new TransDebugDialog(spoon.getShell(), transDebugMeta);
      debugAnswer = transDebugDialog.open();
      if (debugAnswer != TransDebugDialog.DEBUG_CANCEL) {
        executionConfiguration.setExecutingLocally(true);
        executionConfiguration.setExecutingRemotely(false);
        executionConfiguration.setExecutingClustered(false);
      } else {
        // If we cancel the debug dialog, we don't go further with the execution either.
        //
        return;
      }
    } else {
      if (transMeta.findFirstUsedClusterSchema() != null) {
        executionConfiguration.setExecutingLocally(false);
        executionConfiguration.setExecutingRemotely(false);
        executionConfiguration.setExecutingClustered(true);
      } else {
        executionConfiguration.setExecutingLocally(true);
        executionConfiguration.setExecutingRemotely(false);
        executionConfiguration.setExecutingClustered(false);
      }
    }

    Object data[] = spoon.variables.getData();
    String fields[] = spoon.variables.getRowMeta().getFieldNames();
    Map<String, String> variableMap = new HashMap<String, String>();
    variableMap.putAll(executionConfiguration.getVariables()); // the default
    for (int idx = 0; idx < fields.length; idx++) {
      String value = executionConfiguration.getVariables().get(fields[idx]);
      if (Const.isEmpty(value)) value = data[idx].toString();
      variableMap.put(fields[idx], value);
    }

    executionConfiguration.setVariables(variableMap);
    executionConfiguration.getUsedVariables(transMeta);
    executionConfiguration.getUsedArguments(transMeta, spoon.getArguments());
    executionConfiguration.setReplayDate(replayDate);

    executionConfiguration.setLogLevel(spoon.getLog().getLogLevel());

    boolean execConfigAnswer = true;

    if (debugAnswer == TransDebugDialog.DEBUG_CONFIG && replayDate == null) {
      TransExecutionConfigurationDialog dialog =
          new TransExecutionConfigurationDialog(
              spoon.getShell(), executionConfiguration, transMeta);
      execConfigAnswer = dialog.open();
    }

    if (execConfigAnswer) {

      // Verify if there is at least one step specified to debug or preview...
      //
      if (debug || preview) {
        if (transDebugMeta.getNrOfUsedSteps() == 0) {
          MessageBox box = new MessageBox(spoon.getShell(), SWT.ICON_WARNING | SWT.YES | SWT.NO);
          box.setText(Messages.getString("Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Title"));
          box.setMessage(Messages.getString("Spoon.Dialog.Warning.NoPreviewOrDebugSteps.Message"));
          int answer = box.open();
          if (answer != SWT.YES) {
            return;
          }
        }
      }

      // addTransLog(transMeta, executionConfiguration.isExecutingLocally());
      // TransLog transLog = spoon.getActiveTransLog();
      TransGraph activeTransGraph = spoon.getActiveTransGraph();

      // Is this a local execution?
      //
      if (executionConfiguration.isExecutingLocally()) {
        if (debug || preview) {
          activeTransGraph.debug(executionConfiguration, transDebugMeta);
        } else {
          activeTransGraph.start(executionConfiguration);
        }

        // Are we executing remotely?
        //
      } else if (executionConfiguration.isExecutingRemotely()) {
        if (executionConfiguration.getRemoteServer() != null) {
          Trans.sendToSlaveServer(transMeta, executionConfiguration, spoon.rep);
          monitorRemoteTrans(transMeta, executionConfiguration.getRemoteServer());
          spoon.delegates.slaves.addSpoonSlave(executionConfiguration.getRemoteServer());

        } else {
          MessageBox mb = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION);
          mb.setMessage(Messages.getString("Spoon.Dialog.NoRemoteServerSpecified.Message"));
          mb.setText(Messages.getString("Spoon.Dialog.NoRemoteServerSpecified.Title"));
          mb.open();
        }

        // Are we executing clustered?
        //
      } else if (executionConfiguration.isExecutingClustered()) {
        splitTrans(transMeta, executionConfiguration);
      }
    }
  }
  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;
  }
Пример #24
0
 private void dispose() {
   props.setScreen(new WindowProperty(shell));
   shell.dispose();
 }
Пример #25
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();
      }
    }
  }
Пример #26
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);
  }
Пример #27
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();
  }
  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;
  }
Пример #29
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);
  }
Пример #30
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);
  }