Added ErrorPane and implemented various node implementation on Fields
This commit is contained in:
parent
73ee8d093a
commit
b0344bbe24
|
@ -5,8 +5,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
|
@ -14,22 +14,16 @@ public abstract class AbstractAppPane implements AppPane {
|
|||
|
||||
protected GridPane pannello = new GridPane();
|
||||
protected Map<String,Text> Texts = new HashMap<>();
|
||||
protected Map<Text,TextField> Fields = new HashMap<>();
|
||||
protected Map<Text,Node> Fields = new HashMap<>();
|
||||
protected Scene scena = new Scene(pannello);
|
||||
protected int heigth, width, insets;
|
||||
protected List<String> Names = new ArrayList<>();
|
||||
@Override
|
||||
|
||||
abstract public void gridSetup();
|
||||
|
||||
|
||||
@Override
|
||||
public void textFill() {
|
||||
for (String s : Names) {
|
||||
Texts.put(s, new Text(s));
|
||||
Fields.put(Texts.get(s), new TextField());
|
||||
}
|
||||
|
||||
}
|
||||
abstract public void textFill();
|
||||
|
||||
public Scene getScene() {
|
||||
return scena;
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package ClientApp;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class ErrorPane extends AbstractAppPane {
|
||||
private String ErrorMessage;
|
||||
private Stage ErrorStage = new Stage();
|
||||
public ErrorPane(String ErrorMessage) {
|
||||
this.ErrorMessage = ErrorMessage;
|
||||
gridSetup();
|
||||
ErrorStage.setScene(scena);
|
||||
}
|
||||
@Override
|
||||
public void gridSetup() {
|
||||
pannello.setMinHeight(50);
|
||||
pannello.setMinWidth(200);
|
||||
pannello.setPadding(new Insets(10));
|
||||
pannello.setVgap(5);
|
||||
pannello.setHgap(5);
|
||||
pannello.setAlignment(Pos.CENTER);
|
||||
pannello.add(new Text(ErrorMessage), 0, 0);
|
||||
Button CloseButton = new Button("Close");
|
||||
pannello.add(CloseButton, 0, 1);
|
||||
CloseButton.setOnAction( e -> {
|
||||
ErrorStage.close();
|
||||
});
|
||||
|
||||
}
|
||||
public Stage getErrorStage() {
|
||||
return ErrorStage;
|
||||
}
|
||||
@Override
|
||||
public void textFill() {
|
||||
// TODO Auto-generated method stub
|
||||
// Not used for this Pane
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@ import java.util.HashMap;
|
|||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class RegPane extends AbstractAppPane {
|
||||
|
||||
|
@ -25,20 +27,25 @@ public class RegPane extends AbstractAppPane {
|
|||
pannello.add(Fields.get(Texts.get(s)), 1, x++);
|
||||
}
|
||||
Button RegButton = new Button("Register");
|
||||
RegButton.setOnAction(e->{
|
||||
RegButton.setOnAction( e -> {
|
||||
for(String name : UserDataTypes.Names()) {
|
||||
String out = "";
|
||||
ClientInfo.put(name,Fields.get(Texts.get(name)).getText());
|
||||
Fields.get(Texts.get(name)).clear();
|
||||
out += ClientInfo.get(name);
|
||||
|
||||
System.out.println(out);
|
||||
if ( Fields.get(Texts.get(name)) instanceof TextField ) {
|
||||
ClientInfo.put(name,((TextField)Fields.get(Texts.get(name))).getText());
|
||||
((TextField)Fields.get(Texts.get(name))).clear();
|
||||
}
|
||||
/*ClientInfo.put(name,Fields.get(Texts.get(name)).getText());
|
||||
//Fields.get(Texts.get(name)).clear();*/
|
||||
}
|
||||
if (!CheckRegInfo()) {
|
||||
ErrorPane ErSt = new ErrorPane("Invalid Credentials");
|
||||
ErSt.getErrorStage().show();
|
||||
}
|
||||
});
|
||||
pannello.add(RegButton, x++, x);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public RegPane (int insets, int width, int heigth, ArrayList<String> S) {
|
||||
this.width = width;
|
||||
this.heigth = heigth;
|
||||
|
@ -49,5 +56,34 @@ public class RegPane extends AbstractAppPane {
|
|||
textFill();
|
||||
gridSetup();
|
||||
}
|
||||
|
||||
|
||||
private boolean CheckRegInfo() {
|
||||
//TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void textFill() {
|
||||
for (String Name : Names) {
|
||||
if ( Name.equals("Luogo") ) {
|
||||
Texts.put( Name, new Text(Name+" di nascità") );
|
||||
Fields.put( Texts.get(Name), new TextField() );
|
||||
} else if ( Name.equals("Data") ) {
|
||||
Texts.put(Name, new Text(Name+" di nascità") );
|
||||
Fields.put( Texts.get(Name), new TextField() );
|
||||
} else if ( Name.equals("Password") ) {
|
||||
Texts.put( Name, new Text(Name) );
|
||||
Fields.put( Texts.get(Name), new TextField() );
|
||||
|
||||
} else if ( Name.equals("RPassword") ) {
|
||||
Texts.put( Name, new Text("Repeat Password") );
|
||||
Fields.put( Texts.get(Name), new TextField() );
|
||||
|
||||
} else {
|
||||
Texts.put( Name, new Text(Name) );
|
||||
Fields.put( Texts.get(Name), new TextField() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,10 +3,15 @@ package ClientApp;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public enum UserDataTypes {
|
||||
GAY,
|
||||
NERO,
|
||||
FROCIO,
|
||||
GRASSO;
|
||||
Nome,
|
||||
Cognome,
|
||||
Città,
|
||||
Provincia,
|
||||
Luogo,
|
||||
Data,
|
||||
Password,
|
||||
RPassword;
|
||||
|
||||
public static ArrayList<String> Names() {
|
||||
ArrayList<String> names = new ArrayList<>();
|
||||
for (var N: UserDataTypes.values()) {
|
||||
|
|
Loading…
Reference in New Issue