private final List<String> subTypes;
/*
- * if selected, colour settings are also applied to any
- * feature sub-types in the Sequence Ontology
+ * if true, filter or colour settings are also applied to
+ * any feature sub-types in the Sequence Ontology
*/
- private JCheckBox applyToSubtypes;
+ private boolean applyFiltersToSubtypes;
+
+ private boolean applyColourToSubtypes;
/**
* Constructor
*/
if (!subTypes.isEmpty())
{
- colourByPanel.add(initSubtypesPanel());
+ applyColourToSubtypes = false;
+ colourByPanel.add(initSubtypesPanel(false));
}
/*
*
* @return
*/
- protected JPanel initSubtypesPanel()
+ protected JPanel initSubtypesPanel(final boolean forFilters)
{
JPanel toSubtypes = new JPanel(new FlowLayout(FlowLayout.LEFT));
toSubtypes.setBackground(Color.WHITE);
- applyToSubtypes = new JCheckBox(
- "Apply changes also to sub-types of " + featureType);
- applyToSubtypes.setToolTipText(getSubtypesTooltip());
- toSubtypes.add(applyToSubtypes);
+ JCheckBox applyToSubtypesCB = new JCheckBox(MessageManager
+ .formatMessage("label.apply_to_subtypes", featureType));
+ applyToSubtypesCB.setToolTipText(getSubtypesTooltip());
+ applyToSubtypesCB.addActionListener(new ActionListener()
+ {
+ /*
+ * reset and reapply settings on toggle of checkbox
+ */
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (forFilters)
+ {
+ applyFiltersToSubtypes = applyToSubtypesCB.isSelected();
+ restoreOriginalFilters();
+ filtersChanged();
+ }
+ else
+ {
+ applyColourToSubtypes = applyToSubtypesCB.isSelected();
+ restoreOriginalColours();
+ colourChanged(true);
+ }
+ }
+ });
+ toSubtypes.add(applyToSubtypesCB);
+
return toSubtypes;
}
* save the colour, and set on subtypes if selected
*/
fr.setColour(featureType, acg);
- if (applyToSubtypes.isSelected())
+ if (applyColourToSubtypes)
{
for (String child : subTypes)
{
@Override
public void cancelPressed()
{
- for (Entry<String, FeatureColourI> entry : originalColours.entrySet())
- {
- fr.setColour(entry.getKey(), entry.getValue());
- }
+ restoreOriginalColours();
+ restoreOriginalFilters();
+ ap.paintAlignment(true, true);
+ }
+
+ protected void restoreOriginalFilters()
+ {
for (Entry<String, FeatureMatcherSetI> entry : originalFilters
.entrySet())
{
fr.setFeatureFilter(entry.getKey(), entry.getValue());
}
+ }
- ap.paintAlignment(true, true);
+ protected void restoreOriginalColours()
+ {
+ for (Entry<String, FeatureColourI> entry : originalColours.entrySet())
+ {
+ fr.setColour(entry.getKey(), entry.getValue());
+ }
}
/**
*/
if (!subTypes.isEmpty())
{
- outerPanel.add(initSubtypesPanel());
+ applyFiltersToSubtypes = false;
+ outerPanel.add(initSubtypesPanel(true));
}
JPanel filtersPanel = new JPanel();
protected String getSubtypesTooltip()
{
StringBuilder sb = new StringBuilder(20 * subTypes.size());
- sb.append("Apply settings also to" + ":"); // todo i18n
+ sb.append(MessageManager.getString("label.apply_also_to"));
for (String child : subTypes)
{
sb.append("<br>").append(child);
* (note this might now be an empty filter with no conditions)
*/
fr.setFeatureFilter(featureType, combined.isEmpty() ? null : combined);
- if (applyToSubtypes.isSelected())
+ if (applyFiltersToSubtypes)
{
for (String child : subTypes)
{