Improves a lot of comments and variable names

This commit is contained in:
2020-08-19 21:24:37 +02:00
parent d06cc66f31
commit 83f8834530
6 changed files with 67 additions and 66 deletions

View File

@ -12,17 +12,19 @@ import java.awt.event.ActionListener;
import java.io.File;
/**
* Contains all buttons for configuring a server.
* Does some visual stuff by itself, but otherwise reads user inputs.
* Represents a visual server tab used to configure a server
*
* @author Kristian Knarvik <kristian.knarvik@knett.no>
* @version 1.0.0
* @since 1.0.0
*/
public class ServerTab implements ActionListener {
private final JComboBox<String> serverTypes, serverVersions, maxRam;
private final JCheckBox chckbxEnabled;
private final JButton btnRemoveServer, btnBrowse;
private final JComboBox<String> serverTypes;
private final JComboBox<String> serverVersions;
private final JComboBox<String> maxRam;
private final JCheckBox enabledCheckbox;
private final JButton removeServerButton;
private final JButton browseButton;
private final JTextField directory;
private final JPanel panel;
private final String name;
@ -81,45 +83,45 @@ public class ServerTab implements ActionListener {
panel.add(maxRam);
maxRam.addActionListener(this);
chckbxEnabled = new JCheckBox("Enabled");
sl_panel_3.putConstraint(SpringLayout.WEST, chckbxEnabled, 10, SpringLayout.WEST, panel);
panel.add(chckbxEnabled);
chckbxEnabled.addActionListener(this);
enabledCheckbox = new JCheckBox("Enabled");
sl_panel_3.putConstraint(SpringLayout.WEST, enabledCheckbox, 10, SpringLayout.WEST, panel);
panel.add(enabledCheckbox);
enabledCheckbox.addActionListener(this);
btnRemoveServer = new JButton("Remove server");
sl_panel_3.putConstraint(SpringLayout.NORTH, btnRemoveServer, 0, SpringLayout.NORTH, serverVersions);
sl_panel_3.putConstraint(SpringLayout.SOUTH, btnRemoveServer, 0, SpringLayout.SOUTH, serverVersions);
sl_panel_3.putConstraint(SpringLayout.WEST, btnRemoveServer, 6, SpringLayout.EAST, serverVersions);
sl_panel_3.putConstraint(SpringLayout.EAST, btnRemoveServer, -10, SpringLayout.EAST, panel);
panel.add(btnRemoveServer);
btnRemoveServer.addActionListener(this);
removeServerButton = new JButton("Remove server");
sl_panel_3.putConstraint(SpringLayout.NORTH, removeServerButton, 0, SpringLayout.NORTH, serverVersions);
sl_panel_3.putConstraint(SpringLayout.SOUTH, removeServerButton, 0, SpringLayout.SOUTH, serverVersions);
sl_panel_3.putConstraint(SpringLayout.WEST, removeServerButton, 6, SpringLayout.EAST, serverVersions);
sl_panel_3.putConstraint(SpringLayout.EAST, removeServerButton, -10, SpringLayout.EAST, panel);
panel.add(removeServerButton);
removeServerButton.addActionListener(this);
JLabel lblDirectory = new JLabel("Directory");
sl_panel_3.putConstraint(SpringLayout.WEST, lblDirectory, 6, SpringLayout.EAST, chckbxEnabled);
sl_panel_3.putConstraint(SpringLayout.WEST, lblDirectory, 6, SpringLayout.EAST, enabledCheckbox);
panel.add(lblDirectory);
directory = new JTextField();
sl_panel_3.putConstraint(SpringLayout.WEST, directory, 6, SpringLayout.EAST, lblDirectory);
sl_panel_3.putConstraint(SpringLayout.SOUTH, lblDirectory, 0, SpringLayout.SOUTH, directory);
sl_panel_3.putConstraint(SpringLayout.NORTH, lblDirectory, 0, SpringLayout.NORTH, directory);
sl_panel_3.putConstraint(SpringLayout.NORTH, chckbxEnabled, 0, SpringLayout.NORTH, directory);
sl_panel_3.putConstraint(SpringLayout.SOUTH, chckbxEnabled, 0, SpringLayout.SOUTH, directory);
sl_panel_3.putConstraint(SpringLayout.NORTH, enabledCheckbox, 0, SpringLayout.NORTH, directory);
sl_panel_3.putConstraint(SpringLayout.SOUTH, enabledCheckbox, 0, SpringLayout.SOUTH, directory);
panel.add(directory);
directory.setColumns(10);
directory.addActionListener(this);
btnBrowse = new JButton("Browse");
sl_panel_3.putConstraint(SpringLayout.EAST, directory, -6, SpringLayout.WEST, btnBrowse);
sl_panel_3.putConstraint(SpringLayout.NORTH, btnBrowse, 3, SpringLayout.SOUTH, btnRemoveServer);
sl_panel_3.putConstraint(SpringLayout.EAST, btnBrowse, -10, SpringLayout.EAST, panel);
sl_panel_3.putConstraint(SpringLayout.SOUTH, directory, 0, SpringLayout.SOUTH, btnBrowse);
sl_panel_3.putConstraint(SpringLayout.NORTH, directory, 0, SpringLayout.NORTH, btnBrowse);
panel.add(btnBrowse);
btnBrowse.addActionListener(this);
browseButton = new JButton("Browse");
sl_panel_3.putConstraint(SpringLayout.EAST, directory, -6, SpringLayout.WEST, browseButton);
sl_panel_3.putConstraint(SpringLayout.NORTH, browseButton, 3, SpringLayout.SOUTH, removeServerButton);
sl_panel_3.putConstraint(SpringLayout.EAST, browseButton, -10, SpringLayout.EAST, panel);
sl_panel_3.putConstraint(SpringLayout.SOUTH, directory, 0, SpringLayout.SOUTH, browseButton);
sl_panel_3.putConstraint(SpringLayout.NORTH, directory, 0, SpringLayout.NORTH, browseButton);
panel.add(browseButton);
browseButton.addActionListener(this);
}
/**
* Updates the server tab components according to the received parameters.
* Updates the server tab components according to the received parameters
*
* @param path <p>The new path of the server tab</p>
* @param isEnabled <p>Whether to mark the server as enabled</p>
@ -129,7 +131,7 @@ public class ServerTab implements ActionListener {
*/
public void setData(String path, boolean isEnabled, String typeName, String serverVersion, String maxRam) throws ConfigurationException {
this.directory.setText(path);
this.chckbxEnabled.setSelected(isEnabled);
this.enabledCheckbox.setSelected(isEnabled);
this.serverTypes.setSelectedItem(typeName);
this.updateServerVersion();
this.serverVersions.setSelectedItem(serverVersion);
@ -202,14 +204,14 @@ public class ServerTab implements ActionListener {
* @return <p>True if this server is enabled</p>
*/
public boolean isEnabled() {
return this.chckbxEnabled.isSelected();
return this.enabledCheckbox.isSelected();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnRemoveServer) {
if (e.getSource() == removeServerButton) {
remove();
} else if (e.getSource() == btnBrowse) {
} else if (e.getSource() == browseButton) {
browse();
} else if (e.getSource() == serverTypes) {
try {