Skip to content

Commit d79fa4f

Browse files
authored
Merge pull request #20 from NetworkingDevs/version1_2_0
Version1 2 0
2 parents cc45a00 + 4865c6d commit d79fa4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4146
-386
lines changed

NS3-GUI.iml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:win:21.0.1" level="project" />
1919
<orderEntry type="library" name="Maven: org.openjfx:javafx-base:21.0.1" level="project" />
2020
<orderEntry type="library" name="Maven: org.openjfx:javafx-base:win:21.0.1" level="project" />
21+
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.23.1" level="project" />
22+
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.23.1" level="project" />
2123
<orderEntry type="library" name="Maven: com.intellij:forms_rt:7.0.3" level="project" />
2224
<orderEntry type="library" name="Maven: asm:asm-commons:3.0" level="project" />
2325
<orderEntry type="library" name="Maven: asm:asm-tree:3.0" level="project" />

diagram.svg

Lines changed: 1 addition & 1 deletion
Loading

pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@
2121
<artifactId>javafx-swing</artifactId>
2222
<version>21.0.1</version>
2323
</dependency>
24+
<!-- for logging and all that stuff -->
25+
<dependency>
26+
<groupId>org.apache.logging.log4j</groupId>
27+
<artifactId>log4j-api</artifactId>
28+
<version>2.23.1</version>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.apache.logging.log4j</groupId>
32+
<artifactId>log4j-core</artifactId>
33+
<version>2.23.1</version>
34+
</dependency>
2435
<dependency>
2536
<groupId>com.intellij</groupId>
2637
<artifactId>forms_rt</artifactId>

src/main/Dialogs/Dialog_ConfigureClient.java

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
package Dialogs;
22

3+
import Helpers.LoggingHelper;
4+
import Helpers.PlaceHolderHelper;
5+
import org.jetbrains.annotations.Debug;
6+
37
import javax.swing.*;
48
import java.awt.event.ActionEvent;
59
import java.awt.event.ActionListener;
610
import java.util.ArrayList;
711
import java.util.Map;
812

