Skip to content

Commit 7034e22

Browse files
committed
Convert server connection button disabled state according to input value of server connInfo
1 parent 0c5c4d8 commit 7034e22

File tree

7 files changed

+30
-39
lines changed

7 files changed

+30
-39
lines changed

src/main/java/root/javafx/CustomView/ConnectionInfoAP.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import javafx.scene.layout.AnchorPane;
44

5-
public class ConnectionInfoAP extends AnchorPane {
5+
public abstract class ConnectionInfoAP extends AnchorPane {
66

7+
abstract boolean isAnyEmptyInputForConnectionTest();
78
}

src/main/java/root/javafx/CustomView/ConnectionInfoVBox.java

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import root.javafx.DI.DependencyInjection;
2929
import root.javafx.Service.ConnectionTestService;
3030
import root.utils.AlertUtils;
31-
import root.utils.SceneUtils;
3231

3332
public class ConnectionInfoVBox<T> extends VBox {
3433

@@ -47,6 +46,9 @@ public class ConnectionInfoVBox<T> extends VBox {
4746
@FXML
4847
Text connInfoText; // 접속정보 인덱스 텍스트
4948

49+
@FXML
50+
FontAwesomeIconView connTestIcon;
51+
5052
@FXML
5153
JFXButton connTestBtn;
5254

@@ -215,9 +217,6 @@ private void bringFrontConnInfoAnchorPane(long index) {
215217
prevConnInfoBtn.setDisable(false);
216218
nextConnInfoBtn.setDisable(false);
217219
}
218-
219-
// Index logging
220-
// this.connInfoAPMap.print(connInfoIdx);
221220
}
222221

223222
private void setConnInfoIndexText() {
@@ -234,24 +233,23 @@ private void setConnInfoIndexText() {
234233

235234
// TODO Convert to Enum class
236235
private void setConnectionBtnIcon(int type) {
237-
FontAwesomeIconView icon = (FontAwesomeIconView) connTestBtn.lookup("#icon");
238236
switch (type) {
239237
case 1:
240-
icon.setIcon(FontAwesomeIcon.PLUG);
241-
icon.setFill(Paint.valueOf("#000000"));
238+
connTestIcon.setIcon(FontAwesomeIcon.PLUG);
239+
connTestIcon.setFill(Paint.valueOf("#000000"));
242240
break;
243241
case 2:
244-
icon.setIcon(FontAwesomeIcon.CHECK);
245-
icon.setFill(Paint.valueOf("#49a157"));
242+
connTestIcon.setIcon(FontAwesomeIcon.CHECK);
243+
connTestIcon.setFill(Paint.valueOf("#49a157"));
246244
break;
247245
case 3:
248-
icon.setIcon(FontAwesomeIcon.TIMES);
249-
icon.setFill(Paint.valueOf("#c40a0a"));
246+
connTestIcon.setIcon(FontAwesomeIcon.TIMES);
247+
connTestIcon.setFill(Paint.valueOf("#c40a0a"));
250248
break;
251249
case 4:
252-
icon.setIcon(FontAwesomeIcon.SPINNER);
253-
icon.setFill(Paint.valueOf("#484989"));
254-
icon.getStyleClass().add("fa-spin");
250+
connTestIcon.setIcon(FontAwesomeIcon.SPINNER);
251+
connTestIcon.setFill(Paint.valueOf("#484989"));
252+
connTestIcon.getStyleClass().add("fa-spin");
255253
break;
256254
}
257255
}
@@ -357,18 +355,5 @@ public long getNextActiveIdx(long connInfoIdx) {
357355
.findFirst()
358356
.orElse(getLastActiveIdx());
359357
}
360-
361-
public void print(long index) {
362-
System.out.println("Current Index: " + index);
363-
for (Long key : map.keySet()) {
364-
if(key == index) {
365-
System.out.print(key + "[:" + map.get(key).getStatus() + ":], ");
366-
} else {
367-
System.out.print(key + "[" + map.get(key).getStatus() + "], ");
368-
}
369-
370-
}
371-
System.out.println();
372-
}
373358
}
374359
}

src/main/java/root/javafx/CustomView/DBConnInfoControl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public boolean save(String configFilePath, Collection<StatefulAP> statefulAP) {
4242

4343
@Override
4444
public boolean canConnectionTest(ConnectionInfoAP curAP) {
45-
return ((DBConnectionInfoAnchorPane) curAP).isAnyEmptyInputForDBConnectionTest();
45+
return curAP.isAnyEmptyInputForConnectionTest();
4646
}
4747

4848
@Override

src/main/java/root/javafx/CustomView/DBConnectionInfoAnchorPane.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public DBConnectionInfoAnchorPane() {
6161
e.printStackTrace();
6262
}
6363
}
64+
65+
@Override
66+
public boolean isAnyEmptyInputForConnectionTest() {
67+
return StringUtils.isAnyEmpty(hostTF.getText(), portTF.getText(), sidTF.getText(), userTF.getText(),
68+
passwordPF.getText(), driverCB.getSelectionModel().getSelectedItem());
69+
}
6470

6571
public void init() {
6672
// DB Url Generate Event Setting
@@ -123,11 +129,6 @@ public JdbcConnectionInfo getInputValues() {
123129
return jdbc;
124130
}
125131

126-
public boolean isAnyEmptyInputForDBConnectionTest() {
127-
return StringUtils.isAnyEmpty(hostTF.getText(), portTF.getText(), sidTF.getText(), userTF.getText(),
128-
passwordPF.getText(), driverCB.getSelectionModel().getSelectedItem());
129-
}
130-
131132
public boolean isAnyEmptyInput() {
132133
return StringUtils.isAnyEmpty(hostTF.getText(), portTF.getText(), sidTF.getText(), userTF.getText(),
133134
passwordPF.getText(), aliasTF.getText(), driverCB.getSelectionModel().getSelectedItem());
@@ -162,7 +163,7 @@ private void setDBConnTestBtnDisable(Node node) {
162163
}
163164

164165
// DB Connection test button lookup and setDisable
165-
topParent.lookup("#connTestBtn").setDisable(isAnyEmptyInputForDBConnectionTest());
166+
topParent.lookup("#connTestBtn").setDisable(isAnyEmptyInputForConnectionTest());
166167
} catch (Exception e) {
167168
e.printStackTrace();
168169
}

src/main/java/root/javafx/CustomView/ServerConnInfoControl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public boolean save(String configFilePath, Collection<StatefulAP> statefulAP) {
3838

3939
@Override
4040
public boolean canConnectionTest(ConnectionInfoAP curAP) {
41-
// TODO Auto-generated method stub
42-
return true;
41+
return curAP.isAnyEmptyInputForConnectionTest();
4342
}
4443

4544
@Override

src/main/java/root/javafx/CustomView/ServerConnectionInfoAnchorPane.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public ServerConnectionInfoAnchorPane() {
5757
e.printStackTrace();
5858
}
5959
}
60+
61+
@Override
62+
boolean isAnyEmptyInputForConnectionTest() {
63+
return StringUtils.isAnyEmpty(hostTF.getText(), portTF.getText(), userTF.getText(), passwordPF.getText());
64+
}
6065

6166
public void init() {
6267
// Set textFormatter

src/main/resources/fxml/ConnectionInfoVBox.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<String fx:value="font-black" />
3030
</styleClass>
3131
<graphic>
32-
<FontAwesomeIconView fx:id="menuIconIV" fill="#0132ac" glyphName="" selectionFill="BLACK" size="20" />
32+
<FontAwesomeIconView fx:id="menuIconIV" fill="#0132ac" glyphName="" selectionFill="BLACK" size="20" text="" />
3333
</graphic>
3434
</Label>
3535
<ToolBar style="-fx-background-color: #ffffff00;" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="0.0">
@@ -41,7 +41,7 @@
4141
<Cursor fx:constant="HAND" />
4242
</cursor>
4343
<graphic>
44-
<FontAwesomeIconView fx:id="icon" glyphName="PLUG" />
44+
<FontAwesomeIconView fx:id="connTestIcon" glyphName="PLUG" />
4545
</graphic>
4646
<HBox.margin>
4747
<Insets right="5.0" />

0 commit comments

Comments
 (0)