All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fcrepo.client.console.DateTimeInputPanel Maven / Gradle / Ivy

There is a newer version: 3.8.1
Show newest version
/* The contents of this file are subject to the license and copyright terms
 * detailed in the license directory at the root of the source tree (also 
 * available online at http://fedora-commons.org/license/).
 */
package org.fcrepo.client.console;

import java.awt.BorderLayout;

import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import org.fcrepo.utilities.DateUtility;


/**
 * Creates an input panel for entering datetime stamps.
 * 
 * The input format must be of the form:
 * YYYY-MM-DDTHH:mm:ss, where:
 * 
    *
  • YYYY - 4 digit year
  • *
  • MM - 2 digit month
  • *
  • DD - 2 digit day of month
  • *
  • hh - 2 digit hour of day using 24 hour clock
  • *
  • mm - 2 digit minutes of the hour
  • *
  • ss - 2 digit seconds of the minute
  • *
* * @author Ross Wayland */ public class DateTimeInputPanel extends InputPanel { private static final long serialVersionUID = 1L; private final JRadioButton m_nullRadioButton; private final JTextField m_textField; public DateTimeInputPanel() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); JPanel nullPanel = new JPanel(); nullPanel.setLayout(new BorderLayout()); m_nullRadioButton = new JRadioButton("Use null"); m_nullRadioButton.setSelected(true); nullPanel.add(m_nullRadioButton, BorderLayout.WEST); add(nullPanel); JPanel textPanel = new JPanel(); textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS)); JRadioButton textRadioButton = new JRadioButton("Use text: "); textRadioButton.setSelected(false); textPanel.add(textRadioButton); m_textField = new JTextField(10); textPanel.add(m_textField); add(textPanel); ButtonGroup g = new ButtonGroup(); g.add(m_nullRadioButton); g.add(textRadioButton); } @Override public Object getValue() { if (m_nullRadioButton.isSelected()) { return null; } else { return DateUtility.convertStringToDate(m_textField.getText()); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy