Skip to content
Snippets Groups Projects
Commit 840c553b authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

Added the possibility to set received text array as value list (useful for JAVAAPI-646)

parent 00212696
No related branches found
No related tags found
No related merge requests found
...@@ -63,7 +63,7 @@ import fr.soleil.lib.project.swing.ui.OpaqueAdaptedComboBoxUI; ...@@ -63,7 +63,7 @@ import fr.soleil.lib.project.swing.ui.OpaqueAdaptedComboBoxUI;
*/ */
public class ComboBox extends DynamicRenderingComboBox<Object> implements IComboBox, IErrorNotifiableTarget { public class ComboBox extends DynamicRenderingComboBox<Object> implements IComboBox, IErrorNotifiableTarget {
private static final long serialVersionUID = -2004666899812180381L; private static final long serialVersionUID = 4840821474974790614L;
private final Collection<IComboBoxListener> comboBoxListeners; private final Collection<IComboBoxListener> comboBoxListeners;
private int horizontalAlignment; private int horizontalAlignment;
...@@ -75,6 +75,7 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo ...@@ -75,6 +75,7 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo
protected volatile boolean fieldEditable; protected volatile boolean fieldEditable;
protected volatile boolean popupDisplayable; protected volatile boolean popupDisplayable;
protected volatile boolean linkPopupVisibilityWithEditable; protected volatile boolean linkPopupVisibilityWithEditable;
protected boolean possibleValuesInTextArray;
private final boolean initialized; private final boolean initialized;
private final ErrorNotificationDelegate errorNotificationDelegate; private final ErrorNotificationDelegate errorNotificationDelegate;
...@@ -86,6 +87,7 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo ...@@ -86,6 +87,7 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo
fieldEditable = super.isEditable(); fieldEditable = super.isEditable();
popupDisplayable = true; popupDisplayable = true;
linkPopupVisibilityWithEditable = true; linkPopupVisibilityWithEditable = true;
possibleValuesInTextArray = false;
valueLock = new Object(); valueLock = new Object();
editing = false; editing = false;
// Here, we use WeakHashMap to avoid memory leaks // Here, we use WeakHashMap to avoid memory leaks
...@@ -161,6 +163,37 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo ...@@ -161,6 +163,37 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo
} }
} }
/**
* Returns whether {@link #setStringArray(String[])} method will set possible values.<br />
* <code>false</code> by default.
*
* @return Whether {@link #setStringArray(String[])} method will set possible values.
* <ul>
* <li>If <code>true</code>, {@link #setStringArray(String[])} will call
* {@link #setValueList(Object...)}.</li>
* <li>If <code>false</code>, {@link #setStringArray(String[])} will call
* {@link #setDisplayedList(String...)}.</li>
* </ul>
*/
public boolean isPossibleValuesInTextArray() {
return possibleValuesInTextArray;
}
/**
* Sets whether {@link #setStringArray(String[])} method will set possible values.
*
* @param possibleValuesInTextArray Whether {@link #setStringArray(String[])} method will set possible values.
* <ul>
* <li>If <code>true</code>, {@link #setStringArray(String[])} will call
* {@link #setValueList(Object...)}.</li>
* <li>If <code>false</code>, {@link #setStringArray(String[])} will call
* {@link #setDisplayedList(String...)}.</li>
* </ul>
*/
public void setPossibleValuesInTextArray(boolean possibleValuesInTextArray) {
this.possibleValuesInTextArray = possibleValuesInTextArray;
}
@Override @Override
public void setEditable(boolean editable) { public void setEditable(boolean editable) {
if (this.editable != editable) { if (this.editable != editable) {
...@@ -413,8 +446,12 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo ...@@ -413,8 +446,12 @@ public class ComboBox extends DynamicRenderingComboBox<Object> implements ICombo
@Override @Override
public void setStringArray(String[] value) { public void setStringArray(String[] value) {
if (isPossibleValuesInTextArray()) {
setObjectArray(value);
} else {
setDisplayedList(value); setDisplayedList(value);
} }
}
@Override @Override
public Object[] getObjectArray() { public Object[] getObjectArray() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment