示例#1
0
 private void loadPreferences() {
   pingerRegistry.checkSelectedPinger();
   maxThreadsText.setText(Integer.toString(scannerConfig.maxThreads));
   threadDelayText.setText(Integer.toString(scannerConfig.threadDelay));
   String[] pingerNames = pingerRegistry.getRegisteredNames();
   for (int i = 0; i < pingerNames.length; i++) {
     if (scannerConfig.selectedPinger.equals(pingerNames[i])) {
       pingersCombo.select(i);
     }
   }
   pingingCountText.setText(Integer.toString(scannerConfig.pingCount));
   pingingTimeoutText.setText(Integer.toString(scannerConfig.pingTimeout));
   deadHostsCheckbox.setSelection(scannerConfig.scanDeadHosts);
   skipBroadcastsCheckbox.setSelection(scannerConfig.skipBroadcastAddresses);
   portTimeoutText.setText(Integer.toString(scannerConfig.portTimeout));
   adaptTimeoutCheckbox.setSelection(scannerConfig.adaptPortTimeout);
   minPortTimeoutText.setText(Integer.toString(scannerConfig.minPortTimeout));
   minPortTimeoutText.setEnabled(scannerConfig.adaptPortTimeout);
   portsText.setText(scannerConfig.portString);
   addRequestedPortsCheckbox.setSelection(scannerConfig.useRequestedPorts);
   notAvailableText.setText(scannerConfig.notAvailableText);
   notScannedText.setText(scannerConfig.notScannedText);
   displayMethod[guiConfig.displayMethod.ordinal()].setSelection(true);
   showInfoCheckbox.setSelection(guiConfig.showScanStats);
   askConfirmationCheckbox.setSelection(guiConfig.askScanConfirmation);
 }
  private boolean preScanChecks() {
    // autodetect usable pingers and silently ignore any changes -
    // user should see any errors only if they have explicitly selected a pinger
    pingerRegistry.checkSelectedPinger();

    // ask user for confirmation if needed
    if (guiConfig.askScanConfirmation && resultTable.getItemCount() > 0) {
      MessageBox box =
          new MessageBox(resultTable.getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.SHEET);
      box.setText(Labels.getLabel("text.scan.new"));
      box.setMessage(Labels.getLabel("text.scan.confirmation"));
      if (box.open() != SWT.YES) {
        return false;
      }
    }
    return true;
  }
示例#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();
  }