@SuppressWarnings("restriction")
 @Override
 public void handle(WindowEvent event) {
   EventType<WindowEvent> eventType = event.getEventType();
   logger.debug("Window event: " + eventType.getName());
   websocketClientEndpoint.setReceiveTextArea(null);
   websocketClientEndpoint.close();
   try {
     Thread.sleep(500); // wait for websocket to close
   } catch (InterruptedException e) {
     logger.error("cant sleep", e);
   }
   client.shutdown();
   Platform.exit();
   System.exit(0);
 }
示例#2
0
 @Override
 public void handle(MouseEvent event) {
   EventType<? extends Event> type = event.getEventType();
   if (type.equals(MouseEvent.MOUSE_ENTERED) || type.equals(MouseEvent.MOUSE_EXITED)) {
     refreshVisual();
   } else if (type.equals(MouseEvent.MOUSE_MOVED) || type.equals(MouseEvent.MOUSE_DRAGGED)) {
     if (originalBounds != null) {
       if (!originalBounds.contains(event.getSceneX(), event.getSceneY())) {
         // unhover the visual by making it mouse transparent
         getVisual().setMouseTransparent(true);
         // this will result in a MOUSE_EXITED event being fired,
         // which will lead to a refreshVisual() call, which will
         // update the visualization
       }
     }
   }
 }
  @Override
  public void handle(MouseEvent event) {
    EventType<? extends MouseEvent> eventType = event.getEventType();
    if (eventType.equals(MouseEvent.MOUSE_CLICKED)) {
      if (openMenu != null) disposeOpenMenu();
      MenuItem hmi = new MenuItem("Help");
      hmi.setOnAction(e -> DialogService.openHelpDialog());

      PhongMaterial m = new PhongMaterial();
      m.setDiffuseColor(Color.GREEN);
      m.setSpecularColor(Color.WHITE);
      Box box = new Box(10, 10, 10);
      box.setMaterial(m);
      box.getTransforms().addAll(new Rotate(45, Rotate.Z_AXIS), new Rotate(45, Rotate.X_AXIS));

      MenuItem imi = new MenuItem("Inspect", new ImageView(Resources.SEARCH_ICON));
      imi.setOnAction(
          e -> {
            DialogService.openInspectDialog(node);
          });

      MenuItem emi = new MenuItem("Expand / Collapse", box);
      emi.setOnAction(
          e -> {
            handlePrimaryClick();
          });

      openMenu = new ContextMenu();
      openMenu.getItems().addAll(emi, imi, new SeparatorMenuItem(), hmi);
      openMenu.show(shape, event.getScreenX(), event.getScreenY());
    } else if (eventType.equals(MouseEvent.MOUSE_ENTERED)) {
      manager.submitTask(() -> manager.findReferingNodes(node, true));
    } else if (eventType.equals(MouseEvent.MOUSE_EXITED)) {
      manager.submitTask(() -> manager.findReferingNodes(node, false));
    }
  }