Interface ReferenceEditorValue
- All Superinterfaces:
EditorValue<TargetReference>
Tagging interface for an
EditorValue
representing the FirstSpirit input component FS_REFERENCE.- Since:
- 4.2
- Example:
- How to get and store references
import de.espirit.firstspirit.access.editor.*; import de.espirit.firstspirit.access.Language; import de.espirit.firstspirit.access.editor.value.InvalidValueException; import de.espirit.firstspirit.access.editor.value.TargetReference; import de.espirit.firstspirit.access.editor.value.TargetReference.TargetReferences; import de.espirit.firstspirit.access.store.IDProvider; import de.espirit.firstspirit.access.store.pagestore.Section; import org.jetbrains.annotations.Nullable; /** * Example how to get and store references from/to the ReferenceEditorValue * * @since 4.2.34 */ public class ReferenceEditorValueExample { /** * Stores the given IDProvider in the reference editor for the specified language * * @since 4.2.34 */ public ReferenceEditorValue setValueForLanguage(final ReferenceEditorValue editor, final IDProvider idProvider, final Language language) throws InvalidValueException { // 1. check if language is provided if editor is language dependent ("useLanguages='yes'" in gom syntax) if (editor.isLanguageDependent() && (language == null)) { throw new NullPointerException("Language is missing!"); } // 2. create a new @{link TargetReference} using the TargetReferences factory. final TargetReference targetReference = TargetReferences.newInstance(language, idProvider, ""); // 3. store this instance in the editor value editor.set(language, targetReference); // 4. and return the instance for further processing return editor; } /** * Gets the language specific TargetReference from the given editor. * * @since 4.2.34 */ public TargetReference getValueForLanguage(final ReferenceEditorValue editor, final Language language) { // 1. get the stored instance in the editor value final TargetReference targetReference = editor.get(language); // 2. and return the reference container for further processing return targetReference; } /** * Gets the language specific IDProvider from the given editor. * * @since 4.2.34 */ @Nullable public IDProvider getReferenceForLanguage(final ReferenceEditorValue editor, final Language language) { // 1. get the {@link TargetReference } container. final TargetReference targetReference = editor.get(language); // 2. get the referenced {@link IDProvider } element. IDProvider idProvider = null; if (targetReference != null) { idProvider = targetReference.get(); } // 3. and return the instance for further processing return idProvider; } /** * Sets the given section name in the target reference and loads the section. * * @since 4.2.34 */ @Nullable public Section<?> setSectionForValue(final TargetReference targetReference, final String sectionName) { // 1. set an new section to reference. the section will be loaded by it's name. targetReference.setSectionName(sectionName); // 2. return the loaded section instance for further processing return targetReference.getSection(); } }
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Key to store the referenced target.static final String
Key to store the symbolic remote project name.static final String
Key to store the name of a section referenced to.static final String
Key to store the reference's UID.static final String
Key to store the reference's UID type.Fields inherited from interface de.espirit.firstspirit.access.editor.EditorValue
COPY_PRESET, DEFAULT, DELETE, FALLBACK_LANGUAGE, LANG_KEY, SOLE_LANGUAGE, UNSUPPORTED
-
Method Summary
Modifier and TypeMethodDescriptionGet an emptyTargetReference
.getForm()
Get the GuiXml formular definiotn values.boolean
isEmpty
(TargetReference target) Test whether aTargetReference
is empty.Methods inherited from interface de.espirit.firstspirit.access.editor.EditorValue
addEditorValueListener, assimilate, beSet, clear, clear, findReferences, get, getContentType, getDataValue, getEditorLanguages, getGuiXml, getMatches, getSearchableString, getTagName, getValueType, initialize, isDefault, isLanguageDependent, isSet, isSet, isValid, removeEditorValueListener, set, setTagName, setValueNode, toXml, toXml, validate
-
Field Details
-
REF_KEY
Key to store the referenced target.- Since:
- 4.2.24
- See Also:
-
UID_KEY
Key to store the reference's UID.- Since:
- 4.2.24
- See Also:
-
UID_TYPE_KEY
Key to store the reference's UID type.- Since:
- 4.2.24
- See Also:
-
REMOTE_NAME_KEY
Key to store the symbolic remote project name.- Since:
- 4.2.24
- See Also:
-
SECTION_KEY
Key to store the name of a section referenced to.- Since:
- 4.2.24
- See Also:
-
-
Method Details
-
getForm
GomReference getForm()Get the GuiXml formular definiotn values. Covariant return of concrete form container.- Specified by:
getForm
in interfaceEditorValue<TargetReference>
- Returns:
- The form definition.
- Since:
- 4.2
-
getEmpty
Get an emptyTargetReference
.- Parameters:
language
- A Language- Returns:
- an empty TargetReference
- Since:
- 4.2
-
isEmpty
Test whether aTargetReference
is empty. aTargetReference
is empty if the encapsulated element isnull
. element is always a type ofIDProvider
.- Specified by:
isEmpty
in interfaceEditorValue<TargetReference>
- Parameters:
target
- theTargetReference
to test.- Returns:
true
if empty, otherwisefalse
- Since:
- 4.2.24
-