trackeditor: disable subcategory combo box when category not speedway

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8844 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 91d12138a2795a951a59f30102f99338ca48c04a
Former-commit-id: cdbc5292a29704efff3bbb363e5361f22cb75e64
This commit is contained in:
iobyte 2023-03-24 16:08:30 +00:00
parent 8f8563e44f
commit 999bbcc707
3 changed files with 49 additions and 3 deletions

View file

@ -201,7 +201,16 @@ public class NewProjectDialog extends JDialog
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
if ("speedway".equals(trackCategoryComboBox.getSelectedItem()))
{
trackSubcategoryComboBox.setSelectedItem("none");
trackSubcategoryComboBox.setEnabled(true);
}
else
{
trackSubcategoryComboBox.setSelectedItem("none");
trackSubcategoryComboBox.setEnabled(false);
}
}
});
}
@ -219,6 +228,7 @@ public class NewProjectDialog extends JDialog
String[] items =
{"none", "short", "long"};
trackSubcategoryComboBox = new JComboBox<String>(items);
trackSubcategoryComboBox.setEnabled(false);
trackSubcategoryComboBox.setSelectedItem("none");
trackSubcategoryComboBox.setBounds(145, 64, 170, 23);
trackSubcategoryComboBox.addActionListener(new java.awt.event.ActionListener()

View file

@ -56,7 +56,8 @@ public class GeneralProperties extends PropertyPanel
private JLabel descriptionLabel = new JLabel();
private JTextField descriptionTextField = new JTextField();
private final String sep = System.getProperty("file.separator");
private String lastSubcategory = null;
private final String sep = System.getProperty("file.separator");
/**
*
@ -111,6 +112,29 @@ public class GeneralProperties extends PropertyPanel
categoryComboBox = new JComboBox<String>(items);
categoryComboBox.setBounds(130, 37, 125, 23);
categoryComboBox.setSelectedItem(getEditorFrame().getTrackData().getHeader().getCategory());
categoryComboBox.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
if ("speedway".equals(categoryComboBox.getSelectedItem()))
{
if (lastSubcategory != null)
{
subcategoryComboBox.setSelectedItem(lastSubcategory);
}
else
{
subcategoryComboBox.setSelectedItem("none");
}
subcategoryComboBox.setEnabled(true);
}
else
{
subcategoryComboBox.setEnabled(false);
subcategoryComboBox.setSelectedItem("none");
}
}
});
}
return categoryComboBox;
}
@ -131,6 +155,18 @@ public class GeneralProperties extends PropertyPanel
if (subcategory == null)
subcategory = "none";
subcategoryComboBox.setSelectedItem(subcategory);
lastSubcategory = new String(subcategory);
subcategoryComboBox.setEnabled("speedway".equals(getEditorFrame().getTrackData().getHeader().getCategory()));
subcategoryComboBox.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent e)
{
if (subcategoryComboBox.isEnabled())
{
lastSubcategory = new String(subcategoryComboBox.getSelectedItem().toString());
}
}
});
}
return subcategoryComboBox;
}

View file

@ -34,7 +34,7 @@ public class Properties
private static Properties instance = new Properties();
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
public final String title = "sd2-trackeditor";
public final String version = "1.1.3";
public final String version = "1.1.4";
private String path;
private double imageScale = 1;