Skip to content

Commit

Permalink
Formatting + code cleanup on java source files using wicket rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
akiraly committed Apr 12, 2011
1 parent 7296a1b commit a7a8545
Show file tree
Hide file tree
Showing 828 changed files with 29,343 additions and 23,118 deletions.
Expand Up @@ -16,35 +16,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wicketstuff.calendarviews.exampleapp;

import org.apache.wicket.protocol.http.WebApplication;

/**
* Application object for your web application. If you want to run this
* application without deploying, run the Start class.
*
* @see org.wicketstuff.calendarviews.exampleapp.StartCalendarsExamples#main(String[])
* @author Jeremy Thomerson
*/
public class ExampleCalendarApplication extends WebApplication {
/**
* Constructor
*/
public ExampleCalendarApplication() {
}

/**
* @see org.apache.wicket.Application#getHomePage()
*/
public Class<HomePage> getHomePage() {
return HomePage.class;
}

@Override
protected void init() {
super.init();

package org.wicketstuff.calendarviews.exampleapp;

import org.apache.wicket.protocol.http.WebApplication;

/**
* Application object for your web application. If you want to run this application without
* deploying, run the Start class.
*
* @see org.wicketstuff.calendarviews.exampleapp.StartCalendarsExamples#main(String[])
* @author Jeremy Thomerson
*/
public class ExampleCalendarApplication extends WebApplication
{
/**
* Constructor
*/
public ExampleCalendarApplication()
{
}

/**
* @see org.apache.wicket.Application#getHomePage()
*/
@Override
public Class<HomePage> getHomePage()
{
return HomePage.class;
}

@Override
protected void init()
{
super.init();

getDebugSettings().setComponentUseCheck(false);
}
}
}
}
Expand Up @@ -16,8 +16,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wicketstuff.calendarviews.exampleapp;

package org.wicketstuff.calendarviews.exampleapp;

import java.util.List;

import org.apache.wicket.AttributeModifier;
Expand All @@ -38,98 +38,122 @@
import org.wicketstuff.calendarviews.LargeView;
import org.wicketstuff.calendarviews.model.IEvent;
import org.wicketstuff.calendarviews.model.TimePeriod;

