Changeset 31491 in osm
- Timestamp:
- 2015-08-12T12:39:50+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31457 r31491 5 5 import javax.swing.ImageIcon; 6 6 import javax.swing.JMenuItem; 7 import javax.swing.SwingUtilities; 7 8 8 9 import org.apache.commons.jcs.access.CacheAccess; … … 118 119 IMPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, importAction, false, 119 120 14); 120 UPLOAD_MENU = MainMenu.add(Main.main.menu.fileMenu, uploadAction, 121 false, 14); 122 ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 123 15); 121 UPLOAD_MENU = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 122 14); 123 ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15); 124 124 DOWNLOAD_VIEW_MENU = MainMenu.add(Main.main.menu.fileMenu, 125 125 this.downloadViewAction, false, 14); … … 182 182 * true to enable the JMenuItem; false to disable it. 183 183 */ 184 public static void setMenuEnabled(JMenuItem menu, boolean value) { 185 menu.setEnabled(value); 186 menu.getAction().setEnabled(value); 184 public static void setMenuEnabled(final JMenuItem menu, final boolean value) { 185 if (!SwingUtilities.isEventDispatchThread()) { 186 SwingUtilities.invokeLater(new Runnable() { 187 @Override 188 public void run() { 189 setMenuEnabled(menu, value); 190 } 191 }); 192 } else { 193 menu.setEnabled(value); 194 menu.getAction().setEnabled(value); 195 } 187 196 } 188 197 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
r31456 r31491 53 53 if (dialog.sequence.isSelected()) { 54 54 UploadUtils.uploadSequence(MapillaryLayer.getInstance().getData() 55 .getSelectedImage().getSequence() );55 .getSelectedImage().getSequence(), dialog.delete.isSelected()); 56 56 } 57 57 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryUploadDialog.java
r31451 r31491 1 1 package org.openstreetmap.josm.plugins.mapillary.gui; 2 2 3 import javax.swing.BoxLayout; 3 4 import javax.swing.ButtonGroup; 5 import javax.swing.JCheckBox; 4 6 import javax.swing.JPanel; 5 7 import javax.swing.JRadioButton; 6 8 9 import org.openstreetmap.josm.Main; 7 10 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 8 11 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; … … 20 23 /** Upload the whole sequence. */ 21 24 public JRadioButton sequence; 25 /** Whether the images must be deleted after upload or not */ 26 public JCheckBox delete; 22 27 23 28 /** … … 25 30 */ 26 31 public MapillaryUploadDialog() { 32 setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); 33 27 34 this.group = new ButtonGroup(); 28 35 … … 33 40 this.group.add(this.sequence); 34 41 add(this.sequence); 42 this.group.setSelected(this.sequence.getModel(), true); 35 43 36 this.group.setSelected(this.sequence.getModel(), true); 44 this.delete = new JCheckBox("Delete after uplaod"); 45 this.delete.setSelected(Main.pref.getBoolean( 46 "mapillary.delete-after-upload", true)); 47 add(this.delete); 37 48 38 49 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java
r31490 r31491 2 2 3 3 import java.util.ArrayList; 4 5 import javax.swing.SwingUtilities; 4 6 5 7 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; … … 70 72 * The command to be added. 71 73 */ 72 public void addCommand(MapillaryCommand command) { 73 if (command instanceof MapillaryExecutableCommand) 74 ((MapillaryExecutableCommand) command).execute(); 75 // Checks if it is a continuation of last command 76 if (this.position != -1) { 77 boolean equalSets = true; 78 for (MapillaryAbstractImage img : this.commandList.get(this.position).images) 79 if (!command.images.contains(img)) 80 equalSets = false; 81 for (MapillaryAbstractImage img : command.images) 82 if (!this.commandList.get(this.position).images.contains(img)) 83 equalSets = false; 84 if (equalSets 85 && this.commandList.get(this.position).getClass() == command 86 .getClass()) { 87 this.commandList.get(this.position).sum(command); 88 fireRecordChanged(); 89 return; 74 public void addCommand(final MapillaryCommand command) { 75 if (!SwingUtilities.isEventDispatchThread()) { 76 SwingUtilities.invokeLater(new Runnable() { 77 @Override 78 public void run() { 79 addCommand(command); 80 } 81 }); 82 } else { 83 if (command instanceof MapillaryExecutableCommand) 84 ((MapillaryExecutableCommand) command).execute(); 85 // Checks if it is a continuation of last command 86 if (this.position != -1) { 87 boolean equalSets = true; 88 for (MapillaryAbstractImage img : this.commandList.get(this.position).images) 89 if (!command.images.contains(img)) 90 equalSets = false; 91 for (MapillaryAbstractImage img : command.images) 92 if (!this.commandList.get(this.position).images.contains(img)) 93 equalSets = false; 94 if (equalSets 95 && this.commandList.get(this.position).getClass() == command 96 .getClass()) { 97 this.commandList.get(this.position).sum(command); 98 fireRecordChanged(); 99 return; 100 } 90 101 } 102 // Adds the command to the last position of the list. 103 this.commandList.add(this.position + 1, command); 104 this.position++; 105 while (this.commandList.size() > this.position + 1) { 106 this.commandList.remove(this.position + 1); 107 } 108 fireRecordChanged(); 91 109 } 92 // Adds the command to the last position of the list.93 this.commandList.add(this.position + 1, command);94 this.position++;95 while (this.commandList.size() > this.position + 1) {96 this.commandList.remove(this.position + 1);97 }98 fireRecordChanged();99 110 } 100 111 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/commands/CommandImport.java
r31490 r31491 29 29 @Override 30 30 public void execute() { 31 this.redo();31 MapillaryLayer.getInstance().getData().add(this.images); 32 32 } 33 33 … … 42 42 @Override 43 43 public void redo() { 44 MapillaryLayer.getInstance().getData().add(this.images);44 this.execute(); 45 45 } 46 46 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java
r31482 r31491 41 41 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 42 42 import org.openstreetmap.josm.plugins.mapillary.MapillarySequence; 43 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord; 44 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandDelete; 43 45 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 44 46 import org.openstreetmap.josm.plugins.mapillary.utils.PluginState; … … 141 143 * The sequence to upload. It must contain only 142 144 * {@link MapillaryImportedImage} objects. 143 */ 144 public static void uploadSequence(MapillarySequence sequence) { 145 Main.worker.submit(new SequenceUploadThread(sequence.getImages())); 145 * @param delete 146 * Whether the images must be deleted after upload or not. 147 */ 148 public static void uploadSequence(MapillarySequence sequence, boolean delete) { 149 Main.worker.submit(new SequenceUploadThread(sequence.getImages(), delete)); 146 150 } 147 151 … … 149 153 private List<MapillaryAbstractImage> images; 150 154 private UUID uuid; 155 private boolean delete; 151 156 ThreadPoolExecutor ex; 152 157 153 private SequenceUploadThread(List<MapillaryAbstractImage> images) { 158 private SequenceUploadThread(List<MapillaryAbstractImage> images, 159 boolean delete) { 154 160 this.images = images; 155 161 this.uuid = UUID.randomUUID(); 156 162 this.ex = new ThreadPoolExecutor(8, 8, 25, TimeUnit.SECONDS, 157 163 new ArrayBlockingQueue<Runnable>(15)); 164 this.delete = delete; 158 165 } 159 166 … … 176 183 } 177 184 this.ex.shutdown(); 185 try { 186 this.ex.awaitTermination(15, TimeUnit.SECONDS); 187 } catch (InterruptedException e) { 188 Main.error(e); 189 } 190 System.out.println(this.images.size()); 191 if (this.delete) 192 MapillaryRecord.getInstance().addCommand(new CommandDelete(this.images)); 178 193 } 179 194 }
Note:
See TracChangeset
for help on using the changeset viewer.