Esempio n. 1
0
 public void initForReason(Reason reason) {
   switch (reason) {
     case EXIT:
       putValue(NAME, tr("Perform actions before exiting"));
       putValue(
           SHORT_DESCRIPTION,
           tr("Exit JOSM with saving. Unsaved changes are uploaded and/or saved."));
       putValue(BASE_ICON, ImageProvider.get("exit"));
       break;
     case RESTART:
       putValue(NAME, tr("Perform actions before restarting"));
       putValue(
           SHORT_DESCRIPTION,
           tr("Restart JOSM with saving. Unsaved changes are uploaded and/or saved."));
       putValue(BASE_ICON, ImageProvider.get("restart"));
       break;
     case DELETE:
       putValue(NAME, tr("Perform actions before deleting"));
       putValue(
           SHORT_DESCRIPTION,
           tr("Save/Upload layers before deleting. Unsaved changes are not lost."));
       putValue(BASE_ICON, ImageProvider.get("dialogs", "delete"));
       break;
   }
   redrawIcon();
 }
 protected void renderStatistics(Map<OsmPrimitiveType, Integer> stat) {
   if (stat == null) return;
   if (stat.isEmpty()) return;
   if (stat.size() == 1) {
     setIcon(ImageProvider.get(stat.keySet().iterator().next()));
   } else {
     setIcon(ImageProvider.get("data", "object"));
   }
   String text = "";
   for (OsmPrimitiveType type : stat.keySet()) {
     int numPrimitives = stat.get(type) == null ? 0 : stat.get(type);
     if (numPrimitives == 0) {
       continue;
     }
     String msg = "";
     switch (type) {
       case NODE:
         msg = trn("{0} node", "{0} nodes", numPrimitives, numPrimitives);
         break;
       case WAY:
         msg = trn("{0} way", "{0} ways", numPrimitives, numPrimitives);
         break;
       case RELATION:
         msg = trn("{0} relation", "{0} relations", numPrimitives, numPrimitives);
         break;
     }
     text = text.equals("") ? msg : text + ", " + msg;
   }
   setText(text);
 }
Esempio n. 3
0
  public ScrollViewport(int direction) {
    setLayout(new BorderLayout());

    JButton button;

    // UP
    if ((direction & UP_DIRECTION) > 0) {
      button = new JButton();
      button.addMouseListener(new ScrollViewPortMouseListener(UP_DIRECTION));
      button.setPreferredSize(new Dimension(10, 10));
      button.setIcon(ImageProvider.get("svpUp"));
      add(button, BorderLayout.NORTH);
      buttons.add(button);
    }

    // DOWN
    if ((direction & DOWN_DIRECTION) > 0) {
      button = new JButton();
      button.addMouseListener(new ScrollViewPortMouseListener(DOWN_DIRECTION));
      button.setPreferredSize(new Dimension(10, 10));
      button.setIcon(ImageProvider.get("svpDown"));
      add(button, BorderLayout.SOUTH);
      buttons.add(button);
    }

    // LEFT
    if ((direction & LEFT_DIRECTION) > 0) {
      button = new JButton();
      button.addMouseListener(new ScrollViewPortMouseListener(LEFT_DIRECTION));
      button.setPreferredSize(new Dimension(10, 10));
      button.setIcon(ImageProvider.get("svpLeft"));
      add(button, BorderLayout.WEST);
      buttons.add(button);
    }

    // RIGHT
    if ((direction & RIGHT_DIRECTION) > 0) {
      button = new JButton();
      button.addMouseListener(new ScrollViewPortMouseListener(RIGHT_DIRECTION));
      button.setPreferredSize(new Dimension(10, 10));
      button.setIcon(ImageProvider.get("svpRight"));
      add(button, BorderLayout.EAST);
      buttons.add(button);
    }

    add(vp, BorderLayout.CENTER);

    this.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
            showOrHideButtons();
          }
        });

    showOrHideButtons();

    timer.setRepeats(true);
    timer.setInitialDelay(400);
  }
