Skip to content

Commit

Permalink
Redesigned the GUI Screen model.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed May 2, 2016
1 parent 5852f63 commit e2c929e
Show file tree
Hide file tree
Showing 18 changed files with 463 additions and 419 deletions.
12 changes: 8 additions & 4 deletions rapidoid-commons/src/main/java/org/rapidoid/config/Config.java
@@ -1,6 +1,8 @@
package org.rapidoid.config;

import org.rapidoid.RapidoidThing;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.cls.Cls;
import org.rapidoid.commons.Arr;
import org.rapidoid.commons.Coll;
Expand Down Expand Up @@ -31,10 +33,8 @@
* #L%
*/

/**
* @author Nikolche Mihajlovski
* @since 4.1.0
*/
@Authors("Nikolche Mihajlovski")
@Since("4.1.0")
public class Config extends RapidoidThing implements ToMap<String, Object> {

private final Map<String, Object> properties;
Expand Down Expand Up @@ -332,4 +332,8 @@ public Properties toProperties() {
props.putAll(toFlatMap());
return props;
}

public ConfigAlternatives or(Config alternative) {
return new ConfigAlternatives(this, alternative);
}
}
@@ -0,0 +1,52 @@
package org.rapidoid.config;

/*
* #%L
* rapidoid-commons
* %%
* Copyright (C) 2014 - 2016 Nikolche Mihajlovski and contributors
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

import org.rapidoid.RapidoidThing;
import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;
import org.rapidoid.value.Value;

@Authors("Nikolche Mihajlovski")
@Since("5.1.0")
public class ConfigAlternatives extends RapidoidThing {

private final Config primary;

private final Config alternative;

public ConfigAlternatives(Config primary, Config alternative) {
this.primary = primary;
this.alternative = alternative;
}

public Value<Object> entry(String key) {
return primary.entry(key).orElse(alternative.entry(key));
}

public boolean has(String key) {
return primary.has(key) || alternative.has(key);
}

public Config sub(String key) {
return primary.has(key) ? primary.sub(key) : alternative.sub(key);
}
}
Expand Up @@ -51,7 +51,6 @@ public static synchronized void initialize() {
LogbackUtil.setupLogger();
}

Cls.getClassIfExists("org.rapidoid.web.RapidoidWebModule");
Cls.getClassIfExists("org.rapidoid.insight.Metrics");
}
}
Expand Down
@@ -1,8 +1,8 @@
package org.rapidoid.http;
package org.rapidoid.web;

/*
* #%L
* rapidoid-http-fast
* rapidoid-commons
* %%
* Copyright (C) 2014 - 2016 Nikolche Mihajlovski and contributors
* %%
Expand All @@ -20,97 +20,133 @@
* #L%
*/

import org.rapidoid.annotation.Authors;
import org.rapidoid.annotation.Since;

import java.util.Map;
import java.util.Set;

/**
* Response GUI Screen API.<br>
* GUI Screen (HTML Page) API.<br>
* Provides a convenient access to some common GUI screen attributes of the underlying MVC model: <code>Resp#model()</code>.
*/
@Authors("Nikolche Mihajlovski")
@Since("5.1.0")
public interface Screen {

/**
* Sets the "<b>title</b>" attribute in the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().put("title", title)</code>.
* Renders the screen.
*/
String render();

/**
* Sets the "<b>title</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen title(String title);

/**
* Gets the "<b>title</b>" attribute from the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().get("title")</code>.
* Gets the "<b>title</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
String title();

/**
* Sets the "<b>brand</b>" attribute in the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().put("brand", brand)</code>.
* Sets the "<b>brand</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen brand(Object brand);

/**
* Gets the "<b>brand</b>" attribute from the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().get("brand")</code>.
* Gets the "<b>brand</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
Object brand();

/**
* Sets the "<b>menu</b>" attribute in the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().put("menu", menu)</code>.
* Sets the "<b>content</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Object[] content();

/**
* Sets the "<b>content</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen menu(Object menu);
Screen content(Object... content);

/**
* Gets the "<b>menu</b>" attribute from the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().get("menu")</code>.
* Sets the "<b>menu</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Object menu();
Screen menu(Map<String, ?> menu);

/**
* Sets the "<b>search</b>" attribute in the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().put("search", search)</code>.
* Gets the "<b>menu</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
Map<String, Object> menu();

/**
* Sets the "<b>search</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen search(boolean search);

/**
* Gets the "<b>search</b>" attribute from the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().get("search")</code>.
* Gets the "<b>search</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
boolean search();

/**
* Sets the "<b>embedded</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
boolean embedded();

/**
* Sets the "<b>embedded</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Boolean search();
Screen embedded(boolean embedded);

/**
* Sets the "<b>cdn</b>" attribute in the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().put("cdn", cdn)</code>.
* Sets the "<b>cdn</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen cdn(boolean cdn);

/**
* Gets the "<b>cdn</b>" attribute from the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().get("cdn")</code>.
* Gets the "<b>cdn</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
Boolean cdn();
boolean cdn();

/**
* Sets the "<b>navbar</b>" attribute in the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().put("navbar", navbar)</code>.
* Sets the "<b>navbar</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen navbar(boolean navbar);

/**
* Gets the "<b>navbar</b>" attribute from the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().get("navbar")</code>.
* Gets the "<b>navbar</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
Boolean navbar();
boolean navbar();

/**
* Sets the "<b>fluid</b>" attribute in the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().put("fluid", fluid)</code>.
* Sets the "<b>fluid</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen fluid(boolean fluid);

/**
* Gets the "<b>fluid</b>" attribute from the MVC model of the response, used for GUI screen rendering.<br>
* Equivalent to <code>model().get("fluid")</code>.
* Gets the "<b>fluid</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
boolean fluid();

/**
* Sets the "<b>home</b>" attribute in the MVC model of the response, used for GUI page rendering.
*/
Screen home(String home);

/**
* Gets the "<b>home</b>" attribute from the MVC model of the response, used for GUI page rendering.
*/
String home();

/**
* Retrieves a modifiable set of JavaScript asset URIs, used for GUI page rendering.
*/
Set<String> js();

/**
* Retrieves a modifiable set of CSS asset URIs, used for GUI page rendering.
*/
Boolean fluid();
Set<String> css();

}

0 comments on commit e2c929e

Please sign in to comment.