diff --git a/builds/MetaApp.jar b/builds/MetaApp.jar index fbd544a7323cf07e89e43eca052c804d2ce755b3..e55ce5e6e3645be356e559024459f4fccadb8c45 100644 Binary files a/builds/MetaApp.jar and b/builds/MetaApp.jar differ diff --git a/src/AppJ_V03.java b/src/AppJ_V03.java index 17c196a7d6c7652cede72f09eb5f1f3c1262ea7c..623f7277a4832c18aec220e3bd15c9b74696fa93 100644 --- a/src/AppJ_V03.java +++ b/src/AppJ_V03.java @@ -67,7 +67,17 @@ import com.toedter.calendar.JDateChooser; **/ public class AppJ_V03 extends JFrame { - private static final String currentSoftwareVersion = "20240403"; + private static final String currentSoftwareVersion = "20240413"; + + + 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-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 BY-NC-SA Attribution-NonCommercial-ShareAlike 4.0 International", "Creative Commons CC0 1.0 Universal", "Creative Commons Public Domain Mark 1.0", "Creative Commons Public Domain Mark 1.0", "Apache License 2.0", "GNU General Public License", "MIT License" + }; private static final long serialVersionUID = 1L; @@ -76,8 +86,9 @@ public class AppJ_V03 extends JFrame { 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, related_identifier_type_txt_cite, - relation_type_txt_cite, rights_txt_cite, rights_uri_txt_cite, ethics_no_txt, info_txt; + 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 @@ -447,8 +458,8 @@ public class AppJ_V03 extends JFrame { String p_alternate_identifier_type_cite = ""; //.......................................... String p_related_identifier_cite = ""; - String p_related_identifier_type_cite = ""; - String p_relation_type_cite = ""; + String p_related_identifier_type_cite = "DOI"; + String p_relation_type_cite = "IsReferencedBy"; //.......................................... String p_size_cite = ""; String p_version_cite = "1.0"; @@ -1042,13 +1053,14 @@ public class AppJ_V03 extends JFrame { 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, 117); + 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>"); @@ -1065,24 +1077,12 @@ public class AppJ_V03 extends JFrame { coverage_txt_dub.setSelectedItem(p_coverage_dub); panel_dublin.add(coverage_txt_dub); -// JScrollPane scrollPane_2 = new JScrollPane(); -// scrollPane_2.setBounds(388, 202, 230, 70); -// panel_dublin.add(scrollPane_2); - - -// JTextArea description_txt_dub = new JTextArea(p_description_dub); -// scrollPane_2.setViewportView(description_txt_dub); -// description_txt_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 16)); -// description_txt_dub.setBackground(new Color(220, 220, 220)); -// //panel_dublin.add(scroller); - 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); - // description_txt_dub.setNextFocusableComponent(format_txt_dub); JTextField language_txt_dub = new JTextField(p_language_dub); @@ -1105,13 +1105,17 @@ public class AppJ_V03 extends JFrame { relation_txt_dub.setBounds(1076, 202, 230, 70); panel_dublin.add(relation_txt_dub); publisher_txt_dub.setNextFocusableComponent(relation_txt_dub); - - JTextField rights_txt_dub = new JTextField(p_rights_dub); - rights_txt_dub.setFont(new Font("Lucida Grande", Font.PLAIN, 16)); - rights_txt_dub.setBackground(new Color(220, 220, 220)); - rights_txt_dub.setBounds(1076, 338, 230, 70); - panel_dublin.add(rights_txt_dub); - relation_txt_dub.setNextFocusableComponent(rights_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); @@ -1119,7 +1123,7 @@ public class AppJ_V03 extends JFrame { subject_txt_dub.setBackground(new Color(220, 220, 220)); subject_txt_dub.setBounds(388, 202, 230, 70); panel_dublin.add(subject_txt_dub); - rights_txt_dub.setNextFocusableComponent(subject_txt_dub); + rights_combo_dub.setNextFocusableComponent(subject_txt_dub); // //----------------------------------------------- panel DataCite ----------------------------------------- JPanel panel_cite = new JPanel(); @@ -1587,19 +1591,20 @@ public class AppJ_V03 extends JFrame { related_identifier_txt_cite.setBounds(1093, 259, 210, 36); panel_cite.add(related_identifier_txt_cite); - - related_identifier_type_txt_cite = new JTextField(p_related_identifier_type_cite); - related_identifier_type_txt_cite.setColumns(10); - related_identifier_type_txt_cite.setBounds(1093, 330, 210, 36); - panel_cite.add(related_identifier_type_txt_cite); - subject_scheme_uri_txt_cite.setNextFocusableComponent(related_identifier_type_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_txt_cite = new JTextField(p_relation_type_cite); - relation_type_txt_cite.setColumns(10); - relation_type_txt_cite.setBounds(1093, 401, 210, 36); - panel_cite.add(relation_type_txt_cite); - related_identifier_type_txt_cite.setNextFocusableComponent(relation_type_txt_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); @@ -1610,7 +1615,7 @@ public class AppJ_V03 extends JFrame { rights_uri_txt_cite.setColumns(10); rights_uri_txt_cite.setBounds(1093, 543, 210, 36); panel_cite.add(rights_uri_txt_cite); - relation_type_txt_cite.setNextFocusableComponent(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); @@ -1672,10 +1677,7 @@ public class AppJ_V03 extends JFrame { disableInvalid(subject_scheme_txt_cite, comma_invalid); disableInvalid(subject_scheme_uri_txt_cite, comma_invalid); //disableInvalid(subject_value_uri_txt_cite, comma_invalid); - // - disableInvalid(related_identifier_type_txt_cite, comma_invalid); - disableInvalid(relation_type_txt_cite, comma_invalid); -// + backRed(creator_txt); backRed(contributor_txt); backRedCheck(creator_name_identifier_txt_cite, creator_txt); @@ -1690,15 +1692,7 @@ public class AppJ_V03 extends JFrame { // backRedCheck(subject_scheme_txt_cite, subject_txt_dub); backRedCheck(subject_scheme_uri_txt_cite, subject_txt_dub); - //backRedCheck(subject_value_uri_txt_cite, subject_txt_dub); - // - backRedCheck(related_identifier_type_txt_cite, relation_txt_dub); - backRedCheck(relation_type_txt_cite, relation_txt_dub); - // - backRedCheckEmpty(rights_uri_txt_cite, rights_txt_dub); - //backRedCheckEmpty(rights_identifier_txt_cite, rights_txt_dub); - //backRedCheckEmpty(rights_identifier_scheme_txt_cite, rights_txt_dub); - //backRedCheckEmpty(rights_scheme_uri_txt_cite, rights_txt_dub); + // checkRedTrail(publisher_txt_dub); checkRedTrail(relation_txt_dub); @@ -1734,8 +1728,7 @@ public class AppJ_V03 extends JFrame { 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(related_identifier_type_txt_cite) || errBox(relation_type_txt_cite) || - errBox(rights_uri_txt_cite) + errBox(subject_scheme_uri_txt_cite) || errBox(rights_uri_txt_cite) ) { JOptionPane.showMessageDialog(c, "Please correct the red fields!", "", getDefaultCloseOperation()); } @@ -1787,7 +1780,8 @@ public class AppJ_V03 extends JFrame { 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_txt_dub.getText()); + 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)) { @@ -1860,7 +1854,7 @@ public class AppJ_V03 extends JFrame { obj.put("DublinCore-Language", language_txt_dub.getText()); obj.put("DublinCore-Publisher", publisher_txt_dub.getText()); obj.put("DublinCore-Relation", relation_txt_dub.getText()); - obj.put("DublinCore-Rights", rights_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()); @@ -1902,8 +1896,8 @@ public class AppJ_V03 extends JFrame { 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_txt_cite.getText()); - obj.put("DataCite-relationType", relation_type_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); diff --git a/src/SteppedComboBox.java b/src/SteppedComboBox.java new file mode 100644 index 0000000000000000000000000000000000000000..2c035142193b5802a69594be7835c480dc55e945 --- /dev/null +++ b/src/SteppedComboBox.java @@ -0,0 +1,108 @@ +import java.awt.*; +import java.util.*; +import javax.swing.*; +import javax.swing.plaf.basic.*; +import javax.swing.plaf.metal.*; + +/** + * A ComboBox that correctly renders when used in a table. + ** + ** @author Nobuo Tamemasa, codeguru.earthweb.com + */ +public class SteppedComboBox extends JComboBox { + /** The width needed to display the ComboBox's popup window. */ + protected int popupWidth; + + /** Create a ComboBox using the given model. */ + public SteppedComboBox(ComboBoxModel aModel) { + super(aModel); + + setUI(new SteppedComboBoxUI()); + + popupWidth = 0; + } +// end constructor with a ComboBoxModel + + /** Create a ComboBox using the given array. */ + public SteppedComboBox(final Object[] items) { + super(items); + + setUI(new SteppedComboBoxUI()); + + popupWidth = 0; + } +// end constructor with an Object array + + /** Create a ComboBox using the given vector. */ + public SteppedComboBox(Vector items) { + super(items); + + setUI(new SteppedComboBoxUI()); + + popupWidth = 0; + } +// end constructor with a Vector + + /** + * Assign the width of this ComboBox for displaying in a popup window. + */ + public void setPopupWidth(int width) { + popupWidth = width; + } + + /** + * Determine the size necessary to display this ComboBox in a popup window. + */ + public Dimension getPopupSize() { + Dimension size = getSize(); + + if (popupWidth < 1) { + popupWidth = size.width; + } + + return (new Dimension(popupWidth, size.height)); + } +// end method setPopupWidth + + /** The UI for this ComboBox. */ + private class SteppedComboBoxUI extends MetalComboBoxUI { + /** Draw the ComboBox. */ + protected ComboPopup createPopup() { + BasicComboPopup popup = new BasicComboPopup(comboBox) { + public void show() { + Dimension popupSize = ((SteppedComboBox) comboBox).getPopupSize(); + popupSize.setSize(popupSize.width, getPopupHeightForRowCount(comboBox.getMaximumRowCount())); + + Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, + popupSize.height); + + scroller.setMaximumSize(popupBounds.getSize()); + scroller.setPreferredSize(popupBounds.getSize()); + scroller.setMinimumSize(popupBounds.getSize()); + + list.invalidate(); + + int selectedIndex = comboBox.getSelectedIndex(); + + if (selectedIndex == -1) { + list.clearSelection(); + } + + else { + list.setSelectedIndex(selectedIndex); + } + + list.ensureIndexIsVisible(list.getSelectedIndex()); + + setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled()); + + show(comboBox, popupBounds.x, popupBounds.y); + } + }; + + popup.getAccessibleContext().setAccessibleParent(comboBox); + + return (popup); + } + } +}