Skip to content

Commit

Permalink
Creates selection views via unified factory (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
UrsKR committed Jun 12, 2013
1 parent 9575195 commit 84d15d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import net.sf.anathema.character.equipment.item.view.CostSelectionView;
import net.sf.anathema.lib.control.ObjectValueListener;
import net.sf.anathema.lib.gui.selection.ISelectionIntValueChangedListener;
import net.sf.anathema.platform.fx.ComboBoxSelectionView;
import net.sf.anathema.platform.fx.FxObjectSelectionView;
import org.jmock.example.announcer.Announcer;
import org.tbee.javafx.scene.layout.MigPane;

import static net.sf.anathema.lib.gui.layout.LayoutUtils.withoutInsets;

public class FxCostSelectionView implements CostSelectionView {

private ComboBoxSelectionView<String> selection;
private final SelectionViewFactory selectionViewFactory = new SelectionViewFactory();
private FxObjectSelectionView<String> selection;
private ListSpinner<Integer> spinner;
private final MigPane pane = new MigPane(withoutInsets());
private final Announcer<ISelectionIntValueChangedListener> announcer = new Announcer<>(
Expand All @@ -29,7 +30,7 @@ public FxCostSelectionView(final String text) {
Platform.runLater(new Runnable() {
@Override
public void run() {
selection = new ComboBoxSelectionView<>(text, new SimpleUiConfiguration());
selection = selectionViewFactory.create(text, new SimpleUiConfiguration());
spinner = new ListSpinner<>(0, 5);
spinner.getStyleClass().add("dots");
pane.add(selection.getNode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import net.sf.anathema.lib.gui.AgnosticUIConfiguration;
import net.sf.anathema.lib.gui.selection.IObjectSelectionView;
import net.sf.anathema.lib.workflow.textualdescription.ITextView;
import net.sf.anathema.platform.fx.ComboBoxSelectionView;
import net.sf.anathema.platform.fx.FxObjectSelectionView;
import net.sf.anathema.platform.fx.FxTextView;
import org.tbee.javafx.scene.layout.MigPane;

public class FxEquipmentDescriptionPanel implements EquipmentDescriptionPanel {

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

public FxEquipmentDescriptionPanel() {
Expand Down Expand Up @@ -57,7 +57,7 @@ public void run() {
@Override
public IObjectSelectionView<MaterialComposition> addCompositionView(String label,
AgnosticUIConfiguration<MaterialComposition> ui) {
final FxObjectSelectionView<MaterialComposition> selectionView = createSelectionView(label, ui);
final FxObjectSelectionView<MaterialComposition> selectionView = selectionViewFactory.create(label, ui);
Platform.runLater(new Runnable() {
@Override
public void run() {
Expand All @@ -70,7 +70,7 @@ public void run() {
@Override
public IObjectSelectionView<MagicalMaterial> addMaterialView(String label,
AgnosticUIConfiguration<MagicalMaterial> ui) {
final FxObjectSelectionView<MagicalMaterial> selectionView = createSelectionView(label, ui);
final FxObjectSelectionView<MagicalMaterial> selectionView = selectionViewFactory.create(label, ui);
Platform.runLater(new Runnable() {
@Override
public void run() {
Expand All @@ -95,8 +95,4 @@ public void run() {
public Node getNode() {
return pane;
}

private <T> FxObjectSelectionView<T> createSelectionView(String label, AgnosticUIConfiguration<T> ui) {
return new ComboBoxSelectionView<>(label, ui);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.sf.anathema.character.equipment.item.view.fx;

import net.sf.anathema.lib.gui.AgnosticUIConfiguration;
import net.sf.anathema.platform.fx.ComboBoxSelectionView;
import net.sf.anathema.platform.fx.FxObjectSelectionView;

public class SelectionViewFactory {

public <T> FxObjectSelectionView<T> create(String label, AgnosticUIConfiguration<T> ui) {
return new ComboBoxSelectionView<>(label, ui);
}
}

0 comments on commit 84d15d5

Please sign in to comment.