Пример #1
0
  /** Creates a text that controls whether a border radius is set on the registered controls. */
  protected void cteateRoundedBorderGroup() {
    Group group = new Group(styleComp, SWT.NONE);
    group.setText("Rounded Border");
    group.setLayout(new GridLayout(2, false));
    new Label(group, SWT.NONE).setText("Width");
    final Text textWidth = new Text(group, SWT.SINGLE | SWT.BORDER);
    textWidth.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(group, SWT.NONE).setText("Color");
    final Button buttonColor = new Button(group, SWT.PUSH);
    buttonColor.setLayoutData(new GridData(20, 20));
    buttonColor.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(final SelectionEvent event) {
            rbIndex = (rbIndex + 1) % bgColors.length;
            if (bgColors[rbIndex] == null) {
              buttonColor.setText("");
            } else {
              buttonColor.setText("\u2588");
            }
            buttonColor.setForeground(bgColors[rbIndex]);
          }
        });
    new Label(group, SWT.NONE).setText("Radius ");
    Composite radiusGroup = new Composite(group, SWT.NONE);
    radiusGroup.setLayout(new GridLayout(4, false));
    new Label(radiusGroup, SWT.NONE).setText("T-L");
    final Text textTopLeft = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textTopLeft.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(radiusGroup, SWT.NONE).setText("T-R");
    final Text textTopRight = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textTopRight.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(radiusGroup, SWT.NONE).setText("B-L");
    final Text textBottomLeft = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textBottomLeft.setLayoutData(new GridData(20, SWT.DEFAULT));
    new Label(radiusGroup, SWT.NONE).setText("B-R");
    final Text textBottomRight = new Text(radiusGroup, SWT.SINGLE | SWT.BORDER);
    textBottomRight.setLayoutData(new GridData(20, SWT.DEFAULT));
    Button button = new Button(group, SWT.PUSH);
    button.setText("Set");
    button.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(final SelectionEvent e) {
            int width = parseInt(textWidth.getText());
            Color color = buttonColor.getBackground();
            int topLeft = parseInt(textTopLeft.getText());
            int topRight = parseInt(textTopRight.getText());
            int bottomRight = parseInt(textBottomRight.getText());
            int bottomLeft = parseInt(textBottomLeft.getText());
            updateRoundedBorder(width, color, topLeft, topRight, bottomRight, bottomLeft);
          }
        });
  }
Пример #2
0
  void createRTFTransfer(Composite copyParent, Composite pasteParent) {
    //	RTF Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("RTFTransfer:"); // $NON-NLS-1$
    copyRtfText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyRtfText.setText("some\nrtf\ntext");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    copyRtfText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = copyRtfText.getText();
            if (data.length() > 0) {
              status.setText("");
              data = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i " + data + "}";
              clipboard.setContents(
                  new Object[] {data}, new Transfer[] {RTFTransfer.getInstance()});
            } else {
              status.setText("nothing to copy");
            }
          }
        });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("RTFTransfer:"); // $NON-NLS-1$
    pasteRtfText =
        new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteRtfText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = (String) clipboard.getContents(RTFTransfer.getInstance());
            if (data != null && data.length() > 0) {
              status.setText("");
              pasteRtfText.setText("start paste>" + data + "<end paste");
            } else {
              status.setText("nothing to paste");
            }
          }
        });
  }
Пример #3
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("SWT and Swing DND Example");
    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);

    Text swtText = new Text(shell, SWT.BORDER);
    swtText.setText("SWT Text");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    swtText.setLayoutData(data);
    setDragDrop(swtText);

    Composite comp = new Composite(shell, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame(comp);
    JTextField swingText = new JTextField(40);
    swingText.setText("Swing Text");
    swingText.setDragEnabled(true);
    frame.add(swingText);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = swingText.getPreferredSize().height;
    comp.setLayoutData(data);

    shell.setSize(400, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Пример #4
0
  void createHTMLTransfer(Composite copyParent, Composite pasteParent) {
    //	HTML Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("HTMLTransfer:"); // $NON-NLS-1$
    copyHtmlText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyHtmlText.setText("<b>Hello World</b>");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    copyHtmlText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = copyHtmlText.getText();
            if (data.length() > 0) {
              status.setText("");
              clipboard.setContents(
                  new Object[] {data}, new Transfer[] {HTMLTransfer.getInstance()});
            } else {
              status.setText("nothing to copy");
            }
          }
        });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("HTMLTransfer:"); // $NON-NLS-1$
    pasteHtmlText =
        new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteHtmlText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String data = (String) clipboard.getContents(HTMLTransfer.getInstance());
            if (data != null && data.length() > 0) {
              status.setText("");
              pasteHtmlText.setText("start paste>" + data + "<end paste");
            } else {
              status.setText("nothing to paste");
            }
          }
        });
  }
Пример #5
0
 /** Creates the "Example" widgets. */
 void createExampleWidgets() {
   /*
    * Create a multi lined, scrolled text widget for output.
    */
   textWidget = new Text(resultGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
   GridData gridData = new GridData(GridData.FILL_BOTH);
   textWidget.setLayoutData(gridData);
 }
 private Text createTextInput(
     Composite parent, String labelKey, String configKey, String defaultValue, int widthHint) {
   // TODO: use this method to create all text inputs
   createLabel(parent, labelKey);
   final Text t = new Text(parent, SWT.BORDER);
   final GridData gd = new GridData();
   if (widthHint > 0) gd.widthHint = widthHint;
   t.setLayoutData(gd);
   String val = controller.getConfig().getString(configKey);
   if ("".equals(val) && defaultValue != null) val = defaultValue;
   t.setText(String.valueOf(val));
   return t;
 }
Пример #7
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(2, false));

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

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    if (image != null) image.dispose();
    display.dispose();
  }
