Esempio n. 1
0
 @Override
 public Component getExportPanel() {
   final JPanel p = new JPanel(new GridBagLayout());
   export = new JCheckBox();
   export.setSelected(true);
   final JLabel lbl = new JLabel(layer.getName(), layer.getIcon(), SwingConstants.LEFT);
   lbl.setToolTipText(layer.getToolTipText());
   p.add(export, GBC.std());
   p.add(lbl, GBC.std());
   p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
   return p;
 }
Esempio n. 2
0
  @Override
  public JPanel getExportPanel() {
    final JPanel p = new JPanel(new GridBagLayout());
    JPanel topRow = new JPanel(new GridBagLayout());
    export = new JCheckBox();
    export.setSelected(true);
    final JLabel lbl = new JLabel(layer.getName(), layer.getIcon(), SwingConstants.LEFT);
    lbl.setToolTipText(layer.getToolTipText());

    JLabel lblData = new JLabel(tr("Data:"));
    /* I18n: Refer to a OSM data file in session file */ link = new JRadioButton(tr("local file"));
    link.putClientProperty("actionname", "link");
    link.setToolTipText(tr("Link to a OSM data file on your local disk."));
    /* I18n: Include OSM data in session file */ include = new JRadioButton(tr("include"));
    include.setToolTipText(tr("Include OSM data in the .joz session file."));
    include.putClientProperty("actionname", "include");
    ButtonGroup group = new ButtonGroup();
    group.add(link);
    group.add(include);

    JPanel cardLink = new JPanel(new GridBagLayout());
    final File file = layer.getAssociatedFile();
    final LayerSaveAction saveAction = new LayerSaveAction();
    final JButton save = new JButton(saveAction);
    if (file != null) {
      JosmTextField tf = new JosmTextField();
      tf.setText(file.getPath());
      tf.setEditable(false);
      cardLink.add(tf, GBC.std());
      save.setMargin(new Insets(0, 0, 0, 0));
      cardLink.add(save, GBC.eol().insets(2, 0, 0, 0));
    } else {
      cardLink.add(new JLabel(tr("No file association")), GBC.eol());
    }

    JPanel cardInclude = new JPanel(new GridBagLayout());
    JLabel lblIncl = new JLabel(tr("OSM data will be included in the session file."));
    lblIncl.setFont(lblIncl.getFont().deriveFont(Font.PLAIN));
    cardInclude.add(lblIncl, GBC.eol().fill(GBC.HORIZONTAL));

    final CardLayout cl = new CardLayout();
    final JPanel cards = new JPanel(cl);
    cards.add(cardLink, "link");
    cards.add(cardInclude, "include");

    if (file != null) {
      link.setSelected(true);
    } else {
      link.setEnabled(false);
      link.setToolTipText(tr("No file association"));
      include.setSelected(true);
      cl.show(cards, "include");
    }

    link.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cl.show(cards, "link");
          }
        });
    include.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cl.show(cards, "include");
          }
        });

    topRow.add(export, GBC.std());
    topRow.add(lbl, GBC.std());
    topRow.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
    p.add(topRow, GBC.eol().fill(GBC.HORIZONTAL));
    p.add(lblData, GBC.std().insets(10, 0, 0, 0));
    p.add(link, GBC.std());
    p.add(include, GBC.eol());
    p.add(cards, GBC.eol().insets(15, 0, 3, 3));

    export.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.DESELECTED) {
              GuiHelper.setEnabledRec(p, false);
              export.setEnabled(true);
            } else {
              GuiHelper.setEnabledRec(p, true);
              save.setEnabled(saveAction.isEnabled());
              link.setEnabled(file != null);
            }
          }
        });
    return p;
  }