mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
* SelectFetchersDialog now has the preferences button
* AbstractModalDialog now enforces stricter rules resulting in smaller subclasses git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@418 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
parent
8902d3cbcd
commit
c1655a2b2c
@ -123,6 +123,7 @@ text.fetchers.selectedList=Selected fetchers
|
||||
text.fetchers.availableList=Available fetchers
|
||||
text.fetchers.info=Fetcher information:
|
||||
text.fetchers.info.notAvailable=Unfortunately, no additional information about this fetcher is available.
|
||||
text.fetchers.preferences=Preferences of the selected fetcher
|
||||
text.about=%NAME\n\nVersion: %VERSION\nBuild: %BUILD\nBuild date: %DATE\n\n%COPYLEFT
|
||||
text.about.system=Java: %JAVA\nOS: %OS
|
||||
button.OK=OK
|
||||
@ -149,6 +150,7 @@ button.insert=&Insert
|
||||
button.add=&Add
|
||||
button.left=<<
|
||||
button.right=>>
|
||||
button.fetcherPrefs=...
|
||||
button.check=Chec&k...
|
||||
combobox.feeder.tooltip=IP Feeder selection. Change this if you need another source for IP addresses to scan
|
||||
list.unknown.img=images/list/unknown.png
|
||||
|
||||
@ -26,10 +26,10 @@ public interface FetcherRegistry {
|
||||
|
||||
/**
|
||||
* Searches for selected fetcher with the given label
|
||||
* @param label
|
||||
* @param id
|
||||
* @return the index, if found, or -1
|
||||
*/
|
||||
public int getSelectedFetcherIndex(String label);
|
||||
public int getSelectedFetcherIndex(String id);
|
||||
|
||||
/**
|
||||
* Updates the list, retaining only items that are passed in the array.
|
||||
|
||||
@ -11,11 +11,9 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
@ -25,31 +23,15 @@ import org.eclipse.swt.widgets.Text;
|
||||
*/
|
||||
public class AboutDialog extends AbstractModalDialog {
|
||||
|
||||
public AboutDialog() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
createShell();
|
||||
super.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
|
||||
protected void populateShell() {
|
||||
shell.setText(Labels.getLabel("title.about"));
|
||||
shell.setSize(new Point(400, 373));
|
||||
|
||||
Label iconLabel = new Label(shell, SWT.ICON);
|
||||
iconLabel.setLocation(10, 10);
|
||||
if (parent != null) {
|
||||
iconLabel.setImage(parent.getImage());
|
||||
shell.setImage(parent.getImage());
|
||||
if (shell.getImage() != null) {
|
||||
iconLabel.setImage(shell.getImage());
|
||||
}
|
||||
iconLabel.pack();
|
||||
int leftBound = iconLabel.getBounds().width + 20;
|
||||
|
||||
@ -30,8 +30,12 @@ import org.eclipse.swt.widgets.Shell;
|
||||
public abstract class AbstractModalDialog {
|
||||
|
||||
protected Shell shell;
|
||||
|
||||
|
||||
public void open() {
|
||||
if (shell == null || shell.isDisposed()) {
|
||||
createShell();
|
||||
}
|
||||
|
||||
// center dialog box according to the parent window
|
||||
if (shell.getParent() != null) {
|
||||
Rectangle parentBounds = shell.getParent().getBounds();
|
||||
@ -54,6 +58,29 @@ public abstract class AbstractModalDialog {
|
||||
shell = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the newly created shell with controls
|
||||
*/
|
||||
protected abstract void populateShell();
|
||||
|
||||
protected final void createShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
|
||||
shell = new Shell(parent, getShellStyle());
|
||||
if (parent != null)
|
||||
shell.setImage(parent.getImage());
|
||||
|
||||
populateShell();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return combined style constants of the shell to be created
|
||||
*/
|
||||
protected int getShellStyle() {
|
||||
return SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Positions 2 buttons at the bottom-right part of the shell.
|
||||
* On MacOS also changes OK and cancel button order.
|
||||
|
||||
@ -8,8 +8,8 @@ package net.azib.ipscan.gui;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import net.azib.ipscan.config.ConfigDetector;
|
||||
import net.azib.ipscan.config.ScannerConfig;
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.config.ScannerConfig;
|
||||
import net.azib.ipscan.gui.util.LayoutHelper;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
@ -21,7 +21,6 @@ import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.ProgressBar;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
@ -51,21 +50,9 @@ public class ConfigDetectorDialog extends AbstractModalDialog implements ConfigD
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
createShell();
|
||||
super.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
shell.setLayout(LayoutHelper.formLayout(10, 10, 10));
|
||||
|
||||
protected void populateShell() {
|
||||
shell.setText(Labels.getLabel("title.configDetect"));
|
||||
shell.setLayout(LayoutHelper.formLayout(10, 10, 10));
|
||||
|
||||
Label infoLabel = new Label(shell, SWT.WRAP);
|
||||
infoLabel.setText(Labels.getLabel("text.configDetect"));
|
||||
|
||||
@ -18,7 +18,6 @@ import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
@ -41,18 +40,13 @@ public class DetailsWindow extends AbstractModalDialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
createShell(resultTable.getShell());
|
||||
super.open();
|
||||
protected int getShellStyle() {
|
||||
return SWT.TOOL | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell(Shell parent) {
|
||||
shell = new Shell(parent, SWT.TOOL | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
|
||||
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
shell.setText(Labels.getLabel("title.details"));
|
||||
shell.setImage(parent.getImage());
|
||||
shell.setLayout(LayoutHelper.formLayout(3, 3, 3));
|
||||
shell.setSize(guiConfig.detailsWindowSize);
|
||||
|
||||
@ -119,6 +113,7 @@ public class DetailsWindow extends AbstractModalDialog {
|
||||
if (e.detail == SWT.TRAVERSE_RETURN) {
|
||||
guiConfig.detailsWindowSize = shell.getSize();
|
||||
shell.close();
|
||||
shell.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,13 +29,10 @@ public class EditFavoritesDialog extends AbstractModalDialog {
|
||||
|
||||
public EditFavoritesDialog(FavoritesConfig favoritesConfig) {
|
||||
this.favoritesConfig = favoritesConfig;
|
||||
createShell();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
|
||||
@ -48,13 +48,10 @@ public class EditOpenersDialog extends AbstractModalDialog {
|
||||
public EditOpenersDialog(FetcherRegistry fetcherRegistry, OpenersConfig openersConfig) {
|
||||
this.fetcherRegistry = fetcherRegistry;
|
||||
this.openersConfig = openersConfig;
|
||||
createShell();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
|
||||
@ -27,19 +27,8 @@ public class GettingStartedDialog extends AbstractModalDialog {
|
||||
private Button closeButton;
|
||||
private Button nextButton;
|
||||
|
||||
public GettingStartedDialog() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
createShell();
|
||||
super.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
protected void populateShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
|
||||
@ -31,16 +31,14 @@ public class InputDialog extends AbstractModalDialog {
|
||||
private String message;
|
||||
|
||||
public InputDialog(String title, String message) {
|
||||
createShell();
|
||||
populateShell();
|
||||
shell.setText(title);
|
||||
messageLabel.setText(message);
|
||||
messageLabel.pack();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
|
||||
|
||||
@ -26,12 +26,10 @@ import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.TabFolder;
|
||||
import org.eclipse.swt.widgets.TabItem;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
@ -107,13 +105,8 @@ public class PreferencesDialog extends AbstractModalDialog {
|
||||
super.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
|
||||
shell = new Shell(currentDisplay != null ? currentDisplay.getActiveShell() : null, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
shell.setText(Labels.getLabel("title.preferences"));
|
||||
shell.setLayout(LayoutHelper.formLayout(10, 10, 4));
|
||||
|
||||
|
||||
@ -37,22 +37,14 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
|
||||
private List selectedFetchersList;
|
||||
private List registeredFetchersList;
|
||||
Map<String, String> registeredFetcherLabelsByNames = new HashMap<String, String>();
|
||||
Map<String, String> registeredFetcherIdsByNames = new HashMap<String, String>();
|
||||
|
||||
public SelectFetchersDialog(FetcherRegistry fetcherRegistry) {
|
||||
this.fetcherRegistry = fetcherRegistry;
|
||||
}
|
||||
|
||||
public void open() {
|
||||
// create controls on demand
|
||||
createShell();
|
||||
super.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay != null ? currentDisplay.getActiveShell() : null;
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
@ -88,10 +80,15 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
Button removeButton = new Button(shell, SWT.NONE);
|
||||
removeButton.setText(Labels.getLabel("button.right"));
|
||||
|
||||
Button prefsButton = new Button(shell, SWT.NONE);
|
||||
prefsButton.setText(Labels.getLabel("button.fetcherPrefs"));
|
||||
prefsButton.setToolTipText(Labels.getLabel("text.fetchers.preferences"));
|
||||
|
||||
upButton.setLayoutData(LayoutHelper.formData(new FormAttachment(selectedFetchersList), new FormAttachment(downButton, 0, SWT.RIGHT), new FormAttachment(selectedLabel), null));
|
||||
downButton.setLayoutData(LayoutHelper.formData(new FormAttachment(selectedFetchersList), null, new FormAttachment(upButton), null));
|
||||
addButton.setLayoutData(LayoutHelper.formData(new FormAttachment(selectedFetchersList), new FormAttachment(downButton, 0, SWT.RIGHT), new FormAttachment(downButton, 16), null));
|
||||
removeButton.setLayoutData(LayoutHelper.formData(new FormAttachment(selectedFetchersList), new FormAttachment(downButton, 0, SWT.RIGHT), new FormAttachment(addButton), null));
|
||||
prefsButton.setLayoutData(LayoutHelper.formData(new FormAttachment(selectedFetchersList), new FormAttachment(downButton, 0, SWT.RIGHT), new FormAttachment(removeButton, 16), null));
|
||||
|
||||
Label registeredLabel = new Label(shell, SWT.NONE);
|
||||
registeredLabel.setText(Labels.getLabel("text.fetchers.availableList"));
|
||||
@ -104,7 +101,7 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
while (i.hasNext()) {
|
||||
Fetcher fetcher = i.next();
|
||||
String fetcherName = fetcher.getName();
|
||||
registeredFetcherLabelsByNames.put(fetcherName, fetcher.getId());
|
||||
registeredFetcherIdsByNames.put(fetcherName, fetcher.getId());
|
||||
if (selectedFetchersList.indexOf(fetcherName) < 0)
|
||||
registeredFetchersList.add(fetcherName);
|
||||
}
|
||||
@ -125,6 +122,7 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
AddRemoveButtonListener removeButtonListener = new AddRemoveButtonListener(selectedFetchersList, registeredFetchersList);
|
||||
removeButton.addListener(SWT.Selection, removeButtonListener);
|
||||
selectedFetchersList.addListener(SWT.MouseDoubleClick, removeButtonListener);
|
||||
prefsButton.addListener(SWT.Selection, new PrefsListener());
|
||||
|
||||
// this is a workaround for limitation of FormLayout to remove the extra edge below the form
|
||||
shell.layout();
|
||||
@ -136,12 +134,14 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
cancelButton.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
shell.close();
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
okButton.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event event) {
|
||||
saveFetchersToRegistry(selectedFetchersList.getItems());
|
||||
shell.close();
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -156,12 +156,26 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
fetchersLabelsToRetain[0] = IPFetcher.ID;
|
||||
|
||||
for (int i = 0; i < fetchersNamesToSave.length; i++) {
|
||||
fetchersLabelsToRetain[i+1] = registeredFetcherLabelsByNames.get(fetchersNamesToSave[i]);
|
||||
fetchersLabelsToRetain[i+1] = registeredFetcherIdsByNames.get(fetchersNamesToSave[i]);
|
||||
}
|
||||
fetcherRegistry.updateSelectedFetchers(fetchersLabelsToRetain);
|
||||
}
|
||||
|
||||
private static class AddRemoveButtonListener implements Listener {
|
||||
class PrefsListener implements Listener {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
String[] selection = selectedFetchersList.getSelection();
|
||||
String fetcherName = selection.length > 0 ? selection[0] : selectedFetchersList.getItem(0);
|
||||
for (Fetcher fetcher : fetcherRegistry.getRegisteredFetchers()) {
|
||||
if (fetcherName.equals(fetcher.getName())) {
|
||||
fetcherRegistry.openPreferencesEditor(fetcher);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class AddRemoveButtonListener implements Listener {
|
||||
|
||||
private List fromList;
|
||||
private List toList;
|
||||
@ -183,5 +197,5 @@ public class SelectFetchersDialog extends AbstractModalDialog {
|
||||
fromList.remove(selectedItems);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -21,9 +21,7 @@ import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
/**
|
||||
@ -42,44 +40,36 @@ public class StatisticsDialog extends AbstractModalDialog {
|
||||
@Override
|
||||
public void open() {
|
||||
if (scanningResults.isInfoAvailable()) {
|
||||
createShell();
|
||||
if (shell != null) {
|
||||
// close the same window if it is already open ('scanning incomplete')
|
||||
shell.close();
|
||||
shell.dispose();
|
||||
}
|
||||
|
||||
super.open();
|
||||
}
|
||||
else {
|
||||
throw new UserErrorException("commands.noResults");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes shell
|
||||
*/
|
||||
private void createShell() {
|
||||
if (shell != null) {
|
||||
// close the same window if it is already open ('scanning incomplete')
|
||||
shell.close();
|
||||
shell.dispose();
|
||||
}
|
||||
|
||||
Display currentDisplay = Display.getCurrent();
|
||||
Shell parent = currentDisplay.getShells()[0];
|
||||
shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
|
||||
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
shell.setText(Labels.getLabel("title.statistics"));
|
||||
shell.setLayout(LayoutHelper.formLayout(10, 10, 15));
|
||||
|
||||
Label iconLabel = new Label(shell, SWT.ICON);
|
||||
iconLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(0), null, new FormAttachment(0), null));
|
||||
iconLabel.setImage(parent.getImage());
|
||||
shell.setImage(parent.getImage());
|
||||
iconLabel.setImage(shell.getImage());
|
||||
|
||||
Label titleLabel = new Label(shell, SWT.NONE);
|
||||
FontData sysFontData = currentDisplay.getSystemFont().getFontData()[0];
|
||||
FontData sysFontData = shell.getDisplay().getSystemFont().getFontData()[0];
|
||||
titleLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(iconLabel), null, new FormAttachment(0), null));
|
||||
titleLabel.setFont(new Font(null, sysFontData.getName(), sysFontData.getHeight()+3, sysFontData.getStyle() | SWT.BOLD));
|
||||
titleLabel.setText(Labels.getLabel(scanningResults.getScanInfo().isCompletedNormally() ? "text.scan.completed" : "text.scan.incomplete"));
|
||||
|
||||
Text statsText = new Text(shell, SWT.MULTI | SWT.READ_ONLY);
|
||||
statsText.setBackground(currentDisplay.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
statsText.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
|
||||
statsText.setLayoutData(LayoutHelper.formData(new FormAttachment(iconLabel), null, new FormAttachment(titleLabel), null));
|
||||
statsText.setText(prepareText());
|
||||
statsText.pack();
|
||||
@ -88,7 +78,6 @@ public class StatisticsDialog extends AbstractModalDialog {
|
||||
Point buttonSize = button.getSize();
|
||||
button.setLayoutData(LayoutHelper.formData(buttonSize.x, buttonSize.y, null, new FormAttachment(statsText, 30, SWT.RIGHT), new FormAttachment(statsText), null));
|
||||
|
||||
shell.layout();
|
||||
shell.pack();
|
||||
}
|
||||
|
||||
|
||||
@ -6,24 +6,42 @@
|
||||
|
||||
package net.azib.ipscan.gui.fetchers;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import net.azib.ipscan.fetchers.HTTPSenderFetcher;
|
||||
import net.azib.ipscan.gui.InputDialog;
|
||||
import net.azib.ipscan.gui.AbstractModalDialog;
|
||||
import net.azib.ipscan.gui.util.LayoutHelper;
|
||||
|
||||
/**
|
||||
* HTTPSenderFetcherPrefs
|
||||
*
|
||||
* @author Anton Keks
|
||||
*/
|
||||
public class HTTPSenderFetcherPrefs implements Runnable {
|
||||
public class HTTPSenderFetcherPrefs extends AbstractModalDialog implements Runnable {
|
||||
|
||||
private HTTPSenderFetcher fetcher;
|
||||
|
||||
public HTTPSenderFetcherPrefs(HTTPSenderFetcher fetcher) {
|
||||
this.fetcher = fetcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
shell = new Shell(Display.getCurrent().getActiveShell(), SWT.DIALOG_TRIM);
|
||||
shell.setText(fetcher.getName());
|
||||
shell.setLayout(LayoutHelper.formLayout(3, 3, 3));
|
||||
|
||||
Label label = new Label(shell, SWT.NONE);
|
||||
label.setText(fetcher.getTextToSend());
|
||||
|
||||
shell.pack();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
new InputDialog(fetcher.getName(), "hello").open(fetcher.getTextToSend());
|
||||
open();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
/**
|
||||
*
|
||||
* This file is a part of Angry IP Scanner source code,
|
||||
* see http://www.azib.net/ for more information.
|
||||
* Licensed under GPLv2.
|
||||
*/
|
||||
package net.azib.ipscan.gui;
|
||||
|
||||
@ -11,7 +13,6 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Anton Keks
|
||||
*
|
||||
*/
|
||||
public class SelectFetchersDialogTest {
|
||||
|
||||
@ -23,9 +24,9 @@ public class SelectFetchersDialogTest {
|
||||
|
||||
SelectFetchersDialog selectFetchersDialog = new SelectFetchersDialog(fetcherRegistry);
|
||||
|
||||
selectFetchersDialog.registeredFetcherLabelsByNames.put("IP", "fetcher.ip");
|
||||
selectFetchersDialog.registeredFetcherLabelsByNames.put("Hello", "fetcher.hello");
|
||||
selectFetchersDialog.registeredFetcherLabelsByNames.put("Blah", "fetcher.blah");
|
||||
selectFetchersDialog.registeredFetcherIdsByNames.put("IP", "fetcher.ip");
|
||||
selectFetchersDialog.registeredFetcherIdsByNames.put("Hello", "fetcher.hello");
|
||||
selectFetchersDialog.registeredFetcherIdsByNames.put("Blah", "fetcher.blah");
|
||||
|
||||
selectFetchersDialog.saveFetchersToRegistry(new String[] {"Blah", "Hello"});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user