Exemplo n.º 1
0
  @Override
  public boolean ok() {
    layerInfo.save();
    ImageryLayerInfo.instance.clear();
    ImageryLayerInfo.instance.load(false);
    Main.main.menu.imageryMenu.refreshOffsetMenu();
    OffsetBookmark.saveBookmarks();

    if (!GraphicsEnvironment.isHeadless()) {
      DownloadDialog.getInstance().refreshTileSources();
    }

    boolean commonRestartRequired = commonSettings.saveSettings();
    boolean wmsRestartRequired = wmsSettings.saveSettings();
    boolean tmsRestartRequired = tmsSettings.saveSettings();

    return commonRestartRequired || wmsRestartRequired || tmsRestartRequired;
  }
Exemplo n.º 2
0
    /**
     * Constructs a new {@code ImageryProvidersPanel}.
     *
     * @param gui The parent preference tab pane
     * @param layerInfoArg The list of imagery entries to display
     */
    public ImageryProvidersPanel(final PreferenceTabbedPane gui, ImageryLayerInfo layerInfoArg) {
      super(new GridBagLayout());
      this.gui = gui;
      this.layerInfo = layerInfoArg;
      this.activeModel = new ImageryLayerTableModel();

      activeTable =
          new JTable(activeModel) {
            @Override
            public String getToolTipText(MouseEvent e) {
              java.awt.Point p = e.getPoint();
              return activeModel.getValueAt(rowAtPoint(p), columnAtPoint(p)).toString();
            }
          };
      activeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

      defaultModel = new ImageryDefaultLayerTableModel();
      defaultTable = new JTable(defaultModel);

      defaultModel.addTableModelListener(e -> activeTable.repaint());
      activeModel.addTableModelListener(e -> defaultTable.repaint());

      TableColumnModel mod = defaultTable.getColumnModel();
      mod.getColumn(2).setPreferredWidth(800);
      mod.getColumn(2).setCellRenderer(new ImageryURLTableCellRenderer(layerInfo.getLayers()));
      mod.getColumn(1).setPreferredWidth(400);
      mod.getColumn(1).setCellRenderer(new ImageryNameTableCellRenderer());
      mod.getColumn(0).setPreferredWidth(50);

      mod = activeTable.getColumnModel();
      mod.getColumn(1).setPreferredWidth(800);
      mod.getColumn(1)
          .setCellRenderer(new ImageryURLTableCellRenderer(layerInfo.getDefaultLayers()));
      mod.getColumn(0).setPreferredWidth(200);

      RemoveEntryAction remove = new RemoveEntryAction();
      activeTable.getSelectionModel().addListSelectionListener(remove);

      add(new JLabel(tr("Available default entries:")), GBC.eol().insets(5, 5, 0, 0));
      // Add default item list
      JScrollPane scrolldef = new JScrollPane(defaultTable);
      scrolldef.setPreferredSize(new Dimension(200, 200));
      add(
          scrolldef,
          GBC.std()
              .insets(0, 5, 0, 0)
              .fill(GridBagConstraints.BOTH)
              .weight(1.0, 0.6)
              .insets(5, 0, 0, 0));

      // Add default item map
      defaultMap = new JMapViewer();
      defaultMap.setTileSource(new OsmTileSource.Mapnik()); // for attribution
      defaultMap.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              if (e.getButton() == MouseEvent.BUTTON1) {
                defaultMap.getAttribution().handleAttribution(e.getPoint(), true);
              }
            }
          });
      defaultMap.setZoomContolsVisible(false);
      defaultMap.setMinimumSize(new Dimension(100, 200));
      add(
          defaultMap,
          GBC.std()
              .insets(5, 5, 0, 0)
              .fill(GridBagConstraints.BOTH)
              .weight(0.33, 0.6)
              .insets(5, 0, 0, 0));

      defaultTableListener = new DefListSelectionListener();
      defaultTable.getSelectionModel().addListSelectionListener(defaultTableListener);

      defaultToolbar = new JToolBar(JToolBar.VERTICAL);
      defaultToolbar.setFloatable(false);
      defaultToolbar.setBorderPainted(false);
      defaultToolbar.setOpaque(false);
      defaultToolbar.add(new ReloadAction());
      add(defaultToolbar, GBC.eol().anchor(GBC.SOUTH).insets(0, 0, 5, 0));

      ActivateAction activate = new ActivateAction();
      defaultTable.getSelectionModel().addListSelectionListener(activate);
      JButton btnActivate = new JButton(activate);

      middleToolbar = new JToolBar(JToolBar.HORIZONTAL);
      middleToolbar.setFloatable(false);
      middleToolbar.setBorderPainted(false);
      middleToolbar.setOpaque(false);
      middleToolbar.add(btnActivate);
      add(middleToolbar, GBC.eol().anchor(GBC.CENTER).insets(5, 15, 5, 0));

      add(Box.createHorizontalGlue(), GBC.eol().fill(GridBagConstraints.HORIZONTAL));

      add(new JLabel(tr("Selected entries:")), GBC.eol().insets(5, 0, 0, 0));
      JScrollPane scroll = new JScrollPane(activeTable);
      add(
          scroll,
          GBC.std()
              .fill(GridBagConstraints.BOTH)
              .span(GridBagConstraints.RELATIVE)
              .weight(1.0, 0.4)
              .insets(5, 0, 0, 5));
      scroll.setPreferredSize(new Dimension(200, 200));

      activeToolbar = new JToolBar(JToolBar.VERTICAL);
      activeToolbar.setFloatable(false);
      activeToolbar.setBorderPainted(false);
      activeToolbar.setOpaque(false);
      activeToolbar.add(new NewEntryAction(ImageryInfo.ImageryType.WMS));
      activeToolbar.add(new NewEntryAction(ImageryInfo.ImageryType.TMS));
      activeToolbar.add(new NewEntryAction(ImageryInfo.ImageryType.WMTS));
      // activeToolbar.add(edit); TODO
      activeToolbar.add(remove);
      add(activeToolbar, GBC.eol().anchor(GBC.NORTH).insets(0, 0, 5, 5));
    }