JavaFXStructureEditorPresentationDelegate.java

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

  28. import javax.annotation.Nonnull;
  29. import javafx.collections.FXCollections;
  30. import javafx.fxml.FXML;
  31. import javafx.scene.layout.Pane;
  32. import javafx.scene.control.TableView;
  33. import javafx.scene.web.WebView;
  34. import it.tidalwave.role.ui.PresentationModel;
  35. import it.tidalwave.role.ui.javafx.JavaFXBinder;
  36. import it.tidalwave.northernwind.rca.ui.structureeditor.StructureEditorPresentation;
  37. import lombok.RequiredArgsConstructor;

  38. /***********************************************************************************************************************
  39.  *
  40.  * @author Fabrizio Giudici
  41.  *
  42.  **********************************************************************************************************************/
  43. @RequiredArgsConstructor
  44. public class JavaFXStructureEditorPresentationDelegate implements StructureEditorPresentation
  45.   {
  46.     @Nonnull
  47.     private final JavaFXBinder binder;

  48.     @FXML
  49.     private Pane structureEditor;

  50.     @FXML
  51.     private WebView structureWebView;

  52.     @FXML
  53.     private TableView<PresentationModel> structureEditorProperties;

  54.     public void initialize()
  55.       {
  56.       }

  57.     @Override
  58.     public void showUp()
  59.       {
  60.         // never used
  61.       }

  62.     @Override
  63.     public void clear()
  64.       {
  65.         structureWebView.getEngine().loadContent("");
  66.         structureEditorProperties.setItems(FXCollections.<PresentationModel>emptyObservableList());
  67.       }

  68.     @Override
  69.     public void populate (final @Nonnull String text)
  70.       {
  71.         structureWebView.getEngine().loadContent(text);
  72.       }

  73.     @Override
  74.     public void populateProperties (final @Nonnull PresentationModel pm)
  75.       {
  76.         binder.bind(structureEditorProperties, pm);
  77.       }
  78.   }