mirror of
https://github.com/angryip/ipscan.git
synced 2025-10-26 11:18:17 +00:00
About action extracting
This commit is contained in:
parent
0b818b528d
commit
6a482aefb8
@ -113,7 +113,6 @@ public class ComponentRegistry {
|
||||
if (Platform.MAC_OS)
|
||||
container.registerComponentImplementation(MacApplicationMenu.class);
|
||||
|
||||
container.registerComponentImplementation(AboutDialog.class);
|
||||
container.registerComponentImplementation(PreferencesDialog.class);
|
||||
container.registerComponentImplementation(SelectFetchersDialog.class);
|
||||
container.registerComponentImplementation(DetailsWindow.class);
|
||||
|
||||
@ -11,6 +11,8 @@ import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static net.azib.ipscan.config.Version.*;
|
||||
|
||||
/**
|
||||
@ -20,6 +22,10 @@ import static net.azib.ipscan.config.Version.*;
|
||||
*/
|
||||
public class AboutDialog extends AbstractModalDialog {
|
||||
|
||||
@Inject
|
||||
public AboutDialog() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateShell() {
|
||||
shell.setText(Labels.getLabel("title.about"));
|
||||
|
||||
@ -10,18 +10,21 @@ import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.picocontainer.Startable;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Mac-specific application menu handler
|
||||
* in order to conform better to Mac standards.
|
||||
*/
|
||||
public class MacApplicationMenu implements Startable {
|
||||
private final AboutDialog aboutDialog;
|
||||
@Inject
|
||||
AboutDialog aboutDialog;
|
||||
|
||||
private final PreferencesDialog preferencesDialog;
|
||||
private final SelectFetchersDialog selectFetchersDialog;
|
||||
private final CheckVersion checkVersionListener;
|
||||
|
||||
public MacApplicationMenu(AboutDialog aboutDialog, PreferencesDialog preferencesDialog, SelectFetchersDialog selectFetchersDialog, CheckVersion checkVersionListener) {
|
||||
this.aboutDialog = aboutDialog;
|
||||
public MacApplicationMenu(PreferencesDialog preferencesDialog, SelectFetchersDialog selectFetchersDialog, CheckVersion checkVersionListener) {
|
||||
this.preferencesDialog = preferencesDialog;
|
||||
this.selectFetchersDialog = selectFetchersDialog;
|
||||
this.checkVersionListener = checkVersionListener;
|
||||
|
||||
@ -20,13 +20,15 @@ import org.picocontainer.Startable;
|
||||
import org.picocontainer.defaults.ConstructorInjectionComponentAdapter;
|
||||
import org.picocontainer.defaults.DefaultPicoContainer;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* MainMenu
|
||||
*
|
||||
* @author Anton Keks
|
||||
*/
|
||||
public class MainMenu implements Startable {
|
||||
|
||||
|
||||
private MutablePicoContainer container;
|
||||
|
||||
public MainMenu(Shell shell, Menu mainMenu, CommandsMenu resultsContextMenu, StateMachine stateMachine, PicoContainer parentContainer) {
|
||||
@ -123,7 +125,7 @@ public class MainMenu implements Startable {
|
||||
initMenuItem(subMenu, null, null, null, null);
|
||||
initMenuItem(subMenu, "menu.help.checkVersion", null, null, initListener(HelpMenuActions.CheckVersion.class));
|
||||
initMenuItem(subMenu, null, null, null, null);
|
||||
initMenuItem(subMenu, "menu.help.about", null, null, initListener(HelpMenuActions.About.class));
|
||||
initMenuItem(subMenu, "menu.help.about", null, null, DaggerListenerComponent.create().getHelpMenuAboutListener());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,8 @@ import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -56,8 +58,8 @@ public class HelpMenuActions {
|
||||
public static final class About implements Listener {
|
||||
private AboutDialog aboutDialog;
|
||||
|
||||
@Inject
|
||||
public About(AboutDialog aboutDialog) {
|
||||
super();
|
||||
this.aboutDialog = aboutDialog;
|
||||
}
|
||||
|
||||
|
||||
19
src/net/azib/ipscan/gui/actions/HelpMenuModule.java
Normal file
19
src/net/azib/ipscan/gui/actions/HelpMenuModule.java
Normal file
@ -0,0 +1,19 @@
|
||||
package net.azib.ipscan.gui.actions;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* Created by englishman on 8/12/15.
|
||||
*/
|
||||
@Module
|
||||
public class HelpMenuModule {
|
||||
@Provides
|
||||
@Named("about")
|
||||
Listener provideAbout(HelpMenuActions.About action) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
17
src/net/azib/ipscan/gui/actions/ListenerComponent.java
Normal file
17
src/net/azib/ipscan/gui/actions/ListenerComponent.java
Normal file
@ -0,0 +1,17 @@
|
||||
package net.azib.ipscan.gui.actions;
|
||||
|
||||
import dagger.Component;
|
||||
import dagger.Provides;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Created by englishman on 8/12/15.
|
||||
*/
|
||||
@Component(modules = HelpMenuModule.class)
|
||||
public interface ListenerComponent {
|
||||
@Named("about")
|
||||
Listener getHelpMenuAboutListener();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user