mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
use static imports
This commit is contained in:
parent
3dd9bd67cc
commit
7f8b6db551
@ -5,16 +5,17 @@
|
||||
*/
|
||||
package net.azib.ipscan.gui.feeders;
|
||||
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.feeders.Feeder;
|
||||
import net.azib.ipscan.feeders.FileFeeder;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.layout.FormData;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
import static net.azib.ipscan.config.Labels.getLabel;
|
||||
import static net.azib.ipscan.gui.util.LayoutHelper.formData;
|
||||
|
||||
/**
|
||||
* GUI for initialization of FileFeeder.
|
||||
*
|
||||
@ -38,43 +39,26 @@ public class FileFeederGUI extends AbstractFeederGUI {
|
||||
fileNameText = new Text(this, SWT.BORDER);
|
||||
browseButton = new Button(this, SWT.NONE);
|
||||
|
||||
fileNameLabel.setText(Labels.getLabel("feeder.file.name")+":");
|
||||
FormData formData = new FormData();
|
||||
formData.left = new FormAttachment(0);
|
||||
formData.top = new FormAttachment(fileNameText, 0, SWT.CENTER);
|
||||
formData.bottom = new FormAttachment(browseButton, 0, SWT.BOTTOM);
|
||||
fileNameLabel.setLayoutData(formData);
|
||||
|
||||
fileNameLabel.setText(getLabel("feeder.file.name")+":");
|
||||
fileNameLabel.setLayoutData(formData(new FormAttachment(0), null, new FormAttachment(fileNameText, 0, SWT.CENTER), new FormAttachment(browseButton, 0, SWT.BOTTOM)));
|
||||
|
||||
// some long text
|
||||
fileNameText.setText("255.255.255.255.xxx.xxx");
|
||||
formData = new FormData(fileNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, SWT.DEFAULT);
|
||||
formData.top = new FormAttachment(0);
|
||||
formData.left = new FormAttachment(fileNameLabel);
|
||||
fileNameText.setLayoutData(formData);
|
||||
fileNameText.setLayoutData(formData(fileNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, SWT.DEFAULT, new FormAttachment(fileNameLabel), null, new FormAttachment(0), null));
|
||||
fileNameText.setText("");
|
||||
|
||||
browseButton.setText(Labels.getLabel("feeder.file.browse"));
|
||||
formData = new FormData();
|
||||
formData.top = new FormAttachment(0);
|
||||
formData.bottom = new FormAttachment(fileNameText, 0, SWT.BOTTOM);
|
||||
formData.left = new FormAttachment(fileNameText);
|
||||
browseButton.setLayoutData(formData);
|
||||
browseButton.addSelectionListener(new SelectionListener() {
|
||||
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
widgetSelected(e);
|
||||
}
|
||||
|
||||
browseButton.setText(getLabel("feeder.file.browse"));
|
||||
browseButton.setLayoutData(formData(new FormAttachment(fileNameText), null, new FormAttachment(0), new FormAttachment(fileNameText, 0, SWT.BOTTOM)));
|
||||
browseButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
FileDialog dialog = new FileDialog(getShell());
|
||||
dialog.setText(Labels.getLabel("feeder.file.browse"));
|
||||
dialog.setText(getLabel("feeder.file.browse"));
|
||||
String fileName = dialog.open();
|
||||
if (fileName != null) {
|
||||
fileNameText.setText(fileName);
|
||||
fileNameText.setSelection(fileName.length());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
pack();
|
||||
|
||||
@ -10,7 +10,6 @@ import net.azib.ipscan.config.Platform;
|
||||
import net.azib.ipscan.feeders.Feeder;
|
||||
import net.azib.ipscan.feeders.RandomFeeder;
|
||||
import net.azib.ipscan.gui.actions.FeederActions;
|
||||
import net.azib.ipscan.gui.util.LayoutHelper;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.TraverseEvent;
|
||||
import org.eclipse.swt.events.TraverseListener;
|
||||
@ -18,6 +17,9 @@ import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
import static net.azib.ipscan.config.Labels.getLabel;
|
||||
import static net.azib.ipscan.gui.util.LayoutHelper.formData;
|
||||
|
||||
/**
|
||||
* GUI for initialization of RandomFeeder
|
||||
*
|
||||
@ -62,13 +64,13 @@ public class RandomFeederGUI extends AbstractFeederGUI {
|
||||
int textWidth = ipPrototypeText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
|
||||
ipPrototypeText.setText("");
|
||||
|
||||
ipPrototypeLabel.setText(Labels.getLabel("feeder.random.prototype")+":");
|
||||
ipPrototypeLabel.setLayoutData(LayoutHelper.formData(null, new FormAttachment(hostnameLabel, 0, SWT.RIGHT), new FormAttachment(ipPrototypeText, 0, SWT.CENTER), null));
|
||||
ipPrototypeLabel.setText(getLabel("feeder.random.prototype")+":");
|
||||
ipPrototypeLabel.setLayoutData(formData(null, new FormAttachment(hostnameLabel, 0, SWT.RIGHT), new FormAttachment(ipPrototypeText, 0, SWT.CENTER), null));
|
||||
|
||||
ipPrototypeText.setLayoutData(LayoutHelper.formData(textWidth, SWT.DEFAULT, new FormAttachment(ipPrototypeLabel), null, new FormAttachment(0), null));
|
||||
ipPrototypeText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(ipPrototypeLabel), null, new FormAttachment(0), null));
|
||||
|
||||
ipMaskLabel.setText(Labels.getLabel("feeder.random.mask")+":");
|
||||
ipMaskLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(ipPrototypeText, 3), null, new FormAttachment(ipPrototypeText, 0, SWT.CENTER), null));
|
||||
ipMaskLabel.setText(getLabel("feeder.random.mask")+":");
|
||||
ipMaskLabel.setLayoutData(formData(new FormAttachment(ipPrototypeText, 3), null, new FormAttachment(ipPrototypeText, 0, SWT.CENTER), null));
|
||||
|
||||
ipMaskCombo.setVisibleItemCount(10);
|
||||
// Warning: IPv4 specific netmasks
|
||||
@ -80,27 +82,27 @@ public class RandomFeederGUI extends AbstractFeederGUI {
|
||||
ipMaskCombo.add("255..0.255");
|
||||
ipMaskCombo.add("255.0.0.255");
|
||||
ipMaskCombo.select(3);
|
||||
ipMaskCombo.setLayoutData(LayoutHelper.formData(textWidth-15, SWT.DEFAULT, new FormAttachment(ipMaskLabel), null, new FormAttachment(0), new FormAttachment(ipPrototypeText, 0, SWT.BOTTOM)));
|
||||
ipMaskCombo.setLayoutData(formData(textWidth - 15, SWT.DEFAULT, new FormAttachment(ipMaskLabel), null, new FormAttachment(0), new FormAttachment(ipPrototypeText, 0, SWT.BOTTOM)));
|
||||
|
||||
FeederActions.HostnameButton hostnameSelectionListener = new FeederActions.HostnameButton(hostnameText, ipPrototypeText, ipMaskCombo);
|
||||
hostnameText.addTraverseListener(hostnameSelectionListener);
|
||||
hostnameText.setLayoutData(LayoutHelper.formData(textWidth, SWT.DEFAULT, new FormAttachment(ipPrototypeText, 0, SWT.LEFT), null, new FormAttachment(ipPrototypeText), null));
|
||||
hostnameText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(ipPrototypeText, 0, SWT.LEFT), null, new FormAttachment(ipPrototypeText), null));
|
||||
|
||||
hostnameLabel.setText(Labels.getLabel("feeder.random.hostname")+":");
|
||||
hostnameLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(0), null, new FormAttachment(hostnameText, 0, SWT.CENTER), null));
|
||||
hostnameLabel.setText(getLabel("feeder.random.hostname")+":");
|
||||
hostnameLabel.setLayoutData(formData(new FormAttachment(0), null, new FormAttachment(hostnameText, 0, SWT.CENTER), null));
|
||||
|
||||
ipUpButton.setImage(new Image(getDisplay(), Labels.getInstance().getImageAsStream("button.ipUp.img")));
|
||||
ipUpButton.setText(Labels.getLabel("button.ipUp"));
|
||||
ipUpButton.setText(getLabel("button.ipUp"));
|
||||
ipUpButton.addSelectionListener(hostnameSelectionListener);
|
||||
ipUpButton.setLayoutData(LayoutHelper.formData(new FormAttachment(hostnameText), null, new FormAttachment(ipPrototypeText), !Platform.MAC_OS ? new FormAttachment(hostnameText, 1, SWT.BOTTOM) : null));
|
||||
ipUpButton.setLayoutData(formData(new FormAttachment(hostnameText), null, new FormAttachment(ipPrototypeText), !Platform.MAC_OS ? new FormAttachment(hostnameText, 1, SWT.BOTTOM) : null));
|
||||
|
||||
countLabel.setText(Labels.getLabel("feeder.random.count"));
|
||||
countLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(ipUpButton, 3), null, new FormAttachment(ipUpButton, 0, SWT.CENTER), null));
|
||||
countLabel.setText(getLabel("feeder.random.count"));
|
||||
countLabel.setLayoutData(formData(new FormAttachment(ipUpButton, 3), null, new FormAttachment(ipUpButton, 0, SWT.CENTER), null));
|
||||
|
||||
countSpinner.setSelection(100);
|
||||
countSpinner.setMaximum(100000);
|
||||
countSpinner.setMinimum(1);
|
||||
countSpinner.setLayoutData(LayoutHelper.formData(new FormAttachment(countLabel), new FormAttachment(ipMaskCombo, 0, SWT.RIGHT), new FormAttachment(ipUpButton, 0, SWT.CENTER), null));
|
||||
countSpinner.setLayoutData(formData(new FormAttachment(countLabel), new FormAttachment(ipMaskCombo, 0, SWT.RIGHT), new FormAttachment(ipUpButton, 0, SWT.CENTER), null));
|
||||
countSpinner.addTraverseListener(new TraverseListener() {
|
||||
public void keyTraversed(TraverseEvent e) {
|
||||
// this due to a bug either in SWT or GTK:
|
||||
|
||||
@ -11,7 +11,6 @@ import net.azib.ipscan.feeders.Feeder;
|
||||
import net.azib.ipscan.feeders.FeederException;
|
||||
import net.azib.ipscan.feeders.RangeFeeder;
|
||||
import net.azib.ipscan.gui.actions.FeederActions;
|
||||
import net.azib.ipscan.gui.util.LayoutHelper;
|
||||
import net.azib.ipscan.util.InetAddressUtils;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.*;
|
||||
@ -22,6 +21,9 @@ import org.eclipse.swt.widgets.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static net.azib.ipscan.config.Labels.getLabel;
|
||||
import static net.azib.ipscan.gui.util.LayoutHelper.formData;
|
||||
|
||||
/**
|
||||
* GUI for initialization of RangeFeeder.
|
||||
*
|
||||
@ -65,24 +67,24 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
int textWidth = startIPText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
|
||||
startIPText.setText("");
|
||||
|
||||
ipRangeLabel.setText(Labels.getLabel("feeder.range") + ":");
|
||||
ipRangeLabel.setText(getLabel("feeder.range") + ":");
|
||||
hostnameLabel.setAlignment(SWT.RIGHT);
|
||||
ipRangeLabel.pack();
|
||||
hostnameLabel.setText(Labels.getLabel("feeder.range.hostname") + ":");
|
||||
hostnameLabel.setText(getLabel("feeder.range.hostname") + ":");
|
||||
ipRangeLabel.setAlignment(SWT.RIGHT);
|
||||
hostnameLabel.pack();
|
||||
|
||||
int ipHostWidth = Math.max(hostnameLabel.getBounds().width, ipRangeLabel.getBounds().width);
|
||||
ipRangeLabel.setLayoutData(LayoutHelper.formData(ipHostWidth, -1, null, new FormAttachment(hostnameLabel, 0, SWT.RIGHT), new FormAttachment(startIPText, 0, SWT.CENTER), null));
|
||||
hostnameLabel.setLayoutData(LayoutHelper.formData(ipHostWidth, -1, new FormAttachment(0), null, new FormAttachment(hostnameText, 0, SWT.CENTER), null));
|
||||
ipRangeLabel.setLayoutData(formData(ipHostWidth, -1, null, new FormAttachment(hostnameLabel, 0, SWT.RIGHT), new FormAttachment(startIPText, 0, SWT.CENTER), null));
|
||||
hostnameLabel.setLayoutData(formData(ipHostWidth, -1, new FormAttachment(0), null, new FormAttachment(hostnameText, 0, SWT.CENTER), null));
|
||||
|
||||
startIPText.setLayoutData(LayoutHelper.formData(textWidth, SWT.DEFAULT, new FormAttachment(ipRangeLabel), null, new FormAttachment(0), null));
|
||||
startIPText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(ipRangeLabel), null, new FormAttachment(0), null));
|
||||
startIPText.addModifyListener(new StartIPModifyListener());
|
||||
|
||||
toLabel.setText(Labels.getLabel("feeder.range.to"));
|
||||
toLabel.setLayoutData(LayoutHelper.formData(new FormAttachment(startIPText), null, new FormAttachment(startIPText, 0, SWT.CENTER), null));
|
||||
toLabel.setText(getLabel("feeder.range.to"));
|
||||
toLabel.setLayoutData(formData(new FormAttachment(startIPText), null, new FormAttachment(startIPText, 0, SWT.CENTER), null));
|
||||
|
||||
endIPText.setLayoutData(LayoutHelper.formData(textWidth, SWT.DEFAULT, new FormAttachment(toLabel), null, null, null));
|
||||
endIPText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(toLabel), null, null, null));
|
||||
endIPText.addKeyListener(new EndIPKeyListener());
|
||||
|
||||
FeederActions.HostnameButton hostnameListener = new FeederActions.HostnameButton(hostnameText, startIPText, netmaskCombo) {
|
||||
@ -90,26 +92,26 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
// raise the flag
|
||||
isEndIPUnedited = true;
|
||||
// reset the netmask combo
|
||||
netmaskCombo.setText(Labels.getLabel("feeder.range.netmask"));
|
||||
netmaskCombo.setText(getLabel("feeder.range.netmask"));
|
||||
// now do the stuff
|
||||
super.widgetSelected(event);
|
||||
}
|
||||
};
|
||||
|
||||
hostnameText.addTraverseListener(hostnameListener);
|
||||
hostnameText.setLayoutData(LayoutHelper.formData(textWidth, SWT.DEFAULT, new FormAttachment(startIPText, 0, SWT.LEFT), null, new FormAttachment(startIPText), null));
|
||||
hostnameText.setToolTipText(Labels.getLabel("feeder.range.hostname.tooltip"));
|
||||
hostnameText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(startIPText, 0, SWT.LEFT), null, new FormAttachment(startIPText), null));
|
||||
hostnameText.setToolTipText(getLabel("feeder.range.hostname.tooltip"));
|
||||
|
||||
Listener netmaskResetListener = new NetmaskResetListener();
|
||||
startIPText.addListener(SWT.Modify, netmaskResetListener);
|
||||
endIPText.addListener(SWT.Modify, netmaskResetListener);
|
||||
|
||||
ipUpButton.setImage(new Image(getDisplay(), Labels.getInstance().getImageAsStream("button.ipUp.img")));
|
||||
ipUpButton.setText(Labels.getLabel("button.ipUp"));
|
||||
ipUpButton.setText(getLabel("button.ipUp"));
|
||||
ipUpButton.addSelectionListener(hostnameListener);
|
||||
ipUpButton.setLayoutData(LayoutHelper.formData(new FormAttachment(hostnameText), null, new FormAttachment(endIPText), !Platform.MAC_OS ? new FormAttachment(hostnameText, 1, SWT.BOTTOM) : null));
|
||||
ipUpButton.setLayoutData(formData(new FormAttachment(hostnameText), null, new FormAttachment(endIPText), !Platform.MAC_OS ? new FormAttachment(hostnameText, 1, SWT.BOTTOM) : null));
|
||||
|
||||
netmaskCombo.setText(Labels.getLabel("feeder.range.netmask"));
|
||||
netmaskCombo.setText(getLabel("feeder.range.netmask"));
|
||||
netmaskCombo.setVisibleItemCount(10);
|
||||
netmaskCombo.add("/26");
|
||||
netmaskCombo.add("/24");
|
||||
@ -123,8 +125,8 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
NetmaskListener netmaskSelectionListener = new NetmaskListener();
|
||||
netmaskCombo.addListener(SWT.Selection, netmaskSelectionListener);
|
||||
netmaskCombo.addListener(SWT.Traverse, netmaskSelectionListener);
|
||||
netmaskCombo.setLayoutData(LayoutHelper.formData(new FormAttachment(ipUpButton, 5), new FormAttachment(endIPText, 0, SWT.RIGHT), new FormAttachment(startIPText), new FormAttachment(hostnameText, 0, SWT.BOTTOM)));
|
||||
netmaskCombo.setToolTipText(Labels.getLabel("feeder.range.netmask.tooltip"));
|
||||
netmaskCombo.setLayoutData(formData(new FormAttachment(ipUpButton, 5), new FormAttachment(endIPText, 0, SWT.RIGHT), new FormAttachment(startIPText), new FormAttachment(hostnameText, 0, SWT.BOTTOM)));
|
||||
netmaskCombo.setToolTipText(getLabel("feeder.range.netmask.tooltip"));
|
||||
|
||||
pack();
|
||||
|
||||
@ -146,7 +148,7 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
startIPText.setText(parts[0]);
|
||||
endIPText.setText(parts[1]);
|
||||
// reset the netmask combo
|
||||
netmaskCombo.setText(Labels.getLabel("feeder.range.netmask"));
|
||||
netmaskCombo.setText(getLabel("feeder.range.netmask"));
|
||||
}
|
||||
|
||||
public String[] serializePartsLabels() {
|
||||
@ -166,7 +168,7 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
public void handleEvent(Event event) {
|
||||
// reset the netmask combo
|
||||
if (!modifyListenersDisabled)
|
||||
netmaskCombo.setText(Labels.getLabel("feeder.range.netmask"));
|
||||
netmaskCombo.setText(getLabel("feeder.range.netmask"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,5 +221,4 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user