Ignore:
Timestamp:
08/22/08 10:54:44 (16 years ago)
Author:
ra33
Message:

Added more import and mail stuff... including text importer

Location:
trunk/src/org/expeditee/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/MailActions.java

    r242 r247  
    11package org.expeditee.actions;
    22
     3import javax.mail.Flags.Flag;
     4
    35import org.expeditee.agents.mail.MailSession;
     6import org.expeditee.gui.DisplayIO;
     7import org.expeditee.gui.FrameMouseActions;
    48
    59public class MailActions {
     
    1418         * Gets any unread mail and attaches it to the cursor for now
    1519         */
    16         public static String getMail() {
    17                 return MailSession.getInstance().getMail();
     20        public static String getAllMailString() {
     21                String allMail = MailSession.getInstance().getMailString(null, null);
     22                if (allMail.length() == 0) {
     23                        return "Mailbox empty";
     24                }
     25                return allMail;
     26        }
     27
     28        public static String getNewMailString() {
     29                String mail = MailSession.getInstance().getMailString(Flag.RECENT, true);
     30                if (mail.length() == 0) {
     31                        return "No new mail";
     32                }
     33                return mail;
     34        }
     35
     36        public static String getUnreadMailString() {
     37                String mail = MailSession.getInstance().getMailString(Flag.SEEN, false);
     38                if (mail.length() == 0) {
     39                        return "No unread mail";
     40                }
     41                return mail;
     42        }
     43       
     44        public static void getUnreadMail() {
     45                MailSession.getInstance().getMail(Flag.SEEN, false, DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
     46        }
     47       
     48        public static void getAllMail() {
     49                MailSession.getInstance().getMail(null, null, DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
     50        }
     51       
     52        public static void getNewMail() {
     53                MailSession.getInstance().getMail(Flag.RECENT, true, DisplayIO.getCurrentFrame(), FrameMouseActions.getPosition());
     54        }
     55
     56        public static String getUnreadMailCount() {
     57                try {
     58                        int count = MailSession.getInstance().getFolder()
     59                                        .getUnreadMessageCount();
     60                        return count + " unread message" + (count == 1 ? "" : "s");
     61                } catch (Exception e) {
     62                        return "Mail Error";
     63                }
     64        }
     65
     66        public static String getAllMailCount() {
     67                try {
     68                        int count = MailSession.getInstance().getFolder().getMessageCount();
     69                        return count + " message" + (count == 1 ? "" : "s");
     70                } catch (Exception e) {
     71                        return "Mail Error";
     72                }
     73        }
     74
     75        public static String getNewMailCount() {
     76                try {
     77                        int count = MailSession.getInstance().getFolder()
     78                                        .getNewMessageCount();
     79                        return count + " new messages" + (count == 1 ? "" : "s");
     80                } catch (Exception e) {
     81                        return "Mail Error";
     82                }
    1883        }
    1984
  • trunk/src/org/expeditee/actions/Misc.java

    r242 r247  
    2424import org.expeditee.gui.TimeKeeper;
    2525import org.expeditee.importer.FrameDNDTransferHandler;
     26import org.expeditee.items.Dot;
    2627import org.expeditee.items.Item;
    2728import org.expeditee.items.ItemUtils;
     29import org.expeditee.items.Line;
    2830import org.expeditee.items.Text;
    2931import org.expeditee.math.ExpediteeJEP;
     
    757759        }
    758760
    759         public static void importFile(Item item) {
     761        public static void importFiles(Item item) {
    760762                List<File> files = new LinkedList<File>();
    761763                for (String s : item.getText().split("\n")) {
    762764                        File file = new File(s);
    763                         if(file.exists()){
     765                        if (file.exists()) {
    764766                                files.add(file);
    765767                        }
     
    771773                }
    772774        }
    773        
    774         public static void importFiles(Item item) {
    775                 importFile(item);
     775
     776        public static void importFile(Item item) {
     777                File file = new File(item.getText());
     778                if (file.exists()) {
     779                        try {
     780                                FrameDNDTransferHandler.getInstance().importFile(file,
     781                                                FrameMouseActions.getPosition());
     782                        } catch (Exception e) {
     783                                e.printStackTrace();
     784                        }
     785                }
     786        }
     787
     788        public static void createShape(Item item, int sides) {
     789                if (sides < 3) {
     790                        MessageBay.errorMessage("Shapes must have at least 3 sides");
     791                }
     792                double angle = ((sides - 2) * 180.0F) / sides;
     793                double curAngle = 0;
     794                double size = 50F;
     795                if (item instanceof Dot && item.getLines().size() > 0) {
     796                        item = item.getLines().get(0);
     797                }
     798                // Use line length to determine the size of the shape
     799                if (item instanceof Line) {
     800                        size = ((Line) item).getLength();
     801                }
     802
     803                float curX = FrameMouseActions.MouseX;
     804                float curY = FrameMouseActions.MouseY;
     805
     806                Collection<Item> newItems = new LinkedList<Item>();
     807                Item[] d = new Item[sides];
     808                // create dots
     809                Frame current = DisplayIO.getCurrentFrame();
     810                for (int i = 0; i < d.length; i++) {
     811                        d[i] = current.createDot();
     812                        newItems.add(d[i]);
     813                        d[i].setPosition(curX, curY);
     814                        curX += (float) (Math.cos((curAngle) * Math.PI / 180.0) * size);
     815                        curY += (float) (Math.sin((curAngle) * Math.PI / 180.0) * size);
     816
     817                        curAngle += angle;
     818                }
     819                // create lines
     820                for (int i = 1; i < d.length; i++) {
     821                        newItems.add(new Line(d[i - 1], d[i], current.getNextItemID()));
     822                }
     823                newItems.add(new Line(d[d.length - 1], d[0], current.getNextItemID()));
     824
     825                current.addAllItems(newItems);
     826                d[0].setThickness(item.getThickness());
     827                d[0].setFillColor(item.getFillColor());
     828                d[0].setColor(item.getColor());
     829
     830                ItemUtils.EnclosedCheck(newItems);
     831                FrameGraphics.refresh(false);
    776832        }
    777833}
Note: See TracChangeset for help on using the changeset viewer.