Changeset 34684 in osm for applications


Ignore:
Timestamp:
2018-10-20T18:05:17+02:00 (6 years ago)
Author:
holgermappt
Message:

Moved button settings into AbstractAction constructor. See #16842.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoPropertyEditor.java

    r34683 r34684  
    191191                        GBC.std().insets(0, 0, 5, 0));
    192192            content.add(coords, GBC.std().fill(GBC.HORIZONTAL));
    193             Action editCoordAction = new AbstractAction(tr("Edit")) {
    194                 @Override public void actionPerformed(ActionEvent evt) {
    195                     final LatLonDialog llDialog
    196                         = new LatLonDialog(MainApplication.getMainFrame(),
    197                                            tr("Edit Image Coordinates"), null);
    198                     llDialog.setCoordinates(getLatLon());
    199                     llDialog.showDialog();
    200                     if (llDialog.getValue() == 1) {
    201                         final LatLon coordinates = llDialog.getCoordinates();
    202                         if (coordinates != null) {
    203                             coords.setText(posToText(coordinates));
    204                         }
    205                     }
    206                 }
    207             };
    208             final JButton editCoordBtn = new JButton(editCoordAction);
    209             editCoordBtn
    210                 .setToolTipText(tr("Edit coordinates in separate editor"));
     193
     194            final JButton editCoordBtn = new JButton(new EditCoordAction());
    211195            content.add(editCoordBtn, GBC.eol());
    212196
     
    264248
    265249            // Undo.
    266             Action undoAction = new AbstractAction(tr("Undo")) {
    267                 @Override public void actionPerformed(ActionEvent evt) {
    268                     setInitialValues();
    269                 }
    270             };
    271             final JButton undoButton = new JButton(undoAction);
    272             undoButton.setToolTipText(tr("Undo changes made in this dialog"));
    273             undoButton.setIcon(ImageProvider.get("undo"));
     250            final JButton undoButton = new JButton(new UndoAction());
    274251            buttonsPanel.add(undoButton, GBC.std().insets(2, 2, 2, 2));
    275252
    276253            // Reload.
    277             Action reloadAction = new AbstractAction(tr("Reload")) {
    278                 @Override public void actionPerformed(ActionEvent evt) {
    279                     final ImageEntry imgTmp = new ImageEntry(image.getFile());
    280                     imgTmp.extractExif();
    281                     setInitialValues(imgTmp);
    282                 }
    283             };
    284             final JButton reloadButton = new JButton(reloadAction);
    285             reloadButton.setToolTipText(tr("Reload GPS data from image file"));
    286             reloadButton.setIcon(ImageProvider.get("dialogs/refresh"));
     254            final JButton reloadButton = new JButton(new ReloadAction());
    287255            buttonsPanel.add(reloadButton, GBC.std().insets(2, 2, 2, 2));
    288256
    289257            // // Apply.
    290             // Action applyAction = new AbstractAction(tr("Apply")) {
    291             //     @Override public void actionPerformed(ActionEvent evt) {
    292             //         updateImageTmp();
    293             //         updateLayer(layer, image);
    294             //     }
    295             // };
    296             // final JButton applyButton = new JButton(applyAction);
    297             // applyButton.setToolTipText(tr("Apply changes, keep dialog open"));
    298             // applyButton.setIcon(ImageProvider.get("apply"));
     258            // final JButton applyButton = new JButton(new ApplyAction());
    299259            // // fill(VERTICAL) to make the button the same height than the
    300260            // // other buttons.  This is needed because the apply icon is
     
    692652            }
    693653        }
     654
     655        class EditCoordAction extends AbstractAction {
     656            EditCoordAction() {
     657                super(tr("Edit"));
     658                putValue(SHORT_DESCRIPTION,
     659                         tr("Edit coordinates in separate editor"));
     660            }
     661
     662            @Override public void actionPerformed(ActionEvent evt) {
     663                final LatLonDialog llDialog
     664                    = new LatLonDialog(MainApplication.getMainFrame(),
     665                                       tr("Edit Image Coordinates"), null);
     666                llDialog.setCoordinates(getLatLon());
     667                llDialog.showDialog();
     668                if (llDialog.getValue() == 1) {
     669                    final LatLon coordinates = llDialog.getCoordinates();
     670                    if (coordinates != null) {
     671                        coords.setText(posToText(coordinates));
     672                    }
     673                }
     674            }
     675        }
     676
     677        class UndoAction extends AbstractAction {
     678            UndoAction() {
     679                super(tr("Undo"));
     680                new ImageProvider("undo").getResource().attachImageIcon(this);
     681                putValue(SHORT_DESCRIPTION,
     682                         tr("Undo changes made in this dialog"));
     683            }
     684
     685            @Override public void actionPerformed(ActionEvent evt) {
     686                setInitialValues();
     687            }
     688        }
     689
     690        class ReloadAction extends AbstractAction {
     691            ReloadAction() {
     692                super(tr("Reload"));
     693                new ImageProvider("dialogs", "refresh").getResource().
     694                    attachImageIcon(this);
     695                putValue(SHORT_DESCRIPTION,
     696                         tr("Reload GPS data from image file"));
     697            }
     698
     699            @Override public void actionPerformed(ActionEvent evt) {
     700                final ImageEntry imgTmp = new ImageEntry(image.getFile());
     701                imgTmp.extractExif();
     702                setInitialValues(imgTmp);
     703            }
     704        }
     705
     706        // class ApplyAction extends AbstractAction {
     707        //     ApplyAction() {
     708        //         super(tr("Apply"));
     709        //         new ImageProvider("apply").getResource().
     710        //             attachImageIcon(this);
     711        //         putValue(SHORT_DESCRIPTION,
     712        //                  tr("Apply changes, keep dialog open"));
     713        //     }
     714        //
     715        //     @Override public void actionPerformed(ActionEvent evt) {
     716        //         updateImageTmp();
     717        //         updateLayer(layer, image);
     718        //     }
     719        // }
    694720    }
    695721}
Note: See TracChangeset for help on using the changeset viewer.