private void prepareTileStoreInfoPanel() {

    final GridBagConstraints gbc_mapSource = new GridBagConstraints();
    gbc_mapSource.insets = new Insets(5, 10, 5, 10);
    gbc_mapSource.anchor = GridBagConstraints.WEST;
    final GridBagConstraints gbc_mapTiles = new GridBagConstraints();
    gbc_mapTiles.insets = gbc_mapSource.insets;
    gbc_mapTiles.anchor = GridBagConstraints.EAST;
    final GridBagConstraints gbc_eol = new GridBagConstraints();
    gbc_eol.gridwidth = GridBagConstraints.REMAINDER;

    TileStore tileStore = TileStore.getInstance();
    MapSourcesManager mapSourcesManager = MapSourcesManager.getInstance();

    tileStoreInfoPanel.add(new JLabel("<html><b>Map source</b></html>"), gbc_mapSource);
    tileStoreInfoPanel.add(new JLabel("<html><b>Tiles</b></html>"), gbc_mapTiles);
    tileStoreInfoPanel.add(new JLabel("<html><b>Size</b></html>"), gbc_eol);

    ImageIcon trash = Utilities.loadResourceImageIcon("trash.png");

    for (String name : tileStore.getAllStoreNames()) {
      String mapTileCountText = "  ?  ";
      String mapTileSizeText = "    ?    ";
      MapSource mapSource = mapSourcesManager.getSourceByName(name);
      final JLabel mapSourceNameLabel;
      if (mapSource != null) mapSourceNameLabel = new JLabel(name);
      else mapSourceNameLabel = new JLabel(name + " (unused)");
      final JLabel mapTileCountLabel = new JLabel(mapTileCountText);
      final JLabel mapTileSizeLabel = new JLabel(mapTileSizeText);
      final JButton deleteButton = new JButton(trash);
      TileSourceInfoComponents info = new TileSourceInfoComponents();
      info.name = name;
      info.countLabel = mapTileCountLabel;
      info.sizeLabel = mapTileSizeLabel;
      tileStoreInfoList.add(info);
      deleteButton.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
      deleteButton.setToolTipText("Delete all stored " + name + " tiles.");
      deleteButton.addActionListener(new ClearTileCacheAction(name));

      tileStoreInfoPanel.add(mapSourceNameLabel, gbc_mapSource);
      tileStoreInfoPanel.add(mapTileCountLabel, gbc_mapTiles);
      tileStoreInfoPanel.add(mapTileSizeLabel, gbc_mapTiles);
      tileStoreInfoPanel.add(deleteButton, gbc_eol);
    }
    JSeparator hr = new JSeparator(JSeparator.HORIZONTAL);
    hr.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    tileStoreInfoPanel.add(hr, gbc);

    JLabel totalMapLabel = new JLabel("<html><b>Total</b></html>");
    totalTileCountLabel = new JLabel("<html><b>??</b></html>");
    totalTileSizeLabel = new JLabel("<html><b>??</b></html>");
    tileStoreInfoPanel.add(totalMapLabel, gbc_mapSource);
    tileStoreInfoPanel.add(totalTileCountLabel, gbc_mapTiles);
    tileStoreInfoPanel.add(totalTileSizeLabel, gbc_mapTiles);
  }
Beispiel #2
0
  public JProfilesPanel(JAtlasTree atlasTree) {
    super(I18nUtils.localizedStringForKey("lp_atlas_profile_title"), new GridBagLayout());

    if (atlasTree == null) throw new NullPointerException();

    // profiles combo box
    profilesCombo = new JProfilesComboBox();
    profilesCombo.setToolTipText(I18nUtils.localizedStringForKey("lp_atlas_profile_combo_tips"));
    profilesCombo.addActionListener(new ProfileListListener());

    // delete profile button
    deleteButton =
        new JButton(I18nUtils.localizedStringForKey("lp_atlas_profile_delete_btn_title"));
    deleteButton.addActionListener(new DeleteProfileListener());
    deleteButton.setToolTipText(
        I18nUtils.localizedStringForKey("lp_atlas_profile_delete_btn_tips"));

    // save as profile button
    saveAsButton = new JButton(I18nUtils.localizedStringForKey("lp_atlas_profile_save_btn_title"));
    saveAsButton.setToolTipText(I18nUtils.localizedStringForKey("lp_atlas_profile_save_btn_tips"));
    saveAsButton.addActionListener(new SaveAsProfileListener(atlasTree));

    loadButton = new JButton(I18nUtils.localizedStringForKey("lp_atlas_profile_load_btn_title"));
    loadButton.setToolTipText(I18nUtils.localizedStringForKey("lp_atlas_profile_load_btn_tips"));

    GBC gbc = GBC.eol().fill().insets(5, 5, 5, 5);
    reloadButton = new JButton(Utilities.loadResourceImageIcon("refresh.png"));
    reloadButton.setToolTipText(
        I18nUtils.localizedStringForKey("lp_atlas_profile_refresh_btn_tips"));
    reloadButton.addActionListener(new ReloadListener());
    reloadButton.setPreferredSize(new Dimension(24, 0));

    JPanel p = new JPanel(new BorderLayout());
    p.add(profilesCombo, BorderLayout.CENTER);
    p.add(reloadButton, BorderLayout.EAST);

    contentContainer.add(p, gbc);
    contentContainer.add(deleteButton, gbc.toggleEol());
    contentContainer.add(saveAsButton, gbc);
    contentContainer.add(loadButton, gbc.toggleEol());

    saveAsButton.setEnabled(false);
    deleteButton.setEnabled(false);
    loadButton.setEnabled(false);
  }