Esempio n. 4
0
 @Override
 public Icon getDescriptionIcon() {
   if (toDelete.size() == 1) return ImageProvider.get(toDelete.iterator().next().getDisplayType());
   Set<OsmPrimitiveType> typesToDelete = getTypesToDelete();
   if (typesToDelete.size() > 1) return ImageProvider.get("data", "object");
   else return ImageProvider.get(typesToDelete.iterator().next());
 }
Esempio n. 5
0
 public SizeButton(SlippyMapBBoxChooser slippyMapBBoxChooser) {
   this.slippyMapBBoxChooser = slippyMapBBoxChooser;
   enlargeImage = ImageProvider.get("view-fullscreen");
   shrinkImage = ImageProvider.get("view-fullscreen-revert");
   setPreferredSize(new Dimension(enlargeImage.getIconWidth(), enlargeImage.getIconHeight()));
   addMouseListener(mouseListener);
   setToolTipText(tr("Enlarge"));
 }
Esempio n. 6
0
 private JButton createButton(String name) {
   JButton b = new JButton();
   if (name.equals("up")) {
     b.setIcon(ImageProvider.get("dialogs", "up"));
   } else if (name.equals("down")) {
     b.setIcon(ImageProvider.get("dialogs", "down"));
   } else {
     b.setText(name);
   }
   b.addActionListener(moveAction);
   b.setActionCommand(name);
   return b;
 }
Esempio n. 7
0
 public DeleteAction() {
   putValue(NAME, tr("Remove"));
   putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
   putValue(SHORT_DESCRIPTION, tr("Remove the currently selected vias"));
   putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
   updateEnabledState();
 }
 public ActivateStylesAction() {
   putValue(NAME, tr("Activate"));
   putValue(
       SHORT_DESCRIPTION, tr("Add the selected available styles to the list of active styles"));
   putValue(SMALL_ICON, ImageProvider.get("preferences", "activatestyle"));
   updateEnabledState();
 }
Esempio n. 9
0
 public MoveUpAction() {
   putValue(NAME, tr("Move up"));
   putValue(SHORT_DESCRIPTION, tr("Move the selected vias up by one position"));
   putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK));
   putValue(SMALL_ICON, ImageProvider.get("dialogs", "moveup"));
   updateEnabledState();
 }
Esempio n. 10
0
  @Override
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    Object nodeInfo = node.getUserObject();

    if (nodeInfo instanceof Severity) {
      Severity s = (Severity) nodeInfo;
      setIcon(ImageProvider.get("data", s.getIcon()));
    } else if (nodeInfo instanceof TestError) {
      TestError error = (TestError) nodeInfo;
      MultipleNameVisitor v = new MultipleNameVisitor();
      v.visit(error.getPrimitives());
      setText(v.getText());
      setIcon(v.getIcon());
    }
    return this;
  }
Esempio n. 11
0
 public CopyAction() {
   putValue(NAME, tr("Copy"));
   putValue(SHORT_DESCRIPTION, tr("Copy the selected vias to the clipboard"));
   putValue(SMALL_ICON, ImageProvider.get("copy"));
   putValue(ACCELERATOR_KEY, Shortcut.getCopyKeyStroke());
   delegate = ViaList.this.getActionMap().get("copy");
 }
Esempio n. 12
0
 public BackAction(HelpBrowserHistory history) {
   this.history = history;
   history.addObserver(this);
   // putValue(NAME, tr("Back"));
   putValue(SHORT_DESCRIPTION, tr("Go to the previous page"));
   putValue(SMALL_ICON, ImageProvider.get("help", "previous"));
   setEnabled(history.canGoBack());
 }
