Ticket #2174: hourgalss.patch

File hourgalss.patch, 4.2 KB (added by pap, 15 years ago)
  • modules/org.sophie2.core.mvc/src/main/java/org/sophie2/core/mvc/LogicR3.java

    ### Eclipse Workspace Patch 1.0
    #P sophie2
     
    1515        private LogicR3() { 
    1616                // Hidden constructor since this is an utility class. 
    1717        } 
     18         
     19//      private static List<Long> timeStack = Collections.synchronizedList(new LinkedList<Long>()); 
     20         
     21        private static Long startedTime = null; 
     22 
     23        /** 
     24         * Gets the value at the bottom of the time stack with the fire calls. 
     25         *  
     26         * @return 
     27         *              The time at the bottom. 
     28         */ 
     29        public static synchronized Long getTimeStackBottom() { 
     30//              if (!timeStack.isEmpty()) { 
     31//                      return timeStack.get(0); 
     32//              } 
     33//              return null; 
     34                return startedTime; 
     35        } 
    1836 
    1937        private static StringBuffer indentBuffer = new StringBuffer(); 
    2038 
     
    2846         */ 
    2947        public static boolean fire(EventR3 event) { 
    3048                // TODO finding the correct operation can and should be optimized! 
    31  
     49                 
     50                boolean shouldSetTime = startedTime == null; 
     51                if (shouldSetTime) { 
     52                        synchronized (LogicR3.class) { 
     53                                startedTime = System.currentTimeMillis(); 
     54                        } 
     55                } 
    3256                SophieLog.debug(indentBuffer + "Processing event: " + event); 
    3357                try { 
    3458                        // for the indentation 
     
    5276                        return handled; 
    5377 
    5478                } finally { 
     79                        if (shouldSetTime) { 
     80                                synchronized (LogicR3.class) { 
     81                                        startedTime = null; 
     82                                } 
     83                        } 
    5584                        indentBuffer.delete(indentBuffer.length() - 1, indentBuffer.length()); 
    5685                } 
    5786 
  • modules/org.sophie2.main.layout.mydoggy/src/main/java/org/sophie2/main/layout/mydoggy/MDFrameWindow.java

     
    11package org.sophie2.main.layout.mydoggy; 
    22 
    33import java.awt.BorderLayout; 
     4import java.awt.Component; 
    45import java.awt.Dimension; 
    56import java.awt.Frame; 
    67import java.awt.Toolkit; 
     
    910import java.awt.event.KeyListener; 
    1011import java.awt.event.WindowAdapter; 
    1112import java.awt.event.WindowEvent; 
     13import java.util.Timer; 
     14import java.util.TimerTask; 
    1215 
    1316import javax.swing.AbstractAction; 
    1417import javax.swing.JComponent; 
     18import javax.swing.JDialog; 
    1519import javax.swing.JFrame; 
     20import javax.swing.JLabel; 
    1621import javax.swing.JPanel; 
    1722import javax.swing.KeyStroke; 
    1823import javax.swing.WindowConstants; 
     
    7176        public Prop<JFrame> globalContainer() { 
    7277                class globalContainer extends ResourceProperty<JFrame> { 
    7378 
     79                        private static final long LONG_OP_INTERVAL = 500; 
     80 
    7481                        @Override 
    7582                        protected JFrame create() { 
    7683                                final JFrame gcf = new JFrame(); 
     84                                 
     85                                new Timer().schedule(new TimerTask() { 
     86                                        private Component comp = gcf; 
     87                                        private Long lastSetTime = null; 
     88                                        private JDialog workingDialog = null; 
     89                                         
     90                                        private JDialog getDialog() { 
     91                                                if (this.workingDialog == null) { 
     92                                                        this.workingDialog = new JDialog(gcf); 
     93                                                        JLabel working = new JLabel("Working..."); 
     94                                                        this.workingDialog.add(working); 
     95                                                        this.workingDialog.setLocationRelativeTo(this.comp); 
     96                                                        this.workingDialog.setUndecorated(true); 
     97                                                        this.workingDialog.setSize(60, 15); 
     98                                                } 
     99                                                return this.workingDialog; 
     100                                        } 
     101 
     102                                        @Override 
     103                                        public void run() { 
     104                                                Long lastOpStart = LogicR3.getTimeStackBottom(); 
     105                                                if (lastOpStart != this.lastSetTime) { 
     106                                                        long current = System.currentTimeMillis(); 
     107                                                         
     108                                                        if (lastOpStart != null ) { 
     109                                                                if ((current-lastOpStart) > LONG_OP_INTERVAL) { 
     110                                                                        this.lastSetTime = lastOpStart; 
     111                                                                        getDialog().setVisible(true); 
     112                                                                }  
     113                                                        } else { 
     114                                                                this.lastSetTime = lastOpStart; 
     115                                                                getDialog().setVisible(false); 
     116                                                        } 
     117                                                } 
     118                                        } 
     119                                }, 0, 100); 
    77120 
    78121                                gcf.addWindowListener(new WindowAdapter() { 
    79122                                        @Override