From c4012ed07dda00ee3141d83f2a1b5ce6c571973e Mon Sep 17 00:00:00 2001 From: Anton Keks Date: Tue, 29 Apr 2014 00:12:15 +0300 Subject: [PATCH] align feeder gui row heights with button heights, so that the rows match those in MainWindow --- src/net/azib/ipscan/gui/MainWindow.java | 2 +- .../ipscan/gui/feeders/FileFeederGUI.java | 4 ++-- .../ipscan/gui/feeders/RandomFeederGUI.java | 17 ++++++------- .../ipscan/gui/feeders/RangeFeederGUI.java | 24 ++++++++++--------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/net/azib/ipscan/gui/MainWindow.java b/src/net/azib/ipscan/gui/MainWindow.java index 3d65b2d8..8e7a21cf 100644 --- a/src/net/azib/ipscan/gui/MainWindow.java +++ b/src/net/azib/ipscan/gui/MainWindow.java @@ -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; diff --git a/src/net/azib/ipscan/gui/feeders/FileFeederGUI.java b/src/net/azib/ipscan/gui/feeders/FileFeederGUI.java index fdbaad4e..f9d34916 100644 --- a/src/net/azib/ipscan/gui/feeders/FileFeederGUI.java +++ b/src/net/azib/ipscan/gui/feeders/FileFeederGUI.java @@ -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()); diff --git a/src/net/azib/ipscan/gui/feeders/RandomFeederGUI.java b/src/net/azib/ipscan/gui/feeders/RandomFeederGUI.java index 312c4cdf..0ccb2be7 100644 --- a/src/net/azib/ipscan/gui/feeders/RandomFeederGUI.java +++ b/src/net/azib/ipscan/gui/feeders/RandomFeederGUI.java @@ -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)); diff --git a/src/net/azib/ipscan/gui/feeders/RangeFeederGUI.java b/src/net/azib/ipscan/gui/feeders/RangeFeederGUI.java index bfe60962..f11381c3 100644 --- a/src/net/azib/ipscan/gui/feeders/RangeFeederGUI.java +++ b/src/net/azib/ipscan/gui/feeders/RangeFeederGUI.java @@ -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");