// Application to create meta data in .json format // SFB1280
//=========================================================================================
// import libraries
//=========================================================================================
//
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.AbstractListModel;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.border.MatteBorder;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.toedter.calendar.JDateChooser;
/**
 * ======================================================================================================
 * JFrame
 * ======================================================================================================
 **/
public class AppJ_V03 extends JFrame {
	
	private static final String currentSoftwareVersion = "20240415";
	
	
	private static final String[] RIGHTS_URI = new String[] {
			"",
			"http://rightsstatements.org/vocab/InC/1.0/",
			"https://creativecommons.org/licenses/by/4.0/",
			"https://creativecommons.org/licenses/by-sa/4.0/",
			"https://creativecommons.org/licenses/by-nd/4.0/",
			"https://creativecommons.org/licenses/by-nc/4.0/",
			"https://creativecommons.org/licenses/by-nc-nd/4.0/",
			"https://creativecommons.org/licenses/by-nc-sa/4.0/",
			"http://creativecommons.org/publicdomain/zero/1.0/",
			"http://creativecommons.org/publicdomain/mark/1.0/",
			"http://www.apache.org/licenses/LICENSE-2.0",
			"http://www.gnu.org/licenses/gpl.html",
			"http://opensource.org/licenses/MIT"
	};
	private static final String[] RIGHTS_LABELS = new String[] {
			"-",
			"In Copyright",
			"Creative Commons BY Attribution 4.0 International",
			"Creative Commons BY-SA Attribution-ShareAlike 4.0 International",
			"Creative Commons BY-ND Attribution-NoDerivatives 4.0 International",
			"Creative Commons BY-NC Attribution-NonCommercial 4.0 International",
			"Creative Commons BY-NC-ND Attribution-NonCommercial-NoDerivs 4.0 International",
			"Creative Commons BY-NC-SA Attribution-NonCommercial-ShareAlike 4.0 International",
			"Creative Commons CC0 1.0 Universal",
			"Creative Commons Public Domain Mark 1.0",
			"Apache License 2.0",
			"GNU General Public License",
			"MIT License"
	};
	
	
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTextField creator_name_txt_cite, creator_given_name_txt_cite, creator_family_name_txt_cite,
	creator_name_identifier_txt_cite, creator_name_identifier_scheme_txt_cite, creator_scheme_uri_txt_cite, creator_affiliation_txt_cite,
	contributor_name_txt_cite, contributor_given_name_txt_cite, contributor_family_name_txt_cite, contributor_name_identifier_txt_cite,
	contributor_name_identifier_scheme_txt_cite, contributor_scheme_uri_txt_cite, contributor_affiliation_txt_cite, subject_txt_cite, 
	subject_scheme_txt_cite, subject_scheme_uri_txt_cite, related_identifier_txt_cite, rights_txt_cite, rights_uri_txt_cite, ethics_no_txt, info_txt;
	
	private JComboBox<String> related_identifier_type_combo_cite, relation_type_combo_cite;
	/**
	 * ======================================================================================================
	 * Define the Methods 
	 * ======================================================================================================
	 **/
	// Disable asterisk ... format
	//-------------------------------------------------------------------------------------------------------
		static void disableInvalid(JTextField txtField, char[] invalidChar) {
			txtField.addKeyListener(new KeyAdapter() {
	             public void keyPressed(KeyEvent k) {
	                for (char c:invalidChar) {
	            		 if (k.getKeyChar() == c) {
	            			 txtField.setEditable(false);
	            			 return;
	            		 } else {
	            			 txtField.setEditable(true);
	            		 }
	                }
	             }
	          });
	       }
	 // Visual feedback ... creator and contributor 
     //-------------------------------------------------------------------------------------------------------------------------
	 static void backRed(JTextField txtField) {
		 txtField.addKeyListener(new KeyAdapter() {
	            public void keyReleased(KeyEvent k) {
	            	int commas = 0;
		               for(int i=0;i < txtField.getText().toString().length();i++){
		            	   if(txtField.getText().toString().charAt(i)==',') {
		            		   commas++;
		            	   }
		               }
		               int semi = 0;
		               for(int i=0;i < txtField.getText().toString().length();i++){
		            	   if(txtField.getText().toString().charAt(i)== ';') {
		            		   semi++;
		            	   }
		               }
		               Pattern p0 = Pattern.compile(";;");
		       	       Pattern p1 = Pattern.compile("  ");
		       	       Pattern p2 = Pattern.compile(",,");
		               Matcher m0 = p0.matcher(txtField.getText());
		               Matcher m1 = p1.matcher(txtField.getText());
		               Matcher m2 = p2.matcher(txtField.getText());
		               if(txtField.getText().equals("")){
		            	   txtField.setBackground(Color.WHITE);
		               }
		               else if (!txtField.getText().equals("") && m0.find()) {
			           	   txtField.setBackground(Color.RED);
		               }
		               else if(!txtField.getText().equals("") && m1.find()) {
			           	   txtField.setBackground(Color.RED);
		               }
		               else if(!txtField.getText().equals("") && m2.find()) {
			           	   txtField.setBackground(Color.RED);
		               }
		               else if(txtField.getText().indexOf(",", 0) > txtField.getText().indexOf(";", 0) && semi!=0) {
		            	   txtField.setBackground(Color.RED);
		               }
		               else if(!txtField.getText().equals("") && k.getKeyCode() == KeyEvent.VK_SPACE && !Character.isLetterOrDigit(txtField.getText().charAt(txtField.getText().length()-1))) {
		            	   txtField.setBackground(Color.RED);
		               }
		               else if(!txtField.getText().equals("") && k.getKeyCode() == KeyEvent.VK_BACK_SPACE && !Character.isLetterOrDigit(txtField.getText().charAt(txtField.getText().length()-1))) {
		            	   txtField.setBackground(Color.RED);
		               }
		               else if(txtField.getText().equals("") || commas == 0 || k.getKeyChar() == ',' || semi >= commas || txtField.getText().charAt(0) == ',' ||
		            		   commas > semi+1 || k.getKeyChar() == ';' || !Character.isLetterOrDigit(txtField.getText().charAt(txtField.getText().length()-1))) {
		            	   txtField.setBackground(Color.RED); //|| k.getKeyCode()==KeyEvent.VK_SPACE
		               }
		               else {
		            	   txtField.setBackground(Color.WHITE);
		               }
		            }
	         });
	 }
	 // Visual feedback ... creator and contributor sub fields in datacite
     //--------------------------------------------------------------------------------------------------------------------------
	 static void backRedCheck(JTextField txtField1, JTextField txtField2) {
		 txtField1.addKeyListener(new KeyAdapter() {
	            public void keyReleased(KeyEvent k) {
		               int semi1 = 0;
		               for(int i=0;i < txtField1.getText().toString().length();i++){
		            	   if(txtField1.getText().toString().charAt(i)== ';') {
		            		   semi1++;
		            	   }
		               }
		               int semi2 = 0;
		               for(int i=0;i < txtField2.getText().toString().length();i++){
		            	   if(txtField2.getText().toString().charAt(i)== ';') {
		            		   semi2++;
		            	   }
		               }
		               Pattern p0 = Pattern.compile(";;");
		       	       Pattern p1 = Pattern.compile("  ");
		               Matcher m0 = p0.matcher(txtField1.getText());
		               Matcher m1 = p1.matcher(txtField1.getText());
		               if(txtField1.getText().equals("")){
		            	   txtField1.setBackground(Color.WHITE);
		               }
		               else if (!txtField1.getText().equals("") && m0.find()) {
			           	   txtField1.setBackground(Color.RED);
		               }
		               else if(!txtField1.getText().equals("") && m1.find()) {
			           	   txtField1.setBackground(Color.RED);
		               }
		               else if(txtField2.getText().equals("")){
		            	   txtField1.setBackground(Color.RED);
		               }
		               else if(!txtField2.getText().equals("") && semi1 != semi2) {
		            	   txtField1.setBackground(Color.RED);
		               }
		               else if(txtField1.getText().charAt(txtField1.getText().length()-1) == ';' || txtField1.getText().charAt(0) == ';') {
		            	   txtField1.setBackground(Color.RED);
		               }
		               else if(k.getKeyCode() == KeyEvent.VK_SPACE && Character.isSpaceChar(txtField1.getText().charAt(txtField1.getText().length()-1)) ) {
		            	   txtField1.setBackground(Color.RED);
		               }
		               else if(!txtField1.getText().equals("") && k.getKeyCode() == KeyEvent.VK_BACK_SPACE && Character.isSpaceChar(txtField1.getText().charAt(txtField1.getText().length()-1))) {
		            	   txtField1.setBackground(Color.RED);
		               }
		               else {
		            	   txtField1.setBackground(Color.WHITE);
		               }
		            }
	         });
	 }
	 // Visual feedback ... creator and contributor subfields in datacite if the main field is empty the subfield have to be empty 
     //----------------------------------------------------------------------------------------------------------------------------
	 static void backRedCheckEmpty(JTextField txtField1, JTextField txtField2) {
		 txtField1.addKeyListener(new KeyAdapter() {
	            public void keyReleased(KeyEvent k) {
		               if(txtField1.getText().equals("")){
		            	   txtField1.setBackground(Color.WHITE);
		               }
		               else if(txtField2.getText().equals("")){
		            	   txtField1.setBackground(Color.RED);
		               }
		               else {
		            	   txtField1.setBackground(Color.WHITE);
		               }
		            }
	         });
	 }
	 // Visual feedback ... Trail semicolons and whitespace in dublincore
     //-------------------------------------------------------------------------------------------------------------------------
	 static void checkRedTrail(JTextField txtField) {
		 txtField.addKeyListener(new KeyAdapter() {
	            public void keyReleased(KeyEvent k) {
	       	        Pattern p0 = Pattern.compile(";;");
	       	        Pattern p1 = Pattern.compile("  ");
	                Matcher m0 = p0.matcher(txtField.getText());
	                Matcher m1 = p1.matcher(txtField.getText());
	                if(txtField.getText().equals("")){
		            	   txtField.setBackground(Color.WHITE);
		               }
	                else if (m0.find()) {
		            	   txtField.setBackground(Color.RED);
	                }
	                else if(m1.find()) {
		            	   txtField.setBackground(Color.RED);
	                }
	                else if(!txtField.getText().equals("") && k.getKeyCode() == KeyEvent.VK_SPACE && Character.isWhitespace(txtField.getText().charAt(txtField.getText().length()-1))) {
		            	   txtField.setBackground(Color.RED);
		               }
		            else if(txtField.getText().charAt(txtField.getText().length()-1) == ';' || txtField.getText().charAt(0) == ';') {
		            	   txtField.setBackground(Color.RED);
		               }
		            else if(!txtField.getText().equals("") && k.getKeyCode() == KeyEvent.VK_SPACE && !Character.isLetterOrDigit(txtField.getText().charAt(txtField.getText().length()-1))) {
		            	   txtField.setBackground(Color.RED);
		               }
		            else if(!txtField.getText().equals("") && k.getKeyCode() == KeyEvent.VK_BACK_SPACE && !Character.isLetterOrDigit(txtField.getText().charAt(txtField.getText().length()-1))) {
		            	   txtField.setBackground(Color.RED);
		               }
		            else if(!txtField.getText().equals("") && k.getKeyCode() == KeyEvent.VK_SEMICOLON && !Character.isLetterOrDigit(txtField.getText().charAt(txtField.getText().length()-1))) {
		            	   txtField.setBackground(Color.RED);
		               }
		            else {
		            	   txtField.setBackground(Color.WHITE);
		               }
		            }
	         });
	 }
	 // Visual feedback ... creator and contributor sub fields in datacite
     //--------------------------------------------------------------------------------------------------------------------------
	 // Visual feedback ... creator and contributor sub fields auto fill in datacite
     //--------------------------------------------------------------------------------------------------------------------------
	 static String[] fullNameSplit(JTextField txtField) {
		 String res[] = new String[2];
	     Pattern p0 = Pattern.compile(".*,\\s*(.*)");
         Matcher m0 = p0.matcher(txtField.getText());
         String first_l = "";
         if (m0.find())
         	first_l = m0.group(1);
         //
         String first = "";
         Pattern pat_first = Pattern.compile(",+(.*?);", Pattern.DOTALL);
         Matcher mat_first = pat_first.matcher(txtField.getText());
         while(mat_first.find()) {
         	first = first + mat_first.group(1)+";";
         }
         first = first + first_l;
         //For the first last_name
         String splitted[] = txtField.getText().split(",",2); // will be matched 1 times. 
         Pattern p1 = Pattern.compile(";+(.*?),", Pattern.DOTALL);
         Matcher m1 = p1.matcher(txtField.getText());
         String last = "";
         while(m1.find()) {
         	last = last+";"+m1.group(1);
         }
         last = splitted[0]+last;
         res[0]= first;
         res[1] =  last;
         return res;
	 }
	 // error box
     //--------------------------------------------------------------------------------------------------------------------------
	 public boolean errBox(JTextField txtField) {
		 boolean b = false;
		 if(!txtField.getText().equals("") && txtField.getBackground()==Color.RED) {
		    	b = true;
		 }
		 return(b);
	 }
	 
