/**
  * forceFocus.
  *
  * @return
  */
 public void forceFocus() {
   if (combo.getEnabled()) {
     combo.forceFocus();
   } else {
     checkbox.forceFocus();
   }
 }
  protected void createServerSelectionControl(Composite parent) {
    Group group = new Group(parent, SWT.NONE);
    group.setText(PHPServerUIMessages.getString("ServerTab.server")); // $NON-NLS-1$
    GridLayout ly = new GridLayout(1, false);
    ly.marginHeight = 0;
    ly.marginWidth = 0;
    group.setLayout(ly);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite phpServerComp = new Composite(group, SWT.NONE);
    phpServerComp.setLayout(new GridLayout(4, false));
    phpServerComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    phpServerComp.setFont(parent.getFont());

    Label label = new Label(phpServerComp, SWT.WRAP);
    GridData data = new GridData(GridData.BEGINNING);
    data.widthHint = 100;
    label.setLayoutData(data);
    label.setFont(parent.getFont());
    label.setText(PHPServerUIMessages.getString("ServerLaunchConfigurationTab.0")); // $NON-NLS-1$

    serverCombo = new Combo(phpServerComp, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
    serverCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    serverCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleServerSelection();
          }
        });

    createNewServer =
        createPushButton(
            phpServerComp, PHPServerUIMessages.getString("ServerTab.new"), null); // $NON-NLS-1$
    createNewServer.addSelectionListener(fListener);

    configureServers =
        createPushButton(
            phpServerComp,
            PHPServerUIMessages.getString("ServerTab.configure"),
            null); //$NON-NLS-1$
    configureServers.addSelectionListener(fListener);

    servers = new ArrayList<Server>();
    populateServerList(servers);

    // initialize the servers list
    if (!servers.isEmpty()) {
      for (int i = 0; i < servers.size(); i++) {
        Server svr = servers.get(i);
        serverCombo.add(svr.getName());
      }
    }

    // select first item in list
    if (serverCombo.getItemCount() > 0) {
      serverCombo.select(0);
    }

    serverCombo.forceFocus();
  }
Exemplo n.º 3
0
  private void savePreferences() {
    // validate port string
    try {
      new PortIterator(portsText.getText());
    } catch (Exception e) {
      tabFolder.setSelection(portsTabItem);
      portsText.forceFocus();
      throw new FetcherException("unparseablePortString", e);
    }

    scannerConfig.selectedPinger =
        (String) pingersCombo.getData(Integer.toString(pingersCombo.getSelectionIndex()));
    if (!pingerRegistry.checkSelectedPinger()) {
      tabFolder.setSelection(scanningTabItem);
      pingersCombo.forceFocus();
      throw new FetcherException("unsupportedPinger");
    }

    scannerConfig.maxThreads = parseIntValue(maxThreadsText);
    scannerConfig.threadDelay = parseIntValue(threadDelayText);
    scannerConfig.pingCount = parseIntValue(pingingCountText);
    scannerConfig.pingTimeout = parseIntValue(pingingTimeoutText);
    scannerConfig.scanDeadHosts = deadHostsCheckbox.getSelection();
    scannerConfig.skipBroadcastAddresses = skipBroadcastsCheckbox.getSelection();
    scannerConfig.portTimeout = parseIntValue(portTimeoutText);
    scannerConfig.adaptPortTimeout = adaptTimeoutCheckbox.getSelection();
    scannerConfig.minPortTimeout = parseIntValue(minPortTimeoutText);
    scannerConfig.portString = portsText.getText();
    scannerConfig.useRequestedPorts = addRequestedPortsCheckbox.getSelection();
    scannerConfig.notAvailableText = notAvailableText.getText();
    scannerConfig.notScannedText = notScannedText.getText();
    for (int i = 0; i < displayMethod.length; i++) {
      if (displayMethod[i].getSelection()) guiConfig.displayMethod = DisplayMethod.values()[i];
    }
    guiConfig.showScanStats = showInfoCheckbox.getSelection();
    guiConfig.askScanConfirmation = askConfirmationCheckbox.getSelection();
  }
  /**
   * Creates the top group with the field to replace which string and by what and by which options.
   *
   * @param content A composite with a 1-column grid layout
   */
  public void createStringGroup(Composite content) {

    final ExtractStringRefactoring ref = getOurRefactoring();

    Group group = new Group(content, SWT.NONE);
    group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (ref.getMode() == ExtractStringRefactoring.Mode.EDIT_SOURCE) {
      group.setText("String Replacement");
    } else {
      group.setText("New String");
    }

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    group.setLayout(layout);

    // line: Textfield for string value (based on selection, if any)

    Label label = new Label(group, SWT.NONE);
    label.setText("&String");

    String selectedString = ref.getTokenString();

    mStringValueField = new Text(group, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    mStringValueField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mStringValueField.setText(selectedString != null ? selectedString : ""); // $NON-NLS-1$

    ref.setNewStringValue(mStringValueField.getText());

    mStringValueField.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validatePage();
          }
        });

    // TODO provide an option to replace all occurences of this string instead of
    // just the one.

    // line : Textfield for new ID

    label = new Label(group, SWT.NONE);
    if (ref.getMode() == ExtractStringRefactoring.Mode.EDIT_SOURCE) {
      label.setText("&Replace by R.string.");
    } else if (ref.getMode() == ExtractStringRefactoring.Mode.SELECT_NEW_ID) {
      label.setText("New &R.string.");
    } else {
      label.setText("ID &R.string.");
    }

    mStringIdCombo = new Combo(group, SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.DROP_DOWN);
    mStringIdCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mStringIdCombo.setText(guessId(selectedString));
    mStringIdCombo.forceFocus();

    ref.setNewStringId(mStringIdCombo.getText().trim());

    mStringIdCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validatePage();
          }
        });
    mStringIdCombo.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            validatePage();
          }
        });
  }