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
15 15 private LogicR3() { 16 16 // Hidden constructor since this is an utility class. 17 17 } 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 } 18 36 19 37 private static StringBuffer indentBuffer = new StringBuffer(); 20 38 … … 28 46 */ 29 47 public static boolean fire(EventR3 event) { 30 48 // 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 } 32 56 SophieLog.debug(indentBuffer + "Processing event: " + event); 33 57 try { 34 58 // for the indentation … … 52 76 return handled; 53 77 54 78 } finally { 79 if (shouldSetTime) { 80 synchronized (LogicR3.class) { 81 startedTime = null; 82 } 83 } 55 84 indentBuffer.delete(indentBuffer.length() - 1, indentBuffer.length()); 56 85 } 57 86 -
modules/org.sophie2.main.layout.mydoggy/src/main/java/org/sophie2/main/layout/mydoggy/MDFrameWindow.java
1 1 package org.sophie2.main.layout.mydoggy; 2 2 3 3 import java.awt.BorderLayout; 4 import java.awt.Component; 4 5 import java.awt.Dimension; 5 6 import java.awt.Frame; 6 7 import java.awt.Toolkit; … … 9 10 import java.awt.event.KeyListener; 10 11 import java.awt.event.WindowAdapter; 11 12 import java.awt.event.WindowEvent; 13 import java.util.Timer; 14 import java.util.TimerTask; 12 15 13 16 import javax.swing.AbstractAction; 14 17 import javax.swing.JComponent; 18 import javax.swing.JDialog; 15 19 import javax.swing.JFrame; 20 import javax.swing.JLabel; 16 21 import javax.swing.JPanel; 17 22 import javax.swing.KeyStroke; 18 23 import javax.swing.WindowConstants; … … 71 76 public Prop<JFrame> globalContainer() { 72 77 class globalContainer extends ResourceProperty<JFrame> { 73 78 79 private static final long LONG_OP_INTERVAL = 500; 80 74 81 @Override 75 82 protected JFrame create() { 76 83 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); 77 120 78 121 gcf.addWindowListener(new WindowAdapter() { 79 122 @Override