Esempio n. 13
0
 public ForwardAction(HelpBrowserHistory history) {
   this.history = history;
   history.addObserver(this);
   // putValue(NAME, tr("Forward"));
   putValue(SHORT_DESCRIPTION, tr("Go to the next page"));
   putValue(SMALL_ICON, ImageProvider.get("help", "next"));
   setEnabled(history.canGoForward());
 }
Esempio n. 14
0
 /**
  * Internal method that stuffs information into the rendering component provided that it's a kind
  * of JLabel.
  *
  * @param def the rendering component
  * @param value the HistoryOsmPrimtive to render
  * @return the modified rendering component
  */
 private Component renderer(Component def, HistoryOsmPrimitive value) {
   if (value != null && def instanceof JLabel) {
     ((JLabel) def).setText(value.getDisplayName(DefaultNameFormatter.getInstance()));
     ((JLabel) def).setIcon(ImageProvider.get(value.getType()));
     ((JLabel) def).setToolTipText(formatter.buildDefaultToolTip(value));
   }
   return def;
 }
Esempio n. 15
0
 public PasteAction() {
   putValue(NAME, tr("Paste"));
   putValue(SHORT_DESCRIPTION, tr("Insert ''via'' objects from the clipboard"));
   putValue(SMALL_ICON, ImageProvider.get("paste"));
   putValue(ACCELERATOR_KEY, Shortcut.getPasteKeyStroke());
   delegate = ViaList.this.getActionMap().get("paste");
   updateEnabledState();
 }
Esempio n. 16
0
 protected CopyAction(String icon_name, String action_name, String short_description) {
   ImageIcon icon = ImageProvider.get("dialogs/conflict", icon_name + ".png");
   putValue(Action.SMALL_ICON, icon);
   if (icon == null) {
     putValue(Action.NAME, action_name);
   }
   putValue(Action.SHORT_DESCRIPTION, short_description);
   setEnabled(false);
 }
Esempio n. 17
0
 public MoveDownMergedAction() {
   ImageIcon icon = ImageProvider.get("dialogs/conflict", "movedown.png");
   putValue(Action.SMALL_ICON, icon);
   if (icon == null) {
     putValue(Action.NAME, tr("Down"));
   }
   putValue(Action.SHORT_DESCRIPTION, tr("Move down the selected entries by one position."));
   setEnabled(false);
 }
Esempio n. 18
0
 /**
  * Internal method that stuffs information into the rendering component provided that it's a kind
  * of JLabel.
  *
  * @param def the rendering component
  * @param value the OsmPrimitive to render
  * @param fast whether the icons should be loaded fast since many items are being displayed
  * @return the modified rendering component
  */
 private Component renderer(Component def, OsmPrimitive value, boolean fast) {
   if (value != null && def instanceof JLabel) {
     ((JLabel) def).setText(getComponentText(value));
     final ImageIcon icon =
         fast
             ? ImageProvider.get(value.getType())
             : ImageProvider.getPadded(
                 value,
                 // Height of component no yet known, assume the default 16px.
                 ImageProvider.ImageSizes.SMALLICON.getImageDimension());
     if (icon != null) {
       ((JLabel) def).setIcon(icon);
     } else {
       Main.warn("Null icon for " + value.getDisplayType());
     }
     ((JLabel) def).setToolTipText(getComponentToolTipText(value));
   }
   return def;
 }
Esempio n. 19
0
 /**
  * Construct a new DeleteAction. Mnemonic is the delete - key.
  *
  * @param mapFrame The frame this action belongs to.
  */
 public DeleteAction(MapFrame mapFrame) {
   super(
       tr("Delete Mode"),
       "delete",
       tr("Delete nodes or ways."),
       Shortcut.registerShortcut(
           "mapmode:delete", tr("Mode: {0}", tr("Delete")), KeyEvent.VK_DELETE, Shortcut.CTRL),
       mapFrame,
       ImageProvider.getCursor("normal", "delete"));
 }
