* Ctrl+I now inverts the selection

* Ctrl+A correctly updates the status bar with number of selected elements
* Scan Info now is shown on Ctrl+K

git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@373 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
angryziber 2008-04-06 22:07:11 +00:00
parent 534a988df3
commit 61dcc746ce
6 changed files with 59 additions and 24 deletions

1
TODO
View File

@ -10,7 +10,6 @@ Before 3.0:
* plugin loader
* export/import of settings (profiles or tie with Favorites?)
* top-level exception handler for NoClassDefFoundErrors, etc
* Tools -> Select -> Invert Selection
* public XSL for XMLExporter
* Exporter appending functionality exposed to the user
* make Display: status bar right-clickable

View File

@ -28,11 +28,12 @@ menu.favorites.edit=&Manage favorites...
menu.tools=&Tools
menu.tools.preferences=&Preferences...
menu.tools.fetchers=&Fetchers...
menu.tools.select=Se&lect in list
menu.tools.select=Se&lection
menu.tools.select.alive=&Alive hosts
menu.tools.select.dead=&Dead hosts
menu.tools.select.withPorts=With &open ports
menu.tools.select.withoutPorts=Without o&pen ports
menu.tools.select.invert=Invert selection
menu.tools.scanInfo=Show scan &info
menu.help=&Help
menu.help.gettingStarted=Getting &Started

View File

@ -106,12 +106,14 @@ public class MainMenu implements Startable {
initMenuItem(subMenu, "menu.tools.fetchers", "Ctrl+Shift+O", new Integer(SWT.MOD1 | SWT.MOD2 | (Platform.MAC_OS ? ',' : 'O')), initListener(ToolsActions.ChooseFetchers.class), true);
initMenuItem(subMenu, null, null, null, null);
Menu selectMenu = initMenu(subMenu, "menu.tools.select");
initMenuItem(subMenu, "menu.tools.scanInfo", "Ctrl+I", new Integer(SWT.MOD1 | 'I'), initListener(ToolsActions.ScanInfo.class));
initMenuItem(subMenu, "menu.tools.scanInfo", "Ctrl+K", new Integer(SWT.MOD1 | 'K'), initListener(ToolsActions.ScanInfo.class));
initMenuItem(selectMenu, "menu.tools.select.alive", null, null, initListener(ToolsActions.SelectAlive.class), true);
initMenuItem(selectMenu, "menu.tools.select.dead", null, null, initListener(ToolsActions.SelectDead.class), true);
initMenuItem(selectMenu, "menu.tools.select.withPorts", null, null, initListener(ToolsActions.SelectWithPorts.class), true);
initMenuItem(selectMenu, "menu.tools.select.withoutPorts", null, null, initListener(ToolsActions.SelectWithoutPorts.class), true);
initMenuItem(selectMenu, null, null, null, null);
initMenuItem(selectMenu, "menu.tools.select.invert", "Ctrl+I", new Integer(SWT.MOD1 | 'I'), initListener(ToolsActions.SelectInvert.class), true);
subMenu = initMenu(menu, "menu.help");
initMenuItem(subMenu, "menu.help.gettingStarted", !Platform.MAC_OS ? "F1" : null, new Integer(Platform.MAC_OS ? SWT.HELP : SWT.F1), initListener(HelpActions.GettingStarted.class));

View File

@ -69,8 +69,8 @@ public class ResultTable extends Table implements FetcherRegistryUpdateListener
addListener(SWT.Selection, selectionListener);
addListener(SWT.KeyDown, new CommandsActions.Delete(this, stateMachine, selectionListener));
addListener(SWT.KeyDown, new CommandsActions.SelectAll(this));
addListener(SWT.KeyDown, new CommandsActions.CopyIP(this));
addListener(SWT.KeyDown, new ToolsActions.SelectAll(this, selectionListener));
// this one populates table dynamically, taking data from ScanningResultList
addListener(SWT.SetData, new SetDataListener());

View File

@ -107,26 +107,6 @@ public class CommandsActions {
}
}
/**
* This cannot be accessed from the menu, but it provides the Ctrl+A
* Select All functionality for Windows (other platforms implement this themselves)
*/
public static class SelectAll implements Listener {
private final ResultTable resultTable;
public SelectAll(ResultTable resultTable) {
this.resultTable = resultTable;
}
public void handleEvent(Event event) {
// Ctrl+A handler
if (event.type == SWT.KeyDown && event.keyCode == 'a' && event.stateMask == SWT.MOD1) {
resultTable.selectAll();
event.doit = false;
}
}
}
public static final class Rescan implements Listener {
private final ResultTable resultTable;
private final StateMachine stateMachine;

View File

@ -18,6 +18,7 @@ import net.azib.ipscan.gui.SelectFetchersDialog;
import net.azib.ipscan.gui.StatisticsDialog;
import net.azib.ipscan.gui.StatusBar;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
@ -186,4 +187,56 @@ public class ToolsActions {
return type == ResultType.ALIVE;
}
}
/**
* This cannot be accessed from the menu, but it provides the Ctrl+A
* Select All functionality for Windows (other platforms implement this themselves)
*/
public static class SelectAll implements Listener {
private final ResultTable resultTable;
private final TableSelection tableSelectionListener;
public SelectAll(ResultTable resultTable, TableSelection tableSelectionListener) {
this.resultTable = resultTable;
this.tableSelectionListener = tableSelectionListener;
}
public void handleEvent(Event event) {
// Ctrl+A handler
if (event.type == SWT.KeyDown && event.keyCode == 'a' && event.stateMask == SWT.MOD1) {
resultTable.selectAll();
// update selection status
event.widget = resultTable;
tableSelectionListener.handleEvent(event);
event.doit = false;
}
}
}
public static final class SelectInvert implements Listener {
private final ResultTable resultTable;
private final TableSelection tableSelectionListener;
public SelectInvert(ResultTable resultTable, TableSelection tableSelectionListener) {
this.resultTable = resultTable;
this.tableSelectionListener = tableSelectionListener;
}
public void handleEvent(Event event) {
int count = resultTable.getItemCount();
// the most naive implementation
resultTable.setRedraw(false);
for (int i = 0; i < count; i++) {
if (resultTable.isSelected(i))
resultTable.deselect(i);
else
resultTable.select(i);
}
resultTable.setRedraw(true);
resultTable.redraw();
event.widget = resultTable;
tableSelectionListener.handleEvent(event);
resultTable.forceFocus();
}
}
}