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; }
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(); }
/** This method initializes scanningTab */ private void createScanningTab() { RowLayout rowLayout = createRowLayout(); scanningTab = new Composite(tabFolder, SWT.NONE); scanningTab.setLayout(rowLayout); GridLayout groupLayout = new GridLayout(); groupLayout.numColumns = 2; Group threadsGroup = new Group(scanningTab, SWT.NONE); threadsGroup.setText(Labels.getLabel("preferences.threads")); threadsGroup.setLayout(groupLayout); GridData gridData = new GridData(80, SWT.DEFAULT); Label label; label = new Label(threadsGroup, SWT.NONE); label.setText(Labels.getLabel("preferences.threads.delay")); threadDelayText = new Text(threadsGroup, SWT.BORDER); threadDelayText.setLayoutData(gridData); label = new Label(threadsGroup, SWT.NONE); label.setText(Labels.getLabel("preferences.threads.maxThreads")); maxThreadsText = new Text(threadsGroup, SWT.BORDER); maxThreadsText.setLayoutData(gridData); // new Label(threadsGroup, SWT.NONE); // Button checkButton = new Button(threadsGroup, SWT.NONE); // checkButton.setText(Labels.getLabel("button.check")); // checkButton.setLayoutData(gridData); // checkButton.addListener(SWT.Selection, new CheckButtonListener()); Group pingingGroup = new Group(scanningTab, SWT.NONE); pingingGroup.setLayout(groupLayout); pingingGroup.setText(Labels.getLabel("preferences.pinging")); label = new Label(pingingGroup, SWT.NONE); label.setText(Labels.getLabel("preferences.pinging.type")); pingersCombo = new Combo(pingingGroup, SWT.DROP_DOWN | SWT.READ_ONLY); pingersCombo.setLayoutData(gridData); String[] pingerNames = pingerRegistry.getRegisteredNames(); for (int i = 0; i < pingerNames.length; i++) { pingersCombo.add(Labels.getLabel(pingerNames[i])); // this is used by savePreferences() pingersCombo.setData(Integer.toString(i), pingerNames[i]); } pingersCombo.select(0); label = new Label(pingingGroup, SWT.NONE); label.setText(Labels.getLabel("preferences.pinging.count")); pingingCountText = new Text(pingingGroup, SWT.BORDER); pingingCountText.setLayoutData(gridData); label = new Label(pingingGroup, SWT.NONE); label.setText(Labels.getLabel("preferences.pinging.timeout")); pingingTimeoutText = new Text(pingingGroup, SWT.BORDER); pingingTimeoutText.setLayoutData(gridData); GridData gridDataWithSpan = new GridData(); gridDataWithSpan.horizontalSpan = 2; deadHostsCheckbox = new Button(pingingGroup, SWT.CHECK); deadHostsCheckbox.setText(Labels.getLabel("preferences.pinging.deadHosts")); deadHostsCheckbox.setLayoutData(gridDataWithSpan); Group skippingGroup = new Group(scanningTab, SWT.NONE); skippingGroup.setLayout(groupLayout); skippingGroup.setText(Labels.getLabel("preferences.skipping")); skipBroadcastsCheckbox = new Button(skippingGroup, SWT.CHECK); skipBroadcastsCheckbox.setText(Labels.getLabel("preferences.skipping.broadcast")); GridData gridDataWithSpan2 = new GridData(); gridDataWithSpan2.horizontalSpan = 2; skipBroadcastsCheckbox.setLayoutData(gridDataWithSpan2); }