Example #1
0
 /**
  * Returns a {@link Set} containing all {@link IFXOnTypePolicy}s that are installed on the target
  * {@link IVisualPart} for the given {@link Scene}. If an {@link IVisualPart} within the given
  * {@link Scene} has keyboard focus, that part is used as the target part. Otherwise, the root
  * part of the {@link IViewer} that is rendered in the given {@link Scene} is used as the target
  * part.
  *
  * @param scene The {@link Scene} for which to determine the {@link IFXOnTypePolicy}s that are
  *     installed on the target {@link IVisualPart}.
  * @return A {@link List} containing all {@link IFXOnTypePolicy}s that are installed on the target
  *     {@link IVisualPart} for the given {@link Scene}.
  */
 @SuppressWarnings("serial")
 protected List<? extends IFXOnTypePolicy> getTargetPolicies(Scene scene) {
   IVisualPart<Node, ? extends Node> targetPart = null;
   for (IViewer<Node> viewer : getDomain().getViewers().values()) {
     if (viewer instanceof FXViewer) {
       if (((FXViewer) viewer).getScene() == scene) {
         FocusModel<Node> focusModel = viewer.getAdapter(new TypeToken<FocusModel<Node>>() {});
         if (focusModel == null) {
           throw new IllegalStateException("Cannot find FocusModel<Node>.");
         }
         IVisualPart<Node, ? extends Node> part = focusModel.getFocus();
         if (part == null) {
           targetPart = viewer.getRootPart();
         } else {
           targetPart = part;
         }
         break;
       }
     }
   }
   if (targetPart == null) {
     return Collections.emptyList();
   }
   return targetPolicyResolver.getTargetPolicies(
       this, targetPart.getVisual(), IFXOnTypePolicy.class);
 }