Skip to content

Commit 1c4909b

Browse files
committed
Fix to Setup4j
1 parent 46b356f commit 1c4909b

File tree

10 files changed

+180
-122
lines changed

10 files changed

+180
-122
lines changed

c4j_commander4j/commander4j.jar

3.95 KB
Binary file not shown.

c4j_commander4j/src/com/commander4j/cfg/JFrameHostAdmin.java

Lines changed: 80 additions & 114 deletions
Large diffs are not rendered by default.

c4j_commander4j/src/com/commander4j/gui/JTextArea4j.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class JTextArea4j extends JTextArea {
1414

1515
private static final long serialVersionUID = 1L;
1616
private static final Border EMPTY_BORDER = new LineBorder(Color.GRAY);
17+
private boolean hasFocus = false;
1718

1819
private void init()
1920
{
@@ -25,19 +26,40 @@ public JTextArea4j() {
2526
super();
2627
init();
2728
initFocusBehavior();
29+
updateColors();
2830
}
2931

3032
public JTextArea4j(String text) {
3133
super(text);
3234
init();
3335
initFocusBehavior();
36+
updateColors();
3437
}
3538

39+
@Override
40+
public void setEnabled(boolean enabled) {
41+
super.setEnabled(enabled);
42+
updateColors();
43+
}
44+
45+
@Override
46+
public void setEditable(boolean editable) {
47+
super.setEditable(editable);
48+
updateColors();
49+
}
50+
51+
@Override
52+
public void updateUI() {
53+
super.updateUI();
54+
setDisabledTextColor(Common.color_textfield_foreground_disabled);
55+
updateColors();
56+
}
3657

3758
private void initFocusBehavior() {
3859
addFocusListener(new FocusAdapter() {
3960
@Override
4061
public void focusGained(FocusEvent e) {
62+
hasFocus = true;
4163
if (isEditable())
4264
{
4365
setBackground(Common.color_textfield_background_focus_color);
@@ -47,13 +69,32 @@ public void focusGained(FocusEvent e) {
4769

4870
@Override
4971
public void focusLost(FocusEvent e) {
72+
hasFocus = false;
5073
if (isEditable())
5174
{
5275
setBackground(Common.color_textfield_background_nofocus_color);
5376
}
5477
}
5578
});
5679
}
80+
81+
private void updateColors() {
82+
if (!isEnabled()) {
83+
setBackground(Common.color_textfield_background_disabled);
84+
setForeground(Common.color_textfield_foreground_disabled);
85+
} else if (!isEditable()) {
86+
setBackground(Common.color_textfield_background_disabled);
87+
setForeground(Common.color_textfield_foreground_disabled);
88+
} else if (hasFocus){
89+
setBackground(Common.color_textfield_background_focus_color);
90+
setForeground(Common.color_textfield_foreground_focus_color);
91+
} else
92+
{
93+
setBackground(Common.color_textfield_background_nofocus_color);
94+
setForeground(Common.color_textfield_forground_nofocus_color);
95+
}
96+
97+
}
5798

5899
}
59100

c4j_commander4j/src/com/commander4j/sys/Start.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.commander4j.sys;
22

3+
import java.io.IOException;
4+
import java.io.PrintWriter;
35
import java.net.ServerSocket;
46
import java.net.Socket;
57
import java.util.Arrays;
@@ -101,20 +103,24 @@ public static void main(String[] args)
101103
}
102104
catch (Exception e)
103105
{
104-
106+
logger.debug("Waiting for exclusive runtime");
105107
}
106108

107109
if (exclusive == false)
108110
{
109111
try
110112
{
111-
logger.debug("Requesting other Commander4j instances close.");
113+
logger.debug("Requesting other AutoLab instances close.");
112114
Socket clientSocket = new Socket("localhost", Common.singleInstancePort);
115+
116+
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
117+
118+
out.println("shutdown requested");
113119
clientSocket.close();
114120
}
115-
catch (Exception e)
121+
catch (IOException e)
116122
{
117-
123+
118124
}
119125
}
120126
JWait.milliSec(500);

c4j_commander4j/src/com/commander4j/watchdog/WatchDog.java

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.commander4j.watchdog;
22

3+
import java.io.BufferedReader;
34
import java.io.IOException;
5+
import java.io.InputStreamReader;
46
import java.net.ServerSocket;
57
import java.net.Socket;
8+
import java.net.SocketTimeoutException;
69

710
import org.apache.logging.log4j.Logger;
811

@@ -51,6 +54,7 @@ public void run()
5154
try
5255
{
5356
serverSocket = new ServerSocket(port, 1);
57+
logger.debug("WatchDog listening on port " + " : " + String.valueOf(port));
5458

5559
while (true)
5660
{
@@ -59,13 +63,54 @@ public void run()
5963

6064
clientSocket = serverSocket.accept();
6165

62-
clientSocket.close();
66+
String clientIP = clientSocket.getInetAddress().getHostAddress();
6367

64-
logger.debug("WatchDog shutdown request detected.");
68+
try
69+
{
70+
clientSocket.setSoTimeout(5000);
6571

66-
System.exit(0);
72+
BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
73+
String message = in.readLine();
6774

68-
run = false;
75+
if ("shutdown requested".equalsIgnoreCase(message))
76+
{
77+
78+
79+
if (run)
80+
{
81+
82+
logger.debug("WatchDog shutdown request detected.");
83+
84+
System.exit(0);
85+
86+
87+
run = false;
88+
}
89+
}
90+
else
91+
{
92+
System.out.println("Unexpected message: " + message);
93+
}
94+
}
95+
catch (SocketTimeoutException e)
96+
{
97+
98+
}
99+
catch (IOException e)
100+
{
101+
System.out.println("I/O error with " + clientIP + ": " + e.getMessage());
102+
}
103+
finally
104+
{
105+
try
106+
{
107+
clientSocket.close();
108+
}
109+
catch (IOException e)
110+
{
111+
// Ignore
112+
}
113+
}
69114
}
70115
}
71116
catch (IOException e1)
3.95 KB
Binary file not shown.
2.47 KB
Binary file not shown.

c4j_web_WS/target/c4j_web_WS.war

0 Bytes
Binary file not shown.
3.95 KB
Binary file not shown.
2.47 KB
Binary file not shown.

0 commit comments

Comments
 (0)