Пример #8
0
  private void createContent() {
    GridData termGD = new GridData(GridData.FILL_BOTH);
    termGD.heightHint = 400;
    termGD.widthHint = 400;
    termGD.horizontalSpan = 3;

    terminal = new Text(mainPane, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
    terminal.setLayoutData(termGD);

    pause = new Button(mainPane, SWT.TOGGLE);
    pause.setText("Pause");
    pause.setToolTipText("Pause Terminal");

    clear = new Button(mainPane, SWT.PUSH);
    clear.setText("Clear");
    clear.setToolTipText("Clear the Terminal");

    close = new Button(mainPane, SWT.PUSH);
    close.setText("Close");
  }
Пример #9
0
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    shell.setLayout(gridLayout);
    ToolBar toolbar = new ToolBar(shell, SWT.NONE);
    ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
    itemBack.setText("Back");
    ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
    itemForward.setText("Forward");
    ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
    itemStop.setText("Stop");
    ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
    itemRefresh.setText("Refresh");
    ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
    itemGo.setText("Go");

    GridData data = new GridData();
    data.horizontalSpan = 3;
    toolbar.setLayoutData(data);

    Label labelAddress = new Label(shell, SWT.NONE);
    labelAddress.setText("Address");

    final Text location = new Text(shell, SWT.BORDER);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = true;
    location.setLayoutData(data);

    final Browser browser;
    try {
      browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
      System.out.println("Could not instantiate Browser: " + e.getMessage());
      display.dispose();
      return;
    }
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.horizontalSpan = 3;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    browser.setLayoutData(data);

    final Label status = new Label(shell, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    status.setLayoutData(data);

    final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.END;
    progressBar.setLayoutData(data);

    /* event handling */
    Listener listener =
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            ToolItem item = (ToolItem) event.widget;
            String string = item.getText();
            if (string.equals("Back")) browser.back();
            else if (string.equals("Forward")) browser.forward();
            else if (string.equals("Stop")) browser.stop();
            else if (string.equals("Refresh")) browser.refresh();
            else if (string.equals("Go")) browser.setUrl(location.getText());
          }
        };
    browser.addProgressListener(
        new ProgressListener() {
          @Override
          public void changed(ProgressEvent event) {
            if (event.total == 0) return;
            int ratio = event.current * 100 / event.total;
            progressBar.setSelection(ratio);
          }

          @Override
          public void completed(ProgressEvent event) {
            progressBar.setSelection(0);
          }
        });
    browser.addStatusTextListener(
        new StatusTextListener() {
          @Override
          public void changed(StatusTextEvent event) {
            status.setText(event.text);
          }
        });
    browser.addLocationListener(
        new LocationListener() {
          @Override
          public void changed(LocationEvent event) {
            if (event.top) location.setText(event.location);
          }

          @Override
          public void changing(LocationEvent event) {}
        });
    itemBack.addListener(SWT.Selection, listener);
    itemForward.addListener(SWT.Selection, listener);
    itemStop.addListener(SWT.Selection, listener);
    itemRefresh.addListener(SWT.Selection, listener);
    itemGo.addListener(SWT.Selection, listener);
    location.addListener(
        SWT.DefaultSelection,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            browser.setUrl(location.getText());
          }
        });

    shell.open();
    browser.setUrl("http://eclipse.org");

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Пример #10
0
  void createControlTransfer(Composite parent) {
    Label l = new Label(parent, SWT.NONE);
    l.setText("Text:");
    Button b = new Button(parent, SWT.PUSH);
    b.setText("Cut");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            text.cut();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            text.copy();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            text.paste();
          }
        });
    text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    text.setLayoutData(data);

    l = new Label(parent, SWT.NONE);
    l.setText("Combo:");
    b = new Button(parent, SWT.PUSH);
    b.setText("Cut");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            combo.cut();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            combo.copy();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            combo.paste();
          }
        });
    combo = new Combo(parent, SWT.NONE);
    combo.setItems(new String[] {"Item 1", "Item 2", "Item 3", "A longer Item"});

    l = new Label(parent, SWT.NONE);
    l.setText("StyledText:");
    l = new Label(parent, SWT.NONE);
    l.setVisible(false);
    b = new Button(parent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            styledText.copy();
          }
        });
    b = new Button(parent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            styledText.paste();
          }
        });
    styledText = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    styledText.setLayoutData(data);
  }
