Changeset 156 for trunk/src/org/expeditee/actions/Actions.java
- Timestamp:
- 07/25/08 09:24:45 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r154 r156 22 22 import org.expeditee.gui.FrameIO; 23 23 import org.expeditee.gui.FrameUtils; 24 import org.expeditee.gui.FreeItems; 24 25 import org.expeditee.gui.MessageBay; 25 26 import org.expeditee.io.Conversion; … … 38 39 * When adding an action to a class in the actions folder the following must be 39 40 * considered: 40 * <li> If the first parameter is of type Frame or Item they will be called with 41 * the current frame and the item used to execute the action.</li> 42 * <li> If the second item is also of type Frame or Item it will be set to the 43 * current frame or item.</li> 41 * <li> If the first parameter is of type Frame, the current frame will be 42 * passed as a parameter. 43 * <li> If the next param is of type Item the item on the end of the cursor will 44 * be passed or the item that was clicked to execute the action if nothing is on 45 * the end of the cursor. current frame or item.</li> 44 46 * <li> If there are multiple overloads for the same method they should be 45 47 * declared in order of the methods with the most parameteres to least … … 383 385 * The starting Frame that the JAG is being launched on 384 386 */ 385 private static void LaunchAgent(String name, String parameters, Frame source, Item clicked) { 387 private static void LaunchAgent(String name, String parameters, 388 Frame source, Item clicked) { 386 389 // Use the correct case version for printing error messages 387 390 String nameWithCorrectCase = name; … … 444 447 t.setPriority(Thread.MIN_PRIORITY); 445 448 449 Item itemParam = clicked; 450 if (FreeItems.textAttachedToCursor()) { 451 itemParam = FreeItems.getItemAttachedToCursor(); 452 } 453 446 454 // check for errors during initialisation 447 if (!_Agent.initialise(source, clicked)) {455 if (!_Agent.initialise(source, itemParam)) { 448 456 MessageBay.errorMessage("Error initialising agent: " 449 457 + nameWithCorrectCase); … … 521 529 Class[] paramTypes = method.getParameterTypes(); 522 530 531 int paramCount = paramTypes.length; 523 532 // if the method has no parameters 524 if (param Types.length== 0)533 if (paramCount == 0) 525 534 return new Object[0]; 526 535 527 Object[] objects = new Object[param Types.length];536 Object[] objects = new Object[paramCount]; 528 537 int ind = 0; 529 538 … … 531 540 // or launcher 532 541 // length must be at least one if we are still running 533 if (paramTypes[0] == Frame.class) { 534 objects[0] = source; 535 ind = 1; 536 } else if (Item.class.isAssignableFrom(paramTypes[0])) { 537 objects[0] = launcher; 538 ind = 1; 539 } 540 541 // if the first class was a frame or item, the second class might be the 542 // other 543 if (paramTypes.length > 1 && objects[0] != null) { 544 if (paramTypes[1] == Frame.class) { 545 objects[1] = source; 546 ind = 2; 547 } else if (Item.class.isAssignableFrom(paramTypes[1])) { 548 objects[1] = launcher; 549 ind = 2; 550 } 542 if (paramTypes[ind] == Frame.class) { 543 objects[ind] = source; 544 ind++; 545 } 546 547 if (paramCount > ind && Item.class.isAssignableFrom(paramTypes[ind])) { 548 objects[ind] = launcher; 549 ind++; 551 550 } 552 551 … … 670 669 */ 671 670 public static String getCapitalizedFontName(String fontName) { 672 // Initialize the fonts if they have not already been loaded671 // Initialize the fonts if they have not already been loaded 673 672 initFonts(); 674 673 return _Fonts.get(fontName.toLowerCase()); … … 688 687 } 689 688 } 690 691 public static HashMap<String, String> getFonts() {689 690 public static HashMap<String, String> getFonts() { 692 691 initFonts(); 693 692 return _Fonts;
Note:
See TracChangeset
for help on using the changeset viewer.