Changeset 298
- Timestamp:
- 09/12/08 11:53:22 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 added
- 1 deleted
- 27 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Actions.java
r296 r298 108 108 // This doesnt apply when running directly from the jar 109 109 // because the test classes are not compiled into the jar. 110 if (!url.toString().toLowerCase().contains("test")) { 111 resource = url; 112 break; 113 } 110 // TODO change this so it is only done when running from 111 // Eclipse... if it causes problems again!! 112 // if (!url.toString().toLowerCase().contains("/tests/")) { 113 resource = url; 114 // break; 115 // } 114 116 } 115 117 } catch (Exception e) { … … 388 390 command = command.substring(mname.length()).trim(); 389 391 // If no params are provided get them from a text item on the cursor 390 if (command.length() == 0 && launcher instanceof Text && launcher.isFloating()) { 392 if (command.length() == 0 && launcher instanceof Text 393 && launcher.isFloating()) { 391 394 command = launcher.getText(); 392 395 } -
trunk/src/org/expeditee/actions/IDE.java
r133 r298 14 14 Frame source = DisplayIO.getCurrentFrame(); 15 15 String title = source.getTitleItem().getText(); 16 String[] tokens = title.split(" 16 String[] tokens = title.split("\\s+"); 17 17 String className = tokens[tokens.length - 1]; 18 18 String fileName = "expeditee/src/" + className + ".java"; -
trunk/src/org/expeditee/actions/Simple.java
r291 r298 1382 1382 String frameName = context.getPrimitives().getStringValue( 1383 1383 tokens[1]); 1384 String path = FrameIO.LoadFrame(frameName). path;1384 String path = FrameIO.LoadFrame(frameName).getPath(); 1385 1385 String filePath = FrameIO.getFrameFullPathName(path, 1386 1386 frameName); … … 2000 2000 String framesetName = context.getPrimitives().getStringValue( 2001 2001 tokens[1]); 2002 boolean success = FrameIO. DeleteFrameset(framesetName);2002 boolean success = FrameIO.deleteFrameset(framesetName); 2003 2003 if (!success && _verbose) { 2004 2004 MessageBay.warningMessage("Error deleting " + framesetName); … … 2049 2049 try { 2050 2050 FrameIO.CreateFrameset(freshCopy.getFramesetName(), 2051 frameToCopy. path);2051 frameToCopy.getPath()); 2052 2052 nextNumber = 1; 2053 2053 } catch (Exception e) { -
trunk/src/org/expeditee/agents/CopyTree.java
r133 r298 38 38 // get the last used frame in the destination frameset 39 39 _lastNumber = FrameIO.getLastNumber(_nameTo); 40 Frame one = FrameIO.CreateFrameset(_nameTo, init. path);40 Frame one = FrameIO.CreateFrameset(_nameTo, init.getPath()); 41 41 42 _framePath = one. path;42 _framePath = one.getPath(); 43 43 _lastNumber = -1; 44 44 _firstNumber = 1; … … 104 104 } 105 105 _frameCount++; 106 fresh. path = _framePath;106 fresh.setPath(_framePath); 107 107 FrameIO.ForceSaveFrame(fresh); 108 108 FrameIO.ResumeCache(); -
trunk/src/org/expeditee/agents/SearchAgent.java
r294 r298 65 65 String title = this.getClass().getSimpleName() + " [" + startName 66 66 + "] [" + _pattern + "]"; 67 _results = new FrameCreator(resultsFrameset, null, title, false, true);67 _results = new FrameCreator(resultsFrameset, FrameIO.FRAME_PATH, title, false, true); 68 68 // Set the frame to be displayed after running the agent 69 69 _end = _results.getFirstFrame(); -
trunk/src/org/expeditee/agents/SearchFramesetFast.java
r292 r298 27 27 frame = FrameIO.LoadFrame(_startName + '0'); 28 28 } 29 String path = frame. path;29 String path = frame.getPath(); 30 30 31 31 int count = FrameIO.getLastNumber(_startName); -
trunk/src/org/expeditee/agents/SearchFramesetNoResults.java
r292 r298 25 25 @Override 26 26 protected Frame process(Frame frame) { 27 String path = frame. path;27 String path = frame.getPath(); 28 28 int count = FrameIO.getLastNumber(frame.getFramesetName()); 29 29 for (long i = _firstFrame;i <= _maxFrame && i <= count; i++) { -
trunk/src/org/expeditee/agents/mail/MailSession.java
r292 r298 207 207 } catch (Exception e) { 208 208 e.printStackTrace(); 209 MessageBay.errorMessage("Mail connection unavailable"); 210 finalise(); 211 break; 209 212 } 210 213 } … … 464 467 // Create a frameCreator 465 468 final FrameCreator frames = new FrameCreator(frame 466 .getFramesetName(), frame. path, subject, false, false);469 .getFramesetName(), frame.getPath(), subject, false, false); 467 470 468 471 frames.addText("@date: " + message.getSentDate(), null, -
trunk/src/org/expeditee/gui/AttributeUtils.java
r282 r298 262 262 pJustification)); 263 263 _SetMethods.put("width", Text.class.getMethod("setWidth", pInt)); 264 _SetMethods.put("w", Text.class.getMethod("setWidth", pInt)); 265 264 266 _SetMethods.put("size", Item.class.getMethod("setSize", pFloat)); 265 267 _SetMethods.put("s", Item.class.getMethod("setSize", pFloat)); -
trunk/src/org/expeditee/gui/Browser.java
r290 r298 27 27 import org.expeditee.io.Logger; 28 28 import org.expeditee.items.widgets.WidgetCacheManager; 29 import org.expeditee.network.FrameShare; 29 30 import org.expeditee.stats.StatsLogger; 30 31 import org.expeditee.taskmanagement.EntitySaveManager; … … 393 394 MessageBay 394 395 .displayMessage("Stopping Simple programs..."); // TODO: 395 // Only 396 // stop 397 // if 398 // need 399 // to... 396 /** 397 * Only stop if need to... 398 */ 400 399 while (Simple.isProgramRunning()) { 401 400 Thread.sleep(100); // Brook: What purpose does this … … 419 418 FrameIO.SaveFrame(DisplayIO.getCurrentFrame()); 420 419 421 while (FrameIO.DeleteFrameset("messages")) 420 while (FrameIO.moveFrameset("messages", 421 FrameIO.MESSAGES_PATH)) 422 422 ; 423 423 … … 427 427 if (MailSession.getInstance() != null) { 428 428 if (MailSession.getInstance().finalise()) { 429 MessageBay.displayMessage("Closing ExpMail..."); 429 // TODO display this message before the finalising 430 // is done but only if the mail needs closing 431 MessageBay.displayMessage("Closed ExpMail..."); 430 432 } 433 } 434 435 if (FrameShare.getInstance() != null) { 436 MessageBay.displayMessage("Stopping FrameServer..."); 437 FrameShare.getInstance().finalise(); 431 438 } 432 439 -
trunk/src/org/expeditee/gui/Frame.java
r294 r298 83 83 private Color _foreground = null; 84 84 85 public String path; 85 private String path; 86 87 private boolean _isLocal = true; 86 88 87 89 private boolean _sorted = true; … … 201 203 boolean oldValue = _change; 202 204 205 if (value) { 206 notifyObservers(); 207 } 208 203 209 if (oldValue == value) 204 210 return; … … 207 213 208 214 if (_change) { 209 notifyObservers();210 211 215 setBufferValid(false); 212 216 _saved = false; … … 2048 2052 FrameUtils.Parse(this); 2049 2053 } 2054 2055 public void setPath(String path) { 2056 this.path = path; 2057 } 2058 2059 public String getPath() { 2060 return path; 2061 } 2062 2063 public void setLocal(boolean isLocal) { 2064 this._isLocal = isLocal; 2065 } 2066 2067 public boolean isLocal() { 2068 return _isLocal; 2069 } 2050 2070 } -
trunk/src/org/expeditee/gui/FrameCreator.java
r292 r298 39 39 public FrameCreator(String frameTitle) { 40 40 this(DisplayIO.getCurrentFrame().getFramesetName(), DisplayIO 41 .getCurrentFrame(). path, frameTitle, false, false);41 .getCurrentFrame().getPath(), frameTitle, false, false); 42 42 } 43 43 -
trunk/src/org/expeditee/gui/FrameGraphics.java
r296 r298 61 61 public static void ToggleAudienceMode() { 62 62 Frame current = DisplayIO.getCurrentFrame(); 63 if (_Mode == MODE_AUDIENCE) 63 if (_Mode == MODE_XRAY) { 64 ToggleXRayMode(); 65 } 66 67 if (_Mode == MODE_AUDIENCE) { 64 68 _Mode = MODE_NORMAL; 65 else {69 } else { 66 70 _Mode = MODE_AUDIENCE; 67 71 ItemUtils.UpdateConnectedToAnnotations(current.getItems()); … … 86 90 */ 87 91 public static void ToggleXRayMode() { 88 if (_Mode == MODE_XRAY) 92 if (_Mode == MODE_AUDIENCE) { 93 ToggleAudienceMode(); 94 } 95 96 if (_Mode == MODE_XRAY) { 89 97 setMode(MODE_NORMAL, true); 90 else98 } else { 91 99 setMode(MODE_XRAY, true); 100 } 101 DisplayIO.getCurrentFrame().refreshSize(); 92 102 DisplayIO.UpdateTitle(); 93 103 FrameMouseActions.getInstance().refreshHighlights(); -
trunk/src/org/expeditee/gui/FrameIO.java
r294 r298 28 28 import org.expeditee.items.Permission; 29 29 import org.expeditee.items.Text; 30 import org.expeditee.network.FrameShare; 30 31 import org.expeditee.stats.SessionStats; 31 32 … … 46 47 PUBLIC_PATH = PARENT_FOLDER + "public" + File.separator; 47 48 FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator; 49 MESSAGES_PATH = PARENT_FOLDER + "messages" + File.separator; 48 50 TRASH_PATH = PARENT_FOLDER + "trash" + File.separator; 49 51 IMAGES_PATH = PARENT_FOLDER + IMAGES_FOLDER; … … 66 68 67 69 public static String FRAME_PATH; 68 70 71 public static String MESSAGES_PATH; 72 69 73 public static String PUBLIC_PATH; 70 74 … … 148 152 return LoadFrame(frameName, false); 149 153 } 150 154 151 155 public static Frame LoadFrame(String frameName, boolean ignoreAnnotations) { 152 156 if (!isValidFrameName(frameName)) … … 167 171 } 168 172 169 private static Frame LoadUnknownPath(String framename, boolean ignoreAnnotations) { 173 public static String LoadPublicFrame(String frameName) { 174 assert (isValidFrameName(frameName)); 175 Frame loaded = null; 176 String frameNameLower = frameName.toLowerCase(); 177 // first try reading from cache 178 if (isCacheOn() && _Cache.containsKey(frameNameLower)) { 179 Logger.Log(Logger.SYSTEM, Logger.LOAD, "Loading " + frameName 180 + " from cache."); 181 loaded = _Cache.get(frameNameLower); 182 } else { 183 184 Logger.Log(Logger.SYSTEM, Logger.LOAD, "Loading " + frameName 185 + " from disk."); 186 187 loaded = LoadFrame(PUBLIC_PATH, frameName); 188 } 189 190 String result = null; 191 // Get the contents of the frame to send to someone... 192 // TODO use a more efficient method to directly get the frame contents 193 // if possible 194 if (loaded != null) { 195 result = SaveFrame(loaded); 196 } 197 198 return result; 199 } 200 201 private static Frame LoadUnknownPath(String framename, 202 boolean ignoreAnnotations) { 170 203 Frame loaded = null; 171 204 … … 173 206 loaded = LoadFrame(path, framename); 174 207 if (loaded != null) { 175 FrameUtils.Parse(loaded, true, ignoreAnnotations);176 208 break; 177 209 } 210 } 211 212 if (loaded == null) { 213 loaded = FrameShare.getInstance().loadFrame(framename); 214 } 215 216 if (loaded != null) { 217 FrameUtils.Parse(loaded, true, ignoreAnnotations); 178 218 } 179 219 … … 215 255 * @return null if the frame can not be located. 216 256 */ 217 public static synchronized String getFrameFullPathName(String path, String frameName) { 257 public static synchronized String getFrameFullPathName(String path, 258 String frameName) { 218 259 String source = path + Conversion.getFramesetName(frameName) 219 260 + File.separator; … … 244 285 public static boolean canAccessFrame(String frameName) { 245 286 Frame current = DisplayIO.getCurrentFrame(); 246 // Just incase the current frame is not yet saved...247 if (frameName.equals(current.getName())){248 FrameIO.SaveFrame(current, false,false);287 // Just incase the current frame is not yet saved... 288 if (frameName.equals(current.getName())) { 289 FrameIO.SaveFrame(current, false, false); 249 290 current.change(); 250 291 return true; 251 292 } 252 293 253 294 for (String path : UserSettings.FrameDirs) { 254 295 if (getFrameFullPathName(path, frameName) != null) … … 315 356 } 316 357 317 frame. path = path;358 frame.setPath(path); 318 359 319 360 // do not put 0 frames or virtual frames into the cache … … 388 429 // read the maximum from the INF file 389 430 try { 390 max = ReadINF(current. path, current.getFramesetName());431 max = ReadINF(current.getPath(), current.getFramesetName()); 391 432 } catch (IOException ioe) { 392 433 MessageBay.errorMessage("Error loading INF file for frameset '" … … 453 494 public static Frame LoadZero() { 454 495 Frame current = DisplayIO.getCurrentFrame(); 455 return LoadZero(current.getFramesetName(), current. path);496 return LoadZero(current.getFramesetName(), current.getPath()); 456 497 } 457 498 458 499 public static Frame LoadLast() { 459 500 Frame current = DisplayIO.getCurrentFrame(); 460 return LoadLast(current.getFramesetName(), current. path);501 return LoadLast(current.getFramesetName(), current.getPath()); 461 502 } 462 503 … … 486 527 if (toDelete.getNumber() == 0) { 487 528 throw new SecurityException("Deleting a zero frame is illegal"); 529 } 530 531 // Dont delete the zero frame 532 if (!toDelete.isLocal()) { 533 throw new SecurityException("Attempted to delete remote frame"); 488 534 } 489 535 … … 497 543 try { 498 544 // create the new frameset 499 Frame one = FrameIO.CreateFrameset(DELETED_FRAMES, toDelete.path); 500 framePath = one.path; 545 Frame one = FrameIO.CreateFrameset(DELETED_FRAMES, toDelete 546 .getPath()); 547 framePath = one.getPath(); 501 548 lastNumber = 0; 502 549 } catch (Exception e) { 503 550 Frame zero = FrameIO.LoadFrame(DELETED_FRAMES + "0"); 504 framePath = zero. path;551 framePath = zero.getPath(); 505 552 } 506 553 507 554 // get the fill path to determine which file version it is 508 String source = getFrameFullPathName(toDelete.path, toDelete.getName()); 555 String source = getFrameFullPathName(toDelete.getPath(), toDelete 556 .getName()); 509 557 510 558 String oldFrameName = toDelete.getName().toLowerCase(); … … 512 560 toDelete.setFrameset(DELETED_FRAMES); 513 561 toDelete.setFrameNumber(lastNumber + 1); 514 toDelete. path = framePath;562 toDelete.setPath(framePath); 515 563 ForceSaveFrame(toDelete); 516 564 … … 542 590 * @return The newly created Frame. 543 591 */ 544 public static synchronized Frame CreateFrame(String frameset, String frameTitle,545 String templateFrame) throws RuntimeException {592 public static synchronized Frame CreateFrame(String frameset, 593 String frameTitle, String templateFrame) throws RuntimeException { 546 594 547 595 if (!FrameIO.isValidFramesetName(frameset)) { … … 576 624 // read the next number from the INF file 577 625 try { 578 next = ReadINF(destFramesetZero. path, frameset);626 next = ReadINF(destFramesetZero.getPath(), frameset); 579 627 } catch (IOException ioe) { 580 628 ioe.printStackTrace(); … … 595 643 // update INF file 596 644 try { 597 WriteINF(template. path, frameset, frameset + next);645 WriteINF(template.getPath(), frameset, frameset + next); 598 646 } catch (IOException ioe) { 599 647 ioe.printStackTrace(); … … 739 787 return ""; 740 788 } 741 // Get the full path only to determine which format to use for saving742 // the frame743 // At this stage use Exp format for saving Exp frames only.744 // Later this will be changed so that KMS frames will be updated to the745 // Exp format.746 String fullPath = getFrameFullPathName(toSave.path, toSave.getName());747 789 748 790 // Dont save if the frame is protected and it exists … … 752 794 return ""; 753 795 } 796 797 // Save frame that is not local through the Networking classes 798 // TODO 799 if (!toSave.isLocal()) 800 return ""; 801 802 /** 803 * Get the full path only to determine which format to use for saving 804 * the frame. At this stage use Exp format for saving Exp frames only. 805 * Later this will be changed so that KMS frames will be updated to the 806 * Exp format. 807 */ 808 String fullPath = getFrameFullPathName(toSave.getPath(), toSave 809 .getName()); 754 810 755 811 // Check if the frame exists … … 778 834 // This will make sure links to the original are set correctly 779 835 _Cache.remove(toSave.getName().toLowerCase()); 780 int nextnum = ReadINF(toSave.path, toSave.getFramesetName()) + 1; 836 int nextnum = ReadINF(toSave.getPath(), toSave 837 .getFramesetName()) + 1; 781 838 SuspendCache(); 782 839 Frame original = LoadFrame(toSave.getName()); … … 806 863 original = toSave; 807 864 int orignum = original.getNumber(); 808 int nextnum = ReadINF(toSave.path, toSave.getFramesetName()) + 1; 865 int nextnum = ReadINF(toSave.getPath(), toSave 866 .getFramesetName()) + 1; 809 867 810 868 original.setFrameNumber(nextnum); … … 849 907 850 908 // check that the INF file is not out of date 851 int last = ReadINF(toSave. path, toSave.getFramesetName());909 int last = ReadINF(toSave.getPath(), toSave.getFramesetName()); 852 910 if (last <= toSave.getNumber()) 853 WriteINF(toSave. path, toSave.getFramesetName(), toSave911 WriteINF(toSave.getPath(), toSave.getFramesetName(), toSave 854 912 .getName()); 855 913 … … 953 1011 return _Cache.containsKey(name); 954 1012 } 955 1013 956 1014 /** 957 1015 * Gets a frame from the cache. 958 1016 * 959 1017 * @param name 960 * The frame to get from the cache 961 * 962 * @return 963 * The frame from cache. Null if not cached. 1018 * The frame to get from the cache 1019 * 1020 * @return The frame from cache. Null if not cached. 964 1021 */ 965 1022 public static Frame FrameFromCache(String name) { … … 1027 1084 */ 1028 1085 public static Frame CreateNewFrameset(String name) throws Exception { 1029 String path = DisplayIO.getCurrentFrame(). path;1086 String path = DisplayIO.getCurrentFrame().getPath(); 1030 1087 1031 1088 // if current frameset is profile directory change it to framesets … … 1055 1112 1056 1113 try { 1057 num = ReadINF(zero. path, frameset);1114 num = ReadINF(zero.getPath(), frameset); 1058 1115 } catch (IOException e) { 1059 1116 // TODO Auto-generated catch block … … 1146 1203 base.setFrameNumber(0); 1147 1204 base.setTitle(base.getFramesetName() + "0"); 1148 base. path = path;1205 base.setPath(path); 1149 1206 base.change(); 1150 1207 SaveFrame(base, false); … … 1194 1251 } 1195 1252 1196 public static boolean DeleteFrameset(String framesetName) { 1253 public static boolean deleteFrameset(String framesetName) { 1254 return moveFrameset(framesetName, FrameIO.TRASH_PATH); 1255 } 1256 1257 public static boolean moveFrameset(String framesetName, 1258 String destinationFolder) { 1197 1259 if (!FrameIO.canAccessFrameset(framesetName)) 1198 1260 return false; … … 1203 1265 // Once we have found the directory move it to the trash 1204 1266 if (framesetDirectory.exists()) { 1205 String destPath = FrameIO.TRASH_PATH1267 String destPath = destinationFolder 1206 1268 + framesetName.toLowerCase(); 1207 1269 int copyNumber = 1; -
trunk/src/org/expeditee/gui/FrameMouseActions.java
r287 r298 1603 1603 1604 1604 private void mouseMoved(MouseEvent e, boolean shiftStateChanged) { 1605 FrameKeyboardActions.resetEnclosedItems(); 1605 //System.out.println(_context); 1606 if (_context == CONTEXT_FREESPACE) 1607 FrameKeyboardActions.resetEnclosedItems(); 1606 1608 // System.out.println(e.getX() + "," + e.getY() + " " + e.getWhen()); 1607 1609 if (LastRobotX != null) { … … 1870 1872 Item.HighlightMode.Enclosed); 1871 1873 } 1874 _context = CONTEXT_AT_ENCLOSURE; 1872 1875 } else if (_lastHighlightedItem != null) { 1873 1876 // System.out.println("LastHighlightedItem"); -
trunk/src/org/expeditee/gui/FrameUtils.java
r289 r298 32 32 import org.expeditee.items.widgets.WidgetCorner; 33 33 import org.expeditee.items.widgets.WidgetEdge; 34 import org.expeditee.network. PeerToPeer;34 import org.expeditee.network.FrameShare; 35 35 import org.expeditee.stats.SessionStats; 36 36 import org.jfree.util.ArrayUtilities; … … 583 583 else if (attribute.equals("mailsettings")) 584 584 MailSession.init(item.getChild()); 585 else if (attribute.equals(" peertopeersettings"))586 PeerToPeer.init(item.getChild());585 else if (attribute.equals("networksettings")) 586 FrameShare.init(item.getChild()); 587 587 else if (attribute.equals("reminders")) 588 588 Reminders.init(item.getChild()); -
trunk/src/org/expeditee/gui/MessageBay.java
r292 r298 282 282 if (_creator == null) { 283 283 _creator = new FrameCreator(MESSAGES_FRAMESET_NAME, 284 FrameIO. PROFILE_PATH, MESSAGES_FRAMESET_NAME, true, false);284 FrameIO.MESSAGES_PATH, MESSAGES_FRAMESET_NAME, true, false); 285 285 } 286 286 -
trunk/src/org/expeditee/gui/UserSettings.java
r289 r298 80 80 UserSettings.FrameDirs.add(FrameIO.HELP_PATH); 81 81 UserSettings.ImageDirs.add(FrameIO.IMAGES_PATH); 82 UserSettings.FrameDirs.add(FrameIO.MESSAGES_PATH); 82 83 } 83 84 -
trunk/src/org/expeditee/io/ExpReader.java
r247 r298 60 60 * Any exceptions occured by the BufferedReader. 61 61 */ 62 public Frame readFrame( String fullpath) throws IOException {63 _reader = new BufferedReader(new FileReader(fullpath));62 public Frame readFrame(BufferedReader reader) throws IOException { 63 _reader = reader; 64 64 String next = ""; 65 65 Frame newFrame = new Frame(); -
trunk/src/org/expeditee/io/ExpWriter.java
r198 r298 39 39 40 40 if (_filename == null) 41 _filename = start. path+ name + File.separator41 _filename = start.getPath() + name + File.separator 42 42 + start.getNumber() + ExpReader.EXTENTION; 43 43 -
trunk/src/org/expeditee/io/FrameReader.java
r241 r298 4 4 import java.awt.Font; 5 5 import java.awt.Point; 6 import java.io.BufferedReader; 7 import java.io.FileReader; 6 8 import java.io.IOException; 7 9 import java.lang.reflect.Method; … … 126 128 } 127 129 128 public abstract Frame readFrame(String fullPath) throws IOException; 130 public Frame readFrame(String fullPath) throws IOException { 131 return readFrame(new BufferedReader(new FileReader(fullPath))); 132 } 133 134 public abstract Frame readFrame(BufferedReader frameContents) throws IOException; 129 135 } -
trunk/src/org/expeditee/io/KMSReader.java
r247 r298 151 151 * Any exceptions occured by the BufferedReader. 152 152 */ 153 public Frame readFrame( String fullPath) throws IOException {154 _reader = new BufferedReader(new FileReader(fullPath));153 public Frame readFrame(BufferedReader reader) throws IOException { 154 _reader = reader; 155 155 Frame newFrame = null; 156 156 String next = ""; -
trunk/src/org/expeditee/io/KMSWriter.java
r143 r298 42 42 43 43 if (_filename == null) 44 _filename = start. path+ name + File.separator + name + "."44 _filename = start.getPath() + name + File.separator + name + "." 45 45 + start.getNumber(); 46 46 -
trunk/src/org/expeditee/items/Line.java
r278 r298 86 86 87 87 private void refreshStroke(float thick) { 88 thick = Math.round(thick); 89 88 90 int[] pattern = _start.getLinePattern(); 89 91 if (pattern == null) … … 259 261 super.setLinePattern(pattern); 260 262 261 float thick = getThickness();263 float thick = Math.round(getThickness()); 262 264 263 265 if (thick < 0) -
trunk/src/org/expeditee/items/Text.java
r291 r298 936 936 private static final int NEARBY_GRAVITY = 2; 937 937 938 private static final int MINIMUM_FONT_SIZE = 8;938 private static final int MINIMUM_FONT_SIZE = 6; 939 939 940 940 public void toggleFontFamily() { -
trunk/src/org/expeditee/items/widgets/charts/AbstractChart.java
r279 r298 69 69 // create a chart... 70 70 _chart = createNewChart(); 71 _chart.getPlot().setNoDataMessage("Add link to data frame");71 _chart.getPlot().setNoDataMessage("Add data to chart"); 72 72 _legend = _chart.getLegend(); 73 73 ChartPanel cp = new ChartPanel(_chart); -
trunk/src/org/expeditee/items/widgets/charts/AbstractPie.java
r294 r298 65 65 continue; 66 66 AttributeValuePair avp = new AttributeValuePair(text); 67 if (avp != null ) {67 if (avp != null && avp.hasPair()) { 68 68 try { 69 69 _data.setValue(avp.getAttribute(), avp.getDoubleValue()); -
trunk/src/org/expeditee/network/FrameShare.java
r294 r298 1 1 package org.expeditee.network; 2 2 3 import java.io.BufferedReader; 4 import java.io.IOException; 5 import java.io.StringReader; 6 import java.net.DatagramPacket; 7 import java.net.DatagramSocket; 8 import java.net.UnknownHostException; 3 9 import java.util.HashMap; 4 10 import java.util.Map; … … 7 13 import org.expeditee.gui.Frame; 8 14 import org.expeditee.gui.MessageBay; 15 import org.expeditee.io.ExpReader; 16 import org.expeditee.io.FrameReader; 9 17 import org.expeditee.items.Text; 10 import org.net.p2p.Connection;11 import org.net.p2p.Protocol;12 import org.net.p2p.jnmp2p;13 18 19 public class FrameShare { 14 20 15 public class PeerToPeer { 16 public static boolean _autoConnect = false; 21 private static FrameShare _theSession = null; 17 22 18 private static PeerToPeer _theSession= null;23 private static FrameServer _server = null; 19 24 20 private Map<String, AttributeValuePair> _peers; 21 22 private Map<String, Connection> _peerConnections; 23 24 private Boolean _bConnecting; 25 private Map<String, Peer> _peers; 25 26 26 27 public static void init(Frame settingsFrame) { … … 29 30 30 31 if (_theSession == null) 31 _theSession = new PeerToPeer(settingsFrame);32 _theSession = new FrameShare(settingsFrame); 32 33 } 33 34 private PeerToPeer(Frame settingsFrame) {35 _bConnecting = false;36 34 37 _peers = new HashMap<String, AttributeValuePair>(); 35 private FrameShare(Frame settingsFrame) { 36 _peers = new HashMap<String, Peer>(); 38 37 39 38 // Set the settings 40 39 for (Text item : settingsFrame.getBodyTextItems(false)) { 41 if (item.getText().toLowerCase().trim().equals("autoconnect")) { 42 _autoConnect = true; 40 String text = item.getText().toLowerCase().trim(); 41 AttributeValuePair avp = new AttributeValuePair(item.getText()); 42 43 if (text.equals("server")) { 44 try { 45 if (!avp.hasPair()) { 46 _server = new FrameServer(); 47 } else { 48 _server = new FrameServer("FrameServer", avp 49 .getIntegerValue()); 50 } 51 } catch (Exception e) { 52 e.printStackTrace(); 53 MessageBay.errorMessage("Could not start frame server [" 54 + avp.toString() + "]"); 55 } 43 56 continue; 44 57 } 45 AttributeValuePair avp = new AttributeValuePair(item.getText()); 58 46 59 if (!avp.hasPair()) 47 60 continue; 48 String attributeFullCase = avp.getAttribute(); 49 String attribute = attributeFullCase.toLowerCase(); 50 51 _peers.put(attribute, avp); 61 String attribute = avp.getAttribute().toLowerCase(); 62 63 try { 64 _peers.put(attribute, new Peer(avp)); 65 } catch (UnknownHostException e) { 66 MessageBay.errorMessage("Could not locate peer [" 67 + avp.toString() + "]"); 68 } 52 69 } 53 70 54 55 71 try { 56 if (_ autoConnect) {57 connectThreaded();72 if (_server != null) { 73 _server.start(); 58 74 } 59 75 } catch (Exception e) { … … 61 77 } 62 78 } 79 80 public void finalise() { 81 _server.close(); 82 } 83 84 public static FrameShare getInstance() { 85 return _theSession; 86 } 63 87 64 88 /** 65 * Attempts to connect with peers. 89 * TODO check each peer on a different thread. 90 * 91 * @param frameName 92 * @return 66 93 */ 67 public static void connect() { 68 if (_theSession._bConnecting) { 69 MessageBay.errorMessage("Already connecting to peers"); 70 return; 71 } else if (_theSession != null) { 72 _theSession.connectThreaded(); 94 public Frame loadFrame(String frameName) { 95 byte[] nameBuf = frameName.getBytes(); 96 byte[] buf = new byte[2056]; 97 98 String result = null; 99 String peerName = null; 100 try { 101 // get a datagram socket 102 DatagramSocket socket = new DatagramSocket(); 103 socket.setSoTimeout(1000); 104 105 for (Peer peer : _peers.values()) { 106 try { 107 // send request for a frame 108 DatagramPacket packet = new DatagramPacket(nameBuf, 109 nameBuf.length, peer.getAddress(), peer.getPort()); 110 socket.send(packet); 111 112 // get response 113 packet = new DatagramPacket(buf, buf.length); 114 socket.receive(packet); 115 116 // store frame contents 117 result = new String(packet.getData(), 0, packet.getLength()); 118 peerName = peer.getName(); 119 break; 120 } catch (Exception e) { 121 } 122 } 123 socket.close(); 124 } catch (Exception e) { 125 73 126 } 74 }75 127 76 private void connectThreaded() { 77 Thread t = new ConnectThread(this); 78 t.start(); 79 } 128 // Now read the frame from the file contents 129 FrameReader reader = new ExpReader(frameName); 130 Frame frame = null; 131 try { 132 frame = reader.readFrame(new BufferedReader( 133 new StringReader(result))); 134 // Set the path for the frame to indicate it is NOT a local frame 135 // This allows the frame to be saved in the correct location 136 frame.setLocal(false); 137 frame.setPath(peerName); 138 } catch (IOException e) { 139 e.printStackTrace(); 140 } 80 141 81 public synchronized void connectToPeers() { 82 _bConnecting = true; 83 84 //Connect to peers 85 Protocol p = new Protocol(new Object()); 86 87 jnmp2p jnm = new jnmp2p(p, 3000); 88 89 for(AttributeValuePair avp: _peers.values()){ 90 _peerConnections.put(avp.getAttribute().toLowerCase(), jnm.connect(avp.getValue())); 142 if (frame == null) { 143 MessageBay.errorMessage("Error: " + frameName 144 + " could not be successfully loaded."); 145 return null; 91 146 } 92 93 _bConnecting = false;147 148 return frame; 94 149 } 95 150 }
Note:
See TracChangeset
for help on using the changeset viewer.