Skip to content

Commit 3be486c

Browse files
committed
Enables global hotkeys
1 parent 394e3b7 commit 3be486c

File tree

10 files changed

+37
-25
lines changed

10 files changed

+37
-25
lines changed

Campaign_Scribe/src/main/java/net/sf/anathema/scribe/perspective/ScribePerspective.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
import net.sf.anathema.framework.IApplicationModel;
44
import net.sf.anathema.framework.environment.Environment;
5+
import net.sf.anathema.framework.environment.dependencies.Weight;
56
import net.sf.anathema.framework.environment.fx.UiEnvironment;
67
import net.sf.anathema.framework.view.perspective.Container;
78
import net.sf.anathema.framework.view.perspective.Perspective;
89
import net.sf.anathema.framework.view.perspective.PerspectiveAutoCollector;
910
import net.sf.anathema.framework.view.perspective.PerspectiveToggle;
10-
import net.sf.anathema.framework.environment.dependencies.Weight;
1111
import net.sf.anathema.lib.file.RelativePath;
1212
import net.sf.anathema.scribe.perspective.model.ScribeModel;
1313
import net.sf.anathema.scribe.perspective.presenter.ScribePresenter;
@@ -25,7 +25,7 @@ public void configureToggle(PerspectiveToggle toggle) {
2525

2626
@Override
2727
public void initContent(Container container, IApplicationModel applicationModel, Environment environment, UiEnvironment uiEnvironment) {
28-
ScribeView view = new ScribeView();
28+
ScribeView view = new ScribeView(uiEnvironment);
2929
ScribeModel scribeModel = new ScribeModel(applicationModel);
3030
new ScribePresenter(scribeModel, view, environment).initPresentation();
3131
container.setContent(view.perspectivePane.getNode());

Campaign_Scribe/src/main/java/net/sf/anathema/scribe/perspective/view/ScribeNavigation.java

+5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
package net.sf.anathema.scribe.perspective.view;
22

33
import javafx.scene.control.Button;
4+
import net.sf.anathema.interaction.AcceleratorMap;
45
import net.sf.anathema.interaction.Command;
56
import net.sf.anathema.platform.fx.Navigation;
67
import net.sf.anathema.platform.tool.Execute;
78
import net.sf.anathema.scribe.scroll.persistence.ScrollReference;
89

910
public class ScribeNavigation extends Navigation {
1011

12+
public ScribeNavigation(AcceleratorMap acceleratorMap) {
13+
super(acceleratorMap);
14+
}
15+
1116
public void addScroll(ScrollReference reference, Command command) {
1217
Button button = new Button(reference.printName);
1318
button.getStyleClass().add("scribe-navigation-button");

Campaign_Scribe/src/main/java/net/sf/anathema/scribe/perspective/view/ScribeView.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package net.sf.anathema.scribe.perspective.view;
22

3+
import net.sf.anathema.interaction.AcceleratorMap;
34
import net.sf.anathema.platform.fx.PerspectivePane;
45
import net.sf.anathema.scribe.editor.view.FxScrollView;
56

67
public class ScribeView {
78
public final PerspectivePane perspectivePane = new PerspectivePane("skin/scribe/scribe.css");
89
public final FxScrollView scrollView = new FxScrollView();
9-
public final ScribeNavigation scribeNavigation = new ScribeNavigation();
10+
public final ScribeNavigation scribeNavigation;
1011

11-
public ScribeView() {
12+
public ScribeView(AcceleratorMap acceleratorMap) {
13+
scribeNavigation = new ScribeNavigation(acceleratorMap);
1214
perspectivePane.addStyleSheetClass("scribe-perspective");
1315
perspectivePane.setNavigationComponent(scribeNavigation.getNode());
1416
perspectivePane.setContentComponent(scrollView.getNode());

Character_Equipment/src/main/java/net/sf/anathema/character/equipment/item/view/fx/FxEquipmentDatabaseView.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package net.sf.anathema.character.equipment.item.view.fx;
22

33
import net.sf.anathema.character.equipment.item.view.AgnosticEquipmentDatabaseView;
4-
import net.sf.anathema.framework.environment.fx.DialogFactory;
4+
import net.sf.anathema.framework.environment.fx.UiEnvironment;
55
import net.sf.anathema.platform.fx.PerspectivePane;
66
import net.sf.anathema.platform.fx.selection.ComboBoxSelectionFactory;
77

88
public class FxEquipmentDatabaseView {
99

1010
public final PerspectivePane perspectivePane = new PerspectivePane("skin/equipment/equipment.css", "skin/platform/dotselector.css");
11-
private final FxEquipmentNavigation navigation = new FxEquipmentNavigation();
11+
private final FxEquipmentNavigation navigation;
1212
private final FxEquipmentDetails details;
1313
public final AgnosticEquipmentDatabaseView view;
1414

15-
public FxEquipmentDatabaseView(DialogFactory dialogFactory) {
16-
this.details = new FxEquipmentDetails(new ComboBoxSelectionFactory(), dialogFactory);
15+
public FxEquipmentDatabaseView(UiEnvironment uiEnvironment) {
16+
this.details = new FxEquipmentDetails(new ComboBoxSelectionFactory(), uiEnvironment);
17+
this.navigation = new FxEquipmentNavigation(uiEnvironment);
1718
this.view = new AgnosticEquipmentDatabaseView(navigation, details);
1819
initializePerspective();
1920
}

Character_Equipment/src/main/java/net/sf/anathema/character/equipment/item/view/fx/FxEquipmentNavigation.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.sf.anathema.character.equipment.item.view.EquipmentNavigation;
44
import net.sf.anathema.framework.repository.tree.FxVetor;
5+
import net.sf.anathema.interaction.AcceleratorMap;
56
import net.sf.anathema.interaction.Tool;
67
import net.sf.anathema.lib.gui.list.veto.Vetor;
78
import net.sf.anathema.lib.gui.selection.VetoableObjectSelectionView;
@@ -12,7 +13,8 @@ public class FxEquipmentNavigation extends Navigation implements EquipmentNaviga
1213

1314
private ListSelectionView<String> listView = new ListSelectionView<>();
1415

15-
public FxEquipmentNavigation() {
16+
public FxEquipmentNavigation(AcceleratorMap acceleratorMap) {
17+
super(acceleratorMap);
1618
addContainerToNavigation(listView.getNode());
1719
}
1820

Character_Main_FX/src/main/java/net/sf/anathema/fx/hero/perspective/CharacterSystemView.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package net.sf.anathema.fx.hero.perspective;
22

33
import javafx.scene.Node;
4-
import net.sf.anathema.framework.environment.fx.DialogFactory;
4+
import net.sf.anathema.framework.environment.fx.UiEnvironment;
55
import net.sf.anathema.hero.framework.perspective.CharacterGridView;
6-
import net.sf.anathema.platform.view.InteractionView;
76
import net.sf.anathema.platform.fx.PerspectivePane;
7+
import net.sf.anathema.platform.view.InteractionView;
88

99
public class CharacterSystemView {
1010

1111
private final PerspectivePane pane = new PerspectivePane();
1212
private final StackView stackView = new StackView();
1313
private final FxCharacterNavigation navigation;
1414

15-
public CharacterSystemView(DialogFactory dialogFactory) {
16-
this.navigation = new FxCharacterNavigation(dialogFactory);
15+
public CharacterSystemView(UiEnvironment uiEnvironment) {
16+
this.navigation = new FxCharacterNavigation(uiEnvironment);
1717
pane.setNavigationComponent(navigation.getNode());
1818
pane.setContentComponent(stackView.getComponent());
1919
}

Character_Main_FX/src/main/java/net/sf/anathema/fx/hero/perspective/FxCharacterNavigation.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.sf.anathema.fx.hero.perspective;
22

3-
import net.sf.anathema.framework.environment.fx.DialogFactory;
3+
import net.sf.anathema.framework.environment.fx.UiEnvironment;
44
import net.sf.anathema.hero.creation.CharacterTemplateCreator;
55
import net.sf.anathema.hero.framework.perspective.CharacterButtonDto;
66
import net.sf.anathema.hero.framework.perspective.CharacterGridView;
@@ -13,8 +13,9 @@
1313
public class FxCharacterNavigation extends Navigation implements InteractionView, CharacterGridView {
1414
private final CharacterGridFxView gridView;
1515

16-
public FxCharacterNavigation(DialogFactory dialogFactory) {
17-
this.gridView = new CharacterGridFxView(dialogFactory);
16+
public FxCharacterNavigation(UiEnvironment uiEnvironment) {
17+
super(uiEnvironment);
18+
this.gridView = new CharacterGridFxView(uiEnvironment);
1819
addContainerToNavigation(gridView.getNode());
1920
}
2021

Platform_FX/src/main/java/net/sf/anathema/platform/fx/Navigation.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package net.sf.anathema.platform.fx;
22

33
import javafx.scene.Node;
4-
import javafx.scene.Scene;
54
import javafx.scene.control.ToolBar;
65
import net.miginfocom.layout.AC;
76
import net.miginfocom.layout.CC;
7+
import net.sf.anathema.interaction.AcceleratorMap;
88
import net.sf.anathema.interaction.ToggleTool;
99
import net.sf.anathema.interaction.Tool;
1010
import net.sf.anathema.platform.tool.FxBaseTool;
@@ -19,8 +19,10 @@ public class Navigation {
1919
private MigPane pane = new MigPane(withoutInsets().gridGap("0", "2").wrapAfter(1), new AC().grow().fill(), new AC().fill());
2020
private MigPane navigation = new MigPane(withoutInsets().gridGap("0", "2").wrapAfter(1), new AC().grow().fill(), new AC().fill());
2121
private ToolBar toolBar = new ToolBar();
22+
private final AcceleratorMap acceleratorMap;
2223

23-
public Navigation() {
24+
public Navigation(AcceleratorMap acceleratorMap) {
25+
this.acceleratorMap = acceleratorMap;
2426
pane.add(toolBar, new CC().width("100%").grow());
2527
pane.add(navigation, new CC().push());
2628
}
@@ -54,11 +56,8 @@ public Node getNode() {
5456
return pane;
5557
}
5658

57-
protected void addTool(final FxBaseTool fxButtonTool) {
59+
protected void addTool(FxBaseTool fxButtonTool) {
5860
toolBar.getItems().add(fxButtonTool.getNode());
59-
Scene scene = toolBar.getScene();
60-
/*ObservableMap<KeyCombination, Runnable> accelerators = scene.getAccelerators();
61-
FxAcceleratorMap acceleratorMap = new FxAcceleratorMap(accelerators);
62-
fxButtonTool.registerHotkeyIn(acceleratorMap);*/
61+
fxButtonTool.registerHotkeyIn(acceleratorMap);
6362
}
6463
}

Platform_Preferences/src/main/java/net/sf/anathema/framework/preferences/perspective/FxPreferencesNavigation.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import javafx.scene.control.Button;
44
import net.sf.anathema.framework.preferences.elements.PreferenceView;
55
import net.sf.anathema.initialization.InitializationException;
6+
import net.sf.anathema.interaction.AcceleratorMap;
67
import net.sf.anathema.platform.fx.Navigation;
78
import net.sf.anathema.platform.fx.NodeHolder;
89

@@ -12,7 +13,8 @@ public class FxPreferencesNavigation extends Navigation implements PreferencesNa
1213
private final ArrayList<PreferenceView> availableViews;
1314
private final FxPreferencesView preferencesView;
1415

15-
public FxPreferencesNavigation(ArrayList<PreferenceView> preferenceViews, FxPreferencesView preferencesView) {
16+
public FxPreferencesNavigation(ArrayList<PreferenceView> preferenceViews, FxPreferencesView preferencesView, AcceleratorMap uiEnvironment) {
17+
super(uiEnvironment);
1618
this.availableViews = preferenceViews;
1719
this.preferencesView = preferencesView;
1820
}

Platform_Preferences/src/main/java/net/sf/anathema/framework/preferences/perspective/PreferencesSystemView.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class PreferencesSystemView {
1515
public PreferencesSystemView(ObjectFactory objectFactory) {
1616
Collection<PreferenceView> views = objectFactory.instantiateAllImplementers(PreferenceView.class);
1717
this.preferencesView = new FxPreferencesView();
18-
this.preferencesNavigation = new FxPreferencesNavigation(new ArrayList<>(views), preferencesView);
18+
this.preferencesNavigation = new FxPreferencesNavigation(new ArrayList<>(views), preferencesView, null);
1919
perspectivePane.setNavigationComponent(preferencesNavigation.getNode());
2020
perspectivePane.setContentComponent(preferencesView.getNode());
2121
}

0 commit comments

Comments
 (0)