mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
Bugfix: Del button now works in all edit fields in the MainWindow, Del is handled by an event of ResultTable, not by a global accelerator.
Bugfix: InputDialog focuses to the edit field. RangeFeederGUI and RandomFeederGUI do field value initialization asynchronously after the GUI is already shown. Up and Down button listeners now work correctly if there is no selection at all. git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk/ipscan@112 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
parent
7bbd261044
commit
fea798a6bb
@ -5,4 +5,4 @@ handlers = java.util.logging.ConsoleHandler
|
||||
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
|
||||
java.util.logging.ConsoleHandler.level = ALL
|
||||
|
||||
.level = FINE
|
||||
.level = FINER
|
||||
|
||||
@ -35,18 +35,25 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
initSystemProperties();
|
||||
|
||||
Display display = Display.getDefault();
|
||||
Display display = Display.getDefault();
|
||||
LOG.finer("SWT initialized after " + (System.currentTimeMillis() - startTime));
|
||||
|
||||
// initalize Labels instance
|
||||
Labels.initialize(new Locale("en")); // TODO: retrieve locale normally
|
||||
|
||||
Labels.initialize(new Locale("en")); // TODO: retrieve locale normally
|
||||
// initialize Config instance
|
||||
Config.initialize();
|
||||
Config.initialize();
|
||||
LOG.finer("Labels and Config initialized after " + (System.currentTimeMillis() - startTime));
|
||||
|
||||
ComponentRegistry componentRegistry = new ComponentRegistry();
|
||||
LOG.finer("ComponentRegistry initialized after " + (System.currentTimeMillis() - startTime));
|
||||
|
||||
// create the main window using dependency injection
|
||||
MainWindow mainWindow = new ComponentRegistry().createMainWindow();
|
||||
MainWindow mainWindow = componentRegistry.createMainWindow();
|
||||
LOG.fine("Startup time: " + (System.currentTimeMillis() - startTime));
|
||||
|
||||
while (!mainWindow.isDisposed()) {
|
||||
try {
|
||||
|
||||
@ -91,8 +91,8 @@ public abstract class AbstractModalDialog {
|
||||
}
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
if (list.isSelected(0)) {
|
||||
// do not move anything if the first item is selected
|
||||
if (list.getSelectionCount() == 0 || list.isSelected(0)) {
|
||||
// do not move anything if either nothing is selected or only the first item is selected
|
||||
return;
|
||||
}
|
||||
|
||||
@ -121,8 +121,8 @@ public abstract class AbstractModalDialog {
|
||||
}
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
if (list.isSelected(list.getItemCount() - 1)) {
|
||||
// do not move anything if the last items is selected
|
||||
if (list.getSelectionCount() == 0 || list.isSelected(list.getItemCount() - 1)) {
|
||||
// do not move anything if either nothing is selected or only the last item is selected
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,8 @@ public class InputDialog extends AbstractModalDialog {
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
text.setFocus();
|
||||
}
|
||||
|
||||
private void setText(String text) {
|
||||
|
||||
@ -108,7 +108,7 @@ public class MainMenu {
|
||||
initMenuItem(menu, "menu.commands.details", null, null, initListener(CommandsActions.Details.class));
|
||||
initMenuItem(menu, null, null, null, null);
|
||||
initMenuItem(menu, "menu.commands.rescan", "Ctrl+R", new Integer(SWT.MOD1 | 'R'), null);
|
||||
initMenuItem(menu, "menu.commands.delete", "Del", new Integer(SWT.DEL), initListener(CommandsActions.Delete.class));
|
||||
initMenuItem(menu, "menu.commands.delete", "Del", null, initListener(CommandsActions.Delete.class));
|
||||
initMenuItem(menu, null, null, null, null);
|
||||
initMenuItem(menu, "menu.commands.copy", "Ctrl+C", new Integer(SWT.MOD1 | 'C'), initListener(CommandsActions.CopyIP.class));
|
||||
initMenuItem(menu, "menu.commands.copyDetails", null, null, initListener(CommandsActions.CopyIPDetails.class));
|
||||
|
||||
@ -75,6 +75,7 @@ public class ResultTable extends Table implements FetcherRegistryUpdateListener
|
||||
};
|
||||
addListener(SWT.Traverse, detailsListener);
|
||||
addListener(SWT.MouseDoubleClick, detailsListener);
|
||||
addListener(SWT.KeyDown, new CommandsActions.Delete(this));
|
||||
|
||||
addListener(SWT.SetData, new SetDataListener());
|
||||
}
|
||||
|
||||
@ -54,6 +54,9 @@ public class CommandsActions {
|
||||
}
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
// ignore other keys if this is a KeyDown event
|
||||
if (event.type == SWT.KeyDown && event.keyCode != SWT.DEL)
|
||||
return;
|
||||
checkSelection(resultTable);
|
||||
int firstSelection = resultTable.getSelectionIndex();
|
||||
resultTable.remove(resultTable.getSelectionIndices());
|
||||
|
||||
@ -5,8 +5,10 @@ package net.azib.ipscan.gui.feeders;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.azib.ipscan.config.Labels;
|
||||
import net.azib.ipscan.config.LoggerFactory;
|
||||
import net.azib.ipscan.config.Platform;
|
||||
import net.azib.ipscan.core.InetAddressUtils;
|
||||
import net.azib.ipscan.feeders.Feeder;
|
||||
@ -31,7 +33,9 @@ import org.eclipse.swt.widgets.Text;
|
||||
* @author anton
|
||||
*/
|
||||
public class RandomFeederGUI extends AbstractFeederGUI {
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger();
|
||||
|
||||
private Label ipPrototypeLabel;
|
||||
private Text ipPrototypeText;
|
||||
|
||||
@ -104,12 +108,6 @@ public class RandomFeederGUI extends AbstractFeederGUI {
|
||||
ipMaskCombo.setLayoutData(formData);
|
||||
|
||||
FeederActions.HostnameButton hostnameSelectionListener = new FeederActions.HostnameButton(hostnameText, ipPrototypeText);
|
||||
try {
|
||||
hostnameText.setText(InetAddress.getLocalHost().getHostName());
|
||||
}
|
||||
catch (UnknownHostException e1) {
|
||||
// leave hostnameText empty
|
||||
}
|
||||
hostnameText.addTraverseListener(hostnameSelectionListener);
|
||||
formData = new FormData(105, SWT.DEFAULT);
|
||||
formData.top = new FormAttachment(ipPrototypeText);
|
||||
@ -146,13 +144,20 @@ public class RandomFeederGUI extends AbstractFeederGUI {
|
||||
formData.right = new FormAttachment(ipMaskCombo, 0, SWT.RIGHT);
|
||||
countSpinner.setLayoutData(formData);
|
||||
|
||||
// fill the IP text with local IP address
|
||||
try {
|
||||
ipPrototypeText.setText(InetAddressUtils.getAddressByName(hostnameText.getText()));
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
// don't report any errors on initialization
|
||||
}
|
||||
// do this stuff asynchronously (to show GUI faster)
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
// fill the IP and hostname fields with local hostname and IP addresses
|
||||
try {
|
||||
hostnameText.setText(InetAddress.getLocalHost().getHostName());
|
||||
ipPrototypeText.setText(InetAddressUtils.getAddressByName(hostnameText.getText()));
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
// don't report any errors on initialization, leave fields empty
|
||||
LOG.fine(e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
@ -100,13 +100,7 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
formData.left = new FormAttachment(startIPText);
|
||||
formData.top = new FormAttachment(startIPText, 0, SWT.CENTER);
|
||||
toLabel.setLayoutData(formData);
|
||||
|
||||
try {
|
||||
endIPText.setText(InetAddress.getLocalHost().getHostAddress());
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
// leave endIPText empty
|
||||
}
|
||||
|
||||
formData = new FormData(105 + (Platform.MAC_OS ? 35 : 0), SWT.DEFAULT);
|
||||
formData.left = new FormAttachment(toLabel);
|
||||
endIPText.setLayoutData(formData);
|
||||
@ -122,12 +116,7 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
super.widgetSelected(event);
|
||||
}
|
||||
};
|
||||
try {
|
||||
hostnameText.setText(InetAddress.getLocalHost().getHostName());
|
||||
}
|
||||
catch (UnknownHostException e1) {
|
||||
// leave hostnameText empty
|
||||
}
|
||||
|
||||
hostnameText.addTraverseListener(hostnameListener);
|
||||
formData = new FormData(105, SWT.DEFAULT);
|
||||
formData.top = new FormAttachment(startIPText);
|
||||
@ -173,16 +162,22 @@ public class RangeFeederGUI extends AbstractFeederGUI {
|
||||
formData.bottom = new FormAttachment(hostnameText, 0, SWT.BOTTOM);
|
||||
netmaskCombo.setLayoutData(formData);
|
||||
netmaskCombo.setToolTipText(Labels.getLabel("feeder.range.netmask.tooltip"));
|
||||
|
||||
// fill the IP text with local IP address
|
||||
try {
|
||||
startIPText.setText(InetAddressUtils.getAddressByName(hostnameText.getText()));
|
||||
endIPText.setText(startIPText.getText());
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
// don't report any errors on initialization
|
||||
LOG.fine(e.toString());
|
||||
}
|
||||
|
||||
// do this stuff asynchronously (to show GUI faster)
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
// fill the IP and hostname fields with local hostname and IP addresses
|
||||
try {
|
||||
hostnameText.setText(InetAddress.getLocalHost().getHostName());
|
||||
startIPText.setText(InetAddressUtils.getAddressByName(hostnameText.getText()));
|
||||
endIPText.setText(startIPText.getText());
|
||||
}
|
||||
catch (UnknownHostException e) {
|
||||
// don't report any errors on initialization, leave fields empty
|
||||
LOG.fine(e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user