|
AROM-2_2_13 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Window | +--java.awt.Dialog | +--javax.swing.JDialog | +--helix.util.ui.OKCancelDialog | +--helix.util.ui.HParametersDialog
HParametersDialog is an user dialog that allows to ask inputs.
The dialog is rely on a set of Parameter object. Each Parameter represents an input
in the dialog.
A parameter is created upon a HParametersDialog and his rendered by
different way (textfield, combo box, checkbox, textfield group, radio panel).
It is possible to listen to parameters change (directly from user's change).
For each created parameter, a view (ParameterView) is created and is responsible
to renders graphically. By default, the size of the view depends of parameter
label, but it can be changed with adjustViewToInput() method.
// defines a preferences node
Preferences node = Preferences.userRoot().node( "ParametersDialogSample");
// creates an input dialog with a cancel and default button
// a "Initial" button will be created because there is a Preferences node
// it may have initial value different from application default value
HParametersDialog dialog = new HInputDialog(frame, "this is the title",
"Enter your information"
true, true, node);
// adds a first parameter that is rendered by a textfield
Parameter p1 = dialog.addTextfield("param1", "Enter your name", "", false);
p1.setValue("changed value outside");
// adds a second parameter whith a constraint to the value
Parameter p2 = dialog.addTextfield("param2", "Enter your age",
"18", new IntegerConstraint(), true);
Parameter p3 = dialog.addCheckBox("param3", "lobotomisé ?", new Boolean(true), true);
Parameter p4 = dialog.addRadioPanel("param4", "sexe",
new Object[] {"homme", "femme"}, "homme");
Parameter p5 = dialog.addComboBox("param5", "sexe",
new Object[] {"homme", "femme"}, "homme");
// start the modal dialog
dialog.start();
System.out.println("p1 = " + p1.getValue());
System.out.println("p2 = " + p2.getValue());
System.out.println("p3 = " + p3.getValue());
System.out.println("p4 = " + p4.getValue());
System.out.println("p5 = " + p5.getValue());
Field Summary |
Fields inherited from class helix.util.ui.OKCancelDialog |
PREFERENCES_POSITION_KEY, RESOURCES |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
HParametersDialog(Frame parent,
String title,
String dialogLabel,
boolean cancelEnable,
boolean resetEnable)
Creates a new modal HParametersDialog. |
|
HParametersDialog(Frame parent,
String title,
String dialogLabel,
boolean cancelEnable,
boolean resetEnable,
boolean initialEnable,
java.util.prefs.Preferences node)
Creates a new modal HParametersDialog. |
Method Summary | |
void |
actionPerformed(ActionEvent e)
|
BooleanParameter |
addCheckBox(String key,
String label,
Boolean defaultValue,
boolean isPrefSaved)
Adds a Checkbox parameter. |
Parameter |
addComboBox(String key,
String label,
Object[] values,
Object defaultValue)
Adds a choice parameter. |
ListParameter |
addList(String key,
String label,
Object[] defaultValues)
Adds a list parameter. |
Parameter |
addRadioPanel(String key,
String label,
Object[] values,
Object defaultValue)
Adds a choice parameter. |
StringParameter |
addTextfield(String key,
String label,
String defaultValue,
boolean isPrefSaved)
Adds a textfield parameter without constraint upon the input value. |
StringParameter |
addTextfield(String key,
String label,
String defaultValue,
Constraints constraint,
boolean isPrefSaved)
Adds a textfield parameter with a onstraint upon the input value. |
ListParameter |
addTextfieldsGroup(String key,
String label,
String[] defaultValues)
Adds a textfield groups parameter. |
void |
adjustViewToInput(Parameter p)
Adjust view to parameter input component. |
static Dimension |
computePreferredSize(JComponent component,
String str)
Computes the preferred with for component to display the string argument. |
Parameter |
getParameter(int index)
Returns the parameter at specified index. |
Parameter |
getParameter(String key)
Returns the parameter of specified key. |
int |
getParameterCount()
Returns the number of parameter in this input dialog. |
ParameterView |
getParameterView(String key)
Returns the parameter view of Parameter specified by key. |
boolean |
start()
Displays this dialog. |
Methods inherited from class helix.util.ui.OKCancelDialog |
addComponent, dispose, getCancelButton, getCustomButton, getCustomButtons, getOKButton, getPanel, getPreferences, hasPreferences |
Methods inherited from class javax.swing.JDialog |
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, update |
Methods inherited from class java.awt.Dialog |
addNotify, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public HParametersDialog(Frame parent, String title, String dialogLabel, boolean cancelEnable, boolean resetEnable)
parent
- parent frame (may be null)title
- dialog titledialogLabel
- the title of the input panel (may be null)cancelEnable
- indicates wether cancel button is present or notresetEnable
- indicates wether reset button is present or notpublic HParametersDialog(Frame parent, String title, String dialogLabel, boolean cancelEnable, boolean resetEnable, boolean initialEnable, java.util.prefs.Preferences node)
parent
- parent frame (may be null)title
- dialog titledialogLabel
- the title of the input panel (may be null)cancelEnable
- indicates wether cancel button is present or notresetEnable
- indicates wether reset button is present or notinitialEnable
- indicates wether initial button is present or notnode
- preferences node where to store valuesMethod Detail |
public Parameter getParameter(int index) throws IndexOutOfBoundsException
index
-
IndexOutOfBoundsException
- if invalid index.public boolean start()
public StringParameter addTextfield(String key, String label, String defaultValue, boolean isPrefSaved)
key
- label
- defaultValue
- isPrefSaved
- indicates if value of this parameter is related to user preferences
public StringParameter addTextfield(String key, String label, String defaultValue, Constraints constraint, boolean isPrefSaved) throws IllegalArgumentException
key
- label
- defaultValue
- constraint
- isPrefSaved
- indicates if value of this parameter is related to user preferences
IllegalArgumentException
public Parameter addComboBox(String key, String label, Object[] values, Object defaultValue) throws IllegalArgumentException
key
- label
- values
- defaultValue
-
IllegalArgumentException
public BooleanParameter addCheckBox(String key, String label, Boolean defaultValue, boolean isPrefSaved) throws IllegalArgumentException
key
- label
- defaultValue
- isPrefSaved
- indicates if value of this parameter is related to user preferences
IllegalArgumentException
public Parameter addRadioPanel(String key, String label, Object[] values, Object defaultValue) throws IllegalArgumentException
key
- label
- values
- defaultValue
-
IllegalArgumentException
public ListParameter addTextfieldsGroup(String key, String label, String[] defaultValues)
key
- label
- defaultValues
-
public ListParameter addList(String key, String label, Object[] defaultValues)
key
- label
- defaultValues
-
public int getParameterCount()
public Parameter getParameter(String key)
key
-
public ParameterView getParameterView(String key)
key
-
public void adjustViewToInput(Parameter p)
public static Dimension computePreferredSize(JComponent component, String str)
component
- str
-
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
actionPerformed
in class helix.util.ui.OKCancelDialog
|
AROM-2_2_13 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |