Changeset 151 in josm
- Timestamp:
- 2006-10-07T00:14:05+02:00 (18 years ago)
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
build.xml
r147 r151 1 1 <project name="openstreetmap" default="dist" basedir="."> 2 2 3 <property name="src" location="src" /> 4 <property name="po" location="po" /> 5 <property name="build" location="build" /> 6 <property name="dist" location="dist" /> 7 <property name="lib" location="lib" /> 8 3 <!-- All jar files necessary to run only JOSM (no tests) --> 4 <fileset id="josm_required_libs" dir="lib"> 5 <include name="gettext-commons-0.9.jar"/> 6 <include name="metadata-extractor-2.3.1.jar"/> 7 <include name="MinML2.jar"/> 8 </fileset> 9 10 <!-- Java classpath addition (all jar files to compile tests with this) --> 9 11 <path id="classpath"> 10 <fileset dir=" ${lib}">12 <fileset dir="lib"> 11 13 <include name="**/*.jar"/> 12 14 </fileset> 13 15 </path> 14 16 15 <path id="srcfiles">16 <fileset dir="${src}">17 <include name="**/*.java"/>18 </fileset>19 </path>20 21 <target name="init">22 <mkdir dir="${build}" />23 <mkdir dir="${dist}" />24 </target>25 26 <target name="compile" depends="init">27 <javac srcdir="${src}" classpathref="classpath" destdir="${build}">28 <include name="org/openstreetmap/josm/gui/MainApplication.java"/>29 <include name="org/openstreetmap/josm/gui/MainApplet.java"/>30 <include name="org/openstreetmap/josm/plugins/**/*.java"/>31 </javac>32 </target>33 34 17 <target name="dist" depends="compile"> 35 18 <!-- jars --> 36 <unjar src="${lib}/MinML2.jar" dest="${build}" />37 <unjar src="${lib}/gettext-commons-0.9.jar" dest="${build}" />38 < unjar src="${lib}/metadata-extractor-2.3.1.jar" dest="${build}" />19 <unjar dest="build"> 20 <fileset refid="josm_required_libs" /> 21 </unjar> 39 22 40 23 <!-- images --> 41 <copy todir=" ${build}/images">24 <copy todir="build/images"> 42 25 <fileset dir="images" /> 43 26 </copy> 44 <copy todir=" ${build}/org/openstreetmap/josm">45 <fileset dir=" ${po}/org/openstreetmap/josm" />27 <copy todir="build/org/openstreetmap/josm"> 28 <fileset dir="po/org/openstreetmap/josm" /> 46 29 </copy> 47 <jar destfile="${dist}/josm-custom.jar" basedir="${build}"> 30 31 <!-- create josm-custom.jar --> 32 <jar destfile="dist/josm-custom.jar" basedir="build"> 48 33 <manifest> 49 34 <attribute name="Main-class" value="org.openstreetmap.josm.gui.MainApplication" /> … … 52 37 </target> 53 38 54 <target name="clean">55 <delete dir="${build}" />56 <delete dir="${dist}" />57 </target>58 59 60 39 <target name="gettext" depends="init"> 61 <exec executable="find" output=" ${build}/alljava.txt">62 <arg line=" ${src}-name '*.java'"/>40 <exec executable="find" output="build/alljava.txt"> 41 <arg line="src -name '*.java'"/> 63 42 </exec> 64 43 <exec executable="xgettext"> 65 <arg line="-ktr -ktrn:1,2 -ktrc -kmarktr -Ljava -o ${po}/keys.pot -f${build}/alljava.txt"/>44 <arg line="-ktr -ktrn:1,2 -ktrc -kmarktr -Ljava -opo/keys.pot -fbuild/alljava.txt"/> 66 45 </exec> 67 46 <apply executable="msgmerge"> 68 47 <arg value="-U"/> 69 48 <srcfile/> 70 <arg file=" ${po}/keys.pot"/>71 <fileset dir=" ${po}">49 <arg file="po/keys.pot"/> 50 <fileset dir="po"> 72 51 <include name="*.po"/> 73 52 </fileset> … … 76 55 <!-- FIXME: somehow iterate the po-directory and create the java files --> 77 56 <exec executable="msgfmt"> 78 <arg line="--java2 -d ${po}-rorg.openstreetmap.josm.Translation -lde${po}/de.po"/>57 <arg line="--java2 -dpo -rorg.openstreetmap.josm.Translation -lde po/de.po"/> 79 58 </exec> 80 59 <exec executable="msgfmt"> 81 <arg line="--java2 -d ${po}-rorg.openstreetmap.josm.Translation -lfr${po}/fr.po"/>60 <arg line="--java2 -dpo -rorg.openstreetmap.josm.Translation -lfr po/fr.po"/> 82 61 </exec> 83 62 <exec executable="msgfmt"> 84 <arg line="--java2 -d ${po}-rorg.openstreetmap.josm.Translation -len_GB${po}/en_GB.po"/>63 <arg line="--java2 -dpo -rorg.openstreetmap.josm.Translation -len_GB po/en_GB.po"/> 85 64 </exec> 86 65 <exec executable="msgfmt"> 87 <arg line="--java2 -d ${po}-rorg.openstreetmap.josm.Translation -lro${po}/ro.po"/>66 <arg line="--java2 -dpo -rorg.openstreetmap.josm.Translation -lro po/ro.po"/> 88 67 </exec> 89 68 </target> 90 69 70 <target name="compile" depends="init"> 71 <javac srcdir="src" classpathref="classpath" destdir="build" /> 72 </target> 73 74 <target name="compile-tests" depends="compile"> 75 76 </target> 77 78 79 <target name="init"> 80 <mkdir dir="build" /> 81 <mkdir dir="dist" /> 82 </target> 83 84 <target name="clean"> 85 <delete dir="build" /> 86 <delete dir="dist" /> 87 </target> 88 91 89 </project> -
src/org/openstreetmap/josm/actions/mapmode/MoveAction.java
r113 r151 5 5 import java.awt.Cursor; 6 6 import java.awt.Point; 7 import java.awt.Rectangle; 7 8 import java.awt.event.KeyEvent; 8 9 import java.awt.event.MouseEvent; … … 19 20 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 20 21 import org.openstreetmap.josm.gui.MapFrame; 22 import org.openstreetmap.josm.gui.SelectionManager; 23 import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded; 21 24 import org.openstreetmap.josm.tools.ImageProvider; 22 25 /** 23 26 * Move is an action that can move all kind of OsmPrimitives (except Keys for now). 24 * 25 * If any object is selected, all selected objects are moved. If no object is 26 * selected, the nearest object will be selected and moved. In this case, the 27 * object will be unselected as soon as movement stopped. 27 * 28 * If an selected object is under the mouse when dragging, move all selected objects. 29 * If an unselected object is under the mouse when dragging, it becomes selected 30 * and will be moved. 31 * If no object is under the mouse, move all selected objects (if any) 28 32 * 29 33 * @author imi 30 34 */ 31 public class MoveAction extends MapMode { 35 public class MoveAction extends MapMode implements SelectionEnded { 32 36 /** 33 37 * The old cursor before the user pressed the mouse button. … … 38 42 */ 39 43 private Point mousePos; 40 /** 41 * Non-<code>null</code>, if no object was selected before movement 42 * (and so the object get unselected after mouse release). 43 */ 44 private OsmPrimitive singleOsmPrimitive; 44 private SelectionManager selectionManager; 45 private boolean selectionMode = false; 45 46 46 47 /** … … 50 51 public MoveAction(MapFrame mapFrame) { 51 52 super(tr("Move"), 52 "move", 53 tr("Move selected objectsaround."),54 KeyEvent.VK_M, 55 mapFrame, 53 "move", 54 tr("Move around objects that are under the mouse or selected."), 55 KeyEvent.VK_M, 56 mapFrame, 56 57 ImageProvider.getCursor("normal", "move")); 58 selectionManager = new SelectionManager(this, false, mapFrame.mapView); 57 59 } 58 60 … … 69 71 } 70 72 71 73 72 74 /** 73 75 * If the left mouse button is pressed, move all currently selected 74 * objects. 76 * objects (if one of them is under the mouse) or the current one under the 77 * mouse (which will become selected). 75 78 */ 76 79 @Override public void mouseDragged(MouseEvent e) { 77 80 if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == 0) 78 81 return; 82 83 if (selectionMode) 84 return; 79 85 80 if (mousePos == null) {86 if (mousePos == null) 81 87 mousePos = e.getPoint(); 82 singleOsmPrimitive = null;83 }84 88 85 EastNorth mouse Geo= Main.map.mapView.getEastNorth(e.getX(), e.getY());86 EastNorth mouseStart Geo= Main.map.mapView.getEastNorth(mousePos.x, mousePos.y);87 double dx = mouse Geo.east() - mouseStartGeo.east();88 double dy = mouse Geo.north() - mouseStartGeo.north();89 EastNorth mouseEN = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 90 EastNorth mouseStartEN = Main.map.mapView.getEastNorth(mousePos.x, mousePos.y); 91 double dx = mouseEN.east() - mouseStartEN.east(); 92 double dy = mouseEN.north() - mouseStartEN.north(); 89 93 if (dx == 0 && dy == 0) 90 94 return; … … 92 96 Collection<OsmPrimitive> selection = Main.ds.getSelected(); 93 97 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 94 98 95 99 // check if any coordinate would be outside the world 96 100 for (OsmPrimitive osm : affectedNodes) { … … 100 104 } 101 105 } 102 106 103 107 Command c = !Main.main.editLayer().commands.isEmpty() ? Main.main.editLayer().commands.getLast() : null; 104 108 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand)c).objects)) … … 106 110 else 107 111 Main.main.editLayer().add(new MoveCommand(selection, dx, dy)); 108 112 109 113 Main.map.mapView.repaint(); 110 114 mousePos = e.getPoint(); … … 124 128 return; 125 129 126 if (Main.ds.getSelected().size() == 0) { 127 OsmPrimitive osm = Main.map.mapView.getNearest(e.getPoint(), (e.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) != 0); 128 if (osm != null) 129 Main.ds.setSelected(osm); 130 singleOsmPrimitive = osm; 131 Main.map.mapView.repaint(); 132 } else 133 singleOsmPrimitive = null; 134 130 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 131 OsmPrimitive osm = Main.map.mapView.getNearest(e.getPoint(), (e.getModifiersEx() & MouseEvent.ALT_DOWN_MASK) != 0); 132 if (osm != null) { 133 if (!sel.contains(osm)) 134 Main.ds.setSelected(osm); 135 oldCursor = Main.map.mapView.getCursor(); 136 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 137 } else { 138 selectionMode = true; 139 selectionManager.register(Main.map.mapView); 140 } 141 142 Main.map.mapView.repaint(); 143 135 144 mousePos = e.getPoint(); 136 oldCursor = Main.map.mapView.getCursor();137 Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));138 145 } 139 146 140 147 /** 141 148 * Restore the old mouse cursor. 142 149 */ 143 150 @Override public void mouseReleased(MouseEvent e) { 144 Main.map.mapView.setCursor(oldCursor);145 if (singleOsmPrimitive != null) {146 Main.ds.clearSelection();147 Main.map.mapView.repaint();148 }151 if (selectionMode) { 152 selectionManager.unregister(Main.map.mapView); 153 selectionMode = false; 154 } else 155 Main.map.mapView.setCursor(oldCursor); 149 156 } 157 158 159 public void selectionEnded(Rectangle r, boolean alt, boolean shift, boolean ctrl) { 160 SelectionAction.selectEverythingInRectangle(selectionManager, r, alt, shift, ctrl); 161 } 150 162 } -
src/org/openstreetmap/josm/actions/mapmode/SelectionAction.java
r118 r151 138 138 */ 139 139 public void selectionEnded(Rectangle r, boolean alt, boolean shift, boolean ctrl) { 140 if (shift && ctrl) 140 selectEverythingInRectangle(selectionManager, r, alt, shift, ctrl); 141 } 142 143 public static void selectEverythingInRectangle(SelectionManager selectionManager, Rectangle r, boolean alt, boolean shift, boolean ctrl) { 144 if (shift && ctrl) 141 145 return; // not allowed together 142 146 … … 155 159 Main.ds.setSelected(curSel); 156 160 Main.map.mapView.repaint(); 157 161 } 158 162 159 163 @Override public void mouseDragged(MouseEvent e) { -
src/org/openstreetmap/josm/plugins/PluginLoader.java
r149 r151 43 43 try { 44 44 ClassLoader loader = URLClassLoader.newInstance( 45 new URL[]{new URL("file:/"+pluginFile.getAbsolutePath())}, 45 new URL[]{new URL("file://"+pluginFile.getAbsolutePath())}, 46 46 getClass().getClassLoader()); 47 47 Object plugin = Class.forName(pluginClass, true, loader).newInstance(); -
test/org/openstreetmap/josm/plugins/PluginLoaderTest.java
r149 r151 2 2 3 3 import java.io.File; 4 import java.lang.reflect.Field;5 4 6 5 import junit.framework.TestCase; … … 24 23 PluginProxy plugin = loader.loadPlugin(getClass().getName()+"$TestPlugin", new File("foo.jar")); 25 24 assertTrue(plugin.plugin instanceof TestPlugin); 26 Field nameField = Plugin.class.getDeclaredField("name");27 nameField.setAccessible(true);28 assertEquals("foo", nameField.get(plugin.plugin));29 25 } 30 26
Note:
See TracChangeset
for help on using the changeset viewer.