Пример #11
0
  public static void main(String[] args) {
    final Display display = new Display();
    final Clipboard clipboard = new Clipboard(display);
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);
    shell.setLayout(new GridLayout());
    shell.setText("Clipboard ImageTransfer");

    final Button imageButton = new Button(shell, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.minimumHeight = 400;
    gd.minimumWidth = 600;
    imageButton.setLayoutData(gd);

    final Text imageText = new Text(shell, SWT.BORDER);
    imageText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    Composite buttons = new Composite(shell, SWT.NONE);
    buttons.setLayout(new GridLayout(4, true));
    Button button = new Button(buttons, SWT.PUSH);
    button.setText("Open");
    button.addListener(
        SWT.Selection,
        event -> {
          FileDialog dialog = new FileDialog(shell, SWT.OPEN);
          dialog.setText("Open an image file or cancel");
          String string = dialog.open();
          if (string != null) {
            imageButton.setText("");
            Image image = imageButton.getImage();
            if (image != null) image.dispose();
            image = new Image(display, string);
            imageButton.setImage(image);
            imageText.setText(string);
          }
        });

    button = new Button(buttons, SWT.PUSH);
    button.setText("Copy");
    button.addListener(
        SWT.Selection,
        event -> {
          Image image = imageButton.getImage();
          if (image != null) {
            ImageTransfer imageTransfer = ImageTransfer.getInstance();
            TextTransfer textTransfer = TextTransfer.getInstance();
            clipboard.setContents(
                new Object[] {image.getImageData(), imageText.getText()},
                new Transfer[] {imageTransfer, textTransfer});
          }
        });

    button = new Button(buttons, SWT.PUSH);
    button.setText("Paste");
    button.addListener(
        SWT.Selection,
        event -> {
          ImageData imageData = (ImageData) clipboard.getContents(ImageTransfer.getInstance());
          if (imageData != null) {
            imageButton.setText("");
            Image image = imageButton.getImage();
            if (image != null) image.dispose();
            image = new Image(display, imageData);
            imageButton.setImage(image);
          } else {
            imageButton.setText("No image");
            imageButton.setImage(null);
          }
          String text = (String) clipboard.getContents(TextTransfer.getInstance());
          if (text != null) {
            imageText.setText(text);
          } else {
            imageText.setText("");
          }
        });

    button = new Button(buttons, SWT.PUSH);
    button.setText("Clear");
    button.addListener(
        SWT.Selection,
        event -> {
          imageButton.setText("");
          Image image = imageButton.getImage();
          if (image != null) image.dispose();
          imageButton.setImage(null);
          imageText.setText("");
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
    protected authDialog(
        AESemaphore _sem,
        Display display,
        String realm,
        boolean is_tracker,
        String target,
        String details) {
      sem = _sem;

      if (display.isDisposed()) {

        sem.releaseForever();

        return;
      }

      final String ignore_key = "IgnoreAuth:" + realm + ":" + target + ":" + details;

      if (RememberedDecisionsManager.getRememberedDecision(ignore_key) == 1) {

        Debug.out(
            "Authentication for "
                + realm
                + "/"
                + target
                + "/"
                + details
                + " ignored as told not to ask again");

        sem.releaseForever();

        return;
      }

      shell = ShellFactory.createMainShell(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

      Utils.setShellIcon(shell);
      Messages.setLanguageText(shell, "authenticator.title");

      GridLayout layout = new GridLayout();
      layout.numColumns = 3;

      shell.setLayout(layout);

      GridData gridData;

      // realm

      Label realm_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(realm_label, "authenticator.realm");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      realm_label.setLayoutData(gridData);

      Label realm_value = new Label(shell, SWT.NULL);
      realm_value.setText(realm.replaceAll("&", "&&"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      realm_value.setLayoutData(gridData);

      // target

      Label target_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(
          target_label, is_tracker ? "authenticator.tracker" : "authenticator.location");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      target_label.setLayoutData(gridData);

      Label target_value = new Label(shell, SWT.NULL);
      target_value.setText(target.replaceAll("&", "&&"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      target_value.setLayoutData(gridData);

      if (details != null) {

        Label details_label = new Label(shell, SWT.NULL);
        Messages.setLanguageText(
            details_label, is_tracker ? "authenticator.torrent" : "authenticator.details");
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 1;
        details_label.setLayoutData(gridData);

        Label details_value = new Label(shell, SWT.NULL);
        details_value.setText(details.replaceAll("&", "&&"));
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 2;
        details_value.setLayoutData(gridData);
      }
      // user

      Label user_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(user_label, "authenticator.user");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      user_label.setLayoutData(gridData);

      final Text user_value = new Text(shell, SWT.BORDER);
      user_value.setText("");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      user_value.setLayoutData(gridData);

      user_value.addListener(
          SWT.Modify,
          new Listener() {
            public void handleEvent(Event event) {
              username = user_value.getText();
            }
          });

      // password

      Label password_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(password_label, "authenticator.password");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      password_label.setLayoutData(gridData);

      final Text password_value = new Text(shell, SWT.BORDER);
      password_value.setEchoChar('*');
      password_value.setText("");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      password_value.setLayoutData(gridData);

      password_value.addListener(
          SWT.Modify,
          new Listener() {
            public void handleEvent(Event event) {
              password = password_value.getText();
            }
          });

      // persist

      Label blank_label = new Label(shell, SWT.NULL);
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      blank_label.setLayoutData(gridData);

      final Button checkBox = new Button(shell, SWT.CHECK);
      checkBox.setText(MessageText.getString("authenticator.savepassword"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      checkBox.setLayoutData(gridData);
      checkBox.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              persist = checkBox.getSelection();
            }
          });

      final Button dontAsk = new Button(shell, SWT.CHECK);
      dontAsk.setText(MessageText.getString("general.dont.ask.again"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      dontAsk.setLayoutData(gridData);
      dontAsk.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              RememberedDecisionsManager.setRemembered(ignore_key, dontAsk.getSelection() ? 1 : 0);
            }
          });

      // line

      Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.horizontalSpan = 3;
      labelSeparator.setLayoutData(gridData);

      // buttons

      new Label(shell, SWT.NULL);

      Button bOk = new Button(shell, SWT.PUSH);
      Messages.setLanguageText(bOk, "Button.ok");
      gridData =
          new GridData(
              GridData.FILL_HORIZONTAL
                  | GridData.HORIZONTAL_ALIGN_END
                  | GridData.HORIZONTAL_ALIGN_FILL);
      gridData.grabExcessHorizontalSpace = true;
      gridData.widthHint = 70;
      bOk.setLayoutData(gridData);
      bOk.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              close(true);
            }
          });

      Button bCancel = new Button(shell, SWT.PUSH);
      Messages.setLanguageText(bCancel, "Button.cancel");
      gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
      gridData.grabExcessHorizontalSpace = false;
      gridData.widthHint = 70;
      bCancel.setLayoutData(gridData);
      bCancel.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              close(false);
            }
          });

      shell.setDefaultButton(bOk);

      shell.addListener(
          SWT.Traverse,
          new Listener() {
            public void handleEvent(Event e) {
              if (e.character == SWT.ESC) {
                close(false);
              }
            }
          });

      shell.pack();

      Utils.centreWindow(shell);

      shell.open();
    }
  /**
   * Creates the dialog's contents
   *
   * @param shell the dialog window
   */
  private void createContents(final Shell shell) {

    final Config config = controller.getConfig();

    // Create the ScrolledComposite to scroll horizontally and vertically
    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);

    // Create the parent Composite container for the three child containers
    Composite container = new Composite(sc, SWT.NONE);
    GridLayout containerLayout = new GridLayout(1, false);
    container.setLayout(containerLayout);
    shell.setLayout(new FillLayout());

    GridData data;
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 50;
    data.widthHint = 400;

    // START TOP COMPONENT

    Composite topComp = new Composite(container, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    topComp.setLayout(layout);
    topComp.setLayoutData(data);

    Label blank = new Label(topComp, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 10;
    blank.setLayoutData(data);
    blank.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    // Show the message
    Label label = new Label(topComp, SWT.NONE);
    label.setText(message);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 30;
    data.widthHint = 370;

    Font f = label.getFont();
    FontData[] farr = f.getFontData();
    FontData fd = farr[0];
    fd.setStyle(SWT.BOLD);
    label.setFont(new Font(Display.getCurrent(), fd));

    label.setLayoutData(data);
    label.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

    Label labelSeparator = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    labelSeparator.setLayoutData(data);

    // END TOP COMPONENT

    // START MIDDLE COMPONENT

    Composite restComp = new Composite(container, SWT.NONE);
    data = new GridData(GridData.FILL_BOTH);
    restComp.setLayoutData(data);
    layout = new GridLayout(2, false);
    layout.verticalSpacing = 10;
    restComp.setLayout(layout);

    // Hide welecome screen
    Label labelHideWelcomeScreen = new Label(restComp, SWT.RIGHT);
    labelHideWelcomeScreen.setText(
        Labels.getString("AdvancedSettingsDialog.hideWelcomeScreen")); // $NON-NLS-1$
    labelHideWelcomeScreen.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonHideWelcomeScreen = new Button(restComp, SWT.CHECK);
    buttonHideWelcomeScreen.setSelection(config.getBoolean(Config.HIDE_WELCOME_SCREEN));

    // batch size
    Label labelBatch = new Label(restComp, SWT.RIGHT);
    labelBatch.setText(Labels.getString("AdvancedSettingsDialog.batchSize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelBatch.setLayoutData(data);

    textBatch = new Text(restComp, SWT.BORDER);
    textBatch.setText(config.getString(Config.LOAD_BATCH_SIZE));
    textBatch.setTextLimit(8);
    textBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 50;
    textBatch.setLayoutData(data);

    // insert Nulls
    Label labelNulls = new Label(restComp, SWT.RIGHT);
    labelNulls.setText(Labels.getString("AdvancedSettingsDialog.insertNulls")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelNulls.setLayoutData(data);
    buttonNulls = new Button(restComp, SWT.CHECK);
    buttonNulls.setSelection(config.getBoolean(Config.INSERT_NULLS));

    // assignment rules
    Label labelRule = new Label(restComp, SWT.RIGHT);
    labelRule.setText(Labels.getString("AdvancedSettingsDialog.assignmentRule")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRule.setLayoutData(data);

    textRule = new Text(restComp, SWT.BORDER);
    textRule.setTextLimit(18);
    data = new GridData();
    data.widthHint = 115;
    textRule.setLayoutData(data);
    textRule.setText(config.getString(Config.ASSIGNMENT_RULE));

    // endpoint
    Label labelEndpoint = new Label(restComp, SWT.RIGHT);
    labelEndpoint.setText(Labels.getString("AdvancedSettingsDialog.serverURL")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEndpoint.setLayoutData(data);

    textEndpoint = new Text(restComp, SWT.BORDER);
    data = new GridData();
    data.widthHint = 250;
    textEndpoint.setLayoutData(data);
    String endpoint = config.getString(Config.ENDPOINT);
    if ("".equals(endpoint)) { // $NON-NLS-1$
      endpoint = defaultServer;
    }

    textEndpoint.setText(endpoint);

    // reset url on login
    Label labelResetUrl = new Label(restComp, SWT.RIGHT);
    labelResetUrl.setText(
        Labels.getString("AdvancedSettingsDialog.resetUrlOnLogin")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelResetUrl.setLayoutData(data);
    buttonResetUrl = new Button(restComp, SWT.CHECK);
    buttonResetUrl.setSelection(config.getBoolean(Config.RESET_URL_ON_LOGIN));

    // insert compression
    Label labelCompression = new Label(restComp, SWT.RIGHT);
    labelCompression.setText(Labels.getString("AdvancedSettingsDialog.compression")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCompression.setLayoutData(data);
    buttonCompression = new Button(restComp, SWT.CHECK);
    buttonCompression.setSelection(config.getBoolean(Config.NO_COMPRESSION));

    // timeout size
    Label labelTimeout = new Label(restComp, SWT.RIGHT);
    labelTimeout.setText(Labels.getString("AdvancedSettingsDialog.timeout")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTimeout.setLayoutData(data);

    textTimeout = new Text(restComp, SWT.BORDER);
    textTimeout.setTextLimit(4);
    textTimeout.setText(config.getString(Config.TIMEOUT_SECS));
    textTimeout.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textTimeout.setLayoutData(data);

    // extraction batch size
    Label labelQueryBatch = new Label(restComp, SWT.RIGHT);
    labelQueryBatch.setText(Labels.getString("ExtractionInputDialog.querySize")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelQueryBatch.setLayoutData(data);

    textQueryBatch = new Text(restComp, SWT.BORDER);
    textQueryBatch.setText(config.getString(Config.EXTRACT_REQUEST_SIZE));
    textQueryBatch.setTextLimit(4);
    textQueryBatch.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 30;
    textQueryBatch.setLayoutData(data);

    // enable/disable output of success file for extracts
    Label labelOutputExtractStatus = new Label(restComp, SWT.RIGHT);
    labelOutputExtractStatus.setText(
        Labels.getString("AdvancedSettingsDialog.outputExtractStatus")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOutputExtractStatus.setLayoutData(data);

    buttonOutputExtractStatus = new Button(restComp, SWT.CHECK);
    buttonOutputExtractStatus.setSelection(config.getBoolean(Config.ENABLE_EXTRACT_STATUS_OUTPUT));

    // utf-8 for loading
    Label labelReadUTF8 = new Label(restComp, SWT.RIGHT);
    labelReadUTF8.setText(Labels.getString("AdvancedSettingsDialog.readUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelReadUTF8.setLayoutData(data);

    buttonReadUtf8 = new Button(restComp, SWT.CHECK);
    buttonReadUtf8.setSelection(config.getBoolean(Config.READ_UTF8));

    // utf-8 for extraction
    Label labelWriteUTF8 = new Label(restComp, SWT.RIGHT);
    labelWriteUTF8.setText(Labels.getString("AdvancedSettingsDialog.writeUTF8")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelWriteUTF8.setLayoutData(data);

    buttonWriteUtf8 = new Button(restComp, SWT.CHECK);
    buttonWriteUtf8.setSelection(config.getBoolean(Config.WRITE_UTF8));

    // European Dates
    Label labelEuropeanDates = new Label(restComp, SWT.RIGHT);
    labelEuropeanDates.setText(
        Labels.getString("AdvancedSettingsDialog.useEuropeanDateFormat")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelEuropeanDates.setLayoutData(data);

    buttonEuroDates = new Button(restComp, SWT.CHECK);
    buttonEuroDates.setSelection(config.getBoolean(Config.EURO_DATES));

    // Field truncation
    Label labelTruncateFields = new Label(restComp, SWT.RIGHT);
    labelTruncateFields.setText(Labels.getString("AdvancedSettingsDialog.allowFieldTruncation"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTruncateFields.setLayoutData(data);

    buttonTruncateFields = new Button(restComp, SWT.CHECK);
    buttonTruncateFields.setSelection(config.getBoolean(Config.TRUNCATE_FIELDS));

    Label labelCsvCommand = new Label(restComp, SWT.RIGHT);
    labelCsvCommand.setText(Labels.getString("AdvancedSettingsDialog.useCommaAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelCsvCommand.setLayoutData(data);
    buttonCsvComma = new Button(restComp, SWT.CHECK);
    buttonCsvComma.setSelection(config.getBoolean(Config.CSV_DELIMETER_COMMA));

    Label labelTabCommand = new Label(restComp, SWT.RIGHT);
    labelTabCommand.setText(Labels.getString("AdvancedSettingsDialog.useTabAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelTabCommand.setLayoutData(data);
    buttonCsvTab = new Button(restComp, SWT.CHECK);
    buttonCsvTab.setSelection(config.getBoolean(Config.CSV_DELIMETER_TAB));

    Label labelOtherCommand = new Label(restComp, SWT.RIGHT);
    labelOtherCommand.setText(Labels.getString("AdvancedSettingsDialog.useOtherAsCsvDelimiter"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherCommand.setLayoutData(data);
    buttonCsvOther = new Button(restComp, SWT.CHECK);
    buttonCsvOther.setSelection(config.getBoolean(Config.CSV_DELIMETER_OTHER));

    Label labelOtherDelimiterValue = new Label(restComp, SWT.RIGHT);
    labelOtherDelimiterValue.setText(
        Labels.getString("AdvancedSettingsDialog.csvOtherDelimiterValue"));
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelOtherDelimiterValue.setLayoutData(data);
    textSplitterValue = new Text(restComp, SWT.BORDER);
    textSplitterValue.setText(config.getString(Config.CSV_DELIMETER_OTHER_VALUE));
    data = new GridData();
    data.widthHint = 25;
    textSplitterValue.setLayoutData(data);

    // Enable Bulk API Setting
    Label labelUseBulkApi = new Label(restComp, SWT.RIGHT);
    labelUseBulkApi.setText(Labels.getString("AdvancedSettingsDialog.useBulkApi")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelUseBulkApi.setLayoutData(data);

    boolean useBulkAPI = config.getBoolean(Config.BULK_API_ENABLED);
    buttonUseBulkApi = new Button(restComp, SWT.CHECK);
    buttonUseBulkApi.setSelection(useBulkAPI);
    buttonUseBulkApi.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            boolean enabled = buttonUseBulkApi.getSelection();
            // update batch size when this setting changes
            int newDefaultBatchSize = controller.getConfig().getDefaultBatchSize(enabled);
            logger.info("Setting batch size to " + newDefaultBatchSize);
            textBatch.setText(String.valueOf(newDefaultBatchSize));
            // make sure the appropriate check boxes are enabled or disabled
            initBulkApiSetting(enabled);
          }
        });

    // Bulk API serial concurrency mode setting
    Label labelBulkApiSerialMode = new Label(restComp, SWT.RIGHT);
    labelBulkApiSerialMode.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiSerialMode")); // $NON-NLS-1$
    labelBulkApiSerialMode.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiSerialMode = new Button(restComp, SWT.CHECK);
    buttonBulkApiSerialMode.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiSerialMode.setEnabled(useBulkAPI);

    // Bulk API serial concurrency mode setting
    Label labelBulkApiZipContent = new Label(restComp, SWT.RIGHT);
    labelBulkApiZipContent.setText(
        Labels.getString("AdvancedSettingsDialog.bulkApiZipContent")); // $NON-NLS-1$
    labelBulkApiZipContent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));

    buttonBulkApiZipContent = new Button(restComp, SWT.CHECK);
    buttonBulkApiZipContent.setSelection(config.getBoolean(Config.BULK_API_SERIAL_MODE));
    buttonBulkApiZipContent.setEnabled(useBulkAPI);
    // timezone
    textTimezone =
        createTextInput(
            restComp,
            "AdvancedSettingsDialog.timezone",
            Config.TIMEZONE,
            TimeZone.getDefault().getID(),
            200);

    // proxy Host
    Label labelProxyHost = new Label(restComp, SWT.RIGHT);
    labelProxyHost.setText(Labels.getString("AdvancedSettingsDialog.proxyHost")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyHost.setLayoutData(data);

    textProxyHost = new Text(restComp, SWT.BORDER);
    textProxyHost.setText(config.getString(Config.PROXY_HOST));
    data = new GridData();
    data.widthHint = 250;
    textProxyHost.setLayoutData(data);

    // Proxy Port
    Label labelProxyPort = new Label(restComp, SWT.RIGHT);
    labelProxyPort.setText(Labels.getString("AdvancedSettingsDialog.proxyPort")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPort.setLayoutData(data);

    textProxyPort = new Text(restComp, SWT.BORDER);
    textProxyPort.setText(config.getString(Config.PROXY_PORT));
    textProxyPort.setTextLimit(4);
    textProxyPort.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });
    data = new GridData();
    data.widthHint = 25;
    textProxyPort.setLayoutData(data);

    // Proxy Username
    Label labelProxyUsername = new Label(restComp, SWT.RIGHT);
    labelProxyUsername.setText(Labels.getString("AdvancedSettingsDialog.proxyUser")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyUsername.setLayoutData(data);

    textProxyUsername = new Text(restComp, SWT.BORDER);
    textProxyUsername.setText(config.getString(Config.PROXY_USERNAME));
    data = new GridData();
    data.widthHint = 120;
    textProxyUsername.setLayoutData(data);

    // Proxy Password
    Label labelProxyPassword = new Label(restComp, SWT.RIGHT);
    labelProxyPassword.setText(
        Labels.getString("AdvancedSettingsDialog.proxyPassword")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyPassword.setLayoutData(data);

    textProxyPassword = new Text(restComp, SWT.BORDER | SWT.PASSWORD);
    textProxyPassword.setText(config.getString(Config.PROXY_PASSWORD));
    data = new GridData();
    data.widthHint = 120;
    textProxyPassword.setLayoutData(data);

    // proxy NTLM domain
    Label labelProxyNtlmDomain = new Label(restComp, SWT.RIGHT);
    labelProxyNtlmDomain.setText(
        Labels.getString("AdvancedSettingsDialog.proxyNtlmDomain")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelProxyNtlmDomain.setLayoutData(data);

    textProxyNtlmDomain = new Text(restComp, SWT.BORDER);
    textProxyNtlmDomain.setText(config.getString(Config.PROXY_NTLM_DOMAIN));
    data = new GridData();
    data.widthHint = 250;
    textProxyNtlmDomain.setLayoutData(data);

    //////////////////////////////////////////////////
    // Row to start At

    Label blankAgain = new Label(restComp, SWT.NONE);
    data = new GridData();
    data.horizontalSpan = 2;
    blankAgain.setLayoutData(data);

    // Row to start AT
    Label labelLastRow = new Label(restComp, SWT.NONE);

    String lastBatch = controller.getConfig().getString(LastRun.LAST_LOAD_BATCH_ROW);
    if (lastBatch.equals("")) { // $NON-NLS-1$
      lastBatch = "0"; // $NON-NLS-1$
    }

    labelLastRow.setText(
        Labels.getFormattedString("AdvancedSettingsDialog.lastBatch", lastBatch)); // $NON-NLS-1$
    data = new GridData();
    data.horizontalSpan = 2;
    labelLastRow.setLayoutData(data);

    Label labelRowToStart = new Label(restComp, SWT.RIGHT);
    labelRowToStart.setText(Labels.getString("AdvancedSettingsDialog.startRow")); // $NON-NLS-1$
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    labelRowToStart.setLayoutData(data);

    textRowToStart = new Text(restComp, SWT.BORDER);
    textRowToStart.setText(config.getString(Config.LOAD_ROW_TO_START_AT));
    data = new GridData();
    data.widthHint = 75;
    textRowToStart.setLayoutData(data);
    textRowToStart.addVerifyListener(
        new VerifyListener() {
          @Override
          public void verifyText(VerifyEvent event) {
            event.doit =
                Character.isISOControl(event.character) || Character.isDigit(event.character);
          }
        });

    // now that we've created all the buttons, make sure that buttons dependent on the bulk api
    // setting are enabled or disabled appropriately
    initBulkApiSetting(useBulkAPI);

    // the bottow separator
    Label labelSeparatorBottom = new Label(restComp, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    labelSeparatorBottom.setLayoutData(data);

    // ok cancel buttons
    new Label(restComp, SWT.NONE);

    // END MIDDLE COMPONENT

    // START BOTTOM COMPONENT

    Composite buttonComp = new Composite(restComp, SWT.NONE);
    data = new GridData(GridData.HORIZONTAL_ALIGN_END);
    buttonComp.setLayoutData(data);
    buttonComp.setLayout(new GridLayout(2, false));

    // Create the OK button and add a handler
    // so that pressing it will set input
    // to the entered value
    Button ok = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    ok.setText(Labels.getString("UI.ok")); // $NON-NLS-1$
    ok.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            Config config = controller.getConfig();

            // set the configValues
            config.setValue(Config.HIDE_WELCOME_SCREEN, buttonHideWelcomeScreen.getSelection());
            config.setValue(Config.INSERT_NULLS, buttonNulls.getSelection());
            config.setValue(Config.LOAD_BATCH_SIZE, textBatch.getText());
            if (!buttonCsvComma.getSelection()
                && !buttonCsvTab.getSelection()
                && (!buttonCsvOther.getSelection()
                    || textSplitterValue.getText() == null
                    || textSplitterValue.getText().length() == 0)) {
              return;
            }
            config.setValue(Config.CSV_DELIMETER_OTHER_VALUE, textSplitterValue.getText());
            config.setValue(Config.CSV_DELIMETER_COMMA, buttonCsvComma.getSelection());
            config.setValue(Config.CSV_DELIMETER_TAB, buttonCsvTab.getSelection());
            config.setValue(Config.CSV_DELIMETER_OTHER, buttonCsvOther.getSelection());

            config.setValue(Config.EXTRACT_REQUEST_SIZE, textQueryBatch.getText());
            config.setValue(Config.ENDPOINT, textEndpoint.getText());
            config.setValue(Config.ASSIGNMENT_RULE, textRule.getText());
            config.setValue(Config.LOAD_ROW_TO_START_AT, textRowToStart.getText());
            config.setValue(Config.RESET_URL_ON_LOGIN, buttonResetUrl.getSelection());
            config.setValue(Config.NO_COMPRESSION, buttonCompression.getSelection());
            config.setValue(Config.TRUNCATE_FIELDS, buttonTruncateFields.getSelection());
            config.setValue(Config.TIMEOUT_SECS, textTimeout.getText());
            config.setValue(
                Config.ENABLE_EXTRACT_STATUS_OUTPUT, buttonOutputExtractStatus.getSelection());
            config.setValue(Config.READ_UTF8, buttonReadUtf8.getSelection());
            config.setValue(Config.WRITE_UTF8, buttonWriteUtf8.getSelection());
            config.setValue(Config.EURO_DATES, buttonEuroDates.getSelection());
            config.setValue(Config.TIMEZONE, textTimezone.getText());
            config.setValue(Config.PROXY_HOST, textProxyHost.getText());
            config.setValue(Config.PROXY_PASSWORD, textProxyPassword.getText());
            config.setValue(Config.PROXY_PORT, textProxyPort.getText());
            config.setValue(Config.PROXY_USERNAME, textProxyUsername.getText());
            config.setValue(Config.PROXY_NTLM_DOMAIN, textProxyNtlmDomain.getText());
            config.setValue(Config.BULK_API_ENABLED, buttonUseBulkApi.getSelection());
            config.setValue(Config.BULK_API_SERIAL_MODE, buttonBulkApiSerialMode.getSelection());
            config.setValue(Config.BULK_API_ZIP_CONTENT, buttonBulkApiZipContent.getSelection());

            controller.saveConfig();
            controller.logout();

            input = Labels.getString("UI.ok"); // $NON-NLS-1$
            shell.close();
          }
        });
    data = new GridData();
    data.widthHint = 75;
    ok.setLayoutData(data);

    // Create the cancel button and add a handler
    // so that pressing it will set input to null
    Button cancel = new Button(buttonComp, SWT.PUSH | SWT.FLAT);
    cancel.setText(Labels.getString("UI.cancel")); // $NON-NLS-1$
    cancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            input = null;
            shell.close();
          }
        });

    // END BOTTOM COMPONENT

    data = new GridData();
    data.widthHint = 75;
    cancel.setLayoutData(data);

    // Set the OK button as the default, so
    // user can type input and press Enter
    // to dismiss
    shell.setDefaultButton(ok);

    // Set the child as the scrolled content of the ScrolledComposite
    sc.setContent(container);

    // Set the minimum size
    sc.setMinSize(768, 1024);

    // Expand both horizontally and vertically
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
  }
Пример #14
0
  /**
   * Constructor to create an editor to update/create an ontology entry
   *
   * @param display - points back to the display
   * @param oureditOntEntry - the entry being edited
   * @param ontParent - the edited item's parent in the hierarchy
   * @param newItem - true if this is a new item
   */
  public EditOntEntry(
      Display display, OntEntry oureditOntEntry, OntEntry ontParent, boolean newItem) {
    super();
    shell = new Shell(display, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL);
    shell.setText("OntEntry Information");
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    gridLayout.marginHeight = 5;
    gridLayout.makeColumnsEqualWidth = true;
    shell.setLayout(gridLayout);

    ourOntEntry = oureditOntEntry;
    ourParent = ontParent;

    if (newItem) {
      ourOntEntry.setName("");
      ourOntEntry.setImportance(Importance.MODERATE);
    }

    new Label(shell, SWT.NONE).setText("Name:");

    nameField = new Text(shell, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
    nameField.setText(ourOntEntry.getName());
    GridData gridData =
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    DisplayUtilities.setTextDimensions(nameField, gridData, 75);
    gridData.horizontalSpan = 2;
    nameField.setLayoutData(gridData);

    new Label(shell, SWT.NONE).setText("Description:");

    descArea = new Text(shell, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
    descArea.setText(ourOntEntry.getDescription());
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    DisplayUtilities.setTextDimensions(descArea, gridData, 75, 5);
    gridData.horizontalSpan = 2;
    gridData.heightHint = descArea.getLineHeight() * 3;
    descArea.setLayoutData(gridData);

    new Label(shell, SWT.NONE).setText("Importance:");
    importanceBox = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
    Enumeration impEnum = Importance.elements();
    int l = 0;
    Importance itype;
    while (impEnum.hasMoreElements()) {
      itype = (Importance) impEnum.nextElement();
      importanceBox.add(itype.toString());
      if (itype.toString().compareTo(ourOntEntry.getImportance().toString()) == 0) {
        importanceBox.select(l);
      }
      l++;
    }
    // Error checking: if no such selection is valid, set it to select index 0
    if (importanceBox.getSelectionIndex() == -1) {
      importanceBox.select(0);
    }
    importanceBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    new Label(shell, SWT.NONE).setText(" ");
    new Label(shell, SWT.NONE).setText(" ");

    addButton = new Button(shell, SWT.PUSH);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    addButton.setLayoutData(gridData);
    if (newItem) {
      addButton.setText("Add");
      addButton.addSelectionListener(
          new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
              canceled = false;
              if (!nameField.getText().trim().equals("")) {
                ConsistencyChecker checker =
                    new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries");

                if (ourOntEntry.getName() == nameField.getText() || checker.check()) {
                  ourParent.addChild(ourOntEntry);
                  ourOntEntry.setLevel(ourParent.getLevel() + 1);
                  ourOntEntry.setName(nameField.getText());
                  ourOntEntry.setDescription(descArea.getText());
                  ourOntEntry.setImportance(
                      Importance.fromString(
                          importanceBox.getItem(importanceBox.getSelectionIndex())));

                  // comment before this made no sense...
                  ourOntEntry.setID(ourOntEntry.toDatabase(ourParent.getID()));
                  System.out.println("Name of added item = " + ourOntEntry.getName());

                  shell.close();
                  shell.dispose();
                }
              } else {
                MessageBox mbox = new MessageBox(shell, SWT.ICON_ERROR);
                mbox.setMessage("Need to provide the OntEntry name");
                mbox.open();
              }
            }
          });

    } else {
      addButton.setText("Save");
      addButton.addSelectionListener(
          new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
              canceled = false;

              ConsistencyChecker checker =
                  new ConsistencyChecker(ourOntEntry.getID(), nameField.getText(), "OntEntries");

              if (ourOntEntry.getName() == nameField.getText() || checker.check()) {
                ourOntEntry.setName(nameField.getText());
                ourOntEntry.setDescription(descArea.getText());
                ourOntEntry.setImportance(
                    Importance.fromString(
                        importanceBox.getItem(importanceBox.getSelectionIndex())));
                // since this is a save, not an add, the type and parent are ignored
                ourOntEntry.setID(ourOntEntry.toDatabase(0));

                //			RationaleDB db = RationaleDB.getHandle();
                //			db.addOntEntry(ourOntEntry);

                shell.close();
                shell.dispose();
              }
            }
          });
    }

    cancelButton = new Button(shell, SWT.PUSH);
    cancelButton.setText("Cancel");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    cancelButton.setLayoutData(gridData);
    cancelButton.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent event) {
            canceled = true;
            shell.close();
            shell.dispose();
          }
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
Пример #15
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(2, false));

    final Text text = new Text(shell, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Button go = new Button(shell, SWT.PUSH);
    go.setText("Go");
    OleFrame oleFrame = new OleFrame(shell, SWT.NONE);
    oleFrame.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    OleControlSite controlSite;
    OleAutomation automation;
    try {
      controlSite = new OleControlSite(oleFrame, SWT.NONE, "Shell.Explorer");
      automation = new OleAutomation(controlSite);
      controlSite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
    } catch (SWTException ex) {
      System.out.println("Unable to open activeX control");
      display.dispose();
      return;
    }

    final OleAutomation auto = automation;
    go.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event e) {
            String url = text.getText();
            int[] rgdispid = auto.getIDsOfNames(new String[] {"Navigate", "URL"});
            int dispIdMember = rgdispid[0];
            Variant[] rgvarg = new Variant[1];
            rgvarg[0] = new Variant(url);
            int[] rgdispidNamedArgs = new int[1];
            rgdispidNamedArgs[0] = rgdispid[1];
            auto.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
          }
        });

    // Read PostData whenever we navigate to a site that uses it
    int BeforeNavigate2 = 0xfa;
    controlSite.addEventListener(
        BeforeNavigate2,
        new OleListener() {
          public void handleEvent(OleEvent event) {
            Variant url = event.arguments[1];
            Variant postData = event.arguments[4];
            if (postData != null) {
              System.out.println(
                  "PostData = " + readSafeArray(postData) + ", URL = " + url.getString());
            }
          }
        });

    // Navigate to this web site which uses post data to fill in the text field
    // and put the string "hello world" into the text box
    text.setText("file://" + Snippet186.class.getResource("Snippet186.html").getFile());
    int[] rgdispid = automation.getIDsOfNames(new String[] {"Navigate", "URL", "PostData"});
    int dispIdMember = rgdispid[0];
    Variant[] rgvarg = new Variant[2];
    rgvarg[0] = new Variant(text.getText());
    rgvarg[1] = writeSafeArray("hello world");
    int[] rgdispidNamedArgs = new int[2];
    rgdispidNamedArgs[0] = rgdispid[1];
    rgdispidNamedArgs[1] = rgdispid[2];
    automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Пример #16
0
  @Override
  public void createControl(final Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;
    Label label = new Label(container, SWT.NULL);
    label.setText("&Container:");

    containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    containerText.setLayoutData(gd);
    containerText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    Button button = new Button(container, SWT.PUSH);
    button.setText("Browse...");
    button.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent e) {
            handleBrowse();
          }
        });

    label = new Label(container, SWT.NULL);
    label.setText("&Choose a model:");

    Composite middleComposite = new Composite(container, SWT.NULL);
    FillLayout fillLayout = new FillLayout();
    middleComposite.setLayout(fillLayout);

    emptyModelButton = new Button(middleComposite, SWT.RADIO);
    emptyModelButton.setText("Empty");
    emptyModelButton.setSelection(true);
    skeletonModelButton = new Button(middleComposite, SWT.RADIO);
    skeletonModelButton.setText("Skeleton");
    exampleModelButton = new Button(middleComposite, SWT.RADIO);
    exampleModelButton.setText("Example");
    emptyModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "empty";
            radioChanged();
          }
        });
    exampleModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "example";
            radioChanged();
          }
        });
    skeletonModelButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            typeOfModel = "skeleton";
            radioChanged();
          }
        });

    /* Need to add empty label so the next controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&File name:");

    fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fileText.setLayoutData(gd);
    fileText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            Text t = (Text) e.getSource();
            String fname = t.getText();
            int i = fname.lastIndexOf(".gaml");
            if (i > 0) {
              // model title = filename less extension less all non alphanumeric characters
              titleText.setText(fname.substring(0, i).replaceAll("[^\\p{Alnum}]", ""));
            } /*
               * else if (fname.length()>0) {
               * int pos = t.getSelection().x;
               * fname = fname.replaceAll("[[^\\p{Alnum}]&&[^_-]&&[^\\x2E]]", "_");
               * t.setText(fname+".gaml");
               * t.setSelection(pos);
               * } else {
               * t.setText("new.gaml");
               * }
               */
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Author:");

    authorText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    authorText.setLayoutData(gd);
    authorText.setText(getComputerFullName());
    authorText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Model name:");

    titleText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    titleText.setLayoutData(gd);
    titleText.setText("new");
    titleText.addModifyListener(
        new ModifyListener() {

          @Override
          public void modifyText(final ModifyEvent e) {
            dialogChanged();
          }
        });

    /* Need to add empty label so the next two controls are pushed to the next line in the grid. */
    label = new Label(container, SWT.NULL);
    label.setText("");

    label = new Label(container, SWT.NULL);
    label.setText("&Model description:");

    descriptionText =
        new Text(container, SWT.WRAP | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    descriptionText.setBounds(0, 0, 250, 100);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.verticalSpan = 4;
    descriptionText.setLayoutData(gd);

    /*
     * Need to add seven empty labels in order to push next controls after the descriptionText
     * box.
     */
    // TODO Dirty!! Change the way to do this
    for (int i = 0; i < 7; i++) {
      label = new Label(container, SWT.NULL);
      label.setText("");
    }

    label = new Label(container, SWT.NULL);
    label.setText("&Create a html template \nfor the model description ?");

    middleComposite = new Composite(container, SWT.NULL);
    fillLayout = new FillLayout();
    middleComposite.setLayout(fillLayout);

    yesButton = new Button(middleComposite, SWT.RADIO);
    yesButton.setText("Yes");
    yesButton.setSelection(true);
    Button noButton = new Button(middleComposite, SWT.RADIO);
    noButton.setText("No");
    yesButton.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(final SelectionEvent se) {
            dialogChanged();
          }
        });

    /* Finished adding the custom control */
    initialize();
    dialogChanged();
    setControl(container);
  }
