Changeset 1764 in josm
- Timestamp:
- 2009-07-11T12:33:24+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UpdateDataAction.java
r1750 r1764 60 60 61 61 if(bboxCount == 0) { 62 JOptionPane.showMessageDialog(Main.parent, 63 tr("No data to update found. Have you already opened or downloaded a data layer?")); 62 JOptionPane.showMessageDialog( 63 Main.parent, 64 tr("No data to update found. Have you already opened or downloaded a data layer?"), 65 tr("No data"), 66 JOptionPane.WARNING_MESSAGE 67 ); 64 68 return; 65 69 } -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r1750 r1764 217 217 if (layer == activeLayer) { 218 218 if (layer instanceof OsmDataLayer) { 219 Main.ds .setSelected();219 Main.ds = null; 220 220 } 221 221 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1762 r1764 5 5 6 6 import java.awt.Dimension; 7 import java.awt.EventQueue; 7 8 import java.awt.GridBagLayout; 8 9 import java.awt.GridLayout; … … 19 20 import java.util.Collection; 20 21 22 import javax.swing.JDialog; 21 23 import javax.swing.JLabel; 22 24 import javax.swing.JOptionPane; … … 46 48 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 47 49 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 50 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 48 51 import org.openstreetmap.josm.gui.SideButton; 49 52 import org.openstreetmap.josm.gui.dialogs.ConflictDialog; 50 53 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionCache; 51 54 import org.openstreetmap.josm.gui.dialogs.relation.ac.AutoCompletionList; 55 import org.openstreetmap.josm.io.OsmApi; 52 56 import org.openstreetmap.josm.io.OsmServerObjectReader; 53 57 import org.openstreetmap.josm.io.OsmTransferException; … … 162 166 }); 163 167 } 164 @Override public void windowGainedFocus(WindowEvent e) {165 requestFocusInTopLeftCell();166 }167 @Override168 public void windowActivated(WindowEvent e) {169 requestFocusInTopLeftCell();170 }171 168 @Override 172 169 public void windowDeiconified(WindowEvent e) { … … 547 544 Main.main.undoRedo.add(new AddCommand(getClone())); 548 545 DataSet.fireSelectionChanged(Main.ds.getSelected()); 549 } else if ( getRelation().hasEqualSemanticAttributes(getClone())) {546 } else if (! getRelation().hasEqualSemanticAttributes(getClone())) { 550 547 tagEditorModel.applyToPrimitive(getClone()); 551 548 Main.main.undoRedo.add(new ChangeCommand(getRelation(), getClone())); … … 758 755 } 759 756 757 758 /** 759 * Asynchronously download the members of the currently edited relation 760 * 761 */ 760 762 private void downloadRelationMembers() { 763 764 class DownloadTask extends PleaseWaitRunnable { 765 private boolean cancelled; 766 private Exception lastException; 767 768 protected void setIndeterminateEnabled(final boolean enabled) { 769 EventQueue.invokeLater( 770 new Runnable() { 771 public void run() { 772 Main.pleaseWaitDlg.setIndeterminate(enabled); 773 } 774 } 775 ); 776 } 777 778 public DownloadTask() { 779 super(tr("Download relation members"), false /* don't ignore exception */); 780 } 781 @Override 782 protected void cancel() { 783 cancelled = true; 784 OsmApi.getOsmApi().cancel(); 785 } 786 787 protected void showLastException() { 788 String msg = lastException.getMessage(); 789 if (msg == null) { 790 msg = lastException.toString(); 791 } 792 JOptionPane.showMessageDialog( 793 null, 794 msg, 795 tr("Error"), 796 JOptionPane.ERROR_MESSAGE 797 ); 798 } 799 800 @Override 801 protected void finish() { 802 refreshTables(); 803 if (cancelled) return; 804 if (lastException == null) return; 805 showLastException(); 806 } 807 808 @Override 809 protected void realRun() throws SAXException, IOException, OsmTransferException { 810 try { 811 Main.pleaseWaitDlg.setAlwaysOnTop(true); 812 Main.pleaseWaitDlg.toFront(); 813 setIndeterminateEnabled(true); 814 OsmServerObjectReader reader = new OsmServerObjectReader(getClone().id, OsmPrimitiveType.RELATION, true); 815 DataSet dataSet = reader.parseOsm(); 816 if (dataSet != null) { 817 final MergeVisitor visitor = new MergeVisitor(Main.main.map.mapView.getEditLayer() 818 .data, dataSet); 819 visitor.merge(); 820 821 // copy the merged layer's data source info 822 for (DataSource src : dataSet.dataSources) { 823 Main.map.mapView.getEditLayer().data.dataSources.add(src); 824 } 825 Main.map.mapView.getEditLayer().fireDataChange(); 826 827 if (visitor.getConflicts().isEmpty()) 828 return; 829 final ConflictDialog dlg = Main.map.conflictDialog; 830 dlg.getConflicts().add(visitor.getConflicts()); 831 JOptionPane op = new JOptionPane( 832 tr("There were {0} conflicts during import.", 833 visitor.getConflicts().size()), 834 JOptionPane.WARNING_MESSAGE 835 ); 836 JDialog dialog = op.createDialog(Main.pleaseWaitDlg, tr("Conflicts in data")); 837 dialog.setAlwaysOnTop(true); //<-- this line 838 dialog.setModal(true); 839 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 840 dialog.setVisible(true); 841 } 842 } catch(Exception e) { 843 if (cancelled) { 844 System.out.println(tr("Warning: ignoring exception because task is cancelled. Exception: {0}", e.toString())); 845 return; 846 } 847 lastException = e; 848 } finally { 849 Main.pleaseWaitDlg.setAlwaysOnTop(false); 850 setIndeterminateEnabled(false); 851 } 852 } 853 } 854 761 855 boolean download = false; 762 856 for (RelationMember member : getClone().members) { … … 766 860 } 767 861 } 768 if (download) { 769 OsmServerObjectReader reader = new OsmServerObjectReader(getClone().id, OsmPrimitiveType.RELATION, true); 770 try { 771 DataSet dataSet = reader.parseOsm(); 772 if (dataSet != null) { 773 final MergeVisitor visitor = new MergeVisitor(Main.main.map.mapView.getEditLayer() 774 .data, dataSet); 775 visitor.merge(); 776 777 // copy the merged layer's data source info 778 for (DataSource src : dataSet.dataSources) { 779 Main.main.map.mapView.getEditLayer().data.dataSources.add(src); 780 } 781 Main.main.map.mapView.getEditLayer().fireDataChange(); 782 783 if (visitor.getConflicts().isEmpty()) 784 return; 785 final ConflictDialog dlg = Main.map.conflictDialog; 786 dlg.getConflicts().add(visitor.getConflicts()); 787 JOptionPane.showMessageDialog(Main.parent, 788 tr("There were conflicts during import.")); 789 if (!dlg.isVisible()) { 790 dlg.action 791 .actionPerformed(new ActionEvent(this, 0, "")); 792 } 793 } 794 } catch(OsmTransferException e) { 795 e.printStackTrace(); 796 if (e.getCause() != null) { 797 if (e.getCause() instanceof SAXException) { 798 JOptionPane.showMessageDialog(this,tr("Error parsing server response.")+": "+e.getCause().getMessage(), 799 tr("Error"), JOptionPane.ERROR_MESSAGE); 800 } else if(e.getCause() instanceof IOException) { 801 JOptionPane.showMessageDialog(this,tr("Cannot connect to server.")+": "+e.getCause().getMessage(), 802 tr("Error"), JOptionPane.ERROR_MESSAGE); 803 } 804 } else { 805 JOptionPane.showMessageDialog(this,tr("Error when communicating with server.")+": "+e.getMessage(), 806 tr("Error"), JOptionPane.ERROR_MESSAGE); 807 } 808 } 809 } 862 if (! download) return; 863 Main.worker.submit(new DownloadTask()); 810 864 } 811 865 }
Note:
See TracChangeset
for help on using the changeset viewer.