List of usage examples for com.jgoodies.binding PresentationModel getModel
public AbstractValueModel getModel(String propertyName)
From source file:fi.smaa.jsmaa.gui.views.TechnicalParameterView.java
License:Open Source License
public JComponent buildPanel() { FormLayout layout = new FormLayout("left:pref, 3dlu, left:pref:grow", "p, 3dlu, p, 3dlu, p"); int fullWidth = 3; PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder();//from w w w. j a v a 2s .co m CellConstraints cc = new CellConstraints(); builder.addSeparator("Model technical parameters", cc.xyw(1, 1, fullWidth)); builder.addLabel("Lambda interval", cc.xy(1, 3)); Interval range = new Interval(0.5, 1.0); String msg = "Lambda must be within range "; PresentationModel<Interval> imodel = new PresentationModel<Interval>(model.getLambda()); IntervalPanel lambdaPanel = new IntervalPanel( new ConstrainedIntervalValueModel(null, model.getLambda(), imodel.getModel(Interval.PROPERTY_START), true, range, msg), new ConstrainedIntervalValueModel(null, model.getLambda(), imodel.getModel(Interval.PROPERTY_END), false, range, msg)); builder.add(lambdaPanel, cc.xy(3, 3)); builder.addLabel("Exploitation rule", cc.xy(1, 5)); builder.add(BasicComponentFactory.createCheckBox( new PresentationModel<SMAATRIModel>(model).getModel(SMAATRIModel.PROPERTY_RULE), "(optimistic if checked, pessimistic otherwise)"), cc.xy(3, 5)); return builder.getPanel(); }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JFormattedTextField createIntegerField(PresentationModel detailsModel, String fieldName, boolean useGrouping, boolean buffered) { NumberFormat nf = NumberFormat.getIntegerInstance(); nf.setGroupingUsed(useGrouping);/*from w ww.j av a2s .c o m*/ JFormattedTextField returnField; if (buffered) { returnField = BasicComponentFactory.createIntegerField(detailsModel.getBufferedModel(fieldName), nf); } else { returnField = BasicComponentFactory.createIntegerField(detailsModel.getModel(fieldName), nf); } returnField.addFocusListener( new ATFormattedTextFocusListener(returnField, "Invalid entry. This field requires an integer.")); return returnField; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
/** * Method to create a formated textfield which only accepts integers with a certain range * @param detailsModel The details model * @param fieldName The field name to bound to * @param min The minimum value allowed/*from w ww .j ava2 s. c o m*/ * @param max The maximum value allowed * @return */ public static JFormattedTextField createIntegerField(PresentationModel detailsModel, String fieldName, int min, int max) { NumberFormat nf = NumberFormat.getIntegerInstance(); JFormattedTextField returnField; returnField = BasicComponentFactory.createIntegerField(detailsModel.getModel(fieldName), nf); returnField.addFocusListener(new ATFormattedTextFocusListener(returnField, "Invalid entry. This field requires an integer between " + min + " and " + max, min, max)); return returnField; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JFormattedTextField createDoubleField(PresentationModel detailsModel, String fieldName, boolean useGrouping) { NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(useGrouping);/* w w w .j a v a 2 s. c o m*/ NumberFormatter numberFormatter = new EmptyNumberFormatter(nf, null); numberFormatter.setValueClass(Double.class); JFormattedTextField returnField = BasicComponentFactory .createFormattedTextField(detailsModel.getModel(fieldName), numberFormatter); returnField.addFocusListener( new ATFormattedTextFocusListener(returnField, "Invalid entry. This field requires a number.")); return returnField; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
/** * Method to return a text field which has been formated to accept currency * * @param detailsModel The model to bind to * @param fieldName The name of the field in the model to bind to * @param useGrouping//from www . j a va 2 s .c om * @return The textfeild formatted to accept currency */ public static JFormattedTextField createCurrencyField(PresentationModel detailsModel, String fieldName, boolean useGrouping) { NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(useGrouping); nf.setMaximumFractionDigits(2); NumberFormatter numberFormatter = new EmptyNumberFormatter(nf, null); numberFormatter.setValueClass(Double.class); JFormattedTextField returnField = BasicComponentFactory .createFormattedTextField(detailsModel.getModel(fieldName), numberFormatter); returnField.addFocusListener( new ATFormattedTextFocusListener(returnField, "Invalid entry. This field requires a number.")); return returnField; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JCheckBox createCheckBox(PresentationModel detailsModel, String fieldName, Class clazz, boolean buffered) { ATFieldInfo fieldInfo = ATFieldInfo.getFieldInfo(clazz.getName() + "." + fieldName); JCheckBox checkBox;//from w w w. j a v a 2 s . co m if (fieldInfo == null) { if (buffered) { checkBox = BasicComponentFactory.createCheckBox(detailsModel.getBufferedModel(fieldName), fieldName); } else { checkBox = BasicComponentFactory.createCheckBox(detailsModel.getModel(fieldName), fieldName); } } else { if (buffered) { checkBox = BasicComponentFactory.createCheckBox(detailsModel.getBufferedModel(fieldName), fieldInfo.getFieldLabel()); } else { checkBox = BasicComponentFactory.createCheckBox(detailsModel.getModel(fieldName), fieldInfo.getFieldLabel()); } checkBox.setToolTipText(fieldInfo.getPopupHelpText()); } checkBox.addFocusListener(new ATCheckBoxListener(checkBox)); return checkBox; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JComboBox createComboBox(PresentationModel detailsModel, String fieldName, Class clazz, Integer maxLength, boolean buffered) { ATFieldInfo fieldInfo = ATFieldInfo.getFieldInfo(clazz.getName() + "." + fieldName); Vector<LookupListItems> values = null; JComboBox returnCombobox;/* ww w. java 2 s . c o m*/ if (fieldInfo != null) { values = LookupListUtils.getLookupListValues2(fieldInfo.getLookupList()); } if (values == null) { values = new Vector<LookupListItems>(); } else { } if (fieldInfo == null) { returnCombobox = addListCellRenderer(BasicComponentFactory.createComboBox(new SelectionInList(values)), maxLength); } else { if (buffered) { ValueModel valueModel = detailsModel.getBufferedModel(fieldName); detailsModel.observeChanged(valueModel); returnCombobox = addListCellRenderer( BasicComponentFactory .createComboBox(new SelectionInList(values, ATJgoodiesBindingConverterFactory .createLookupListConverter(valueModel, fieldInfo.getLookupList()))), maxLength); } else { ValueModel valueModel = detailsModel.getModel(fieldName); detailsModel.observeChanged(valueModel); returnCombobox = addListCellRenderer( BasicComponentFactory .createComboBox(new SelectionInList(values, ATJgoodiesBindingConverterFactory .createLookupListConverter(valueModel, fieldInfo.getLookupList()))), maxLength); } } returnCombobox.addFocusListener(new ATComboBoxListener(returnCombobox)); return returnCombobox; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JComboBox createComboBoxWithConverter(PresentationModel detailsModel, String fieldName, Vector values, String listName) { return addListCellRenderer( BasicComponentFactory/* ww w. j a v a 2 s . co m*/ .createComboBox(new SelectionInList(values, ATJgoodiesBindingConverterFactory .createLookupListConverter(detailsModel.getModel(fieldName), listName))), 0); // return createComboBox(detailsModel, fieldName, values, 0); }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JComboBox createComboBox(PresentationModel detailsModel, String fieldName, Object[] values, Integer maxLength, boolean buffered) { JComboBox returnCombobox;/*from w w w . j av a 2 s . c o m*/ if (buffered) { returnCombobox = addListCellRenderer(BasicComponentFactory .createComboBox(new SelectionInList(values, detailsModel.getModel(fieldName))), maxLength); } else { returnCombobox = addListCellRenderer(BasicComponentFactory.createComboBox( new SelectionInList(values, detailsModel.getBufferedModel(fieldName))), maxLength); } returnCombobox.addFocusListener(new ATComboBoxListener(returnCombobox)); return returnCombobox; }
From source file:org.archiviststoolkit.swing.ATBasicComponentFactory.java
License:Open Source License
public static JComboBox createComboBox(PresentationModel detailsModel, String fieldName, ArrayList values, Integer maxLength) {/* w w w . ja va 2 s .co m*/ JComboBox returnCombobox = addListCellRenderer( BasicComponentFactory.createComboBox(new SelectionInList(values, detailsModel.getModel(fieldName))), maxLength); returnCombobox.addFocusListener(new ATComboBoxListener(returnCombobox)); return returnCombobox; }