Skip to content
Snippets Groups Projects
Commit e81f4d2b authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Progress Dialog für Funkraum

parent 88f56483
No related branches found
No related tags found
No related merge requests found
......@@ -10,9 +10,7 @@ import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Circle;
import javafx.stage.StageStyle;
import org.apache.http.HttpException;
import org.controlsfx.dialog.ProgressDialog;
import projekt.enigma.model.Codierer;
import projekt.enigma.model.Fehler;
......@@ -56,10 +54,10 @@ public class GuiController {
@FXML
private Label lblA, lblB, lblC, lblD, lblE, lblF, lblG, lblH, lblI, lblJ, lblK, lblL, lblM, lblN, lblO, lblP, lblQ,
lblR, lblS, lblT, lblU, lblV, lblW, lblX, lblY, lblZ, lblLadeNachricht, lblTagesschluessel,
lblSpruchschluessel, lblKenngruppe;
//deklariert die ProgressBar
lblSpruchschluessel, lblKenngruppe, lblProgressText;
//deklariert den ProgressIndicator
@FXML
private ProgressBar pbLadeNachricht;
private ProgressIndicator piProgress;
//deklariert die MenueButtons
@FXML
private MenuButton mBtnWalzPos1, mBtnWalzPos2, mBtnWalzPos3, mBtnNotchPos1, mBtnNotchPos2, mBtnNotchPos3,
......@@ -70,7 +68,7 @@ public class GuiController {
tfStecker9, tfStecker10, tfCodiert, tfKlartext;
//deklariert benötigtes pane
@FXML
private Pane portPane;
private Pane portPane, paneProgress;
//deklariert benötigtes GridPane
@FXML
private GridPane mainGrid;
......@@ -90,7 +88,6 @@ public class GuiController {
textEingabe = "";
textCodiert = "";
resetDisplay = true;
lblKenngruppe.setText(this.codierer.getKenngruppe());
//Einträge für Walzen
menu(mBtnWalzPos1, walzenNr);
......@@ -550,25 +547,7 @@ public class GuiController {
* sowie den Klartext in das Textfeld tfKlartext. Setzt den Spruchschlüssel
*/
private void empfangeFunkspruch() {
progressDialogue("rx");
try {
if (this.empfangeneNachricht[2] != null && this.empfangeneNachricht[1] != null) {
setzeTagesSchluessel();
tfKlartext.setText(this.empfangeneNachricht[2]);
tfCodiert.setText(this.empfangeneNachricht[1]);
resetDisplay = true;
// Spruchschluessel in das Feld lblSpruchschluessel schreiben
lblSpruchschluessel.setText(codierer.empfangenerSpruchschluessel(this.empfangeneNachricht[2]));
}
} catch (NullPointerException ignored) {
new Fehler().showErrorDialog(
"warning",
"Keiner schreibt dir...",
"Es liegen keine neuen Nachrichten im Funkraum für Sie vor.");
}
funkraumProgressDialogue("rx");
}
/**
......@@ -576,11 +555,10 @@ public class GuiController {
* Löscht die Textfelder tfKlartext und tfCodiert
*/
private void sendeFunkspruch() {
this.tfKlartext.setText("");
this.tfCodiert.setText("");
progressDialogue("tx");
funkraumProgressDialogue("tx");
}
/**
......@@ -588,25 +566,18 @@ public class GuiController {
*
* @param strRxTx
*/
private void progressDialogue(String strRxTx) {
private void funkraumProgressDialogue(String strRxTx) {
Task copyWorker = createWorker(strRxTx);
ProgressDialog dialog = new ProgressDialog(copyWorker);
dialog.initStyle(StageStyle.TRANSPARENT);
dialog.setGraphic(null);
dialog.initStyle(StageStyle.TRANSPARENT);
dialog.setTitle("Kommunikation zum Funkraum");
if (strRxTx.equals("rx")) {
dialog.setContentText("Empfange Nachricht");
//dialog.setContentText("Empfange Nachricht");
paneProgress.setVisible(true);
} else if (strRxTx.equals("tx")) {
dialog.setContentText("Sende Nachricht");
paneProgress.setVisible(true);
//dialog.setContentText("Sende Nachricht");
}
dialog.setHeaderText(null);
dialog.setGraphic(null);
dialog.initStyle(StageStyle.UTILITY);
new Thread(copyWorker).start();
dialog.showAndWait();
}
/**
......@@ -619,16 +590,33 @@ public class GuiController {
return new Task() {
@Override
protected Object call() throws Exception {
if (strRxTx.equals("rx")) {
empfangeneNachricht = codierer.empfangeNachricht();
} else if (strRxTx.equals("tx")) {
try {
try {
if (strRxTx.equals("rx")) {
empfangeneNachricht = codierer.empfangeNachricht();
try {
if (empfangeneNachricht[2] != null && empfangeneNachricht[1] != null) {
setzeTagesSchluessel();
tfKlartext.setText(empfangeneNachricht[2]);
tfCodiert.setText(empfangeneNachricht[1]);
resetDisplay = true;
// Spruchschluessel in das Feld lblSpruchschluessel schreiben
lblSpruchschluessel.setText(codierer.empfangenerSpruchschluessel(empfangeneNachricht[2]));
}
} catch (NullPointerException ignored) {
new Fehler().showErrorDialog(
"warning",
"Keiner schreibt dir...",
"Es liegen keine neuen Nachrichten im Funkraum für Sie vor.");
}
} else if (strRxTx.equals("tx")) {
codierer.sendeNachricht();
} catch (HttpException | IOException e) {
e.printStackTrace();
}
} catch (HttpException | IOException e) {
e.printStackTrace();
} finally {
paneProgress.setVisible(false);
}
return true;
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment