Ejemplo n.º 1
0
  public void setMode(Mode mode) {
    if (mode != this.mode) {
      Mode previousMode = this.mode;
      this.mode = mode;
      log.info(String.format("Dock mode is now %s", mode));
      switch (mode) {
        case LAUNCHERS:
          rebuildIcons();
          setAvailable();
          flinger.recentre();
          break;
        case UPDATE:
          try {
            // Starting an update, so hide the all other windows
            hideIfShowing(signInPopup);
            hideIfShowing(optionsPopup);
            hideIfShowing(resourceGroupPopup);
            setAvailable();
            updateScene =
                (Update)
                    context.openScene(
                        Update.class, Configuration.getDefault().isVertical() ? "Vertical" : null);
            Scene scn = updateScene.getScene();
            scn.setFill(new Color(0, 0, 0, 0));

            /*
             * The update popup will get future update events, but it
             * needs this one to initialize
             */
            updateScene.initUpdate(appsToUpdate, previousMode);

            Parent sceneRoot = scn.rootProperty().get();
            scn.setRoot(new Group());

            if (cfg.isVertical())
              ((VBox) sceneRoot).minWidthProperty().bind(shortcuts.heightProperty());
            else ((HBox) sceneRoot).minHeightProperty().bind(shortcuts.widthProperty());

            flinger.getContent().getChildren().clear();
            flinger.getContent().getChildren().add(sceneRoot);
          } catch (IOException ioe) {
            log.error("Failed to load update scene.", ioe);
          }
          break;
        case IDLE:
          flinger.getContent().getChildren().clear();
          setAvailable();
          break;
        default:
          throw new UnsupportedOperationException();
      }
    }
  }