Changeset 16267 in josm for trunk


Ignore:
Timestamp:
2020-04-12T11:14:42+02:00 (4 years ago)
Author:
simon04
Message:

Use non-optional ImageResource without null check

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/AbstractListMerger.java

    r14214 r16267  
    4141import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTable;
    4242import org.openstreetmap.josm.tools.ImageProvider;
    43 import org.openstreetmap.josm.tools.ImageResource;
    4443
    4544/**
     
    421420    abstract static class CopyAction extends AbstractAction implements ListSelectionListener {
    422421
    423         protected CopyAction(String iconName, String actionName, String shortDescription) {
    424             ImageResource icon = new ImageProvider("dialogs/conflict", iconName).getResource();
    425             if (icon == null) {
    426                 putValue(Action.NAME, actionName);
    427             } else {
    428                 icon.attachImageIcon(this, true);
    429             }
     422        protected CopyAction(String iconName, String shortDescription) {
     423            new ImageProvider("dialogs/conflict", iconName).getResource().attachImageIcon(this, true);
    430424            putValue(Action.SHORT_DESCRIPTION, shortDescription);
    431425            setEnabled(false);
     
    440434
    441435        CopyStartLeftAction() {
    442             super(/* ICON(dialogs/conflict/)*/ "copystartleft", tr("> top"),
     436            super(/* ICON(dialogs/conflict/)*/ "copystartleft",
    443437                tr("Copy my selected nodes to the start of the merged node list"));
    444438        }
     
    462456
    463457        CopyEndLeftAction() {
    464             super(/* ICON(dialogs/conflict/)*/ "copyendleft", tr("> bottom"),
     458            super(/* ICON(dialogs/conflict/)*/ "copyendleft",
    465459                tr("Copy my selected elements to the end of the list of merged elements."));
    466460        }
     
    484478
    485479        CopyBeforeCurrentLeftAction() {
    486             super(/* ICON(dialogs/conflict/)*/ "copybeforecurrentleft", tr("> before"),
     480            super(/* ICON(dialogs/conflict/)*/ "copybeforecurrentleft",
    487481                    tr("Copy my selected elements before the first selected element in the list of merged elements."));
    488482        }
     
    514508
    515509        CopyAfterCurrentLeftAction() {
    516             super(/* ICON(dialogs/conflict/)*/ "copyaftercurrentleft", tr("> after"),
     510            super(/* ICON(dialogs/conflict/)*/ "copyaftercurrentleft",
    517511                    tr("Copy my selected elements after the first selected element in the list of merged elements."));
    518512        }
     
    540534
    541535        CopyStartRightAction() {
    542             super(/* ICON(dialogs/conflict/)*/ "copystartright", tr("< top"),
     536            super(/* ICON(dialogs/conflict/)*/ "copystartright",
    543537                tr("Copy their selected element to the start of the list of merged elements."));
    544538        }
     
    558552
    559553        CopyEndRightAction() {
    560             super(/* ICON(dialogs/conflict/)*/ "copyendright", tr("< bottom"),
     554            super(/* ICON(dialogs/conflict/)*/ "copyendright",
    561555                tr("Copy their selected elements to the end of the list of merged elements."));
    562556        }
     
    576570
    577571        CopyBeforeCurrentRightAction() {
    578             super(/* ICON(dialogs/conflict/)*/ "copybeforecurrentright", tr("< before"),
     572            super(/* ICON(dialogs/conflict/)*/ "copybeforecurrentright",
    579573                    tr("Copy their selected elements before the first selected element in the list of merged elements."));
    580574        }
     
    602596
    603597        CopyAfterCurrentRightAction() {
    604             super(/* ICON(dialogs/conflict/)*/ "copyaftercurrentright", tr("< after"),
     598            super(/* ICON(dialogs/conflict/)*/ "copyaftercurrentright",
    605599                    tr("Copy their selected element after the first selected element in the list of merged elements"));
    606600        }
     
    684678
    685679        MoveUpMergedAction() {
    686             ImageResource icon = new ImageProvider("dialogs/conflict", "moveup").getResource();
    687             if (icon == null) {
    688                 putValue(Action.NAME, tr("Up"));
    689             } else {
    690                 icon.attachImageIcon(this, true);
    691             }
     680            new ImageProvider("dialogs/conflict", "moveup").getResource().attachImageIcon(this, true);
    692681            putValue(Action.SHORT_DESCRIPTION, tr("Move up the selected entries by one position."));
    693682            setEnabled(false);
     
    717706
    718707        MoveDownMergedAction() {
    719             ImageResource icon = new ImageProvider("dialogs/conflict", "movedown").getResource();
    720             if (icon == null) {
    721                 putValue(Action.NAME, tr("Down"));
    722             } else {
    723                 icon.attachImageIcon(this, true);
    724             }
     708            new ImageProvider("dialogs/conflict", "movedown").getResource().attachImageIcon(this, true);
    725709            putValue(Action.SHORT_DESCRIPTION, tr("Move down the selected entries by one position."));
    726710            setEnabled(false);
     
    750734
    751735        RemoveMergedAction() {
    752             ImageResource icon = new ImageProvider("dialogs/conflict", "remove").getResource();
    753             if (icon == null) {
    754                 putValue(Action.NAME, tr("Remove"));
    755             } else {
    756                 icon.attachImageIcon(this, true);
    757             }
     736            new ImageProvider("dialogs/conflict", "remove").getResource().attachImageIcon(this, true);
    758737            putValue(Action.SHORT_DESCRIPTION, tr("Remove the selected entries from the list of merged elements."));
    759738            setEnabled(false);
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMerger.java

    r15586 r16267  
    3232import org.openstreetmap.josm.tools.GBC;
    3333import org.openstreetmap.josm.tools.ImageProvider;
    34 import org.openstreetmap.josm.tools.ImageResource;
    3534
    3635/**
     
    180179    class KeepMineAction extends AbstractAction implements ListSelectionListener {
    181180        KeepMineAction() {
    182             ImageResource icon = new ImageProvider("dialogs/conflict", "tagkeepmine").getResource();
    183             if (icon != null) {
    184                 icon.attachImageIcon(this, true);
    185                 putValue(Action.NAME, "");
    186             } else {
    187                 putValue(Action.NAME, ">");
    188             }
     181            new ImageProvider("dialogs/conflict", "tagkeepmine").getResource().attachImageIcon(this, true);
    189182            putValue(Action.SHORT_DESCRIPTION, tr("Keep the selected key/value pairs from the local dataset"));
    190183            setEnabled(false);
     
    212205    class KeepTheirAction extends AbstractAction implements ListSelectionListener {
    213206        KeepTheirAction() {
    214             ImageResource icon = new ImageProvider("dialogs/conflict", "tagkeeptheir").getResource();
    215             if (icon != null) {
    216                 icon.attachImageIcon(this, true);
    217                 putValue(Action.NAME, "");
    218             } else {
    219                 putValue(Action.NAME, ">");
    220             }
     207            new ImageProvider("dialogs/conflict", "tagkeeptheir").getResource().attachImageIcon(this, true);
    221208            putValue(Action.SHORT_DESCRIPTION, tr("Keep the selected key/value pairs from the server dataset"));
    222209            setEnabled(false);
     
    241228     * Synchronizes scrollbar adjustments between a set of
    242229     * {@link Adjustable}s. Whenever the adjustment of one of
    243      * the registerd Adjustables is updated the adjustment of
     230     * the registered Adjustables is updated the adjustment of
    244231     * the other registered Adjustables is adjusted too.
    245232     *
     
    310297
    311298        UndecideAction() {
    312             ImageResource icon = new ImageProvider("dialogs/conflict", "tagundecide").getResource();
    313             if (icon != null) {
    314                 icon.attachImageIcon(this, true);
    315                 putValue(Action.NAME, "");
    316             } else {
    317                 putValue(Action.NAME, tr("Undecide"));
    318             }
     299            new ImageProvider("dialogs/conflict", "tagundecide").getResource().attachImageIcon(this, true);
    319300            putValue(SHORT_DESCRIPTION, tr("Mark the selected tags as undecided"));
    320301            setEnabled(false);
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r14470 r16267  
    5555import org.openstreetmap.josm.tools.GBC;
    5656import org.openstreetmap.josm.tools.ImageProvider;
    57 import org.openstreetmap.josm.tools.ImageResource;
    5857import org.openstreetmap.josm.tools.InputMapUtils;
    5958import org.openstreetmap.josm.tools.Logging;
     
    364363            putValue(NAME, tr("Cancel"));
    365364            putValue(SHORT_DESCRIPTION, tr("Close this dialog and resume editing in JOSM"));
    366             ImageResource resource = new ImageProvider("cancel").setOptional(true).getResource();
    367             if (resource != null) {
    368                 resource.attachImageIcon(this, true);
    369             }
     365            new ImageProvider("cancel").getResource().attachImageIcon(this, true);
    370366            InputMapUtils.addEscapeAction(getRootPane(), this);
    371367        }
     
    401397                    putValue(NAME, tr("Exit now!"));
    402398                    putValue(SHORT_DESCRIPTION, tr("Exit JOSM without saving. Unsaved changes are lost."));
    403                     attachImageIcon(new ImageProvider("exit"));
     399                    new ImageProvider("exit").getResource().attachImageIcon(this, true);
    404400                    break;
    405401                case RESTART:
    406402                    putValue(NAME, tr("Restart now!"));
    407403                    putValue(SHORT_DESCRIPTION, tr("Restart JOSM without saving. Unsaved changes are lost."));
    408                     attachImageIcon(new ImageProvider("restart"));
     404                    new ImageProvider("restart").getResource().attachImageIcon(this, true);
    409405                    break;
    410406                case DELETE:
    411407                    putValue(NAME, tr("Delete now!"));
    412408                    putValue(SHORT_DESCRIPTION, tr("Delete layers without saving. Unsaved changes are lost."));
    413                     attachImageIcon(new ImageProvider("dialogs", "delete"));
    414                     break;
    415             }
    416         }
    417 
    418         private void attachImageIcon(ImageProvider provider) {
    419             ImageResource resource = provider.setOptional(true).getResource();
    420             if (resource != null) {
    421                 resource.attachImageIcon(this, true);
     409                    new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
     410                    break;
    422411            }
    423412        }
Note: See TracChangeset for help on using the changeset viewer.