diff options
Diffstat (limited to 'Dozentenmodul/src/gui/image/EditImageAllgemein_GUI.java')
| -rw-r--r-- | Dozentenmodul/src/gui/image/EditImageAllgemein_GUI.java | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/Dozentenmodul/src/gui/image/EditImageAllgemein_GUI.java b/Dozentenmodul/src/gui/image/EditImageAllgemein_GUI.java index 5ebee0c1..114e6952 100644 --- a/Dozentenmodul/src/gui/image/EditImageAllgemein_GUI.java +++ b/Dozentenmodul/src/gui/image/EditImageAllgemein_GUI.java @@ -56,7 +56,7 @@ public class EditImageAllgemein_GUI extends JFrame { private JTextField Hochschule; private JTextField EMail; private JTextField imagename; - JTextArea textAreadesc; + private JTextArea textAreadesc; ThriftConnection con = new ThriftConnection(); Client client = models.Client.clientcon.getClient(); private JPanel panel_2; @@ -65,6 +65,8 @@ public class EditImageAllgemein_GUI extends JFrame { private JPanel buttonPane; private JButton backButton; private JButton okButton; + boolean textfieldsHaveContent = false; //no textfield is empty + boolean nameIsLettersOnly = false; //imagename only contains letters /** * Create the dialog. @@ -296,13 +298,7 @@ public class EditImageAllgemein_GUI extends JFrame { okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { // check is textfield is empty - if (imagename.getText().length() <= 0) { - JOptionPane.showMessageDialog(null, - "Bitte geben Sie einen Labornamen ein.", - "Daten nicht vollst\u00e4ndig", - JOptionPane.INFORMATION_MESSAGE); - - } else { + if (checkContent() == true && checkNameIsLettersOnly() == true) { // setze Namen, egal ob alt oder nicht Image.image.setImagename(imagename.getText()); @@ -313,6 +309,9 @@ public class EditImageAllgemein_GUI extends JFrame { EditImageTechnisch_GUI ea = new EditImageTechnisch_GUI(); ea.setVisible(true); dispose(); + + } else { + }// end else } }); @@ -444,5 +443,50 @@ public class EditImageAllgemein_GUI extends JFrame { e.getCause() + "\n" + e.getStackTrace(), "Debug-Message", JOptionPane.ERROR_MESSAGE); } - } -} + }//end initData() + + public boolean checkNameIsLettersOnly() { + nameIsLettersOnly = false; + + //only allow letter from alphabet and nothing else + if (imagename.getText().matches("[a-zA-Z]+")) { + nameIsLettersOnly = true; + } else { + JOptionPane + .showMessageDialog( + null, + "Der Imagename darf keine Leer- oder Sonderzeichen enthalten.", + "Unerlaubte Zeichen", + JOptionPane.INFORMATION_MESSAGE); + }// if + + return nameIsLettersOnly; + }// end nameIsLettersOnly + + public boolean checkContent(){ + textfieldsHaveContent=false; + + //check if any textfield is empty + if(imagename.getText().isEmpty() == false + && textAreadesc.getText().isEmpty() == false + && Vorname.getText().isEmpty() == false + && Nachname.getText().isEmpty() == false + && Hochschule.getText().isEmpty() == false + && EMail.getText().isEmpty() == false) { + //all textfields have content + textfieldsHaveContent = true; + } else { + JOptionPane + .showMessageDialog( + null, + "Bitte geben Sie alle notwendigen Daten an!", + "Daten unvollst\u00e4ndig", + JOptionPane.INFORMATION_MESSAGE); + }//end if + + return textfieldsHaveContent; + }//end checkContent + + + +}//end class |