Esempio n. 20
0
  @Override
  protected void finish() {

    // depending on the success of the upload operation and on the policy for
    // multi changeset uploads this will sent the user back to the appropriate
    // place in JOSM, either
    // - to an error dialog
    // - to the Upload Dialog
    // - to map editing
    GuiHelper.runInEDT(
        () -> {
          // if the changeset is still open after this upload we want it to be selected on the next
          // upload
          ChangesetCache.getInstance().update(changeset);
          if (changeset != null && changeset.isOpen()) {
            UploadDialog.getUploadDialog().setSelectedChangesetForNextUpload(changeset);
          }
          if (uploadCanceled) return;
          if (lastException == null) {
            new Notification("<h3>" + tr("Upload successful!") + "</h3>")
                .setIcon(ImageProvider.get("misc", "check_large"))
                .show();
            return;
          }
          if (lastException instanceof ChangesetClosedException) {
            ChangesetClosedException e = (ChangesetClosedException) lastException;
            if (e.getSource().equals(ChangesetClosedException.Source.UPDATE_CHANGESET)) {
              handleFailedUpload(lastException);
              return;
            }
            if (strategy.getPolicy() == null)
              /* do nothing if unknown policy */
              return;
            if (e.getSource().equals(ChangesetClosedException.Source.UPLOAD_DATA)) {
              switch (strategy.getPolicy()) {
                case ABORT:
                  break; /* do nothing - we return to map editing */
                case AUTOMATICALLY_OPEN_NEW_CHANGESETS:
                  break; /* do nothing - we return to map editing */
                case FILL_ONE_CHANGESET_AND_RETURN_TO_UPLOAD_DIALOG:
                  // return to the upload dialog
                  //
                  toUpload.removeProcessed(processedPrimitives);
                  UploadDialog.getUploadDialog().setUploadedPrimitives(toUpload);
                  UploadDialog.getUploadDialog().setVisible(true);
                  break;
              }
            } else {
              handleFailedUpload(lastException);
            }
          } else {
            handleFailedUpload(lastException);
          }
        });
  }
 /**
  * Constructs a new {@code AddSelectedAtStartAction}.
  *
  * @param memberTableModel member table model
  * @param selectionTableModel selection table model
  * @param editor relation editor
  */
 public AddSelectedAtStartAction(
     MemberTableModel memberTableModel,
     SelectionTableModel selectionTableModel,
     IRelationEditor editor) {
   super(null, memberTableModel, null, selectionTableModel, null, null, editor);
   putValue(
       SHORT_DESCRIPTION,
       tr("Add all objects selected in the current dataset before the first member"));
   putValue(SMALL_ICON, ImageProvider.get("dialogs/conflict", "copystartright"));
   updateEnabledState();
 }
Esempio n. 22
0
 public RemoveMergedAction() {
   ImageIcon icon = ImageProvider.get("dialogs/conflict", "remove.png");
   putValue(Action.SMALL_ICON, icon);
   if (icon == null) {
     putValue(Action.NAME, tr("Remove"));
   }
   putValue(
       Action.SHORT_DESCRIPTION,
       tr("Remove the selected entries from the list of merged elements."));
   setEnabled(false);
 }
Esempio n. 23
0
 public void initForReason(Reason reason) {
   switch (reason) {
     case EXIT:
       putValue(NAME, tr("Exit now!"));
       putValue(SHORT_DESCRIPTION, tr("Exit JOSM without saving. Unsaved changes are lost."));
       putValue(SMALL_ICON, ImageProvider.get("exit"));
       break;
     case RESTART:
       putValue(NAME, tr("Restart now!"));
       putValue(SHORT_DESCRIPTION, tr("Restart JOSM without saving. Unsaved changes are lost."));
       putValue(SMALL_ICON, ImageProvider.get("restart"));
       break;
     case DELETE:
       putValue(NAME, tr("Delete now!"));
       putValue(
           SHORT_DESCRIPTION, tr("Delete layers without saving. Unsaved changes are lost."));
       putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
       break;
   }
 }
