Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add htmlHelp attribute #80

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Model/lib/rng/wdkModel.rng
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,12 @@
<optional>
<attribute name="attributeCategory" />
</optional>
<optional>
<element name="htmlHelp">
<ref name="IncludeExclude" />
<text />
</element>
</optional>
<zeroOrMore>
<choice>
<ref name="reporterRef" />
Expand Down
1 change: 1 addition & 0 deletions Model/src/main/java/org/gusdb/wdk/core/api/JsonKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class JsonKeys {
public static final String ICON_NAME = "iconName";
public static final String DISPLAY_TEXT = "displayText";
public static final String HELP = "help";
public static final String HTML_HELP = "htmlHelp";
public static final String DESCRIPTION = "description";
public static final String SHORT_DESCRIPTION = "shortDescription";
public static final String SUMMARY = "summary";
Expand Down
2 changes: 2 additions & 0 deletions Model/src/main/java/org/gusdb/wdk/model/ModelXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,8 @@ private static void configureAttributeFields(Digester digester) {
configureNode(digester, "*/columnAttribute", QueryColumnAttributeField.class, "addAttributeField");
configureNode(digester, "*/columnAttribute/propertyList", PropertyList.class, "addPropertyList");
configureNode(digester, "*/columnAttribute/filterRef", FilterReference.class, "addFilterReference");
configureNode(digester, "*/columnAttribute/htmlHelp", WdkModelText.class, "addHtmlHelp");
digester.addCallMethod("*/columnAttribute/htmlHelp", "setText", 0);
configureAttributeReporters(digester, "columnAttribute");

// link attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.gusdb.wdk.model.RngAnnotations.RngUndefined;
import org.gusdb.wdk.model.WdkModel;
import org.gusdb.wdk.model.WdkModelException;
import org.gusdb.wdk.model.WdkModelText;
import org.gusdb.wdk.model.columntool.ColumnTool;
import org.gusdb.wdk.model.columntool.ColumnToolBundle;
import org.gusdb.wdk.model.columntool.ColumnToolElementRefPair;
Expand All @@ -39,11 +40,14 @@
*/
public abstract class AttributeField extends Field implements Cloneable {

private List<WdkModelText> _htmlHelps = new ArrayList<WdkModelText>();

private boolean _sortable = true;
private String _align;
private boolean _nowrap;
private boolean _removable = true;
private String _categoryName;
protected String _htmlHelp;

protected AttributeFieldDataType _dataType = AttributeFieldDataType.OTHER;
protected AttributeFieldContainer _container;
Expand Down Expand Up @@ -160,6 +164,17 @@ public boolean isDerived() {
return false;
}

/**
* @return Returns the htmlHelp.
*/
public String getHtmlHelp() {
return _htmlHelp;
}

public void addHtmlHelp(WdkModelText htmlHelp) {
_htmlHelps.add(htmlHelp);
}

@RngOptional
public void setToolBundleRef(String toolBundleRef) {
_toolBundleRef = toolBundleRef;
Expand Down Expand Up @@ -195,6 +210,33 @@ public void excludeResources(String projectId) throws WdkModelException {
}
_reporterList = null;

if (_container != null) {
_htmlHelp = excludeModelText(_htmlHelps, projectId, "htmlHelp", false);
}
}

protected String excludeModelText(List<WdkModelText> texts, String projectId,
String textTag, boolean isRequired) throws WdkModelException {
String source = "The " + getClass().getSimpleName() + " " + _container.getNameForLogging() + "." + getName();
String selectedText = null;
boolean hasText = false;
for (WdkModelText text : texts) {
if (text.include(projectId)) {
if (hasText) {
throw new WdkModelException(source + " has more than one " + textTag + " tag for project " + projectId);
}
else {
selectedText = text.getText();
hasText = true;
}
}
}
// check if all texts are excluded
if (selectedText == null && isRequired) {
throw new WdkModelException(source + " does not have a " + textTag + " tag for project " + projectId);
}
texts.clear();
return selectedText;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,6 @@ public Map<String, ColumnAttributeField> getColumnAttributeFields() throws WdkMo
return leaves;
}

protected String excludeModelText(List<WdkModelText> texts, String projectId,
String textTag, boolean isRequired) throws WdkModelException {
String source = "The " + getClass().getSimpleName() + " " + _container.getNameForLogging() + "." + getName();
String selectedText = null;
boolean hasText = false;
for (WdkModelText text : texts) {
if (text.include(projectId)) {
if (hasText) {
throw new WdkModelException(source + " has more than one " + textTag + " tag for project " + projectId);
}
else {
selectedText = text.getText();
hasText = true;
}
}
}
// check if all texts are excluded
if (selectedText == null && isRequired) {
throw new WdkModelException(source + " does not have a " + textTag + " tag for project " + projectId);
}
texts.clear();
return selectedText;
}

/**
* Several kinds of fields can embed other fields in their properties. This method
* parses out the embedded fields from the text.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static JSONObject getAttributeJson(AttributeField attribute) {
.put(JsonKeys.DISPLAY_NAME, attribute.getDisplayName())
.put(JsonKeys.FORMATS, RecordClassFormatter.getAnswerFormatsJson(attribute.getReporters().values(), FieldScope.ALL))
.put(JsonKeys.HELP, attribute.getHelp())
.put(JsonKeys.HTML_HELP, attribute.getHtmlHelp())
.put(JsonKeys.IS_DISPLAYABLE, FieldScope.NON_INTERNAL.isFieldInScope(attribute))
.put(JsonKeys.IS_IN_REPORT, FieldScope.REPORT_MAKER.isFieldInScope(attribute))
.put(JsonKeys.IS_REMOVABLE, attribute.isRemovable())
Expand Down
Loading