mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
restore context menu after dagger migration
This commit is contained in:
parent
0117f62431
commit
1fc82ec0ac
@ -36,7 +36,8 @@ public class MainMenu {
|
||||
FavoritesMenu favoritesMenu,
|
||||
ToolsMenu toolsMenu,
|
||||
HelpMenu helpMenu,
|
||||
ResultsContextMenu resultsContextMenu, StateMachine stateMachine) {
|
||||
ResultsContextMenu resultsContextMenu,
|
||||
StateMachine stateMachine) {
|
||||
|
||||
parent.setMenuBar(mainMenu);
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Commands and Context menu Actions.
|
||||
@ -33,7 +34,19 @@ import javax.inject.Inject;
|
||||
*
|
||||
* @author Anton Keks
|
||||
*/
|
||||
@Singleton
|
||||
public class CommandsMenuActions {
|
||||
@Inject public Details details;
|
||||
@Inject public Delete delete;
|
||||
@Inject public Rescan rescan;
|
||||
@Inject public CopyIP copyIP;
|
||||
@Inject public CopyIPDetails copyIPDetails;
|
||||
@Inject public ShowOpenersMenu showOpenersMenu;
|
||||
@Inject public EditOpeners editOpeners;
|
||||
@Inject public SelectOpener selectOpener;
|
||||
|
||||
@Inject public CommandsMenuActions() {}
|
||||
|
||||
/**
|
||||
* Checks that there is at least one item selected in the results list.
|
||||
*/
|
||||
@ -72,8 +85,7 @@ public class CommandsMenuActions {
|
||||
private final ResultTable resultTable;
|
||||
private final StateMachine stateMachine;
|
||||
|
||||
@Inject
|
||||
public Delete(ResultTable resultTable, StateMachine stateMachine) {
|
||||
@Inject public Delete(ResultTable resultTable, StateMachine stateMachine) {
|
||||
this.resultTable = resultTable;
|
||||
this.stateMachine = stateMachine;
|
||||
}
|
||||
@ -86,12 +98,12 @@ public class CommandsMenuActions {
|
||||
if (!stateMachine.inState(ScanningState.IDLE)) return;
|
||||
|
||||
int firstSelection = resultTable.getSelectionIndex();
|
||||
if (firstSelection < 0) return;
|
||||
if (firstSelection < 0) return;
|
||||
|
||||
resultTable.remove(resultTable.getSelectionIndices());
|
||||
resultTable.setSelection(firstSelection);
|
||||
event.widget = resultTable;
|
||||
resultTable.notifyListeners(SWT.Selection, event);
|
||||
event.widget = resultTable;
|
||||
resultTable.notifyListeners(SWT.Selection, event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +256,7 @@ public class CommandsMenuActions {
|
||||
// TODO: somehow wait until the process is started
|
||||
Thread.sleep(500);
|
||||
}
|
||||
catch (InterruptedException e) {}
|
||||
catch (InterruptedException ignore) {}
|
||||
finally {
|
||||
statusBar.setStatusText(null);
|
||||
}
|
||||
|
||||
@ -5,6 +5,10 @@ import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public abstract class AbstractMenu extends ExtendableMenu {
|
||||
|
||||
public AbstractMenu(Shell parent, int style) {
|
||||
super(parent, style);
|
||||
}
|
||||
|
||||
public AbstractMenu(Shell parent) {
|
||||
super(parent, SWT.DROP_DOWN);
|
||||
}
|
||||
|
||||
@ -13,24 +13,20 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
public class CommandsMenu extends AbstractMenu {
|
||||
|
||||
@Inject
|
||||
public CommandsMenu(Shell parent,
|
||||
CommandsMenuActions.Details details,
|
||||
CommandsMenuActions.Rescan rescan,
|
||||
CommandsMenuActions.Delete delete,
|
||||
CommandsMenuActions.CopyIP copyIP,
|
||||
CommandsMenuActions.CopyIPDetails copyIPDetails,
|
||||
OpenersMenu openersMenu) {
|
||||
@Inject public CommandsMenu(Shell parent, CommandsMenuActions actions, OpenersMenu openersMenu) {
|
||||
this(parent, SWT.DROP_DOWN, actions, openersMenu);
|
||||
}
|
||||
|
||||
super(parent);
|
||||
protected CommandsMenu(Shell parent, int style, CommandsMenuActions actions, OpenersMenu openersMenu) {
|
||||
super(parent, style);
|
||||
|
||||
initMenuItem(this, "menu.commands.details", null, null, details);
|
||||
initMenuItem(this, "menu.commands.details", null, null, actions.details);
|
||||
initMenuItem(this, null, null, null, null);
|
||||
initMenuItem(this, "menu.commands.rescan", "Ctrl+R", SWT.MOD1 | 'R', rescan, true);
|
||||
initMenuItem(this, "menu.commands.delete", Platform.MAC_OS ? "?" : "Del", /* this is not a global key binding */ null, delete, true);
|
||||
initMenuItem(this, "menu.commands.rescan", "Ctrl+R", SWT.MOD1 | 'R', actions.rescan, true);
|
||||
initMenuItem(this, "menu.commands.delete", Platform.MAC_OS ? "?" : "Del", /* this is not a global key binding */ null, actions.delete, true);
|
||||
initMenuItem(this, null, null, null, null);
|
||||
initMenuItem(this, "menu.commands.copy", Platform.MAC_OS ? "?C" : "Ctrl+C", /* this is not a global key binding */ null, copyIP);
|
||||
initMenuItem(this, "menu.commands.copyDetails", null, null, copyIPDetails);
|
||||
initMenuItem(this, "menu.commands.copy", Platform.MAC_OS ? "?C" : "Ctrl+C", /* this is not a global key binding */ null, actions.copyIP);
|
||||
initMenuItem(this, "menu.commands.copyDetails", null, null, actions.copyIPDetails);
|
||||
initMenuItem(this, null, null, null, null);
|
||||
|
||||
MenuItem openersMenuItem = new MenuItem(this, SWT.CASCADE);
|
||||
|
||||
@ -1,19 +1,16 @@
|
||||
package net.azib.ipscan.gui.menu;
|
||||
|
||||
import net.azib.ipscan.gui.actions.CommandsMenuActions;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* CommandsMenu wrapper for type-safety
|
||||
*/
|
||||
@Singleton
|
||||
public class ResultsContextMenu extends ExtendableMenu {
|
||||
public class ResultsContextMenu extends CommandsMenu {
|
||||
|
||||
@Inject
|
||||
public ResultsContextMenu(Shell parent) {
|
||||
super(parent, SWT.POP_UP);
|
||||
@Inject public ResultsContextMenu(Shell parent, CommandsMenuActions actions, OpenersMenu openersMenu) {
|
||||
super(parent, SWT.POP_UP, actions, openersMenu);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user