Skip to content

Commit

Permalink
Chooses SelectionFactory where the decision to embed Fx in Swing is m…
Browse files Browse the repository at this point in the history
…ade (#332)
  • Loading branch information
UrsKR committed Jun 12, 2013
1 parent c58b7aa commit bb2f87e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.sf.anathema.lib.control.ObjectValueListener;
import net.sf.anathema.lib.gui.selection.ISelectionIntValueChangedListener;
import net.sf.anathema.platform.fx.FxObjectSelectionView;
import net.sf.anathema.platform.fx.selection.ComboBoxSelectionFactory;
import net.sf.anathema.platform.fx.selection.SelectionViewFactory;
import org.jmock.example.announcer.Announcer;
import org.tbee.javafx.scene.layout.MigPane;
Expand All @@ -19,7 +18,7 @@

public class FxCostSelectionView implements CostSelectionView {

private final SelectionViewFactory selectionViewFactory = new ComboBoxSelectionFactory();
private final SelectionViewFactory selectionViewFactory;
private FxObjectSelectionView<String> selection;
private ListSpinner<Integer> spinner;
private final MigPane pane = new MigPane(withoutInsets());
Expand All @@ -28,7 +27,8 @@ public class FxCostSelectionView implements CostSelectionView {
private final CostTypeChangeListener typeChangeListener = new CostTypeChangeListener();
private final CostValueChangeListener valueChangeListener = new CostValueChangeListener();

public FxCostSelectionView(final String text) {
public FxCostSelectionView(final String text, SelectionViewFactory viewFactory) {
selectionViewFactory = viewFactory;
Platform.runLater(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package net.sf.anathema.character.equipment.item.view.fx;

import javafx.application.Platform;
import net.sf.anathema.character.equipment.item.view.AgnosticEquipmentDatabaseView;
import net.sf.anathema.platform.fx.FxThreading;
import net.sf.anathema.platform.fx.PerspectivePane;
import net.sf.anathema.platform.fx.selection.ComboBoxSelectionFactory;

import static net.sf.anathema.platform.fx.FxThreading.runOnCorrectThread;
import static net.sf.anathema.platform.fx.FxUtilities.systemSupportsPopUpsWhileEmbeddingFxIntoSwing;

public class FxEquipmentDatabaseView {

public final PerspectivePane perspectivePane = new PerspectivePane("skin/anathema/equipment.css");
private final FxEquipmentDetails details = new FxEquipmentDetails();
private final FxEquipmentNavigation navigation = new FxEquipmentNavigation();
public final AgnosticEquipmentDatabaseView view = new AgnosticEquipmentDatabaseView(navigation, details);
private final FxEquipmentDetails details;
public final AgnosticEquipmentDatabaseView view;

public FxEquipmentDatabaseView() {
FxThreading.assertNotOnFxThread();
Platform.runLater(new Runnable() {
this.details = new FxEquipmentDetails(selectionFactory());
this.view = new AgnosticEquipmentDatabaseView(navigation, details);
initializePerspective();
}

private void initializePerspective() {
runOnCorrectThread(new Runnable() {
@Override
public void run() {
perspectivePane.addStyleSheetClass("equipment-perspective");
Expand All @@ -23,4 +30,12 @@ public void run() {
}
});
}

private ComboBoxSelectionFactory selectionFactory() {
if (systemSupportsPopUpsWhileEmbeddingFxIntoSwing()) {
return new ComboBoxSelectionFactory();
} else {
return new ComboBoxSelectionFactory();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
import net.sf.anathema.lib.workflow.textualdescription.ITextView;
import net.sf.anathema.platform.fx.FxObjectSelectionView;
import net.sf.anathema.platform.fx.FxTextView;
import net.sf.anathema.platform.fx.selection.ComboBoxSelectionFactory;
import net.sf.anathema.platform.fx.selection.SelectionViewFactory;
import org.tbee.javafx.scene.layout.MigPane;

public class FxEquipmentDescriptionPanel implements EquipmentDescriptionPanel {

private final SelectionViewFactory selectionViewFactory = new ComboBoxSelectionFactory();
private final SelectionViewFactory selectionViewFactory;
private MigPane pane;

public FxEquipmentDescriptionPanel() {
public FxEquipmentDescriptionPanel(SelectionViewFactory selectionFactory) {
this.selectionViewFactory = selectionFactory;
Platform.runLater(new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -84,7 +84,7 @@ public void run() {

@Override
public CostSelectionView addCostView(String label) {
final FxCostSelectionView costSelectionView = new FxCostSelectionView(label);
final FxCostSelectionView costSelectionView = new FxCostSelectionView(label, selectionViewFactory);
Platform.runLater(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
import net.sf.anathema.lib.gui.AgnosticUIConfiguration;
import net.sf.anathema.lib.gui.layout.LayoutUtils;
import net.sf.anathema.platform.fx.BorderedTitledPane;
import net.sf.anathema.platform.fx.selection.SelectionViewFactory;
import org.tbee.javafx.scene.layout.MigPane;

public class FxEquipmentDetails implements EquipmentDetails {

private final FxToolListView<IEquipmentStats> listView = new FxToolListView<>();
private final FxEquipmentDescriptionPanel descriptionPanel = new FxEquipmentDescriptionPanel();
private final FxEquipmentDescriptionPanel descriptionPanel;
private MigPane outerPane;

public FxEquipmentDetails() {
public FxEquipmentDetails(SelectionViewFactory selectionFactory) {
this.descriptionPanel = new FxEquipmentDescriptionPanel(selectionFactory);
Platform.runLater(new Runnable() {
@Override
public void run() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public class FxUtilities {
public static boolean systemSupportsPopUpsWhileEmbeddingFxIntoSwing() {
return !SystemUtils.IS_OS_MAC;
}
}
}

0 comments on commit bb2f87e

Please sign in to comment.