13+
/**
14+
* to manage the configuration of one UDP Echo client
15+
* */
916
public class Dialog_ConfigureClient extends JFrame {
1017
private JPanel JPanel_main;
1118
private JLabel lbl_clientIndex;
@@ -22,18 +29,62 @@ public class Dialog_ConfigureClient extends JFrame {
2229
private JTextField textField_packets;
2330
private JButton btn_save;
2431

32+
/**
33+
* placeholder for start time
34+
* */
35+
private static String PLACEHOLDER_START_TIME = "Enter start time";
36+
/**
37+
* placeholder for uptime
38+
* */
39+
private static String PLACEHOLDER_UP_TIME = "Enter total up time";
40+
/**
41+
* placeholder for MTU
42+
* */
43+
private static String PLACEHOLDER_MTU = "Enter the MTU";
44+
/**
45+
* placeholder for interval between two packets
46+
* */
47+
private static String PLACEHOLDER_INTERVAL = "Enter the interval";
48+
/**
49+
* placeholder for total packets to be sent
50+
* */
51+
private static String PLACEHOLDER_TOT_PACKETS = "Enter total packets";
2552
// mention all the components that have to be taken here....
53+
/**
54+
* the key for overview label
55+
* */
2656
public static final String COMPONENT_OVERVIEW_LABEL = "Server_OverviewLabel";
2757

2858
// for serving the functionalities....
59+
/**
60+
* the map for helpful components
61+
* */
2962
Map<String, JComponent> helpfulComponents;
3063

3164
// for serving the functionalities...
65+
/**
66+
* the total no. of nodes
67+
* */
3268
int totalNodes;
69+
/**
70+
* the client configuration settings
71+
* */
3372
public ArrayList<String> settings;
73+
/**
74+
* dialog helper
75+
* */
3476
Dialog_Helper dialogHelper;
3577

78+
79+
/**
80+
* to create the object of type Dialog_ConfigureClient Server
81+
*
82+
* @param n total no. of nodes
83+
* @param helpfulComponents the map of helpful components
84+
* @since 0.3.0
85+
* */
3686
public Dialog_ConfigureClient(int n, Map<String, JComponent> helpfulComponents) {
87+
LoggingHelper.Log("Creating object of type Dialog_ConfigureClient");
3788
this.helpfulComponents = helpfulComponents;
3889
this.totalNodes = n;
3990
this.settings = new ArrayList<>();
@@ -42,15 +93,22 @@ public Dialog_ConfigureClient(int n, Map<String, JComponent> helpfulComponents)
4293
// initializing the components...
4394
this.setContentPane(this.JPanel_main);
4495
this.setTitle("Client Configuration");
45-
this.setSize(400,275);
96+
this.setSize(400,300);
4697
this.setVisible(false);
4798
this.setResizable(false);
4899
this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
49100

101+
PlaceHolderHelper.addPlaceHolder(textField_startTime,PLACEHOLDER_START_TIME);
102+
PlaceHolderHelper.addPlaceHolder(textField_upTime,PLACEHOLDER_UP_TIME);
103+
PlaceHolderHelper.addPlaceHolder(textField_mtu,PLACEHOLDER_MTU);
104+
PlaceHolderHelper.addPlaceHolder(textField_interval,PLACEHOLDER_INTERVAL);
105+
PlaceHolderHelper.addPlaceHolder(textField_packets,PLACEHOLDER_TOT_PACKETS);
106+
50107
// action to be performed when clicking on save settings button...
51108
btn_save.addActionListener(new ActionListener() {
52109
@Override
53110
public void actionPerformed(ActionEvent e) {
111+
LoggingHelper.LogFunction("Saving the client configurations!");
54112
// validate inputs...
55113
if (validateInputs()) {
56114
// and if all are valid then save settings...
@@ -69,50 +127,113 @@ public void actionPerformed(ActionEvent e) {
69127
});
70128
}
71129

130+
/**
131+
* to make the dialog visible with list of all nodes
132+
*
133+
* @param b whether to show or hide
134+
* @since 0.3.0
135+
* */
72136
@Override
73137
public void setVisible(boolean b) {
74138
super.setVisible(b);
75139
if (b) {
140+
LoggingHelper.LogFunction("Configure CLinet : Populating the dropdown items for all nodes.");
76141
for (int i=0; i<this.totalNodes; i++) {
77142
this.comboBox_clientIndex.addItem("Node "+i);
78143
}
79144
}
80145
}
81146

147+
/**
148+
* to show dialog with nodes
149+
*
150+
* @param n the total nodes
151+
* @since 0.3.0
152+
* */
82153
public void showDialog(int n) {
154+
LoggingHelper.LogInfo("Configure Client : Setting total nodes!");
83155
this.totalNodes = n;
84156
this.setVisible(true);
85157
}
86158

159+
/**
160+
* to get the stop time of the client
161+
*
162+
* @since 1.0.0
163+
* */
87164
public int getStopTime() {
165+
LoggingHelper.Log("Configure Client : Get Stop Time Called!");
88166
return Integer.parseInt(this.settings.get(1)) + Integer.parseInt(this.settings.get(2));
89167
}
90168

169+
/**
170+
* to get the start time of the client
171+
*
172+
* @since 1.0.0
173+
* */
91174
public String getStartTime() {
175+
LoggingHelper.Log("Configure Client : Get Start Time Called!");
92176
return this.settings.get(1);
93177
}
94178

179+
/**
180+
* to get the index of the client node
181+
*
182+
* @since 1.0.0
183+
* */
95184
public String getClientIndex() {
185+
LoggingHelper.Log("Configure Client : Get Client Index Called!");
96186
return this.settings.get(0);
97187
}
98188

189+
/**
190+
* to get the MTU of the client
191+
*
192+
* @since 1.0.0
193+
* */
99194
public String getMTU() {
195+
LoggingHelper.Log("Configure Client : Get MTU Called!");
100196
return this.settings.get(3);
101197
}
102198

199+
/**
200+
* to get the interval of the client
201+
*
202+
* @since 1.0.0
203+
* */
103204
public String getInterval() {
205+
LoggingHelper.Log("Configure Client : Get Interval Called!");
104206
return this.settings.get(4);
105207
}
106208

209+
/**
210+
* to get the no. of packets for the client
211+
*
212+
* @since 1.0.0
213+
* */
107214
public String getPackets() {
215+
LoggingHelper.Log("Configure Client : Get Packets Called!");
108216
return this.settings.get(5);
109217
}
110218

219+
/**
220+
* to update the overview text
221+
*
222+
* @since 0.3.0
223+
* */
111224
private void updateOverviewTxt() {
225+
LoggingHelper.Log("Configure Client : Changing the overview label!");
112226
((JLabel)this.helpfulComponents.get(COMPONENT_OVERVIEW_LABEL)).setText("Client Index : Configured node "+this.settings.get(0));
113227
}
114228

229+
/**
230+
* to validate the input settings
231+
*
232+
* @return the boolean value indicating the validity of the inputs
233+
* @since 0.3.0
234+
* */
115235
private boolean validateInputs() {
236+
LoggingHelper.LogFunction("Configure Client : Validating all inputs");
116237

117238
// start time validation...
118239
if (!textField_startTime.getText().chars().allMatch(Character::isDigit) || textField_startTime.getText().toString().length() == 0) {

0 commit comments

Comments
 (0)