Esempio n. 24
0
 /**
  * Internal method that stuffs information into the rendering component provided that it's a kind
  * of JLabel.
  *
  * @param def the rendering component
  * @param value the OsmPrimtive to render
  * @return the modified rendering component
  */
 private Component renderer(Component def, OsmPrimitive value) {
   if (value != null && def instanceof JLabel) {
     ((JLabel) def).setText(getComponentText(value));
     ImageIcon icon = ImageProvider.get(value.getDisplayType());
     if (icon != null) {
       ((JLabel) def).setIcon(icon);
     } else {
       Main.warn("Null icon for " + value.getDisplayType());
     }
     ((JLabel) def).setToolTipText(getComponentToolTipText(value));
   }
   return def;
 }
 /**
  * Constructs a new {@code RecentRelationsPopupMenu}.
  *
  * @param recentRelations list of recent relations
  * @param keystroke key stroke for the first menu item
  */
 public RecentRelationsPopupMenu(List<Relation> recentRelations, KeyStroke keystroke) {
   boolean first = true;
   for (Relation relation : recentRelations) {
     if (!isRelationListable(relation)) continue;
     JMenuItem menuItem = new RecentRelationsMenuItem(relation);
     if (first) {
       menuItem.setAccelerator(keystroke);
       first = false;
     }
     menuItem.setIcon(
         ImageProvider.getPadded(relation, ImageProvider.ImageSizes.MENU.getImageDimension()));
     add(menuItem);
   }
 }
 public ImageryAdjustMapMode(MapFrame mapFrame) {
   super(
       tr("Adjust imagery"),
       "adjustimg",
       tr("Adjust the position of the selected imagery layer"),
       Shortcut.registerShortcut(
           "imageryadjust:adjustmode",
           tr("Mode: {0}", tr("Adjust imagery")),
           KeyEvent.VK_Y,
           Shortcut.ALT_CTRL),
       mapFrame,
       ImageProvider.getCursor("normal", "move"));
   MapFrame.addMapModeChangeListener(this);
 }
Esempio n. 27
0
  public void removeCurrentPhotoFromDisk() {
    ImageEntry toDelete;
    if (data != null && !data.isEmpty() && currentPhoto >= 0 && currentPhoto < data.size()) {
      toDelete = data.get(currentPhoto);

      int result =
          new ExtendedDialog(
                  Main.parent,
                  tr("Delete image file from disk"),
                  new String[] {tr("Cancel"), tr("Delete")})
              .setButtonIcons(new String[] {"cancel", "dialogs/delete"})
              .setContent(
                  new JLabel(
                      tr(
                          "<html><h3>Delete the file {0} from disk?<p>The image file will be permanently lost!</h3></html>",
                          toDelete.getFile().getName()),
                      ImageProvider.get("dialogs/geoimage/deletefromdisk"),
                      SwingConstants.LEFT))
              .toggleEnable("geoimage.deleteimagefromdisk")
              .setCancelButton(1)
              .setDefaultButton(2)
              .showDialog()
              .getValue();

      if (result == 2) {
        data.remove(currentPhoto);
        if (currentPhoto >= data.size()) {
          currentPhoto = data.size() - 1;
        }
        if (currentPhoto >= 0) {
          ImageViewerDialog.showImage(this, data.get(currentPhoto));
        } else {
          ImageViewerDialog.showImage(this, null);
        }

        if (Utils.deleteFile(toDelete.getFile())) {
          Main.info("File " + toDelete.getFile() + " deleted. ");
        } else {
          JOptionPane.showMessageDialog(
              Main.parent,
              tr("Image file could not be deleted."),
              tr("Error"),
              JOptionPane.ERROR_MESSAGE);
        }

        updateOffscreenBuffer = true;
        Main.map.repaint();
      }
    }
  }
 private void renderStatistics(Map<OsmPrimitiveType, Integer> stat) {
   if (stat == null) return;
   if (stat.isEmpty()) return;
   if (stat.size() == 1) {
     setIcon(ImageProvider.get(stat.keySet().iterator().next()));
   } else {
     setIcon(ImageProvider.get("data", "object"));
   }
   StringBuilder text = new StringBuilder();
   for (Entry<OsmPrimitiveType, Integer> entry : stat.entrySet()) {
     OsmPrimitiveType type = entry.getKey();
     int numPrimitives = entry.getValue() == null ? 0 : entry.getValue();
     if (numPrimitives == 0) {
       continue;
     }
     String msg;
     switch (type) {
       case NODE:
         msg = trn("{0} node", "{0} nodes", numPrimitives, numPrimitives);
         break;
       case WAY:
         msg = trn("{0} way", "{0} ways", numPrimitives, numPrimitives);
         break;
       case RELATION:
         msg = trn("{0} relation", "{0} relations", numPrimitives, numPrimitives);
         break;
       default:
         throw new AssertionError();
     }
     if (text.length() > 0) {
       text.append(", ");
     }
     text.append(msg);
   }
   setText(text.toString());
 }
