save
Showing
2 changed files
with
87 additions
and
7 deletions
| ... | @@ -16,14 +16,15 @@ import javax.swing.Icon; | ... | @@ -16,14 +16,15 @@ import javax.swing.Icon; |
| 16 | import javax.swing.ImageIcon; | 16 | import javax.swing.ImageIcon; |
| 17 | import javax.swing.JFrame; | 17 | import javax.swing.JFrame; |
| 18 | import javax.swing.JPanel; | 18 | import javax.swing.JPanel; |
| 19 | import javax.swing.SwingWorker; | ||
| 19 | import javax.swing.UIManager; | 20 | import javax.swing.UIManager; |
| 20 | import javax.swing.border.Border; | 21 | import javax.swing.border.Border; |
| 21 | 22 | ||
| 22 | import java.awt.event.ActionEvent; | 23 | import java.awt.event.ActionEvent; |
| 23 | import java.awt.event.ActionListener; | 24 | import java.awt.event.ActionListener; |
| 24 | 25 | ||
| 26 | import org.emercit.szs.controldevtools.bean.NotificationBB; | ||
| 25 | import org.emercit.szs.model.Config; | 27 | import org.emercit.szs.model.Config; |
| 26 | |||
| 27 | import org.emercit.szs.szsterminal.SZSTerminal; | 28 | import org.emercit.szs.szsterminal.SZSTerminal; |
| 28 | 29 | ||
| 29 | import java.net.URL; | 30 | import java.net.URL; |
| ... | @@ -33,6 +34,10 @@ public class JPnlHeader extends RoundedPanel3 { | ... | @@ -33,6 +34,10 @@ public class JPnlHeader extends RoundedPanel3 { |
| 33 | private JLabel jlblclock; | 34 | private JLabel jlblclock; |
| 34 | private JLabel jlbltitle; | 35 | private JLabel jlbltitle; |
| 35 | 36 | ||
| 37 | private JLabel jlblconnect; | ||
| 38 | |||
| 39 | private NotificationBB notificationbb=new NotificationBB(); | ||
| 40 | |||
| 36 | public JPnlHeader() { | 41 | public JPnlHeader() { |
| 37 | 42 | ||
| 38 | this.setLayout(null); | 43 | this.setLayout(null); |
| ... | @@ -58,10 +63,10 @@ public class JPnlHeader extends RoundedPanel3 { | ... | @@ -58,10 +63,10 @@ public class JPnlHeader extends RoundedPanel3 { |
| 58 | add(jlbltitle); | 63 | add(jlbltitle); |
| 59 | 64 | ||
| 60 | // connect | 65 | // connect |
| 61 | // jlblconnect = new JLabel(); | 66 | jlblconnect = new JLabel(); |
| 62 | // jlblconnect.setBounds(5, 5, 50, 30); | 67 | jlblconnect.setBounds(650, 5, 50, 30); |
| 63 | // ChangeConnectImg(false); | 68 | jlblconnect.setIcon(new ImageIcon(this.getClass().getResource("/disconnect_service.png"))); |
| 64 | // add(jlblconnect); | 69 | add(jlblconnect); |
| 65 | } | 70 | } |
| 66 | 71 | ||
| 67 | static class exitApp implements ActionListener { | 72 | static class exitApp implements ActionListener { |
| ... | @@ -79,5 +84,51 @@ public class JPnlHeader extends RoundedPanel3 { | ... | @@ -79,5 +84,51 @@ public class JPnlHeader extends RoundedPanel3 { |
| 79 | public void SetBlue() { | 84 | public void SetBlue() { |
| 80 | setBackground(new Color(168, 181, 224)); | 85 | setBackground(new Color(168, 181, 224)); |
| 81 | } | 86 | } |
| 87 | |||
| 88 | public void setConnect() { | ||
| 89 | |||
| 90 | |||
| 91 | |||
| 92 | new SwingWorker<Void, Void>() | ||
| 93 | { | ||
| 94 | protected Void doInBackground() throws Exception | ||
| 95 | { | ||
| 96 | jlblconnect.setIcon(new ImageIcon(this.getClass().getResource("/connect_service.png"))); | ||
| 97 | |||
| 98 | |||
| 99 | return null; | ||
| 100 | } | ||
| 101 | |||
| 102 | }.execute(); | ||
| 103 | |||
| 104 | } | ||
| 105 | |||
| 106 | public void setDisconnect() { | ||
| 107 | |||
| 108 | new SwingWorker<Void, Void>() | ||
| 109 | { | ||
| 110 | protected Void doInBackground() throws Exception | ||
| 111 | { | ||
| 112 | jlblconnect.setIcon(new ImageIcon(this.getClass().getResource("/disconnect_service.png"))); | ||
| 113 | |||
| 114 | |||
| 115 | notificationbb.playSiren(); | ||
| 116 | Thread.sleep(1000); | ||
| 117 | notificationbb.stopSiren(); | ||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | return null; | ||
| 122 | } | ||
| 123 | }.execute(); | ||
| 124 | |||
| 125 | |||
| 126 | } | ||
| 127 | |||
| 128 | |||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | |||
| 82 | 133 | ||
| 83 | } | 134 | } | ... | ... |
| ... | @@ -47,6 +47,8 @@ import org.emercit.szs.service.SData; | ... | @@ -47,6 +47,8 @@ import org.emercit.szs.service.SData; |
| 47 | 47 | ||
| 48 | import org.emercit.szs.model.MsgSzs; | 48 | import org.emercit.szs.model.MsgSzs; |
| 49 | 49 | ||
| 50 | import org.emercit.szs.szsterminal.SZSTerminal; | ||
| 51 | |||
| 50 | 52 | ||
| 51 | public class WebPost { | 53 | public class WebPost { |
| 52 | 54 | ||
| ... | @@ -61,6 +63,8 @@ public class WebPost { | ... | @@ -61,6 +63,8 @@ public class WebPost { |
| 61 | 63 | ||
| 62 | private Gprs gprs; | 64 | private Gprs gprs; |
| 63 | 65 | ||
| 66 | private int count=0; | ||
| 67 | |||
| 64 | 68 | ||
| 65 | 69 | ||
| 66 | public WebPost() { | 70 | public WebPost() { |
| ... | @@ -184,14 +188,31 @@ public class WebPost { | ... | @@ -184,14 +188,31 @@ public class WebPost { |
| 184 | } | 188 | } |
| 185 | } | 189 | } |
| 186 | } | 190 | } |
| 191 | |||
| 192 | |||
| 187 | 193 | ||
| 188 | urlConnection.disconnect(); | 194 | urlConnection.disconnect(); |
| 195 | |||
| 196 | |||
| 197 | SZSTerminal.jpnlheader.setConnect(); | ||
| 198 | |||
| 199 | count=0; | ||
| 189 | 200 | ||
| 190 | } catch (Exception e) { | 201 | } catch (Exception e) { |
| 202 | |||
| 203 | count++; | ||
| 204 | if (count>=5) { | ||
| 205 | count=0; | ||
| 206 | SZSTerminal.jpnlheader.setDisconnect(); | ||
| 207 | gprs.Reconnect(); | ||
| 208 | |||
| 209 | } | ||
| 210 | |||
| 191 | log.error(e.getMessage()); | 211 | log.error(e.getMessage()); |
| 192 | log.error(MsgSzs.connectServerError); | 212 | log.error(MsgSzs.connectServerError); |
| 193 | 213 | ||
| 194 | gprs.Reconnect(); | 214 | |
| 215 | |||
| 195 | 216 | ||
| 196 | } finally { | 217 | } finally { |
| 197 | 218 | ||
| ... | @@ -205,10 +226,18 @@ public class WebPost { | ... | @@ -205,10 +226,18 @@ public class WebPost { |
| 205 | } | 226 | } |
| 206 | 227 | ||
| 207 | } catch (Exception ex) { | 228 | } catch (Exception ex) { |
| 229 | |||
| 230 | count++; | ||
| 231 | if (count>=5) { | ||
| 232 | count=0; | ||
| 233 | SZSTerminal.jpnlheader.setDisconnect(); | ||
| 234 | gprs.Reconnect(); | ||
| 235 | |||
| 236 | } | ||
| 208 | log.error(ex.getMessage()); | 237 | log.error(ex.getMessage()); |
| 209 | log.error(MsgSzs.connectServerError); | 238 | log.error(MsgSzs.connectServerError); |
| 210 | 239 | ||
| 211 | gprs.Reconnect(); | 240 | |
| 212 | } | 241 | } |
| 213 | } | 242 | } |
| 214 | 243 | ... | ... |
-
Please register or sign in to post a comment