Quellcode durchsuchen

Change instructions to use a binding.

Sam Jaffe vor 5 Jahren
Ursprung
Commit
1bf3636665
1 geänderte Dateien mit 5 neuen und 4 gelöschten Zeilen
  1. 5 4
      src/main/lombok/org/leumasjaffe/recipe/view/StepPanel.java

+ 5 - 4
src/main/lombok/org/leumasjaffe/recipe/view/StepPanel.java

@@ -7,6 +7,7 @@ import org.leumasjaffe.observer.ForwardingObservableListener;
 import org.leumasjaffe.observer.ObservableController;
 import org.leumasjaffe.observer.ObservableListener;
 import org.leumasjaffe.observer.ObserverDispatch;
+import org.leumasjaffe.recipe.controller.TextBinding;
 import org.leumasjaffe.recipe.model.Ingredient;
 import org.leumasjaffe.recipe.model.Step;
 
@@ -31,7 +32,7 @@ import java.awt.Dimension;
 @FieldDefaults(level=AccessLevel.PRIVATE)
 public class StepPanel extends JPanel implements AutoGrowPanel.ChildComponent {
 	ForwardingObservableListener<Step> listener = new ForwardingObservableListener<>();
-	ObservableListener<JTextPane, Step> instructionListener;
+	TextBinding<Step> instructionBinding;
 	ObservableListener<JFormattedTextField, Step> durationController;
 
 	JLabel lblIndex;
@@ -98,7 +99,7 @@ public class StepPanel extends JPanel implements AutoGrowPanel.ChildComponent {
 		gbc_txtpnInstructions.gridy = 0;
 		add(txtpnInstructions, gbc_txtpnInstructions);
 		
-		instructionListener = ObservableController.from(txtpnInstructions,
+		instructionBinding = new TextBinding<>(txtpnInstructions,
 				Step::getInstruction, Step::setInstruction);
 		durationController = ObservableController.from(panelDuration.txtTime,
 				Step::getDuration, Step::setDuration);
@@ -119,7 +120,7 @@ public class StepPanel extends JPanel implements AutoGrowPanel.ChildComponent {
 			}
 		});
 		listener.setObserved(step, step.getIngredients());
-		instructionListener.setObserved(step);
+		instructionBinding.setModel(step);
 		durationController.setObserved(step);
 	}
 	
@@ -127,7 +128,7 @@ public class StepPanel extends JPanel implements AutoGrowPanel.ChildComponent {
 	public void removeNotify() {
 		super.removeNotify();
 		ObserverDispatch.unsubscribeAll(listener);
-		ObserverDispatch.unsubscribeAll(instructionListener);
+		ObserverDispatch.unsubscribeAll(instructionBinding);
 		ObserverDispatch.unsubscribeAll(durationController);
 	}