Skip to content

Commit

Permalink
Adjusted max. allowed year of validity selection (#440)
Browse files Browse the repository at this point in the history
- Decreased max duration in years from 999 to 100 for validity selection spinner
- Increased max end year from 2100 to 2200 for calendar selection
- Together this fixes the reported issue and implements more realistic boundaries
  • Loading branch information
kaikramer committed Aug 18, 2023
1 parent 2b5a960 commit 5519466
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
36 changes: 7 additions & 29 deletions kse/src/org/kse/gui/crypto/JValidityPeriod.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*/
package org.kse.gui.crypto;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.Date;
Expand All @@ -34,6 +31,8 @@
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

import net.miginfocom.swing.MigLayout;

/**
* Component that allows a user to choose a validity period. User can choose an
* integral value and a period type (year, month, week, day). Choice is
Expand Down Expand Up @@ -80,25 +79,11 @@ public JValidityPeriod(int periodType) {

private void initComponents(int periodType) {
jsValue = new JSpinner();
GridBagConstraints gbc_jsValue = new GridBagConstraints();
gbc_jsValue.gridheight = 1;
gbc_jsValue.gridwidth = 1;
gbc_jsValue.gridx = 0;
gbc_jsValue.gridy = 0;
gbc_jsValue.insets = new Insets(0, 0, 0, 5);

jcbType = new JComboBox<>(new String[] { res.getString("JValidityPeriod.jcbType.years.text"),
res.getString("JValidityPeriod.jcbType.months.text"),
res.getString("JValidityPeriod.jcbType.weeks.text"),
res.getString("JValidityPeriod.jcbType.days.text"), });

GridBagConstraints gbc_jcbType = new GridBagConstraints();
gbc_jcbType.gridheight = 1;
gbc_jcbType.gridwidth = 1;
gbc_jcbType.gridx = 1;
gbc_jcbType.gridy = 0;
gbc_jcbType.insets = new Insets(0, 0, 0, 5);

switch (periodType) {
case YEARS:
jcbType.setSelectedIndex(YEARS);
Expand All @@ -122,17 +107,10 @@ private void initComponents(int periodType) {

jbApply = new JButton(res.getString("JValidityPeriod.jbApply.text"));

GridBagConstraints gbc_jbApply = new GridBagConstraints();
gbc_jbApply.gridheight = 1;
gbc_jbApply.gridwidth = 1;
gbc_jbApply.gridx = 2;
gbc_jbApply.gridy = 0;
gbc_jbApply.insets = new Insets(0, 0, 0, 0);

setLayout(new GridBagLayout());
add(jsValue, gbc_jsValue);
add(jcbType, gbc_jcbType);
add(jbApply, gbc_jbApply);
setLayout(new MigLayout("insets 0", "[]", "[]"));
add(jsValue);
add(jcbType);
add(jbApply);
}

/**
Expand All @@ -155,7 +133,7 @@ private void typeChanged(int periodType) {

switch (periodType) {
case YEARS:
model = new SpinnerNumberModel(1, 1, 999, 1);
model = new SpinnerNumberModel(1, 1, 100, 1);
break;
case MONTHS:
model = new SpinnerNumberModel(1, 1, 12, 1);
Expand Down
2 changes: 1 addition & 1 deletion kse/src/org/kse/gui/datetime/DDateTimeChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private void initComponents(Date date) {
jcbMonth = new JComboBox<>(MONTH_NAMES);
jcbMonth.addItemListener(evt -> update());

jsYear = new JSpinner(new SpinnerNumberModel(calendar.get(Calendar.YEAR), 1900, 2100, 1));
jsYear = new JSpinner(new SpinnerNumberModel(calendar.get(Calendar.YEAR), 1900, 2200, 1));
jsYear.setEditor(new JSpinner.NumberEditor(jsYear, "0000"));
jsYear.addChangeListener(evt -> update());

Expand Down

0 comments on commit 5519466

Please sign in to comment.