Exemple #1
0
 /**
  * Launches an array of <code>providers</code> delegating the time consuming construction of
  * {@link Downloader#getDownloadFragment()} into a background threads.
  */
 public static void launch(LaunchableProvider[] providers) {
   boolean audioLaunched = false;
   GUIMediator.instance().setFrameCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   for (LaunchableProvider provider : providers) {
     File file = provider.getFile();
     if (file != null) {
       audioLaunched = GUIUtils.launchOrEnqueueFile(file, audioLaunched);
     }
   }
   GUIMediator.instance().setFrameCursor(Cursor.getDefaultCursor());
 }
  /**
   * Makes the options window either visible or not visible depending on the boolean argument.
   *
   * @param visible <tt>boolean</tt> value specifying whether the options window should be made
   *     visible or not visible
   * @param key the unique identifying key of the panel to show
   */
  final void setOptionsVisible(boolean visible, final String key) {
    if (!visible) {
      DIALOG.dispose();
      OptionsMediator.instance().disposeOptions();
    } else {
      GUIUtils.centerOnScreen(DIALOG);
      //  initial tree selection
      if (key == null) TREE_MANAGER.setDefaultSelection();
      else TREE_MANAGER.setSelection(key);

      // make tree component the default component instead of the search field
      TREE_MANAGER.getComponent().requestFocusInWindow();

      DIALOG.setVisible(true);
    }
  }
  public void setupWindow() {
    String title = I18n.tr("Upload to device");
    setTitle(title);

    Dimension prefDimension = new Dimension(400, 100);

    setSize(prefDimension);
    setMinimumSize(prefDimension);
    setPreferredSize(prefDimension);
    setResizable(false);

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setModalityType(ModalityType.APPLICATION_MODAL);
    GUIUtils.addHideAction((JComponent) getContentPane());

    container = getContentPane();
    container.setLayout(new GridBagLayout());
  }
  @SuppressWarnings({"unchecked"})
  private OptionsTreeNode initializePanels() {
    // bittorrent
    addGroupTreeNode(OptionsMediator.ROOT_NODE_KEY, BITTORRENT_KEY, I18n.tr("BitTorrent"));
    OptionsTreeNode node =
        addOption(
            BITTORRENT_KEY,
            BITTORRENT_BASIC_KEY,
            I18n.tr("Basic"),
            TorrentSaveFolderPaneItem.class,
            TorrentSeedingSettingPaneItem.class);
    addOption(
        BITTORRENT_KEY,
        BITTORRENT_ADVANCED_KEY,
        I18n.tr("Advanced"),
        TorrentGlobalSpeedPaneItem.class,
        TorrentConnectionPaneItem.class);

    // library
    addOption(
        OptionsMediator.ROOT_NODE_KEY,
        LIBRARY_KEY,
        I18n.tr("Library"),
        LibraryFoldersPaneItem.class,
        WiFiSharingPaneItem.class,
        LibraryInternetRadioPaneItem.class);

    // player
    addOption(OptionsMediator.ROOT_NODE_KEY, PLAYER_KEY, I18n.tr("Player"), PlayerPaneItem.class);

    // search options
    addOption(
        OptionsMediator.ROOT_NODE_KEY,
        SEARCH_KEY,
        I18n.tr("Searching"),
        SearchEnginesPaneItem.class,
        MaximumSearchesPaneItem.class,
        SmartSearchDBPaneItem.class,
        DetailsPaneItem.class);

    // status bar
    addOption(
        OptionsMediator.ROOT_NODE_KEY,
        STATUS_BAR_KEY,
        I18n.tr("Status Bar"),
        StatusBarConnectionQualityPaneItem.class,
        StatusBarFirewallPaneItem.class,
        StatusBarBandwidthPaneItem.class); // Removed Lime Store

    // itunes
    if (OSUtils.isMacOSX() || OSUtils.isWindows()) {
      addGroupTreeNode(OptionsMediator.ROOT_NODE_KEY, ITUNES_KEY, I18n.tr("iTunes"));
      addOption(
          ITUNES_KEY, ITUNES_IMPORT_KEY, I18n.tr("Importing"), iTunesPreferencePaneItem.class);
    }

    if (!OSUtils.isWindows() && !OSUtils.isAnyMac()) {
      addOption(
          OptionsMediator.ROOT_NODE_KEY,
          APPS_KEY,
          I18n.tr("Helper Apps"),
          BrowserPaneItem.class,
          ImageViewerPaneItem.class,
          VideoPlayerPaneItem.class,
          AudioPlayerPaneItem.class);
    }

    // view options
    if (OSUtils.isWindows()) {
      addOption(
          OptionsMediator.ROOT_NODE_KEY,
          GUI_KEY,
          I18n.tr("View"),
          PopupsPaneItem.class,
          ShowPromoOverlaysPaneItem.class,
          ShowFrostWireRecommendationsPaneItem.class,
          AutoCompletePaneItem.class);
    } else {
      addOption(
          OptionsMediator.ROOT_NODE_KEY,
          GUI_KEY,
          I18n.tr("View"),
          PopupsPaneItem.class,
          ShowPromoOverlaysPaneItem.class,
          AutoCompletePaneItem.class);
    }

    // community chat
    addOption(
        OptionsMediator.ROOT_NODE_KEY,
        CHAT_KEY,
        I18n.tr("Community Chat"),
        ChatCommunityPaneItem.class);

    // filter options
    addGroupTreeNode(OptionsMediator.ROOT_NODE_KEY, FILTERS_KEY, I18n.tr("Filters"));
    addOption(FILTERS_KEY, RESULTS_KEY, I18n.tr("Keywords"), IgnoreResultsPaneItem.class);

    // advanced options
    addGroupTreeNode(OptionsMediator.ROOT_NODE_KEY, ADVANCED_KEY, I18n.tr("Advanced"));
    addOption(
        ADVANCED_KEY,
        PREFERENCING_KEY,
        I18n.tr("Updates"),
        AutomaticInstallerDownloadPaneItem.class);
    addOption(ADVANCED_KEY, FIREWALL_KEY, I18n.tr("Firewall"), ForceIPPaneItem.class);
    addOption(
        ADVANCED_KEY, PROXY_KEY, I18n.tr("Proxy"), ProxyPaneItem.class, ProxyLoginPaneItem.class);
    addOption(
        ADVANCED_KEY,
        NETWORK_INTERFACE_KEY,
        I18n.tr("Network Interface"),
        NetworkInterfacePaneItem.class);
    if (FrostAssociations.anyAssociationsSupported()) {
      addOption(
          ADVANCED_KEY,
          ASSOCIATIONS_KEY,
          I18n.tr("File Associations"),
          AssociationPreferencePaneItem.class);
    }

    if (GUIUtils.shouldShowStartOnStartupWindow()) {
      addOption(ADVANCED_KEY, STARTUP_KEY, I18n.tr("System Boot"), StartupPaneItem.class);
    }

    addOption(
        OptionsMediator.ROOT_NODE_KEY,
        SHUTDOWN_KEY,
        I18n.tr("System Tray"),
        ShutdownPaneItem.class);

    // debug
    addOption(OptionsMediator.ROOT_NODE_KEY, BUGS_KEY, I18n.tr("Bug Reports"), BugsPaneItem.class);

    return node;
  }
  /**
   * The constructor create all of the options windows and their components.
   *
   * @param treeManager the <tt>OptionsTreeManager</tt> instance to use for constructing the main
   *     panels and adding elements
   * @param paneManager the <tt>OptionsPaneManager</tt> instance to use for constructing the main
   *     panels and adding elements
   */
  public OptionsConstructor(
      final OptionsTreeManager treeManager, final OptionsPaneManager paneManager) {
    TREE_MANAGER = treeManager;
    PANE_MANAGER = paneManager;
    final String title = I18n.tr("Options");
    final boolean shouldBeModal = !OSUtils.isMacOSX();

    DIALOG = new JDialog(GUIMediator.getAppFrame(), title, shouldBeModal);
    DIALOG.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    GUIUtils.addHideAction((JComponent) DIALOG.getContentPane());

    if (UISettings.UI_OPTIONS_DIALOG_HEIGHT.getValue()
        < UISettings.UI_OPTIONS_DIALOG_HEIGHT.getDefaultValue()) {
      UISettings.UI_OPTIONS_DIALOG_HEIGHT.revertToDefault();
    }

    if (UISettings.UI_OPTIONS_DIALOG_WIDTH.getValue()
        < UISettings.UI_OPTIONS_DIALOG_WIDTH.getDefaultValue()) {
      UISettings.UI_OPTIONS_DIALOG_WIDTH.revertToDefault();
    }

    DialogSizeSettingUpdater.install(
        DIALOG, UISettings.UI_OPTIONS_DIALOG_WIDTH, UISettings.UI_OPTIONS_DIALOG_HEIGHT);

    // most Mac users expect changes to be saved when the window
    // is closed, so save them
    DIALOG.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            try {
              DialogOption answer = null;
              if (OptionsMediator.instance().isDirty()) {
                answer =
                    GUIMediator.showYesNoCancelMessage(
                        I18n.tr(
                            "You have made changes to some of FrostWire's settings. Would you like to save these changes?"));
                if (answer == DialogOption.YES) {
                  OptionsMediator.instance().applyOptions();
                  SettingsGroupManager.instance().save();
                }
              }
              if (answer != DialogOption.CANCEL) {
                DIALOG.dispose();
                OptionsMediator.instance().disposeOptions();
              }
            } catch (IOException ioe) {
              // nothing we should do here.  a message should
              // have been displayed to the user with more
              // information
            }
          }
        });

    PaddedPanel mainPanel = new PaddedPanel();

    Box splitBox = new Box(BoxLayout.X_AXIS);

    BoxPanel treePanel = new BoxPanel(BoxLayout.Y_AXIS);

    BoxPanel filterPanel = new BoxPanel(BoxLayout.X_AXIS);
    treePanel.add(filterPanel);

    filterTextField = new SearchField();
    filterTextField.setPrompt(I18n.tr("Search here"));
    filterTextField.setMinimumSize(new Dimension(100, 27));
    filterTextField.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            filter();
          }
        });
    filterPanel.add(filterTextField);

    filterPanel.add(Box.createHorizontalStrut(2));

    treePanel.add(Box.createVerticalStrut(3));

    Component treeComponent = TREE_MANAGER.getComponent();
    treePanel.add(treeComponent);

    Component paneComponent = PANE_MANAGER.getComponent();

    splitBox.add(treePanel);
    splitBox.add(paneComponent);
    mainPanel.add(splitBox);

    mainPanel.add(Box.createVerticalStrut(17));
    mainPanel.add(new OptionsButtonPanel().getComponent());

    DIALOG.getContentPane().add(mainPanel);

    OptionsTreeNode node = initializePanels();
    PANE_MANAGER.show(node);
  }
Exemple #6
0
 /** Constructor. */
 public QRPHolder(double percentFull, int size) {
   _percentFull = (float) percentFull;
   _size = size;
   _string = PERCENT_FORMAT.format(percentFull / 100) + " / " + GUIUtils.toKilobytes(size);
 }