コード例 #1
0
  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());
  }
コード例 #2
0
  /**
   * 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);
  }