align feeder gui row heights with button heights, so that the rows match those in MainWindow

This commit is contained in:
Anton Keks 2014-04-29 00:12:15 +03:00
parent 760a657423
commit c4012ed07d
4 changed files with 25 additions and 22 deletions

View File

@ -45,7 +45,7 @@ public class MainWindow {
private Composite feederArea;
private static int buttonHeight = 22;
private int buttonHeight;
private Button startStopButton;
private Combo feederSelectionCombo;
private FeederGUIRegistry feederRegistry;

View File

@ -44,11 +44,11 @@ public class FileFeederGUI extends AbstractFeederGUI {
// some long text
fileNameText.setText("255.255.255.255.xxx.xxx");
fileNameText.setLayoutData(formData(fileNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, SWT.DEFAULT, new FormAttachment(fileNameLabel), null, new FormAttachment(0), null));
fileNameText.setLayoutData(formData(fileNameText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, SWT.DEFAULT, new FormAttachment(fileNameLabel), null, new FormAttachment(0), new FormAttachment(browseButton, 0, SWT.BOTTOM)));
fileNameText.setText("");
browseButton.setText(getLabel("feeder.file.browse"));
browseButton.setLayoutData(formData(new FormAttachment(fileNameText), null, new FormAttachment(0), new FormAttachment(fileNameText, 0, SWT.BOTTOM)));
browseButton.setLayoutData(formData(new FormAttachment(fileNameText), null, new FormAttachment(0), null));
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(getShell());

View File

@ -6,7 +6,6 @@
package net.azib.ipscan.gui.feeders;
import net.azib.ipscan.config.Labels;
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;
@ -63,11 +62,15 @@ public class RandomFeederGUI extends AbstractFeederGUI {
ipPrototypeText.setText("255.255.255.255xx");
int textWidth = ipPrototypeText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
ipPrototypeText.setText("");
ipUpButton.setImage(new Image(getDisplay(), Labels.getInstance().getImageAsStream("button.ipUp.img")));
ipUpButton.setText(getLabel("button.ipUp"));
int rowHeight = ipUpButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 10;
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(formData(textWidth, SWT.DEFAULT, new FormAttachment(ipPrototypeLabel), null, new FormAttachment(0), null));
ipPrototypeText.setLayoutData(formData(textWidth, rowHeight, new FormAttachment(ipPrototypeLabel), null, new FormAttachment(0), null));
ipMaskLabel.setText(getLabel("feeder.random.mask")+":");
ipMaskLabel.setLayoutData(formData(new FormAttachment(ipPrototypeText, 3), null, new FormAttachment(ipPrototypeText, 0, SWT.CENTER), null));
@ -82,19 +85,17 @@ public class RandomFeederGUI extends AbstractFeederGUI {
ipMaskCombo.add("255..0.255");
ipMaskCombo.add("255.0.0.255");
ipMaskCombo.select(3);
ipMaskCombo.setLayoutData(formData(textWidth - 15, SWT.DEFAULT, new FormAttachment(ipMaskLabel), null, new FormAttachment(0), new FormAttachment(ipPrototypeText, 0, SWT.BOTTOM)));
ipMaskCombo.setLayoutData(formData(textWidth - 15, rowHeight, 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(formData(textWidth, SWT.DEFAULT, new FormAttachment(ipPrototypeText, 0, SWT.LEFT), null, new FormAttachment(ipPrototypeText), null));
hostnameText.setLayoutData(formData(textWidth, rowHeight, new FormAttachment(ipPrototypeText, 0, SWT.LEFT), null, new FormAttachment(ipPrototypeText), 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(getLabel("button.ipUp"));
ipUpButton.addSelectionListener(hostnameSelectionListener);
ipUpButton.setLayoutData(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), new FormAttachment(hostnameText, 0, SWT.BOTTOM)));
countLabel.setText(getLabel("feeder.random.count"));
countLabel.setLayoutData(formData(new FormAttachment(ipUpButton, 3), null, new FormAttachment(ipUpButton, 0, SWT.CENTER), null));

View File

@ -61,8 +61,12 @@ public class RangeFeederGUI extends AbstractFeederGUI {
hostnameText = new Text(this, SWT.BORDER);
ipUpButton = new Button(this, SWT.NONE);
netmaskCombo = new Combo(this, SWT.NONE);
// the longest possible IP
ipUpButton.setImage(new Image(getDisplay(), Labels.getInstance().getImageAsStream("button.ipUp.img")));
ipUpButton.setText(getLabel("button.ipUp"));
int rowHeight = ipUpButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 10;
// the longest possible IP
startIPText.setText("255.255.255.255xx");
int textWidth = startIPText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
startIPText.setText("");
@ -75,16 +79,16 @@ public class RangeFeederGUI extends AbstractFeederGUI {
hostnameLabel.pack();
int ipHostWidth = Math.max(hostnameLabel.getBounds().width, ipRangeLabel.getBounds().width);
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));
ipRangeLabel.setLayoutData(formData(ipHostWidth, SWT.DEFAULT, null, new FormAttachment(hostnameLabel, 0, SWT.RIGHT), new FormAttachment(startIPText, 0, SWT.CENTER), null));
hostnameLabel.setLayoutData(formData(ipHostWidth, SWT.DEFAULT, new FormAttachment(0), null, new FormAttachment(hostnameText, 0, SWT.CENTER), null));
startIPText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(ipRangeLabel), null, new FormAttachment(0), null));
startIPText.setLayoutData(formData(textWidth, rowHeight, new FormAttachment(ipRangeLabel), null, new FormAttachment(0), null));
startIPText.addModifyListener(new StartIPModifyListener());
toLabel.setText(getLabel("feeder.range.to"));
toLabel.setLayoutData(formData(new FormAttachment(startIPText), null, new FormAttachment(startIPText, 0, SWT.CENTER), null));
endIPText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(toLabel), null, null, null));
endIPText.setLayoutData(formData(textWidth, rowHeight, new FormAttachment(toLabel), null, null, null));
endIPText.addKeyListener(new EndIPKeyListener());
FeederActions.HostnameButton hostnameListener = new FeederActions.HostnameButton(hostnameText, startIPText, netmaskCombo) {
@ -99,18 +103,16 @@ public class RangeFeederGUI extends AbstractFeederGUI {
};
hostnameText.addTraverseListener(hostnameListener);
hostnameText.setLayoutData(formData(textWidth, SWT.DEFAULT, new FormAttachment(startIPText, 0, SWT.LEFT), null, new FormAttachment(startIPText), null));
hostnameText.setLayoutData(formData(textWidth, rowHeight, 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(getLabel("button.ipUp"));
ipUpButton.addSelectionListener(hostnameListener);
ipUpButton.setLayoutData(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), new FormAttachment(hostnameText, 0, SWT.BOTTOM)));
netmaskCombo.setText(getLabel("feeder.range.netmask"));
netmaskCombo.setVisibleItemCount(10);
netmaskCombo.add("/26");