Changeset 305 for trunk/src/org/expeditee/actions
- Timestamp:
- 09/12/08 17:19:37 (16 years ago)
- Location:
- trunk/src/org/expeditee/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r298 r305 257 257 258 258 /** 259 * Temporary, if a plugin system is devised then this would porbably become redundant.260 * For now this allows external agents to be included.261 * 259 * Temporary, if a plugin system is devised then this would porbably become 260 * redundant. For now this allows external agents to be included. 261 * 262 262 * @param fullClassNames 263 * A set of full class names, that is, the class package and name. For example" 264 * "org.myplugin.agents.SerializedSearch" 265 * 266 * @return 267 * A collection of classes their were omitted because either there was a name clash 268 * with existing agents or did not exist. 269 * i.e. is completely successful this will be empty. Never null. 263 * A set of full class names, that is, the class package and 264 * name. For example" "org.myplugin.agents.SerializedSearch" 265 * 266 * @return A collection of classes their were omitted because either there 267 * was a name clash with existing agents or did not exist. i.e. is 268 * completely successful this will be empty. Never null. 270 269 * 271 270 * @throws NullPointerException 272 * 273 * 271 * If fullClassNames is null. 272 * 274 273 */ 275 274 public static Collection<String> addAgents(Set<String> fullClassNames) { 276 if (fullClassNames == null) throw new NullPointerException("fullClassNames"); 277 275 if (fullClassNames == null) 276 throw new NullPointerException("fullClassNames"); 277 278 278 List<String> omittedAgents = new LinkedList<String>(); 279 279 280 280 for (String fullName : fullClassNames) { 281 282 if (fullName == null || fullName.length() == 0) continue; 283 281 282 if (fullName == null || fullName.length() == 0) 283 continue; 284 284 285 boolean didAdd = false; 285 286 286 287 try { 287 288 // Does the class even exist? 288 289 Class c = Class.forName(fullName); 289 290 290 291 String name = c.getSimpleName().toLowerCase(); 291 292 292 293 if (!_JAGs.containsKey(name)) { 293 294 294 295 _JAGs.put(name, fullName); 295 296 didAdd = true; 296 297 297 298 } 298 299 … … 300 301 e.printStackTrace(); 301 302 } 302 303 if (!didAdd) omittedAgents.add(fullName);304 305 } 306 307 303 304 if (!didAdd) 305 omittedAgents.add(fullName); 306 307 } 308 308 309 return omittedAgents; 309 310 } 310 311 311 312 /** 312 313 * Loads all the Methods that meet the requirements checked by MethodCheck … … 470 471 String nameWithCorrectCase = name; 471 472 name = name.toLowerCase(); 472 473 473 474 String fullClassName = AGENTS_PACKAGE + name; 474 475 … … 481 482 + " " + parameters; 482 483 fullClassName = AGENTS_PACKAGE + "writetree"; 483 484 484 485 } else if (name.endsWith("frame")) { 485 486 parameters = name … … 552 553 // create the JAG 553 554 Agent toLaunch = (Agent) con.newInstance(params); 554 555 555 556 LaunchAgent(toLaunch, source, clicked); 556 557 … … 559 560 throw new RuntimeException(nameWithCorrectCase 560 561 + "' is not an action or agent."); 561 } 562 } 563 562 } 563 } 564 564 565 /** 565 566 * Launches an agent from a aleady instantiated object. 566 567 * 567 568 * @param agent 568 * 569 * The agent to launch. Must not be null. 569 570 * 570 571 * @param source 571 * 572 * The calling frame that launched it. Must not be null. 572 573 * 573 574 * @param itemParam 574 * The item paremeter for the agent. Must not be null.575 * The item paremeter for the agent. 575 576 * 576 577 * @throws NullPointerException 577 * if any of the arguments are null. 578 */ 579 public static void LaunchAgent( 580 Agent agent, 581 Frame source, 582 Item itemParam) { 583 584 if (agent == null) throw new NullPointerException("agent"); 585 if (source == null) throw new NullPointerException("source"); 586 if (itemParam == null) throw new NullPointerException("itemParam"); 587 578 * if any of the arguments are null. 579 */ 580 public static void LaunchAgent(Agent agent, Frame source, Item itemParam) { 581 582 if (agent == null) 583 throw new NullPointerException("agent"); 584 if (source == null) 585 throw new NullPointerException("source"); 586 // if (itemParam == null) throw new NullPointerException("itemParam"); 587 588 588 String nameWithCorrectCase = agent.getClass().getSimpleName(); 589 589 590 590 try { 591 592 591 593 592 // create the JAG 594 593 _Agent = agent; 595 594 596 595 Thread t = new Thread(_Agent); 597 596 t.setPriority(Thread.MIN_PRIORITY); … … 600 599 itemParam = FreeItems.getItemAttachedToCursor(); 601 600 } 602 601 603 602 // check for errors during initialisation 604 603 if (!_Agent.initialise(source, itemParam)) { … … 607 606 + nameWithCorrectCase); 608 607 } 609 608 610 609 // save the current frame (if necesssary) 611 610 // TODO make this nicer... ie. make Format an action rather than an 612 611 // agent and save frames only before running agents 613 if (!nameWithCorrectCase.equalsIgnoreCase("format") && !nameWithCorrectCase.equalsIgnoreCase("sort")) { 612 if (!nameWithCorrectCase.equalsIgnoreCase("format") 613 && !nameWithCorrectCase.equalsIgnoreCase("sort")) { 614 614 FrameUtils.LeavingFrame(source); 615 615 } 616 616 617 617 if (_Agent.hasResultString()) { 618 618 // Just run the agent on this thread... dont run it in the -
trunk/src/org/expeditee/actions/MailActions.java
r284 r305 6 6 7 7 import org.expeditee.agents.mail.MailSession; 8 import org.expeditee.gui.AttributeValuePair; 8 9 import org.expeditee.gui.DisplayIO; 9 10 import org.expeditee.gui.Frame; … … 48 49 return mail; 49 50 } 50 51 51 52 public static Collection<Text> getRecentMail(int number) { 52 53 return getMail(null, null, number); 53 54 } 54 55 56 public static Collection<Text> getUnreadMail(Item clicked, int number) { 57 if (clicked instanceof Text) { 58 AttributeValuePair avp = new AttributeValuePair(clicked 59 .getText()); 60 if (avp.hasPair() && avp.getValue().contains(MailSession.UNREAD_MESSAGE)) { 61 avp.setValue("0" + MailSession.UNREAD_MESSAGE + "s"); 62 clicked.setText(avp.toString()); 63 clicked.setActions(null); 64 } 65 } 66 67 return getMail(Flag.SEEN, false, number); 68 } 69 55 70 public static Collection<Text> getUnreadMail() { 56 71 return getMail(Flag.SEEN, false, Integer.MAX_VALUE); … … 60 75 return getMail(null, null, Integer.MAX_VALUE); 61 76 } 62 77 78 public static Text getMail(int messageNo) { 79 Text mailItem = MailSession.getInstance().getMail( 80 DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition(), 81 messageNo - 1); 82 // MessageBay.displayMessage(mailItems.size() + " messages read", 83 // Color.green); 84 85 return mailItem; 86 } 87 63 88 public static Collection<Text> getMail() { 64 89 return getAllMail(); … … 68 93 return getMail(Flag.RECENT, true, Integer.MAX_VALUE); 69 94 } 70 71 private static Collection<Text> getMail(Flag flag, Boolean isPresent, int noOfMessages){ 72 Collection<Text> mailItems = MailSession.getInstance().getMail(flag, isPresent, 73 DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition(), noOfMessages); 74 //MessageBay.displayMessage(mailItems.size() + " messages read", Color.green); 75 95 96 private static Collection<Text> getMail(Flag flag, Boolean isPresent, 97 int noOfMessages) { 98 Collection<Text> mailItems = MailSession.getInstance().getMail(flag, 99 isPresent, DisplayIO.getCurrentFrame(), 100 FrameMouseActions.getPosition(), noOfMessages); 101 // MessageBay.displayMessage(mailItems.size() + " messages read", 102 // Color.green); 103 76 104 return mailItems; 77 105 } … … 95 123 } 96 124 } 97 125 98 126 public static String getMailCount() { 99 127 return getAllMailCount(); … … 121 149 Frame replyFrame = DisplayIO.getCurrentFrame(); 122 150 String titleText = frame.getTitle(); 123 // Add Re on the end if it is not already there151 // Add Re on the end if it is not already there 124 152 if (titleText.length() >= 3 125 153 && !"re:".equals(titleText.substring(0, 3).toLowerCase())) { … … 128 156 replyFrame.setTitle(titleText); 129 157 FrameKeyboardActions.Drop(null, false); 130 131 // Add a link to the original message158 159 // Add a link to the original message 132 160 Text original = replyFrame.createNewText("@original"); 133 161 original.setPosition(FrameMouseActions.getPosition()); … … 139 167 to.addAction("MailTree"); 140 168 FrameKeyboardActions.Drop(to, false); 141 DisplayIO.setCursorPosition(FrameMouseActions.MouseX, FrameMouseActions.MouseY + 15); 169 DisplayIO.setCursorPosition(FrameMouseActions.MouseX, 170 FrameMouseActions.MouseY + 15); 142 171 } 143 172
Note:
See TracChangeset
for help on using the changeset viewer.