- Timestamp:
- 04/04/19 14:41:47 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Debug.java
r1196 r1280 28 28 import javax.swing.JPanel; 29 29 30 import org.expeditee.core.Colour; 30 31 import org.expeditee.gio.swing.SwingGraphicsManager; 31 32 import org.expeditee.gio.swing.SwingInputManager; 32 33 import org.expeditee.gui.DisplayController; 34 import org.expeditee.gui.FrameCreator; 35 import org.expeditee.gui.FrameIO; 33 36 import org.expeditee.gui.MessageBay; 34 37 import org.expeditee.items.Constraint; … … 126 129 MessageBay.displayMessage(DisplayController.getCurrentFrame().getItems().stream().filter(t -> t.getMinWidth() != null).collect(Collectors.toList()).size() + ""); 127 130 } 131 132 public static void FrameCreatorTest() { 133 FrameCreator creator = new FrameCreator("testFrameset", FrameIO.FRAME_PATH, "TestFrameset", FrameCreator.ExistingFramesetOptions.AppendSegregatedFrames, false); 134 creator.addText("Test1", Colour.CYAN, null, null, true); 135 136 creator = new FrameCreator("testFrameset", FrameIO.FRAME_PATH, "TestFrameset", FrameCreator.ExistingFramesetOptions.AppendSegregatedFrames, false); 137 creator.addText("Test2", Colour.CYAN, null, null, true); 138 139 creator = new FrameCreator("testFrameset", FrameIO.FRAME_PATH, "TestFrameset", FrameCreator.ExistingFramesetOptions.OverrideExistingFrames, false); 140 creator.addText("Test3", Colour.CYAN, null, null, true); 141 } 128 142 } -
trunk/src/org/expeditee/agents/SearchAgent.java
r1276 r1280 98 98 + "]"+getResultsTitleSuffix(); 99 99 _results = new FrameCreator(resultsFrameset, FrameIO.FRAME_PATH, title, 100 FrameCreator.ExistingFramesetOptions. CreateNewFramesOnly, true);100 FrameCreator.ExistingFramesetOptions.AppendSegregatedFrames, true); 101 101 // Set the frame to be displayed after running the agent 102 102 _end = _results.getFirstFrame(); -
trunk/src/org/expeditee/agents/mail/MailSession.java
r1276 r1280 527 527 final FrameCreator frames = new FrameCreator(frame 528 528 .getFramesetName(), frame.getPath(), subject, 529 FrameCreator.ExistingFramesetOptions. CreateNewFramesOnly, false);529 FrameCreator.ExistingFramesetOptions.AppendSegregatedFrames, false); 530 530 531 531 frames.addText("@date: " + message.getSentDate(), null, -
trunk/src/org/expeditee/auth/Actions.java
r1279 r1280 97 97 * @throws ParseException 98 98 */ 99 public static void MailMode() throws KeyStoreException, FileNotFoundException, NoSuchAlgorithmException, CertificateException, ClassNotFoundException, SQLException, IOException, ParseException {99 public static void ToggleBay() throws KeyStoreException, FileNotFoundException, NoSuchAlgorithmException, CertificateException, ClassNotFoundException, SQLException, IOException, ParseException { 100 100 if (!DisplayController.isMailMode()) { 101 101 Mail.clear(); -
trunk/src/org/expeditee/auth/gui/MailBay.java
r1276 r1280 93 93 if (_creator == null || currentUser != UserSettings.UserName.get()) { 94 94 currentUser = UserSettings.UserName.get(); 95 _creator = new FrameCreator(EXPEDITEE_MAIL_FRAMESET_NAME, FrameIO.MAIL_PATH, EXPEDITEE_MAIL_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions. ReobtainStateFromExistingFrames, false);95 _creator = new FrameCreator(EXPEDITEE_MAIL_FRAMESET_NAME, FrameIO.MAIL_PATH, EXPEDITEE_MAIL_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.AppendAfterLastItem, false); 96 96 } 97 97 … … 107 107 Mail mail = new Mail(message, message2, options); 108 108 Text t = mail.getPreviewMessage(true); 109 _previewMessages.add(t);110 109 _messages.add(t); 111 110 _creator.addText(timestamp, Colour.BLACK, null, null, false); … … 113 112 _creator.addItem(line.copy(), false); 114 113 } 114 t.setLink(_creator.getCurrentFrame().getName()); 115 _previewMessages.add(t); 115 116 _creator.addSpace(SPACING); 116 117 _creator.save(); -
trunk/src/org/expeditee/gui/FrameCreator.java
r1276 r1280 19 19 package org.expeditee.gui; 20 20 21 import java.io.File; 22 import java.io.IOException; 23 import java.nio.file.Files; 24 import java.nio.file.Path; 25 import java.nio.file.Paths; 21 26 import java.util.LinkedList; 22 27 import java.util.List; 23 28 24 29 import org.expeditee.agents.ExistingFramesetException; 30 import org.expeditee.agents.InvalidFramesetNameException; 25 31 import org.expeditee.core.Colour; 26 32 import org.expeditee.items.Item; … … 28 34 29 35 public class FrameCreator { 30 36 31 37 public static final int INDENT_FROM_TITLE = 20; 32 38 … … 53 59 54 60 private boolean _multiColumn; 55 61 56 62 public enum ExistingFramesetOptions { 57 63 /** 58 * Do not attempt to use any existing frames in specified framesets. 64 * Do not attempt to use any existing frames in specified framesets. 59 65 */ 60 CreateNewFramesOnly,66 AppendSegregatedFrames, 61 67 /** 62 68 * Override any existing frames in specified framesets. … … 64 70 OverrideExistingFrames, 65 71 /** 66 * Use the existing frames in the framesets to reobtain what the state of the FrameCreator should be. 72 * Use the existing frames in the framesets to reobtain what the state of the 73 * FrameCreator should be. 67 74 */ 68 ReobtainStateFromExistingFrames69 } 70 75 AppendAfterLastItem 76 } 77 71 78 private final List<Frame> framesCreated = new LinkedList<Frame>(); 72 79 73 80 public FrameCreator(String frameTitle) { 74 this(DisplayController.getCurrentFrame().getFramesetName(), DisplayController 75 .getCurrentFrame().getPath(), frameTitle, ExistingFramesetOptions.CreateNewFramesOnly, false);76 } 77 81 this(DisplayController.getCurrentFrame().getFramesetName(), DisplayController.getCurrentFrame().getPath(), 82 frameTitle, ExistingFramesetOptions.AppendSegregatedFrames, false); 83 } 84 78 85 public FrameCreator(String framesetName, String path, String frameTitle, ExistingFramesetOptions establishState, boolean multiColumn) { 79 if (establishState == ExistingFramesetOptions.ReobtainStateFromExistingFrames) { 80 initialiseReobtainState(framesetName, path, frameTitle, establishState, multiColumn); 81 } else { 82 initialiseStandard(framesetName, path, frameTitle, establishState, multiColumn); 83 } 84 } 85 86 private void initialiseReobtainState(String framesetName, String path, String frameTitle, ExistingFramesetOptions establishState, boolean multiColumn) { 86 switch (establishState) { 87 case OverrideExistingFrames: 88 try { 89 FrameIO.SuspendCache(); 90 Path framesetDir = Files.createTempDirectory("temporaryExpediteeFrameset"); 91 initialise(framesetName, framesetDir.toAbsolutePath(), frameTitle, multiColumn); 92 FrameIO.EnableCache(); 93 FrameIO.deleteFrameset(framesetName); 94 FrameIO.moveFrameset(framesetName, framesetDir.toAbsolutePath().toString() + File.separator, path); 95 _current.setPath(path); 96 } catch (IOException e) { 97 e.printStackTrace(); 98 } 99 break; 100 case AppendSegregatedFrames: 101 initialise(framesetName, Paths.get(path), frameTitle, multiColumn); 102 break; 103 case AppendAfterLastItem: 104 initialiseReobtainState(framesetName, Paths.get(path), frameTitle, multiColumn); 105 break; 106 } 107 } 108 109 private void initialiseReobtainState(String framesetName, Path path, String frameTitle, boolean multiColumn) { 87 110 _multiColumn = multiColumn; 88 111 _Mnext = createButton("@Next", null, null, 10, 15); 89 112 _Mprev = createButton("@Previous", null, null, _Mnext.getBoundsWidth() + _Mnext.getAnchorRight() + 20, 15); 90 113 _Mfirst = createButton("@First", null, null, _Mprev.getBoundsWidth() + _Mprev.getAnchorRight() + 20, 15); 91 114 92 115 int lastNumber = FrameIO.getLastNumber(framesetName); 93 116 for (int i = 1; i <= lastNumber; i++) { 94 Frame frame = FrameIO.LoadFrame(framesetName + i, path );117 Frame frame = FrameIO.LoadFrame(framesetName + i, path.toAbsolutePath().toString()); 95 118 this.framesCreated.add(frame); 96 119 } 97 120 if (this.framesCreated.isEmpty()) { 98 initialise Standard(framesetName, path, frameTitle, ExistingFramesetOptions.CreateNewFramesOnly, multiColumn);121 initialise(framesetName, path, frameTitle, multiColumn); 99 122 return; 100 123 } 101 124 _firstFrame = this.framesCreated.get(0); 102 125 _current = this.framesCreated.get(this.framesCreated.size() - 1); 126 127 createNextFrame(); 103 128 104 createNextFrame(); 105 } 106 107 private void initialiseStandard(String framesetName, String path, String frameTitle, ExistingFramesetOptions establishState, 108 boolean multiColumn) { 129 Paths.get(_current.getFramePathLogical()); 130 } 131 132 private void initialise(String framesetName, Path path, String frameTitle, boolean multiColumn) { 109 133 _multiColumn = multiColumn; 110 134 _Mnext = createButton("@Next", null, null, 10, 15); 111 112 _Mprev = createButton("@Previous", null, null, _Mnext.getBoundsWidth() 113 + _Mnext.getAnchorRight() + 20, 15); 114 115 _Mfirst = createButton("@First", null, null, _Mprev.getBoundsWidth() 116 + _Mprev.getAnchorRight() + 20, 15); 117 118 Frame toUse = null; 135 _Mprev = createButton("@Previous", null, null, _Mnext.getBoundsWidth() + _Mnext.getAnchorRight() + 20, 15); 136 _Mfirst = createButton("@First", null, null, _Mprev.getBoundsWidth() + _Mprev.getAnchorRight() + 20, 15); 137 119 138 try { 120 toUse = FrameIO.CreateFrameset(framesetName, path, establishState == ExistingFramesetOptions.CreateNewFramesOnly ? false : true); 121 } catch (ExistingFramesetException efe) { 122 // Need a comment here to explain why this catch() clause is empty 123 // (or else it should be throwing an exception) 124 } catch (Exception e) { 139 Frame toUse; 140 if (FrameIO.canAccessFrameset(framesetName, path)) { 141 toUse = FrameIO.CreateFrame(framesetName, frameTitle, null); 142 } else { 143 toUse = FrameIO.CreateFrameset(framesetName, path.toAbsolutePath().toString() + File.separator, true); 144 } 145 146 this.framesCreated.add(toUse); 147 resetGlobals(toUse); 148 _firstFrame = toUse; 149 150 path.toAbsolutePath().resolve(framesetName); 151 } catch (InvalidFramesetNameException e) { 125 152 e.printStackTrace(); 126 } 127 128 if (toUse == null) { 129 toUse = FrameIO.CreateFrame(framesetName, frameTitle, null); 130 this.framesCreated.add(toUse); 131 } 132 133 resetGlobals(toUse); 134 _firstFrame = toUse; 153 } catch (ExistingFramesetException e) { 154 // This should never happen as we are allowing for an override of existing frameset. 155 } 135 156 } 136 157 … … 141 162 * the caption for the button 142 163 * @param x 143 * the x position for the button. Null if the button is anchored 144 * t o the right of the screen.164 * the x position for the button. Null if the button is anchored to 165 * the right of the screen. 145 166 * @param y 146 * the y position for the button. Null if the button is anchored 147 * t o the bottom of the screen.167 * the y position for the button. Null if the button is anchored to 168 * the bottom of the screen. 148 169 * @param right 149 * the distance the button is anchored from the right of this 150 * screen.Null if an absolute position is used.170 * the distance the button is anchored from the right of this screen. 171 * Null if an absolute position is used. 151 172 * @param bottom 152 * the distance the button is to be anchored from the bottom of 153 * thescreen. Null if the button is given an absolute position.173 * the distance the button is to be anchored from the bottom of the 174 * screen. Null if the button is given an absolute position. 154 175 * @return the newly created button. 155 176 */ 156 public static Item createButton(String text, Integer x, Integer y, Integer right, 157 Integer bottom) { 177 public static Item createButton(String text, Integer x, Integer y, Integer right, Integer bottom) { 158 178 Text button = new Text(text); 159 179 … … 180 200 181 201 /** 182 * Creates the next frame in the frameset, with a previous button already 183 * a dded and linked to the last frame. _current then gets updated to point184 * at thenewly created Frame, and _lastY is reset202 * Creates the next frame in the frameset, with a previous button already added 203 * and linked to the last frame. _current then gets updated to point at the 204 * newly created Frame, and _lastY is reset 185 205 */ 186 206 public boolean createNextFrame() { 187 207 try { 188 Frame newFrame = FrameIO.CreateFrame(_current.getFramesetName(), 189 _current.getTitle(), null); 208 Frame newFrame = FrameIO.CreateFrame(_current.getFramesetName(), _current.getTitle(), null); 190 209 191 210 this.framesCreated.add(newFrame); 192 211 193 212 // add link to previous frame 194 213 // _prev = … … 211 230 } 212 231 } 213 232 214 233 public List<Frame> getFramesCreated() { 215 234 return this.framesCreated; 216 235 } 217 236 218 private void resetGlobals(Frame toUse) 219 { 237 private void resetGlobals(Frame toUse) { 220 238 Text title = toUse.getTitleItem(); 221 239 START_X = INDENT_FROM_TITLE + title.getX(); … … 227 245 if (it instanceof Text) { 228 246 Text t = (Text) it; 229 if (t.getText().toLowerCase().equals("@start") 230 || t.getText().toLowerCase().startsWith("@start:")) { 247 if (t.getText().toLowerCase().equals("@start") || t.getText().toLowerCase().startsWith("@start:")) { 231 248 t.stripFirstWord(); 232 249 … … 253 270 // if there is no more room on the X axis, we have to start a 254 271 // new frame 255 if (!_multiColumn 256 || toAdd.getBoundsWidth() + _lastX > DisplayController.getFramePaintAreaWidth()) { 272 if (!_multiColumn || toAdd.getBoundsWidth() + _lastX > DisplayController.getFramePaintAreaWidth()) { 257 273 // Make sure text items that are created on the current 258 274 // frame are removed … … 281 297 } 282 298 283 public Text addText(String toAdd, Colour c, String link, String action, 284 boolean bSave) { 299 public Text addText(String toAdd, Colour c, String link, String action, boolean bSave) { 285 300 Text text = _current.createNewText(toAdd); 286 301 if (c != null) … … 297 312 FrameIO.ForceSaveFrame(_current); 298 313 } 299 314 300 315 public int getLastY() { 301 316 return _lastY; 302 317 } 303 318 304 319 public void setLastY(int lastY) { 305 320 _lastY = lastY; 306 321 } 307 322 308 323 public Frame getCurrentFrame() { 309 324 return _current; … … 345 360 previousButton.setLinkHistory(false); 346 361 previousButton.setLinkMark(false); 347 // previousButton.setPermission(new PermissionPair(UserAppliedPermission.followLinks)); 362 // previousButton.setPermission(new 363 // PermissionPair(UserAppliedPermission.followLinks)); 348 364 current.addItem(previousButton); 349 365 -
trunk/src/org/expeditee/gui/FrameIO.java
r1277 r1280 1579 1579 * @return 1580 1580 */ 1581 public static Boolean canAccessFrameset(String framesetName) {1581 public static boolean canAccessFrameset(String framesetName) { 1582 1582 framesetName = framesetName.toLowerCase(); 1583 1583 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1584 if ( (new File(path + framesetName)).exists()) {1584 if (canAccessFrameset(framesetName, Paths.get(path))) { 1585 1585 return true; 1586 1586 } 1587 1587 } 1588 1588 return false; 1589 } 1590 1591 public static boolean canAccessFrameset(String framesetName, Path path) { 1592 File framesetDir = path.resolve(framesetName).toFile(); 1593 if (framesetDir.exists() && framesetDir.isDirectory()) { 1594 return true; 1595 } else { 1596 return false; 1597 } 1589 1598 } 1590 1599 … … 1723 1732 // Search all the available directories for the directory 1724 1733 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1725 String source = path + framesetName.toLowerCase() + File.separator; 1726 File framesetDirectory = new File(source); 1727 // Once we have found the directory move it 1728 if (framesetDirectory.exists()) { 1729 String destPath = destinationFolder 1730 + framesetName.toLowerCase(); 1731 int copyNumber = 1; 1732 File dest = new File(destPath + File.separator); 1733 // Create the destination folder if it doesnt already exist 1734 if (!dest.getParentFile().exists()) { 1735 dest.mkdirs(); 1734 return moveFrameset(framesetName, path, destinationFolder); 1735 } 1736 return false; 1737 } 1738 1739 public static boolean moveFrameset(String framesetName, String path, String destinationFolder) { 1740 String source = path + framesetName.toLowerCase() + File.separator; 1741 File framesetDirectory = new File(source); 1742 // Once we have found the directory move it 1743 if (framesetDirectory.exists()) { 1744 String destPath = destinationFolder 1745 + framesetName.toLowerCase(); 1746 int copyNumber = 1; 1747 File dest = new File(destPath + File.separator); 1748 // Create the destination folder if it doesnt already exist 1749 if (!dest.getParentFile().exists()) { 1750 dest.mkdirs(); 1751 } 1752 // If a frameset with the same name is already in the 1753 // destination add 1754 // a number to the end 1755 while (dest.exists()) { 1756 dest = new File(destPath + ++copyNumber + File.separator); 1757 } 1758 try { 1759 copyFileTree(framesetDirectory.toPath(), dest.toPath()); 1760 } catch (IOException e) { 1761 e.printStackTrace(); 1762 return false; 1763 } 1764 1765 for (File f : framesetDirectory.listFiles()) { 1766 if (!f.delete()) { 1767 return false; 1736 1768 } 1737 // If a frameset with the same name is already in the 1738 // destination add 1739 // a number to the end 1740 while (dest.exists()) { 1741 dest = new File(destPath + ++copyNumber + File.separator); 1742 } 1743 if (!framesetDirectory.renameTo(dest)) { 1744 for (File f : framesetDirectory.listFiles()) { 1745 if (!f.delete()) { 1746 return false; 1747 } 1748 } 1749 if (!framesetDirectory.delete()) { 1750 return false; 1751 } 1752 } 1753 return true; 1754 } 1755 } 1756 return false; 1769 } 1770 if (!framesetDirectory.delete()) { 1771 return false; 1772 } 1773 return true; 1774 } else { 1775 return false; 1776 } 1757 1777 } 1758 1778 -
trunk/src/org/expeditee/settings/Settings.java
r1276 r1280 230 230 private static void generateSettingsTree(String page, Text text) { 231 231 Frame parent = text.getParentOrCurrentFrame(); 232 FrameCreator frames = new FrameCreator(parent.getFramesetName(), parent.getPath(), page, FrameCreator.ExistingFramesetOptions. CreateNewFramesOnly, false);232 FrameCreator frames = new FrameCreator(parent.getFramesetName(), parent.getPath(), page, FrameCreator.ExistingFramesetOptions.AppendSegregatedFrames, false); 233 233 text.setLink(frames.getName()); 234 234
Note:
See TracChangeset
for help on using the changeset viewer.