> allEvents = new LinkedHashSet<>();
+ getChildrenHierarchy(true).stream()
+ .filter(Objects::nonNull)
+ .forEach(child -> {
+ for (Object event : child.asEventBase()
+ .getEvents()) {
+ if (event != null) {
+ allEvents.add((IEvent, ?>) event);
+ }
+ }
+ });
+ return allEvents;
+ }
+
+ /**
+ * Get the page this component exists on
+ *
+ *
+ * @return A Page
+ */
+ @Override
+ @NotNull
+ public IPage> getPage() {
+ if (page == null) {
+ setPage(new Page<>());
+ }
+ return page;
+ }
+
+ /**
+ * Gets the parent of this hierarchy item
+ *
+ * @return The parent object
+ */
+ @Override
+ public IComponentHierarchyBase, ?> getParent() {
+ return parent;
+ }
+
+ /**
+ * Sets the parent of this item
+ *
+ * @param parent Sets the parent object
+ */
+ @Override
+ @NotNull
+ @SuppressWarnings("unchecked")
+ public J setParent(IComponentHierarchyBase, ?> parent) {
+ this.parent = parent;
+ return (J) this;
+ }
+
+ /**
+ * Adds a class name to the class list
+ *
+ *
+ * @param className The class name to add
+ *
+ * @return True if it was added, false if it already existed
+ */
+ @Override
+ @NotNull
+ @SuppressWarnings("unchecked")
+ public J addClass(@NotNull String className) {
+ getClasses().add(className);
+ return (J) this;
+ }
+
+ /**
+ * Removes a class name from this component
+ *
+ *
+ * @param className Class Name to Remove
+ *
+ * @return True if the class was removed, False if the class was not part of the collection
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public J removeClass(String className) {
+ getClasses().remove(className);
+ return (J) this;
+ }
+
+ /**
+ * Removes a class name from this component
+ *
+ *
+ * @param className Class Name to Remove
+ *
+ * @return True if the class was removed, False if the class was not part of the collection
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public J removeClass(String className, String... classNames) {
+ this.removeClass(className);
+ for (String name : classNames) {
+ this.removeClass(name);
+ }
+ return (J) this;
+ }
+
+ /**
+ * Enumeration to remove
+ *
+ * @param className
+ * @return
+ */
+ @Override
+ public J removeClass(@NotNull Enum> className, Enum>... classNames) {
+ this.removeClass(className);
+ for (Enum> name : classNames) {
+ this.removeClass(name);
+ }
+ return (J) this;
+ }
+
+ /**
+ * Enumeration to remove
+ *
+ * @param className
+ * @return
+ */
+ @Override
+ public boolean removeClass(@NotNull Enum> className) {
+ if (getClasses().contains(className.toString())) {
+ getClasses().remove(className.toString());
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Method addClass ...
+ *
+ * @param className of type ICssClassName
+ * @return J
+ * @see com.jwebmp.core.base.interfaces.IComponentHierarchyBase#addClass(ICssClassName)
+ */
+ @Override
+ @NotNull
+ @SuppressWarnings("unchecked")
+ public J addClass(@NotNull ICssClassName className) {
+ getClasses().add(className.toString());
+ return (J) this;
+ }
+
+ /**
+ * Returns a complete list of all class names associated with this component
+ *
+ *
+ * @return
+ */
+ @Override
+ @NotNull
+ public Set getClasses() {
+ if (classes == null) {
+ classes = new LinkedHashSet<>();
+ }
+ return classes;
+ }
+
+ /**
+ * Sets the classes set
+ *
+ * @param classes a new set of classes
+ */
+ @NotNull
+ @SuppressWarnings("unchecked")
+ @Override
+ public J setClasses(Set classes) {
+ this.classes = classes;
+ return (J) this;
+ }
+
+ /**
+ * Set the theme applied to this component
+ *
+ *
+ * @param theme The JQuery UI theme to apply to the component
+ * @see com.jwebmp.core.base.interfaces.IComponentHierarchyBase#addTheme(Theme)
+ */
+ @Override
+ @NotNull
+ @SuppressWarnings("unchecked")
+ public J addTheme(@NotNull Theme theme) {
+ if (!getThemes().contains(theme)) {
+ getThemes().add(theme);
+ addClass(theme.getClassName());
+ }
+
+ return (J) this;
+ }
+
+ /**
+ * *
+ * Returns all the variables for all the components
+ *
+ * @return
+ */
+ @Override
+ @NotNull
+ public Set getVariablesAll() {
+ Set allVariables = new TreeSet<>();
+ getChildrenHierarchy().forEach(child -> {
+ if (child != null) {
+ for (Object o : child.asFeatureBase()
+ .getVariables()) {
+ if (o != null) {
+ allVariables.add(o.toString());
+ }
+ }
+ }
+ });
+ return allVariables;
+ }
+
+ /**
+ * Creates loading part objects that return an injected instance of the class associated to that part
+ *
+ * @return
+ */
+ @Override
+ public IComponentHierarchyBase getLoadingPart(IEvent... events) {
+ if (JWebMPSiteBinder.loadingPartClass != null) {
+ ComponentHierarchyBase, ?, ?, GlobalEvents, ?> loadingPart = (ComponentHierarchyBase, ?, ?, GlobalEvents, ?>) IGuiceContext.get(JWebMPSiteBinder.loadingPartClass);
+ loadingPart.setID(getID());
+ for (IEvent event : events) {
+ loadingPart.addEvent(event);
+ }
+ return (IComponentHierarchyBase) loadingPart;
+ }
+ return null;
+ }
+
+ @Override
+ protected StringBuilder renderHTML(int tabCount) {
+ boolean renderChildren = true;
+ Set htmlRenderTriggers = IGuiceContext.loaderToSet(ServiceLoader.load(IOnComponentHtmlRender.class));
+ for (IOnComponentHtmlRender htmlRenderTrigger : htmlRenderTriggers) {
+ try {
+ boolean result = htmlRenderTrigger.onHtmlRender((ComponentHierarchyBase, ?, ?, ?, ?>) this);
+ if (!result) {
+ renderChildren = result;
+ }
+ } catch (Throwable T) {
+ log.log(Level.WARNING, "Error in processing html render interceptor", T);
+ }
+ }
+ setRenderChildren(renderChildren);
+ return super.renderHTML(tabCount);
+ }
+
+ /**
+ * Returns if this object has children or not
+ *
+ *
+ * @return true if there are children attached
+ */
+ @Override
+ public boolean hasChildren() {
+ return !getChildren().isEmpty();
+ }
+
+ /**
+ * Takes a component off this components child list
+ *
+ *
+ * @param childToRemove The child object to remove from this list
+ *
+ * @return True if the child was part of this components children's list
+ */
+ @Override
+ public boolean remove(C childToRemove) {
+ getChildren().remove(childToRemove);
+ return true;
+ }
+
+ /**
+ * *
+ * Returns all the JavaScript for all the components
+ *
+ * @return
+ */
+ @Override
+ @NotNull
+ public StringBuilder renderJavascriptAll() {
+ preConfigure();
+ StringBuilder sb = new StringBuilder();
+ Set allScripts = new LinkedHashSet<>();
+ Set queries = getQueriesAll();
+ queries.forEach(a ->
+ {
+ if (!Strings.isNullOrEmpty(a.toString())) {
+ allScripts.add(a.toString());
+ }
+ });
+ allScripts.forEach(sb.append(getNewLine())::append);
+ return sb;
+ }
+
+ /**
+ * Configures the page and all its components
+ *
+ * @see ComponentHTMLAttributeBase#preConfigure()
+ */
+ @Override
+ public void preConfigure() {
+ if (!isConfigured()) {
+ setNewLineForClosingTag(hasChildren());
+ }
+ super.preConfigure();
+ }
+
+ /**
+ * Renders the classes array as an in-line class string
+ *
+ * @return
+ * @see ComponentHTMLAttributeBase#renderClasses()
+ */
+ @Override
+ @NotNull
+ protected StringBuilder renderClasses() {
+ StringBuilder sb = new StringBuilder();
+ Set eachClass = getClasses();
+ eachClass.forEach(a -> sb.append(a)
+ .append(StaticStrings.STRING_SPACE));
+ if (sb.length() > 0) {
+ sb.deleteCharAt(sb.length() - 1);
+ }
+ return sb;
+ }
+
+ /**
+ * @see ComponentHTMLAttributeBase#cloneComponent()
+ */
+ @Override
+ @NotNull
+ @SuppressWarnings("unchecked")
+ public J cloneComponent() {
+ ComponentHierarchyBase, ?, ?, ?, ?> cloned = super.cloneComponent();
+ //noinspection CastCanBeRemovedNarrowingVariableType
+ return (J) cloned;
+ }
+
+ /**
+ * Returns all the feature queries associated to this component and all its children
+ *
+ * @return
+ * @see ComponentFeatureBase#getQueriesAll()
+ */
+ @Override
+ @NotNull
+ public Set getQueriesAll() {
+ Set reallyAllQueries = new LinkedHashSet<>();
+ Set> allComponents = getChildrenHierarchy(true);
+ Consumer super IComponentHierarchyBase, ?>> action = componentQuery -> processComponentQueries(componentQuery, reallyAllQueries);
+ for (IComponentHierarchyBase, ?> allComponent : allComponents) {
+ if (allComponent != null) {
+ action.accept(allComponent);
+ }
+ }
+ return reallyAllQueries;
+ }
+
+ /**
+ * Pre-Configure the children tree
+ *
+ * @return
+ * @see ComponentBase#toString()
+ */
+ @Override
+ @NotNull
+ public String toString() {
+ getChildren().forEach(next ->
+ {
+ if (next != null) {
+ if (!next.isConfigured()) {
+ next.preConfigure();
+ }
+ }
+ });
+ return super.toString();
+ }
+
+ /**
+ * Processes the queries
+ *
+ * @param componentQuery
+ * @param reallyAllQueries
+ */
+ @SuppressWarnings("unchecked")
+ private void processComponentQueries(@NotNull IComponentHierarchyBase, ?> componentQuery, @NotNull Set reallyAllQueries) {
+ reallyAllQueries.addAll(getQueries());
+ @SuppressWarnings("rawtypes")
+ List> features = new ArrayList(componentQuery.asFeatureBase()
+ .getFeatures());
+ features.forEach(feature -> reallyAllQueries.add(feature.renderJavascript()));
+ features.sort(comparing(ComponentFeatureBase::getSortOrder));
+ Set events = (Set) componentQuery.asEventBase()
+ .getEvents();
+
+ events.forEach(event -> reallyAllQueries.add(((IComponentFeatureBase, ?>) event).asFeatureBase()
+ .renderJavascript()));
+
+ features.sort(comparing(ComponentFeatureBase::getSortOrder));
+ }
+
+ /**
+ * Sets the page this component belongs on.
+ * Null to reset the page hierarchy for all children
+ *
+ *
+ * @param page A Page
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public J setPage(IPage> page) {
+ this.page = page;
+ getChildren().stream()
+ .filter(a -> a != null)
+ .forEach(child -> child.cast().asHierarchyBase()
+ .setPage(page));
+ return (J) this;
+ }
+
+ /**
+ * Processes the angular objects into a map
+ *
+ * @param next
+ * @param map
+ */
+ private void processAngularObjects(@NotNull IComponentHierarchyBase, ?> next, @NotNull Map map) {
+ for (Map.Entry entry : next.asAngularBase()
+ .getJsonObjects()
+ .entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (key != null) {
+ try {
+ map.put(key, value);
+ } catch (ClassCastException cce) {
+ ComponentHierarchyBase.log.log(Level.WARNING, "Incorrect Object Type, Perhaps JavaScriptPart?", cce);
+ } catch (Exception e) {
+ ComponentHierarchyBase.log.log(Level.WARNING, "Unable to render angular object", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Iterates through all the children checking if a boolean property has been placed, Returns the first instance of true or always false
+ *
+ * @param propertyName
+ * @param returnBool
+ * @return
+ */
+ @SuppressWarnings("unused")
+ public boolean readChildrenPropertyFirstResult(String propertyName, boolean returnBool) {
+ for (IComponentHierarchyBase, ?> next : getChildrenHierarchy(true)) {
+ if (next != null) {
+ if (next.asBase()
+ .getProperties()
+ .containsKey(propertyName)) {
+ String propertyValue = next.asBase()
+ .getProperties()
+ .get(propertyName)
+ .toString();
+ try {
+ return Boolean.parseBoolean(propertyValue);
+ } catch (Exception e) {
+ ComponentHierarchyBase.log.log(Level.WARNING, "Property value was not a boolean.", e);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the first parent in the chain of the class type
+ *
+ * @param The class type
+ * @param parentType The type to look for
+ * @return
+ */
+ @Override
+ public > T findParent(Class parentType) {
+ return findParent(this, parentType);
+ }
+
+ /**
+ * Recursive method for going through the parent base
+ *
+ * @param root The root
+ * @param parentType The parent type
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private > T findParent(@NotNull IComponentHierarchyBase, ?> root, @NotNull Class parentType) {
+ if (root.getParent() != null) {
+ T found;
+ found = (T) root.getParent();
+ while (found != null && !parentType.isAssignableFrom(found.getClass())) {
+ found = (T) found.getParent();
+ }
+ return found;
+ }
+ return null;
+ }
+
+ /**
+ * Method findChild ...
+ *
+ * @param childType of type Class T
+ * @return T
+ */
+ @SuppressWarnings({"unchecked", "unused"})
+ @Override
+ public > T findChild(@NotNull Class childType) {
+ return (T) getChildren().stream()
+ .filter(componentHierarchyBase -> componentHierarchyBase.getClass()
+ .equals(childType))
+ .findFirst()
+ .orElse(null);
+ }
+
+ /**
+ * Convenience method for checking if a tag has already been added as a child
+ *
+ *
+ * @param classType The Tag type to check for
+ *
+ * @return The Obvious
+ */
+ @SuppressWarnings("unused")
+ protected boolean containsClass(@NotNull Class> classType) {
+ for (C next : getChildren()) {
+ if (next.getClass()
+ .equals(classType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Renders each child
+ *
+ * @return
+ * @see ComponentHTMLBase#renderChildren()
+ */
+ @Override
+ @NotNull
+ protected StringBuilder renderChildren() {
+ StringBuilder sb = new StringBuilder();
+ if (!renderChildren) {
+ return sb;
+ }
+ if (renderBeforeChildren() != null) {
+ sb.append(renderBeforeChildren());
+ }
+ CopyOnWriteArraySet objects = new CopyOnWriteArraySet<>();
+ objects.addAll(getChildren());
+ objects.stream()
+ .filter(Objects::nonNull)
+ .forEach(child -> {
+ try {
+ sb.append(getNewLine())
+ .append(child.toString(child.cast().asBase()
+ .isTiny() ? 0 : getCurrentTabIndents() + 1));
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "Cannot work on child object - " + child.getClass()
+ .getCanonicalName() + "\n, adding to the tree\n", e);
+ }
+ }
+ );
+ if (renderAfterChildren() != null) {
+ sb.append(renderAfterChildren());
+ }
+ return sb;
+ }
+
+ /**
+ * Ensure if there are children that new lines must be rendered
+ *
+ * Boxed for operating purposes
+ *
+ * @return
+ * @see ComponentHTMLBase#isNewLineForClosingTag()
+ */
+ @Override
+ @NotNull
+ public Boolean isNewLineForClosingTag() {
+ if (hasChildren() && !isTiny()) {
+ return true;
+ } else {
+ return super.isNewLineForClosingTag();
+ }
+ }
+
+ /**
+ * Renders String content before the children tags are rendered
+ *
+ *
+ * @return Custom HTML String to be inserted before Children tags
+ * @see ComponentHTMLBase#renderBeforeChildren()
+ */
+ @Override
+
+ protected StringBuilder renderBeforeChildren() {
+ return null;
+ }
+
+ /**
+ * Renders String content after the children tags are rendered
+ *
+ *
+ * @return Custom HTML String to be inserted after Children tags
+ * @see ComponentHTMLBase#renderAfterChildren()
+ */
+ @Override
+
+ protected StringBuilder renderAfterChildren() {
+ return null;
+ }
+
+ private Set configurations = new HashSet<>();
+
+ protected Set getConfigurations() {
+ if (configurations == null) {
+ configurations = new HashSet<>();
+ }
+ return configurations;
+ }
+
+ public J addConfiguration(IConfiguration configuration) {
+ getConfigurations().add(configuration);
+ return (J) this;
+ }
+
+ public Set getConfigurations(Class> configurationType) {
+ Set out = new LinkedHashSet<>();
+ for (IComponentHierarchyBase, ?> iComponentHierarchyBase : getChildrenHierarchy(true)) {
+ ComponentHierarchyBase chb = (ComponentHierarchyBase) iComponentHierarchyBase;
+ out.addAll((Set) chb.getConfigurations()
+ .stream()
+ .filter(b -> configurationType.isAssignableFrom(b.getClass()))
+ .collect(Collectors.toSet()));
+ }
+ return out;
+ }
+
+ /**
+ * if children should be rendered
+ *
+ * @return
+ */
+ public boolean isRenderChildren() {
+ return renderChildren;
+ }
+
+ /**
+ * if children should be rendered
+ *
+ * @param renderChildren
+ * @return
+ */
+ public J setRenderChildren(boolean renderChildren) {
+ this.renderChildren = renderChildren;
+ return (J) this;
+ }
+
+
}
diff --git a/src/main/java/com/jwebmp/core/base/ComponentStyleBase.java b/src/main/java/com/jwebmp/core/base/ComponentStyleBase.java
index 6179159f5..9dad526cc 100644
--- a/src/main/java/com/jwebmp/core/base/ComponentStyleBase.java
+++ b/src/main/java/com/jwebmp/core/base/ComponentStyleBase.java
@@ -21,8 +21,7 @@
import com.jwebmp.core.base.html.interfaces.GlobalChildren;
import com.jwebmp.core.base.html.interfaces.GlobalFeatures;
import com.jwebmp.core.base.html.interfaces.events.GlobalEvents;
-import com.jwebmp.core.base.interfaces.IComponentHierarchyBase;
-import com.jwebmp.core.base.interfaces.IComponentStyleBase;
+import com.jwebmp.core.base.interfaces.*;
import com.jwebmp.core.base.servlets.enumarations.ComponentTypes;
import com.jwebmp.core.htmlbuilder.css.CSSImpl;
import com.jwebmp.core.htmlbuilder.css.composer.CSSComposer;
@@ -46,233 +45,213 @@
*/
@SuppressWarnings("MissingClassJavaDoc")
public abstract class ComponentStyleBase & AttributeDefinitions,
- F extends GlobalFeatures,
- E extends GlobalEvents,
- J extends ComponentStyleBase>
- extends ComponentHierarchyBase
- implements IComponentStyleBase
-{
- /**
- * The CSS Object for all styling
- */
- private CSSImpl css;
-
- /**
- * The CSS Class name if required
- */
- private String cssName;
-
- /**
- * Container for all the CSS Types
- */
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- private Map cssTypeHashMap;
-
- /**
- * Constructs a tag with styling options enabled
- *
- * @param componentType The type of component this is
- */
- public ComponentStyleBase(ComponentTypes componentType)
- {
- super(componentType);
- }
-
- /**
- * Returns a ComponentStyleBase component of this
- *
- * @return This class with only the styling methods
- */
- @SuppressWarnings("unused")
- @NotNull
- public IComponentStyleBase> asStyleBase()
- {
- return this;
- }
-
- /**
- * Adds a CSS object to the component with the given type
- *
- * @param type The CSS Type
- * @param cssItem Thee CSS Item to add
- * @return Always this object
- */
- @Override
- @SuppressWarnings("unchecked")
- @NotNull
- public J addCSSEntry(CSSTypes type, CSSImpl cssItem)
- {
- getCssTypeHashMap().put(type, cssItem);
- return (J) this;
- }
-
- /**
- * Removes a CSS item for the component
- *
- * @param cssType The CSS Type Entry to remove
- * @return Always this object
- */
- @Override
- @SuppressWarnings("unchecked")
- @NotNull
- public J removeCSSEntry(CSSTypes cssType)
- {
- getCssTypeHashMap().remove(cssType);
- return (J) this;
- }
-
- /**
- * Gets the CSS Object used for styling
- *
- * @return The CSS Implementation Object for default (CSSTypes.None)
- */
- @Override
- @NotNull
- public CSSImpl getCss()
- {
- if (css == null)
- {
- css = new CSSImpl();
- getCssTypeHashMap().put(CSSTypes.None, css);
- }
- return css;
- }
-
- /**
- * Sets the CSS Object used for styling
- *
- * @param css The CSS Implementation object to add
- * @return Always this object
- */
- @Override
- @NotNull
- @SuppressWarnings("unchecked")
- public J setCss(CSSImpl css)
- {
- this.css = css;
- return (J) this;
- }
-
- /**
- * Returns the currently assigned CSS Name
- *
- * @return The currently assigned css Name for this objects style
- */
- @Override
- @NotNull
- public String getCssName()
- {
- return cssName;
- }
-
- /**
- * Sets the currently assigned CSS Name
- *
- * @param cssName Sets the CSS Name to a valid value
- * @return Always this object
- */
- @Override
- @NotNull
- @SuppressWarnings("unchecked")
- public J setCssName(@NotNull String cssName)
- {
- this.cssName = cssName;
- return (J) this;
- }
-
- /**
- * Returns the current HashMap of all CSS Entries for the component
- *
- * @return The CSS Types and Implementations for each type for this object
- */
- @Override
- @NotNull
- public Map getCssTypeHashMap()
- {
- if (cssTypeHashMap == null)
- {
- cssTypeHashMap = new EnumMap<>(CSSTypes.class);
- }
- return cssTypeHashMap;
- }
-
- /**
- * Renders the component CSS at the specified tab count with the <style> tag
- *
- *
- * @param tabCount Tab indentation for the SQL
- * @return The Component CSS
- */
- @Override
- @NotNull
- public StringBuilder renderCss(int tabCount)
- {
- return renderCss(tabCount, true, false, false);
- }
-
- /**
- * Renders the component CSS at the specified tab count with the <style> tag This includes everything from this classes CSS, to
- * the CSS for each field. It will also populate the lower level
- * child CSS for fields in this class
- *
- *
- * @param tabCount Tab indentation for the SQL
- * @param renderOpening Whether or not to render the opening XML tag for a CSS style
- * @param renderInQuotations Sets whether to render the CSS Fields in Quotations
- * @param isAjaxCall Sets whether the CSS is being called from an AJAX call
- *
- * @return The Component CSS
- */
- @Override
- @NotNull
- public StringBuilder renderCss(int tabCount, boolean renderOpening, boolean renderInQuotations, boolean isAjaxCall)
- {
- if (!isInitialized())
- {
- init();
- }
- if (!isConfigured())
- {
- preConfigure();
- }
- CSSComposer comp = new CSSComposer();
- comp.addComponent(this, true);
- return new StringBuilder(comp.toString());
- }
-
- /**
- * @return hash-int
- */
- @Override
- public int hashCode()
- {
- return super.hashCode();
- }
-
- /**
- * Method equals ...
- *
- * @param o of type Object
- * @return boolean
- */
- @Override
- public boolean equals(Object o)
- {
- return super.equals(o);
- }
-
- /**
- * Method destroy ...
- */
- @Override
- public void destroy()
- {
- if (cssTypeHashMap != null)
- {
- cssTypeHashMap.clear();
- cssTypeHashMap = null;
- }
- super.destroy();
- }
+ A extends Enum> & AttributeDefinitions,
+ F extends GlobalFeatures,
+ E extends GlobalEvents,
+ J extends ComponentStyleBase>
+ extends ComponentHierarchyBase
+ implements IComponentStyleBase {
+ /**
+ * The CSS Object for all styling
+ */
+ private CSSImpl css;
+
+ /**
+ * The CSS Class name if required
+ */
+ private String cssName;
+
+ /**
+ * Container for all the CSS Types
+ */
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private Map cssTypeHashMap;
+
+ /**
+ * Constructs a tag with styling options enabled
+ *
+ * @param componentType The type of component this is
+ */
+ public ComponentStyleBase(ComponentTypes componentType) {
+ super(componentType);
+ }
+
+ /**
+ * Returns a ComponentStyleBase component of this
+ *
+ * @return This class with only the styling methods
+ */
+ @SuppressWarnings("unused")
+ @NotNull
+ public IComponentStyleBase> asStyleBase() {
+ return this;
+ }
+
+ /**
+ * Adds a CSS object to the component with the given type
+ *
+ * @param type The CSS Type
+ * @param cssItem Thee CSS Item to add
+ * @return Always this object
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ @NotNull
+ public J addCSSEntry(CSSTypes type, ICSSImpl cssItem) {
+ getCssTypeHashMap().put(type, cssItem);
+ return (J) this;
+ }
+
+ /**
+ * Removes a CSS item for the component
+ *
+ * @param cssType The CSS Type Entry to remove
+ * @return Always this object
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ @NotNull
+ public J removeCSSEntry(CSSTypes cssType) {
+ getCssTypeHashMap().remove(cssType);
+ return (J) this;
+ }
+
+ /**
+ * Gets the CSS Object used for styling
+ *
+ * @return The CSS Implementation Object for default (CSSTypes.None)
+ */
+ @Override
+ @NotNull
+ public CSSImpl getCss() {
+ if (css == null) {
+ css = new CSSImpl();
+ getCssTypeHashMap().put(CSSTypes.None, css);
+ }
+ return css;
+ }
+
+ /**
+ * Sets the CSS Object used for styling
+ *
+ * @param css The CSS Implementation object to add
+ * @return Always this object
+ */
+ @Override
+ @NotNull
+ @SuppressWarnings("unchecked")
+ public J setCss(ICSSImpl css) {
+ this.css = (CSSImpl) css;
+ return (J) this;
+ }
+
+ /**
+ * Returns the currently assigned CSS Name
+ *
+ * @return The currently assigned css Name for this objects style
+ */
+ @Override
+ @NotNull
+ public String getCssName() {
+ return cssName;
+ }
+
+ /**
+ * Sets the currently assigned CSS Name
+ *
+ * @param cssName Sets the CSS Name to a valid value
+ * @return Always this object
+ */
+ @Override
+ @NotNull
+ @SuppressWarnings("unchecked")
+ public J setCssName(@NotNull String cssName) {
+ this.cssName = cssName;
+ return (J) this;
+ }
+
+ /**
+ * Returns the current HashMap of all CSS Entries for the component
+ *
+ * @return The CSS Types and Implementations for each type for this object
+ */
+ @Override
+ @NotNull
+ public Map getCssTypeHashMap() {
+ if (cssTypeHashMap == null) {
+ cssTypeHashMap = new EnumMap<>(CSSTypes.class);
+ }
+ return cssTypeHashMap;
+ }
+
+ /**
+ * Renders the component CSS at the specified tab count with the <style> tag
+ *
+ *
+ * @param tabCount Tab indentation for the SQL
+ * @return The Component CSS
+ */
+ @Override
+ @NotNull
+ public StringBuilder renderCss(int tabCount) {
+ return renderCss(tabCount, true, false, false);
+ }
+
+ /**
+ * Renders the component CSS at the specified tab count with the <style> tag This includes everything from this classes CSS, to
+ * the CSS for each field. It will also populate the lower level
+ * child CSS for fields in this class
+ *
+ *
+ * @param tabCount Tab indentation for the SQL
+ * @param renderOpening Whether or not to render the opening XML tag for a CSS style
+ * @param renderInQuotations Sets whether to render the CSS Fields in Quotations
+ * @param isAjaxCall Sets whether the CSS is being called from an AJAX call
+ *
+ * @return The Component CSS
+ */
+ @Override
+ @NotNull
+ public StringBuilder renderCss(int tabCount, boolean renderOpening, boolean renderInQuotations, boolean isAjaxCall) {
+ if (!isInitialized()) {
+ init();
+ }
+ if (!isConfigured()) {
+ preConfigure();
+ }
+ CSSComposer comp = new CSSComposer();
+ comp.addComponent(this, true);
+ return new StringBuilder(comp.toString());
+ }
+
+ /**
+ * @return hash-int
+ */
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ /**
+ * Method equals ...
+ *
+ * @param o of type Object
+ * @return boolean
+ */
+ @Override
+ public boolean equals(Object o) {
+ return super.equals(o);
+ }
+
+ /**
+ * Method destroy ...
+ */
+ @Override
+ public void destroy() {
+ if (cssTypeHashMap != null) {
+ cssTypeHashMap.clear();
+ cssTypeHashMap = null;
+ }
+ super.destroy();
+ }
}
diff --git a/src/main/java/com/jwebmp/core/base/ajax/AjaxCall.java b/src/main/java/com/jwebmp/core/base/ajax/AjaxCall.java
deleted file mode 100644
index 6824c23d7..000000000
--- a/src/main/java/com/jwebmp/core/base/ajax/AjaxCall.java
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * Copyright (C) 2017 GedMarc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.jwebmp.core.base.ajax;
-
-import com.fasterxml.jackson.annotation.*;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.google.common.base.Strings;
-import com.google.inject.Inject;
-import com.google.inject.OutOfScopeException;
-import com.google.inject.ProvisionException;
-import com.guicedee.guicedinjection.GuiceContext;
-import com.guicedee.guicedinjection.interfaces.ObjectBinderKeys;
-import com.guicedee.guicedservlets.GuicedServletKeys;
-import com.guicedee.guicedservlets.servlets.services.scopes.CallScope;
-import com.jwebmp.core.base.interfaces.IComponentHierarchyBase;
-import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart;
-import com.jwebmp.core.htmlbuilder.javascript.events.enumerations.EventTypes;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.validation.constraints.NotNull;
-import jakarta.websocket.Session;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This class handles the decoding of an AJAX call being received
- *
- *
- * @author GedMarc
- * @since 04 May 2015
- */
-@SuppressWarnings({"JavaDoc", "unused"})
-@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY,
- getterVisibility = JsonAutoDetect.Visibility.NONE,
- setterVisibility = JsonAutoDetect.Visibility.NONE)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-@CallScope
-public class AjaxCall>
- extends JavaScriptPart
- implements IAjaxCall
-{
- /**
- * The component ID that was sent back
- */
- private String componentId;
- /**
- * The date of the client event - used to measure network congestion.
- */
- private Date datetime;
- /**
- * The event type
- */
- private EventTypes eventType;
-
- private HeadersDTO headers;
-
- private Map attributes;
-
- /**
- * The current history state
- */
- private Map state;
- /**
- * The component object that this call is linked to
- */
- @JsonIgnore
- private IComponentHierarchyBase, ?> component;
- /**
- * The parameters associated with the call
- */
- private Map parameters;
-
- /**
- * The parameters associated with the call
- */
- private Map sessionStorage;
- /**
- * The parameters associated with the call
- */
- private Map localStorage;
-
- /**
- * The class to create
- */
- @JsonAlias({"classname","eventClass"})
- private String className;
- /**
- * The given hash bang
- */
- @JsonAlias("hashbang")
- private String hashBang;
- /**
- * The given path route for the application
- */
- private String route;
- /**
- * If this call originates through a web socket (so there is no request or session scope),
- * or if it is a direct page call
- */
- private boolean isWebSocketCall;
- /**
- * The web socket session for this call
- */
- @JsonIgnore
- private Session websocketSession;
-
- /**
- * If this is a page or a supporting servlet call
- */
- private boolean pageCall;
-
- private Map unknownFields = new HashMap<>();
- private Map history = new HashMap<>();
-
- /**
- * JSon Jackson Constructor
- */
- public AjaxCall()
- {
- //set nothing
- }
-
- /**
- * Creates a valid AJAX call object that can be processed
- *
- * @param componentId The component ID
- * @param datetime The Date Time
- * @param eventType The ComponentEventBase Type
- * @param eventTypeFrom The ComponentEventBase Type From
- */
- public AjaxCall(String componentId, Date datetime, String eventType, String eventTypeFrom)
- {
- this.componentId = componentId;
- this.datetime = datetime;
- this.eventType = EventTypes.valueOf(eventType);
- }
-
- @Inject
- void configure()
- {
- try
- {
- HttpServletRequest request = GuiceContext.get(GuicedServletKeys.getHttpServletRequestKey());
- for (Map.Entry entry : request.getParameterMap()
- .entrySet())
- {
- String key = entry.getKey();
- String[] value = entry.getValue();
- getParameters()
- .put(key, value[0]);
- }
- }
- catch (OutOfScopeException | ProvisionException e)
- {
- //ignore
- }
- }
-
- public String getAttribute(String attribute)
- {
- if (getAttributes() != null && getAttributes()
- .get(attribute) != null)
- {
- return getAttributes()
- .get(attribute)
- .toString();
- }
- return null;
- }
-
- /**
- * @return
- */
- @SuppressWarnings("Convert2Diamond")
- public Map getAttributeAsMap(String attributeName)
- {
- String variableText = getAttribute(attributeName);
- if (Strings.isNullOrEmpty(variableText))
- {
- return new HashMap<>();
- }
- TypeReference> typeRef
- = new TypeReference>()
- {
- };
- try
- {
- return GuiceContext.get(ObjectBinderKeys.DefaultObjectMapper)
- .readValue(variableText, typeRef);
- }
- catch (JsonProcessingException e)
- {
- return new HashMap<>();
- }
-
- }
-
- /**
- * The given hash bang
- *
- * @return
- */
- public String getHashBang()
- {
- return hashBang;
- }
-
- /**
- * The given hash bang
- *
- * @param hashBang
- */
- public void setHashBang(String hashBang)
- {
- this.hashBang = hashBang;
- }
-
- @Override
- public final String getComponentId()
- {
- return componentId;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public J fromCall(AjaxCall> incoming)
- {
- setComponent(incoming.getComponent());
- setComponentId(incoming.getComponentId());
- setDatetime(incoming.getDatetime());
- setEventType(incoming.getEventType());
- setReferenceId(incoming.getReferenceId());
- setClassName(incoming.getClassName());
- setParameters(incoming.getParameters());
- setLocalStorage(incoming.getLocalStorage());
- setSessionStorage(incoming.getSessionStorage());
- setHashBang(incoming.getHashBang());
- setWebsocketSession(incoming.getWebsocketSession());
- setWebSocketCall(incoming.isWebSocketCall());
- unknownFields = Map.copyOf(incoming.unknownFields);
-
- return (J) this;
- }
-
- @Override
- public Date getDatetime()
- {
- return datetime;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public J setComponent(IComponentHierarchyBase, ?> component)
- {
- this.component = component;
- return (J) this;
- }
-
- @Override
- public EventTypes getEventType()
- {
- return eventType;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public J setComponentId(String componentId)
- {
- this.componentId = componentId;
- return (J) this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public J setDatetime(Date datetime)
- {
- this.datetime = datetime;
- return (J) this;
- }
-
- @Override
- public IComponentHierarchyBase, ?> getComponent()
- {
- return component;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public J setEventType(EventTypes eventType)
- {
- this.eventType = eventType;
- return (J) this;
- }
-
- /**
- * If this call originates through a web socket (so there is no request or session scope),
- * * or if it is a direct page call
- *
- * @return
- */
- public boolean isWebSocketCall()
- {
- return isWebSocketCall;
- }
-
- /**
- * If this call originates through a web socket (so there is no request or session scope),
- * * or if it is a direct page call
- *
- * @param webSocketCall
- */
- @SuppressWarnings("unchecked")
- public J setWebSocketCall(boolean webSocketCall)
- {
- isWebSocketCall = webSocketCall;
- return (J) this;
- }
-
- /**
- * The web socket session for this call
- *
- * @return
- */
- public Session getWebsocketSession()
- {
- return websocketSession;
- }
-
- /**
- * The web socket session for this call
- *
- * @param websocketSession
- * @return
- */
- @SuppressWarnings("unchecked")
- public J setWebsocketSession(Session websocketSession)
- {
- this.websocketSession = websocketSession;
- return (J) this;
- }
-
- @Override
- @NotNull
- public Map getParameters()
- {
- if (parameters == null)
- {
- parameters = new HashMap<>();
- }
- return parameters;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public J setParameters(Map parameters)
- {
- this.parameters = parameters;
- return (J) this;
- }
-
- @Override
- @NotNull
- public String getClassName()
- {
- return className;
- }
-
- @Override
- @NotNull
- @SuppressWarnings("unchecked")
- public J setClassName(String className)
- {
- this.className = className;
- return (J) this;
- }
-
- /**
- * If the call originates as a live page call, or a supporting servlet call
- *
- * @return
- */
- public boolean isPageCall()
- {
- return pageCall;
- }
-
- /**
- * If the call originates as a live page call, or a supporting servlet call
- *
- * @param pageCall
- * @return
- */
- @SuppressWarnings("unchecked")
- public J setPageCall(boolean pageCall)
- {
- this.pageCall = pageCall;
- return (J) this;
- }
-
- /**
- * Returns the sent through state of the session storage
- *
- * @return
- */
- public Map getSessionStorage()
- {
- if (sessionStorage == null)
- {
- sessionStorage = new HashMap<>();
- }
- return sessionStorage;
- }
-
- /**
- * Sets the call list for session storage
- *
- * @param sessionStorage
- * @return
- */
- public J setSessionStorage(Map sessionStorage)
- {
- this.sessionStorage = sessionStorage;
- return (J) this;
- }
-
- /**
- * Gets the local storage
- *
- * @return
- */
- public Map getLocalStorage()
- {
- if (localStorage == null)
- {
- localStorage = new HashMap<>();
- }
- return localStorage;
- }
-
- /**
- * Sets local storage
- *
- * @param localStorage
- * @return
- */
- public J setLocalStorage(Map localStorage)
- {
- this.localStorage = localStorage;
- return (J) this;
- }
-
-
- @JsonAnyGetter
- public Map getUnknownFields()
- {
- return unknownFields;
- }
-
- @JsonAnySetter
- public void setOtherField(String name, Object value)
- {
- unknownFields.put(name, value);
- }
-
-
- public Map getAttributes()
- {
- if (attributes == null)
- {
- attributes = new HashMap<>();
- }
- return attributes;
- }
-
- @SuppressWarnings("unchecked")
- public J setAttributes(Map attributes)
- {
- this.attributes = attributes;
- return (J) this;
- }
-
- public HeadersDTO getHeaders()
- {
- return headers;
- }
-
- public AjaxCall setHeaders(HeadersDTO headers)
- {
- this.headers = headers;
- return this;
- }
-
- public String getRoute()
- {
- return route;
- }
-
- public AjaxCall setRoute(String route)
- {
- this.route = route;
- return this;
- }
-
- public Map getState()
- {
- return state;
- }
-
- public AjaxCall setState(Map state)
- {
- this.state = state;
- return this;
- }
-
- public Map getHistory()
- {
- return history;
- }
-
- public AjaxCall setHistory(Map history)
- {
- this.history = history;
- return this;
- }
-}
diff --git a/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentInsertType.java b/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentInsertType.java
deleted file mode 100644
index a91d92de1..000000000
--- a/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentInsertType.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2017 GedMarc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.jwebmp.core.base.ajax;
-
-/**
- * @author GedMarc
- * @since 22 Apr 2017
- */
-public enum AjaxComponentInsertType
-{
- Replace,
- Append,
- Prepend,
- Insert,
- Remove,
- Insert_Last("InsertLast");
- /**
- * Any sub data
- */
- private String data;
-
- /**
- * A new AjaxComponentInsertType
- */
- AjaxComponentInsertType()
- {
-
- }
-
- /**
- * A new AjaxComponentInsertType with data
- */
- AjaxComponentInsertType(String data)
- {
-
- }
-
- /**
- * Returns the name or the data contained within
- *
- * @return
- */
- @Override
- public String toString()
- {
- if (data != null && !data.isEmpty())
- {
- return data;
- }
- else
- {
- return name();
- }
- }
-}
diff --git a/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentUpdates.java b/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentUpdates.java
deleted file mode 100644
index 4fc5f23ba..000000000
--- a/src/main/java/com/jwebmp/core/base/ajax/AjaxComponentUpdates.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2017 GedMarc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.jwebmp.core.base.ajax;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.jwebmp.core.base.ComponentHierarchyBase;
-import com.jwebmp.core.base.interfaces.IComponentHierarchyBase;
-import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart;
-
-import jakarta.validation.constraints.NotNull;
-
-/**
- * A JSON Class for component updates
- */
-public class AjaxComponentUpdates>
- extends JavaScriptPart
-{
- /**
- * The stored HTML
- */
- @JsonProperty("html")
- private String html;
- /**
- * An assigned ID for a component action
- */
- @JsonProperty("id")
- private String id;
- /**
- * The type for an action, defaulted to Replace
- */
- @JsonProperty("insertType")
- private AjaxComponentInsertType insertType;
-
- /**
- * Constructs an update class from a given component
- *
- * @param component
- */
- public AjaxComponentUpdates(IComponentHierarchyBase,?> component)
- {
- component.setTiny(true);
- html = component.toString(true);
- id = component.asBase().getID();
- insertType = AjaxComponentInsertType.Replace;
- }
-
- /**
- * Returns the HTML of the component
- *
- * @return
- */
- public String getHtml()
- {
- return html;
- }
-
- /**
- * Sets the HTML
- *
- * @param html
- */
- @SuppressWarnings("unchecked")
- @NotNull
- public J setHtml(String html)
- {
- this.html = html;
- return (J) this;
- }
-
- /**
- * Returns which component ID is getting replaced
- *
- * @return
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Sets the ID being used for the insert type
- *
- * @param id
- */
- @SuppressWarnings("unchecked")
- @NotNull
- public J setId(String id)
- {
- this.id = id;
- return (J) this;
- }
-
- /**
- * Sets the type of insert that should occur on component ID
- *
- * @return
- */
- public AjaxComponentInsertType getInsertType()
- {
- return insertType;
- }
-
- /**
- * Sets the type of insert that should occur on component ID
- *
- * @param insertType
- */
- @SuppressWarnings("unchecked")
- @NotNull
- public J setInsertType(AjaxComponentInsertType insertType)
- {
- this.insertType = insertType;
- return (J) this;
- }
-
-}
diff --git a/src/main/java/com/jwebmp/core/base/ajax/AjaxResponse.java b/src/main/java/com/jwebmp/core/base/ajax/AjaxResponse.java
deleted file mode 100644
index b575a02d6..000000000
--- a/src/main/java/com/jwebmp/core/base/ajax/AjaxResponse.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2017 GedMarc
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.jwebmp.core.base.ajax;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.guicedee.guicedservlets.servlets.services.scopes.CallScope;
-import com.guicedee.services.jsonrepresentation.IJsonRepresentation;
-import com.jwebmp.core.Feature;
-import com.jwebmp.core.htmlbuilder.javascript.JavaScriptPart;
-import jakarta.validation.constraints.NotNull;
-
-import java.util.*;
-
-/**
- * A response sent back to the client
- *
- * @author GedMarc
- * @since 27 Apr 2016
- */
-@SuppressWarnings("MissingClassJavaDoc")
-@CallScope
-public class AjaxResponse>
- extends JavaScriptPart {
- /**
- * Whether or not the response is a success or not
- */
- @JsonProperty("success")
- private boolean success = true;
-
- /**
- * All relevant client reactions to perform
- */
- @JsonProperty("reactions")
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- private Set