void hideActivityCircle() {
   if (activityCircle != null) {
     // We use an animation to dim the activity circle; need to clear this or it will remain
     // visible.
     activityCircle.clearAnimation();
     activityCircle.setVisibility(View.INVISIBLE);
   }
 }
Esempio n. 2
0
  private View getActivityCircleView(View convertView, ViewGroup parent) {
    View result = convertView;

    if (result == null) {
      result = inflater.inflate(R.layout.com_facebook_picker_activity_circle_row, null);
    }
    ProgressBar activityCircle =
        (ProgressBar) result.findViewById(R.id.com_facebook_picker_row_activity_circle);
    activityCircle.setVisibility(View.VISIBLE);

    return result;
  }
Esempio n. 3
0
 @FXML
 void seek(MouseEvent evt) {
   if (player != null) {
     Duration d = player.getMedia().getDuration();
     double millis = (evt.getX() / loadProgressBar.getWidth()) * d.toMillis();
     Duration s = new Duration(millis);
     player.seek(s);
   }
 }
  @Override
  public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    saveSettingsToBundle(outState);
    selectionStrategy.saveSelectionToBundle(outState, SELECTION_BUNDLE_KEY);
    if (activityCircle != null) {
      outState.putBoolean(ACTIVITY_CIRCLE_SHOW_KEY, activityCircle.getVisibility() == View.VISIBLE);
    }
  }
Esempio n. 5
0
 void updatePlayProgress() {
   if (player != null && Tray.stage.isShowing()) {
     Duration d = player.getMedia().getDuration();
     Duration t = player.getCurrentTime();
     loadProgressBar.setProgress(t.toMillis() / d.toMillis());
     timeUpdate++;
     if (timeUpdate == 10) {
       timeUpdate = 0;
       Platform.runLater(
           () -> {
             timeLabel.setText(formatTime(d, t));
           });
     }
   }
 }
        @Override
        public void handleResponse(BackendlessCollection<SearchMatchesResult> response) {
          for (SearchMatchesResult geoPoint : response.getCurrentPage()) {

            if (geoPoint.getGeoPoint().equals(targetUserGeoPoint)) {
              travelMatchCount = geoPoint.getMatches();
              if (travelMatchCount <= 1) travelMatchCount = travelMatchCount * 100;
              travelMatchValue.setText(String.valueOf(round(travelMatchCount, 2)));
              travelProgressBar.setProgress((int) round(travelMatchCount, 2));
              travel = true;
            }
          }

          if (music == true && food == true && hobbies == true && travel == true) {
            summMatch =
                (foodMatchCount + musicMatchCount + hobbiesMatchCount + travelMatchCount) / 4;
            matchPercentField.setText(String.valueOf(round(summMatch, 2)));
            progressDialog.cancel();
          }
        }
Esempio n. 7
0
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    if ((mode & DEBUG) != 0) IJ.setDebugMode(true);
    mode = mode & 255;
    if (IJ.debugMode) IJ.log("ImageJ starting in debug mode: " + mode);
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    setBackground(backgroundColor);
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new BorderLayout());

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add("Center", toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new JLabel();
    statusLine.setFont(new Font("SansSerif", Font.PLAIN, 13));
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    add("South", statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);
    m.installStartupMacroSet(); // add custom tools
    runStartupMacro();

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setLocation(loc.x, loc.y);
      setResizable(!IJ.isMacOSX());
      pack();
      setVisible(true);
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    configureProxy();
    if (applet == null) loadCursors();
  }