Esempio n. 29
0
 /**
  * Constructs a new {@code RemoveAction}.
  *
  * @param memberTable member table
  * @param memberTableModel member table model
  * @param actionMapKey action map key
  */
 public RemoveAction(
     MemberTable memberTable, MemberTableModel memberTableModel, String actionMapKey) {
   super(memberTable, memberTableModel, actionMapKey);
   putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));
   putValue(NAME, tr("Remove"));
   Shortcut sc =
       Shortcut.registerShortcut(
           "relationeditor:remove",
           tr("Relation Editor: Remove"),
           KeyEvent.VK_DELETE,
           Shortcut.ALT);
   sc.setAccelerator(this);
   putValue(
       SHORT_DESCRIPTION,
       Main.platform.makeTooltip(
           tr("Remove the currently selected members from this relation"), sc));
   setEnabled(false);
 }
Esempio n. 30
0
  /**
   * Builds the panel with general information in the header
   *
   * @return panel woth information display
   */
  protected JPanel buildHeaderInfoPanel() {
    JPanel pnl = new JPanel(new GridBagLayout());
    pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    GridBagConstraints gc = new GridBagConstraints();

    // the oauth logo in the header
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1.0;
    gc.gridwidth = 2;
    JLabel lbl = new JLabel();
    lbl.setIcon(ImageProvider.get("oauth", "oauth-logo"));
    lbl.setOpaque(true);
    pnl.add(lbl, gc);

    // OAuth in a nutshell ...
    gc.gridy = 1;
    gc.insets = new Insets(5, 0, 0, 5);
    HtmlPanel pnlMessage = new HtmlPanel();
    pnlMessage.setText(
        "<html><body>"
            + tr(
                "With OAuth you grant JOSM the right to upload map data and GPS tracks "
                    + "on your behalf (<a href=\"{0}\">more info...</a>).",
                "http://oauth.net/")
            + "</body></html>");
    pnlMessage.getEditorPane().addHyperlinkListener(new ExternalBrowserLauncher());
    pnl.add(pnlMessage, gc);

    // the authorisation procedure
    gc.gridy = 2;
    gc.gridwidth = 1;
    gc.weightx = 0.0;
    lbl = new JLabel(tr("Please select an authorization procedure: "));
    lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
    pnl.add(lbl, gc);

    gc.gridx = 1;
    gc.gridwidth = 1;
    gc.weightx = 1.0;
    pnl.add(cbAuthorisationProcedure = new AuthorizationProcedureComboBox(), gc);
    cbAuthorisationProcedure.addItemListener(new AuthorisationProcedureChangeListener());
    return pnl;
  }