Changeset 8947 in josm for trunk/src/org


Ignore:
Timestamp:
2015-10-25T14:52:06+01:00 (4 years ago)
Author:
Don-vip
Message:

fix HeadlessException seen in unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java

    r8919 r8947  
    1010import java.awt.Dimension;
    1111import java.awt.FlowLayout;
     12import java.awt.GraphicsEnvironment;
    1213import java.awt.event.ActionEvent;
    1314import java.awt.event.HierarchyBoundsListener;
     
    494495        }
    495496
    496         // Build conflict resolution dialog
    497         final CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance();
    498 
    499         dialog.getTagConflictResolverModel().populate(tagsToEdit, completeWayTags.getKeysWithMultipleValues());
    500         dialog.getRelationMemberConflictResolverModel().populate(parentRelations, primitives);
    501         dialog.prepareDefaultDecisions();
    502 
    503         // Ensure a proper title is displayed instead of a previous target (fix #7925)
    504         if (targetPrimitives.size() == 1) {
    505             dialog.setTargetPrimitive(targetPrimitives.iterator().next());
    506         } else {
    507             dialog.setTargetPrimitive(null);
    508         }
    509 
    510         // Resolve tag conflicts if necessary
    511         if (!dialog.isResolvedCompletely()) {
    512             dialog.setVisible(true);
    513             if (dialog.isCanceled()) {
    514                 throw new UserCancelException();
    515             }
    516         }
    517497        List<Command> cmds = new LinkedList<>();
    518         for (OsmPrimitive i : targetPrimitives) {
    519             dialog.setTargetPrimitive(i);
    520             cmds.addAll(dialog.buildResolutionCommands());
     498
     499        if (!GraphicsEnvironment.isHeadless()) {
     500            // Build conflict resolution dialog
     501            final CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance();
     502
     503            dialog.getTagConflictResolverModel().populate(tagsToEdit, completeWayTags.getKeysWithMultipleValues());
     504            dialog.getRelationMemberConflictResolverModel().populate(parentRelations, primitives);
     505            dialog.prepareDefaultDecisions();
     506
     507            // Ensure a proper title is displayed instead of a previous target (fix #7925)
     508            if (targetPrimitives.size() == 1) {
     509                dialog.setTargetPrimitive(targetPrimitives.iterator().next());
     510            } else {
     511                dialog.setTargetPrimitive(null);
     512            }
     513
     514            // Resolve tag conflicts if necessary
     515            if (!dialog.isResolvedCompletely()) {
     516                dialog.setVisible(true);
     517                if (dialog.isCanceled()) {
     518                    throw new UserCancelException();
     519                }
     520            }
     521            for (OsmPrimitive i : targetPrimitives) {
     522                dialog.setTargetPrimitive(i);
     523                cmds.addAll(dialog.buildResolutionCommands());
     524            }
    521525        }
    522526        return cmds;
Note: See TracChangeset for help on using the changeset viewer.