Пример #17
0
    protected authDialog(
        AESemaphore _sem, Display display, String realm, String tracker, String torrent_name) {
      sem = _sem;

      if (display.isDisposed()) {

        sem.release();

        return;
      }

      shell = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

      Utils.setShellIcon(shell);
      Messages.setLanguageText(shell, "authenticator.title");

      GridLayout layout = new GridLayout();
      layout.numColumns = 3;

      shell.setLayout(layout);

      GridData gridData;

      // realm

      Label realm_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(realm_label, "authenticator.realm");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      realm_label.setLayoutData(gridData);

      Label realm_value = new Label(shell, SWT.NULL);
      realm_value.setText(realm.replaceAll("&", "&&"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      realm_value.setLayoutData(gridData);

      // tracker

      Label tracker_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(tracker_label, "authenticator.tracker");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      tracker_label.setLayoutData(gridData);

      Label tracker_value = new Label(shell, SWT.NULL);
      tracker_value.setText(tracker.replaceAll("&", "&&"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      tracker_value.setLayoutData(gridData);

      if (torrent_name != null) {

        Label torrent_label = new Label(shell, SWT.NULL);
        Messages.setLanguageText(torrent_label, "authenticator.torrent");
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 1;
        torrent_label.setLayoutData(gridData);

        Label torrent_value = new Label(shell, SWT.NULL);
        torrent_value.setText(torrent_name.replaceAll("&", "&&"));
        gridData = new GridData(GridData.FILL_BOTH);
        gridData.horizontalSpan = 2;
        torrent_value.setLayoutData(gridData);
      }
      // user

      Label user_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(user_label, "authenticator.user");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      user_label.setLayoutData(gridData);

      final Text user_value = new Text(shell, SWT.BORDER);
      user_value.setText("");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      user_value.setLayoutData(gridData);

      user_value.addListener(
          SWT.Modify,
          new Listener() {
            public void handleEvent(Event event) {
              username = user_value.getText();
            }
          });

      // password

      Label password_label = new Label(shell, SWT.NULL);
      Messages.setLanguageText(password_label, "authenticator.password");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      password_label.setLayoutData(gridData);

      final Text password_value = new Text(shell, SWT.BORDER);
      password_value.setEchoChar('*');
      password_value.setText("");
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      password_value.setLayoutData(gridData);

      password_value.addListener(
          SWT.Modify,
          new Listener() {
            public void handleEvent(Event event) {
              password = password_value.getText();
            }
          });

      // persist

      Label blank_label = new Label(shell, SWT.NULL);
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 1;
      blank_label.setLayoutData(gridData);

      final Button checkBox = new Button(shell, SWT.CHECK);
      checkBox.setText(MessageText.getString("authenticator.savepassword"));
      gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalSpan = 2;
      checkBox.setLayoutData(gridData);
      checkBox.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              persist = checkBox.getSelection();
            }
          });

      // line

      Label labelSeparator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      gridData.horizontalSpan = 3;
      labelSeparator.setLayoutData(gridData);

      // buttons

      new Label(shell, SWT.NULL);

      Button bOk = new Button(shell, SWT.PUSH);
      Messages.setLanguageText(bOk, "Button.ok");
      gridData =
          new GridData(
              GridData.FILL_HORIZONTAL
                  | GridData.HORIZONTAL_ALIGN_END
                  | GridData.HORIZONTAL_ALIGN_FILL);
      gridData.grabExcessHorizontalSpace = true;
      gridData.widthHint = 70;
      bOk.setLayoutData(gridData);
      bOk.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              close(true);
            }
          });

      Button bCancel = new Button(shell, SWT.PUSH);
      Messages.setLanguageText(bCancel, "Button.cancel");
      gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
      gridData.grabExcessHorizontalSpace = false;
      gridData.widthHint = 70;
      bCancel.setLayoutData(gridData);
      bCancel.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event e) {
              close(false);
            }
          });

      shell.setDefaultButton(bOk);

      shell.addListener(
          SWT.Traverse,
          new Listener() {
            public void handleEvent(Event e) {
              if (e.character == SWT.ESC) {
                close(false);
              }
            }
          });

      shell.pack();

      Utils.centreWindow(shell);

      shell.open();

      shell.forceActive();
    }