Esempio n. 8
0
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    if (IJ.isLinux()) {
      backgroundColor = new Color(240, 240, 240);
      setBackground(backgroundColor);
    }
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new GridLayout(2, 1));

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add(toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new Label();
    statusLine.setFont(SansSerif12);
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    statusBar.setSize(toolbar.getPreferredSize());
    add(statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    int ijWidth = tbSize.width + 10;
    int ijHeight = 100;
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work
      setLocation(loc.x, loc.y);
      pack();
      setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux
      show();
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    m.installStartupMacroSet();
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    // if (applet==null && !embedded && Prefs.runSocketListener)
    //	new SocketListener();
    configureProxy();
    if (applet == null) loadCursors();
  }
Esempio n. 9
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    AppController.instance = this;
    this.res = resources;

    ObservableList<String> modeItems =
        FXCollections.observableArrayList(
            Settings.MODE_NEXT, Settings.MODE_RANDOM, Settings.MODE_SAME);
    modeList.setItems(modeItems);
    modeList.getSelectionModel().select(Settings.currentMode);
    modeList
        .valueProperty()
        .addListener(
            (ObservableValue ov, Object oldVal, Object newVal) -> {
              Settings.currentMode = (String) newVal;
            });

    setupPlaylistsView();
    setupPlaylistsContextMenu();

    setupTracksView();

    tracksView.setContextMenu(tracksContextMenu);
    tracksView.setOnContextMenuRequested(
        (ContextMenuEvent evt) -> {
          setupTracksContextMenu();
          evt.consume();
        });
    tracksView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ObservableValue observable, Object oldValue, Object newValue) -> {
              Settings.lastTrackId = newValue != null ? ((Track) newValue).getId() : null;
            });

    playlistsView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ObservableValue observable, Object oldValue, Object newValue) -> {
              loadSelectedPlaylist();
              Settings.lastPlaylistId = newValue != null ? ((Playlist) newValue).getId() : null;
              searching = false;
              searchText.setText(StringUtils.EMPTY);
            });

    volumeSlider.setCursor(Cursor.HAND);
    volumeSlider
        .valueProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldVal, Number newVal) -> {
              if (player != null) {
                player.setVolume(newVal.doubleValue());
              }
              Settings.currentVolume = newVal.doubleValue();
              volumeLabel.setText(
                  String.valueOf((int) Math.ceil(newVal.doubleValue() * 100)) + "%");
            });
    volumeSlider.setValue(Settings.currentVolume);

    imagePlay = new ImageView(new Image(getClass().getResourceAsStream("/images/button_play.png")));
    imagePlay.setScaleX(0.40);
    imagePlay.setScaleY(0.40);
    imagePause =
        new ImageView(new Image(getClass().getResourceAsStream("/images/button_pause.png")));
    imagePause.setScaleX(0.5);
    imagePause.setScaleY(0.5);
    imageSettings =
        new ImageView(new Image(getClass().getResourceAsStream("/images/settings.png")));
    imageSettings.setScaleX(0.5);
    imageSettings.setScaleY(0.5);
    imageUpdate = new ImageView(new Image(getClass().getResourceAsStream("/images/refresh.png")));
    imageUpdate.setScaleX(0.5);
    imageUpdate.setScaleY(0.5);
    imageAdd = new ImageView(new Image(getClass().getResourceAsStream("/images/add.png")));
    imageAdd.setScaleX(0.5);
    imageAdd.setScaleY(0.5);
    imageRename = new ImageView(new Image(getClass().getResourceAsStream("/images/rename.png")));
    imageRename.setScaleX(0.5);
    imageRename.setScaleY(0.5);
    imageDelete = new ImageView(new Image(getClass().getResourceAsStream("/images/delete.png")));
    imageDelete.setScaleX(0.5);
    imageDelete.setScaleY(0.5);

    stateButton.setGraphic(imagePlay);
    settingsButton.setGraphic(imageSettings);
    refreshButton.setGraphic(imageUpdate);
    refreshButton.setTooltip(new Tooltip(res.getString("tooltip_sync")));

    addButton.setGraphic(imageAdd);
    addButton.setOnAction((evt) -> createOfflinePlaylist());
    addButton.setTooltip(new Tooltip(res.getString("tooltip_add_offline")));
    renameButton.setGraphic(imageRename);
    renameButton.setOnAction(evt -> renamePlaylist());
    renameButton.setTooltip(new Tooltip(res.getString("rename_playlist")));
    deleteButton.setGraphic(imageDelete);
    deleteButton.setOnAction(evt -> deletePlaylist());
    deleteButton.setTooltip(new Tooltip(res.getString("delete_playlist")));

    loadProgressBar.setCursor(Cursor.HAND);
    volumeSlider.setCursor(Cursor.HAND);
    updatePlaylists();
    if (Settings.lastPlaylistId != null) {
      currentPlaylist =
          ((ObservableList<Playlist>) playlistsView.getItems())
              .stream()
              .filter((playlist) -> playlist.getId().equals(Settings.lastPlaylistId))
              .findFirst()
              .orElse(null);
      playlistsView.getSelectionModel().select(currentPlaylist);
      playlistsView.scrollTo(currentPlaylist);
      Platform.runLater(
          () -> {
            if (Settings.lastTrackId != null) {
              currentTrack =
                  ((ObservableList<Track>) tracksView.getItems())
                      .stream()
                      .filter((track) -> track.getId().equals(Settings.lastTrackId))
                      .findFirst()
                      .orElse(null);
              tracksView.getSelectionModel().select(currentTrack);
              tracksView.scrollTo(currentTrack);
            }
          });
    }
    new Timer()
        .scheduleAtFixedRate(
            new TimerTask() {
              @Override
              public void run() {
                updatePlayProgress();
              }
            },
            100,
            100);
    setupTracksContextMenu();

    setupShortcuts();

    Platform.runLater(
        () -> {
          tracksView.requestFocus();
        });
  }
  public DownloadGUI() {

    setTitle("Rav's Download Manager");

    setSize(640, 480);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            actionExit();
          }
        });

    JPanel addPanel = new JPanel();
    pauseButton = new JButton("", new ImageIcon("icons/pause.gif"));
    pauseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionPause();
          }
        });
    pauseButton.setEnabled(false);
    addPanel.add(pauseButton);
    resumeButton = new JButton("", new ImageIcon("icons/resume.gif"));
    resumeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionResume();
          }
        });
    resumeButton.setEnabled(false);
    addPanel.add(resumeButton);
    cancelButton = new JButton("", new ImageIcon("icons/cancel.gif"));
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionCancel();
          }
        });
    cancelButton.setEnabled(false);
    addPanel.add(cancelButton);
    clearButton = new JButton("", new ImageIcon("icons/clear.gif"));
    clearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionClear();
          }
        });
    clearButton.setEnabled(false);
    addPanel.add(clearButton);

    JPanel addPane2 = new JPanel();
    addTextField = new JTextField(30);
    addPane2.add(addTextField);
    JButton addButton = new JButton("", new ImageIcon("icons/add.gif"));
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            actionAdd();
          }
        });
    addPane2.add(addButton);

    tableModel = new DownloadList();
    table = new JTable(tableModel);
    table
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                tableSelectionChanged();
              }
            });

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ProgressBar renderer = new ProgressBar(0, 100);
    renderer.setStringPainted(true);
    table.setDefaultRenderer(JProgressBar.class, renderer);

    table.setRowHeight((int) renderer.getPreferredSize().getHeight());

    JPanel downloadsPanel = new JPanel();
    downloadsPanel.setBorder(BorderFactory.createTitledBorder("Downloads"));
    downloadsPanel.setLayout(new BorderLayout());
    downloadsPanel.add(new JScrollPane(table), BorderLayout.CENTER);

    getContentPane().setLayout(new GridLayout(3, 1));
    getContentPane().add(addPane2);
    getContentPane().add(addPanel);
    getContentPane().add(downloadsPanel);
  }
 void displayActivityCircle() {
   if (activityCircle != null) {
     layoutActivityCircle();
     activityCircle.setVisibility(View.VISIBLE);
   }
 }
  public static EventHandler<ActionEvent> getUploadHandler(
      FXController controller, ProgressBar progressBar, CheckBox stem) {
    return e -> {
      Alert a;
      if (selectedFiles != null) {
        controller.selectedFiles = new File[selectedFiles.size()];
        for (int i = 0; i < selectedFiles.size(); i++) {
          String filepath = selectedFiles.get(i).getAbsolutePath();
          if (lastUpload.contains(filepath)) {
            a = new Alert(Alert.AlertType.CONFIRMATION);
            a.setTitle("Are you sure?");
            a.setContentText(
                "You just uploaded " + filepath + ", are you sure you want to upload it again?");
            Optional<ButtonType> result = a.showAndWait();
            if (result.get() != ButtonType.OK) {
              return;
            }
          }
          if (selectedFiles.get(i).isAbsolute() && selectedFiles.get(i).exists()) {
            controller.selectedFiles[i] = selectedFiles.get(i);
          } else {
            a = new Alert(Alert.AlertType.INFORMATION, "Invalid path to file.", ButtonType.OK);
            a.setTitle("Information");
            a.showAndWait();
            return;
          }
        }
      } else {
        a = new Alert(Alert.AlertType.INFORMATION, "Please select a file.", ButtonType.OK);
        a.initStyle(StageStyle.UTILITY);
        a.setTitle("Information");
        a.showAndWait();
        return;
      }

      progressBar.setProgress(0);
      controller.writeLog("Uploading file(s)...");
      Button source = (Button) e.getSource();
      source.setDisable(true);

      SwingWorker<Boolean, Double> worker =
          new SwingWorker<Boolean, Double>() {
            @Override
            protected Boolean doInBackground() throws Exception {
              String[] key = new String[FXController.selectedFiles.length];
              publish(0.05);

              for (int i = 0; i < FXController.selectedFiles.length; i++) {
                key[i] = UUID.randomUUID().toString();
                FileUtils.uploadFile(FXController.selectedFiles[i], key[i], AESCTR.secretKey);
              }
              publish(0.4);

              Map<String, ArrayList<StringPair>> map =
                  SSE.EDBSetup(
                      FXController.selectedFiles, AESCTR.secretKey, key, stem.isSelected());
              publish(0.6);

              ObjectMapper mapper = new ObjectMapper();
              try {
                String json = mapper.writeValueAsString(map);
                publish(0.8);
                HttpUtil.HttpPost(json);
              } catch (JsonProcessingException e1) {
                e1.printStackTrace();
                return false;
              }

              publish(1.0);
              return true;
            }

            @Override
            protected void done() {
              Platform.runLater(
                  new TimerTask() {
                    @Override
                    public void run() {
                      Alert a;
                      try {
                        if (get()) {
                          controller.writeLog("Upload successful!");
                          a =
                              new Alert(
                                  Alert.AlertType.INFORMATION, "Upload successful!", ButtonType.OK);
                          a.setTitle("Success!");
                          a.showAndWait();
                          lastUpload.clear();
                          for (File f : FXController.selectedFiles) {
                            lastUpload.add(f.getAbsolutePath());
                          }
                        } else {
                          controller.writeLog("Upload failed!");
                          a = new Alert(Alert.AlertType.ERROR, "Upload failed!", ButtonType.OK);
                          a.setTitle("Error!");
                          a.showAndWait();
                        }
                      } catch (Exception ex) {
                        a = new Alert(Alert.AlertType.ERROR, "Upload error!", ButtonType.OK);
                        a.setTitle("Error!");
                        a.showAndWait();
                        ex.printStackTrace();
                      }
                      source.setDisable(false);
                    }
                  });
            }

            @Override
            protected void process(List<Double> n) {
              progressBar.setProgress(n.get(n.size() - 1));
            }
          };

      worker.execute();
    };
  }