save
Showing
70 changed files
with
3919 additions
and
0 deletions
SZSTerminal/.classpath
0 → 100755
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <classpath> | ||
| 3 | <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
| 4 | <attributes> | ||
| 5 | <attribute name="optional" value="true"/> | ||
| 6 | <attribute name="maven.pomderived" value="true"/> | ||
| 7 | </attributes> | ||
| 8 | </classpathentry> | ||
| 9 | <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
| 10 | <attributes> | ||
| 11 | <attribute name="maven.pomderived" value="true"/> | ||
| 12 | </attributes> | ||
| 13 | </classpathentry> | ||
| 14 | <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| 15 | <attributes> | ||
| 16 | <attribute name="optional" value="true"/> | ||
| 17 | <attribute name="maven.pomderived" value="true"/> | ||
| 18 | </attributes> | ||
| 19 | </classpathentry> | ||
| 20 | <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | ||
| 21 | <attributes> | ||
| 22 | <attribute name="maven.pomderived" value="true"/> | ||
| 23 | </attributes> | ||
| 24 | </classpathentry> | ||
| 25 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> | ||
| 26 | <attributes> | ||
| 27 | <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="SZSTerminal/src/main/java/org/emercit/jni"/> | ||
| 28 | <attribute name="maven.pomderived" value="true"/> | ||
| 29 | </attributes> | ||
| 30 | </classpathentry> | ||
| 31 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
| 32 | <attributes> | ||
| 33 | <attribute name="maven.pomderived" value="true"/> | ||
| 34 | </attributes> | ||
| 35 | </classpathentry> | ||
| 36 | <classpathentry kind="output" path="target/classes"/> | ||
| 37 | </classpath> |
SZSTerminal/.gitignore
0 → 100755
| 1 | /target |
SZSTerminal/.project
0 → 100755
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <projectDescription> | ||
| 3 | <name>SZSTerminal</name> | ||
| 4 | <comment></comment> | ||
| 5 | <projects> | ||
| 6 | </projects> | ||
| 7 | <buildSpec> | ||
| 8 | <buildCommand> | ||
| 9 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
| 10 | <arguments> | ||
| 11 | </arguments> | ||
| 12 | </buildCommand> | ||
| 13 | <buildCommand> | ||
| 14 | <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| 15 | <arguments> | ||
| 16 | </arguments> | ||
| 17 | </buildCommand> | ||
| 18 | </buildSpec> | ||
| 19 | <natures> | ||
| 20 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
| 21 | <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| 22 | </natures> | ||
| 23 | </projectDescription> |
SZSTerminal/log4j.properties
0 → 100755
| 1 | log4j.rootLogger=DEBUG, CA, file | ||
| 2 | |||
| 3 | |||
| 4 | log4j.appender.CA=org.apache.log4j.ConsoleAppender | ||
| 5 | log4j.appender.CA.layout=org.apache.log4j.PatternLayout | ||
| 6 | log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n | ||
| 7 | |||
| 8 | |||
| 9 | log4j.appender.file=org.apache.log4j.RollingFileAppender | ||
| 10 | log4j.appender.file.File=logging.log | ||
| 11 | log4j.appender.file.MaxFileSize=10MB | ||
| 12 | log4j.appender.file.MaxBackupIndex=10 | ||
| 13 | log4j.appender.file.layout=org.apache.log4j.PatternLayout | ||
| 14 | log4j.appender.file.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
SZSTerminal/logging.log
0 → 100755
File mode changed
SZSTerminal/pom.xml
0 → 100755
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 2 | <modelVersion>4.0.0</modelVersion> | ||
| 3 | <groupId>SZSTerminal</groupId> | ||
| 4 | <artifactId>SZSTerminal</artifactId> | ||
| 5 | <version>0.0.1-SNAPSHOT</version> | ||
| 6 | |||
| 7 | |||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | <dependencies> | ||
| 12 | |||
| 13 | |||
| 14 | <dependency> | ||
| 15 | <groupId>junit</groupId> | ||
| 16 | <artifactId>junit</artifactId> | ||
| 17 | <version>3.8.1</version> | ||
| 18 | <scope>test</scope> | ||
| 19 | </dependency> | ||
| 20 | |||
| 21 | <dependency> | ||
| 22 | <groupId>com.google.code.gson</groupId> | ||
| 23 | <artifactId>gson</artifactId> | ||
| 24 | <version>2.3</version> | ||
| 25 | </dependency> | ||
| 26 | |||
| 27 | <dependency> | ||
| 28 | <groupId>com.googlecode.json-simple</groupId> | ||
| 29 | <artifactId>json-simple</artifactId> | ||
| 30 | <version>1.1.1</version> | ||
| 31 | </dependency> | ||
| 32 | |||
| 33 | |||
| 34 | <dependency> | ||
| 35 | <groupId>javax.inject</groupId> | ||
| 36 | <artifactId>javax.inject</artifactId> | ||
| 37 | <version>1</version> | ||
| 38 | </dependency> | ||
| 39 | |||
| 40 | |||
| 41 | <dependency> | ||
| 42 | <groupId>log4j</groupId> | ||
| 43 | <artifactId>log4j</artifactId> | ||
| 44 | <version>1.2.17</version> | ||
| 45 | </dependency> | ||
| 46 | |||
| 47 | </dependencies> | ||
| 48 | |||
| 49 | <pluginRepositories> | ||
| 50 | <pluginRepository> | ||
| 51 | <id>onejar-maven-plugin.googlecode.com</id> | ||
| 52 | <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url> | ||
| 53 | </pluginRepository> | ||
| 54 | </pluginRepositories> | ||
| 55 | |||
| 56 | |||
| 57 | </project> | ||
| 58 | |||
| 59 | |||
| 60 |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.BorderLayout; | ||
| 4 | import java.awt.FlowLayout; | ||
| 5 | import java.awt.GraphicsEnvironment; | ||
| 6 | import java.awt.Image; | ||
| 7 | |||
| 8 | import javax.swing.JButton; | ||
| 9 | import javax.swing.JDialog; | ||
| 10 | import javax.swing.JPanel; | ||
| 11 | import javax.swing.SwingUtilities; | ||
| 12 | import javax.swing.border.EmptyBorder; | ||
| 13 | import javax.swing.border.LineBorder; | ||
| 14 | |||
| 15 | import java.awt.event.ActionListener; | ||
| 16 | import java.awt.event.ActionEvent; | ||
| 17 | |||
| 18 | import javax.swing.SwingConstants; | ||
| 19 | |||
| 20 | import java.awt.event.KeyEvent; | ||
| 21 | import java.awt.Dimension; | ||
| 22 | import java.awt.GridLayout; | ||
| 23 | |||
| 24 | import javax.swing.JLabel; | ||
| 25 | |||
| 26 | import java.awt.ComponentOrientation; | ||
| 27 | import java.awt.Font; | ||
| 28 | |||
| 29 | import javax.swing.UIManager; | ||
| 30 | |||
| 31 | import java.awt.Color; | ||
| 32 | import java.awt.EventQueue; | ||
| 33 | import java.awt.SystemColor; | ||
| 34 | import java.text.DateFormat; | ||
| 35 | import java.text.SimpleDateFormat; | ||
| 36 | import java.util.Calendar; | ||
| 37 | import java.util.Date; | ||
| 38 | import java.util.Timer; | ||
| 39 | import java.util.TimerTask; | ||
| 40 | |||
| 41 | import javax.swing.ImageIcon; | ||
| 42 | import javax.swing.SwingWorker; | ||
| 43 | |||
| 44 | import java.util.ArrayList; | ||
| 45 | import java.io.File; | ||
| 46 | |||
| 47 | import javax.xml.parsers.DocumentBuilder; | ||
| 48 | import javax.xml.parsers.DocumentBuilderFactory; | ||
| 49 | |||
| 50 | |||
| 51 | import org.w3c.dom.Document; | ||
| 52 | import org.w3c.dom.Element; | ||
| 53 | import org.w3c.dom.Node; | ||
| 54 | import org.w3c.dom.NodeList; | ||
| 55 | |||
| 56 | import com.google.gson.Gson; | ||
| 57 | |||
| 58 | |||
| 59 | import java.io.BufferedReader; | ||
| 60 | import java.io.InputStreamReader; | ||
| 61 | import java.io.OutputStream; | ||
| 62 | import java.io.OutputStreamWriter; | ||
| 63 | import java.net.HttpURLConnection; | ||
| 64 | import java.net.InetSocketAddress; | ||
| 65 | import java.net.Proxy; | ||
| 66 | import java.net.URL; | ||
| 67 | |||
| 68 | import org.emercit.model.*; | ||
| 69 | |||
| 70 | import java.util.Timer; | ||
| 71 | import java.util.TimerTask; | ||
| 72 | |||
| 73 | import org.emercit.config.Config; | ||
| 74 | |||
| 75 | import org.emercit.service.SData; | ||
| 76 | |||
| 77 | |||
| 78 | import org.emercit.szsterminal.SZSTerminal; | ||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | public class DlgConfirm extends JDialog { | ||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | private Timer timer = new Timer(); | ||
| 87 | |||
| 88 | boolean animate = false; | ||
| 89 | |||
| 90 | private final JPanel contentPanel = new JPanel(); | ||
| 91 | |||
| 92 | JLabel lblTitleAgk = new JLabel(); | ||
| 93 | JLabel lblTitleStatus = new JLabel(); | ||
| 94 | JLabel lblTitleTime = new JLabel(); | ||
| 95 | JLabel lblTitleRiver = new JLabel(); | ||
| 96 | JLabel lblTitleRepair = new JLabel(); | ||
| 97 | JLabel lblTitleOpenDoor = new JLabel(); | ||
| 98 | JLabel lblTitleVeracity = new JLabel(); | ||
| 99 | |||
| 100 | ImageIcon IconNotification = new ImageIcon(getClass().getResource( | ||
| 101 | "/notification.png")); | ||
| 102 | JLabel lblIcon = new JLabel(); | ||
| 103 | |||
| 104 | JButton okButton = new JButton("ПОДТВЕРЖДЕНИЕ"); | ||
| 105 | |||
| 106 | public MdlEvent ev; | ||
| 107 | |||
| 108 | private void setVisibleFalse() { | ||
| 109 | this.setVisible(false); | ||
| 110 | } | ||
| 111 | |||
| 112 | |||
| 113 | private class AnimateTask extends TimerTask { | ||
| 114 | |||
| 115 | @Override | ||
| 116 | public void run() { | ||
| 117 | EventQueue.invokeLater(new Runnable() { | ||
| 118 | |||
| 119 | //@Override | ||
| 120 | public void run() { | ||
| 121 | |||
| 122 | if (ev != null) { | ||
| 123 | |||
| 124 | if (animate) { | ||
| 125 | contentPanel | ||
| 126 | .setBackground(new Color(102, 102, 255)); | ||
| 127 | animate = false; | ||
| 128 | } else { | ||
| 129 | animate = true; | ||
| 130 | contentPanel | ||
| 131 | .setBackground(new Color(204, 102, 102)); | ||
| 132 | } | ||
| 133 | |||
| 134 | int countanimate = ev.getCoundAnimate(); | ||
| 135 | if (countanimate > 0) { | ||
| 136 | ev.setCountAnimate(countanimate - 1); | ||
| 137 | } else { | ||
| 138 | if (ev.getSound()) { | ||
| 139 | |||
| 140 | int countsound = ev.getCountSound(); | ||
| 141 | // on sound method | ||
| 142 | Util.Alarm(); | ||
| 143 | |||
| 144 | if (countsound > 0) { | ||
| 145 | ev.setCountSound(countsound - 1); | ||
| 146 | } else { | ||
| 147 | if (ev.getSiren()) { | ||
| 148 | Util.RunSiren(); | ||
| 149 | } | ||
| 150 | } | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | } | ||
| 155 | |||
| 156 | } | ||
| 157 | }); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | public void setEvent(MdlEvent event) { | ||
| 162 | |||
| 163 | SData.INSTANCE.setIsOpenDialog(true); | ||
| 164 | this.ev = event; | ||
| 165 | |||
| 166 | |||
| 167 | lblTitleAgk.setText(event.getTitleAgk()); | ||
| 168 | lblTitleAgk.setForeground(Color.WHITE); | ||
| 169 | |||
| 170 | lblTitleStatus.setText(event.getTitleStatusForConfirm()); | ||
| 171 | lblTitleStatus.setForeground(Color.WHITE); | ||
| 172 | lblTitleStatus.setIcon(event.getIconStatusLarge()); | ||
| 173 | |||
| 174 | lblTitleTime.setText(event.getDateTime()); | ||
| 175 | lblTitleTime.setIcon(event.getIconDateTime()); | ||
| 176 | lblTitleTime.setForeground(Color.WHITE); | ||
| 177 | |||
| 178 | lblTitleRiver.setText(event.getTitleRiver()); | ||
| 179 | lblTitleRiver.setIcon(event.getIconRiver()); | ||
| 180 | lblTitleRiver.setForeground(Color.WHITE); | ||
| 181 | |||
| 182 | lblTitleRepair.setText(event.getTitleRepair()); | ||
| 183 | lblTitleRepair.setForeground(Color.WHITE); | ||
| 184 | lblTitleRepair.setIcon(event.getIconRepairLarge()); | ||
| 185 | |||
| 186 | lblTitleOpenDoor.setText(event.getTitleOpenDorr()); | ||
| 187 | lblTitleOpenDoor.setForeground(Color.WHITE); | ||
| 188 | lblTitleOpenDoor.setIcon(event.getIconOpenDoorLarge()); | ||
| 189 | |||
| 190 | lblTitleVeracity.setText(event.getTitleVeracity()); | ||
| 191 | lblTitleVeracity.setForeground(Color.WHITE); | ||
| 192 | lblTitleVeracity.setIcon(event.getIconVeracityLarge()); | ||
| 193 | |||
| 194 | |||
| 195 | |||
| 196 | } | ||
| 197 | |||
| 198 | |||
| 199 | |||
| 200 | public DlgConfirm( ) { | ||
| 201 | |||
| 202 | |||
| 203 | |||
| 204 | contentPanel.setLayout(null); | ||
| 205 | contentPanel.setBorder(new LineBorder(new Color(100, 149, 237), 10)); | ||
| 206 | |||
| 207 | this.setUndecorated(true); | ||
| 208 | this.setForeground(UIManager.getColor("activeCaption")); | ||
| 209 | this.setBackground(Color.BLUE); | ||
| 210 | this.setLayout(null); | ||
| 211 | this.setSize(500, 370); | ||
| 212 | |||
| 213 | this.setLocationRelativeTo(null); // CENTER | ||
| 214 | |||
| 215 | this.setAlwaysOnTop(true); | ||
| 216 | this.setModal(true); | ||
| 217 | |||
| 218 | lblTitleAgk.setFont(new Font(null, Font.BOLD, 18)); | ||
| 219 | lblTitleStatus.setFont(new Font(null, Font.BOLD, 18)); | ||
| 220 | lblTitleTime.setFont(new Font(null, Font.BOLD, 18)); | ||
| 221 | lblTitleRiver.setFont(new Font(null, Font.BOLD, 18)); | ||
| 222 | |||
| 223 | lblTitleRepair.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 224 | lblTitleVeracity.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 225 | lblTitleOpenDoor.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 226 | |||
| 227 | contentPanel.setForeground(Color.BLUE); | ||
| 228 | |||
| 229 | this.setBackground(Color.BLUE); | ||
| 230 | |||
| 231 | lblTitleAgk.setBounds(15, 15, 300, 35); | ||
| 232 | contentPanel.add(lblTitleAgk); | ||
| 233 | |||
| 234 | lblTitleStatus.setBounds(15, 50, 450, 35); | ||
| 235 | contentPanel.add(lblTitleStatus); | ||
| 236 | |||
| 237 | lblTitleRiver.setBounds(15, 85, 345, 35); | ||
| 238 | contentPanel.add(lblTitleRiver); | ||
| 239 | |||
| 240 | lblTitleTime.setBounds(15, 120, 300, 35); | ||
| 241 | contentPanel.add(lblTitleTime); | ||
| 242 | |||
| 243 | lblTitleRepair.setBounds(15, 155, 300, 35); | ||
| 244 | contentPanel.add(lblTitleRepair); | ||
| 245 | |||
| 246 | lblTitleVeracity.setBounds(15, 190, 300, 35); | ||
| 247 | contentPanel.add(lblTitleVeracity); | ||
| 248 | |||
| 249 | lblTitleOpenDoor.setBounds(15, 225, 300, 35); | ||
| 250 | contentPanel.add(lblTitleOpenDoor); | ||
| 251 | |||
| 252 | lblIcon.setBounds(350, 100, 124, 124); | ||
| 253 | Image img = IconNotification.getImage(); | ||
| 254 | Image newimg = img.getScaledInstance(124, 124, | ||
| 255 | java.awt.Image.SCALE_SMOOTH); | ||
| 256 | IconNotification = new ImageIcon(newimg); | ||
| 257 | lblIcon.setIcon(IconNotification); | ||
| 258 | contentPanel.add(lblIcon); | ||
| 259 | |||
| 260 | contentPanel.setBounds(5, 5, 490, 280); | ||
| 261 | add(contentPanel); | ||
| 262 | |||
| 263 | okButton.setBorder(new LineBorder(new Color(100, 149, 237), 7)); | ||
| 264 | okButton.setFont(new Font("Tahoma", Font.PLAIN, 24)); | ||
| 265 | okButton.setPreferredSize(new Dimension(320, 80)); | ||
| 266 | okButton.setMinimumSize(new Dimension(220, 80)); | ||
| 267 | okButton.setMaximumSize(new Dimension(220, 80)); | ||
| 268 | okButton.setMnemonic(KeyEvent.VK_COMPOSE); | ||
| 269 | okButton.addActionListener(new ActionListener() { | ||
| 270 | public void actionPerformed(ActionEvent arg0) { | ||
| 271 | |||
| 272 | SwingUtilities.invokeLater(new Runnable() { | ||
| 273 | public void run() { | ||
| 274 | |||
| 275 | MdlEvent buff = ev; | ||
| 276 | ev = null; | ||
| 277 | Util.StopSiren(); | ||
| 278 | |||
| 279 | EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table | ||
| 280 | .getModel(); | ||
| 281 | model.AddRow(buff); | ||
| 282 | model.Update(); | ||
| 283 | SZSTerminal.jpnllog.table.updateUI(); | ||
| 284 | |||
| 285 | setVisibleFalse(); | ||
| 286 | |||
| 287 | SData.INSTANCE.Confirm(buff); | ||
| 288 | } | ||
| 289 | |||
| 290 | }); | ||
| 291 | |||
| 292 | } | ||
| 293 | }); | ||
| 294 | |||
| 295 | okButton.setBounds(5, 290, 488, 75); | ||
| 296 | |||
| 297 | add(okButton); | ||
| 298 | |||
| 299 | timer.schedule(new AnimateTask(), 0, 1000); | ||
| 300 | |||
| 301 | } | ||
| 302 | |||
| 303 | } | ||
| 304 | |||
| 305 | |||
| 306 | |||
| 307 | |||
| 308 | |||
| 309 | |||
| 310 | |||
| 311 | |||
| 312 | |||
| 313 | |||
| 314 | |||
| 315 | |||
| 316 | |||
| 317 | |||
| 318 | |||
| 319 |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | |||
| 4 | import java.awt.BorderLayout; | ||
| 5 | import java.awt.FlowLayout; | ||
| 6 | import java.awt.GraphicsEnvironment; | ||
| 7 | import java.awt.Image; | ||
| 8 | |||
| 9 | import javax.swing.JButton; | ||
| 10 | import javax.swing.JDialog; | ||
| 11 | import javax.swing.JPanel; | ||
| 12 | import javax.swing.JScrollPane; | ||
| 13 | import javax.swing.JTextPane; | ||
| 14 | import javax.swing.JTextArea; | ||
| 15 | import javax.swing.SwingUtilities; | ||
| 16 | import javax.swing.border.EmptyBorder; | ||
| 17 | import javax.swing.border.LineBorder; | ||
| 18 | |||
| 19 | import java.awt.event.ActionListener; | ||
| 20 | import java.awt.event.ActionEvent; | ||
| 21 | |||
| 22 | import javax.swing.SwingConstants; | ||
| 23 | |||
| 24 | import java.awt.event.KeyEvent; | ||
| 25 | import java.awt.Dimension; | ||
| 26 | import java.awt.GridLayout; | ||
| 27 | |||
| 28 | import javax.swing.JLabel; | ||
| 29 | |||
| 30 | import java.awt.ComponentOrientation; | ||
| 31 | import java.awt.Font; | ||
| 32 | |||
| 33 | import javax.swing.UIManager; | ||
| 34 | |||
| 35 | import java.awt.Color; | ||
| 36 | import java.awt.EventQueue; | ||
| 37 | import java.awt.SystemColor; | ||
| 38 | import java.text.DateFormat; | ||
| 39 | import java.text.SimpleDateFormat; | ||
| 40 | import java.util.Calendar; | ||
| 41 | import java.util.Date; | ||
| 42 | import java.util.Timer; | ||
| 43 | import java.util.TimerTask; | ||
| 44 | |||
| 45 | import javax.swing.ImageIcon; | ||
| 46 | import javax.swing.SwingWorker; | ||
| 47 | |||
| 48 | import java.util.ArrayList; | ||
| 49 | import java.io.File; | ||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | import com.google.gson.Gson; | ||
| 55 | |||
| 56 | import java.io.BufferedReader; | ||
| 57 | import java.io.FileInputStream; | ||
| 58 | import java.io.InputStreamReader; | ||
| 59 | import java.io.OutputStream; | ||
| 60 | import java.io.OutputStreamWriter; | ||
| 61 | import java.net.HttpURLConnection; | ||
| 62 | import java.net.InetSocketAddress; | ||
| 63 | import java.net.Proxy; | ||
| 64 | import java.net.URL; | ||
| 65 | |||
| 66 | import org.emercit.model.*; | ||
| 67 | import org.emercit.service.SData; | ||
| 68 | import org.emercit.szsterminal.*; | ||
| 69 | |||
| 70 | import java.io.BufferedWriter; | ||
| 71 | import java.io.File; | ||
| 72 | import java.io.FileWriter; | ||
| 73 | import java.io.IOException; | ||
| 74 | |||
| 75 | import javax.swing.JCheckBox; | ||
| 76 | import javax.swing.JTextField; | ||
| 77 | import javax.swing.JFormattedTextField; | ||
| 78 | import javax.swing.text.MaskFormatter; | ||
| 79 | |||
| 80 | import org.emercit.config.*; | ||
| 81 | public class DlgMainConfig extends JDialog { | ||
| 82 | |||
| 83 | |||
| 84 | private final JPanel contentPanel = new JPanel(); | ||
| 85 | |||
| 86 | |||
| 87 | private JButton ApplyButton = new JButton("ПРИМЕНИТЬ"); | ||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 | private JLabel lblGUID=new JLabel("GUID:"); | ||
| 92 | |||
| 93 | private JLabel lblProxyServer=new JLabel("Server:"); | ||
| 94 | private JLabel lblProxyPort=new JLabel("Port:"); | ||
| 95 | private JLabel lblPassword=new JLabel("Password:"); | ||
| 96 | |||
| 97 | public static JCheckBox chkUseProxy=new JCheckBox(); | ||
| 98 | |||
| 99 | public static JTextField txtGUID=new JTextField(); | ||
| 100 | |||
| 101 | |||
| 102 | public static JFormattedTextField txtProxyServer; | ||
| 103 | |||
| 104 | |||
| 105 | public static JFormattedTextField txtProxyPort; | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | private void setIsOpen(boolean visible) { | ||
| 110 | this.setVisible(visible); | ||
| 111 | } | ||
| 112 | |||
| 113 | |||
| 114 | public void setValue(Config config) { | ||
| 115 | |||
| 116 | this.txtGUID.setText(config.getRegKey()); | ||
| 117 | this.txtProxyServer.setText(config.getProxyServer()); | ||
| 118 | this.txtProxyPort.setText(String.valueOf(config.getProxyPort())); | ||
| 119 | this.chkUseProxy.setSelected(config.getProxyEnabled()); | ||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | } | ||
| 124 | |||
| 125 | |||
| 126 | private void setVisibleFalse() { | ||
| 127 | this.setVisible(false); | ||
| 128 | } | ||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | |||
| 133 | |||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | |||
| 139 | public DlgMainConfig() { | ||
| 140 | |||
| 141 | try { | ||
| 142 | contentPanel.setLayout(null); | ||
| 143 | contentPanel.setBorder(new LineBorder(new Color(100, 149, 237), 10)); | ||
| 144 | |||
| 145 | this.setTitle("Настройка программы"); | ||
| 146 | //this.setUndecorated(true); | ||
| 147 | this.setForeground(UIManager.getColor("activeCaption")); | ||
| 148 | this.setBackground(Color.BLUE); | ||
| 149 | this.setLayout(null); | ||
| 150 | this.setSize(500, 400); | ||
| 151 | |||
| 152 | this.setLocationRelativeTo(null); // CENTER | ||
| 153 | |||
| 154 | this.setAlwaysOnTop(true); | ||
| 155 | this.setModal(true); | ||
| 156 | |||
| 157 | contentPanel.setForeground(Color.BLUE); | ||
| 158 | |||
| 159 | this.setBackground(Color.BLUE); | ||
| 160 | |||
| 161 | |||
| 162 | // GUID | ||
| 163 | this.lblGUID.setFont(new Font(null, Font.BOLD, 18)); | ||
| 164 | this.lblGUID.setBounds(15, 20, 110, 35); | ||
| 165 | contentPanel.add(lblGUID); | ||
| 166 | this.txtGUID.setFont(new Font(null, Font.BOLD, 18)); | ||
| 167 | this.txtGUID.setBounds(80, 20, 370, 35); | ||
| 168 | contentPanel.add(txtGUID); | ||
| 169 | |||
| 170 | // use Proxy | ||
| 171 | this.chkUseProxy.setFont(new Font(null, Font.BOLD, 18)); | ||
| 172 | this.chkUseProxy.setBounds(15, 57, 370, 35); | ||
| 173 | this.chkUseProxy.setText("Proxy"); | ||
| 174 | contentPanel.add(chkUseProxy); | ||
| 175 | |||
| 176 | //Server | ||
| 177 | this.lblProxyServer.setFont(new Font(null, Font.BOLD, 18)); | ||
| 178 | this.lblProxyServer.setBounds(15, 100, 110, 35); | ||
| 179 | contentPanel.add(lblProxyServer); | ||
| 180 | |||
| 181 | MaskFormatter formatteIp = new MaskFormatter("###.###.###.###"); | ||
| 182 | this.txtProxyServer = new JFormattedTextField(formatteIp); | ||
| 183 | |||
| 184 | |||
| 185 | |||
| 186 | |||
| 187 | this.txtProxyServer.setFont(new Font(null, Font.BOLD, 18)); | ||
| 188 | this.txtProxyServer.setBounds(90, 100, 350, 35); | ||
| 189 | contentPanel.add(txtProxyServer); | ||
| 190 | |||
| 191 | // Port | ||
| 192 | this.lblProxyPort.setFont(new Font(null, Font.BOLD, 18)); | ||
| 193 | this.lblProxyPort.setBounds(15, 143, 110, 35); | ||
| 194 | contentPanel.add(lblProxyPort); | ||
| 195 | |||
| 196 | |||
| 197 | MaskFormatter formattePort = new MaskFormatter("####"); | ||
| 198 | this.txtProxyPort = new JFormattedTextField(formattePort); | ||
| 199 | |||
| 200 | |||
| 201 | this.txtProxyPort.setFont(new Font(null, Font.BOLD, 18)); | ||
| 202 | this.txtProxyPort.setBounds(90, 143, 350, 35); | ||
| 203 | contentPanel.add(txtProxyPort); | ||
| 204 | |||
| 205 | |||
| 206 | contentPanel.setBounds(5, 5, 490, 280); | ||
| 207 | add(contentPanel); | ||
| 208 | |||
| 209 | ApplyButton.setBorder(new LineBorder(new Color(100, 149, 237), 7)); | ||
| 210 | ApplyButton.setFont(new Font("Tahoma", Font.PLAIN, 24)); | ||
| 211 | ApplyButton.setPreferredSize(new Dimension(320, 80)); | ||
| 212 | ApplyButton.setMinimumSize(new Dimension(220, 80)); | ||
| 213 | ApplyButton.setMaximumSize(new Dimension(220, 80)); | ||
| 214 | ApplyButton.setMnemonic(KeyEvent.VK_COMPOSE); | ||
| 215 | ApplyButton.addActionListener(new ActionListener() { | ||
| 216 | public void actionPerformed(ActionEvent arg0) { | ||
| 217 | |||
| 218 | SwingUtilities.invokeLater(new Runnable() { | ||
| 219 | public void run() { | ||
| 220 | |||
| 221 | |||
| 222 | setVisibleFalse(); | ||
| 223 | |||
| 224 | try | ||
| 225 | { | ||
| 226 | Config config=SData.INSTANCE.getConfig(); | ||
| 227 | |||
| 228 | |||
| 229 | |||
| 230 | |||
| 231 | config.setRegkey(DlgMainConfig.txtGUID.getText()); | ||
| 232 | config.setProxyServer(DlgMainConfig.txtProxyServer.getText()); | ||
| 233 | config.setProxyPort(Integer.valueOf(DlgMainConfig.txtProxyPort.getText())); | ||
| 234 | config.setProxyEnabled(DlgMainConfig.chkUseProxy.isSelected()); | ||
| 235 | |||
| 236 | config.Save(); | ||
| 237 | |||
| 238 | SData.INSTANCE.SetConfig(config); | ||
| 239 | |||
| 240 | //configmain.setServer(DlgMainConfig.txtProxyServer.getText()); | ||
| 241 | |||
| 242 | //configmain.setPort(Integer.valueOf(DlgMainConfig.txtProxyPort.getText())); | ||
| 243 | |||
| 244 | |||
| 245 | // String inputpassword=DlgMainConfig.txtPassword.getText(); | ||
| 246 | // String pass=SZSTerminal.configmain.getPassword(); | ||
| 247 | |||
| 248 | // if (inputpassword.trim().equals(pass.trim())) { | ||
| 249 | // SZSTerminal.configmain.Save(); | ||
| 250 | // } | ||
| 251 | |||
| 252 | } | ||
| 253 | catch (Exception e) { | ||
| 254 | |||
| 255 | } | ||
| 256 | |||
| 257 | |||
| 258 | |||
| 259 | |||
| 260 | |||
| 261 | |||
| 262 | |||
| 263 | } | ||
| 264 | }); | ||
| 265 | |||
| 266 | |||
| 267 | |||
| 268 | } | ||
| 269 | }); | ||
| 270 | |||
| 271 | ApplyButton.setBounds(5, 290, 488, 75); | ||
| 272 | |||
| 273 | add(ApplyButton); | ||
| 274 | |||
| 275 | } | ||
| 276 | catch(Exception e) { | ||
| 277 | |||
| 278 | } | ||
| 279 | |||
| 280 | |||
| 281 | } | ||
| 282 | |||
| 283 | } | ||
| 284 | |||
| 285 | |||
| 286 | |||
| 287 | |||
| 288 | |||
| 289 | |||
| 290 | |||
| 291 |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | import javax.swing.*; | ||
| 11 | |||
| 12 | public class DrawPanel extends JComponent implements Runnable { | ||
| 13 | |||
| 14 | private long t = System.nanoTime(); | ||
| 15 | |||
| 16 | public DrawPanel() { | ||
| 17 | super(); | ||
| 18 | new Thread(this).start(); | ||
| 19 | } | ||
| 20 | |||
| 21 | //@Override | ||
| 22 | public void run() { | ||
| 23 | while (true) { | ||
| 24 | repaint(); | ||
| 25 | try { | ||
| 26 | Thread.sleep(5); | ||
| 27 | } catch (InterruptedException ex) { | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
| 31 | |||
| 32 | @Override | ||
| 33 | protected void paintComponent(Graphics g) { | ||
| 34 | super.paintComponent(g); | ||
| 35 | Graphics2D g2d = (Graphics2D) g; | ||
| 36 | |||
| 37 | long tm = System.nanoTime() - t; | ||
| 38 | double angle = tm / 300000000.0; | ||
| 39 | |||
| 40 | double sn = Math.sin(Math.sin(angle) * 0.5); | ||
| 41 | double cs = Math.cos(Math.sin(angle) * 0.5); | ||
| 42 | int x = (int) (250 * sn + 150); | ||
| 43 | int y = (int) (250 * cs); | ||
| 44 | g2d.drawLine(150, 0, x, y); | ||
| 45 | g2d.drawOval(x - 20, y - 20, 40, 40); | ||
| 46 | } | ||
| 47 | } |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | |||
| 10 | import javax.swing.JComponent; | ||
| 11 | import javax.swing.JLabel; | ||
| 12 | import javax.swing.JPanel; | ||
| 13 | |||
| 14 | public class ExtPnlAgk extends JPanel { | ||
| 15 | |||
| 16 | protected int _strokeSize = 1; | ||
| 17 | protected Color _shadowColor = Color.BLACK; | ||
| 18 | protected boolean _shadowed = true; | ||
| 19 | protected boolean _highQuality = true; | ||
| 20 | protected Dimension _arcs = new Dimension(15, 15); | ||
| 21 | protected int _shadowGap = 5; | ||
| 22 | protected int _shadowOffset = 4; | ||
| 23 | protected int _shadowAlpha = 150; | ||
| 24 | |||
| 25 | public Color _backgroundColor = Color.lightGray; | ||
| 26 | |||
| 27 | public ExtPnlAgk() { | ||
| 28 | super(); | ||
| 29 | |||
| 30 | } | ||
| 31 | |||
| 32 | /* | ||
| 33 | * @Override public void setBackground(Color c) { _backgroundColor = c; } | ||
| 34 | */ | ||
| 35 | |||
| 36 | public void setGreen() { | ||
| 37 | _backgroundColor = new Color(51, 204, 102); | ||
| 38 | } | ||
| 39 | |||
| 40 | public void setYellow() { | ||
| 41 | _backgroundColor = new Color(255, 255, 102); | ||
| 42 | } | ||
| 43 | |||
| 44 | public void setRed() { | ||
| 45 | _backgroundColor = new Color(255, 51, 102); | ||
| 46 | } | ||
| 47 | |||
| 48 | @Override | ||
| 49 | protected void paintComponent(Graphics g) { | ||
| 50 | super.paintComponent(g); | ||
| 51 | |||
| 52 | int width = getWidth(); | ||
| 53 | int height = getHeight(); | ||
| 54 | |||
| 55 | int shadowGap = this._shadowGap; | ||
| 56 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 57 | _shadowColor.getGreen(), _shadowColor.getGreen(), _shadowAlpha); | ||
| 58 | Graphics2D graphics = (Graphics2D) g; | ||
| 59 | |||
| 60 | if (_highQuality) { | ||
| 61 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 62 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 63 | } | ||
| 64 | |||
| 65 | if (_shadowed) { | ||
| 66 | graphics.setColor(shadowColorA); | ||
| 67 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 68 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 69 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 70 | } else { | ||
| 71 | _shadowGap = 1; | ||
| 72 | } | ||
| 73 | |||
| 74 | graphics.setColor(_backgroundColor); | ||
| 75 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 76 | _arcs.width, _arcs.height); | ||
| 77 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 78 | graphics.setColor(getForeground()); | ||
| 79 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 80 | _arcs.width, _arcs.height); | ||
| 81 | graphics.setStroke(new BasicStroke()); | ||
| 82 | |||
| 83 | } | ||
| 84 | } |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | |||
| 11 | public class ExtPnlInfo extends JPanel { | ||
| 12 | protected int _strokeSize = 1; | ||
| 13 | protected Color _shadowColor = Color.BLACK; | ||
| 14 | protected boolean _shadowed = true; | ||
| 15 | protected boolean _highQuality = true; | ||
| 16 | protected Dimension _arcs = new Dimension(7, 7); | ||
| 17 | protected int _shadowGap = 3; | ||
| 18 | protected int _shadowOffset = 1; | ||
| 19 | protected int _shadowAlpha = 75; | ||
| 20 | |||
| 21 | public ExtPnlInfo() { | ||
| 22 | super(); | ||
| 23 | setOpaque(false); | ||
| 24 | } | ||
| 25 | |||
| 26 | @Override | ||
| 27 | protected void paintComponent(Graphics g) { | ||
| 28 | super.paintComponent(g); | ||
| 29 | |||
| 30 | int width = getWidth(); | ||
| 31 | int height = getHeight(); | ||
| 32 | int shadowGap = this._shadowGap; | ||
| 33 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 34 | _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha); | ||
| 35 | Graphics2D graphics = (Graphics2D) g; | ||
| 36 | |||
| 37 | if (_highQuality) { | ||
| 38 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 39 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 40 | } | ||
| 41 | |||
| 42 | if (_shadowed) { | ||
| 43 | graphics.setColor(shadowColorA); | ||
| 44 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 45 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 46 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 47 | } else { | ||
| 48 | _shadowGap = 1; | ||
| 49 | } | ||
| 50 | |||
| 51 | graphics.setColor(Color.WHITE); | ||
| 52 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 53 | _arcs.width, _arcs.height); | ||
| 54 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 55 | graphics.setColor(getForeground()); | ||
| 56 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 57 | _arcs.width, _arcs.height); | ||
| 58 | graphics.setStroke(new BasicStroke()); | ||
| 59 | } | ||
| 60 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | import javax.swing.ImageIcon; | ||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JPanel; | ||
| 7 | import java.awt.Image; | ||
| 8 | import java.awt.Font; | ||
| 9 | import org.emercit.model.*; | ||
| 10 | import javax.swing.UIManager; | ||
| 11 | |||
| 12 | public class JPnlAgk extends ExtPnlAgk { | ||
| 13 | |||
| 14 | private class JPnlInfoExt extends ExtPnlInfo { | ||
| 15 | |||
| 16 | } | ||
| 17 | |||
| 18 | private int id; | ||
| 19 | private JLabel lblTitleAgk = new JLabel(); | ||
| 20 | private JLabel lblTitleRiver = new JLabel(); | ||
| 21 | private JLabel lblTitleStatus = new JLabel(); | ||
| 22 | private JLabel lblTitleOpenDoor = new JLabel(); | ||
| 23 | private JLabel lblTitleRepair = new JLabel(); | ||
| 24 | private JLabel lblTitleVeracity = new JLabel(); | ||
| 25 | |||
| 26 | private JPnlInfoExt JPnlInfo = new JPnlInfoExt(); | ||
| 27 | |||
| 28 | public JPnlAgk(MdlEvent event) { | ||
| 29 | |||
| 30 | setLayout(null); | ||
| 31 | |||
| 32 | lblTitleAgk.setBounds(7, 47, 70, 15); | ||
| 33 | lblTitleAgk.setText(event.getTitleAgk()); | ||
| 34 | // lblTitleAgk.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 35 | lblTitleAgk.setFont(new Font(null, Font.BOLD, 14)); | ||
| 36 | lblTitleAgk.setForeground(Color.BLACK); | ||
| 37 | |||
| 38 | add(lblTitleAgk); | ||
| 39 | |||
| 40 | JPnlInfo.setLayout(null); | ||
| 41 | JPnlInfo.setBounds(83, 7, 142, 88); | ||
| 42 | |||
| 43 | // River | ||
| 44 | |||
| 45 | lblTitleRiver.setText(event.getTitleRiver()); | ||
| 46 | lblTitleRiver.setForeground(Color.BLACK); | ||
| 47 | |||
| 48 | if (event.getIdStatus() != 0 || event.getOpenDorr() | ||
| 49 | || event.getRepair() || !event.getVeracity()) { | ||
| 50 | |||
| 51 | this.setYellow(); | ||
| 52 | if (event.getIdStatus() == 2) | ||
| 53 | this.setRed(); | ||
| 54 | |||
| 55 | lblTitleRiver.setFont(new Font(null, Font.ITALIC, 12)); | ||
| 56 | lblTitleRiver.setBounds(3, 3, 138, 15); | ||
| 57 | JPnlInfo.add(lblTitleRiver); | ||
| 58 | |||
| 59 | /* | ||
| 60 | * ***************************STATUS*************************** | ||
| 61 | */ | ||
| 62 | lblTitleStatus.setBounds(3, 18, 138, 15); | ||
| 63 | lblTitleStatus.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 64 | |||
| 65 | lblTitleStatus.setText("cтатус:" + event.getTitleStatus()); | ||
| 66 | lblTitleStatus.setForeground(event.getColorStatus()); | ||
| 67 | lblTitleStatus.setIcon(event.getIconStatusSmall()); | ||
| 68 | |||
| 69 | JPnlInfo.add(lblTitleStatus); | ||
| 70 | |||
| 71 | // ********************************************************************************** | ||
| 72 | /* | ||
| 73 | * *****************************DOOR******************************** | ||
| 74 | */ | ||
| 75 | lblTitleOpenDoor.setBounds(3, 34, 138, 15); | ||
| 76 | lblTitleOpenDoor.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 77 | |||
| 78 | lblTitleOpenDoor.setText(event.getTitleOpenDorr()); | ||
| 79 | lblTitleOpenDoor.setForeground(event.getColorOpenDoor()); | ||
| 80 | lblTitleOpenDoor.setIcon(event.getIconOpenDoorSmall()); | ||
| 81 | JPnlInfo.add(lblTitleOpenDoor); | ||
| 82 | // *************************************************************************** | ||
| 83 | |||
| 84 | /* | ||
| 85 | * *****************************REPAIR******************************* | ||
| 86 | * * | ||
| 87 | */ | ||
| 88 | |||
| 89 | lblTitleRepair.setBounds(3, 50, 138, 15); | ||
| 90 | lblTitleRepair.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 91 | |||
| 92 | lblTitleRepair.setText(event.getTitleRepair()); | ||
| 93 | lblTitleRepair.setForeground(event.getColorRepair()); | ||
| 94 | lblTitleRepair.setIcon(event.getIconRepairSmall()); | ||
| 95 | JPnlInfo.add(lblTitleRepair); | ||
| 96 | |||
| 97 | // *************************************************************************** | ||
| 98 | |||
| 99 | /* | ||
| 100 | * ******************************VERACITY**************************** | ||
| 101 | * ********* | ||
| 102 | */ | ||
| 103 | |||
| 104 | lblTitleVeracity.setBounds(3, 66, 138, 15); | ||
| 105 | lblTitleVeracity.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 106 | |||
| 107 | lblTitleVeracity.setText(event.getTitleVeracity()); | ||
| 108 | lblTitleVeracity.setForeground(event.getColorVeracity()); | ||
| 109 | lblTitleVeracity.setIcon(event.getIconVeracitySmall()); | ||
| 110 | JPnlInfo.add(lblTitleVeracity); | ||
| 111 | |||
| 112 | // **************************************************************************** | ||
| 113 | |||
| 114 | add(JPnlInfo); | ||
| 115 | } else { | ||
| 116 | |||
| 117 | this.setGreen(); | ||
| 118 | lblTitleRiver.setFont(new Font(null, Font.ITALIC, 14)); | ||
| 119 | lblTitleRiver.setBounds(83, 47, 138, 15); | ||
| 120 | JPnlInfo.add(lblTitleRiver); | ||
| 121 | add(lblTitleRiver); | ||
| 122 | } | ||
| 123 | |||
| 124 | } | ||
| 125 | |||
| 126 | } |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | import javax.swing.JTextPane; | ||
| 8 | import javax.swing.JScrollPane; | ||
| 9 | |||
| 10 | import java.awt.BasicStroke; | ||
| 11 | import java.awt.BorderLayout; | ||
| 12 | import java.awt.Dimension; | ||
| 13 | import java.awt.EventQueue; | ||
| 14 | import java.awt.FlowLayout; | ||
| 15 | import java.awt.Graphics; | ||
| 16 | import java.awt.Graphics2D; | ||
| 17 | import java.awt.GridLayout; | ||
| 18 | import java.awt.Font; | ||
| 19 | import java.awt.RenderingHints; | ||
| 20 | import java.util.Random; | ||
| 21 | import java.util.TimerTask; | ||
| 22 | import java.io.*; | ||
| 23 | import java.util.*; | ||
| 24 | import java.awt.Toolkit; | ||
| 25 | import java.net.URL; | ||
| 26 | import java.nio.*; | ||
| 27 | import java.net.*; | ||
| 28 | |||
| 29 | import javax.swing.SwingWorker; | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | public class JPnlContacts extends RoundedPanel3 { | ||
| 34 | |||
| 35 | private JTextPane pane = new JTextPane(); | ||
| 36 | |||
| 37 | public JPnlContacts() { | ||
| 38 | |||
| 39 | this.setLayout(null); | ||
| 40 | |||
| 41 | pane.setFont(new Font(null, Font.ITALIC, 22)); | ||
| 42 | // lblContact.setText(SZSTerminal.configmain.getPhone()); | ||
| 43 | pane.setText(""); | ||
| 44 | // pane.setBounds(10, 5, 750, 440); | ||
| 45 | |||
| 46 | JScrollPane sp = new JScrollPane(pane); | ||
| 47 | sp.setBounds(10, 5, 750, 440); | ||
| 48 | |||
| 49 | this.add(sp); | ||
| 50 | |||
| 51 | // setBackground(new Color(168, 181, 224)); // blue | ||
| 52 | |||
| 53 | } | ||
| 54 | |||
| 55 | public void setTitleContact(String title) { | ||
| 56 | try { | ||
| 57 | pane.setEditable(false); | ||
| 58 | |||
| 59 | pane.setText(title); | ||
| 60 | |||
| 61 | } | ||
| 62 | catch(Exception e) { | ||
| 63 | |||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | import javax.swing.JTextPane; | ||
| 8 | import javax.swing.JScrollPane; | ||
| 9 | |||
| 10 | import java.awt.BasicStroke; | ||
| 11 | import java.awt.BorderLayout; | ||
| 12 | import java.awt.Dimension; | ||
| 13 | import java.awt.EventQueue; | ||
| 14 | import java.awt.FlowLayout; | ||
| 15 | import java.awt.Graphics; | ||
| 16 | import java.awt.Graphics2D; | ||
| 17 | import java.awt.GridLayout; | ||
| 18 | import java.awt.Font; | ||
| 19 | import java.awt.RenderingHints; | ||
| 20 | import java.util.Enumeration; | ||
| 21 | import java.util.Random; | ||
| 22 | import java.util.TimerTask; | ||
| 23 | import java.io.*; | ||
| 24 | import java.util.*; | ||
| 25 | import java.awt.Toolkit; | ||
| 26 | import java.awt.event.ActionEvent; | ||
| 27 | import java.awt.event.ActionListener; | ||
| 28 | import java.net.URL; | ||
| 29 | import java.nio.*; | ||
| 30 | import java.net.*; | ||
| 31 | import java.net.*; | ||
| 32 | import java.io.*; | ||
| 33 | import java.util.StringTokenizer; | ||
| 34 | |||
| 35 | import javax.swing.SwingWorker; | ||
| 36 | |||
| 37 | import org.emercit.config.Config; | ||
| 38 | import org.emercit.service.SData; | ||
| 39 | import org.emercit.szsterminal.SZSTerminal; | ||
| 40 | |||
| 41 | public class JPnlControl extends RoundedPanel3 { | ||
| 42 | |||
| 43 | |||
| 44 | private JButton JbtnMainConfig=new JButton("НАСТРОЙКИ ПРОГРАММЫ"); | ||
| 45 | |||
| 46 | |||
| 47 | public JPnlControl() { | ||
| 48 | |||
| 49 | this.setLayout(null); | ||
| 50 | |||
| 51 | JbtnMainConfig.addActionListener(new openSettingMainConfig()); | ||
| 52 | JbtnMainConfig.setBounds(10, 20, 220, 30); | ||
| 53 | |||
| 54 | this.add(JbtnMainConfig); | ||
| 55 | |||
| 56 | |||
| 57 | } | ||
| 58 | |||
| 59 | static class exitApp implements ActionListener { | ||
| 60 | public void actionPerformed(ActionEvent e) { | ||
| 61 | |||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | static class openSettingMainConfig implements ActionListener { | ||
| 66 | |||
| 67 | public void actionPerformed(ActionEvent e) { | ||
| 68 | |||
| 69 | DlgMainConfig dlgmainconfig=new DlgMainConfig(); | ||
| 70 | |||
| 71 | Config config=SData.INSTANCE.getConfig(); | ||
| 72 | |||
| 73 | dlgmainconfig.setValue(config); | ||
| 74 | |||
| 75 | dlgmainconfig.show(); | ||
| 76 | |||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | |||
| 90 | } | ||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | |||
| 99 | |||
| 100 | |||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | |||
| 113 |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | |||
| 8 | import java.awt.BasicStroke; | ||
| 9 | import java.awt.BorderLayout; | ||
| 10 | import java.awt.Dimension; | ||
| 11 | import java.awt.EventQueue; | ||
| 12 | import java.awt.FlowLayout; | ||
| 13 | import java.awt.Graphics; | ||
| 14 | import java.awt.Graphics2D; | ||
| 15 | import java.awt.GridLayout; | ||
| 16 | import java.awt.Font; | ||
| 17 | import java.awt.RenderingHints; | ||
| 18 | import java.util.Random; | ||
| 19 | import java.util.TimerTask; | ||
| 20 | import java.io.*; | ||
| 21 | |||
| 22 | import javax.swing.BorderFactory; | ||
| 23 | import javax.swing.Icon; | ||
| 24 | import javax.swing.ImageIcon; | ||
| 25 | import javax.swing.JFrame; | ||
| 26 | import javax.swing.JPanel; | ||
| 27 | import javax.swing.SwingUtilities; | ||
| 28 | import javax.swing.UIManager; | ||
| 29 | import javax.swing.border.Border; | ||
| 30 | |||
| 31 | import java.util.Comparator; | ||
| 32 | |||
| 33 | import org.emercit.model.*; | ||
| 34 | |||
| 35 | import java.awt.event.ActionListener; | ||
| 36 | import java.awt.event.ActionEvent; | ||
| 37 | |||
| 38 | import java.util.*; | ||
| 39 | import java.awt.Toolkit; | ||
| 40 | import java.net.URL; | ||
| 41 | import java.nio.*; | ||
| 42 | import java.net.*; | ||
| 43 | import java.awt.EventQueue; | ||
| 44 | |||
| 45 | import javax.swing.SwingWorker; | ||
| 46 | |||
| 47 | |||
| 48 | import java.awt.GridBagLayout; | ||
| 49 | import java.awt.GridBagConstraints; | ||
| 50 | import java.awt.Insets; | ||
| 51 | |||
| 52 | import java.util.*; | ||
| 53 | |||
| 54 | public class JPnlCurrent extends RoundedPanel3 { | ||
| 55 | |||
| 56 | public class EventComparator1 implements Comparator<MdlEvent> { | ||
| 57 | |||
| 58 | // @Override | ||
| 59 | public int compare(MdlEvent a, MdlEvent b) { | ||
| 60 | |||
| 61 | return Integer.valueOf(a.getIdStatus()).compareTo( | ||
| 62 | Integer.valueOf(b.getIdStatus())); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | private JButton btnDown = new JButton(); | ||
| 67 | private JButton btnUp = new JButton(); | ||
| 68 | private JPanel panel = new JPanel(); | ||
| 69 | |||
| 70 | private int start = 0; | ||
| 71 | private int end = 9; | ||
| 72 | |||
| 73 | private List<MdlEvent> lstevent; | ||
| 74 | |||
| 75 | private EventComparator1 eventComparator1=new EventComparator1(); | ||
| 76 | |||
| 77 | public void setListEventCurrent(List<MdlEvent> lstevent) { | ||
| 78 | this.lstevent = lstevent; | ||
| 79 | try { | ||
| 80 | Update(); | ||
| 81 | } | ||
| 82 | catch(Exception e) { | ||
| 83 | |||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | private void Update()throws Exception { | ||
| 90 | |||
| 91 | Collections.sort(lstevent, eventComparator1); | ||
| 92 | |||
| 93 | panel.removeAll(); | ||
| 94 | |||
| 95 | int x = 0; | ||
| 96 | int y = 10; | ||
| 97 | for (int i = start; i < end; i++) { | ||
| 98 | |||
| 99 | try { | ||
| 100 | |||
| 101 | JPnlAgk agk = new JPnlAgk(lstevent.get(i)); | ||
| 102 | |||
| 103 | agk.setBounds(x, y, 240, 105); | ||
| 104 | panel.add(agk); | ||
| 105 | x += 250; | ||
| 106 | if (x > 500) { | ||
| 107 | x = 0; | ||
| 108 | y += 105; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | catch(Exception e) { | ||
| 112 | |||
| 113 | } | ||
| 114 | |||
| 115 | } | ||
| 116 | |||
| 117 | panel.updateUI(); | ||
| 118 | } | ||
| 119 | |||
| 120 | private void Up() throws Exception { | ||
| 121 | |||
| 122 | if (start - 9 <= 0) { | ||
| 123 | start = 0; | ||
| 124 | end = 9; | ||
| 125 | btnUp.setEnabled(false); | ||
| 126 | } else { | ||
| 127 | end = start; | ||
| 128 | start = start - 9; | ||
| 129 | } | ||
| 130 | |||
| 131 | Update(); | ||
| 132 | } | ||
| 133 | |||
| 134 | private void Down() throws Exception { | ||
| 135 | |||
| 136 | if (end + 9 > lstevent.size()) { | ||
| 137 | start = end; | ||
| 138 | end = lstevent.size(); | ||
| 139 | btnDown.setEnabled(false); | ||
| 140 | |||
| 141 | } else { | ||
| 142 | |||
| 143 | start = end; | ||
| 144 | end += 9; | ||
| 145 | } | ||
| 146 | |||
| 147 | Update(); | ||
| 148 | } | ||
| 149 | |||
| 150 | public JPnlCurrent() { | ||
| 151 | |||
| 152 | btnUp.setEnabled(false); | ||
| 153 | this.setBackground(new Color(168, 181, 224)); | ||
| 154 | this.setLayout(null); | ||
| 155 | |||
| 156 | panel.setBounds(5, 5, 740, 350); | ||
| 157 | panel.setLayout(null); | ||
| 158 | panel.setBackground(new Color(168, 181, 224)); | ||
| 159 | |||
| 160 | this.add(panel); | ||
| 161 | |||
| 162 | panel.updateUI(); | ||
| 163 | |||
| 164 | ImageIcon imgUp = new ImageIcon(getClass().getResource("/top.png")); | ||
| 165 | btnUp.setIcon(imgUp); | ||
| 166 | btnUp.setBounds(5, 355, 370, 100); | ||
| 167 | btnUp.addActionListener(new ActionListener() { | ||
| 168 | public void actionPerformed(ActionEvent arg0) { | ||
| 169 | SwingUtilities.invokeLater(new Runnable() { | ||
| 170 | public void run() { | ||
| 171 | try { | ||
| 172 | btnDown.setEnabled(true); | ||
| 173 | Up(); | ||
| 174 | } | ||
| 175 | catch(Exception e) { | ||
| 176 | |||
| 177 | } | ||
| 178 | } | ||
| 179 | }); | ||
| 180 | } | ||
| 181 | |||
| 182 | }); | ||
| 183 | add(btnUp); | ||
| 184 | |||
| 185 | ImageIcon imgDown = new ImageIcon(getClass().getResource("/bottom.png")); | ||
| 186 | btnDown.setIcon(imgDown); | ||
| 187 | btnDown.setBounds(385, 355, 370, 100); | ||
| 188 | btnDown.addActionListener(new ActionListener() { | ||
| 189 | public void actionPerformed(ActionEvent arg0) { | ||
| 190 | |||
| 191 | SwingUtilities.invokeLater(new Runnable() { | ||
| 192 | public void run() { | ||
| 193 | try { | ||
| 194 | btnUp.setEnabled(true); | ||
| 195 | Down(); | ||
| 196 | } | ||
| 197 | catch(Exception e) { | ||
| 198 | |||
| 199 | } | ||
| 200 | } | ||
| 201 | }); | ||
| 202 | } | ||
| 203 | |||
| 204 | }); | ||
| 205 | add(btnDown); | ||
| 206 | |||
| 207 | } | ||
| 208 | |||
| 209 | } |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | |||
| 8 | import java.awt.BorderLayout; | ||
| 9 | import java.awt.Dimension; | ||
| 10 | import java.awt.FlowLayout; | ||
| 11 | import java.awt.GridLayout; | ||
| 12 | import java.awt.Font; | ||
| 13 | |||
| 14 | import javax.swing.BorderFactory; | ||
| 15 | import javax.swing.Icon; | ||
| 16 | import javax.swing.ImageIcon; | ||
| 17 | import javax.swing.JFrame; | ||
| 18 | import javax.swing.JPanel; | ||
| 19 | import javax.swing.UIManager; | ||
| 20 | import javax.swing.border.Border; | ||
| 21 | |||
| 22 | import java.awt.event.ActionEvent; | ||
| 23 | import java.awt.event.ActionListener; | ||
| 24 | |||
| 25 | public class JPnlHeader extends RoundedPanel3 { | ||
| 26 | |||
| 27 | private JLabel jlblclock; | ||
| 28 | private JLabel jlbltitle; | ||
| 29 | private JLabel jlblconnect; | ||
| 30 | private JButton jbtnExit; | ||
| 31 | |||
| 32 | public JPnlHeader(String title) { | ||
| 33 | |||
| 34 | this.setLayout(null); | ||
| 35 | |||
| 36 | // время | ||
| 37 | jlblclock = new JLabel(); | ||
| 38 | jlblclock.setBounds(5, 2, 300, 30); | ||
| 39 | jlblclock.setText("Сегодня:03.03.2014 08:55:33"); | ||
| 40 | jlblclock.setFont(new Font(null, Font.ITALIC, 13)); | ||
| 41 | jlblclock.setForeground(Color.YELLOW); | ||
| 42 | jlblclock.setIcon(new ImageIcon(this.getClass().getResource( | ||
| 43 | "/clock.png"))); | ||
| 44 | add(jlblclock); | ||
| 45 | |||
| 46 | // название | ||
| 47 | jlbltitle = new JLabel(); | ||
| 48 | jlbltitle.setBounds(320, 2, 250, 30); | ||
| 49 | jlbltitle.setText(title); | ||
| 50 | jlbltitle.setFont(new Font(null, Font.ITALIC, 13)); | ||
| 51 | jlbltitle.setForeground(Color.YELLOW); | ||
| 52 | add(jlbltitle); | ||
| 53 | |||
| 54 | // connect | ||
| 55 | jlblconnect = new JLabel(); | ||
| 56 | jlblconnect.setBounds(600, 5, 50, 30); | ||
| 57 | ChangeConnectImg(false); | ||
| 58 | add(jlblconnect); | ||
| 59 | |||
| 60 | // exit | ||
| 61 | jbtnExit = new JButton("Выход"); | ||
| 62 | jbtnExit.setText("ВЫХОД"); | ||
| 63 | jbtnExit.addActionListener(new exitApp()); | ||
| 64 | jbtnExit.setBounds(650, 5, 100, 30); | ||
| 65 | // add(jbtnExit); | ||
| 66 | |||
| 67 | } | ||
| 68 | |||
| 69 | static class exitApp implements ActionListener { | ||
| 70 | public void actionPerformed(ActionEvent e) { | ||
| 71 | System.exit(0); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | /* | ||
| 76 | * Обновляем время | ||
| 77 | */ | ||
| 78 | public void UpdateTime(String val) { | ||
| 79 | jlblclock.setText(val); | ||
| 80 | } | ||
| 81 | |||
| 82 | public void SetBlue() { | ||
| 83 | setBackground(new Color(168, 181, 224)); | ||
| 84 | } | ||
| 85 | |||
| 86 | public void ChangeConnectImg(boolean connect) { | ||
| 87 | |||
| 88 | if (connect) { | ||
| 89 | jlblconnect.setIcon(new ImageIcon(this.getClass().getResource( | ||
| 90 | "/connect_service.png"))); | ||
| 91 | |||
| 92 | } else { | ||
| 93 | jlblconnect.setIcon(new ImageIcon(this.getClass().getResource( | ||
| 94 | "/disconnect_service.png"))); | ||
| 95 | |||
| 96 | } | ||
| 97 | |||
| 98 | this.repaint(); | ||
| 99 | } | ||
| 100 | |||
| 101 | public void setTitleSubscriver(String title) { | ||
| 102 | try { | ||
| 103 | jlbltitle.setText(title); | ||
| 104 | } | ||
| 105 | catch(Exception e) { | ||
| 106 | |||
| 107 | } | ||
| 108 | } | ||
| 109 | |||
| 110 | } |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | |||
| 5 | import javax.swing.JLabel; | ||
| 6 | import javax.swing.JButton; | ||
| 7 | |||
| 8 | import java.awt.BasicStroke; | ||
| 9 | import java.awt.BorderLayout; | ||
| 10 | import java.awt.Dimension; | ||
| 11 | import java.awt.EventQueue; | ||
| 12 | import java.awt.FlowLayout; | ||
| 13 | import java.awt.Graphics; | ||
| 14 | import java.awt.Graphics2D; | ||
| 15 | import java.awt.GridLayout; | ||
| 16 | import java.awt.Font; | ||
| 17 | import java.awt.RenderingHints; | ||
| 18 | import java.util.ArrayList; | ||
| 19 | import java.util.Random; | ||
| 20 | import java.util.TimerTask; | ||
| 21 | import java.io.*; | ||
| 22 | import java.awt.Color; | ||
| 23 | |||
| 24 | import javax.swing.JLabel; | ||
| 25 | import javax.swing.JButton; | ||
| 26 | import javax.swing.JTable; | ||
| 27 | |||
| 28 | import java.awt.BasicStroke; | ||
| 29 | import java.awt.BorderLayout; | ||
| 30 | import java.awt.Dimension; | ||
| 31 | import java.awt.EventQueue; | ||
| 32 | import java.awt.FlowLayout; | ||
| 33 | import java.awt.Graphics; | ||
| 34 | import java.awt.Graphics2D; | ||
| 35 | import java.awt.GridLayout; | ||
| 36 | import java.awt.Font; | ||
| 37 | import java.awt.RenderingHints; | ||
| 38 | import java.util.Random; | ||
| 39 | import java.util.TimerTask; | ||
| 40 | import java.io.*; | ||
| 41 | |||
| 42 | import javax.swing.BorderFactory; | ||
| 43 | import javax.swing.Icon; | ||
| 44 | import javax.swing.ImageIcon; | ||
| 45 | import javax.swing.JFrame; | ||
| 46 | import javax.swing.JPanel; | ||
| 47 | import javax.swing.SwingUtilities; | ||
| 48 | import javax.swing.UIManager; | ||
| 49 | import javax.swing.border.Border; | ||
| 50 | |||
| 51 | import org.emercit.model.*; | ||
| 52 | |||
| 53 | import java.awt.event.ActionListener; | ||
| 54 | import java.awt.event.ActionEvent; | ||
| 55 | import java.util.*; | ||
| 56 | import java.awt.Toolkit; | ||
| 57 | import java.net.URL; | ||
| 58 | import java.nio.*; | ||
| 59 | import java.net.*; | ||
| 60 | import java.awt.EventQueue; | ||
| 61 | |||
| 62 | import javax.swing.SwingWorker; | ||
| 63 | |||
| 64 | |||
| 65 | import java.awt.GridBagLayout; | ||
| 66 | import java.awt.GridBagConstraints; | ||
| 67 | import java.awt.Insets; | ||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 | import javax.swing.SwingWorker; | ||
| 72 | import javax.swing.table.TableModel; | ||
| 73 | |||
| 74 | import org.emercit.szsterminal.*; | ||
| 75 | |||
| 76 | public class JPnlLog extends RoundedPanel3 { | ||
| 77 | |||
| 78 | private JButton btnDown = new JButton(); | ||
| 79 | private JButton btnUp = new JButton(); | ||
| 80 | |||
| 81 | TableModel model = new EventTableModel(); | ||
| 82 | |||
| 83 | public JButton btnBtndown = new JButton(); | ||
| 84 | public JTable table = new JTable(model); | ||
| 85 | |||
| 86 | private int start = 0; | ||
| 87 | private int end = 7; | ||
| 88 | |||
| 89 | private void Update() { | ||
| 90 | |||
| 91 | EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table | ||
| 92 | .getModel(); | ||
| 93 | model.Update(start, end); | ||
| 94 | SZSTerminal.jpnllog.table.updateUI(); | ||
| 95 | } | ||
| 96 | |||
| 97 | private void Up() { | ||
| 98 | |||
| 99 | if (start - 7 <= 0) { | ||
| 100 | start = 0; | ||
| 101 | end = 7; | ||
| 102 | btnUp.setEnabled(false); | ||
| 103 | } else { | ||
| 104 | end = start; | ||
| 105 | start = start - 7; | ||
| 106 | } | ||
| 107 | Update(); | ||
| 108 | } | ||
| 109 | |||
| 110 | private void Down() { | ||
| 111 | |||
| 112 | EventTableModel model = (EventTableModel) SZSTerminal.jpnllog.table | ||
| 113 | .getModel(); | ||
| 114 | int valsize = model.getSize(); | ||
| 115 | |||
| 116 | if (end + 7 > valsize) { | ||
| 117 | start = end; | ||
| 118 | end = valsize; | ||
| 119 | btnDown.setEnabled(false); | ||
| 120 | } else { | ||
| 121 | start = end; | ||
| 122 | end += 7; | ||
| 123 | } | ||
| 124 | |||
| 125 | Update(); | ||
| 126 | } | ||
| 127 | |||
| 128 | public JPnlLog() { | ||
| 129 | |||
| 130 | btnUp.setEnabled(false); | ||
| 131 | this.setBackground(new Color(168, 181, 224)); | ||
| 132 | this.setLayout(null); | ||
| 133 | |||
| 134 | table.setBounds(5, 5, 760, 350); | ||
| 135 | table.setDefaultRenderer(MdlEvent.class, new EventCellRenderer()); | ||
| 136 | table.setRowHeight(40); | ||
| 137 | table.setBackground(new Color(168, 181, 224)); | ||
| 138 | |||
| 139 | this.add(table); | ||
| 140 | |||
| 141 | ImageIcon imgUp = new ImageIcon(getClass().getResource("/top.png")); | ||
| 142 | |||
| 143 | btnUp.setIcon(imgUp); | ||
| 144 | |||
| 145 | btnUp.setBounds(5, 355, 370, 100); | ||
| 146 | |||
| 147 | btnUp.addActionListener(new ActionListener() { | ||
| 148 | public void actionPerformed(ActionEvent arg0) { | ||
| 149 | SwingUtilities.invokeLater(new Runnable() { | ||
| 150 | public void run() { | ||
| 151 | btnDown.setEnabled(true); | ||
| 152 | Up(); | ||
| 153 | } | ||
| 154 | }); | ||
| 155 | } | ||
| 156 | |||
| 157 | }); | ||
| 158 | add(btnUp); | ||
| 159 | |||
| 160 | ImageIcon imgDown = new ImageIcon(getClass().getResource("/bottom.png")); | ||
| 161 | btnDown.setIcon(imgDown); | ||
| 162 | btnDown.setBounds(385, 355, 370, 100); | ||
| 163 | btnDown.addActionListener(new ActionListener() { | ||
| 164 | public void actionPerformed(ActionEvent arg0) { | ||
| 165 | |||
| 166 | SwingUtilities.invokeLater(new Runnable() { | ||
| 167 | public void run() { | ||
| 168 | btnUp.setEnabled(true); | ||
| 169 | Down(); | ||
| 170 | } | ||
| 171 | }); | ||
| 172 | } | ||
| 173 | }); | ||
| 174 | |||
| 175 | add(btnDown); | ||
| 176 | } | ||
| 177 | |||
| 178 | } | ||
| 179 | |||
| 180 |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | |||
| 11 | public class RoundedPanel2 extends JPanel { | ||
| 12 | protected int _strokeSize = 1; | ||
| 13 | protected Color _shadowColor = Color.BLACK; | ||
| 14 | protected boolean _shadowed = true; | ||
| 15 | protected boolean _highQuality = true; | ||
| 16 | protected Dimension _arcs = new Dimension(15, 15); | ||
| 17 | protected int _shadowGap = 3; | ||
| 18 | protected int _shadowOffset = 1; | ||
| 19 | protected int _shadowAlpha = 75; | ||
| 20 | |||
| 21 | protected Color _backgroundColor = new Color(168, 181, 224); | ||
| 22 | |||
| 23 | public RoundedPanel2() { | ||
| 24 | super(); | ||
| 25 | setOpaque(false); | ||
| 26 | } | ||
| 27 | |||
| 28 | @Override | ||
| 29 | public void setBackground(Color c) { | ||
| 30 | _backgroundColor = c; | ||
| 31 | } | ||
| 32 | |||
| 33 | @Override | ||
| 34 | protected void paintComponent(Graphics g) { | ||
| 35 | super.paintComponent(g); | ||
| 36 | |||
| 37 | int width = getWidth(); | ||
| 38 | int height = getHeight(); | ||
| 39 | int shadowGap = this._shadowGap; | ||
| 40 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 41 | _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha); | ||
| 42 | Graphics2D graphics = (Graphics2D) g; | ||
| 43 | |||
| 44 | if (_highQuality) { | ||
| 45 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 46 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 47 | } | ||
| 48 | |||
| 49 | if (_shadowed) { | ||
| 50 | graphics.setColor(shadowColorA); | ||
| 51 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 52 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 53 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 54 | } else { | ||
| 55 | _shadowGap = 1; | ||
| 56 | } | ||
| 57 | |||
| 58 | graphics.setColor(_backgroundColor); | ||
| 59 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 60 | _arcs.width, _arcs.height); | ||
| 61 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 62 | graphics.setColor(getForeground()); | ||
| 63 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 64 | _arcs.width, _arcs.height); | ||
| 65 | graphics.setStroke(new BasicStroke()); | ||
| 66 | } | ||
| 67 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.components; | ||
| 2 | |||
| 3 | import java.awt.BasicStroke; | ||
| 4 | import java.awt.Color; | ||
| 5 | import java.awt.Dimension; | ||
| 6 | import java.awt.Graphics; | ||
| 7 | import java.awt.Graphics2D; | ||
| 8 | import java.awt.RenderingHints; | ||
| 9 | import javax.swing.JPanel; | ||
| 10 | |||
| 11 | public class RoundedPanel3 extends JPanel { | ||
| 12 | protected int _strokeSize = 1; | ||
| 13 | protected Color _shadowColor = Color.BLACK; | ||
| 14 | protected boolean _shadowed = true; | ||
| 15 | protected boolean _highQuality = true; | ||
| 16 | protected Dimension _arcs = new Dimension(30, 30); | ||
| 17 | protected int _shadowGap = 5; | ||
| 18 | protected int _shadowOffset = 4; | ||
| 19 | protected int _shadowAlpha = 150; | ||
| 20 | |||
| 21 | public Color _backgroundColor = Color.LIGHT_GRAY; | ||
| 22 | |||
| 23 | public RoundedPanel3() { | ||
| 24 | super(); | ||
| 25 | setOpaque(false); | ||
| 26 | } | ||
| 27 | |||
| 28 | @Override | ||
| 29 | public void setBackground(Color c) { | ||
| 30 | _backgroundColor = c; | ||
| 31 | } | ||
| 32 | |||
| 33 | @Override | ||
| 34 | protected void paintComponent(Graphics g) { | ||
| 35 | super.paintComponent(g); | ||
| 36 | |||
| 37 | int width = getWidth(); | ||
| 38 | int height = getHeight(); | ||
| 39 | int shadowGap = this._shadowGap; | ||
| 40 | Color shadowColorA = new Color(_shadowColor.getRed(), | ||
| 41 | _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha); | ||
| 42 | Graphics2D graphics = (Graphics2D) g; | ||
| 43 | |||
| 44 | if (_highQuality) { | ||
| 45 | graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 46 | RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 47 | } | ||
| 48 | |||
| 49 | if (_shadowed) { | ||
| 50 | graphics.setColor(shadowColorA); | ||
| 51 | graphics.fillRoundRect(_shadowOffset, _shadowOffset, width | ||
| 52 | - _strokeSize - _shadowOffset, height - _strokeSize | ||
| 53 | - _shadowOffset, _arcs.width, _arcs.height); | ||
| 54 | } else { | ||
| 55 | _shadowGap = 1; | ||
| 56 | } | ||
| 57 | |||
| 58 | graphics.setColor(_backgroundColor); | ||
| 59 | graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 60 | _arcs.width, _arcs.height); | ||
| 61 | graphics.setStroke(new BasicStroke(_strokeSize)); | ||
| 62 | graphics.setColor(getForeground()); | ||
| 63 | graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, | ||
| 64 | _arcs.width, _arcs.height); | ||
| 65 | graphics.setStroke(new BasicStroke()); | ||
| 66 | } | ||
| 67 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.config; | ||
| 2 | |||
| 3 | |||
| 4 | import java.io.File; | ||
| 5 | |||
| 6 | |||
| 7 | import java.io.FileInputStream; | ||
| 8 | import java.io.IOException; | ||
| 9 | import java.io.InputStream; | ||
| 10 | import java.util.Properties; | ||
| 11 | import java.io.FileOutputStream; | ||
| 12 | import java.io.OutputStream; | ||
| 13 | |||
| 14 | |||
| 15 | import java.awt.Toolkit; | ||
| 16 | import java.net.URL; | ||
| 17 | |||
| 18 | import org.apache.log4j.Logger; | ||
| 19 | |||
| 20 | public class Config { | ||
| 21 | |||
| 22 | static final Logger logger = Logger.getLogger(Config.class); | ||
| 23 | |||
| 24 | private Properties prop = new Properties(); | ||
| 25 | |||
| 26 | private String regkey; | ||
| 27 | private String service; | ||
| 28 | private boolean proxyEnabled; | ||
| 29 | private String proxyServer; | ||
| 30 | private int proxyPort; | ||
| 31 | private String version; | ||
| 32 | |||
| 33 | public Config() { | ||
| 34 | |||
| 35 | InputStream input = null; | ||
| 36 | |||
| 37 | try { | ||
| 38 | |||
| 39 | input = new FileInputStream("szsterminal.properties"); | ||
| 40 | |||
| 41 | prop.load(input); | ||
| 42 | |||
| 43 | this.regkey=String.valueOf(prop.getProperty("regkey")); | ||
| 44 | this.service=String.valueOf(prop.getProperty("service")); | ||
| 45 | |||
| 46 | this.proxyEnabled=Boolean.valueOf(prop.getProperty("proxyEnabled")); | ||
| 47 | this.proxyServer=String.valueOf(prop.getProperty("proxyServer")); | ||
| 48 | this.proxyPort=Integer.valueOf(prop.getProperty("proxyPort")); | ||
| 49 | |||
| 50 | |||
| 51 | //029d10ca-22c3-4303-8fc0-2d2c586990a1 | ||
| 52 | |||
| 53 | |||
| 54 | this.version=String.valueOf(prop.getProperty("version")); | ||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | } catch (IOException ex) { | ||
| 62 | |||
| 63 | logger.error(ex.getMessage()); | ||
| 64 | |||
| 65 | } finally { | ||
| 66 | if (input != null) { | ||
| 67 | try { | ||
| 68 | input.close(); | ||
| 69 | } catch (IOException e) { | ||
| 70 | |||
| 71 | logger.error(e.getMessage()); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | } | ||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | public void Save() { | ||
| 81 | |||
| 82 | OutputStream output = null; | ||
| 83 | |||
| 84 | try { | ||
| 85 | |||
| 86 | output = new FileOutputStream("szsterminal.properties"); | ||
| 87 | |||
| 88 | prop.setProperty("regkey", String.valueOf(this.regkey)); | ||
| 89 | // prop.setProperty("service", String.valueOf(this.service)); | ||
| 90 | prop.setProperty("proxyEnabled", String.valueOf(this.proxyEnabled)); | ||
| 91 | prop.setProperty("proxyServer", String.valueOf(this.proxyServer)); | ||
| 92 | prop.setProperty("proxyPort", String.valueOf(this.proxyPort)); | ||
| 93 | |||
| 94 | prop.setProperty("version", String.valueOf(this.version)); | ||
| 95 | |||
| 96 | prop.store(output, null); | ||
| 97 | |||
| 98 | } catch (IOException io) { | ||
| 99 | |||
| 100 | } finally { | ||
| 101 | if (output != null) { | ||
| 102 | try { | ||
| 103 | output.close(); | ||
| 104 | } catch (IOException e) { | ||
| 105 | |||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | |||
| 113 | /* | ||
| 114 | * Get | ||
| 115 | */ | ||
| 116 | |||
| 117 | public String getRegKey() { | ||
| 118 | return this.regkey; | ||
| 119 | } | ||
| 120 | public String getService() { | ||
| 121 | return this.service; | ||
| 122 | } | ||
| 123 | |||
| 124 | public boolean getProxyEnabled() { | ||
| 125 | return this.proxyEnabled; | ||
| 126 | } | ||
| 127 | public String getProxyServer() { | ||
| 128 | return this.proxyServer; | ||
| 129 | } | ||
| 130 | public int getProxyPort() { | ||
| 131 | return this.proxyPort; | ||
| 132 | } | ||
| 133 | public String getVersion() { | ||
| 134 | return this.version; | ||
| 135 | } | ||
| 136 | |||
| 137 | |||
| 138 | /* | ||
| 139 | * Set | ||
| 140 | */ | ||
| 141 | |||
| 142 | public void setRegkey(String value){ | ||
| 143 | this.regkey=value; | ||
| 144 | } | ||
| 145 | public void setService(String value){ | ||
| 146 | this.service=value; | ||
| 147 | } | ||
| 148 | |||
| 149 | public void setProxyEnabled(boolean value){ | ||
| 150 | this.proxyEnabled=value; | ||
| 151 | } | ||
| 152 | public void setProxyServer(String value){ | ||
| 153 | this.proxyServer=value; | ||
| 154 | } | ||
| 155 | public void setProxyPort(int value){ | ||
| 156 | this.proxyPort=value; | ||
| 157 | } | ||
| 158 | |||
| 159 | |||
| 160 | |||
| 161 | public void setVersion(String version) { | ||
| 162 | this.version=version; | ||
| 163 | } | ||
| 164 | |||
| 165 | |||
| 166 | } | ||
| 167 | |||
| 168 | |||
| 169 | |||
| 170 | |||
| 171 |
| 1 | #include <jni.h> | ||
| 2 | #include <stdio.h> | ||
| 3 | #include "model_SirenJNI.h" | ||
| 4 | #include <fcntl.h> | ||
| 5 | #include <errno.h> | ||
| 6 | #include <sys/types.h> | ||
| 7 | #include <sys/stat.h> | ||
| 8 | #include <asm/ioctl.h> | ||
| 9 | #include <linux/parport.h> | ||
| 10 | #include <linux/ppdev.h> | ||
| 11 | |||
| 12 | #define DEVICE "/dev/parport0" | ||
| 13 | |||
| 14 | JNIEXPORT void JNICALL Java_model_SirenJNI_sirenOn(JNIEnv *env, jobject obj) { | ||
| 15 | |||
| 16 | |||
| 17 | int fd = open(DEVICE, O_WRONLY | O_NOCTTY | O_NDELAY); | ||
| 18 | if (fd < 0) { | ||
| 19 | // fprintf(stderr, "can not open %s\n", DEVICE); | ||
| 20 | return; | ||
| 21 | } | ||
| 22 | |||
| 23 | if(ioctl(fd, PPCLAIM)) { | ||
| 24 | perror("PPCLAIM"); | ||
| 25 | close(fd); | ||
| 26 | return; | ||
| 27 | } | ||
| 28 | |||
| 29 | unsigned char data = 255; | ||
| 30 | |||
| 31 | if (ioctl(fd, PPWDATA, &data) < 0) | ||
| 32 | perror("ioctl()"); | ||
| 33 | |||
| 34 | |||
| 35 | ioctl(fd, PPRELEASE); | ||
| 36 | close(fd); | ||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | return; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | JNIEXPORT void JNICALL Java_model_SirenJNI_sirenOff (JNIEnv *env, jobject obj) { | ||
| 45 | |||
| 46 | int fd = open(DEVICE, O_WRONLY | O_NOCTTY | O_NDELAY); | ||
| 47 | if (fd < 0) { | ||
| 48 | // fprintf(stderr, "can not open %s\n", DEVICE); | ||
| 49 | return; | ||
| 50 | } | ||
| 51 | |||
| 52 | if(ioctl(fd, PPCLAIM)) { | ||
| 53 | perror("PPCLAIM"); | ||
| 54 | close(fd); | ||
| 55 | return; | ||
| 56 | } | ||
| 57 | |||
| 58 | unsigned char data = 0; | ||
| 59 | |||
| 60 | if (ioctl(fd, PPWDATA, &data) < 0) | ||
| 61 | perror("ioctl()"); | ||
| 62 | |||
| 63 | |||
| 64 | ioctl(fd, PPRELEASE); | ||
| 65 | close(fd); | ||
| 66 | |||
| 67 | return; | ||
| 68 | } | ||
| 69 |
No preview for this file type
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | #gcc -std=gnu99 -shared -fPIC -c Siren.c -L/usr/local/lib/lisiren.so -I /usr/java/jdk1.7.0_04/include/ -I /usr/java/jdk1.7.0_04/include/linux/ | ||
| 6 | #gcc -shared Siren.o -shared -o libsiren.so -Wl,-soname,siren | ||
| 7 | |||
| 8 | |||
| 9 | gcc -std=gnu99 -shared -fPIC -c Siren.c -L/usr/local/lib/lisiren.so -I /usr/lib/jvm/java-1.7.0-openjdk-amd64/include -I /usr/lib/jvm/java-1.7.0-openjdk-amd64/include/linux/ | ||
| 10 | gcc -shared Siren.o -shared -o libsiren.so -Wl,-soname,siren | ||
| 11 |
No preview for this file type
| 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ | ||
| 2 | #include <jni.h> | ||
| 3 | /* Header for class model_SirenJNI */ | ||
| 4 | |||
| 5 | #ifndef _Included_model_SirenJNI | ||
| 6 | #define _Included_model_SirenJNI | ||
| 7 | #ifdef __cplusplus | ||
| 8 | extern "C" { | ||
| 9 | #endif | ||
| 10 | /* | ||
| 11 | * Class: model_SirenJNI | ||
| 12 | * Method: sirenOn | ||
| 13 | * Signature: ()V | ||
| 14 | */ | ||
| 15 | JNIEXPORT void JNICALL Java_model_SirenJNI_sirenOn | ||
| 16 | (JNIEnv *, jobject); | ||
| 17 | |||
| 18 | /* | ||
| 19 | * Class: model_SirenJNI | ||
| 20 | * Method: sirenOff | ||
| 21 | * Signature: ()V | ||
| 22 | */ | ||
| 23 | JNIEXPORT void JNICALL Java_model_SirenJNI_sirenOff | ||
| 24 | (JNIEnv *, jobject); | ||
| 25 | |||
| 26 | #ifdef __cplusplus | ||
| 27 | } | ||
| 28 | #endif | ||
| 29 | #endif |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | import java.io.File; | ||
| 4 | import java.io.IOException; | ||
| 5 | |||
| 6 | import javax.sound.sampled.AudioFormat; | ||
| 7 | import javax.sound.sampled.AudioInputStream; | ||
| 8 | import javax.sound.sampled.AudioSystem; | ||
| 9 | import javax.sound.sampled.DataLine; | ||
| 10 | import javax.sound.sampled.FloatControl; | ||
| 11 | import javax.sound.sampled.LineUnavailableException; | ||
| 12 | import javax.sound.sampled.SourceDataLine; | ||
| 13 | import javax.sound.sampled.UnsupportedAudioFileException; | ||
| 14 | |||
| 15 | import java.net.*; | ||
| 16 | |||
| 17 | public class AePlayWave extends Thread { | ||
| 18 | |||
| 19 | private String filename; | ||
| 20 | |||
| 21 | private Position curPosition; | ||
| 22 | |||
| 23 | private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb | ||
| 24 | |||
| 25 | enum Position { | ||
| 26 | LEFT, RIGHT, NORMAL | ||
| 27 | }; | ||
| 28 | |||
| 29 | public AePlayWave(String wavfile) { | ||
| 30 | filename = wavfile; | ||
| 31 | curPosition = Position.NORMAL; | ||
| 32 | } | ||
| 33 | |||
| 34 | public AePlayWave(String wavfile, Position p) { | ||
| 35 | filename = wavfile; | ||
| 36 | curPosition = p; | ||
| 37 | } | ||
| 38 | |||
| 39 | public void run() { | ||
| 40 | |||
| 41 | // URL url= getClass().getResource(filename); | ||
| 42 | // URL jarLocation = | ||
| 43 | // getClass().getProtectionDomain().getCodeSource().getLocation(); | ||
| 44 | // URL dataXML = new URL(jarLocation, "config.xml"); | ||
| 45 | |||
| 46 | // URL url; | ||
| 47 | |||
| 48 | // url = this.getClass().getResource("/config.xml"); | ||
| 49 | |||
| 50 | try { | ||
| 51 | |||
| 52 | File soundFile = new File(getClass().getResource(filename) | ||
| 53 | .getFile()); | ||
| 54 | if (!soundFile.exists()) { | ||
| 55 | System.err.println("Wave file not found: " + filename); | ||
| 56 | return; | ||
| 57 | } | ||
| 58 | |||
| 59 | AudioInputStream audioInputStream = null; | ||
| 60 | try { | ||
| 61 | audioInputStream = AudioSystem.getAudioInputStream(soundFile); | ||
| 62 | } catch (UnsupportedAudioFileException e1) { | ||
| 63 | e1.printStackTrace(); | ||
| 64 | return; | ||
| 65 | } catch (IOException e1) { | ||
| 66 | e1.printStackTrace(); | ||
| 67 | return; | ||
| 68 | } | ||
| 69 | |||
| 70 | AudioFormat format = audioInputStream.getFormat(); | ||
| 71 | SourceDataLine auline = null; | ||
| 72 | DataLine.Info info = new DataLine.Info(SourceDataLine.class, format); | ||
| 73 | |||
| 74 | try { | ||
| 75 | auline = (SourceDataLine) AudioSystem.getLine(info); | ||
| 76 | auline.open(format); | ||
| 77 | } catch (LineUnavailableException e) { | ||
| 78 | e.printStackTrace(); | ||
| 79 | return; | ||
| 80 | } catch (Exception e) { | ||
| 81 | e.printStackTrace(); | ||
| 82 | return; | ||
| 83 | } | ||
| 84 | |||
| 85 | if (auline.isControlSupported(FloatControl.Type.PAN)) { | ||
| 86 | FloatControl pan = (FloatControl) auline | ||
| 87 | .getControl(FloatControl.Type.PAN); | ||
| 88 | if (curPosition == Position.RIGHT) | ||
| 89 | pan.setValue(1.0f); | ||
| 90 | else if (curPosition == Position.LEFT) | ||
| 91 | pan.setValue(-1.0f); | ||
| 92 | } | ||
| 93 | |||
| 94 | auline.start(); | ||
| 95 | int nBytesRead = 0; | ||
| 96 | byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; | ||
| 97 | |||
| 98 | try { | ||
| 99 | while (nBytesRead != -1) { | ||
| 100 | nBytesRead = audioInputStream | ||
| 101 | .read(abData, 0, abData.length); | ||
| 102 | if (nBytesRead >= 0) | ||
| 103 | auline.write(abData, 0, nBytesRead); | ||
| 104 | } | ||
| 105 | } catch (IOException e) { | ||
| 106 | e.printStackTrace(); | ||
| 107 | return; | ||
| 108 | } finally { | ||
| 109 | auline.drain(); | ||
| 110 | auline.close(); | ||
| 111 | } | ||
| 112 | |||
| 113 | } catch (Exception e1) { | ||
| 114 | } | ||
| 115 | |||
| 116 | } | ||
| 117 | } |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | public class EventAgk { | ||
| 4 | |||
| 5 | public long id; | ||
| 6 | public int id_agk; | ||
| 7 | |||
| 8 | public String river; | ||
| 9 | public String datetime; | ||
| 10 | public String value; | ||
| 11 | |||
| 12 | public int id_status; // 0-norm, 1-nj-2, oj; | ||
| 13 | public boolean repair; // true -repair; false- no repair | ||
| 14 | public boolean opendoor; // true - open; false-close | ||
| 15 | public boolean veracity; // veracity -true, no veracity -false; | ||
| 16 | |||
| 17 | } |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | import java.awt.Color; | ||
| 4 | import java.awt.Component; | ||
| 5 | import java.awt.Font; | ||
| 6 | import java.awt.Image; | ||
| 7 | |||
| 8 | import javax.swing.*; | ||
| 9 | import javax.swing.table.DefaultTableCellRenderer; | ||
| 10 | import javax.swing.table.TableCellRenderer; | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | import java.awt.*; | ||
| 15 | |||
| 16 | public class EventCellRenderer implements TableCellRenderer { | ||
| 17 | public Component getTableCellRendererComponent(JTable table, Object value, | ||
| 18 | boolean isSelected, boolean hasFocus, int row, int column) { | ||
| 19 | MdlEvent event = (MdlEvent) value; | ||
| 20 | |||
| 21 | JPanel panel = new JPanel(); | ||
| 22 | panel.setLayout(null); | ||
| 23 | |||
| 24 | // Row1 | ||
| 25 | |||
| 26 | // DateTime | ||
| 27 | JLabel lblTitleDateTime = new JLabel(); | ||
| 28 | lblTitleDateTime.setBounds(5, 0, 170, 17); | ||
| 29 | lblTitleDateTime.setForeground(Color.BLUE); | ||
| 30 | lblTitleDateTime.setIcon(event.getIconDateTimeSmall()); | ||
| 31 | lblTitleDateTime.setText(event.getDateTime()); | ||
| 32 | panel.add(lblTitleDateTime); | ||
| 33 | |||
| 34 | // Title Status | ||
| 35 | JLabel lblTitleStatus = new JLabel(); | ||
| 36 | lblTitleStatus.setBounds(185, 0, 300, 17); | ||
| 37 | lblTitleStatus.setForeground(event.getColorStatus()); | ||
| 38 | lblTitleStatus.setText(event.getTitleStatusForConfirm()); | ||
| 39 | lblTitleStatus.setIcon(event.getIconStatusSmall()); | ||
| 40 | panel.add(lblTitleStatus); | ||
| 41 | |||
| 42 | // TitleRiver | ||
| 43 | JLabel lblTitleRiver = new JLabel(); | ||
| 44 | lblTitleRiver.setBounds(500, 0, 250, 17); | ||
| 45 | lblTitleRiver.setForeground(Color.BLUE); | ||
| 46 | lblTitleRiver.setText(event.getTitleRiver()); | ||
| 47 | lblTitleRiver.setIcon(event.getIconRiverSmall()); | ||
| 48 | panel.add(lblTitleRiver); | ||
| 49 | |||
| 50 | // Row2 | ||
| 51 | |||
| 52 | // TitileAGK | ||
| 53 | JLabel lblTitleAgk = new JLabel(); | ||
| 54 | lblTitleAgk.setBounds(5, 18, 80, 17); | ||
| 55 | lblTitleAgk.setForeground(Color.BLUE); | ||
| 56 | lblTitleAgk.setText(event.getTitleAgk()); | ||
| 57 | lblTitleAgk.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 58 | panel.add(lblTitleAgk); | ||
| 59 | |||
| 60 | // Title Repair | ||
| 61 | |||
| 62 | JLabel lblTitleRepair = new JLabel(); | ||
| 63 | lblTitleRepair.setBounds(100, 18, 170, 17); | ||
| 64 | lblTitleRepair.setForeground(Color.BLUE); | ||
| 65 | lblTitleRepair.setIcon(event.getIconRepairSmall()); | ||
| 66 | lblTitleRepair.setText(event.getTitleRepair()); | ||
| 67 | lblTitleRepair.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 68 | panel.add(lblTitleRepair); | ||
| 69 | |||
| 70 | // Title box | ||
| 71 | |||
| 72 | JLabel lblTitleBox = new JLabel(); | ||
| 73 | lblTitleBox.setBounds(280, 18, 170, 17); | ||
| 74 | lblTitleBox.setForeground(Color.BLUE); | ||
| 75 | lblTitleBox.setIcon(event.getIconOpenDoorSmall()); | ||
| 76 | lblTitleBox.setText(event.getTitleOpenDorr()); | ||
| 77 | lblTitleBox.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 78 | panel.add(lblTitleBox); | ||
| 79 | |||
| 80 | // Title veracity | ||
| 81 | JLabel lblTitleVeracity = new JLabel(); | ||
| 82 | lblTitleVeracity.setBounds(450, 18, 200, 17); | ||
| 83 | lblTitleVeracity.setForeground(Color.BLUE); | ||
| 84 | lblTitleVeracity.setIcon(event.getIconVeracitySmall()); | ||
| 85 | lblTitleVeracity.setText(event.getTitleVeracity()); | ||
| 86 | lblTitleVeracity.setFont(new Font(null, Font.ITALIC, 11)); | ||
| 87 | panel.add(lblTitleVeracity); | ||
| 88 | |||
| 89 | panel.setBackground(event.getColorLogPanel()); | ||
| 90 | |||
| 91 | return panel; | ||
| 92 | } | ||
| 93 | } |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | import java.util.HashSet; | ||
| 4 | import java.util.List; | ||
| 5 | import java.util.Set; | ||
| 6 | |||
| 7 | import javax.swing.event.TableModelListener; | ||
| 8 | import javax.swing.table.TableModel; | ||
| 9 | import javax.swing.table.TableCellRenderer; | ||
| 10 | |||
| 11 | import java.util.ArrayList; | ||
| 12 | |||
| 13 | import javax.swing.*; | ||
| 14 | import javax.swing.event.TableModelListener; | ||
| 15 | import javax.swing.table.TableCellRenderer; | ||
| 16 | import javax.swing.table.TableModel; | ||
| 17 | import javax.swing.table.AbstractTableModel; | ||
| 18 | |||
| 19 | import java.awt.*; | ||
| 20 | import java.text.MessageFormat; | ||
| 21 | import java.text.NumberFormat; | ||
| 22 | import java.text.SimpleDateFormat; | ||
| 23 | import java.util.Date; | ||
| 24 | |||
| 25 | public class EventTableModel extends AbstractTableModel { | ||
| 26 | |||
| 27 | private Set<TableModelListener> listeners = new HashSet<TableModelListener>(); | ||
| 28 | |||
| 29 | private List<MdlEvent> event; | ||
| 30 | private List<MdlEvent> eventsource; | ||
| 31 | |||
| 32 | private int start = 0; | ||
| 33 | private int end = 9; | ||
| 34 | |||
| 35 | public int getSize() { | ||
| 36 | return eventsource.size(); | ||
| 37 | } | ||
| 38 | |||
| 39 | public void AddRow(MdlEvent event) { | ||
| 40 | eventsource.add(0, event); | ||
| 41 | |||
| 42 | for (int i = 0; i < eventsource.size(); i++) { | ||
| 43 | MdlEvent obj = eventsource.get(i); | ||
| 44 | // if (obj.IsOld()) | ||
| 45 | // eventsource.remove(i); | ||
| 46 | } | ||
| 47 | |||
| 48 | Update(start, end); | ||
| 49 | } | ||
| 50 | |||
| 51 | public void Update(int start, int end) { | ||
| 52 | |||
| 53 | this.start = start; | ||
| 54 | this.end = end; | ||
| 55 | event = new ArrayList<MdlEvent>(); | ||
| 56 | |||
| 57 | try { | ||
| 58 | for (int i = start; i < end; i++) | ||
| 59 | event.add(eventsource.get(i)); | ||
| 60 | } catch (Exception ex) { | ||
| 61 | |||
| 62 | } | ||
| 63 | |||
| 64 | } | ||
| 65 | |||
| 66 | public void Update() { | ||
| 67 | |||
| 68 | event = new ArrayList<MdlEvent>(); | ||
| 69 | |||
| 70 | try { | ||
| 71 | for (int i = start; i < end; i++) | ||
| 72 | event.add(eventsource.get(i)); | ||
| 73 | |||
| 74 | } catch (Exception ex) { | ||
| 75 | |||
| 76 | } | ||
| 77 | |||
| 78 | } | ||
| 79 | |||
| 80 | public void RemoveOld() { | ||
| 81 | try { | ||
| 82 | ArrayList<MdlEvent> buff = new ArrayList<MdlEvent>(); | ||
| 83 | |||
| 84 | for (int i = 0; i < eventsource.size(); i++) | ||
| 85 | buff.add(eventsource.get(i)); | ||
| 86 | |||
| 87 | this.eventsource = buff; | ||
| 88 | |||
| 89 | } catch (Exception e) { | ||
| 90 | } | ||
| 91 | |||
| 92 | } | ||
| 93 | |||
| 94 | public EventTableModel(List<MdlEvent> event) { | ||
| 95 | this.eventsource = event; | ||
| 96 | |||
| 97 | } | ||
| 98 | |||
| 99 | public EventTableModel() { | ||
| 100 | List<MdlEvent> initList = new ArrayList<MdlEvent>(); | ||
| 101 | // for (int i=0;i<100;i++) | ||
| 102 | // { | ||
| 103 | // LRTable lrtable=new | ||
| 104 | // LRTable(i,"River "+i,i,"20.11.2013 8:00","7.5"+i); | ||
| 105 | // initList.add(0,lrtable); | ||
| 106 | // } | ||
| 107 | this.event = initList; | ||
| 108 | this.eventsource = initList; | ||
| 109 | } | ||
| 110 | |||
| 111 | public Class getColumnClass(int columnIndex) { | ||
| 112 | return MdlEvent.class; | ||
| 113 | } | ||
| 114 | |||
| 115 | public int getColumnCount() { | ||
| 116 | return 1; | ||
| 117 | } | ||
| 118 | |||
| 119 | public String getColumnName(int columnIndex) { | ||
| 120 | return "Event"; | ||
| 121 | } | ||
| 122 | |||
| 123 | public int getRowCount() { | ||
| 124 | return (event == null) ? 0 : event.size(); | ||
| 125 | } | ||
| 126 | |||
| 127 | public Object getValueAt(int rowIndex, int columnIndex) { | ||
| 128 | return (event == null) ? null : event.get(rowIndex); | ||
| 129 | } | ||
| 130 | |||
| 131 | public boolean isCellEditable(int columnIndex, int rowIndex) { | ||
| 132 | return true; | ||
| 133 | } | ||
| 134 | |||
| 135 | } |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | |||
| 4 | import java.io.*; | ||
| 5 | |||
| 6 | public class LinuxCMD { | ||
| 7 | |||
| 8 | |||
| 9 | public void ConfigLanStatic(String eth, String address, String gateway, String netmask, String password) { | ||
| 10 | |||
| 11 | |||
| 12 | String pas = password; | ||
| 13 | |||
| 14 | String[] array= { "nano"}; | ||
| 15 | |||
| 16 | |||
| 17 | Process proc = null; | ||
| 18 | BufferedWriter writer = null; | ||
| 19 | try | ||
| 20 | { | ||
| 21 | proc = Runtime.getRuntime().exec(array); | ||
| 22 | writer = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())); | ||
| 23 | writer.write(pas); | ||
| 24 | } | ||
| 25 | catch (IOException e) | ||
| 26 | { | ||
| 27 | |||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | public void RestartInterfaces() { | ||
| 34 | |||
| 35 | |||
| 36 | String[] array= { "/etc/init.d/networking restart"}; | ||
| 37 | |||
| 38 | |||
| 39 | Process proc = null; | ||
| 40 | BufferedWriter writer = null; | ||
| 41 | try | ||
| 42 | { | ||
| 43 | proc = Runtime.getRuntime().exec(array); | ||
| 44 | try { | ||
| 45 | int res=proc.waitFor(); | ||
| 46 | } | ||
| 47 | catch (Exception e) { | ||
| 48 | |||
| 49 | } | ||
| 50 | // writer = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream())); | ||
| 51 | // writer.write(pas); | ||
| 52 | } | ||
| 53 | catch (IOException e) | ||
| 54 | { | ||
| 55 | |||
| 56 | } | ||
| 57 | |||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | } | ||
| 63 | |||
| 64 | public void ConfigLanDHCP(String eth, String password) { | ||
| 65 | |||
| 66 | try | ||
| 67 | { | ||
| 68 | |||
| 69 | |||
| 70 | } | ||
| 71 | catch(Exception e) { | ||
| 72 | |||
| 73 | |||
| 74 | } | ||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | public void InstallTiemViewer() { | ||
| 82 | |||
| 83 | |||
| 84 | } | ||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | } |
This diff is collapsed.
Click to expand it.
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | import java.util.List; | ||
| 4 | import java.util.ArrayList; | ||
| 5 | |||
| 6 | public class ModelResponse { | ||
| 7 | |||
| 8 | public String titlesubscriber; | ||
| 9 | |||
| 10 | public String titlecontact; | ||
| 11 | |||
| 12 | public boolean siren; | ||
| 13 | |||
| 14 | public boolean updateguid; | ||
| 15 | |||
| 16 | public List<EventAgk> lsteventagkconfirm; | ||
| 17 | |||
| 18 | public List<EventAgk> lsteventagkstate; | ||
| 19 | |||
| 20 | } |
No preview for this file type
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | import java.io.*; | ||
| 4 | import java.util.*; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * This class is an auto-resizable String array. It has similar methods to ArrayList | ||
| 8 | * | ||
| 9 | * @author Henry Zheng | ||
| 10 | * @url http://www.ireasoning.com | ||
| 11 | */ | ||
| 12 | |||
| 13 | public class StringArray implements Serializable | ||
| 14 | { | ||
| 15 | public static final int DEFAULT_CAPACITY = 10; | ||
| 16 | |||
| 17 | protected String[] _strings = null; | ||
| 18 | protected int _upperBound = 0; | ||
| 19 | protected int _capacity = DEFAULT_CAPACITY; | ||
| 20 | protected int _initialSize = _capacity; | ||
| 21 | protected float _loadFactory = 1.5F; | ||
| 22 | |||
| 23 | public StringArray () | ||
| 24 | { | ||
| 25 | this(DEFAULT_CAPACITY); | ||
| 26 | } | ||
| 27 | |||
| 28 | public StringArray( int size) | ||
| 29 | { | ||
| 30 | _capacity = size; | ||
| 31 | _initialSize = size; | ||
| 32 | _strings = new String[size]; | ||
| 33 | } | ||
| 34 | |||
| 35 | public synchronized void ensureCapacity(int capacity) | ||
| 36 | { | ||
| 37 | if(_capacity < capacity) | ||
| 38 | { | ||
| 39 | _capacity = (_capacity * 3)/2 + 1; | ||
| 40 | if(_capacity < capacity) | ||
| 41 | { | ||
| 42 | _capacity = capacity; | ||
| 43 | } | ||
| 44 | String [] oldData = _strings; | ||
| 45 | _strings = new String[_capacity]; | ||
| 46 | System.arraycopy(oldData, 0, _strings, 0, _upperBound); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | public synchronized void add(String s) | ||
| 52 | { | ||
| 53 | if(_upperBound == _capacity ) | ||
| 54 | { | ||
| 55 | resize((int) (_capacity * _loadFactory)); | ||
| 56 | } | ||
| 57 | _strings[_upperBound++] = s; | ||
| 58 | } | ||
| 59 | |||
| 60 | public synchronized void add(StringArray sa) | ||
| 61 | { | ||
| 62 | for (int i = 0; i < sa.size() ; i++) | ||
| 63 | { | ||
| 64 | add(sa.get(i)); | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | public synchronized String get(int index) | ||
| 69 | { | ||
| 70 | return _strings[index]; | ||
| 71 | } | ||
| 72 | |||
| 73 | public synchronized void set(int index, String newVal) | ||
| 74 | { | ||
| 75 | _strings[index] = newVal; | ||
| 76 | } | ||
| 77 | |||
| 78 | /** Adds all elements in passed string array */ | ||
| 79 | public synchronized void add(String [] strs) | ||
| 80 | { | ||
| 81 | for (int i = 0; i < strs.length ; i++) | ||
| 82 | { | ||
| 83 | add(strs[i]); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | /** Resets this object. */ | ||
| 88 | public synchronized void clear() | ||
| 89 | { | ||
| 90 | _capacity = _initialSize; | ||
| 91 | _strings = new String[_capacity]; | ||
| 92 | _upperBound = 0; | ||
| 93 | |||
| 94 | } | ||
| 95 | |||
| 96 | public synchronized String remove(int index) | ||
| 97 | { | ||
| 98 | if(index >= _upperBound ) | ||
| 99 | { | ||
| 100 | throw new IndexOutOfBoundsException(); | ||
| 101 | } | ||
| 102 | String s = _strings[index]; | ||
| 103 | for (int i = index; i < _upperBound - 1 ; i++) | ||
| 104 | { | ||
| 105 | _strings[i] = _strings[i + 1]; | ||
| 106 | } | ||
| 107 | _upperBound --; | ||
| 108 | return s; | ||
| 109 | } | ||
| 110 | |||
| 111 | /** | ||
| 112 | * Removes the first occurance of passed str | ||
| 113 | * @return the string removed, or null if not found | ||
| 114 | */ | ||
| 115 | public synchronized String remove(String str) | ||
| 116 | { | ||
| 117 | for (int i = 0; i < _upperBound ; i++) | ||
| 118 | { | ||
| 119 | if(_strings[i].equals(str)) | ||
| 120 | { | ||
| 121 | return remove(i); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | return null; | ||
| 125 | } | ||
| 126 | |||
| 127 | public synchronized int size() | ||
| 128 | { | ||
| 129 | return _upperBound; | ||
| 130 | } | ||
| 131 | |||
| 132 | public synchronized boolean isEmpty() | ||
| 133 | { | ||
| 134 | return _upperBound == 0; | ||
| 135 | } | ||
| 136 | |||
| 137 | public synchronized String[] toArray() | ||
| 138 | { | ||
| 139 | String [] ret = new String[_upperBound]; | ||
| 140 | for (int i = 0; i < _upperBound ; i++) | ||
| 141 | { | ||
| 142 | ret[i] = _strings[i]; | ||
| 143 | } | ||
| 144 | return ret; | ||
| 145 | } | ||
| 146 | |||
| 147 | protected synchronized void resize(int newCapacity) | ||
| 148 | { | ||
| 149 | String [] as = new String[newCapacity]; | ||
| 150 | for (int i = 0; i < _strings.length ; i++) | ||
| 151 | { | ||
| 152 | as[i] = _strings[i]; | ||
| 153 | } | ||
| 154 | _strings = as; | ||
| 155 | _capacity = newCapacity; | ||
| 156 | } | ||
| 157 | |||
| 158 | public String toString() | ||
| 159 | { | ||
| 160 | StringBuffer buf = new StringBuffer(); | ||
| 161 | for (int i = 0; i < _upperBound ; i++) | ||
| 162 | { | ||
| 163 | buf.append(_strings[i] + "\n"); | ||
| 164 | } | ||
| 165 | return buf.toString(); | ||
| 166 | } | ||
| 167 | |||
| 168 | public static void main(String[] args) | ||
| 169 | { | ||
| 170 | StringArray as = new StringArray(); | ||
| 171 | String [] ss = null; | ||
| 172 | ss = as.toArray(); | ||
| 173 | // System.out.println( "ss len="+ss.length); | ||
| 174 | // System.out.println( "ss = " + ss); | ||
| 175 | for (int i = 0; i < 10 ; i++) | ||
| 176 | { | ||
| 177 | as.add("" + i); | ||
| 178 | } | ||
| 179 | // System.out.println( "size = " + as.size()); | ||
| 180 | ss = as.toArray(); | ||
| 181 | for (int i = 0; i < ss.length ; i++) | ||
| 182 | { | ||
| 183 | // System.out.println( ss[i]); | ||
| 184 | } | ||
| 185 | // System.out.println( "remove 5th element."); | ||
| 186 | as.remove(5); | ||
| 187 | |||
| 188 | // System.out.println( "size = " + as.size()); | ||
| 189 | ss = as.toArray(); | ||
| 190 | for (int i = 0; i < ss.length ; i++) | ||
| 191 | { | ||
| 192 | // System.out.println( ss[i]); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | }//end of class StringArray | ||
| 196 | |||
| 197 | |||
| 198 |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | import java.io.*; | ||
| 4 | import java.util.*; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * This class perform similar functionality to StringTokenizer class but faster. | ||
| 8 | * The difference is StringTokenizer doesn't count empty token, but this class does. | ||
| 9 | * | ||
| 10 | * @author Henry Zheng | ||
| 11 | * @url http://www.ireasoning.com | ||
| 12 | */ | ||
| 13 | public class Tokenizer | ||
| 14 | { | ||
| 15 | private Tokenizer() | ||
| 16 | { | ||
| 17 | } | ||
| 18 | |||
| 19 | /** | ||
| 20 | * It's different from the other parse method in that it checks left and right string first, which take higer | ||
| 21 | * priority than the delimiter. For example, if left and right is ", for string a:b:1"c:d"2:3 , | ||
| 22 | * it returns { a, b, 1"c:d"2, 3 } | ||
| 23 | * @param left the openning tag of higher priority token | ||
| 24 | * @param right the closing tag of higher priority token | ||
| 25 | * @trimEachToken if true, each token will be trim by calling String.trim() | ||
| 26 | */ | ||
| 27 | public static String[] parse(String text, char delimiter, boolean trimEachToken, String left, String right) | ||
| 28 | { | ||
| 29 | if(text == null) return null; | ||
| 30 | int len = text.length(); | ||
| 31 | StringArray tokens = new StringArray(); | ||
| 32 | int pos1 = -1; | ||
| 33 | int pos2 = -1; | ||
| 34 | int firstPos = -1; | ||
| 35 | while(true) | ||
| 36 | { | ||
| 37 | pos2 = text.indexOf(delimiter, firstPos + 1); | ||
| 38 | if(pos2 < 0 ) | ||
| 39 | { | ||
| 40 | String str = text.substring(pos1 + 1); | ||
| 41 | if(trimEachToken ) | ||
| 42 | { | ||
| 43 | str = str.trim(); | ||
| 44 | } | ||
| 45 | tokens.add(str); | ||
| 46 | break; | ||
| 47 | } | ||
| 48 | if(pos2 == pos1 + 1) | ||
| 49 | { | ||
| 50 | tokens.add(""); | ||
| 51 | } | ||
| 52 | else | ||
| 53 | { | ||
| 54 | int tagPos1 = text.indexOf(left, firstPos + 1); | ||
| 55 | if(tagPos1 > 0 && tagPos1 < pos2 ) | ||
| 56 | { | ||
| 57 | int tagPos2 = text.indexOf(right, tagPos1 + 1); | ||
| 58 | if(tagPos2 > 0) | ||
| 59 | { | ||
| 60 | firstPos = tagPos2; | ||
| 61 | continue; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | String str = text.substring(pos1 + 1, pos2); | ||
| 65 | if(trimEachToken ) | ||
| 66 | { | ||
| 67 | str = str.trim(); | ||
| 68 | } | ||
| 69 | tokens.add(str); | ||
| 70 | } | ||
| 71 | pos1 = pos2; | ||
| 72 | firstPos = pos1; | ||
| 73 | } | ||
| 74 | String[] ret = tokens.toArray(); | ||
| 75 | return ret; | ||
| 76 | } | ||
| 77 | |||
| 78 | /** | ||
| 79 | * @trimEachToken if true, each token will be trim by calling String.trim() | ||
| 80 | */ | ||
| 81 | public static String[] parse(String text, char delimiter, boolean trimEachToken) | ||
| 82 | { | ||
| 83 | return parse(text, delimiter, trimEachToken, false); | ||
| 84 | } | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @trimEachToken if true, each token will be trim by calling String.trim() | ||
| 88 | */ | ||
| 89 | public static String[] parse(String text, char delimiter, boolean trimEachToken, boolean ignoreEmptyToken) | ||
| 90 | { | ||
| 91 | if(text == null) return null; | ||
| 92 | int len = text.length(); | ||
| 93 | StringArray tokens = new StringArray(); | ||
| 94 | int pos1 = -1; | ||
| 95 | int pos2 = -1; | ||
| 96 | while(true) | ||
| 97 | { | ||
| 98 | pos2 = text.indexOf(delimiter, pos1 + 1); | ||
| 99 | if(pos2 < 0 ) | ||
| 100 | { | ||
| 101 | String str = text.substring(pos1 + 1); | ||
| 102 | if(trimEachToken ) | ||
| 103 | { | ||
| 104 | str = str.trim(); | ||
| 105 | } | ||
| 106 | if(ignoreEmptyToken) | ||
| 107 | { | ||
| 108 | if(str.length() != 0) tokens.add(str); | ||
| 109 | } | ||
| 110 | else | ||
| 111 | { | ||
| 112 | tokens.add(str); | ||
| 113 | } | ||
| 114 | break; | ||
| 115 | } | ||
| 116 | if(pos2 == pos1 + 1) | ||
| 117 | { | ||
| 118 | if(!ignoreEmptyToken) { tokens.add(""); } | ||
| 119 | } | ||
| 120 | else | ||
| 121 | { | ||
| 122 | String str = text.substring(pos1 + 1, pos2); | ||
| 123 | if(trimEachToken ) | ||
| 124 | { | ||
| 125 | str = str.trim(); | ||
| 126 | } | ||
| 127 | if(ignoreEmptyToken) | ||
| 128 | { | ||
| 129 | if(str.length() != 0) tokens.add(str); | ||
| 130 | } | ||
| 131 | else | ||
| 132 | { | ||
| 133 | tokens.add(str); | ||
| 134 | } | ||
| 135 | } | ||
| 136 | pos1 = pos2; | ||
| 137 | } | ||
| 138 | String[] ret = tokens.toArray(); | ||
| 139 | return ret; | ||
| 140 | } | ||
| 141 | |||
| 142 | /** | ||
| 143 | * Does not trim each token. | ||
| 144 | * @see #parse(String, char, boolean) | ||
| 145 | */ | ||
| 146 | public static String[] parse(String text, char delimiter) | ||
| 147 | { | ||
| 148 | return parse(text, delimiter, false); | ||
| 149 | } | ||
| 150 | |||
| 151 | |||
| 152 | public static void main(String[] args) | ||
| 153 | { | ||
| 154 | String str = "1,\"2,\"ab\",ttt1,\"3,,a\"222\",4"; | ||
| 155 | if(args.length > 0) | ||
| 156 | { | ||
| 157 | str = args[0]; | ||
| 158 | } | ||
| 159 | // String [] tokens = Tokenizer.parse(str, ','); | ||
| 160 | // | ||
| 161 | //// System.out.println( "Text = (" + str + ")"); | ||
| 162 | // // System.out.println( "------------------------------------------"); | ||
| 163 | // for (int i = 0; i < tokens.length ; i++) | ||
| 164 | // { | ||
| 165 | // // System.out.println( "(" + tokens[i] + ")"); | ||
| 166 | // } | ||
| 167 | // // System.out.println( "------------------------------------------"); | ||
| 168 | |||
| 169 | // String [] tokens = Tokenizer.parse(str, ',', new String[]{"("}, new String[]{")"}); | ||
| 170 | // | ||
| 171 | // // System.out.println( "Text = [" + str + "]"); | ||
| 172 | // // System.out.println( "------------------------------------------"); | ||
| 173 | // for (int i = 0; i < tokens.length ; i++) | ||
| 174 | // { | ||
| 175 | // // System.out.println( "[" + tokens[i] + "]"); | ||
| 176 | // } | ||
| 177 | // // System.out.println( "------------------------------------------"); | ||
| 178 | |||
| 179 | } | ||
| 180 | }//end of class Tokenizer | ||
| 181 | |||
| 182 | |||
| 183 |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | import java.util.Random; | ||
| 4 | |||
| 5 | import java.io.*; | ||
| 6 | |||
| 7 | import org.emercit.szsterminal.*; | ||
| 8 | |||
| 9 | import java.util.regex.*; | ||
| 10 | |||
| 11 | public class Util { | ||
| 12 | |||
| 13 | public static void StopSiren() { | ||
| 14 | try { | ||
| 15 | SZSTerminal.siren.sirenOff(); | ||
| 16 | |||
| 17 | } catch (Exception e) { | ||
| 18 | |||
| 19 | } | ||
| 20 | |||
| 21 | |||
| 22 | } | ||
| 23 | |||
| 24 | public static void RunSiren() { | ||
| 25 | try { | ||
| 26 | |||
| 27 | SZSTerminal.siren.sirenOn(); | ||
| 28 | |||
| 29 | } catch (Exception e) { | ||
| 30 | |||
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | } | ||
| 35 | |||
| 36 | public static final void Alarm() { | ||
| 37 | try { | ||
| 38 | AePlayWave player = new AePlayWave("/Alarm.wav"); | ||
| 39 | player.start(); | ||
| 40 | } catch (Exception e) { | ||
| 41 | |||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | public static final String reverse(String str) { | ||
| 46 | if (str.length() <= 1) | ||
| 47 | return str; | ||
| 48 | |||
| 49 | String result = ""; | ||
| 50 | |||
| 51 | result += str.charAt(str.length() - 1) | ||
| 52 | + reverse(str.substring(0, str.length() - 1)); | ||
| 53 | |||
| 54 | return result; | ||
| 55 | } | ||
| 56 | |||
| 57 | public static boolean[] toBinary(int number, int base) { | ||
| 58 | final boolean[] ret = new boolean[base]; | ||
| 59 | for (int i = 0; i < base; i++) { | ||
| 60 | |||
| 61 | ret[base - 1 - i] = (1 << i & number) != 0; | ||
| 62 | |||
| 63 | } | ||
| 64 | return ret; | ||
| 65 | |||
| 66 | } | ||
| 67 | |||
| 68 | public static double round(double value, int places) { | ||
| 69 | |||
| 70 | if (places < 0) | ||
| 71 | throw new IllegalArgumentException(); | ||
| 72 | |||
| 73 | long factor = (long) Math.pow(10, places); | ||
| 74 | value = value * factor; | ||
| 75 | long tmp = Math.round(value); | ||
| 76 | |||
| 77 | return (double) tmp / factor; | ||
| 78 | } | ||
| 79 | |||
| 80 | public static int randInt(int min, int max) { | ||
| 81 | |||
| 82 | Random rand = new Random(); | ||
| 83 | int randomNum = rand.nextInt((max - min) + 1) + min; | ||
| 84 | |||
| 85 | return randomNum; | ||
| 86 | |||
| 87 | } | ||
| 88 | |||
| 89 | public static String DoubleToString(double d) { | ||
| 90 | |||
| 91 | String result = String.valueOf(d); | ||
| 92 | String buff = ""; | ||
| 93 | int i = 0; | ||
| 94 | while (result.charAt(i) != '.') { | ||
| 95 | buff += result.charAt(i); | ||
| 96 | i++; | ||
| 97 | } | ||
| 98 | buff += result.charAt(i); // '.' | ||
| 99 | buff += result.charAt(i + 1); // 1 число после точки | ||
| 100 | |||
| 101 | return buff; | ||
| 102 | } | ||
| 103 | |||
| 104 | // представление дробной части | ||
| 105 | public static final int Drob(String str) { | ||
| 106 | double j = 0; | ||
| 107 | |||
| 108 | str = reverse(str); | ||
| 109 | |||
| 110 | for (int i = 0; i < str.length(); i++) { | ||
| 111 | if (str.charAt(i) == '1') { | ||
| 112 | j = j + Math.pow(2, str.length() - 1 - i); | ||
| 113 | } | ||
| 114 | |||
| 115 | } | ||
| 116 | return (int) j; | ||
| 117 | } | ||
| 118 | |||
| 119 | public static final byte[] stringToBytesASCII(char[] buffer) { | ||
| 120 | |||
| 121 | byte[] b = new byte[buffer.length]; | ||
| 122 | for (int i = 0; i < b.length; i++) { | ||
| 123 | b[i] = (byte) buffer[i]; | ||
| 124 | } | ||
| 125 | return b; | ||
| 126 | } | ||
| 127 | |||
| 128 | private static String ParserID(String input) { | ||
| 129 | |||
| 130 | String pattern = "id=[0-9]*"; | ||
| 131 | |||
| 132 | Pattern r = Pattern.compile(pattern); | ||
| 133 | |||
| 134 | Matcher m = r.matcher(input); | ||
| 135 | if (m.find()) { | ||
| 136 | |||
| 137 | String buff = m.group(0); | ||
| 138 | if (buff.length() >= 12) { | ||
| 139 | char[] str = buff.toCharArray(); | ||
| 140 | String res = ""; | ||
| 141 | for (int i = 3; i < buff.length(); i++) | ||
| 142 | res += str[i]; | ||
| 143 | |||
| 144 | return res; | ||
| 145 | |||
| 146 | } | ||
| 147 | |||
| 148 | } | ||
| 149 | return ""; | ||
| 150 | } | ||
| 151 | |||
| 152 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.model; | ||
| 2 | |||
| 3 | |||
| 4 | import java.io.*; | ||
| 5 | import java.net.*; | ||
| 6 | import java.io.BufferedOutputStream; | ||
| 7 | import java.io.BufferedReader; | ||
| 8 | import java.io.File; | ||
| 9 | import java.io.IOException; | ||
| 10 | import java.io.InputStreamReader; | ||
| 11 | import java.io.OutputStream; | ||
| 12 | import java.io.OutputStreamWriter; | ||
| 13 | import java.net.HttpURLConnection; | ||
| 14 | import java.net.InetSocketAddress; | ||
| 15 | import java.net.Proxy; | ||
| 16 | import java.net.URL; | ||
| 17 | import java.net.URLEncoder; | ||
| 18 | import java.util.Map; | ||
| 19 | import java.util.Map; | ||
| 20 | |||
| 21 | import org.json.simple.*; | ||
| 22 | |||
| 23 | import com.google.gson.*; | ||
| 24 | |||
| 25 | import org.emercit.config.Config; | ||
| 26 | import org.emercit.service.SData; | ||
| 27 | |||
| 28 | public class WebPost { | ||
| 29 | |||
| 30 | private Config config; | ||
| 31 | |||
| 32 | public WebPost(Config config) { | ||
| 33 | this.config=config; | ||
| 34 | } | ||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | public ModelResponse Request() { | ||
| 40 | |||
| 41 | |||
| 42 | |||
| 43 | ModelResponse md = null; | ||
| 44 | |||
| 45 | StringBuilder sb = new StringBuilder(); | ||
| 46 | |||
| 47 | HttpURLConnection urlConnection = null; | ||
| 48 | |||
| 49 | |||
| 50 | BufferedReader br=null; | ||
| 51 | |||
| 52 | try { | ||
| 53 | |||
| 54 | |||
| 55 | URL url = new URL("http://"+ config.getService()+":8088/api/DataSzs/"); | ||
| 56 | |||
| 57 | Proxy proxy; | ||
| 58 | |||
| 59 | if (config.getProxyEnabled()) { | ||
| 60 | proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress( | ||
| 61 | config.getProxyServer(), | ||
| 62 | config.getProxyPort())); | ||
| 63 | |||
| 64 | // System.out.println(config.getProxyServer()+":"+config.getProxyPort()); | ||
| 65 | urlConnection = (HttpURLConnection) url.openConnection(proxy); | ||
| 66 | } else { | ||
| 67 | urlConnection = (HttpURLConnection) url.openConnection(); | ||
| 68 | } | ||
| 69 | |||
| 70 | urlConnection.setDoOutput(true); | ||
| 71 | urlConnection.setRequestMethod("POST"); | ||
| 72 | urlConnection | ||
| 73 | .setRequestProperty("Content-Type", "application/json"); | ||
| 74 | |||
| 75 | urlConnection.setConnectTimeout(5000); | ||
| 76 | urlConnection.setReadTimeout(10000); | ||
| 77 | |||
| 78 | |||
| 79 | JSONObject jsonParam = new JSONObject(); | ||
| 80 | |||
| 81 | jsonParam.put("RegKey", config.getRegKey()); | ||
| 82 | jsonParam.put("SoftVersion", config.getVersion()); | ||
| 83 | jsonParam.put("IDTeamViewer",""); | ||
| 84 | |||
| 85 | OutputStreamWriter out = new OutputStreamWriter( | ||
| 86 | urlConnection.getOutputStream()); | ||
| 87 | out.write(jsonParam.toString()); | ||
| 88 | out.close(); | ||
| 89 | |||
| 90 | |||
| 91 | |||
| 92 | int HttpResult = urlConnection.getResponseCode(); | ||
| 93 | |||
| 94 | if (HttpResult == HttpURLConnection.HTTP_OK) { | ||
| 95 | |||
| 96 | br = new BufferedReader(new InputStreamReader( | ||
| 97 | urlConnection.getInputStream(), "utf-8")); | ||
| 98 | |||
| 99 | String line = null; | ||
| 100 | |||
| 101 | while ((line = br.readLine()) != null) { | ||
| 102 | sb.append(line + "\n"); | ||
| 103 | } | ||
| 104 | |||
| 105 | |||
| 106 | br.close(); | ||
| 107 | |||
| 108 | Gson gson = new Gson(); | ||
| 109 | |||
| 110 | md = gson.fromJson(sb.toString(), ModelResponse.class); | ||
| 111 | |||
| 112 | |||
| 113 | } | ||
| 114 | br.close(); | ||
| 115 | urlConnection.disconnect(); | ||
| 116 | |||
| 117 | SData.INSTANCE.setIsConnect(true); | ||
| 118 | |||
| 119 | } catch (Exception e) { | ||
| 120 | |||
| 121 | SData.INSTANCE.setIsConnect(false); | ||
| 122 | |||
| 123 | } finally { | ||
| 124 | |||
| 125 | |||
| 126 | try { | ||
| 127 | if (urlConnection != null) { | ||
| 128 | urlConnection.disconnect(); | ||
| 129 | } | ||
| 130 | if (br!=null) { | ||
| 131 | br.close(); | ||
| 132 | } | ||
| 133 | |||
| 134 | } catch (Exception ex) { | ||
| 135 | |||
| 136 | SData.INSTANCE.setIsConnect(false); | ||
| 137 | |||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | |||
| 142 | |||
| 143 | return md; | ||
| 144 | |||
| 145 | } | ||
| 146 | |||
| 147 | |||
| 148 | public void Confirm(MdlEvent event) { | ||
| 149 | |||
| 150 | |||
| 151 | HttpURLConnection urlConnection = null; | ||
| 152 | try { | ||
| 153 | |||
| 154 | |||
| 155 | |||
| 156 | URL url = new URL("http://"+config.getService()+":8088/api/ConfirmLevelsRivers/"); | ||
| 157 | |||
| 158 | Proxy proxy; | ||
| 159 | |||
| 160 | if (config.getProxyEnabled()) { | ||
| 161 | proxy = new Proxy(Proxy.Type.HTTP, | ||
| 162 | new InetSocketAddress(config.getProxyServer(), | ||
| 163 | config.getProxyPort())); | ||
| 164 | urlConnection = (HttpURLConnection) url | ||
| 165 | .openConnection(proxy); | ||
| 166 | } else { | ||
| 167 | urlConnection = (HttpURLConnection) url | ||
| 168 | .openConnection(); | ||
| 169 | } | ||
| 170 | |||
| 171 | urlConnection.setDoOutput(true); | ||
| 172 | urlConnection.setRequestMethod("POST"); | ||
| 173 | urlConnection.setRequestProperty("Content-Type", | ||
| 174 | "application/json"); | ||
| 175 | |||
| 176 | |||
| 177 | urlConnection.setConnectTimeout(5000); | ||
| 178 | urlConnection.setReadTimeout(10000); | ||
| 179 | |||
| 180 | |||
| 181 | // Create JSONObject here | ||
| 182 | JSONObject jsonParam = new JSONObject(); | ||
| 183 | |||
| 184 | jsonParam.put("RegKey", | ||
| 185 | config.getRegKey()); | ||
| 186 | jsonParam.put("id_agk", event.getIdAgk()); | ||
| 187 | jsonParam.put("id_webapi_message", event.getId()); | ||
| 188 | |||
| 189 | OutputStreamWriter out = new OutputStreamWriter( | ||
| 190 | urlConnection.getOutputStream()); | ||
| 191 | out.write(jsonParam.toString()); | ||
| 192 | out.close(); | ||
| 193 | |||
| 194 | int HttpResult = urlConnection.getResponseCode(); | ||
| 195 | |||
| 196 | if (HttpResult == HttpURLConnection.HTTP_OK) { | ||
| 197 | |||
| 198 | } | ||
| 199 | |||
| 200 | |||
| 201 | urlConnection.disconnect(); | ||
| 202 | } catch (Exception e) { | ||
| 203 | |||
| 204 | |||
| 205 | } finally { | ||
| 206 | try { | ||
| 207 | if (urlConnection != null) { | ||
| 208 | urlConnection.disconnect(); | ||
| 209 | } | ||
| 210 | |||
| 211 | } catch (Exception ex) { | ||
| 212 | |||
| 213 | |||
| 214 | |||
| 215 | } | ||
| 216 | } | ||
| 217 | |||
| 218 | |||
| 219 | } | ||
| 220 | |||
| 221 | |||
| 222 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.service; | ||
| 2 | |||
| 3 | import java.util.ArrayList; | ||
| 4 | import java.util.List; | ||
| 5 | |||
| 6 | import org.emercit.model.EventAgk; | ||
| 7 | import org.emercit.model.ModelResponse; | ||
| 8 | import org.emercit.model.MdlEvent; | ||
| 9 | import org.emercit.config.Config; | ||
| 10 | import org.emercit.model.WebPost; | ||
| 11 | import org.emercit.szsterminal.SZSTerminal; | ||
| 12 | |||
| 13 | |||
| 14 | @javax.inject.Singleton | ||
| 15 | public enum SData { | ||
| 16 | |||
| 17 | INSTANCE; | ||
| 18 | |||
| 19 | private ModelResponse data; | ||
| 20 | |||
| 21 | private boolean IsConnect; | ||
| 22 | |||
| 23 | private Config config; | ||
| 24 | |||
| 25 | |||
| 26 | private boolean IsOpenDialog=false; | ||
| 27 | |||
| 28 | |||
| 29 | /* | ||
| 30 | * Получение данных с веб сервиса | ||
| 31 | */ | ||
| 32 | public void Scan() { | ||
| 33 | |||
| 34 | |||
| 35 | if (!IsOpenDialog) { | ||
| 36 | WebPost webpost=new WebPost(config); | ||
| 37 | this.data= webpost.Request(); | ||
| 38 | |||
| 39 | } | ||
| 40 | |||
| 41 | |||
| 42 | } | ||
| 43 | |||
| 44 | /* | ||
| 45 | * Получение текущего состояния датчиков | ||
| 46 | */ | ||
| 47 | public ModelResponse getData() { | ||
| 48 | return this.data; | ||
| 49 | } | ||
| 50 | |||
| 51 | /* | ||
| 52 | * Подтверждение события | ||
| 53 | */ | ||
| 54 | |||
| 55 | public void Confirm(MdlEvent mdlevent) { | ||
| 56 | |||
| 57 | WebPost webpost=new WebPost(config); | ||
| 58 | webpost.Confirm(mdlevent); | ||
| 59 | |||
| 60 | this.IsOpenDialog=false; | ||
| 61 | |||
| 62 | } | ||
| 63 | |||
| 64 | /* | ||
| 65 | * Установка конфигурации | ||
| 66 | */ | ||
| 67 | public void SetConfig(Config config) { | ||
| 68 | |||
| 69 | this.config=config; | ||
| 70 | } | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Получение конфигурации | ||
| 74 | */ | ||
| 75 | |||
| 76 | public Config getConfig() { | ||
| 77 | return this.config; | ||
| 78 | } | ||
| 79 | |||
| 80 | |||
| 81 | /* | ||
| 82 | * Связь с сервисом | ||
| 83 | */ | ||
| 84 | public boolean isConnect() { | ||
| 85 | return this.IsConnect; | ||
| 86 | } | ||
| 87 | |||
| 88 | |||
| 89 | public void setIsConnect(boolean value) { | ||
| 90 | this.IsConnect=value; | ||
| 91 | } | ||
| 92 | |||
| 93 | /* | ||
| 94 | * Удаление события для подтверждеия | ||
| 95 | */ | ||
| 96 | public void RemoveEvent() { | ||
| 97 | this.data.lsteventagkconfirm.clear(); | ||
| 98 | } | ||
| 99 | |||
| 100 | |||
| 101 | /* | ||
| 102 | * | ||
| 103 | */ | ||
| 104 | public boolean getIsOpenDialog() { | ||
| 105 | return this.IsOpenDialog; | ||
| 106 | |||
| 107 | } | ||
| 108 | |||
| 109 | /* | ||
| 110 | * | ||
| 111 | */ | ||
| 112 | public void setIsOpenDialog(boolean value) { | ||
| 113 | |||
| 114 | this.IsOpenDialog=value; | ||
| 115 | } | ||
| 116 | |||
| 117 | |||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | } | ||
| 122 |
| 1 | package org.emercit.service; | ||
| 2 | |||
| 3 | |||
| 4 | import org.apache.log4j.Logger; | ||
| 5 | |||
| 6 | import org.emercit.service.SData; | ||
| 7 | |||
| 8 | |||
| 9 | public class TScan implements Runnable{ | ||
| 10 | |||
| 11 | static final Logger logger = Logger.getLogger(TScan.class); | ||
| 12 | |||
| 13 | public TScan() { | ||
| 14 | |||
| 15 | } | ||
| 16 | |||
| 17 | public void run() { | ||
| 18 | |||
| 19 | while(true) { | ||
| 20 | try { | ||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | |||
| 25 | SData.INSTANCE.Scan(); | ||
| 26 | |||
| 27 | |||
| 28 | Thread.sleep(3000); | ||
| 29 | |||
| 30 | } | ||
| 31 | catch(Exception e) { | ||
| 32 | |||
| 33 | //logger.error(e.getMessage()); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | |||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | package org.emercit.szsterminal; | ||
| 2 | |||
| 3 | import java.awt.BorderLayout; | ||
| 4 | import java.awt.EventQueue; | ||
| 5 | |||
| 6 | import javax.swing.JFrame; | ||
| 7 | import javax.swing.JPanel; | ||
| 8 | |||
| 9 | import java.awt.Color; | ||
| 10 | import java.awt.GridLayout; | ||
| 11 | import java.awt.GridBagLayout; | ||
| 12 | import java.awt.GridBagConstraints; | ||
| 13 | |||
| 14 | import javax.swing.border.BevelBorder; | ||
| 15 | import javax.swing.border.CompoundBorder; | ||
| 16 | import javax.swing.border.SoftBevelBorder; | ||
| 17 | import javax.swing.JLabel; | ||
| 18 | import javax.swing.JTable; | ||
| 19 | import javax.swing.border.LineBorder; | ||
| 20 | |||
| 21 | import java.awt.Dimension; | ||
| 22 | |||
| 23 | import javax.swing.table.TableModel; | ||
| 24 | |||
| 25 | import java.util.ArrayList; | ||
| 26 | import java.util.List; | ||
| 27 | import java.util.Timer; | ||
| 28 | import java.util.TimerTask; | ||
| 29 | import java.util.Date; | ||
| 30 | import java.text.DateFormat; | ||
| 31 | import java.text.SimpleDateFormat; | ||
| 32 | import java.util.Calendar; | ||
| 33 | |||
| 34 | import javax.swing.SwingWorker; | ||
| 35 | import javax.swing.JButton; | ||
| 36 | import javax.swing.ImageIcon; | ||
| 37 | |||
| 38 | import java.awt.Font; | ||
| 39 | |||
| 40 | import javax.swing.*; | ||
| 41 | |||
| 42 | import java.awt.event.ActionListener; | ||
| 43 | import java.awt.event.ActionEvent; | ||
| 44 | |||
| 45 | import javax.swing.event.ChangeListener; | ||
| 46 | import javax.swing.event.ChangeEvent; | ||
| 47 | |||
| 48 | import java.awt.Toolkit; | ||
| 49 | import java.awt.Rectangle; | ||
| 50 | import java.io.BufferedReader; | ||
| 51 | import java.io.BufferedWriter; | ||
| 52 | import java.io.FileWriter; | ||
| 53 | import java.io.IOException; | ||
| 54 | import java.io.InputStreamReader; | ||
| 55 | import java.io.OutputStreamWriter; | ||
| 56 | import java.io.PrintWriter; | ||
| 57 | import java.net.HttpURLConnection; | ||
| 58 | import java.net.InetSocketAddress; | ||
| 59 | import java.net.Proxy; | ||
| 60 | import java.net.URL; | ||
| 61 | import java.util.Scanner; | ||
| 62 | |||
| 63 | import org.emercit.components.*; | ||
| 64 | |||
| 65 | import java.awt.Dialog.ModalExclusionType; | ||
| 66 | import java.awt.*; | ||
| 67 | import java.awt.event.*; | ||
| 68 | |||
| 69 | import javax.swing.*; | ||
| 70 | |||
| 71 | import com.google.gson.Gson; | ||
| 72 | |||
| 73 | import java.beans.*; | ||
| 74 | |||
| 75 | import org.emercit.model.*; | ||
| 76 | import org.emercit.config.*; | ||
| 77 | import org.emercit.service.*; | ||
| 78 | |||
| 79 | |||
| 80 | import org.apache.log4j.Logger; | ||
| 81 | import org.apache.log4j.BasicConfigurator; | ||
| 82 | import org.apache.log4j.PropertyConfigurator; | ||
| 83 | |||
| 84 | public class SZSTerminal { | ||
| 85 | |||
| 86 | private static JFrame mainFrame; | ||
| 87 | private static JPanel mainPanel; | ||
| 88 | public static JPnlHeader jpnlheader; | ||
| 89 | |||
| 90 | |||
| 91 | public static JPnlCurrent pnlcurrent = new JPnlCurrent(); | ||
| 92 | public static JPnlLog jpnllog = new JPnlLog(); | ||
| 93 | public static JPnlContacts jpnlcontacts = new JPnlContacts(); | ||
| 94 | public static JPnlControl jpnlcontrol = new JPnlControl(); | ||
| 95 | |||
| 96 | public static SirenJNI siren = new SirenJNI(); | ||
| 97 | |||
| 98 | private static Timer ftdTimerMain = new Timer(); | ||
| 99 | |||
| 100 | public static DlgConfirm dlgconfirm = new DlgConfirm(); | ||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | private static class ftdTimerTask extends TimerTask { | ||
| 105 | |||
| 106 | @Override | ||
| 107 | public void run() { | ||
| 108 | EventQueue.invokeLater(new Runnable() { | ||
| 109 | |||
| 110 | // @Override | ||
| 111 | public void run() { | ||
| 112 | |||
| 113 | |||
| 114 | |||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | |||
| 119 | DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); | ||
| 120 | Date date = new Date(); | ||
| 121 | Calendar cal = Calendar.getInstance(); | ||
| 122 | |||
| 123 | jpnlheader.UpdateTime("Сегодня:"+ dateFormat.format(cal.getTime())); | ||
| 124 | |||
| 125 | jpnlheader.ChangeConnectImg(SData.INSTANCE.isConnect()); | ||
| 126 | |||
| 127 | |||
| 128 | if (SData.INSTANCE.isConnect()){ | ||
| 129 | |||
| 130 | |||
| 131 | jpnlheader.setTitleSubscriver(SData.INSTANCE.getData().titlesubscriber); | ||
| 132 | |||
| 133 | jpnlcontacts.setTitleContact(SData.INSTANCE.getData().titlecontact); | ||
| 134 | |||
| 135 | |||
| 136 | /* | ||
| 137 | * Текущее состояние датчиков | ||
| 138 | */ | ||
| 139 | new SwingWorker<Void, Void>() | ||
| 140 | { | ||
| 141 | protected Void doInBackground() throws Exception | ||
| 142 | { | ||
| 143 | |||
| 144 | List<MdlEvent> lstEvent = new ArrayList<MdlEvent>(); | ||
| 145 | |||
| 146 | ModelResponse mdl=SData.INSTANCE.getData(); | ||
| 147 | for (EventAgk eventagk : mdl.lsteventagkstate) { | ||
| 148 | |||
| 149 | MdlEvent ev = new MdlEvent(eventagk.id, | ||
| 150 | eventagk.id_agk, | ||
| 151 | eventagk.river, | ||
| 152 | eventagk.datetime, | ||
| 153 | eventagk.value, | ||
| 154 | eventagk.id_status, | ||
| 155 | eventagk.repair, | ||
| 156 | eventagk.opendoor, | ||
| 157 | eventagk.veracity); | ||
| 158 | |||
| 159 | lstEvent.add(ev); | ||
| 160 | } | ||
| 161 | |||
| 162 | pnlcurrent.setListEventCurrent(lstEvent); | ||
| 163 | |||
| 164 | return null; | ||
| 165 | |||
| 166 | } | ||
| 167 | |||
| 168 | }.execute(); | ||
| 169 | |||
| 170 | |||
| 171 | |||
| 172 | /* | ||
| 173 | * События для подтверждения | ||
| 174 | */ | ||
| 175 | new SwingWorker<Void, Void>() | ||
| 176 | { | ||
| 177 | protected Void doInBackground() throws Exception | ||
| 178 | { | ||
| 179 | |||
| 180 | |||
| 181 | ModelResponse mdl=SData.INSTANCE.getData(); | ||
| 182 | |||
| 183 | |||
| 184 | |||
| 185 | for (EventAgk eventagk : mdl.lsteventagkconfirm) { | ||
| 186 | |||
| 187 | |||
| 188 | SData.INSTANCE.RemoveEvent(); | ||
| 189 | |||
| 190 | MdlEvent ev = new MdlEvent(eventagk.id, eventagk.id_agk, | ||
| 191 | eventagk.river, eventagk.datetime, eventagk.value, | ||
| 192 | eventagk.id_status, eventagk.repair, eventagk.opendoor, | ||
| 193 | eventagk.veracity); | ||
| 194 | |||
| 195 | ev.setSiren(mdl.siren); | ||
| 196 | |||
| 197 | |||
| 198 | dlgconfirm.setEvent(ev); | ||
| 199 | |||
| 200 | dlgconfirm.setVisible(true); | ||
| 201 | |||
| 202 | |||
| 203 | |||
| 204 | } | ||
| 205 | |||
| 206 | return null; | ||
| 207 | |||
| 208 | } | ||
| 209 | |||
| 210 | }.execute(); | ||
| 211 | } | ||
| 212 | |||
| 213 | } | ||
| 214 | }); | ||
| 215 | } | ||
| 216 | |||
| 217 | } | ||
| 218 | |||
| 219 | public static void main(String[] args) { | ||
| 220 | |||
| 221 | |||
| 222 | |||
| 223 | |||
| 224 | PropertyConfigurator.configure("log4j.properties"); | ||
| 225 | |||
| 226 | |||
| 227 | |||
| 228 | |||
| 229 | |||
| 230 | |||
| 231 | EventQueue.invokeLater(new Runnable() { | ||
| 232 | public void run() { | ||
| 233 | try { | ||
| 234 | // siren.sirenOff(); | ||
| 235 | |||
| 236 | } catch (Exception e) { | ||
| 237 | |||
| 238 | } | ||
| 239 | |||
| 240 | |||
| 241 | |||
| 242 | mainFrame = new JFrame(); | ||
| 243 | mainFrame.setSize(800, 600); | ||
| 244 | mainFrame.setUndecorated(false); | ||
| 245 | mainFrame.setResizable(false); | ||
| 246 | mainFrame.setVisible(true); | ||
| 247 | mainPanel = new JPanel(); | ||
| 248 | Toolkit tk = Toolkit.getDefaultToolkit(); | ||
| 249 | int xSize = ((int) tk.getScreenSize().getWidth()); | ||
| 250 | int ySize = ((int) tk.getScreenSize().getHeight()); | ||
| 251 | // mainFrame.setSize(xSize,ySize); | ||
| 252 | |||
| 253 | mainPanel.setBackground(UIManager | ||
| 254 | .getColor("Separator.foreground")); | ||
| 255 | |||
| 256 | mainPanel.setBounds(0, 0, xSize, ySize); | ||
| 257 | |||
| 258 | jpnlheader = new JPnlHeader(""); | ||
| 259 | jpnlheader.setBounds(10, 10, 770, 50); | ||
| 260 | jpnlheader.setBackground(new Color(168, 181, 224)); | ||
| 261 | mainPanel.add(jpnlheader); | ||
| 262 | |||
| 263 | // pnlcurrent.setBounds(10, 70, 770, 470); | ||
| 264 | List<Event> lstevent = new ArrayList<Event>(); | ||
| 265 | |||
| 266 | |||
| 267 | |||
| 268 | JTabbedPane jtp = new JTabbedPane(); | ||
| 269 | jtp.setFont(new Font("Tahoma", Font.PLAIN, 14)); | ||
| 270 | mainPanel.add(jtp); | ||
| 271 | jtp.setBounds(10, 70, 780, 520); | ||
| 272 | |||
| 273 | ImageIcon imgJournal = new ImageIcon(getClass().getResource( | ||
| 274 | "/journal.png")); | ||
| 275 | ImageIcon imgCurrent = new ImageIcon(getClass().getResource( | ||
| 276 | "/current.png")); | ||
| 277 | ImageIcon imgContact = new ImageIcon(getClass().getResource( | ||
| 278 | "/contacts.png")); | ||
| 279 | ImageIcon imgControl = new ImageIcon(getClass().getResource( | ||
| 280 | "/update.png")); | ||
| 281 | |||
| 282 | jtp.addTab("Текущее состояние", imgCurrent, pnlcurrent); | ||
| 283 | jtp.addTab("Журнал", imgJournal, jpnllog); | ||
| 284 | jtp.addTab("Контакты", imgContact, jpnlcontacts); | ||
| 285 | jtp.addTab("Управление", imgControl, jpnlcontrol); | ||
| 286 | |||
| 287 | mainFrame.setAlwaysOnTop(true); | ||
| 288 | |||
| 289 | mainPanel.setBackground(UIManager | ||
| 290 | .getColor("Separator.foreground")); | ||
| 291 | jpnlheader.SetBlue(); | ||
| 292 | |||
| 293 | mainPanel.setLayout(null); | ||
| 294 | mainFrame.getContentPane().add(mainPanel); | ||
| 295 | |||
| 296 | Config config=new Config(); | ||
| 297 | SData.INSTANCE.SetConfig(config); | ||
| 298 | Runnable rTScan = new TScan(); | ||
| 299 | |||
| 300 | Thread tScan = new Thread(rTScan); | ||
| 301 | tScan.start(); | ||
| 302 | |||
| 303 | ftdTimerMain.schedule(new ftdTimerTask(), 0, 1000); | ||
| 304 | |||
| 305 | } | ||
| 306 | }); | ||
| 307 | } | ||
| 308 | } |
SZSTerminal/src/main/resources/Alarm.wav
0 → 100755
No preview for this file type
SZSTerminal/src/main/resources/bottom.png
0 → 100755
3.02 KB
SZSTerminal/src/main/resources/circle.png
0 → 100755
1.32 KB
SZSTerminal/src/main/resources/clock.png
0 → 100755
2.32 KB
SZSTerminal/src/main/resources/closedoor.png
0 → 100755
18.3 KB
2.16 KB
SZSTerminal/src/main/resources/contacts.png
0 → 100755
745 Bytes
SZSTerminal/src/main/resources/current.png
0 → 100755
1.59 KB
SZSTerminal/src/main/resources/desktop.ini
0 → 100755
| 1 | [LocalizedFileNames] | ||
| 2 | notify.wav=@%windir%\system32\mmres.dll,-706 | ||
| 3 | Windows Minimize.wav=@%windir%\system32\mmres.dll,-726 | ||
| 4 | Windows Startup.wav=@%windir%\system32\mmres.dll,-735 | ||
| 5 | Windows Notify.wav=@%windir%\system32\mmres.dll,-727 | ||
| 6 | Windows Pop-up Blocked.wav=@%windir%\system32\mmres.dll,-737 | ||
| 7 | tada.wav=@%windir%\system32\mmres.dll,-710 |
1.9 KB
SZSTerminal/src/main/resources/good.png
0 → 100755
813 Bytes
SZSTerminal/src/main/resources/green.png
0 → 100755
4.69 KB
SZSTerminal/src/main/resources/journal.png
0 → 100755
1.99 KB
4.67 KB
SZSTerminal/src/main/resources/opendoor.png
0 → 100755
2.96 KB
SZSTerminal/src/main/resources/red.png
0 → 100755
2.93 KB
SZSTerminal/src/main/resources/repair.png
0 → 100755
1.03 KB
SZSTerminal/src/main/resources/river.png
0 → 100755
15.3 KB
SZSTerminal/src/main/resources/top.png
0 → 100755
3.31 KB
SZSTerminal/src/main/resources/update.png
0 → 100755
1.3 KB
3.82 KB
4.59 KB
SZSTerminal/src/main/resources/yellow.png
0 → 100755
2.11 KB
-
Please register or sign in to post a comment