/**
   * Creates the contents of this group, using the given toolkit where appropriate so that the
   * controls have the form editor look and feel.
   *
   * @param parent parent composite
   * @param toolkit toolkit to create controls with
   */
  protected void createFormContents(Composite parent, FormToolkit toolkit) {
    fGrouping = GROUP_BY_NONE;

    Composite comp = toolkit.createComposite(parent);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = layout.marginHeight = 0;
    comp.setLayout(layout);
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));
    comp.setFont(parent.getFont());

    createTree(comp, toolkit);
    createButtons(comp, toolkit);

    fCountLabel = toolkit.createLabel(comp, ""); // $NON-NLS-1$
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    fCountLabel.setLayoutData(data);

    updateButtons();
    initializeFilters();
  }
  /**
   * Creates the buttons in this group inside a new composite
   *
   * @param parent parent composite
   * @param toolkit toolkit to give form style or <code>null</code> for dialog style
   */
  private void createButtons(Composite parent, FormToolkit toolkit) {
    if (toolkit != null) {
      Composite buttonComp = toolkit.createComposite(parent);
      GridLayout layout = new GridLayout();
      layout.marginWidth = layout.marginHeight = 0;
      buttonComp.setLayout(layout);
      buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));

      fSelectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH);
      fSelectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      fDeselectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH);
      fDeselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Label emptySpace = new Label(buttonComp, SWT.NONE);
      GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH);
      fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      fDeselectAllButton =
          toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH);
      fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      emptySpace = new Label(buttonComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectRequiredButton =
          toolkit.createButton(buttonComp, Messages.TargetContentsGroup_4, SWT.PUSH);
      fSelectRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Composite filterComp = toolkit.createComposite(buttonComp);
      layout = new GridLayout();
      layout.marginWidth = layout.marginHeight = 0;
      filterComp.setLayout(layout);
      filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));

      fModeLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing);

      fPluginModeButton =
          toolkit.createButton(filterComp, Messages.TargetContentsGroup_PluginMode, SWT.RADIO);
      fPluginModeButton.setSelection(true);
      fFeaureModeButton =
          toolkit.createButton(filterComp, Messages.TargetContentsGroup_FeatureMode, SWT.RADIO);
      fFeaureModeButton.setSelection(true);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9);

      fShowPluginsButton =
          toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK);
      fShowPluginsButton.setSelection(true);
      fShowSourceButton =
          toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK);
      fShowSourceButton.setSelection(true);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fGroupLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_0);

      fGroupComboPart = new ComboPart();
      fGroupComboPart.createControl(filterComp, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
      gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 10;
      fGroupComboPart.getControl().setLayoutData(gd);
      fGroupComboPart.setItems(
          new String[] {
            Messages.TargetContentsGroup_1,
            Messages.TargetContentsGroup_2,
            Messages.TargetContentsGroup_3
          });
      fGroupComboPart.setVisibleItemCount(30);
      fGroupComboPart.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleGroupChange();
            }
          });
      fGroupComboPart.select(0);

    } else {
      Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
      fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
      fDeselectButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);

      Label emptySpace = new Label(buttonComp, SWT.NONE);
      GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectAllButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
      fDeselectAllButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);

      emptySpace = new Label(buttonComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectRequiredButton =
          SWTFactory.createPushButton(buttonComp, Messages.TargetContentsGroup_4, null);

      Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
      filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));

      fModeLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing, 1);

      fPluginModeButton =
          SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_PluginMode);
      fFeaureModeButton =
          SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_FeatureMode);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);

      fShowPluginsButton =
          SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
      fShowSourceButton =
          SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fGroupLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_0, 1);
      fGroupCombo =
          SWTFactory.createCombo(
              filterComp,
              SWT.READ_ONLY,
              1,
              new String[] {
                Messages.TargetContentsGroup_1,
                Messages.TargetContentsGroup_2,
                Messages.TargetContentsGroup_3
              });
      gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 10;
      fGroupCombo.setLayoutData(gd);
      fGroupCombo.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleGroupChange();
            }
          });
      fGroupCombo.select(0);
    }

    fSelectButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fTree.getSelection().isEmpty()) {
              Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
              for (int i = 0; i < selected.length; i++) {
                fTree.setChecked(selected[i], true);
              }
              saveIncludedBundleState();
              contentChanged();
              updateButtons();
              fTree.update(
                  fTargetDefinition.getBundleContainers(),
                  new String[] {IBasicPropertyConstants.P_TEXT});
            }
          }
        });

    fDeselectButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fTree.getSelection().isEmpty()) {
              Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
              for (int i = 0; i < selected.length; i++) {
                fTree.setChecked(selected[i], false);
              }
              saveIncludedBundleState();
              contentChanged();
              updateButtons();
              fTree.update(
                  fTargetDefinition.getBundleContainers(),
                  new String[] {IBasicPropertyConstants.P_TEXT});
            }
          }
        });

    fSelectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fTree.setAllChecked(true);
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fDeselectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fTree.setAllChecked(false);
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fSelectRequiredButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Object[] allChecked = fTree.getCheckedLeafElements();
            Object[] required = null;
            if (fFeaureModeButton.getSelection()) {
              required = getRequiredFeatures(fTargetDefinition.getAllFeatures(), allChecked);
            } else {
              required = getRequiredPlugins(fAllBundles, allChecked);
            }
            for (int i = 0; i < required.length; i++) {
              fTree.setChecked(required[i], true);
            }
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fPluginModeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Moving from feature based filtering to plug-in based, need to update storage
            ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_PLUGIN);
            contentChanged();
            fTargetDefinition.setIncluded(null);

            fGroupLabel.setEnabled(true);
            if (fGroupCombo != null) {
              fGroupCombo.setEnabled(true);
            } else {
              fGroupComboPart.getControl().setEnabled(true);
            }

            fTree.getControl().setRedraw(false);
            fTree.refresh(false);
            fTree.expandAll();
            updateCheckState();
            updateButtons();
            fTree.getControl().setRedraw(true);
          }
        });
    fPluginModeButton.setSelection(true);
    GridData gd = new GridData();
    gd.horizontalIndent = 10;
    fPluginModeButton.setLayoutData(gd);

    fFeaureModeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Moving from plug-in based filtering to feature based, need to update storage
            ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_FEATURE);
            contentChanged();
            fTargetDefinition.setIncluded(null);

            fGroupLabel.setEnabled(false);
            if (fGroupCombo != null) {
              fGroupCombo.setEnabled(false);
            } else {
              fGroupComboPart.getControl().setEnabled(false);
            }

            fTree.getControl().setRedraw(false);
            fTree.refresh(false);
            fTree.expandAll();
            updateCheckState();
            updateButtons();
            fTree.getControl().setRedraw(true);
          }
        });
    fFeaureModeButton.setSelection(false);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fFeaureModeButton.setLayoutData(gd);

    fShowPluginsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fShowPluginsButton.getSelection()) {
              fTree.addFilter(fPluginFilter);
            } else {
              fTree.removeFilter(fPluginFilter);
              fTree.expandAll();
              updateCheckState();
            }
            updateButtons();
          }
        });
    fShowPluginsButton.setSelection(true);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fShowPluginsButton.setLayoutData(gd);

    fShowSourceButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fShowSourceButton.getSelection()) {
              fTree.addFilter(fSourceFilter);
            } else {
              fTree.removeFilter(fSourceFilter);
              fTree.expandAll();
              updateCheckState();
            }
            updateButtons();
          }
        });
    fShowSourceButton.setSelection(true);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fShowSourceButton.setLayoutData(gd);
  }
    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();
    }
Ejemplo n.º 4
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();
    }