added more Attributes getter and setter with descriptions and corresponding Enums(unfinished)

This commit is contained in:
LegitCheetah 2024-03-13 18:31:16 +01:00
parent 2d232a4c71
commit 6237f1aa5f
6 changed files with 235 additions and 19 deletions

View File

@ -8,6 +8,9 @@ public class ModuleComment extends ModuleGeneric {
@Override @Override
public StringBuilder build() { public StringBuilder build() {
StringBuilder output = new StringBuilder(); StringBuilder output = new StringBuilder();
if (!singleLine){
output.append("\n");
}
output output
.append("<!--") .append("<!--")
.append(comment) .append(comment)

View File

@ -1,7 +1,9 @@
package main.htmlModules; package main.htmlModules;
import main.HtmlTagsEnum; import main.HtmlTagsEnum;
import main.htmlModules.attributeEnums.GlobalAttributeDirEnum;
import main.htmlModules.attributeEnums.GlobalAttributeDraggableEnum; import main.htmlModules.attributeEnums.GlobalAttributeDraggableEnum;
import main.htmlModules.attributeEnums.GlobalAttributeEnterkeyhintEnum;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -12,16 +14,18 @@ public class ModuleGeneric {
protected HtmlTagsEnum tag = null; protected HtmlTagsEnum tag = null;
protected String comment; protected String comment;
protected List<ModuleGeneric> content = new ArrayList<>(); protected List<ModuleGeneric> content = new ArrayList<>();
protected String contentText;
protected boolean singleLine;
//Global Attributes------------------------------------------------------------------------------------------------- //Global Attributes-------------------------------------------------------------------------------------------------
protected char globalAttributeAccesskey; protected char globalAttributeAccesskey;
protected String globalAttributeClass; protected String globalAttributeClass;
protected Boolean globalAttributeContenteditable; protected Boolean globalAttributeContenteditable;
protected String globalAttributeDataPrefix; //used with dataValue protected String globalAttributeDataName; //used with dataValue
protected String globalAttributeDataValue; //used with dataPrefix protected String globalAttributeDataValue; //used with dataPrefix
protected String globalAttributeDir; protected GlobalAttributeDirEnum globalAttributeDir;
protected GlobalAttributeDraggableEnum globalAttributeDraggable; protected GlobalAttributeDraggableEnum globalAttributeDraggable;
protected String globalAttributeEnterkeyhint; protected GlobalAttributeEnterkeyhintEnum globalAttributeEnterkeyhint;
protected boolean globalAttributeHidden; protected boolean globalAttributeHidden;
protected String globalAttributeId; protected String globalAttributeId;
protected boolean globalAttributeInert; protected boolean globalAttributeInert;
@ -404,8 +408,18 @@ public class ModuleGeneric {
} }
} }
if (contentText != null){
if (!singleLine){
buildString.append("\n");
}
buildString.append(contentText);
}
if (!singleLine){
buildString.append("\n");
}
buildString buildString
.append("\n</") .append("</")
.append(tag.getTag()) .append(tag.getTag())
.append(">"); .append(">");
return buildString; return buildString;

View File

@ -1,25 +1,45 @@
package main.htmlModules; package main.htmlModules;
import main.HtmlTagsEnum; import main.HtmlTagsEnum;
import main.htmlModules.attributeEnums.GlobalAttributeDirEnum;
import main.htmlModules.attributeEnums.GlobalAttributeDraggableEnum; import main.htmlModules.attributeEnums.GlobalAttributeDraggableEnum;
import main.htmlModules.attributeEnums.GlobalAttributeEnterkeyhintEnum;
public class ModuleTag extends ModuleGeneric { public class ModuleTag extends ModuleGeneric {
public ModuleTag(){ public ModuleTag(){
} }
/**
* Adds a module into current module's content.
* @param module A new module
*/
public void addModule(ModuleGeneric module){ public void addModule(ModuleGeneric module){
content.add(module); content.add(module);
} }
/**
* Adds a Comment into current modules content.
* @param comment String of comment
*/
public void addComment(String comment){ public void addComment(String comment){
content.add(new ModuleComment(comment)); content.add(new ModuleComment(comment));
} }
/**
* Sets the Tag for the current module.
* @param tag sets Tag of the current module
* @see HtmlTagsEnum HtmlTagsEnum -> For list of possible Tags
*/
public void setTag(HtmlTagsEnum tag) { public void setTag(HtmlTagsEnum tag) {
this.tag = tag; this.tag = tag;
} }
/**
* Gets the Tag from the current module
* @return gets Tag of current module
* @see HtmlTagsEnum HtmlTagsEnum -> For list of possible Tags
*/
public HtmlTagsEnum getTag() { public HtmlTagsEnum getTag() {
return tag; return tag;
} }
@ -42,69 +62,214 @@ public class ModuleTag extends ModuleGeneric {
} }
/** /**
* *The Class-Attribute is used to assign a classname to be used with either StyleSheets or JavaScript.
* @param classAttribute * @param classAttribute String which should be used with StyleSheets or JS.
*/ */
public void setClassAttribute(String classAttribute){ public void setClassAttribute(String classAttribute){
this.globalAttributeClass = classAttribute; this.globalAttributeClass = classAttribute;
} }
/**
* The Class-Attribute is used to assign a classname to be used with either StyleSheets or JavaScript.
* @return String which is set to be used with StyleSheets or JS.
*/
public String getClassAttribute(){ public String getClassAttribute(){
return globalAttributeClass; return globalAttributeClass;
} }
/**
* The Contenteditable-Attribute specifies of an element is editable or not.
* @param contenteditableAttribute <br>
* "true" -> editable <br>
* "false" -> not editable <br>
* "null" or not set at all -> inherits state from parent (default false)
*/
public void setContenteditableAttribute(Boolean contenteditableAttribute){ public void setContenteditableAttribute(Boolean contenteditableAttribute){
this.globalAttributeContenteditable = contenteditableAttribute; this.globalAttributeContenteditable = contenteditableAttribute;
} }
/**
* The Contenteditable-Attribute specifies of an element is editable or not.
* @return "true" -> editable <br>
* "false" -> not editable <br>
* "null" -> not set at all, inherits state from parent (default false)
*/
public Boolean getContenteditableAttribute(){ public Boolean getContenteditableAttribute(){
return globalAttributeContenteditable; return globalAttributeContenteditable;
} }
public void setDataPrefixAttribute(String dataPrefixAttribute){ /**
this.globalAttributeDataPrefix = dataPrefixAttribute; * The Data-Attribute is used to embed custom data without the need of a database call. <br>
* Consists out of a Name and a Value.
* @param dataNameAttribute Name of set data after the prefix "data-*"
* @param dataValueAttribute Value of set data
* @see #setDataNameAttribute(String) setDataNameAttribute(String) -> For setting Name only
* @see #setDataValueAttribute(String) setDataValueAttribute(String) -> For setting Value only
*/
public void setDataAttribute(String dataNameAttribute, String dataValueAttribute){
setDataNameAttribute(dataNameAttribute);
setDataValueAttribute(dataValueAttribute);
} }
public String getDataPrefixAttribute(){ /**
return globalAttributeDataPrefix; * The Data-Attribute is used to embed custom data without the need of a database call. <br>
* Consists out of a Name and a Value.
* @return The full attribute String with Prefix, Name and Value (data-<name>="<value>")
* @see #getDataNameAttribute() getDataNameAttribute() -> For getting Name only
* @see #getDataValueAttribute() getDataValueAttribute() -> For getting Value only
*/
public String getDataAttribute(){
return "data-"+globalAttributeDataName+"=\""+globalAttributeDataValue+"\"";
} }
/**
* The Data-Attribute is used to embed custom data without the need of a database call. <br>
* Consists out of a Name and a Value.
* @param dataNameAttribute Name of data after the prefix "data-*"
* @see #setDataAttribute(String, String) setDataAttribute(String, String) -> For setting Name and Value
* @see #setDataValueAttribute(String) setDataValueAttribute(String) -> For setting Value only
*/
public void setDataNameAttribute(String dataNameAttribute){
this.globalAttributeDataName = dataNameAttribute;
}
/**
* The Data-Attribute is used to embed custom data without the need of a database call. <br>
* Consists out of a Name and a Value.
* @return Name of set data after the prefix "data-*"
* @see #getDataAttribute() getDataAttribute() -> For getting the whole String
* @see #getDataValueAttribute() getDataValueAttribute() -> For getting Value only
*/
public String getDataNameAttribute(){
return globalAttributeDataName;
}
/**
* The Data-Attribute is used to embed custom data without the need of a database call. <br>
* Consists out of a Name and a Value.
* @param dataValueAttribute Value of data
* @see #setDataAttribute(String, String) setDataAttribute(String, String) -> For setting Name and Value
* @see #setDataNameAttribute(String) setDataNameAttribute(String) -> For setting Value only
*/
public void setDataValueAttribute(String dataValueAttribute){ public void setDataValueAttribute(String dataValueAttribute){
this.globalAttributeDataValue = dataValueAttribute; this.globalAttributeDataValue = dataValueAttribute;
} }
/**
* The Data-Attribute is used to embed custom data without the need of a database call. <br>
* Consists out of a Name and a Value.
* @return Value of set data
* @see #getDataAttribute() getDataAttribute() -> For getting the whole String
* @see #getDataNameAttribute() getDataNameAttribute() -> For getting Name only
*/
public String getDataValueAttribute(){ public String getDataValueAttribute(){
return globalAttributeDataValue; return globalAttributeDataValue;
} }
public void setDirAttribute(String dirAttribute){ /**
* The Dir-Attribute specifies the direction of text.
* @param dirAttribute <br>
* "ltr" -> left to right <br>
* "rtl" -> right to left <br>
* "auto" -> if unknown (lets the browser figure it out) <br>
* "null" -> not set
* @see GlobalAttributeDirEnum
*/
public void setDirAttribute(GlobalAttributeDirEnum dirAttribute){
this.globalAttributeDir = dirAttribute; this.globalAttributeDir = dirAttribute;
} }
public String getDirAttribute(){ /**
* The Dir-Attribute specifies the direction of text.
* @return "ltr" -> left to right <br>
* "rtl" -> right to left <br>
* "auto" -> if unknown (lets the browser figure it out)<br>
* "null" -> not set
* @see GlobalAttributeDirEnum
*/
public GlobalAttributeDirEnum getDirAttribute(){
return globalAttributeDir; return globalAttributeDir;
} }
/**
* The Draggable-Attribute specifies if an element is draggable. <br>
* Often used for Drag-and-Drop operations. <br>
* Links and images are draggable by default.
* @param draggableAttribute <br>
* "true" -> draggable <br>
* "false" -> not draggable <br>
* "auto" -> browser default <br>
* "null" -> not set
* @see GlobalAttributeDraggableEnum
*/
public void setDraggableAttribute(GlobalAttributeDraggableEnum draggableAttribute){ public void setDraggableAttribute(GlobalAttributeDraggableEnum draggableAttribute){
this.globalAttributeDraggable = draggableAttribute; this.globalAttributeDraggable = draggableAttribute;
} }
/**
* The Draggable-Attribute specifies if an element is draggable. <br>
* Often used for Drag-and-Drop operations. <br>
* Links and images are draggable by default.
* @return "true" -> draggable <br>
* "false" -> not draggable <br>
* "auto" -> browser default <br>
* "null" -> not set
* @see GlobalAttributeDraggableEnum
*/
public GlobalAttributeDraggableEnum getDraggableAttribute(){ public GlobalAttributeDraggableEnum getDraggableAttribute(){
return globalAttributeDraggable; return globalAttributeDraggable;
} }
public void setEnterkeyhintAttribute(String enterkeyhintAttribute){ /**
* The Enterkeyhint-Attribute changes the text that is appearing on the enter key of a virtual keyboard.
* @param enterkeyhintAttribute <br>
* "done"<br>
* "enter"<br>
* "go"<br>
* "next"<br>
* "previous"<br>
* "search"<br>
* "send"<br>
* "null" -> not set
* @see GlobalAttributeEnterkeyhintEnum
*/
public void setEnterkeyhintAttribute(GlobalAttributeEnterkeyhintEnum enterkeyhintAttribute){
this.globalAttributeEnterkeyhint = enterkeyhintAttribute; this.globalAttributeEnterkeyhint = enterkeyhintAttribute;
} }
public String getEnterkeyhintAttribute(){ /**
* The Enterkeyhint-Attribute changes the text that is appearing on the enter key of a virtual keyboard.
* @return "done"<br>
* "enter"<br>
* "go"<br>
* "next"<br>
* "previous"<br>
* "search"<br>
* "send"<br>
* "null" -> not set
* @see GlobalAttributeEnterkeyhintEnum
*/
public GlobalAttributeEnterkeyhintEnum getEnterkeyhintAttribute(){
return globalAttributeEnterkeyhint; return globalAttributeEnterkeyhint;
} }
/**
* The Hidden-Attribute specifies that an element is hidden if set.<br>
* This could later be altered via JS.
* @param hiddenAttribute <br>
* "true" -> element is hidden<br>
* "false" (default) -> element is not hidden
*/
public void setHiddenAttribute(boolean hiddenAttribute){ public void setHiddenAttribute(boolean hiddenAttribute){
this.globalAttributeHidden = hiddenAttribute; this.globalAttributeHidden = hiddenAttribute;
} }
/**
* The Hidden-Attribute specifies that an element is hidden if set.<br>
* This could later be altered via JS.
* @return "true" -> element is hidden<br>
* "false" (default) -> element is not hidden
*/
public boolean getHiddenAttribute(){ public boolean getHiddenAttribute(){
return globalAttributeHidden; return globalAttributeHidden;
} }

View File

@ -0,0 +1,15 @@
package main.htmlModules.attributeEnums;
public enum GlobalAttributeDirEnum {
LTR("ltr"),
RTL("rtl"),
AUTO("auto");
private String value;
public String getValue(){
return this.value;
}
private GlobalAttributeDirEnum(String value){
this.value = value;
}
}

View File

@ -5,11 +5,11 @@ public enum GlobalAttributeDraggableEnum {
FALSE("false"), FALSE("false"),
AUTO("auto"); AUTO("auto");
private String attribute; private String value;
public String getAttribute(){ public String getValue(){
return this.attribute; return this.value;
} }
private GlobalAttributeDraggableEnum(String attribute){ private GlobalAttributeDraggableEnum(String value){
this.attribute = attribute; this.value = value;
} }
} }

View File

@ -0,0 +1,19 @@
package main.htmlModules.attributeEnums;
public enum GlobalAttributeEnterkeyhintEnum {
DONE("done"),
ENTER("enter"),
GO("go"),
NEXT("next"),
PREVIOUS("previous"),
SEARCH("search"),
SEND("send");
private String value;
public String getValue(){
return this.value;
}
private GlobalAttributeEnterkeyhintEnum(String value){
this.value = value;
}
}