Changeset 10881 in josm for trunk/src


Ignore:
Timestamp:
2016-08-23T22:54:08+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13430 - Allow paste of OSM links (patch by michael2402) - gsoc-core

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/GettingStarted.java

    r10634 r10881  
    2424import org.openstreetmap.josm.Main;
    2525import org.openstreetmap.josm.data.Version;
    26 import org.openstreetmap.josm.gui.datatransfer.FileTransferHandler;
     26import org.openstreetmap.josm.gui.datatransfer.OpenTransferHandler;
    2727import org.openstreetmap.josm.gui.preferences.server.ProxyPreference;
    2828import org.openstreetmap.josm.gui.preferences.server.ProxyPreferenceListener;
     
    133133        getMOTD();
    134134
    135         setTransferHandler(new FileTransferHandler());
     135        setTransferHandler(new OpenTransferHandler());
    136136    }
    137137
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java

    r10766 r10881  
    99import java.util.Collection;
    1010
    11 import javax.swing.TransferHandler;
    12 
    1311import org.openstreetmap.josm.Main;
    1412import org.openstreetmap.josm.data.coor.EastNorth;
     
    1614import org.openstreetmap.josm.gui.datatransfer.importers.AbstractOsmDataPaster;
    1715import org.openstreetmap.josm.gui.datatransfer.importers.FilePaster;
     16import org.openstreetmap.josm.gui.datatransfer.importers.OsmLinkPaster;
    1817import org.openstreetmap.josm.gui.datatransfer.importers.PrimitiveDataPaster;
    1918import org.openstreetmap.josm.gui.datatransfer.importers.PrimitiveTagTransferPaster;
     
    2726 * @since 10604
    2827 */
    29 public class OsmTransferHandler extends TransferHandler {
     28public class OsmTransferHandler extends AbstractStackTransferHandler {
    3029
    3130    private static final Collection<AbstractOsmDataPaster> SUPPORTED = Arrays.asList(
    3231            new FilePaster(), new PrimitiveDataPaster(),
    3332            new PrimitiveTagTransferPaster(),
    34             new TagTransferPaster(), new TextTagPaster());
     33            new TagTransferPaster(), new OsmLinkPaster(), new TextTagPaster());
    3534
    3635    @Override
    37     public boolean canImport(TransferSupport support) {
    38         // import everything for now, only support copy.
    39         for (AbstractOsmDataPaster df : SUPPORTED) {
    40             if (df.supports(support)) {
    41                 return true;
    42             }
    43         }
    44         return false;
    45     }
    46 
    47     @Override
    48     public boolean importData(TransferSupport support) {
    49         return importData(support, Main.getLayerManager().getEditLayer(), null);
    50     }
    51 
    52     private boolean importData(TransferSupport support, OsmDataLayer layer, EastNorth center) {
    53         for (AbstractOsmDataPaster df : SUPPORTED) {
    54             if (df.supports(support)) {
    55                 try {
    56                     if (df.importData(support, layer, center)) {
    57                         return true;
    58                     }
    59                 } catch (UnsupportedFlavorException | IOException e) {
    60                     Main.warn(e);
    61                 }
    62             }
    63         }
    64         return super.importData(support);
     36    protected Collection<AbstractOsmDataPaster> getSupportedPasters() {
     37        return SUPPORTED;
    6538    }
    6639
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractOsmDataPaster.java

    r10604 r10881  
    5757     * Attempts to import the given transfer data.
    5858     * @param support The transfer support to import from.
    59      * @param layer The layer to paste at.
     59     * @param layer The layer to paste at. May be null.
    6060     * @param pasteAt The position to paste at.
    6161     * @return <code>true</code> if the import was successful.
Note: See TracChangeset for help on using the changeset viewer.