MainScreenPresentation.java

  1. /*
  2.  * #%L
  3.  * *********************************************************************************************************************
  4.  *
  5.  * SteelBlue
  6.  * http://steelblue.tidalwave.it - git clone git@bitbucket.org:tidalwave/steelblue-src.git
  7.  * %%
  8.  * Copyright (C) 2015 - 2015 Tidalwave s.a.s. (http://tidalwave.it)
  9.  * %%
  10.  *
  11.  * *********************************************************************************************************************
  12.  *
  13.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  14.  * the License. You may obtain a copy of the License at
  15.  *
  16.  *     http://www.apache.org/licenses/LICENSE-2.0
  17.  *
  18.  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  19.  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
  20.  * specific language governing permissions and limitations under the License.
  21.  *
  22.  * *********************************************************************************************************************
  23.  *
  24.  *
  25.  *
  26.  * *********************************************************************************************************************
  27.  * #L%
  28.  */
  29. package it.tidalwave.role.ui.javafx.example.large.mainscreen;

  30. import javax.annotation.Nonnull;
  31. import java.nio.file.Path;
  32. import it.tidalwave.util.ui.UserNotificationWithFeedback;
  33. import it.tidalwave.role.ui.BoundProperty;
  34. import it.tidalwave.role.ui.PresentationModel;
  35. import it.tidalwave.role.ui.UserAction;
  36. import lombok.Builder;

  37. /***********************************************************************************************************************
  38.  *
  39.  * This interface describes all the interactions with the presentation object.
  40.  *
  41.  * @stereotype  Presentation
  42.  *
  43.  * @author  Fabrizio Giudici (Fabrizio.Giudici@tidalwave.it)
  44.  *
  45.  **********************************************************************************************************************/
  46. public interface MainScreenPresentation
  47.   {
  48.     /*******************************************************************************************************************
  49.      *
  50.      * If the presentation contains form fields, it's a good practice to group them together within a single class
  51.      * which exposes {@link BoundProperty} instances.
  52.      *
  53.      ******************************************************************************************************************/
  54.     @Builder
  55.     public static class Bindings
  56.       {
  57.         @Nonnull
  58.         public final UserAction buttonAction;

  59.         @Nonnull
  60.         public final UserAction actionDialogOk;

  61.         @Nonnull
  62.         public final UserAction actionDialogCancelOk;

  63.         @Nonnull
  64.         public final UserAction actionPickFile;

  65.         @Nonnull
  66.         public final UserAction actionPickDirectory;

  67.         public final BoundProperty<String> textProperty = new BoundProperty<>("1");

  68.         public final BoundProperty<Boolean> booleanProperty = new BoundProperty<>(true);
  69.       }

  70.     /*******************************************************************************************************************
  71.      *
  72.      * A presentation always exposes a {@code bind()} method which is invoked by the control and binds callbacks
  73.      * and form fields. There is no requirement on the name and signature of the method.
  74.      *
  75.      ******************************************************************************************************************/
  76.     public void bind (@Nonnull Bindings bindings);

  77.     /*******************************************************************************************************************
  78.      *
  79.      * A presentation typically exposes a {@code showUp()} method which brings the object into a visible state.
  80.      * There is no requirement on the name and signature of the method.
  81.      *
  82.      ******************************************************************************************************************/
  83.     public void showUp();

  84.     /*******************************************************************************************************************
  85.      *
  86.      * A presentation also exposes some {@link populateXYZ()} methods which are used to fill various parts of the UI
  87.      * with data. Data structures are modelled by {@link PresentationModel}s. There is no requirement on the name of the
  88.      * method.
  89.      *
  90.      ******************************************************************************************************************/
  91.     public void populate (@Nonnull PresentationModel pm1, @Nonnull PresentationModel pm2);

  92.     /*******************************************************************************************************************
  93.      *
  94.      * When the control requires an interaction with the user in form of a dialog box with feedback (such as Ok/Cancel)
  95.      * a method must be exposed which accepts a {@link UserNotificationWithFeedback}. There is no requirement on the
  96.      * name of the method.
  97.      *
  98.      ******************************************************************************************************************/
  99.     public void notify (@Nonnull UserNotificationWithFeedback notification);

  100.     /*******************************************************************************************************************
  101.      *
  102.      * Simple message notifications that appear in the presentation (for instance in a {@link Label} can be passed as
  103.      * simple strings of specific methods.
  104.      *
  105.      ******************************************************************************************************************/
  106.     public void notify (@Nonnull String message);

  107.     /*******************************************************************************************************************
  108.      *
  109.      *
  110.      *
  111.      ******************************************************************************************************************/
  112.     public void pickFile (@Nonnull BoundProperty<Path> selectedFile,
  113.                           @Nonnull UserNotificationWithFeedback notification);

  114.     /*******************************************************************************************************************
  115.      *
  116.      *
  117.      *
  118.      ******************************************************************************************************************/
  119.     public void pickDirectory (@Nonnull BoundProperty<Path> selectedFolder,
  120.                                @Nonnull UserNotificationWithFeedback notification);
  121.   }