/**
* @author Jeremy Thomerson
*/
public class HomePage extends WebPage {

private static final String KEY_WEEKS = "0";
// private static final Logger LOGGER = LoggerFactory.getLogger(HomePage.class);

/**
* @author Jeremy Thomerson
*/
public class HomePage extends WebPage
{

private static final String KEY_WEEKS = "0";
// private static final Logger LOGGER = LoggerFactory.getLogger(HomePage.class);
private static final long serialVersionUID = 1L;
public static final ResourceReference EXAMPLES_CSS_REFERENCE = new PackageResourceReference(HomePage.class, "examples.css");

public HomePage() {
this(0);
}
public HomePage(PageParameters params) {
this(params.get(KEY_WEEKS).isNull() ? 0 : params.get(KEY_WEEKS).toInt());
}

public HomePage(int weeks) {
public static final ResourceReference EXAMPLES_CSS_REFERENCE = new PackageResourceReference(
HomePage.class, "examples.css");

public HomePage()
{
this(0);
}

public HomePage(PageParameters params)
{
this(params.get(KEY_WEEKS).isNull() ? 0 : params.get(KEY_WEEKS).toInt());
}

public HomePage(int weeks)
{
TimePeriod tp = LargeView.createMonthViewDates();
if (weeks != 0) {
if (weeks != 0)
{
tp = LargeView.createWeeksViewDates(weeks);
}
add(new LargeView("large", tp, new PersistentRandomTestEventProvider()) {
}
add(new LargeView("large", tp, new PersistentRandomTestEventProvider())
{
private static final long serialVersionUID = 1L;

@Override
protected Page createMoreDetailPage(IModel<DateMidnight> model, IModel<List<IEvent>> eventsModel) {
protected Page createMoreDetailPage(IModel<DateMidnight> model,
IModel<List<IEvent>> eventsModel)
{
Page page = super.createMoreDetailPage(model, eventsModel);
page.add(new Behavior() {
page.add(new Behavior()
{
@Override
public void renderHead(Component component,
IHeaderResponse response) {
public void renderHead(Component component, IHeaderResponse response)
{

response.renderCSSReference(EXAMPLES_CSS_REFERENCE);
}
});
return page;
}

@Override
protected WebMarkupContainer createEventLink(String id, final IModel<IEvent> model) {
protected WebMarkupContainer createEventLink(String id, final IModel<IEvent> model)
{
WebMarkupContainer wmc = new WebMarkupContainer(id);
wmc.add(new AttributeModifier("onclick", true, new AbstractReadOnlyModel<String>() {
wmc.add(new AttributeModifier("onclick", true, new AbstractReadOnlyModel<String>()
{
private static final long serialVersionUID = 1L;

@Override
public String getObject() {
return "alert('" + JavaScriptUtils.escapeQuotes(model.getObject().getTitle()) + "');";
public String getObject()
{
return "alert('" +
JavaScriptUtils.escapeQuotes(model.getObject().getTitle()) + "');";
}

}));
return wmc;
}
});
addLinks();
}

addLinks();
}

@Override
public void renderHead(IHeaderResponse response) {
public void renderHead(IHeaderResponse response)
{
super.renderHead(response);

response.renderCSSReference(EXAMPLES_CSS_REFERENCE);
}

private void addLinks() {
add(createLink("month", 0));
add(createLink("2weeks", 2));
add(createLink("3weeks", 3));
add(createLink("4weeks", 4));
add(createLink("5weeks", 5));
add(createLink("6weeks", 6));
}

public static PageParameters createParameters(int weeks) {
PageParameters params = null;
if (weeks > 0) {
params = new PageParameters();
params.add(KEY_WEEKS, Integer.toString(weeks));
}
return params;
}
public static Link<Void> createLink(String id, final int weeks) {
return new Link<Void>(id) {
private static final long serialVersionUID = 1L;

@Override
public void onClick() {
PersistentRandomTestEventProvider.clearEventsForFreshReload();
setResponsePage(HomePage.class, createParameters(weeks));
}

};
}
}

private void addLinks()
{
add(createLink("month", 0));
add(createLink("2weeks", 2));
add(createLink("3weeks", 3));
add(createLink("4weeks", 4));
add(createLink("5weeks", 5));
add(createLink("6weeks", 6));
}

public static PageParameters createParameters(int weeks)
{
PageParameters params = null;
if (weeks > 0)
{
params = new PageParameters();
params.add(KEY_WEEKS, Integer.toString(weeks));
}
return params;
}

public static Link<Void> createLink(String id, final int weeks)
{
return new Link<Void>(id)
{
private static final long serialVersionUID = 1L;

@Override
public void onClick()
{
PersistentRandomTestEventProvider.clearEventsForFreshReload();
setResponsePage(HomePage.class, createParameters(weeks));
}

};
}
}
Expand Up @@ -23,25 +23,29 @@
import org.wicketstuff.calendarviews.model.IEvent;

/**
* For testing - allows you to use a set of random test data that won't change
* with every page refresh or change. Can be cleared upon request.
* For testing - allows you to use a set of random test data that won't change with every page
* refresh or change. Can be cleared upon request.
*
* @author Jeremy Thomerson
*/
public class PersistentRandomTestEventProvider extends RandomTestEventProvider {
public class PersistentRandomTestEventProvider extends RandomTestEventProvider
{

private static final long serialVersionUID = 1L;
private static Collection<? extends IEvent> STATIC_COLLECTION = null;

@Override
protected Collection<? extends IEvent> load() {
if (STATIC_COLLECTION == null) {
protected Collection<? extends IEvent> load()
{
if (STATIC_COLLECTION == null)
{
STATIC_COLLECTION = super.load();
}
return STATIC_COLLECTION;
}

public static final void clearEventsForFreshReload() {

public static final void clearEventsForFreshReload()
{
STATIC_COLLECTION = null;
}
}

0 comments on commit a7a8545

Please sign in to comment.