	 /**
	  * Checks whether the ExperimentDescription is in the correct format.
	  * @param expDesc
	  * @returns null when everything is correct, otherwise it will return an error message.
	  */
	 public String sanitizeExperimentDescription(JTextArea expDesc) {
		 String txt = expDesc.getText();
		 txt = txt.trim();
		 expDesc.setText(txt);
		 
		 if(txt.length() == 0) return "Experiment Description: Please fill in the field";
		 if(txt.charAt(0) == ',') return "Experiment Description: Please remove leading commas";
		 if(txt.length() >= 5000) return "Experiment Description is too long. (Max 5000 chars)";
		 /*if(txt.charAt(txt.length() - 1) == ',') return "Experiment Description: Please remove trailing commas";
		 String[] split = txt.split(",");
		 for(int i2 = 0; i2 < split.length; i2++) {
			 split[i2] = split[i2].trim();
			 if (split[i2].length() == 0) {
				 String newTxt = "";
				 for(int i = 0; i < split.length; i++) {
					 newTxt += split[i];
					 if (i < split.length - 1) newTxt += ", ";
				 }
				 expDesc.setText(newTxt);
				 return "Experiment Description: Please remove any comma-seperated areas without content";
			 }
		 }
		 String newTxt = "";
		 for(int i = 0; i < split.length; i++) {
			 newTxt += split[i];
			 if (i < split.length - 1) newTxt += ", ";
		 }
		 expDesc.setText(newTxt);*/
		 return null;
		 
		 
	 }
	 // No usage right now
     //--------------------------------------------------------------------------------------------------------------------------
	 static void checkParent(JTextField txtField1, JTextField txtField2) {
		 if(!txtField1.getText().equals("") && txtField2.getText().equals("")) {
		    	txtField2.setBackground(Color.RED);
		 }
	 }
	/**
	 * ======================================================================================================
	 * Launch the application
	 * ======================================================================================================
	 **/
	public static void main(String[] args) {
		//checkAge(90);
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					AppJ_V03 frame = new AppJ_V03();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" })
	public AppJ_V03() throws FileNotFoundException, IOException, ParseException {
        final Container c = getContentPane();  //to show dialog boxes
		this.setResizable(false);     // disable maximize bottom
		/**
		 * ======================================================================================================
		 * Define the default values for each field
		 * ======================================================================================================
		 **/
		String dt = null; //predefined for date
		//------------------------------------------ SFB meta data ----------------------------------------------
		String p_group_id = "-";
		String p_experiment_title = "";
		String p_creator = "";
		String p_contributor = "";
		//
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		Date today = new Date();
		String p_record_date = dateFormat.format(today).toString();
		//
		String p_data_type = "";
		JSONArray p_modality = null;
		String p_subject_id = "";
		String p_subject_species = "";
		String p_subject_type = "";
		String p_subject_sex = "";
		String p_subject_age = "0";
		JSONArray p_shared_with = null;
		String p_ethics_no = "";
		String p_info = "";
		String p_experimentDescription = null;
		//---------------------------------------- DublinCore ---------------------------------------------------
		String p_coverage_dub = "";
		String p_description_dub = "";
		String p_format_dub = "";
		String p_identifier_dub = "";
		String p_language_dub = "";
		String p_publisher_dub = "";
		String p_relation_dub = "";
		String p_rights_dub = "-";
		String p_source_dub = "";					
		String p_subject_dub = "";
		String p_type_dub = "Collection";
		//---------------------------------------- DataCite ---------------------------------------------------
		String p_identifier_cite = "";
		String p_identifier_type_cite = "";
		String p_title_type_cite = "";
		//.........................................
		String p_creator_name_cite = "";
		String p_creator_name_type_cite = "Personal";
		String p_creator_given_name_cite = "";
		String p_creator_family_name_cite = "";
		String p_creator_name_identifier_cite = "";
		String p_creator_name_identifier_scheme_cite = "";
		String p_creator_scheme_uri_cite = "";
		String p_creator_affiliation_cite = "";
		//..........................................
		String p_contributor_type_cite = "";
		String p_contributor_name_cite = "";
		String p_contributor_name_type_cite = "Personal";
		String p_contributor_given_name_cite = "";
		String p_contributor_family_name_cite = "";
		String p_contributor_name_identifier_cite = "";
		String p_contributor_name_identifier_scheme_cite = "";
		String p_contributor_scheme_uri_cite = "";
		String p_contributor_affiliation_cite = "";
		//...........................................
		String p_date_type_cite = "Created";
		//...........................................
		String p_resource_type_general_cite = "Collection";
		//...........................................
		String p_publication_year_cite = "";
		//...........................................
		String p_subject_cite = "";
		String p_subject_scheme_cite = "";
		String p_subject_scheme_uri_cite = "";
		String p_subject_value_uri_cite = "";
		//..........................................
		String p_alternate_identifier_cite = "";
		String p_alternate_identifier_type_cite = "";
		//..........................................
		String p_related_identifier_cite = "";
		String p_related_identifier_type_cite = "-";
	    String p_relation_type_cite = "-";
	    //..........................................
		String p_size_cite = "";
		String p_version_cite = "1.0";
		//...........................................
		String p_rights_cite = "";
		String p_rights_uri_cite = "";
		String p_rights_identifier_cite = "";
		String p_rights_identifier_scheme_cite = "";
		String p_rights_scheme_uri_cite = "";
		//...........................................
		String p_description_type_cite = "Abstract";
		String p_funding_reference_cite = "DFG";
		String p_funder_name_cite = "Deutsche Forschungsgemeinschaft";
		String p_funder_identifier_cite = "http://dx.doi.org/10.13039/501100001659";
		String p_funder_identifier_type_cite = "Crossref Funder ID";
		/**
		 * ======================================================================================================
		 * check if meta.json exists in up to two parent directories 
		 * ======================================================================================================
		 **/
		String sfilename = "meta.json";
		File srcfile = new File(sfilename);
		String sfilename1 = "../meta.json";
		File srcfile1 = new File(sfilename1);
		String sfilename2 = "../../meta.json";
		File srcfile2 = new File(sfilename2);
		//......................................
		if(srcfile.exists() || srcfile1.exists() || srcfile2.exists()) {
			
			Object obj1 = null;
			System.out.println("Default Charset=" + Charset.defaultCharset());
			if(srcfile.exists()) {
				File file = new File(srcfile.toString());
				SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy, HH:mm:ss");
				dt = "Last modified : " + sdf.format(file.lastModified()) ;
				//
				JSONParser parser = new JSONParser();
				obj1 = parser.parse(new FileReader(srcfile)); // #Anchor 1 , StandardCharsets.UTF_8
			} else if(srcfile1.exists()){
				//
				File file = new File(srcfile1.toString());
				SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy, HH:mm:ss");
				dt = "Last modified : " + sdf.format(file.lastModified());
				JSONParser parser = new JSONParser();
				obj1 = parser.parse(new FileReader(srcfile1));
				//
			} else if(srcfile2.exists()) {
				//
				File file = new File(srcfile2.toString());
				SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy, HH:mm:ss");
				dt = "Last modified : " + sdf.format(file.lastModified());
				JSONParser parser = new JSONParser();
				obj1 = parser.parse(new FileReader(srcfile2));
			}
				JSONObject jsonObject = (JSONObject) obj1;	
				/**
				 * ======================================================================================================
				 * Read meta data from existing meta.json file
				 * ======================================================================================================
				 **/
				//---------------------------------------- SFB meta data ---------------------------------------------------
				p_group_id = (String) jsonObject.get("Group ID");
				p_experiment_title = (String) jsonObject.get("Experiment title");
				p_creator = (String) jsonObject.get("Creator");
				p_contributor = (String) jsonObject.get("Contributor");
				p_record_date = (String) jsonObject.get("Record date");
				p_data_type = (String) jsonObject.get("Resource Type");
				p_modality = (JSONArray) jsonObject.get("Modality");
				p_subject_id = (String) jsonObject.get("Subject ID");
				p_subject_species = (String) jsonObject.get("Subject Species");
				p_subject_type = (String) jsonObject.get("Subject type");
				p_subject_sex = (String) jsonObject.get("Subject sex");
				p_subject_age = (String) jsonObject.get("Subject age");
				p_shared_with = (JSONArray) jsonObject.get("Shared with");
				p_ethics_no = (String) jsonObject.get("Animal|Ethics approval No.");
				p_info = (String) jsonObject.get("Extra information");
				
				
				Object experimentDescriptionObject = jsonObject.get("Experiment Description");
				if (experimentDescriptionObject instanceof JSONArray) {
					p_experimentDescription = ((JSONArray)experimentDescriptionObject).toString();
				} else {
					p_experimentDescription = (String) experimentDescriptionObject;		
				}
				//---------------------------------------- DublinCore ---------------------------------------------------
				p_coverage_dub = (String) jsonObject.get("DublinCore-Coverage");
				p_description_dub = (String) jsonObject.get("DublinCore-Description");
				p_format_dub = (String) jsonObject.get("DublinCore-Format");
				p_language_dub = (String) jsonObject.get("DublinCore-Language");
				p_publisher_dub = (String) jsonObject.get("DublinCore-Publisher");
				p_relation_dub = (String) jsonObject.get("DublinCore-Relation");
				p_rights_dub = (String) jsonObject.get("DublinCore-Rights");
				p_subject_dub = (String) jsonObject.get("DublinCore-Subject");
				//p_type_dub = p_modality;
				//
				//p_format_dub = p_format_dub.replaceAll(",", ";");
				//p_subject_dub = p_subject_dub.replaceAll(",", ";");
				//---------------------------------------- DataCite ---------------------------------------------------
				p_creator_name_cite = (String) jsonObject.get("DataCite-creatorName");
				p_creator_given_name_cite = (String) jsonObject.get("DataCite-creatorGivenName");
				p_creator_family_name_cite = (String) jsonObject.get("DataCite-creatorFamilyName");
				p_creator_name_identifier_cite = (String) jsonObject.get("DataCite-creatorNameIdentifier");
				p_creator_name_identifier_scheme_cite = (String) jsonObject.get("DataCite-creatorNameIdentifierScheme");
				p_creator_scheme_uri_cite = (String) jsonObject.get("DataCite-creatorSchemeURI");
				p_creator_affiliation_cite = (String) jsonObject.get("DataCite-creatorAffiliation");
				//..........................................
				p_contributor_type_cite = (String) jsonObject.get("DataCite-contributorType");
				p_contributor_name_cite = (String) jsonObject.get("DataCite-contributorName");
				p_contributor_given_name_cite = (String) jsonObject.get("DataCite-contributorGivenName");
				p_contributor_family_name_cite = (String) jsonObject.get("DataCite-contributorFamilyName");
				p_contributor_name_identifier_cite = (String) jsonObject.get("DataCite-contributorNameIdentifier");
				p_contributor_name_identifier_scheme_cite = (String) jsonObject.get("DataCite-contributorNameIdentifierScheme");
				p_contributor_scheme_uri_cite = (String) jsonObject.get("DataCite-contributorSchemeURI");
				
				p_contributor_affiliation_cite = (String) jsonObject.get("DataCite-contributorAffiliation");
				if (p_contributor_affiliation_cite == null)
					p_contributor_affiliation_cite = (String) jsonObject.get("DataCite-contirbutorAffiliation");
				//...........................................
				p_subject_cite = (String) jsonObject.get("DataCite-Subject");
				p_subject_scheme_cite = (String) jsonObject.get("DataCite-subjectScheme");
				p_subject_scheme_uri_cite = (String) jsonObject.get("DataCite-subjectSchemeURI");
				//p_subject_value_uri_cite = (String) jsonObject.get("DataCite-subjectValueURI");
				//..........................................
				p_related_identifier_cite = (String) jsonObject.get("DataCite-RelatedIdentifier");
				p_related_identifier_type_cite = (String) jsonObject.get("DataCite-relatedIdentifierType");
			    p_relation_type_cite = (String) jsonObject.get("DataCite-relationType");
				//...........................................
				p_rights_cite = (String) jsonObject.get("DataCite-Rights");
				p_rights_uri_cite = (String) jsonObject.get("DataCite-rightsURI");
				//p_rights_idenfitier_cite = (String) jsonObject.get("DataCite-rightsIdentifier");
				//p_rights_identifier_scheme_cite = (String) jsonObject.get("DataCite-rightsIdentifierScheme");
				//p_rights_scheme_uri_cite = (String) jsonObject.get("DataCite-rightsSchemeURI");
		}
		/**
		 * ======================================================================================================
		 * Design the forms
		 * ======================================================================================================
		 **/
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1350, 700); //#JSize
		contentPane = new JPanel();   // main frame
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		
		JPanel panel = new JPanel();
		panel.setPreferredSize(new Dimension(1350, 640)); 
		contentPane.add(panel, BorderLayout.NORTH);
		panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		JLabel logo1 = new JLabel("");
		panel.add(logo1);
		logo1.setIcon(new ImageIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Logo_SFB_1280_transparent.png")).getImage().getScaledInstance(200, 50, Image.SCALE_SMOOTH)));
		panel.setPreferredSize(new Dimension(1350, 60));
		
		JPanel cards ;
		cards = new JPanel(new CardLayout());
		cards.setBackground(new Color(0, 51, 102));
		cards.setPreferredSize(new Dimension(1350, 660));
		contentPane.add(cards, BorderLayout.CENTER);
		
		JPanel southPanel = new JPanel();
		southPanel.setLayout(null);
		southPanel.setBackground(new Color(0, 51, 102));
		//southPanel.setPreferredSize(new Dimension(1350, 130));
		southPanel.setBounds(0, 500, 1350, 100);
		
		
		/**
		 * ======================================================================================================
		 * Create panels
		 * ======================================================================================================
		 **/
        //--------------------------------------------- panel SFB meta data -------------------------------------
		JPanel panel_meta = new JPanel();
		panel_meta.setBackground(new Color(0, 51, 102));
		panel_meta.setPreferredSize(new Dimension(1350, 590));
		
		panel_meta.add(southPanel);
		
		cards.add(panel_meta, BorderLayout.SOUTH);
		
		panel_meta.setLayout(null);
		
		JLabel group_id = new JLabel("<html>Group ID <BR><font size = 2> The SFB1280 ID of your group. </font></html>");
		group_id.setForeground(new Color(211, 211, 211));
		group_id.setFont(new Font("Tahoma", Font.BOLD, 14));
		group_id.setBounds(40, 42, 173, 42);
		panel_meta.add(group_id);
		
		JLabel experiment_title = new JLabel("<html>Experiment Title<BR><font size = 2> Use a proper description of your experiment. </font></html>");
		experiment_title.setForeground(new Color(211, 211, 211));
		experiment_title.setFont(new Font("Tahoma", Font.BOLD, 14));
		experiment_title.setBounds(40, 103, 173, 56);
		panel_meta.add(experiment_title);
		
		
		JLabel creator = new JLabel("<html>Creator<BR> <font size = 2> Name of the main experimenter or collector of the research data. Please enter the name in the following format: Last name, comma and first name. </font></html>");
		creator.setForeground(new Color(211, 211, 211));
		creator.setFont(new Font("Tahoma", Font.BOLD, 14));
		creator.setBounds(40, 158, 216, 84);
		//creator.setToolTipText("<html>The fields  require a special format for the names of <BR>the persons that were involved as "
		//		+ "an experimenter or data collector.<BR>Every name has to be entered in the format: family name followed by a comma and the given name.<BR>\r\n" + 
		//		"E.g.: Musterfrau, Monika</html>\r\n" + 
		//		"");
		panel_meta.add(creator);
		
		JLabel contributor = new JLabel("<html>Contributor<BR> <font size = 2> Other experimenter or collectors. Separate more than one name with semicolon. Please enter the name in the following format: Last name, comma and first name. </font></html>");
		contributor.setForeground(new Color(211, 211, 211));
		contributor.setFont(new Font("Tahoma", Font.BOLD, 14));
		contributor.setBounds(40, 248, 216, 92);
		//contributor.setToolTipText("<html>The fields require a special format for the names of <BR>the persons that were involved as "
		//		+ "an experimenter or data collector.<BR>Every name has to be entered in the format: family name followed by a comma and the given name.<BR>\r\n" + 
		//		"E.g.: Musterfrau, Monika</html>\r\n" + 
		//		"");
		panel_meta.add(contributor);
		
		JLabel record_date = new JLabel("<html>Record Date<BR> <font size = 2> Date when the data were collected or recorded. </font> </html>");
		record_date.setForeground(new Color(211, 211, 211));
		record_date.setFont(new Font("Tahoma", Font.BOLD, 14));
		record_date.setBounds(40, 339, 173, 58);
		panel_meta.add(record_date);
		
		JLabel data_type = new JLabel("<html>Resource Type <BR> <font size = 2> Type of research data. </font></html>");
		data_type.setForeground(new Color(211, 211, 211));
		data_type.setFont(new Font("Tahoma", Font.BOLD, 14));
		data_type.setBounds(40, 409, 173, 42);
		panel_meta.add(data_type);
		
		JLabel modality = new JLabel("<html>Modality<BR> <font size = 2> Characteristics of the data (Press Ctrl or Strg to select more than one). </font></html>");
		modality.setForeground(new Color(211, 211, 211));
		modality.setFont(new Font("Tahoma", Font.BOLD, 14));
		modality.setBounds(524, 39, 132, 54);
		panel_meta.add(modality);
		
		JLabel shared_with = new JLabel("<html>Shared With<BR> <font size = 2> Group to share the data with (Press Ctrl or Strg to select more than one). </font></html>");
		shared_with.setForeground(new Color(211, 211, 211));
		shared_with.setFont(new Font("Tahoma", Font.BOLD, 14));
		shared_with.setBounds(524, 200, 132, 58);
		panel_meta.add(shared_with);
		
		JLabel experiment_decription = new JLabel("<html><center>Experiment Description</center></html>");
		experiment_decription.setForeground(new Color(211, 211, 211));
		experiment_decription.setFont(new Font("Tahoma", Font.BOLD, 14));
		experiment_decription.setBounds(525, 345, 400, 58);
		panel_meta.add(experiment_decription);
		
		JLabel subject_id = new JLabel("<html>Subject ID<BR> <font size = 2> SFB1280 defined subject ID. </font></html>");
		subject_id.setForeground(new Color(211, 211, 211));
		subject_id.setFont(new Font("Tahoma", Font.BOLD, 14));
		subject_id.setBounds(902, 42, 157, 42);
		panel_meta.add(subject_id);
		
		JLabel subject_species = new JLabel("<html>Subject Species<BR> <font size = 2> Species of your subject. </font></html>");
		subject_species.setForeground(new Color(211, 211, 211));
		subject_species.setFont(new Font("Tahoma", Font.BOLD, 14));
		subject_species.setBounds(902, 110, 157, 42);
		panel_meta.add(subject_species);
		
		JLabel subject_type = new JLabel("<html>Subject Type<BR> <font size = 2> Characteristics of your subject. </font></html>");
		subject_type.setForeground(new Color(211, 211, 211));
		subject_type.setFont(new Font("Tahoma", Font.BOLD, 14));
		subject_type.setBounds(902, 172, 157, 42);
		panel_meta.add(subject_type);
		
		JLabel subject_sex = new JLabel("<html>Subject Sex <BR> <font size = 2>This should be self-explanatory.</font> </html>");
		subject_sex.setForeground(new Color(211, 211, 211));
		subject_sex.setFont(new Font("Tahoma", Font.BOLD, 14));
		subject_sex.setBounds(902, 247, 157, 42);
		panel_meta.add(subject_sex);
		
		JLabel subject_age = new JLabel("<html>Subject Age<BR><font size = 2> Age of the Subject.<br>0 when not needed.</font></html>");
		subject_age.setForeground(new Color(211, 211, 211));
		subject_age.setFont(new Font("Tahoma", Font.BOLD, 14));
		subject_age.setBounds(902, 314, 157, 42);
		panel_meta.add(subject_age);
		
		JLabel ethics_no = new JLabel("<html>Animal|Ethics Approval No.<BR><font size = 2> The official number of your approval. </font></html>");
		ethics_no.setForeground(new Color(211, 211, 211));
		ethics_no.setFont(new Font("Tahoma", Font.BOLD, 14));
		ethics_no.setBounds(902, 390, 212, 30);
		panel_meta.add(ethics_no);
		
		JLabel info = new JLabel("<html>Extra Information<BR><font size = 2> Optional entry. </font></html>");
		info.setForeground(new Color(211, 211, 211));
		info.setFont(new Font("Tahoma", Font.BOLD, 14));
		info.setBounds(902, 453, 212, 27);
		panel_meta.add(info);
		
		JLabel last_modified = new JLabel(dt);
		last_modified.setForeground(new Color(255, 255, 255));
		last_modified.setFont(new Font("Tahoma", Font.ITALIC, 12));
		last_modified.setBounds(1057, 541 - 483, 212, 24);
		southPanel.add(last_modified);
		
		JLabel lblSoftwareVersion = new JLabel("Software version " + currentSoftwareVersion);
		lblSoftwareVersion.setForeground(Color.WHITE);
		lblSoftwareVersion.setFont(new Font("Tahoma", Font.ITALIC, 12));
		lblSoftwareVersion.setBounds(1057, 558 - 483, 212, 24);
		southPanel.add(lblSoftwareVersion);
		
		JLabel lblMetadatanecessary = new JLabel("MetaData (necessary)");
		lblMetadatanecessary.setForeground(new Color(204, 204, 204));
		lblMetadatanecessary.setFont(new Font("Tahoma", Font.BOLD, 22));
		lblMetadatanecessary.setBounds(6, 0, 266, 30);
		panel_meta.add(lblMetadatanecessary);
		
		JLabel lblHighlyRecommended = new JLabel("Highly recommended");
		lblHighlyRecommended.setForeground(new Color(204, 204, 204));
		lblHighlyRecommended.setFont(new Font("Tahoma", Font.BOLD, 22));
		lblHighlyRecommended.setBounds(152, 0, 243, 34);
		southPanel.add(lblHighlyRecommended);
		
		JComboBox<String> group_id_txt = new JComboBox<String>();//new JTextField(p_group_id);
		group_id_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		group_id_txt.setModel(new DefaultComboBoxModel<String>( new String[] {"-", "A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A18", "A19", "A21", "F01", "F02"}));
		group_id_txt.setBackground(new Color(220, 220, 220));
		group_id_txt.setBounds(268, 51, 185, 42);
		group_id_txt.setSelectedItem(p_group_id);
		panel_meta.add(group_id_txt);
		

		JTextField experiment_title_txt = new JTextField(p_experiment_title);
		experiment_title_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		experiment_title_txt.setColumns(10);
		experiment_title_txt.setBackground(new Color(220, 220, 220));
		experiment_title_txt.setBounds(268, 117, 185, 42);
		panel_meta.add(experiment_title_txt);
		group_id_txt.setNextFocusableComponent(experiment_title_txt);

		JTextField creator_txt = new JTextField(p_creator);
		creator_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		creator_txt.setColumns(10);
		creator_txt.setBackground(new Color(220, 220, 220));
		creator_txt.setBounds(268, 179, 185, 42);
		panel_meta.add(creator_txt);
		experiment_title_txt.setNextFocusableComponent(creator_txt);
		
		JTextField contributor_txt = new JTextField(p_contributor);
		contributor_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		contributor_txt.setColumns(10);
		contributor_txt.setBackground(new Color(220, 220, 220));
		contributor_txt.setBounds(268, 258, 185, 42);
		panel_meta.add(contributor_txt);
		creator_txt.setNextFocusableComponent(contributor_txt);
		
		Date date1 = new Date();
		try {
			date1 = new SimpleDateFormat("yyyy-MM-dd").parse(p_record_date);
			
		} catch (java.text.ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		JDateChooser record_date_txt = new JDateChooser(date1);

		if (date1.getTime() == 0 || date1.getTime() == -3600000) {
			record_date_txt.setCalendar(null);
		}
		
		record_date_txt.setBounds(268, 353, 185, 42);
		panel_meta.add(record_date_txt);
		
		JComboBox<String> data_type_txt = new JComboBox<String>();
		data_type_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		data_type_txt.setModel(new DefaultComboBoxModel<String>(new String[] {"Analysed", "Measured", "Simulated"}));
		data_type_txt.setSelectedItem(p_data_type);
		data_type_txt.setBounds(268, 413, 185, 42);
		panel_meta.add(data_type_txt);	
		
		JScrollPane scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(680, 40, 141, 136);
		panel_meta.add(scrollPane_1);
		
		JList modality_txt = new JList();
		modality_txt.setVisibleRowCount(2);
	    modality_txt.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		scrollPane_1.setViewportView(modality_txt);
		
		modality_txt.setModel(new AbstractListModel() {
			private static final long serialVersionUID = 1L;
			String[] values = new String[] {"Behavorial", "Calcium Imaging", "ECG|Pulse", "EDA", "EEG", "Eyetracking", "Histology", "Hormone measurements", "LFP", "MRI", "Questionaires", "Respiration", "Single cell recording", "TMS"};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		  ArrayList<String> temp1 = new ArrayList<>(Arrays.asList("Behavorial", "Calcium Imaging", "ECG|Pulse", "EDA", "EEG", "Eyetracking", "Histology", "Hormone measurements", "LFP", "MRI", "Questionaires", "Respiration", "Single cell recording", "TMS"));
		  if(p_modality!=null) {
			  int[] p1 = new int[p_modality.size()];
			  for (int j=0; j < p_modality.size(); j++) {
		            int p01 = temp1.indexOf(p_modality.get(j));
		            p1[j]= p01;
			  }
	      modality_txt.setSelectedIndices(p1);
	}
		//........................................
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(680, 200, 141, 136);
		panel_meta.add(scrollPane);
		
		JList shared_with_txt = new JList();
		scrollPane.setViewportView(shared_with_txt);
		shared_with_txt.setVisibleRowCount(2);
	    shared_with_txt.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
	    
		shared_with_txt.setModel(new AbstractListModel() {
			private static final long serialVersionUID = 1L;
			String[] values = new String[] {"-", "A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A18", "A19", "A21", "F01", "F02"};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		 //....................................................
         //To extract selected multiple values from JSON array
		  ArrayList<String> temp = new ArrayList<>(Arrays.asList("-", "A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A10", "A11", "A12", "A13", "A14", "A15", "A16", "A18", "A19", "A21", "F01", "F02"));
		  if(p_shared_with!=null) {
			  int[] p = new int[p_shared_with.size()];
			  for (int j=0; j < p_shared_with.size(); j++) {
		            int p0 = temp.indexOf(p_shared_with.get(j));
		            p[j]= p0;
			  }
	      shared_with_txt.setSelectedIndices(p);
		  }
		  
		//........................................
		
		String experimentDescriptionString = "";
		if (p_experimentDescription != null) {
			/*for(int i = 0; i < p_experimentDescription.size(); i++) {
				experimentDescriptionString += p_experimentDescription.get(i);
				if (i < p_experimentDescription.size() - 1)
					experimentDescriptionString += ",";
			}*/
			experimentDescriptionString = p_experimentDescription;
		}
		  
		JTextArea experimentDescriptionTextArea = new JTextArea(experimentDescriptionString);
		//experimentDescriptionTextArea.setBounds(525, 390, 300, 136);
		experimentDescriptionTextArea.setLineWrap(true);
		experimentDescriptionTextArea.setWrapStyleWord(true);
		experimentDescriptionTextArea.setMinimumSize(new Dimension(300, 136));
		//experimentDescriptionTextArea.setPreferredSize(new Dimension(300, 136));
		
		JPanel scrollPanelOuterBorderLayoutPanel = new JPanel();
		scrollPanelOuterBorderLayoutPanel.setLayout(new BorderLayout());
		scrollPanelOuterBorderLayoutPanel.setBounds(525, 390, 300, 136);
		scrollPanelOuterBorderLayoutPanel.setBackground(Color.GREEN);
	
		
		JScrollPane scrollPaneExperimentDescription = new JScrollPane(experimentDescriptionTextArea);
		scrollPaneExperimentDescription.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPanelOuterBorderLayoutPanel.add(scrollPaneExperimentDescription, BorderLayout.CENTER);
		scrollPanelOuterBorderLayoutPanel.repaint();
		scrollPanelOuterBorderLayoutPanel.revalidate();
		//panel_meta.add(experimentDescriptionTextArea);
		panel_meta.add(scrollPanelOuterBorderLayoutPanel);
		//panel_meta.add(scrollPaneExperimentDescription);
		//........................................
		JTextField subject_id_txt = new JTextField(p_subject_id);
		subject_id_txt.setColumns(10);
		subject_id_txt.setBackground(new Color(220, 220, 220));
		subject_id_txt.setBounds(1112, 44, 185, 42);
		panel_meta.add(subject_id_txt);
		contributor_txt.setNextFocusableComponent(subject_id_txt);
		
		JComboBox<String> subject_species_txt = new JComboBox<String>();
		subject_species_txt.setEditable(true);
		subject_species_txt.setModel(new DefaultComboBoxModel(new String[] {"Humans", "Pigeons", "Mice", "Rats", "Crows", "Jackdaws"}));
		subject_species_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		subject_species_txt.setSelectedItem(p_subject_species);
		subject_species_txt.setBounds(1112, 112, 185, 42);
		panel_meta.add(subject_species_txt);
	
		JComboBox<String> subject_type_txt = new JComboBox<String>();
		subject_type_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		subject_type_txt.setModel(new DefaultComboBoxModel<String>(new String[] {"Healthy test subject", "Patient", "Healthy control subject"}));
		subject_type_txt.setSelectedItem(p_subject_type);
		subject_type_txt.setBounds(1112, 180, 185, 42);
		panel_meta.add(subject_type_txt);
			
		JComboBox<String> subject_sex_txt = new JComboBox<String>();
		subject_sex_txt.setEditable(true);
		subject_sex_txt.setModel(new DefaultComboBoxModel(new String[] {"female", "male", "diverse", "undefined"}));
		subject_sex_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		subject_sex_txt.setSelectedItem(p_subject_sex);
		subject_sex_txt.setBounds(1112, 248, 185, 42);
		panel_meta.add(subject_sex_txt);
	
		JSpinner subject_age_txt = new JSpinner(new SpinnerNumberModel(18, 0, Integer.MAX_VALUE, 1));
		subject_age_txt.setFont(new Font("Tahoma", Font.PLAIN, 13));
		float subjAgeValue = Float.parseFloat(p_subject_age);
		boolean inMonths = false;
		if (!Float.isNaN(subjAgeValue)) {
			if (subjAgeValue - (int) subjAgeValue != 0) {
				inMonths = true;
				subjAgeValue = Math.round(subjAgeValue * 12);
			}
			subject_age_txt.setValue(subjAgeValue <= 0 ? 0 : subjAgeValue);
		} else {
			((JSpinner.DefaultEditor)subject_age_txt.getEditor()).getTextField().setText("NaN");
		}
		
		subject_age_txt.setBounds(1112 + 85, 314, 185 - 85, 42);
		panel_meta.add(subject_age_txt);
		
		JRadioButton ageInMonths = new JRadioButton("In Months");
		ageInMonths.setBounds(1112, 315, 85, 20);
		ageInMonths.setSelected(inMonths);
		panel_meta.add(ageInMonths);
		
		JRadioButton ageInYears = new JRadioButton("In Years");
		ageInYears.setBounds(1112, 314 + 21, 85, 21);
		ageInYears.setSelected(!inMonths);
		panel_meta.add(ageInYears);
		
		ButtonGroup selectMonthOrYear = new ButtonGroup();
		selectMonthOrYear.add(ageInMonths);
		selectMonthOrYear.add(ageInYears);
		
		ethics_no_txt = new JTextField(p_ethics_no);
		ethics_no_txt.setColumns(10);
		ethics_no_txt.setBackground(new Color(220, 220, 220));
		ethics_no_txt.setBounds(1112, 388, 185, 42);
		panel_meta.add(ethics_no_txt);		
		subject_id_txt.setNextFocusableComponent(ethics_no_txt);
		
		info_txt = new JTextField(p_info);
		info_txt.setColumns(10);
		info_txt.setBackground(new Color(220, 220, 220));
		info_txt.setBounds(1112, 453, 185, 42);
		panel_meta.add(info_txt);
		ethics_no_txt.setNextFocusableComponent(info_txt);
		//
        //----------------------------------------------- panel DublinCore -----------------------------------------
		JPanel panel_dublin = new JPanel();
		panel_dublin.setBackground(new Color(0, 51, 102));
		panel_dublin.setPreferredSize(new Dimension(1350, 590));
		cards.add(panel_dublin, BorderLayout.SOUTH);
		panel_dublin.setLayout(null);
		
		JLabel title_dublin = new JLabel("DublinCore");
		title_dublin.setBounds(10, 0, 132, 20);
		title_dublin.setFont(new Font("Tahoma", Font.BOLD, 24));
		title_dublin.setForeground(new Color(204, 204, 204));
		panel_dublin.add(title_dublin);
		
		JLabel coverage = new JLabel("<html>Coverage<BR> <font size = 2> Enter your location either as Name or as TGN code.\r\nE.g. Bochum or as TGN code tgn_7004904\r\nMore information on TGN: http://www.getty.edu/research/tools/vocabularies/tgn/\r\nE.g. Bochum or as TGN code tgn_7004904\r\n</font></html>");
		coverage.setForeground(new Color(211, 211, 211));
		coverage.setFont(new Font("Tahoma", Font.BOLD, 18));
		coverage.setBounds(26, 45, 334, 138);
		panel_dublin.add(coverage);
		
//		JLabel description = new JLabel("<html>Description<BR><font size = 2>Enter a generally understandable description of the stored research data.</font></html>");
//		description.setForeground(new Color(211, 211, 211));
//		description.setFont(new Font("Tahoma", Font.BOLD, 18));
//		description.setBounds(26, 202, 334, 70);
//		panel_dublin.add(description);
		
		JLabel format = new JLabel("<html>Format<BR><font size = 2>The file format, physical medium, or dimensions of the resource. A semicolon-separated list of file extensions that are used. \r\n" + 
				"E.g.: acq; mat; xls; xlsx\r\n" + 
				"</font></html>");
		format.setForeground(new Color(211, 211, 211));
		format.setFont(new Font("Tahoma", Font.BOLD, 18));
		format.setBounds(26, 331, 334, 70);
		panel_dublin.add(format);
		
		JLabel language = new JLabel("<html>Language<BR><font size = 2>A language of the resource. The language that is used in short form.\r\n" + 
				"E.g.: EN or DE\r\n" + 
				"</font></html>");
		language.setForeground(new Color(211, 211, 211));
		language.setFont(new Font("Tahoma", Font.BOLD, 18));
		language.setBounds(26, 455, 334, 70);
		panel_dublin.add(language);
		
		JLabel publisher = new JLabel("<html>Publisher<BR><font size = 2>Please enter SFB 1280 in this field or if more than one publisher is involved enter a semicolon-separated list of publishers. \r\nE.g.: SFB1280\r\nE.g. (more than one publisher): SFB1280; SFB874\r\n</font></html>");
		publisher.setForeground(new Color(211, 211, 211));
		publisher.setFont(new Font("Tahoma", Font.BOLD, 18));
		publisher.setBounds(692, 66, 334, 70);
		panel_dublin.add(publisher);
		
		JLabel relation = new JLabel("<html>Relation<BR><font size = 2>A related resource. Enter a semicolon separated list of identifiers for each publication related to the data.\r\nE.g.: Enter DOI identifier \r\n</font></html>");
		relation.setForeground(new Color(211, 211, 211));
		relation.setFont(new Font("Tahoma", Font.BOLD, 18));
		relation.setBounds(692, 202, 334, 70);
		panel_dublin.add(relation);
		
		
		JLabel rights = new JLabel("<html>Rights<BR><font size = 2> Information about rights held in and over the resource. Enter a license name under which the data will be published if a publication of the data is planned. More information about the licenses can be found here: https://creativecommons.org/licenses/\r\n" + 
				"E.g.: CC BY-SA\r\n" + 
				"</font></html>");
		rights.setAutoscrolls(true);
		rights.setForeground(new Color(211, 211, 211));
		rights.setFont(new Font("Tahoma", Font.BOLD, 18));
		rights.setBounds(692, 321, 334 - 100, 117);
		panel_dublin.add(rights);
		
		JLabel subject = new JLabel("<html>Keywords<BR><font size = 2>The topic of the resource. Please use general search terms separated<BR> by a semicolon that best describe the research data.<BR> Individual search terms can be used as well as defined terms as listed in PSYNDEX: \r\nhttps://www.psyndex.de/ueber/inhalte-aufbau/<BR>schlagwoerter-klassifikationen/</font></html>");
		subject.setForeground(new Color(211, 211, 211));
		subject.setFont(new Font("Tahoma", Font.BOLD, 18));
		subject.setBounds(26, 190, 350, 100);;
		panel_dublin.add(subject);

		
		JComboBox<String> coverage_txt_dub = new JComboBox<String>();
		coverage_txt_dub.setModel(new DefaultComboBoxModel(new String[] {"Bochum", "Dortmund", "Essen", "Marburg"}));
		coverage_txt_dub.setFont(new Font("Tahoma", Font.PLAIN, 16));
		coverage_txt_dub.setBounds(388, 66, 230, 70);
		coverage_txt_dub.setSelectedItem(p_coverage_dub);
		panel_dublin.add(coverage_txt_dub);
		
		
		JTextField format_txt_dub = new JTextField(p_format_dub);
		format_txt_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
		format_txt_dub.setBackground(new Color(220, 220, 220));
		format_txt_dub.setBounds(388, 338, 230, 70);
		panel_dublin.add(format_txt_dub);
		

		JComboBox<String> language_txt_dub = new JComboBox<>();
		language_txt_dub.setEditable(true);
		language_txt_dub.setModel(new DefaultComboBoxModel<>(new String[] {"EN", "DE"}));
		language_txt_dub.setSelectedItem(p_language_dub);
		language_txt_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
		language_txt_dub.setBackground(new Color(220, 220, 220));
		language_txt_dub.setBounds(388, 474, 230, 70);
		panel_dublin.add(language_txt_dub);
		format_txt_dub.setNextFocusableComponent(language_txt_dub);
		
		JTextField publisher_txt_dub = new JTextField(p_publisher_dub);
		publisher_txt_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
		publisher_txt_dub.setBackground(new Color(220, 220, 220));
		publisher_txt_dub.setBounds(1076, 66, 230, 70);
		panel_dublin.add(publisher_txt_dub);
		language_txt_dub.setNextFocusableComponent(publisher_txt_dub);
		
		JTextField relation_txt_dub = new JTextField(p_relation_dub);
		relation_txt_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
		relation_txt_dub.setBackground(new Color(220, 220, 220));
		relation_txt_dub.setBounds(1076, 202, 230, 70);
		panel_dublin.add(relation_txt_dub);		
		publisher_txt_dub.setNextFocusableComponent(relation_txt_dub);
		
		
		SteppedComboBox rights_combo_dub = new SteppedComboBox(new DefaultComboBoxModel(RIGHTS_LABELS));
		rights_combo_dub.setPopupWidth(600);
		//rights_combo_dub.setModel();
		rights_combo_dub.setSelectedItem(p_rights_dub);
		rights_combo_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 12));
		rights_combo_dub.setBackground(new Color(220, 220, 220));
		rights_combo_dub.setBounds(1076 - 100, 338, 230 + 100, 70);
		panel_dublin.add(rights_combo_dub);
		relation_txt_dub.setNextFocusableComponent(rights_combo_dub);
		
		
		JTextField subject_txt_dub = new JTextField(p_subject_dub);
		subject_txt_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
		subject_txt_dub.setBackground(new Color(220, 220, 220));
		subject_txt_dub.setBounds(388, 202, 230, 70);
		panel_dublin.add(subject_txt_dub);
		rights_combo_dub.setNextFocusableComponent(subject_txt_dub);
		//
        //----------------------------------------------- panel DataCite -----------------------------------------
		JPanel panel_cite = new JPanel();
		panel_cite.setBackground(new Color(0, 51, 102));
		//panel_cite.setPreferredSize(new Dimension(1350, 590));
		panel_cite.setPreferredSize(new Dimension(1350, 590));
		cards.add(panel_cite);
		panel_cite.setLayout(null);
		//
		
		JLabel title_cite = new JLabel("DataCite");
		title_cite.setBounds(10, 0, 132, 20);
		title_cite.setFont(new Font("Tahoma", Font.BOLD, 22));
		title_cite.setForeground(new Color(204, 204, 204));
		panel_cite.add(title_cite);
		
		JLabel label_2 = new JLabel("Creator");
		label_2.setForeground(new Color(204, 204, 204));
		label_2.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_2.setBounds(10, 46, 115, 14);
		label_2.setToolTipText("<html>The main researchers involved\r\n" + 
				"in producing the data, or the\r\n" + 
				"authors of the publication, <BR>in \r\n" + 
				"priority order. To supply\r\n" + 
				"multiple creators, repeat this\r\n" + 
				"property.</html>");
		panel_cite.add(label_2);
		
		JLabel label_3 = new JLabel("Creator Name (M)");
		label_3.setForeground(new Color(204, 204, 204));
		label_3.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_3.setBounds(41, 72, 135, 36);
		label_3.setToolTipText("The full name of the creator.");
		panel_cite.add(label_3);
		
		JLabel label_5 = new JLabel("Given Name (O)");
		label_5.setForeground(new Color(204, 204, 204));
		label_5.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_5.setBounds(41, 137, 115, 36);
		label_5.setToolTipText("The personal or first name of\r\n" + 
				"the creator.");
		panel_cite.add(label_5);
		
		JLabel label_6 = new JLabel("Family Name (O)");
		label_6.setForeground(new Color(204, 204, 204));
		label_6.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_6.setBounds(41, 208, 115, 36);
		label_6.setToolTipText("The surname or last name of\r\n" + 
				"the creator.");
		panel_cite.add(label_6);
		
		JLabel label_7 = new JLabel("Name Identifier (O)");
		label_7.setForeground(new Color(204, 204, 204));
		label_7.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_7.setBounds(41, 275, 135, 36);
		label_7.setToolTipText("<html>Uniquely identifies an \r\n" + 
				"individual or legal entity, \r\n" + 
				"according to various schemas. <BR>This field requires an ID that is mapped to your name.<BR>\r\n" + 
				"E.g.: Enter your ORCID ID\r\n" + 
				"</html>");
		panel_cite.add(label_7);
		
		JLabel lblnameIdentifiernbspnbsp = new JLabel("<html>Name Identifier<BR> &nbsp; &nbsp; Scheme (O)</html>");
		lblnameIdentifiernbspnbsp.setForeground(new Color(204, 204, 204));
		lblnameIdentifiernbspnbsp.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblnameIdentifiernbspnbsp.setBounds(41, 345, 113, 36);
		lblnameIdentifiernbspnbsp.setToolTipText("The name of the name\r\n" + 
				"identifier schema. The name of the issuing organization.\r\n" + 
				"E.g.: ORCID\r\n" + 
				"");
		panel_cite.add(lblnameIdentifiernbspnbsp);
		
		JLabel label_9 = new JLabel("Scheme URI (O)");
		label_9.setForeground(new Color(204, 204, 204));
		label_9.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_9.setBounds(41, 421, 115, 36);
		label_9.setToolTipText("<html>The URI of the name identifier\r\n" + 
				"schema. The Link of the issuing organization.<BR>\r\n" + 
				"E.g.: http://orcid.org</html>\r\n" + 
				"");
		panel_cite.add(label_9);
		
		JLabel label_10 = new JLabel("Affiliation (O)");
		label_10.setForeground(new Color(204, 204, 204));
		label_10.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_10.setBounds(41, 483, 115, 36);
		label_10.setToolTipText("<html>The organizational or\r\n" + 
				"institutional affiliation of the\r\n" + 
				"creator. <BR>Enter your affiliation, as it has to be used in publications.<BR>\r\n" + 
				"E.g.: Department of Cognitive Psychology, Ruhr University Bochum, Germany\r\n" + 
				"</html>");
		panel_cite.add(label_10);
		
		JLabel label_11 = new JLabel("Contributor Type (O)");
		label_11.setForeground(new Color(204, 204, 204));
		label_11.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_11.setBounds(476, 66, 152, 36);
		label_11.setToolTipText("<html>The type of contributor of the\r\n" + 
				"resource. <BR>Choose one entry of the fields in the drop-down menu.</html>");
		panel_cite.add(label_11);
		
		JLabel label_12 = new JLabel("Contributor Name (R)");
		label_12.setForeground(new Color(204, 204, 204));
		label_12.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_12.setBounds(476, 137, 152, 36);
		label_12.setToolTipText("The full name of the contributor.");
		panel_cite.add(label_12);
		
		JLabel label_14 = new JLabel("Given Name (O)");
		label_14.setForeground(new Color(204, 204, 204));
		label_14.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_14.setBounds(476, 208, 115, 36);
		label_14.setToolTipText("The personal or first name of the \r\n" + 
				"contributor.");
		panel_cite.add(label_14);
		
		JLabel label_15 = new JLabel("Family Name (O)");
		label_15.setForeground(new Color(204, 204, 204));
		label_15.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_15.setBounds(476, 279, 115, 36);
		label_15.setToolTipText("The surname or last name of the\r\n" + 
				"contributor.");
		panel_cite.add(label_15);
		
		JLabel label_16 = new JLabel("Name Identifier (O)");
		label_16.setForeground(new Color(204, 204, 204));
		label_16.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_16.setBounds(476, 350, 163, 36);
		label_16.setToolTipText("<html>Uniquely identifies an individual or \r\n" + 
				"legal entity, according to various \r\n" + 
				"schemes.<BR> This field requires an ID that is mapped to every name listed in the field Contributor Name. <BR> \r\n" + 
				"Check the correct order of the name identifier to verify a correct mapping to each contributor. <BR>Separate each name identifier with a semicolon.\r\n" + 
				"If one contributor has now name identifier<BR> add a whitespace in the list instead and continue with a semicolon for the following identifiers.<BR>\r\n" + 
				"E.g. (All researchers have an ORCID ID): <BR>\r\n" + 
				"0000-0002-9994-0910; 0000-0001-9318-9540; 0000-0001-5679-6595<BR> \r\n" + 
				"\r\n" + 
				"E.g. (The second researcher has no ORCID ID) <BR>\r\n" + 
				"0000-0002-9994-0910;  ; 0000-0001-5679-6595 <BR> E.g. (The first researcher has no ORCID ID)<BR>\r\n" + 
				" ; 0000-0001-9318-9540; 0000-0001-5679-6595\r\n" + 
				"\r\n" + 
				"E.g. (The last researcher has no ORCID ID)<BR>\r\n" + 
				"0000-0002-9994-0910; 0000-0001-9318-9540; \r\n" + 
				"\r\n" + 
				"</html>");
		panel_cite.add(label_16);
		
		JLabel lblNameIdentifierSchemeo = new JLabel("<html>Name Identifier<BR> &nbsp; &nbsp; Scheme (O)</html>");
		lblNameIdentifierSchemeo.setForeground(new Color(204, 204, 204));
		lblNameIdentifierSchemeo.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblNameIdentifierSchemeo.setBounds(476, 421, 115, 44);
		lblNameIdentifierSchemeo.setToolTipText("<html>The name of the name identifier \r\n" + 
				"scheme. <BR>Enter the name of the issuing organization for each researcher <BR> listed in the field Contributor Name. <BR>"
				+ " The order of the entries is again very important <BR> here and separate each name identifier scheme with a semicolon. <BR>\r\n" + 
				"E.g. (All researchers have an ORCID ID): <BR> \r\n" + 
				"ORCID; ORCID; ORCID <BR>\r\n" + 
				"\r\n" + 
				"E.g. (The second researcher has no ORCID ID) <BR>\r\n" + 
				"ORCID; -; ORCID <BR>\r\n" + 
				"\r\n" + 
				"E.g. (The first researcher has no ORCID ID) <BR>\r\n" + 
				" -; ORCID; ORCID <BR>\r\n" + 
				"\r\n" + 
				"E.g. (The last researcher has no ORCID ID) <BR>\r\n" + 
				"ORCID; ORCID; -\r\n </html>" + 
				"");
		panel_cite.add(lblNameIdentifierSchemeo);
		
		JLabel label_18 = new JLabel("Scheme URI (O)");
		label_18.setForeground(new Color(204, 204, 204));
		label_18.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_18.setBounds(476, 492, 115, 36);
		label_18.setToolTipText("<html>The URI of the name identifier \r\n" + 
				"scheme. <BR> Enter the Link of the issuing organization for each researcher <BR>listed in the field Contributor Name.<BR> "
				+ "The order of the entries is again very important <BR>here and separate each scheme URI with a semicolon.<BR>\r\n" + 
				"\r\n" + 
				"\r\n" + 
				"E.g. (All researchers have an ORCID ID): <BR>\r\n" + 
				"http://orcid.org; http://orcid.org; http://orcid.org <BR>\r\n" + 
				"\r\n" + 
				"E.g. (The second researcher has no ORCID ID) <BR>\r\n" + 
				"http://orcid.org; -; http://orcid.org <BR> E.g. (The first researcher has no ORCID ID) <BR>\r\n" + 
				" -; http://orcid.org; http://orcid.org <BR>\r\n" + 
				"\r\n" + 
				"E.g. (The last researcher has no ORCID ID) <BR>\r\n" + 
				"http://orcid.org; http://orcid.org; \r\n" + 
				"\r\n" + 
				" </html>");
		panel_cite.add(label_18);
		
		JLabel label_19 = new JLabel("Affiliation (O)");
		label_19.setForeground(new Color(204, 204, 204));
		label_19.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_19.setBounds(476, 563, 115, 36);
		label_19.setToolTipText("<html> The organizational or institutional \r\n" + 
				"affiliation of the contributor. <BR> Enter the affiliation, as it has to be used in publications for contributors.<BR> "
				+ "The correct order is very important and must not differ <BR>from the order in the field  Contributor Name. Separate each affiliation with a semicolon.<BR>\r\n" + 
				"E.g.: Department of Cognitive Psychology, Ruhr University Bochum, Germany<BR>\r\n" + 
				"\r\n" + 
				"E.g. (All researchers have an ORCID ID):<BR> \r\n" + 
				"Department of Cognitive Psychology, Ruhr University Bochum, Germany; <BR>Department of Cognitive Psychology, Ruhr University Bochum, Germany; <BR>"
				+ "Department of Cognitive Psychology, Ruhr University Bochum, Germany<BR>\r\n" + 
				"\r\n" + 
				"E.g. (The second researcher has no ORCID ID)<BR>\r\n" + 
				"Department of Cognitive Psychology, Ruhr University Bochum, Germany; -; <BR>Department of Cognitive Psychology, Ruhr University Bochum, Germany<BR>\r\n" + 
				"\r\n" + 
				"E.g. (The first researcher has no ORCID ID)<BR>\r\n" + 
				" -; Department of Cognitive Psychology, Ruhr University Bochum, Germany; <BR>Department of Cognitive Psychology, Ruhr University Bochum, Germany<BR>\r\n" + 
				"\r\n" + 
				"E.g. (The last researcher has no ORCID ID)<BR>\r\n" + 
				"Department of Cognitive Psychology, Ruhr University Bochum, Germany;<BR> Department of Cognitive Psychology, Ruhr University Bochum, Germany; -\r\n" + 
				" </html>");
		panel_cite.add(label_19);
		
		JLabel lblKeywordsr = new JLabel("Keywords (R)");
		lblKeywordsr.setForeground(new Color(204, 204, 204));
		lblKeywordsr.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblKeywordsr.setBounds(902, 46, 115, 36);
		lblKeywordsr.setToolTipText("<html>Subject, keyword, classification \r\n" + 
				"code, or key phrase describing the \r\n" + 
				"resource.<BR> Please use general search terms that best describe the research data. <BR>"
				+ "Individual search terms can be used as well as<BR> defined terms as listed in PSYNDEX:<BR> \r\n" + 
				"https://www.psyndex.de/ueber/inhalte-aufbau/schlagwoerter-klassifikationen/<BR>\r\n" + 
				"</html>");
		panel_cite.add(lblKeywordsr);
		
		JLabel lblKeywordschemer = new JLabel("Keyword Scheme (R)");
		lblKeywordschemer.setForeground(new Color(204, 204, 204));
		lblKeywordschemer.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblKeywordschemer.setBounds(941, 117, 152, 36);
		lblKeywordschemer.setToolTipText("<html>The name of the subject scheme or \r\n" + 
				"classification code or authority if \r\n" + 
				"one is used.<BR> Use the name of the word scheme that was used if a special scheme was used.<BR> \r\n" + 
				"E.g.: PSYNDEX\r\n" + 
				"</html>");
		panel_cite.add(lblKeywordschemer);
		
		JLabel label_29 = new JLabel("Scheme URI (R)");
		label_29.setForeground(new Color(204, 204, 204));
		label_29.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_29.setBounds(941, 188, 115, 36);
		label_29.setToolTipText("<html>The URI of the subject identifier \r\n" + 
				"scheme.<BR> Name of the word scheme that was used. Please use PSYINDEX.<BR> \r\n" + 
				"https://www.psyndex.de/ueber/inhalte-aufbau/schlagwoerter-klassifikationen/\r\n" + 
				"</html>");
		panel_cite.add(label_29);
		
//		JLabel label_30 = new JLabel("Value URI(R)");
//		label_30.setForeground(new Color(204, 204, 204));
//		label_30.setFont(new Font("Tahoma", Font.BOLD, 13));
//		label_30.setBounds(941, 173, 115, 36);
//		label_30.setToolTipText("<html>The URI of the subject term. This field can be left empty and will later <BR>be filled in automatically by the university repository.</html>");
//		panel_cite.add(label_30);
		
		JLabel label_34 = new JLabel("Related Identifier (R)");
		label_34.setForeground(new Color(204, 204, 204));
		label_34.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_34.setBounds(902, 259, 145, 36);
		label_34.setToolTipText("Identifiers of related resources.<BR>\r\n" + 
				"These must be globally unique\r\n" + 
				"identifiers.");
		panel_cite.add(label_34);
		
		JLabel lblrelatedIdentifiernbsp = new JLabel("<html>Related Identifier<BR> &nbsp; &nbsp; &nbsp; &nbsp; Type (R)</html>");
		lblrelatedIdentifiernbsp.setForeground(new Color(204, 204, 204));
		lblrelatedIdentifiernbsp.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblrelatedIdentifiernbsp.setBounds(941, 330, 123, 36);
		lblrelatedIdentifiernbsp.setToolTipText("<html>The type of the RelatedIdentifier E.g.:<BR> ARK\", \"arXiv\", \"bibcode\", \"DOI\", \"EAN13\", \"EISSN\",<BR> "
				+ "\"Handle\", \"IGSN\", \"ISBN\", \"ISSN\", \"ISTC\", \"LISSN\",<BR> \"LSID\", \"PMID\", \"PURL\", \"UPC\", \"URL\", \"URN\", \"w3id\"</html>");
		panel_cite.add(lblrelatedIdentifiernbsp);
		
		JLabel label_36 = new JLabel("Relation Type (R)");
		label_36.setForeground(new Color(204, 204, 204));
		label_36.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_36.setBounds(941, 401, 115, 36);
		label_36.setToolTipText("<html>Description of the relationship of \r\n" + 
				"the resource being registered (A) \r\n" + 
				"and the related resource (B). E.g.: <BR> \"IsCitedBy\", \"Cites\", \"IsSupplementTo\", \"IsSupplementedBy\", \"IsContinuedBy\", \"Continues\", <BR>"
				+ "\"IsDescribedBy\", \"Describes\", \"HasMetadata\", \"IsMetadataFor\", \"HasVersion\", \"IsVersionOf\", <BR> \"IsNewVersionOf\", \"IsPreviousVersionOf\", "
				+ "\"IsPartOf\", \"HasPart\", \"IsReferencedBy\", \"References\", \"IsDocumentedBy\", <BR>\"Documents\", \"IsCompiledBy\", \"Compiles\", \"IsVariantFormOf\", "
				+ "\"IsOriginalFormOf\", \"IsIdenticalTo\", \"IsReviewedBy\", <BR>\"Reviews\", \"IsDerivedFrom\", \"IsSourceOf\", \"IsRequiredBy\", \"Requires\", \"IsObsoletedBy\", \"Obsoletes\" </html>");
		panel_cite.add(label_36);
		
		
		JLabel label_41 = new JLabel("Rights (O)");
		label_41.setForeground(new Color(204, 204, 204));
		label_41.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_41.setBounds(902, 472, 115, 36);
		label_41.setToolTipText("<html>Any rights information for this \r\n" + 
				"resource. \r\n" + 
				"The property may <BR>be repeated to \r\n" + 
				"record complex rights \r\n" + 
				"characteristics. <BR> Enter a license name under which the data will be published if a publication<BR> of the data is planned. More information"
				+ " about the licenses can be found here:<BR> https://creativecommons.org/licenses/ <BR>\r\n" + 
				"This field is automatically filled in by the SFB1280 App.<BR> It uses the entries of the field Rights of the Dublin Core meta data.<BR>\r\n" + 
				"E.g.: CC BY-SA\r\n" + 
				"</html>");
		panel_cite.add(label_41);
		
		JLabel label_42 = new JLabel("Rights URI (O)");
		label_42.setForeground(new Color(204, 204, 204));
		label_42.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_42.setBounds(941, 543, 115, 36);
		label_42.setToolTipText("<html>The URI of the license. The Link to the licensing organization. <BR>\r\n" + 
				"E.g.: https://creativecommons.org\r\n" + 
				"</html>");
		panel_cite.add(label_42);
		
//		JLabel label_43 = new JLabel("Rights Identifier(O)");
//		label_43.setForeground(new Color(204, 204, 204));
//		label_43.setFont(new Font("Tahoma", Font.BOLD, 13));
//		label_43.setBounds(941, 467, 163, 36);
//		label_43.setToolTipText("<html>A short, standardized version of \r\n" + 
//				"the license name. <BR> This field can be left empty and will later be filled<BR> in automatically by the university repository.</html> ");
//		panel_cite.add(label_43);
		
//		JLabel lblRightsidentifierschemeo = new JLabel("Rights Identifier Scheme(O)");
//		lblRightsidentifierschemeo.setForeground(new Color(204, 204, 204));
//		lblRightsidentifierschemeo.setFont(new Font("Tahoma", Font.BOLD, 13));
//		lblRightsidentifierschemeo.setBounds(941, 516, 187, 36);
//		lblRightsidentifierschemeo.setToolTipText("<html>The name of the scheme. This field can be left empty and <BR>will later be filled in automatically by the university repository. <html> ");
//		panel_cite.add(lblRightsidentifierschemeo);
		
		//JLabel lblSchemeurio = new JLabel("Scheme URI(O)");
		//lblSchemeurio.setForeground(new Color(204, 204, 204));
		//lblSchemeurio.setFont(new Font("Tahoma", Font.BOLD, 13));
		//lblSchemeurio.setBounds(941, 565, 115, 36);
		//lblSchemeurio.setToolTipText("<html>The URI of the rightsIdentifierScheme. <BR>This field can be left empty and will later be filled <BR>in automatically by the university repository.</html> ");
		//panel_cite.add(lblSchemeurio);
		
		JLabel label_52 = new JLabel("Contributor");
		label_52.setForeground(new Color(204, 204, 204));
		label_52.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_52.setBounds(426, 46, 113, 14);
		label_52.setToolTipText("<html>The institution or person \r\n" + 
				"responsible for collecting, \r\n" + 
				"managing, distributing, or \r\n" + 
				"otherwise <BR>contributing to the \r\n" + 
				"development of the resource. \r\n" + 
				"To supply multiple contributors, \r\n" + 
				"repeat<BR> this property. \r\n" + 
				"For software, if there is an \r\n" + 
				"alternate entity that \"holds, \r\n" + 
				"archives, publishes,<BR> prints, \r\n" + 
				"distributes, releases, issues, or \r\n" + 
				"produces\" the code, use the \r\n" + 
				"contributorType<BR> \r\n" + 
				"\"hostingInstitution\" for the code \r\n" + 
				"repository.</html>");
		panel_cite.add(label_52);
		JLabel lblNewLabel = new JLabel("(M): Mandatory, (R): Recommended, (O): Optional");
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 11));
		lblNewLabel.setForeground(Color.WHITE);
		lblNewLabel.setBounds(736, 8, 292, 14);
		panel_cite.add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("Please point your cursor to the text fields to get more information about the meta data.");
		lblNewLabel_1.setForeground(new Color(0, 255, 0));
		lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblNewLabel_1.setBounds(135, 1, 622, 27);
		panel_cite.add(lblNewLabel_1);
		//.......................................................
		
		creator_name_txt_cite = new JTextField(p_creator_name_cite);
		creator_name_txt_cite.setColumns(10);
		creator_name_txt_cite.setBounds(178, 80, 210, 36);
		panel_cite.add(creator_name_txt_cite);
		
		creator_given_name_txt_cite = new JTextField(p_creator_given_name_cite);
		creator_given_name_txt_cite.setColumns(10);
		creator_given_name_txt_cite.setBounds(178, 145, 210, 36);
		panel_cite.add(creator_given_name_txt_cite);
		
		creator_family_name_txt_cite = new JTextField(p_creator_family_name_cite);
		creator_family_name_txt_cite.setColumns(10);
		creator_family_name_txt_cite.setBounds(178, 207, 210, 36);
		panel_cite.add(creator_family_name_txt_cite);
		
		creator_name_identifier_txt_cite = new JTextField(p_creator_name_identifier_cite);
		creator_name_identifier_txt_cite.setColumns(10);
		creator_name_identifier_txt_cite.setBounds(178, 272, 210, 36);
		panel_cite.add(creator_name_identifier_txt_cite);
		
		creator_name_identifier_scheme_txt_cite = new JTextField(p_creator_name_identifier_scheme_cite );
		creator_name_identifier_scheme_txt_cite.setColumns(10);
		creator_name_identifier_scheme_txt_cite.setBounds(178, 345, 210, 36);
		panel_cite.add(creator_name_identifier_scheme_txt_cite);
		creator_name_identifier_txt_cite.setNextFocusableComponent(creator_name_identifier_scheme_txt_cite);
		
		creator_scheme_uri_txt_cite = new JTextField(p_creator_scheme_uri_cite);
		creator_scheme_uri_txt_cite.setColumns(10);
		creator_scheme_uri_txt_cite.setBounds(178, 416, 210, 36);
		panel_cite.add(creator_scheme_uri_txt_cite);
		creator_name_identifier_scheme_txt_cite.setNextFocusableComponent(creator_scheme_uri_txt_cite);

		creator_affiliation_txt_cite = new JTextField(p_creator_affiliation_cite);
		creator_affiliation_txt_cite.setColumns(10);
		creator_affiliation_txt_cite.setBounds(178, 483, 210, 36);
		panel_cite.add(creator_affiliation_txt_cite);
		creator_scheme_uri_txt_cite.setNextFocusableComponent(creator_affiliation_txt_cite);
		
		contributor_name_txt_cite = new JTextField(p_contributor_name_cite);
		contributor_name_txt_cite.setColumns(10);
		contributor_name_txt_cite.setBounds(635, 137, 210, 36);
		panel_cite.add(contributor_name_txt_cite);
		
		contributor_given_name_txt_cite = new JTextField(p_contributor_given_name_cite);
		contributor_given_name_txt_cite.setColumns(10);
		contributor_given_name_txt_cite.setBounds(635, 208, 210, 36);
		panel_cite.add(contributor_given_name_txt_cite);
		
		contributor_family_name_txt_cite = new JTextField(p_contributor_family_name_cite);
		contributor_family_name_txt_cite.setColumns(10);
		contributor_family_name_txt_cite.setBounds(635, 279, 210, 36);
		panel_cite.add(contributor_family_name_txt_cite);
		
		contributor_name_identifier_txt_cite = new JTextField(p_contributor_name_identifier_cite);
		contributor_name_identifier_txt_cite.setColumns(10);
		contributor_name_identifier_txt_cite.setBounds(635, 350, 210, 36);
		panel_cite.add(contributor_name_identifier_txt_cite);
		creator_affiliation_txt_cite.setNextFocusableComponent(contributor_name_identifier_txt_cite);
		
		contributor_name_identifier_scheme_txt_cite = new JTextField(p_contributor_name_identifier_scheme_cite);
		contributor_name_identifier_scheme_txt_cite.setColumns(10);
		contributor_name_identifier_scheme_txt_cite.setBounds(635, 421, 210, 36);
		panel_cite.add(contributor_name_identifier_scheme_txt_cite);
		contributor_name_identifier_txt_cite.setNextFocusableComponent(contributor_name_identifier_scheme_txt_cite);
		
		contributor_scheme_uri_txt_cite = new JTextField(p_contributor_scheme_uri_cite);
		contributor_scheme_uri_txt_cite.setColumns(10);
		contributor_scheme_uri_txt_cite.setBounds(635, 492, 210, 36);
		panel_cite.add(contributor_scheme_uri_txt_cite);
		contributor_name_identifier_scheme_txt_cite.setNextFocusableComponent(contributor_scheme_uri_txt_cite);
		
		contributor_affiliation_txt_cite = new JTextField(p_contributor_affiliation_cite);
		contributor_affiliation_txt_cite.setColumns(10);
		contributor_affiliation_txt_cite.setBounds(635, 563, 210, 36);
		panel_cite.add(contributor_affiliation_txt_cite);
		contributor_scheme_uri_txt_cite.setNextFocusableComponent(contributor_affiliation_txt_cite);
		
		subject_txt_cite = new JTextField(p_subject_cite);
		subject_txt_cite.setColumns(10);
		subject_txt_cite.setBounds(1093, 46, 210, 36);
		panel_cite.add(subject_txt_cite);
		
		subject_scheme_txt_cite = new JTextField(p_subject_scheme_cite);
		subject_scheme_txt_cite.setColumns(10);
		subject_scheme_txt_cite.setBounds(1093, 117, 210, 36);
		panel_cite.add(subject_scheme_txt_cite);
		contributor_affiliation_txt_cite.setNextFocusableComponent(subject_scheme_txt_cite);
		
		subject_scheme_uri_txt_cite = new JTextField(p_subject_scheme_uri_cite);
		subject_scheme_uri_txt_cite.setColumns(10);
		subject_scheme_uri_txt_cite.setBounds(1093, 188, 210, 36);
		panel_cite.add(subject_scheme_uri_txt_cite);
		subject_scheme_txt_cite.setNextFocusableComponent(subject_scheme_uri_txt_cite);
		
//		subject_value_uri_txt_cite = new JTextField(p_subject_value_uri_cite);
//		subject_value_uri_txt_cite.setColumns(10);
//		subject_value_uri_txt_cite.setBounds(1158, 173, 145, 36);
//		panel_cite.add(subject_value_uri_txt_cite);
//		subject_scheme_uri_txt_cite.setNextFocusableComponent(subject_value_uri_txt_cite);
		
		related_identifier_txt_cite = new JTextField(p_related_identifier_cite);
		related_identifier_txt_cite.setColumns(10);
		related_identifier_txt_cite.setBounds(1093, 259, 210, 36);
		panel_cite.add(related_identifier_txt_cite);
		
		related_identifier_type_combo_cite = new JComboBox<String>();
		related_identifier_type_combo_cite.setModel(new DefaultComboBoxModel<>(new String[] {"-", "ARK", "arXiv", "bibcode", "DOI", "EAN13", "EISSN", "Handle", "IGSN", "ISBN", "ISSN", "ISTC", "LISSN", "LSID", "PMID", "PURL", "UPC", "URL", "URN", "w3id"}));
		related_identifier_type_combo_cite.setSelectedItem(p_related_identifier_type_cite);
		related_identifier_type_combo_cite.setBounds(1093, 330, 210, 36);
		panel_cite.add(related_identifier_type_combo_cite);
		subject_scheme_uri_txt_cite.setNextFocusableComponent(related_identifier_type_combo_cite);

		
		relation_type_combo_cite = new  JComboBox<String>();
		relation_type_combo_cite.setModel(new DefaultComboBoxModel<>(new String[] {"-", "IsCitedBy", "Cites", "IsSupplementTo", "IsSupplementedBy", "IsContinuedBy", "Continues", "IsDescribedBy", "Describes", "HasMetadata", "IsMetadataFor", "HasVersion", "IsVersionOf", "IsNewVersionOf", "IsPreviousVersionOf", "IsPartOf", "HasPart", "IsPublishedIn", "IsReferencedBy", "References", "IsDocumentedBy", "Documents", "IsCompiledBy", "Compiles", "IsVariantFormOf", "IsOriginalFormOf", "IsIdenticalTo", "IsReviewedBy", "Reviews", "IsDerivedFrom", "IsSourceOf", "IsRequiredBy", "Requires", "IsObsoletedBy", "Obsoletes", "IsCollectedBy", "Collects"}));
		relation_type_combo_cite.setSelectedItem(p_relation_type_cite);
		relation_type_combo_cite.setBounds(1093, 401, 210, 36);
		panel_cite.add(relation_type_combo_cite);
		related_identifier_type_combo_cite.setNextFocusableComponent(relation_type_combo_cite);
		
		rights_txt_cite = new JTextField(p_rights_cite);
		rights_txt_cite.setColumns(10);
		rights_txt_cite.setBounds(1093, 472, 210, 36);
		panel_cite.add(rights_txt_cite);
		
		rights_uri_txt_cite = new JTextField(p_rights_uri_cite);
		rights_uri_txt_cite.setColumns(10);
		rights_uri_txt_cite.setBounds(1093, 543, 210, 36);
		panel_cite.add(rights_uri_txt_cite);
		relation_type_combo_cite.setNextFocusableComponent(rights_uri_txt_cite);
		
		//rights_identifier_txt_cite = new JTextField(p_rights_idenfitier_cite);
		//rights_identifier_txt_cite.setColumns(10);
		//rights_identifier_txt_cite.setBounds(1158, 467, 145, 36);
		//panel_cite.add(rights_identifier_txt_cite);
		//rights_uri_txt_cite.setNextFocusableComponent(rights_identifier_txt_cite);
		
		//rights_identifier_scheme_txt_cite = new JTextField(p_rights_identifier_scheme_cite);
		//rights_identifier_scheme_txt_cite.setColumns(10);
		//rights_identifier_scheme_txt_cite.setBounds(1158, 516, 145, 36);
		//panel_cite.add(rights_identifier_scheme_txt_cite);
		//rights_identifier_txt_cite.setNextFocusableComponent(rights_identifier_scheme_txt_cite);
		
		//rights_scheme_uri_txt_cite = new JTextField(p_rights_scheme_uri_cite);
		//rights_scheme_uri_txt_cite.setColumns(10);
		//rights_scheme_uri_txt_cite.setBounds(1158, 565, 145, 34);
		//panel_cite.add(rights_scheme_uri_txt_cite);
		//rights_identifier_scheme_txt_cite.setNextFocusableComponent(rights_scheme_uri_txt_cite);
		
		
		JComboBox contributor_type_txt_cite = new JComboBox();
		contributor_type_txt_cite.setModel(new DefaultComboBoxModel(new String[] {"ContactPerson", "DataCollector", "DataCurator",
				"DataManager", "Distributor", "Editor", "HostingInstitution", "Producer", "ProjectLeader", "ProjectManager", "ProjectMember", "RegistrationAgency",
				"RegistrationAuthority", "RelatedPerson", "Researcher", "ResearchGroup", "RightsHolder", "Sponsor", "Supervisor", "WorkPackageLeader", "Other"}));
		contributor_type_txt_cite.setBounds(635, 66, 210, 36);
		panel_cite.add(contributor_type_txt_cite);
		contributor_type_txt_cite.setSelectedItem(p_contributor_type_cite);
		/**
		 * ======================================================================================================
		 * Commands for buttons
		 * ======================================================================================================
		 **/
        final String FIRST = "FIRST";
        final String NEXT = "NEXT";
        final String PREVIOUS = "PREVIOUS";
        final String LAST = "LAST";
        final String EXIT = "EXIT";
        final String SAVE = "SAVE";
        //
       // Disable asterisk for format in dublinCore 
        char[] form_invalid = new char[] {',','*'};
        disableInvalid(format_txt_dub, form_invalid);
        char[] comma_invalid = new char[] {','};
        disableInvalid(publisher_txt_dub, comma_invalid);
        disableInvalid(subject_txt_dub, comma_invalid);
        //disableInvalid(language_txt_dub, comma_invalid);
        disableInvalid(relation_txt_dub, comma_invalid);
        //
        disableInvalid(creator_name_identifier_txt_cite, comma_invalid);
        disableInvalid(creator_name_identifier_scheme_txt_cite, comma_invalid);
        disableInvalid(creator_scheme_uri_txt_cite, comma_invalid);
        disableInvalid(creator_affiliation_txt_cite, comma_invalid);
        //
        disableInvalid(contributor_name_identifier_txt_cite, comma_invalid);
        disableInvalid(contributor_name_identifier_scheme_txt_cite, comma_invalid);
        disableInvalid(contributor_scheme_uri_txt_cite, comma_invalid);
        disableInvalid(contributor_affiliation_txt_cite, comma_invalid);
        //
        disableInvalid(subject_scheme_txt_cite, comma_invalid);
        disableInvalid(subject_scheme_uri_txt_cite, comma_invalid);
        //disableInvalid(subject_value_uri_txt_cite, comma_invalid);

        backRed(creator_txt);
        backRed(contributor_txt);
        backRedCheck(creator_name_identifier_txt_cite, creator_txt);
        backRedCheck(creator_name_identifier_scheme_txt_cite, creator_txt);
        backRedCheck(creator_scheme_uri_txt_cite, creator_txt);
        backRedCheck(creator_affiliation_txt_cite, creator_txt);
        //
        backRedCheck(contributor_name_identifier_txt_cite, contributor_txt);
        backRedCheck(contributor_name_identifier_scheme_txt_cite, contributor_txt);
        backRedCheck(contributor_scheme_uri_txt_cite, contributor_txt);
        backRedCheck(contributor_affiliation_txt_cite, contributor_txt);
        //
        backRedCheck(subject_scheme_txt_cite, subject_txt_dub);         
        backRedCheck(subject_scheme_uri_txt_cite, subject_txt_dub);
        
        //
        checkRedTrail(publisher_txt_dub);
        checkRedTrail(relation_txt_dub);
        checkRedTrail(format_txt_dub);
        //checkRedTrail(language_txt_dub);
        checkRedTrail(subject_txt_dub);

//        checkParent(creator_name_identifier_txt_cite, creator_txt);
//        checkParent(creator_name_identifier_scheme_txt_cite, creator_txt);
//        checkParent(creator_scheme_uri_txt_cite, creator_txt);
//        checkParent(creator_affiliation_txt_cite, creator_txt);
//        checkParent(contributor_name_identifier_txt_cite, contributor_txt);
//        checkParent(contributor_name_identifier_scheme_txt_cite, contributor_txt);
//        checkParent(contributor_scheme_uri_txt_cite, contributor_txt);
//        checkParent(contributor_affiliation_txt_cite, contributor_txt);
//

        //
		class ControlActionListenter implements ActionListener {
            public void actionPerformed(ActionEvent e) {
        		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        		Date dateObj = record_date_txt.getDate();
        		if (dateObj == null) {
        			dateObj = new Date();
        			//dateObj.setTime(0);
        		}
        		String dat = sdf.format(dateObj);
                CardLayout cl = (CardLayout) (cards.getLayout());
                String cmd = e.getActionCommand();
                //.................................................................................
                // from DataCite to SFB meta data
                if (cmd.equals(FIRST)) { 
                	if(errBox(creator_name_identifier_txt_cite) || errBox(creator_name_identifier_scheme_txt_cite) || errBox(creator_scheme_uri_txt_cite) || 
                			errBox(creator_affiliation_txt_cite) || errBox(contributor_name_identifier_txt_cite) || errBox(contributor_name_identifier_scheme_txt_cite) || 
                			errBox(contributor_scheme_uri_txt_cite) || errBox(contributor_affiliation_txt_cite) || errBox(subject_scheme_txt_cite) || 
                			errBox(subject_scheme_uri_txt_cite) || errBox(rights_uri_txt_cite) 
                			) {
                        JOptionPane.showMessageDialog(c, "Please correct the red fields!", "", getDefaultCloseOperation());
                	}
                    else {
                    	cl.first(cards);
                    }        
                 //................................................................................
                 // from SFB meta data to DublinCore
                } else if (cmd.equals(NEXT)) {  
                	if(errBox(creator_txt) || errBox(contributor_txt)) {
                        JOptionPane.showMessageDialog(c, "Please correct the red fields!", "", getDefaultCloseOperation());
                	}
                	else {
                		cl.next(cards);
                	}
                  //...............................................................................
                  //from DublinCore to SFB meta data
                } else if (cmd.equals(PREVIOUS)) { 
                	if(errBox(publisher_txt_dub)|| errBox(subject_txt_dub) || errBox(relation_txt_dub) || errBox(format_txt_dub) ) { //|| errBox(language_txt_dub)
                        JOptionPane.showMessageDialog(c, "Please correct the red fields!", "", getDefaultCloseOperation());
                	} else {
                		cl.previous(cards);
                	}
                  //...............................................................................
                  //from SFB meta data to DataCite
                } else if (cmd.equals(LAST)) { 
                	if(errBox(creator_txt) || errBox(contributor_txt)) {
                        JOptionPane.showMessageDialog(c, "Please correct the red fields!", "", getDefaultCloseOperation());
                	}
                	else {
	                    cl.last(cards);
	                    String[] creator_res = fullNameSplit(creator_txt);
	                    String[] contributor_res = fullNameSplit(contributor_txt);
	                    //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
	                    //|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
	                    creator_name_txt_cite.setText(creator_txt.getText());
	                    creator_name_txt_cite.setEditable(false);
	                    creator_given_name_txt_cite.setText(creator_res[0]);
	                    creator_given_name_txt_cite.setEditable(false);
	                    creator_family_name_txt_cite.setText(creator_res[1]);
	                    creator_family_name_txt_cite.setEditable(false);
	                    contributor_name_txt_cite.setText(contributor_txt.getText());
	                    contributor_name_txt_cite.setEditable(false);
	                    contributor_given_name_txt_cite.setText(contributor_res[0]);
	                    contributor_given_name_txt_cite.setEditable(false);
	                    contributor_family_name_txt_cite.setText(contributor_res[1]);
	                    contributor_family_name_txt_cite.setEditable(false);
	                    subject_txt_cite.setText(subject_txt_dub.getText());
	                    subject_txt_cite.setEditable(false);
	                    related_identifier_txt_cite.setText(relation_txt_dub.getText());
	                    related_identifier_txt_cite.setEditable(false);
	                    rights_txt_cite.setText(rights_combo_dub.getSelectedItem().toString());
	                    rights_uri_txt_cite.setText(RIGHTS_URI[rights_combo_dub.getSelectedIndex()]);
	                    rights_txt_cite.setEditable(false);
                }
                } else if(cmd.equals(EXIT)) {
                	if(contributor_txt.getText().trim().isEmpty() 
            	    		|| creator_txt.getText().trim().isEmpty() 
            	    		|| group_id_txt.getSelectedItem().toString().equals("-")
            	    		|| experiment_title_txt.getText().trim().isEmpty() 
            	    		|| subject_id_txt.getText().trim().isEmpty() 
            	    		|| subject_species_txt.getSelectedItem().toString().isEmpty() 
            	    		|| subject_sex_txt.getSelectedItem().toString().isEmpty()
            	    		|| modality_txt.getSelectedValuesList().isEmpty() 
            	    		|| shared_with_txt.getSelectedValuesList().isEmpty()
            	    		|| experimentDescriptionTextArea.getText().length() == 0 ) {
                    	    	//.........................................................
                                // To pop up an info message dialog
                                JOptionPane.showMessageDialog(c, "Some fields are missing! Please complete the fields as soon as possible!", "", getDefaultCloseOperation());         
                    	    }
                	System.exit(0);
                 //................................................................................
                 // Click save
                } else if(cmd.equals(SAVE)){
                	
                	sanitizeExperimentDescription(experimentDescriptionTextArea);
                	
                	BufferedWriter writer;
                    JSONObject obj = new JSONObject();
                    //
                    String[] creator_res = fullNameSplit(creator_txt);
                    String[] contributor_res = fullNameSplit(contributor_txt);
                    //
                    //String form_txt_dub = format_txt_dub.getText().replaceAll(";", ",");
                    //String sub_txt_dub = subject_txt_dub.getText().replaceAll(";", ",");
                    //..........................................................................
                    obj.put("Software version",  currentSoftwareVersion); // Old-version: 20200909
                    //..........................................................................
                    // SFB meta data
                    obj.put("Group ID",  group_id_txt.getSelectedItem().toString());
            		obj.put("Experiment title", experiment_title_txt.getText());
            		obj.put("Creator", creator_txt.getText());
            		obj.put("Contributor", contributor_txt.getText());
            		obj.put("Record date", dat);
            		obj.put("Resource Type", data_type_txt.getSelectedItem().toString());
            		obj.put("Modality", modality_txt.getSelectedValuesList());
            		obj.put("Subject ID", subject_id_txt.getText());
            		obj.put("Subject Species", subject_species_txt.getSelectedItem().toString());
            		obj.put("Subject type", subject_type_txt.getSelectedItem().toString());
            		obj.put("Subject sex", subject_sex_txt.getSelectedItem().toString());
            		float ageValue = 0;
            		try {
            			ageValue = (Float.parseFloat(subject_age_txt.getValue().toString()));
            		} catch (NumberFormatException e1) {          		}
            		
            		String ageValueString = ageInYears.isSelected() ? subject_age_txt.getValue().toString() : Float.toString(ageValue / 12f);
            		if (ageValue == 0 || Float.isNaN(ageValue)) ageValueString = Float.toString(Float.NaN);
            		obj.put("Subject age", ageValueString);
            		
            		obj.put("Shared with", shared_with_txt.getSelectedValuesList());
            		obj.put("Animal|Ethics approval No.", ethics_no_txt.getText());
            		obj.put("Extra information", info_txt.getText());
            		obj.put("Experiment Description", experimentDescriptionTextArea.getText());
            		//............................................................................
            		//DublinCore
            		obj.put("DublinCore-Creator", creator_txt.getText());
    				obj.put("DublinCore-Contributor", contributor_txt.getText());
    				obj.put("DublinCore-Coverage", coverage_txt_dub.getSelectedItem().toString());
    				obj.put("DublinCore-Date", dat);
    				obj.put("DublinCore-Description", experimentDescriptionTextArea.getText());
    				obj.put("DublinCore-Format", format_txt_dub.getText());
    				obj.put("DublinCore-Identifier", p_identifier_dub);
    				obj.put("DublinCore-Language", language_txt_dub.getSelectedItem());
    				obj.put("DublinCore-Publisher", publisher_txt_dub.getText());
    				obj.put("DublinCore-Relation", relation_txt_dub.getText());
    				obj.put("DublinCore-Rights", rights_combo_dub.getSelectedItem());
    				obj.put("DublinCore-Source", p_source_dub);
    				obj.put("DublinCore-Subject", subject_txt_dub.getText());
    				obj.put("DublinCore-Title", experiment_title_txt.getText());
    				obj.put("DublinCore-Type", p_type_dub);
            		//..........................................................................
            		// DataCite				
            		obj.put("DataCite-Identifier", p_identifier_cite); 
            		obj.put("DataCite-identifierType", p_identifier_type_cite);
            		obj.put("DataCite-Title", experiment_title_txt.getText());
            		obj.put("DataCite-titleType", p_title_type_cite);
            		obj.put("DataCite-creatorName", creator_txt.getText());
            		obj.put("DataCite-creatorNameType", p_creator_name_type_cite);
            		obj.put("DataCite-creatorGivenName", creator_res[0]);
            		obj.put("DataCite-creatorFamilyName", creator_res[1]);
            	    obj.put("DataCite-creatorNameIdentifier", creator_name_identifier_txt_cite.getText());
            	    obj.put("DataCite-creatorNameIdentifierScheme", creator_name_identifier_scheme_txt_cite.getText());
            	    obj.put("DataCite-creatorSchemeURI", creator_scheme_uri_txt_cite.getText());
            	    obj.put("DataCite-creatorAffiliation", creator_affiliation_txt_cite.getText());
            	    obj.put("DataCite-contributorType", contributor_type_txt_cite.getSelectedItem().toString());
            	    obj.put("DataCite-contributorName", contributor_txt.getText());
            	    obj.put("DataCite-contributorNameType", p_contributor_name_type_cite);
            	    obj.put("DataCite-contributorGivenName", contributor_res[0]);
            	    obj.put("DataCite-contributorFamilyName", contributor_res[1]);
            	    obj.put("DataCite-contributorNameIdentifier", contributor_name_identifier_txt_cite.getText());
            	    obj.put("DataCite-contributorNameIdentifierScheme", contributor_name_identifier_scheme_txt_cite.getText());
            	    obj.put("DataCite-contributorSchemeURI", contributor_scheme_uri_txt_cite.getText());
            	    obj.put("DataCite-contributorAffiliation", contributor_affiliation_txt_cite.getText());
            	    obj.put("DataCite-Date", dat);
            	    obj.put("DataCite-dateType", p_date_type_cite);
            	    obj.put("DataCite-ResourceType", modality_txt.getSelectedValuesList());
            	    obj.put("DataCite-resourceTypeGeneral", p_resource_type_general_cite);
            	    obj.put("DataCite-Publisher", publisher_txt_dub.getText());
            	    obj.put("DataCite-PublicationYear", p_publication_year_cite);
            	    obj.put("DataCite-Subject", subject_txt_dub.getText());
            	    obj.put("DataCite-subjectScheme", subject_scheme_txt_cite.getText());
            	    obj.put("DataCite-subjectSchemeURI", subject_scheme_uri_txt_cite.getText());
            	    obj.put("DataCite-subjectValueURI", p_subject_value_uri_cite);
            	    obj.put("DataCite-Language", language_txt_dub.getSelectedItem());
            	    obj.put("DataCite-alternateIdentifier", p_alternate_identifier_cite);
            	    obj.put("DataCite-alternateIdentifierType", p_alternate_identifier_type_cite);
            	    obj.put("DataCite-RelatedIdentifier", related_identifier_txt_cite.getText());
            	    obj.put("DataCite-relatedIdentifierType", related_identifier_type_combo_cite.getSelectedItem());
            	    obj.put("DataCite-relationType", relation_type_combo_cite.getSelectedItem());
            	    obj.put("DataCite-Size", p_size_cite);
            	    obj.put("DataCite-Format", format_txt_dub.getText());
            	    obj.put("DataCite-Version", p_version_cite);
            	    obj.put("DataCite-Rights", rights_txt_cite.getText());
            	    obj.put("DataCite-rightsURI", rights_uri_txt_cite.getText());
            	    obj.put("DataCite-rightsIdentifier", p_rights_identifier_cite);
            	    obj.put("DataCite-rightsIdentifierScheme", p_rights_identifier_scheme_cite);
            	    obj.put("DataCite-rightsSchemeURI", p_rights_scheme_uri_cite);
            	    obj.put("DataCite-Description", experimentDescriptionTextArea.getText());
            	    obj.put("DataCite-descriptionType", p_description_type_cite);
            	    obj.put("DataCite-GeoLocationPlace", coverage_txt_dub.getSelectedItem().toString());
            	    obj.put("DataCite-FundingReference", p_funding_reference_cite);
            	    obj.put("DataCite-funderName", p_funder_name_cite);
            	    obj.put("DataCite-funderIdentifier", p_funder_identifier_cite);
            	    obj.put("DataCite-funderIdentifierType", p_funder_identifier_type_cite);
            	    
            	    
            	    
            	    if(errBox(creator_txt) || errBox(contributor_txt)) {
                        JOptionPane.showMessageDialog(c, "Please correct the red fields!", "", getDefaultCloseOperation());
            	    } 
            	    else {
            	    	
            	    	if(sanitizeExperimentDescription(experimentDescriptionTextArea) != null) {
                	    	JOptionPane.showMessageDialog(c, sanitizeExperimentDescription(experimentDescriptionTextArea), "", getDefaultCloseOperation());
                	    }
            	    	
	                    try {
	                        writer = new BufferedWriter(new FileWriter("meta.json",false)); // false to overwrite
	                        Gson gson = new GsonBuilder().setPrettyPrinting().create();         
	                        writer.write(gson.toJson(obj));
	                        writer.flush();
	                        writer.close();
	                    } catch(FileNotFoundException ex) {
	                        ex.printStackTrace();
	                    } catch (IOException ex) {
	                        ex.printStackTrace();
	                    }
	                    // To pop up an info message dialog
	                    JOptionPane.showMessageDialog(c, "Successfully copied data to the meta.json file!", "", getDefaultCloseOperation());
	                }
                }
            }
        }
        ControlActionListenter cal = new ControlActionListenter();
		
        JButton btndublin = new JButton("(1) DublinCore");
        btndublin.setBackground(new Color(176, 196, 222));
        btndublin.setFont(new Font("Tahoma", Font.BOLD, 14));
		btndublin.setBounds(95, 523 - 483, 139, 42);  //LEFT, TOP, Width, Length
		southPanel.add(btndublin);
		btndublin.setActionCommand(NEXT);
        btndublin.addActionListener(cal);
		
		JButton btncite = new JButton("(2) DataCite");
		btncite.setBackground(new Color(176, 196, 222));
        btncite.setFont(new Font("Tahoma", Font.BOLD, 14));
		btncite.setBounds(329, 523 - 483, 139, 42);
		southPanel.add(btncite);
        	
		btncite.setActionCommand(LAST);
	    btncite.addActionListener(cal);
		
		JButton btnsave = new JButton("Save");
		btnsave.setBackground(new Color(176, 196, 222));
        btnsave.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnsave.setBounds(563, 523 - 483, 139, 42);
		southPanel.add(btnsave);
		btnsave.setActionCommand(SAVE);
		btnsave.addActionListener(cal);
		
		JButton btnexit = new JButton("Exit");
		btnexit.setBackground(new Color(176, 196, 222));
        btnexit.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnexit.setBounds(797, 523 - 483, 139, 42);
		southPanel.add(btnexit);
		btnexit.setActionCommand(EXIT);	
		btnexit.addActionListener(cal);
		
		JButton btnbackdub = new JButton("Back");
		btnbackdub.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnbackdub.setBounds(121, 551, 120, 40);
		panel_dublin.add(btnbackdub);
		btnbackdub.setActionCommand(PREVIOUS);
		btnbackdub.addActionListener(cal);
		
		JButton btnbackcite = new JButton("Back");
		btnbackcite.setFont(new Font("Tahoma", Font.BOLD, 13));
		btnbackcite.setBounds(87, 563, 140, 33);
		panel_cite.add(btnbackcite);
		btnbackcite.setActionCommand(FIRST);
		
		JPanel panel_1 = new JPanel();
		panel_1.setOpaque(false);
		panel_1.setBorder(new MatteBorder(1, 1, 1, 1, (Color) Color.LIGHT_GRAY));
		panel_1.setBounds(20, 66, 387, 462);
		panel_cite.add(panel_1);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new MatteBorder(1, 1, 1, 1, (Color) Color.LIGHT_GRAY));
		panel_2.setOpaque(false);
		panel_2.setBounds(454, 66, 407, 538);
		panel_cite.add(panel_2);
		
		JPanel panel_3 = new JPanel();
		panel_3.setBorder(new MatteBorder(1, 1, 1, 1, (Color) Color.LIGHT_GRAY));
		panel_3.setOpaque(false);
		panel_3.setBounds(922, 107, 397, 127);
		panel_cite.add(panel_3);
		
		JPanel panel_4 = new JPanel();
		panel_4.setBorder(new MatteBorder(1, 1, 1, 1, (Color) Color.LIGHT_GRAY));
		panel_4.setOpaque(false);
		panel_4.setBounds(922, 319, 397, 127);
		panel_cite.add(panel_4);
		
		JPanel panel_5 = new JPanel();
		panel_5.setBorder(new MatteBorder(1, 1, 1, 1, (Color) Color.LIGHT_GRAY));
		panel_5.setOpaque(false);
		panel_5.setBounds(922, 537, 397, 49);
		panel_cite.add(panel_5);
		btnbackcite.addActionListener(cal);
	}
}
