Code formatting

This commit is contained in:
xfarrow
2023-08-07 12:39:29 +02:00
parent 52e4de968f
commit 0ba5721315
24 changed files with 1691 additions and 1468 deletions

View File

@ -10,65 +10,65 @@ import code.GuiAbstractions.Interfaces.IFrameFactory;
import views.interfaces.ILoginFrame;
public class LoginController {
private ILoginFrame frame;
public LoginController() {
try {
frame = (ILoginFrame) JFrameFactory.createJFrame(IFrameFactory.LOGIN, this);
}
catch (Exception e) {
frame = (ILoginFrame) JFrameFactory
.createJFrame(IFrameFactory.LOGIN, this);
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean Login(String host, String username, String password, String port) throws IllegalArgumentException {
public boolean Login(String host, String username, String password,
String port) throws IllegalArgumentException {
LoginCredentials.host = host;
LoginCredentials.username = username;
LoginCredentials.password = password;
LoginCredentials.port = Integer.parseInt(port);
if (SshEngine.connetion()) {
frame.setVisible(false);
new DesktopController().showFrame(true);;
return true;
}
else {
} else {
return false;
}
}
public void ValidateInput(String host, String username, String password, String port) throws IllegalArgumentException {
public void ValidateInput(String host, String username, String password,
String port) throws IllegalArgumentException {
// Host Validation. Consider its necessity.
try {
InetAddress.getByName(host);
} catch (UnknownHostException ex) {
throw new IllegalArgumentException("Host could not be found", ex);
}
// Port Validation
try {
Integer.parseInt(port);
}
catch(NumberFormatException ex) {
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Invalid port number", ex);
}
}
}
public void showFrame(boolean show) {
frame.setVisible(show);
}
public String getTitle() {
return Constants.APP_NAME + " " + Constants.VERSION;
}
public static class LoginCredentials{
public static class LoginCredentials {
public static String host;
public static String username;
public static String password;
public static int port;
}
}