Changeset 1276 for trunk


Ignore:
Timestamp:
04/02/19 15:19:35 (5 years ago)
Author:
bln4
Message:

FrameCreator now has the option to extend an existing frameset rather than overwrite or ignore the previous frameset content. A boolean variable to the FrameCreator constructor has changed to a Enum with three options to facilitate this.

The MailBay uses this new FrameCreator functionality.

In the near future, 'extend' option will be updated to more precisely reobtain the exact state of the FrameCreator when last used (IE, what the FrameCreator thinks its Y position is).

Location:
trunk/src/org/expeditee
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/SearchAgent.java

    r1102 r1276  
    9898                                + "]"+getResultsTitleSuffix();
    9999                _results = new FrameCreator(resultsFrameset, FrameIO.FRAME_PATH, title,
    100                                 false, true);
     100                                FrameCreator.ExistingFramesetOptions.CreateNewFramesOnly, true);
    101101                // Set the frame to be displayed after running the agent
    102102                _end = _results.getFirstFrame();
  • trunk/src/org/expeditee/agents/mail/MailSession.java

    r1142 r1276  
    527527                                        final FrameCreator frames = new FrameCreator(frame
    528528                                                        .getFramesetName(), frame.getPath(), subject,
    529                                                         false, false);
     529                                                        FrameCreator.ExistingFramesetOptions.CreateNewFramesOnly, false);
    530530
    531531                                        frames.addText("@date: " + message.getSentDate(), null,
  • trunk/src/org/expeditee/auth/gui/MailBay.java

    r1275 r1276  
    11package org.expeditee.auth.gui;
    22
    3 import java.io.File;
    43import java.util.LinkedList;
    54import java.util.List;
     
    2322
    2423public class MailBay {
    25         public static final String EXPEDITEE_MAIL_FRAMESET_NAME = "ExpediteeMail";
     24        public static final String EXPEDITEE_MAIL_FRAMESET_NAME = "expediteemail";
    2625
    2726        /** The y position of the header to the mail bay. */
     
    3534        private static final int OFFSET_X = 20;
    3635
    37 
    3836        /** Buffer image of the mail window. */
    3937        private static Image _mailBuffer;
     
    9593                if (_creator == null || currentUser != UserSettings.UserName.get()) {
    9694                        currentUser = UserSettings.UserName.get();
    97                         _creator = new FrameCreator(EXPEDITEE_MAIL_FRAMESET_NAME, FrameIO.MAIL_PATH, EXPEDITEE_MAIL_FRAMESET_NAME, true, false);
    98                         _creator.setTitle("Expeditee Mail");
     95                        _creator = new FrameCreator(EXPEDITEE_MAIL_FRAMESET_NAME, FrameIO.MAIL_PATH, EXPEDITEE_MAIL_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.ReobtainStateFromExistingFrames, false);
    9996                }
    10097                               
  • trunk/src/org/expeditee/gui/FrameCreator.java

    r1258 r1276  
    5050        private Item _Mfirst;
    5151
    52         // Next and previous links for the current frame
    53         // private Item _next;
    54 
    55         // private Item _prev;
    56 
    5752        private Frame _firstFrame;
    5853
    5954        private boolean _multiColumn;
     55       
     56        public enum ExistingFramesetOptions {
     57                /**
     58                 * Do not attempt to use any existing frames in specified framesets.
     59                 */
     60                CreateNewFramesOnly,
     61                /**
     62                 * Override any existing frames in specified framesets.
     63                 */
     64                OverrideExistingFrames,
     65                /**
     66                 * Use the existing frames in the framesets to reobtain what the state of the FrameCreator should be.
     67                 */
     68                ReobtainStateFromExistingFrames
     69        }
    6070       
    6171        private final List<Frame> framesCreated = new LinkedList<Frame>();
     
    6373        public FrameCreator(String frameTitle) {
    6474                this(DisplayController.getCurrentFrame().getFramesetName(), DisplayController
    65                                 .getCurrentFrame().getPath(), frameTitle, false, false);
     75                                .getCurrentFrame().getPath(), frameTitle, ExistingFramesetOptions.CreateNewFramesOnly, false);
     76        }
     77       
     78        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) {
     87                _multiColumn = multiColumn;
     88                _Mnext = createButton("@Next", null, null, 10, 15);
     89                _Mprev = createButton("@Previous", null, null, _Mnext.getBoundsWidth() + _Mnext.getAnchorRight() + 20, 15);
     90                _Mfirst = createButton("@First", null, null, _Mprev.getBoundsWidth() + _Mprev.getAnchorRight() + 20, 15);
     91               
     92                int lastNumber = FrameIO.getLastNumber(framesetName);
     93                for (int i = 1; i <= lastNumber; i++) {
     94                        Frame frame = FrameIO.LoadFrame(framesetName + i, path);
     95                        this.framesCreated.add(frame);
     96                }
     97                if (this.framesCreated.isEmpty()) {
     98                        initialiseStandard(framesetName, path, frameTitle, ExistingFramesetOptions.CreateNewFramesOnly, multiColumn);
     99                        return;
     100                }
     101                _firstFrame = this.framesCreated.get(0);
     102                _current = this.framesCreated.get(this.framesCreated.size() - 1);
     103               
     104                createNextFrame();
     105        }
     106
     107        private void initialiseStandard(String framesetName, String path, String frameTitle, ExistingFramesetOptions establishState,
     108                        boolean multiColumn) {
     109                _multiColumn = multiColumn;
     110                _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;
     119                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) {
     125                        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;
    66135        }
    67136
     
    106175        }
    107176
    108         public FrameCreator(String name, String path, String frameTitle, boolean recreate, boolean multiColumn)
    109         {
    110                 _multiColumn = multiColumn;
    111                 _Mnext = createButton("@Next", null, null, 10, 15);
    112 
    113                 _Mprev = createButton("@Previous", null, null, _Mnext.getBoundsWidth()
    114                                 + _Mnext.getAnchorRight() + 20, 15);
    115 
    116                 _Mfirst = createButton("@First", null, null, _Mprev.getBoundsWidth()
    117                                 + _Mprev.getAnchorRight() + 20, 15);
    118 
    119                 Frame toUse = null;
    120                 try {
    121                         toUse = FrameIO.CreateFrameset(name, path, recreate);
    122                 } catch (ExistingFramesetException efe) {
    123                         // Need a comment here to explain why this catch() clause is empty
    124                         // (or else it should be throwing an exception)
    125                 } catch (Exception e) {
    126                         e.printStackTrace();
    127                 }
    128 
    129                 if (toUse == null) {
    130                         toUse = FrameIO.CreateFrame(name, frameTitle, null);
    131                         this.framesCreated.add(toUse);
    132                 }
    133 
    134                 resetGlobals(toUse);
    135                 _firstFrame = toUse;
    136 
    137                 // set positions of next\prev frame links
    138                 // _Mnext.setPosition(FrameGraphics.getMaxSize().width - 100,
    139                 // FrameGraphics.getMaxSize().height - 15);
    140                 // _Mprev.setPosition(50, FrameGraphics.getMaxSize().height - 15);
    141         }
    142 
    143177        public String getName() {
    144178                return _firstFrame.getName();
  • trunk/src/org/expeditee/gui/MessageBay.java

    r1258 r1276  
    258258
    259259                if (_creator == null) {
    260                         _creator = new FrameCreator(MESSAGES_FRAMESET_NAME, FrameIO.MESSAGES_PATH, MESSAGES_FRAMESET_NAME, true,
     260                        _creator = new FrameCreator(MESSAGES_FRAMESET_NAME, FrameIO.MESSAGES_PATH, MESSAGES_FRAMESET_NAME, FrameCreator.ExistingFramesetOptions.OverrideExistingFrames,
    261261                                        false);
    262262                }
  • trunk/src/org/expeditee/settings/Settings.java

    r1269 r1276  
    230230        private static void generateSettingsTree(String page, Text text) {
    231231                Frame parent = text.getParentOrCurrentFrame();
    232                 FrameCreator frames = new FrameCreator(parent.getFramesetName(), parent.getPath(), page, false, false);
     232                FrameCreator frames = new FrameCreator(parent.getFramesetName(), parent.getPath(), page, FrameCreator.ExistingFramesetOptions.CreateNewFramesOnly, false);
    233233                text.setLink(frames.getName());
    234234               
Note: See TracChangeset for help on using the changeset viewer.