Changeset 686


Ignore:
Timestamp:
01/13/14 11:07:18 (10 years ago)
Author:
jts21
Message:

Add status message for widgets. Cannot simply handle widgets as different widgets behave differently (i.e. some such as MemoryMonitor act like an expeditee item (allowing picking up, copying, deleting), while others such as JfxBrowser don't implement expeditee style events). Therefore we instead simply print out the name of the widget and a message explaining that widgets have different behaviour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Help.java

    r685 r686  
    11package org.expeditee.gui;
     2
     3import java.util.Collection;
    24
    35import org.expeditee.items.Item;
    46import org.expeditee.items.Line;
    57import org.expeditee.items.Text;
     8import org.expeditee.items.widgets.InteractiveWidget;
     9import org.expeditee.items.widgets.WidgetCorner;
     10import org.expeditee.items.widgets.WidgetEdge;
    611import org.expeditee.settings.experimental.ExperimentalFeatures;
    712
     
    1015       
    1116        // contexts
    12         private static final int background = 0, item = 1, line = 2, text = 3;
     17        private static enum Context {
     18                background,
     19                item,
     20                line,
     21                text
     22        };
    1323       
    1424        // mouse buttons
     
    4050        }
    4151       
    42         private static final String left(int context, int mod, int other) {
     52        private static final String left(Context context, int mod, int other) {
    4353                switch(context) {
    4454                case background:
     
    5161        }
    5262       
    53         private static final String middle(int context, int mod, int other) {
     63        private static final String middle(Context context, int mod, int other) {
    5464                switch(context) {
    5565                case background:
     
    6777        }
    6878       
    69         private static final String right(int context, int mod, int other) {
     79        private static final String right(Context context, int mod, int other) {
    7080                switch(context) {
    7181                case background:
     
    8191        }
    8292       
    83         private static final String left_middle(int context, int mod, int other) {
    84                 return null;
    85         }
    86        
    87         private static final String left_right(int context, int mod, int other) {
     93        private static final String left_middle(Context context, int mod, int other) {
     94                return null;
     95        }
     96       
     97        private static final String left_right(Context context, int mod, int other) {
    8898                switch(context) {
    8999                default:
     
    94104        }
    95105       
    96         private static final String middle_right(int context, int mod, int other) {
     106    private static final String middle_right(Context context, int mod, int other) {
    97107                switch(context) {
    98108                case text:
     
    106116        }
    107117       
    108         private static final String drag_left(int context, int mod, int other) {
     118        private static final String drag_left(Context context, int mod, int other) {
    109119                switch(context) {
    110120                case background:
     
    118128        }
    119129       
    120         private static final String drag_middle(int context, int mod, int other) {
     130        private static final String drag_middle(Context context, int mod, int other) {
    121131                switch(context) {
    122132                case text:
     
    126136        }
    127137       
    128         private static final String drag_right(int context, int mod, int other) {
     138        private static final String drag_right(Context context, int mod, int other) {
    129139                switch(context) {
    130140                case line:
     
    139149        public static void updateStatus() {
    140150                Item current = FrameUtils.getCurrentItem();
    141                 int context;
     151                Collection<Item> currents;
     152                Context context;
     153                InteractiveWidget iw = null;
    142154                if(current != null) {
    143155                        if(current instanceof Line) {
    144                                 context = line;
     156                                context = Context.line;
    145157                        } else if(current instanceof Text) {
    146                                 context = text;
     158                                context = Context.text;
    147159                        } else {
    148                                 context = item;
     160                                context = Context.item;
    149161                        }
    150                 } else if(FrameUtils.getCurrentItems() != null) {
    151                         context = item;
    152162                } else {
    153                         context = background;
     163                        currents = FrameUtils.getCurrentItems();
     164                        if(currents != null) {
     165                                if(currents.size() >= 4) {
     166                                for(Item i : currents) {
     167                                        if (i instanceof WidgetCorner) {
     168                                                iw = ((WidgetCorner) i).getWidgetSource();
     169                                                break;
     170                                        } else if (i instanceof WidgetEdge) {
     171                                                iw = ((WidgetEdge) i).getWidgetSource();
     172                                                break;
     173                                        }
     174                                }
     175                                }
     176                                context = Context.item;
     177                        } else {
     178                                context = Context.background;
     179                        }
    154180                }
    155181                int mod = (FrameMouseActions.isControlDown() ? control : 0) | (FrameMouseActions.isShiftDown() ? shift : 0);
     
    157183                String status = "";
    158184               
    159                 String l =  left(context, mod, other);
    160                 String m =  middle(context, mod, other);
    161                 String r =  right(context, mod, other);
    162                 String lr = left_right(context, mod, other);
    163                 String lm = left_middle(context, mod, other);
    164                 String mr = middle_right(context, mod, other);
    165                 String dl = drag_left(context, mod, other);
    166                 String dm = drag_middle(context, mod, other);
    167                 String dr = drag_right(context, mod, other);
     185                if(iw != null) {
     186                       
     187                        status = " Widget: " + iw.getName() + "\n (widgets have their own individual input handling)";
     188                       
     189                } else {
    168190               
    169                 if(l != null)  status += command(mod, left) + l + padding.substring(l.length());
    170                 if(m != null)  status += command(mod, middle) + m + padding.substring(m.length());
    171                 if(r != null)  status += command(mod, right) + r + padding.substring(r.length());
    172                 if(lm != null) status += command(mod, left | middle) + lm + padding.substring(lm.length());
    173                 if(lr != null) status += command(mod, left | right) + lr + padding.substring(lr.length());
    174                 if(mr != null) status += command(mod, middle | right) + mr + padding.substring(mr.length());
    175                 if(dl != null || dm != null || dr != null) status += "\n";
    176                 if(dl != null) status += command(mod, left, true) + dl + padding.substring(dl.length());
    177                 if(dm != null) status += command(mod, middle, true) + dm + padding.substring(dm.length());
    178                 if(dr != null) status += command(mod, right, true) + dr + padding.substring(dr.length());
     191                String l =  left(context, mod, other);
     192                String m =  middle(context, mod, other);
     193                String r =  right(context, mod, other);
     194                String lr = left_right(context, mod, other);
     195                String lm = left_middle(context, mod, other);
     196                String mr = middle_right(context, mod, other);
     197                String dl = drag_left(context, mod, other);
     198                String dm = drag_middle(context, mod, other);
     199                String dr = drag_right(context, mod, other);
     200               
     201                if(l != null)  status += command(mod, left) + l + padding.substring(l.length());
     202                if(m != null)  status += command(mod, middle) + m + padding.substring(m.length());
     203                if(r != null)  status += command(mod, right) + r + padding.substring(r.length());
     204                if(lm != null) status += command(mod, left | middle) + lm + padding.substring(lm.length());
     205                if(lr != null) status += command(mod, left | right) + lr + padding.substring(lr.length());
     206                if(mr != null) status += command(mod, middle | right) + mr + padding.substring(mr.length());
     207                if(dl != null || dm != null || dr != null) status += "\n";
     208                if(dl != null) status += command(mod, left, true) + dl + padding.substring(dl.length());
     209                if(dm != null) status += command(mod, middle, true) + dm + padding.substring(dm.length());
     210                if(dr != null) status += command(mod, right, true) + dr + padding.substring(dr.length());
     211               
     212                }
    179213               
    180214                MessageBay.setStatus(status);
Note: See TracChangeset for help on using the changeset viewer.