Skip to content

Commit

Permalink
Simplification and i18n of book parameters handling
Browse files Browse the repository at this point in the history
  • Loading branch information
hbitteur committed Nov 12, 2023
1 parent 4409646 commit b08ae85
Show file tree
Hide file tree
Showing 15 changed files with 549 additions and 611 deletions.
687 changes: 302 additions & 385 deletions src/main/org/audiveris/omr/score/ui/BookParameters.java

Large diffs are not rendered by default.

22 changes: 7 additions & 15 deletions src/main/org/audiveris/omr/score/ui/BooleanPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
// </editor-fold>
package org.audiveris.omr.score.ui;

import org.audiveris.omr.util.param.Param;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -37,8 +35,8 @@
* @param <T> specific category
* @author Hervé Bitteur
*/
public class BooleanPane<T extends Enum<T>>
extends XactPane<T, Boolean>
public class BooleanPane
extends XactPane<Boolean>
{
//~ Static fields/initializers -----------------------------------------------------------------

Expand All @@ -54,19 +52,13 @@ public class BooleanPane<T extends Enum<T>>
/**
* Creates a new <code>BooleanPane</code> object.
*
* @param tag unique in scope
* @param title pane title string
* @param parent parent pane if any
* @param tip data description
* @param model underlying data model (cannot be null)
* @param title pane title string
* @param tip data description
*/
public BooleanPane (T tag,
String title,
BooleanPane<T> parent,
String tip,
Param<Boolean> model)
public BooleanPane (String title,
String tip)
{
super(tag, title, parent, model);
super(title);

if ((tip != null) && !tip.isBlank()) {
boolBox.setToolTipText(tip);
Expand Down
25 changes: 8 additions & 17 deletions src/main/org/audiveris/omr/score/ui/EnumPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
// </editor-fold>
package org.audiveris.omr.score.ui;

import org.audiveris.omr.util.param.Param;

import org.jdesktop.application.ResourceMap;

import com.jgoodies.forms.builder.PanelBuilder;
Expand All @@ -42,8 +40,8 @@
* @param <E> the enum to handle
* @author Hervé Bitteur
*/
public class EnumPane<T extends Enum<T>, E extends Enum<E>>
extends XactPane<T, E>
public class EnumPane<T, E extends Enum<E>>
extends XactPane<E>
{
//~ Instance fields ----------------------------------------------------------------------------

Expand All @@ -57,25 +55,18 @@ public class EnumPane<T extends Enum<T>, E extends Enum<E>>

/**
* Creates an <code>EnumPane</code> object.
* <p>
* Model and Parent to be assigned later.
*
* @param tag unique in scope
* @param values value array of the enum
* @param parentPanel parent panel if any
* @param model underlying data model (cannot be null)
* @param resources UI resources
* @param tag unique in scope
* @param values value array of the enum
* @param resources UI resources
*/
@SuppressWarnings("unchecked")
public EnumPane (T tag,
E[] values,
ScopedPanel<T> parentPanel,
Param<E> model,
ResourceMap resources)
{
super(
tag,
resources.getString(tag + "Pane.title"),
(parentPanel != null) ? parentPanel.getPane(tag) : null,
model);
super(resources.getString(tag + "Pane.title"));

title.setToolTipText(resources.getString(tag + "Pane.toolTipText"));

Expand Down
23 changes: 8 additions & 15 deletions src/main/org/audiveris/omr/score/ui/IntegerPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package org.audiveris.omr.score.ui;

import org.audiveris.omr.ui.field.LIntegerField;
import org.audiveris.omr.util.param.Param;

import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.layout.CellConstraints;
Expand All @@ -33,8 +32,8 @@
* @param <T> specific category
* @author Hervé Bitteur
*/
public class IntegerPane<T extends Enum<T>>
extends XactPane<T, Integer>
public class IntegerPane
extends XactPane<Integer>
{
//~ Instance fields ----------------------------------------------------------------------------

Expand All @@ -46,21 +45,15 @@ public class IntegerPane<T extends Enum<T>>
/**
* Creates a new <code>IntegerPane</code> object.
*
* @param tag unique in scope
* @param title pane title string
* @param parent parent pane if any
* @param text data text
* @param tip data description
* @param model underlying data model (cannot be null)
* @param title pane title string
* @param text data text
* @param tip data description
*/
public IntegerPane (T tag,
String title,
IntegerPane<T> parent,
public IntegerPane (String title,
String text,
String tip,
Param<Integer> model)
String tip)
{
super(tag, title, parent, model);
super(title);
data = new LIntegerField(true, text, tip);
}

Expand Down
9 changes: 3 additions & 6 deletions src/main/org/audiveris/omr/score/ui/IntegerSpinPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package org.audiveris.omr.score.ui;

import org.audiveris.omr.ui.field.SpinnerUtil;
import org.audiveris.omr.util.param.Param;

import org.jdesktop.application.ResourceMap;

Expand All @@ -42,8 +41,8 @@
* @param <T> specific category
* @author Hervé Bitteur
*/
public class IntegerSpinPane<T extends Enum<T>>
extends XactPane<T, Integer>
public class IntegerSpinPane<T>
extends XactPane<Integer>
{
//~ Instance fields ----------------------------------------------------------------------------

Expand All @@ -53,11 +52,9 @@ public class IntegerSpinPane<T extends Enum<T>>

public IntegerSpinPane (T tag,
SpinData spinData,
IntegerSpinPane<T> parent,
Param<Integer> model,
ResourceMap resources)
{
super(tag, resources.getString(tag + "Pane.title"), parent, model);
super(resources.getString(tag + "Pane.title"));
title.setToolTipText(resources.getString(tag + "Pane.toolTipText"));
this.spinData = spinData;
}
Expand Down
32 changes: 16 additions & 16 deletions src/main/org/audiveris/omr/score/ui/SheetScaling.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------------------------//
// //
// S h e e t P a r a m e t e r s //
// S h e e t S c a l i n g //
// //
//------------------------------------------------------------------------------------------------//
// <editor-fold defaultstate="collapsed" desc="hdr">
Expand Down Expand Up @@ -62,7 +62,7 @@ public class SheetScaling
//~ Instance fields ----------------------------------------------------------------------------

/** The swing component of this entity. */
private final ScopedPanel<Item> scopedPanel;
private final TopicsPanel topicsPanel;

/** The related sheet. */
private final Sheet sheet;
Expand Down Expand Up @@ -97,15 +97,17 @@ public SheetScaling (Sheet sheet)
ip = new ScalingParam(key);
}

topic.add(new ScaledPane(key, null, ip));
final ScaledPane scaledPane = new ScaledPane(key);
scaledPane.setModel(ip);
topic.add(scaledPane);
}

scopedPanel = new ScopedPanel<>(
topicsPanel = new TopicsPanel(
"Sheet settings",
Arrays.asList(topic),
resources,
colSpec,
1,
resources);
1);

initialDisplay();
}
Expand All @@ -126,7 +128,7 @@ public boolean commit ()
// Commit all specific values, if any, to their model object
boolean modified = false;

for (XactPane pane : scopedPanel.getPanes()) {
for (XactPane pane : topicsPanel.getPanes()) {
modified |= pane.commit();
}

Expand All @@ -151,17 +153,17 @@ public boolean commit ()
*
* @return the concrete component
*/
public ScopedPanel getComponent ()
public TopicsPanel getComponent ()
{
return scopedPanel;
return topicsPanel;
}

//----------//
// getTitle //
//----------//
public String getTitle ()
{
final String pattern = resources.getString("SheetParameters.titlePattern");
final String pattern = resources.getString("SheetScaling.titlePattern");

return MessageFormat.format(pattern, sheet.getId());
}
Expand All @@ -171,7 +173,7 @@ public String getTitle ()
//----------------//
private void initialDisplay ()
{
for (XactPane pane : scopedPanel.getPanes()) {
for (XactPane pane : topicsPanel.getPanes()) {
pane.actionPerformed(null);
}
}
Expand All @@ -195,16 +197,14 @@ private void populateScalings ()
* Pane to define a scaled parameter.
*/
private static class ScaledPane
extends IntegerPane<Scale.Item>
extends IntegerPane
{
/** The scale item handled by this ScaledPane. */
final Scale.Item key;

ScaledPane (Scale.Item key,
ScaledPane parent,
ScalingParam model)
ScaledPane (Scale.Item key)
{
super(key, description(key), parent, "", null, model);
super(description(key), "", null);
this.key = key;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------------------------------------------//
// //
// S c o p e d P a n e l //
// T o p i c s P a n e l //
// //
//------------------------------------------------------------------------------------------------//
// <editor-fold defaultstate="collapsed" desc="hdr">
Expand Down Expand Up @@ -36,12 +36,12 @@
import javax.swing.SwingConstants;

/**
* Class <code>ScopedPanel</code> is a panel corresponding to a given scope tab.
* Class <code>TopicsPanel</code> is a panel where the individual components (panes) are
* gathered by topics.
*
* @param <T> tagging used within the panel
* @author Hervé Bitteur
*/
public class ScopedPanel<T extends Enum<T>>
public class TopicsPanel
extends Panel
{
//~ Static fields/initializers -----------------------------------------------------------------
Expand All @@ -62,33 +62,33 @@ public class ScopedPanel<T extends Enum<T>>
//~ Constructors -------------------------------------------------------------------------------

/**
* Creates a new <code>ScopedPanel</code> object, using default colSpec.
* Creates a new <code>TopicsPanel</code> object, using default colSpec.
*
* @param name panel name
* @param topics contained data topics
* @param resources UI resources
*/
public ScopedPanel (String name,
public TopicsPanel (String name,
List<XactTopic> topics,
ResourceMap resources)
{
this(name, topics, colSpec, 3, resources);
this(name, topics, resources, colSpec, 3);
}

/**
* Creates a new <code>ScopedPanel</code> object.
* Creates a new <code>TopicsPanel</code> object, with a provided columns specification.
*
* @param name panel name
* @param topics contained data topics
* @param resources UI resources
* @param colSpec specific columns specification
* @param titleWidth number of cells for title, either 1 (just Item1) or 3 (Ite
* @param resources UI resources
*/
public ScopedPanel (String name,
public TopicsPanel (String name,
List<XactTopic> topics,
ResourceMap resources,
String colSpec,
int titleWidth,
ResourceMap resources)
int titleWidth)
{
setName(name);
this.resources = resources;
Expand Down Expand Up @@ -153,24 +153,6 @@ private void defineLayout (String colSpec,
}
}

/**
* Report the contained pane for the desired tag.
*
* @param tag desired tag
* @return the pane found or null
*/
public XactPane getPane (T tag)
{
for (XactTopic topic : topics) {
for (XactPane pane : topic) {
if (pane.tag == tag)
return pane;
}
}

return null;
}

/**
* Report the contained data panes.
*
Expand All @@ -189,7 +171,7 @@ public List<XactPane> getPanes ()

private String textOf (String name)
{
// Priority given to text in resources file if any
// Priority is given to text in resources file if any
final String desc = resources.getString(name + ".text");

return (desc != null) ? desc : name;
Expand Down
Loading

0 comments on commit b08ae85

Please sign in to comment.