Commit 0235aab1 0235aab15ac88b3389b4b9d8357fb178aba78c10 by root

save

1 parent 293ffec7
...@@ -139,6 +139,15 @@ ...@@ -139,6 +139,15 @@
139 <version>1.13</version> 139 <version>1.13</version>
140 </dependency> 140 </dependency>
141 141
142 <dependency>
143 <groupId>log4j</groupId>
144 <artifactId>log4j</artifactId>
145 <version>1.2.14</version>
146 <type>jar</type>
147 <scope>compile</scope>
148 </dependency>
149
150
142 </dependencies> 151 </dependencies>
143 152
144 153
......
1 package org.emercit.devtools.service; 1 package org.emercit.devtools.service;
2 import org.apache.log4j.Logger;
2 import org.emercit.model.IPAddressValidator; 3 import org.emercit.model.IPAddressValidator;
3 4
4 import java.util.Vector; 5 import java.util.Vector;
...@@ -12,10 +13,17 @@ import java.util.Vector; ...@@ -12,10 +13,17 @@ import java.util.Vector;
12 import org.emercit.pckutils.checkservice.STService; 13 import org.emercit.pckutils.checkservice.STService;
13 import org.emercit.utilstools.config.Paths; 14 import org.emercit.utilstools.config.Paths;
14 15
16 import org.apache.log4j.Logger;
17
15 public enum SvService { 18 public enum SvService {
16 19
20
21
22
23
17 INSTANCE; 24 INSTANCE;
18 25
26 private static final Logger log = Logger.getLogger(SvService.class);
19 27
20 private Sv sv=new Sv(); 28 private Sv sv=new Sv();
21 29
...@@ -36,6 +44,20 @@ public enum SvService { ...@@ -36,6 +44,20 @@ public enum SvService {
36 svbeans=sv.get(); 44 svbeans=sv.get();
37 45
38 for (SvBean s:svbeans) { // проверяем запущен или остановлен 46 for (SvBean s:svbeans) { // проверяем запущен или остановлен
47
48
49 try {
50 boolean status=st.IsRun(s.getProcess());
51
52 log.info("Процесс:"+status);
53
54 } catch (Exception e) {
55
56 }
57
58
59
60
39 try { s.setIsrun(st.IsRun(s.getProcess())); } catch (Exception e) {}; 61 try { s.setIsrun(st.IsRun(s.getProcess())); } catch (Exception e) {};
40 } 62 }
41 63
......
...@@ -220,18 +220,12 @@ Ext.application({ ...@@ -220,18 +220,12 @@ Ext.application({
220 title: 'СЕРВИСЫ', 220 title: 'СЕРВИСЫ',
221 items:[ 221 items:[
222 { 222 {
223 region: 'center',
224 xtype: 'tabpanel',
225 items: [
226
227 {
228 xtype : 'mvvm-SvView', 223 xtype : 'mvvm-SvView',
229 id:'grdSv', 224 id:'grdSv',
230 name:'grdSv' 225 name:'grdSv',
231 226 width: 700,
232 } 227 height: 300
233 228
234 ]
235 229
236 } 230 }
237 ] 231 ]
......
...@@ -43,8 +43,7 @@ Ext.define('App.view.Sv', { ...@@ -43,8 +43,7 @@ Ext.define('App.view.Sv', {
43 } 43 }
44 ] 44 ]
45 }, 45 },
46 width: 500, 46
47 height: 300,
48 selType: 'rowmodel', 47 selType: 'rowmodel',
49 plugins: [new Ext.create('Ext.grid.plugin.RowEditing', { 48 plugins: [new Ext.create('Ext.grid.plugin.RowEditing', {
50 clicksToEdit: 2, 49 clicksToEdit: 2,
...@@ -54,7 +53,7 @@ Ext.define('App.view.Sv', { ...@@ -54,7 +53,7 @@ Ext.define('App.view.Sv', {
54 columns: [{ 53 columns: [{
55 text : '№', 54 text : '№',
56 dataIndex : 'id', 55 dataIndex : 'id',
57 flex: 1, 56 width: 50,
58 hidden:true 57 hidden:true
59 }, 58 },
60 59
...@@ -62,10 +61,10 @@ Ext.define('App.view.Sv', { ...@@ -62,10 +61,10 @@ Ext.define('App.view.Sv', {
62 { 61 {
63 text : 'Статус', 62 text : 'Статус',
64 dataIndex : 'isrun', 63 dataIndex : 'isrun',
65 flex : 1, 64 width : 100,
66 renderer:rendererstatusimg, 65 renderer:rendererstatusimg,
67 // editor: new Ext.form.TextField({ 66 // editor: new Ext.form.TextField({
68 allowBlank: true 67 // allowBlank: true
69 // }) 68 // })
70 }, 69 },
71 70
...@@ -73,7 +72,7 @@ Ext.define('App.view.Sv', { ...@@ -73,7 +72,7 @@ Ext.define('App.view.Sv', {
73 { 72 {
74 text : 'Процесс', 73 text : 'Процесс',
75 dataIndex : 'process', 74 dataIndex : 'process',
76 flex : 1, 75 width : 150,
77 renderer:renderercell, 76 renderer:renderercell,
78 // editor: new Ext.form.TextField({ 77 // editor: new Ext.form.TextField({
79 // allowBlank: true 78 // allowBlank: true
...@@ -83,7 +82,7 @@ Ext.define('App.view.Sv', { ...@@ -83,7 +82,7 @@ Ext.define('App.view.Sv', {
83 { 82 {
84 text : 'Примечание', 83 text : 'Примечание',
85 dataIndex : 'isrun', 84 dataIndex : 'isrun',
86 flex : 1, 85 width : 170,
87 renderer:rendererstatustitle, 86 renderer:rendererstatustitle,
88 // editor: new Ext.form.TextField({ 87 // editor: new Ext.form.TextField({
89 allowBlank: true 88 allowBlank: true
...@@ -93,18 +92,17 @@ Ext.define('App.view.Sv', { ...@@ -93,18 +92,17 @@ Ext.define('App.view.Sv', {
93 { 92 {
94 text : 'Автозагрузка', 93 text : 'Автозагрузка',
95 dataIndex : 'autostart', 94 dataIndex : 'autostart',
96 flex : 1, 95 width : 100,
97 xtype: 'checkcolumn' 96 xtype: 'checkcolumn'
98 }, 97 },
99 98
100 99
101 { 100 {
102 xtype:'actioncolumn', 101 xtype:'actioncolumn',
103 margin: "10 20 20 20", 102 width:170,
104 items: [{ 103 items: [{
105 icon: 'resources/img/start.png', 104 icon: 'resources/img/start.png',
106 tooltip: 'Запустить', 105 tooltip: 'Запустить',
107 margin: "10 20 20 20",
108 handler: function(grid, rowIndex, colIndex) { 106 handler: function(grid, rowIndex, colIndex) {
109 var rec = grid.getStore().getAt(rowIndex); 107 var rec = grid.getStore().getAt(rowIndex);
110 alert("Edit " + rec.get('firstname')); 108 alert("Edit " + rec.get('firstname'));
...@@ -112,7 +110,6 @@ Ext.define('App.view.Sv', { ...@@ -112,7 +110,6 @@ Ext.define('App.view.Sv', {
112 },{ 110 },{
113 icon: 'resources/img/stop.png', 111 icon: 'resources/img/stop.png',
114 tooltip: 'Остановить', 112 tooltip: 'Остановить',
115 margin: "10 20 20 20",
116 handler: function(grid, rowIndex, colIndex) { 113 handler: function(grid, rowIndex, colIndex) {
117 var rec = grid.getStore().getAt(rowIndex); 114 var rec = grid.getStore().getAt(rowIndex);
118 alert("Terminate " + rec.get('firstname')); 115 alert("Terminate " + rec.get('firstname'));
...@@ -121,7 +118,6 @@ Ext.define('App.view.Sv', { ...@@ -121,7 +118,6 @@ Ext.define('App.view.Sv', {
121 { 118 {
122 icon: 'resources/img/replay.png', 119 icon: 'resources/img/replay.png',
123 tooltip: 'Перезапустить', 120 tooltip: 'Перезапустить',
124 margin: "10 20 20 20",
125 handler: function(grid, rowIndex, colIndex) { 121 handler: function(grid, rowIndex, colIndex) {
126 var rec = grid.getStore().getAt(rowIndex); 122 var rec = grid.getStore().getAt(rowIndex);
127 alert("Terminate " + rec.get('firstname')); 123 alert("Terminate " + rec.get('firstname'));
...@@ -131,8 +127,6 @@ Ext.define('App.view.Sv', { ...@@ -131,8 +127,6 @@ Ext.define('App.view.Sv', {
131 ] 127 ]
132 } 128 }
133 129
134
135
136 ] 130 ]
137 }); 131 });
138 132
......
1 package org.emercit.controldevtools.bean;
2
3 import java.awt.Color;
4 import java.awt.Dimension;
5 import java.awt.EventQueue;
6 import java.awt.Font;
7 import java.awt.Graphics;
8 import java.awt.event.ActionEvent;
9 import java.awt.event.ActionListener;
10 import java.beans.PropertyChangeListener;
11 import java.beans.PropertyVetoException;
12 import java.beans.VetoableChangeListener;
13 import java.beans.VetoableChangeSupport;
14 import java.io.Externalizable;
15 import java.io.IOException;
16 import java.io.ObjectInput;
17 import java.io.ObjectOutput;
18 import java.util.Timer;
19 import java.util.TimerTask;
20
21 import javax.swing.ImageIcon;
22 import javax.swing.JButton;
23 import javax.swing.JComponent;
24 import javax.swing.JFrame;
25 import javax.swing.JLabel;
26 import javax.swing.SwingWorker;
27 import javax.swing.event.ChangeEvent;
28 import javax.swing.event.ChangeListener;
29 import javax.swing.event.EventListenerList;
30 import javax.swing.event.SwingPropertyChangeSupport;
31
32 import org.apache.log4j.Logger;
33 import org.emercit.utilstools.config.DefSettings;
34 import org.emercit.pckutils.checkservice.STService;
35
36 import org.emercit.utilstools.service.Settings;
37
38 public class DevToolsBean extends RoundPanel implements Externalizable {
39
40 private static final Logger log = Logger.getLogger(DevToolsBean.class);
41
42 private Dimension beanDimension; // simple
43
44 private JLabel lblTitle=new JLabel();
45
46 private JLabel lblStatus=new JLabel();
47
48 private JButton btnStart=new JButton("ЗАПУСТИТЬ");
49
50 private JButton btnStop=new JButton("ОСТАНОВИТЬ");
51
52 private JButton btnDefaults=new JButton("СБРОС НАСТРОЕК");
53
54 private STService stservice=new STService();
55
56 private Timer timerAnimate=new Timer();
57
58 private Settings settings=new Settings();
59
60 protected transient ChangeEvent changeEvent = null;
61
62 public Update update=null;
63
64 public boolean block=false;
65
66 protected EventListenerList listenerList = new EventListenerList();
67
68
69 public DevToolsBean() {
70
71 this.setLayout(null);
72 this.setBackground(new Color(168, 181, 224)); // blue
73
74 beanDimension = new Dimension(600, 130);
75
76 Font font = new Font(null, Font.ITALIC, 13);
77 lblTitle.setBounds(10, 2, 600, 30);
78
79 lblTitle.setText(DefSettings.devtools_title);
80 lblTitle.setFont(font);
81 lblTitle.setForeground(Color.BLUE);
82 add(lblTitle);
83
84 // BUTTON START
85 btnStart.setIcon(new ImageIcon(DevToolsBean.class.getResource("/start.png")));
86 btnStart.setBounds(10,30,150,40);
87 btnStart.setFont(font);
88 btnStart.setSelected(false);
89 btnStart.addActionListener(new Start());
90 add(btnStart);
91
92
93
94 // BUTTON STOP
95 btnStop.setIcon(new ImageIcon(DevToolsBean.class.getResource("/stop.png")));
96 btnStop.setBounds(170,30,180,40);
97 btnStop.setFont(font);
98 btnStop.setSelected(false);
99 btnStop.addActionListener(new Stop());
100 add(btnStop);
101
102
103 // BUTTON DEFAULTS
104 btnDefaults.setIcon(new ImageIcon(DevToolsBean.class.getResource("/replay.png")));
105 btnDefaults.setBounds(360,30,230,40);
106 btnDefaults.setFont(font);
107 btnDefaults.setSelected(false);
108 btnDefaults.addActionListener(new Defaults());
109 add(btnDefaults);
110
111
112 // STATUS
113 font = new Font(null, Font.ITALIC, 18);
114 lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/running.png")));
115 lblStatus.setBounds(10,80,600,55);
116 lblStatus.setForeground(Color.YELLOW);
117 lblStatus.setText("");
118 lblStatus.setVisible(true);
119 lblStatus.setFont(font);
120 add(lblStatus);
121
122
123 timerAnimate.schedule(new Task(),0,10000);
124 }
125
126
127 public void initCmpEnabled() {
128
129 try {
130 boolean jattyrun=stservice.IsRun(DefSettings.jetty_process);
131
132 if(jattyrun){
133
134 btnStop.setEnabled(true);
135 btnStart.setEnabled(false);
136
137 lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/up.png")));
138 lblStatus.setForeground(Color.GREEN);
139 lblStatus.setText("- Web конфигуратор запущен.");
140
141
142 }else {
143
144 btnStop.setEnabled(false);
145 btnStart.setEnabled(true);
146
147 lblStatus.setIcon(new ImageIcon(DevToolsBean.class.getResource("/down.png")));
148 lblStatus.setForeground(Color.WHITE);
149 lblStatus.setText("- Web конфигуратор не запущен.");
150
151
152 }
153 }catch(Exception e){
154 log.error(e.getMessage());
155 }
156
157 }
158
159
160 public class Start implements ActionListener
161 {
162 public void actionPerformed(ActionEvent e)
163 {
164
165 btnStart.setEnabled(false);
166 btnStop.setEnabled(false);
167 lblStatus.setForeground(Color.YELLOW);
168 lblStatus.setText(" - выполняется запуск Web конфигуратора ...");
169
170 block=true;
171
172 //TODO
173
174 block=false;
175 }
176 }
177
178
179 public class Stop implements ActionListener
180 {
181 public void actionPerformed(ActionEvent e)
182 {
183 btnStart.setEnabled(false);
184 btnStop.setEnabled(false);
185 lblStatus.setForeground(Color.YELLOW);
186 lblStatus.setText(" - выполняется остановка Web конфигуратора ...");
187
188 block=true;
189
190 //TODO
191
192 block=false;
193
194
195 }
196 }
197
198
199 public class Defaults implements ActionListener
200 {
201 public void actionPerformed(ActionEvent e)
202 {
203
204 new SwingWorker<Void, Void>()
205 {
206 protected Void doInBackground() throws Exception
207 {
208 block=true;
209 lblStatus.setForeground(Color.YELLOW);
210 lblStatus.setText(" - выполняется сброс настроек ...");
211
212 btnDefaults.setEnabled(false);
213 btnStart.setEnabled(false);
214 btnStop.setEnabled(false);
215
216 try {
217 settings.init();
218
219 Thread.sleep(5000);
220
221 }catch(Exception er) {
222 log.error(er.getMessage());
223 }
224 btnDefaults.setEnabled(true);
225 block=false;
226 return null;
227
228 }
229
230 }.execute();
231
232
233
234
235
236
237 }
238 }
239
240
241
242
243
244
245 public void paintComponent(Graphics g) {
246 super.paintComponent(g);
247 }
248
249
250 public void setPreferredSize(Dimension dim) {
251 beanDimension = dim;
252 }
253
254 public Dimension getPreferredSize() {
255 return beanDimension;
256 }
257
258 public void setMinimumSize(Dimension dim) {
259 beanDimension = dim;
260 }
261
262 public Dimension getMinimumSize() {
263 return beanDimension;
264 }
265
266
267
268 public void addChangeListener(ChangeListener l) {
269 listenerList.add(ChangeListener.class, l);
270 }
271
272 public void removeChangeListener(ChangeListener l) {
273 listenerList.remove(ChangeListener.class, l);
274 }
275
276
277 protected void fireStateChanged() {
278 Object[] listeners = listenerList.getListenerList();
279
280 for (int i = listeners.length - 2; i >= 0; i -= 2) {
281 if (listeners[i] == ChangeListener.class) {
282 if (changeEvent == null)
283 changeEvent = new ChangeEvent(this);
284 ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent);
285 }
286 }
287 }
288
289 public void writeExternal(ObjectOutput out) throws IOException {
290
291 out.writeObject(beanDimension);
292
293 }
294
295 public void readExternal(ObjectInput in) throws IOException,
296 ClassNotFoundException {
297
298 setPreferredSize((Dimension) in.readObject());
299
300 setMinimumSize(getPreferredSize());
301
302 }
303
304
305
306
307 public class Update extends SwingWorker<Void, Void> {
308 @Override
309 public Void doInBackground()
310 {
311 // Если выполняется запуск или остановка, то не проверяем
312 if (!block){
313 initCmpEnabled();
314 }
315
316 return null;
317 }
318
319 @Override
320 public void done(){
321
322
323 }
324 }
325
326
327
328 private class Task extends TimerTask {
329
330 @Override
331 public void run() {
332 EventQueue.invokeLater(new Runnable() {
333 // @Override
334 public void run() {
335
336 update=new Update();
337 update.execute();
338
339
340
341 }
342
343 });
344 }
345 }
346
347
348
349 public static void main(String[] args) {
350 JFrame frame = new JFrame("Управление Web конфигуратором");
351 frame.getContentPane().add(new DevToolsBean());
352 frame.setVisible(true);
353 frame.pack();
354 }
355 }
...\ No newline at end of file ...\ No newline at end of file
1 package org.emercit.controldevtools.bean;
2
3
4 import java.awt.BasicStroke;
5 import java.awt.Color;
6 import java.awt.Dimension;
7 import java.awt.Graphics;
8 import java.awt.Graphics2D;
9 import java.awt.RenderingHints;
10 import javax.swing.JPanel;
11
12 public class RoundPanel extends JPanel
13 {
14 protected int _strokeSize = 1;
15 protected Color _shadowColor = Color.BLACK;
16 protected boolean _shadowed = true;
17 protected boolean _highQuality = true;
18 protected Dimension _arcs = new Dimension(15, 15);
19 protected int _shadowGap = 3;
20 protected int _shadowOffset = 4;
21 protected int _shadowAlpha = 100;
22
23 public Color _backgroundColor = Color.WHITE;
24
25 public RoundPanel()
26 {
27 super();
28 setOpaque(false);
29 }
30
31
32 @Override
33 public void setBackground(Color c)
34 {
35 _backgroundColor = c;
36 }
37
38 @Override
39 protected void paintComponent(Graphics g)
40 {
41 super.paintComponent(g);
42
43 int width = getWidth();
44 int height = getHeight();
45 int shadowGap = this._shadowGap;
46 Color shadowColorA = new Color(_shadowColor.getRed(), _shadowColor.getGreen(), _shadowColor.getBlue(), _shadowAlpha);
47 Graphics2D graphics = (Graphics2D) g;
48
49 if(_highQuality)
50 {
51 graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
52 }
53
54 if(_shadowed)
55 {
56 graphics.setColor(shadowColorA);
57 graphics.fillRoundRect(_shadowOffset, _shadowOffset, width - _strokeSize - _shadowOffset,
58 height - _strokeSize - _shadowOffset, _arcs.width, _arcs.height);
59 }
60 else
61 {
62 _shadowGap = 1;
63 }
64
65 graphics.setColor(_backgroundColor);
66 graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, _arcs.width, _arcs.height);
67 graphics.setStroke(new BasicStroke(_strokeSize));
68 graphics.setColor(getForeground());
69 graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, _arcs.width, _arcs.height);
70 graphics.setStroke(new BasicStroke());
71 }
72 }
...\ No newline at end of file ...\ No newline at end of file
1 /**
2 *
3 */
4 /**
5 * @author root
6 *
7 */
8 package org.emercit.controldevtools.bean;
...\ No newline at end of file ...\ No newline at end of file
...@@ -81,6 +81,7 @@ public class DefSettings { ...@@ -81,6 +81,7 @@ public class DefSettings {
81 public static final int ctrlpnl_starttime=10000; // время запуска процесса в мс 81 public static final int ctrlpnl_starttime=10000; // время запуска процесса в мс
82 public static final int ctrlpnl_stoptime=5000; // время остановки процесса 82 public static final int ctrlpnl_stoptime=5000; // время остановки процесса
83 83
84 public static final String devtools_title="Web интерфейс для конфигурации";
84 85
85 86
86 } 87 }
......