Exemplo n.º 1
0
  protected void openDialog() {

    if (Const.isWindows()) {
      shell.setSize(653, 671);
    }
    if (Const.isLinux()) {
      shell.setSize(740, 678);
    }
    if (Const.isOSX()) {
      shell.setSize(653, 678);
    }

    // Set the focus on the OK button
    wOK.setFocus();
    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();
      }
    }
  }
Exemplo n.º 2
0
 protected void ok() {
   if (Const.isOSX()) {
     // OSX bug workaround.
     //
     wArguments.applyOSXChanges();
   }
   getInfoArguments();
   dispose();
 }
Exemplo n.º 3
0
 protected void ok() {
   setCheckboxFlag();
   if (Const.isOSX()) {
     // OSX bug workaround.
     wVariables.applyOSXChanges();
     wParams.applyOSXChanges();
   }
   getInfo();
   retval = true;
   dispose();
 }
  protected void optionsSectionControls() {

    wSafeMode = new Button(gDetails, SWT.CHECK);
    wSafeMode.setText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.SafeMode.Label"));
    wSafeMode.setToolTipText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.SafeMode.Tooltip"));
    props.setLook(wSafeMode);
    FormData fdSafeMode = new FormData();
    fdSafeMode.right = new FormAttachment(0, 186);
    fdSafeMode.top = new FormAttachment(0, 30);
    fdSafeMode.left = new FormAttachment(0, 10);
    wSafeMode.setLayoutData(fdSafeMode);

    wGatherMetrics = new Button(gDetails, SWT.CHECK);
    wGatherMetrics.setText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.GatherMetrics.Label"));
    wGatherMetrics.setToolTipText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.GatherMetrics.Tooltip"));
    props.setLook(wGatherMetrics);
    FormData fdGatherMetrics = new FormData();
    fdGatherMetrics.right = new FormAttachment(0, 230);
    fdGatherMetrics.top = new FormAttachment(0, 55);
    fdGatherMetrics.left = new FormAttachment(0, 10);
    wGatherMetrics.setLayoutData(fdGatherMetrics);

    wClearLog = new Button(gDetails, SWT.CHECK);
    wClearLog.setText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.ClearLog.Label"));
    wClearLog.setToolTipText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.ClearLog.Tooltip"));
    props.setLook(wClearLog);
    FormData fdClearLog = new FormData();
    fdClearLog.right = new FormAttachment(0, 200);
    fdClearLog.top = new FormAttachment(0, 5);
    fdClearLog.left = new FormAttachment(0, 10);
    wClearLog.setLayoutData(fdClearLog);

    wlLogLevel = new Label(gDetails, SWT.RIGHT);
    props.setLook(wlLogLevel);
    wlLogLevel.setText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.LogLevel.Label"));
    wlLogLevel.setToolTipText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.LogLevel.Tooltip"));
    FormData fdlLogLevel = new FormData();
    fdlLogLevel.right = new FormAttachment(0, 333);
    fdlLogLevel.top = new FormAttachment(0, 7);
    fdlLogLevel.left = new FormAttachment(0, 260);
    wlLogLevel.setLayoutData(fdlLogLevel);

    wLogLevel = new CCombo(gDetails, SWT.READ_ONLY | SWT.BORDER);
    wLogLevel.setToolTipText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.LogLevel.Tooltip"));
    props.setLook(wLogLevel);
    FormData fdLogLevel = new FormData();
    fdLogLevel.left = new FormAttachment(wlLogLevel, 6);
    fdLogLevel.width = 200;
    if (Const.isOSX()) {
      fdLogLevel.top = new FormAttachment(wClearLog, 2, SWT.TOP);
    } else {
      fdLogLevel.top = new FormAttachment(wClearLog, -2, SWT.TOP);
    }
    fdLogLevel.right = new FormAttachment(0, 500);
    wLogLevel.setLayoutData(fdLogLevel);
    wLogLevel.setItems(LogLevel.getLogLevelDescriptions());

    wStartCopy = new CCombo(gDetails, SWT.READ_ONLY | SWT.BORDER);
    props.setLook(wStartCopy);
    wStartCopy.setToolTipText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.StartCopy.Tooltip"));
    FormData fd_startJobCombo = new FormData();
    fd_startJobCombo.right = new FormAttachment(wLogLevel, 0, SWT.RIGHT);
    if (Const.isOSX()) {
      fd_startJobCombo.top = new FormAttachment(wLogLevel, 8);
    } else {
      fd_startJobCombo.top = new FormAttachment(wLogLevel, 10);
    }
    wStartCopy.setLayoutData(fd_startJobCombo);

    JobMeta jobMeta = (JobMeta) super.abstractMeta;

    String[] names = new String[jobMeta.getJobCopies().size()];
    for (int i = 0; i < names.length; i++) {
      JobEntryCopy copy = jobMeta.getJobCopies().get(i);
      names[i] = getJobEntryCopyName(copy);
    }
    wStartCopy.setItems(names);

    Label lblStartJob = new Label(gDetails, SWT.NONE);
    props.setLook(lblStartJob);
    fd_startJobCombo.left = new FormAttachment(lblStartJob, 6);
    FormData fd_lblStartJob = new FormData();
    if (Const.isOSX()) {
      fd_lblStartJob.top = new FormAttachment(wlLogLevel, 8);
    } else {
      fd_lblStartJob.top = new FormAttachment(wlLogLevel, 18);
    }
    fd_lblStartJob.right = new FormAttachment(wlLogLevel, 0, SWT.RIGHT);
    lblStartJob.setLayoutData(fd_lblStartJob);
    lblStartJob.setText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.StartCopy.Label"));
    lblStartJob.setToolTipText(
        BaseMessages.getString(PKG, "JobExecutionConfigurationDialog.StartCopy.Tooltip"));
  }
  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;
  }