diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/ExampleCalendarApplication.java b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/ExampleCalendarApplication.java index 0cf7a621ea..85cb37cf79 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/ExampleCalendarApplication.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/ExampleCalendarApplication.java @@ -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 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 getHomePage() + { + return HomePage.class; + } + + @Override + protected void init() + { + super.init(); + getDebugSettings().setComponentUseCheck(false); - } -} + } +} diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/HomePage.java b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/HomePage.java index 62e177f37e..811eb28790 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/HomePage.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/HomePage.java @@ -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; @@ -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 model, IModel> eventsModel) { + protected Page createMoreDetailPage(IModel model, + IModel> 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 model) { + protected WebMarkupContainer createEventLink(String id, final IModel model) + { WebMarkupContainer wmc = new WebMarkupContainer(id); - wmc.add(new AttributeModifier("onclick", true, new AbstractReadOnlyModel() { + wmc.add(new AttributeModifier("onclick", true, new AbstractReadOnlyModel() + { 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 createLink(String id, final int weeks) { - return new Link(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 createLink(String id, final int weeks) + { + return new Link(id) + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick() + { + PersistentRandomTestEventProvider.clearEventsForFreshReload(); + setResponsePage(HomePage.class, createParameters(weeks)); + } + + }; + } +} diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/PersistentRandomTestEventProvider.java b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/PersistentRandomTestEventProvider.java index 959395b062..14eb4e51a7 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/PersistentRandomTestEventProvider.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/PersistentRandomTestEventProvider.java @@ -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 STATIC_COLLECTION = null; @Override - protected Collection load() { - if (STATIC_COLLECTION == null) { + protected Collection 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; } } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/RandomTestEventProvider.java b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/RandomTestEventProvider.java index c00e26dcc7..a7635efc00 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/RandomTestEventProvider.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/main/java/org/wicketstuff/calendarviews/exampleapp/RandomTestEventProvider.java @@ -37,92 +37,123 @@ /** * @author Jeremy Thomerson */ -public class RandomTestEventProvider extends LoadableDetachableModel> implements IEventProvider { +public class RandomTestEventProvider extends LoadableDetachableModel> + implements IEventProvider +{ private static final long serialVersionUID = 1L; private static final long MILLIS_DAY = 1000 * 60 * 60 * 24; private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd"); private static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm"); - + private final Random mRandom = new Random(); private final Set mEvents = new HashSet(); - - protected Collection load() { + + @Override + protected Collection load() + { return mEvents; } - public void initializeWithDateRange(Date start, Date end) { - if (isAttached()) { + public void initializeWithDateRange(Date start, Date end) + { + if (isAttached()) + { return; } - int counter = 1; - if (getAdjustedDate(start, +3).before(end)) { - // let's add one that starts 10 days before and runs three days into range - mEvents.add(createEvent(counter++, true, getAdjustedDate(start, -10), getAdjustedDate(start, +3))); - } - // let's add one that starts 5 days before and runs 5 days after range - mEvents.add(createEvent(counter++, true, getAdjustedDate(start, -5), getAdjustedDate(end, +5))); - - // start a few days early so that we can get ones that start before but extend into this range - for (Date current = getAdjustedDate(start, -3); current.before(end); current = getAdjustedDate(current, +1)) { + int counter = 1; + if (getAdjustedDate(start, +3).before(end)) + { + // let's add one that starts 10 days before and runs three days into range + mEvents.add(createEvent(counter++, true, getAdjustedDate(start, -10), + getAdjustedDate(start, +3))); + } + // let's add one that starts 5 days before and runs 5 days after range + mEvents.add(createEvent(counter++, true, getAdjustedDate(start, -5), + getAdjustedDate(end, +5))); + + // start a few days early so that we can get ones that start before but extend into this +// range + for (Date current = getAdjustedDate(start, -3); current.before(end); current = getAdjustedDate( + current, +1)) + { int events = mRandom.nextInt(4); - for (int i = 1; i <= events; i++) { - IEvent evt = createRandomEvent(current, counter++); - if (evt.getStartTime().before(start)) { - // this is one that starts out of range, so let's only add it if it extends into range - // this mimics what a well-behaved provider should do according to contract - if (evt.getEndTime() == null || evt.getEndTime().before(start)) { - counter--; - continue; - } - } + for (int i = 1; i <= events; i++) + { + IEvent evt = createRandomEvent(current, counter++); + if (evt.getStartTime().before(start)) + { + // this is one that starts out of range, so let's only add it if it extends into +// range + // this mimics what a well-behaved provider should do according to contract + if (evt.getEndTime() == null || evt.getEndTime().before(start)) + { + counter--; + continue; + } + } mEvents.add(evt); } - } + } } - protected final Date getAdjustedDate(Date date, int days) { - return new Date(date.getTime() + (days * MILLIS_DAY)); - } - - private IEvent createRandomEvent(Date current, int id) { - // TODO: add support for events that last from a certain time today to a certain time tomorrow + protected final Date getAdjustedDate(Date date, int days) + { + return new Date(date.getTime() + (days * MILLIS_DAY)); + } + + private IEvent createRandomEvent(Date current, int id) + { + // TODO: add support for events that last from a certain time today to a certain time +// tomorrow boolean multiDay = mRandom.nextInt(4) == 1; Date start = new DateMidnight(current).toDate(); - if (multiDay) { + if (multiDay) + { // a multi-day event (always all-day) Date end = new DateTime(start).plusDays(mRandom.nextInt(9)).toDate(); return createEvent(id, true, start, end); } boolean allDay = mRandom.nextInt(3) == 1; - if (allDay) { + if (allDay) + { // an all day, single-day event return createEvent(id, true, start, null); } - + // this is a partial day event int startHour = mRandom.nextInt(13); int startMinutes = (mRandom.nextInt(4) * 15); int durationHours = mRandom.nextInt(5); int durationMinutes = (mRandom.nextInt(4) * 15); - start = new DateTime(new DateMidnight(current)).plusHours(startHour).plusMinutes(startMinutes).toDate(); - Date end = new DateTime(start).plusHours(durationHours).plusMinutes(durationMinutes).toDate(); + start = new DateTime(new DateMidnight(current)).plusHours(startHour) + .plusMinutes(startMinutes) + .toDate(); + Date end = new DateTime(start).plusHours(durationHours) + .plusMinutes(durationMinutes) + .toDate(); return createEvent(id, false, start, end); - } - - private BasicEvent createEvent(int id, boolean allDay, Date start, Date end) { + } + + private BasicEvent createEvent(int id, boolean allDay, Date start, Date end) + { BasicCategorizedEvent event = new BasicCategorizedEvent(); StringBuffer title = new StringBuffer(); - //title.append("Event"); + // title.append("Event"); title.append(" #").append(id); - if (allDay) { + if (allDay) + { title.append(" [").append(DATE_FORMAT.format(start)); - if (end != null) { + if (end != null) + { title.append(" - ").append(DATE_FORMAT.format(end)); } - } else { + } + else + { title.append(" [").append(TIME_FORMAT.format(start)); - if (end != null) { + if (end != null) + { title.append(" - ").append(TIME_FORMAT.format(end)); } } @@ -131,8 +162,8 @@ private BasicEvent createEvent(int id, boolean allDay, Date start, Date end) { event.setAllDayEvent(allDay); event.setStartTime(start); event.setEndTime(end); - event.setCssClassForCategory("cat" + ((mRandom.nextInt(3)) + 1)); - return event; + event.setCssClassForCategory("cat" + ((mRandom.nextInt(3)) + 1)); + return event; } } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/test/java/org/wicketstuff/calendarviews/exampleapp/StartCalendarViewsExamples.java b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/test/java/org/wicketstuff/calendarviews/exampleapp/StartCalendarViewsExamples.java index 5598b606f1..63c1c66b89 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/test/java/org/wicketstuff/calendarviews/exampleapp/StartCalendarViewsExamples.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews-examples/src/test/java/org/wicketstuff/calendarviews/exampleapp/StartCalendarViewsExamples.java @@ -16,52 +16,58 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.wicketstuff.calendarviews.exampleapp; - -import org.mortbay.jetty.Connector; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.bio.SocketConnector; -import org.mortbay.jetty.webapp.WebAppContext; - -/** - * @author Jeremy Thomerson - */ -public class StartCalendarViewsExamples { - - public static void main(String[] args) throws Exception { - Server server = new Server(); - SocketConnector connector = new SocketConnector(); - // Set some timeout options to make debugging easier. - connector.setMaxIdleTime(1000 * 60 * 60); - connector.setSoLingerTime(-1); - connector.setPort(8080); - server.setConnectors(new Connector[] { connector }); - - WebAppContext bb = new WebAppContext(); - bb.setServer(server); - bb.setContextPath("/"); - bb.setWar("src/main/webapp"); - - - // START JMX SERVER - // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); - // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); - // server.getContainer().addEventListener(mBeanContainer); - // mBeanContainer.start(); - - server.addHandler(bb); - - try { - System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); - server.start(); - while (System.in.available() == 0) { - Thread.sleep(5000); - } - server.stop(); - server.join(); - } catch (Exception e) { - e.printStackTrace(); - System.exit(100); - } - } -} +package org.wicketstuff.calendarviews.exampleapp; + +import org.mortbay.jetty.Connector; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.bio.SocketConnector; +import org.mortbay.jetty.webapp.WebAppContext; + +/** + * @author Jeremy Thomerson + */ +public class StartCalendarViewsExamples +{ + + public static void main(String[] args) throws Exception + { + Server server = new Server(); + SocketConnector connector = new SocketConnector(); + // Set some timeout options to make debugging easier. + connector.setMaxIdleTime(1000 * 60 * 60); + connector.setSoLingerTime(-1); + connector.setPort(8080); + server.setConnectors(new Connector[] { connector }); + + WebAppContext bb = new WebAppContext(); + bb.setServer(server); + bb.setContextPath("/"); + bb.setWar("src/main/webapp"); + + + // START JMX SERVER + // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); + // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); + // server.getContainer().addEventListener(mBeanContainer); + // mBeanContainer.start(); + + server.addHandler(bb); + + try + { + System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); + server.start(); + while (System.in.available() == 0) + { + Thread.sleep(5000); + } + server.stop(); + server.join(); + } + catch (Exception e) + { + e.printStackTrace(); + System.exit(100); + } + } +} diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/AddCssClassBehavior.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/AddCssClassBehavior.java index e4ff7587ea..d28cc26ee0 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/AddCssClassBehavior.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/AddCssClassBehavior.java @@ -30,37 +30,42 @@ import org.wicketstuff.calendarviews.util.StringUtil; /** - * A behavior for adding a class attribute of ICategorizedEvent - * events to a component, even if there is already a class on the tag. - * If there is, this behavior will add a space between the two classes. - * + * A behavior for adding a class attribute of ICategorizedEvent events to a component, even + * if there is already a class on the tag. If there is, this behavior will add a space between the + * two classes. + * * @author Jeremy Thomerson */ -public class AddCssClassBehavior extends Behavior { +public class AddCssClassBehavior extends Behavior +{ private static final String ATTRIBUTE_NAME = "class"; private static final long serialVersionUID = 1L; private final IModel mEventModel; - - public AddCssClassBehavior(IModel event) { + + public AddCssClassBehavior(IModel event) + { mEventModel = event; } @Override - public void onComponentTag(Component component, ComponentTag tag) { + public void onComponentTag(Component component, ComponentTag tag) + { super.onComponentTag(component, tag); List classes = new ArrayList(); String existing = tag.getAttributes().getString(ATTRIBUTE_NAME); - if (StringUtil.isEmpty(existing) == false) { + if (StringUtil.isEmpty(existing) == false) + { classes.add(existing); } - + IEvent event = mEventModel.getObject(); classes.add(event.isAllDayEvent() ? "allday" : "partday"); - - if (event instanceof ICategorizedEvent) { - String css = ((ICategorizedEvent) event).getCssClassForCategory(); + + if (event instanceof ICategorizedEvent) + { + String css = ((ICategorizedEvent)event).getCssClassForCategory(); classes.add(css); } tag.put(ATTRIBUTE_NAME, StringUtil.join(classes.toArray(new String[classes.size()]), " ")); diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/BaseCalendarView.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/BaseCalendarView.java index f2d9c9cd55..95682ad3f2 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/BaseCalendarView.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/BaseCalendarView.java @@ -40,20 +40,24 @@ import org.wicketstuff.calendarviews.model.IEventProvider; import org.wicketstuff.calendarviews.util.Comparators; -public abstract class BaseCalendarView extends Panel { - +public abstract class BaseCalendarView extends Panel +{ + private static final long serialVersionUID = 1L; - public static final PackageResourceReference CALENDARS_CSS_REFERENCE = new PackageResourceReference(BaseCalendarView.class, "calendars.css"); -// private static final Logger LOGGER = LoggerFactory.getLogger(BaseCalendarView.class); + public static final PackageResourceReference CALENDARS_CSS_REFERENCE = new PackageResourceReference( + BaseCalendarView.class, "calendars.css"); +// private static final Logger LOGGER = LoggerFactory.getLogger(BaseCalendarView.class); private final Date mStartDate; private final Date mEndDate; private IEventProvider mEventProvider; - public BaseCalendarView(String id, Date startDate, Date endDate, IEventProvider eventProvider) { + public BaseCalendarView(String id, Date startDate, Date endDate, IEventProvider eventProvider) + { super(id); - - if (startDate == null || endDate == null || eventProvider == null) { + + if (startDate == null || endDate == null || eventProvider == null) + { throw new IllegalArgumentException("no null parameters are allowed in this constructor"); } mStartDate = startDate; @@ -62,82 +66,106 @@ public BaseCalendarView(String id, Date startDate, Date endDate, IEventProvider } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { super.renderHead(response); - + response.renderCSSReference(CALENDARS_CSS_REFERENCE); } - + /* Helper methods for subclasses */ - protected final Map> convertToMapByDay(Collection allEvents) { + protected final Map> convertToMapByDay( + Collection allEvents) + { // TODO: this could probably use a much more efficient algorithm Map> map = new HashMap>(); - for (IEvent event : allEvents) { + for (IEvent event : allEvents) + { getRenderStrategy().mapEvent(map, event, this); } // now sort - for (List list : map.values()) { + for (List list : map.values()) + { Collections.sort(list, Comparators.EVENT_START_DATE_ASC_COMPARATOR); } return map; } - - protected IRenderStrategy getRenderStrategy() { - return IRenderStrategy.EVERY_DAY_OF_EVENT; + + protected IRenderStrategy getRenderStrategy() + { + return IRenderStrategy.EVERY_DAY_OF_EVENT; } - protected IDataProvider createDaysDataProvider(final DateTime start, final DateTime end, final Period period) { - return new IDataProvider() { + protected IDataProvider createDaysDataProvider(final DateTime start, + final DateTime end, final Period period) + { + return new IDataProvider() + { private static final long serialVersionUID = 1L; - public Iterator iterator(final int first, int count) { + public Iterator iterator(final int first, int count) + { return createDateMidnightIterator(start, end, first, count); } - public IModel model(DateMidnight object) { + public IModel model(DateMidnight object) + { return new Model(object); } - public int size() { + public int size() + { return period.getDays() + 1; } - public void detach() { + public void detach() + { // no-op } - + @Override - public String toString() { + public String toString() + { return "BaseCalendarView#DaysDataProvider [size: " + size() + "]"; } }; } - protected Iterator createDateMidnightIterator(DateTime start, DateTime end, int first, int count) { + protected Iterator createDateMidnightIterator(DateTime start, + DateTime end, int first, int count) + { return new DateMidnightIterator(start, end, first, count); } - protected final int getNumberOfColumns() { + protected final int getNumberOfColumns() + { return 7; } - protected final int getLastDayOfWeek() { + protected final int getLastDayOfWeek() + { return 6; } - protected final int getFirstDayOfWeek() { + protected final int getFirstDayOfWeek() + { return 7; } - + /* Getters / Setters */ - public final IEventProvider getEventProvider() { + public final IEventProvider getEventProvider() + { return mEventProvider; } - public final Date getStartDate() { + + public final Date getStartDate() + { return mStartDate; } - public final Date getEndDate() { + + public final Date getEndDate() + { return mEndDate; } } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/FullWeekCalendarView.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/FullWeekCalendarView.java index f89fb80c67..2617e50c90 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/FullWeekCalendarView.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/FullWeekCalendarView.java @@ -34,38 +34,42 @@ * * @author Jeremy Thomerson */ -public class FullWeekCalendarView extends BaseCalendarView { +public class FullWeekCalendarView extends BaseCalendarView +{ private static final Logger LOGGER = LoggerFactory.getLogger(FullWeekCalendarView.class); private static final long serialVersionUID = 1L; - public FullWeekCalendarView(String id, Date startDate, Date endDate, IEventProvider eventProvider) { + public FullWeekCalendarView(String id, Date startDate, Date endDate, + IEventProvider eventProvider) + { super(id, startDate, endDate, eventProvider); } /** - * This implementation makes sure to include the entire data range specified - * by the start date and end date passed in to the constructor, and any - * additional days before and after that are needed to complete the full weeks - * contained in this view. + * This implementation makes sure to include the entire data range specified by the start date + * and end date passed in to the constructor, and any additional days before and after that are + * needed to complete the full weeks contained in this view. * * @return a data provider of days to be shown on the calendar */ - protected final IDataProvider createDaysDataProvider() { + protected final IDataProvider createDaysDataProvider() + { int firstDOW = getFirstDayOfWeek(); int lastDOW = getLastDayOfWeek(); - // TODO: is this logic right? doing this since JODA has Sunday as day 7 + // TODO: is this logic right? doing this since JODA has Sunday as day 7 int add = firstDOW > lastDOW ? -7 : 0; final DateTime start = new DateTime(getStartDate()).withDayOfWeek(firstDOW).plusDays(add); final DateTime end = new DateTime(getEndDate()).withDayOfWeek(lastDOW); final Period period = new Period(start, end, PeriodType.days()); getEventProvider().initializeWithDateRange(start.toDate(), end.toDate()); - - if (LOGGER.isDebugEnabled()) { + + if (LOGGER.isDebugEnabled()) + { LOGGER.debug("start: " + start + "; end: " + end + "; days: " + period.getDays()); } - + return createDaysDataProvider(start, end, period); } } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/IRenderStrategy.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/IRenderStrategy.java index 9ec7c98b4e..d978702639 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/IRenderStrategy.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/IRenderStrategy.java @@ -27,58 +27,87 @@ import org.wicketstuff.calendarviews.logic.DateMidnightIterator; import org.wicketstuff.calendarviews.model.IEvent; -public interface IRenderStrategy { - +public interface IRenderStrategy +{ + void mapEvent(Map> map, IEvent event, BaseCalendarView calendar); - public static final IRenderStrategy ONLY_ONCE_PER_EVENT = new IRenderStrategy() { - public void mapEvent(Map> map, IEvent event, BaseCalendarView calendar) { + public static final IRenderStrategy ONLY_ONCE_PER_EVENT = new IRenderStrategy() + { + public void mapEvent(Map> map, IEvent event, + BaseCalendarView calendar) + { RenderStrategyUtility.addEventToDate(map, new DateMidnight(event.getStartTime()), event); } }; - - public static final IRenderStrategy EVERY_DAY_OF_EVENT = new IRenderStrategy() { - public void mapEvent(Map> map, IEvent event, BaseCalendarView calendar) { + + public static final IRenderStrategy EVERY_DAY_OF_EVENT = new IRenderStrategy() + { + public void mapEvent(Map> map, IEvent event, + BaseCalendarView calendar) + { DateMidnight start = new DateMidnight(event.getStartTime()); DateMidnight end = start; - if (event.getEndTime() != null && event.getEndTime().equals(event.getStartTime()) == false) { + if (event.getEndTime() != null && + event.getEndTime().equals(event.getStartTime()) == false) + { end = new DateMidnight(event.getEndTime()); } - if (end.isAfter(start)) { - for (Iterator it = new DateMidnightIterator(start.toDateTime(), end.toDateTime()); it.hasNext(); ) { + if (end.isAfter(start)) + { + for (Iterator it = new DateMidnightIterator(start.toDateTime(), + end.toDateTime()); it.hasNext();) + { RenderStrategyUtility.addEventToDate(map, it.next(), event); } - } else { + } + else + { RenderStrategyUtility.addEventToDate(map, start, event); } } }; - - - public static final IRenderStrategy FIRST_AND_FIRST_OF_ROW = new IRenderStrategy() { - public void mapEvent(Map> map, IEvent event, BaseCalendarView calendar) { + + + public static final IRenderStrategy FIRST_AND_FIRST_OF_ROW = new IRenderStrategy() + { + public void mapEvent(Map> map, IEvent event, + BaseCalendarView calendar) + { DateMidnight start = new DateMidnight(event.getStartTime()); DateMidnight end = start; - if (event.getEndTime() != null && event.getEndTime().equals(event.getStartTime()) == false) { + if (event.getEndTime() != null && + event.getEndTime().equals(event.getStartTime()) == false) + { end = new DateMidnight(event.getEndTime()); } - if (end.isAfter(start)) { - for (Iterator it = new DateMidnightIterator(start.toDateTime(), end.toDateTime()); it.hasNext(); ) { + if (end.isAfter(start)) + { + for (Iterator it = new DateMidnightIterator(start.toDateTime(), + end.toDateTime()); it.hasNext();) + { DateMidnight date = it.next(); - if (date.equals(start) || date.getDayOfWeek() == calendar.getFirstDayOfWeek()) { + if (date.equals(start) || date.getDayOfWeek() == calendar.getFirstDayOfWeek()) + { RenderStrategyUtility.addEventToDate(map, date, event); } } - } else { + } + else + { RenderStrategyUtility.addEventToDate(map, start, event); } } }; - public static class RenderStrategyUtility { - private static void addEventToDate(Map> map, DateMidnight date, IEvent event) { + public static class RenderStrategyUtility + { + private static void addEventToDate(Map> map, DateMidnight date, + IEvent event) + { List events = map.get(date); - if (events == null) { + if (events == null) + { events = new ArrayList(); map.put(date, events); } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/LargeView.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/LargeView.java index 26f3e39726..f09df6ab36 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/LargeView.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/LargeView.java @@ -57,34 +57,34 @@ import org.wicketstuff.jslibraries.VersionDescriptor; /** - * This is a larger view of a calendar, typically used for multiple weeks or - * entire months. It generates a month-style grid calendar with events that can - * span multiple days and supports categorized events.
+ * This is a larger view of a calendar, typically used for multiple weeks or entire months. It + * generates a month-style grid calendar with events that can span multiple days and supports + * categorized events.
*
- * You could think of it as similar to the month view in Outlook or Google - * calendar. + * You could think of it as similar to the month view in Outlook or Google calendar. * * @author Jeremy Thomerson */ -public class LargeView extends FullWeekCalendarView { +public class LargeView extends FullWeekCalendarView +{ - private static final VersionDescriptor JS_LIB_VERSION_DESCRIPTOR = VersionDescriptor - .alwaysLatestOfVersion(Library.PROTOTYPE, 1, 6); + private static final VersionDescriptor JS_LIB_VERSION_DESCRIPTOR = VersionDescriptor.alwaysLatestOfVersion( + Library.PROTOTYPE, 1, 6); private static final long serialVersionUID = 1L; - private static final Logger LOGGER = LoggerFactory - .getLogger(LargeView.class); + private static final Logger LOGGER = LoggerFactory.getLogger(LargeView.class); - public static final PackageResourceReference JS = new PackageResourceReference( - LargeView.class, "LargeView.js"); + public static final PackageResourceReference JS = new PackageResourceReference(LargeView.class, + "LargeView.js"); private final ModalWindow mDetailModal; - public LargeView(String id, TimePeriod tp, IEventProvider eventProvider) { + public LargeView(String id, TimePeriod tp, IEventProvider eventProvider) + { this(id, tp.getStartDate(), tp.getEndDate(), eventProvider); } - public LargeView(String id, Date startDate, Date endDate, - IEventProvider eventProvider) { + public LargeView(String id, Date startDate, Date endDate, IEventProvider eventProvider) + { super(id, startDate, endDate, eventProvider); setOutputMarkupId(true); @@ -96,75 +96,79 @@ public LargeView(String id, Date startDate, Date endDate, Collection allEvents = getEventProvider().getObject(); final Map> mapOfEvents = convertToMapByDay(allEvents); - if (LOGGER.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) + { LOGGER.debug("Data provider: " + dp); } add(new LargeGridView("rows", dp, mapOfEvents)); } - protected final void initializeDetailModalWindow(ModalWindow modal) { + protected final void initializeDetailModalWindow(ModalWindow modal) + { modal.setCookieName("calendar-detail-modal"); } @Override - protected final IRenderStrategy getRenderStrategy() { + protected final IRenderStrategy getRenderStrategy() + { return IRenderStrategy.FIRST_AND_FIRST_OF_ROW; } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { super.renderHead(response); - JSLib.getHeaderContribution(JS_LIB_VERSION_DESCRIPTOR).renderHead( - response); + JSLib.getHeaderContribution(JS_LIB_VERSION_DESCRIPTOR).renderHead(response); response.renderJavaScriptReference(JS); String calID = LargeView.this.getMarkupId(); - response.renderOnDomReadyJavaScript("LargeViewCalendar.initialize('" - + calID + "');"); + response.renderOnDomReadyJavaScript("LargeViewCalendar.initialize('" + calID + "');"); } protected final ListView createEventListView(String id, - final IModel dateModel, final int cellsLeftInRow, - IModel> model) { - return new ListView(id, model) { + final IModel dateModel, final int cellsLeftInRow, IModel> model) + { + return new ListView(id, model) + { private static final long serialVersionUID = 1L; @Override - protected void populateItem(final ListItem item) { - WebMarkupContainer link = createEventLink("link", item - .getModel()); + protected void populateItem(final ListItem item) + { + WebMarkupContainer link = createEventLink("link", item.getModel()); link.add(createStartTimeLabel("startTime", item.getModel())); - link.add(new Label("title", new PropertyModel(item - .getModel(), "title"))); + link.add(new Label("title", new PropertyModel(item.getModel(), "title"))); item.add(link); - // things to decorate the item itself - item.add(new HowManyDaysClassBehavior(dateModel, - cellsLeftInRow, item.getModel())); + // things to decorate the item itself + item.add(new HowManyDaysClassBehavior(dateModel, cellsLeftInRow, item.getModel())); item.add(new AddCssClassBehavior(item.getModel())); } - private Label createStartTimeLabel(String id, - final IModel model) { - return new Label(id, new LoadableDetachableModel() { + private Label createStartTimeLabel(String id, final IModel model) + { + return new Label(id, new LoadableDetachableModel() + { private static final long serialVersionUID = 1L; @Override - protected String load() { + protected String load() + { // TODO : make this implementation more // internationalized... this one is too static // use dateformat or something - DateTime start = new DateTime(model.getObject() - .getStartTime()); + DateTime start = new DateTime(model.getObject().getStartTime()); StringBuffer sb = new StringBuffer(); int hr = start.getHourOfDay(); sb.append(hr > 12 ? hr - 12 : hr); int min = start.getMinuteOfHour(); - if (min != 0) { + if (min != 0) + { sb.append(':'); - if (min < 0) { + if (min < 0) + { sb.append('0'); } sb.append(min); @@ -173,11 +177,13 @@ protected String load() { return sb.toString(); } - }) { + }) + { private static final long serialVersionUID = 1L; @Override - public boolean isVisible() { + public boolean isVisible() + { return model.getObject().isAllDayEvent() == false; } }; @@ -185,79 +191,88 @@ public boolean isVisible() { }; } - private class LargeGridView extends GridView { + private class LargeGridView extends GridView + { private static final long serialVersionUID = 1L; private Map> mMapOfEvents; private int mCounter; public LargeGridView(String id, IDataProvider dp, - Map> mapOfEvents) { + Map> mapOfEvents) + { super(id, dp); mMapOfEvents = mapOfEvents; } @Override - public int getColumns() { - return LargeView.this.getNumberOfColumns(); + public int getColumns() + { + return getNumberOfColumns(); } @Override - protected void populateEmptyItem(Item item) { - throw new UnsupportedOperationException( - "LargeView should not have any empty items"); + protected void populateEmptyItem(Item item) + { + throw new UnsupportedOperationException("LargeView should not have any empty items"); } @Override - protected void populateItem(final Item item) { + protected void populateItem(final Item item) + { int cell = (mCounter++ % getColumns()) + 1; int cellsLeft = getColumns() - cell; - final LoadableDetachableModel> eventsModel = new LoadableDetachableModel>() { + final LoadableDetachableModel> eventsModel = new LoadableDetachableModel>() + { private static final long serialVersionUID = 1L; @Override - protected List load() { + protected List load() + { return mMapOfEvents.get(item.getModelObject()); } }; - Label dateHeader = new Label("date", new PropertyModel( - item.getModel(), "dayOfMonth")); - dateHeader.add(new AjaxEventBehavior("onclick") { + Label dateHeader = new Label("date", new PropertyModel(item.getModel(), + "dayOfMonth")); + dateHeader.add(new AjaxEventBehavior("onclick") + { private static final long serialVersionUID = 1L; @Override - protected void onEvent(AjaxRequestTarget target) { - LOGGER.debug("Show more events for: " - + item.getModelObject()); + protected void onEvent(AjaxRequestTarget target) + { + LOGGER.debug("Show more events for: " + item.getModelObject()); onMoreLinkClicked(target, item.getModel(), eventsModel); } }); item.add(dateHeader); - item.add(createEventListView("events", item.getModel(), cellsLeft, - eventsModel)); + item.add(createEventListView("events", item.getModel(), cellsLeft, eventsModel)); } @Override - protected void onDetach() { + protected void onDetach() + { super.onDetach(); } } - protected void onMoreLinkClicked(AjaxRequestTarget target, - IModel model, IModel> eventsModel) { - mDetailModal.setPageCreator(getDetailModalPageCreator(model, - eventsModel)); + protected void onMoreLinkClicked(AjaxRequestTarget target, IModel model, + IModel> eventsModel) + { + mDetailModal.setPageCreator(getDetailModalPageCreator(model, eventsModel)); mDetailModal.show(target); } - protected PageCreator getDetailModalPageCreator( - final IModel model, - final IModel> eventsModel) { - return new ModalWindow.PageCreator() { + protected PageCreator getDetailModalPageCreator(final IModel model, + final IModel> eventsModel) + { + return new ModalWindow.PageCreator() + { private static final long serialVersionUID = 1L; - public Page createPage() { + public Page createPage() + { return createMoreDetailPage(model, eventsModel); } @@ -265,64 +280,79 @@ public Page createPage() { } protected Page createMoreDetailPage(final IModel model, - final IModel> eventsModel) { + final IModel> eventsModel) + { return new DateDetailPage(model, eventsModel, - new DateDetailPage.IDateDetailPageEventLinkCreator() { - private static final long serialVersionUID = 1L; + new DateDetailPage.IDateDetailPageEventLinkCreator() + { + private static final long serialVersionUID = 1L; - public WebMarkupContainer createEventLink(String id, - IModel model) { - return LargeView.this.createEventLink(id, model); - } - }); + public WebMarkupContainer createEventLink(String id, IModel model) + { + return LargeView.this.createEventLink(id, model); + } + }); } - protected WebMarkupContainer createEventLink(String id, IModel model) { + protected WebMarkupContainer createEventLink(String id, IModel model) + { return new WebMarkupContainer(id); } - public static TimePeriod createWeeksViewDates(int weeks) { + public static TimePeriod createWeeksViewDates(int weeks) + { // TODO add a similar method that allows an offset of weeks (i.e. 3 - // weeks, starting two weeks past today) + // weeks, starting two weeks past today) Date start = new Date(); Date end = new DateTime(start).plusWeeks(weeks - 1).toDate(); return new TimePeriod(start, end); } - public static TimePeriod createMonthViewDates() { + public static TimePeriod createMonthViewDates() + { Date start = new DateTime().dayOfMonth().setCopy(1).toDate(); Date end = new DateTime(start).plusMonths(1).minusDays(1).toDate(); return new TimePeriod(start, end); } - public static TimePeriod createMonthViewDates(int month, int year) { - Date start = new DateTime().dayOfMonth().setCopy(1).monthOfYear() - .setCopy(month).year().setCopy(year).toDate(); + public static TimePeriod createMonthViewDates(int month, int year) + { + Date start = new DateTime().dayOfMonth() + .setCopy(1) + .monthOfYear() + .setCopy(month) + .year() + .setCopy(year) + .toDate(); Date end = new DateTime(start).plusMonths(1).minusDays(1).toDate(); return new TimePeriod(start, end); } - private static class HowManyDaysClassBehavior extends Behavior { + private static class HowManyDaysClassBehavior extends Behavior + { private static final long serialVersionUID = 1L; private int mDaysLeftInRow; private IModel mDateModel; private IModel mEventModel; - public HowManyDaysClassBehavior(IModel dateModel, - int daysLeftInRow, IModel model) { + public HowManyDaysClassBehavior(IModel dateModel, int daysLeftInRow, + IModel model) + { mDaysLeftInRow = daysLeftInRow; mDateModel = dateModel; mEventModel = model; } @Override - public void onComponentTag(Component component, ComponentTag tag) { + public void onComponentTag(Component component, ComponentTag tag) + { super.onComponentTag(component, tag); DateMidnight day = mDateModel.getObject(); Date end = mEventModel.getObject().getEndTime(); int numberOfDays = 1; - if (end != null) { + if (end != null) + { DateTime endTime = new DateTime(end); int days = Math.abs(Days.daysBetween(day, endTime).getDays()); numberOfDays = Math.min(days, mDaysLeftInRow) + 1; @@ -331,7 +361,7 @@ public void onComponentTag(Component component, ComponentTag tag) { // defined // in the spec? It sure makes it simple on the JS-side to access // additional data about the event needed for the client-side - // rendering. + // rendering. tag.put("days", numberOfDays); } } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/logic/DateMidnightIterator.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/logic/DateMidnightIterator.java index ba6561a0f1..d25bf08d20 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/logic/DateMidnightIterator.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/logic/DateMidnightIterator.java @@ -28,32 +28,38 @@ /** * @author Jeremy Thomerson */ -public class DateMidnightIterator implements Iterator { +public class DateMidnightIterator implements Iterator +{ private DateTime mCurrent; private final DateTime mEndDateTime; - - public DateMidnightIterator(DateTime start, DateTime end, int first, int count) { + + public DateMidnightIterator(DateTime start, DateTime end, int first, int count) + { mCurrent = start.plusDays(first); mEndDateTime = mCurrent.plusDays(count); } - public DateMidnightIterator(DateTime start, DateTime end) { + public DateMidnightIterator(DateTime start, DateTime end) + { this(start, end, 0, new Period(start, end, PeriodType.days()).getDays() + 1); } - public boolean hasNext() { + public boolean hasNext() + { return mCurrent.isBefore(mEndDateTime); } - public DateMidnight next() { + public DateMidnight next() + { DateMidnight dm = new DateMidnight(mCurrent); mCurrent = mCurrent.plusDays(1); return dm; } - public void remove() { + public void remove() + { throw new UnsupportedOperationException("this should not be called"); } - + } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/modal/DateDetailPage.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/modal/DateDetailPage.java index ea10cd1062..252726cf5d 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/modal/DateDetailPage.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/modal/DateDetailPage.java @@ -36,31 +36,42 @@ import org.wicketstuff.calendarviews.BaseCalendarView; import org.wicketstuff.calendarviews.model.IEvent; -public class DateDetailPage extends WebPage { +public class DateDetailPage extends WebPage +{ - public static interface IDateDetailPageEventLinkCreator extends Serializable { + public static interface IDateDetailPageEventLinkCreator extends Serializable + { WebMarkupContainer createEventLink(String id, IModel model); } - - public DateDetailPage(IModel model, IModel> eventsModel, final IDateDetailPageEventLinkCreator linkCreator) { - add(new Label("title", new StringResourceModel("DateDetailPage.windowTitle", null, new Object[] { model.getObject().toDate() }))); - add(new Label("inPageTitle", new StringResourceModel("DateDetailPage.inPageTitle", null, new Object[] { model.getObject().toDate() }))); - add(new PropertyListView("list", eventsModel) { + + public DateDetailPage(IModel model, IModel> eventsModel, + final IDateDetailPageEventLinkCreator linkCreator) + { + add(new Label("title", new StringResourceModel("DateDetailPage.windowTitle", null, + new Object[] { model.getObject().toDate() }))); + add(new Label("inPageTitle", new StringResourceModel("DateDetailPage.inPageTitle", null, + new Object[] { model.getObject().toDate() }))); + add(new PropertyListView("list", eventsModel) + { private static final long serialVersionUID = 1L; private int mCounter = 0; + @Override - protected void populateItem(ListItem item) { + protected void populateItem(ListItem item) + { WebMarkupContainer link = linkCreator.createEventLink("link", item.getModel()); link.add(new Label("title").setRenderBodyOnly(true)); item.add(link); item.add(new Label("startTime")); item.add(new Label("endTime")); - - item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel() { + + item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel() + { private static final long serialVersionUID = 1L; @Override - public String getObject() { + public String getObject() + { return "row" + (mCounter++ % 2); } })); @@ -70,9 +81,10 @@ public String getObject() { } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { super.renderHead(response); - response.renderCSSReference(BaseCalendarView.CALENDARS_CSS_REFERENCE); + response.renderCSSReference(BaseCalendarView.CALENDARS_CSS_REFERENCE); } } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicCategorizedEvent.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicCategorizedEvent.java index eb02f326b8..0213a1d69b 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicCategorizedEvent.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicCategorizedEvent.java @@ -19,23 +19,25 @@ package org.wicketstuff.calendarviews.model; /** - * This is just an extension of BasicEvent that adds the - * specified CSS class to events. + * This is just an extension of BasicEvent that adds the specified CSS class to events. * * @see BasicEvent * @author Jeremy Thomerson */ -public class BasicCategorizedEvent extends BasicEvent implements ICategorizedEvent { +public class BasicCategorizedEvent extends BasicEvent implements ICategorizedEvent +{ private static final long serialVersionUID = 1L; private String mCssClassForCategory; - public String getCssClassForCategory() { + public String getCssClassForCategory() + { return mCssClassForCategory; } - public void setCssClassForCategory(String cssClassForCategory) { + public void setCssClassForCategory(String cssClassForCategory) + { mCssClassForCategory = cssClassForCategory; } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicEvent.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicEvent.java index 368f18b073..00e5b49251 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicEvent.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/BasicEvent.java @@ -22,26 +22,28 @@ import java.util.Date; /** - * This is just a simple IEvent implementation, mostly used for - * testing. You may use it as a wrapper in your own application if you would - * like, but it is not necessary. + * This is just a simple IEvent implementation, mostly used for testing. You may use it as + * a wrapper in your own application if you would like, but it is not necessary. * * @author Jeremy Thomerson */ -public class BasicEvent implements IEvent, Serializable { - +public class BasicEvent implements IEvent, Serializable +{ + private static final long serialVersionUID = 1L; - + private String mTitle; private Date mEndTime; private Date mStartTime; private boolean mAllDayEvent; - public BasicEvent() { + public BasicEvent() + { // no-op } - - public BasicEvent(String title, Date endTime, Date startTime, boolean allDayEvent) { + + public BasicEvent(String title, Date endTime, Date startTime, boolean allDayEvent) + { super(); mTitle = title; mEndTime = endTime; @@ -49,76 +51,90 @@ public BasicEvent(String title, Date endTime, Date startTime, boolean allDayEven mAllDayEvent = allDayEvent; } - public String getTitle() { + public String getTitle() + { return mTitle; } - public void setTitle(String title) { + public void setTitle(String title) + { mTitle = title; } - public Date getEndTime() { + public Date getEndTime() + { return mEndTime; } - public void setEndTime(Date endTime) { + public void setEndTime(Date endTime) + { mEndTime = endTime; } - public Date getStartTime() { + public Date getStartTime() + { return mStartTime; } - public void setStartTime(Date startTime) { + public void setStartTime(Date startTime) + { mStartTime = startTime; } - public boolean isAllDayEvent() { + public boolean isAllDayEvent() + { return mAllDayEvent; } - public void setAllDayEvent(boolean allDayEvent) { + public void setAllDayEvent(boolean allDayEvent) + { mAllDayEvent = allDayEvent; } @Override - public int hashCode() { + public int hashCode() + { final int prime = 31; int result = 1; result = prime * result + (mAllDayEvent ? 1231 : 1237); - result = prime * result - + ((mEndTime == null) ? 0 : mEndTime.hashCode()); - result = prime * result - + ((mStartTime == null) ? 0 : mStartTime.hashCode()); + result = prime * result + ((mEndTime == null) ? 0 : mEndTime.hashCode()); + result = prime * result + ((mStartTime == null) ? 0 : mStartTime.hashCode()); result = prime * result + ((mTitle == null) ? 0 : mTitle.hashCode()); return result; } @Override - public boolean equals(Object obj) { + public boolean equals(Object obj) + { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - BasicEvent other = (BasicEvent) obj; + BasicEvent other = (BasicEvent)obj; if (mAllDayEvent != other.mAllDayEvent) return false; - if (mEndTime == null) { + if (mEndTime == null) + { if (other.mEndTime != null) return false; - } else if (!mEndTime.equals(other.mEndTime)) + } + else if (!mEndTime.equals(other.mEndTime)) return false; - if (mStartTime == null) { + if (mStartTime == null) + { if (other.mStartTime != null) return false; - } else if (!mStartTime.equals(other.mStartTime)) + } + else if (!mStartTime.equals(other.mStartTime)) return false; - if (mTitle == null) { + if (mTitle == null) + { if (other.mTitle != null) return false; - } else if (!mTitle.equals(other.mTitle)) + } + else if (!mTitle.equals(other.mTitle)) return false; return true; } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/ICategorizedEvent.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/ICategorizedEvent.java index 87f9832ccd..91f588ba46 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/ICategorizedEvent.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/ICategorizedEvent.java @@ -19,14 +19,15 @@ package org.wicketstuff.calendarviews.model; /** - * If your events fall into multiple categories, you can return implementations of - * this anywhere you would normally return IEvent's (i.e. IEventProvider). Then - * the calendar will add the specified CSS class to each event. + * If your events fall into multiple categories, you can return implementations of this anywhere you + * would normally return IEvent's (i.e. IEventProvider). Then the calendar will add the specified + * CSS class to each event. * * @author Jeremy Thomerson */ -public interface ICategorizedEvent extends IEvent { +public interface ICategorizedEvent extends IEvent +{ public String getCssClassForCategory(); - + } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEvent.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEvent.java index 3878b73d50..780c49a96a 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEvent.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEvent.java @@ -21,26 +21,28 @@ import java.util.Date; /** - * The main model-object interface for using CalendarViews - this is - * what maps your model to the CalendarViews model. Your domain model - * object can either implement this interface directly, or you can use - * a DTO of sorts and convert between the two. + * The main model-object interface for using CalendarViews - this is what maps your model to the + * CalendarViews model. Your domain model object can either implement this interface directly, or + * you can use a DTO of sorts and convert between the two. * * @author Jeremy Thomerson */ -public interface IEvent { +public interface IEvent +{ String getTitle(); + Date getStartTime(); + Date getEndTime(); - + /** - * Is this event an all day event or does it have a specific start - * and end time throughout the day? + * Is this event an all day event or does it have a specific start and end time throughout the + * day? * - * @return true if the event lasts all day (has no hour / minute start time) - * always false if the event is a multi-day event + * @return true if the event lasts all day (has no hour / minute start time) always false if the + * event is a multi-day event */ boolean isAllDayEvent(); - + } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEventProvider.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEventProvider.java index d33511f43d..728816ded8 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEventProvider.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/IEventProvider.java @@ -24,45 +24,46 @@ import org.apache.wicket.model.IModel; /** - * The main data-locator interface between your service or data access - * layer and CalendarViews. Note that it is at its heart a standard Wicket - * IModel<Collection<? extends IEvent>>. It only adds a - * single method so that the CalendarViews layer can initialize it to the - * proper date range needed.
+ * The main data-locator interface between your service or data access layer and CalendarViews. Note + * that it is at its heart a standard Wicket IModel<Collection<? extends IEvent>>. It + * only adds a single method so that the CalendarViews layer can initialize it to the proper date + * range needed.
*
- * NOTE: Read the documentation on the initializeWithDateRange - * method carefully. It is important to understand the difference between - * the dates that you initialize your calendar with and the dates that the - * calendar will initialize your IEventProvider with. - * + * NOTE: Read the documentation on the initializeWithDateRange method carefully. It + * is important to understand the difference between the dates that you initialize your calendar + * with and the dates that the calendar will initialize your IEventProvider with. + * * @see #initializeWithDateRange(Date, Date) * @author Jeremy Thomerson */ -public interface IEventProvider extends IModel> { +public interface IEventProvider extends IModel> +{ /** - * Called by the calendar view when it has computed what the actual start - * and end dates of the range that it will be displaying are. This is - * necessary, for example, because you may initialize the calendar view with - * a range of Wednesday through a Thursday, but depending on the type of - * view that it is, it may show from the Sunday prior to your start to the - * Saturday after your end.
+ * Called by the calendar view when it has computed what the actual start and end dates of the + * range that it will be displaying are. This is necessary, for example, because you may + * initialize the calendar view with a range of Wednesday through a Thursday, but depending on + * the type of view that it is, it may show from the Sunday prior to your start to the Saturday + * after your end.
*
- * Note that the end time is exclusive. Therefore, if the calendar is - * displaying Sunday through Saturday, the start date will be Sunday at - * 00:00:00.000 and the end date will be the following Sunday at 00:00:00.000
- *
- * Also notable is that you need to remember to include not only events that - * begin within this range, but also events that begin before, but end within - * this range. i.e. your query may be like:
- *
+	 * Note that the end time is exclusive. Therefore, if the calendar is displaying Sunday through
+	 * Saturday, the start date will be Sunday at 00:00:00.000 and the end date will be the
+	 * following Sunday at 00:00:00.000
+ *
+ * Also notable is that you need to remember to include not only events that begin within this + * range, but also events that begin before, but end within this range. i.e. your query may be + * like:
+ * + *
 	 * 	where (start > :start and start < :end)
-	 *	   or (end < :end and end > :start)
+	 *    or (end < :end and end > :start)
 	 * 
* - * @param start The first instant that the calendar will display, inclusive - * @param end The last instant that the calendar will display, exclusive + * @param start + * The first instant that the calendar will display, inclusive + * @param end + * The last instant that the calendar will display, exclusive */ void initializeWithDateRange(Date start, Date end); - + } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/TimePeriod.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/TimePeriod.java index 96ea26df42..31c7a4e27d 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/TimePeriod.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/model/TimePeriod.java @@ -3,57 +3,65 @@ import java.io.Serializable; import java.util.Date; -public class TimePeriod implements Serializable { +public class TimePeriod implements Serializable +{ private static final long serialVersionUID = 1L; - + private final Date mStartDate; private final Date mEndDate; - public TimePeriod(Date startDate, Date endDate) { + public TimePeriod(Date startDate, Date endDate) + { super(); mStartDate = startDate; mEndDate = endDate; } - public Date getStartDate() { + public Date getStartDate() + { return mStartDate; } - public Date getEndDate() { + public Date getEndDate() + { return mEndDate; } @Override - public int hashCode() { + public int hashCode() + { final int prime = 31; int result = 1; - result = prime * result - + ((mEndDate == null) ? 0 : mEndDate.hashCode()); - result = prime * result - + ((mStartDate == null) ? 0 : mStartDate.hashCode()); + result = prime * result + ((mEndDate == null) ? 0 : mEndDate.hashCode()); + result = prime * result + ((mStartDate == null) ? 0 : mStartDate.hashCode()); return result; } @Override - public boolean equals(Object obj) { + public boolean equals(Object obj) + { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - TimePeriod other = (TimePeriod) obj; - if (mEndDate == null) { + TimePeriod other = (TimePeriod)obj; + if (mEndDate == null) + { if (other.mEndDate != null) return false; - } else if (!mEndDate.equals(other.mEndDate)) + } + else if (!mEndDate.equals(other.mEndDate)) return false; - if (mStartDate == null) { + if (mStartDate == null) + { if (other.mStartDate != null) return false; - } else if (!mStartDate.equals(other.mStartDate)) + } + else if (!mStartDate.equals(other.mStartDate)) return false; return true; } - + } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/Comparators.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/Comparators.java index 7f5b71985e..d78e73e56e 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/Comparators.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/Comparators.java @@ -23,32 +23,41 @@ import org.wicketstuff.calendarviews.model.IEvent; /** - * General utility holding comparators used within this library. Not typically - * useful or intended for use outside of CalendarViews. + * General utility holding comparators used within this library. Not typically useful or intended + * for use outside of CalendarViews. * * @author Jeremy Thomerson */ -public abstract class Comparators { - - private Comparators() { +public abstract class Comparators +{ + + private Comparators() + { // no-op hide-a-constructor } - - public static final Comparator EVENT_START_DATE_ASC_COMPARATOR = new Comparator() { - public int compare(IEvent o1, IEvent o2) { - if (o1 == o2) { + public static final Comparator EVENT_START_DATE_ASC_COMPARATOR = new Comparator() + { + + public int compare(IEvent o1, IEvent o2) + { + if (o1 == o2) + { return 0; - } else if (o1 == null) { + } + else if (o1 == null) + { return 1; - } else if (o2 == null) { + } + else if (o2 == null) + { return -1; } // NOTE: we don't do null checks on o1.getStartTime() here because - // a start time is required to be used. + // a start time is required to be used. return o1.getStartTime().compareTo(o2.getStartTime()); } - + }; } diff --git a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/StringUtil.java b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/StringUtil.java index 86a72d41e5..e35a69c7be 100644 --- a/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/StringUtil.java +++ b/jdk-1.5-parent/calendarviews-parent/calendarviews/src/main/java/org/wicketstuff/calendarviews/util/StringUtil.java @@ -19,59 +19,69 @@ package org.wicketstuff.calendarviews.util; /** - * You shouldn't use this class - you should use commons-lang. We only - * use it internally to avoid having an extra dependency for the very few - * things we need. + * You shouldn't use this class - you should use commons-lang. We only use it internally to avoid + * having an extra dependency for the very few things we need. * * @author Jeremy Thomerson */ -public class StringUtil { +public class StringUtil +{ - public static final String EMPTY = ""; + public static final String EMPTY = ""; - /** - * @param string the string to test + /** + * @param string + * the string to test * @return true if the string is null, 0 length, or 0 length after a trim() */ - public static boolean isEmpty(String string) { + public static boolean isEmpty(String string) + { return string == null || string.trim().length() == 0; } - - public static String join(Object[] array, String separator) { - if (array == null) { - return null; - } - return join(array, separator, 0, array.length); - } - public static String join(Object[] array, String separator, int startIndex, int endIndex) { - if (array == null) { - return null; - } - if (separator == null) { - separator = EMPTY; - } + public static String join(Object[] array, String separator) + { + if (array == null) + { + return null; + } + return join(array, separator, 0, array.length); + } + + public static String join(Object[] array, String separator, int startIndex, int endIndex) + { + if (array == null) + { + return null; + } + if (separator == null) + { + separator = EMPTY; + } - // endIndex - startIndex > 0: Len = NofStrings *(len(firstString) + len(separator)) - // (Assuming that all Strings are roughly equally long) - int bufSize = (endIndex - startIndex); - if (bufSize <= 0) { - return EMPTY; - } + // endIndex - startIndex > 0: Len = NofStrings *(len(firstString) + len(separator)) + // (Assuming that all Strings are roughly equally long) + int bufSize = (endIndex - startIndex); + if (bufSize <= 0) + { + return EMPTY; + } - bufSize *= ((array[startIndex] == null ? 16 : array[startIndex].toString().length()) - + separator.length()); + bufSize *= ((array[startIndex] == null ? 16 : array[startIndex].toString().length()) + separator.length()); - StringBuffer buf = new StringBuffer(bufSize); + StringBuffer buf = new StringBuffer(bufSize); - for (int i = startIndex; i < endIndex; i++) { - if (i > startIndex) { - buf.append(separator); - } - if (array[i] != null) { - buf.append(array[i]); - } - } - return buf.toString(); - } + for (int i = startIndex; i < endIndex; i++) + { + if (i > startIndex) + { + buf.append(separator); + } + if (array[i] != null) + { + buf.append(array[i]); + } + } + return buf.toString(); + } } diff --git a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/AbstractClientAndServerValidatingBehavior.java b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/AbstractClientAndServerValidatingBehavior.java index ddee10b206..b24bc0a84b 100644 --- a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/AbstractClientAndServerValidatingBehavior.java +++ b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/AbstractClientAndServerValidatingBehavior.java @@ -33,81 +33,101 @@ import org.apache.wicket.util.string.interpolator.MapVariableInterpolator; /** - * Abstract validating behavior that all ClientAndServer...Behaviors can extend to - * provide the base functionality needed to validate on the client side where possible. + * Abstract validating behavior that all ClientAndServer...Behaviors can extend to provide the base + * functionality needed to validate on the client side where possible. * * @author Jeremy Thomerson */ -public abstract class AbstractClientAndServerValidatingBehavior extends Behavior { +public abstract class AbstractClientAndServerValidatingBehavior extends Behavior +{ private static final long serialVersionUID = 1L; - + private FormComponent mComponent; private Form mForm; - - public AbstractClientAndServerValidatingBehavior(Form form) { - if (form == null) { - throw new IllegalArgumentException("ClientAndServer validating behaviors require a non-null form"); + + public AbstractClientAndServerValidatingBehavior(Form form) + { + if (form == null) + { + throw new IllegalArgumentException( + "ClientAndServer validating behaviors require a non-null form"); } mForm = form; } - + @Override - public final void bind(Component component) { + public final void bind(Component component) + { super.bind(component); checkComponentIsFormComponent(component); - mComponent = (FormComponent) component; + mComponent = (FormComponent)component; addServerSideValidator(mComponent); - + // make sure that both IDs are rendered mComponent.setOutputMarkupId(true); mForm.setOutputMarkupId(true); } - protected final void checkComponentIsFormComponent(Component component) { - if ((component instanceof FormComponent) == false) { - throw new IllegalArgumentException("This behavior [" + Classes.simpleName(getClass()) + "] can only be added to a FormComponent"); + protected final void checkComponentIsFormComponent(Component component) + { + if ((component instanceof FormComponent) == false) + { + throw new IllegalArgumentException("This behavior [" + Classes.simpleName(getClass()) + + "] can only be added to a FormComponent"); } } - + @Override - public final void renderHead(Component c, IHeaderResponse response) { + public final void renderHead(Component c, IHeaderResponse response) + { super.renderHead(c, response); - + // add our validation javascript file response.renderJavaScriptReference(new PackageResourceReference(getClass(), "validation.js")); - + // add a trigger that will add our validation to the forms' onSubmit methods response.renderOnLoadJavaScript("ClientAndServerValidator.addFormOnloadEvents();"); CharSequence formID = jsEscape(mForm.getMarkupId()); CharSequence compID = jsEscape(mComponent.getMarkupId()); - String message = Application.get().getResourceSettings().getLocalizer().getString(getResourceKey(), mComponent); + String message = Application.get() + .getResourceSettings() + .getLocalizer() + .getString(getResourceKey(), mComponent); Map vars = variablesMap(mForm, mComponent); - boolean thrExc = Application.get().getResourceSettings().getThrowExceptionOnMissingResource(); + boolean thrExc = Application.get() + .getResourceSettings() + .getThrowExceptionOnMissingResource(); MapVariableInterpolator mvi = new MapVariableInterpolator(message, vars, thrExc); CharSequence escapedMessage = jsEscape(mvi.toString()); - - String validator = createValidatorConstructorJavaScript(formID, compID, escapedMessage); + + String validator = createValidatorConstructorJavaScript(formID, compID, escapedMessage); String js = "ClientAndServerValidator.registerValidator(" + validator + ");"; response.renderOnDomReadyJavaScript(js.toString()); } - protected final CharSequence jsEscape(CharSequence js) { + protected final CharSequence jsEscape(CharSequence js) + { // TODO: this may need more escaping return JavaScriptUtils.escapeQuotes(js); } - protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, CharSequence escapedMessage) { - return "new " + getValidatorJSClassName() + "('" + formID + "', '" + compID + "', '" + escapedMessage + "')"; + protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, + CharSequence escapedMessage) + { + return "new " + getValidatorJSClassName() + "('" + formID + "', '" + compID + "', '" + + escapedMessage + "')"; } - protected String getValidatorJSClassName() { + protected String getValidatorJSClassName() + { return Classes.simpleName(getClass()); } - protected Map variablesMap(Form form, FormComponent component) { + protected Map variablesMap(Form form, FormComponent component) + { Map vars = new HashMap(); vars.put("form", form.getMarkupId()); vars.put("label", component.getMarkupId()); @@ -118,7 +138,8 @@ protected Map variablesMap(Form form, FormComponent compon /** * @return the resource key where the 'failed' message for this validator can be found */ - protected String getResourceKey() { + protected String getResourceKey() + { return Classes.simpleName(getClass()); } diff --git a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerExactLengthValidatingBehavior.java b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerExactLengthValidatingBehavior.java index f9a6e4a3ed..c5beb89b08 100644 --- a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerExactLengthValidatingBehavior.java +++ b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerExactLengthValidatingBehavior.java @@ -29,46 +29,54 @@ * * @author Jeremy Thomerson */ -public class ClientAndServerExactLengthValidatingBehavior extends AbstractClientAndServerValidatingBehavior { +public class ClientAndServerExactLengthValidatingBehavior extends + AbstractClientAndServerValidatingBehavior +{ private static final long serialVersionUID = 1L; private final int mLength; - - public ClientAndServerExactLengthValidatingBehavior(Form form, int length) { + + public ClientAndServerExactLengthValidatingBehavior(Form form, int length) + { super(form); mLength = length; } @Override - protected void addServerSideValidator(FormComponent component) { + protected void addServerSideValidator(FormComponent component) + { component.add(StringValidator.exactLength(mLength)); } - + @Override - protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, CharSequence escapedMessage) { + protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, + CharSequence escapedMessage) + { String js = super.createValidatorConstructorJavaScript(formID, compID, escapedMessage); js = js + ".setExactLength(" + mLength + ")"; return js; } - + @Override - protected Map variablesMap(Form form, FormComponent component) { + protected Map variablesMap(Form form, FormComponent component) + { Map map = super.variablesMap(form, component); map.put("exact", mLength); return map; } - + @Override - protected String getResourceKey() { + protected String getResourceKey() + { return "StringValidator.exact"; } - + @Override - protected String getValidatorJSClassName() { + protected String getValidatorJSClassName() + { return "StringExactLengthValidator"; } - } diff --git a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerLengthBetweenValidatingBehavior.java b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerLengthBetweenValidatingBehavior.java index a84617037d..efedc49fc5 100644 --- a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerLengthBetweenValidatingBehavior.java +++ b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerLengthBetweenValidatingBehavior.java @@ -25,50 +25,60 @@ import org.apache.wicket.validation.validator.StringValidator; /** - * Validates that the form component value has a length between the min and the max specified (inclusive). + * Validates that the form component value has a length between the min and the max specified + * (inclusive). * * @author Jeremy Thomerson */ -public class ClientAndServerLengthBetweenValidatingBehavior extends AbstractClientAndServerValidatingBehavior { +public class ClientAndServerLengthBetweenValidatingBehavior extends + AbstractClientAndServerValidatingBehavior +{ private static final long serialVersionUID = 1L; private final int mMin; private final int mMax; - - public ClientAndServerLengthBetweenValidatingBehavior(Form form, int min, int max) { + + public ClientAndServerLengthBetweenValidatingBehavior(Form form, int min, int max) + { super(form); mMin = min; mMax = max; } @Override - protected void addServerSideValidator(FormComponent component) { + protected void addServerSideValidator(FormComponent component) + { component.add(StringValidator.lengthBetween(mMin, mMax)); } - + @Override - protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, CharSequence escapedMessage) { + protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, + CharSequence escapedMessage) + { String js = super.createValidatorConstructorJavaScript(formID, compID, escapedMessage); js = js + ".setMinimumLength(" + mMin + ").setMaximumLength(" + mMax + ")"; return js; } - + @Override - protected Map variablesMap(Form form, FormComponent component) { + protected Map variablesMap(Form form, FormComponent component) + { Map map = super.variablesMap(form, component); map.put("minimum", mMin); map.put("maximum", mMax); return map; } - + @Override - protected String getResourceKey() { + protected String getResourceKey() + { return "StringValidator.range"; } - + @Override - protected String getValidatorJSClassName() { + protected String getValidatorJSClassName() + { return "StringLengthBetweenValidator"; } diff --git a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMaximumLengthValidatingBehavior.java b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMaximumLengthValidatingBehavior.java index 18174b7d3d..f7f7353663 100644 --- a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMaximumLengthValidatingBehavior.java +++ b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMaximumLengthValidatingBehavior.java @@ -29,43 +29,52 @@ * * @author Jeremy Thomerson */ -public class ClientAndServerMaximumLengthValidatingBehavior extends AbstractClientAndServerValidatingBehavior { +public class ClientAndServerMaximumLengthValidatingBehavior extends + AbstractClientAndServerValidatingBehavior +{ private static final long serialVersionUID = 1L; private final int mMax; - - public ClientAndServerMaximumLengthValidatingBehavior(Form form, int max) { + + public ClientAndServerMaximumLengthValidatingBehavior(Form form, int max) + { super(form); mMax = max; } @Override - protected void addServerSideValidator(FormComponent component) { + protected void addServerSideValidator(FormComponent component) + { component.add(StringValidator.maximumLength(mMax)); } - + @Override - protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, CharSequence escapedMessage) { + protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, + CharSequence escapedMessage) + { String js = super.createValidatorConstructorJavaScript(formID, compID, escapedMessage); js = js + ".setMaximumLength(" + mMax + ")"; return js; } - + @Override - protected Map variablesMap(Form form, FormComponent component) { + protected Map variablesMap(Form form, FormComponent component) + { Map map = super.variablesMap(form, component); map.put("maximum", mMax); return map; } - + @Override - protected String getResourceKey() { + protected String getResourceKey() + { return "StringValidator.maximum"; } - + @Override - protected String getValidatorJSClassName() { + protected String getValidatorJSClassName() + { return "StringMaximumLengthValidator"; } diff --git a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMinimumLengthValidatingBehavior.java b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMinimumLengthValidatingBehavior.java index dd598bf25f..618a3c5f14 100644 --- a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMinimumLengthValidatingBehavior.java +++ b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerMinimumLengthValidatingBehavior.java @@ -25,47 +25,57 @@ import org.apache.wicket.validation.validator.StringValidator; /** - * Validates that the form component value has a length greater than or equal to the length specified. + * Validates that the form component value has a length greater than or equal to the length + * specified. * * @author Jeremy Thomerson */ -public class ClientAndServerMinimumLengthValidatingBehavior extends AbstractClientAndServerValidatingBehavior { +public class ClientAndServerMinimumLengthValidatingBehavior extends + AbstractClientAndServerValidatingBehavior +{ private static final long serialVersionUID = 1L; private final int mMin; - - public ClientAndServerMinimumLengthValidatingBehavior(Form form, int min) { + + public ClientAndServerMinimumLengthValidatingBehavior(Form form, int min) + { super(form); mMin = min; } @Override - protected void addServerSideValidator(FormComponent component) { + protected void addServerSideValidator(FormComponent component) + { component.add(StringValidator.minimumLength(mMin)); } - + @Override - protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, CharSequence escapedMessage) { + protected String createValidatorConstructorJavaScript(CharSequence formID, CharSequence compID, + CharSequence escapedMessage) + { String js = super.createValidatorConstructorJavaScript(formID, compID, escapedMessage); js = js + ".setMinimumLength(" + mMin + ")"; return js; } - + @Override - protected Map variablesMap(Form form, FormComponent component) { + protected Map variablesMap(Form form, FormComponent component) + { Map map = super.variablesMap(form, component); map.put("minimum", mMin); return map; } - + @Override - protected String getResourceKey() { + protected String getResourceKey() + { return "StringValidator.minimum"; } - + @Override - protected String getValidatorJSClassName() { + protected String getValidatorJSClassName() + { return "StringMinimumLengthValidator"; } diff --git a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerRequiredValidatingBehavior.java b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerRequiredValidatingBehavior.java index ecad5f6e54..c714608e40 100644 --- a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerRequiredValidatingBehavior.java +++ b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerRequiredValidatingBehavior.java @@ -26,26 +26,32 @@ * * @author Jeremy Thomerson */ -public class ClientAndServerRequiredValidatingBehavior extends AbstractClientAndServerValidatingBehavior { +public class ClientAndServerRequiredValidatingBehavior extends + AbstractClientAndServerValidatingBehavior +{ private static final long serialVersionUID = 1L; - public ClientAndServerRequiredValidatingBehavior(Form form) { + public ClientAndServerRequiredValidatingBehavior(Form form) + { super(form); } - + @Override - protected void addServerSideValidator(FormComponent component) { + protected void addServerSideValidator(FormComponent component) + { component.setRequired(true); } @Override - protected String getResourceKey() { + protected String getResourceKey() + { return "Required"; } - + @Override - protected String getValidatorJSClassName() { + protected String getValidatorJSClassName() + { return "RequiredValidator"; } diff --git a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerValidatingFeedbackBehavior.java b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerValidatingFeedbackBehavior.java index 194ff20f70..156ab0672b 100644 --- a/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerValidatingFeedbackBehavior.java +++ b/jdk-1.5-parent/client-and-server-validation/src/main/java/org/wicketstuff/validation/client/ClientAndServerValidatingFeedbackBehavior.java @@ -27,46 +27,54 @@ /** * By adding this behavior to a feedback panel or other WebMarkupContainer, the client and server - * validating engine will render the errors as if they were inserted into a feedback panel - * rather than just using the default behavior, which is to use an alert message to notify the - * user of the errors. + * validating engine will render the errors as if they were inserted into a feedback panel rather + * than just using the default behavior, which is to use an alert message to notify the user of the + * errors. * * @author Jeremy Thomerson */ -public class ClientAndServerValidatingFeedbackBehavior extends Behavior { +public class ClientAndServerValidatingFeedbackBehavior extends Behavior +{ private static final long serialVersionUID = 1L; private WebMarkupContainer mContainer; private final Form mForm; - - public ClientAndServerValidatingFeedbackBehavior(Form form) { + + public ClientAndServerValidatingFeedbackBehavior(Form form) + { mForm = form; } - + @Override - public void bind(Component component) { + public void bind(Component component) + { super.bind(component); checkComponentIsWebMarkupContainer(component); - mContainer = (WebMarkupContainer) component; + mContainer = (WebMarkupContainer)component; mContainer.setOutputMarkupId(true); } - - protected final void checkComponentIsWebMarkupContainer(Component component) { - if ((component instanceof WebMarkupContainer) == false) { - throw new IllegalArgumentException("This behavior [" + getClass().getSimpleName() + "] can only be added to a WebMarkupContainer"); + + protected final void checkComponentIsWebMarkupContainer(Component component) + { + if ((component instanceof WebMarkupContainer) == false) + { + throw new IllegalArgumentException("This behavior [" + getClass().getSimpleName() + + "] can only be added to a WebMarkupContainer"); } } @Override - public void renderHead(Component c, IHeaderResponse response) { + public void renderHead(Component c, IHeaderResponse response) + { super.renderHead(c, response); response.renderJavaScriptReference(WicketAjaxReference.INSTANCE); - + // add a trigger that will add our validation to the forms' onSubmit methods String formID = mForm.getMarkupId(); String containerID = mContainer.getMarkupId(); - response.renderOnLoadJavaScript("ClientAndServerValidator.registerFeedbackContainerForForm('" + formID + "', '" + containerID + "');"); + response.renderOnLoadJavaScript("ClientAndServerValidator.registerFeedbackContainerForForm('" + + formID + "', '" + containerID + "');"); } } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ClojureEngine.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ClojureEngine.java index e8e701b95a..bc483e55c2 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ClojureEngine.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ClojureEngine.java @@ -35,83 +35,94 @@ /** * Executes Clojure code. *

- * stdout and stderr are captured. Bindings are pushed into user namespace, so - * to access a binding named "foo" use "user/foo". * + * stdout and stderr are captured. Bindings are pushed into user namespace, so to access a binding + * named "foo" use "user/foo". * * * @author cretzel */ -public class ClojureEngine implements IScriptEngine { - - /** - * {@inheritDoc} - */ - public synchronized IScriptExecutionResult execute(final String script) { - return execute(script, null); - } - - /** - * {@inheritDoc} - */ - public synchronized IScriptExecutionResult execute(final String script, - final Map bindings) { - - Throwable exception = null; - String output = null; - Object returnValue = null; - - final PrintStream oldOut = System.out; - final PrintStream oldErr = System.err; - final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - final PrintStream newOut = new PrintStream(bout, false); - final OutputStreamWriter newRtOut = new OutputStreamWriter(newOut); - - try { - System.setOut(newOut); - System.setErr(newOut); - - Associative mappings = PersistentHashMap.EMPTY; - mappings = mappings.assoc(RT.CURRENT_NS, RT.CURRENT_NS.get()); - mappings = mappings.assoc(RT.OUT, newRtOut); - mappings = mappings.assoc(RT.ERR, newRtOut); - mappings = applyBindings(bindings, mappings); - Var.pushThreadBindings(mappings); - - returnValue = Compiler.load(new StringReader(script)); - } catch (final Exception e) { - exception = e; - } finally { - - try { - Var.popThreadBindings(); - newRtOut.flush(); - newRtOut.close(); - System.setOut(oldOut); - System.setErr(oldErr); - - output = bout.toString(); - } catch (final Exception e1) { - throw new ScriptEngineException(e1); - } - - } - - return new DefaultScriptExecutionResult(script, exception, output, - returnValue); - } - - private Associative applyBindings(final Map bindings, - Associative mappings) { - if (bindings != null) { - final Set> entrySet = bindings.entrySet(); - for (final Entry entry : entrySet) { - final Symbol symbol = Symbol.intern(entry.getKey()); - final Namespace userNs = Namespace.findOrCreate(Symbol - .create("user".intern())); - final Var var = Var.intern(userNs, symbol); - mappings = mappings.assoc(var, entry.getValue()); - } - } - return mappings; - } +public class ClojureEngine implements IScriptEngine +{ + + /** + * {@inheritDoc} + */ + public synchronized IScriptExecutionResult execute(final String script) + { + return execute(script, null); + } + + /** + * {@inheritDoc} + */ + public synchronized IScriptExecutionResult execute(final String script, + final Map bindings) + { + + Throwable exception = null; + String output = null; + Object returnValue = null; + + final PrintStream oldOut = System.out; + final PrintStream oldErr = System.err; + final ByteArrayOutputStream bout = new ByteArrayOutputStream(); + final PrintStream newOut = new PrintStream(bout, false); + final OutputStreamWriter newRtOut = new OutputStreamWriter(newOut); + + try + { + System.setOut(newOut); + System.setErr(newOut); + + Associative mappings = PersistentHashMap.EMPTY; + mappings = mappings.assoc(RT.CURRENT_NS, RT.CURRENT_NS.get()); + mappings = mappings.assoc(RT.OUT, newRtOut); + mappings = mappings.assoc(RT.ERR, newRtOut); + mappings = applyBindings(bindings, mappings); + Var.pushThreadBindings(mappings); + + returnValue = Compiler.load(new StringReader(script)); + } + catch (final Exception e) + { + exception = e; + } + finally + { + + try + { + Var.popThreadBindings(); + newRtOut.flush(); + newRtOut.close(); + System.setOut(oldOut); + System.setErr(oldErr); + + output = bout.toString(); + } + catch (final Exception e1) + { + throw new ScriptEngineException(e1); + } + + } + + return new DefaultScriptExecutionResult(script, exception, output, returnValue); + } + + private Associative applyBindings(final Map bindings, Associative mappings) + { + if (bindings != null) + { + final Set> entrySet = bindings.entrySet(); + for (final Entry entry : entrySet) + { + final Symbol symbol = Symbol.intern(entry.getKey()); + final Namespace userNs = Namespace.findOrCreate(Symbol.create("user".intern())); + final Var var = Var.intern(userNs, symbol); + mappings = mappings.assoc(var, entry.getValue()); + } + } + return mappings; + } } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/DefaultScriptExecutionResult.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/DefaultScriptExecutionResult.java index 9ac7650cc4..0e59b9c3ee 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/DefaultScriptExecutionResult.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/DefaultScriptExecutionResult.java @@ -23,39 +23,46 @@ * * @author cretzel */ -final class DefaultScriptExecutionResult implements IScriptExecutionResult { - - private final String script; - private final Throwable exception; - private final String output; - private final Object returnValue; - - public DefaultScriptExecutionResult(final String script, final Throwable exception, - final String output, final Object returnValue) { - this.script = script; - this.exception = exception; - this.output = output; - this.returnValue = returnValue; - } - - public String getScript() { - return script; - } - - public boolean isSuccess() { - return exception == null; - } - - public Throwable getException() { - return exception; - } - - public String getOutput() { - return output; - } - - public Object getReturnValue() { - return returnValue; - } +final class DefaultScriptExecutionResult implements IScriptExecutionResult +{ + + private final String script; + private final Throwable exception; + private final String output; + private final Object returnValue; + + public DefaultScriptExecutionResult(final String script, final Throwable exception, + final String output, final Object returnValue) + { + this.script = script; + this.exception = exception; + this.output = output; + this.returnValue = returnValue; + } + + public String getScript() + { + return script; + } + + public boolean isSuccess() + { + return exception == null; + } + + public Throwable getException() + { + return exception; + } + + public String getOutput() + { + return output; + } + + public Object getReturnValue() + { + return returnValue; + } } \ No newline at end of file diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Engines.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Engines.java index c0dcb371c3..4b95c99dfe 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Engines.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Engines.java @@ -22,17 +22,19 @@ * * @author cretzel */ -public class Engines { +public class Engines +{ - public static IScriptEngine create(final Lang lang) { - switch (lang) { - case GROOVY: - return new GroovyEngine(); - case CLOJURE: - return new ClojureEngine(); - default: - throw new UnsupportedOperationException("Unsupported language: " - + lang); + public static IScriptEngine create(final Lang lang) + { + switch (lang) + { + case GROOVY : + return new GroovyEngine(); + case CLOJURE : + return new ClojureEngine(); + default : + throw new UnsupportedOperationException("Unsupported language: " + lang); } } } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/GroovyEngine.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/GroovyEngine.java index cb0358b655..858561fb17 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/GroovyEngine.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/GroovyEngine.java @@ -26,52 +26,59 @@ /** * Executes Groovy scripts. *

- * Executes Groovy scripts with {@link GroovyShell}. stdout and stderr are - * captured. Bindings are available in Groovy code simply by their names. + * Executes Groovy scripts with {@link GroovyShell}. stdout and stderr are captured. Bindings are + * available in Groovy code simply by their names. * * @author cretzel */ -public class GroovyEngine implements IScriptEngine { +public class GroovyEngine implements IScriptEngine +{ - /** - * {@inheritDoc} - */ - public synchronized IScriptExecutionResult execute(final String script) { - return execute(script, null); - } + /** + * {@inheritDoc} + */ + public synchronized IScriptExecutionResult execute(final String script) + { + return execute(script, null); + } - /** - * {@inheritDoc} - */ - public synchronized IScriptExecutionResult execute(final String script, - final Map bindings) { + /** + * {@inheritDoc} + */ + public synchronized IScriptExecutionResult execute(final String script, + final Map bindings) + { - Throwable exception = null; - String output = null; - Object returnValue = null; + Throwable exception = null; + String output = null; + Object returnValue = null; - final PrintStream oldOut = System.out; - final PrintStream oldErr = System.err; - final ByteArrayOutputStream bout = new ByteArrayOutputStream(); - final PrintStream newOut = new PrintStream(bout, false); + final PrintStream oldOut = System.out; + final PrintStream oldErr = System.err; + final ByteArrayOutputStream bout = new ByteArrayOutputStream(); + final PrintStream newOut = new PrintStream(bout, false); - try { - System.setOut(newOut); - System.setErr(newOut); + try + { + System.setOut(newOut); + System.setErr(newOut); - final GroovyShell shell = new GroovyShell(new Binding(bindings)); - returnValue = shell.evaluate(script); + final GroovyShell shell = new GroovyShell(new Binding(bindings)); + returnValue = shell.evaluate(script); - } catch (final Exception e) { - exception = e; - } finally { - System.setOut(oldOut); - System.setErr(oldErr); - output = bout.toString(); - } + } + catch (final Exception e) + { + exception = e; + } + finally + { + System.setOut(oldOut); + System.setErr(oldErr); + output = bout.toString(); + } - return new DefaultScriptExecutionResult(script, exception, output, - returnValue); - } + return new DefaultScriptExecutionResult(script, exception, output, returnValue); + } } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptEngine.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptEngine.java index 2ea67e5b16..e031df210c 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptEngine.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptEngine.java @@ -19,12 +19,13 @@ import java.util.Map; /** - * An {@link IScriptEngine} executes a script in a certain language and returns - * the results of the execution as an {@link IScriptExecutionResult}. + * An {@link IScriptEngine} executes a script in a certain language and returns the results of the + * execution as an {@link IScriptExecutionResult}. * * @author cretzel */ -public interface IScriptEngine { +public interface IScriptEngine +{ /** * Executes a script. diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptExecutionResult.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptExecutionResult.java index 7cc020a8b4..a81230aeaf 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptExecutionResult.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/IScriptExecutionResult.java @@ -19,16 +19,16 @@ /** * Result of an {@link IScriptEngine} execution. *

- * Contains the input script, the return value, the output, any exceptions and a - * success flag. + * Contains the input script, the return value, the output, any exceptions and a success flag. * * @author cretzel */ -public interface IScriptExecutionResult { +public interface IScriptExecutionResult +{ - String getScript(); + String getScript(); - boolean isSuccess(); + boolean isSuccess(); String getOutput(); diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Lang.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Lang.java index e13b868038..827ae29a86 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Lang.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/Lang.java @@ -17,18 +17,21 @@ package org.wicketstuff.console.engine; /** Supported Languages enum. */ -public enum Lang { +public enum Lang +{ - CLOJURE, GROOVY; + CLOJURE, GROOVY; - public String getFileExtension() { - switch (this) { - case CLOJURE: - return ".clj"; - case GROOVY: - return ".groovy"; - default: - throw new IllegalArgumentException(); + public String getFileExtension() + { + switch (this) + { + case CLOJURE : + return ".clj"; + case GROOVY : + return ".groovy"; + default : + throw new IllegalArgumentException(); } } } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/LangFileFilter.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/LangFileFilter.java index 57ce94e9b2..02b68b5765 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/LangFileFilter.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/LangFileFilter.java @@ -27,40 +27,49 @@ * * @author cretzel */ -public class LangFileFilter implements FilenameFilter { +public class LangFileFilter implements FilenameFilter +{ - private final String suffix; + private final String suffix; - private LangFileFilter(final String ext) { + private LangFileFilter(final String ext) + { suffix = ext; } - public boolean accept(final File dir, final String name) { + public boolean accept(final File dir, final String name) + { return name.toLowerCase().endsWith(suffix); } - public static LangFileFilter create(final Lang lang) { - switch (lang) { - case GROOVY: - return new GroovyFileFilter(); - case CLOJURE: - return new ClojureFileFilter(); - default: - throw new IllegalArgumentException("Lang " + lang + "not supported"); + public static LangFileFilter create(final Lang lang) + { + switch (lang) + { + case GROOVY : + return new GroovyFileFilter(); + case CLOJURE : + return new ClojureFileFilter(); + default : + throw new IllegalArgumentException("Lang " + lang + "not supported"); } } - public static class GroovyFileFilter extends LangFileFilter { + public static class GroovyFileFilter extends LangFileFilter + { - public GroovyFileFilter() { + public GroovyFileFilter() + { super(Lang.GROOVY.getFileExtension()); } } - public static class ClojureFileFilter extends LangFileFilter { + public static class ClojureFileFilter extends LangFileFilter + { - public ClojureFileFilter() { + public ClojureFileFilter() + { super(Lang.CLOJURE.getFileExtension()); } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ScriptEngineException.java b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ScriptEngineException.java index 7ede96483e..ae47063fd6 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ScriptEngineException.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/main/java/org/wicketstuff/console/engine/ScriptEngineException.java @@ -20,29 +20,34 @@ /** * Represents an exception during script engine execution. *

- * This does not represent an exception thrown by the script itself, which would - * rather be included in the {@link IScriptExecutionResult}. + * This does not represent an exception thrown by the script itself, which would rather be included + * in the {@link IScriptExecutionResult}. * * @author cretzel * */ -public class ScriptEngineException extends RuntimeException { +public class ScriptEngineException extends RuntimeException +{ private static final long serialVersionUID = 1L; - public ScriptEngineException() { + public ScriptEngineException() + { super(); } - public ScriptEngineException(final String message, final Throwable cause) { + public ScriptEngineException(final String message, final Throwable cause) + { super(message, cause); } - public ScriptEngineException(final String message) { + public ScriptEngineException(final String message) + { super(message); } - public ScriptEngineException(final Throwable cause) { + public ScriptEngineException(final Throwable cause) + { super(cause); } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/ClojureEngineTest.java b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/ClojureEngineTest.java index 686f0e3442..21595b0f01 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/ClojureEngineTest.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/ClojureEngineTest.java @@ -28,22 +28,26 @@ import org.junit.Before; import org.junit.Test; -public class ClojureEngineTest { +public class ClojureEngineTest +{ - private ClojureEngine engine; + private ClojureEngine engine; - @Before - public void setup() { - engine = new ClojureEngine(); - } + @Before + public void setup() + { + engine = new ClojureEngine(); + } - @Test - public void test_instanceof_engine() throws Exception { + @Test + public void test_instanceof_engine() throws Exception + { assertTrue(engine instanceof IScriptEngine); } @Test - public void test_empty_script() throws Exception { + public void test_empty_script() throws Exception + { // Given final String script = ""; @@ -58,7 +62,8 @@ public void test_empty_script() throws Exception { } @Test - public void test_execute_exception_01() throws Exception { + public void test_execute_exception_01() throws Exception + { // Given final String script = "xxx"; @@ -75,7 +80,8 @@ public void test_execute_exception_01() throws Exception { } @Test - public void test_simple_returnValue() throws Exception { + public void test_simple_returnValue() throws Exception + { // Given final String script = "5"; @@ -90,7 +96,8 @@ public void test_simple_returnValue() throws Exception { } @Test - public void test_simple_output_sysout() throws Exception { + public void test_simple_output_sysout() throws Exception + { // Given final String script = "(.print System/out 5)"; @@ -106,7 +113,8 @@ public void test_simple_output_sysout() throws Exception { } @Test - public void test_simple_output_rtout() throws Exception { + public void test_simple_output_rtout() throws Exception + { // Given final String script = "(print 6)"; @@ -122,10 +130,11 @@ public void test_simple_output_rtout() throws Exception { } @Test - public void test_simple_defn() throws Exception { + public void test_simple_defn() throws Exception + { // Given - final String script = "(defn fak [n]" - + "(if (< n 1) 1 (* n (fak (dec n)))))" + "(print (fak 5))"; + final String script = "(defn fak [n]" + "(if (< n 1) 1 (* n (fak (dec n)))))" + + "(print (fak 5))"; // When final IScriptExecutionResult result = engine.execute(script); @@ -137,7 +146,8 @@ public void test_simple_defn() throws Exception { } @Test - public void test_simple_binding() throws Exception { + public void test_simple_binding() throws Exception + { // Given final String script = "user/x"; final Map bindings = new HashMap(); diff --git a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/DefaultScriptExecutionResultTest.java b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/DefaultScriptExecutionResultTest.java index bd5485e836..5efce61baf 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/DefaultScriptExecutionResultTest.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/DefaultScriptExecutionResultTest.java @@ -22,43 +22,46 @@ import org.junit.Test; -public class DefaultScriptExecutionResultTest { +public class DefaultScriptExecutionResultTest +{ - @Test - public void test_success() throws Exception { + @Test + public void test_success() throws Exception + { - // Given - final String script = ""; - final Throwable exception = null; - final String output = "output"; - final Object returnValue = null; + // Given + final String script = ""; + final Throwable exception = null; + final String output = "output"; + final Object returnValue = null; - // When - final DefaultScriptExecutionResult result = new DefaultScriptExecutionResult( - script, exception, output, returnValue); + // When + final DefaultScriptExecutionResult result = new DefaultScriptExecutionResult(script, + exception, output, returnValue); - // Then - assertTrue(result.isSuccess()); + // Then + assertTrue(result.isSuccess()); - } + } - @Test - public void test_simple_fail() throws Exception { + @Test + public void test_simple_fail() throws Exception + { - // Given - final String script = ""; - final Throwable exception = new IllegalArgumentException("foo"); - final String output = "output"; - final Object returnValue = null; + // Given + final String script = ""; + final Throwable exception = new IllegalArgumentException("foo"); + final String output = "output"; + final Object returnValue = null; - // When - final DefaultScriptExecutionResult result = new DefaultScriptExecutionResult( - script, exception, output, returnValue); + // When + final DefaultScriptExecutionResult result = new DefaultScriptExecutionResult(script, + exception, output, returnValue); - // Then - assertFalse(result.isSuccess()); - assertSame(exception, result.getException()); + // Then + assertFalse(result.isSuccess()); + assertSame(exception, result.getException()); - } + } } diff --git a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/GroovyEngineTest.java b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/GroovyEngineTest.java index c481289c9a..e9aa2282f2 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/GroovyEngineTest.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/GroovyEngineTest.java @@ -28,22 +28,26 @@ import org.junit.Before; import org.junit.Test; -public class GroovyEngineTest { +public class GroovyEngineTest +{ - private GroovyEngine engine; + private GroovyEngine engine; - @Before - public void setup() { - engine = new GroovyEngine(); - } + @Before + public void setup() + { + engine = new GroovyEngine(); + } @Test - public void test_instanceof_engine() throws Exception { + public void test_instanceof_engine() throws Exception + { assertTrue(engine instanceof IScriptEngine); } @Test - public void test_empty_script() throws Exception { + public void test_empty_script() throws Exception + { // Given final String script = ""; @@ -58,7 +62,8 @@ public void test_empty_script() throws Exception { } @Test - public void test_execute_exception_01() throws Exception { + public void test_execute_exception_01() throws Exception + { // Given final String script = "xxx"; @@ -75,7 +80,8 @@ public void test_execute_exception_01() throws Exception { } @Test - public void test_simple_returnValue() throws Exception { + public void test_simple_returnValue() throws Exception + { // Given final String script = "5"; @@ -90,7 +96,8 @@ public void test_simple_returnValue() throws Exception { } @Test - public void test_simple_output_sysout() throws Exception { + public void test_simple_output_sysout() throws Exception + { // Given final String script = "System.out.print(\"5\")"; @@ -106,7 +113,8 @@ public void test_simple_output_sysout() throws Exception { } @Test - public void test_simple_output_rtout() throws Exception { + public void test_simple_output_rtout() throws Exception + { // Given final String script = "print 6"; @@ -122,10 +130,10 @@ public void test_simple_output_rtout() throws Exception { } @Test - public void test_simple_def() throws Exception { + public void test_simple_def() throws Exception + { // Given - final String script = "def fak(n) {\n" - + "if (n>1) n * fak(n-1) else 1}\n" + "print fak(5)"; + final String script = "def fak(n) {\n" + "if (n>1) n * fak(n-1) else 1}\n" + "print fak(5)"; // When final IScriptExecutionResult result = engine.execute(script); @@ -137,7 +145,8 @@ public void test_simple_def() throws Exception { } @Test - public void test_simple_binding() throws Exception { + public void test_simple_binding() throws Exception + { // Given final String script = "x"; final Map bindings = new HashMap(); diff --git a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/LangFileFilterTest.java b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/LangFileFilterTest.java index 8193e290f1..0009db4fe6 100644 --- a/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/LangFileFilterTest.java +++ b/jdk-1.5-parent/console-parent/console-engine/src/test/java/org/wicketstuff/console/engine/LangFileFilterTest.java @@ -28,39 +28,43 @@ * * @author cretzel */ -public class LangFileFilterTest { +public class LangFileFilterTest +{ - private LangFileFilter groovyFileFilter; - private LangFileFilter clojureFileFilter; + private LangFileFilter groovyFileFilter; + private LangFileFilter clojureFileFilter; - @Before - public void setup() { - groovyFileFilter = LangFileFilter.create(Lang.GROOVY); - clojureFileFilter = LangFileFilter.create(Lang.CLOJURE); - } + @Before + public void setup() + { + groovyFileFilter = LangFileFilter.create(Lang.GROOVY); + clojureFileFilter = LangFileFilter.create(Lang.CLOJURE); + } - @Test - public void test_accept_groovy() throws Exception { + @Test + public void test_accept_groovy() throws Exception + { - assertTrue(groovyFileFilter.accept(null, "Main.groovy")); - assertTrue(groovyFileFilter.accept(null, "Main.GROOVY")); - assertTrue(groovyFileFilter.accept(null, "/home/files/Main.GROOVY")); + assertTrue(groovyFileFilter.accept(null, "Main.groovy")); + assertTrue(groovyFileFilter.accept(null, "Main.GROOVY")); + assertTrue(groovyFileFilter.accept(null, "/home/files/Main.GROOVY")); - assertFalse(groovyFileFilter.accept(null, "Main.clj")); - assertFalse(groovyFileFilter.accept(null, "Main.TXT")); - assertFalse(groovyFileFilter.accept(null, "/home/files/groovy")); + assertFalse(groovyFileFilter.accept(null, "Main.clj")); + assertFalse(groovyFileFilter.accept(null, "Main.TXT")); + assertFalse(groovyFileFilter.accept(null, "/home/files/groovy")); - } + } - @Test - public void test_accept_clojure() throws Exception { - assertTrue(clojureFileFilter.accept(null, "Main.clj")); - assertTrue(clojureFileFilter.accept(null, "Main.CLJ")); - assertTrue(clojureFileFilter.accept(null, "/home/files/Main.clj")); + @Test + public void test_accept_clojure() throws Exception + { + assertTrue(clojureFileFilter.accept(null, "Main.clj")); + assertTrue(clojureFileFilter.accept(null, "Main.CLJ")); + assertTrue(clojureFileFilter.accept(null, "/home/files/Main.clj")); - assertFalse(clojureFileFilter.accept(null, "Main.groovy")); - assertFalse(clojureFileFilter.accept(null, "Main.TXT")); - assertFalse(clojureFileFilter.accept(null, "/home/files/clj")); + assertFalse(clojureFileFilter.accept(null, "Main.groovy")); + assertFalse(clojureFileFilter.accept(null, "Main.TXT")); + assertFalse(clojureFileFilter.accept(null, "/home/files/clj")); - } + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineTestPage.java index 3e8c91c41d..b03f0dd2e4 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineTestPage.java @@ -21,17 +21,18 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import org.wicketstuff.console.ClojureScriptEnginePanel; -public class ClojureEngineTestPage extends WebPage { - private static final long serialVersionUID = 1L; +public class ClojureEngineTestPage extends WebPage +{ + private static final long serialVersionUID = 1L; - public ClojureEngineTestPage(final PageParameters params) { - super(params); + public ClojureEngineTestPage(final PageParameters params) + { + super(params); - add(new Label("version", getApplication().getFrameworkSettings() - .getVersion())); - // TODO Add your page's components here - add(new ClojureScriptEnginePanel("scriptPanel")); + add(new Label("version", getApplication().getFrameworkSettings().getVersion())); + // TODO Add your page's components here + add(new ClojureScriptEnginePanel("scriptPanel")); - add(new TestPageLinksPanel("links")); - } + add(new TestPageLinksPanel("links")); + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWindowTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWindowTestPage.java index 7ca51a06db..98e15928dc 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWindowTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWindowTestPage.java @@ -22,32 +22,37 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import org.wicketstuff.console.ClojureScriptEngineWindow; -public class ClojureEngineWindowTestPage extends WebPage { - - private static final class OpenLink extends AjaxLink { - private final ClojureScriptEngineWindow window; - private static final long serialVersionUID = 1L; - - private OpenLink(final String id, final ClojureScriptEngineWindow window) { - super(id); - this.window = window; - } - - @Override - public void onClick(final AjaxRequestTarget target) { - window.show(target); - } - } - - private static final long serialVersionUID = 1L; - private ClojureScriptEngineWindow window; - - public ClojureEngineWindowTestPage(final PageParameters params) { - super(params); - - add(window = new ClojureScriptEngineWindow("window")); - add(new OpenLink("link", window)); - add(new TestPageLinksPanel("links")); - } +public class ClojureEngineWindowTestPage extends WebPage +{ + + private static final class OpenLink extends AjaxLink + { + private final ClojureScriptEngineWindow window; + private static final long serialVersionUID = 1L; + + private OpenLink(final String id, final ClojureScriptEngineWindow window) + { + super(id); + this.window = window; + } + + @Override + public void onClick(final AjaxRequestTarget target) + { + window.show(target); + } + } + + private static final long serialVersionUID = 1L; + private ClojureScriptEngineWindow window; + + public ClojureEngineWindowTestPage(final PageParameters params) + { + super(params); + + add(window = new ClojureScriptEngineWindow("window")); + add(new OpenLink("link", window)); + add(new TestPageLinksPanel("links")); + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesTestPage.java index adcc3d08a5..643656d7d8 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesTestPage.java @@ -22,16 +22,18 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import org.wicketstuff.console.ClojureScriptEngineWithTemplatesPanel; -public class ClojureEngineWithTemplatesTestPage extends WebPage { - private static final long serialVersionUID = 1L; +public class ClojureEngineWithTemplatesTestPage extends WebPage +{ + private static final long serialVersionUID = 1L; - public ClojureEngineWithTemplatesTestPage(final PageParameters params) { - super(params); - add(new Label("title", new ResourceModel("application.title"))); + public ClojureEngineWithTemplatesTestPage(final PageParameters params) + { + super(params); + add(new Label("title", new ResourceModel("application.title"))); - add(new ClojureScriptEngineWithTemplatesPanel("panel", null, null)); + add(new ClojureScriptEngineWithTemplatesPanel("panel", null, null)); - add(new TestPageLinksPanel("links")); - } + add(new TestPageLinksPanel("links")); + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesWindowTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesWindowTestPage.java index 3b474734d0..c07e30fd1d 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesWindowTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/ClojureEngineWithTemplatesWindowTestPage.java @@ -27,43 +27,46 @@ import org.wicketstuff.console.templates.PackagedScriptTemplates; import org.wicketstuff.console.templates.ScriptTemplate; -public class ClojureEngineWithTemplatesWindowTestPage extends WebPage { +public class ClojureEngineWithTemplatesWindowTestPage extends WebPage +{ - private static final class OpenLink extends AjaxLink { - private final ClojureScriptEngineWithTemplatesWindow window; - private static final long serialVersionUID = 1L; + private static final class OpenLink extends AjaxLink + { + private final ClojureScriptEngineWithTemplatesWindow window; + private static final long serialVersionUID = 1L; - private OpenLink(final String id, - final ClojureScriptEngineWithTemplatesWindow window) { - super(id); - this.window = window; - } + private OpenLink(final String id, final ClojureScriptEngineWithTemplatesWindow window) + { + super(id); + this.window = window; + } - @Override - public void onClick(final AjaxRequestTarget target) { - window.show(target); - } - } + @Override + public void onClick(final AjaxRequestTarget target) + { + window.show(target); + } + } - private static final long serialVersionUID = 1L; - private ClojureScriptEngineWithTemplatesWindow window; - private final OpenLink openLink; + private static final long serialVersionUID = 1L; + private ClojureScriptEngineWithTemplatesWindow window; + private final OpenLink openLink; - public ClojureEngineWithTemplatesWindowTestPage(final PageParameters params) { - super(params); + public ClojureEngineWithTemplatesWindowTestPage(final PageParameters params) + { + super(params); - final IDataProvider dataProvider = new ListDataProvider( - PackagedScriptTemplates - .getPackagedScriptTemplates(Lang.CLOJURE)); - add(window = new ClojureScriptEngineWithTemplatesWindow("window", null, - dataProvider)); - openLink = new OpenLink("link", window); - add(openLink); - add(new TestPageLinksPanel("links")); - } + final IDataProvider dataProvider = new ListDataProvider( + PackagedScriptTemplates.getPackagedScriptTemplates(Lang.CLOJURE)); + add(window = new ClojureScriptEngineWithTemplatesWindow("window", null, dataProvider)); + openLink = new OpenLink("link", window); + add(openLink); + add(new TestPageLinksPanel("links")); + } - public OpenLink getOpenLink() { - return openLink; - } + public OpenLink getOpenLink() + { + return openLink; + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineTestPage.java index 1bb880e446..a8dd9bc293 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineTestPage.java @@ -26,23 +26,23 @@ import org.wicketstuff.console.templates.ScriptTemplate; import org.wicketstuff.console.templates.ScriptTemplateSelectionTablePanel; -public class GroovyEngineTestPage extends WebPage { - private static final long serialVersionUID = 1L; +public class GroovyEngineTestPage extends WebPage +{ + private static final long serialVersionUID = 1L; - public GroovyEngineTestPage(final PageParameters params) { - super(params); + public GroovyEngineTestPage(final PageParameters params) + { + super(params); - final GroovyScriptEnginePanel enginePanel = new GroovyScriptEnginePanel( - "scriptPanel"); - enginePanel.setOutputMarkupId(true); - add(enginePanel); + final GroovyScriptEnginePanel enginePanel = new GroovyScriptEnginePanel("scriptPanel"); + enginePanel.setOutputMarkupId(true); + add(enginePanel); final IDataProvider dataProvider = new ListDataProvider( - PackagedScriptTemplates.getPackagedScriptTemplates(Lang.GROOVY)); + PackagedScriptTemplates.getPackagedScriptTemplates(Lang.GROOVY)); final ScriptTemplateSelectionTablePanel scriptTable = new ScriptTemplateSelectionTablePanel( - "templatesTable", enginePanel, - dataProvider, 100); + "templatesTable", enginePanel, dataProvider, 100); add(scriptTable); add(new TestPageLinksPanel("links")); diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWindowTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWindowTestPage.java index 6b19b22b7c..e21a3aa7e5 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWindowTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWindowTestPage.java @@ -22,32 +22,37 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import org.wicketstuff.console.GroovyScriptEngineWindow; -public class GroovyEngineWindowTestPage extends WebPage { - - private static final class OpenLink extends AjaxLink { - private final GroovyScriptEngineWindow window; - private static final long serialVersionUID = 1L; - - private OpenLink(final String id, final GroovyScriptEngineWindow window) { - super(id); - this.window = window; - } - - @Override - public void onClick(final AjaxRequestTarget target) { - window.show(target); - } - } - - private static final long serialVersionUID = 1L; - private GroovyScriptEngineWindow window; - - public GroovyEngineWindowTestPage(final PageParameters params) { - super(params); - - add(window = new GroovyScriptEngineWindow("window")); - add(new OpenLink("link", window)); - add(new TestPageLinksPanel("links")); - } +public class GroovyEngineWindowTestPage extends WebPage +{ + + private static final class OpenLink extends AjaxLink + { + private final GroovyScriptEngineWindow window; + private static final long serialVersionUID = 1L; + + private OpenLink(final String id, final GroovyScriptEngineWindow window) + { + super(id); + this.window = window; + } + + @Override + public void onClick(final AjaxRequestTarget target) + { + window.show(target); + } + } + + private static final long serialVersionUID = 1L; + private GroovyScriptEngineWindow window; + + public GroovyEngineWindowTestPage(final PageParameters params) + { + super(params); + + add(window = new GroovyScriptEngineWindow("window")); + add(new OpenLink("link", window)); + add(new TestPageLinksPanel("links")); + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesTestPage.java index 71852dce1f..d92ab5fc5f 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesTestPage.java @@ -22,16 +22,18 @@ import org.apache.wicket.request.mapper.parameter.PageParameters; import org.wicketstuff.console.GroovyScriptEngineWithTemplatesPanel; -public class GroovyEngineWithTemplatesTestPage extends WebPage { - private static final long serialVersionUID = 1L; +public class GroovyEngineWithTemplatesTestPage extends WebPage +{ + private static final long serialVersionUID = 1L; - public GroovyEngineWithTemplatesTestPage(final PageParameters params) { - super(params); - add(new Label("title", new ResourceModel("application.title"))); + public GroovyEngineWithTemplatesTestPage(final PageParameters params) + { + super(params); + add(new Label("title", new ResourceModel("application.title"))); - add(new GroovyScriptEngineWithTemplatesPanel("panel", null, null)); + add(new GroovyScriptEngineWithTemplatesPanel("panel", null, null)); - add(new TestPageLinksPanel("links")); - } + add(new TestPageLinksPanel("links")); + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesWindowTestPage.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesWindowTestPage.java index 1803d43708..0a416e1be0 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesWindowTestPage.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/GroovyEngineWithTemplatesWindowTestPage.java @@ -27,42 +27,46 @@ import org.wicketstuff.console.templates.PackagedScriptTemplates; import org.wicketstuff.console.templates.ScriptTemplate; -public class GroovyEngineWithTemplatesWindowTestPage extends WebPage { +public class GroovyEngineWithTemplatesWindowTestPage extends WebPage +{ - private static final class OpenLink extends AjaxLink { - private final GroovyScriptEngineWithTemplatesWindow window; - private static final long serialVersionUID = 1L; + private static final class OpenLink extends AjaxLink + { + private final GroovyScriptEngineWithTemplatesWindow window; + private static final long serialVersionUID = 1L; - private OpenLink(final String id, - final GroovyScriptEngineWithTemplatesWindow window) { - super(id); - this.window = window; - } + private OpenLink(final String id, final GroovyScriptEngineWithTemplatesWindow window) + { + super(id); + this.window = window; + } - @Override - public void onClick(final AjaxRequestTarget target) { - window.show(target); - } - } + @Override + public void onClick(final AjaxRequestTarget target) + { + window.show(target); + } + } - private static final long serialVersionUID = 1L; - private GroovyScriptEngineWithTemplatesWindow window; - private final OpenLink openLink; + private static final long serialVersionUID = 1L; + private GroovyScriptEngineWithTemplatesWindow window; + private final OpenLink openLink; - public GroovyEngineWithTemplatesWindowTestPage(final PageParameters params) { - super(params); + public GroovyEngineWithTemplatesWindowTestPage(final PageParameters params) + { + super(params); - final IDataProvider dataProvider = new ListDataProvider( - PackagedScriptTemplates.getPackagedScriptTemplates(Lang.GROOVY)); - add(window = new GroovyScriptEngineWithTemplatesWindow("window", null, - dataProvider)); - openLink = new OpenLink("link", window); - add(openLink); - add(new TestPageLinksPanel("links")); - } + final IDataProvider dataProvider = new ListDataProvider( + PackagedScriptTemplates.getPackagedScriptTemplates(Lang.GROOVY)); + add(window = new GroovyScriptEngineWithTemplatesWindow("window", null, dataProvider)); + openLink = new OpenLink("link", window); + add(openLink); + add(new TestPageLinksPanel("links")); + } - public OpenLink getOpenLink() { - return openLink; - } + public OpenLink getOpenLink() + { + return openLink; + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/TestPageLinksPanel.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/TestPageLinksPanel.java index dd594dc59d..18bc9b8c20 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/TestPageLinksPanel.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/TestPageLinksPanel.java @@ -23,33 +23,35 @@ import org.apache.wicket.markup.repeater.RepeatingView; import org.apache.wicket.model.Model; -public class TestPageLinksPanel extends Panel { - - private static final long serialVersionUID = 1L; - - public TestPageLinksPanel(final String id) { - super(id); - - final RepeatingView r = new RepeatingView("testPageLinks"); - add(r); - - addLink(r, GroovyEngineTestPage.class); - addLink(r, GroovyEngineWindowTestPage.class); - addLink(r, GroovyEngineWithTemplatesTestPage.class); - addLink(r, GroovyEngineWithTemplatesWindowTestPage.class); - - addLink(r, ClojureEngineTestPage.class); - addLink(r, ClojureEngineWindowTestPage.class); - addLink(r, ClojureEngineWithTemplatesTestPage.class); - addLink(r, ClojureEngineWithTemplatesWindowTestPage.class); - } - - private void addLink(final RepeatingView r, - final Class pageClass) { - final BookmarkablePageLink link1 = new BookmarkablePageLink( - r.newChildId(), pageClass); - link1.add(new Label("label", Model.of(pageClass.getSimpleName()))); - r.add(link1); - } +public class TestPageLinksPanel extends Panel +{ + + private static final long serialVersionUID = 1L; + + public TestPageLinksPanel(final String id) + { + super(id); + + final RepeatingView r = new RepeatingView("testPageLinks"); + add(r); + + addLink(r, GroovyEngineTestPage.class); + addLink(r, GroovyEngineWindowTestPage.class); + addLink(r, GroovyEngineWithTemplatesTestPage.class); + addLink(r, GroovyEngineWithTemplatesWindowTestPage.class); + + addLink(r, ClojureEngineTestPage.class); + addLink(r, ClojureEngineWindowTestPage.class); + addLink(r, ClojureEngineWithTemplatesTestPage.class); + addLink(r, ClojureEngineWithTemplatesWindowTestPage.class); + } + + private void addLink(final RepeatingView r, final Class pageClass) + { + final BookmarkablePageLink link1 = new BookmarkablePageLink(r.newChildId(), + pageClass); + link1.add(new Label("label", Model.of(pageClass.getSimpleName()))); + r.add(link1); + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/WicketApplication.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/WicketApplication.java index ef2f2abd7e..328bc9ba6f 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/WicketApplication.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/WicketApplication.java @@ -22,45 +22,45 @@ import org.wicketstuff.console.examples.hibernate.Book; /** - * Application object for your web application. If you want to run this - * application without deploying, run the Start class. + * Application object for your web application. If you want to run this application without + * deploying, run the Start class. * * @see org.wicketstuff.console.examples.Start#main(String[]) */ -public class WicketApplication extends WebApplication { - private SessionFactory sessionFactory; +public class WicketApplication extends WebApplication +{ + private SessionFactory sessionFactory; - /** - * @see org.apache.wicket.Application#getHomePage() - */ - @Override - public Class getHomePage() { - return ClojureEngineTestPage.class; - } + /** + * @see org.apache.wicket.Application#getHomePage() + */ + @Override + public Class getHomePage() + { + return ClojureEngineTestPage.class; + } - /** - * @see org.apache.wicket.Application#init() - */ - @Override - public void init() { - super.init(); - final Configuration cfg = new Configuration() - .addAnnotatedClass(Book.class) - .setProperty("hibernate.dialect", - "org.hibernate.dialect.HSQLDialect") - .setProperty("hibernate.connection.driver_class", - "org.hsqldb.jdbcDriver") - .setProperty("hibernate.connection.url", - "jdbc:hsqldb:mem:console") - .setProperty("hibernate.connection.username", "sa") - .setProperty("hibernate.connection.password", "") - .setProperty("hibernate.order_updates", "true") - .setProperty("hibernate.hbm2ddl.auto", "update"); - sessionFactory = cfg.buildSessionFactory(); - } + /** + * @see org.apache.wicket.Application#init() + */ + @Override + public void init() + { + super.init(); + final Configuration cfg = new Configuration().addAnnotatedClass(Book.class) + .setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect") + .setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver") + .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:console") + .setProperty("hibernate.connection.username", "sa") + .setProperty("hibernate.connection.password", "") + .setProperty("hibernate.order_updates", "true") + .setProperty("hibernate.hbm2ddl.auto", "update"); + sessionFactory = cfg.buildSessionFactory(); + } - public SessionFactory getSessionFactory() { - return sessionFactory; - } + public SessionFactory getSessionFactory() + { + return sessionFactory; + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/hibernate/Book.java b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/hibernate/Book.java index 921a873912..31e85866b2 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/hibernate/Book.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/main/java/org/wicketstuff/console/examples/hibernate/Book.java @@ -30,50 +30,59 @@ */ @Entity @Table(name = "Book") -public class Book { +public class Book +{ - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - private String title; - private String author; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private String title; + private String author; - public Book() { - } + public Book() + { + } - public Book(final String title, final String author) { - this.title = title; - this.author = author; - } + public Book(final String title, final String author) + { + this.title = title; + this.author = author; + } - public Long getId() { - return id; - } + public Long getId() + { + return id; + } - public void setId(final Long id) { - this.id = id; - } + public void setId(final Long id) + { + this.id = id; + } - public String getTitle() { - return title; - } + public String getTitle() + { + return title; + } - public void setTitle(final String title) { - this.title = title; - } + public void setTitle(final String title) + { + this.title = title; + } - public String getAuthor() { - return author; - } + public String getAuthor() + { + return author; + } - public void setAuthor(final String author) { - this.author = author; - } + public void setAuthor(final String author) + { + this.author = author; + } - @Override - public String toString() { - return "Book [id=" + id + ", title=" + title + ", author=" + author - + "]"; - } + @Override + public String toString() + { + return "Book [id=" + id + ", title=" + title + ", author=" + author + "]"; + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/Start.java b/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/Start.java index 25ff70a793..aff1a10f81 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/Start.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/Start.java @@ -21,45 +21,49 @@ import org.eclipse.jetty.server.bio.SocketConnector; import org.eclipse.jetty.webapp.WebAppContext; -public class Start { +public class Start +{ - public static void main(final String[] args) throws Exception { - final Server server = new Server(); - final SocketConnector connector = new SocketConnector(); + public static void main(final String[] args) throws Exception + { + final Server server = new Server(); + final SocketConnector connector = new SocketConnector(); - // Set some timeout options to make debugging easier. - connector.setMaxIdleTime(1000 * 60 * 60); - connector.setSoLingerTime(-1); - connector.setPort(8080); - server.setConnectors(new Connector[] { connector }); + // Set some timeout options to make debugging easier. + connector.setMaxIdleTime(1000 * 60 * 60); + connector.setSoLingerTime(-1); + connector.setPort(8080); + server.setConnectors(new Connector[] { connector }); - final WebAppContext bb = new WebAppContext(); - bb.setServer(server); - bb.setContextPath("/"); - bb.setWar("src/main/webapp"); + final WebAppContext bb = new WebAppContext(); + bb.setServer(server); + bb.setContextPath("/"); + bb.setWar("src/main/webapp"); - // START JMX SERVER - // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); - // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); - // server.getContainer().addEventListener(mBeanContainer); - // mBeanContainer.start(); + // START JMX SERVER + // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); + // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); + // server.getContainer().addEventListener(mBeanContainer); + // mBeanContainer.start(); - server.setHandler(bb); + server.setHandler(bb); - try { - System.out - .println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); - server.start(); - System.in.read(); - System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); - // while (System.in.available() == 0) { - // Thread.sleep(5000); - // } - server.stop(); - server.join(); - } catch (final Exception e) { - e.printStackTrace(); - System.exit(100); - } - } + try + { + System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); + server.start(); + System.in.read(); + System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); + // while (System.in.available() == 0) { + // Thread.sleep(5000); + // } + server.stop(); + server.join(); + } + catch (final Exception e) + { + e.printStackTrace(); + System.exit(100); + } + } } diff --git a/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/TestPagesTest.java b/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/TestPagesTest.java index ff55dde0bd..40baf4786d 100644 --- a/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/TestPagesTest.java +++ b/jdk-1.5-parent/console-parent/console-examples/src/test/java/org/wicketstuff/console/examples/TestPagesTest.java @@ -21,74 +21,82 @@ import org.junit.Before; import org.junit.Test; -public class TestPagesTest { +public class TestPagesTest +{ - private WicketTester tester; - private Class clazz; + private WicketTester tester; + private Class clazz; - @Before - public void setUp() { - tester = new WicketTester(new WicketApplication()); - } + @Before + public void setUp() + { + tester = new WicketTester(new WicketApplication()); + } - @Test - public void test_rendersSuccessfully_ClojureEngineTestPage() { - clazz = ClojureEngineTestPage.class; - tester.startPage(clazz); - tester.assertRenderedPage(clazz); - } + @Test + public void test_rendersSuccessfully_ClojureEngineTestPage() + { + clazz = ClojureEngineTestPage.class; + tester.startPage(clazz); + tester.assertRenderedPage(clazz); + } - @Test - public void test_rendersSuccessfully_ClojureEngineWindowTestPage() { - clazz = ClojureEngineWindowTestPage.class; - tester.startPage(clazz); - tester.assertRenderedPage(clazz); - } + @Test + public void test_rendersSuccessfully_ClojureEngineWindowTestPage() + { + clazz = ClojureEngineWindowTestPage.class; + tester.startPage(clazz); + tester.assertRenderedPage(clazz); + } - @Test - public void test_rendersSuccessfully_GroovyEngineTestPage() { - clazz = GroovyEngineTestPage.class; - tester.startPage(clazz); - tester.assertRenderedPage(clazz); - } + @Test + public void test_rendersSuccessfully_GroovyEngineTestPage() + { + clazz = GroovyEngineTestPage.class; + tester.startPage(clazz); + tester.assertRenderedPage(clazz); + } - @Test - public void test_rendersSuccessfully_GroovyEngineWindowTestPage() { - clazz = GroovyEngineWindowTestPage.class; - tester.startPage(clazz); - tester.assertRenderedPage(clazz); - } + @Test + public void test_rendersSuccessfully_GroovyEngineWindowTestPage() + { + clazz = GroovyEngineWindowTestPage.class; + tester.startPage(clazz); + tester.assertRenderedPage(clazz); + } - @Test - public void test_rendersSuccessfully_ClojureEngineWithTemplatesTestPage() { - clazz = ClojureEngineWithTemplatesTestPage.class; - tester.startPage(clazz); - tester.assertRenderedPage(clazz); - } + @Test + public void test_rendersSuccessfully_ClojureEngineWithTemplatesTestPage() + { + clazz = ClojureEngineWithTemplatesTestPage.class; + tester.startPage(clazz); + tester.assertRenderedPage(clazz); + } - @Test - public void test_rendersSuccessfully_GroovyEngineWithTemplatesTestPage() { - clazz = GroovyEngineWithTemplatesTestPage.class; - tester.startPage(clazz); - tester.assertRenderedPage(clazz); - } + @Test + public void test_rendersSuccessfully_GroovyEngineWithTemplatesTestPage() + { + clazz = GroovyEngineWithTemplatesTestPage.class; + tester.startPage(clazz); + tester.assertRenderedPage(clazz); + } - @Test - public void test_rendersSuccessfully_GroovyEngineWithTemplatesWindowTestPage() { - clazz = GroovyEngineWithTemplatesWindowTestPage.class; - final GroovyEngineWithTemplatesWindowTestPage page = (GroovyEngineWithTemplatesWindowTestPage) tester - .startPage(clazz); - tester.assertRenderedPage(clazz); - tester.clickLink(page.getOpenLink()); - } + @Test + public void test_rendersSuccessfully_GroovyEngineWithTemplatesWindowTestPage() + { + clazz = GroovyEngineWithTemplatesWindowTestPage.class; + final GroovyEngineWithTemplatesWindowTestPage page = (GroovyEngineWithTemplatesWindowTestPage)tester.startPage(clazz); + tester.assertRenderedPage(clazz); + tester.clickLink(page.getOpenLink()); + } - @Test - public void test_rendersSuccessfully_ClojureEngineWithTemplatesWindowTestPage() { - clazz = ClojureEngineWithTemplatesWindowTestPage.class; - final ClojureEngineWithTemplatesWindowTestPage page = (ClojureEngineWithTemplatesWindowTestPage) tester - .startPage(clazz); - tester.assertRenderedPage(clazz); - tester.clickLink(page.getOpenLink()); - } + @Test + public void test_rendersSuccessfully_ClojureEngineWithTemplatesWindowTestPage() + { + clazz = ClojureEngineWithTemplatesWindowTestPage.class; + final ClojureEngineWithTemplatesWindowTestPage page = (ClojureEngineWithTemplatesWindowTestPage)tester.startPage(clazz); + tester.assertRenderedPage(clazz); + tester.clickLink(page.getOpenLink()); + } } diff --git a/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/PackagedScriptTemplates.java b/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/PackagedScriptTemplates.java index 6067fb85bf..bcca5422c6 100644 --- a/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/PackagedScriptTemplates.java +++ b/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/PackagedScriptTemplates.java @@ -27,25 +27,22 @@ * * @author cretzel */ -public class PackagedScriptTemplates { +public class PackagedScriptTemplates +{ private static final String SCRIPT_DIR_BASE = "org/wicketstuff/console/templates/"; - private static final String[] PACKAGED_GROOVY_TEMPLATES = new String[] { - "HibernateCriteria", "HibernateHqlQuery", "HibernateSave", - "HibernateShowSql", "HibernateStatistics", "Log4j", - "MethodsAndFields", "ReadClasspathResource", "SystemProperties", - "WicketClearMarkupCache", "WicketClearPropertiesCache", - "WicketClientInfo", "WicketComponentHierarchy", - "WicketInvalidateSession", "WicketSize" }; + private static final String[] PACKAGED_GROOVY_TEMPLATES = new String[] { "HibernateCriteria", + "HibernateHqlQuery", "HibernateSave", "HibernateShowSql", "HibernateStatistics", + "Log4j", "MethodsAndFields", "ReadClasspathResource", "SystemProperties", + "WicketClearMarkupCache", "WicketClearPropertiesCache", "WicketClientInfo", + "WicketComponentHierarchy", "WicketInvalidateSession", "WicketSize" }; - private static final String[] PACKAGED_CLOJURE_TEMPLATES = new String[] { - "HibernateCriteria", "HibernateHqlQuery", "HibernateSave", - "HibernateShowSql", "HibernateStatistics", "Log4j", - "MethodsAndFields", "ReadClasspathResource", "SystemProperties", - "WicketClearMarkupCache", "WicketClearPropertiesCache", - "WicketClientInfo", "WicketComponentHierarchy", - "WicketInvalidateSession", "WicketSize" }; + private static final String[] PACKAGED_CLOJURE_TEMPLATES = new String[] { "HibernateCriteria", + "HibernateHqlQuery", "HibernateSave", "HibernateShowSql", "HibernateStatistics", + "Log4j", "MethodsAndFields", "ReadClasspathResource", "SystemProperties", + "WicketClearMarkupCache", "WicketClearPropertiesCache", "WicketClientInfo", + "WicketComponentHierarchy", "WicketInvalidateSession", "WicketSize" }; /** * Returns all packaged script templates for a given source language. @@ -54,30 +51,31 @@ public class PackagedScriptTemplates { * language * @return List of {@link ScriptTemplate}s */ - public static List getPackagedScriptTemplates( - final Lang lang) { + public static List getPackagedScriptTemplates(final Lang lang) + { final List templates = new ArrayList(); String[] templateNames = new String[0]; - switch (lang) { - case GROOVY: - templateNames = PACKAGED_GROOVY_TEMPLATES; - break; - case CLOJURE: - templateNames = PACKAGED_CLOJURE_TEMPLATES; - break; - default: - break; + switch (lang) + { + case GROOVY : + templateNames = PACKAGED_GROOVY_TEMPLATES; + break; + case CLOJURE : + templateNames = PACKAGED_CLOJURE_TEMPLATES; + break; + default : + break; } final ClassLoader cl = PackagedScriptTemplates.class.getClassLoader(); - for (final String name : templateNames) { - final String scriptBase = SCRIPT_DIR_BASE - + lang.name().toLowerCase() + "/"; - final ScriptTemplate template = ScriptTemplateUtils - .readTemplateFromClasspath(cl, scriptBase, name, lang); + for (final String name : templateNames) + { + final String scriptBase = SCRIPT_DIR_BASE + lang.name().toLowerCase() + "/"; + final ScriptTemplate template = ScriptTemplateUtils.readTemplateFromClasspath(cl, + scriptBase, name, lang); templates.add(template); } diff --git a/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplate.java b/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplate.java index b74e0955ef..54398958d6 100644 --- a/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplate.java +++ b/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplate.java @@ -23,13 +23,14 @@ /** * Represents a single script template. *

- * Script templates can be used to provide frequently used scripts. These script - * templates can than be provided to a {@link ScriptTemplateSelectionTablePanel} - * to make them accessible through the UI. + * Script templates can be used to provide frequently used scripts. These script templates can than + * be provided to a {@link ScriptTemplateSelectionTablePanel} to make them accessible through the + * UI. * * @author cretzel */ -public class ScriptTemplate implements Serializable { +public class ScriptTemplate implements Serializable +{ private static final long serialVersionUID = 1L; @@ -37,8 +38,8 @@ public class ScriptTemplate implements Serializable { public String script; public Lang lang; - public ScriptTemplate(final String title, final String script, - final Lang lang) { + public ScriptTemplate(final String title, final String script, final Lang lang) + { this.title = title; this.script = script; this.lang = lang; diff --git a/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplateUtils.java b/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplateUtils.java index 57c9fb15fc..2a38dd03ee 100644 --- a/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplateUtils.java +++ b/jdk-1.5-parent/console-parent/console-templates/src/main/java/org/wicketstuff/console/templates/ScriptTemplateUtils.java @@ -37,176 +37,190 @@ * @author cretzel * */ -public class ScriptTemplateUtils { - - /** - * Read a source file from class path into a {@link ScriptTemplate}. - *

- * The file has to have an appropriate extension such as .groovy or .clj. - * - * @param cl - * ClassLoader - * @param path - * path on the class path - * @param name - * name of the script (without file extension) - * @param lang - * source language - * @return a ScriptTemplate - */ - static ScriptTemplate readTemplateFromClasspath(final ClassLoader cl, - final String path, final String name, final Lang lang) { - - final String resourceName = path + name + lang.getFileExtension(); - final URL url = cl.getResource(resourceName); - if (url == null) { - throw new RuntimeException("Classpath URL for " + resourceName - + " not found"); - } - - StringBuilder content; - try { - content = readUrl(url); - } catch (final IOException e) { - throw new RuntimeException( - String.format("Could not read class path file %s %s %s", - path, name, lang)); - } - - final ScriptTemplate template = new ScriptTemplate( - camelCaseSpace(name), content.toString(), lang); - return template; - } - - private static StringBuilder readUrl(final URL url) throws IOException { - - final InputStream is = url.openConnection().getInputStream(); - final LineNumberReader r = new LineNumberReader(new InputStreamReader( - is)); - - final StringBuilder content = new StringBuilder(); - String line = null; - while ((line = r.readLine()) != null) { - content.append(line).append("\n"); - } - - return content; - } - - /** - * Utility method to read {@link ScriptTemplate}s from a source directory. - * - * @param lang - * source language - * @param dir - * directory to scan for source files - * @return list of {@link ScriptTemplate}s - */ - public static List readTemplatesFromDir(final Lang lang, - final File dir) { - - final List templates = new ArrayList(); - - final File[] files = dir.listFiles(LangFileFilter.create(lang)); - - for (final File file : files) { - final ScriptTemplate template = readTemplateFromFile(lang, file); - templates.add(template); - } - - return templates; - } - - /** - * Utility method to read a {@link ScriptTemplate} from a source file. - * - * @param lang - * source language - * @param file - * source file - * @return a {@link ScriptTemplate} - */ - public static ScriptTemplate readTemplateFromFile(final Lang lang, - final File file) { - final String title = camelCaseSpaceFilename(file); - final String script = readFile(file); - final ScriptTemplate template = new ScriptTemplate(title, script, lang); - return template; - } - - /** - * Utility method to convert a camel cased file name using - * {@link #camelCaseSpace(String)}. - */ - public static String camelCaseSpaceFilename(final File file) { - final String filename = file.getName(); - return camelCaseSpaceFilename(filename); - } - - /** - * Utility method to convert a camel cased file name using - * {@link #camelCaseSpace(String)}. - */ - public static String camelCaseSpaceFilename(final String filename) { - final int indexOfExt = filename.lastIndexOf('.'); - if (indexOfExt == 0) { - throw new RuntimeException("Invalid filename " + filename); - } - - final String baseFilename = filename.substring(0, indexOfExt); - final String scriptName = camelCaseSpace(baseFilename); - - return scriptName; - } - - /** - * Converts a camel cased string into a string where each upper case letter - * is prefixed with a space. - * - * @param str - * a camel cased string - * @return a string where each upper case letter is prefixed with a space - */ - public static String camelCaseSpace(final String str) { - if (str.length() == 0) { - throw new RuntimeException( - "camelCaseSpace not allowed for string length 0"); - } - - final char[] charArray = str.toCharArray(); - final StringBuilder result = new StringBuilder(charArray[0] + ""); - for (int i = 1; i < charArray.length; i++) { - final char c = charArray[i]; - - if (Character.isUpperCase(c)) { - result.append(' '); - } - - result.append(c); - } - - return result.toString(); - } - - static String readFile(final File file) { - try { - final BufferedInputStream bin = new BufferedInputStream( - new FileInputStream(file)); - - final StringBuilder builder = new StringBuilder(); - - int read = 0; - byte[] buffer = new byte[1024]; - while ((read = bin.read(buffer)) != -1) { - final String str = new String(buffer, 0, read); - builder.append(str); - buffer = new byte[1024]; - } - - return builder.toString(); - } catch (final IOException e) { - throw new RuntimeException("Could not read file " + file, e); - } - } +public class ScriptTemplateUtils +{ + + /** + * Read a source file from class path into a {@link ScriptTemplate}. + *

+ * The file has to have an appropriate extension such as .groovy or .clj. + * + * @param cl + * ClassLoader + * @param path + * path on the class path + * @param name + * name of the script (without file extension) + * @param lang + * source language + * @return a ScriptTemplate + */ + static ScriptTemplate readTemplateFromClasspath(final ClassLoader cl, final String path, + final String name, final Lang lang) + { + + final String resourceName = path + name + lang.getFileExtension(); + final URL url = cl.getResource(resourceName); + if (url == null) + { + throw new RuntimeException("Classpath URL for " + resourceName + " not found"); + } + + StringBuilder content; + try + { + content = readUrl(url); + } + catch (final IOException e) + { + throw new RuntimeException(String.format("Could not read class path file %s %s %s", + path, name, lang)); + } + + final ScriptTemplate template = new ScriptTemplate(camelCaseSpace(name), + content.toString(), lang); + return template; + } + + private static StringBuilder readUrl(final URL url) throws IOException + { + + final InputStream is = url.openConnection().getInputStream(); + final LineNumberReader r = new LineNumberReader(new InputStreamReader(is)); + + final StringBuilder content = new StringBuilder(); + String line = null; + while ((line = r.readLine()) != null) + { + content.append(line).append("\n"); + } + + return content; + } + + /** + * Utility method to read {@link ScriptTemplate}s from a source directory. + * + * @param lang + * source language + * @param dir + * directory to scan for source files + * @return list of {@link ScriptTemplate}s + */ + public static List readTemplatesFromDir(final Lang lang, final File dir) + { + + final List templates = new ArrayList(); + + final File[] files = dir.listFiles(LangFileFilter.create(lang)); + + for (final File file : files) + { + final ScriptTemplate template = readTemplateFromFile(lang, file); + templates.add(template); + } + + return templates; + } + + /** + * Utility method to read a {@link ScriptTemplate} from a source file. + * + * @param lang + * source language + * @param file + * source file + * @return a {@link ScriptTemplate} + */ + public static ScriptTemplate readTemplateFromFile(final Lang lang, final File file) + { + final String title = camelCaseSpaceFilename(file); + final String script = readFile(file); + final ScriptTemplate template = new ScriptTemplate(title, script, lang); + return template; + } + + /** + * Utility method to convert a camel cased file name using {@link #camelCaseSpace(String)}. + */ + public static String camelCaseSpaceFilename(final File file) + { + final String filename = file.getName(); + return camelCaseSpaceFilename(filename); + } + + /** + * Utility method to convert a camel cased file name using {@link #camelCaseSpace(String)}. + */ + public static String camelCaseSpaceFilename(final String filename) + { + final int indexOfExt = filename.lastIndexOf('.'); + if (indexOfExt == 0) + { + throw new RuntimeException("Invalid filename " + filename); + } + + final String baseFilename = filename.substring(0, indexOfExt); + final String scriptName = camelCaseSpace(baseFilename); + + return scriptName; + } + + /** + * Converts a camel cased string into a string where each upper case letter is prefixed with a + * space. + * + * @param str + * a camel cased string + * @return a string where each upper case letter is prefixed with a space + */ + public static String camelCaseSpace(final String str) + { + if (str.length() == 0) + { + throw new RuntimeException("camelCaseSpace not allowed for string length 0"); + } + + final char[] charArray = str.toCharArray(); + final StringBuilder result = new StringBuilder(charArray[0] + ""); + for (int i = 1; i < charArray.length; i++) + { + final char c = charArray[i]; + + if (Character.isUpperCase(c)) + { + result.append(' '); + } + + result.append(c); + } + + return result.toString(); + } + + static String readFile(final File file) + { + try + { + final BufferedInputStream bin = new BufferedInputStream(new FileInputStream(file)); + + final StringBuilder builder = new StringBuilder(); + + int read = 0; + byte[] buffer = new byte[1024]; + while ((read = bin.read(buffer)) != -1) + { + final String str = new String(buffer, 0, read); + builder.append(str); + buffer = new byte[1024]; + } + + return builder.toString(); + } + catch (final IOException e) + { + throw new RuntimeException("Could not read file " + file, e); + } + } } diff --git a/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/PackagedScriptTemplatesTest.java b/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/PackagedScriptTemplatesTest.java index c6c1840b46..3a8c10c5ac 100644 --- a/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/PackagedScriptTemplatesTest.java +++ b/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/PackagedScriptTemplatesTest.java @@ -29,24 +29,26 @@ * * @author cretzel */ -public class PackagedScriptTemplatesTest { +public class PackagedScriptTemplatesTest +{ - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception + { + } - @Test - public void test_getPackagedGroovyTemplates() throws Exception { - final List templates = PackagedScriptTemplates - .getPackagedScriptTemplates(Lang.GROOVY); + @Test + public void test_getPackagedGroovyTemplates() throws Exception + { + final List templates = PackagedScriptTemplates.getPackagedScriptTemplates(Lang.GROOVY); assertEquals(15, templates.size()); } @Test - public void test_getPackagedClojureTemplates() throws Exception { - final List templates = PackagedScriptTemplates - .getPackagedScriptTemplates(Lang.CLOJURE); + public void test_getPackagedClojureTemplates() throws Exception + { + final List templates = PackagedScriptTemplates.getPackagedScriptTemplates(Lang.CLOJURE); assertEquals(15, templates.size()); } diff --git a/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/ScriptTemplatesUtilsTest.java b/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/ScriptTemplatesUtilsTest.java index 0f3033926e..b64f7c1d5c 100644 --- a/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/ScriptTemplatesUtilsTest.java +++ b/jdk-1.5-parent/console-parent/console-templates/src/test/java/org/wicketstuff/console/templates/ScriptTemplatesUtilsTest.java @@ -28,19 +28,22 @@ /** * Testing {@link ScriptTemplateUtils}. - * + * * @author cretzel */ -public class ScriptTemplatesUtilsTest { +public class ScriptTemplatesUtilsTest +{ private static final String TEST_SCRIPTS_BASE_DIR = "org/wicketstuff/console/scripts/"; @Before - public void setUp() throws Exception { + public void setUp() throws Exception + { } @Test - public void test_camelCaseSpace() throws Exception { + public void test_camelCaseSpace() throws Exception + { // Given final String str = "GimmeSomeMo"; @@ -52,7 +55,8 @@ public void test_camelCaseSpace() throws Exception { } @Test - public void test_camelCaseSpace_Numbers() throws Exception { + public void test_camelCaseSpace_Numbers() throws Exception + { // Given final String str = "GimmeSome4Mo"; @@ -64,54 +68,53 @@ public void test_camelCaseSpace_Numbers() throws Exception { } @Test - public void test_camelCaseSpaceFilename() throws Exception { + public void test_camelCaseSpaceFilename() throws Exception + { // Given final String filename = "GimmeSomeMo.Mo.groovy"; // When - final String result = ScriptTemplateUtils - .camelCaseSpaceFilename(filename); + final String result = ScriptTemplateUtils.camelCaseSpaceFilename(filename); // Then assertEquals("Gimme Some Mo. Mo", result); } @Test - public void test_readTemplateFromFile() throws Exception { + public void test_readTemplateFromFile() throws Exception + { // Given final File file = new File(getClass().getClassLoader() - .getResource(TEST_SCRIPTS_BASE_DIR + "groovy/Test01.groovy") - .toURI()); + .getResource(TEST_SCRIPTS_BASE_DIR + "groovy/Test01.groovy") + .toURI()); // When - final ScriptTemplate template = ScriptTemplateUtils - .readTemplateFromFile(Lang.GROOVY, file); + final ScriptTemplate template = ScriptTemplateUtils.readTemplateFromFile(Lang.GROOVY, file); // Then assertNotNull(template); assertEquals("println \"foo\"", template.script); } - @Test - public void test_readTemplateFromClasspath() throws Exception { + @Test + public void test_readTemplateFromClasspath() throws Exception + { - // When - final ScriptTemplate template = ScriptTemplateUtils - .readTemplateFromClasspath(getClass().getClassLoader(), - TEST_SCRIPTS_BASE_DIR + "clojure/", "Test01", - Lang.CLOJURE); + // When + final ScriptTemplate template = ScriptTemplateUtils.readTemplateFromClasspath( + getClass().getClassLoader(), TEST_SCRIPTS_BASE_DIR + "clojure/", "Test01", Lang.CLOJURE); - // Then - assertNotNull(template); - } + // Then + assertNotNull(template); + } @Test(expected = RuntimeException.class) - public void test_readTemplateFromClasspath_NotFound() throws Exception { + public void test_readTemplateFromClasspath_NotFound() throws Exception + { // When - ScriptTemplateUtils.readTemplateFromClasspath(getClass() - .getClassLoader(), TEST_SCRIPTS_BASE_DIR + "clojure/", - "Test02", Lang.CLOJURE); + ScriptTemplateUtils.readTemplateFromClasspath(getClass().getClassLoader(), + TEST_SCRIPTS_BASE_DIR + "clojure/", "Test02", Lang.CLOJURE); // Then RuntimeException diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEnginePanel.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEnginePanel.java index d72ea89cb7..0f6eb46807 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEnginePanel.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEnginePanel.java @@ -24,23 +24,27 @@ * * @author cretzel */ -public class ClojureScriptEnginePanel extends ScriptEnginePanel { +public class ClojureScriptEnginePanel extends ScriptEnginePanel +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public ClojureScriptEnginePanel(final String wicketId) { - this(wicketId, null); + public ClojureScriptEnginePanel(final String wicketId) + { + this(wicketId, null); - } + } - public ClojureScriptEnginePanel(final String id, final IModel title) { - super(id, Lang.CLOJURE, title); - init(); - } + public ClojureScriptEnginePanel(final String id, final IModel title) + { + super(id, Lang.CLOJURE, title); + init(); + } - protected void init() { - setInput("(println user/application)\n" + "(println user/page)\n" - + "(println user/component)\n"); - } + protected void init() + { + setInput("(println user/application)\n" + "(println user/page)\n" + + "(println user/component)\n"); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWindow.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWindow.java index e7144beb88..ffc676472d 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWindow.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWindow.java @@ -24,12 +24,14 @@ * * @author cretzel */ -public class ClojureScriptEngineWindow extends ScriptEngineWindow { +public class ClojureScriptEngineWindow extends ScriptEngineWindow +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public ClojureScriptEngineWindow(final String id) { - super(id, Lang.CLOJURE, null); - } + public ClojureScriptEngineWindow(final String id) + { + super(id, Lang.CLOJURE, null); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesPanel.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesPanel.java index 55646058af..a912fd6e18 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesPanel.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesPanel.java @@ -23,31 +23,29 @@ import org.wicketstuff.console.templates.ScriptTemplateSelectionTablePanel; /** - * A combination of {@link ClojureScriptEnginePanel} and - * {@link ScriptTemplateSelectionTablePanel}. + * A combination of {@link ClojureScriptEnginePanel} and {@link ScriptTemplateSelectionTablePanel}. * * @author cretzel */ -public class ClojureScriptEngineWithTemplatesPanel extends - ScriptEnginePanelWithTemplates { +public class ClojureScriptEngineWithTemplatesPanel extends ScriptEnginePanelWithTemplates +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * Creates an instance using the given title and script template data - * provider. - * - * @param id - * id - * @param title - * title, {@code null} for default - * @param dataProvider - * data provider for script templates, {@code null} for default - */ - public ClojureScriptEngineWithTemplatesPanel(final String id, - final IModel title, - final IDataProvider dataProvider) { - super(id, Lang.CLOJURE, title, dataProvider); - } + /** + * Creates an instance using the given title and script template data provider. + * + * @param id + * id + * @param title + * title, {@code null} for default + * @param dataProvider + * data provider for script templates, {@code null} for default + */ + public ClojureScriptEngineWithTemplatesPanel(final String id, final IModel title, + final IDataProvider dataProvider) + { + super(id, Lang.CLOJURE, title, dataProvider); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesWindow.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesWindow.java index e7455ed4a2..58a86cb58e 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesWindow.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ClojureScriptEngineWithTemplatesWindow.java @@ -23,20 +23,19 @@ import org.wicketstuff.console.templates.ScriptTemplate; /** - * A {@link ModalWindow} displaying a - * {@link ClojureScriptEngineWithTemplatesPanel}. + * A {@link ModalWindow} displaying a {@link ClojureScriptEngineWithTemplatesPanel}. * * @author cretzel */ -public class ClojureScriptEngineWithTemplatesWindow extends - ScriptEngineWithTemplatesWindow { +public class ClojureScriptEngineWithTemplatesWindow extends ScriptEngineWithTemplatesWindow +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public ClojureScriptEngineWithTemplatesWindow(final String id, - final IModel windowTitle, - final IDataProvider dataProvider) { - super(id, Lang.CLOJURE, windowTitle, dataProvider); - } + public ClojureScriptEngineWithTemplatesWindow(final String id, + final IModel windowTitle, final IDataProvider dataProvider) + { + super(id, Lang.CLOJURE, windowTitle, dataProvider); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEnginePanel.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEnginePanel.java index 3612669ae6..5a477e9ea6 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEnginePanel.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEnginePanel.java @@ -24,22 +24,25 @@ * * @author cretzel */ -public class GroovyScriptEnginePanel extends ScriptEnginePanel { +public class GroovyScriptEnginePanel extends ScriptEnginePanel +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public GroovyScriptEnginePanel(final String wicketId) { - this(wicketId, null); - } + public GroovyScriptEnginePanel(final String wicketId) + { + this(wicketId, null); + } - public GroovyScriptEnginePanel(final String id, final IModel title) { - super(id, Lang.GROOVY, title); - init(); - } + public GroovyScriptEnginePanel(final String id, final IModel title) + { + super(id, Lang.GROOVY, title); + init(); + } - protected void init() { - setInput("println application\n" + "println page\n" - + "println component\n"); - } + protected void init() + { + setInput("println application\n" + "println page\n" + "println component\n"); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWindow.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWindow.java index 10d59bdf8d..c046149884 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWindow.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWindow.java @@ -24,12 +24,14 @@ * * @author cretzel */ -public class GroovyScriptEngineWindow extends ScriptEngineWindow { +public class GroovyScriptEngineWindow extends ScriptEngineWindow +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public GroovyScriptEngineWindow(final String id) { - super(id, Lang.GROOVY, null); - } + public GroovyScriptEngineWindow(final String id) + { + super(id, Lang.GROOVY, null); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesPanel.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesPanel.java index 33cf30ca07..2d9fb3b10d 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesPanel.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesPanel.java @@ -23,31 +23,29 @@ import org.wicketstuff.console.templates.ScriptTemplateSelectionTablePanel; /** - * A combination {@link GroovyScriptEnginePanel} and - * {@link ScriptTemplateSelectionTablePanel}. + * A combination {@link GroovyScriptEnginePanel} and {@link ScriptTemplateSelectionTablePanel}. * * @author cretzel */ -public class GroovyScriptEngineWithTemplatesPanel extends - ScriptEnginePanelWithTemplates { +public class GroovyScriptEngineWithTemplatesPanel extends ScriptEnginePanelWithTemplates +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * Creates an instance using the given title and script template data - * provider. - * - * @param id - * id - * @param title - * title, {@code null} for default - * @param dataProvider - * data provider for script templates, {@code null} for default - */ - public GroovyScriptEngineWithTemplatesPanel(final String id, - final IModel title, - final IDataProvider dataProvider) { - super(id, Lang.GROOVY, title, dataProvider); - } + /** + * Creates an instance using the given title and script template data provider. + * + * @param id + * id + * @param title + * title, {@code null} for default + * @param dataProvider + * data provider for script templates, {@code null} for default + */ + public GroovyScriptEngineWithTemplatesPanel(final String id, final IModel title, + final IDataProvider dataProvider) + { + super(id, Lang.GROOVY, title, dataProvider); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesWindow.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesWindow.java index 7c0e5f7895..f158642359 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesWindow.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/GroovyScriptEngineWithTemplatesWindow.java @@ -23,24 +23,23 @@ import org.wicketstuff.console.templates.ScriptTemplate; /** - * A {@link ModalWindow} displaying a - * {@link GroovyScriptEngineWithTemplatesPanel}. + * A {@link ModalWindow} displaying a {@link GroovyScriptEngineWithTemplatesPanel}. * * @author cretzel */ -public class GroovyScriptEngineWithTemplatesWindow extends - ScriptEngineWithTemplatesWindow { +public class GroovyScriptEngineWithTemplatesWindow extends ScriptEngineWithTemplatesWindow +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * @see ScriptEngineWithTemplatesWindow#ScriptEngineWithTemplatesWindow(String, - * Lang, org.apache.wicket.model.IModel) - */ - public GroovyScriptEngineWithTemplatesWindow(final String id, - final IModel windowTitle, - final IDataProvider dataProvider) { - super(id, Lang.GROOVY, windowTitle, dataProvider); - } + /** + * @see ScriptEngineWithTemplatesWindow#ScriptEngineWithTemplatesWindow(String, Lang, + * org.apache.wicket.model.IModel) + */ + public GroovyScriptEngineWithTemplatesWindow(final String id, final IModel windowTitle, + final IDataProvider dataProvider) + { + super(id, Lang.GROOVY, windowTitle, dataProvider); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanel.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanel.java index 0aa4c99149..87d7088264 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanel.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanel.java @@ -61,220 +61,249 @@ * * @author cretzel */ -public class ScriptEnginePanel extends Panel { +public class ScriptEnginePanel extends Panel +{ - private final class ClearButton extends Button { - private static final long serialVersionUID = 1L; + private final class ClearButton extends Button + { + private static final long serialVersionUID = 1L; - private ClearButton(final String id) { - super(id); - } + private ClearButton(final String id) + { + super(id); + } - @Override - protected void onInitialize() { - super.onInitialize(); - add(new AttributeAppender("onclick", Model.of("clearTextarea('" - + inputTf.getMarkupId() + "')"), ";")); + @Override + protected void onInitialize() + { + super.onInitialize(); + add(new AttributeAppender("onclick", Model.of("clearTextarea('" + + inputTf.getMarkupId() + "')"), ";")); - } + } - } + } - final class SubmitButton extends AjaxButton implements IAjaxIndicatorAware { - private static final long serialVersionUID = 1L; + final class SubmitButton extends AjaxButton implements IAjaxIndicatorAware + { + private static final long serialVersionUID = 1L; - private SubmitButton(final String id, final Form form) { - super(id, form); - } + private SubmitButton(final String id, final Form form) + { + super(id, form); + } - @Override - protected void onSubmit(final AjaxRequestTarget target, - final Form form) { - process(target); - } + @Override + protected void onSubmit(final AjaxRequestTarget target, final Form form) + { + process(target); + } - @Override - protected void onError(final AjaxRequestTarget target, - final Form form) { + @Override + protected void onError(final AjaxRequestTarget target, final Form form) + { - } + } - public String getAjaxIndicatorMarkupId() { - return indicator.getMarkupId(); - } - } + public String getAjaxIndicatorMarkupId() + { + return indicator.getMarkupId(); + } + } - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private static final ResourceReference CSS = new CompressedResourceReference( - ScriptEnginePanel.class, "ScriptEnginePanel.css"); + private static final ResourceReference CSS = new CompressedResourceReference( + ScriptEnginePanel.class, "ScriptEnginePanel.css"); - private static final ResourceReference JS = new CompressedResourceReference( - ScriptEnginePanel.class, "ScriptEnginePanel.js"); - - private String input; - private String output; - private String returnValue; - - private Label title; - private Form form; - private TextArea inputTf; - private TextArea outputTf; - private TextField returnValueTf; - - private Image indicator; - - private final IModel titleModel; - - private final Lang lang; - - public ScriptEnginePanel(final String id, final Lang lang) { - this(id, lang, null); - } - - public ScriptEnginePanel(final String id, final Lang lang, - final IModel title) { - super(id); - this.lang = lang; - this.titleModel = title != null ? title : Model.of("Wicket Console"); - - init(); - } - - private void init() { - setDefaultModel(new CompoundPropertyModel(this)); - initComponents(); - } - - protected void initComponents() { - title = new Label("title", titleModel); - add(title); - - form = new Form("form"); - add(form); - - inputTf = new TextArea("input"); - inputTf.setOutputMarkupId(true); - form.add(inputTf); - - add(new SubmitButton("submit", form)); - add(new ClearButton("clear")); - - indicator = new Image("indicator", - AbstractDefaultAjaxBehavior.INDICATOR); - indicator.setOutputMarkupId(true); - add(indicator); - - returnValueTf = new TextField("returnValue"); - returnValueTf.setOutputMarkupId(true); - add(returnValueTf); - - outputTf = new TextArea("output"); - outputTf.setOutputMarkupId(true); - add(outputTf); - } - - protected ResourceReference getCSS() { - return CSS; - } - - @Override - public void renderHead(final IHeaderResponse response) { - super.renderHead(response); - - final ResourceReference css = getCSS(); - if (css != null) { - response.renderCSSReference(css); - } - - response.renderJavaScriptReference(JS); - } - - protected void process(final AjaxRequestTarget target) { - - final IScriptEngine engine = newEngine(); - final Map bindings = newBindings(); - - final IScriptExecutionResult result = engine.execute(input, bindings); - - if (result.isSuccess()) { - returnValue = String.valueOf(result.getReturnValue()); - output = result.getOutput(); - } else { - returnValue = null; - output = String.format("%s\n\n%s", result.getOutput(), - result.getException()); - } - - target.add(returnValueTf, outputTf); - } - - protected IScriptEngine newEngine() { - return Engines.create(lang); - } - - protected Map newBindings() { - final Map bindings = new HashMap(); - bindings.put("application", Application.get()); - bindings.put("page", getPage()); - bindings.put("component", this); - return bindings; - } - - public String getInput() { - return input; - } - - public void setInput(final String input) { - this.input = input; - } - - public String getOutput() { - return output; - } - - public void setOutput(final String output) { - this.output = output; - } - - public String getReturnValue() { - return returnValue; - } - - public void setReturnValue(final String returnValue) { - this.returnValue = returnValue; - } - - public TextArea getInputTf() { - return inputTf; - } - - public TextArea getOutputTf() { - return outputTf; - } - - public TextField getReturnValueTf() { - return returnValueTf; - } - - @Override - public void detachModels() { - super.detachModels(); - if (titleModel != null) { - titleModel.detach(); - } - } - - public static ScriptEnginePanel create(final String wicketId, - final Lang lang, final IModel title) { - switch (lang) { - case GROOVY: - return new GroovyScriptEnginePanel(wicketId, title); - case CLOJURE: - return new ClojureScriptEnginePanel(wicketId, title); - default: - throw new UnsupportedOperationException("Unsupported language: " - + lang); - } - } + private static final ResourceReference JS = new CompressedResourceReference( + ScriptEnginePanel.class, "ScriptEnginePanel.js"); + + private String input; + private String output; + private String returnValue; + + private Label title; + private Form form; + private TextArea inputTf; + private TextArea outputTf; + private TextField returnValueTf; + + private Image indicator; + + private final IModel titleModel; + + private final Lang lang; + + public ScriptEnginePanel(final String id, final Lang lang) + { + this(id, lang, null); + } + + public ScriptEnginePanel(final String id, final Lang lang, final IModel title) + { + super(id); + this.lang = lang; + titleModel = title != null ? title : Model.of("Wicket Console"); + + init(); + } + + private void init() + { + setDefaultModel(new CompoundPropertyModel(this)); + initComponents(); + } + + protected void initComponents() + { + title = new Label("title", titleModel); + add(title); + + form = new Form("form"); + add(form); + + inputTf = new TextArea("input"); + inputTf.setOutputMarkupId(true); + form.add(inputTf); + + add(new SubmitButton("submit", form)); + add(new ClearButton("clear")); + + indicator = new Image("indicator", AbstractDefaultAjaxBehavior.INDICATOR); + indicator.setOutputMarkupId(true); + add(indicator); + + returnValueTf = new TextField("returnValue"); + returnValueTf.setOutputMarkupId(true); + add(returnValueTf); + + outputTf = new TextArea("output"); + outputTf.setOutputMarkupId(true); + add(outputTf); + } + + protected ResourceReference getCSS() + { + return CSS; + } + + @Override + public void renderHead(final IHeaderResponse response) + { + super.renderHead(response); + + final ResourceReference css = getCSS(); + if (css != null) + { + response.renderCSSReference(css); + } + + response.renderJavaScriptReference(JS); + } + + protected void process(final AjaxRequestTarget target) + { + + final IScriptEngine engine = newEngine(); + final Map bindings = newBindings(); + + final IScriptExecutionResult result = engine.execute(input, bindings); + + if (result.isSuccess()) + { + returnValue = String.valueOf(result.getReturnValue()); + output = result.getOutput(); + } + else + { + returnValue = null; + output = String.format("%s\n\n%s", result.getOutput(), result.getException()); + } + + target.add(returnValueTf, outputTf); + } + + protected IScriptEngine newEngine() + { + return Engines.create(lang); + } + + protected Map newBindings() + { + final Map bindings = new HashMap(); + bindings.put("application", Application.get()); + bindings.put("page", getPage()); + bindings.put("component", this); + return bindings; + } + + public String getInput() + { + return input; + } + + public void setInput(final String input) + { + this.input = input; + } + + public String getOutput() + { + return output; + } + + public void setOutput(final String output) + { + this.output = output; + } + + public String getReturnValue() + { + return returnValue; + } + + public void setReturnValue(final String returnValue) + { + this.returnValue = returnValue; + } + + public TextArea getInputTf() + { + return inputTf; + } + + public TextArea getOutputTf() + { + return outputTf; + } + + public TextField getReturnValueTf() + { + return returnValueTf; + } + + @Override + public void detachModels() + { + super.detachModels(); + if (titleModel != null) + { + titleModel.detach(); + } + } + + public static ScriptEnginePanel create(final String wicketId, final Lang lang, + final IModel title) + { + switch (lang) + { + case GROOVY : + return new GroovyScriptEnginePanel(wicketId, title); + case CLOJURE : + return new ClojureScriptEnginePanel(wicketId, title); + default : + throw new UnsupportedOperationException("Unsupported language: " + lang); + } + } } \ No newline at end of file diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanelWithTemplates.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanelWithTemplates.java index 385f8bfd17..fdbdb566b5 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanelWithTemplates.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEnginePanelWithTemplates.java @@ -31,7 +31,8 @@ * * @author cretzel */ -public class ScriptEnginePanelWithTemplates extends Panel { +public class ScriptEnginePanelWithTemplates extends Panel +{ private static final long serialVersionUID = 1L; private final Lang lang; @@ -50,75 +51,76 @@ public class ScriptEnginePanelWithTemplates extends Panel { * @param title * title, may be {@code null} for default * @param dataProvider - * data provider for script templates, may be {@code null} for - * default + * data provider for script templates, may be {@code null} for default */ public ScriptEnginePanelWithTemplates(final String id, final Lang lang, - final IModel title, - final IDataProvider dataProvider) { + final IModel title, final IDataProvider dataProvider) + { super(id); this.lang = lang; this.title = title; this.dataProvider = dataProvider; - if (dataProvider == null) { + if (dataProvider == null) + { this.dataProvider = packagedScriptTemplatesDataProvider(lang); } } /** - * Creates a data provider that returns all packaged templates for a given - * source language. + * Creates a data provider that returns all packaged templates for a given source language. * * @param lang * language * @return data provider * @see PackagedScriptTemplates#getPackagedScriptTemplates(Lang) */ - public static IDataProvider packagedScriptTemplatesDataProvider( - final Lang lang) { + public static IDataProvider packagedScriptTemplatesDataProvider(final Lang lang) + { return new ListDataProvider( - PackagedScriptTemplates.getPackagedScriptTemplates(lang)); + PackagedScriptTemplates.getPackagedScriptTemplates(lang)); } @Override - protected void onInitialize() { + protected void onInitialize() + { super.onInitialize(); enginePanel = newEnginePanel(); enginePanel.setOutputMarkupId(true); add(enginePanel); - selectionTable = newSelectionTable("selectionPanel", enginePanel, - dataProvider); + selectionTable = newSelectionTable("selectionPanel", enginePanel, dataProvider); add(selectionTable); } /** * Create the engine panel, override to customize. */ - protected ScriptEnginePanel newEnginePanel() { + protected ScriptEnginePanel newEnginePanel() + { return ScriptEnginePanel.create("enginePanel", lang, title); } /** * Create the selection table, override to customize. */ - protected ScriptTemplateSelectionTablePanel newSelectionTable( - final String wicketId, final ScriptEnginePanel enginePanel, - final IDataProvider dataProvider) { + protected ScriptTemplateSelectionTablePanel newSelectionTable(final String wicketId, + final ScriptEnginePanel enginePanel, final IDataProvider dataProvider) + { - return new ScriptTemplateSelectionTablePanel(wicketId, enginePanel, - dataProvider, 100); + return new ScriptTemplateSelectionTablePanel(wicketId, enginePanel, dataProvider, 100); } - public ScriptEnginePanel getEnginePanel() { + public ScriptEnginePanel getEnginePanel() + { return enginePanel; } - public ScriptTemplateSelectionTablePanel getSelectionTable() { + public ScriptTemplateSelectionTablePanel getSelectionTable() + { return selectionTable; } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWindow.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWindow.java index 496e228ca4..d7c352999c 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWindow.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWindow.java @@ -28,64 +28,67 @@ * * @author cretzel */ -public abstract class ScriptEngineWindow extends ModalWindow { +public abstract class ScriptEngineWindow extends ModalWindow +{ - private static final long serialVersionUID = 1L; - private final Lang lang; - private ScriptEnginePanel enginePanel; + private static final long serialVersionUID = 1L; + private final Lang lang; + private ScriptEnginePanel enginePanel; - /** - * Constructor. - * - * @param id - * id - * @param lang - * source language - * @param windowTitle - * window title, may be {@code null} for default - */ - public ScriptEngineWindow(final String id, final Lang lang, - final IModel windowTitle) { - super(id); - this.lang = lang; + /** + * Constructor. + * + * @param id + * id + * @param lang + * source language + * @param windowTitle + * window title, may be {@code null} for default + */ + public ScriptEngineWindow(final String id, final Lang lang, final IModel windowTitle) + { + super(id); + this.lang = lang; - setTitle(windowTitle != null ? windowTitle : Model.of("Wicket Console")); - setAutoSize(true); - setResizable(false); + setTitle(windowTitle != null ? windowTitle : Model.of("Wicket Console")); + setAutoSize(true); + setResizable(false); - } + } - @Override - protected void onInitialize() { - super.onInitialize(); + @Override + protected void onInitialize() + { + super.onInitialize(); - enginePanel = newEnginePanel(getContentId(), lang); - setContent(enginePanel); - } + enginePanel = newEnginePanel(getContentId(), lang); + setContent(enginePanel); + } - /** - * Creates a new engine panel, override to customize. - * - * @param wicketId - * id - * @return a script engine panel - */ - protected ScriptEnginePanel newEnginePanel(final String wicketId, - final Lang lang) { + /** + * Creates a new engine panel, override to customize. + * + * @param wicketId + * id + * @return a script engine panel + */ + protected ScriptEnginePanel newEnginePanel(final String wicketId, final Lang lang) + { - final ScriptEnginePanel panel = ScriptEnginePanel.create(wicketId, - lang, Model.of("")); - panel.add(new AttributeAppender("style", Model.of("width:500px"), ";")); + final ScriptEnginePanel panel = ScriptEnginePanel.create(wicketId, lang, Model.of("")); + panel.add(new AttributeAppender("style", Model.of("width:500px"), ";")); - return panel; - } + return panel; + } - public ScriptEnginePanel getEnginePanel() { - return enginePanel; - } + public ScriptEnginePanel getEnginePanel() + { + return enginePanel; + } - public Lang getLang() { - return lang; - } + public Lang getLang() + { + return lang; + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWithTemplatesWindow.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWithTemplatesWindow.java index 1bdb511586..52df817fd1 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWithTemplatesWindow.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/ScriptEngineWithTemplatesWindow.java @@ -29,60 +29,60 @@ * * @author cretzel */ -public abstract class ScriptEngineWithTemplatesWindow extends ModalWindow { +public abstract class ScriptEngineWithTemplatesWindow extends ModalWindow +{ - private static final long serialVersionUID = 1L; - private final Lang lang; - private ScriptEnginePanelWithTemplates enginePanelWithTemplates; - private final IDataProvider dataProvider; + private static final long serialVersionUID = 1L; + private final Lang lang; + private ScriptEnginePanelWithTemplates enginePanelWithTemplates; + private final IDataProvider dataProvider; - /** - * Constructor. - * - * @param id - * id - * @param lang - * source language - * @param windowTitle - * window title, may be {@code null} for default - * @param dataProvider - * data provider for script templates, may be {@code null} for - * default - */ - public ScriptEngineWithTemplatesWindow(final String id, final Lang lang, - final IModel windowTitle, - final IDataProvider dataProvider) { - super(id); - this.lang = lang; - this.dataProvider = dataProvider; + /** + * Constructor. + * + * @param id + * id + * @param lang + * source language + * @param windowTitle + * window title, may be {@code null} for default + * @param dataProvider + * data provider for script templates, may be {@code null} for default + */ + public ScriptEngineWithTemplatesWindow(final String id, final Lang lang, + final IModel windowTitle, final IDataProvider dataProvider) + { + super(id); + this.lang = lang; + this.dataProvider = dataProvider; - setTitle(windowTitle != null ? windowTitle : Model.of("Wicket Console")); - setAutoSize(true); - setResizable(false); + setTitle(windowTitle != null ? windowTitle : Model.of("Wicket Console")); + setAutoSize(true); + setResizable(false); - } + } - @Override - protected void onInitialize() { - super.onInitialize(); + @Override + protected void onInitialize() + { + super.onInitialize(); - enginePanelWithTemplates = newEnginePanelWithTemplates(getContentId(), - lang); - setContent(enginePanelWithTemplates); - } + enginePanelWithTemplates = newEnginePanelWithTemplates(getContentId(), lang); + setContent(enginePanelWithTemplates); + } - /** - * Creates a new engine panel with templates, override to customize. - * - * @param wicketId - * id - * @return a script engine panel - */ - protected ScriptEnginePanelWithTemplates newEnginePanelWithTemplates( - final String wicketId, final Lang lang) { + /** + * Creates a new engine panel with templates, override to customize. + * + * @param wicketId + * id + * @return a script engine panel + */ + protected ScriptEnginePanelWithTemplates newEnginePanelWithTemplates(final String wicketId, + final Lang lang) + { - return new ScriptEnginePanelWithTemplates(wicketId, lang, Model.of(""), - dataProvider); - } + return new ScriptEnginePanelWithTemplates(wicketId, lang, Model.of(""), dataProvider); + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangColumn.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangColumn.java index 8d3dfa8d70..558aafc3a0 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangColumn.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangColumn.java @@ -23,19 +23,21 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; -final class LangColumn extends PropertyColumn { +final class LangColumn extends PropertyColumn +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public LangColumn(final ScriptTemplateSelectionTablePanel tablePanel) { - super(Model.of("Language"), "lang"); - } + public LangColumn(final ScriptTemplateSelectionTablePanel tablePanel) + { + super(Model.of("Language"), "lang"); + } - @Override - public void populateItem(final Item> item, - final String componentId, final IModel rowModel) { - final Label label = new LangLabel(componentId, - createLabelModel(rowModel)); - item.add(label); - } + @Override + public void populateItem(final Item> item, + final String componentId, final IModel rowModel) + { + final Label label = new LangLabel(componentId, createLabelModel(rowModel)); + item.add(label); + } } \ No newline at end of file diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangConverter.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangConverter.java index 2c7d9ef291..ed1bb22ee3 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangConverter.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangConverter.java @@ -22,24 +22,31 @@ import org.apache.wicket.util.string.Strings; import org.wicketstuff.console.engine.Lang; -final class LangConverter extends AbstractConverter { - private static final long serialVersionUID = 1L; +final class LangConverter extends AbstractConverter +{ + private static final long serialVersionUID = 1L; - public Lang convertToObject(final String value, final Locale locale) { - return Lang.valueOf(value); - } + public Lang convertToObject(final String value, final Locale locale) + { + return Lang.valueOf(value); + } - @Override - public String convertToString(final Lang value, final Locale locale) { - if (value == null) { - return null; - } else { - return Strings.capitalize(value.name().toLowerCase()); - } - } + @Override + public String convertToString(final Lang value, final Locale locale) + { + if (value == null) + { + return null; + } + else + { + return Strings.capitalize(value.name().toLowerCase()); + } + } - @Override - protected Class getTargetType() { - return Lang.class; - } + @Override + protected Class getTargetType() + { + return Lang.class; + } } \ No newline at end of file diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangLabel.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangLabel.java index 8ee69faf88..fe6afe9dca 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangLabel.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/LangLabel.java @@ -21,18 +21,21 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.util.convert.IConverter; -final class LangLabel extends Label { +final class LangLabel extends Label +{ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - LangLabel(final String id, final IModel model) { - super(id, model); - } + LangLabel(final String id, final IModel model) + { + super(id, model); + } - @Override - @SuppressWarnings("unchecked") - public IConverter getConverter(final Class type) { - return (IConverter) new LangConverter(); - } + @Override + @SuppressWarnings("unchecked") + public IConverter getConverter(final Class type) + { + return (IConverter)new LangConverter(); + } } \ No newline at end of file diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/ScriptTemplateSelectionTablePanel.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/ScriptTemplateSelectionTablePanel.java index a204601add..d8e291d1cf 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/ScriptTemplateSelectionTablePanel.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/ScriptTemplateSelectionTablePanel.java @@ -33,13 +33,11 @@ /** * A table displaying {@link ScriptTemplate}s. *

- * Script templates can be used to represent frequently used scripts. Typically - * such scripts would be stored in some kind of storage. A data provider on top - * of this storage could then be used to provide these scripts as - * {@link ScriptTemplate}s to this table, which displays them as a list. When a - * script is selected this table copies it over to the attached - * {@link AbstractScriptEnginePanel}'s input field so that the script can be - * executed immediately. + * Script templates can be used to represent frequently used scripts. Typically such scripts would + * be stored in some kind of storage. A data provider on top of this storage could then be used to + * provide these scripts as {@link ScriptTemplate}s to this table, which displays them as a list. + * When a script is selected this table copies it over to the attached + * {@link AbstractScriptEnginePanel}'s input field so that the script can be executed immediately. *

* Example: * @@ -49,7 +47,7 @@ * add(enginePanel); * * ScriptTemplateSelectionTablePanel scriptTable = new ScriptTemplateSelectionTablePanel( - * "templatesTable", enginePanel, dataProvider(), 10); + * "templatesTable", enginePanel, dataProvider(), 10); * add(scriptTable); *

* @@ -62,82 +60,88 @@ * * @author cretzel */ -public class ScriptTemplateSelectionTablePanel extends Panel { - - private static final long serialVersionUID = 1L; - - private static final ResourceReference CSS = new CompressedResourceReference( - ScriptTemplateSelectionTablePanel.class, - ScriptTemplateSelectionTablePanel.class.getSimpleName() + ".css"); - - private final ScriptEnginePanel enginePanel; - - private DataTable table; - - public ScriptTemplateSelectionTablePanel(final String id, - final ScriptEnginePanel enginePanel, - final IDataProvider dataProvider, - final int rowsPerPage) { - super(id); - this.enginePanel = enginePanel; - checkEnginePanelOutputMarkupId(enginePanel); - - init(dataProvider, rowsPerPage); - } - - private void init(final IDataProvider dataProvider, - final int rowsPerPage) { - table = new DataTable("table", createColumns(), - dataProvider, rowsPerPage); - add(table); - } - - protected List> createColumns() { - - final List> columns = new ArrayList>(); - columns.add(new TitleColumn(this)); - columns.add(new LangColumn(this)); - - return columns; - } - - @Override - public void renderHead(final IHeaderResponse response) { - super.renderHead(response); - - final ResourceReference css = getCSS(); - if (css != null) { - response.renderCSSReference(css); - } - - } - - protected ResourceReference getCSS() { - return CSS; - } - - private void checkEnginePanelOutputMarkupId( - final ScriptEnginePanel enginePanel) { - if (enginePanel != null) { - if (!enginePanel.getOutputMarkupId()) { - throw new IllegalStateException( - "Set enginePanel.setOutputMarkupId(true) to use " - + "it with ScriptTemplateSelectionTablePanel"); - } - } - } - - public void onScriptTemplateSelected(final IModel model, - final AjaxRequestTarget target) { - - final ScriptTemplate template = model.getObject(); - final String script = template.script; - - if (enginePanel != null) { - enginePanel.setInput(script); - target.add(enginePanel.getInputTf()); - } - - } +public class ScriptTemplateSelectionTablePanel extends Panel +{ + + private static final long serialVersionUID = 1L; + + private static final ResourceReference CSS = new CompressedResourceReference( + ScriptTemplateSelectionTablePanel.class, + ScriptTemplateSelectionTablePanel.class.getSimpleName() + ".css"); + + private final ScriptEnginePanel enginePanel; + + private DataTable table; + + public ScriptTemplateSelectionTablePanel(final String id, final ScriptEnginePanel enginePanel, + final IDataProvider dataProvider, final int rowsPerPage) + { + super(id); + this.enginePanel = enginePanel; + checkEnginePanelOutputMarkupId(enginePanel); + + init(dataProvider, rowsPerPage); + } + + private void init(final IDataProvider dataProvider, final int rowsPerPage) + { + table = new DataTable("table", createColumns(), dataProvider, rowsPerPage); + add(table); + } + + protected List> createColumns() + { + + final List> columns = new ArrayList>(); + columns.add(new TitleColumn(this)); + columns.add(new LangColumn(this)); + + return columns; + } + + @Override + public void renderHead(final IHeaderResponse response) + { + super.renderHead(response); + + final ResourceReference css = getCSS(); + if (css != null) + { + response.renderCSSReference(css); + } + + } + + protected ResourceReference getCSS() + { + return CSS; + } + + private void checkEnginePanelOutputMarkupId(final ScriptEnginePanel enginePanel) + { + if (enginePanel != null) + { + if (!enginePanel.getOutputMarkupId()) + { + throw new IllegalStateException("Set enginePanel.setOutputMarkupId(true) to use " + + "it with ScriptTemplateSelectionTablePanel"); + } + } + } + + public void onScriptTemplateSelected(final IModel model, + final AjaxRequestTarget target) + { + + final ScriptTemplate template = model.getObject(); + final String script = template.script; + + if (enginePanel != null) + { + enginePanel.setInput(script); + target.add(enginePanel.getInputTf()); + } + + } } diff --git a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/TitleColumn.java b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/TitleColumn.java index 69bb0c70f6..db12d1f41a 100644 --- a/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/TitleColumn.java +++ b/jdk-1.5-parent/console-parent/console/src/main/java/org/wicketstuff/console/templates/TitleColumn.java @@ -26,19 +26,22 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model; -final class TitleColumn extends PropertyColumn { +final class TitleColumn extends PropertyColumn +{ - private final class TitleLink extends AjaxLink { - private static final long serialVersionUID = 1L; + private final class TitleLink extends AjaxLink + { + private static final long serialVersionUID = 1L; - private TitleLink(final String id, final IModel model) { + private TitleLink(final String id, final IModel model) + { super(id, model); } @Override - public void onClick(final AjaxRequestTarget target) { - TitleColumn.this.tablePanel.onScriptTemplateSelected(getModel(), - target); + public void onClick(final AjaxRequestTarget target) + { + tablePanel.onScriptTemplateSelected(getModel(), target); } } @@ -46,21 +49,21 @@ public void onClick(final AjaxRequestTarget target) { private final ScriptTemplateSelectionTablePanel tablePanel; - TitleColumn( - final ScriptTemplateSelectionTablePanel scriptTemplateSelectionTablePanel) { + TitleColumn(final ScriptTemplateSelectionTablePanel scriptTemplateSelectionTablePanel) + { super(Model.of("Title"), "title"); tablePanel = scriptTemplateSelectionTablePanel; } @Override public void populateItem(final Item> item, - final String componentId, final IModel rowModel) { + final String componentId, final IModel rowModel) + { final AjaxLink link = new TitleLink("link", rowModel); link.add(new Label("label", createLabelModel(rowModel))); - final Fragment fragment = new Fragment(componentId, "titleFragment", - tablePanel); + final Fragment fragment = new Fragment(componentId, "titleFragment", tablePanel); fragment.add(link); item.add(fragment); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AbstractTrieConfiguration.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AbstractTrieConfiguration.java index f44b41a05a..f094efe04d 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AbstractTrieConfiguration.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AbstractTrieConfiguration.java @@ -19,10 +19,11 @@ /** * @author mocleiri * - * Provides a base configuration for a Trie. - * + * Provides a base configuration for a Trie. + * */ -public abstract class AbstractTrieConfiguration implements ITrieConfiguration { +public abstract class AbstractTrieConfiguration implements ITrieConfiguration +{ /** * @@ -32,8 +33,9 @@ public abstract class AbstractTrieConfiguration implements ITrieConfiguration /** * */ - public AbstractTrieConfiguration() { - + public AbstractTrieConfiguration() + { + defaultFilter = newTrieFilter(); } @@ -41,52 +43,61 @@ public AbstractTrieConfiguration() { * * @return the trie filter that will be used by default by the Trie. */ - protected ITrieFilter newTrieFilter() { - return new ITrieFilter() { + protected ITrieFilter newTrieFilter() + { + return new ITrieFilter() + { - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.TrieFilter#isVisible(java.lang.Object) + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.TrieFilter#isVisible(java.lang.Object) */ - public boolean isVisible(C word) { + public boolean isVisible(C word) + { return true; } - + }; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#createTrieNode() */ - public TrieNode createTrieNode(TrieNode parent, String rootMatchedString, String nextCharacter) { - return new TrieNode(parent, rootMatchedString, nextCharacter, - this); + public TrieNode createTrieNode(TrieNode parent, String rootMatchedString, + String nextCharacter) + { + return new TrieNode(parent, rootMatchedString, nextCharacter, this); } - private final ITrieFilterdefaultFilter; + private final ITrieFilter defaultFilter; private Trie containerTrie; - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getDefaultFilter() */ - public ITrieFilter getDefaultFilter() { - + public ITrieFilter getDefaultFilter() + { + return defaultFilter; } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#setTrie(org.wicketstuff.datatable_autocomplete.trie.Trie) + /* + * (non-Javadoc) + * + * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#setTrie(org.wicketstuff. + * datatable_autocomplete.trie.Trie) */ - public void setTrie(Trie containerTrie) { + public void setTrie(Trie containerTrie) + { this.containerTrie = containerTrie; - + } - - - - - - - } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AnyWhereTrieMatch.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AnyWhereTrieMatch.java index c62552f22d..248af82b8d 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AnyWhereTrieMatch.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/AnyWhereTrieMatch.java @@ -24,10 +24,11 @@ /** * @author mocleiri * - * A match corresponding to an anywhere in the string search. - * + * A match corresponding to an anywhere in the string search. + * */ -public class AnyWhereTrieMatch extends TrieMatch { +public class AnyWhereTrieMatch extends TrieMatch +{ /** * @@ -38,7 +39,9 @@ public class AnyWhereTrieMatch extends TrieMatch { /** * @param matchingNodeList */ - public AnyWhereTrieMatch(String matched, ITrieFilternodeFilter, Set> matchingNodeList) { + public AnyWhereTrieMatch(String matched, ITrieFilter nodeFilter, + Set> matchingNodeList) + { super(matched, Type.ANY_MATCH, nodeFilter); this.nodeSet = matchingNodeList; } @@ -46,42 +49,46 @@ public AnyWhereTrieMatch(String matched, ITrieFilternodeFilter, Set> getNodeSet() { + public Set> getNodeSet() + { return nodeSet; } - public void visit(ITrieNodeVisitorvisitor) { - - for (TrieNode node : nodeSet) { - + public void visit(ITrieNodeVisitor visitor) + { + + for (TrieNode node : nodeSet) + { + visitor.visit(node); - + } - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.TrieMatch#getWordList() */ @Override - public List getWordList(final int limit) { - + public List getWordList(final int limit) + { + final List dataList = new LinkedList(); - - for (TrieNode node : nodeSet) { - - node.buildWordList(dataList, super.nodeFilter, limit); - + + for (TrieNode node : nodeSet) + { + + node.buildWordList(dataList, super.nodeFilter, limit); + if (dataList.size() == limit) break; } - + return dataList; - + } - - - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieConfiguration.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieConfiguration.java index bbb99ef06b..dd0eefce01 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieConfiguration.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieConfiguration.java @@ -21,27 +21,28 @@ /** * @author mocleiri * - * Provides the logic to create the string that is indexed from the actual object context. + * Provides the logic to create the string that is indexed from the actual object context. + * + * Can hint as to the * - * Can hint as to the - * */ -public interface ITrieConfiguration extends IClusterable { - +public interface ITrieConfiguration extends IClusterable +{ + /** * Extract the word from the context given. * * @param ctx * @return the extracted word. */ - public String getWord (C ctx); - + public String getWord(C ctx); + /** * Provides the default filter to be used when searching for a match. * */ public ITrieFilter getDefaultFilter(); - + /** * * If true then capitalized and lower case will be sorted separately. @@ -52,23 +53,25 @@ public interface ITrieConfiguration extends IClusterable { * */ public boolean isIndexCaseSensitive(); - + public TrieNode createTrieNode(TrieNode parent, String rootMatchedString, - String nextCharacter); - + String nextCharacter); + /** * A callback to let the instantiated trie to register with us. + * * @param containerTrie */ - public void setTrie (Trie containerTrie); - - + public void setTrie(Trie containerTrie); + + /** * - * @return true if the trie contains a suffix tree (used when the trie is built to make sure we build it right). + * @return true if the trie contains a suffix tree (used when the trie is built to make sure we + * build it right). * */ public boolean isSuffixTree(); - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieFilter.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieFilter.java index 3dd6c62556..f471c0c605 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieFilter.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieFilter.java @@ -18,17 +18,17 @@ import org.apache.wicket.IClusterable; - /** * @author mocleiri - * + * */ -public interface ITrieFilter extends IClusterable { - /** - * - * @param word - * @return true if the indexed word should be visible. - * - */ - public boolean isVisible (C word); +public interface ITrieFilter extends IClusterable +{ + /** + * + * @param word + * @return true if the indexed word should be visible. + * + */ + public boolean isVisible(C word); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieNodeVisitor.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieNodeVisitor.java index 05aa84fd87..07263d7e04 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieNodeVisitor.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/ITrieNodeVisitor.java @@ -20,13 +20,14 @@ /** * @author mocleiri * - * Provides a way to visit each TrieNode in a Trie. Typically used to visit a specific subtree of and expand - * out the ordered list of words. + * Provides a way to visit each TrieNode in a Trie. Typically used to visit a specific + * subtree of and expand out the ordered list of words. * */ -public interface ITrieNodeVisitor { - - public void visit (TrieNode node); +public interface ITrieNodeVisitor +{ + + public void visit(TrieNode node); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PatriciaTrie.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PatriciaTrie.java index 1daa3bbb8e..6d71d7f56a 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PatriciaTrie.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PatriciaTrie.java @@ -27,31 +27,30 @@ /** * @author mocleiri * - * A Trie is a specialized search tree that is optimized for - * retrieval of data. + * A Trie is a specialized search tree that is optimized for retrieval of data. * - * This implementation is read-only and expects to load the data then - * minimize itself and be part of a singleton that returns the indexed - * data. + * This implementation is read-only and expects to load the data then minimize itself and be + * part of a singleton that returns the indexed data. * * A Patricia Trie is used to index words from left to right. - * - * A Suffix Tree, which is useful for any string matching, can be build on top of a Patricia Trie simply using a variant indexing method. * - * An ITrieFilter can be used to filter additional fields within an - * indexed object when the list of matching words (objects) is being - * computed. + * A Suffix Tree, which is useful for any string matching, can be build on top of a Patricia + * Trie simply using a variant indexing method. + * + * An ITrieFilter can be used to filter additional fields within an indexed object when + * the list of matching words (objects) is being computed. * * @see Radix tree * - * It is suited for quick retrieval of prefix matches over large static - * datasets (100,000 elements) + * It is suited for quick retrieval of prefix matches over large static datasets (100,000 + * elements) * - * This implementation will index an object C based on the word (String) - * that is extracted using the ITrieNodeConfiguration.getWord (C c) method. + * This implementation will index an object C based on the word (String) that is extracted + * using the ITrieNodeConfiguration.getWord (C c) method. * */ -public class PatriciaTrie implements IClusterable, Trie { +public class PatriciaTrie implements IClusterable, Trie +{ /** * @@ -63,70 +62,82 @@ public class PatriciaTrie implements IClusterable, Trie { private TrieNode root = null; private ITrieConfiguration configuration = null; - + /** * */ - public PatriciaTrie() { + public PatriciaTrie() + { super(); } - + /** * */ - public PatriciaTrie(ITrieConfiguration configuration) { + public PatriciaTrie(ITrieConfiguration configuration) + { this.configuration = configuration; this.configuration.setTrie(this); - + this.root = configuration.createTrieNode(null, "", ""); - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.Trie#index(C) */ - public void index(C value) { + public void index(C value) + { // traverse to the point where no match is found and then insert at that // point. - if (configuration.isSuffixTree()) { + if (configuration.isSuffixTree()) + { // suffix tree // for anystring match - + String word = configuration.getWord(value); - + int length = word.length(); - - for (int i = 0; i < length; i++) { - - // index each substring of the word from the initial full word through to the last character. + + for (int i = 0; i < length; i++) + { + + // index each substring of the word from the initial full word through to the last +// character. String subWord = word.substring(i); - + this.root.index(subWord, value); - - + + } } - else { + else + { // prefix tree // for prefix match this.root.index(value); - + } - + } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.Trie#getWordList(java.lang.String) */ - public List getWordList(String prefix) { + public List getWordList(String prefix) + { return getWordList(prefix, configuration.getDefaultFilter(), -1); @@ -137,12 +148,14 @@ public List getWordList(String prefix) { // return getWordList(prefixNode, configuration.getDefaultFilter(), -1); // } - public PrefixTrieMatch find(String prefix, ITrieFilterfilter) { + public PrefixTrieMatch find(String prefix, ITrieFilter filter) + { return this.root.find(prefix, filter); } - public List getWordList(String prefix, ITrieFilter filter, int limit) { + public List getWordList(String prefix, ITrieFilter filter, int limit) + { PrefixTrieMatch prefixNodeMatch = this.root.find(prefix, filter); @@ -152,7 +165,6 @@ public List getWordList(String prefix, ITrieFilter filter, int limit) { return prefixNodeMatch.getWordList(limit); } - /** * Visit each TrieNode @@ -160,16 +172,18 @@ public List getWordList(String prefix, ITrieFilter filter, int limit) { * @param v */ - public void visit(ITrieNodeVisitor v) { + public void visit(ITrieNodeVisitor v) + { this.root.visit(v); } /** - * Compresses the sparse nodes with only 1 branch; makes the Trie into a - * Patricia Trie which uses less space. + * Compresses the sparse nodes with only 1 branch; makes the Trie into a Patricia Trie which + * uses less space. */ - public void simplifyIndex() { + public void simplifyIndex() + { // the first simplification is to remove nodes that have only 1 branch. // we will basically have nodes that represent more than a single @@ -177,20 +191,23 @@ public void simplifyIndex() { this.root.simplify(); /* - * We visit each leaf then iterate over upward to mark the max length of - * each nodes sub tree. + * We visit each leaf then iterate over upward to mark the max length of each nodes sub + * tree. */ final List> leafNodeList = new LinkedList>(); - this.root.visit(new ITrieNodeVisitor() { + this.root.visit(new ITrieNodeVisitor() + { - public void visit(TrieNode element) { + public void visit(TrieNode element) + { if (element.getOrderedNodeList().size() == 0) leafNodeList.add(element); - for (TrieNode trieNode : element.getOrderedNodeList()) { + for (TrieNode trieNode : element.getOrderedNodeList()) + { trieNode.visit(this); } @@ -198,23 +215,25 @@ public void visit(TrieNode element) { } }); - for (TrieNode trieNode : leafNodeList) { + for (TrieNode trieNode : leafNodeList) + { TrieNode parentNode = trieNode.getParentNode(); TrieNode currentNode = trieNode; - while (parentNode != null) { + while (parentNode != null) + { // start at the bottom and work upwards int currentLength = currentNode.getCharacter().length(); - int currentMax = currentNode.getMaxChildStringLength() - + currentLength; + int currentMax = currentNode.getMaxChildStringLength() + currentLength; int maxParentLength = parentNode.getMaxChildStringLength(); - if (currentMax > maxParentLength) { + if (currentMax > maxParentLength) + { parentNode.setMaxChildStringLength(currentMax); } @@ -228,28 +247,26 @@ public void visit(TrieNode element) { } - - - /** * @return children of the root node. */ - public int getChildren() { + public int getChildren() + { return root.getOrderedNodeList().size(); } /** - * Return the size of the subtree for the prefix given. This avoids the need - * to get the list especially when the count is large. + * Return the size of the subtree for the prefix given. This avoids the need to get the list + * especially when the count is large. * * @param prefix - * @return the number of elements in the subtree corresponding to the prefix - * given. + * @return the number of elements in the subtree corresponding to the prefix given. * */ - public int getPrefixMatchedElementCount(String prefix, final ITrieFilternodeFilter) { + public int getPrefixMatchedElementCount(String prefix, final ITrieFilter nodeFilter) + { PrefixTrieMatch match = root.find(prefix, nodeFilter); @@ -258,16 +275,20 @@ public int getPrefixMatchedElementCount(String prefix, final ITrieFilternodeF final AtomicInteger counter = new AtomicInteger(0); - match.getNode().visit(new ITrieNodeVisitor() { + match.getNode().visit(new ITrieNodeVisitor() + { - public void visit(TrieNode node) { - - for (C value : node.getOrderedMatchList()) { - if (nodeFilter.isVisible(value)) { - counter.addAndGet(node.getTotalMatches()); + public void visit(TrieNode node) + { + + for (C value : node.getOrderedMatchList()) + { + if (nodeFilter.isVisible(value)) + { + counter.addAndGet(node.getTotalMatches()); } - } - + } + } }); @@ -279,19 +300,21 @@ public void visit(TrieNode node) { * * @return the total number of elements indexed by this trie. * - * Note this can be an expensive call as each node in the trie is - * visited. + * Note this can be an expensive call as each node in the trie is visited. * */ - public int size() { + public int size() + { final AtomicInteger counter = new AtomicInteger(0); // visit each node an aggregate the number of matches: - root.visit(new ITrieNodeVisitor() { + root.visit(new ITrieNodeVisitor() + { - public void visit(TrieNode node) { + public void visit(TrieNode node) + { counter.addAndGet(node.getTotalMatches()); } @@ -304,51 +327,61 @@ public void visit(TrieNode node) { * @return the set of strings that map to the next nodes of the root node. * @see org.wicketstuff.datatable_autocomplete.trie.TrieNode#getNextNodeCharacterSet() */ - public Set getNextNodeCharacterSet() { + public Set getNextNodeCharacterSet() + { /* - * This is really just to support the datatable-autocomplete-examples - * where we give a count of the matches for each first character - * contained in this set. + * This is really just to support the datatable-autocomplete-examples where we give a count + * of the matches for each first character contained in this set. */ return root.getNextNodeCharacterSet(); } - public List getWordList(String prefix, ITrieFilter filter) { + public List getWordList(String prefix, ITrieFilter filter) + { return getWordList(prefix, filter, -1); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.Trie#getWordList(java.lang.String, int) */ - public List getWordList(String prefix, int limit) { + public List getWordList(String prefix, int limit) + { return getWordList(prefix, null, limit); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.Trie#postIndexing() */ - public void postIndexing() { - + public void postIndexing() + { + this.simplifyIndex(); - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.Trie#preIndexing() */ - public void preIndexing() { - + public void preIndexing() + { + } - public TrieNode getRoot() { + public TrieNode getRoot() + { return root; } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PrefixTrieMatch.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PrefixTrieMatch.java index 3aa0d55533..f0add1a1c1 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PrefixTrieMatch.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/PrefixTrieMatch.java @@ -23,10 +23,11 @@ /** * @author mocleiri * - * A trie match using the prefix search. - * + * A trie match using the prefix search. + * */ -public class PrefixTrieMatch extends TrieMatch { +public class PrefixTrieMatch extends TrieMatch +{ /** * @@ -34,37 +35,43 @@ public class PrefixTrieMatch extends TrieMatch { private static final long serialVersionUID = 1L; // the node that the prefix was matched to private TrieNode node; - + /** * @param node */ - public PrefixTrieMatch(String matched, ITrieFilternodeFilter, TrieNode node) { + public PrefixTrieMatch(String matched, ITrieFilter nodeFilter, TrieNode node) + { super(matched, Type.PREFIX_MATCH, nodeFilter); this.node = node; } - + /** * @return the node */ - public TrieNode getNode() { - + public TrieNode getNode() + { + return this.node; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.TrieMatch#getWordList(int) */ @Override - public List getWordList(int limit) { - - List wordList = new LinkedList();; - + public List getWordList(int limit) + { + + List wordList = new LinkedList(); + ; + this.node.buildWordList(wordList, nodeFilter, limit); - + return wordList; } - - + + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/Trie.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/Trie.java index 7a253d25bd..638e07f58b 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/Trie.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/Trie.java @@ -7,10 +7,12 @@ /** * * @author mocleiri - * - * With the introduction of the TernarySearchTrie this interface was extracted to provide a common base between them. + * + * With the introduction of the TernarySearchTrie this interface was extracted to provide a + * common base between them. */ -public interface Trie extends IClusterable { +public interface Trie extends IClusterable +{ /** * @param value @@ -26,10 +28,10 @@ public interface Trie extends IClusterable { * @return reachable list of strings. */ public abstract List getWordList(String prefix); - - public abstract ListgetWordList (String prefix, ITrieFilterfilter); - - public abstract ListgetWordList (String prefix, ITrieFilterfilter, int limit); + + public abstract List getWordList(String prefix, ITrieFilter filter); + + public abstract List getWordList(String prefix, ITrieFilter filter, int limit); public abstract List getWordList(String prefix, int limit); @@ -42,6 +44,6 @@ public interface Trie extends IClusterable { * Invoked after the index process has completed. */ public abstract void postIndexing(); - + } \ No newline at end of file diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieMatch.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieMatch.java index 8e4a89b93e..cfac64e0f7 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieMatch.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieMatch.java @@ -19,34 +19,37 @@ import java.util.List; - /** * @author mocleiri * - * Represents a match of a string into a Trie - * + * Represents a match of a string into a Trie + * */ -public abstract class TrieMatch implements Serializable { +public abstract class TrieMatch implements Serializable +{ + + private static final long serialVersionUID = -6521672186761294453L; - private static final long serialVersionUID = -6521672186761294453L; + public static enum Type + { + PREFIX_MATCH, ANY_MATCH + }; - public static enum Type { PREFIX_MATCH, ANY_MATCH }; - private Type type; private final String matched; - + protected ITrieFilter nodeFilter; - - - public abstract ListgetWordList(int limit); - - + + + public abstract List getWordList(int limit); + /** * @param matched * @param type */ - public TrieMatch(String matched, Type type, ITrieFilterfilter) { + public TrieMatch(String matched, Type type, ITrieFilter filter) + { super(); this.matched = matched; @@ -55,25 +58,4 @@ public TrieMatch(String matched, Type type, ITrieFilterfilter) { } - - - - - - - - - - - - - - - - - - - - - } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNode.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNode.java index 52d99e2622..3f282c8951 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNode.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNode.java @@ -37,18 +37,18 @@ * * Contains the character(s) that are contained in this node. * - * A map of next character(s) to TrieNode's and the count of the - * number of words in the subtree beneath this node. + * A map of next character(s) to TrieNode's and the count of the number of words in the + * subtree beneath this node. * * The C context object that is indexed by this node. * - * The configuration object that provides the string version of an C - * object. + * The configuration object that provides the string version of an C object. * * * */ -public class TrieNode implements Serializable { +public class TrieNode implements Serializable +{ /** * @@ -57,9 +57,11 @@ public class TrieNode implements Serializable { private static final Logger log = LoggerFactory.getLogger(TrieNode.class); - private static final Comparator> trieNodeComparator = new Comparator>() { + private static final Comparator> trieNodeComparator = new Comparator>() + { - public int compare(TrieNode o1, TrieNode o2) { + public int compare(TrieNode o1, TrieNode o2) + { return o1.getCharacter().compareTo(o2.getCharacter()); @@ -89,7 +91,7 @@ public int compare(TrieNode o1, TrieNode o2) { // i.e. index 0 matches the character.get(0) and index 1 matches the element // that matches to character.get(0) + character.get(1) private Map> matchMap = new LinkedHashMap>(); - + // if the entire tree below this node was traversed this would be the length // of the longest string formed. // this is used when doing a 'superselect' match to know when a branch is @@ -106,8 +108,9 @@ public int compare(TrieNode o1, TrieNode o2) { * @param character * @param configuration */ - public TrieNode(TrieNode parentNode, String rootMatchedString, - String character, ITrieConfiguration configuration) { + public TrieNode(TrieNode parentNode, String rootMatchedString, String character, + ITrieConfiguration configuration) + { super(); @@ -122,7 +125,8 @@ public TrieNode(TrieNode parentNode, String rootMatchedString, /** * @return the maxChildStringLength */ - public int getMaxChildStringLength() { + public int getMaxChildStringLength() + { return this.maxChildStringLength; } @@ -131,19 +135,22 @@ public int getMaxChildStringLength() { * @param maxChildStringLength * the maxChildStringLength to set */ - public void setMaxChildStringLength(int maxChildStringLength) { + public void setMaxChildStringLength(int maxChildStringLength) + { this.maxChildStringLength = maxChildStringLength; } @Override - public String toString() { + public String toString() + { StringBuffer children = new StringBuffer(); List nodeList = new ArrayList(this.nodeMap.keySet()); - for (int i = 0; i < nodeList.size() - 1; i++) { + for (int i = 0; i < nodeList.size() - 1; i++) + { String node = nodeList.get(i); children.append(node); @@ -154,15 +161,15 @@ public String toString() { if (nodeList.size() > 0) children.append(nodeList.get(nodeList.size() - 1)); - return "NODE [ matchedPrefix = '" + rootMatchedString - + "', character ='" + getCharacter() + "', word = '" - + getWord() + "', children = (" + children.toString() + ") ]"; + return "NODE [ matchedPrefix = '" + rootMatchedString + "', character ='" + getCharacter() + + "', word = '" + getWord() + "', children = (" + children.toString() + ") ]"; } /** * @return the character */ - public String getCharacter() { + public String getCharacter() + { return this.character; } @@ -170,19 +177,19 @@ public String getCharacter() { /** * Add the word into the Trie index. * - * Recurses down the tree until all of the characters in word have been - * placed. + * Recurses down the tree until all of the characters in word have been placed. * * @param object * @return the node that the word was finally attached to */ - public TrieNode index(C object) { + public TrieNode index(C object) + { String word = configuration.getWord(object); - + return index(word, object); } - + /** * * @param word @@ -190,15 +197,17 @@ public TrieNode index(C object) { * * @return the node that the word was finally attached to */ - public TrieNode index (String word, C object) { - + public TrieNode index(String word, C object) + { + if (!configuration.isIndexCaseSensitive()) word = word.toLowerCase(); - + return index(word, object, 0); } - public List> getOrderedNodeList() { + public List> getOrderedNodeList() + { return this.orderedNodeList; @@ -209,26 +218,26 @@ public List> getOrderedNodeList() { * @param i * @return */ - private TrieNode index(String word, C context, int startingIndex) { + private TrieNode index(String word, C context, int startingIndex) + { + - - - - if (word.length() == startingIndex) { + if (word.length() == startingIndex) + { /* * This is the node that matches the word. * * First: make sure that this is the first match on this node. * - * Second: insert the object into the first slot in the matchMap. - * Note: the index is always zero because we build an uncompressed - * Trie first. + * Second: insert the object into the first slot in the matchMap. Note: the index is + * always zero because we build an uncompressed Trie first. */ List matchList = this.matchMap.get(0); - if (matchList == null) { + if (matchList == null) + { matchList = new ArrayList(); this.matchMap.put(0, matchList); } @@ -237,16 +246,18 @@ private TrieNode index(String word, C context, int startingIndex) { matchList.add(context); return this; - } else { + } + else + { // use the character at the starting index to get the next node - String nextCharacter = word.substring(startingIndex, - startingIndex + 1); + String nextCharacter = word.substring(startingIndex, startingIndex + 1); TrieNode nextNode = nodeMap.get(nextCharacter); - if (nextNode == null) { + if (nextNode == null) + { String matchedSubString = word.substring(0, startingIndex); @@ -266,36 +277,37 @@ private TrieNode index(String word, C context, int startingIndex) { * @param nextCharacter * @return */ - protected TrieNode newNode(TrieNode parent, String rootMatchedString, - String nextCharacter) { + protected TrieNode newNode(TrieNode parent, String rootMatchedString, String nextCharacter) + { return this.configuration.createTrieNode(parent, rootMatchedString, nextCharacter); } - /** * - * In the normal case there is a single path through the tree and we - * identify the node that matches the prefix. + * In the normal case there is a single path through the tree and we identify the node that + * matches the prefix. * - * In the any case there will be many nodes since there are multiple paths - * to a match. + * In the any case there will be many nodes since there are multiple paths to a match. * * @param matchingNodeList * @param substring */ - private void findMatchingNodes(Set> matchingNodeList, ITrieFilternodeFilter, - String substring) { + private void findMatchingNodes(Set> matchingNodeList, ITrieFilter nodeFilter, + String substring) + { PrefixTrieMatch match = find(substring, nodeFilter); - if (match != null) { + if (match != null) + { TrieNode node = match.getNode(); - + matchingNodeList.add(node); // guaranteed to match the subtree so just exit at this point. - // this will prevent matching the same words multiple times where the substring is small. + // this will prevent matching the same words multiple times where the substring is +// small. return; } @@ -303,11 +315,12 @@ private void findMatchingNodes(Set> matchingNodeList, ITrieFilter return; // not enough length in the subtree to match the string so // no need to look. - for (TrieNode trieNode : this.orderedNodeList) { + for (TrieNode trieNode : this.orderedNodeList) + { trieNode.findMatchingNodes(matchingNodeList, nodeFilter, substring); // match = trieNode.find(substring); - // + // // if (match != null) // matchingNodeList.add (match.getNode()); @@ -315,16 +328,17 @@ private void findMatchingNodes(Set> matchingNodeList, ITrieFilter } - + /* * Recursively finds the Node that corresponds to the prefix specificed. */ - public PrefixTrieMatch find(String key, ITrieFilternodeFilter) { + public PrefixTrieMatch find(String key, ITrieFilter nodeFilter) + { if (!configuration.isIndexCaseSensitive()) key = key.toLowerCase(); - + /* * Check the current character against the */ @@ -333,21 +347,28 @@ public PrefixTrieMatch find(String key, ITrieFilternodeFilter) { int characterLength = getCharacter().length(); - if (keyLength == characterLength) { + if (keyLength == characterLength) + { - if (getCharacter().equals(key)) { + if (getCharacter().equals(key)) + { // match return new PrefixTrieMatch(getWord(), nodeFilter, this); - } else { + } + else + { // no match return null; } - } else if (keyLength > characterLength) { + } + else if (keyLength > characterLength) + { // compare the 'characterLength' substring of key String subKey = key.substring(0, characterLength); - if (subKey.equals(getCharacter())) { + if (subKey.equals(getCharacter())) + { // matches this node but we still need to compare against the // child nodes. @@ -364,28 +385,32 @@ public PrefixTrieMatch find(String key, ITrieFilternodeFilter) { return nextNode.find(newKey, nodeFilter); - } else { + } + else + { return null; } - } else { + } + else + { // keyLength < characterLength - if (keyLength > 0 && characterLength > 1 - && getCharacter().contains(key)) { + if (keyLength > 0 && characterLength > 1 && getCharacter().contains(key)) + { return new PrefixTrieMatch(getWord(), nodeFilter, this); } return null; } - } /** * @return the parentNode */ - public TrieNode getParentNode() { + public TrieNode getParentNode() + { return this.parentNode; } @@ -393,70 +418,75 @@ public TrieNode getParentNode() { /** * @return the totalMatches */ - public int getTotalMatches() { + public int getTotalMatches() + { return this.totalMatches; } /** - * Traverses up the tree to the root to generate the word that this node - * represents. + * Traverses up the tree to the root to generate the word that this node represents. * * @return generated word */ - public String getWord() { + public String getWord() + { return this.rootMatchedString + this.character; - -// StringBuffer buf = new StringBuffer(); + +// StringBuffer buf = new StringBuffer(); +// +// TrieNode currentNode = this; // -// TrieNode currentNode = this; +// while (currentNode != null) { +// buf.insert(0, currentNode.getCharacter()); // -// while (currentNode != null) { -// buf.insert(0, currentNode.getCharacter()); +// currentNode = currentNode.getParentNode(); +// } // -// currentNode = currentNode.getParentNode(); -// } -// -// if (buf.toString().equals(this.rootMatchedString + this.character)) { -// log.info("can remove the looping back to parent."); -// } -// return buf.toString(); +// if (buf.toString().equals(this.rootMatchedString + this.character)) { +// log.info("can remove the looping back to parent."); +// } +// return buf.toString(); } /** * @param wordList * @param filter - * @param limit -1 if no limit or the value at which point the list should stop being filled in. + * @param limit + * -1 if no limit or the value at which point the list should stop being filled in. */ - public void buildWordList(List wordList, ITrieFilter filter, int limit) { + public void buildWordList(List wordList, ITrieFilter filter, int limit) + { -// if (this.orderedNodeList.size() == 0 -// && (filter == null || filter.isVisible(this))) { -// // can be null in certain cases where the match is to an empty Trie. -// addExistingContextToList(wordList, filter); +// if (this.orderedNodeList.size() == 0 +// && (filter == null || filter.isVisible(this))) { +// // can be null in certain cases where the match is to an empty Trie. +// addExistingContextToList(wordList, filter); // -// } else { +// } else { + + log.debug(orderedNodeList.toString()); - log.debug(orderedNodeList.toString()); + addExistingContextToList(wordList, filter, limit); + + if (wordList.size() == limit) + return; + + for (TrieNode node : orderedNodeList) + { + node.buildWordList(wordList, filter, limit); - addExistingContextToList(wordList, filter, limit); - if (wordList.size() == limit) return; - for (TrieNode node : orderedNodeList) { - node.buildWordList(wordList, filter, limit); - - if (wordList.size() == limit) - return; - - } -// } + } +// } } - private void addExistingContextToList(List wordList, ITrieFilter filter, int limit) { + private void addExistingContextToList(List wordList, ITrieFilter filter, int limit) + { List keyList = new LinkedList(); @@ -467,25 +497,28 @@ private void addExistingContextToList(List wordList, ITrieFilter filter, i */ Collections.sort(keyList); - for (Integer i : keyList) { + for (Integer i : keyList) + { List contextList = this.matchMap.get(i); - + // check with the filter to only include those with the proper - - for (C c : contextList) { - - if (filter.isVisible(c)) { + + for (C c : contextList) + { + + if (filter.isVisible(c)) + { wordList.add(c); - + if (wordList.size() == limit) return; } - - + + } - + } } @@ -494,33 +527,36 @@ private void addExistingContextToList(List wordList, ITrieFilter filter, i * * @param v */ - public void visit(ITrieNodeVisitor v) { + public void visit(ITrieNodeVisitor v) + { v.visit(this); - for (TrieNode child : this.orderedNodeList) { + for (TrieNode child : this.orderedNodeList) + { child.visit(v); } } - /** * Called once all the keys have been added into the Trie. * - * This will compact the nodes so that there will be no single child nodes - * which will help to reduce the memory usage. + * This will compact the nodes so that there will be no single child nodes which will help to + * reduce the memory usage. * * */ - public void simplify() { + public void simplify() + { Collections.sort(orderedNodeList, trieNodeComparator); /* * simplify our children first. */ - while (this.orderedNodeList.size() == 1) { + while (this.orderedNodeList.size() == 1) + { // consolidate with the subnode // remove the sub node and set us as the parent to their // children. @@ -530,7 +566,8 @@ public void simplify() { String childCharacter = onlyChild.getCharacter(); - for (int i = 0; i < childCharacter.length(); i++) { + for (int i = 0; i < childCharacter.length(); i++) + { String c = childCharacter.substring(i, i + 1); @@ -539,17 +576,19 @@ public void simplify() { List childContext = onlyChild.matchMap.get(i); - if (childContext != null && childContext.size() > 0) { + if (childContext != null && childContext.size() > 0) + { int matchIndex = this.character.length() + i; - ListourContext = this.matchMap.get(i); - - if (ourContext == null) { + List ourContext = this.matchMap.get(i); + + if (ourContext == null) + { // insert the child context as our own. - this.matchMap - .put(Integer.valueOf(matchIndex), childContext); + this.matchMap.put(Integer.valueOf(matchIndex), childContext); } - else { + else + { // append the child context to our own ourContext.addAll(childContext); } @@ -562,7 +601,8 @@ public void simplify() { this.totalMatches += onlyChild.totalMatches; - for (TrieNode n : orderedNodeList) { + for (TrieNode n : orderedNodeList) + { // adjust the parent reference n.parentNode = this; @@ -574,7 +614,8 @@ public void simplify() { * then simplify our children */ - for (TrieNode n : orderedNodeList) { + for (TrieNode n : orderedNodeList) + { n.simplify(); @@ -587,46 +628,51 @@ public void simplify() { * @return the set of strings that map to the next nodes. * */ - public Set getNextNodeCharacterSet() { + public Set getNextNodeCharacterSet() + { return this.nodeMap.keySet(); } - public void setNodeID(Long nodeID) { + public void setNodeID(Long nodeID) + { this.nodeID = nodeID; // TODO Auto-generated method stub - + } /** * @return the nodeID */ - public Long getNodeID() { + public Long getNodeID() + { return nodeID; } - + /** * * @return the ordered list of matches for this node */ - public ListgetOrderedMatchList() { - - ListmatchList = new LinkedList(); - - ListkeyList = new ArrayList(); - + public List getOrderedMatchList() + { + + List matchList = new LinkedList(); + + List keyList = new ArrayList(); + keyList.addAll(matchMap.keySet()); - + Collections.sort(keyList); - - for (Integer key : keyList) { - + + for (Integer key : keyList) + { + matchList.addAll(matchMap.get(key)); - + } - + return matchList; - + } - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNodeInspectingVisitor.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNodeInspectingVisitor.java index 3e31bc8675..69a55f6808 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNodeInspectingVisitor.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieNodeInspectingVisitor.java @@ -19,57 +19,57 @@ import org.slf4j.LoggerFactory; - /** * @author mocleiri * - * Used as part of the minimization procedure when compacting the Trie. - * + * Used as part of the minimization procedure when compacting the Trie. + * */ -public class TrieNodeInspectingVisitor implements ITrieNodeVisitor { - - private static final Logger log = LoggerFactory - .getLogger(TrieNodeInspectingVisitor.class); - - - - int totalConsolidateable = 0; - - int totalNodes = 0; - - public void visit(TrieNode element) { - - this.totalNodes++; - - if (element.getOrderedNodeList().size() == 1) - this.totalConsolidateable++; - - } - - /** - * @return the totalConsolidateable - */ - public int getTotalConsolidateable() { - - return this.totalConsolidateable; - } - - - /** - * @return the totalNodes - */ - public int getTotalNodes() { - - return this.totalNodes; - } - - public void reset() { - - this.totalConsolidateable = 0; - this.totalNodes = 0; - } - - - - +public class TrieNodeInspectingVisitor implements ITrieNodeVisitor +{ + + private static final Logger log = LoggerFactory.getLogger(TrieNodeInspectingVisitor.class); + + + int totalConsolidateable = 0; + + int totalNodes = 0; + + public void visit(TrieNode element) + { + + this.totalNodes++; + + if (element.getOrderedNodeList().size() == 1) + this.totalConsolidateable++; + + } + + /** + * @return the totalConsolidateable + */ + public int getTotalConsolidateable() + { + + return this.totalConsolidateable; + } + + + /** + * @return the totalNodes + */ + public int getTotalNodes() + { + + return this.totalNodes; + } + + public void reset() + { + + this.totalConsolidateable = 0; + this.totalNodes = 0; + } + + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieUtils.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieUtils.java index 75b579fb90..3f33731825 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieUtils.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/trie/TrieUtils.java @@ -26,28 +26,31 @@ /** * @author mocleiri persist a built Trie to disk. - * + * */ -public final class TrieUtils { +public final class TrieUtils +{ /** * */ - private TrieUtils() { + private TrieUtils() + { } /** - * Save the Trie into the file named. This can be useful since creating the Trie takes more memory than storing the simplified/compressed Patricia Trie. + * Save the Trie into the file named. This can be useful since creating the Trie takes more + * memory than storing the simplified/compressed Patricia Trie. * * @param dataFile * @param trie * @throws FileNotFoundException * @throws IOException */ - public static void save(File dataFile, Trietrie) throws FileNotFoundException, IOException { + public static void save(File dataFile, Trie trie) throws FileNotFoundException, IOException + { - ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream( - dataFile, false)); + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(dataFile, false)); oos.writeObject(trie); @@ -65,23 +68,18 @@ public static void save(File dataFile, Trietrie) throws FileNotFoundException * @throws ClassNotFoundException */ public static Trie load(File dataFile) throws FileNotFoundException, IOException, - ClassNotFoundException { + ClassNotFoundException + { - ObjectInputStream ois = new ObjectInputStream(new FileInputStream( - dataFile)); + ObjectInputStream ois = new ObjectInputStream(new FileInputStream(dataFile)); - Trie trie = (Trie) ois.readObject(); + Trie trie = (Trie)ois.readObject(); ois.close(); - + return trie; } - - - - - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNode.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNode.java index f951047a8f..3e4b2d9907 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNode.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNode.java @@ -8,7 +8,8 @@ import org.apache.wicket.IClusterable; -public class TernaryNode implements IClusterable { +public class TernaryNode implements IClusterable +{ /** * @@ -21,8 +22,8 @@ public class TernaryNode implements IClusterable { // single character if we are an interior node // long string if we are an interior node. private String character; - - + + // character within the original string? private int level = -1; @@ -32,20 +33,22 @@ public class TernaryNode implements IClusterable { private TernaryNode equalsNode = null; private TernaryNode greaterThanNode = null; - - public boolean isCompressedLeafNode() { - + + public boolean isCompressedLeafNode() + { + if (this.character.length() > 1) return true; else return false; } - + /** * @return the level */ - public int getLevel() { + public int getLevel() + { return level; } @@ -53,31 +56,35 @@ public int getLevel() { /** * @return the str */ - public String getCharacter() { + public String getCharacter() + { return character; } /** * */ - - public TernaryNode(TernaryNode parent, int level, String str) { + + public TernaryNode(TernaryNode parent, int level, String str) + { this(parent, level, str, null); - + } - public TernaryNode(TernaryNode parent, int level, String str, C value) { + + public TernaryNode(TernaryNode parent, int level, String str, C value) + { super(); this.level = level; this.valueListMap = new LinkedHashMap>(); this.character = str; - + List list = new LinkedList(); - + list.add(value); - - this.valueListMap.put((str.length()-1), list); + + this.valueListMap.put((str.length() - 1), list); } @@ -87,76 +94,87 @@ public TernaryNode(TernaryNode parent, int level, String str, C value) { * @param word * @param value */ - public void index(String word, C value) { + public void index(String word, C value) + { + + if (isCompressedLeafNode()) + { - if (isCompressedLeafNode()) { - // is the word contained within our string. - - -// if (this.character.startsWith(word)) { -// -// int index = word.length()-1; -// -// ListmatchList = this.valueListMap.get(index); -// -// if (matchList == null) { -// matchList = new LinkedList(); -// this.valueListMap.put(index, matchList); -// } -// -// matchList.add(value); -// } -// else { + + +// if (this.character.startsWith(word)) { +// +// int index = word.length()-1; +// +// ListmatchList = this.valueListMap.get(index); +// +// if (matchList == null) { +// matchList = new LinkedList(); +// this.valueListMap.put(index, matchList); +// } +// +// matchList.add(value); +// } +// else { } - - String testCharacter = word.substring(this.level, this.level+1); - - + + String testCharacter = word.substring(this.level, this.level + 1); + + int comparison = testCharacter.compareTo(this.character); TernaryNode node; - if (comparison < 0) { + if (comparison < 0) + { if (lessThanNode == null) lessThanNode = new TernaryNode(this, this.level, testCharacter); - + lessThanNode.index(word, value); - - - } else if (comparison > 0) { - + + + } + else if (comparison > 0) + { + if (greaterThanNode == null) greaterThanNode = new TernaryNode(this, this.level, testCharacter); - + greaterThanNode.index(word, value); } - else if (level < (word.length() -1)) { + else if (level < (word.length() - 1)) + { // equals - - if (equalsNode == null) { + + if (equalsNode == null) + { // if null we write the rest of the string into this node - equalsNode = new TernaryNode(this, this.level+1, word.substring(this.level+1)); - + equalsNode = new TernaryNode(this, this.level + 1, + word.substring(this.level + 1)); + } - else { + else + { equalsNode.index(word, value); } - + } - - else { + + else + { // terminates here - ListvalueList = this.valueListMap.get(0); - - if (valueList == null) { + List valueList = this.valueListMap.get(0); + + if (valueList == null) + { valueList = new LinkedList(); this.valueListMap.put(0, valueList); } - + valueList.add(value); } @@ -168,131 +186,137 @@ else if (level < (word.length() -1)) { * @see java.lang.Object#toString() */ @Override - public String toString() { - return "TernaryNode [str= " + character + ", lessThanNode=" + lessThanNode + ", equalsNode=" + equalsNode + ", greaterThanNode=" - + greaterThanNode + " ]"; + public String toString() + { + return "TernaryNode [str= " + character + ", lessThanNode=" + lessThanNode + + ", equalsNode=" + equalsNode + ", greaterThanNode=" + greaterThanNode + " ]"; } - -// public void buildWordList(List wordList, String prefix, int limit) { + +// public void buildWordList(List wordList, String prefix, int limit) { // -// // find the node that matches the prefix then add all words in the tree -// // and subtree. +// // find the node that matches the prefix then add all words in the tree +// // and subtree. // -// if (prefix.length() == 1 && prefix.equals(this.str)) { +// if (prefix.length() == 1 && prefix.equals(this.str)) { // -// // this and below is the match +// // this and below is the match // -// this.accumulate(wordList, limit, true); -// -// +// this.accumulate(wordList, limit, true); // -// } else { -// -// String decendent = prefix.substring(1); // -// TernaryNode next = a(decendent, false); // -// next.buildWordList(wordList, decendent, limit); +// } else { // -// } +// String decendent = prefix.substring(1); // -// } +// TernaryNode next = a(decendent, false); +// +// next.buildWordList(wordList, decendent, limit); +// +// } +// +// } /** * @return the parentNode */ - public TernaryNode getParentNode() { + public TernaryNode getParentNode() + { return parentNode; } /** - * Find all of the matches in the sub trie indicated and add them onto the - * list. + * Find all of the matches in the sub trie indicated and add them onto the list. * * @param wordList * @param limit - * @param first true if we want to only include the equals first + * @param first + * true if we want to only include the equals first * */ - public void accumulate(List wordList, int limit, boolean first) { + public void accumulate(List wordList, int limit, boolean first) + { - for (List col : this.valueListMap.values()) { + for (List col : this.valueListMap.values()) + { wordList.addAll(col); } if (!first && lessThanNode != null) lessThanNode.accumulate(wordList, limit, false); - + if (equalsNode != null) equalsNode.accumulate(wordList, limit, false); - + if (!first && greaterThanNode != null) greaterThanNode.accumulate(wordList, limit, false); } - - public void collect (ListvalueList) { -// private void collect(Node x, String prefix, Queue queue) { -// if (x == null) return; -// collect(x.left, prefix, queue); -// if (x.val != null) queue.enqueue(prefix + x.c); -// collect(x.mid, prefix + x.c, queue); -// collect(x.right, prefix, queue); - - - for (List col : this.valueListMap.values()) { + + public void collect(List valueList) + { +// private void collect(Node x, String prefix, Queue queue) { +// if (x == null) return; +// collect(x.left, prefix, queue); +// if (x.val != null) queue.enqueue(prefix + x.c); +// collect(x.mid, prefix + x.c, queue); +// collect(x.right, prefix, queue); + + + for (List col : this.valueListMap.values()) + { valueList.addAll(col); } - + if (lessThanNode != null) lessThanNode.collect(valueList); - + if (equalsNode != null) equalsNode.collect(valueList); - + if (greaterThanNode != null) greaterThanNode.collect(valueList); - - - + + } -// private TernaryNode getNextNode(String word, boolean initialize) { +// private TernaryNode getNextNode(String word, boolean initialize) { +// // -// -// String targetCharacter = word.substring(this.level+1, this.level+2); +// String targetCharacter = word.substring(this.level+1, this.level+2); // -// int comparison = targetCharacter.compareTo(this.str); +// int comparison = targetCharacter.compareTo(this.str); // -// TernaryNode node; +// TernaryNode node; // -// if (comparison < 1) { +// if (comparison < 1) { // -// lessThanNode = initializeNode(this, targetCharacter, lessThanNode, level, -// initialize); +// lessThanNode = initializeNode(this, targetCharacter, lessThanNode, level, +// initialize); // -// node = lessThanNode; +// node = lessThanNode; // -// } else if (comparison > 1) { -// greaterThanNode = initializeNode(this, targetCharacter, -// greaterThanNode, level, initialize); -// -// node = greaterThanNode; +// } else if (comparison > 1) { +// greaterThanNode = initializeNode(this, targetCharacter, +// greaterThanNode, level, initialize); // -// } else { -// equalsNode = initializeNode(this, targetCharacter, equalsNode, level+1, -// initialize); -// node = equalsNode; -// } +// node = greaterThanNode; // -// return node; +// } else { +// equalsNode = initializeNode(this, targetCharacter, equalsNode, level+1, +// initialize); +// node = equalsNode; +// } // -// } +// return node; +// +// } - private TernaryNode initializeNode(TernaryNode parent, String str, - TernaryNode node, int level, boolean initialize) { + private TernaryNode initializeNode(TernaryNode parent, String str, TernaryNode node, + int level, boolean initialize) + { if (node != null) return node; @@ -303,7 +327,8 @@ else if (initialize) } - public void visit(TernaryNodeVisitor visitor) { + public void visit(TernaryNodeVisitor visitor) + { visitor.visit(this); @@ -324,39 +349,43 @@ public void visit(TernaryNodeVisitor visitor) { * @return the node theat matches the prefix given. * */ - public TernaryNode matchPrefix(String prefix) { - -// private Node get(Node x, String key, int d) { -// if (key == null || key.length() == 0) throw new RuntimeException("illegal key"); -// if (x == null) return null; -// char c = key.charAt(d); -// if (c < x.c) return get(x.left, key, d); -// else if (c > x.c) return get(x.right, key, d); -// else if (d < key.length() - 1) return get(x.mid, key, d+1); -// else return x; - + public TernaryNode matchPrefix(String prefix) + { + +// private Node get(Node x, String key, int d) { +// if (key == null || key.length() == 0) throw new RuntimeException("illegal key"); +// if (x == null) return null; +// char c = key.charAt(d); +// if (c < x.c) return get(x.left, key, d); +// else if (c > x.c) return get(x.right, key, d); +// else if (d < key.length() - 1) return get(x.mid, key, d+1); +// else return x; + if (prefix.length() == 0) return this; - - String testCharacter = prefix.substring(this.level, this.level+1); - + + String testCharacter = prefix.substring(this.level, this.level + 1); + String thisCharacter = this.character; - + int comparison = testCharacter.compareTo(thisCharacter); TernaryNode node; - if (comparison < 0) { + if (comparison < 0) + { if (lessThanNode != null) return lessThanNode.matchPrefix(prefix); else return null; - - - } else if (comparison > 0) { - + + + } + else if (comparison > 0) + { + if (greaterThanNode != null) return greaterThanNode.matchPrefix(prefix); @@ -364,47 +393,51 @@ public TernaryNode matchPrefix(String prefix) { return null; } - else if (level < (prefix.length() -1)) { + else if (level < (prefix.length() - 1)) + { // equals - + if (equalsNode != null) return equalsNode.matchPrefix(prefix); else return null; - - + + } - - else { + + else + { return this; } - + } /** * * @param levelZeroSet * - * Visit all of the level zero nodes and add their character value into the set. + * Visit all of the level zero nodes and add their character value into the set. * */ - public void getStartingCharacterSet(Set levelZeroSet) { - + public void getStartingCharacterSet(Set levelZeroSet) + { + if (this.level > 0) return; - - if (this.level == 0) { - + + if (this.level == 0) + { + levelZeroSet.add(this.character); - + if (lessThanNode != null) lessThanNode.getStartingCharacterSet(levelZeroSet); - + if (greaterThanNode != null) greaterThanNode.getStartingCharacterSet(levelZeroSet); } - + } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeCountingVisitor.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeCountingVisitor.java index 49ac066692..056edac5ad 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeCountingVisitor.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeCountingVisitor.java @@ -28,78 +28,90 @@ /** * @author mocleiri - * + * */ -public class TernaryNodeCountingVisitor implements TernaryNodeVisitor { +public class TernaryNodeCountingVisitor implements TernaryNodeVisitor +{ private static final Logger log = LoggerFactory.getLogger(TernaryNodeCountingVisitor.class); - + /** * */ - public TernaryNodeCountingVisitor() { + public TernaryNodeCountingVisitor() + { // TODO Auto-generated constructor stub } - private MapnodeCountMap = new LinkedHashMap(); - - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#visit(org.wicketstuff.datatable_autocomplete.tst.TernaryNode) - */ - public void visit(TernaryNode node) { - - AtomicLong nodeCounter = nodeCountMap.get(node.getCharacter()); - - if (nodeCounter == null) { - nodeCounter = new AtomicLong(); - nodeCountMap.put(node.getCharacter(), nodeCounter); - - } - - nodeCounter.addAndGet(1L); - - - } + private Map nodeCountMap = new LinkedHashMap(); + + + /* + * (non-Javadoc) + * + * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#visit(org.wicketstuff. + * datatable_autocomplete.tst.TernaryNode) + */ + public void visit(TernaryNode node) + { + + AtomicLong nodeCounter = nodeCountMap.get(node.getCharacter()); + + if (nodeCounter == null) + { + nodeCounter = new AtomicLong(); + nodeCountMap.put(node.getCharacter(), nodeCounter); - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#postVisit() - */ - public void postVisit() { - - ListkeyList = new LinkedList(); - - keyList.addAll(nodeCountMap.keySet()); - - Collections.sort(keyList); - - AtomicLong overallNodeCounter = new AtomicLong(); - - - for (String character : keyList) { - - AtomicLong counter = nodeCountMap.get(character); - - overallNodeCounter.addAndGet(counter.longValue()); - - log.info(" [ "+character+" ] = " + counter.longValue()); - - } - - log.info("overall node count = " + overallNodeCounter.longValue()); - - } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#preVisit() - */ - public void preVisit() { - + nodeCounter.addAndGet(1L); + + + } + + /* + * (non-Javadoc) + * + * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#postVisit() + */ + public void postVisit() + { + + List keyList = new LinkedList(); + + keyList.addAll(nodeCountMap.keySet()); + + Collections.sort(keyList); + + AtomicLong overallNodeCounter = new AtomicLong(); + + + for (String character : keyList) + { + + AtomicLong counter = nodeCountMap.get(character); + + overallNodeCounter.addAndGet(counter.longValue()); + + log.info(" [ " + character + " ] = " + counter.longValue()); + } - - - - + + log.info("overall node count = " + overallNodeCounter.longValue()); + + + } + + /* + * (non-Javadoc) + * + * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#preVisit() + */ + public void preVisit() + { + + } + + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeVisitor.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeVisitor.java index c64db9f20d..fc950e5ebb 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeVisitor.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernaryNodeVisitor.java @@ -20,13 +20,14 @@ /** * @author Michael O'Cleirigh (michael.ocleirigh@rivulet.ca) - * + * */ -public interface TernaryNodeVisitor extends IClusterable { +public interface TernaryNodeVisitor extends IClusterable +{ public void preVisit(); - - public void visit (TernaryNodenode); - + + public void visit(TernaryNode node); + public void postVisit(); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernarySearchTrie.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernarySearchTrie.java index ceebb553a2..4747e22e24 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernarySearchTrie.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/main/java/org/wicketstuff/datatable_autocomplete/tst/TernarySearchTrie.java @@ -34,7 +34,8 @@ * * */ -public class TernarySearchTrie implements Trie { +public class TernarySearchTrie implements Trie +{ private TernaryNode root = null; private final ITrieConfiguration configuration; @@ -42,13 +43,15 @@ public class TernarySearchTrie implements Trie { /** * */ - public TernarySearchTrie(ITrieConfiguration configuration) { + public TernarySearchTrie(ITrieConfiguration configuration) + { this.configuration = configuration; } - public void index(C value) { + public void index(C value) + { String word = this.configuration.getWord(value); @@ -57,19 +60,21 @@ public void index(C value) { String firstLetter = word.substring(0, 1); - if (root == null) { + if (root == null) + { root = new TernaryNode(null, 0, firstLetter); } - - root.index(word, value); - + + root.index(word, value); + } - public List getWordList(String prefix, int limit) { + public List getWordList(String prefix, int limit) + { List wordList = new LinkedList(); @@ -81,7 +86,8 @@ public List getWordList(String prefix, int limit) { return wordList; } - public List getWordList(String prefix) { + public List getWordList(String prefix) + { return this.getWordList(prefix, -1); @@ -90,11 +96,11 @@ public List getWordList(String prefix) { /* * (non-Javadoc) * - * @see - * org.wicketstuff.datatable_autocomplete.trie.Trie#getWordList(java.lang - * .String, org.wicketstuff.datatable_autocomplete.trie.ITrieFilter, int) + * @see org.wicketstuff.datatable_autocomplete.trie.Trie#getWordList(java.lang .String, + * org.wicketstuff.datatable_autocomplete.trie.ITrieFilter, int) */ - public List getWordList(String prefix, ITrieFilter filter, int limit) { + public List getWordList(String prefix, ITrieFilter filter, int limit) + { /* * TODO: add support for TrieFiltering */ @@ -104,18 +110,19 @@ public List getWordList(String prefix, ITrieFilter filter, int limit) { /* * (non-Javadoc) * - * @see - * org.wicketstuff.datatable_autocomplete.trie.Trie#getWordList(java.lang - * .String, org.wicketstuff.datatable_autocomplete.trie.ITrieFilter) + * @see org.wicketstuff.datatable_autocomplete.trie.Trie#getWordList(java.lang .String, + * org.wicketstuff.datatable_autocomplete.trie.ITrieFilter) */ - public List getWordList(String prefix, ITrieFilter filter) { + public List getWordList(String prefix, ITrieFilter filter) + { /* * TODO: add support for TrieFiltering */ return getWordList(prefix); } - public void visit(TernaryNodeVisitor visitor) { + public void visit(TernaryNodeVisitor visitor) + { visitor.preVisit(); @@ -126,11 +133,11 @@ public void visit(TernaryNodeVisitor visitor) { /** * - * @return the Set for the starting (level 0) characters in the - * index. + * @return the Set for the starting (level 0) characters in the index. * */ - public Set getNextNodeCharacterSet() { + public Set getNextNodeCharacterSet() + { Set levelZeroSet = new LinkedHashSet(); @@ -144,7 +151,8 @@ public Set getNextNodeCharacterSet() { * * @see org.wicketstuff.datatable_autocomplete.trie.Trie#postIndexing() */ - public void postIndexing() { + public void postIndexing() + { // TODO Auto-generated method stub } @@ -154,31 +162,32 @@ public void postIndexing() { * * @see org.wicketstuff.datatable_autocomplete.trie.Trie#preIndexing() */ - public void preIndexing() { + public void preIndexing() + { // TODO Auto-generated method stub } - - + /** * @return the root */ - public TernaryNode getRoot() { + public TernaryNode getRoot() + { return root; } - public void printTree() { - + public void printTree() + { + /* - * _N_ - * | \ - * - * build all down less than then level ordered from there. back up until an unrendered left is encountered. + * _N_ | \ + * + * build all down less than then level ordered from there. back up until an unrendered left + * is encountered. */ - - - + + } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicPrefixTrieTestCase.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicPrefixTrieTestCase.java index d9153b9b53..04ff36f160 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicPrefixTrieTestCase.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicPrefixTrieTestCase.java @@ -30,7 +30,8 @@ * @author mocleiri */ -public class BasicPrefixTrieTestCase extends TestCase { +public class BasicPrefixTrieTestCase extends TestCase +{ private PatriciaTrie trie; private List dataList; @@ -41,51 +42,60 @@ public class BasicPrefixTrieTestCase extends TestCase { /** * */ - public BasicPrefixTrieTestCase() { + public BasicPrefixTrieTestCase() + { init(); } /** * @param name */ - public BasicPrefixTrieTestCase(String name) { + public BasicPrefixTrieTestCase(String name) + { super(name); init(); } - protected void init() { + protected void init() + { - this.trie = new PatriciaTrie(new AbstractTrieConfiguration() { + trie = new PatriciaTrie(new AbstractTrieConfiguration() + { /* * (non-Javadoc) * - * @see - * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration + * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration * #getWord(java.lang.Object) */ - public String getWord(String ctx) { + public String getWord(String ctx) + { return ctx; } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() */ - public boolean isIndexCaseSensitive() { + public boolean isIndexCaseSensitive() + { // default to no insensitivity return false; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() */ - public boolean isSuffixTree() { + public boolean isSuffixTree() + { // TODO Auto-generated method stub return false; } - - - + }); @@ -94,13 +104,14 @@ public boolean isSuffixTree() { doubleZeroWordList = new ArrayList(); oneWordList = new ArrayList(); - for (int i = 1000; i < 9999; i++) { + for (int i = 1000; i < 9999; i++) + { String stringValue = String.valueOf(i); if (stringValue.contains("00")) doubleZeroWordList.add(stringValue); - + if (stringValue.contains("1")) oneWordList.add(stringValue); @@ -109,11 +120,11 @@ public boolean isSuffixTree() { } // for (char c = 'a'; c <= 'z'; c++) { - // + // // for (char b = 'a'; b <= 'z'; b++) { - // + // // String value = String.valueOf(c) + String.valueOf(b); - // + // // trie.index(value); // dataList.add(value); // } @@ -124,7 +135,8 @@ public boolean isSuffixTree() { } - public void testMissingValues() { + public void testMissingValues() + { List wordList = trie.getWordList(""); @@ -132,83 +144,84 @@ public void testMissingValues() { } - public void testAnyDoubleZeroMatch() { + public void testAnyDoubleZeroMatch() + { List wordList = trie.getWordList("00"); Collection disjunction = CollectionUtils.disjunction(wordList, doubleZeroWordList); - - for (String string : disjunction) { + + for (String string : disjunction) + { System.out.println("extra = " + string); } - - - + + assertEquals(doubleZeroWordList.size(), wordList.size()); - - - - - + + } - - public void testAnyOneMatch () { - + + public void testAnyOneMatch() + { + List wordList = trie.getWordList("1"); Collection disjunction = CollectionUtils.disjunction(wordList, oneWordList); - - for (String string : disjunction) { + + for (String string : disjunction) + { System.out.println("extra = " + string); } - - - + + assertEquals(oneWordList.size(), wordList.size()); - - + + } // public void testContainsAll() { - // + // // for (char c = 'a'; c <= 'z'; c++) { - // + // // for (char b = 'a'; b <= 'z'; b++) { - // + // // List wordList = trie.getWordList(String.valueOf(c) + // String.valueOf(b)); // t // assertTrue(wordList.size() == 1); - // + // // } // } // } /** - * Verify that all the words that were indexed into the Trie can be - * retrieved. + * Verify that all the words that were indexed into the Trie can be retrieved. */ - public void testValueTrie() { + public void testValueTrie() + { List wordList = trie.getWordList(""); Collections.sort(wordList); Collections.sort(dataList); - for (String source : dataList) { + for (String source : dataList) + { - if (!wordList.contains(source)) { - System.out - .println(source + " is not contained in the wordlist"); + if (!wordList.contains(source)) + { + System.out.println(source + " is not contained in the wordlist"); } } - for (int i = 0; i < dataList.size(); i++) { + for (int i = 0; i < dataList.size(); i++) + { // if (wordList.size() > i) // log.info("["+i+"] index = " + wordList.get(i)); - // + // // log.info("["+i+"] data = " + dataList.get(i)); String word = wordList.get(i); diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicSuffixTrieTestCase.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicSuffixTrieTestCase.java index 21a0554c7e..310adc0791 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicSuffixTrieTestCase.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/trie/BasicSuffixTrieTestCase.java @@ -30,7 +30,8 @@ * @author mocleiri */ -public class BasicSuffixTrieTestCase extends TestCase { +public class BasicSuffixTrieTestCase extends TestCase +{ private PatriciaTrie trie; private List dataList; @@ -41,51 +42,60 @@ public class BasicSuffixTrieTestCase extends TestCase { /** * */ - public BasicSuffixTrieTestCase() { + public BasicSuffixTrieTestCase() + { init(); } /** * @param name */ - public BasicSuffixTrieTestCase(String name) { + public BasicSuffixTrieTestCase(String name) + { super(name); init(); } - protected void init() { + protected void init() + { - this.trie = new PatriciaTrie(new AbstractTrieConfiguration() { + trie = new PatriciaTrie(new AbstractTrieConfiguration() + { /* * (non-Javadoc) * - * @see - * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration + * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration * #getWord(java.lang.Object) */ - public String getWord(String ctx) { + public String getWord(String ctx) + { return ctx; } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() */ - public boolean isIndexCaseSensitive() { + public boolean isIndexCaseSensitive() + { // default to no insensitivity return false; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() */ - public boolean isSuffixTree() { + public boolean isSuffixTree() + { // TODO Auto-generated method stub return true; } - - - + }); @@ -94,13 +104,14 @@ public boolean isSuffixTree() { doubleZeroWordList = new ArrayList(); oneWordList = new ArrayList(); - for (int i = 1000; i < 9999; i++) { + for (int i = 1000; i < 9999; i++) + { String stringValue = String.valueOf(i); if (stringValue.contains("00")) doubleZeroWordList.add(stringValue); - + if (stringValue.contains("1")) oneWordList.add(stringValue); @@ -109,11 +120,11 @@ public boolean isSuffixTree() { } // for (char c = 'a'; c <= 'z'; c++) { - // + // // for (char b = 'a'; b <= 'z'; b++) { - // + // // String value = String.valueOf(c) + String.valueOf(b); - // + // // trie.index(value); // dataList.add(value); // } @@ -124,7 +135,8 @@ public boolean isSuffixTree() { } - public void testMissingValues() { + public void testMissingValues() + { List wordList = trie.getWordList(""); @@ -132,83 +144,84 @@ public void testMissingValues() { } - public void testAnyDoubleZeroMatch() { + public void testAnyDoubleZeroMatch() + { List wordList = trie.getWordList("00"); Collection disjunction = CollectionUtils.disjunction(wordList, doubleZeroWordList); - - for (String string : disjunction) { + + for (String string : disjunction) + { System.out.println("extra = " + string); } - - - + + assertEquals(doubleZeroWordList.size(), wordList.size()); - - - - - + + } - - public void testAnyOneMatch () { - + + public void testAnyOneMatch() + { + List wordList = trie.getWordList("1"); Collection disjunction = CollectionUtils.disjunction(wordList, oneWordList); - - for (String string : disjunction) { + + for (String string : disjunction) + { System.out.println("extra = " + string); } - - - + + assertEquals(oneWordList.size(), wordList.size()); - - + + } // public void testContainsAll() { - // + // // for (char c = 'a'; c <= 'z'; c++) { - // + // // for (char b = 'a'; b <= 'z'; b++) { - // + // // List wordList = trie.getWordList(String.valueOf(c) + // String.valueOf(b)); // t // assertTrue(wordList.size() == 1); - // + // // } // } // } /** - * Verify that all the words that were indexed into the Trie can be - * retrieved. + * Verify that all the words that were indexed into the Trie can be retrieved. */ - public void testValueTrie() { + public void testValueTrie() + { List wordList = trie.getWordList(""); Collections.sort(wordList); Collections.sort(dataList); - for (String source : dataList) { + for (String source : dataList) + { - if (!wordList.contains(source)) { - System.out - .println(source + " is not contained in the wordlist"); + if (!wordList.contains(source)) + { + System.out.println(source + " is not contained in the wordlist"); } } - for (int i = 0; i < dataList.size(); i++) { + for (int i = 0; i < dataList.size(); i++) + { // if (wordList.size() > i) // log.info("["+i+"] index = " + wordList.get(i)); - // + // // log.info("["+i+"] data = " + dataList.get(i)); String word = wordList.get(i); diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/tst/BasicTernarySearchTrieTest.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/tst/BasicTernarySearchTrieTest.java index c6aa3ac1b9..6c1b52f0d0 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/tst/BasicTernarySearchTrieTest.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-common/src/test/java/org/wicketstuff/datatable_autocomplete/tst/BasicTernarySearchTrieTest.java @@ -25,202 +25,265 @@ /** * @author mocleiri * - * Basic tests for the TernarySearchTrie - * + * Basic tests for the TernarySearchTrie + * */ -public class BasicTernarySearchTrieTest extends TestCase { +public class BasicTernarySearchTrieTest extends TestCase +{ private static final Logger log = LoggerFactory.getLogger(BasicTernarySearchTrieTest.class); - + /** * */ - public BasicTernarySearchTrieTest() { + public BasicTernarySearchTrieTest() + { // TODO Auto-generated constructor stub } - - public void testSimpleTST() { - - TernarySearchTrietrie = new TernarySearchTrie(new AbstractTrieConfiguration() { - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang.Object) - */ - public String getWord(String ctx) { - return ctx; - } - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() - */ - public boolean isIndexCaseSensitive() { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() - */ - public boolean isSuffixTree() { - // TODO Auto-generated method stub - return false; - } - - }); - - + + public void testSimpleTST() + { + + TernarySearchTrie trie = new TernarySearchTrie( + new AbstractTrieConfiguration() + { + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang + * .Object) + */ + public String getWord(String ctx) + { + return ctx; + } + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive + * () + */ + public boolean isIndexCaseSensitive() + { + // TODO Auto-generated method stub + return false; + } + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() + */ + public boolean isSuffixTree() + { + // TODO Auto-generated method stub + return false; + } + + }); + + trie.index("household"); trie.index("person"); trie.index("trip"); trie.index("transit"); trie.index("survey"); - + trie.visit(new TernaryNodeCountingVisitor()); - + log.info("prefix = 'hou'"); - - for (String word : trie.getWordList("hou", -1)) { - + + for (String word : trie.getWordList("hou", -1)) + { + log.info("word = " + word); } - + log.info("prefix = ''"); - for (String word : trie.getWordList("", -1)) { - + for (String word : trie.getWordList("", -1)) + { + log.info("word = " + word); } - + log.info("prefix = 'tr'"); - - for (String word : trie.getWordList("tr", -1)) { - + + for (String word : trie.getWordList("tr", -1)) + { + log.info("word = " + word); } } - - public void testCompressedTST() { - - TernarySearchTrietrie = new TernarySearchTrie(new AbstractTrieConfiguration() { - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang.Object) - */ - public String getWord(String ctx) { - return ctx; - } - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() - */ - public boolean isIndexCaseSensitive() { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() - */ - public boolean isSuffixTree() { - // TODO Auto-generated method stub - return false; - } - - }); - - + + public void testCompressedTST() + { + + TernarySearchTrie trie = new TernarySearchTrie( + new AbstractTrieConfiguration() + { + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang + * .Object) + */ + public String getWord(String ctx) + { + return ctx; + } + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive + * () + */ + public boolean isIndexCaseSensitive() + { + // TODO Auto-generated method stub + return false; + } + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() + */ + public boolean isSuffixTree() + { + // TODO Auto-generated method stub + return false; + } + + }); + + trie.index("transit"); trie.index("trip"); - + trie.printTree(); - + trie.visit(new TernaryNodeCountingVisitor()); - + log.info("prefix = 'hou'"); - - for (String word : trie.getWordList("hou", -1)) { - + + for (String word : trie.getWordList("hou", -1)) + { + log.info("word = " + word); } - + log.info("prefix = ''"); - for (String word : trie.getWordList("", -1)) { - + for (String word : trie.getWordList("", -1)) + { + log.info("word = " + word); } - + log.info("prefix = 'tr'"); - - for (String word : trie.getWordList("tr", -1)) { - + + for (String word : trie.getWordList("tr", -1)) + { + log.info("word = " + word); } } - public void testSimpleSuffixTST() { - - TernarySearchTrietrie = new TernarySearchTrie(new AbstractTrieConfiguration() { - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang.Object) - */ - public String getWord(String ctx) { - return ctx; - } - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() - */ - public boolean isIndexCaseSensitive() { - // TODO Auto-generated method stub - return false; - } - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() - */ - public boolean isSuffixTree() { - // TODO Auto-generated method stub - return true; - } - - }); - - + public void testSimpleSuffixTST() + { + + TernarySearchTrie trie = new TernarySearchTrie( + new AbstractTrieConfiguration() + { + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang + * .Object) + */ + public String getWord(String ctx) + { + return ctx; + } + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive + * () + */ + public boolean isIndexCaseSensitive() + { + // TODO Auto-generated method stub + return false; + } + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() + */ + public boolean isSuffixTree() + { + // TODO Auto-generated method stub + return true; + } + + }); + + trie.index("household"); trie.index("person"); trie.index("trip"); trie.index("transit"); trie.index("survey"); - + trie.visit(new TernaryNodeCountingVisitor()); - - reportPrefix (trie, "o"); - + + reportPrefix(trie, "o"); + log.info("prefix = ''"); - for (String word : trie.getWordList("", -1)) { - + for (String word : trie.getWordList("", -1)) + { + log.info("word = " + word); } - + log.info("prefix = 'e'"); - - for (String word : trie.getWordList("e", -1)) { - + + for (String word : trie.getWordList("e", -1)) + { + log.info("word = " + word); } } - private void reportPrefix(TernarySearchTrie trie, String prefix) { - - log.info("prefix = '"+prefix+"'"); - - for (String word : trie.getWordList(prefix, -1)) { - + private void reportPrefix(TernarySearchTrie trie, String prefix) + { + + log.info("prefix = '" + prefix + "'"); + + for (String word : trie.getWordList(prefix, -1)) + { + log.info("word = " + word); } - + } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/WicketApplication.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/WicketApplication.java index d166b5d44c..2c9bf7ff28 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/WicketApplication.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/WicketApplication.java @@ -31,10 +31,11 @@ * @author mocleiri */ -public class WicketApplication extends WebApplication { +public class WicketApplication extends WebApplication +{ /* - * The number of methods to load into the Trie index. + * The number of methods to load into the Trie index. * * try 12500 if you have enought memory (-Xmx512m should allow it) */ @@ -42,46 +43,53 @@ public class WicketApplication extends WebApplication { private static Logger log = LoggerFactory.getLogger(WicketApplication.class); - - + + private static PatriciaTrie trie; /** * */ - public WicketApplication() { + public WicketApplication() + { // TODO Auto-generated constructor stub } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.Application#getHomePage() */ @Override - public Class getHomePage() { + public Class getHomePage() + { return HomePage.class; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.protocol.http.WebApplication#init() */ @Override - protected void init() { + protected void init() + { super.init(); - + TrieBuilder builder = new TrieBuilder(); - + builder.buildTrie(methodLimit); WicketApplication.trie = builder.getTrie(); - - + + } - public static PatriciaTrie getTrie() { - + public static PatriciaTrie getTrie() + { + return trie; } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TernarySearchTrieBuilder.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TernarySearchTrieBuilder.java index 543292d971..6ab4a73545 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TernarySearchTrieBuilder.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TernarySearchTrieBuilder.java @@ -36,58 +36,73 @@ /** * @author mocleiri * - * Builds a TernartSearchTrie by loading Methods from the rt.jar in the JVM running the examples. + * Builds a TernartSearchTrie by loading Methods from the rt.jar in the JVM running the + * examples. + * * - * */ -public final class TernarySearchTrieBuilder { +public final class TernarySearchTrieBuilder +{ private static final Logger log = LoggerFactory.getLogger(TernarySearchTrieBuilder.class); - + // holds the count of first charcter to count - private Map>map = new LinkedHashMap>(); + private Map> map = new LinkedHashMap>(); private TernarySearchTrie trie; - + /** * */ - public TernarySearchTrieBuilder(final boolean suffixTrie) { - trie = new TernarySearchTrie(new AbstractTrieConfiguration() { - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang.Object) + public TernarySearchTrieBuilder(final boolean suffixTrie) + { + trie = new TernarySearchTrie(new AbstractTrieConfiguration() + { + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang. + * Object) */ - public String getWord(Method ctx) { - + public String getWord(Method ctx) + { + return ctx.getName(); } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() */ - public boolean isIndexCaseSensitive() { + public boolean isIndexCaseSensitive() + { // default to not distinuishing between the case of the strings in the index. return false; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() */ - public boolean isSuffixTree() { + public boolean isSuffixTree() + { return suffixTrie; } - - - + + }); } - - - public void buildTrie (int maxElements) { - - + + public void buildTrie(int maxElements) + { + + String path = System.getProperty("sun.boot.class.path"); String[] parts = path.split(":"); @@ -95,35 +110,39 @@ public void buildTrie (int maxElements) { String targetPart = null; int addedElements = 0; - - for (String p : parts) { - if (p.endsWith("rt.jar")) { + for (String p : parts) + { + + if (p.endsWith("rt.jar")) + { targetPart = p; break; } } - try { + try + { JarFile jar = new JarFile(targetPart); - + Enumeration entries = jar.entries(); - while (entries.hasMoreElements()) { - + while (entries.hasMoreElements()) + { + JarEntry jarEntry = entries.nextElement(); if (!jarEntry.getName().contains(".class")) continue; - + Class clazz; - try { + try + { - String className = jarEntry.getName().replace("/", ".") - .replace(".class", ""); + String className = jarEntry.getName().replace("/", ".").replace(".class", ""); -// System.out.println(className); +// System.out.println(className); ClassLoader.getSystemClassLoader().loadClass(className); @@ -131,64 +150,74 @@ public void buildTrie (int maxElements) { Method[] m = clazz.getDeclaredMethods(); - - for (Method method : m) { + + for (Method method : m) + { if (!Modifier.isPublic(method.getModifiers())) continue; // skip non public methods - + trie.index(method); - + addedElements++; - + String firstCharacter = method.getName().substring(0, 1); - - List methodList = this.map.get(firstCharacter); - - if (methodList == null) { + + List methodList = map.get(firstCharacter); + + if (methodList == null) + { methodList = new LinkedList(); - this.map.put(firstCharacter, methodList); + map.put(firstCharacter, methodList); } - + methodList.add(method); - - if (addedElements >= maxElements) { - - log.info ("indexed " + addedElements + " elements."); -// trie.simplifyIndex(); + + if (addedElements >= maxElements) + { + + log.info("indexed " + addedElements + " elements."); +// trie.simplifyIndex(); return; } - -// System.out.println(clazz.getCanonicalName() + " " -// + method.getName() + " ( " + parameterList + " )"); + +// System.out.println(clazz.getCanonicalName() + " " +// + method.getName() + " ( " + parameterList + " )"); } - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) + { // continue } } - } catch (SecurityException e) { + } + catch (SecurityException e) + { e.printStackTrace(); - } catch (IOException e) { + } + catch (IOException e) + { e.printStackTrace(); } - - log.info ("indexed " + addedElements + " elements."); - + + log.info("indexed " + addedElements + " elements."); + trie.visit(new TernaryNodeCountingVisitor()); - - - + + } - public List getListForFirstCharacter (String character) { - - return this.map.get(character); - + public List getListForFirstCharacter(String character) + { + + return map.get(character); + } - public TernarySearchTrie getTrie() { + public TernarySearchTrie getTrie() + { return trie; } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TrieBuilder.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TrieBuilder.java index 065317d1b9..b98d2043cb 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TrieBuilder.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/data/TrieBuilder.java @@ -35,57 +35,71 @@ /** * @author mocleirihe boot class path for the rt.jar and then loading X methods where X is large. - * + * */ -public final class TrieBuilder { +public final class TrieBuilder +{ private static final Logger log = LoggerFactory.getLogger(TrieBuilder.class); - + // holds the count of first charcter to count - private Map>map = new LinkedHashMap>(); + private Map> map = new LinkedHashMap>(); private PatriciaTrie trie; - + /** * */ - public TrieBuilder() { - trie = new PatriciaTrie(new AbstractTrieConfiguration() { - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang.Object) + public TrieBuilder() + { + trie = new PatriciaTrie(new AbstractTrieConfiguration() + { + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#getWord(java.lang. + * Object) */ - public String getWord(Method ctx) { - + public String getWord(Method ctx) + { + return ctx.getName(); } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isIndexCaseSensitive() */ - public boolean isIndexCaseSensitive() { + public boolean isIndexCaseSensitive() + { // default to not distinuishing between the case of the strings in the index. return false; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.trie.ITrieConfiguration#isSuffixTree() */ - public boolean isSuffixTree() { + public boolean isSuffixTree() + { // TODO Auto-generated method stub return false; } - - - + + }); } - - - public void buildTrie (int maxElements) { - - + + public void buildTrie(int maxElements) + { + + String path = System.getProperty("sun.boot.class.path"); String[] parts = path.split(":"); @@ -93,37 +107,41 @@ public void buildTrie (int maxElements) { String targetPart = null; int addedElements = 0; - - for (String p : parts) { + + for (String p : parts) + { p = p.replaceAll(";C", ""); - - if (p.endsWith("rt.jar")) { + + if (p.endsWith("rt.jar")) + { targetPart = p; break; } } - try { + try + { JarFile jar = new JarFile(targetPart); - + Enumeration entries = jar.entries(); - while (entries.hasMoreElements()) { - + while (entries.hasMoreElements()) + { + JarEntry jarEntry = entries.nextElement(); if (!jarEntry.getName().contains(".class")) continue; - + Class clazz; - try { + try + { - String className = jarEntry.getName().replace("/", ".") - .replace(".class", ""); + String className = jarEntry.getName().replace("/", ".").replace(".class", ""); -// System.out.println(className); +// System.out.println(className); ClassLoader.getSystemClassLoader().loadClass(className); @@ -131,79 +149,89 @@ public void buildTrie (int maxElements) { Method[] m = clazz.getDeclaredMethods(); - - for (Method method : m) { + + for (Method method : m) + { if (!Modifier.isPublic(method.getModifiers())) continue; // skip non public methods - + trie.index(method); - + addedElements++; - + String firstCharacter = method.getName().substring(0, 1); - - List methodList = this.map.get(firstCharacter); - - if (methodList == null) { + + List methodList = map.get(firstCharacter); + + if (methodList == null) + { methodList = new LinkedList(); - this.map.put(firstCharacter, methodList); + map.put(firstCharacter, methodList); } - + methodList.add(method); - - if (addedElements >= maxElements) { - - log.info ("indexed " + addedElements + " elements."); + + if (addedElements >= maxElements) + { + + log.info("indexed " + addedElements + " elements."); trie.simplifyIndex(); return; } - -// System.out.println(clazz.getCanonicalName() + " " -// + method.getName() + " ( " + parameterList + " )"); + +// System.out.println(clazz.getCanonicalName() + " " +// + method.getName() + " ( " + parameterList + " )"); } - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) + { // continue } } - } catch (SecurityException e) { + } + catch (SecurityException e) + { e.printStackTrace(); - } catch (IOException e) { + } + catch (IOException e) + { e.printStackTrace(); } - - log.info ("indexed " + addedElements + " elements."); + + log.info("indexed " + addedElements + " elements."); // compact the trie. - + TrieNodeInspectingVisitor visitor = new TrieNodeInspectingVisitor(); - + trie.visit(visitor); - + log.info("total trie nodes = " + visitor.getTotalNodes()); - + log.info("total consolidateable = " + visitor.getTotalConsolidateable()); - + trie.simplifyIndex(); - + visitor.reset(); - + trie.visit(visitor); - + log.info("total trie nodes = " + visitor.getTotalNodes()); - - - + + } - public List getListForFirstCharacter (String character) { - - return this.map.get(character); - + public List getListForFirstCharacter(String character) + { + + return map.get(character); + } - public PatriciaTrie getTrie() { + public PatriciaTrie getTrie() + { return trie; } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/model/LoadableDetachableMethodModel.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/model/LoadableDetachableMethodModel.java index 40605481ff..30b25d0395 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/model/LoadableDetachableMethodModel.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/model/LoadableDetachableMethodModel.java @@ -22,11 +22,11 @@ import org.apache.wicket.model.IModel; /** - * @author mocleirie so this model is used to load it back from - * the class loader as needed. + * @author mocleirie so this model is used to load it back from the class loader as needed. * */ -public class LoadableDetachableMethodModel implements IModel { +public class LoadableDetachableMethodModel implements IModel +{ /** * @@ -44,86 +44,105 @@ public class LoadableDetachableMethodModel implements IModel { /** * @param object */ - public LoadableDetachableMethodModel(Method object) { + public LoadableDetachableMethodModel(Method object) + { setObject(object); - + } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IModel#getObject() */ - public Method getObject() { - + public Method getObject() + { + if (attached) return transientMethod; - - else { + + else + { transientMethod = load(); attached = true; - + return transientMethod; } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IModel#setObject(java.lang.Object) */ - public void setObject(Method object) { - - this.attached = true; - this.transientMethod = object; - - if (object != null) { - this.className = object.getDeclaringClass().getName(); - this.methodName = object.getName(); + public void setObject(Method object) + { + + attached = true; + transientMethod = object; + + if (object != null) + { + className = object.getDeclaringClass().getName(); + methodName = object.getName(); } - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IDetachable#detach() */ - public void detach() { - - this.attached = false; - this.transientMethod = null; - + public void detach() + { + + attached = false; + transientMethod = null; + } - private Method load() { + private Method load() + { - if (this.className == null) + if (className == null) return null; Method m = null; - try { + try + { + + Class clazz = ClassLoader.getSystemClassLoader().loadClass(className); - Class clazz = ClassLoader.getSystemClassLoader().loadClass( - this.className); + for (Method method : clazz.getDeclaredMethods()) + { - for (Method method : clazz.getDeclaredMethods()) { - - if (method.getName().trim().equals(this.methodName.trim())) { + if (method.getName().trim().equals(methodName.trim())) + { m = method; break; } } - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) + { e.printStackTrace(); // fall through - } catch (SecurityException e) { + } + catch (SecurityException e) + { e.printStackTrace(); // fall through } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/page/HomePage.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/page/HomePage.java index 01d8716d11..83025e94de 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/page/HomePage.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/page/HomePage.java @@ -57,298 +57,335 @@ * @author mocleiri * */ -public class HomePage extends WebPage { +public class HomePage extends WebPage +{ + + + private TextField classNameFilterField; - - - private TextFieldclassNameFilterField; - private AutoCompletingTextField field; private LoadableDetachableMethodModel selectedMethodModel; private Label selectedMethodField; - + @SuppressWarnings("serial") - class MethodNameComparator extends DTAComparator { + class MethodNameComparator extends DTAComparator + { - - public MethodNameComparator(boolean ascending) { + + public MethodNameComparator(boolean ascending) + { super(ascending); } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.comparator.DTAComparator#compareAscending(java.lang.Object, java.lang.Object) + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.comparator.DTAComparator#compareAscending(java + * .lang.Object, java.lang.Object) */ @Override - protected int compareAscending(Method o1, Method o2) { + protected int compareAscending(Method o1, Method o2) + { String m1 = o1.getName(); String m2 = o2.getName(); return m1.compareTo(m2); } - - + + } - + @SuppressWarnings("serial") - class MethodClassNameComparator extends DTAComparator { - + class MethodClassNameComparator extends DTAComparator + { + /** * @param ascending */ - public MethodClassNameComparator(boolean ascending) { + public MethodClassNameComparator(boolean ascending) + { super(ascending); // TODO Auto-generated constructor stub } - - - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.comparator.DTAComparator#compareAscending(java.lang.Object, java.lang.Object) + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.comparator.DTAComparator#compareAscending(java + * .lang.Object, java.lang.Object) */ @Override - protected int compareAscending(Method o1, Method o2) { - + protected int compareAscending(Method o1, Method o2) + { + String className1 = o1.getDeclaringClass().getName(); String className2 = o2.getDeclaringClass().getName(); - + return className1.compareTo(className2); } - + } + /** * */ - public HomePage() { + public HomePage() + { super(); IModel stringModel = new Model(); - -classNameFilterField = new TextField("filter", new Model("")); - - - - - - + + classNameFilterField = new TextField("filter", new Model("")); + + add(classNameFilterField); final TrieDataProvider methodProvider = new TrieDataProvider( - new ITrieProvider() { + new ITrieProvider() + { - /* - * (non-Javadoc) - * - * @see - * org.wicketstuff.datatable_autocomplete.provider.ITrieProvider - * #provideTrie() - */ - public Trie provideTrie() { - return WicketApplication.getTrie(); - } + /* + * (non-Javadoc) + * + * @see org.wicketstuff.datatable_autocomplete.provider.ITrieProvider #provideTrie() + */ + public Trie provideTrie() + { + return WicketApplication.getTrie(); + } - }, - new ITrieFilter() { + }, new ITrieFilter() + { - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.trie.TrieFilter#isVisible(java.lang.Object) - */ - public boolean isVisible(Method word) { - - String classNameFilter = classNameFilterField.getModelObject(); - - if (classNameFilter == null || classNameFilter.trim().length() == 0) + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.trie.TrieFilter#isVisible(java.lang.Object + * ) + */ + public boolean isVisible(Method word) + { + + String classNameFilter = classNameFilterField.getModelObject(); + + if (classNameFilter == null || classNameFilter.trim().length() == 0) + return true; + + if (classNameFilter != null && classNameFilter.trim().length() > 0) + { + + String className = word.getDeclaringClass().getName(); + + word.getDeclaringClass().getName(); + + if (className.matches(".*" + classNameFilter + ".*")) return true; - - if (classNameFilter != null && classNameFilter.trim().length() > 0) { - - String className = word.getDeclaringClass().getName(); - - word.getDeclaringClass().getName(); - - if (className.matches(".*" + classNameFilter + ".*")) - return true; - } - - // all other cases - return false; - } - - }, - - stringModel, new IProviderSorter() { + + // all other cases + return false; + + } + + }, + + stringModel, new IProviderSorter() + { + + /* + * (non-Javadoc) + * + * @seeorg.wicketstuff.datatable_autocomplete.provider. IProviderSorter + * #getComparatorForProperty(org.apache.wicket + * .extensions.markup.html.repeater.util.SortParam) + */ + public Comparator getComparatorForProperty(SortParam sort) + { + + if (sort.getProperty().equals(MethodColumnType.CLASS_NAME)) + return new MethodNameComparator(true); + else + return new MethodClassNameComparator(true); + } + + }, new IModelProvider() + { + + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.provider.IModelProvider#model(java.lang + * .Object) + */ + public IModel model(Method obj) + { + + return new LoadableDetachableMethodModel(obj); + } + + }); + + + field = new AutoCompletingTextField("field", stringModel, new IColumn[] { + new MethodColumn("Method Name", MethodColumnType.METHOD_NAME), + new MethodColumn("Parameters", MethodColumnType.PARAMETERS), + new MethodColumn("Class Name", MethodColumnType.CLASS_NAME) }, methodProvider, + new ITableRowSelectionHandler() + { + + /** + * + */ + private static final long serialVersionUID = 8814576423898775282L; + + public void handleSelection(int index, Method modelObject, AjaxRequestTarget target) + { /* - * (non-Javadoc) + * If the matched row were being used to build part of another object. + * + * The assignment/setup of that other object can take place here. * - * @seeorg.wicketstuff.datatable_autocomplete.provider. - * IProviderSorter - * #getComparatorForProperty(org.apache.wicket - * .extensions.markup.html.repeater.util.SortParam) + * i.e. it occurs outside of the standard form processing logic. */ - public Comparator getComparatorForProperty( - SortParam sort) { - - if (sort.getProperty().equals(MethodColumnType.CLASS_NAME)) - return new MethodNameComparator(true); - else - return new MethodClassNameComparator(true); - } - }, new IModelProvider() { - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.provider.IModelProvider#model(java.lang.Object) - */ - public IModel model(Method obj) { - - return new LoadableDetachableMethodModel (obj); - } - - }); - - +// target.prependJavascript("alert('selected method = " +// + modelObject.getName() + "');"); + selectedMethodModel.setObject(modelObject); - field = new AutoCompletingTextField( - "field", stringModel, new IColumn[] { new MethodColumn( - "Method Name", MethodColumnType.METHOD_NAME), new MethodColumn("Parameters", MethodColumnType.PARAMETERS), new MethodColumn("Class Name", MethodColumnType.CLASS_NAME) }, methodProvider, - new ITableRowSelectionHandler() { + target.add(field); + target.add(selectedMethodField); - /** - * - */ - private static final long serialVersionUID = 8814576423898775282L; - - public void handleSelection(int index, Method modelObject, - AjaxRequestTarget target) { - - /* - * If the matched row were being used to build part of another object. - * - * The assignment/setup of that other object can take place here. - * - * i.e. it occurs outside of the standard form processing logic. - * - */ - - -// target.prependJavascript("alert('selected method = " -// + modelObject.getName() + "');"); - - selectedMethodModel.setObject(modelObject); - - target.add(HomePage.this.field); - target.add(HomePage.this.selectedMethodField); - - - - } - }, new IAutocompleteControlPanelProvider() { - - public Component getPanel(Component onChangeComponent, String controlPanelId) { - - return new MatchControlPanel(controlPanelId, methodProvider, onChangeComponent); - - } - }, new DefaultAutocompleteRenderingHints(25, true)); + + } + }, new IAutocompleteControlPanelProvider() + { + + public Component getPanel(Component onChangeComponent, String controlPanelId) + { + + return new MatchControlPanel(controlPanelId, methodProvider, onChangeComponent); + + } + }, new DefaultAutocompleteRenderingHints(25, true)); field.setOutputMarkupId(true); - - classNameFilterField.add(new AjaxFormComponentUpdatingBehavior("onchange") { - /* (non-Javadoc) - * @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget) + classNameFilterField.add(new AjaxFormComponentUpdatingBehavior("onchange") + { + + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache + * .wicket.ajax.AjaxRequestTarget) */ @Override - protected void onUpdate(AjaxRequestTarget target) { - - if (target != null) { + protected void onUpdate(AjaxRequestTarget target) + { + + if (target != null) + { target.add(field); } - - + + } - - + + }); - selectedMethodField = new Label("selectedMethod", selectedMethodModel = new LoadableDetachableMethodModel(null)); - + selectedMethodField = new Label("selectedMethod", + selectedMethodModel = new LoadableDetachableMethodModel(null)); + selectedMethodField.setOutputMarkupId(true); - + add(field); - + add(selectedMethodField); - - add(new Label ("numberOfMethods", new AbstractReadOnlyModel() { - /* (non-Javadoc) + add(new Label("numberOfMethods", new AbstractReadOnlyModel() + { + + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() */ @Override - public String getObject() { - + public String getObject() + { + final AtomicInteger counter = new AtomicInteger(0); - + return String.valueOf(WicketApplication.getTrie().size()); - - + + } - + })); - + Label freqLabel; - add(freqLabel = new Label ("alphabetFrequency", new AbstractReadOnlyModel() { + add(freqLabel = new Label("alphabetFrequency", new AbstractReadOnlyModel() + { - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() */ @Override - public String getObject() { - + public String getObject() + { + StringBuffer buf = new StringBuffer(); - - PatriciaTrietrie = WicketApplication.getTrie(); - - ListnextCharacterList = new LinkedList(); + + PatriciaTrie trie = WicketApplication.getTrie(); + + List nextCharacterList = new LinkedList(); nextCharacterList.addAll(trie.getNextNodeCharacterSet()); - + int count = 0; - + Collections.sort(nextCharacterList); - - for (String c : nextCharacterList) { - + + for (String c : nextCharacterList) + { + int size = trie.getWordList(c).size(); - + count += size; - - + + buf.append(c); buf.append(" (elements = "); buf.append(size); buf.append(")
"); - + } - - + + buf.append("

total = " + count + "
"); - + return buf.toString(); - + } - + })); - - - + + freqLabel.setEscapeModelStrings(false); - - - + } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/panel/MatchControlPanel.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/panel/MatchControlPanel.java index 9deee18d4f..571058ec2d 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/panel/MatchControlPanel.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/panel/MatchControlPanel.java @@ -34,111 +34,133 @@ /** * @author Michael O'Cleirigh (michael.ocleirigh@rivulet.ca) - * + * */ -public class MatchControlPanel extends Panel { +public class MatchControlPanel extends Panel +{ private static final String SUBSTRING_MATCH = "SUBSTRING_MATCH"; private static final String PREFIX_MATCH = "PREFIX_MATCH"; - + private TextField classNameFilterField; /** * @param id - * @param methodProvider - * @param onChangeComponent + * @param methodProvider + * @param onChangeComponent */ - public MatchControlPanel(String id, final TrieDataProvider methodProvider, final Component onChangeComponent) { + public MatchControlPanel(String id, final TrieDataProvider methodProvider, + final Component onChangeComponent) + { super(id); - -classNameFilterField = new TextField("filter", new Model("")); - -classNameFilterField = new TextField("filter", new Model("")); + classNameFilterField = new TextField("filter", new Model("")); + classNameFilterField = new TextField("filter", new Model("")); + add(classNameFilterField); -add(classNameFilterField); - - - classNameFilterField.add(new AjaxFormComponentUpdatingBehavior("onchange") { + classNameFilterField.add(new AjaxFormComponentUpdatingBehavior("onchange") + { - /* (non-Javadoc) - * @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget) + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache + * .wicket.ajax.AjaxRequestTarget) */ @Override - protected void onUpdate(AjaxRequestTarget target) { - - if (target != null) { + protected void onUpdate(AjaxRequestTarget target) + { + + if (target != null) + { target.add(onChangeComponent); } - - + + } - - + + }); - - Formform = new Form("settingsForm"); - + + Form form = new Form("settingsForm"); + form.add(classNameFilterField); - + DropDownChoice findMethodDDC; - form.add(findMethodDDC= new DropDownChoice("findMethod", new IModel() { + form.add(findMethodDDC = new DropDownChoice("findMethod", new IModel() + { /* * This model toggles the substring to prefix string behaviour of the TrieDataProvider. - * */ - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IModel#getObject() */ - public String getObject() { - + public String getObject() + { + if (methodProvider.isMatchAnyWhereInString()) return SUBSTRING_MATCH; else return PREFIX_MATCH; - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IModel#setObject(java.lang.Object) */ - public void setObject(String object) { - + public void setObject(String object) + { + if (object.equals(SUBSTRING_MATCH)) methodProvider.setMatchAnyWhereInString(true); else methodProvider.setMatchAnyWhereInString(false); - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IDetachable#detach() */ - public void detach() { - + public void detach() + { + // intentionally not implemented. - - }}, new ListModel(Arrays.asList(PREFIX_MATCH, SUBSTRING_MATCH))) { - - /* (non-Javadoc) - * @see org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications() - */ - @Override - protected boolean wantOnSelectionChangedNotifications() { - // cause the change to be recorded when the ddc is changed. - return true; - }}); - + + } + }, new ListModel(Arrays.asList(PREFIX_MATCH, SUBSTRING_MATCH))) + { + + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications + * () + */ + @Override + protected boolean wantOnSelectionChangedNotifications() + { + // cause the change to be recorded when the ddc is changed. + return true; + } + }); + add(form); - + } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/table/column/MethodColumn.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/table/column/MethodColumn.java index 99b5060a59..a9ed3f8165 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/table/column/MethodColumn.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/main/java/org/wicketstuff/datatable_autocomplete/web/table/column/MethodColumn.java @@ -29,95 +29,120 @@ /** * @author mocleiri * - * A Column that knows how to extract various attributes from the Method row model object. - * + * A Column that knows how to extract various attributes from the Method row model object. + * */ -public class MethodColumn extends AbstractColumn { +public class MethodColumn extends AbstractColumn +{ private final MethodColumnType type; - public static enum MethodColumnType { METHOD_NAME, CLASS_NAME, PARAMETERS }; + public static enum MethodColumnType + { + METHOD_NAME, CLASS_NAME, PARAMETERS + }; + /** * @param displayModel */ - public MethodColumn(IModel displayModel, MethodColumnType type) { + public MethodColumn(IModel displayModel, MethodColumnType type) + { super(displayModel); this.type = type; } - public MethodColumn (String display, MethodColumnType type) { - this (new Model(display), type); + public MethodColumn(String display, MethodColumnType type) + { + this(new Model(display), type); } - - /* (non-Javadoc) - * @see org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator#populateItem(org.apache.wicket.markup.repeater.Item, java.lang.String, org.apache.wicket.model.IModel) + + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator#populateItem(org + * .apache.wicket.markup.repeater.Item, java.lang.String, org.apache.wicket.model.IModel) */ - public void populateItem(Item> cellItem, String componentId, final IModel rowModel) { + public void populateItem(Item> cellItem, String componentId, + final IModel rowModel) + { - cellItem.add(new Label (componentId, new AbstractReadOnlyModel() { + cellItem.add(new Label(componentId, new AbstractReadOnlyModel() + { /** * */ private static final long serialVersionUID = 4014268651055132209L; - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.AbstractReadOnlyModel#getObject() */ @Override - public String getObject() { - + public String getObject() + { + Method m = rowModel.getObject(); - - switch (MethodColumn.this.type) { - case CLASS_NAME: - - return m.getDeclaringClass().getName(); - - case METHOD_NAME: - - return m.getName(); - - case PARAMETERS: - - String name = m.toString(); - - int startIndex = name.indexOf("("); - int endIndex = name.indexOf(")"); - - // exclude the brackets - String parameters = name.substring(startIndex+1, endIndex); - - // add better comma spacing - parameters = parameters.replace(",", ", "); - - return parameters; - default: - return ""; + + switch (type) + { + case CLASS_NAME : + + return m.getDeclaringClass().getName(); + + case METHOD_NAME : + + return m.getName(); + + case PARAMETERS : + + String name = m.toString(); + + int startIndex = name.indexOf("("); + int endIndex = name.indexOf(")"); + + // exclude the brackets + String parameters = name.substring(startIndex + 1, endIndex); + + // add better comma spacing + parameters = parameters.replace(",", ", "); + + return parameters; + default : + return ""; } - + } - + })); } - /* (non-Javadoc) - * @see org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn#getSortProperty() + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn#getSortProperty() */ @Override - public String getSortProperty() { + public String getSortProperty() + { return type.name(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn#isSortable() */ @Override - public boolean isSortable() { + public boolean isSortable() + { return true; } - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/data/TestClassLoaderExtractor.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/data/TestClassLoaderExtractor.java index 96dcd5ec2f..df96e55938 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/data/TestClassLoaderExtractor.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/data/TestClassLoaderExtractor.java @@ -29,12 +29,14 @@ * @author mocleiri */ -public class TestClassLoaderExtractor extends TestCase { +public class TestClassLoaderExtractor extends TestCase +{ /** * */ - public TestClassLoaderExtractor() { + public TestClassLoaderExtractor() + { super(); // TODO Auto-generated constructor stub } @@ -42,12 +44,14 @@ public TestClassLoaderExtractor() { /** * @param name */ - public TestClassLoaderExtractor(String name) { + public TestClassLoaderExtractor(String name) + { super(name); // TODO Auto-generated constructor stub } - public void testGetDetailsFromClassLoader() { + public void testGetDetailsFromClassLoader() + { System.out.print("in method"); @@ -55,7 +59,8 @@ public void testGetDetailsFromClassLoader() { Enumeration e = p.keys(); - while (e.hasMoreElements()) { + while (e.hasMoreElements()) + { Object key = e.nextElement(); Object value = p.get(key); @@ -66,7 +71,8 @@ public void testGetDetailsFromClassLoader() { } - public void testLoadAllClassNamesFromBootClass() throws IOException { + public void testLoadAllClassNamesFromBootClass() throws IOException + { String path = System.getProperty("sun.boot.class.path"); @@ -74,31 +80,34 @@ public void testLoadAllClassNamesFromBootClass() throws IOException { String targetPart = null; - for (String p : parts) { + for (String p : parts) + { - if (p.endsWith("rt.jar")) { + if (p.endsWith("rt.jar")) + { targetPart = p; break; } } JarFile jar = new JarFile(targetPart); - + Enumeration entries = jar.entries(); - while (entries.hasMoreElements()) { - + while (entries.hasMoreElements()) + { + JarEntry jarEntry = entries.nextElement(); if (!jarEntry.getName().contains(".class")) continue; - + Class clazz; - try { + try + { - String className = jarEntry.getName().replace("/", ".") - .replace(".class", ""); + String className = jarEntry.getName().replace("/", ".").replace(".class", ""); System.out.println(className); @@ -108,22 +117,26 @@ public void testLoadAllClassNamesFromBootClass() throws IOException { Method[] m = clazz.getDeclaredMethods(); - for (Method method : m) { + for (Method method : m) + { String parameterList = getParameters(method); - System.out.println(clazz.getCanonicalName() + " " - + method.getName() + " ( " + parameterList + " )"); + System.out.println(clazz.getCanonicalName() + " " + method.getName() + " ( " + + parameterList + " )"); } - } catch (ClassNotFoundException e) { + } + catch (ClassNotFoundException e) + { // continue } } } - private String getParameters(Method method) { + private String getParameters(Method method) + { StringBuffer buffer = new StringBuffer(); @@ -131,10 +144,11 @@ private String getParameters(Method method) { if (types.length == 0) return " "; - + int number = 1; - for (int i = 0; i < types.length - 1; i++) { + for (int i = 0; i < types.length - 1; i++) + { Class class1 = types[i]; buffer.append(class1.getName()); diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/trie/LargeTrieTestCase.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/trie/LargeTrieTestCase.java index 1587411f0c..bf3896f94e 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/trie/LargeTrieTestCase.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/trie/LargeTrieTestCase.java @@ -31,12 +31,13 @@ /** * @author mocleiriilding properly. * - * This done in the examples because of the availability of the - * TrieBuilder which can build a large dataset. + * This done in the examples because of the availability of the TrieBuilder which can build + * a large dataset. * * */ -public class LargeTrieTestCase extends TestCase { +public class LargeTrieTestCase extends TestCase +{ // note you will need to increase the heap size to run this example private static final int TRIE_SIZE = 125000; @@ -46,37 +47,42 @@ public class LargeTrieTestCase extends TestCase { /** * */ - public LargeTrieTestCase() { + public LargeTrieTestCase() + { super("LargeTrieTestCase"); init(); } /* */ - protected void init() { + protected void init() + { builder = new TrieBuilder(); builder.buildTrie(TRIE_SIZE); trie = builder.getTrie(); - + } - private Comparator methodComparator = new Comparator() { + private Comparator methodComparator = new Comparator() + { /* * (non-Javadoc) * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ - public int compare(Method o1, Method o2) { + public int compare(Method o1, Method o2) + { return o1.getName().compareTo(o2.getName()); } }; - public void testTrieStructure() { + public void testTrieStructure() + { int total = 0; @@ -85,7 +91,8 @@ public void testTrieStructure() { Collections.sort(nextCharacterList); - for (String c : nextCharacterList) { + for (String c : nextCharacterList) + { List wordList = trie.getWordList(c); @@ -94,7 +101,8 @@ public void testTrieStructure() { Collections.sort(wordList, methodComparator); Collections.sort(indexedList, methodComparator); - for (int i = 0; i < wordList.size(); i++) { + for (int i = 0; i < wordList.size(); i++) + { Method found = wordList.get(i); Method indexed = wordList.get(i); @@ -102,7 +110,8 @@ public void testTrieStructure() { String foundString = found.toString(); String indexedString = indexed.toString(); - if (!foundString.equals(indexedString)) { + if (!foundString.equals(indexedString)) + { System.out.println("found = " + found.toString()); System.out.println("as indexed = " + indexed.toString()); } @@ -111,52 +120,56 @@ public void testTrieStructure() { } - for (int i = wordList.size(); i < indexedList.size(); i++) { + for (int i = wordList.size(); i < indexedList.size(); i++) + { System.out.println("found = NONE"); - System.out.println("as indexed = " - + indexedList.get(i).toString()); + System.out.println("as indexed = " + indexedList.get(i).toString()); } // get the list of elements that are not in the union of the two lists Collection disjunctionList = CollectionUtils.disjunction(wordList, indexedList); - - for (Method method : disjunctionList) { - + + for (Method method : disjunctionList) + { + System.out.println("missing = " + method.toString()); } - + assertEquals(wordList.size(), indexedList.size()); } - + } - public void testSpecificWords() { + public void testSpecificWords() + { List wordList = trie.getWordList("assign"); - for (Method method : wordList) { + for (Method method : wordList) + { System.out.println("match = " + method.toString()); } - + System.out.println("assign matches " + wordList.size() + " methods."); - + wordList = trie.getWordList("access"); - for (Method method : wordList) { + for (Method method : wordList) + { System.out.println("match = " + method.toString()); } - + System.out.println("access matches " + wordList.size() + " methods."); - + } - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/tst/LargeTrieTestCase.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/tst/LargeTrieTestCase.java index 44ae5e6a95..1771f85bc3 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/tst/LargeTrieTestCase.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-examples/src/test/java/org/wicketstuff/datatable_autocomplete/tst/LargeTrieTestCase.java @@ -31,12 +31,13 @@ /** * @author mocleiri * - * This done in the examples because of the availability of the - * TrieBuilder which can build a large dataset. + * This done in the examples because of the availability of the TrieBuilder which can build + * a large dataset. * * */ -public class LargeTrieTestCase extends TestCase { +public class LargeTrieTestCase extends TestCase +{ // note you will need to increase the heap size to run this example private static final int TRIE_SIZE = 125000; @@ -46,47 +47,53 @@ public class LargeTrieTestCase extends TestCase { /** * */ - public LargeTrieTestCase() { + public LargeTrieTestCase() + { super("LargeTrieTestCase"); init(true); } /* */ - protected void init(boolean isSuffixTrie) { + protected void init(boolean isSuffixTrie) + { builder = new TernarySearchTrieBuilder(isSuffixTrie); builder.buildTrie(TRIE_SIZE); trie = builder.getTrie(); - + } - private Comparator methodComparator = new Comparator() { + private Comparator methodComparator = new Comparator() + { /* * (non-Javadoc) * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ - public int compare(Method o1, Method o2) { + public int compare(Method o1, Method o2) + { return o1.getName().compareTo(o2.getName()); } }; - public void testTrieStructure() { + public void testTrieStructure() + { int total = 0; List nextCharacterList = new LinkedList(); - + nextCharacterList.addAll(trie.getNextNodeCharacterSet()); Collections.sort(nextCharacterList); - for (String c : nextCharacterList) { + for (String c : nextCharacterList) + { List wordList = trie.getWordList(c, -1); @@ -95,7 +102,8 @@ public void testTrieStructure() { Collections.sort(wordList, methodComparator); Collections.sort(indexedList, methodComparator); - for (int i = 0; i < wordList.size(); i++) { + for (int i = 0; i < wordList.size(); i++) + { Method found = wordList.get(i); Method indexed = wordList.get(i); @@ -103,7 +111,8 @@ public void testTrieStructure() { String foundString = found.toString(); String indexedString = indexed.toString(); - if (!foundString.equals(indexedString)) { + if (!foundString.equals(indexedString)) + { System.out.println("found = " + found.toString()); System.out.println("as indexed = " + indexed.toString()); } @@ -112,52 +121,56 @@ public void testTrieStructure() { } - for (int i = wordList.size(); i < indexedList.size(); i++) { + for (int i = wordList.size(); i < indexedList.size(); i++) + { System.out.println("found = NONE"); - System.out.println("as indexed = " - + indexedList.get(i).toString()); + System.out.println("as indexed = " + indexedList.get(i).toString()); } // get the list of elements that are not in the union of the two lists Collection disjunctionList = CollectionUtils.disjunction(wordList, indexedList); - - for (Method method : disjunctionList) { - + + for (Method method : disjunctionList) + { + System.out.println("missing = " + method.toString()); } - + assertEquals(wordList.size(), indexedList.size()); } - + } - public void testSpecificWords() { + public void testSpecificWords() + { List wordList = trie.getWordList("assign", -1); - for (Method method : wordList) { + for (Method method : wordList) + { System.out.println("match = " + method.toString()); } - + System.out.println("assign matches " + wordList.size() + " methods."); - + wordList = trie.getWordList("access", -1); - for (Method method : wordList) { + for (Method method : wordList) + { System.out.println("match = " + method.toString()); } - + System.out.println("access matches " + wordList.size() + " methods."); - + } - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTGraph.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTGraph.java index 9d45d97ac7..b51da72fce 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTGraph.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTGraph.java @@ -24,67 +24,81 @@ /** * @author mocleiri * - * A JUNG graph to represent the TernarySearchTrie - * + * A JUNG graph to represent the TernarySearchTrie + * */ -public class TSTGraph extends DirectedSparseMultigraph, String> { +public class TSTGraph extends DirectedSparseMultigraph, String> +{ /** * @param order */ - public TSTGraph(TernarySearchTrietrie) { + public TSTGraph(TernarySearchTrie trie) + { super(); - + TernaryNode rootNode = trie.getRoot(); - + addVertex(rootNode); - - - buildNode (rootNode); - - - + + + buildNode(rootNode); + + } - private void buildNode(TernaryNode node) { - - node.visit(new TernaryNodeVisitor() { + private void buildNode(TernaryNode node) + { - /* (non-Javadoc) + node.visit(new TernaryNodeVisitor() + { + + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#postVisit() */ - public void postVisit() { + public void postVisit() + { // TODO Auto-generated method stub - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#preVisit() */ - public void preVisit() { + public void preVisit() + { // TODO Auto-generated method stub - + } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#visit(org.wicketstuff.datatable_autocomplete.tst.TernaryNode) + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.tst.TernaryNodeVisitor#visit(org.wicketstuff + * .datatable_autocomplete.tst.TernaryNode) */ - public void visit(TernaryNode node) { - + public void visit(TernaryNode node) + { + TernaryNode parent = node.getParentNode(); - - if (parent != null) { + + if (parent != null) + { addEdge("", node.getParentNode(), node); - - + + } - + node.visit(this); } - + }); } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizer.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizer.java index b0b9079b63..1ee069fa09 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizer.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizer.java @@ -30,40 +30,44 @@ /** * @author mocleiri - * + * */ -public class TSTVisualizer { +public class TSTVisualizer +{ + - - - /** - * @param title - * @param graph + * @param title + * @param graph * */ - public TSTVisualizer(String title, TSTGraph graph) { + public TSTVisualizer(String title, TSTGraph graph) + { super(); - + this.graph = graph; - + // The Layout is parameterized by the vertex and edge types - Layout, String> layout = new TreeLayout, String>(new DelegateForest, String>(graph)); -// layout.setSize(new Dimension(300,300)); // sets the initial size of the space + Layout, String> layout = new TreeLayout, String>( + new DelegateForest, String>(graph)); +// layout.setSize(new Dimension(300,300)); // sets the initial size of the space // The BasicVisualizationServer is parameterized by the edge types - BasicVisualizationServer, String> vv = - new BasicVisualizationServer, String> (layout); - vv.setPreferredSize(new Dimension(350,350)); //Sets the viewing area size - + BasicVisualizationServer, String> vv = new BasicVisualizationServer, String>( + layout); + vv.setPreferredSize(new Dimension(350, 350)); // Sets the viewing area size + vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); - - vv.getRenderContext().setVertexLabelTransformer(new Transformer, String>() { - - public String transform(TernaryNode node) { - return node.getCharacter(); - } - }); - + + vv.getRenderContext().setVertexLabelTransformer( + new Transformer, String>() + { + + public String transform(TernaryNode node) + { + return node.getCharacter(); + } + }); + JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); @@ -71,8 +75,7 @@ public String transform(TernaryNode node) { frame.setVisible(true); } - private TSTGraphgraph; - - + private TSTGraph graph; + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TreeVisualizer.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TreeVisualizer.java index 423f619c63..273764d5e6 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TreeVisualizer.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TreeVisualizer.java @@ -31,43 +31,46 @@ /** * @author mocleiri - * + * */ -public class TreeVisualizer { +public class TreeVisualizer +{ /** - * @param graph + * @param graph * */ - public TreeVisualizer(String title, DirectedGraph, String> graph) { + public TreeVisualizer(String title, DirectedGraph, String> graph) + { super(); - - + // The Layout is parameterized by the vertex and edge types - Layout, String> layout = new TreeLayout, String>(new DelegateForest, String>(graph)); -// layout.setSize(new Dimension(300,300)); // sets the initial size of the space + Layout, String> layout = new TreeLayout, String>( + new DelegateForest, String>(graph)); +// layout.setSize(new Dimension(300,300)); // sets the initial size of the space // The BasicVisualizationServer is parameterized by the edge types - BasicVisualizationServer, String> vv = - new BasicVisualizationServer, String> (layout); - vv.setPreferredSize(new Dimension(350,350)); //Sets the viewing area size - + BasicVisualizationServer, String> vv = new BasicVisualizationServer, String>( + layout); + vv.setPreferredSize(new Dimension(350, 350)); // Sets the viewing area size + vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); - - vv.getRenderContext().setVertexLabelTransformer(new Transformer, String>() { - - public String transform(TrieNode node) { + + vv.getRenderContext().setVertexLabelTransformer(new Transformer, String>() + { + + public String transform(TrieNode node) + { return node.getCharacter(); } - }); - + }); + JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieGraph.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieGraph.java index dc530c75c9..516305bbe0 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieGraph.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieGraph.java @@ -25,48 +25,42 @@ /** * @author mocleiri - * + * */ -public class TrieGraph extends DirectedSparseMultigraph, String> { +public class TrieGraph extends DirectedSparseMultigraph, String> +{ private final AtomicLong counter = new AtomicLong(); - + /** * @param order */ - public TrieGraph(PatriciaTrietrie) { + public TrieGraph(PatriciaTrie trie) + { super(); - + addVertex(trie.getRoot()); - - buildGraph (trie.getRoot()); - - - - - - - - + + buildGraph(trie.getRoot()); + + } - private void buildGraph(TrieNode root) { + private void buildGraph(TrieNode root) + { List> nodeList = root.getOrderedNodeList(); - - for (TrieNode trieNode : nodeList) { - + + for (TrieNode trieNode : nodeList) + { + addEdge(String.valueOf(counter.addAndGet(1)), root, trieNode); - + buildGraph(trieNode); } - - + + } - - - - } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizer.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizer.java index 5cfd4aaa14..d6b0882655 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizer.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizer.java @@ -39,7 +39,8 @@ * * */ -public class TrieVisualizer { +public class TrieVisualizer +{ private TrieGraph graph; @@ -48,44 +49,46 @@ public class TrieVisualizer { * @param graph * */ - public TrieVisualizer(String title, TrieGraph graph, - TrieVisualizerLayout layoutType) { + public TrieVisualizer(String title, TrieGraph graph, TrieVisualizerLayout layoutType) + { this.graph = graph; // The Layout is parameterized by the vertex and edge types Layout, String> layout = null; - - switch (layoutType) { - case TREE: - layout = new TreeLayout, String>( + + switch (layoutType) + { + case TREE : + layout = new TreeLayout, String>( new DelegateForest, String>(graph)); - break; - - case DAG: - layout = new DAGLayout, String>(graph); - break; + break; + + case DAG : + layout = new DAGLayout, String>(graph); + break; } - - + + // layout.setSize(new Dimension(300,300)); // sets the initial size of // the space // The BasicVisualizationServer is parameterized by the edge types VisualizationViewer, String> vv = new VisualizationViewer, String>( - layout); + layout); vv.setPreferredSize(new Dimension(350, 350)); // Sets the viewing area // size vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); - vv.getRenderContext().setVertexLabelTransformer( - new Transformer, String>() { + vv.getRenderContext().setVertexLabelTransformer(new Transformer, String>() + { - public String transform(TrieNode node) { - return node.getCharacter(); - } - }); + public String transform(TrieNode node) + { + return node.getCharacter(); + } + }); // Create a graph mouse and add it to the visualization component DefaultModalGraphMouse, String> gm = new DefaultModalGraphMouse, String>(); @@ -99,7 +102,8 @@ public String transform(TrieNode node) { frame.setVisible(true); } - public TrieVisualizer(String title, PatriciaTrie trie, TrieVisualizerLayout layoutType) { + public TrieVisualizer(String title, PatriciaTrie trie, TrieVisualizerLayout layoutType) + { this(title, new TrieGraph(trie), layoutType); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerLayout.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerLayout.java index 9abe1ca73a..407bd32a8e 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerLayout.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/main/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerLayout.java @@ -4,6 +4,7 @@ * @author mocleiri * */ -public enum TrieVisualizerLayout { +public enum TrieVisualizerLayout +{ TREE, DAG; } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizerMain.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizerMain.java index ecf530ee71..b4c3c8950d 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizerMain.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TSTVisualizerMain.java @@ -7,46 +7,52 @@ * @author mocleiri * */ -public class TSTVisualizerMain { +public class TSTVisualizerMain +{ - public static void main(String[] args) { + public static void main(String[] args) + { TernarySearchTrie trie = new TernarySearchTrie( - new AbstractTrieConfiguration() { - - /* - * (non-Javadoc) - * - * @seeorg.wicketstuff.datatable_autocomplete.trie. - * ITrieConfiguration#getWord(java.lang.Object) - */ - public String getWord(String ctx) { - return ctx; - } - - /* - * (non-Javadoc) - * - * @seeorg.wicketstuff.datatable_autocomplete.trie. - * ITrieConfiguration#isIndexCaseSensitive() - */ - public boolean isIndexCaseSensitive() { - // TODO Auto-generated method stub - return false; - } - - /* - * (non-Javadoc) - * - * @seeorg.wicketstuff.datatable_autocomplete.trie. - * ITrieConfiguration#isSuffixTree() - */ - public boolean isSuffixTree() { - // TODO Auto-generated method stub - return false; - } - - }); + new AbstractTrieConfiguration() + { + + /* + * (non-Javadoc) + * + * @seeorg.wicketstuff.datatable_autocomplete.trie. + * ITrieConfiguration#getWord(java.lang.Object) + */ + public String getWord(String ctx) + { + return ctx; + } + + /* + * (non-Javadoc) + * + * @seeorg.wicketstuff.datatable_autocomplete.trie. + * ITrieConfiguration#isIndexCaseSensitive() + */ + public boolean isIndexCaseSensitive() + { + // TODO Auto-generated method stub + return false; + } + + /* + * (non-Javadoc) + * + * @seeorg.wicketstuff.datatable_autocomplete.trie. + * ITrieConfiguration#isSuffixTree() + */ + public boolean isSuffixTree() + { + // TODO Auto-generated method stub + return false; + } + + }); trie.index("transit"); trie.index("trip"); diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerMain.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerMain.java index 25a03aff9f..b12dd7b042 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerMain.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete-test/src/test/java/org/wicketstuff/datatable_autocomplete/tree/TrieVisualizerMain.java @@ -7,58 +7,64 @@ * @author mocleiri * */ -public class TrieVisualizerMain { +public class TrieVisualizerMain +{ /** * */ - public TrieVisualizerMain() { + public TrieVisualizerMain() + { // TODO Auto-generated constructor stub } - public static void main(String[] args) { + public static void main(String[] args) + { PatriciaTrie trie = new PatriciaTrie( - new AbstractTrieConfiguration() { + new AbstractTrieConfiguration() + { - /* - * (non-Javadoc) - * - * @seeorg.wicketstuff.datatable_autocomplete.trie. - * ITrieConfiguration#getWord(java.lang.Object) - */ - public String getWord(String ctx) { - return ctx; - } + /* + * (non-Javadoc) + * + * @seeorg.wicketstuff.datatable_autocomplete.trie. + * ITrieConfiguration#getWord(java.lang.Object) + */ + public String getWord(String ctx) + { + return ctx; + } - /* - * (non-Javadoc) - * - * @seeorg.wicketstuff.datatable_autocomplete.trie. - * ITrieConfiguration#isIndexCaseSensitive() - */ - public boolean isIndexCaseSensitive() { - // TODO Auto-generated method stub - return false; - } + /* + * (non-Javadoc) + * + * @seeorg.wicketstuff.datatable_autocomplete.trie. + * ITrieConfiguration#isIndexCaseSensitive() + */ + public boolean isIndexCaseSensitive() + { + // TODO Auto-generated method stub + return false; + } - /* - * (non-Javadoc) - * - * @seeorg.wicketstuff.datatable_autocomplete.trie. - * ITrieConfiguration#isSuffixTree() - */ - public boolean isSuffixTree() { - // TODO Auto-generated method stub - return false; - } + /* + * (non-Javadoc) + * + * @seeorg.wicketstuff.datatable_autocomplete.trie. + * ITrieConfiguration#isSuffixTree() + */ + public boolean isSuffixTree() + { + // TODO Auto-generated method stub + return false; + } - }); + }); trie.index("transit"); trie.index("trip"); - new TrieVisualizer("Patrcia Trie", trie, TrieVisualizerLayout.TREE); diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/behaviour/AutoCompletingBehavior.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/behaviour/AutoCompletingBehavior.java index 636ca9a60e..1e1f68adf9 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/behaviour/AutoCompletingBehavior.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/behaviour/AutoCompletingBehavior.java @@ -35,48 +35,48 @@ * @author mocleiri * */ -public class AutoCompletingBehavior extends AJAXAutoCompleteBehavior { +public class AutoCompletingBehavior extends AJAXAutoCompleteBehavior +{ /** * */ - private static final long serialVersionUID = 7722548233439995560L; - private static final Logger log = LoggerFactory - .getLogger(AutoCompletingBehavior.class); - private TextField textModel; - private final HiddenField selectedContextField; + private static final long serialVersionUID = 7722548233439995560L; + private static final Logger log = LoggerFactory.getLogger(AutoCompletingBehavior.class); + private TextField textModel; + private final HiddenField selectedContextField; - private class AutoCompletingDependencyProcessor extends - AbstractAutoCompleteDependencyProcessor { + private class AutoCompletingDependencyProcessor extends AbstractAutoCompleteDependencyProcessor + { /** * */ - private static final long serialVersionUID = 5497206492287083574L; - private final AutoCompletingPanel autoCompletingPanel; + private static final long serialVersionUID = 5497206492287083574L; + private final AutoCompletingPanel autoCompletingPanel; - private final String callbackName; + private final String callbackName; /** * @param names * @param components * @param duration */ - public AutoCompletingDependencyProcessor(String callbackName, - TextField textField, - AutoCompletingPanel autoCompletingPanel, Duration duration) { + public AutoCompletingDependencyProcessor(String callbackName, TextField textField, + AutoCompletingPanel autoCompletingPanel, Duration duration) + { - super(new String[] { callbackName }, new Component[] { textField }, - duration); + super(new String[] { callbackName }, new Component[] { textField }, duration); this.callbackName = callbackName; this.autoCompletingPanel = autoCompletingPanel; } - - public void onAjaxUpdate(Request request, AjaxRequestTarget target) { + + public void onAjaxUpdate(Request request, AjaxRequestTarget target) + { IRequestParameters params = request.getRequestParameters(); - + StringValue value = params.getParameterValue(callbackName); textModel.setModelObject(value.toString()); @@ -94,53 +94,51 @@ public void onAjaxUpdate(Request request, AjaxRequestTarget target) { }; /** - * A special behaviour to generate a GET request for changes to the - * textComponent provided. + * A special behaviour to generate a GET request for changes to the textComponent provided. * * @param selectedContextField * the field where the id value of the selected row is placed * @param textComponent - * the component whose value is updated on the request (this - * behavoir should be added to textComponent). + * the component whose value is updated on the request (this behavoir should be added + * to textComponent). * @param referenceAutoCompletingPanel - * the completing panel that needs to be updated when the - * textfield value changes. + * the completing panel that needs to be updated when the textfield value changes. * @param milisecondDurationBetweenRequests - * the number of mmiliseconds that must elapse before a - * subsequent get request will be sent from the client. + * the number of mmiliseconds that must elapse before a subsequent get request will + * be sent from the client. */ public AutoCompletingBehavior(HiddenField selectedContextField, - TextField textComponent, - AutoCompletingPanel referenceAutoCompletingPanel, - long milisecondDurationBetweenRequests) { + TextField textComponent, AutoCompletingPanel referenceAutoCompletingPanel, + long milisecondDurationBetweenRequests) + { super("onkeyup"); this.selectedContextField = selectedContextField; - this.textModel = textComponent; + textModel = textComponent; - super.setDependencyProcessor(new AutoCompletingDependencyProcessor( - "value", textComponent, referenceAutoCompletingPanel, Duration - .milliseconds(milisecondDurationBetweenRequests))); + super.setDependencyProcessor(new AutoCompletingDependencyProcessor("value", textComponent, + referenceAutoCompletingPanel, Duration.milliseconds(milisecondDurationBetweenRequests))); } public AutoCompletingBehavior(TextField textComponent, - AutoCompletingPanel referenceAutoCompletingPanel, - long milisecondDurationBetweenRequests) { + AutoCompletingPanel referenceAutoCompletingPanel, long milisecondDurationBetweenRequests) + { - this(null, textComponent, referenceAutoCompletingPanel, - milisecondDurationBetweenRequests); + this(null, textComponent, referenceAutoCompletingPanel, milisecondDurationBetweenRequests); } @Override - protected void addAdditionalJavaScript(List eventScripts) { + protected void addAdditionalJavaScript(List eventScripts) + { - if (selectedContextField != null) { + if (selectedContextField != null) + { // add in the clear script to be the first part of the element. - eventScripts.add(0, "Wicket.$(" - + selectedContextField.getMarkupId() + ").value='CLEAR'"); + eventScripts.add(0, "Wicket.$(" + selectedContextField.getMarkupId() + + ").value='CLEAR'"); } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAAjaxFallbackButton.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAAjaxFallbackButton.java index 4606ef0165..e681b27081 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAAjaxFallbackButton.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAAjaxFallbackButton.java @@ -37,57 +37,60 @@ * * It will only render if the action is defined. * - * It also allows for appending an onclick string. useful for poping an - * alert is state is missing on the client side. + * It also allows for appending an onclick string. useful for poping an alert is state is + * missing on the client side. * * Will by default handle the refresh on the invoking form. * */ -public class DTAAjaxFallbackButton extends AjaxFallbackButton implements - DTAButtonProvider, IAjaxIndicatorAware { +public class DTAAjaxFallbackButton extends AjaxFallbackButton implements DTAButtonProvider, + IAjaxIndicatorAware +{ /** * */ - private static final long serialVersionUID = 1829825558587963971L; + private static final long serialVersionUID = 1829825558587963971L; - private static final Logger log = LoggerFactory - .getLogger(DTAAjaxFallbackButton.class); + private static final Logger log = LoggerFactory.getLogger(DTAAjaxFallbackButton.class); - private IFormOnSubmitAction submitAction = null; + private IFormOnSubmitAction submitAction = null; - private IAjaxCallDecorator ajaxCallDecorator = null; + private IAjaxCallDecorator ajaxCallDecorator = null; - private IModel preAjaxScriptModel = null; + private IModel preAjaxScriptModel = null; - private Form form = null; + private Form form = null; - private boolean actionDeterminesVisibility = true; + private boolean actionDeterminesVisibility = true; - private int callCounter = 0; + private int callCounter = 0; - private final AjaxIndicatorAppender indicatorAppender = new AjaxIndicatorAppender(); + private final AjaxIndicatorAppender indicatorAppender = new AjaxIndicatorAppender(); - class DTAButtonAjaxCallDecorator extends AjaxCallDecorator { + class DTAButtonAjaxCallDecorator extends AjaxCallDecorator + { /** * */ private static final long serialVersionUID = -8601609694500314263L; - private final IModel decoratingStringModel; + private final IModel decoratingStringModel; /** * @param delegate */ - public DTAButtonAjaxCallDecorator(IModel decoratingStringModel) { + public DTAButtonAjaxCallDecorator(IModel decoratingStringModel) + { this.decoratingStringModel = decoratingStringModel; } - @Override - public CharSequence decorateScript(Component c, CharSequence script) { - + @Override + public CharSequence decorateScript(Component c, CharSequence script) + { + String preDecorator = decoratingStringModel.getObject(); @@ -103,14 +106,15 @@ public CharSequence decorateScript(Component c, CharSequence script) { * @param actionDeterminesVisibility * the actionDeterminesVisibility to set * - * Normally the existance of an action is used to control the - * visiblilty of the button. + * Normally the existance of an action is used to control the visiblilty of the + * button. * - * setting this to true will have the default behaviour. Setting - * to false will allow visibilty to be controlled externally. + * setting this to true will have the default behaviour. Setting to false will allow + * visibilty to be controlled externally. * */ - public void setActionDeterminesVisibility(boolean actionDeterminesVisibility) { + public void setActionDeterminesVisibility(boolean actionDeterminesVisibility) + { this.actionDeterminesVisibility = actionDeterminesVisibility; } @@ -119,7 +123,8 @@ public void setActionDeterminesVisibility(boolean actionDeterminesVisibility) { * @param id */ public DTAAjaxFallbackButton(String id, String label, Form form, - IFormOnSubmitAction submitAction) { + IFormOnSubmitAction submitAction) + { super(id, new Model(label), form); this.form = form; @@ -129,8 +134,8 @@ public DTAAjaxFallbackButton(String id, String label, Form form, } - public DTAAjaxFallbackButton(String id, String label, Form form, - IModel preAjaxScriptModel) { + public DTAAjaxFallbackButton(String id, String label, Form form, IModel preAjaxScriptModel) + { this(id, label, form); this.form = form; @@ -139,29 +144,32 @@ public DTAAjaxFallbackButton(String id, String label, Form form, } - public DTAAjaxFallbackButton(String id, IModel labelModel, Form form) { + public DTAAjaxFallbackButton(String id, IModel labelModel, Form form) + { super(id, labelModel, form); this.form = form; add(indicatorAppender); } - public DTAAjaxFallbackButton(String id, String label, Form form) { + public DTAAjaxFallbackButton(String id, String label, Form form) + { this(id, new Model(label), form); add(indicatorAppender); } - + /* * (non-Javadoc) * * @see org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton#getForm() */ @Override - public Form getForm() { + public Form getForm() + { - return this.form; + return form; } @@ -169,7 +177,8 @@ public Form getForm() { * @param form * the form to set */ - public void setForm(Form form) { + public void setForm(Form form) + { this.form = form; this.form.setOutputMarkupId(true); @@ -178,13 +187,12 @@ public void setForm(Form form) { /* * (non-Javadoc) * - * @see - * org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton#onSubmit(org - * .apache.wicket.ajax.AjaxRequestTarget, - * org.apache.wicket.markup.html.form.Form) + * @see org.apache.wicket.ajax.markup.html.form.AjaxFallbackButton#onSubmit(org + * .apache.wicket.ajax.AjaxRequestTarget, org.apache.wicket.markup.html.form.Form) */ @Override - protected final void onSubmit(AjaxRequestTarget target, Form form) { + protected final void onSubmit(AjaxRequestTarget target, Form form) + { callCounter++; @@ -194,28 +202,31 @@ protected final void onSubmit(AjaxRequestTarget target, Form form) { } @Override - protected void onError(AjaxRequestTarget target, Form form) { - + protected void onError(AjaxRequestTarget target, Form form) + { + if (submitAction != null) - submitAction.onError (target, form); - + submitAction.onError(target, form); + } + /* * (non-Javadoc) * - * @seeorg.apache.wicket.ajax.markup.html.form.AjaxFallbackButton# - * getAjaxCallDecorator() + * @seeorg.apache.wicket.ajax.markup.html.form.AjaxFallbackButton# getAjaxCallDecorator() */ @Override - protected IAjaxCallDecorator getAjaxCallDecorator() { - - if (this.ajaxCallDecorator == null) { - if (this.preAjaxScriptModel != null) { - this.ajaxCallDecorator = new DTAButtonAjaxCallDecorator( - this.preAjaxScriptModel); + protected IAjaxCallDecorator getAjaxCallDecorator() + { + + if (ajaxCallDecorator == null) + { + if (preAjaxScriptModel != null) + { + ajaxCallDecorator = new DTAButtonAjaxCallDecorator(preAjaxScriptModel); } } - return this.ajaxCallDecorator; + return ajaxCallDecorator; } @@ -225,16 +236,18 @@ protected IAjaxCallDecorator getAjaxCallDecorator() { * @see org.apache.wicket.Component#onBeforeRender() */ @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { - if (actionDeterminesVisibility) { - if (this.submitAction == null) + if (actionDeterminesVisibility) + { + if (submitAction == null) setVisible(false); else setVisible(true); } - this.callCounter = 0; + callCounter = 0; super.onBeforeRender(); } @@ -243,18 +256,21 @@ protected void onBeforeRender() { * @param submitAction * the submitAction to set */ - public void setSubmitAction(IFormOnSubmitAction submitAction) { + public void setSubmitAction(IFormOnSubmitAction submitAction) + { this.submitAction = submitAction; } - public DTAAjaxFallbackButton getButton() { + public DTAAjaxFallbackButton getButton() + { - if (!getId().equals(DTAButtonProvider.BUTTON_ID)) { + if (!getId().equals(DTAButtonProvider.BUTTON_ID)) + { // this is a problem - throw new RuntimeException("ID of button (" + getId() - + " != DTAButtonProvider.BUTTON_ID"); + throw new RuntimeException("ID of button (" + getId() + + " != DTAButtonProvider.BUTTON_ID"); } return this; @@ -263,10 +279,10 @@ public DTAAjaxFallbackButton getButton() { /* * (non-Javadoc) * - * @see - * org.apache.wicket.ajax.IAjaxIndicatorAware#getAjaxIndicatorMarkupId() + * @see org.apache.wicket.ajax.IAjaxIndicatorAware#getAjaxIndicatorMarkupId() */ - public String getAjaxIndicatorMarkupId() { + public String getAjaxIndicatorMarkupId() + { return indicatorAppender.getMarkupId(); @@ -278,7 +294,8 @@ public String getAjaxIndicatorMarkupId() { * @see org.apache.wicket.markup.html.form.FormComponent#onDetach() */ @Override - protected void onDetach() { + protected void onDetach() + { super.onDetach(); @@ -287,7 +304,5 @@ protected void onDetach() { } - - } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButton.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButton.java index 9a76b83cb7..a5f159f81e 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButton.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButton.java @@ -26,96 +26,105 @@ /** * @author mocleiri * - * Data Table Autocomplete button that extends the standard wicket button to support IOnFormSubmitAction actions. - * + * Data Table Autocomplete button that extends the standard wicket button to support + * IOnFormSubmitAction actions. + * */ -public class DTAButton extends Button implements DTAButtonProvider { +public class DTAButton extends Button implements DTAButtonProvider +{ /** * */ - private static final long serialVersionUID = 1829825558587963971L; + private static final long serialVersionUID = 1829825558587963971L; + + private static final Logger log = LoggerFactory.getLogger(DTAButton.class); + + private IFormOnSubmitAction submitAction = null; - private static final Logger log = LoggerFactory.getLogger(DTAButton.class); - - private IFormOnSubmitAction submitAction = null; - - /** * @param id */ - public DTAButton(String id, String label, IFormOnSubmitAction submitAction) { - - - super(id, new Model (label)); + public DTAButton(String id, String label, IFormOnSubmitAction submitAction) + { + + + super(id, new Model(label)); this.submitAction = submitAction; - + } - public DTAButton(String id, String label) { + public DTAButton(String id, String label) + { + + this(id, label, null); - this (id, label, null); - } - - /* (non-Javadoc) - * @see org.apache.wicket.markup.html.form.Button#onComponentTag(org.apache.wicket.markup.ComponentTag) + + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.markup.html.form.Button#onComponentTag(org.apache.wicket.markup.ComponentTag + * ) */ @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { // this allows the button to be used in a repeater tag.setName("input"); tag.setHasNoCloseTag(true); - - - + + super.onComponentTag(tag); - + tag.getAttributes().put("type", "submit"); } - - - - - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.markup.html.form.Button#onSubmit() */ @Override - public void onSubmit() { + public void onSubmit() + { + - - if (submitAction != null) submitAction.onSubmit(null, getForm()); - - + } - - + + /** - * @param submitAction the submitAction to set + * @param submitAction + * the submitAction to set */ - public void setSubmitAction(IFormOnSubmitAction submitAction) { - + public void setSubmitAction(IFormOnSubmitAction submitAction) + { + this.submitAction = submitAction; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.apache.wicket.Component#onBeforeRender() */ @Override - protected void onBeforeRender() { - + protected void onBeforeRender() + { + /* * Defaults to hidden if there is no action defined. */ - if (this.submitAction == null) + if (submitAction == null) setVisible(false); else setVisible(true); @@ -123,22 +132,18 @@ protected void onBeforeRender() { super.onBeforeRender(); } - public Button getButton() { + public Button getButton() + { - if (!getId().equals(DTAButtonProvider.BUTTON_ID)) { + if (!getId().equals(DTAButtonProvider.BUTTON_ID)) + { // this is a problem - throw new RuntimeException ("ID of button ("+getId()+" != DTAButtonProvider.BUTTON_ID"); + throw new RuntimeException("ID of button (" + getId() + + " != DTAButtonProvider.BUTTON_ID"); } - + return this; } - - - - - - - } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButtonProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButtonProvider.java index a96385d14f..edacb19057 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButtonProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/button/DTAButtonProvider.java @@ -20,19 +20,20 @@ /** * @author mocleiri - * + * */ -public interface DTAButtonProvider { - +public interface DTAButtonProvider +{ + public static final String BUTTON_ID = "button"; - + /** * return a button with its id set as BUTTON_ID * * @param id * @return the instantiated button. */ - public Button getButton (); - + public Button getButton(); + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/comparator/DTAComparator.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/comparator/DTAComparator.java index 148415a720..3a79991175 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/comparator/DTAComparator.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/comparator/DTAComparator.java @@ -24,40 +24,49 @@ /** * @author mocleiri * - * Used for sortable columns in a DTATable. clicking on the link will toggle between sort ascending and sort descending. - * + * Used for sortable columns in a DTATable. clicking on the link will toggle between sort + * ascending and sort descending. + * */ -public abstract class DTAComparator implements Comparator, IClusterable { +public abstract class DTAComparator implements Comparator, IClusterable +{ /** * */ - private static final long serialVersionUID = -4782414530696776582L; + private static final long serialVersionUID = -4782414530696776582L; - private static final org.slf4j.Logger log = LoggerFactory.getLogger(DTAComparator.class); + private static final org.slf4j.Logger log = LoggerFactory.getLogger(DTAComparator.class); private boolean ascending = true; + /** * */ - public DTAComparator(boolean ascending) { - this.ascending = ascending; + public DTAComparator(boolean ascending) + { + this.ascending = ascending; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ - public final int compare(E o1, E o2) { + public final int compare(E o1, E o2) + { - if (ascending) { - return compareAscending (o1, o2); + if (ascending) + { + return compareAscending(o1, o2); } - else { + else + { // switch the results since we want the opposite - - int test = compareAscending(o1, o2); - + + int test = compareAscending(o1, o2); + if (test >= 1) return -1; else if (test <= -1) @@ -67,7 +76,7 @@ else if (test <= -1) } } - + /** * @param o1 * @param o2 @@ -75,5 +84,5 @@ else if (test <= -1) */ protected abstract int compareAscending(E o1, E o2); - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/AbstractFormOnSubmitAction.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/AbstractFormOnSubmitAction.java index 3e774f6a19..0c14240fc0 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/AbstractFormOnSubmitAction.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/AbstractFormOnSubmitAction.java @@ -21,25 +21,28 @@ /** * @author mocleiri - * - * Base form on submit action. The onError callback is part of the new 1.5 form event processing behaviour. - * What needs to be implemented for our purposes is not yet determined. + * + * Base form on submit action. The onError callback is part of the new 1.5 form event + * processing behaviour. What needs to be implemented for our purposes is not yet + * determined. * */ -public abstract class AbstractFormOnSubmitAction implements IFormOnSubmitAction { +public abstract class AbstractFormOnSubmitAction implements IFormOnSubmitAction +{ /** * */ - public AbstractFormOnSubmitAction() { + public AbstractFormOnSubmitAction() + { // TODO Auto-generated constructor stub } - public void onError(AjaxRequestTarget target, Form form) { + public void onError(AjaxRequestTarget target, Form form) + { // TODO Auto-generated method stub - + } - -} +} diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/IFormOnSubmitAction.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/IFormOnSubmitAction.java index e7f47fe03b..1656a34f11 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/IFormOnSubmitAction.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/form/action/IFormOnSubmitAction.java @@ -20,21 +20,21 @@ import org.apache.wicket.markup.html.form.Form; - /** * @author mocleiri * - * A way to implement the submission logic outside of the submitting component. - * + * A way to implement the submission logic outside of the submitting component. + * */ -public interface IFormOnSubmitAction extends IClusterable { +public interface IFormOnSubmitAction extends IClusterable +{ - public void onSubmit (AjaxRequestTarget target, Form form); + public void onSubmit(AjaxRequestTarget target, Form form); /** - * Listener method invoked on form submit with errors - */ + * Listener method invoked on form submit with errors + */ public void onError(AjaxRequestTarget target, Form form); - - + + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/model/MarkupIDInStringModel.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/model/MarkupIDInStringModel.java index a56d2df5ad..a711852144 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/model/MarkupIDInStringModel.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/model/MarkupIDInStringModel.java @@ -28,102 +28,119 @@ /** * @author mocleiri * - * Used for situations like rendering javascript method calls where we need the markupid for the component. + * Used for situations like rendering javascript method calls where we need the markupid for + * the component. + * + * The markupid is not available until the component is on a page so we need the model to + * defer the question until rendering time which by definition the context will exist. * - * The markupid is not available until the component is on a page so we need the model to defer the question until rendering time which by - * definition the context will exist. - * */ -public class MarkupIDInStringModel implements IModel { +public class MarkupIDInStringModel implements IModel +{ /** * */ - private static final long serialVersionUID = 548831417478329002L; + private static final long serialVersionUID = 548831417478329002L; + + private static final Logger log = LoggerFactory.getLogger(MarkupIDInStringModel.class); - private static final Logger log = LoggerFactory - .getLogger(MarkupIDInStringModel.class); - /** * Used by child classes to define the markupid placeholder in their attached template */ - public static final String MARKUP_ID_TAG = ":markupID:"; - - private final String template; - private final Component target; - private final Map> templateArgMap; + public static final String MARKUP_ID_TAG = ":markupID:"; + + private final String template; + private final Component target; + private final Map> templateArgMap; + - /** * */ - public MarkupIDInStringModel(String template, Component target, Map>templateArgMap) { + public MarkupIDInStringModel(String template, Component target, + Map> templateArgMap) + { super(); this.template = template; this.target = target; this.templateArgMap = templateArgMap; - + target.setOutputMarkupId(true); } - - public MarkupIDInStringModel (String template, Component target) { - this (template, target, new LinkedHashMap>()); - + + public MarkupIDInStringModel(String template, Component target) + { + this(template, target, new LinkedHashMap>()); + } - - protected void storeTemplateArgument (String alias, IModel valueModel) { - this.templateArgMap.put(alias, valueModel); + + protected void storeTemplateArgument(String alias, IModel valueModel) + { + templateArgMap.put(alias, valueModel); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IModel#getObject() */ - public final String getObject() { + public final String getObject() + { /* - * Render the string using the template and replacing the content as dictated by the parameters. + * Render the string using the template and replacing the content as dictated by the + * parameters. */ - + String renderedMarkupIDString = template; - + if (target != null) - renderedMarkupIDString = renderedMarkupIDString.replaceAll(MARKUP_ID_TAG, target.getMarkupId()); - - for (String id : templateArgMap.keySet()) { - + renderedMarkupIDString = renderedMarkupIDString.replaceAll(MARKUP_ID_TAG, + target.getMarkupId()); + + for (String id : templateArgMap.keySet()) + { + IModel replacement = templateArgMap.get(id); - + String replacementValue = null; - + if (replacement == null || replacement.getObject() == null) replacementValue = ""; else replacementValue = replacement.getObject().toString(); - + renderedMarkupIDString = renderedMarkupIDString.replaceAll(id, replacementValue); } - + return renderedMarkupIDString; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IModel#setObject(java.lang.Object) */ - public void setObject(String object) { + public void setObject(String object) + { // does nothing } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.IDetachable#detach() */ - public void detach() { + public void detach() + { // does nothing } - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AJAXAutoCompleteBehavior.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AJAXAutoCompleteBehavior.java index 2f7751cb8f..b8e9d6743d 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AJAXAutoCompleteBehavior.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AJAXAutoCompleteBehavior.java @@ -33,26 +33,25 @@ /** * @author mocleiri - * - * Originally the intent was to use this to allow multiple fields to - * drive search for results. - * - * However it has been modified so that it will work with just a single - * field. - * - * The idea is that changes to the search field will be encoded onto the - * url which will then be processed accordingly without having to submit - * anything. - * - * + * + * Originally the intent was to use this to allow multiple fields to drive search for + * results. + * + * However it has been modified so that it will work with just a single field. + * + * The idea is that changes to the search field will be encoded onto the url which will then + * be processed accordingly without having to submit anything. + * + * */ -public class AJAXAutoCompleteBehavior extends - AjaxEventBehavior { +public class AJAXAutoCompleteBehavior extends AjaxEventBehavior +{ /** * @param event */ - public AJAXAutoCompleteBehavior(String event) { + public AJAXAutoCompleteBehavior(String event) + { super(event); @@ -62,52 +61,49 @@ public AJAXAutoCompleteBehavior(String event) { /** * */ - private static final long serialVersionUID = -3314379544248117565L; + private static final long serialVersionUID = -3314379544248117565L; - private static final Logger log = LoggerFactory - .getLogger(AJAXAutoCompleteBehavior.class); + private static final Logger log = LoggerFactory.getLogger(AJAXAutoCompleteBehavior.class); // controls how the dependencies are appended to the behaviour callback URL and then parsed // on the server side within the behaviour processing action. - private AutoCompleteDependencyProcessor dependencyProcessor; + private AutoCompleteDependencyProcessor dependencyProcessor; /** * */ - public AJAXAutoCompleteBehavior(String event, - AutoCompleteDependencyProcessor processor) { + public AJAXAutoCompleteBehavior(String event, AutoCompleteDependencyProcessor processor) + { super(event); - this.dependencyProcessor = processor; + dependencyProcessor = processor; } - - /** - * @param dependencyProcessor the dependencyProcessor to set + * @param dependencyProcessor + * the dependencyProcessor to set */ - protected void setDependencyProcessor( - AutoCompleteDependencyProcessor dependencyProcessor) { + protected void setDependencyProcessor(AutoCompleteDependencyProcessor dependencyProcessor) + { this.dependencyProcessor = dependencyProcessor; } - /* * (non-Javadoc) - * - * @see - * org.apache.wicket.ajax.AjaxEventBehavior#onEvent(org.apache.wicket.ajax + * + * @see org.apache.wicket.ajax.AjaxEventBehavior#onEvent(org.apache.wicket.ajax * .AjaxRequestTarget) */ @Override - protected final void onEvent(AjaxRequestTarget target) { + protected final void onEvent(AjaxRequestTarget target) + { /* * First we apply any of the parameters to the data provider @@ -122,36 +118,40 @@ protected final void onEvent(AjaxRequestTarget target) { /* * (non-Javadoc) - * - * @see - * org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getFailureScript() + * + * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getFailureScript() */ @Override - protected CharSequence getFailureScript() { + protected CharSequence getFailureScript() + { return "Wicket.Log.info ('on failure script');"; } /* * (non-Javadoc) - * - * @see - * org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getSuccessScript() + * + * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getSuccessScript() */ @Override - protected CharSequence getSuccessScript() { + protected CharSequence getSuccessScript() + { return "Wicket.Log.info ('on success script');"; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getCallbackScript() */ @Override - protected final CharSequence getCallbackScript() { + protected final CharSequence getCallbackScript() + { /* - * Encode the callback script appending to the url the current client side value of the component values. + * Encode the callback script appending to the url the current client side value of the + * component values. */ CharSequence baseUrl = super.getCallbackUrl(); @@ -159,28 +159,26 @@ protected final CharSequence getCallbackScript() { List parameterList = new ArrayList(); - for (String parameter : dependencyProcessor - .getQueryParameterToComponentMap().keySet()) { + for (String parameter : dependencyProcessor.getQueryParameterToComponentMap().keySet()) + { - Component c = dependencyProcessor.getQueryParameterToComponentMap() - .get(parameter); + Component c = dependencyProcessor.getQueryParameterToComponentMap().get(parameter); - String adjustedUrl = "&" + parameter + "='+Wicket.$('" - + c.getMarkupId() + "').value"; + String adjustedUrl = "&" + parameter + "='+Wicket.$('" + c.getMarkupId() + "').value"; parameterList.add(adjustedUrl); } - - callbackScript = StringUtils.join (new StringBuffer(callbackScript), parameterList, "+'").toString(); + callbackScript = StringUtils.join(new StringBuffer(callbackScript), parameterList, "+'") + .toString(); String script = "wicketAjaxGet('" + callbackScript + ");"; if (dependencyProcessor.getThrottingDuration() != null) - return AbstractDefaultAjaxBehavior.throttleScript(script, - getComponent().getMarkupId(), dependencyProcessor.getThrottingDuration()); + return AbstractDefaultAjaxBehavior.throttleScript(script, getComponent().getMarkupId(), + dependencyProcessor.getThrottingDuration()); else return script; @@ -197,25 +195,24 @@ protected final void onComponentTag(final ComponentTag tag) if (myComponent.isEnabled() && myComponent.isEnableAllowed()) { - ListeventScripts = new LinkedList(); + List eventScripts = new LinkedList(); eventScripts.add(getEventHandler().toString()); - addAdditionalJavaScript (eventScripts); + addAdditionalJavaScript(eventScripts); tag.put(super.getEvent(), StringUtils.join(eventScripts, ";")); } } - - /** * Allows subclasses to adjust the ordering of the scripts and to add in additional scripts. - * + * * @param eventScripts */ - protected void addAdditionalJavaScript(List eventScripts) { + protected void addAdditionalJavaScript(List eventScripts) + { } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AbstractAutoCompleteDependencyProcessor.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AbstractAutoCompleteDependencyProcessor.java index ee17ac7407..2a6783108a 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AbstractAutoCompleteDependencyProcessor.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AbstractAutoCompleteDependencyProcessor.java @@ -27,64 +27,69 @@ /** * @author mocleiri * - * A base implementation for the autocomplete dependency processor. + * A base implementation for the autocomplete dependency processor. * - * Note that extendors define the components to be updated + * Note that extendors define the components to be updated */ public abstract class AbstractAutoCompleteDependencyProcessor implements - AutoCompleteDependencyProcessor { + AutoCompleteDependencyProcessor +{ /** * */ private static final long serialVersionUID = -7293448644441764951L; - private Duration duration = null; - private Map queryParameterToComponentMap; + private Duration duration = null; + private Map queryParameterToComponentMap; /** * */ - public AbstractAutoCompleteDependencyProcessor(String[] names, Component[] components) { + public AbstractAutoCompleteDependencyProcessor(String[] names, Component[] components) + { super(); - + queryParameterToComponentMap = new LinkedHashMap(); - - for (int i = 0; i < components.length; i++) { + + for (int i = 0; i < components.length; i++) + { String parameter = names[i]; Component component = components[i]; - + // to guarantee that the markupid will be generated component.setOutputMarkupId(true); component.setOutputMarkupPlaceholderTag(true); - + queryParameterToComponentMap.put(parameter, component); - + } - + } - public AbstractAutoCompleteDependencyProcessor(String[] names, Component[] components, Duration duration) { - this (names, components); + public AbstractAutoCompleteDependencyProcessor(String[] names, Component[] components, + Duration duration) + { + this(names, components); this.duration = duration; } - - private static final Logger log = LoggerFactory - .getLogger(AbstractAutoCompleteDependencyProcessor.class); - - - public Map getQueryParameterToComponentMap() { + private static final Logger log = LoggerFactory.getLogger(AbstractAutoCompleteDependencyProcessor.class); + + + public Map getQueryParameterToComponentMap() + { return queryParameterToComponentMap; } - - public Duration getThrottingDuration() { - return duration ; + public Duration getThrottingDuration() + { + + return duration; } - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompleteDependencyProcessor.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompleteDependencyProcessor.java index 968b8fc042..8395734d2e 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompleteDependencyProcessor.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompleteDependencyProcessor.java @@ -30,19 +30,18 @@ * * */ -public interface AutoCompleteDependencyProcessor extends IClusterable { +public interface AutoCompleteDependencyProcessor extends IClusterable +{ /** * - * @return the list of dependencies to push through with the get - * request. + * @return the list of dependencies to push through with the get request. * */ public Map getQueryParameterToComponentMap(); - public void onAjaxUpdate(Request request, - AjaxRequestTarget target); - + public void onAjaxUpdate(Request request, AjaxRequestTarget target); + /** * * @return the duration to throttle the request (null if no throttling should be performed) diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingPanel.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingPanel.java index d31bf2406b..e3d69bf861 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingPanel.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingPanel.java @@ -42,15 +42,15 @@ * @author mocleiri * */ -public class AutoCompletingPanel extends Panel { +public class AutoCompletingPanel extends Panel +{ /** * */ private static final long serialVersionUID = -6173248750432002480L; - private static final org.slf4j.Logger log = LoggerFactory - .getLogger(AutoCompletingPanel.class); + private static final org.slf4j.Logger log = LoggerFactory.getLogger(AutoCompletingPanel.class); private SelectableTableViewPanel viewPanel; @@ -59,10 +59,10 @@ public class AutoCompletingPanel extends Panel { private boolean initialRenderMode = false; private static final ResourceReference CSS = new CompressedResourceReference( - AutoCompletingPanel.class, "dta_auto_complete_overlay.css"); + AutoCompletingPanel.class, "dta_auto_complete_overlay.css"); private static final ResourceReference TABLE_CSS = new CompressedResourceReference( - AutoCompletingPanel.class, "dta_autocomplete_table.css"); + AutoCompletingPanel.class, "dta_autocomplete_table.css"); private Label theLabel; @@ -72,10 +72,12 @@ public class AutoCompletingPanel extends Panel { * @param id * @param ctx */ - public AutoCompletingPanel(String id, IModel fieldStringModel, - IColumn[] columns, SortableDataProvider aliasDataProvider, - ITableRowSelectionHandler rowSelectionHandler, IAutocompleteControlPanelProvider controlPanelProvider, - IAutocompleteRenderingHints renderingHints) { + public AutoCompletingPanel(String id, IModel fieldStringModel, IColumn[] columns, + SortableDataProvider aliasDataProvider, + ITableRowSelectionHandler rowSelectionHandler, + IAutocompleteControlPanelProvider controlPanelProvider, + IAutocompleteRenderingHints renderingHints) + { super(id, new Model()); @@ -84,7 +86,8 @@ public AutoCompletingPanel(String id, IModel fieldStringModel, this.provider = aliasDataProvider; - add(new Behavior() { + add(new Behavior() + { /** * @@ -92,39 +95,44 @@ public AutoCompletingPanel(String id, IModel fieldStringModel, private static final long serialVersionUID = 1L; @Override - public void renderHead(Component c, IHeaderResponse response) { + public void renderHead(Component c, IHeaderResponse response) + { response.renderCSSReference(CSS); - }}); - + } + }); + Component controlPanel = controlPanelProvider.getPanel(this, "controlPanel"); - + if (controlPanel == null) controlPanel = new EmptyPanel("controlPanel"); - + add(controlPanel); - viewPanel = new SelectableTableViewPanel("view", TABLE_CSS, - "dta_data_table", "{title}", columns, aliasDataProvider, - false, rowSelectionHandler, renderingHints); + viewPanel = new SelectableTableViewPanel("view", TABLE_CSS, "dta_data_table", "{title}", + columns, aliasDataProvider, false, rowSelectionHandler, renderingHints); DTADataTable dataTable = viewPanel.getDataTable(); // redo the table on each update. dataTable.setItemReuseStrategy(new DefaultItemReuseStrategy()); -// dataTable.setDisableRowHighlight(true); +// dataTable.setDisableRowHighlight(true); add(viewPanel); - if (renderingHints.isVisibleOnZeroMatches()) { + if (renderingHints.isVisibleOnZeroMatches()) + { viewPanel.setHideIfNoResults(false); - } else { + } + else + { viewPanel.setHideIfNoResults(true); } add(theLabel = new Label("label_close", "Close")); - add(closeButton = new Button("close_button", new Model("x")) { + add(closeButton = new Button("close_button", new Model("x")) + { /** * @@ -132,7 +140,8 @@ public void renderHead(Component c, IHeaderResponse response) { private static final long serialVersionUID = 1L; @Override - public void onSubmit() { + public void onSubmit() + { // does nothing since it is a client side only action. } @@ -141,7 +150,8 @@ public void onSubmit() { setOutputMarkupId(true); setOutputMarkupPlaceholderTag(true); - closeButton.add(new AttributeModifier("onclick", true, new AbstractReadOnlyModel() { + closeButton.add(new AttributeModifier("onclick", true, new AbstractReadOnlyModel() + { /** * @@ -149,33 +159,38 @@ public void onSubmit() { private static final long serialVersionUID = 1L; @Override - public String getObject() { - return "document.getElementById('" + AutoCompletingPanel.this.getMarkupId() + "').style.display='none';"; + public String getObject() + { + return "document.getElementById('" + AutoCompletingPanel.this.getMarkupId() + + "').style.display='none';"; } - + })); - + } - public AutoCompletingPanel(String id, IModel fieldStringModel, - int resultsToShow, IColumn[] columns, - SortableDataProvider dataProvider, - ITableRowSelectionHandler rowSelectionHandler, IAutocompleteControlPanelProvider controlPanelProvider, boolean paginationEnabled) { - - this (id, fieldStringModel, columns, dataProvider, rowSelectionHandler, controlPanelProvider, new DefaultAutocompleteRenderingHints(resultsToShow, paginationEnabled)); + public AutoCompletingPanel(String id, IModel fieldStringModel, int resultsToShow, + IColumn[] columns, SortableDataProvider dataProvider, + ITableRowSelectionHandler rowSelectionHandler, + IAutocompleteControlPanelProvider controlPanelProvider, boolean paginationEnabled) + { + + this(id, fieldStringModel, columns, dataProvider, rowSelectionHandler, + controlPanelProvider, new DefaultAutocompleteRenderingHints(resultsToShow, + paginationEnabled)); } /* * (non-Javadoc) * - * @see - * org.apache.wicket.markup.html.form.FormComponentPanel#onComponentTag( + * @see org.apache.wicket.markup.html.form.FormComponentPanel#onComponentTag( * org.apache.wicket.markup.ComponentTag) */ @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { tag.put("class", "dta_wicket_ajax_panel_overlay"); @@ -183,11 +198,11 @@ protected void onComponentTag(ComponentTag tag) { } /** - * if value is true then on the inial non ajax rendering this component will - * be invisible. + * if value is true then on the inial non ajax rendering this component will be invisible. * */ - public void setInitialRenderDisabledMode(boolean value) { + public void setInitialRenderDisabledMode(boolean value) + { this.initialRenderMode = value; @@ -199,13 +214,16 @@ public void setInitialRenderDisabledMode(boolean value) { * @see org.apache.wicket.Component#onBeforeRender() */ @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { - if (!initialRenderMode) { + if (!initialRenderMode) + { this.viewPanel.updateVisibility(); setVisible(this.viewPanel.isVisible()); - } else + } + else setVisible(false); super.onBeforeRender(); diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingTextField.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingTextField.java index a26f7b29c0..410fcc1347 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingTextField.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/AutoCompletingTextField.java @@ -32,19 +32,18 @@ /** * @author mocleiri - * + * * R is the type used in the look up. */ -public class AutoCompletingTextField extends Panel { - +public class AutoCompletingTextField extends Panel +{ /** * */ private static final long serialVersionUID = -5234331727415699325L; - private static final Logger log = LoggerFactory - .getLogger(AutoCompletingTextField.class); + private static final Logger log = LoggerFactory.getLogger(AutoCompletingTextField.class); private AutoCompletingPanel autoCompletingPanel; private final IAutocompleteRenderingHints renderingHints; @@ -53,7 +52,7 @@ public class AutoCompletingTextField extends Panel { private TextField searchField; /** - * + * * @param id * @param searchFieldModel * model that contains the prefix used in filtering the results. @@ -64,25 +63,25 @@ public class AutoCompletingTextField extends Panel { * @param provider * provides the data for the autocompleting panel. * @param rowSelectionHandler - * This is what handles the assignment of the selected row - * somewhere. + * This is what handles the assignment of the selected row somewhere. * @param usePagination * allows turning on or off the pagination controls. */ public AutoCompletingTextField(String id, IModel searchFieldModel, - IColumn[] columns, - SortableDataProvider provider, - ITableRowSelectionHandler rowSelectionHandler, IAutocompleteControlPanelProvider controlPanelProvider, - IAutocompleteRenderingHints renderingHints) { + IColumn[] columns, SortableDataProvider provider, + ITableRowSelectionHandler rowSelectionHandler, + IAutocompleteControlPanelProvider controlPanelProvider, + IAutocompleteRenderingHints renderingHints) + { - this(id, searchFieldModel, columns, provider, - rowSelectionHandler, controlPanelProvider, 300, renderingHints); + this(id, searchFieldModel, columns, provider, rowSelectionHandler, controlPanelProvider, + 300, renderingHints); } /** - * + * * @param id * @param searchFieldModel * model that contains the prefix used in filtering the results. @@ -93,20 +92,20 @@ public AutoCompletingTextField(String id, IModel searchFieldModel, * @param provider * provides the data for the autocompleting panel. * @param rowSelectionHandler - * This is what handles the assignment of the selected row - * somewhere. + * This is what handles the assignment of the selected row somewhere. * @param usePagination * allows turning on or off the pagination controls. * @param throttlingDelay - * Controls the number of miliseconds to wait after a keystroke - * before issuing the get request to the server. + * Controls the number of miliseconds to wait after a keystroke before issuing the + * get request to the server. * @param renderingHints2 */ public AutoCompletingTextField(String id, IModel searchFieldModel, - IColumn[] columns, - SortableDataProvider provider, - ITableRowSelectionHandler rowSelectionHandler, IAutocompleteControlPanelProvider controlPanelProvider, - int throttlingDelay, IAutocompleteRenderingHints renderingHints) { + IColumn[] columns, SortableDataProvider provider, + ITableRowSelectionHandler rowSelectionHandler, + IAutocompleteControlPanelProvider controlPanelProvider, int throttlingDelay, + IAutocompleteRenderingHints renderingHints) + { // dummy model. // we are a formcomponentpanel so that we are traversed during form @@ -115,42 +114,44 @@ public AutoCompletingTextField(String id, IModel searchFieldModel, this.searchFieldModel = searchFieldModel; this.renderingHints = renderingHints; - searchField = new TextField("searchField", - searchFieldModel); + searchField = new TextField("searchField", searchFieldModel); - searchField.add(new AttributeModifier("autocomplete", true, - new Model("off"))); + searchField.add(new AttributeModifier("autocomplete", true, new Model("off"))); autoCompletingPanel = new AutoCompletingPanel("autoCompletingPanel", - searchField.getModel(), columns, provider, - rowSelectionHandler, controlPanelProvider, renderingHints); + searchField.getModel(), columns, provider, rowSelectionHandler, controlPanelProvider, + renderingHints); add(searchField); add(autoCompletingPanel); searchField.add(autoCompletingBehaviour = new AutoCompletingBehavior(searchField, - autoCompletingPanel, throttlingDelay)); + autoCompletingPanel, throttlingDelay)); - add(new AjaxLink("showLink") { + add(new AjaxLink("showLink") + { /** * */ private static final long serialVersionUID = -5603196048089462726L; - /* (non-Javadoc) - * @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget) + /* + * (non-Javadoc) + * + * @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax. + * AjaxRequestTarget) */ @Override - public void onClick(AjaxRequestTarget target) { + public void onClick(AjaxRequestTarget target) + { String callbackScript = autoCompletingBehaviour.getCallbackScript().toString(); target.prependJavaScript(callbackScript); - } }); @@ -159,23 +160,29 @@ public void onClick(AjaxRequestTarget target) { /* * (non-Javadoc) - * + * * @see org.apache.wicket.Component#onBeforeRender() */ @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { - if (renderingHints != null) { + if (renderingHints != null) + { - if (renderingHints.isVisibleOnRender()) { + if (renderingHints.isVisibleOnRender()) + { this.autoCompletingPanel.setInitialRenderDisabledMode(false); } - else { + else + { this.autoCompletingPanel.setInitialRenderDisabledMode(true); } - } else { + } + else + { // default to hide the autocomplete panel on no input. this.autoCompletingPanel.setInitialRenderDisabledMode(true); } @@ -187,19 +194,21 @@ protected void onBeforeRender() { * @return the AJAX listener url for the autocompleting behaviour * @see org.apache.wicket.behavior.AbstractAjaxBehavior#getCallbackUrl() */ - public String getAutoCompleteCallbackUrl() { + public String getAutoCompleteCallbackUrl() + { return autoCompletingBehaviour.getCallbackUrl().toString(); } /** * Allows behaviours to be placed on the inner text field. - * + * * This can be used to add an onblur action to push results to the server side. - * + * * @param beh */ - public void addBehaviorToAutoCompletingTextField (Behavior beh) { + public void addBehaviorToAutoCompletingTextField(Behavior beh) + { this.searchField.add(beh); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/DefaultAutocompleteRenderingHints.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/DefaultAutocompleteRenderingHints.java index 465047a266..7575f6ecb7 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/DefaultAutocompleteRenderingHints.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/DefaultAutocompleteRenderingHints.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ - + package org.wicketstuff.datatable_autocomplete.panel; import org.wicketstuff.datatable_autocomplete.table.DefaultDTATableRenderingHints; @@ -22,12 +22,13 @@ /** * @author mocleiri * - * Default implementation of the hints. + * Default implementation of the hints. + * * - * */ public class DefaultAutocompleteRenderingHints extends DefaultDTATableRenderingHints implements - IAutocompleteRenderingHints { + IAutocompleteRenderingHints +{ /** * @@ -38,29 +39,37 @@ public class DefaultAutocompleteRenderingHints extends DefaultDTATableRenderingH * @param pageSize * @param paginationEnabled */ - public DefaultAutocompleteRenderingHints(int pageSize, - boolean paginationEnabled) { + public DefaultAutocompleteRenderingHints(int pageSize, boolean paginationEnabled) + { super(pageSize, paginationEnabled); } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.panel.IAutocompleteRenderingHints#isVisibleOnRender(java.lang.String) + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.panel.IAutocompleteRenderingHints#isVisibleOnRender + * (java.lang.String) */ - public boolean isVisibleOnRender() { - // default is to be invisible on initial render. becoming visible only after the ajax requests are sent. + public boolean isVisibleOnRender() + { + // default is to be invisible on initial render. becoming visible only after the ajax +// requests are sent. return false; } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.panel.IAutocompleteRenderingHints#isVisibleOnZeroMatches() + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.panel.IAutocompleteRenderingHints#isVisibleOnZeroMatches + * () */ - public boolean isVisibleOnZeroMatches() { + public boolean isVisibleOnZeroMatches() + { // default is to be visible when there are zero matches. return true; } - - - } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteControlPanelProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteControlPanelProvider.java index 83b712a9d9..d491c5beea 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteControlPanelProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteControlPanelProvider.java @@ -21,13 +21,14 @@ /** * @author mocleiri * - * The autocomplete panel provides a space just above the results table where extra controls can be placed to finetune - * the operation of the autocompletion process. + * The autocomplete panel provides a space just above the results table where extra controls + * can be placed to finetune the operation of the autocompletion process. + * + * This interface provides a way to create the component to use as the control panel. * - * This interface provides a way to create the component to use as the control panel. - * */ -public interface IAutocompleteControlPanelProvider extends IClusterable { +public interface IAutocompleteControlPanelProvider extends IClusterable +{ Component getPanel(Component container, String controlPanelId); diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteRenderingHints.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteRenderingHints.java index 929514b50e..0aa1a06103 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteRenderingHints.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/panel/IAutocompleteRenderingHints.java @@ -20,11 +20,12 @@ /** * @author mocleiri * - * Provides hints to the AutoComplete components about what do do on the - * initial render, no match and no input cases. + * Provides hints to the AutoComplete components about what do do on the initial render, no + * match and no input cases. * */ -public interface IAutocompleteRenderingHints extends IDTATableRenderingHints { +public interface IAutocompleteRenderingHints extends IDTATableRenderingHints +{ /** * @return true if the autocompleting panel should be visible. diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/DefaultModelProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/DefaultModelProvider.java index ec8703016e..64e4f94c01 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/DefaultModelProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/DefaultModelProvider.java @@ -23,24 +23,28 @@ /** * @author mocleiri - * + * */ -public class DefaultModelProvider implements IModelProvider { +public class DefaultModelProvider implements IModelProvider +{ /** * */ - public DefaultModelProvider() { + public DefaultModelProvider() + { // TODO Auto-generated constructor stub } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.provider.IModelProvider#model(java.lang.Object) */ - public IModel model(C obj) { + public IModel model(C obj) + { return new Model(obj); } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/EmptyAutocompleteControlPanelProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/EmptyAutocompleteControlPanelProvider.java index c7a72b73ca..abbbc4c17b 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/EmptyAutocompleteControlPanelProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/EmptyAutocompleteControlPanelProvider.java @@ -22,10 +22,11 @@ /** * @author mocleiri - * + * */ -public class EmptyAutocompleteControlPanelProvider implements - IAutocompleteControlPanelProvider, IClusterable { +public class EmptyAutocompleteControlPanelProvider implements IAutocompleteControlPanelProvider, + IClusterable +{ /** * @@ -35,14 +36,20 @@ public class EmptyAutocompleteControlPanelProvider implements /** * */ - public EmptyAutocompleteControlPanelProvider() { + public EmptyAutocompleteControlPanelProvider() + { // TODO Auto-generated constructor stub } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.panel.IAutocompleteControlPanelProvider#getPanel(java.lang.String) + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.panel.IAutocompleteControlPanelProvider#getPanel(java + * .lang.String) */ - public Component getPanel(Component updateOnChangeComponent, String controlPanelId) { + public Component getPanel(Component updateOnChangeComponent, String controlPanelId) + { return new EmptyPanel(controlPanelId); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IModelProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IModelProvider.java index 46090278b5..6da0cd3195 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IModelProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IModelProvider.java @@ -21,14 +21,15 @@ /** * @author mocleiri - * + * */ -public interface IModelProvider extends IClusterable { +public interface IModelProvider extends IClusterable +{ /** * * @param obj - * @return create a new model for the object provided. Typically a loadable detachable model. + * @return create a new model for the object provided. Typically a loadable detachable model. */ - public IModelmodel (C obj); + public IModel model(C obj); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IProviderSorter.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IProviderSorter.java index 89719d7b6d..6e3cde089a 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IProviderSorter.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/IProviderSorter.java @@ -24,16 +24,17 @@ /** * @author mocleiri * - * Defines how a trie list data can be sorted + * Defines how a trie list data can be sorted */ -public interface IProviderSorter extends IClusterable { +public interface IProviderSorter extends IClusterable +{ /** - * @param sort the string value of the Model for C Type.name + * @param sort + * the string value of the Model for C Type.name * @return the comparator for sorting a list of C by the property name given. */ Comparator getComparatorForProperty(SortParam sort); - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/ITrieProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/ITrieProvider.java index 8f002753c9..b060af9097 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/ITrieProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/ITrieProvider.java @@ -20,21 +20,22 @@ import org.wicketstuff.datatable_autocomplete.trie.Trie; - /** * @author mocleiri * - * A mechanism to supply a Trie from either a static or non-serializable context. + * A mechanism to supply a Trie from either a static or non-serializable context. + * + * Serializing the Trie imposes a big performance penalty and needs to be avoided. Using + * this interface is a good way to do so. * - * Serializing the Trie imposes a big performance penalty and needs to be avoided. Using this interface is a good way to do so. - * */ -public interface ITrieProvider extends IClusterable { - +public interface ITrieProvider extends IClusterable +{ + /** * * @return a Trie instance. */ - public TrieprovideTrie(); + public Trie provideTrie(); } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/TrieDataProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/TrieDataProvider.java index dd3130c1a5..eaa60f5963 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/TrieDataProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/TrieDataProvider.java @@ -35,14 +35,13 @@ /** * @author mocleiri * - * A SortableDataProvider connector which loads the data from the - * backing Trie. + * A SortableDataProvider connector which loads the data from the backing Trie. * */ -public class TrieDataProvider extends SortableDataProvider { +public class TrieDataProvider extends SortableDataProvider +{ - private static final Logger log = LoggerFactory - .getLogger(TrieDataProvider.class); + private static final Logger log = LoggerFactory.getLogger(TrieDataProvider.class); private static final long serialVersionUID = 6404076914195910834L; @@ -68,7 +67,8 @@ public class TrieDataProvider extends SortableDataProvider { private Map resultLimitMap = new LinkedHashMap(); - protected IModel getInputModel() { + protected IModel getInputModel() + { return fieldStringModel; } @@ -77,7 +77,8 @@ protected IModel getInputModel() { * @param noResultsOnEmptyString * the noResultsOnEmptyString to set */ - public void setNoResultsOnEmptyString(boolean noResultsOnEmptyString) { + public void setNoResultsOnEmptyString(boolean noResultsOnEmptyString) + { this.noResultsOnEmptyString = noResultsOnEmptyString; } @@ -86,7 +87,8 @@ public void setNoResultsOnEmptyString(boolean noResultsOnEmptyString) { * @param matchAnyWhereInString * the matchAnyWhereInString to set */ - public void setMatchAnyWhereInString(boolean matchAnyWhereInString) { + public void setMatchAnyWhereInString(boolean matchAnyWhereInString) + { this.matchAnyWhereInString = matchAnyWhereInString; } @@ -94,31 +96,33 @@ public void setMatchAnyWhereInString(boolean matchAnyWhereInString) { /** * @return the matchAnyWhereInString */ - public boolean isMatchAnyWhereInString() { + public boolean isMatchAnyWhereInString() + { return matchAnyWhereInString; } /* * (non-Javadoc) * - * @see - * org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider - * #detach() + * @see org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider #detach() */ @Override - public void detach() { + public void detach() + { /* - * If we want to support selectable values then we need to make the list - * last longer than just one rendered pass. + * If we want to support selectable values then we need to make the list last longer than + * just one rendered pass. */ clear(); super.detach(); } - public final void clear() { + public final void clear() + { - if (currentListData != null) { + if (currentListData != null) + { currentListData.clear(); currentListData = null; } @@ -128,9 +132,9 @@ public final void clear() { * @param fieldStringModel * */ - public TrieDataProvider(ITrieProvider trieProvider, - ITrieFilter resultFilter, IModel fieldStringModel, - IProviderSorter sorter, IModelProvider modelProvider) { + public TrieDataProvider(ITrieProvider trieProvider, ITrieFilter resultFilter, + IModel fieldStringModel, IProviderSorter sorter, IModelProvider modelProvider) + { super(); this.trieProvider = trieProvider; @@ -141,23 +145,31 @@ public TrieDataProvider(ITrieProvider trieProvider, this.modelProvider = modelProvider; } - public int size() { + public int size() + { String prefix = fieldStringModel.getObject(); - if (prefix == null) { + if (prefix == null) + { return 0; - } else if (noResultsOnEmptyString && prefix.length() == 0) { + } + else if (noResultsOnEmptyString && prefix.length() == 0) + { // show no results since no input filter specified. return 0; - } else { + } + else + { // if no input is given any element in the entire trie is // selectable. - if (currentListData == null) { + if (currentListData == null) + { Trie trie = trieProvider.provideTrie(); - if (trie == null) { + if (trie == null) + { log.warn("trie is unexpectantly null!"); currentListData = new LinkedList(); return 0; @@ -168,16 +180,16 @@ public int size() { Integer limit = this.resultLimitMap.get(prefix.length()); - if (limit == null) { + if (limit == null) + { // no limit - currentListData = trie.getWordList(prefix, - this.trieResultFilter); + currentListData = trie.getWordList(prefix, this.trieResultFilter); } - else { - currentListData = trie.getWordList(prefix, - this.trieResultFilter, limit); + else + { + currentListData = trie.getWordList(prefix, this.trieResultFilter, limit); } @@ -191,10 +203,10 @@ public int size() { /* * (non-Javadoc) * - * @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, - * int) + * @see org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int, int) */ - public Iterator iterator(int first, int count) { + public Iterator iterator(int first, int count) + { String prefix = fieldStringModel.getObject(); @@ -203,7 +215,8 @@ public Iterator iterator(int first, int count) { SortParam sort = super.getSort(); - if (sort != null && this.currentListData.size() > 1) { + if (sort != null && this.currentListData.size() > 1) + { Comparator c = sorter.getComparatorForProperty(sort); @@ -216,7 +229,8 @@ public Iterator iterator(int first, int count) { int last = DataProviderUtils.getLastIndex(size, first, count); - if (first > last) { + if (first > last) + { log.warn("indexing problem"); last = DataProviderUtils.getLastIndex(size, first, count); } @@ -227,23 +241,23 @@ public Iterator iterator(int first, int count) { /* * (non-Javadoc) * - * @see - * org.apache.wicket.markup.repeater.data.IDataProvider#model(java.lang. - * Object) + * @see org.apache.wicket.markup.repeater.data.IDataProvider#model(java.lang. Object) */ - public IModel model(C object) { + public IModel model(C object) + { return modelProvider.model(object); } /** - * Used to set the upper bounds on results returned based on the length of - * the prefix being searched. + * Used to set the upper bounds on results returned based on the length of the prefix being + * searched. * * @param resultMatchMap * */ - public void setMaxResultMap(Map resultMatchMap) { + public void setMaxResultMap(Map resultMatchMap) + { this.resultLimitMap = resultMatchMap; } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/utils/DataProviderUtils.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/utils/DataProviderUtils.java index 688e6b800d..67185684f1 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/utils/DataProviderUtils.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/provider/utils/DataProviderUtils.java @@ -1,31 +1,34 @@ - package org.wicketstuff.datatable_autocomplete.provider.utils; /** * @author mocleiri - * + * */ -public final class DataProviderUtils { +public final class DataProviderUtils +{ /** * */ - private DataProviderUtils() { + private DataProviderUtils() + { // TODO Auto-generated constructor stub } /** * @param first * @param count - * @return the last index to get, designed for use in sublist() so its actually the ith index. so we get elements from first to i-1 + * @return the last index to get, designed for use in sublist() so its actually the ith index. + * so we get elements from first to i-1 */ - - - public static int getLastIndex (int size, int first, int count) { - - int last = Math.min(size, first+count+1); - + + + public static int getLastIndex(int size, int first, int count) + { + + int last = Math.min(size, first + count + 1); + return last; } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadio.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadio.java index 8bee598937..1e04810aee 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadio.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadio.java @@ -26,20 +26,22 @@ /** * @author mocleiri - * + * */ -public class DTARadio extends Radio { +public class DTARadio extends Radio +{ /** * */ - private static final long serialVersionUID = -7457090902151030992L; - private static final Logger log = LoggerFactory.getLogger(DTARadio.class); + private static final long serialVersionUID = -7457090902151030992L; + private static final Logger log = LoggerFactory.getLogger(DTARadio.class); /** * @param id */ - public DTARadio(String id) { + public DTARadio(String id) + { super(id); } @@ -48,52 +50,59 @@ public DTARadio(String id) { * @param id * @param model */ - public DTARadio(String id, IModel model) { + public DTARadio(String id, IModel model) + { super(id, model); // TODO Auto-generated constructor stub } - /* (non-Javadoc) - * @see org.apache.wicket.markup.html.form.Radio#onComponentTag(org.apache.wicket.markup.ComponentTag) + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.markup.html.form.Radio#onComponentTag(org.apache.wicket.markup.ComponentTag + * ) */ @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { + + if (tag.isOpenClose()) + { - if (tag.isOpenClose()) { - tag.setHasNoCloseTag(true); - + tag.setType(XmlTag.TagType.OPEN); - + } - + tag.setName("input"); tag.getAttributes().put("type", "radio"); - - - + + // Default handling for component tag super.onComponentTag(tag); } - /* (non-Javadoc) - * @see org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket.markup.MarkupStream, org.apache.wicket.markup.ComponentTag) + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket.markup.MarkupStream, + * org.apache.wicket.markup.ComponentTag) */ @Override - public void onComponentTagBody(MarkupStream markupStream, - ComponentTag openTag) { + public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) + { openTag.setName("input"); - - - - + + markupStream.next(); - + } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadioGroup.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadioGroup.java index d486f5a9cc..3ecd1215f3 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadioGroup.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/radio/DTARadioGroup.java @@ -20,11 +20,12 @@ /** * @author mocleiri - * - * A Custom radio group that requires a valid selection. - * + * + * A Custom radio group that requires a valid selection. + * */ -public class DTARadioGroup extends RadioGroup { +public class DTARadioGroup extends RadioGroup +{ /** * @@ -34,7 +35,8 @@ public class DTARadioGroup extends RadioGroup { /** * @param id */ - public DTARadioGroup(String id) { + public DTARadioGroup(String id) + { super(id); // TODO Auto-generated constructor stub } @@ -43,20 +45,23 @@ public DTARadioGroup(String id) { * @param id * @param model */ - public DTARadioGroup(String id, IModel model) { + public DTARadioGroup(String id, IModel model) + { super(id, model); - + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.markup.html.form.FormComponent#isInputNullable() */ @Override - public boolean isInputNullable() { + public boolean isInputNullable() + { // override the default return false; } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/selection/ITableRowSelectionHandler.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/selection/ITableRowSelectionHandler.java index 98a48f431c..a1e57cf3b4 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/selection/ITableRowSelectionHandler.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/selection/ITableRowSelectionHandler.java @@ -22,12 +22,15 @@ * @author mocleiri * */ -public interface ITableRowSelectionHandler extends IClusterable { +public interface ITableRowSelectionHandler extends IClusterable +{ /** - * Implements a callback to allow the selection of the index'ed item from the current list to be handled. + * Implements a callback to allow the selection of the index'ed item from the current list to be + * handled. * * The target should be updated accordingly + * * @param index * @param modelObject * @param target diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/AbstractSelectableTableViewPanel.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/AbstractSelectableTableViewPanel.java index 453994f543..de3fc6413d 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/AbstractSelectableTableViewPanel.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/AbstractSelectableTableViewPanel.java @@ -46,16 +46,15 @@ * @author mocleiri * */ -public abstract class AbstractSelectableTableViewPanel extends - FormComponentPanel { +public abstract class AbstractSelectableTableViewPanel extends FormComponentPanel +{ /** * */ private static final long serialVersionUID = -4369026666390989926L; - private static final Logger log = LoggerFactory - .getLogger(AbstractSelectableTableViewPanel.class); + private static final Logger log = LoggerFactory.getLogger(AbstractSelectableTableViewPanel.class); private DTADataTable dataTable; @@ -66,7 +65,7 @@ public abstract class AbstractSelectableTableViewPanel extends protected final ISortableDataProvider dataProvider; private static final ResourceReference DEFAULT_CSS = new CompressedResourceReference( - DTADataTable.class, "dta_table.css"); + DTADataTable.class, "dta_table.css"); protected ButtonListView buttonView; @@ -77,38 +76,35 @@ public abstract class AbstractSelectableTableViewPanel extends /** * @param asList * - * Sets the list of button providers to use with the selectable - * table view @see + * Sets the list of button providers to use with the selectable table view @see * {@link DefaultSelectableTableViewPanelButtonProviderImpl} * * and {@link SelectableTableViewPanel} for examples */ - public final void setButtonProviderList( - List asList) { + public final void setButtonProviderList(List asList) + { this.buttonView.setList(asList); } - public AbstractSelectableTableViewPanel(String id, - ResourceReference css_reference, String cssClassNamne, - String displayEntityName, IColumn column, - ISortableDataProvider dataProvider, - ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { + public AbstractSelectableTableViewPanel(String id, ResourceReference css_reference, + String cssClassNamne, String displayEntityName, IColumn column, + ISortableDataProvider dataProvider, ITableRowSelectionHandler selectionHandler, + IDTATableRenderingHints hints) + { - this(id, css_reference, cssClassNamne, displayEntityName, column, - dataProvider, true, selectionHandler, hints); + this(id, css_reference, cssClassNamne, displayEntityName, column, dataProvider, true, + selectionHandler, hints); } - public AbstractSelectableTableViewPanel(String id, - ResourceReference css_reference, String cssClassName, - String displayEntityName, IColumn column, - ISortableDataProvider dataProvider, - boolean showTableFeedbackPanel, - ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { + public AbstractSelectableTableViewPanel(String id, ResourceReference css_reference, + String cssClassName, String displayEntityName, IColumn column, + ISortableDataProvider dataProvider, boolean showTableFeedbackPanel, + ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) + { - this(id, css_reference, cssClassName, displayEntityName, - new IColumn[] { column }, dataProvider, - showTableFeedbackPanel, selectionHandler, hints); + this(id, css_reference, cssClassName, displayEntityName, new IColumn[] { column }, + dataProvider, showTableFeedbackPanel, selectionHandler, hints); } /** @@ -123,72 +119,78 @@ public AbstractSelectableTableViewPanel(String id, * @param selectedRowContextExtractor * @param buttonProviderList * @param showTableFeedbackPanel - * true if the feedback panel should be visible; used in the - * nesteded components with many feedback panels situation. + * true if the feedback panel should be visible; used in the nesteded components with + * many feedback panels situation. */ - public AbstractSelectableTableViewPanel(String id, - ResourceReference css_reference, String cssClassName, - String displayEntityName, IColumn[] columns, - ISortableDataProvider dataProvider, - ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { - - this(id, css_reference, cssClassName, displayEntityName, columns, - dataProvider, true, selectionHandler, hints); + public AbstractSelectableTableViewPanel(String id, ResourceReference css_reference, + String cssClassName, String displayEntityName, IColumn[] columns, + ISortableDataProvider dataProvider, ITableRowSelectionHandler selectionHandler, + IDTATableRenderingHints hints) + { + + this(id, css_reference, cssClassName, displayEntityName, columns, dataProvider, true, + selectionHandler, hints); } - public AbstractSelectableTableViewPanel(String id, - final ResourceReference css_reference, String cssClassName, - String displayEntityName, IColumn[] columns, - ISortableDataProvider dataProvider, - boolean showTableFeedbackPanel, - ITableRowSelectionHandler rowSelectionHandler, IDTATableRenderingHints hints) { + public AbstractSelectableTableViewPanel(String id, final ResourceReference css_reference, + String cssClassName, String displayEntityName, IColumn[] columns, + ISortableDataProvider dataProvider, boolean showTableFeedbackPanel, + ITableRowSelectionHandler rowSelectionHandler, IDTATableRenderingHints hints) + { super(id, new Model()); this.dataProvider = dataProvider; this.rowSelectionHandler = rowSelectionHandler; - add(new Behavior () { + add(new Behavior() + { @Override - public void renderHead(Component c, IHeaderResponse response) { + public void renderHead(Component c, IHeaderResponse response) + { response.renderCSSReference(css_reference); - }}); + } + }); Form form = new Form("viewForm"); - radioGroup = new DTARadioGroup("radioGroup", this.dataProvider - .model(null)); + radioGroup = new DTARadioGroup("radioGroup", this.dataProvider.model(null)); List> includingRadioColumnList = new ArrayList>(); // TODO: allow customization of the radio column label final DTARadioColumn radioColumn = new DTARadioColumn(""); - includingRadioColumnList.add (radioColumn); + includingRadioColumnList.add(radioColumn); - for (int i = 0; i < columns.length; i++) { + for (int i = 0; i < columns.length; i++) + { - includingRadioColumnList.add ((IColumn) columns[i]); + includingRadioColumnList.add((IColumn)columns[i]); } - dataTable = new DTADataTable("dataTable", cssClassName, - includingRadioColumnList, dataProvider, hints); + dataTable = new DTADataTable("dataTable", cssClassName, includingRadioColumnList, + dataProvider, hints); + - radioGroup.add(dataTable); form.add(radioGroup); - dataTable.setItemModifier(new DTADataTableItemModifier() { + dataTable.setItemModifier(new DTADataTableItemModifier() + { private static final long serialVersionUID = 5144108737965241352L; - - public void modifyRowItem(final Item item) { - if (AbstractSelectableTableViewPanel.this.rowSelectionHandler != null) { + public void modifyRowItem(final Item item) + { - item.add(new AjaxEventBehavior("onclick") { + if (AbstractSelectableTableViewPanel.this.rowSelectionHandler != null) + { + + item.add(new AjaxEventBehavior("onclick") + { /** * @@ -196,21 +198,24 @@ public void modifyRowItem(final Item item) { private static final long serialVersionUID = 2282163166444338308L; @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { int index = item.getIndex(); T selectedObject = item.getModelObject(); - + /* * Delegate to the row selection handler */ - AbstractSelectableTableViewPanel.this.rowSelectionHandler - .handleSelection(index, selectedObject, target); + AbstractSelectableTableViewPanel.this.rowSelectionHandler.handleSelection( + index, selectedObject, target); } }); - } else { + } + else + { // Intentionally does nothing. } @@ -218,10 +223,8 @@ protected void onEvent(AjaxRequestTarget target) { }); - - buttonView = new ButtonListView("buttonView", form, - displayEntityName, radioGroup); + buttonView = new ButtonListView("buttonView", form, displayEntityName, radioGroup); form.add(buttonView); @@ -245,13 +248,13 @@ protected void onEvent(AjaxRequestTarget target) { * @param selectedRowContextConverter * @param i */ - public AbstractSelectableTableViewPanel(String id, - String displayEntityName, IColumn[] tableColumns, - ISortableDataProvider attributeFilterDataProvider, - ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { + public AbstractSelectableTableViewPanel(String id, String displayEntityName, + IColumn[] tableColumns, ISortableDataProvider attributeFilterDataProvider, + ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) + { - this(id, DEFAULT_CSS, "dta_data_table", displayEntityName, - tableColumns, attributeFilterDataProvider, selectionHandler, hints); + this(id, DEFAULT_CSS, "dta_data_table", displayEntityName, tableColumns, + attributeFilterDataProvider, selectionHandler, hints); } /** @@ -263,17 +266,18 @@ public AbstractSelectableTableViewPanel(String id, * @param i * @param b */ - public AbstractSelectableTableViewPanel(String id, String title, - IColumn[] columns, - ISortableDataProvider sortableListDataProvider, - boolean showTableFeedbackPanel, ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { + public AbstractSelectableTableViewPanel(String id, String title, IColumn[] columns, + ISortableDataProvider sortableListDataProvider, boolean showTableFeedbackPanel, + ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) + { - this(id, DEFAULT_CSS, "dta_data_table", title, columns, - sortableListDataProvider, showTableFeedbackPanel, selectionHandler, hints); + this(id, DEFAULT_CSS, "dta_data_table", title, columns, sortableListDataProvider, + showTableFeedbackPanel, selectionHandler, hints); } - public T getSelectedRow() { + public T getSelectedRow() + { return radioGroup.getModelObject(); } @@ -281,7 +285,8 @@ public T getSelectedRow() { * @param hideIfNoResults * the hideIfNoResults to set */ - public void setHideIfNoResults(boolean hideIfNoResults) { + public void setHideIfNoResults(boolean hideIfNoResults) + { this.hideIfNoResults = hideIfNoResults; } @@ -289,7 +294,8 @@ public void setHideIfNoResults(boolean hideIfNoResults) { /** * @return */ - public final DTADataTable getDataTable() { + public final DTADataTable getDataTable() + { return dataTable; } @@ -300,7 +306,8 @@ public final DTADataTable getDataTable() { * @see org.apache.wicket.Component#onBeforeRender() */ @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { updateVisibility(); @@ -309,19 +316,23 @@ protected void onBeforeRender() { } /** - * Normally a wicket component that is made invisible will never render again. This will cause our - * visibility to be updated and allow rendering to occur. + * Normally a wicket component that is made invisible will never render again. This will cause + * our visibility to be updated and allow rendering to occur. * - * This method is public because our visibility is used by the AutoCompletingPanel to determine its visibility. + * This method is public because our visibility is used by the AutoCompletingPanel to determine + * its visibility. * */ - public void updateVisibility() { + public void updateVisibility() + { + - - if (this.hideIfNoResults && dataProvider.size() == 0) { + if (this.hideIfNoResults && dataProvider.size() == 0) + { setVisible(false); - } else + } + else setVisible(true); } @@ -331,11 +342,12 @@ public void updateVisibility() { * * @param disableRowHighlight */ - public final void setDisableRowHighlight(boolean disableRowHighlight) { + public final void setDisableRowHighlight(boolean disableRowHighlight) + { // FIXME: find out how to disable the row highlight on the table. - -// this.dataTable.setDisableRowHighlight(disableRowHighlight); + +// this.dataTable.setDisableRowHighlight(disableRowHighlight); } /** @@ -343,22 +355,26 @@ public final void setDisableRowHighlight(boolean disableRowHighlight) { * @return * @see org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable#setItemReuseStrategy(org.apache.wicket.markup.repeater.IItemReuseStrategy) */ - public final DataTable setItemReuseStrategy(IItemReuseStrategy strategy) { + public final DataTable setItemReuseStrategy(IItemReuseStrategy strategy) + { return dataTable.setItemReuseStrategy(strategy); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.markup.html.form.FormComponent#convertInput() */ @Override - protected void convertInput() { - + protected void convertInput() + { + radioGroup.processInput(); - + super.convertInput(); - - + + } - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DTADataTable.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DTADataTable.java index 3a6b44c4ba..bea03ff6aa 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DTADataTable.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DTADataTable.java @@ -36,39 +36,37 @@ /** * @author mocleiri * - * Almost an exact copy of the wicket AjaxFallbackDefaultDataTable except that we have control over when the pagination toolbar is added. - * + * Almost an exact copy of the wicket AjaxFallbackDefaultDataTable except that we have + * control over when the pagination toolbar is added. + * */ -public class DTADataTable extends DataTable { +public class DTADataTable extends DataTable +{ + + private static final org.slf4j.Logger log = LoggerFactory.getLogger(DTADataTable.class); - private static final org.slf4j.Logger log = LoggerFactory - .getLogger(DTADataTable.class); + public static interface DTADataTableItemModifier extends IClusterable + { - public static interface DTADataTableItemModifier extends IClusterable { - /** - * Allows the row item to be modified when it is created. Typcially used for on row click listeners. + * Allows the row item to be modified when it is created. Typcially used for on row click + * listeners. * * @param item */ - public void modifyRowItem (Item item); - - + public void modifyRowItem(Item item); + + } + /** * */ - private static final long serialVersionUID = -1878257266564660026L; - - + private static final long serialVersionUID = -1878257266564660026L; - private DTADataTableItemModifier itemModifier; - - + private DTADataTableItemModifier itemModifier; - - /** * @param id @@ -76,9 +74,9 @@ public static interface DTADataTableItemModifier extends IClusterable { * @param dataProvider * @param rowsPerPage */ - public DTADataTable(String id, String cssClassName, - List> columns, ISortableDataProvider dataProvider, - IDTATableRenderingHints hints) { + public DTADataTable(String id, String cssClassName, List> columns, + ISortableDataProvider dataProvider, IDTATableRenderingHints hints) + { super(id, columns, dataProvider, hints.getPageSize()); @@ -86,16 +84,16 @@ public DTADataTable(String id, String cssClassName, // set the table class add(new AttributeModifier("class", new Model(cssClassName))); - + setOutputMarkupId(true); setVersioned(false); - - + + if (hints.isPaginationEnabled()) addTopToolbar(new AjaxNavigationToolbar(this)); - + addTopToolbar(new AjaxFallbackHeadersToolbar(this, dataProvider)); - + if (hints.showNoRecordsToolbar()) addBottomToolbar(new NoRecordsToolbar(this)); @@ -109,7 +107,8 @@ public DTADataTable(String id, String cssClassName, * @param i */ public DTADataTable(String id, List> tableColumns, - ISortableDataProvider provider, IDTATableRenderingHints hints) { + ISortableDataProvider provider, IDTATableRenderingHints hints) + { this(id, "dta_data_table", tableColumns, provider, hints); } @@ -117,12 +116,12 @@ public DTADataTable(String id, List> tableColumns, /* * (non-Javadoc) * - * @see - * org.apache.wicket.markup.html.panel.Panel#onComponentTag(org.apache.wicket + * @see org.apache.wicket.markup.html.panel.Panel#onComponentTag(org.apache.wicket * .markup.ComponentTag) */ @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { // force the name of the tag to be table. // this allows us to use this component on a span or div tag. @@ -134,13 +133,12 @@ protected void onComponentTag(ComponentTag tag) { /* * (non-Javadoc) * - * @see - * org.apache.wicket.markup.html.panel.Panel#onComponentTagBody(org.apache + * @see org.apache.wicket.markup.html.panel.Panel#onComponentTagBody(org.apache * .wicket.markup.MarkupStream, org.apache.wicket.markup.ComponentTag) */ @Override - public void onComponentTagBody(MarkupStream markupStream, - ComponentTag openTag) { + public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) + { // force the name of the tag to be table. // this allows us to use this component on a span or div tag. @@ -152,33 +150,34 @@ public void onComponentTagBody(MarkupStream markupStream, /* * (non-Javadoc) * - * @see - * org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable + * @see org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable * #newRowItem(java.lang.String, int, org.apache.wicket.model.IModel) */ @Override - protected Item newRowItem(String id, int index, IModel model) { + protected Item newRowItem(String id, int index, IModel model) + { Item rowItem = super.newRowItem(id, index, model); - - if (itemModifier != null) { - + + if (itemModifier != null) + { + // optionally modify the 'row' item. // a good place to put onclick listeners. itemModifier.modifyRowItem(rowItem); - + } - + return rowItem; } - /** * Set the item modifier. */ - public final void setItemModifier(DTADataTableItemModifier itemModifier) { + public final void setItemModifier(DTADataTableItemModifier itemModifier) + { this.itemModifier = itemModifier; } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultDTATableRenderingHints.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultDTATableRenderingHints.java index e3055a344f..c2a9b236b9 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultDTATableRenderingHints.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultDTATableRenderingHints.java @@ -18,11 +18,12 @@ /** * @author mocleiri * - * Default implementation of the IDTATableRenderingHints interface. + * Default implementation of the IDTATableRenderingHints interface. + * * - * */ -public class DefaultDTATableRenderingHints implements IDTATableRenderingHints { +public class DefaultDTATableRenderingHints implements IDTATableRenderingHints +{ private final int pageSize; private final boolean paginationEnabled; @@ -30,30 +31,42 @@ public class DefaultDTATableRenderingHints implements IDTATableRenderingHints { /** * */ - public DefaultDTATableRenderingHints(int pageSize, boolean paginationEnabled) { + public DefaultDTATableRenderingHints(int pageSize, boolean paginationEnabled) + { this.pageSize = pageSize; this.paginationEnabled = paginationEnabled; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.wicketstuff.datatable_autocomplete.table.IDTATableRenderingHints#getPageSize() */ - public int getPageSize() { - return this.pageSize; + public int getPageSize() + { + return pageSize; } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.table.IDTATableRenderingHints#isPaginationEnabled() + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.table.IDTATableRenderingHints#isPaginationEnabled() */ - public boolean isPaginationEnabled() { - return this.paginationEnabled; + public boolean isPaginationEnabled() + { + return paginationEnabled; } - /* (non-Javadoc) - * @see org.wicketstuff.datatable_autocomplete.table.IDTATableRenderingHints#showNoMatchToolbar() + /* + * (non-Javadoc) + * + * @see + * org.wicketstuff.datatable_autocomplete.table.IDTATableRenderingHints#showNoMatchToolbar() */ - public boolean showNoRecordsToolbar() { - + public boolean showNoRecordsToolbar() + { + return true; } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultSelectableTableViewPanelButtonProviderImpl.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultSelectableTableViewPanelButtonProviderImpl.java index a1dfad8edc..3075c27457 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultSelectableTableViewPanelButtonProviderImpl.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/DefaultSelectableTableViewPanelButtonProviderImpl.java @@ -22,92 +22,103 @@ /** * @author mocleiri - * + * */ public class DefaultSelectableTableViewPanelButtonProviderImpl implements - ISelectableTableViewPanelButtonProvider { + ISelectableTableViewPanelButtonProvider +{ /** * */ private static final long serialVersionUID = 3162806247349691580L; - private static final Logger log = LoggerFactory - .getLogger(DefaultSelectableTableViewPanelButtonProviderImpl.class); - private String buttonLabelText; - private IFormOnSubmitAction action = null; - private final boolean clearSelectedRowOnAction; - private final boolean requireSelectedRow; + private static final Logger log = LoggerFactory.getLogger(DefaultSelectableTableViewPanelButtonProviderImpl.class); + private String buttonLabelText; + private IFormOnSubmitAction action = null; + private final boolean clearSelectedRowOnAction; + private final boolean requireSelectedRow; private String cssClassName; /** * */ - public DefaultSelectableTableViewPanelButtonProviderImpl(String buttonLabelText, IFormOnSubmitAction action, boolean clearSelectedRowOnAction, boolean requireSelectedRow) { + public DefaultSelectableTableViewPanelButtonProviderImpl(String buttonLabelText, + IFormOnSubmitAction action, boolean clearSelectedRowOnAction, boolean requireSelectedRow) + { this.buttonLabelText = buttonLabelText; this.action = action; this.clearSelectedRowOnAction = clearSelectedRowOnAction; this.requireSelectedRow = requireSelectedRow; } - - public DefaultSelectableTableViewPanelButtonProviderImpl(String buttonLabelText, boolean clearSelectedRowOnAction, boolean requireSelectedRow) { + + public DefaultSelectableTableViewPanelButtonProviderImpl(String buttonLabelText, + boolean clearSelectedRowOnAction, boolean requireSelectedRow) + { this.buttonLabelText = buttonLabelText; this.clearSelectedRowOnAction = clearSelectedRowOnAction; this.requireSelectedRow = requireSelectedRow; } - - - + /** - * @param buttonLabelText the buttonLabelText to set + * @param buttonLabelText + * the buttonLabelText to set */ - public void setButtonLabelText(String buttonLabelText) { - + public void setButtonLabelText(String buttonLabelText) + { + this.buttonLabelText = buttonLabelText; } /** - * @param action the action to set + * @param action + * the action to set */ - public void setAction(IFormOnSubmitAction action) { - + public void setAction(IFormOnSubmitAction action) + { + this.action = action; } - public IFormOnSubmitAction getButtonAction() { + public IFormOnSubmitAction getButtonAction() + { return action; } - public String getButtonLabelText(String displayEntityName) { + public String getButtonLabelText(String displayEntityName) + { return buttonLabelText + " " + displayEntityName; } - public boolean isClearSelectedRowOnAction() { + public boolean isClearSelectedRowOnAction() + { return clearSelectedRowOnAction; } - public boolean isSelectedRowRequired() { + public boolean isSelectedRowRequired() + { return requireSelectedRow; } - public String getCSSClassName() { + public String getCSSClassName() + { return cssClassName; } /** - * @param cssClassName the cssClassName to set + * @param cssClassName + * the cssClassName to set */ - public void setCssClassName(String cssClassName) { + public void setCssClassName(String cssClassName) + { this.cssClassName = cssClassName; } - - - - + + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/IDTATableRenderingHints.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/IDTATableRenderingHints.java index 9aac962523..7475801685 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/IDTATableRenderingHints.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/IDTATableRenderingHints.java @@ -19,21 +19,23 @@ /** * @author mocleiri - * + * */ -public interface IDTATableRenderingHints extends IClusterable { +public interface IDTATableRenderingHints extends IClusterable +{ /** * * @return true if the results table should use AJAX pagination. */ public boolean isPaginationEnabled(); - + /** * - * @return the number of rows per page. If isPaginationEnabled() returns false then only 1 page is shown. - */ - public int getPageSize(); - + * @return the number of rows per page. If isPaginationEnabled() returns false then only 1 page + * is shown. + */ + public int getPageSize(); + /** * * @return true if the no match tool bar should be shown in the table when there are no results. diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/ISelectableTableViewPanelButtonProvider.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/ISelectableTableViewPanelButtonProvider.java index d95421217d..91c8f05057 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/ISelectableTableViewPanelButtonProvider.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/ISelectableTableViewPanelButtonProvider.java @@ -28,8 +28,8 @@ * We default to ajaxfallback buttons. * */ -public interface ISelectableTableViewPanelButtonProvider extends - IClusterable { +public interface ISelectableTableViewPanelButtonProvider extends IClusterable +{ /** * @@ -50,7 +50,7 @@ public interface ISelectableTableViewPanelButtonProvider extends * @return non null if there is a class atribute that should be written on the button. */ public String getCSSClassName(); - + /** * * @return if a selected row is a precondition to this action. @@ -58,11 +58,9 @@ public interface ISelectableTableViewPanelButtonProvider extends public boolean isSelectedRowRequired(); /** - * @return true if the selected row should be cleared as a result of - * clicking on the button. + * @return true if the selected row should be cleared as a result of clicking on the button. */ public boolean isClearSelectedRowOnAction(); - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/SelectableTableViewPanel.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/SelectableTableViewPanel.java index dc7a886cdd..6944016143 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/SelectableTableViewPanel.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/SelectableTableViewPanel.java @@ -30,14 +30,20 @@ * * Allows a table to be rendered where the rows are selectable * - * @param T the type of the object in the table row. The type of the object returned from the dataprovidcer + * @param T + * the type of the object in the table row. The type of the object returned from the + * dataprovidcer */ -public class SelectableTableViewPanel extends AbstractSelectableTableViewPanel { +public class SelectableTableViewPanel extends AbstractSelectableTableViewPanel +{ + + private DefaultSelectableTableViewPanelButtonProviderImpl createButtonProvider = new DefaultSelectableTableViewPanelButtonProviderImpl( + "Create New", false, false); + private DefaultSelectableTableViewPanelButtonProviderImpl editButtonProvider = new DefaultSelectableTableViewPanelButtonProviderImpl( + "Edit Selected", true, true); + private DefaultSelectableTableViewPanelButtonProviderImpl deleteButtonProvider = new DefaultSelectableTableViewPanelButtonProviderImpl( + "Delete Selected", true, true); - private DefaultSelectableTableViewPanelButtonProviderImpl createButtonProvider = new DefaultSelectableTableViewPanelButtonProviderImpl ("Create New", false, false); - private DefaultSelectableTableViewPanelButtonProviderImpl editButtonProvider = new DefaultSelectableTableViewPanelButtonProviderImpl ("Edit Selected", true, true); - private DefaultSelectableTableViewPanelButtonProviderImpl deleteButtonProvider = new DefaultSelectableTableViewPanelButtonProviderImpl ("Delete Selected", true, true); - /** * @param id * @param css_reference @@ -49,22 +55,22 @@ public class SelectableTableViewPanel extends AbstractSelectableTableViewPane * @param selectedRowContextExtractor * @param rowsPerPage * @param showTableFeedbackPanel - * @param selectionHandler + * @param selectionHandler */ - public SelectableTableViewPanel(String id, - ResourceReference css_reference, String cssClassName, - String displayEntityName, IColumn column, - ISortableDataProvider dataProvider, - boolean showTableFeedbackPanel, ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { + public SelectableTableViewPanel(String id, ResourceReference css_reference, + String cssClassName, String displayEntityName, IColumn column, + ISortableDataProvider dataProvider, boolean showTableFeedbackPanel, + ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) + { super(id, css_reference, cssClassName, displayEntityName, column, dataProvider, - - showTableFeedbackPanel, selectionHandler, hints); - - setButtonProviderList (Arrays.asList(new ISelectableTableViewPanelButtonProvider[] {editButtonProvider, deleteButtonProvider, createButtonProvider})); + + showTableFeedbackPanel, selectionHandler, hints); + + setButtonProviderList(Arrays.asList(new ISelectableTableViewPanelButtonProvider[] { + editButtonProvider, deleteButtonProvider, createButtonProvider })); } - /** * @param id @@ -76,19 +82,19 @@ public SelectableTableViewPanel(String id, * @param buttonProviderList * @param selectedRowContextExtractor * @param rowsPerPage - * @param selectionHandler + * @param selectionHandler */ - public SelectableTableViewPanel(String id, - ResourceReference css_reference, String cssClassNamne, - String displayEntityName, IColumn column, - ISortableDataProvider dataProvider, - ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { + public SelectableTableViewPanel(String id, ResourceReference css_reference, + String cssClassNamne, String displayEntityName, IColumn column, + ISortableDataProvider dataProvider, ITableRowSelectionHandler selectionHandler, + IDTATableRenderingHints hints) + { - super(id, css_reference, cssClassNamne, displayEntityName, column, - dataProvider, - selectionHandler, hints); + super(id, css_reference, cssClassNamne, displayEntityName, column, dataProvider, + selectionHandler, hints); - setButtonProviderList (Arrays.asList(new ISelectableTableViewPanelButtonProvider[] {editButtonProvider, deleteButtonProvider, createButtonProvider})); + setButtonProviderList(Arrays.asList(new ISelectableTableViewPanelButtonProvider[] { + editButtonProvider, deleteButtonProvider, createButtonProvider })); } /** @@ -102,19 +108,19 @@ public SelectableTableViewPanel(String id, * @param selectedRowContextExtractor * @param rowsPerPage * @param showTableFeedbackPanel - * @param selectionHandler + * @param selectionHandler */ - public SelectableTableViewPanel(String id, - ResourceReference css_reference, String cssClassName, - String displayEntityName, IColumn[] columns, - ISortableDataProvider dataProvider, - boolean showTableFeedbackPanel, ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { - - super(id, css_reference, cssClassName, displayEntityName, columns, - dataProvider, - showTableFeedbackPanel, selectionHandler, hints); - - setButtonProviderList (Arrays.asList(new ISelectableTableViewPanelButtonProvider[] {editButtonProvider, deleteButtonProvider, createButtonProvider})); + public SelectableTableViewPanel(String id, ResourceReference css_reference, + String cssClassName, String displayEntityName, IColumn[] columns, + ISortableDataProvider dataProvider, boolean showTableFeedbackPanel, + ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) + { + + super(id, css_reference, cssClassName, displayEntityName, columns, dataProvider, + showTableFeedbackPanel, selectionHandler, hints); + + setButtonProviderList(Arrays.asList(new ISelectableTableViewPanelButtonProvider[] { + editButtonProvider, deleteButtonProvider, createButtonProvider })); } /** @@ -127,18 +133,18 @@ public SelectableTableViewPanel(String id, * @param buttonProviderList * @param selectedRowContextExtractor * @param rowsPerPage - * @param selectionHandler + * @param selectionHandler */ - public SelectableTableViewPanel(String id, - ResourceReference css_reference, String cssClassName, - String displayEntityName, IColumn[] columns, - ISortableDataProvider dataProvider, - ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { - - super(id, css_reference, cssClassName, displayEntityName, columns, - dataProvider, - selectionHandler, hints); - setButtonProviderList (Arrays.asList(new ISelectableTableViewPanelButtonProvider[] {editButtonProvider, deleteButtonProvider, createButtonProvider})); + public SelectableTableViewPanel(String id, ResourceReference css_reference, + String cssClassName, String displayEntityName, IColumn[] columns, + ISortableDataProvider dataProvider, ITableRowSelectionHandler selectionHandler, + IDTATableRenderingHints hints) + { + + super(id, css_reference, cssClassName, displayEntityName, columns, dataProvider, + selectionHandler, hints); + setButtonProviderList(Arrays.asList(new ISelectableTableViewPanelButtonProvider[] { + editButtonProvider, deleteButtonProvider, createButtonProvider })); } /** @@ -150,16 +156,17 @@ public SelectableTableViewPanel(String id, * @param rowContextConverter * @param i * @param showTableFeedbackPanel - * @param selectionHandler + * @param selectionHandler */ - public SelectableTableViewPanel(String id, String title, - IColumn[] columns, - ISortableDataProvider sortableListDataProvider, - boolean showTableFeedbackPanel, ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { - - super(id, title, columns, sortableListDataProvider, - showTableFeedbackPanel, selectionHandler, hints); - setButtonProviderList (Arrays.asList(new ISelectableTableViewPanelButtonProvider[] {editButtonProvider, deleteButtonProvider, createButtonProvider})); + public SelectableTableViewPanel(String id, String title, IColumn[] columns, + ISortableDataProvider sortableListDataProvider, boolean showTableFeedbackPanel, + ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) + { + + super(id, title, columns, sortableListDataProvider, showTableFeedbackPanel, + selectionHandler, hints); + setButtonProviderList(Arrays.asList(new ISelectableTableViewPanelButtonProvider[] { + editButtonProvider, deleteButtonProvider, createButtonProvider })); } /** @@ -170,71 +177,69 @@ public SelectableTableViewPanel(String id, String title, * @param buttonProviderList * @param selectedRowContextConverter * @param i - * @param selectionHandler + * @param selectionHandler */ - public SelectableTableViewPanel(String id, String displayEntityName, - IColumn[] tableColumns, - ISortableDataProvider attributeFilterDataProvider, - ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) { - - super(id, displayEntityName, tableColumns, attributeFilterDataProvider, - selectionHandler, hints); - - setButtonProviderList (Arrays.asList(new ISelectableTableViewPanelButtonProvider[] {editButtonProvider, deleteButtonProvider, createButtonProvider})); + public SelectableTableViewPanel(String id, String displayEntityName, IColumn[] tableColumns, + ISortableDataProvider attributeFilterDataProvider, + ITableRowSelectionHandler selectionHandler, IDTATableRenderingHints hints) + { + + super(id, displayEntityName, tableColumns, attributeFilterDataProvider, selectionHandler, + hints); + + setButtonProviderList(Arrays.asList(new ISelectableTableViewPanelButtonProvider[] { + editButtonProvider, deleteButtonProvider, createButtonProvider })); } - public SelectableTableViewPanel(String string, String string2, - IColumn[] tableColumns, - ISortableDataProvider provider, IDTATableRenderingHints hints) { - - this (string, string2, tableColumns, provider, null, hints); + public SelectableTableViewPanel(String string, String string2, IColumn[] tableColumns, + ISortableDataProvider provider, IDTATableRenderingHints hints) + { + + this(string, string2, tableColumns, provider, null, hints); } /** * */ - private static final long serialVersionUID = 1000109813724689754L; - - private static final Logger log = LoggerFactory - .getLogger(SelectableTableViewPanel.class); - + private static final long serialVersionUID = 1000109813724689754L; + private static final Logger log = LoggerFactory.getLogger(SelectableTableViewPanel.class); - /** * @param formOnSubmitAction */ - public void setEditOnSubmitAction( - final IFormOnSubmitAction formOnSubmitAction) { + public void setEditOnSubmitAction(final IFormOnSubmitAction formOnSubmitAction) + { editButtonProvider.setAction(formOnSubmitAction); } - - public void setButtonCSSClass (String cssClass) { + + public void setButtonCSSClass(String cssClass) + { this.createButtonProvider.setCssClassName(cssClass); this.editButtonProvider.setCssClassName(cssClass); this.deleteButtonProvider.setCssClassName(cssClass); } - + /** * @param formOnSubmitAction */ - public void setDeleteOnSubmitAction( - final IFormOnSubmitAction formOnSubmitAction) { + public void setDeleteOnSubmitAction(final IFormOnSubmitAction formOnSubmitAction) + { deleteButtonProvider.setAction(formOnSubmitAction); } - - + /** * @param formOnSubmitAction */ - public void setCreateOnSubmitAction(IFormOnSubmitAction formOnSubmitAction) { + public void setCreateOnSubmitAction(IFormOnSubmitAction formOnSubmitAction) + { createButtonProvider.setAction(formOnSubmitAction); } @@ -242,12 +247,12 @@ public void setCreateOnSubmitAction(IFormOnSubmitAction formOnSubmitAction) { /** * @param actionLabel */ - public void setEditButtonLabel(String actionLabel) { + public void setEditButtonLabel(String actionLabel) + { editButtonProvider.setButtonLabelText(actionLabel); } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/button/ButtonListView.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/button/ButtonListView.java index 4042d482f4..34a85d263e 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/button/ButtonListView.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/button/ButtonListView.java @@ -35,23 +35,23 @@ /** * @author mocleiri - * - * Expects the markup to look like: - * - * + * + * Expects the markup to look like: + * * * * */ -public class ButtonListView extends ListView { +public class ButtonListView extends ListView +{ public static final String BUTTON_ID = "button"; /** * */ private static final long serialVersionUID = 8897933872966515782L; - private final Form form; - private final String displayEntityName; + private final Form form; + private final String displayEntityName; private FormComponent selectedContextField; /** @@ -59,7 +59,9 @@ public class ButtonListView extends ListView form, String displayEntityName, FormComponentselectedContextField) { + public ButtonListView(String id, Form form, String displayEntityName, + FormComponent selectedContextField) + { super(id); this.form = form; @@ -71,20 +73,20 @@ public ButtonListView(String id, Form form, String displayEntityName, FormCom /* * (non-Javadoc) * - * @see - * org.apache.wicket.markup.html.list.ListView#populateItem(org.apache + * @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache * .wicket.markup.html.list.ListItem) */ @SuppressWarnings("unchecked") @Override - protected void populateItem(ListItem item) { + protected void populateItem(ListItem item) + { final ISelectableTableViewPanelButtonProvider buttonProvider = item.getModelObject(); - - IFormOnSubmitAction buttonAction = buttonProvider - .getButtonAction(); - if (buttonAction == null) { + IFormOnSubmitAction buttonAction = buttonProvider.getButtonAction(); + + if (buttonAction == null) + { Label label; // not visible item.add(label = new Label(BUTTON_ID)); @@ -96,106 +98,112 @@ protected void populateItem(ListItem it return; } - // if the tow is required then - buttonAction = new AbstractFormOnSubmitAction() { - + // if the tow is required then + buttonAction = new AbstractFormOnSubmitAction() + { - /** + + /** * */ - private static final long serialVersionUID = 5910571859628875165L; - - - public void onSubmit(AjaxRequestTarget target, Form form) { - - if (buttonProvider.isSelectedRowRequired()) { - - if (selectedContextField.getModelObject() == null) { - if (target != null) { - target.prependJavaScript("alert ('A selected row is required.');"); - } - else - error("A selected row is required."); - - return; + private static final long serialVersionUID = 5910571859628875165L; + + + public void onSubmit(AjaxRequestTarget target, Form form) + { + + if (buttonProvider.isSelectedRowRequired()) + { + + if (selectedContextField.getModelObject() == null) + { + if (target != null) + { + target.prependJavaScript("alert ('A selected row is required.');"); } - - // fall through + else + error("A selected row is required."); + + return; } - - // run the user logic - buttonProvider.getButtonAction().onSubmit(target, form); + // fall through + } + + // run the user logic + buttonProvider.getButtonAction().onSubmit(target, form); - // else the action is defined. - if (buttonProvider.isClearSelectedRowOnAction()) { - // clear the value in the form. - selectedContextField.clearInput(); - } + // else the action is defined. + if (buttonProvider.isClearSelectedRowOnAction()) + { + // clear the value in the form. + selectedContextField.clearInput(); } - }; + } + + }; DTAAjaxFallbackButton button; -// if (buttonProvider.isSelectedRowRequired()) { -// -// IModel requireASelectedRow; -// -// final ListradioList = new LinkedList(); -// -// if (selectedContextField instanceof RadioGroup) { -// RadioGroup rg = (RadioGroup) selectedContextField; -// -// rg.visitChildren(new IVisitor() { -// -// /* (non-Javadoc) -// * @see org.apache.wicket.Component.IVisitor#component(org.apache.wicket.Component) -// */ -// public Object component(Component component) { -// -// if (component instanceof Radio) { -// -// radioList.add((Radio) component); -// } -// -// return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER; -// } -// -// }); -// -// -// requireASelectedRow = createRadioRequireSelectedRowModel (radioList); -// -// } -// else { -// // String hidden field -// -// -// requireASelectedRow = new MarkupIDInStringModel( -// "if (Wicket.$('" + MarkupIDInStringModel.MARKUP_ID_TAG -// + "').value == '') {" -// + "\nalert ('A selected row is required.');" -// + "\nreturn false;" + "}", selectedContextField); -// } -// -// button = new DTAAjaxFallbackButton(BUTTON_ID, buttonProvider -// .getButtonLabelText(displayEntityName), this.form, -// requireASelectedRow); -// -// button.setSubmitAction(buttonAction); -// } -// else { - - button = new DTAAjaxFallbackButton(BUTTON_ID, buttonProvider - .getButtonLabelText(displayEntityName), this.form, - buttonAction); -// } - +// if (buttonProvider.isSelectedRowRequired()) { +// +// IModel requireASelectedRow; +// +// final ListradioList = new LinkedList(); +// +// if (selectedContextField instanceof RadioGroup) { +// RadioGroup rg = (RadioGroup) selectedContextField; +// +// rg.visitChildren(new IVisitor() { +// +// /* (non-Javadoc) +// * @see org.apache.wicket.Component.IVisitor#component(org.apache.wicket.Component) +// */ +// public Object component(Component component) { +// +// if (component instanceof Radio) { +// +// radioList.add((Radio) component); +// } +// +// return IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER; +// } +// +// }); +// +// +// requireASelectedRow = createRadioRequireSelectedRowModel (radioList); +// +// } +// else { +// // String hidden field +// +// +// requireASelectedRow = new MarkupIDInStringModel( +// "if (Wicket.$('" + MarkupIDInStringModel.MARKUP_ID_TAG +// + "').value == '') {" +// + "\nalert ('A selected row is required.');" +// + "\nreturn false;" + "}", selectedContextField); +// } +// +// button = new DTAAjaxFallbackButton(BUTTON_ID, buttonProvider +// .getButtonLabelText(displayEntityName), this.form, +// requireASelectedRow); +// +// button.setSubmitAction(buttonAction); +// } +// else { + + button = new DTAAjaxFallbackButton(BUTTON_ID, + buttonProvider.getButtonLabelText(displayEntityName), form, buttonAction); +// } + String cssClass = buttonProvider.getCSSClassName(); - - if (cssClass != null) { + + if (cssClass != null) + { button.add(new AttributeModifier("class", true, new Model(cssClass))); } @@ -203,50 +211,55 @@ public void onSubmit(AjaxRequestTarget target, Form form) { } - private IModel createRadioRequireSelectedRowModel( - final List radioList) { - - return new LoadableDetachableModel() { + private IModel createRadioRequireSelectedRowModel(final List radioList) + { + + return new LoadableDetachableModel() + { /** * */ private static final long serialVersionUID = 8113932643386163719L; - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.model.LoadableDetachableModel#load() */ @Override - protected String load() { - + protected String load() + { + StringBuffer template = new StringBuffer(); - + template.append("if ("); - - - for (int i = 0; i < radioList.size(); i++) { - + + + for (int i = 0; i < radioList.size(); i++) + { + Radio radio = radioList.get(i); - - template.append ("(Wicket.$('"+ radio.getMarkupId(true) +"').checked == false)"); - - if (i > 0 && (i < (radioList.size()-1))) { - template.append (" and "); + + template.append("(Wicket.$('" + radio.getMarkupId(true) + + "').checked == false)"); + + if (i > 0 && (i < (radioList.size() - 1))) + { + template.append(" and "); } radio.setOutputMarkupId(true); } - - template.append("{" - + "\nalert ('A selected row is required.');" + + template.append("{" + "\nalert ('A selected row is required.');" + "\nreturn false;" + "\n}"); - - - + + return template.toString(); - + } - + }; - + } } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/column/DTARadioColumn.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/column/DTARadioColumn.java index caae6d7ef1..b3c1fb44a1 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/column/DTARadioColumn.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/table/column/DTARadioColumn.java @@ -30,23 +30,26 @@ /** * @author mocleiri * - * A radio for use where the table this column is added to is wrapped by a {@link RadioGroup} - * + * A radio for use where the table this column is added to is wrapped by a + * {@link RadioGroup} + * */ -public class DTARadioColumn extends AbstractColumn { +public class DTARadioColumn extends AbstractColumn +{ /** * */ private static final long serialVersionUID = -24109845922068732L; - private List>radioList = new LinkedList>(); - - + private List> radioList = new LinkedList>(); + + /** * @param displayModel */ - public DTARadioColumn(IModel displayModel) { + public DTARadioColumn(IModel displayModel) + { super(displayModel); // TODO Auto-generated constructor stub } @@ -54,50 +57,61 @@ public DTARadioColumn(IModel displayModel) { /** * @param columnName */ - public DTARadioColumn(String columnName) { - this (new Model(columnName)); + public DTARadioColumn(String columnName) + { + this(new Model(columnName)); } - /* (non-Javadoc) - * @see org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator#populateItem(org.apache.wicket.markup.repeater.Item, java.lang.String, org.apache.wicket.model.IModel) + /* + * (non-Javadoc) + * + * @see + * org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator#populateItem(org + * .apache.wicket.markup.repeater.Item, java.lang.String, org.apache.wicket.model.IModel) */ - public void populateItem(Item> cellItem, String componentId, IModel rowModel) { - + public void populateItem(Item> cellItem, String componentId, + IModel rowModel) + { + DTARadio rd; cellItem.add(rd = new DTARadio(componentId, rowModel)); - + rd.setOutputMarkupId(true); - + // should have a worst case size of visible page size. radioList.add(rd); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn#detach() */ @Override - public void detach() { + public void detach() + { super.detach(); -// this.radioList.clear(); - +// this.radioList.clear(); + } - + /** - * Get the markupid for the radio representing a specific row. Used to allow row onclick actions to trigger a radio selection DOM action. + * Get the markupid for the radio representing a specific row. Used to allow row onclick actions + * to trigger a radio selection DOM action. * * @param index - * @return the markup id for the radio for the row index given. + * @return the markup id for the radio for the row index given. */ - public final String getRadioMarkupID (int index) { + public final String getRadioMarkupID(int index) + { Radio radio = radioList.get(index); - + if (radio == null) return null; else return radio.getMarkupId(); } - - + } diff --git a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/util/StringUtils.java b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/util/StringUtils.java index 16fe2845b2..d76d1f3a0d 100644 --- a/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/util/StringUtils.java +++ b/jdk-1.5-parent/datatable-autocomplete-parent/datatable-autocomplete/src/main/java/org/wicketstuff/datatable_autocomplete/util/StringUtils.java @@ -21,24 +21,28 @@ * @author mocleiri * */ -public final class StringUtils { +public final class StringUtils +{ /** * */ - private StringUtils() { + private StringUtils() + { // TODO Auto-generated constructor stub } - public static String join(List c, String seperator) { + public static String join(List c, String seperator) + { return join(new StringBuffer(), c, seperator).toString(); } - - public static StringBuffer join(StringBuffer buf, List c, - String seperator) { - for (int i = 0; i < c.size() - 1; i++) { + public static StringBuffer join(StringBuffer buf, List c, String seperator) + { + + for (int i = 0; i < c.size() - 1; i++) + { String param = c.get(i); diff --git a/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/DemoApplication.java b/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/DemoApplication.java index 3b567aecc7..15194dbf82 100755 --- a/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/DemoApplication.java +++ b/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/DemoApplication.java @@ -19,12 +19,13 @@ import org.apache.wicket.Page; import org.apache.wicket.protocol.http.WebApplication; -public class DemoApplication extends WebApplication { +public class DemoApplication extends WebApplication +{ - @Override - public Class getHomePage() { - return HomePage.class; - } + @Override + public Class getHomePage() + { + return HomePage.class; + } } - diff --git a/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/HomePage.java b/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/HomePage.java index 1b7373ed72..497d3e8c34 100755 --- a/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/HomePage.java +++ b/jdk-1.5-parent/datatables-parent/datatables-examples/src/main/java/org/wicketstuff/datatables/demo/HomePage.java @@ -26,20 +26,25 @@ import org.apache.wicket.markup.html.list.ListView; import org.wicketstuff.datatables.DemoDatatable; -public class HomePage extends WebPage { +public class HomePage extends WebPage +{ - public HomePage() { + public HomePage() + { WebMarkupContainer table = new DemoDatatable("table"); add(table); List rows = new ArrayList(); - for (int i = 0; i < 50; i++) { + for (int i = 0; i < 50; i++) + { rows.add(new String[] { "Foo" + i, "Bar" + i, "fizzbuzz" + i }); } - ListView lv = new ListView("rows", rows) { + ListView lv = new ListView("rows", rows) + { @Override - protected void populateItem(ListItem item) { + protected void populateItem(ListItem item) + { String[] row = item.getModelObject(); item.add(new Label("col1", row[0])); diff --git a/jdk-1.5-parent/datatables-parent/datatables-examples/src/test/java/org/wicketstuff/RunWebApp.java b/jdk-1.5-parent/datatables-parent/datatables-examples/src/test/java/org/wicketstuff/RunWebApp.java index 6c49015fbe..1b504252fa 100644 --- a/jdk-1.5-parent/datatables-parent/datatables-examples/src/test/java/org/wicketstuff/RunWebApp.java +++ b/jdk-1.5-parent/datatables-parent/datatables-examples/src/test/java/org/wicketstuff/RunWebApp.java @@ -21,13 +21,15 @@ /** * Seperate startup class for people that want to run the examples directly. */ -public class RunWebApp { +public class RunWebApp +{ /** * Main function, starts the jetty server. - * + * * @param args */ - public static void main(String[] args) { + public static void main(String[] args) + { Server server = new Server(); SocketConnector connector = new SocketConnector(); connector.setPort(8080); @@ -39,9 +41,12 @@ public static void main(String[] args) { context.setWar("src/main/webapp"); server.setHandler(context); - try { + try + { server.start(); - } catch (Exception e) { + } + catch (Exception e) + { throw new RuntimeException(e); } diff --git a/jdk-1.5-parent/datatables-parent/datatables/src/main/java/org/wicketstuff/datatables/DemoDatatable.java b/jdk-1.5-parent/datatables-parent/datatables/src/main/java/org/wicketstuff/datatables/DemoDatatable.java index dd023fca66..d4acf43b07 100644 --- a/jdk-1.5-parent/datatables-parent/datatables/src/main/java/org/wicketstuff/datatables/DemoDatatable.java +++ b/jdk-1.5-parent/datatables-parent/datatables/src/main/java/org/wicketstuff/datatables/DemoDatatable.java @@ -6,11 +6,13 @@ import org.apache.wicket.model.Model; import org.apache.wicket.request.resource.PackageResourceReference; -public class DemoDatatable extends WebMarkupContainer { +public class DemoDatatable extends WebMarkupContainer +{ private static final long serialVersionUID = -4387194295178034384L; - public DemoDatatable(String id) { + public DemoDatatable(String id) + { super(id); setOutputMarkupId(true); @@ -18,7 +20,8 @@ public DemoDatatable(String id) { } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { renderDemoCSS(response); renderBasicJS(response); @@ -33,28 +36,29 @@ public void renderHead(IHeaderResponse response) { response.renderJavaScript(js, getId() + "_datatables"); } - private void renderDemoCSS(IHeaderResponse response) { + private void renderDemoCSS(IHeaderResponse response) + { final Class _ = DemoDatatable.class; - response.renderCSSReference(new PackageResourceReference(_, - "media/css/demo_table_jui.css"), "screen"); + response.renderCSSReference( + new PackageResourceReference(_, "media/css/demo_table_jui.css"), "screen"); - response.renderCSSReference(new PackageResourceReference(_, - "media/css/" + getJUITheme() + "/jquery-ui-1.8.10.custom.css"), - "screen"); + response.renderCSSReference(new PackageResourceReference(_, "media/css/" + getJUITheme() + + "/jquery-ui-1.8.10.custom.css"), "screen"); } - private String getJUITheme() { + private String getJUITheme() + { return "smoothness"; } - private void renderBasicJS(IHeaderResponse response) { + private void renderBasicJS(IHeaderResponse response) + { final Class _ = DemoDatatable.class; + response.renderJavaScriptReference(new PackageResourceReference(_, "media/js/jquery.js")); response.renderJavaScriptReference(new PackageResourceReference(_, - "media/js/jquery.js")); + "media/js/jquery.dataTables.min.js")); response.renderJavaScriptReference(new PackageResourceReference(_, - "media/js/jquery.dataTables.min.js")); - response.renderJavaScriptReference(new PackageResourceReference(_, - "media/js/jquery-ui-1.8.10.custom.min.js")); + "media/js/jquery-ui-1.8.10.custom.min.js")); } } diff --git a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/ExampleHomePage.java b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/ExampleHomePage.java index 88a2ae9cbb..27c239dafb 100644 --- a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/ExampleHomePage.java +++ b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/ExampleHomePage.java @@ -23,25 +23,27 @@ /** * Homepage to test Wicket-EidoGo player functionalities. */ -public class ExampleHomePage extends WebPage { +public class ExampleHomePage extends WebPage +{ private static final long serialVersionUID = 1L; - /** + /** * Constructor that is invoked when page is invoked without a session. * * @param parameters * Page parameters */ - public ExampleHomePage(final PageParameters parameters) { - // Add an example of eidogo player. - Eidogo eidogo = new Eidogo("eidogo", "/sgf/example.sgf"); + public ExampleHomePage(final PageParameters parameters) + { + // Add an example of eidogo player. + Eidogo eidogo = new Eidogo("eidogo", "/sgf/example.sgf"); add(eidogo); eidogo.setShowComments(true); eidogo.setShowGameInfo(true); eidogo.setShowOtions(true); eidogo.setShowPlayerInfo(true); eidogo.setShowTools(true); - } + } } diff --git a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/WicketApplication.java b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/WicketApplication.java index 1478a23c9b..ee7ffa5f44 100644 --- a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/WicketApplication.java +++ b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/main/java/org/wicketstuff/eidogo/example/WicketApplication.java @@ -3,19 +3,20 @@ 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. + * Application object for your web application. If you want to run this application without + * deploying, run the Start class. * * @see org.wicketstuff.eidogo.example.Start#main(String[]) */ public class WicketApplication extends WebApplication -{ - /** - * Constructor - */ +{ + /** + * Constructor + */ public WicketApplication() { } - + /** * @see org.apache.wicket.Application#getHomePage() */ diff --git a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/Start.java b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/Start.java index b72ee58388..93c1b47383 100644 --- a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/Start.java +++ b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/Start.java @@ -5,12 +5,14 @@ import org.eclipse.jetty.server.bio.SocketConnector; import org.eclipse.jetty.webapp.WebAppContext; -public class Start { +public class Start +{ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception + { Server server = new Server(); SocketConnector connector = new SocketConnector(); - + // Set some timeout options to make debugging easier. connector.setMaxIdleTime(1000 * 60 * 60); connector.setSoLingerTime(-1); @@ -21,26 +23,29 @@ public static void main(String[] args) throws Exception { bb.setServer(server); bb.setContextPath("/"); bb.setWar("src/main/webapp"); - + // START JMX SERVER // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); // server.getContainer().addEventListener(mBeanContainer); // mBeanContainer.start(); - + server.setHandler(bb); - try { + try + { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); System.in.read(); - System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); - // while (System.in.available() == 0) { - // Thread.sleep(5000); + System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); + // while (System.in.available() == 0) { + // Thread.sleep(5000); // } server.stop(); server.join(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); System.exit(100); } diff --git a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/TestHomePage.java b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/TestHomePage.java index 5d7f80db8d..17be3cd5b2 100644 --- a/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/TestHomePage.java +++ b/jdk-1.5-parent/eidogo-parent/eidogo-example/src/test/java/org/wicketstuff/eidogo/example/TestHomePage.java @@ -36,13 +36,13 @@ public void setUp() public void testRenderMyPage() { - //start and render the test page + // start and render the test page tester.startPage(ExampleHomePage.class); - //assert rendered page class + // assert rendered page class tester.assertRenderedPage(ExampleHomePage.class); - //assert rendered label component + // assert rendered label component tester.assertComponent("eidogo", Eidogo.class); } } diff --git a/jdk-1.5-parent/eidogo-parent/eidogo/src/main/java/org/wicketstuff/eidogo/Eidogo.java b/jdk-1.5-parent/eidogo-parent/eidogo/src/main/java/org/wicketstuff/eidogo/Eidogo.java index 44a9f009ff..402416ccc5 100644 --- a/jdk-1.5-parent/eidogo-parent/eidogo/src/main/java/org/wicketstuff/eidogo/Eidogo.java +++ b/jdk-1.5-parent/eidogo-parent/eidogo/src/main/java/org/wicketstuff/eidogo/Eidogo.java @@ -42,8 +42,10 @@ * Page.java : * *
- * public class Page extends WebPage {
- * 	public Page() {
+ * public class Page extends WebPage
+ * {
+ * 	public Page()
+ * 	{
  * 		add(new Eidogo("eidogo"));
  * 	}
  * }
@@ -57,17 +59,18 @@
  * 
  * @author Isammoc
  */
-public class Eidogo extends WebComponent implements IHeaderContributor {
+public class Eidogo extends WebComponent implements IHeaderContributor
+{
 
 	/** */
 	private static final long serialVersionUID = 1L;
 
 	/** Reference to the javascript resource. */
-	private static final ResourceReference JS = new JavaScriptResourceReference(
-			Eidogo.class, "js/all.compressed.js");
+	private static final ResourceReference JS = new JavaScriptResourceReference(Eidogo.class,
+		"js/all.compressed.js");
 	/** Reference to the CSS resource. */
-	private static final ResourceReference CSS = new PackageResourceReference(
-			Eidogo.class, "css/player.css");
+	private static final ResourceReference CSS = new PackageResourceReference(Eidogo.class,
+		"css/player.css");
 
 	/** true to show comments in the player. */
 	private boolean showComments;
@@ -101,7 +104,8 @@ public class Eidogo extends WebComponent implements IHeaderContributor {
 	 * 
 	 * @author Isammoc
 	 */
-	public enum Theme {
+	public enum Theme
+	{
 		/** Standard theme. */
 		STANDARD("standard");
 		/** The value in the JSon. */
@@ -113,7 +117,8 @@ public enum Theme {
 		 * @param value
 		 *            Value to store.
 		 */
-		private Theme(String value) {
+		private Theme(String value)
+		{
 			this.value = value;
 		}
 
@@ -123,8 +128,9 @@ private Theme(String value) {
 		 * @return the JSon value
 		 */
 		@Override
-		public String toString() {
-			return this.value;
+		public String toString()
+		{
+			return value;
 		}
 	}
 
@@ -133,44 +139,38 @@ public String toString() {
 	 * 
 	 * @author Isammoc
 	 */
-	public enum Mode {
+	public enum Mode
+	{
 		/** Play mode. Allows user to play the game. */
 		PLAY("play"),
 		/**
-		 * Add black stone mode. Allows user to add as many black stones as
-		 * (s)he wants.
+		 * Add black stone mode. Allows user to add as many black stones as (s)he wants.
 		 */
 		ADD_BLACK("add_b"),
 		/**
-		 * Add white stone mode. Allows user to add as many white stones as
-		 * (s)he wants.
+		 * Add white stone mode. Allows user to add as many white stones as (s)he wants.
 		 */
 		ADD_WHITE("add_w"),
 		/** Region mode. Allows user to mark a region. */
 		REGION("region"),
 		/**
-		 * Triangle mode. Allows user to mark stone and/or intersection with a
-		 * triangle.
+		 * Triangle mode. Allows user to mark stone and/or intersection with a triangle.
 		 */
 		TRIANGLE("tr"),
 		/**
-		 * Square mode. Allows user to mark stone and/or intersection with a
-		 * square.
+		 * Square mode. Allows user to mark stone and/or intersection with a square.
 		 */
 		SQUARE("sq"),
 		/**
-		 * Circle mode. Allows user to mark stone and/or intersection with a
-		 * circle.
+		 * Circle mode. Allows user to mark stone and/or intersection with a circle.
 		 */
 		CIRCLE("cr"),
 		/**
-		 * Label mode. Allows user to mark stone and/or intersection with a
-		 * letter.
+		 * Label mode. Allows user to mark stone and/or intersection with a letter.
 		 */
 		LABEL("label"),
 		/**
-		 * Number mode. Allows user to mark stone and/or intersection with a
-		 * number.
+		 * Number mode. Allows user to mark stone and/or intersection with a number.
 		 */
 		NUMBER("number"),
 		/** Score mode. Allows user to view score. */
@@ -185,7 +185,8 @@ public enum Mode {
 		 * @param value
 		 *            The JSon value to store.
 		 */
-		private Mode(String value) {
+		private Mode(String value)
+		{
 			this.value = value;
 		}
 
@@ -195,8 +196,9 @@ private Mode(String value) {
 		 * @return the JSon value
 		 */
 		@Override
-		public String toString() {
-			return this.value;
+		public String toString()
+		{
+			return value;
 		}
 	}
 
@@ -206,7 +208,8 @@ public String toString() {
 	 * @param id
 	 *            Wicket ID of the component
 	 */
-	public Eidogo(String id) {
+	public Eidogo(String id)
+	{
 		this(id, null);
 	}
 
@@ -218,20 +221,21 @@ public Eidogo(String id) {
 	 * @param sgfUrl
 	 *            URL to the SGF file
 	 */
-	public Eidogo(String id, String sgfUrl) {
+	public Eidogo(String id, String sgfUrl)
+	{
 		super(id);
 		this.sgfUrl = sgfUrl;
 	}
 
 	/**
-	 * Renders links to the needed javascript and the CSS in the head of
-	 * response.
+	 * Renders links to the needed javascript and the CSS in the head of response.
 	 * 
 	 * @param response
 	 *            The header response to contribute to.
 	 */
 	@Override
-	public void renderHead(IHeaderResponse response) {
+	public void renderHead(IHeaderResponse response)
+	{
 		response.renderJavaScriptReference(JS);
 		response.renderCSSReference(CSS);
 		super.renderHead(response);
@@ -241,10 +245,12 @@ public void renderHead(IHeaderResponse response) {
 	 * Checks that component tag is a <div> and adds a markup id.
 	 */
 	@Override
-	protected void onComponentTag(ComponentTag tag) {
+	protected void onComponentTag(ComponentTag tag)
+	{
 		checkComponentTag(tag, "div");
-		this.setOutputMarkupId(true);
-		if (tag.isOpenClose()) {
+		setOutputMarkupId(true);
+		if (tag.isOpenClose())
+		{
 			tag.setType(XmlTag.TagType.OPEN);
 		}
 		super.onComponentTag(tag);
@@ -254,30 +260,26 @@ protected void onComponentTag(ComponentTag tag) {
 	 * Renders a javascript component to create the player.
 	 */
 	@Override
-	public void onComponentTagBody(MarkupStream markupStream,
-			ComponentTag openTag) {
+	public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
+	{
 		super.onComponentTagBody(markupStream, openTag);
 		replaceComponentTagBody(markupStream, openTag, null);
 		JavaScriptUtils.writeJavaScript(getResponse(),
-				"new eidogo.Player({container:\"" + getMarkupId()
-						+ "\",theme:\"" + theme + "\"," + "sgfUrl:\""
-						+ getResponse().encodeURL(sgfUrl) + "\","
-						+ "loadPath:[0, 0]" + ",mode:\"" + mode + "\","
-						+ "showComments:" + showComments + ","
-						+ "showPlayerInfo:" + showPlayerInfo + ","
-						+ "showGameInfo:" + showGameInfo + "," + "showTools:"
-						+ showTools + "," + "showOptions:" + showOptions + ","
-						+ "markCurrent:" + markCurrent + ","
-						+ "markVariations:" + markVariation + "," + "markNext:"
-						+ markNext + "," + "enableShortcuts:" + enableShortcuts
-						+ "," + "problemMode:" + problemMode + "});");
+			"new eidogo.Player({container:\"" + getMarkupId() + "\",theme:\"" + theme + "\"," +
+				"sgfUrl:\"" + getResponse().encodeURL(sgfUrl) + "\"," + "loadPath:[0, 0]" +
+				",mode:\"" + mode + "\"," + "showComments:" + showComments + "," +
+				"showPlayerInfo:" + showPlayerInfo + "," + "showGameInfo:" + showGameInfo + "," +
+				"showTools:" + showTools + "," + "showOptions:" + showOptions + "," +
+				"markCurrent:" + markCurrent + "," + "markVariations:" + markVariation + "," +
+				"markNext:" + markNext + "," + "enableShortcuts:" + enableShortcuts + "," +
+				"problemMode:" + problemMode + "});");
 	}
 
 	/**
-	 * @return true if comments must be shown, false
-	 *         otherwise.
+	 * @return true if comments must be shown, false otherwise.
 	 */
-	public boolean isShowComments() {
+	public boolean isShowComments()
+	{
 		return showComments;
 	}
 
@@ -285,18 +287,18 @@ public boolean isShowComments() {
 	 * Set the visibility of the comments.
 	 * 
 	 * @param showComments
-	 *            true if comments must be shown,
-	 *            false otherwise.
+	 *            true if comments must be shown, false otherwise.
 	 */
-	public void setShowComments(boolean showComments) {
+	public void setShowComments(boolean showComments)
+	{
 		this.showComments = showComments;
 	}
 
 	/**
-	 * @return true if players information must be shown,
-	 *         false otherwise
+	 * @return true if players information must be shown, false otherwise
 	 */
-	public boolean isShowPlayerInfo() {
+	public boolean isShowPlayerInfo()
+	{
 		return showPlayerInfo;
 	}
 
@@ -304,18 +306,19 @@ public boolean isShowPlayerInfo() {
 	 * Set the visibility of players information.
 	 * 
 	 * @param showPlayerInfo
-	 *            true if players information must be shown,
-	 *            false otherwise
+	 *            true if players information must be shown, false
+	 *            otherwise
 	 */
-	public void setShowPlayerInfo(boolean showPlayerInfo) {
+	public void setShowPlayerInfo(boolean showPlayerInfo)
+	{
 		this.showPlayerInfo = showPlayerInfo;
 	}
 
 	/**
-	 * @return true if game information must be shown,
-	 *         false otherwise
+	 * @return true if game information must be shown, false otherwise
 	 */
-	public boolean isShowGameInfo() {
+	public boolean isShowGameInfo()
+	{
 		return showGameInfo;
 	}
 
@@ -323,18 +326,18 @@ public boolean isShowGameInfo() {
 	 * Set the visibility of game information.
 	 * 
 	 * @param showGameInfo
-	 *            true if game information must be shown,
-	 *            false otherwise
+	 *            true if game information must be shown, false otherwise
 	 */
-	public void setShowGameInfo(boolean showGameInfo) {
+	public void setShowGameInfo(boolean showGameInfo)
+	{
 		this.showGameInfo = showGameInfo;
 	}
 
 	/**
-	 * @return true if tools must be shown, false
-	 *         otherwise
+	 * @return true if tools must be shown, false otherwise
 	 */
-	public boolean isShowTools() {
+	public boolean isShowTools()
+	{
 		return showTools;
 	}
 
@@ -342,18 +345,18 @@ public boolean isShowTools() {
 	 * Set the visibility of the tools.
 	 * 
 	 * @param showTools
-	 *            true if tools must be shown, false
-	 *            otherwise
+	 *            true if tools must be shown, false otherwise
 	 */
-	public void setShowTools(boolean showTools) {
+	public void setShowTools(boolean showTools)
+	{
 		this.showTools = showTools;
 	}
 
 	/**
-	 * @return true if options must be shown, false
-	 *         otherwise
+	 * @return true if options must be shown, false otherwise
 	 */
-	public boolean isShowOtions() {
+	public boolean isShowOtions()
+	{
 		return showOptions;
 	}
 
@@ -361,18 +364,18 @@ public boolean isShowOtions() {
 	 * Set the visibility of the options.
 	 * 
 	 * @param showOtions
-	 *            true if options must be shown, false
-	 *            otherwise
+	 *            true if options must be shown, false otherwise
 	 */
-	public void setShowOtions(boolean showOtions) {
-		this.showOptions = showOtions;
+	public void setShowOtions(boolean showOtions)
+	{
+		showOptions = showOtions;
 	}
 
 	/**
-	 * @return true if current stone must be marked,
-	 *         false otherwise
+	 * @return true if current stone must be marked, false otherwise
 	 */
-	public boolean isMarkCurrent() {
+	public boolean isMarkCurrent()
+	{
 		return markCurrent;
 	}
 
@@ -380,18 +383,18 @@ public boolean isMarkCurrent() {
 	 * Set the visibility of the mark on the last played stone.
 	 * 
 	 * @param markCurrent
-	 *            true if current stone must be marked,
-	 *            false otherwise
+	 *            true if current stone must be marked, false otherwise
 	 */
-	public void setMarkCurrent(boolean markCurrent) {
+	public void setMarkCurrent(boolean markCurrent)
+	{
 		this.markCurrent = markCurrent;
 	}
 
 	/**
-	 * @return true if variation positions must be marked,
-	 *         false otherwise
+	 * @return true if variation positions must be marked, false otherwise
 	 */
-	public boolean isMarkVariation() {
+	public boolean isMarkVariation()
+	{
 		return markVariation;
 	}
 
@@ -399,18 +402,19 @@ public boolean isMarkVariation() {
 	 * Enable or disable the mark on variation positions.
 	 * 
 	 * @param markVariation
-	 *            true if variation positions must be marked,
-	 *            false otherwise
+	 *            true if variation positions must be marked, false
+	 *            otherwise
 	 */
-	public void setMarkVariation(boolean markVariation) {
+	public void setMarkVariation(boolean markVariation)
+	{
 		this.markVariation = markVariation;
 	}
 
 	/**
-	 * @return true if the next position must be marked,
-	 *         false otherwise
+	 * @return true if the next position must be marked, false otherwise
 	 */
-	public boolean isMarkNext() {
+	public boolean isMarkNext()
+	{
 		return markNext;
 	}
 
@@ -418,18 +422,19 @@ public boolean isMarkNext() {
 	 * Enable or disable the mark on the position of the next move.
 	 * 
 	 * @param markNext
-	 *            true if the next position must be marked,
-	 *            false otherwise
+	 *            true if the next position must be marked, false
+	 *            otherwise
 	 */
-	public void setMarkNext(boolean markNext) {
+	public void setMarkNext(boolean markNext)
+	{
 		this.markNext = markNext;
 	}
 
 	/**
-	 * @return true if shortcuts are enabled, false
-	 *         otherwise
+	 * @return true if shortcuts are enabled, false otherwise
 	 */
-	public boolean isEnableShortcuts() {
+	public boolean isEnableShortcuts()
+	{
 		return enableShortcuts;
 	}
 
@@ -437,18 +442,18 @@ public boolean isEnableShortcuts() {
 	 * Enable or disable the keyboard shortcuts.
 	 * 
 	 * @param enableShortcuts
-	 *            true if shortcuts are enabled, false
-	 *            otherwise
+	 *            true if shortcuts are enabled, false otherwise
 	 */
-	public void setEnableShortcuts(boolean enableShortcuts) {
+	public void setEnableShortcuts(boolean enableShortcuts)
+	{
 		this.enableShortcuts = enableShortcuts;
 	}
 
 	/**
-	 * @return true if eidogo player is in problem mode,
-	 *         false otherwise
+	 * @return true if eidogo player is in problem mode, false otherwise
 	 */
-	public boolean isProblemMode() {
+	public boolean isProblemMode()
+	{
 		return problemMode;
 	}
 
@@ -456,10 +461,11 @@ public boolean isProblemMode() {
 	 * Enable or disable problem mode
 	 * 
 	 * @param problemMode
-	 *            true if eidogo player is in problem mode,
-	 *            false otherwise
+	 *            true if eidogo player is in problem mode, false
+	 *            otherwise
 	 */
-	public void setProblemMode(boolean problemMode) {
+	public void setProblemMode(boolean problemMode)
+	{
 		this.problemMode = problemMode;
 	}
 }
diff --git a/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/HomePage.java b/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/HomePage.java
index 97556c0205..3d2d5973d0 100644
--- a/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/HomePage.java
+++ b/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/HomePage.java
@@ -15,7 +15,8 @@
 /**
  * Homepage
  */
-public class HomePage extends WebPage {
+public class HomePage extends WebPage
+{
 
 	private static final long serialVersionUID = 1L;
 
@@ -25,7 +26,8 @@ public class HomePage extends WebPage {
 	 * @param parameters
 	 *            Page parameters
 	 */
-	public HomePage(final PageParameters parameters) {
+	public HomePage(final PageParameters parameters)
+	{
 		FlotPanel panel = new FlotPanel("flotPanel", new PropertyModel>(this, "data"));
 		panel.setAxisMinX(-5.0);
 		panel.setAxisMaxX(5.0);
@@ -34,14 +36,16 @@ public HomePage(final PageParameters parameters) {
 		add(panel);
 	}
 
-	public List getData() {
+	public List getData()
+	{
 		List result = new ArrayList();
 
 		List sine = new ArrayList();
 		for (double x = -5.0; x < 5.0; x += 0.1)
 			sine.add(new DataSet(x, Math.sin(x)));
 
-		result.add(new Series(sine, "sin(x)", new Color(0x00, 0x89, 0xBB), new LineGraphType(null, false, null)));
+		result.add(new Series(sine, "sin(x)", new Color(0x00, 0x89, 0xBB), new LineGraphType(null,
+			false, null)));
 
 		return result;
 	}
diff --git a/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/WicketApplication.java b/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/WicketApplication.java
index c5788ae411..7c82b00221 100644
--- a/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/WicketApplication.java
+++ b/jdk-1.5-parent/flot-parent/flot-examples/src/main/java/org/wicketstuff/flot/examples/WicketApplication.java
@@ -3,19 +3,20 @@
 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.
+ * Application object for your web application. If you want to run this application without
+ * deploying, run the Start class.
  * 
  * @see org.wicketstuff.flot.examples.Start#main(String[])
  */
 public class WicketApplication extends WebApplication
-{    
-    /**
-     * Constructor
-     */
+{
+	/**
+	 * Constructor
+	 */
 	public WicketApplication()
 	{
 	}
-	
+
 	/**
 	 * @see org.apache.wicket.Application#getHomePage()
 	 */
diff --git a/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/Start.java b/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/Start.java
index f5bc50887c..89e04bfff5 100644
--- a/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/Start.java
+++ b/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/Start.java
@@ -5,12 +5,14 @@
 import org.eclipse.jetty.server.bio.SocketConnector;
 import org.eclipse.jetty.webapp.WebAppContext;
 
-public class Start {
+public class Start
+{
 
-	public static void main(String[] args) throws Exception {
+	public static void main(String[] args) throws Exception
+	{
 		Server server = new Server();
 		SocketConnector connector = new SocketConnector();
-		
+
 		// Set some timeout options to make debugging easier.
 		connector.setMaxIdleTime(1000 * 60 * 60);
 		connector.setSoLingerTime(-1);
@@ -21,26 +23,29 @@ public static void main(String[] args) throws Exception {
 		bb.setServer(server);
 		bb.setContextPath("/");
 		bb.setWar("src/main/webapp");
-		
+
 		// START JMX SERVER
 		// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
 		// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
 		// server.getContainer().addEventListener(mBeanContainer);
 		// mBeanContainer.start();
-		
+
 		server.setHandler(bb);
 
-		try {
+		try
+		{
 			System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
 			server.start();
 			System.in.read();
-			System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); 
-            // while (System.in.available() == 0) {
-			//   Thread.sleep(5000);
+			System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
+			// while (System.in.available() == 0) {
+			// Thread.sleep(5000);
 			// }
 			server.stop();
 			server.join();
-		} catch (Exception e) {
+		}
+		catch (Exception e)
+		{
 			e.printStackTrace();
 			System.exit(100);
 		}
diff --git a/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/TestHomePage.java b/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/TestHomePage.java
index b85e865ec2..6ce38f7ec1 100644
--- a/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/TestHomePage.java
+++ b/jdk-1.5-parent/flot-parent/flot-examples/src/test/java/org/wicketstuff/flot/examples/TestHomePage.java
@@ -19,13 +19,14 @@ public void setUp()
 
 	public void testRenderMyPage()
 	{
-		//start and render the test page
+		// start and render the test page
 		tester.startPage(HomePage.class);
 
-		//assert rendered page class
+		// assert rendered page class
 		tester.assertRenderedPage(HomePage.class);
 
-		//assert rendered label component
-		tester.assertLabel("message", "If you see this message wicket is properly configured and running");
+		// assert rendered label component
+		tester.assertLabel("message",
+			"If you see this message wicket is properly configured and running");
 	}
 }
diff --git a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/BarGraphType.java b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/BarGraphType.java
index f7f865a3ed..dcac663dce 100644
--- a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/BarGraphType.java
+++ b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/BarGraphType.java
@@ -21,57 +21,67 @@
 /**
  * 
  * @author Michael Würtinger (mwuertinger@users.sourceforge.net)
- *
+ * 
  */
-public class BarGraphType extends GraphType {
+public class BarGraphType extends GraphType
+{
 	/** Required by {@link Serializable} */
 	private static final long serialVersionUID = 1L;
 
-	public enum Align {LEFT, CENTER};
-	
+	public enum Align
+	{
+		LEFT, CENTER
+	};
+
 	private Double barWidth;
 	private Align align;
-	
-	public BarGraphType(Double lineWidth, Boolean fill, Color fillColor, Double barWidth, Align align) {
+
+	public BarGraphType(Double lineWidth, Boolean fill, Color fillColor, Double barWidth,
+		Align align)
+	{
 		super(lineWidth, fill, fillColor);
 		this.barWidth = barWidth;
 		this.align = align;
 	}
-	
+
 	@Override
-	public String toString() {
+	public String toString()
+	{
 		StringBuffer str = new StringBuffer();
-		
+
 		str.append("bars: {");
-		
+
 		String superStr = super.toString();
-		
-		if(barWidth != null) {
+
+		if (barWidth != null)
+		{
 			str.append("barWidth: ");
 			str.append(barWidth);
-			if(align != null || superStr.length()>0)
+			if (align != null || superStr.length() > 0)
 				str.append(", ");
 		}
 
-		if(align != null) {
+		if (align != null)
+		{
 			str.append("align: ");
-			switch(align) {
-			case LEFT:
-				str.append("\"left\"");
-				break;
-			case CENTER:
-				str.append("\"center\"");
-				break;
+			switch (align)
+			{
+				case LEFT :
+					str.append("\"left\"");
+					break;
+				case CENTER :
+					str.append("\"center\"");
+					break;
 			}
-			
-			if(superStr.length()>0)
+
+			if (superStr.length() > 0)
 				str.append(", ");
 		}
-		
+
 		str.append(superStr);
-		
+
 		str.append("}");
-		
+
 		return str.toString();
 	}
 }
diff --git a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/Color.java b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/Color.java
index 612e017f81..13ea1e6f45 100644
--- a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/Color.java
+++ b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/Color.java
@@ -21,7 +21,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class Color implements Serializable {
+public class Color implements Serializable
+{
 	/** Required by {@link Serializable} */
 	private static final long serialVersionUID = 1L;
 
@@ -33,47 +34,57 @@ public class Color implements Serializable {
 	public static final Color BLUE = new Color(0.0, 0.0, 1.0);
 	public static final Color GREEN = new Color(0.0, 1.0, 0.0);
 	public static final Color RED = new Color(1.0, 0.0, 0.0);
-	
+
 	private float r, b, g;
-	
-	public Color(int r, int g, int b) {
-		if(r<0 || g<0 || b<0 || r>255 || g>255 || b>255)
-			throw new IllegalArgumentException("Arguments have to be between 0 (inclusive) and 256 (exclusive)");
-		this.r = (float) (r/255.0);
-		this.g = (float) (g/255.0);
-		this.b = (float) (b/255.0);
+
+	public Color(int r, int g, int b)
+	{
+		if (r < 0 || g < 0 || b < 0 || r > 255 || g > 255 || b > 255)
+			throw new IllegalArgumentException(
+				"Arguments have to be between 0 (inclusive) and 256 (exclusive)");
+		this.r = (float)(r / 255.0);
+		this.g = (float)(g / 255.0);
+		this.b = (float)(b / 255.0);
 	}
-	
-	public Color(double r, double g, double b) {
-		if(r<0.0 || g<0.0 || b<0.0 || r>1.0 || g>1.0 || b>1.0)
-			throw new IllegalArgumentException("Arguments have to be between 0 (inclusive) and 1.0 (inclusive)");
-		this.r = (float) r;
-		this.g = (float) g;
-		this.b = (float) b;
+
+	public Color(double r, double g, double b)
+	{
+		if (r < 0.0 || g < 0.0 || b < 0.0 || r > 1.0 || g > 1.0 || b > 1.0)
+			throw new IllegalArgumentException(
+				"Arguments have to be between 0 (inclusive) and 1.0 (inclusive)");
+		this.r = (float)r;
+		this.g = (float)g;
+		this.b = (float)b;
 	}
-	
-	public float red() {
+
+	public float red()
+	{
 		return r;
 	}
-	
-	public float green() {
+
+	public float green()
+	{
 		return g;
 	}
-	
-	public float blue() {
+
+	public float blue()
+	{
 		return b;
 	}
-	
-	public String html() {
-		return String.format("#%02X%02X%02X", (int)(r*255.0), (int)(g*255.0), (int)(b*255.0));
+
+	public String html()
+	{
+		return String.format("#%02X%02X%02X", (int)(r * 255.0), (int)(g * 255.0), (int)(b * 255.0));
 	}
-	
+
 	@Override
-	public String toString() {
+	public String toString()
+	{
 		return String.format("rgb(%.1f, %.1f, %.1f), html(%s)", r, g, b, html());
 	}
 
-	public static Color random() {
+	public static Color random()
+	{
 		Random random = new Random();
 		Color color = new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256));
 		return color;
@@ -81,27 +92,38 @@ public static Color random() {
 
 	/**
 	 * Crops the value to the specified range.
-	 * @param min The minimum value of the range.
-	 * @param max The maximum value of the range.
-	 * @param value A value which has to be cropped.
+	 * 
+	 * @param min
+	 *            The minimum value of the range.
+	 * @param max
+	 *            The maximum value of the range.
+	 * @param value
+	 *            A value which has to be cropped.
 	 * @return cropped value.
 	 */
-	private static float limit(float min, float max, float value) {
+	private static float limit(float min, float max, float value)
+	{
 		return (float)Math.max(0.0, Math.min(max, value));
 	}
-	
+
 	/**
-	 * Returns a copy of this color the values of which are multiplied with the according factors and cropped to 0..1.
-	 * @param fr The factor for red.
-	 * @param fg The factor for green.
-	 * @param fb The factor for blue.
+	 * Returns a copy of this color the values of which are multiplied with the according factors
+	 * and cropped to 0..1.
+	 * 
+	 * @param fr
+	 *            The factor for red.
+	 * @param fg
+	 *            The factor for green.
+	 * @param fb
+	 *            The factor for blue.
 	 * @return scaled copy.
 	 */
-	public Color scale(float fr, float fg, float fb) {
-		float r = limit(0, 1, this.r*fr);
-		float g = limit(0, 1, this.g*fg);
-		float b = limit(0, 1, this.b*fb);
-		
+	public Color scale(float fr, float fg, float fb)
+	{
+		float r = limit(0, 1, this.r * fr);
+		float g = limit(0, 1, this.g * fg);
+		float b = limit(0, 1, this.b * fb);
+
 		return new Color(r, g, b);
 	}
 }
diff --git a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/DataSet.java b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/DataSet.java
index 1e6cb0e9f2..a8358e2706 100644
--- a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/DataSet.java
+++ b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/DataSet.java
@@ -20,33 +20,39 @@
 
 import org.joda.time.DateTime;
 
-public class DataSet implements Serializable {
+public class DataSet implements Serializable
+{
 	/** Required by {@link Serializable} */
 	private static final long serialVersionUID = 1L;
 
 	private double x;
 	private double y;
-	
-	public DataSet(double x, double y) {
+
+	public DataSet(double x, double y)
+	{
 		this.x = x;
 		this.y = y;
 	}
-	
-	public DataSet(DateTime time, double value) {
-		this.x = time.getMillis();
-		this.y = value;
+
+	public DataSet(DateTime time, double value)
+	{
+		x = time.getMillis();
+		y = value;
 	}
-	
-	public double getX() {
+
+	public double getX()
+	{
 		return x;
 	}
-	
-	public double getY() {
+
+	public double getY()
+	{
 		return y;
 	}
-	
+
 	@Override
-	public String toString() {
+	public String toString()
+	{
 		return String.format(Locale.US, "[%f, %f]", x, y);
 	}
 }
diff --git a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/FlotPanel.java b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/FlotPanel.java
index de78fb778f..98a0dcffb2 100644
--- a/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/FlotPanel.java
+++ b/jdk-1.5-parent/flot-parent/flot/src/main/java/org/wicketstuff/flot/FlotPanel.java
@@ -35,261 +35,314 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class FlotPanel extends Panel {
+public class FlotPanel extends Panel
+{
 	/** Required by {@link Serializable} */
 	private static final long serialVersionUID = 1L;
 
 	private static final Logger LOGGER = LoggerFactory.getLogger(FlotPanel.class);
 
 	private Map> options = new HashMap>();
-    private boolean showTooltip = false;
+	private boolean showTooltip = false;
 
-    public FlotPanel(final String id, final IModel> model) {
+	public FlotPanel(final String id, final IModel> model)
+	{
 		super(id, model);
-		
-		String[] optionsKeys = {"lines", "points", "legend", "xaxis", "yaxis", "x2axis", "y2axis", "selection", "grid"};
-		
-		for(String key : optionsKeys)
+
+		String[] optionsKeys = { "lines", "points", "legend", "xaxis", "yaxis", "x2axis", "y2axis",
+				"selection", "grid" };
+
+		for (String key : optionsKeys)
 			options.put(key, new HashMap());
-		
+
 		options.get("selection").put("mode", "xy");
 		options.get("grid").put("hoverable", true);
 		options.get("grid").put("clickable", true);
 
-        // JN - commented out to allow autoscaling if not set
-		//options.get("yaxis").put("min", 0);
-		//options.get("yaxis").put("max", 15);
-		
+		// JN - commented out to allow autoscaling if not set
+		// options.get("yaxis").put("min", 0);
+		// options.get("yaxis").put("max", 15);
+
 		// This custom component fills the ");
-        }
-    }
-
-    /**
-     * @param updateInterval
-     *            Duration between AJAX callbacks
-     * @return JS script
-     */
-    protected final String getJsTimeoutCall(final Duration updateInterval) {
-        return "window.GmapAutoTimer = setTimeout(\"" + getCallbackScript() + "\", " + updateInterval.getMilliseconds() + ");";
-    }
-
-    /**
-     * 
-     * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(org.apache.wicket.ajax.AjaxRequestTarget)
-     */
-    @Override
-	protected final void respond(final AjaxRequestTarget target) {
-    	if(!stopped) {
-    		target.appendJavaScript(getJsTimeoutCall(updateInterval));
-    	}
-        onTimer(target, getGMap2());
-    }
-
-    /**
-     * Listener method for the AJAX timer event.
-     * 
-     * @param target
-     *            The request target
-     */
-    protected abstract void onTimer(final AjaxRequestTarget target, GMap2 map);
+	/**
+	 * Stops the timer
+	 */
+	public final void stop()
+	{
+		stopped = true;
+	}
+
+	@Override
+	protected void onComponentRendered()
+	{
+		if (!stopped)
+		{
+			Response response = RequestCycle.get().getResponse();
+			response.write("");
+		}
+	}
+
+	/**
+	 * @param updateInterval
+	 *            Duration between AJAX callbacks
+	 * @return JS script
+	 */
+	protected final String getJsTimeoutCall(final Duration updateInterval)
+	{
+		return "window.GmapAutoTimer = setTimeout(\"" + getCallbackScript() + "\", " +
+			updateInterval.getMilliseconds() + ");";
+	}
+
+	/**
+	 * 
+	 * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#respond(org.apache.wicket.ajax.AjaxRequestTarget)
+	 */
+	@Override
+	protected final void respond(final AjaxRequestTarget target)
+	{
+		if (!stopped)
+		{
+			target.appendJavaScript(getJsTimeoutCall(updateInterval));
+		}
+		onTimer(target, getGMap2());
+	}
+
+	/**
+	 * Listener method for the AJAX timer event.
+	 * 
+	 * @param target
+	 *            The request target
+	 */
+	protected abstract void onTimer(final AjaxRequestTarget target, GMap2 map);
 
 }
diff --git a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/refreshpoint/RefreshPointPage.java b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/refreshpoint/RefreshPointPage.java
index 8ce20e4194..18f281fe4e 100644
--- a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/refreshpoint/RefreshPointPage.java
+++ b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/refreshpoint/RefreshPointPage.java
@@ -33,7 +33,7 @@ public RefreshPointPage()
 		add(map);
 
 		GOverlay overlay = createOverlay("Amsterdam", new GLatLng(52.37649, 4.888573), "image.gif",
-				"shadow.png");
+			"shadow.png");
 
 		map.addOverlay(overlay);
 
@@ -50,18 +50,18 @@ protected void onTimer(AjaxRequestTarget target, GMap2 map)
 				if (i % 3 == 0)
 				{
 					overlay = createOverlay("Amsterdam", new GLatLng(52.37649, 4.888573),
-							"image.gif", "shadow.png");
+						"image.gif", "shadow.png");
 					i = 0;
 				}
 				else if (i % 3 == 1)
 				{
 					overlay = createOverlay("Amsterdam", new GLatLng(52.37649, 4.888573),
-							"image2.gif", "shadow2.png");
+						"image2.gif", "shadow2.png");
 				}
 				else
 				{
 					overlay = createOverlay("Toulouse", new GLatLng(43.604363, 1.442951),
-							"image2.gif", "shadow2.png");
+						"image2.gif", "shadow2.png");
 				}
 				i++;
 				map.setOverlays(Collections.singletonList(overlay));
@@ -71,11 +71,13 @@ else if (i % 3 == 1)
 
 	private GOverlay createOverlay(String title, GLatLng latLng, String image, String shadow)
 	{
-		GIcon icon = new GIcon(urlFor(new PackageResourceReference(RefreshPointPage.class, image), null)
-				.toString(), urlFor(new PackageResourceReference(RefreshPointPage.class, shadow), null)
-				.toString()).iconSize(new GSize(64, 64)).shadowSize(new GSize(64, 64)).iconAnchor(
-				new GPoint(19, 40)).infoWindowAnchor(new GPoint(9, 2)).infoShadowAnchor(
-				new GPoint(18, 25));
+		GIcon icon = new GIcon(urlFor(new PackageResourceReference(RefreshPointPage.class, image),
+			null).toString(), urlFor(new PackageResourceReference(RefreshPointPage.class, shadow),
+			null).toString()).iconSize(new GSize(64, 64))
+			.shadowSize(new GSize(64, 64))
+			.iconAnchor(new GPoint(19, 40))
+			.infoWindowAnchor(new GPoint(9, 2))
+			.infoShadowAnchor(new GPoint(18, 25));
 		map.setCenter(latLng);
 		return new GMarker(latLng, new GMarkerOptions(title, icon));
 	}
diff --git a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/search/HomePage.java b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/search/HomePage.java
index 88c0fd75e6..844ed724bd 100644
--- a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/search/HomePage.java
+++ b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/search/HomePage.java
@@ -14,8 +14,7 @@ public class HomePage extends WicketExamplePage
 
 	public HomePage()
 	{
-		final GMap2 map = new GMap2("topPanel", GMapExampleApplication.get()
-				.getGoogleMapsAPIkey());
+		final GMap2 map = new GMap2("topPanel", GMapExampleApplication.get().getGoogleMapsAPIkey());
 		map.enableGoogleBar(true);
 		add(map);
 	}
diff --git a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/simple/SimplePage.java b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/simple/SimplePage.java
index 5852ba3930..1496f68d97 100644
--- a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/simple/SimplePage.java
+++ b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/simple/SimplePage.java
@@ -15,8 +15,7 @@ public class SimplePage extends WicketExamplePage
 
 	public SimplePage()
 	{
-		GMap2 map = new GMap2("map", GMapExampleApplication.get()
-				.getGoogleMapsAPIkey());
+		GMap2 map = new GMap2("map", GMapExampleApplication.get().getGoogleMapsAPIkey());
 		map.setCenter(new GLatLng(52.37649, 4.888573));
 		add(map);
 	}
diff --git a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HelloPanel.java b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HelloPanel.java
index 8f655acf47..d9ddf7c8f3 100644
--- a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HelloPanel.java
+++ b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HelloPanel.java
@@ -19,7 +19,7 @@ public class HelloPanel extends Panel
 	public HelloPanel()
 	{
 		super("content" + i++);
-		
+
 		add(new Label("label", HelloPanel.this.getId()));
 	}
 }
diff --git a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HomePage.java b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HomePage.java
index fe2016f703..ac6e5f5dc9 100644
--- a/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HomePage.java
+++ b/jdk-1.5-parent/gmap2-parent/gmap2-examples/src/main/java/wicket/contrib/examples/gmap/top/HomePage.java
@@ -37,7 +37,7 @@ public HomePage()
 		add(feedback);
 
 		final GMap2 topMap = new GMap2("topPanel", GMapExampleApplication.get()
-				.getGoogleMapsAPIkey());
+			.getGoogleMapsAPIkey());
 		topMap.setDoubleClickZoomEnabled(true);
 		topMap.add(new ClickListener()
 		{
@@ -83,9 +83,9 @@ protected void onEvent(AjaxRequestTarget target)
 				{
 					GLatLng point = marker.getLatLng();
 
-					GMarker random = new GMarker(new GLatLng(point.getLat()
-							* (0.9995 + Math.random() / 1000), point.getLng()
-							* (0.9995 + Math.random() / 1000)));
+					GMarker random = new GMarker(new GLatLng(point.getLat() *
+						(0.9995 + Math.random() / 1000), point.getLng() *
+						(0.9995 + Math.random() / 1000)));
 
 					topMap.addOverlay(random);
 				}
diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMap2.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMap2.java
index 56b8aa4db5..b748556a45 100644
--- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMap2.java
+++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMap2.java
@@ -47,13 +47,11 @@
 import wicket.contrib.gmap.event.GEventListenerBehavior;
 
 /**
- * Wicket component to embed Google Maps
- * into your pages.
+ * Wicket component to embed Google Maps into your pages.
  * 

- * The Google Maps API requires an API key to use it. You will need to generate - * one for each deployment context you have. See the Google Maps API sign up - * page for more information. + * The Google Maps API requires an API key to use it. You will need to generate one for each + * deployment context you have. See the Google + * Maps API sign up page for more information. */ public class GMap2 extends Panel implements GOverlayContainer { @@ -65,7 +63,7 @@ public class GMap2 extends Panel implements GOverlayContainer private GLatLng center = new GLatLng(37.4419, -122.1419); private boolean googleBarEnabled = false; - + private boolean draggingEnabled = true; private boolean doubleClickZoomEnabled = false; @@ -90,7 +88,7 @@ public class GMap2 extends Panel implements GOverlayContainer /** * Construct. - * + * * @param id * @param gMapKey * Google gmap API KEY @@ -102,13 +100,13 @@ public GMap2(final String id, final String gMapKey) /** * Construct. - * + * * @param id * @param gMapKey * Google gmap API KEY * @param overlays - * @deprecated The usage is discouraged. Use this(String, String) instead - * and add the overlays later on. + * @deprecated The usage is discouraged. Use this(String, String) instead and add the overlays + * later on. */ @Deprecated public GMap2(final String id, final String gMapKey, List overlays) @@ -118,7 +116,7 @@ public GMap2(final String id, final String gMapKey, List overlays) /** * Construct. - * + * * @param id * @param headerContrib */ @@ -140,12 +138,12 @@ public GMap2(final String id, final GMapHeaderContributor headerContrib) /** * Construct. - * + * * @param id * @param headerContrib * @param overlays - * @deprecated The usage is discouraged. Use this(String, String) instead - * and add the overlays later on. + * @deprecated The usage is discouraged. Use this(String, String) instead and add the overlays + * later on. */ @Deprecated public GMap2(final String id, final GMapHeaderContributor headerContrib, List overlays) @@ -158,12 +156,13 @@ public GMap2(final String id, final GMapHeaderContributor headerContrib, List markersToShow) { + public void fitMarkers(final List markersToShow) + { fitMarkers(markersToShow, false, 0.0); } - + /** * @see #fitMarkers(List, boolean, double) */ - public void fitMarkers(final List markersToShow, boolean showMarkersForPoints) { + public void fitMarkers(final List markersToShow, boolean showMarkersForPoints) + { fitMarkers(markersToShow, showMarkersForPoints, 0.0); } /** *

- * Makes the map zoom out and centre around all the GLatLng points in - * markersToShow. + * Makes the map zoom out and centre around all the GLatLng points in markersToShow. *

* Big ups to Doug Leeper for the code. - * - * @see Doug's Nabble post * @param markersToShow * the points to centre around. * @param showMarkersForPoints - * if true, will also add basic markers to the map for each point - * focused on. Just a simple convenience method - you will probably - * want to turn this off so that you can show more information - * with each marker when clicked etc. + * if true, will also add basic markers to the map for each point focused on. Just a + * simple convenience method - you will probably want to turn this off so that you + * can show more information with each marker when clicked etc. */ - public void fitMarkers(final List markersToShow, boolean showMarkersForPoints, final double zoomAdjustment) { - if (markersToShow.isEmpty()) { + public void fitMarkers(final List markersToShow, boolean showMarkersForPoints, + final double zoomAdjustment) + { + if (markersToShow.isEmpty()) + { log.warn("Empty list provided to GMap2.fitMarkers method."); return; } - this.add(new Behavior() { + this.add(new Behavior() + { private static final long serialVersionUID = 1L; @Override - public void renderHead(Component component, IHeaderResponse response) { + public void renderHead(Component component, IHeaderResponse response) + { StringBuffer buf = new StringBuffer(); buf.append("var bounds = new GLatLngBounds();\n"); buf.append("var map = " + GMap2.this.getJSinvoke("map")); // Ask google maps to keep extending the bounds to include each // point - for (GLatLng point : markersToShow) { - buf.append("bounds.extend( " + point.getJSconstructor() - + " );\n"); + for (GLatLng point : markersToShow) + { + buf.append("bounds.extend( " + point.getJSconstructor() + " );\n"); } // set the zoom level that shows the bounds - buf.append("map.setZoom( map.getBoundsZoomLevel(bounds) + " - + zoomAdjustment + ");\n"); + buf.append("map.setZoom( map.getBoundsZoomLevel(bounds) + " + zoomAdjustment + + ");\n"); // center in the middle of the bounds buf.append("map.setCenter( bounds.getCenter() );\n"); @@ -578,9 +581,11 @@ public void renderHead(Component component, IHeaderResponse response) { }); // show the markers - if (showMarkersForPoints) { - for (GLatLng location : markersToShow) { - this.addOverlay(new GMarker(location)); + if (showMarkersForPoints) + { + for (GLatLng location : markersToShow) + { + addOverlay(new GMarker(location)); } } } @@ -647,10 +652,16 @@ public void update(AjaxRequestTarget target) // Attention: don't use setters as this will result in an endless // AJAX request loop - bounds = GLatLngBounds.parse(request.getRequestParameters().getParameterValue("bounds").toString()); - center = GLatLng.parse(request.getRequestParameters().getParameterValue("center").toString()); + bounds = GLatLngBounds.parse(request.getRequestParameters() + .getParameterValue("bounds") + .toString()); + center = GLatLng.parse(request.getRequestParameters() + .getParameterValue("center") + .toString()); zoom = request.getRequestParameters().getParameterValue("zoom").toInt(); - mapType = GMapType.valueOf(request.getRequestParameters().getParameterValue("currentMapType").toString()); + mapType = GMapType.valueOf(request.getRequestParameters() + .getParameterValue("currentMapType") + .toString()); infoWindow.update(target); } @@ -816,8 +827,12 @@ protected void respond(AjaxRequestTarget target) { Request request = RequestCycle.get().getRequest(); - String overlayId = request.getRequestParameters().getParameterValue("overlay.overlayId").toString(); - String event = request.getRequestParameters().getParameterValue("overlay.event").toString(); + String overlayId = request.getRequestParameters() + .getParameterValue("overlay.overlayId") + .toString(); + String event = request.getRequestParameters() + .getParameterValue("overlay.event") + .toString(); // TODO this is ugly // the id's of the Overlays are unique within the ArrayList // maybe we should change that collection @@ -833,7 +848,8 @@ protected void respond(AjaxRequestTarget target) public Object getJSinit() { - return GMap2.this.getJSinvoke("overlayListenerCallbackUrl = '" + this.getCallbackUrl() + "'"); + return getJSinvoke("overlayListenerCallbackUrl = '" + getCallbackUrl() + + "'"); } } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMapHeaderContributor.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMapHeaderContributor.java index 278bacf940..d2a84e87b3 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMapHeaderContributor.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/GMapHeaderContributor.java @@ -10,7 +10,7 @@ /** * - * using a {@link Behavior} + * using a {@link Behavior} */ public class GMapHeaderContributor extends Behavior { @@ -19,12 +19,13 @@ public class GMapHeaderContributor extends Behavior // URL for Google Maps' API endpoint. private static final String GMAP_API_URL = "http://www.google.com/jsapi?key="; // We have some custom JavaScript. - private static final ResourceReference WICKET_GMAP_JS = new JavaScriptResourceReference(GMap2.class, "wicket-gmap.js"); + private static final ResourceReference WICKET_GMAP_JS = new JavaScriptResourceReference( + GMap2.class, "wicket-gmap.js"); protected static final String GOOGLE_LOAD_MAPS = "google.load(\"maps\", \"2.x\");"; private final String gMapKey; - - + + /** * * @param gMapKey @@ -35,7 +36,8 @@ public GMapHeaderContributor(final String gMapKey) } /** - * see: IE memory leak issues + * see: IE memory leak + * issues * * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse) */ @@ -43,7 +45,8 @@ public GMapHeaderContributor(final String gMapKey) public void renderHead(Component component, IHeaderResponse response) { response.renderJavaScriptReference(GMAP_API_URL + gMapKey); - response.renderJavaScript(GOOGLE_LOAD_MAPS, GMapHeaderContributor.class.getName() + "_googleload"); + response.renderJavaScript(GOOGLE_LOAD_MAPS, GMapHeaderContributor.class.getName() + + "_googleload"); response.renderJavaScriptReference(WicketEventReference.INSTANCE); response.renderJavaScriptReference(WicketAjaxReference.INSTANCE); response.renderJavaScriptReference(WICKET_GMAP_JS); diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GClientGeocoder.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GClientGeocoder.java index 625c612378..632b6213b7 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GClientGeocoder.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GClientGeocoder.java @@ -13,7 +13,8 @@ /** */ -public abstract class GClientGeocoder extends AjaxEventBehavior { +public abstract class GClientGeocoder extends AjaxEventBehavior +{ private static final long serialVersionUID = 1L; @@ -27,37 +28,41 @@ public abstract class GClientGeocoder extends AjaxEventBehavior { * * @param event */ - public GClientGeocoder(String event, TextField addressField, String key) { + public GClientGeocoder(String event, TextField addressField, String key) + { super(event); this.addressField = addressField; this.addressField.setOutputMarkupId(true); - this.headerContrib = new GMapHeaderContributor(key); + headerContrib = new GMapHeaderContributor(key); } @Override - public void renderHead(Component c, IHeaderResponse response) { + public void renderHead(Component c, IHeaderResponse response) + { super.renderHead(c, response); headerContrib.renderHead(c, response); } @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { Request request = RequestCycle.get().getRequest(); IRequestParameters parameters = request.getRequestParameters(); onGeoCode(target, parameters.getParameterValue("status").toInt(), - parameters.getParameterValue("address").toString(), - GLatLng.parse(parameters.getParameterValue("point").toString())); + parameters.getParameterValue("address").toString(), + GLatLng.parse(parameters.getParameterValue("point").toString())); } - public abstract void onGeoCode(AjaxRequestTarget target, int status, - String address, GLatLng latLng); + public abstract void onGeoCode(AjaxRequestTarget target, int status, String address, + GLatLng latLng); @Override - protected CharSequence generateCallbackScript(CharSequence partialCall) { - return "Wicket.geocoder.getLatLng('" + getCallbackUrl() + "', '" - + addressField.getMarkupId() + "');" + "return false;"; + protected CharSequence generateCallbackScript(CharSequence partialCall) + { + return "Wicket.geocoder.getLatLng('" + getCallbackUrl() + "', '" + + addressField.getMarkupId() + "');" + "return false;"; } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GControl.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GControl.java index 9c4aa9f50e..81c2eb4201 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GControl.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GControl.java @@ -20,8 +20,8 @@ import wicket.contrib.gmap.GMap2; /** - * Represents an Google Maps API's - * GControl. + * Represents an Google Maps API's GControl. */ public enum GControl implements Serializable { diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GEvent.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GEvent.java index 0287324516..16f502c2ae 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GEvent.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GEvent.java @@ -20,7 +20,8 @@ import java.io.Serializable; -public enum GEvent implements Serializable { +public enum GEvent implements Serializable +{ click, dblclick, dragstart, dragend; @@ -33,13 +34,13 @@ public String toString() public String getJSadd(GOverlay overlay) { return overlay.getParent().getJSinvoke( - "addOverlayListener('" + overlay.getId() + "', '" + name() + "')"); + "addOverlayListener('" + overlay.getId() + "', '" + name() + "')"); } public String getJSclear(GOverlay overlay) { return overlay.getParent().getJSinvoke( - "clearOverlayListeners('" + overlay.getId() + "', '" + name() + "')"); + "clearOverlayListeners('" + overlay.getId() + "', '" + name() + "')"); } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GGeoXml.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GGeoXml.java index 71156b94d3..5d6a8324d2 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GGeoXml.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GGeoXml.java @@ -43,12 +43,12 @@ public GGeoXml(URL kmlFileUrl) @Override public String getJSconstructor() { - Constructor constructor = new Constructor("GGeoXml").add("'"+kmlFileUrl.toString()+"'"); + Constructor constructor = new Constructor("GGeoXml").add("'" + kmlFileUrl.toString() + "'"); return constructor.toJS(); } @Override - protected void updateOnAjaxCall(AjaxRequestTarget target, - GEvent overlayEvent) { + protected void updateOnAjaxCall(AjaxRequestTarget target, GEvent overlayEvent) + { } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GIcon.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GIcon.java index b50bfc4f2c..ab6950dff8 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GIcon.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GIcon.java @@ -22,11 +22,13 @@ import java.util.List; /** - * Represents an Google Maps API's http://code.google.com/apis/maps/documentation/reference.html#GIcon + * Represents an Google Maps API's + * http://code.google.com/apis/maps/documentation/reference.html#GIcon * * @author Robert Jacolin, Gregory Maes, Vincent Demay, Anyware Technologies */ -public class GIcon implements GValue, Cloneable { +public class GIcon implements GValue, Cloneable +{ private static final long serialVersionUID = 1714038753187423501L; @@ -42,19 +44,24 @@ public class GIcon implements GValue, Cloneable { */ private List imageMap = null; - public GIcon() { + public GIcon() + { } - public GIcon(String image) { + public GIcon(String image) + { this.image = image; } - public GIcon(String image, String shadow) { + public GIcon(String image, String shadow) + { this.image = image; this.shadow = shadow; } - public GIcon(String image, String shadow, GSize iconSize, GSize shadowSize, GPoint iconAnchor, GPoint infoWindowAnchor, GPoint infoShadowAnchor) { + public GIcon(String image, String shadow, GSize iconSize, GSize shadowSize, GPoint iconAnchor, + GPoint infoWindowAnchor, GPoint infoShadowAnchor) + { this.image = image; this.shadow = shadow; this.iconSize = iconSize; @@ -65,148 +72,208 @@ public GIcon(String image, String shadow, GSize iconSize, GSize shadowSize, GPoi } @Override - public GIcon clone() { - try { - return (GIcon) super.clone(); - } catch (CloneNotSupportedException e) { + public GIcon clone() + { + try + { + return (GIcon)super.clone(); + } + catch (CloneNotSupportedException e) + { throw new Error(e); } } @Override - public boolean equals(Object obj) { - if (this == obj) { + public boolean equals(Object obj) + { + if (this == obj) + { return true; } - if (obj == null) { + if (obj == null) + { return false; } - if (getClass() != obj.getClass()) { + if (getClass() != obj.getClass()) + { return false; } - GIcon other = (GIcon) obj; - if (iconAnchor == null) { - if (other.iconAnchor != null) { + GIcon other = (GIcon)obj; + if (iconAnchor == null) + { + if (other.iconAnchor != null) + { return false; } - } else if (!iconAnchor.equals(other.iconAnchor)) { + } + else if (!iconAnchor.equals(other.iconAnchor)) + { return false; } - if (iconSize == null) { - if (other.iconSize != null) { + if (iconSize == null) + { + if (other.iconSize != null) + { return false; } - } else if (!iconSize.equals(other.iconSize)) { + } + else if (!iconSize.equals(other.iconSize)) + { return false; } - if (image == null) { - if (other.image != null) { + if (image == null) + { + if (other.image != null) + { return false; } - } else if (!image.equals(other.image)) { + } + else if (!image.equals(other.image)) + { return false; } - if (imageMap == null) { - if (other.imageMap != null) { + if (imageMap == null) + { + if (other.imageMap != null) + { return false; } - } else if (!imageMap.equals(other.imageMap)) { + } + else if (!imageMap.equals(other.imageMap)) + { return false; } - if (infoShadowAnchor == null) { - if (other.infoShadowAnchor != null) { + if (infoShadowAnchor == null) + { + if (other.infoShadowAnchor != null) + { return false; } - } else if (!infoShadowAnchor.equals(other.infoShadowAnchor)) { + } + else if (!infoShadowAnchor.equals(other.infoShadowAnchor)) + { return false; } - if (infoWindowAnchor == null) { - if (other.infoWindowAnchor != null) { + if (infoWindowAnchor == null) + { + if (other.infoWindowAnchor != null) + { return false; } - } else if (!infoWindowAnchor.equals(other.infoWindowAnchor)) { + } + else if (!infoWindowAnchor.equals(other.infoWindowAnchor)) + { return false; } - if (shadow == null) { - if (other.shadow != null) { + if (shadow == null) + { + if (other.shadow != null) + { return false; } - } else if (!shadow.equals(other.shadow)) { + } + else if (!shadow.equals(other.shadow)) + { return false; } - if (shadowSize == null) { - if (other.shadowSize != null) { + if (shadowSize == null) + { + if (other.shadowSize != null) + { return false; } - } else if (!shadowSize.equals(other.shadowSize)) { + } + else if (!shadowSize.equals(other.shadowSize)) + { return false; } return true; } - public GPoint getIconAnchor() { + public GPoint getIconAnchor() + { return iconAnchor; } - public GSize getIconSize() { + public GSize getIconSize() + { return iconSize; } - public String getId() { + public String getId() + { return "icon" + String.valueOf(System.identityHashCode(this)); } - public String getImage() { + public String getImage() + { return image; } - public List getImageMap() { + public List getImageMap() + { return imageMap; } - public GPoint getInfoShadowAnchor() { + public GPoint getInfoShadowAnchor() + { return infoShadowAnchor; } - public GPoint getInfoWindowAnchor() { + public GPoint getInfoWindowAnchor() + { return infoWindowAnchor; } - public String getJSconstructor() { + public String getJSconstructor() + { StringBuffer buffer = new StringBuffer(); buffer.append("(function() {\n"); buffer.append("var icon = new GIcon(G_DEFAULT_ICON);\n"); buffer.append("icon.image = \"").append(image).append("\";\n"); buffer.append("icon.shadow = \"").append(shadow).append("\";\n"); - if (iconSize != null) { + if (iconSize != null) + { buffer.append("icon.iconSize = ").append(iconSize.getJSconstructor()).append(";\n"); } - if (shadowSize != null) { + if (shadowSize != null) + { buffer.append("icon.shadowSize = ").append(shadowSize.getJSconstructor()).append(";\n"); } - if (imageMap != null) { + if (imageMap != null) + { buffer.append("icon.imageMap = ["); Iterator imit = imageMap.iterator(); - while (imit.hasNext()) { + while (imit.hasNext()) + { buffer.append(imit.next().toString()); - if (imit.hasNext()) { + if (imit.hasNext()) + { buffer.append(", "); } } buffer.append("];\n"); } - if (iconAnchor != null) { + if (iconAnchor != null) + { buffer.append("icon.iconAnchor = ").append(iconAnchor.getJSconstructor()).append(";\n"); } - if (infoWindowAnchor != null) { - buffer.append("icon.infoWindowAnchor = ").append(infoWindowAnchor.getJSconstructor()).append(";\n"); + if (infoWindowAnchor != null) + { + buffer.append("icon.infoWindowAnchor = ") + .append(infoWindowAnchor.getJSconstructor()) + .append(";\n"); } - if (infoShadowAnchor != null) { - buffer.append("icon.infoShadowAnchor = ").append(infoShadowAnchor.getJSconstructor()).append(";\n"); + if (infoShadowAnchor != null) + { + buffer.append("icon.infoShadowAnchor = ") + .append(infoShadowAnchor.getJSconstructor()) + .append(";\n"); } buffer.append("return icon;\n"); @@ -214,16 +281,19 @@ public String getJSconstructor() { return buffer.toString(); } - public String getShadow() { + public String getShadow() + { return shadow; } - public GSize getShadowSize() { + public GSize getShadowSize() + { return shadowSize; } @Override - public int hashCode() { + public int hashCode() + { final int prime = 31; int result = 1; result = prime * result + ((iconAnchor == null) ? 0 : iconAnchor.hashCode()); @@ -237,63 +307,76 @@ public int hashCode() { return result; } - public GIcon iconAnchor(GPoint iconAnchor) { + public GIcon iconAnchor(GPoint iconAnchor) + { GIcon clone = clone(); clone.iconAnchor = iconAnchor; return clone; } - public GIcon iconSize(GSize iconSize) { + public GIcon iconSize(GSize iconSize) + { GIcon clone = clone(); clone.iconSize = iconSize; return clone; } - public GIcon infoShadowAnchor(GPoint infoShadowAnchor) { + public GIcon infoShadowAnchor(GPoint infoShadowAnchor) + { GIcon clone = clone(); clone.infoShadowAnchor = infoShadowAnchor; return clone; } - public GIcon infoWindowAnchor(GPoint infoWindowAnchor) { + public GIcon infoWindowAnchor(GPoint infoWindowAnchor) + { GIcon clone = clone(); clone.infoWindowAnchor = infoWindowAnchor; return clone; } - public void setIconAnchor(GPoint iconAnchor) { + public void setIconAnchor(GPoint iconAnchor) + { this.iconAnchor = iconAnchor; } - public void setIconSize(GSize iconSize) { + public void setIconSize(GSize iconSize) + { this.iconSize = iconSize; } - public void setImage(String image) { + public void setImage(String image) + { this.image = image; } - public void setImageMap(List imageMap) { + public void setImageMap(List imageMap) + { this.imageMap = imageMap; } - public void setInfoShadowAnchor(GPoint infoShadowAnchor) { + public void setInfoShadowAnchor(GPoint infoShadowAnchor) + { this.infoShadowAnchor = infoShadowAnchor; } - public void setInfoWindowAnchor(GPoint infoWindowAnchor) { + public void setInfoWindowAnchor(GPoint infoWindowAnchor) + { this.infoWindowAnchor = infoWindowAnchor; } - public void setShadow(String shadow) { + public void setShadow(String shadow) + { this.shadow = shadow; } - public void setShadowSize(GSize shadowSize) { + public void setShadowSize(GSize shadowSize) + { this.shadowSize = shadowSize; } - public GIcon shadowSize(GSize shadowSize) { + public GIcon shadowSize(GSize shadowSize) + { GIcon clone = clone(); clone.shadowSize = shadowSize; return clone; diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindow.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindow.java index 95e6d9c151..7105207bf6 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindow.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindow.java @@ -108,7 +108,7 @@ public GInfoWindow open(GLatLng latLng, GInfoWindowTab... tabs) setTabs(tabs); this.latLng = latLng; - this.marker = null; + marker = null; if (AjaxRequestTarget.get() != null) { @@ -123,7 +123,7 @@ public GInfoWindow open(GMarker marker, GInfoWindowTab... tabs) { setTabs(tabs); - this.latLng = null; + latLng = null; this.marker = marker; if (AjaxRequestTarget.get() != null) diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindowTab.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindowTab.java index 28377fd698..274b6e08d0 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindowTab.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GInfoWindowTab.java @@ -21,7 +21,8 @@ /** * Represents an Google Maps API's GInfoWindowTab. + * href="http://www.google.com/apis/maps/documentation/reference.html#GInfoWindowTab" + * >GInfoWindowTab. */ public class GInfoWindowTab implements GValue { @@ -73,7 +74,8 @@ public Component getContent() */ public String getJSconstructor() { - return new Constructor("GInfoWindowTab").addString(title).add( - "document.getElementById('" + content.getMarkupId() + "')").toJS(); + return new Constructor("GInfoWindowTab").addString(title) + .add("document.getElementById('" + content.getMarkupId() + "')") + .toJS(); } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLng.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLng.java index bb32418f54..f8f3d7985c 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLng.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLng.java @@ -79,8 +79,7 @@ public String toString() */ public String getJSconstructor() { - return new Constructor("GLatLng").add(lat).add(lng).add(unbounded) - .toJS(); + return new Constructor("GLatLng").add(lat).add(lng).add(unbounded).toJS(); } @Override diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLngBounds.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLngBounds.java index 0f36a31c8d..c74245553d 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLngBounds.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GLatLngBounds.java @@ -20,8 +20,9 @@ import wicket.contrib.gmap.js.Constructor; /** - * Represents an Google Maps API's - * GLatLngBounds. + * Represents an Google Maps API's GLatLngBounds. */ public class GLatLngBounds implements GValue { @@ -29,7 +30,7 @@ public class GLatLngBounds implements GValue * Default serialVersionUID. */ private static final long serialVersionUID = 1L; - + private final GLatLng sw; private final GLatLng ne; @@ -54,7 +55,7 @@ public GLatLng getNE() { return ne; } - + @Override public String toString() { @@ -66,7 +67,9 @@ public String toString() */ public String getJSconstructor() { - return new Constructor("GLatLngBounds").add(sw.getJSconstructor()).add(ne.getJSconstructor()).toJS(); + return new Constructor("GLatLngBounds").add(sw.getJSconstructor()) + .add(ne.getJSconstructor()) + .toJS(); } @Override @@ -85,7 +88,7 @@ public boolean equals(Object obj) } return false; } - + /** * ((37.34068368469045, -122.48519897460936), (37.72184917678752, -121.79855346679686)) */ @@ -104,9 +107,11 @@ public static GLatLngBounds parse(String value) { return null; } - - GLatLng sw = new GLatLng(Float.valueOf(tokenizer.nextToken()), Float.valueOf(tokenizer.nextToken())); - GLatLng ne = new GLatLng(Float.valueOf(tokenizer.nextToken()), Float.valueOf(tokenizer.nextToken())); + + GLatLng sw = new GLatLng(Float.valueOf(tokenizer.nextToken()), + Float.valueOf(tokenizer.nextToken())); + GLatLng ne = new GLatLng(Float.valueOf(tokenizer.nextToken()), + Float.valueOf(tokenizer.nextToken())); return new GLatLngBounds(sw, ne); } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMapType.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMapType.java index f7558fc30e..2c883a9c7a 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMapType.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMapType.java @@ -20,14 +20,15 @@ import wicket.contrib.gmap.GMap2; /** - * Represents an Google Maps API's - * GMapType. + * Represents an Google Maps API's GMapType. */ -public enum GMapType implements Serializable { +public enum GMapType implements Serializable +{ G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP; public String getJSsetMapType(GMap2 map) { return map.getJSinvoke("setMapType(" + name() + ")"); - } + } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarker.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarker.java index d521167c8b..c8eade69f7 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarker.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarker.java @@ -45,7 +45,7 @@ public GMarker(GLatLng gLatLng) public GMarker(GLatLng gLatLng, GMarkerOptions options) { super(); - this.latLng = gLatLng; + latLng = gLatLng; this.options = options; } @@ -56,12 +56,12 @@ public GLatLng getLatLng() public void setLatLng(GLatLng gLatLng) { - this.latLng = gLatLng; + latLng = gLatLng; } public GMarkerOptions getMarkerOptions() { - return this.options; + return options; } @Override @@ -79,6 +79,8 @@ public String getJSconstructor() protected void updateOnAjaxCall(AjaxRequestTarget target, GEvent overlayEvent) { Request request = RequestCycle.get().getRequest(); - this.latLng = GLatLng.parse(request.getRequestParameters().getParameterValue("overlay.latLng").toString()); + latLng = GLatLng.parse(request.getRequestParameters() + .getParameterValue("overlay.latLng") + .toString()); } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarkerOptions.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarkerOptions.java index 9966d33161..1d9a8efd32 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarkerOptions.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GMarkerOptions.java @@ -26,17 +26,17 @@ public class GMarkerOptions implements GValue, Cloneable * Default serialVersionUID. */ private static final long serialVersionUID = 1L; - + private String title; - + private boolean clickable = true; - + private boolean draggable = false; - + private boolean bouncy = true; - + private boolean autoPan = false; - + private GIcon icon = null; public GMarkerOptions() @@ -78,7 +78,7 @@ public String getJSconstructor() { literal.set("autoPan", "true"); } - if(icon != null) + if (icon != null) { literal.set("icon", icon.getJSconstructor()); } @@ -91,19 +91,23 @@ public String getTitle() return title; } - public boolean isDraggable() { + public boolean isDraggable() + { return draggable; } - public boolean isClickable() { + public boolean isClickable() + { return clickable; } - public boolean isBouncy() { + public boolean isBouncy() + { return bouncy; } - public boolean isAutoPan() { + public boolean isAutoPan() + { return autoPan; } @@ -111,9 +115,10 @@ public GIcon getIcon() { return icon; } - + @Override - public GMarkerOptions clone() { + public GMarkerOptions clone() + { try { return (GMarkerOptions)super.clone(); @@ -123,31 +128,35 @@ public GMarkerOptions clone() { throw new Error(e); } } - - public GMarkerOptions clickable(boolean clickable) { + + public GMarkerOptions clickable(boolean clickable) + { GMarkerOptions clone = clone(); clone.clickable = clickable; return clone; } - - public GMarkerOptions draggable(boolean draggable) { + + public GMarkerOptions draggable(boolean draggable) + { GMarkerOptions clone = clone(); clone.draggable = draggable; return clone; } - - public GMarkerOptions autoPan(boolean autoPan) { + + public GMarkerOptions autoPan(boolean autoPan) + { GMarkerOptions clone = clone(); clone.autoPan = autoPan; return clone; } - - public GMarkerOptions bouncy(boolean bouncy) { + + public GMarkerOptions bouncy(boolean bouncy) + { GMarkerOptions clone = clone(); clone.bouncy = bouncy; return clone; } - + @Override public int hashCode() { diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GOverlay.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GOverlay.java index 7b32a2e1a7..abee15ee90 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GOverlay.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GOverlay.java @@ -27,8 +27,7 @@ /** * Represents an Google Maps API's GOverlay. + * "http://www.google.com/apis/maps/documentation/reference.html#GOverlay" >GOverlay. */ public abstract class GOverlay implements Serializable { @@ -42,7 +41,7 @@ public abstract class GOverlay implements Serializable private GMap2 parent = null; private final Map events = new EnumMap( - GEvent.class); + GEvent.class); /** * Construct. @@ -54,13 +53,13 @@ public GOverlay() } /** - * @return String representing the JavaScript add command for the - * corresponding JavaScript object. + * @return String representing the JavaScript add command for the corresponding JavaScript + * object. */ public String getJSadd() { - StringBuffer js = new StringBuffer(parent.getJSinvoke("addOverlay('" + getId() + "', " - + getJSconstructor() + ")")); + StringBuffer js = new StringBuffer(parent.getJSinvoke("addOverlay('" + getId() + "', " + + getJSconstructor() + ")")); // Add the Events for (GEvent event : events.keySet()) { @@ -70,8 +69,8 @@ public String getJSadd() } /** - * @return String representing the JavaScript remove command for the - * corresponding JavaScript object. + * @return String representing the JavaScript remove command for the corresponding JavaScript + * object. */ public String getJSremove() { @@ -94,8 +93,7 @@ public String getId() } /** - * Implement the needed JavaScript constructor for the corresponding - * JavaScript object. + * Implement the needed JavaScript constructor for the corresponding JavaScript object. * * @return String representing the JavaScript constructor. */ diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GPolygon.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GPolygon.java index fe60345630..07ea875635 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GPolygon.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GPolygon.java @@ -36,7 +36,7 @@ public class GPolygon extends GOverlay private final float fillOpacity; public GPolygon(String strokeColor, int strokeWeight, float strokeOpacity, String fillColor, - float fillOpacity, GLatLng... gLatLngs) + float fillOpacity, GLatLng... gLatLngs) { super(); diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GSize.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GSize.java index e61fe6842a..8de3674620 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GSize.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GSize.java @@ -31,7 +31,7 @@ public class GSize implements GValue * Default serialVersionUID. */ private static final long serialVersionUID = 1L; - + private float width; private float height; @@ -55,7 +55,7 @@ public String getJSconstructor() { return new Constructor("GSize").add(width).add(height).toJS(); } - + @Override public int hashCode() { diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GValue.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GValue.java index 7fa15196b9..8f3e46df70 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GValue.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/api/GValue.java @@ -19,8 +19,7 @@ /** * Root class for all Value Objects.
- * All implementations shall override {@link #equals(Object)} and - * {@link #hashCode()}. + * All implementations shall override {@link #equals(Object)} and {@link #hashCode()}. */ public interface GValue extends Serializable { diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ClickListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ClickListener.java index da439294af..9b7141fc28 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ClickListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ClickListener.java @@ -29,33 +29,44 @@ * See "click" in the event section of GMap2. */ -public abstract class ClickListener extends GEventListenerBehavior { +public abstract class ClickListener extends GEventListenerBehavior +{ private static final long serialVersionUID = 1L; @Override - protected String getEvent() { + protected String getEvent() + { return "click"; } @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { Request request = RequestCycle.get().getRequest(); GOverlay overlay = null; GLatLng latLng = null; - String markerParameter = request.getRequestParameters().getParameterValue("argument0").toString(); - if (markerParameter != null) { - for (GOverlay ovl : getGMap2().getOverlays()) { - if (ovl.getId().equals(markerParameter)) { + String markerParameter = request.getRequestParameters() + .getParameterValue("argument0") + .toString(); + if (markerParameter != null) + { + for (GOverlay ovl : getGMap2().getOverlays()) + { + if (ovl.getId().equals(markerParameter)) + { overlay = ovl; break; } } } - String latLngParameter = request.getRequestParameters().getParameterValue("argument1").toString(); - if (latLngParameter != null) { + String latLngParameter = request.getRequestParameters() + .getParameterValue("argument1") + .toString(); + if (latLngParameter != null) + { latLng = GLatLng.parse(latLngParameter); } @@ -63,8 +74,7 @@ protected void onEvent(AjaxRequestTarget target) { } /** - * Override this method to provide handling of a click on the map. See the - * event section of GMap2. * * @param latLng @@ -74,6 +84,5 @@ protected void onEvent(AjaxRequestTarget target) { * @param target * The target that initiated the click. */ - protected abstract void onClick(AjaxRequestTarget target, GLatLng latLng, - GOverlay overlay); + protected abstract void onClick(AjaxRequestTarget target, GLatLng latLng, GOverlay overlay); } \ No newline at end of file diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DblClickListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DblClickListener.java index ae34c4854a..eacd1d4102 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DblClickListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DblClickListener.java @@ -28,22 +28,28 @@ * See "dblclick" in the event section of GMap2. */ -public abstract class DblClickListener extends GEventListenerBehavior { +public abstract class DblClickListener extends GEventListenerBehavior +{ private static final long serialVersionUID = 1L; @Override - protected String getEvent() { + protected String getEvent() + { return "dblclick"; } @Override - protected final void onEvent(AjaxRequestTarget target) { + protected final void onEvent(AjaxRequestTarget target) + { Request request = RequestCycle.get().getRequest(); GLatLng latLng = null; - String latLngParameter = request.getRequestParameters().getParameterValue("argument1").toString(); - if (latLngParameter != null) { + String latLngParameter = request.getRequestParameters() + .getParameterValue("argument1") + .toString(); + if (latLngParameter != null) + { latLng = GLatLng.parse(latLngParameter); } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragEndListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragEndListener.java index f947f01927..2d71b364ac 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragEndListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragEndListener.java @@ -28,7 +28,8 @@ public abstract class DragEndListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "dragend"; } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragListener.java index fca780bf5b..0aa95f0b9f 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragListener.java @@ -28,7 +28,8 @@ public abstract class DragListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "drag"; } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragStartListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragStartListener.java index 357dae97d7..6264804af7 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragStartListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/DragStartListener.java @@ -28,7 +28,8 @@ public abstract class DragStartListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "dragstart"; } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/GEventListenerBehavior.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/GEventListenerBehavior.java index 3a5fd9b364..9e25c617dd 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/GEventListenerBehavior.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/GEventListenerBehavior.java @@ -39,7 +39,7 @@ protected void onBind() public String getJSaddListener() { return getGMap2().getJSinvoke( - "addListener('" + getEvent() + "', '" + getCallbackUrl() + "')"); + "addListener('" + getEvent() + "', '" + getCallbackUrl() + "')"); } protected final GMap2 getGMap2() @@ -59,8 +59,8 @@ protected final void respond(AjaxRequestTarget target) } /** - * Typically response parameters that are meant for this event are picket up - * and made available for the further processing. + * Typically response parameters that are meant for this event are picket up and made available + * for the further processing. * * @param target * Target to add the Components, that need to be redrawn, to. diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowBeforeCloseListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowBeforeCloseListener.java index f1607c4e45..e182f6c959 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowBeforeCloseListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowBeforeCloseListener.java @@ -28,7 +28,8 @@ public abstract class InfoWindowBeforeCloseListener extends GEventListenerBehavi { @Override - protected String getEvent() { + protected String getEvent() + { return "infowindowbeforeclose"; } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowCloseListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowCloseListener.java index ca28d02114..ec0ae3caaf 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowCloseListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowCloseListener.java @@ -28,7 +28,8 @@ public abstract class InfoWindowCloseListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "infowindowclose"; } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowOpenListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowOpenListener.java index 09980ce0bf..bd62bdb4dc 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowOpenListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/InfoWindowOpenListener.java @@ -28,7 +28,8 @@ public abstract class InfoWindowOpenListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "infowindowopen"; } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/LoadListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/LoadListener.java index 229f524769..084c2ac354 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/LoadListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/LoadListener.java @@ -24,25 +24,28 @@ * See "load" in the event section of GMap2. */ -public abstract class LoadListener extends GEventListenerBehavior { +public abstract class LoadListener extends GEventListenerBehavior +{ @Override - protected String getEvent() { + protected String getEvent() + { return "load"; } @Override - public String getJSaddListener() { + public String getJSaddListener() + { // where notifying immediately (instead of adding a listener) because // GMap2 will not fire the "load" event when we are finished adding our // listeners :( - return getGMap2() - .getJSinvoke("onEvent('" + getCallbackUrl() + "', {})"); + return getGMap2().getJSinvoke("onEvent('" + getCallbackUrl() + "', {})"); } @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { onLoad(target); } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MapTypeChangedListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MapTypeChangedListener.java index ffa5521470..d8c66ec7a8 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MapTypeChangedListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MapTypeChangedListener.java @@ -22,8 +22,7 @@ /** * See "maptypechanged" in the event section of GMap2. + * href="http://www.google.com/apis/maps/documentation/reference.html#GMap2" >GMap2. */ public abstract class MapTypeChangedListener extends GEventListenerBehavior { diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveEndListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveEndListener.java index 69bf7cd5c2..5f8c4bcb95 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveEndListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveEndListener.java @@ -30,7 +30,8 @@ public abstract class MoveEndListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "moveend"; } @@ -43,8 +44,7 @@ protected void onEvent(AjaxRequestTarget target) /** * Override this method to provide handling of a moveend.
- * You can get the new center coordinates of the map by calling - * {@link GMap2#getCenter()}. + * You can get the new center coordinates of the map by calling {@link GMap2#getCenter()}. * * @param target * the target that initiated the move diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveListener.java index 4f0c0bc8af..a41a5a0e82 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveListener.java @@ -30,7 +30,8 @@ public abstract class MoveListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "move"; } @@ -43,8 +44,7 @@ protected void onEvent(AjaxRequestTarget target) /** * Override this method to provide handling of a move.
- * You can get the new center coordinates of the map by calling - * {@link GMap2#getCenter()}. + * You can get the new center coordinates of the map by calling {@link GMap2#getCenter()}. * * @param target * the target that initiated the move diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveStartListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveStartListener.java index 2d93e005dc..5443de2626 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveStartListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/MoveStartListener.java @@ -30,7 +30,8 @@ public abstract class MoveStartListener extends GEventListenerBehavior { @Override - protected String getEvent() { + protected String getEvent() + { return "movestart"; } @@ -43,8 +44,7 @@ protected void onEvent(AjaxRequestTarget target) /** * Override this method to provide handling of a move.
- * You can get the new center coordinates of the map by calling - * {@link GMap2#getCenter()}. + * You can get the new center coordinates of the map by calling {@link GMap2#getCenter()}. * * @param target * the target that initiated the move diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ZoomEndListener.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ZoomEndListener.java index 4bde5e9ecb..8d53e42484 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ZoomEndListener.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/event/ZoomEndListener.java @@ -29,22 +29,28 @@ * See "zoomend" in the event section of GMap2. */ -public abstract class ZoomEndListener extends GEventListenerBehavior { +public abstract class ZoomEndListener extends GEventListenerBehavior +{ private static final long serialVersionUID = 1L; @Override - protected String getEvent() { + protected String getEvent() + { return "zoomend"; } @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { Request request = RequestCycle.get().getRequest(); int oldLevel = 0; int newLevel = 0; - StringValue oldZoomLevelParameter = request.getRequestParameters().getParameterValue("argument0"); - StringValue newZoomLevelParameter = request.getRequestParameters().getParameterValue("argument1"); - if (oldZoomLevelParameter.isNull() || newZoomLevelParameter.isNull()) { + StringValue oldZoomLevelParameter = request.getRequestParameters().getParameterValue( + "argument0"); + StringValue newZoomLevelParameter = request.getRequestParameters().getParameterValue( + "argument1"); + if (oldZoomLevelParameter.isNull() || newZoomLevelParameter.isNull()) + { return; } oldLevel = oldZoomLevelParameter.toInt(); @@ -54,13 +60,11 @@ protected void onEvent(AjaxRequestTarget target) { /** * Override this method to provide handling of a zoomEnd.
- * You can get the new center coordinates of the map by calling - * {@link GMap2#getCenter()}. + * You can get the new center coordinates of the map by calling {@link GMap2#getCenter()}. * * @param target * the target that initiated the move */ - protected abstract void onZoomEnd(AjaxRequestTarget target, int oldLevel, - int newLevel); + protected abstract void onZoomEnd(AjaxRequestTarget target, int oldLevel, int newLevel); } \ No newline at end of file diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/Array.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/Array.java index ed04dfd14b..0254ce7e60 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/Array.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/Array.java @@ -21,26 +21,29 @@ public class Array { private StringBuffer buffer = new StringBuffer("["); - + private boolean first = true; - - public Array add(Object value) { - if (!first) { + + public Array add(Object value) + { + if (!first) + { buffer.append(", "); } buffer.append(value); - + first = false; return this; } - public String toJS() { + public String toJS() + { buffer.append("]"); - + String string = buffer.toString(); - + buffer.deleteCharAt(buffer.length() - 1); - + return string; } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/ObjectLiteral.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/ObjectLiteral.java index 3a7a5a02ad..e7b7a53709 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/ObjectLiteral.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/js/ObjectLiteral.java @@ -22,30 +22,34 @@ public class ObjectLiteral { private StringBuffer buffer = new StringBuffer("{"); private boolean first = true; - - public ObjectLiteral setString(String name, String value) { + + public ObjectLiteral setString(String name, String value) + { return set(name, "\"" + value + "\""); } - public ObjectLiteral set(String name, String value) { - if (!first) { + public ObjectLiteral set(String name, String value) + { + if (!first) + { buffer.append(", "); } buffer.append(name); buffer.append(": "); buffer.append(value); - + first = false; return this; } - public String toJS() { + public String toJS() + { buffer.append("}"); - + String string = buffer.toString(); - + buffer.deleteCharAt(buffer.length() - 1); - + return string; } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/Geocoder.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/Geocoder.java index 9251cbd440..ae5b761374 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/Geocoder.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/Geocoder.java @@ -30,7 +30,8 @@ * * @author Thijs Vonk */ -public class Geocoder implements Serializable { +public class Geocoder implements Serializable +{ private static final long serialVersionUID = 1L; @@ -53,15 +54,18 @@ public class Geocoder implements Serializable { * @throws IllegalArgumentException * If the API key is null */ - public Geocoder(String gMapKey) { - if (gMapKey == null) { + public Geocoder(String gMapKey) + { + if (gMapKey == null) + { throw new IllegalArgumentException("API key cannot be null"); } this.gMapKey = gMapKey; } - public GLatLng decode(String response) throws GeocoderException { + public GLatLng decode(String response) throws GeocoderException + { StringTokenizer gLatLng = new StringTokenizer(response, ","); @@ -70,7 +74,8 @@ public GLatLng decode(String response) throws GeocoderException { String latitude = gLatLng.nextToken(); String longitude = gLatLng.nextToken(); - if (Integer.parseInt(status) != GeocoderException.G_GEO_SUCCESS) { + if (Integer.parseInt(status) != GeocoderException.G_GEO_SUCCESS) + { throw new GeocoderException(Integer.parseInt(status)); } @@ -83,8 +88,10 @@ public GLatLng decode(String response) throws GeocoderException { * @param address * @return */ - public String encode(final String address) { - return "http://maps.google.com/maps/geo?q=" + urlEncode(address) + "&output=" + output + "&key=" + gMapKey; + public String encode(final String address) + { + return "http://maps.google.com/maps/geo?q=" + urlEncode(address) + "&output=" + output + + "&key=" + gMapKey; } /** @@ -92,13 +99,18 @@ public String encode(final String address) { * @return * @throws IOException */ - public GLatLng geocode(final String address) throws IOException { + public GLatLng geocode(final String address) throws IOException + { InputStream is = invokeService(encode(address)); - if (is != null) { - try { + if (is != null) + { + try + { String content = org.apache.wicket.util.io.IOUtils.toString(is); return decode(content); - } finally { + } + finally + { is.close(); } } @@ -112,7 +124,8 @@ public GLatLng geocode(final String address) throws IOException { * @return * @throws IOException */ - protected InputStream invokeService(final String address) throws IOException { + protected InputStream invokeService(final String address) throws IOException + { URL url = new URL(address); return url.openStream(); } @@ -123,10 +136,14 @@ protected InputStream invokeService(final String address) throws IOException { * @param value * @return */ - private String urlEncode(final String value) { - try { + private String urlEncode(final String value) + { + try + { return URLEncoder.encode(value, "UTF-8"); - } catch (UnsupportedEncodingException ex) { + } + catch (UnsupportedEncodingException ex) + { throw new RuntimeException(ex.getMessage()); } } diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/GeocoderException.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/GeocoderException.java index 80dfb443a5..10b169ef5b 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/GeocoderException.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/main/java/wicket/contrib/gmap/util/GeocoderException.java @@ -17,7 +17,8 @@ import java.io.IOException; -public class GeocoderException extends IOException { +public class GeocoderException extends IOException +{ private static final long serialVersionUID = 1L; @@ -41,13 +42,15 @@ public class GeocoderException extends IOException { private int status; - public GeocoderException(int status) { + public GeocoderException(int status) + { super("Status " + status); this.status = status; } - public final int getStatus() { + public final int getStatus() + { return status; } } \ No newline at end of file diff --git a/jdk-1.5-parent/gmap2-parent/gmap2/src/test/java/wicket/contrib/gmap/util/GeocoderTest.java b/jdk-1.5-parent/gmap2-parent/gmap2/src/test/java/wicket/contrib/gmap/util/GeocoderTest.java index c482cad84d..e451aa6e56 100644 --- a/jdk-1.5-parent/gmap2-parent/gmap2/src/test/java/wicket/contrib/gmap/util/GeocoderTest.java +++ b/jdk-1.5-parent/gmap2-parent/gmap2/src/test/java/wicket/contrib/gmap/util/GeocoderTest.java @@ -8,22 +8,24 @@ import wicket.contrib.gmap.api.GLatLng; -public class GeocoderTest { +public class GeocoderTest +{ /** - * martin-g: - * according to http://www.backups.nl/geocoding/ the provided address is correct but for some reason - * the test fails with status 602 (Unknown address) + * martin-g: according to http://www.backups.nl/geocoding/ the provided address is correct but + * for some reason the test fails with status 602 (Unknown address) + * * @maintainer: please remove @Ignore when the issue is fixed. * - * akiraly: - * I am not the maintainer but this file was not in UTF-8 encoding. After - * correcting that test seems to pass. So I commented @Ignore for now. + * akiraly: I am not the maintainer but this file was not in UTF-8 encoding. After + * correcting that test seems to pass. So I commented @Ignore for now. */ - //@Ignore + // @Ignore @Test - public void testGeocoding() throws IOException { - Geocoder coder = new Geocoder("ABQIAAAADk60rPazQzTdmKT7CvyKXRQEr9A52YiMqcOFyKYFGBLG6IXC6RQpL6leG0_YYqR-KhNEFosZSJieGQ"); + public void testGeocoding() throws IOException + { + Geocoder coder = new Geocoder( + "ABQIAAAADk60rPazQzTdmKT7CvyKXRQEr9A52YiMqcOFyKYFGBLG6IXC6RQpL6leG0_YYqR-KhNEFosZSJieGQ"); GLatLng result = coder.geocode("Salzburgerstraße 205, 4030 Linz, Österreich"); Assert.assertNotNull(result); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/ChartsApplication.java b/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/ChartsApplication.java index 6d39445b05..9b0503d304 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/ChartsApplication.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/ChartsApplication.java @@ -9,10 +9,12 @@ /** * @author Daniel Spiewak */ -public class ChartsApplication extends WebApplication { +public class ChartsApplication extends WebApplication +{ - @Override - public Class getHomePage() { - return Home.class; - } + @Override + public Class getHomePage() + { + return Home.class; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/Home.java b/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/Home.java index 3aed10470e..637f062dfb 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/Home.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts-examples/src/main/java/org/wicketstuff/googlecharts/examples/Home.java @@ -24,158 +24,164 @@ /** * @author Daniel Spiewak */ -public class Home extends WebPage { +public class Home extends WebPage +{ - public Home() { - IChartData data = new AbstractChartData() { + public Home() + { + IChartData data = new AbstractChartData() + { - public double[][] getData() { - return new double[][]{{34, 22}}; - } - }; + public double[][] getData() + { + return new double[][] { { 34, 22 } }; + } + }; - ChartProvider provider = new ChartProvider(new Dimension(250, 100), ChartType.PIE_3D, data); - provider.setPieLabels(new String[]{"Hello", "World"}); + ChartProvider provider = new ChartProvider(new Dimension(250, 100), ChartType.PIE_3D, data); + provider.setPieLabels(new String[] { "Hello", "World" }); - add(new Chart("helloWorld", provider)); + add(new Chart("helloWorld", provider)); - data = new AbstractChartData() { + data = new AbstractChartData() + { - public double[][] getData() { - return new double[][]{{34, 30, 38, 38, 41, 22, 41, 44, 38, 29}}; - } - }; + public double[][] getData() + { + return new double[][] { { 34, 30, 38, 38, 41, 22, 41, 44, 38, 29 } }; + } + }; - provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE, data); + provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE, data); - ChartAxis axis = new ChartAxis(ChartAxisType.BOTTOM); - axis.setLabels(new String[]{"Mar", "Apr", "May", "June", "July"}); - provider.addAxis(axis); + ChartAxis axis = new ChartAxis(ChartAxisType.BOTTOM); + axis.setLabels(new String[] { "Mar", "Apr", "May", "June", "July" }); + provider.addAxis(axis); - axis = new ChartAxis(ChartAxisType.LEFT); - axis.setLabels(new String[]{null, "50 Kb"}); - provider.addAxis(axis); + axis = new ChartAxis(ChartAxisType.LEFT); + axis.setLabels(new String[] { null, "50 Kb" }); + provider.addAxis(axis); - add(new Chart("lineHelloWorld", provider)); + add(new Chart("lineHelloWorld", provider)); - data = new AbstractChartData(ChartDataEncoding.TEXT, 100) { + data = new AbstractChartData(ChartDataEncoding.TEXT, 100) + { - public double[][] getData() { - return new double[][]{ - {0, 30, 60, 70, 90, 95, 100}, - {20, 30, 40, 50, 60, 70, 80}, - {10, 30, 40, 45, 52}, - {100, 90, 40, 20, 10}, - null, - {5, 33, 50, 55, 7} - }; - } - }; + public double[][] getData() + { + return new double[][] { { 0, 30, 60, 70, 90, 95, 100 }, + { 20, 30, 40, 50, 60, 70, 80 }, { 10, 30, 40, 45, 52 }, + { 100, 90, 40, 20, 10 }, null, { 5, 33, 50, 55, 7 } }; + } + }; - provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE_XY, data); - provider.setColors(new Color[]{Color.decode("#3072F3"), Color.RED, Color.decode("#00aaaa")}); - provider.setLineStyles(new LineStyle[]{new LineStyle(2, 4, 1)}); + provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE_XY, data); + provider.setColors(new Color[] { Color.decode("#3072F3"), Color.RED, + Color.decode("#00aaaa") }); + provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 1) }); - provider.addShapeMarker(new ShapeMarker(MarkerType.SQUARE, Color.RED, 0, -1, 5)); - provider.addShapeMarker(new ShapeMarker(MarkerType.SQUARE, Color.BLUE, 1, -1, 5)); - provider.addShapeMarker(new ShapeMarker(MarkerType.SQUARE, Color.decode("#00aa00"), 2, -1, 5)); + provider.addShapeMarker(new ShapeMarker(MarkerType.SQUARE, Color.RED, 0, -1, 5)); + provider.addShapeMarker(new ShapeMarker(MarkerType.SQUARE, Color.BLUE, 1, -1, 5)); + provider.addShapeMarker(new ShapeMarker(MarkerType.SQUARE, Color.decode("#00aa00"), 2, -1, + 5)); - add(new Chart("lineChart", provider)); + add(new Chart("lineChart", provider)); - data = new AbstractChartData() { + data = new AbstractChartData() + { - public double[][] getData() { - return new double[][]{ - {7, 4, 11, 11}, - {22, 14, 17, 11} - }; - } - }; + public double[][] getData() + { + return new double[][] { { 7, 4, 11, 11 }, { 22, 14, 17, 11 } }; + } + }; - provider = new ChartProvider(new Dimension(200, 125), ChartType.BAR_HORIZONTAL_SET, data); - provider.setColors(new Color[]{Color.RED, Color.decode("#00aa00")}); + provider = new ChartProvider(new Dimension(200, 125), ChartType.BAR_HORIZONTAL_SET, data); + provider.setColors(new Color[] { Color.RED, Color.decode("#00aa00") }); - add(new Chart("horizontalBarSet", provider)); + add(new Chart("horizontalBarSet", provider)); - data = new AbstractChartData() { + data = new AbstractChartData() + { - public double[][] getData() { - return new double[][]{{34, 30, 38, 38, 41}}; - } - }; + public double[][] getData() + { + return new double[][] { { 34, 30, 38, 38, 41 } }; + } + }; - provider = new ChartProvider(new Dimension(200, 125), ChartType.BAR_HORIZONTAL_SET, data); + provider = new ChartProvider(new Dimension(200, 125), ChartType.BAR_HORIZONTAL_SET, data); - add(new Chart("horizontalScaledBar", provider)); + add(new Chart("horizontalScaledBar", provider)); - data = new AbstractChartData(ChartDataEncoding.TEXT, 100) { + data = new AbstractChartData(ChartDataEncoding.TEXT, 100) + { - public double[][] getData() { - return new double[][]{{100, 80, 60, 30, 30, 30, 10}}; - } - }; + public double[][] getData() + { + return new double[][] { { 100, 80, 60, 30, 30, 30, 10 } }; + } + }; - provider = new ChartProvider(new Dimension(200, 100), ChartType.VENN, data); + provider = new ChartProvider(new Dimension(200, 100), ChartType.VENN, data); - add(new Chart("venn", provider)); + add(new Chart("venn", provider)); - data = new AbstractChartData() { + data = new AbstractChartData() + { - public double[][] getData() { - return new double[][]{{42, 43, 41, 38, 31, 24, 14, 13, 14, 12, - 4, 1, 0, 10, 15, 14, 16, 21, 19, 23, 25, 30, 31, 29, 27, 20, - 29, 33, 28, 42, 44, 43, 50, 47, 47, 50, 55, 61, 55, 52, 46, - 42, 41, 41, 40, 37, 31, 33, 33, 36, 42}}; - } - }; + public double[][] getData() + { + return new double[][] { { 42, 43, 41, 38, 31, 24, 14, 13, 14, 12, 4, 1, 0, 10, 15, + 14, 16, 21, 19, 23, 25, 30, 31, 29, 27, 20, 29, 33, 28, 42, 44, 43, 50, 47, + 47, 50, 55, 61, 55, 52, 46, 42, 41, 41, 40, 37, 31, 33, 33, 36, 42 } }; + } + }; - provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE, data); - provider.setColors(new Color[]{Color.RED}); - provider.setLineStyles(new LineStyle[]{new LineStyle(4, 3, 0)}); + provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE, data); + provider.setColors(new Color[] { Color.RED }); + provider.setLineStyles(new LineStyle[] { new LineStyle(4, 3, 0) }); - provider.setBackgroundFill(new SolidFill(Color.decode("#EFEFEF"))); - provider.setChartFill(new LinearGradientFill(45, - new Color[]{Color.WHITE, Color.decode("#76A4FB")}, new double[]{0, 0.75})); + provider.setBackgroundFill(new SolidFill(Color.decode("#EFEFEF"))); + provider.setChartFill(new LinearGradientFill(45, new Color[] { Color.WHITE, + Color.decode("#76A4FB") }, new double[] { 0, 0.75 })); - axis = new ChartAxis(ChartAxisType.BOTTOM); - axis.setLabels(new String[]{"1", "2", "3", "4", "5"}); - provider.addAxis(axis); + axis = new ChartAxis(ChartAxisType.BOTTOM); + axis.setLabels(new String[] { "1", "2", "3", "4", "5" }); + provider.addAxis(axis); - axis = new ChartAxis(ChartAxisType.LEFT); - axis.setLabels(new String[]{"0", "50", "100"}); - provider.addAxis(axis); + axis = new ChartAxis(ChartAxisType.LEFT); + axis.setLabels(new String[] { "0", "50", "100" }); + provider.addAxis(axis); - add(new Chart("backgrounds", provider)); + add(new Chart("backgrounds", provider)); - data = new AbstractChartData(ChartDataEncoding.TEXT, 100) { + data = new AbstractChartData(ChartDataEncoding.TEXT, 100) + { - public double[][] getData() { - return new double[][]{ - {12, 4, 4, 8, 24, 28, 24, 28, 12, 12, 16}, - {28, 28, 96, 40, 16, 32, 12, 24, 100, 44, 16, 8}, - {36, 40, 40, 24, 56, 72, 12, 8, 4, 48, 40, 12} - }; - } - }; + public double[][] getData() + { + return new double[][] { { 12, 4, 4, 8, 24, 28, 24, 28, 12, 12, 16 }, + { 28, 28, 96, 40, 16, 32, 12, 24, 100, 44, 16, 8 }, + { 36, 40, 40, 24, 56, 72, 12, 8, 4, 48, 40, 12 } }; + } + }; - provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE, data); - provider.setColors(new Color[]{Color.GREEN, Color.BLUE, Color.RED}); - provider.setLegend(new String[]{"2005", "2006", "2007"}); - provider.setLineStyles(new LineStyle[]{ - new LineStyle(3, 2, 0), - new LineStyle(3, 2, 0), - new LineStyle(3, 2, 0) - }); - provider.setBackgroundFill(new SolidFill(new Color(0, 0, 0, 0))); + provider = new ChartProvider(new Dimension(200, 125), ChartType.LINE, data); + provider.setColors(new Color[] { Color.GREEN, Color.BLUE, Color.RED }); + provider.setLegend(new String[] { "2005", "2006", "2007" }); + provider.setLineStyles(new LineStyle[] { new LineStyle(3, 2, 0), new LineStyle(3, 2, 0), + new LineStyle(3, 2, 0) }); + provider.setBackgroundFill(new SolidFill(new Color(0, 0, 0, 0))); - axis = new ChartAxis(ChartAxisType.BOTTOM); - axis.setLabels(new String[]{"J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}); - provider.addAxis(axis); + axis = new ChartAxis(ChartAxisType.BOTTOM); + axis.setLabels(new String[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" }); + provider.addAxis(axis); - axis = new ChartAxis(ChartAxisType.LEFT); - axis.setLabels(new String[]{null, "5", "10", "15", "20", "25"}); - provider.addAxis(axis); + axis = new ChartAxis(ChartAxisType.LEFT); + axis.setLabels(new String[] { null, "5", "10", "15", "20", "25" }); + provider.addAxis(axis); - add(new Chart("alex", provider)); - } + add(new Chart("alex", provider)); + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AbstractChartData.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AbstractChartData.java index 9630a52b56..4936bd5201 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AbstractChartData.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AbstractChartData.java @@ -6,37 +6,45 @@ /** * @author Daniel Spiewak */ -public abstract class AbstractChartData implements IChartData { - - private ChartDataEncoding encoding; - private double max; - - public AbstractChartData() { - this(62); - } - - public AbstractChartData(double max) { - this(ChartDataEncoding.SIMPLE, max); - } - - public AbstractChartData(ChartDataEncoding encoding, double max) { - this.encoding = encoding; - this.max = max; - } - - public ChartDataEncoding getEncoding() { - return encoding; - } - - public double getMax() { - return max; - } - - public void setEncoding(ChartDataEncoding encoding) { - this.encoding = encoding; - } - - public void setMax(double max) { - this.max = max; - } +public abstract class AbstractChartData implements IChartData +{ + + private ChartDataEncoding encoding; + private double max; + + public AbstractChartData() + { + this(62); + } + + public AbstractChartData(double max) + { + this(ChartDataEncoding.SIMPLE, max); + } + + public AbstractChartData(ChartDataEncoding encoding, double max) + { + this.encoding = encoding; + this.max = max; + } + + public ChartDataEncoding getEncoding() + { + return encoding; + } + + public double getMax() + { + return max; + } + + public void setEncoding(ChartDataEncoding encoding) + { + this.encoding = encoding; + } + + public void setMax(double max) + { + this.max = max; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AreaFillType.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AreaFillType.java index 704c04cdbf..77386e1fc1 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AreaFillType.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AreaFillType.java @@ -6,17 +6,19 @@ /** * @author Daniel Spiewak */ -public enum AreaFillType { +public enum AreaFillType +{ - BETWEEN("b"), - DOWN("B"); - private final String rendering; + BETWEEN("b"), DOWN("B"); + private final String rendering; - private AreaFillType(String rendering) { - this.rendering = rendering; - } + private AreaFillType(String rendering) + { + this.rendering = rendering; + } - public String getRendering() { - return rendering; - } + public String getRendering() + { + return rendering; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AxisAlignment.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AxisAlignment.java index f72461808f..ecdbdb0f4b 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AxisAlignment.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/AxisAlignment.java @@ -6,18 +6,19 @@ /** * @author Daniel Spiewak */ -public enum AxisAlignment { +public enum AxisAlignment +{ - LEFT(-1), - CENTER(0), - RIGHT(1); - private final int rendering; + LEFT(-1), CENTER(0), RIGHT(1); + private final int rendering; - private AxisAlignment(int rendering) { - this.rendering = rendering; - } + private AxisAlignment(int rendering) + { + this.rendering = rendering; + } - public int getRendering() { - return rendering; - } + public int getRendering() + { + return rendering; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Chart.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Chart.java index bf4a63df8a..d0b5251cd5 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Chart.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Chart.java @@ -16,575 +16,703 @@ /** * @author Daniel Spiewak */ -public class Chart extends WebComponent implements Serializable { - - private static final long serialVersionUID = 6286305912682861488L; - private IChartProvider provider; - private StringBuilder url; - private final ReadWriteLock lock = new ReentrantReadWriteLock(); - - public Chart(String id, IChartProvider provider) { - super(id); - - this.provider = provider; - } - - public void invalidate() { - lock.writeLock().lock(); - try { - url = null; - } finally { - lock.writeLock().unlock(); - } - } - - public CharSequence constructURL() { - lock.writeLock().lock(); - try { - if (url != null) { - return url; - } - - url = new StringBuilder("http://chart.apis.google.com/chart?"); - - addParameter(url, "chs", render(provider.getSize())); - addParameter(url, "chd", render(provider.getData())); - addParameter(url, "cht", render(provider.getType())); - addParameter(url, "chbh", render(provider.getBarWidth(), provider.getBarGroupSpacing())); - addParameter(url, "chtt", render(provider.getTitle())); - addParameter(url, "chdl", render(provider.getLegend())); - addParameter(url, "chco", render(provider.getColors())); - - IChartFill bgFill = provider.getBackgroundFill(); - IChartFill fgFill = provider.getChartFill(); - - StringBuilder fillParam = new StringBuilder(); - - if (bgFill != null) { - fillParam.append("bg,").append(render(bgFill)); - } - - if (fgFill != null) { - if (fillParam.length() > 0) { - fillParam.append('|'); - } - - fillParam.append("c,").append(render(fgFill)); - } - - if (fillParam.toString().trim().equals("")) { - fillParam = null; - } - - addParameter(url, "chf", fillParam); - - IChartAxis[] axes = provider.getAxes(); - addParameter(url, "chxt", renderTypes(axes)); - addParameter(url, "chxl", renderLabels(axes)); - addParameter(url, "chxp", renderPositions(axes)); - addParameter(url, "chxr", renderRanges(axes)); - addParameter(url, "chxs", renderStyles(axes)); - - addParameter(url, "chg", render(provider.getGrid())); - addParameter(url, "chm", render(provider.getShapeMarkers())); - addParameter(url, "chm", render(provider.getRangeMarkers())); - addParameter(url, "chls", render(provider.getLineStyles())); - addParameter(url, "chm", render(provider.getFillAreas())); - addParameter(url, "chl", render(provider.getPieLabels())); - - return url; - } finally { - lock.writeLock().unlock(); - } - } - - private void addParameter(StringBuilder url, CharSequence param, CharSequence value) { - if (value == null || value.length() == 0) { - return; - } - - if (url.charAt(url.length() - 1) != '?') { - url.append('&'); - } - - url.append(param).append('=').append(value); - } - - private CharSequence render(Dimension dim) { - if (dim == null) { - return null; - } - - return new StringBuilder().append(dim.width).append('x').append(dim.height); - } - - private CharSequence render(IChartData data) { - if (data == null) { - return null; - } - - ChartDataEncoding encoding = data.getEncoding(); - - StringBuilder back = new StringBuilder(); - back.append(render(encoding)).append(':'); - - for (double[] set : data.getData()) { - if (set == null || set.length == 0) { - back.append(encoding.convert(-1, data.getMax())); - } else { - for (double value : set) { - back.append(encoding.convert(value, data.getMax())).append(encoding.getValueSeparator()); - } - - if (back.substring(back.length() - encoding.getValueSeparator().length(), - back.length()).equals(encoding.getValueSeparator())) { - back.setLength(back.length() - encoding.getValueSeparator().length()); - } - } - - back.append(encoding.getSetSeparator()); - } - - if (back.substring(back.length() - encoding.getSetSeparator().length(), - back.length()).equals(encoding.getSetSeparator())) { - back.setLength(back.length() - encoding.getSetSeparator().length()); - } - - return back; - } - - private CharSequence render(Enum value) { - if (value == null) { - return null; - } - - try { - Object back = value.getClass().getMethod("getRendering").invoke(value); - - if (back != null) { - return back.toString(); - } - } catch (IllegalArgumentException e) { - } catch (SecurityException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } catch (NoSuchMethodException e) { - } - - return null; - } - - private CharSequence render(int barWidth, int groupSpacing) { - if (barWidth == -1) { - return null; - } - - StringBuilder back = new StringBuilder(barWidth); - - if (groupSpacing >= 0) { - back.append(',').append(groupSpacing); - } - - return back; - } - - private CharSequence render(String[] values) { - if (values == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (String value : values) { - CharSequence toRender = render(value); - if (toRender == null) { - toRender = ""; - } - - back.append(toRender).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(String value) { - if (value == null) { - return value; - } - - StringBuilder back = new StringBuilder(); - - for (char c : value.toCharArray()) { - if (c == ' ') { - back.append('+'); - } else { - back.append(c); - } - } - - return back; - } - - private CharSequence render(Color[] values) { - if (values == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (Color value : values) { - CharSequence toRender = render(value); - if (toRender == null) { - toRender = ""; - } - - back.append(toRender).append(','); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(Color value) { - if (value == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - { - String toPad = Integer.toHexString(value.getRed()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - { - String toPad = Integer.toHexString(value.getGreen()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - { - String toPad = Integer.toHexString(value.getBlue()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - { - String toPad = Integer.toHexString(value.getAlpha()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - return back; - } - - private CharSequence render(IChartFill fill) { - if (fill == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - if (fill instanceof ISolidFill) { - ISolidFill solidFill = (ISolidFill) fill; - - back.append("s,"); - back.append(render(solidFill.getColor())); - } else if (fill instanceof ILinearGradientFill) { - ILinearGradientFill gradientFill = (ILinearGradientFill) fill; - - back.append("lg,").append(gradientFill.getAngle()).append(','); - - Color[] colors = gradientFill.getColors(); - double[] offsets = gradientFill.getOffsets(); - for (int i = 0; i < colors.length; i++) { - back.append(render(colors[i])).append(',').append(offsets[i]).append(','); - } - - back.setLength(back.length() - 1); - } else if (fill instanceof ILinearStripesFill) { - ILinearStripesFill stripesFill = (ILinearStripesFill) fill; - - back.append("ls,").append(stripesFill.getAngle()).append(','); - - Color[] colors = stripesFill.getColors(); - double[] widths = stripesFill.getWidths(); - for (int i = 0; i < colors.length; i++) { - back.append(render(colors[i])).append(',').append(widths[i]).append(','); - } - - back.setLength(back.length() - 1); - } else { - return null; - } - - return back; - } - - private CharSequence renderTypes(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IChartAxis axis : axes) { - back.append(render(axis.getType())).append(','); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence renderLabels(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getLabels() == null) { - continue; - } - - back.append(i).append(":|"); - - for (String label : axes[i].getLabels()) { - if (label == null) { - back.append('|'); - continue; - } - - back.append(render(label)).append('|'); - } - - if (i == axes.length - 1) { - back.setLength(back.length() - 1); - } - } - - return back; - } - - private CharSequence renderPositions(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getPositions() == null) { - continue; - } - - back.append(i).append(','); - - for (double position : axes[i].getPositions()) { - back.append(position).append(','); - } - - back.setLength(back.length() - 1); - - back.append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence renderRanges(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getRange() == null) { - continue; - } - - back.append(i).append(','); - - Range range = axes[i].getRange(); - back.append(range.getStart()).append(',').append(range.getEnd()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence renderStyles(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getColor() == null - || axes[i].getFontSize() < 0 || axes[i].getAlignment() == null) { - continue; - } - - back.append(i).append(','); - back.append(render(axes[i].getColor())).append(','); - back.append(axes[i].getFontSize()).append(','); - back.append(render(axes[i].getAlignment())).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(IChartGrid grid) { - if (grid == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - back.append(grid.getXStepSize()).append(','); - back.append(grid.getYStepSize()); - - if (grid.getSegmentLength() >= 0) { - back.append(',').append(grid.getSegmentLength()); - back.append(',').append(grid.getBlankLength()); - } - - return back; - } - - private CharSequence render(IShapeMarker[] markers) { - if (markers == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IShapeMarker marker : markers) { - back.append(render(marker.getType())).append(','); - back.append(render(marker.getColor())).append(','); - back.append(marker.getIndex()).append(','); - back.append(marker.getPoint()).append(','); - back.append(marker.getSize()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(IRangeMarker[] markers) { - if (markers == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IRangeMarker marker : markers) { - back.append(render(marker.getType())).append(','); - back.append(render(marker.getColor())).append(','); - back.append(0).append(','); - back.append(marker.getStart()).append(','); - back.append(marker.getEnd()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(IFillArea[] areas) { - if (areas == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IFillArea area : areas) { - back.append(render(area.getType())).append(','); - back.append(render(area.getColor())).append(','); - back.append(area.getStartIndex()).append(','); - back.append(area.getEndIndex()).append(','); - back.append(0).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(ILineStyle[] styles) { - if (styles == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (ILineStyle style : styles) { - if (style == null) { - back.append('|'); - continue; - } - - back.append(style.getThickness()).append(','); - back.append(style.getSegmentLength()).append(','); - back.append(style.getBlankLength()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - @Override - protected void onComponentTag(ComponentTag tag) { - checkComponentTag(tag, "img"); - super.onComponentTag(tag); - - tag.put("src", constructURL()); - } +public class Chart extends WebComponent implements Serializable +{ + + private static final long serialVersionUID = 6286305912682861488L; + private IChartProvider provider; + private StringBuilder url; + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + + public Chart(String id, IChartProvider provider) + { + super(id); + + this.provider = provider; + } + + public void invalidate() + { + lock.writeLock().lock(); + try + { + url = null; + } + finally + { + lock.writeLock().unlock(); + } + } + + public CharSequence constructURL() + { + lock.writeLock().lock(); + try + { + if (url != null) + { + return url; + } + + url = new StringBuilder("http://chart.apis.google.com/chart?"); + + addParameter(url, "chs", render(provider.getSize())); + addParameter(url, "chd", render(provider.getData())); + addParameter(url, "cht", render(provider.getType())); + addParameter(url, "chbh", render(provider.getBarWidth(), provider.getBarGroupSpacing())); + addParameter(url, "chtt", render(provider.getTitle())); + addParameter(url, "chdl", render(provider.getLegend())); + addParameter(url, "chco", render(provider.getColors())); + + IChartFill bgFill = provider.getBackgroundFill(); + IChartFill fgFill = provider.getChartFill(); + + StringBuilder fillParam = new StringBuilder(); + + if (bgFill != null) + { + fillParam.append("bg,").append(render(bgFill)); + } + + if (fgFill != null) + { + if (fillParam.length() > 0) + { + fillParam.append('|'); + } + + fillParam.append("c,").append(render(fgFill)); + } + + if (fillParam.toString().trim().equals("")) + { + fillParam = null; + } + + addParameter(url, "chf", fillParam); + + IChartAxis[] axes = provider.getAxes(); + addParameter(url, "chxt", renderTypes(axes)); + addParameter(url, "chxl", renderLabels(axes)); + addParameter(url, "chxp", renderPositions(axes)); + addParameter(url, "chxr", renderRanges(axes)); + addParameter(url, "chxs", renderStyles(axes)); + + addParameter(url, "chg", render(provider.getGrid())); + addParameter(url, "chm", render(provider.getShapeMarkers())); + addParameter(url, "chm", render(provider.getRangeMarkers())); + addParameter(url, "chls", render(provider.getLineStyles())); + addParameter(url, "chm", render(provider.getFillAreas())); + addParameter(url, "chl", render(provider.getPieLabels())); + + return url; + } + finally + { + lock.writeLock().unlock(); + } + } + + private void addParameter(StringBuilder url, CharSequence param, CharSequence value) + { + if (value == null || value.length() == 0) + { + return; + } + + if (url.charAt(url.length() - 1) != '?') + { + url.append('&'); + } + + url.append(param).append('=').append(value); + } + + private CharSequence render(Dimension dim) + { + if (dim == null) + { + return null; + } + + return new StringBuilder().append(dim.width).append('x').append(dim.height); + } + + private CharSequence render(IChartData data) + { + if (data == null) + { + return null; + } + + ChartDataEncoding encoding = data.getEncoding(); + + StringBuilder back = new StringBuilder(); + back.append(render(encoding)).append(':'); + + for (double[] set : data.getData()) + { + if (set == null || set.length == 0) + { + back.append(encoding.convert(-1, data.getMax())); + } + else + { + for (double value : set) + { + back.append(encoding.convert(value, data.getMax())).append( + encoding.getValueSeparator()); + } + + if (back.substring(back.length() - encoding.getValueSeparator().length(), + back.length()).equals(encoding.getValueSeparator())) + { + back.setLength(back.length() - encoding.getValueSeparator().length()); + } + } + + back.append(encoding.getSetSeparator()); + } + + if (back.substring(back.length() - encoding.getSetSeparator().length(), back.length()) + .equals(encoding.getSetSeparator())) + { + back.setLength(back.length() - encoding.getSetSeparator().length()); + } + + return back; + } + + private CharSequence render(Enum value) + { + if (value == null) + { + return null; + } + + try + { + Object back = value.getClass().getMethod("getRendering").invoke(value); + + if (back != null) + { + return back.toString(); + } + } + catch (IllegalArgumentException e) + { + } + catch (SecurityException e) + { + } + catch (IllegalAccessException e) + { + } + catch (InvocationTargetException e) + { + } + catch (NoSuchMethodException e) + { + } + + return null; + } + + private CharSequence render(int barWidth, int groupSpacing) + { + if (barWidth == -1) + { + return null; + } + + StringBuilder back = new StringBuilder(barWidth); + + if (groupSpacing >= 0) + { + back.append(',').append(groupSpacing); + } + + return back; + } + + private CharSequence render(String[] values) + { + if (values == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (String value : values) + { + CharSequence toRender = render(value); + if (toRender == null) + { + toRender = ""; + } + + back.append(toRender).append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence render(String value) + { + if (value == null) + { + return value; + } + + StringBuilder back = new StringBuilder(); + + for (char c : value.toCharArray()) + { + if (c == ' ') + { + back.append('+'); + } + else + { + back.append(c); + } + } + + return back; + } + + private CharSequence render(Color[] values) + { + if (values == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (Color value : values) + { + CharSequence toRender = render(value); + if (toRender == null) + { + toRender = ""; + } + + back.append(toRender).append(','); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence render(Color value) + { + if (value == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + { + String toPad = Integer.toHexString(value.getRed()); + + if (toPad.length() == 1) + { + back.append(0); + } + back.append(toPad); + } + + { + String toPad = Integer.toHexString(value.getGreen()); + + if (toPad.length() == 1) + { + back.append(0); + } + back.append(toPad); + } + + { + String toPad = Integer.toHexString(value.getBlue()); + + if (toPad.length() == 1) + { + back.append(0); + } + back.append(toPad); + } + + { + String toPad = Integer.toHexString(value.getAlpha()); + + if (toPad.length() == 1) + { + back.append(0); + } + back.append(toPad); + } + + return back; + } + + private CharSequence render(IChartFill fill) + { + if (fill == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + if (fill instanceof ISolidFill) + { + ISolidFill solidFill = (ISolidFill)fill; + + back.append("s,"); + back.append(render(solidFill.getColor())); + } + else if (fill instanceof ILinearGradientFill) + { + ILinearGradientFill gradientFill = (ILinearGradientFill)fill; + + back.append("lg,").append(gradientFill.getAngle()).append(','); + + Color[] colors = gradientFill.getColors(); + double[] offsets = gradientFill.getOffsets(); + for (int i = 0; i < colors.length; i++) + { + back.append(render(colors[i])).append(',').append(offsets[i]).append(','); + } + + back.setLength(back.length() - 1); + } + else if (fill instanceof ILinearStripesFill) + { + ILinearStripesFill stripesFill = (ILinearStripesFill)fill; + + back.append("ls,").append(stripesFill.getAngle()).append(','); + + Color[] colors = stripesFill.getColors(); + double[] widths = stripesFill.getWidths(); + for (int i = 0; i < colors.length; i++) + { + back.append(render(colors[i])).append(',').append(widths[i]).append(','); + } + + back.setLength(back.length() - 1); + } + else + { + return null; + } + + return back; + } + + private CharSequence renderTypes(IChartAxis[] axes) + { + if (axes == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (IChartAxis axis : axes) + { + back.append(render(axis.getType())).append(','); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence renderLabels(IChartAxis[] axes) + { + if (axes == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (int i = 0; i < axes.length; i++) + { + if (axes[i] == null || axes[i].getLabels() == null) + { + continue; + } + + back.append(i).append(":|"); + + for (String label : axes[i].getLabels()) + { + if (label == null) + { + back.append('|'); + continue; + } + + back.append(render(label)).append('|'); + } + + if (i == axes.length - 1) + { + back.setLength(back.length() - 1); + } + } + + return back; + } + + private CharSequence renderPositions(IChartAxis[] axes) + { + if (axes == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (int i = 0; i < axes.length; i++) + { + if (axes[i] == null || axes[i].getPositions() == null) + { + continue; + } + + back.append(i).append(','); + + for (double position : axes[i].getPositions()) + { + back.append(position).append(','); + } + + back.setLength(back.length() - 1); + + back.append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence renderRanges(IChartAxis[] axes) + { + if (axes == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (int i = 0; i < axes.length; i++) + { + if (axes[i] == null || axes[i].getRange() == null) + { + continue; + } + + back.append(i).append(','); + + Range range = axes[i].getRange(); + back.append(range.getStart()).append(',').append(range.getEnd()).append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence renderStyles(IChartAxis[] axes) + { + if (axes == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (int i = 0; i < axes.length; i++) + { + if (axes[i] == null || axes[i].getColor() == null || axes[i].getFontSize() < 0 || + axes[i].getAlignment() == null) + { + continue; + } + + back.append(i).append(','); + back.append(render(axes[i].getColor())).append(','); + back.append(axes[i].getFontSize()).append(','); + back.append(render(axes[i].getAlignment())).append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence render(IChartGrid grid) + { + if (grid == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + back.append(grid.getXStepSize()).append(','); + back.append(grid.getYStepSize()); + + if (grid.getSegmentLength() >= 0) + { + back.append(',').append(grid.getSegmentLength()); + back.append(',').append(grid.getBlankLength()); + } + + return back; + } + + private CharSequence render(IShapeMarker[] markers) + { + if (markers == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (IShapeMarker marker : markers) + { + back.append(render(marker.getType())).append(','); + back.append(render(marker.getColor())).append(','); + back.append(marker.getIndex()).append(','); + back.append(marker.getPoint()).append(','); + back.append(marker.getSize()).append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence render(IRangeMarker[] markers) + { + if (markers == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (IRangeMarker marker : markers) + { + back.append(render(marker.getType())).append(','); + back.append(render(marker.getColor())).append(','); + back.append(0).append(','); + back.append(marker.getStart()).append(','); + back.append(marker.getEnd()).append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence render(IFillArea[] areas) + { + if (areas == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (IFillArea area : areas) + { + back.append(render(area.getType())).append(','); + back.append(render(area.getColor())).append(','); + back.append(area.getStartIndex()).append(','); + back.append(area.getEndIndex()).append(','); + back.append(0).append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + private CharSequence render(ILineStyle[] styles) + { + if (styles == null) + { + return null; + } + + StringBuilder back = new StringBuilder(); + + for (ILineStyle style : styles) + { + if (style == null) + { + back.append('|'); + continue; + } + + back.append(style.getThickness()).append(','); + back.append(style.getSegmentLength()).append(','); + back.append(style.getBlankLength()).append('|'); + } + + if (back.length() > 0) + { + back.setLength(back.length() - 1); + } + + return back; + } + + @Override + protected void onComponentTag(ComponentTag tag) + { + checkComponentTag(tag, "img"); + super.onComponentTag(tag); + + tag.put("src", constructURL()); + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxis.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxis.java index cf33f36184..de01716a7a 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxis.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxis.java @@ -8,74 +8,90 @@ /** * @author Daniel Spiewak */ -public class ChartAxis implements IChartAxis { - - private static final long serialVersionUID = 7846972840224609873L; - private AxisAlignment alignment; - private Color color; - private int fontSize = -1; - private String[] labels; - private double[] positions; - private Range range; - private ChartAxisType type; - - public ChartAxis(ChartAxisType type) { - this.type = type; - } - - public AxisAlignment getAlignment() { - return alignment; - } - - public Color getColor() { - return color; - } - - public int getFontSize() { - return fontSize; - } - - public String[] getLabels() { - return labels; - } - - public double[] getPositions() { - return positions; - } - - public Range getRange() { - return range; - } - - public ChartAxisType getType() { - return type; - } - - public void setAlignment(AxisAlignment alignment) { - this.alignment = alignment; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setFontSize(int fontSize) { - this.fontSize = fontSize; - } - - public void setLabels(String[] labels) { - this.labels = labels; - } - - public void setPositions(double[] positions) { - this.positions = positions; - } - - public void setRange(Range range) { - this.range = range; - } - - public void setType(ChartAxisType type) { - this.type = type; - } +public class ChartAxis implements IChartAxis +{ + + private static final long serialVersionUID = 7846972840224609873L; + private AxisAlignment alignment; + private Color color; + private int fontSize = -1; + private String[] labels; + private double[] positions; + private Range range; + private ChartAxisType type; + + public ChartAxis(ChartAxisType type) + { + this.type = type; + } + + public AxisAlignment getAlignment() + { + return alignment; + } + + public Color getColor() + { + return color; + } + + public int getFontSize() + { + return fontSize; + } + + public String[] getLabels() + { + return labels; + } + + public double[] getPositions() + { + return positions; + } + + public Range getRange() + { + return range; + } + + public ChartAxisType getType() + { + return type; + } + + public void setAlignment(AxisAlignment alignment) + { + this.alignment = alignment; + } + + public void setColor(Color color) + { + this.color = color; + } + + public void setFontSize(int fontSize) + { + this.fontSize = fontSize; + } + + public void setLabels(String[] labels) + { + this.labels = labels; + } + + public void setPositions(double[] positions) + { + this.positions = positions; + } + + public void setRange(Range range) + { + this.range = range; + } + + public void setType(ChartAxisType type) + { + this.type = type; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxisType.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxisType.java index b66dfe7a4f..aefa6b7209 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxisType.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartAxisType.java @@ -6,19 +6,19 @@ /** * @author Daniel Spiewak */ -public enum ChartAxisType { +public enum ChartAxisType +{ - BOTTOM("x"), - TOP("t"), - LEFT("y"), - RIGHT("r"); - private final String rendering; + BOTTOM("x"), TOP("t"), LEFT("y"), RIGHT("r"); + private final String rendering; - private ChartAxisType(String rendering) { - this.rendering = rendering; - } + private ChartAxisType(String rendering) + { + this.rendering = rendering; + } - public String getRendering() { - return rendering; - } + public String getRendering() + { + return rendering; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartDataEncoding.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartDataEncoding.java index e92e8b22ad..4f77824960 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartDataEncoding.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartDataEncoding.java @@ -6,81 +6,98 @@ /** * @author Daniel Spiewak */ -public enum ChartDataEncoding { - - SIMPLE("s", "", ",") { - - @Override - CharSequence convert(double value, double max) { - if (value < 0) { - return "_"; - } - - value = Math.round((CHARS.length() - 1) * value / max); - - if (value > CHARS.length() - 1) { - throw new IllegalArgumentException(value + " is out of range for SIMPLE encoding"); - } - - return Character.toString(CHARS.charAt((int) value)); - } - }, - TEXT("t", ",", "|") { - - @Override - CharSequence convert(double value, double max) { - if (value < 0) { - value = -1; - } - - if (value > 100) { - throw new IllegalArgumentException(value + " is out of range for TEXT encoding"); - } - - return Double.toString(value); - } - }, - EXTENDED("e", "", ",") { - - @Override - CharSequence convert(double value, double max) { - if (value < 0) { - return "__"; - } - - value = Math.round(value); - - if (value > (EXT_CHARS.length() - 1) * (EXT_CHARS.length() - 1)) { - throw new IllegalArgumentException(value + " is out of range for EXTENDED encoding"); - } - - int rem = (int) (value % EXT_CHARS.length()); - int exp = (int) (value / EXT_CHARS.length()); - - return new StringBuilder().append(EXT_CHARS.charAt(exp)).append(EXT_CHARS.charAt(rem)); - } - }; - private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - private static final String EXT_CHARS = CHARS + "-_."; - private final String rendering, valueSeparator, setSeparator; - - private ChartDataEncoding(String rendering, String valueSeparator, String setSeparator) { - this.rendering = rendering; - this.valueSeparator = valueSeparator; - this.setSeparator = setSeparator; - } - - public String getRendering() { - return rendering; - } - - public String getValueSeparator() { - return valueSeparator; - } - - public String getSetSeparator() { - return setSeparator; - } - - abstract CharSequence convert(double value, double max); +public enum ChartDataEncoding +{ + + SIMPLE("s", "", ",") + { + + @Override + CharSequence convert(double value, double max) + { + if (value < 0) + { + return "_"; + } + + value = Math.round((CHARS.length() - 1) * value / max); + + if (value > CHARS.length() - 1) + { + throw new IllegalArgumentException(value + " is out of range for SIMPLE encoding"); + } + + return Character.toString(CHARS.charAt((int)value)); + } + }, + TEXT("t", ",", "|") + { + + @Override + CharSequence convert(double value, double max) + { + if (value < 0) + { + value = -1; + } + + if (value > 100) + { + throw new IllegalArgumentException(value + " is out of range for TEXT encoding"); + } + + return Double.toString(value); + } + }, + EXTENDED("e", "", ",") + { + + @Override + CharSequence convert(double value, double max) + { + if (value < 0) + { + return "__"; + } + + value = Math.round(value); + + if (value > (EXT_CHARS.length() - 1) * (EXT_CHARS.length() - 1)) + { + throw new IllegalArgumentException(value + " is out of range for EXTENDED encoding"); + } + + int rem = (int)(value % EXT_CHARS.length()); + int exp = (int)(value / EXT_CHARS.length()); + + return new StringBuilder().append(EXT_CHARS.charAt(exp)).append(EXT_CHARS.charAt(rem)); + } + }; + private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + private static final String EXT_CHARS = CHARS + "-_."; + private final String rendering, valueSeparator, setSeparator; + + private ChartDataEncoding(String rendering, String valueSeparator, String setSeparator) + { + this.rendering = rendering; + this.valueSeparator = valueSeparator; + this.setSeparator = setSeparator; + } + + public String getRendering() + { + return rendering; + } + + public String getValueSeparator() + { + return valueSeparator; + } + + public String getSetSeparator() + { + return setSeparator; + } + + abstract CharSequence convert(double value, double max); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartGrid.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartGrid.java index 31d0d2c250..1d8ad15c12 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartGrid.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartGrid.java @@ -6,48 +6,58 @@ /** * @author Daniel Spiewak */ -public class ChartGrid implements IChartGrid { - - private static final long serialVersionUID = -3877045632327926844L; - private int blankLength = -1; - private int segmentLength = -1; - private int xStepSize = -1; - private int yStepSize = -1; - - public ChartGrid(int xStepSize, int yStepSize) { - this.xStepSize = xStepSize; - this.yStepSize = yStepSize; - } - - public int getBlankLength() { - return blankLength; - } - - public int getSegmentLength() { - return segmentLength; - } - - public double getXStepSize() { - return xStepSize; - } - - public double getYStepSize() { - return yStepSize; - } - - public void setBlankLength(int blankLength) { - this.blankLength = blankLength; - } - - public void setSegmentLength(int segmentLength) { - this.segmentLength = segmentLength; - } - - public void setXStepSize(int stepSize) { - xStepSize = stepSize; - } - - public void setYStepSize(int stepSize) { - yStepSize = stepSize; - } +public class ChartGrid implements IChartGrid +{ + + private static final long serialVersionUID = -3877045632327926844L; + private int blankLength = -1; + private int segmentLength = -1; + private int xStepSize = -1; + private int yStepSize = -1; + + public ChartGrid(int xStepSize, int yStepSize) + { + this.xStepSize = xStepSize; + this.yStepSize = yStepSize; + } + + public int getBlankLength() + { + return blankLength; + } + + public int getSegmentLength() + { + return segmentLength; + } + + public double getXStepSize() + { + return xStepSize; + } + + public double getYStepSize() + { + return yStepSize; + } + + public void setBlankLength(int blankLength) + { + this.blankLength = blankLength; + } + + public void setSegmentLength(int segmentLength) + { + this.segmentLength = segmentLength; + } + + public void setXStepSize(int stepSize) + { + xStepSize = stepSize; + } + + public void setYStepSize(int stepSize) + { + yStepSize = stepSize; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartProvider.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartProvider.java index 23b02c964c..14d940d912 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartProvider.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartProvider.java @@ -11,166 +11,202 @@ /** * @author Daniel Spiewak */ -public class ChartProvider implements IChartProvider { - - private static final long serialVersionUID = -2660199063331734673L; - private List axes = new ArrayList(); - private IChartFill backgroundFill; - private int barGroupSpacing = -1; - private int barWidth = -1; - private IChartFill chartFill; - private Color[] colors; - private List fillAreas = new ArrayList(); - private IChartGrid grid; - private String[] legend; - private ILineStyle[] lineStyles; - private String[] pieLabels; - private List rangeMarkers = new ArrayList(); - private List shapeMarkers = new ArrayList(); - private Dimension size; - private String title; - private ChartType type; - private IChartData data; - - public ChartProvider(Dimension size, ChartType type, IChartData data) { - this.size = size; - this.type = type; - this.data = data; - } - - public IChartAxis[] getAxes() { - return axes.toArray(new IChartAxis[axes.size()]); - } - - public IChartFill getBackgroundFill() { - return backgroundFill; - } - - public int getBarGroupSpacing() { - return barGroupSpacing; - } - - public int getBarWidth() { - return barWidth; - } - - public IChartFill getChartFill() { - return chartFill; - } - - public Color[] getColors() { - return colors; - } - - public IFillArea[] getFillAreas() { - return fillAreas.toArray(new IFillArea[fillAreas.size()]); - } - - public IChartGrid getGrid() { - return grid; - } - - public String[] getLegend() { - return legend; - } - - public ILineStyle[] getLineStyles() { - return lineStyles; - } - - public String[] getPieLabels() { - return pieLabels; - } - - public IRangeMarker[] getRangeMarkers() { - return rangeMarkers.toArray(new IRangeMarker[rangeMarkers.size()]); - } - - public IShapeMarker[] getShapeMarkers() { - return shapeMarkers.toArray(new IShapeMarker[shapeMarkers.size()]); - } - - public Dimension getSize() { - return size; - } - - public String getTitle() { - return title; - } - - public ChartType getType() { - return type; - } - - public void addFillArea(IFillArea fillArea) { - fillAreas.add(fillArea); - } - - public void addAxis(IChartAxis axis) { - axes.add(axis); - } - - public void setBackgroundFill(IChartFill backgroundFill) { - this.backgroundFill = backgroundFill; - } - - public void setBarGroupSpacing(int barGroupSpacing) { - this.barGroupSpacing = barGroupSpacing; - } - - public void setBarWidth(int barWidth) { - this.barWidth = barWidth; - } - - public void setChartFill(IChartFill chartFill) { - this.chartFill = chartFill; - } - - public void setColors(Color[] colors) { - this.colors = colors; - } - - public void setGrid(IChartGrid grid) { - this.grid = grid; - } - - public void setLegend(String[] legend) { - this.legend = legend; - } - - public void setLineStyles(ILineStyle[] lineStyles) { - this.lineStyles = lineStyles; - } - - public void setPieLabels(String[] pieLabels) { - this.pieLabels = pieLabels; - } - - public void addRangeMarker(IRangeMarker rangeMarker) { - rangeMarkers.add(rangeMarker); - } - - public void addShapeMarker(IShapeMarker shapeMarker) { - shapeMarkers.add(shapeMarker); - } - - public void setSize(Dimension size) { - this.size = size; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setType(ChartType type) { - this.type = type; - } - - public IChartData getData() { - return data; - } - - public void setData(IChartData data) { - this.data = data; - } +public class ChartProvider implements IChartProvider +{ + + private static final long serialVersionUID = -2660199063331734673L; + private List axes = new ArrayList(); + private IChartFill backgroundFill; + private int barGroupSpacing = -1; + private int barWidth = -1; + private IChartFill chartFill; + private Color[] colors; + private List fillAreas = new ArrayList(); + private IChartGrid grid; + private String[] legend; + private ILineStyle[] lineStyles; + private String[] pieLabels; + private List rangeMarkers = new ArrayList(); + private List shapeMarkers = new ArrayList(); + private Dimension size; + private String title; + private ChartType type; + private IChartData data; + + public ChartProvider(Dimension size, ChartType type, IChartData data) + { + this.size = size; + this.type = type; + this.data = data; + } + + public IChartAxis[] getAxes() + { + return axes.toArray(new IChartAxis[axes.size()]); + } + + public IChartFill getBackgroundFill() + { + return backgroundFill; + } + + public int getBarGroupSpacing() + { + return barGroupSpacing; + } + + public int getBarWidth() + { + return barWidth; + } + + public IChartFill getChartFill() + { + return chartFill; + } + + public Color[] getColors() + { + return colors; + } + + public IFillArea[] getFillAreas() + { + return fillAreas.toArray(new IFillArea[fillAreas.size()]); + } + + public IChartGrid getGrid() + { + return grid; + } + + public String[] getLegend() + { + return legend; + } + + public ILineStyle[] getLineStyles() + { + return lineStyles; + } + + public String[] getPieLabels() + { + return pieLabels; + } + + public IRangeMarker[] getRangeMarkers() + { + return rangeMarkers.toArray(new IRangeMarker[rangeMarkers.size()]); + } + + public IShapeMarker[] getShapeMarkers() + { + return shapeMarkers.toArray(new IShapeMarker[shapeMarkers.size()]); + } + + public Dimension getSize() + { + return size; + } + + public String getTitle() + { + return title; + } + + public ChartType getType() + { + return type; + } + + public void addFillArea(IFillArea fillArea) + { + fillAreas.add(fillArea); + } + + public void addAxis(IChartAxis axis) + { + axes.add(axis); + } + + public void setBackgroundFill(IChartFill backgroundFill) + { + this.backgroundFill = backgroundFill; + } + + public void setBarGroupSpacing(int barGroupSpacing) + { + this.barGroupSpacing = barGroupSpacing; + } + + public void setBarWidth(int barWidth) + { + this.barWidth = barWidth; + } + + public void setChartFill(IChartFill chartFill) + { + this.chartFill = chartFill; + } + + public void setColors(Color[] colors) + { + this.colors = colors; + } + + public void setGrid(IChartGrid grid) + { + this.grid = grid; + } + + public void setLegend(String[] legend) + { + this.legend = legend; + } + + public void setLineStyles(ILineStyle[] lineStyles) + { + this.lineStyles = lineStyles; + } + + public void setPieLabels(String[] pieLabels) + { + this.pieLabels = pieLabels; + } + + public void addRangeMarker(IRangeMarker rangeMarker) + { + rangeMarkers.add(rangeMarker); + } + + public void addShapeMarker(IShapeMarker shapeMarker) + { + shapeMarkers.add(shapeMarker); + } + + public void setSize(Dimension size) + { + this.size = size; + } + + public void setTitle(String title) + { + this.title = title; + } + + public void setType(ChartType type) + { + this.type = type; + } + + public IChartData getData() + { + return data; + } + + public void setData(IChartData data) + { + this.data = data; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartType.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartType.java index 55c110f499..77e4fb8391 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartType.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ChartType.java @@ -6,25 +6,20 @@ /** * @author Daniel Spiewak */ -public enum ChartType { +public enum ChartType +{ - LINE("lc"), - LINE_XY("lxy"), - BAR_HORIZONTAL_SET("bhs"), - BAR_VERTICAL_SET("bvs"), - BAR_HORIZONTAL_GROUP("bhg"), - BAR_VERTICAL_GROUP("bvg"), - PIE("p"), - PIE_3D("p3"), - VENN("v"), - SCATTER("s"); - private final String rendering; + LINE("lc"), LINE_XY("lxy"), BAR_HORIZONTAL_SET("bhs"), BAR_VERTICAL_SET("bvs"), BAR_HORIZONTAL_GROUP( + "bhg"), BAR_VERTICAL_GROUP("bvg"), PIE("p"), PIE_3D("p3"), VENN("v"), SCATTER("s"); + private final String rendering; - private ChartType(String rendering) { - this.rendering = rendering; - } + private ChartType(String rendering) + { + this.rendering = rendering; + } - public String getRendering() { - return rendering; - } + public String getRendering() + { + return rendering; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/FillArea.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/FillArea.java index 5ad7e9456c..78fa8022fb 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/FillArea.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/FillArea.java @@ -8,49 +8,59 @@ /** * @author Daniel Spiewak */ -public class FillArea implements IFillArea { - - private static final long serialVersionUID = 6195093558116437908L; - private Color color; - private int endIndex = -1; - private int startIndex = -1; - private AreaFillType type = AreaFillType.BETWEEN; - - public FillArea(Color color, int startIndex, int endIndex) { - this.color = color; - this.startIndex = startIndex; - this.endIndex = endIndex; - } - - public Color getColor() { - return color; - } - - public int getEndIndex() { - return endIndex; - } - - public int getStartIndex() { - return startIndex; - } - - public AreaFillType getType() { - return type; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setEndIndex(int endIndex) { - this.endIndex = endIndex; - } - - public void setStartIndex(int startIndex) { - this.startIndex = startIndex; - } - - public void setType(AreaFillType type) { - this.type = type; - } +public class FillArea implements IFillArea +{ + + private static final long serialVersionUID = 6195093558116437908L; + private Color color; + private int endIndex = -1; + private int startIndex = -1; + private AreaFillType type = AreaFillType.BETWEEN; + + public FillArea(Color color, int startIndex, int endIndex) + { + this.color = color; + this.startIndex = startIndex; + this.endIndex = endIndex; + } + + public Color getColor() + { + return color; + } + + public int getEndIndex() + { + return endIndex; + } + + public int getStartIndex() + { + return startIndex; + } + + public AreaFillType getType() + { + return type; + } + + public void setColor(Color color) + { + this.color = color; + } + + public void setEndIndex(int endIndex) + { + this.endIndex = endIndex; + } + + public void setStartIndex(int startIndex) + { + this.startIndex = startIndex; + } + + public void setType(AreaFillType type) + { + this.type = type; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartAxis.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartAxis.java index 1818208299..ddb3b62112 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartAxis.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartAxis.java @@ -9,19 +9,20 @@ /** * @author Daniel Spiewak */ -public interface IChartAxis extends Serializable { +public interface IChartAxis extends Serializable +{ - public ChartAxisType getType(); + public ChartAxisType getType(); - public String[] getLabels(); + public String[] getLabels(); - public double[] getPositions(); + public double[] getPositions(); - public Range getRange(); + public Range getRange(); - public Color getColor(); + public Color getColor(); - public int getFontSize(); + public int getFontSize(); - public AxisAlignment getAlignment(); + public AxisAlignment getAlignment(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartData.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartData.java index c9199ef3dc..37762dde7f 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartData.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartData.java @@ -8,11 +8,12 @@ /** * @author Daniel Spiewak */ -public interface IChartData extends Serializable { +public interface IChartData extends Serializable +{ - public ChartDataEncoding getEncoding(); + public ChartDataEncoding getEncoding(); - public double[][] getData(); + public double[][] getData(); - public double getMax(); + public double getMax(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartFill.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartFill.java index f48cfb4e48..074d88f46e 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartFill.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartFill.java @@ -8,5 +8,6 @@ /** * @author Daniel Spiewak */ -public interface IChartFill extends Serializable { +public interface IChartFill extends Serializable +{ } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartGrid.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartGrid.java index 62902249dd..6151672da9 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartGrid.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartGrid.java @@ -8,13 +8,14 @@ /** * @author Daniel Spiewak */ -public interface IChartGrid extends Serializable { +public interface IChartGrid extends Serializable +{ - public double getXStepSize(); + public double getXStepSize(); - public double getYStepSize(); + public double getYStepSize(); - public int getSegmentLength(); + public int getSegmentLength(); - public int getBlankLength(); + public int getBlankLength(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartProvider.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartProvider.java index e203a3e0d5..2b23dc626d 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartProvider.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IChartProvider.java @@ -10,39 +10,40 @@ /** * @author Daniel Spiewak */ -public interface IChartProvider extends Serializable { +public interface IChartProvider extends Serializable +{ - public Dimension getSize(); + public Dimension getSize(); - public IChartData getData(); + public IChartData getData(); - public ChartType getType(); + public ChartType getType(); - public int getBarWidth(); + public int getBarWidth(); - public int getBarGroupSpacing(); + public int getBarGroupSpacing(); - public String getTitle(); + public String getTitle(); - public String[] getLegend(); + public String[] getLegend(); - public Color[] getColors(); + public Color[] getColors(); - public IChartFill getChartFill(); + public IChartFill getChartFill(); - public IChartFill getBackgroundFill(); + public IChartFill getBackgroundFill(); - public String[] getPieLabels(); + public String[] getPieLabels(); - public IChartAxis[] getAxes(); + public IChartAxis[] getAxes(); - public ILineStyle[] getLineStyles(); + public ILineStyle[] getLineStyles(); - public IChartGrid getGrid(); + public IChartGrid getGrid(); - public IShapeMarker[] getShapeMarkers(); + public IShapeMarker[] getShapeMarkers(); - public IRangeMarker[] getRangeMarkers(); + public IRangeMarker[] getRangeMarkers(); - public IFillArea[] getFillAreas(); + public IFillArea[] getFillAreas(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IFillArea.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IFillArea.java index 594ecfc843..b508bd3c22 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IFillArea.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IFillArea.java @@ -9,14 +9,15 @@ /** * @author Daniel Spiewak */ -public interface IFillArea extends Serializable { +public interface IFillArea extends Serializable +{ - public AreaFillType getType(); + public AreaFillType getType(); - public Color getColor(); + public Color getColor(); - public int getStartIndex(); + public int getStartIndex(); - // unnecessary if BOTTOM - public int getEndIndex(); + // unnecessary if BOTTOM + public int getEndIndex(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILineStyle.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILineStyle.java index ea46d7c6c0..ef3feb2bf0 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILineStyle.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILineStyle.java @@ -8,11 +8,12 @@ /** * @author Daniel Spiewak */ -public interface ILineStyle extends Serializable { +public interface ILineStyle extends Serializable +{ - public int getThickness(); + public int getThickness(); - public int getSegmentLength(); + public int getSegmentLength(); - public int getBlankLength(); + public int getBlankLength(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearGradientFill.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearGradientFill.java index 7be75b4013..7d11d7db70 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearGradientFill.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearGradientFill.java @@ -8,11 +8,12 @@ /** * @author Daniel Spiewak */ -public interface ILinearGradientFill extends IChartFill { +public interface ILinearGradientFill extends IChartFill +{ - public int getAngle(); + public int getAngle(); - public Color[] getColors(); + public Color[] getColors(); - public double[] getOffsets(); + public double[] getOffsets(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearStripesFill.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearStripesFill.java index 5a3241d587..8184a1cfae 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearStripesFill.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ILinearStripesFill.java @@ -8,11 +8,12 @@ /** * @author Daniel Spiewak */ -public interface ILinearStripesFill extends IChartFill { +public interface ILinearStripesFill extends IChartFill +{ - public int getAngle(); + public int getAngle(); - public Color[] getColors(); + public Color[] getColors(); - public double[] getWidths(); + public double[] getWidths(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IRangeMarker.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IRangeMarker.java index 6357709c77..15080ca5a9 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IRangeMarker.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IRangeMarker.java @@ -9,13 +9,14 @@ /** * @author Daniel Spiewak */ -public interface IRangeMarker extends Serializable { +public interface IRangeMarker extends Serializable +{ - public RangeType getType(); + public RangeType getType(); - public Color getColor(); + public Color getColor(); - public double getStart(); + public double getStart(); - public double getEnd(); + public double getEnd(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IShapeMarker.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IShapeMarker.java index 4892bb7c1f..21a2590046 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IShapeMarker.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/IShapeMarker.java @@ -9,15 +9,16 @@ /** * @author Daniel Spiewak */ -public interface IShapeMarker extends Serializable { +public interface IShapeMarker extends Serializable +{ - public MarkerType getType(); + public MarkerType getType(); - public Color getColor(); + public Color getColor(); - public int getIndex(); + public int getIndex(); - public double getPoint(); + public double getPoint(); - public int getSize(); + public int getSize(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ISolidFill.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ISolidFill.java index 7c14a61028..2aaa7241cc 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ISolidFill.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ISolidFill.java @@ -8,7 +8,8 @@ /** * @author Daniel Spiewak */ -public interface ISolidFill extends IChartFill { +public interface ISolidFill extends IChartFill +{ - public Color getColor(); + public Color getColor(); } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LineStyle.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LineStyle.java index 777a6f22d0..cc38cf47c2 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LineStyle.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LineStyle.java @@ -6,40 +6,48 @@ /** * @author Daniel Spiewak */ -public class LineStyle implements ILineStyle { - - private static final long serialVersionUID = -1280622316647035330L; - private int blankLength = -1; - private int segmentLength = -1; - private int thickness = -1; - - public LineStyle(int thickness, int segmentLength, int blankLength) { - this.thickness = thickness; - this.segmentLength = segmentLength; - this.blankLength = blankLength; - } - - public int getBlankLength() { - return blankLength; - } - - public int getSegmentLength() { - return segmentLength; - } - - public int getThickness() { - return thickness; - } - - public void setBlankLength(int blankLength) { - this.blankLength = blankLength; - } - - public void setSegmentLength(int segmentLength) { - this.segmentLength = segmentLength; - } - - public void setThickness(int thickness) { - this.thickness = thickness; - } +public class LineStyle implements ILineStyle +{ + + private static final long serialVersionUID = -1280622316647035330L; + private int blankLength = -1; + private int segmentLength = -1; + private int thickness = -1; + + public LineStyle(int thickness, int segmentLength, int blankLength) + { + this.thickness = thickness; + this.segmentLength = segmentLength; + this.blankLength = blankLength; + } + + public int getBlankLength() + { + return blankLength; + } + + public int getSegmentLength() + { + return segmentLength; + } + + public int getThickness() + { + return thickness; + } + + public void setBlankLength(int blankLength) + { + this.blankLength = blankLength; + } + + public void setSegmentLength(int segmentLength) + { + this.segmentLength = segmentLength; + } + + public void setThickness(int thickness) + { + this.thickness = thickness; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearGradientFill.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearGradientFill.java index 9f9306bff3..c5b622caf7 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearGradientFill.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearGradientFill.java @@ -8,44 +8,53 @@ /** * @author Daniel Spiewak */ -public class LinearGradientFill implements ILinearGradientFill { - - private static final long serialVersionUID = -859208642003059004L; - private int angle = -1; - private Color[] colors; - private double[] offsets; - - public LinearGradientFill(int angle, Color[] colors, double[] offsets) { - if (colors.length != offsets.length) { - throw new IllegalArgumentException("Must be same number of colors as offsets"); - } - - this.angle = angle; - this.colors = colors; - this.offsets = offsets; - } - - public int getAngle() { - return angle; - } - - public Color[] getColors() { - return colors; - } - - public double[] getOffsets() { - return offsets; - } - - public void setAngle(int angle) { - this.angle = angle; - } - - public void setColors(Color[] colors) { - this.colors = colors; - } - - public void setOffsets(double[] offsets) { - this.offsets = offsets; - } +public class LinearGradientFill implements ILinearGradientFill +{ + + private static final long serialVersionUID = -859208642003059004L; + private int angle = -1; + private Color[] colors; + private double[] offsets; + + public LinearGradientFill(int angle, Color[] colors, double[] offsets) + { + if (colors.length != offsets.length) + { + throw new IllegalArgumentException("Must be same number of colors as offsets"); + } + + this.angle = angle; + this.colors = colors; + this.offsets = offsets; + } + + public int getAngle() + { + return angle; + } + + public Color[] getColors() + { + return colors; + } + + public double[] getOffsets() + { + return offsets; + } + + public void setAngle(int angle) + { + this.angle = angle; + } + + public void setColors(Color[] colors) + { + this.colors = colors; + } + + public void setOffsets(double[] offsets) + { + this.offsets = offsets; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearStripesFill.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearStripesFill.java index e5900cbf9e..3b23b1e725 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearStripesFill.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/LinearStripesFill.java @@ -8,44 +8,53 @@ /** * @author Daniel Spiewak */ -public class LinearStripesFill implements ILinearStripesFill { - - private static final long serialVersionUID = 4864424675217937390L; - private int angle = -1; - private Color[] colors; - private double[] widths; - - public LinearStripesFill(int angle, Color[] colors, double[] widths) { - if (colors.length != widths.length) { - throw new IllegalArgumentException("Must be same number of colors as widths"); - } - - this.angle = angle; - this.colors = colors; - this.widths = widths; - } - - public int getAngle() { - return angle; - } - - public Color[] getColors() { - return colors; - } - - public double[] getWidths() { - return widths; - } - - public void setAngle(int angle) { - this.angle = angle; - } - - public void setColors(Color[] colors) { - this.colors = colors; - } - - public void setWidths(double[] widths) { - this.widths = widths; - } +public class LinearStripesFill implements ILinearStripesFill +{ + + private static final long serialVersionUID = 4864424675217937390L; + private int angle = -1; + private Color[] colors; + private double[] widths; + + public LinearStripesFill(int angle, Color[] colors, double[] widths) + { + if (colors.length != widths.length) + { + throw new IllegalArgumentException("Must be same number of colors as widths"); + } + + this.angle = angle; + this.colors = colors; + this.widths = widths; + } + + public int getAngle() + { + return angle; + } + + public Color[] getColors() + { + return colors; + } + + public double[] getWidths() + { + return widths; + } + + public void setAngle(int angle) + { + this.angle = angle; + } + + public void setColors(Color[] colors) + { + this.colors = colors; + } + + public void setWidths(double[] widths) + { + this.widths = widths; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/MarkerType.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/MarkerType.java index 8d2ceebe7f..41c34a6bc3 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/MarkerType.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/MarkerType.java @@ -6,24 +6,20 @@ /** * @author Daniel Spiewak */ -public enum MarkerType { +public enum MarkerType +{ - ARROW("a"), - CROSS("c"), - DIAMOND("d"), - CIRCLE("o"), - SQUARE("s"), - VERTICAL_TO_DATA("v"), - VERTICAL_TO_TOP("V"), - HORIZONTAL_ACROSS("h"), - X("x"); - private final String rendering; + ARROW("a"), CROSS("c"), DIAMOND("d"), CIRCLE("o"), SQUARE("s"), VERTICAL_TO_DATA("v"), VERTICAL_TO_TOP( + "V"), HORIZONTAL_ACROSS("h"), X("x"); + private final String rendering; - private MarkerType(String rendering) { - this.rendering = rendering; - } + private MarkerType(String rendering) + { + this.rendering = rendering; + } - public String getRendering() { - return rendering; - } + public String getRendering() + { + return rendering; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Range.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Range.java index f935c9bbc9..8431a98064 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Range.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/Range.java @@ -8,29 +8,35 @@ /** * @author Daniel Spiewak */ -public class Range implements Serializable { - - private static final long serialVersionUID = 5280524789527071838L; - private double start, end; - - public Range(double start, double end) { - this.start = start; - this.end = end; - } - - public double getStart() { - return start; - } - - public void setStart(double start) { - this.start = start; - } - - public double getEnd() { - return end; - } - - public void setEnd(double end) { - this.end = end; - } +public class Range implements Serializable +{ + + private static final long serialVersionUID = 5280524789527071838L; + private double start, end; + + public Range(double start, double end) + { + this.start = start; + this.end = end; + } + + public double getStart() + { + return start; + } + + public void setStart(double start) + { + this.start = start; + } + + public double getEnd() + { + return end; + } + + public void setEnd(double end) + { + this.end = end; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeMarker.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeMarker.java index 10515f51f3..67a6a9a87b 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeMarker.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeMarker.java @@ -8,50 +8,60 @@ /** * @author Daniel Spiewak */ -public class RangeMarker implements IRangeMarker { - - private static final long serialVersionUID = 885106818212539922L; - private Color color; - private double end = -1; - private double start = -1; - private RangeType type; - - public RangeMarker(RangeType type, Color color, double start, double end) { - this.type = type; - this.color = color; - this.start = start; - this.end = end; - } - - public Color getColor() { - return color; - } - - public double getEnd() { - return end; - } - - public double getStart() { - return start; - } - - public RangeType getType() { - return type; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setEnd(double end) { - this.end = end; - } - - public void setStart(double start) { - this.start = start; - } - - public void setType(RangeType type) { - this.type = type; - } +public class RangeMarker implements IRangeMarker +{ + + private static final long serialVersionUID = 885106818212539922L; + private Color color; + private double end = -1; + private double start = -1; + private RangeType type; + + public RangeMarker(RangeType type, Color color, double start, double end) + { + this.type = type; + this.color = color; + this.start = start; + this.end = end; + } + + public Color getColor() + { + return color; + } + + public double getEnd() + { + return end; + } + + public double getStart() + { + return start; + } + + public RangeType getType() + { + return type; + } + + public void setColor(Color color) + { + this.color = color; + } + + public void setEnd(double end) + { + this.end = end; + } + + public void setStart(double start) + { + this.start = start; + } + + public void setType(RangeType type) + { + this.type = type; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeType.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeType.java index 250d6a2315..ed70571845 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeType.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/RangeType.java @@ -6,17 +6,19 @@ /** * @author Daniel Spiewak */ -public enum RangeType { +public enum RangeType +{ - HORIZONTAL("r"), - VERTICAL("R"); - private final String rendering; + HORIZONTAL("r"), VERTICAL("R"); + private final String rendering; - private RangeType(String rendering) { - this.rendering = rendering; - } + private RangeType(String rendering) + { + this.rendering = rendering; + } - public String getRendering() { - return rendering; - } + public String getRendering() + { + return rendering; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ShapeMarker.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ShapeMarker.java index 00f1895342..6eb579ae9f 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ShapeMarker.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/ShapeMarker.java @@ -8,60 +8,72 @@ /** * @author Daniel Spiewak */ -public class ShapeMarker implements IShapeMarker { +public class ShapeMarker implements IShapeMarker +{ - private static final long serialVersionUID = 1460707384284308604L; - private Color color; - private int index = -1; - private double point = -1; - private int size = -1; - private MarkerType type; + private static final long serialVersionUID = 1460707384284308604L; + private Color color; + private int index = -1; + private double point = -1; + private int size = -1; + private MarkerType type; - public ShapeMarker(MarkerType type, Color color, int index, double point, int size) { - this.type = type; - this.color = color; - this.index = index; - this.point = point; - this.size = size; - } + public ShapeMarker(MarkerType type, Color color, int index, double point, int size) + { + this.type = type; + this.color = color; + this.index = index; + this.point = point; + this.size = size; + } - public Color getColor() { - return color; - } + public Color getColor() + { + return color; + } - public int getIndex() { - return index; - } + public int getIndex() + { + return index; + } - public double getPoint() { - return point; - } + public double getPoint() + { + return point; + } - public int getSize() { - return size; - } + public int getSize() + { + return size; + } - public MarkerType getType() { - return type; - } + public MarkerType getType() + { + return type; + } - public void setColor(Color color) { - this.color = color; - } + public void setColor(Color color) + { + this.color = color; + } - public void setIndex(int index) { - this.index = index; - } + public void setIndex(int index) + { + this.index = index; + } - public void setPoint(double point) { - this.point = point; - } + public void setPoint(double point) + { + this.point = point; + } - public void setSize(int size) { - this.size = size; - } + public void setSize(int size) + { + this.size = size; + } - public void setType(MarkerType type) { - this.type = type; - } + public void setType(MarkerType type) + { + this.type = type; + } } diff --git a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/SolidFill.java b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/SolidFill.java index 04f0e848b1..7cb3550ff8 100644 --- a/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/SolidFill.java +++ b/jdk-1.5-parent/googlecharts-parent/googlecharts/src/main/java/org/wicketstuff/googlecharts/SolidFill.java @@ -8,20 +8,24 @@ /** * @author Daniel Spiewak */ -public class SolidFill implements ISolidFill { +public class SolidFill implements ISolidFill +{ - private static final long serialVersionUID = -8021753397593009779L; - private Color color; + private static final long serialVersionUID = -8021753397593009779L; + private Color color; - public SolidFill(Color color) { - this.color = color; - } + public SolidFill(Color color) + { + this.color = color; + } - public Color getColor() { - return color; - } + public Color getColor() + { + return color; + } - public void setColor(Color color) { - this.color = color; - } + public void setColor(Color color) + { + this.color = color; + } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/Session.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/Session.java index dc442ecc42..e9631bd769 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/Session.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/Session.java @@ -9,36 +9,42 @@ import com.inmethod.grid.examples.contact.ContactsDatabase; /** - * Wicket {@link org.apache.wicket.Session} subclass that keeps a {@link ContactsDatabase}. This is necessary - * so that when user edits a {@link Contact} the change is isolated from other users. + * Wicket {@link org.apache.wicket.Session} subclass that keeps a {@link ContactsDatabase}. This is + * necessary so that when user edits a {@link Contact} the change is isolated from other users. * * @author Matej Knopp * */ -public class Session extends WebSession { +public class Session extends WebSession +{ private static final long serialVersionUID = 1L; /** * Constructor. + * * @param request */ - public Session(Request request) { + public Session(Request request) + { super(request); } /** * Returns the {@link ContactsDatabase}. + * * @return {@link ContactsDatabase} instance. */ - public ContactsDatabase getDatabase() { + public ContactsDatabase getDatabase() + { return database; } private ContactsDatabase database = new ContactsDatabase(330); - + @Override - public Locale getLocale() { + public Locale getLocale() + { return Locale.ENGLISH; } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/WicketApplication.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/WicketApplication.java index 921562a06e..5f392b73e0 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/WicketApplication.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/WicketApplication.java @@ -24,16 +24,17 @@ * */ public class WicketApplication extends WebApplication -{ - /** - * Constructor - */ +{ + /** + * Constructor + */ public WicketApplication() { } - + @Override - protected void init() { + protected void init() + { mount("/data-grid/simple", SimpleDataGridPage.class); mount("/data-grid/vertical-scrolling", VerticalScrollingDataGridPage.class); mount("/data-grid/item-selection", DataGridSelectionPage.class); @@ -41,26 +42,28 @@ protected void init() { mount("/data-grid/editable", EditableDataGridPage.class); mount("/data-grid/editable-selection", EditableDataGridWithSelectionPage.class); mount("/data-grid/unknown-count", DataGridWithUnknownItemCount.class); - + mount("/tree-grid/simple", SimpleTreeGridPage.class); mount("/tree-grid/vertical-scrolling", VerticalScrollingTreeGridPage.class); mount("/tree-grid/item-selection", TreeGridSelectionPage.class); mount("/tree-grid/column-properties", TreeGridColumnPropertiesPage.class); - mount("/tree-grid/editable", EditableTreeGridPage.class); + mount("/tree-grid/editable", EditableTreeGridPage.class); } - - private void mount(String mountPath, Class pageClass) { + + private void mount(String mountPath, Class pageClass) + { getRootRequestMapperAsCompound().add(new MountedMapper(mountPath, pageClass)); } - + /** * {@inheritDoc} */ @Override - public Session newSession(Request request, Response response) { + public Session newSession(Request request, Response response) + { return new Session(request); } - + /** * {@inheritDoc} */ @@ -69,5 +72,5 @@ public Class getHomePage() { return SimpleDataGridPage.class; } - + } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileEntry.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileEntry.java index 2c464785c6..3b4bf8cd54 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileEntry.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileEntry.java @@ -11,66 +11,85 @@ /** * Simple wrapper for java.io.File */ -public class FileEntry implements Serializable { - +public class FileEntry implements Serializable +{ + private static final long serialVersionUID = 1L; - public FileEntry(File file) { + public FileEntry(File file) + { this.file = file; } - public boolean isFolder() { + public boolean isFolder() + { return file.isDirectory(); } - - public String getSizeAsString() { - if (file.isDirectory()) { + + public String getSizeAsString() + { + if (file.isDirectory()) + { return ""; - } else { + } + else + { return "" + file.length(); } }; - - public long getSize() { + + public long getSize() + { if (file.isDirectory() == true) return 0L; else - return file.length(); + return file.length(); } - - public Date lastModified() { - return new Date(file.lastModified()); + + public Date lastModified() + { + return new Date(file.lastModified()); } - - public String getAbsolutePath() { - return file.getAbsolutePath(); + + public String getAbsolutePath() + { + return file.getAbsolutePath(); } - - public boolean canRead() { + + public boolean canRead() + { return file.canRead(); } - - public boolean canWrite() { + + public boolean canWrite() + { return file.canWrite(); } - - public boolean canExecute() { + + public boolean canExecute() + { return false; } - - public List getChildren() { + + public List getChildren() + { List result = new ArrayList(); File files[] = file.listFiles(); - if (files != null) { - for (File file : files) { + if (files != null) + { + for (File file : files) + { if (file.isHidden() == false) result.add(new FileEntry(file)); } } // sort the children - Collections.sort(result, new Comparator() { - public int compare(FileEntry o1, FileEntry o2) { - if (o1.isFolder() != o2.isFolder()) { + Collections.sort(result, new Comparator() + { + public int compare(FileEntry o1, FileEntry o2) + { + if (o1.isFolder() != o2.isFolder()) + { return -((Boolean)o1.isFolder()).compareTo(o2.isFolder()); } return o1.getName().compareToIgnoreCase(o2.getName()); @@ -78,10 +97,11 @@ public int compare(FileEntry o1, FileEntry o2) { }); return result; } - - public String getName() { + + public String getName() + { return file.getName(); } - + private File file; } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeModel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeModel.java index 363f5ae628..0f6f119ec9 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeModel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeModel.java @@ -8,45 +8,55 @@ import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -public class FileTreeModel implements TreeModel, Serializable { +public class FileTreeModel implements TreeModel, Serializable +{ private static final long serialVersionUID = 1L; - public Object getChild(Object parent, int index) { + public Object getChild(Object parent, int index) + { return ((TreeNode)parent).getChildAt(index); } - public int getChildCount(Object parent) { + public int getChildCount(Object parent) + { return ((TreeNode)parent).getChildCount(); } - public int getIndexOfChild(Object parent, Object child) { - if(parent == null || child == null) - return -1; - return ((TreeNode)parent).getIndex((TreeNode)child); + public int getIndexOfChild(Object parent, Object child) + { + if (parent == null || child == null) + return -1; + return ((TreeNode)parent).getIndex((TreeNode)child); } private FileTreeNode root; - - public FileTreeModel(String rootFolder) { + + public FileTreeModel(String rootFolder) + { root = new FileTreeNode(new FileEntry(new File(rootFolder)), null); } - - public Object getRoot() { + + public Object getRoot() + { return root; } - public boolean isLeaf(Object node) { + public boolean isLeaf(Object node) + { return ((TreeNode)node).isLeaf(); } - public void valueForPathChanged(TreePath path, Object newValue) { + public void valueForPathChanged(TreePath path, Object newValue) + { } - public void addTreeModelListener(TreeModelListener l) { + public void addTreeModelListener(TreeModelListener l) + { } - public void removeTreeModelListener(TreeModelListener l) { + public void removeTreeModelListener(TreeModelListener l) + { } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeNode.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeNode.java index 3391b143ee..bd0c852be9 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeNode.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/browser/model/FileTreeNode.java @@ -8,73 +8,90 @@ import javax.swing.tree.TreeNode; -public class FileTreeNode implements TreeNode, Serializable { +public class FileTreeNode implements TreeNode, Serializable +{ private static final long serialVersionUID = 1L; - + private FileEntry fileEntry; private List children = null; private FileTreeNode parent; - - FileTreeNode(FileEntry fileEntry, FileTreeNode parent) { + + FileTreeNode(FileEntry fileEntry, FileTreeNode parent) + { this.fileEntry = fileEntry; this.parent = parent; } - - public FileEntry getFileEntry() { + + public FileEntry getFileEntry() + { return fileEntry; } - - private void ensureChildrenLoaded() { - if (children == null) { + + private void ensureChildrenLoaded() + { + if (children == null) + { children = new ArrayList(); - + List entries = fileEntry.getChildren(); - for (FileEntry entry : entries) { + for (FileEntry entry : entries) + { FileTreeNode node = new FileTreeNode(entry, this); children.add(node); } } } - - public Enumeration children() { + + public Enumeration children() + { ensureChildrenLoaded(); - return new Enumeration() { + return new Enumeration() + { Iterator i = children.iterator(); - - public boolean hasMoreElements() { + + public boolean hasMoreElements() + { return i.hasNext(); } - public FileTreeNode nextElement() { + + public FileTreeNode nextElement() + { return i.next(); } }; } - public boolean getAllowsChildren() { + public boolean getAllowsChildren() + { return fileEntry.isFolder(); } - public TreeNode getChildAt(int childIndex) { + public TreeNode getChildAt(int childIndex) + { ensureChildrenLoaded(); - return children.get(childIndex); + return children.get(childIndex); } - public int getChildCount() { + public int getChildCount() + { ensureChildrenLoaded(); return children.size(); } - public int getIndex(TreeNode node) { + public int getIndex(TreeNode node) + { ensureChildrenLoaded(); return children.indexOf(node); } - public TreeNode getParent() { + public TreeNode getParent() + { return parent; } - public boolean isLeaf() { + public boolean isLeaf() + { return fileEntry.isFolder() == false; } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/Contact.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/Contact.java index 06c6183d0a..7031ff7c63 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/Contact.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/Contact.java @@ -53,7 +53,7 @@ public Contact() public String toString() { return "[Contact id=" + id + " firstName=" + firstName + " lastName=" + lastName + - " homePhone=" + homePhone + " cellPhone=" + cellPhone + "]"; + " homePhone=" + homePhone + " cellPhone=" + cellPhone + "]"; } @@ -75,9 +75,9 @@ public boolean equals(Object obj) { Contact other = (Contact)obj; return other.getFirstName().equals(getFirstName()) && - other.getLastName().equals(getLastName()) && - other.getHomePhone().equals(getHomePhone()) && - other.getCellPhone().equals(getCellPhone()); + other.getLastName().equals(getLastName()) && + other.getHomePhone().equals(getHomePhone()) && + other.getCellPhone().equals(getCellPhone()); } else diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactGenerator.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactGenerator.java index 17bc42154c..efc462c051 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactGenerator.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactGenerator.java @@ -91,9 +91,15 @@ public void generate(Collection collection, int count) private String generatePhoneNumber() { - return new StringBuffer().append(rint(2, 9)).append(rint(0, 9)).append(rint(0, 9)).append( - "-555-").append(rint(1, 9)).append(rint(0, 9)).append(rint(0, 9)) - .append(rint(0, 9)).toString(); + return new StringBuffer().append(rint(2, 9)) + .append(rint(0, 9)) + .append(rint(0, 9)) + .append("-555-") + .append(rint(1, 9)) + .append(rint(0, 9)) + .append(rint(0, 9)) + .append(rint(0, 9)) + .toString(); } private int rint(int min, int max) diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactsDatabase.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactsDatabase.java index 1513a6d343..7882663d81 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactsDatabase.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/ContactsDatabase.java @@ -113,7 +113,7 @@ else if (prop.equals("lastName")) return (asc) ? lnameIdx : lnameDescIdx; } throw new RuntimeException("uknown sort option [" + prop + - "]. valid options: [firstName] , [lastName]"); + "]. valid options: [firstName] , [lastName]"); } /** @@ -140,7 +140,7 @@ public void save(final Contact contact) else { throw new IllegalArgumentException("contact [" + contact.getFirstName() + - "] is already persistent"); + "] is already persistent"); } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DatabaseLocator.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DatabaseLocator.java index da08ca54c7..8899fdb020 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DatabaseLocator.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DatabaseLocator.java @@ -35,5 +35,5 @@ public class DatabaseLocator public static ContactsDatabase getDatabase() { return ((Session)WebSession.get()).getDatabase(); - } + } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DetachableContactModel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DetachableContactModel.java index 0b2d284b93..bb3bdf7629 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DetachableContactModel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/contact/DetachableContactModel.java @@ -27,7 +27,7 @@ public class DetachableContactModel extends LoadableDetachableModel { private static final long serialVersionUID = 1L; - + private long id; protected ContactsDatabase getContactsDB() @@ -84,7 +84,7 @@ else if (obj == null) else if (obj instanceof DetachableContactModel) { DetachableContactModel other = (DetachableContactModel)obj; - return other.id == this.id; + return other.id == id; } return false; } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/BaseExamplePage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/BaseExamplePage.java index ffbbcde805..b4e8326b36 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/BaseExamplePage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/BaseExamplePage.java @@ -7,15 +7,17 @@ * * @author Matej Knopp */ -public class BaseExamplePage extends WebPage { +public class BaseExamplePage extends WebPage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public BaseExamplePage() { - + public BaseExamplePage() + { + } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSource.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSource.java index e0aa963cb4..951f691936 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSource.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSource.java @@ -17,56 +17,63 @@ * * @author Matej Knopp */ -public class ContactDataSource implements IDataSource { +public class ContactDataSource implements IDataSource +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public ContactDataSource() { - + public ContactDataSource() + { + } /** * {@inheritDoc} - */ - public IModel model(Object object) { + */ + public IModel model(Object object) + { return new DetachableContactModel((Contact)object); } /** * {@inheritDoc} */ - public void query(IQuery query, IQueryResult result) { + public void query(IQuery query, IQueryResult result) + { ContactsDatabase database = DatabaseLocator.getDatabase(); - + String sortProperty = null; boolean sortAsc = true; - + // is there any sorting - if (query.getSortState().getColumns().size() > 0) { - // get the most relevant column + if (query.getSortState().getColumns().size() > 0) + { + // get the most relevant column ISortStateColumn state = query.getSortState().getColumns().get(0); - + // get the column sort properties sortProperty = state.getPropertyName(); sortAsc = state.getDirection() == IGridSortState.Direction.ASC; } - + // determine the total count result.setTotalCount(database.getCount()); - + // get the actual items - List resultList = database.find(query.getFrom(), query.getCount(), sortProperty, sortAsc); + List resultList = database.find(query.getFrom(), query.getCount(), sortProperty, + sortAsc); result.setItems(resultList.iterator()); - + } /** * {@inheritDoc} */ - public void detach() { + public void detach() + { } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSourceWithUnknownItemCount.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSourceWithUnknownItemCount.java index 8d131a96b8..8bab3a2657 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSourceWithUnknownItemCount.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/ContactDataSourceWithUnknownItemCount.java @@ -13,68 +13,78 @@ import com.inmethod.grid.examples.contact.DetachableContactModel; /** - * Simple DataSource that load contacts without knowing the actual item count. + * Simple DataSource that load contacts without knowing the actual item count. * * @author Matej Knopp */ -public class ContactDataSourceWithUnknownItemCount implements IDataSource { +public class ContactDataSourceWithUnknownItemCount implements IDataSource +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public ContactDataSourceWithUnknownItemCount() { - + public ContactDataSourceWithUnknownItemCount() + { + } /** * {@inheritDoc} */ - public IModel model(Object object) { + public IModel model(Object object) + { return new DetachableContactModel((Contact)object); } /** * {@inheritDoc} */ - public void query(IQuery query, IQueryResult result) { + public void query(IQuery query, IQueryResult result) + { ContactsDatabase database = DatabaseLocator.getDatabase(); - + String sortProperty = null; boolean sortAsc = true; - + // is there any sorting - if (query.getSortState().getColumns().size() > 0) { - // get the most relevant column + if (query.getSortState().getColumns().size() > 0) + { + // get the most relevant column ISortStateColumn state = query.getSortState().getColumns().get(0); - + // get the column sort properties sortProperty = state.getPropertyName(); sortAsc = state.getDirection() == IGridSortState.Direction.ASC; } - + // since we don't know the actual item count we try to load one item more than requested // if there are n+1 items we know there will be something on the next page - + // get the actual items - List resultList = database.find(query.getFrom(), query.getCount() + 1, sortProperty, sortAsc); + List resultList = database.find(query.getFrom(), query.getCount() + 1, + sortProperty, sortAsc); result.setItems(resultList.iterator()); - - if (resultList.size() == query.getCount() + 1) { + + if (resultList.size() == query.getCount() + 1) + { // if we managed to load n + 1 items (thus there will be another page) result.setTotalCount(IQueryResult.MORE_ITEMS); - } else { + } + else + { // no more items - this is the latest page result.setTotalCount(IQueryResult.NO_MORE_ITEMS); } - + } /** * {@inheritDoc} */ - public void detach() { + public void detach() + { } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridColumnPropertiesPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridColumnPropertiesPage.java index e328a3525e..23a69d2fb4 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridColumnPropertiesPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridColumnPropertiesPage.java @@ -19,65 +19,61 @@ * * @author Matej Knopp */ -public class DataGridColumnPropertiesPage extends BaseExamplePage { +public class DataGridColumnPropertiesPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public DataGridColumnPropertiesPage() { + public DataGridColumnPropertiesPage() + { List columns = new ArrayList(); - - columns.add( - new PropertyColumn(new ResourceModel("id"), "id") - .setInitialSize(3) - .setSizeUnit(SizeUnit.EM) - .setResizable(false) - .setReorderable(false) - .setHeaderTooltipModel(new Model("Person Id")) - ); - - columns.add( - new PropertyColumn(new ResourceModel("firstName"), "firstName", "firstName") - .setReorderable(false) - .setInitialSize(200) - .setMinSize(100) - .setMaxSize(250) - .setHeaderTooltipModel(new Model("Person First Name")) - ); - - columns.add(new PropertyColumn(new ResourceModel("lastName"), "lastName", "lastName") { + + columns.add(new PropertyColumn(new ResourceModel("id"), "id").setInitialSize(3) + .setSizeUnit(SizeUnit.EM) + .setResizable(false) + .setReorderable(false) + .setHeaderTooltipModel(new Model("Person Id"))); + + columns.add(new PropertyColumn(new ResourceModel("firstName"), "firstName", "firstName").setReorderable( + false) + .setInitialSize(200) + .setMinSize(100) + .setMaxSize(250) + .setHeaderTooltipModel(new Model("Person First Name"))); + + columns.add(new PropertyColumn(new ResourceModel("lastName"), "lastName", "lastName") + { private static final long serialVersionUID = 1L; + @Override - public String getCellCssClass(IModel rowModel, int rowNum) { + public String getCellCssClass(IModel rowModel, int rowNum) + { return "lastName"; } }); - - columns.add( - new PropertyColumn(new ResourceModel("homePhone"), "homePhone") { - private static final long serialVersionUID = 1L; - @Override - public String getCellCssClass(IModel rowModel, int rowNum) { - return "homePhone"; - } + + columns.add(new PropertyColumn(new ResourceModel("homePhone"), "homePhone") + { + private static final long serialVersionUID = 1L; + + @Override + public String getCellCssClass(IModel rowModel, int rowNum) + { + return "homePhone"; } - .setInitialSize(10) + }.setInitialSize(10).setSizeUnit(SizeUnit.EM).setResizable(false)); + + columns.add(new PropertyColumn(new ResourceModel("cellPhone"), "cellPhone").setInitialSize( + 10) .setSizeUnit(SizeUnit.EM) - .setResizable(false) - ); - - columns.add( - new PropertyColumn(new ResourceModel("cellPhone"), "cellPhone") - .setInitialSize(10) - .setSizeUnit(SizeUnit.EM) - .setResizable(false) - ); - + .setResizable(false)); + DataGrid grid = new DefaultDataGrid("grid", new ContactDataSource(), columns); add(grid); - + grid.setRowsPerPage(15); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridSelectionPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridSelectionPage.java index 01a76bf032..13d8c39911 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridSelectionPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridSelectionPage.java @@ -26,7 +26,8 @@ * * @author Matej Knopp */ -public class DataGridSelectionPage extends BaseExamplePage { +public class DataGridSelectionPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; @@ -35,7 +36,8 @@ public class DataGridSelectionPage extends BaseExamplePage { /** * Constructor. */ - public DataGridSelectionPage() { + public DataGridSelectionPage() + { List columns = new ArrayList(); columns.add(new CheckBoxColumn("checkBox")); @@ -45,12 +47,14 @@ public DataGridSelectionPage() { columns.add(new PropertyColumn(new ResourceModel("homePhone"), "homePhone")); columns.add(new PropertyColumn(new ResourceModel("cellPhone"), "cellPhone")); - final DataGrid grid = new DefaultDataGrid("grid", new ContactDataSource(), columns) { + final DataGrid grid = new DefaultDataGrid("grid", new ContactDataSource(), columns) + { private static final long serialVersionUID = 1L; @Override - public void onItemSelectionChanged(IModel item, boolean newValue) { + public void onItemSelectionChanged(IModel item, boolean newValue) + { super.onItemSelectionChanged(item, newValue); // when item selection changes the label showing selected items needs to be @@ -66,11 +70,13 @@ public void onItemSelectionChanged(IModel item, boolean newValue) { grid.setRowsPerPage(15); // model for label that shows selected items - IModel selectedItemsModel = new Model() { + IModel selectedItemsModel = new Model() + { private static final long serialVersionUID = 1L; @Override - public Serializable getObject() { + public Serializable getObject() + { return selectedItemsAsString(grid); } }; @@ -80,12 +86,15 @@ public Serializable getObject() { addOptionLinks(grid); } - private String selectedItemsAsString(AbstractGrid grid) { + private String selectedItemsAsString(AbstractGrid grid) + { StringBuilder res = new StringBuilder(); Collection selected = grid.getSelectedItems(); - for (IModel model : selected) { - Contact contact = (Contact) model.getObject(); - if (res.length() > 0) { + for (IModel model : selected) + { + Contact contact = (Contact)model.getObject(); + if (res.length() > 0) + { res.append(", "); } res.append(contact.getFirstName()); @@ -95,64 +104,77 @@ private String selectedItemsAsString(AbstractGrid grid) { return res.toString(); } - private void addOptionLinks(final DataGrid grid) { + private void addOptionLinks(final DataGrid grid) + { - add(new Link("cleanSelectionOnPageChangeOn") { + add(new Link("cleanSelectionOnPageChangeOn") + { private static final long serialVersionUID = 1L; @Override - public void onClick() { + public void onClick() + { grid.setCleanSelectionOnPageChange(true); } @Override - public boolean isEnabled() { + public boolean isEnabled() + { return !grid.isCleanSelectionOnPageChange(); } }); - add(new Link("cleanSelectionOnPageChangeOff") { + add(new Link("cleanSelectionOnPageChangeOff") + { private static final long serialVersionUID = 1L; @Override - public void onClick() { + public void onClick() + { grid.setCleanSelectionOnPageChange(false); } @Override - public boolean isEnabled() { + public boolean isEnabled() + { return grid.isCleanSelectionOnPageChange(); } }); - add(new Link("selectMultipleOn") { + add(new Link("selectMultipleOn") + { private static final long serialVersionUID = 1L; @Override - public void onClick() { + public void onClick() + { grid.setAllowSelectMultiple(true); } @Override - public boolean isEnabled() { + public boolean isEnabled() + { return !grid.isAllowSelectMultiple(); } }); - add(new Link("selectMultipleOff") { + add(new Link("selectMultipleOff") + { private static final long serialVersionUID = 1L; @Override - public void onClick() { + public void onClick() + { grid.setAllowSelectMultiple(false); } @Override - public boolean isEnabled() { + public boolean isEnabled() + { return grid.isAllowSelectMultiple(); } }); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridWithUnknownItemCount.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridWithUnknownItemCount.java index f5b48cb2ac..623c389a9c 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridWithUnknownItemCount.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/DataGridWithUnknownItemCount.java @@ -18,14 +18,16 @@ * * @author Matej Knopp */ -public class DataGridWithUnknownItemCount extends BaseExamplePage { +public class DataGridWithUnknownItemCount extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Page constructor */ - public DataGridWithUnknownItemCount() { + public DataGridWithUnknownItemCount() + { List columns = new ArrayList(); columns.add(new PropertyColumn(new ResourceModel("id"), "id")); @@ -34,7 +36,8 @@ public DataGridWithUnknownItemCount() { columns.add(new PropertyColumn(new ResourceModel("homePhone"), "homePhone")); columns.add(new PropertyColumn(new ResourceModel("cellPhone"), "cellPhone")); - DataGrid grid = new DefaultDataGrid("grid", new ContactDataSourceWithUnknownItemCount(), columns); + DataGrid grid = new DefaultDataGrid("grid", new ContactDataSourceWithUnknownItemCount(), + columns); add(grid); grid.setRowsPerPage(50); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridPage.java index 1f6ecda47d..f8e3fb690c 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridPage.java @@ -22,47 +22,55 @@ * * @author Matej Knopp */ -public class EditableDataGridPage extends BaseExamplePage { +public class EditableDataGridPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public EditableDataGridPage() { + public EditableDataGridPage() + { List columns = new ArrayList(); - + Form form = new Form("form"); add(form); - + columns.add(new PropertyColumn(new ResourceModel("id"), "id")); - columns.add(new EditablePropertyColumn(new ResourceModel("firstName"), "firstName", "firstName") { - + columns.add(new EditablePropertyColumn(new ResourceModel("firstName"), "firstName", + "firstName") + { + private static final long serialVersionUID = 1L; @Override - protected void addValidators(FormComponent component) { + protected void addValidators(FormComponent component) + { component.setRequired(true); } }); - columns.add(new EditablePropertyColumn(new ResourceModel("lastName"), "lastName", "lastName") { + columns.add(new EditablePropertyColumn(new ResourceModel("lastName"), "lastName", + "lastName") + { private static final long serialVersionUID = 1L; @Override - protected void addValidators(FormComponent component) { + protected void addValidators(FormComponent component) + { component.setRequired(true); } }); columns.add(new EditablePropertyColumn(new ResourceModel("homePhone"), "homePhone")); columns.add(new EditablePropertyColumn(new ResourceModel("cellPhone"), "cellPhone")); columns.add(new SubmitCancelColumn("esd", new Model("Edit"))); - + DataGrid grid = new DefaultDataGrid("grid", new ContactDataSource(), columns); form.add(grid); - + grid.setAllowSelectMultiple(true); - + grid.setSelectToEdit(true); grid.setClickRowToSelect(true); grid.setClickRowToDeselect(false); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridWithSelectionPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridWithSelectionPage.java index 8545f441bf..15e30d81b3 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridWithSelectionPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/EditableDataGridWithSelectionPage.java @@ -23,49 +23,57 @@ * * @author Matej Knopp */ -public class EditableDataGridWithSelectionPage extends BaseExamplePage { +public class EditableDataGridWithSelectionPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public EditableDataGridWithSelectionPage() { + public EditableDataGridWithSelectionPage() + { List columns = new ArrayList(); - + Form form = new Form("form"); add(form); - + columns.add(new CheckBoxColumn("check")); columns.add(new PropertyColumn(new ResourceModel("id"), "id")); - columns.add(new EditablePropertyColumn(new ResourceModel("firstName"), "firstName", "firstName") { - + columns.add(new EditablePropertyColumn(new ResourceModel("firstName"), "firstName", + "firstName") + { + private static final long serialVersionUID = 1L; @Override - protected void addValidators(FormComponent component) { + protected void addValidators(FormComponent component) + { component.setRequired(true); } }); - columns.add(new EditablePropertyColumn(new ResourceModel("lastName"), "lastName", "lastName") { + columns.add(new EditablePropertyColumn(new ResourceModel("lastName"), "lastName", + "lastName") + { private static final long serialVersionUID = 1L; @Override - protected void addValidators(FormComponent component) { + protected void addValidators(FormComponent component) + { component.setRequired(true); } }); columns.add(new EditablePropertyColumn(new ResourceModel("homePhone"), "homePhone")); columns.add(new EditablePropertyColumn(new ResourceModel("cellPhone"), "cellPhone")); columns.add(new SubmitCancelColumn("esd", new Model("Edit"))); - + DataGrid grid = new DefaultDataGrid("grid", new ContactDataSource(), columns); form.add(grid); - + grid.setAllowSelectMultiple(true); grid.setSelectToEdit(false); - + grid.setClickRowToSelect(true); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/SimpleDataGridPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/SimpleDataGridPage.java index 0ae5008758..bb9dc0193f 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/SimpleDataGridPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/SimpleDataGridPage.java @@ -53,7 +53,7 @@ public void onClick() try { IRequestHandler handler = new TableComponentAsXlsHandler( - grid.get("form:bodyContainer:body"), "example.xls"); + grid.get("form:bodyContainer:body"), "example.xls"); RequestCycle.get().scheduleRequestHandlerAfterCurrent(handler); } catch (Exception e) diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/VerticalScrollingDataGridPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/VerticalScrollingDataGridPage.java index 9cf1fa86ff..e3c7333d21 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/VerticalScrollingDataGridPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/datagrid/VerticalScrollingDataGridPage.java @@ -17,14 +17,16 @@ * * @author Matej Knopp */ -public class VerticalScrollingDataGridPage extends BaseExamplePage { +public class VerticalScrollingDataGridPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public VerticalScrollingDataGridPage() { + public VerticalScrollingDataGridPage() + { List columns = new ArrayList(); columns.add(new PropertyColumn(new ResourceModel("id"), "id")); @@ -35,7 +37,7 @@ public VerticalScrollingDataGridPage() { DataGrid grid = new DefaultDataGrid("grid", new ContactDataSource(), columns); add(grid); - + grid.setRowsPerPage(30); grid.setContentHeight(25, SizeUnit.EM); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/EditableTreeGridPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/EditableTreeGridPage.java index 5d3ee545f3..fbd55f5d53 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/EditableTreeGridPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/EditableTreeGridPage.java @@ -21,36 +21,38 @@ * * @author Matej Knopp */ -public class EditableTreeGridPage extends BaseExamplePage { +public class EditableTreeGridPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public EditableTreeGridPage() { + public EditableTreeGridPage() + { List columns = new ArrayList(); - + columns.add(new SubmitCancelColumn("edit", new Model("Edit"))); columns.add(new EditablePropertyTreeColumn(new Model("Property 1"), "userObject.property1")); columns.add(new EditablePropertyColumn(new Model("Property 2"), "userObject.property2")); columns.add(new EditablePropertyColumn(new Model("Property 3"), "userObject.property3")); columns.add(new EditablePropertyColumn(new Model("Property 4"), "userObject.property4")); columns.add(new EditablePropertyColumn(new Model("Property 5"), "userObject.property5")); - columns.add(new EditablePropertyColumn(new Model("Property 6"), "userObject.property6")); - + columns.add(new EditablePropertyColumn(new Model("Property 6"), "userObject.property6")); + TreeModel model = TreeModelFactory.createTreeModel(); TreeGrid grid = new TreeGrid("grid", model, columns); - + grid.setContentHeight(23, SizeUnit.EM); grid.setAllowSelectMultiple(true); grid.setClickRowToSelect(true); grid.setClickRowToDeselect(false); grid.setSelectToEdit(true); - + // expand the root node grid.getTreeState().expandNode(model.getRoot()); - + add(grid); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/SimpleTreeGridPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/SimpleTreeGridPage.java index 1e4f72dec4..d7a632951c 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/SimpleTreeGridPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/SimpleTreeGridPage.java @@ -19,29 +19,31 @@ * * @author Matej Knopp */ -public class SimpleTreeGridPage extends BaseExamplePage { +public class SimpleTreeGridPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public SimpleTreeGridPage() { + public SimpleTreeGridPage() + { List columns = new ArrayList(); - + columns.add(new PropertyTreeColumn(new Model("Property 1"), "userObject.property1")); columns.add(new PropertyColumn(new Model("Property 2"), "userObject.property2")); columns.add(new PropertyColumn(new Model("Property 3"), "userObject.property3")); columns.add(new PropertyColumn(new Model("Property 4"), "userObject.property4")); columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5")); columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6")); - + TreeModel model = TreeModelFactory.createTreeModel(); TreeGrid grid = new TreeGrid("grid", model, columns); - + // expand the root node grid.getTreeState().expandNode(model.getRoot()); - + add(grid); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridColumnPropertiesPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridColumnPropertiesPage.java index 8379e2adcd..bba5066e94 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridColumnPropertiesPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridColumnPropertiesPage.java @@ -22,61 +22,60 @@ * * @author Matej Knopp */ -public class TreeGridColumnPropertiesPage extends BaseExamplePage { +public class TreeGridColumnPropertiesPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * constructor. */ - public TreeGridColumnPropertiesPage() { + public TreeGridColumnPropertiesPage() + { List columns = new ArrayList(); - columns.add( - new PropertyTreeColumn(new Model("Property 1"), "userObject.property1") { - private static final long serialVersionUID = 1L; - @Override - public int getColSpan(IModel rowModel) { - TreeNode node = (TreeNode) rowModel.getObject(); - if (node.isLeaf()) { - return 1; - } else { - return 6; - } + columns.add(new PropertyTreeColumn(new Model("Property 1"), "userObject.property1") + { + private static final long serialVersionUID = 1L; + + @Override + public int getColSpan(IModel rowModel) + { + TreeNode node = (TreeNode)rowModel.getObject(); + if (node.isLeaf()) + { + return 1; + } + else + { + return 6; } } - .setReorderable(false) - .setInitialSize(200) - .setMinSize(100) - .setMaxSize(250) - ); - - columns.add( - new PropertyColumn(new Model("Property 2"), "userObject.property2") { - private static final long serialVersionUID = 1L; - @Override - public String getCellCssClass(IModel rowModel, int rowNum) { - return "property2"; - } + }.setReorderable(false).setInitialSize(200).setMinSize(100).setMaxSize(250)); + + columns.add(new PropertyColumn(new Model("Property 2"), "userObject.property2") + { + private static final long serialVersionUID = 1L; + + @Override + public String getCellCssClass(IModel rowModel, int rowNum) + { + return "property2"; } - .setResizable(false) - ); - - columns.add( - new PropertyColumn(new Model("Property 3"), "userObject.property3") { - private static final long serialVersionUID = 1L; - @Override - public String getCellCssClass(IModel rowModel, int rowNum) { - return "property3"; - } + }.setResizable(false)); + + columns.add(new PropertyColumn(new Model("Property 3"), "userObject.property3") + { + private static final long serialVersionUID = 1L; + + @Override + public String getCellCssClass(IModel rowModel, int rowNum) + { + return "property3"; } - .setHeaderTooltipModel(new Model("Property 3 column")) - ); - - columns.add( - new PropertyColumn(new Model("Property 4"), "userObject.property4") - .setWrapText(true) - ); + }.setHeaderTooltipModel(new Model("Property 3 column"))); + + columns.add(new PropertyColumn(new Model("Property 4"), "userObject.property4").setWrapText(true)); columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5")); columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6")); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridSelectionPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridSelectionPage.java index 38dd438601..31468120c8 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridSelectionPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/TreeGridSelectionPage.java @@ -30,18 +30,20 @@ * * @author Matej Knopp */ -public class TreeGridSelectionPage extends BaseExamplePage { +public class TreeGridSelectionPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; private Label selectionLabel; - + /** * Constructor. */ - public TreeGridSelectionPage() { + public TreeGridSelectionPage() + { List columns = new ArrayList(); - + columns.add(new CheckBoxColumn("checkBox")); columns.add(new PropertyTreeColumn(new Model("Property 1"), "userObject.property1")); columns.add(new PropertyColumn(new Model("Property 2"), "userObject.property2")); @@ -49,88 +51,104 @@ public TreeGridSelectionPage() { columns.add(new PropertyColumn(new Model("Property 4"), "userObject.property4")); columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5")); columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6")); - + TreeModel model = TreeModelFactory.createTreeModel(); - final TreeGrid grid = new TreeGrid("grid", model, columns) { + final TreeGrid grid = new TreeGrid("grid", model, columns) + { private static final long serialVersionUID = 1L; @Override - public void onItemSelectionChanged(IModel item, boolean newValue) { + public void onItemSelectionChanged(IModel item, boolean newValue) + { super.onItemSelectionChanged(item, newValue); - + // refresh the selection label when an item gets selected/deselected. AjaxRequestTarget target = AjaxRequestTarget.get(); target.add(selectionLabel); } }; - + grid.setAllowSelectMultiple(true); grid.setClickRowToSelect(true); grid.setContentHeight(23, SizeUnit.EM); - + // expand the root node grid.getTreeState().expandNode(model.getRoot()); - + add(grid); - - IModel selectedItemsModel = new Model() { + + IModel selectedItemsModel = new Model() + { private static final long serialVersionUID = 1L; @Override - public Serializable getObject() { + public Serializable getObject() + { return selectedItemsAsString(grid); } }; add(selectionLabel = new Label("currentSelection", selectedItemsModel)); selectionLabel.setOutputMarkupId(true); - + addOptionLinks(grid); } - private String selectedItemsAsString(AbstractGrid grid) { + private String selectedItemsAsString(AbstractGrid grid) + { StringBuilder res = new StringBuilder(); Collection selected = grid.getSelectedItems(); - for (IModel model : selected) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) model.getObject(); + for (IModel model : selected) + { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)model.getObject(); TreeBean bean = (TreeBean)node.getUserObject(); - if (res.length() > 0) { + if (res.length() > 0) + { res.append(", "); } res.append(bean.getProperty1()); } - return res.toString(); + return res.toString(); } - - private void addOptionLinks(final TreeGrid grid) { - - add(new Link("selectMultipleOn") { + + private void addOptionLinks(final TreeGrid grid) + { + + add(new Link("selectMultipleOn") + { private static final long serialVersionUID = 1L; @Override - public void onClick() { + public void onClick() + { grid.setAllowSelectMultiple(true); } + @Override - public boolean isEnabled() { + public boolean isEnabled() + { return !grid.isAllowSelectMultiple(); } }); - - add(new Link("selectMultipleOff") { + + add(new Link("selectMultipleOff") + { private static final long serialVersionUID = 1L; @Override - public void onClick() { + public void onClick() + { grid.setAllowSelectMultiple(false); } + @Override - public boolean isEnabled() { + public boolean isEnabled() + { return grid.isAllowSelectMultiple(); } - }); + }); } - + } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/VerticalScrollingTreeGridPage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/VerticalScrollingTreeGridPage.java index 07c11aa31e..f009f2ab67 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/VerticalScrollingTreeGridPage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/pages/treegrid/VerticalScrollingTreeGridPage.java @@ -20,31 +20,33 @@ * * @author Matej Knopp */ -public class VerticalScrollingTreeGridPage extends BaseExamplePage { +public class VerticalScrollingTreeGridPage extends BaseExamplePage +{ private static final long serialVersionUID = 1L; /** * Constructor. */ - public VerticalScrollingTreeGridPage() { + public VerticalScrollingTreeGridPage() + { List columns = new ArrayList(); - + columns.add(new PropertyTreeColumn(new Model("Property 1"), "userObject.property1")); columns.add(new PropertyColumn(new Model("Property 2"), "userObject.property2")); columns.add(new PropertyColumn(new Model("Property 3"), "userObject.property3")); columns.add(new PropertyColumn(new Model("Property 4"), "userObject.property4")); columns.add(new PropertyColumn(new Model("Property 5"), "userObject.property5")); columns.add(new PropertyColumn(new Model("Property 6"), "userObject.property6")); - + TreeModel model = TreeModelFactory.createTreeModel(); TreeGrid grid = new TreeGrid("grid", model, columns); - + grid.setContentHeight(23, SizeUnit.EM); - + // expand the root node grid.getTreeState().expandAll(); - + add(grid); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeBean.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeBean.java index 6b01328467..51608b4549 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeBean.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeBean.java @@ -9,7 +9,8 @@ * * @author Matej Knopp */ -public class TreeBean implements Serializable { +public class TreeBean implements Serializable +{ private static final long serialVersionUID = 1L; @@ -171,5 +172,5 @@ public String toString() return getProperty1() + ", " + getProperty2() + ", " + getProperty3(); } - + } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeModelFactory.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeModelFactory.java index ca30fd7c64..ef216791a6 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeModelFactory.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/main/java/com/inmethod/grid/examples/tree/TreeModelFactory.java @@ -14,7 +14,8 @@ * * @author Matej Knopp */ -public class TreeModelFactory { +public class TreeModelFactory +{ /** * Creates the model that feeds the tree. * @@ -80,15 +81,15 @@ private void add(DefaultMutableTreeNode parent, List sub) Object o = i.next(); if (o instanceof List) { - DefaultMutableTreeNode child = new DefaultMutableTreeNode(new TreeBean( - "subtree...")); + DefaultMutableTreeNode child = new DefaultMutableTreeNode( + new TreeBean("subtree...")); parent.add(child); add(child, (List)o); } else { - DefaultMutableTreeNode child = new DefaultMutableTreeNode(new TreeBean(o - .toString())); + DefaultMutableTreeNode child = new DefaultMutableTreeNode( + new TreeBean(o.toString())); parent.add(child); } } @@ -99,7 +100,8 @@ private void add(DefaultMutableTreeNode parent, List sub) * * @return {@link TreeModel} instance. */ - public static TreeModel createTreeModel() { + public static TreeModel createTreeModel() + { return new TreeModelFactory().createTreeModelInternal(); } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/test/java/com/inmethod/grid/examples/Start.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/test/java/com/inmethod/grid/examples/Start.java index 54d1e139c2..646ad06f4d 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/test/java/com/inmethod/grid/examples/Start.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid-examples/src/test/java/com/inmethod/grid/examples/Start.java @@ -5,9 +5,11 @@ import org.eclipse.jetty.server.bio.SocketConnector; import org.eclipse.jetty.webapp.WebAppContext; -public class Start { +public class Start +{ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception + { Server server = new Server(); SocketConnector connector = new SocketConnector(); // Set some timeout options to make debugging easier. @@ -21,24 +23,28 @@ public static void main(String[] args) throws Exception { bb.setContextPath("/"); bb.setWar("src/main/webapp"); - + // START JMX SERVER // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); // server.getContainer().addEventListener(mBeanContainer); // mBeanContainer.start(); - + server.setHandler(bb); - try { + try + { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); - while (System.in.available() == 0) { + while (System.in.available() == 0) + { Thread.sleep(5000); } server.stop(); server.join(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); System.exit(100); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/DataProviderAdapter.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/DataProviderAdapter.java index 1546d557bf..1e82abd347 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/DataProviderAdapter.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/DataProviderAdapter.java @@ -17,7 +17,8 @@ * * @author Matej Knopp */ -public class DataProviderAdapter implements IDataSource { +public class DataProviderAdapter implements IDataSource +{ private static final long serialVersionUID = 1L; @@ -29,40 +30,51 @@ public class DataProviderAdapter implements IDataSource { * @param dataProvider * {@link IDataProvider} instance */ - public DataProviderAdapter(IDataProvider dataProvider) { + public DataProviderAdapter(IDataProvider dataProvider) + { this.dataProvider = dataProvider; } /** * {@inheritDoc} */ - public void detach() { + public void detach() + { dataProvider.detach(); } /** * {@inheritDoc} */ - public IModel model(Object object) { + public IModel model(Object object) + { return dataProvider.model(object); } - - private void setSortState(ISortState dest, DataGrid grid, IGridSortState gridSortState) { + + private void setSortState(ISortState dest, DataGrid grid, IGridSortState gridSortState) + { Set unsortedColumns = new HashSet(grid.getAllColumns().size()); - for (IGridColumn column : grid.getAllColumns()) { - if (column.getSortProperty() != null) { + for (IGridColumn column : grid.getAllColumns()) + { + if (column.getSortProperty() != null) + { unsortedColumns.add(column.getSortProperty()); } } - for (IGridSortState.ISortStateColumn column : gridSortState.getColumns()) { + for (IGridSortState.ISortStateColumn column : gridSortState.getColumns()) + { unsortedColumns.remove(column.getPropertyName()); } - for (int i = gridSortState.getColumns().size(); i > 0; --i) { + for (int i = gridSortState.getColumns().size(); i > 0; --i) + { IGridSortState.ISortStateColumn column = gridSortState.getColumns().get(i - 1); SortOrder dir = SortOrder.NONE; - if (column.getDirection() == IGridSortState.Direction.ASC) { + if (column.getDirection() == IGridSortState.Direction.ASC) + { dir = SortOrder.ASCENDING; - } else if (column.getDirection() == IGridSortState.Direction.DESC) { + } + else if (column.getDirection() == IGridSortState.Direction.DESC) + { dir = SortOrder.DESCENDING; } dest.setPropertySortOrder(column.getPropertyName(), dir); @@ -72,15 +84,18 @@ private void setSortState(ISortState dest, DataGrid grid, IGridSortState gridSor /** * {@inheritDoc} */ - public void query(IQuery query, IQueryResult result) { - if (dataProvider instanceof ISortStateLocator) { - ISortStateLocator locator = (ISortStateLocator) dataProvider; + public void query(IQuery query, IQueryResult result) + { + if (dataProvider instanceof ISortStateLocator) + { + ISortStateLocator locator = (ISortStateLocator)dataProvider; IGridSortState gridSortState = query.getSortState(); ISortState state = locator.getSortState(); - if (state != null) { - DataGrid grid = ((DataGrid.IGridQuery) query).getDataGrid(); + if (state != null) + { + DataGrid grid = ((DataGrid.IGridQuery)query).getDataGrid(); setSortState(state, grid, gridSortState); } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IDataSource.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IDataSource.java index 7cdce309b4..376d910ad4 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IDataSource.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IDataSource.java @@ -27,7 +27,7 @@ * public IModel model(Object object) { * return new DetachableUserModel(objecT); * } - * } + * } *

* * An example of situation when the row count can't be determined. The pagination then only allows @@ -58,12 +58,13 @@ * * @author Matej Knopp */ -public interface IDataSource extends IDetachable, IClusterable { +public interface IDataSource extends IDetachable, IClusterable +{ /** * Implementation of this method should load subset of the data specified by - * query.getFrom() and query.getCount(). Also if the total item - * count can be determined, it should be passed to result. + * query.getFrom() and query.getCount(). Also if the total item count + * can be determined, it should be passed to result. * * @param query * Specified the amount and position of items to be queried @@ -86,7 +87,8 @@ public interface IDataSource extends IDetachable, IClusterable { * * @author Matej Knopp */ - public interface IQuery { + public interface IQuery + { /** * Returns the index of first item to be loaded * @@ -97,9 +99,8 @@ public interface IQuery { /** * Returns the amount of items to be loaded. If the total amount is known (it was either set * by {@link IQueryResult#setTotalCount(int)} before calling this method or the previous - * call to - * {@link IDataSource#query(IDataSource.IQuery, IDataSource.IQueryResult)} - * set {@link IQueryResult#NO_MORE_ITEMS} as total count), this method will return the exact + * call to {@link IDataSource#query(IDataSource.IQuery, IDataSource.IQueryResult)} set + * {@link IQueryResult#NO_MORE_ITEMS} as total count), this method will return the exact * amount of required rows. If the total amount of rows is not known, it will always return * the number of items per page. * @@ -136,7 +137,8 @@ public interface IQuery { * * @author Matej Knopp */ - public interface IQueryResult { + public interface IQueryResult + { /** * Constant indicating that there are more items left. */ diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridColumn.java index a29a0c0e40..eeeb996645 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridColumn.java @@ -14,7 +14,8 @@ * * @author Matej Knopp */ -public interface IGridColumn extends IDetachable { +public interface IGridColumn extends IDetachable +{ /** * Returns the column id. Each column must have a unique Id. The only allowed characters in a @@ -50,15 +51,16 @@ public interface IGridColumn extends IDetachable { * * @param parent * Parent component. This is passed in only for convenience, the method - * implementation is not supposed to add the newly created component to - * the parent. + * implementation is not supposed to add the newly created component to the + * parent. * @param componentId * required id of newly created components * @param rowModel * model for given row * @return new cell component */ - Component newCell(final WebMarkupContainer parent, final String componentId, final IModel rowModel); + Component newCell(final WebMarkupContainer parent, final String componentId, + final IModel rowModel); /** * Creates a new {@link IRenderable} instance that is used to render to render the output of @@ -171,22 +173,22 @@ public interface IGridColumn extends IDetachable { /** * Determines the behavior when there is more text in cell than it fits in it. If the method - * returns true, the text will be wrapped and row height increased. If the - * method returns false, the remaining part of text will be hidden. + * returns true, the text will be wrapped and row height increased. If the method + * returns false, the remaining part of text will be hidden. * * @return whether this colulmn's text should wrap or not */ public boolean getWrapText(); - + /** * Allows to override default behavior when a row is clicked. Depending on grid settings the * default behavior can select the item. If this method returns true the default * behavior will be suppressed. + * * @param rowModel - * Model for clicked row - * @return - * true if the default behavior when row is clicked should be supressed, - * false otherwise. + * Model for clicked row + * @return true if the default behavior when row is clicked should be supressed, + * false otherwise. */ public boolean cellClicked(IModel rowModel); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridSortState.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridSortState.java index f44cd898ea..f532e63e81 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridSortState.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IGridSortState.java @@ -7,10 +7,11 @@ /** * Allows to query the sort state of a grid. Sort state determines by which properties and in what - * direction the data should be sorted. This interface allows data to be sorted by multiple properties - * at the same time. + * direction the data should be sorted. This interface allows data to be sorted by multiple + * properties at the same time. *

* Example of use: + * *

  *  IGridSortState state = ... // acquire sort state
  *  
@@ -28,19 +29,21 @@
  * 
  * @author Matej Knopp
  */
-public interface IGridSortState {
+public interface IGridSortState
+{
 
 	/**
 	 * The direction.
-	 *  
+	 * 
 	 * @author Matej Knopp
 	 */
-	enum Direction {
+	enum Direction
+	{
 		/**
 		 * Ascending direction
 		 */
-		ASC, 
-		
+		ASC,
+
 		/**
 		 * Descending direction
 		 */
@@ -52,7 +55,8 @@ enum Direction {
 	 * 
 	 * @author Matej Knopp
 	 */
-	public interface ISortStateColumn {
+	public interface ISortStateColumn
+	{
 		/**
 		 * Returns the property name
 		 * 
@@ -60,9 +64,10 @@ public interface ISortStateColumn {
 		 * @return property name
 		 */
 		public String getPropertyName();
-		
+
 		/**
-		 * Returns the direction in which this column should be sorted 
+		 * Returns the direction in which this column should be sorted
+		 * 
 		 * @return direction
 		 */
 		public IGridSortState.Direction getDirection();
diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IRenderable.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IRenderable.java
index 11be8dcacc..c1594686e2 100644
--- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IRenderable.java
+++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/IRenderable.java
@@ -9,7 +9,8 @@
  * @see IGridColumn#isLightWeight(IModel)
  * @author Matej Knopp
  */
-public interface IRenderable {
+public interface IRenderable
+{
 
 	/**
 	 * Renders the output for given cell model. The implementation must take care of proper escaping
diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/SizeUnit.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/SizeUnit.java
index 1295f06515..dd4187e54e 100644
--- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/SizeUnit.java
+++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/SizeUnit.java
@@ -2,39 +2,43 @@
 
 /**
  * Represents a HTML size unit.
- *
+ * 
  * @author Matej Knopp
  */
-public enum SizeUnit {
-		
+public enum SizeUnit
+{
+
 	/**
 	 * CSS EM unit
 	 */
-	EM ("em"),
-	
+	EM("em"),
+
 	/**
 	 * CSS PX unit
 	 */
-	PX ("px"),
-	
+	PX("px"),
+
 	/**
 	 * CSS EX unit
 	 */
-	EX ("ex");
-	
+	EX("ex");
+
 	private final String value;
-	
-	SizeUnit(String value) {
+
+	SizeUnit(String value)
+	{
 		this.value = value;
 	}
-	
+
 	/**
 	 * Returns the string representation of the unit.
+	 * 
 	 * @return string representation of the unit
 	 */
-	public String getValue() {
+	public String getValue()
+	{
 		return value;
 	}
-	
-	
+
+
 };
diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractColumn.java
index 43a881839b..4f2bb3ea5d 100644
--- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractColumn.java
+++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractColumn.java
@@ -13,12 +13,11 @@
 import com.inmethod.grid.common.AbstractGrid;
 
 /**
- * Convenience implementation of {@link IGridColumn}. This class should be used
- * as base for non-lightweight columns.
+ * Convenience implementation of {@link IGridColumn}. This class should be used as base for
+ * non-lightweight columns.
  * 

- * Contains getters and setters for most properties and takes care of the header - * component. The only method necessary to implement is - * {@link #newCell(WebMarkupContainer, String, IModel)}. + * Contains getters and setters for most properties and takes care of the header component. The only + * method necessary to implement is {@link #newCell(WebMarkupContainer, String, IModel)}. *

* * @see AbstractLightWeightColumn @@ -27,379 +26,370 @@ public abstract class AbstractColumn implements IGridColumn { - private static final long serialVersionUID = 1L; - - private final String columnId; - private final IModel headerModel; - private IModel headerTooltipModel; - private final String sortProperty; - - /** - * Creates instance with specified column id, header model and sort - * property. - * - * @param columnId - * column identifier - must be unique within the grid - * @param headerModel - * model for column title - * @param sortProperty - * optional string that will be returned by {@link ISortState} to - * indicate that the column is being sorted - */ - public AbstractColumn(String columnId, IModel headerModel, - String sortProperty) - { - this.columnId = columnId; - this.headerModel = headerModel; - this.sortProperty = sortProperty; - } - - /** - * Creates instance with specified column id and header model - * - * @param columnId - * column identifier - must be unique within the grid - * @param headerModel - * model for column title - */ - public AbstractColumn(String columnId, IModel headerModel) - { - this(columnId, headerModel, null); - } - - /** - * Sets the model for header tooltip. - * - * @param headerTooltipModel - * model for header tooltip - * @return this (useful for method chaining) - */ - public AbstractColumn setHeaderTooltipModel(IModel headerTooltipModel) - { - this.headerTooltipModel = headerTooltipModel; - return this; - } - - /** - * Returns the model for header tooltip - * - * @return model for header tooltip - */ - public IModel getHeaderTooltipModel() - { - return headerTooltipModel; - } - - /** - * Returns the model for header (caption) - * - * @return header model - */ - public IModel getHeaderModel() - { - return headerModel; - } - - /** - * {@inheritDoc} - */ - public String getCellCssClass(IModel rowModel, int rowNum) - { - return null; - } - - /** - * {@inheritDoc} - */ - public int getColSpan(IModel rowModel) - { - return 1; - } - - /** - * {@inheritDoc} - */ - public String getHeaderCssClass() - { - return null; - } - - /** - * {@inheritDoc} - */ - public String getId() - { - return columnId; - } - - private int initialSize = 150; - - /** - * Sets the initial size for this column. The unit depends on - * {@link #setSizeUnit(SizeUnit)}. By default the unit is pixels. - * - * @param initialSize - * initial size of the column - * @return this (useful for method chaining) - */ - public AbstractColumn setInitialSize(int initialSize) - { - this.initialSize = initialSize; - return this; - } - - /** - * {@inheritDoc} - */ - public int getInitialSize() - { - return initialSize; - } - - private SizeUnit sizeUnit = SizeUnit.PX; - - /** - * Sets the size unit for this column. The default size unit is - * {@link SizeUnit#PX}. - * - * @param sizeUnit - * @return this (useful for method chaining) - */ - public AbstractColumn setSizeUnit(SizeUnit sizeUnit) - { - this.sizeUnit = sizeUnit; - return this; - } - - /** - * {@inheritDoc} - */ - public SizeUnit getSizeUnit() - { - return sizeUnit; - } - - private int maxSize = 0; - - /** - * Sets the maximal size of this column. Only relevant if the column is - * resizable and the column unit is {@link SizeUnit#PX} (pixels). - * - * @param maxSize - * maximal column size - * @return this (useful for method chaining) - */ - public AbstractColumn setMaxSize(int maxSize) - { - this.maxSize = maxSize; - return this; - } - - /** - * {@inheritDoc} - */ - public int getMaxSize() - { - return maxSize; - } - - private int minSize = 0; - - /** - * Sets the minimal size of this column. Only relevant if the column is - * resizable and the column unit is {@link SizeUnit#PX} (pixels). - * - * @param minSize - * minimal column size - * @return this (useful for method chaining) - */ - - public AbstractColumn setMinSize(int minSize) - { - this.minSize = minSize; - return this; - } - - /** - * {@inheritDoc} - */ - public int getMinSize() - { - return minSize; - } - - /** - * {@inheritDoc} - */ - public String getSortProperty() - { - return sortProperty; - } - - private boolean reorderable = true; - - /** - * Sets whether the user will be able to drag and reorder this column (true - * by default). - * - * @param reorderable - * true if the column will be reorderable, - * false otherwise - * @return this (useful for method chaining) - */ - public AbstractColumn setReorderable(boolean reorderable) - { - this.reorderable = reorderable; - return this; - } - - /** - * #see {@link IGridColumn#isReorderable()} - */ - public boolean isReorderable() - { - return reorderable; - } - - private boolean resizable = true; - - /** - * Sets whether the user will be able to resize this column (true by - * default). In order for the column to be resizable, the size unit must be - * {@link SizeUnit#PX}. - * - * @see #setSizeUnit(SizeUnit) - * @param resizable - * true if the column will be resizable, - * false otherwise - * @return this (useful for method chaining) - */ - public AbstractColumn setResizable(boolean resizable) - { - this.resizable = resizable; - return this; - } - - /** - * {@inheritDoc} - */ - public boolean isResizable() - { - return resizable; - } - - /** - * {@inheritDoc} - */ - public boolean isLightWeight(IModel rowModel) - { - return false; - } - - /** - * {@inheritDoc} - */ - public abstract Component newCell(WebMarkupContainer parent, - String componentId, IModel rowModel); - - /** - * {@inheritDoc} - */ - public IRenderable newCell(IModel rowModel) - { - return null; - } - - /** - * {@inheritDoc} - */ - public Component newHeader(String componentId) - { - return new Label(componentId, getHeaderModel()) - { - - private static final long serialVersionUID = 1L; - - @Override - protected void onComponentTag(ComponentTag tag) - { - super.onComponentTag(tag); - - if (getHeaderTooltipModel() != null) - { - Object object = getHeaderTooltipModel().getObject(); - if (object != null) - { - tag.put("title", object.toString()); - } - } - } - }; - } - - /** - * {@inheritDoc} - */ - public void detach() - { - - } - - private AbstractGrid grid = null; - - /** - * {@inheritDoc} - */ - public void setGrid(AbstractGrid grid) - { - if (this.grid != null && this.grid != grid) - { - throw new IllegalStateException( - "One column instance can not be used with multiple grid instances."); - } - this.grid = grid; - } - - /** - * Returns the grid instance associated with this column. - * - * @return grid instance - */ - public AbstractGrid getGrid() - { - return grid; - } - - private boolean wrapText = false; - - /** - * Sets whether the text in column will be wrapped when it is too long to - * fit the column (false by default). - * - * @param wrapText - * true if the text will be wrapped, false - * otherwise. - * @return this (useful for method chaining) - */ - public AbstractColumn setWrapText(boolean wrapText) - { - this.wrapText = wrapText; - return this; - } - - /** - * {@inheritDoc} - */ - public boolean getWrapText() - { - return wrapText; - } - - /** - * {@inheritDoc} - */ - public boolean cellClicked(IModel rowModel) - { - return false; - } + private static final long serialVersionUID = 1L; + + private final String columnId; + private final IModel headerModel; + private IModel headerTooltipModel; + private final String sortProperty; + + /** + * Creates instance with specified column id, header model and sort property. + * + * @param columnId + * column identifier - must be unique within the grid + * @param headerModel + * model for column title + * @param sortProperty + * optional string that will be returned by {@link ISortState} to indicate that the + * column is being sorted + */ + public AbstractColumn(String columnId, IModel headerModel, String sortProperty) + { + this.columnId = columnId; + this.headerModel = headerModel; + this.sortProperty = sortProperty; + } + + /** + * Creates instance with specified column id and header model + * + * @param columnId + * column identifier - must be unique within the grid + * @param headerModel + * model for column title + */ + public AbstractColumn(String columnId, IModel headerModel) + { + this(columnId, headerModel, null); + } + + /** + * Sets the model for header tooltip. + * + * @param headerTooltipModel + * model for header tooltip + * @return this (useful for method chaining) + */ + public AbstractColumn setHeaderTooltipModel(IModel headerTooltipModel) + { + this.headerTooltipModel = headerTooltipModel; + return this; + } + + /** + * Returns the model for header tooltip + * + * @return model for header tooltip + */ + public IModel getHeaderTooltipModel() + { + return headerTooltipModel; + } + + /** + * Returns the model for header (caption) + * + * @return header model + */ + public IModel getHeaderModel() + { + return headerModel; + } + + /** + * {@inheritDoc} + */ + public String getCellCssClass(IModel rowModel, int rowNum) + { + return null; + } + + /** + * {@inheritDoc} + */ + public int getColSpan(IModel rowModel) + { + return 1; + } + + /** + * {@inheritDoc} + */ + public String getHeaderCssClass() + { + return null; + } + + /** + * {@inheritDoc} + */ + public String getId() + { + return columnId; + } + + private int initialSize = 150; + + /** + * Sets the initial size for this column. The unit depends on {@link #setSizeUnit(SizeUnit)}. By + * default the unit is pixels. + * + * @param initialSize + * initial size of the column + * @return this (useful for method chaining) + */ + public AbstractColumn setInitialSize(int initialSize) + { + this.initialSize = initialSize; + return this; + } + + /** + * {@inheritDoc} + */ + public int getInitialSize() + { + return initialSize; + } + + private SizeUnit sizeUnit = SizeUnit.PX; + + /** + * Sets the size unit for this column. The default size unit is {@link SizeUnit#PX}. + * + * @param sizeUnit + * @return this (useful for method chaining) + */ + public AbstractColumn setSizeUnit(SizeUnit sizeUnit) + { + this.sizeUnit = sizeUnit; + return this; + } + + /** + * {@inheritDoc} + */ + public SizeUnit getSizeUnit() + { + return sizeUnit; + } + + private int maxSize = 0; + + /** + * Sets the maximal size of this column. Only relevant if the column is resizable and the column + * unit is {@link SizeUnit#PX} (pixels). + * + * @param maxSize + * maximal column size + * @return this (useful for method chaining) + */ + public AbstractColumn setMaxSize(int maxSize) + { + this.maxSize = maxSize; + return this; + } + + /** + * {@inheritDoc} + */ + public int getMaxSize() + { + return maxSize; + } + + private int minSize = 0; + + /** + * Sets the minimal size of this column. Only relevant if the column is resizable and the column + * unit is {@link SizeUnit#PX} (pixels). + * + * @param minSize + * minimal column size + * @return this (useful for method chaining) + */ + + public AbstractColumn setMinSize(int minSize) + { + this.minSize = minSize; + return this; + } + + /** + * {@inheritDoc} + */ + public int getMinSize() + { + return minSize; + } + + /** + * {@inheritDoc} + */ + public String getSortProperty() + { + return sortProperty; + } + + private boolean reorderable = true; + + /** + * Sets whether the user will be able to drag and reorder this column (true by default). + * + * @param reorderable + * true if the column will be reorderable, false otherwise + * @return this (useful for method chaining) + */ + public AbstractColumn setReorderable(boolean reorderable) + { + this.reorderable = reorderable; + return this; + } + + /** + * #see {@link IGridColumn#isReorderable()} + */ + public boolean isReorderable() + { + return reorderable; + } + + private boolean resizable = true; + + /** + * Sets whether the user will be able to resize this column (true by default). In order for the + * column to be resizable, the size unit must be {@link SizeUnit#PX}. + * + * @see #setSizeUnit(SizeUnit) + * @param resizable + * true if the column will be resizable, false otherwise + * @return this (useful for method chaining) + */ + public AbstractColumn setResizable(boolean resizable) + { + this.resizable = resizable; + return this; + } + + /** + * {@inheritDoc} + */ + public boolean isResizable() + { + return resizable; + } + + /** + * {@inheritDoc} + */ + public boolean isLightWeight(IModel rowModel) + { + return false; + } + + /** + * {@inheritDoc} + */ + public abstract Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel); + + /** + * {@inheritDoc} + */ + public IRenderable newCell(IModel rowModel) + { + return null; + } + + /** + * {@inheritDoc} + */ + public Component newHeader(String componentId) + { + return new Label(componentId, getHeaderModel()) + { + + private static final long serialVersionUID = 1L; + + @Override + protected void onComponentTag(ComponentTag tag) + { + super.onComponentTag(tag); + + if (getHeaderTooltipModel() != null) + { + Object object = getHeaderTooltipModel().getObject(); + if (object != null) + { + tag.put("title", object.toString()); + } + } + } + }; + } + + /** + * {@inheritDoc} + */ + public void detach() + { + + } + + private AbstractGrid grid = null; + + /** + * {@inheritDoc} + */ + public void setGrid(AbstractGrid grid) + { + if (this.grid != null && this.grid != grid) + { + throw new IllegalStateException( + "One column instance can not be used with multiple grid instances."); + } + this.grid = grid; + } + + /** + * Returns the grid instance associated with this column. + * + * @return grid instance + */ + public AbstractGrid getGrid() + { + return grid; + } + + private boolean wrapText = false; + + /** + * Sets whether the text in column will be wrapped when it is too long to fit the column ( + * false by default). + * + * @param wrapText + * true if the text will be wrapped, false otherwise. + * @return this (useful for method chaining) + */ + public AbstractColumn setWrapText(boolean wrapText) + { + this.wrapText = wrapText; + return this; + } + + /** + * {@inheritDoc} + */ + public boolean getWrapText() + { + return wrapText; + } + + /** + * {@inheritDoc} + */ + public boolean cellClicked(IModel rowModel) + { + return false; + } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractLightWeightColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractLightWeightColumn.java index cb466bd087..496c37aa84 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractLightWeightColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/AbstractLightWeightColumn.java @@ -10,7 +10,8 @@ import com.inmethod.grid.column.editable.EditablePropertyColumn; /** - * Convenience implementation of {@link IGridColumn}. This class should be used as base for lightweight columns. + * Convenience implementation of {@link IGridColumn}. This class should be used as base for + * lightweight columns. *

* Contains getters and setters for most properties and takes care of the header component. The only * method necessary to implement is {@link #newCell(IModel)}. @@ -19,7 +20,8 @@ * @see EditablePropertyColumn * @author Matej Knopp */ -public abstract class AbstractLightWeightColumn extends AbstractColumn { +public abstract class AbstractLightWeightColumn extends AbstractColumn +{ /** * Creates instance with specified column id, header model and sort property. @@ -32,7 +34,8 @@ public abstract class AbstractLightWeightColumn extends AbstractColumn { * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public AbstractLightWeightColumn(String columnId, IModel headerModel, String sortProperty) { + public AbstractLightWeightColumn(String columnId, IModel headerModel, String sortProperty) + { super(columnId, headerModel, sortProperty); } @@ -45,7 +48,8 @@ public AbstractLightWeightColumn(String columnId, IModel headerModel, String sor * model for column title */ - public AbstractLightWeightColumn(String columnId, IModel headerModel) { + public AbstractLightWeightColumn(String columnId, IModel headerModel) + { super(columnId, headerModel); } @@ -53,7 +57,8 @@ public AbstractLightWeightColumn(String columnId, IModel headerModel) { * {@inheritDoc} */ @Override - public boolean isLightWeight(IModel rowModel) { + public boolean isLightWeight(IModel rowModel) + { return true; } @@ -67,7 +72,8 @@ public boolean isLightWeight(IModel rowModel) { * {@inheritDoc} */ @Override - public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) { + public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) + { return null; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/CheckBoxColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/CheckBoxColumn.java index 9acd72bd13..836ddd506d 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/CheckBoxColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/CheckBoxColumn.java @@ -18,21 +18,20 @@ import com.inmethod.grid.treegrid.TreeGrid; /** - * Column that allows a row in grid to be selected. The column cell contains a - * checkbox which selects and deselects the row. When row selection state is - * changed, the entire row is updated using Ajax. + * Column that allows a row in grid to be selected. The column cell contains a checkbox which + * selects and deselects the row. When row selection state is changed, the entire row is updated + * using Ajax. *

- * If the grid is in single selection mode, the column header will remain empty. - * If the column is in multi selection mode, the column header will contain a - * checkbox which selects all displayed rows (i.e. the rows on current page for - * {@link DataGrid} and visible rows in {@link TreeGrid}). When the header - * checkbox is deselected, it deselects all rows (on all pages). This is to - * ensure that when user deselects one page, no invisible rows are left - * selected. + * If the grid is in single selection mode, the column header will remain empty. If the column is in + * multi selection mode, the column header will contain a checkbox which selects all displayed rows + * (i.e. the rows on current page for {@link DataGrid} and visible rows in {@link TreeGrid}). When + * the header checkbox is deselected, it deselects all rows (on all pages). This is to ensure that + * when user deselects one page, no invisible rows are left selected. * * @author Matej Knopp */ -public class CheckBoxColumn extends AbstractColumn { +public class CheckBoxColumn extends AbstractColumn +{ private static final long serialVersionUID = 1L; @@ -42,7 +41,8 @@ public class CheckBoxColumn extends AbstractColumn { * @param columnId * column id (must be unique within the grid) */ - public CheckBoxColumn(String columnId) { + public CheckBoxColumn(String columnId) + { super(columnId, null); setResizable(false); setInitialSize(30); @@ -52,8 +52,8 @@ public CheckBoxColumn(String columnId) { * {@inheritDoc} */ @Override - public Component newCell(WebMarkupContainer parent, String componentId, - IModel rowModel) { + public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) + { return new BodyCheckBoxPanel(componentId, rowModel); } @@ -61,31 +61,38 @@ public Component newCell(WebMarkupContainer parent, String componentId, * {@inheritDoc} */ @Override - public Component newHeader(String componentId) { + public Component newHeader(String componentId) + { return new HeadPanel(componentId); } - private void processTag(ComponentTag tag, IModel model) { - if (!isCheckBoxEnabled(model)) { + private void processTag(ComponentTag tag, IModel model) + { + if (!isCheckBoxEnabled(model)) + { tag.put("disabled", "disabled"); - } else if (getGrid() instanceof TreeGrid - && ((TreeGrid) getGrid()).isAutoSelectChildren()) { - - TreeGrid grid = (TreeGrid) getGrid(); + } + else if (getGrid() instanceof TreeGrid && ((TreeGrid)getGrid()).isAutoSelectChildren()) + { + + TreeGrid grid = (TreeGrid)getGrid(); Object parent = grid.getTree().getParentNode(model.getObject()); - if (parent != null && grid.getTreeState().isNodeSelected(parent)) { + if (parent != null && grid.getTreeState().isNodeSelected(parent)) + { tag.put("disabled", "disabled"); } } } - protected boolean isCheckBoxEnabled(IModel model) { + protected boolean isCheckBoxEnabled(IModel model) + { return true; } - protected boolean isCheckBoxVisible(IModel model) { + protected boolean isCheckBoxVisible(IModel model) + { return true; } @@ -94,28 +101,35 @@ protected boolean isCheckBoxVisible(IModel model) { * * @author Matej Knopp */ - private class BodyCheckBoxPanel extends Panel { + private class BodyCheckBoxPanel extends Panel + { private static final long serialVersionUID = 1L; - private BodyCheckBoxPanel(String id, final IModel model) { + private BodyCheckBoxPanel(String id, final IModel model) + { super(id, model); - WebMarkupContainer checkbox = new WebMarkupContainer("checkbox") { + WebMarkupContainer checkbox = new WebMarkupContainer("checkbox") + { private static final long serialVersionUID = 1L; @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); - if (getGrid().isItemSelected(model)) { + if (getGrid().isItemSelected(model)) + { tag.put("checked", "checked"); } IModel tooltipModel = getRowTooltipModel(model); - if (tooltipModel != null) { + if (tooltipModel != null) + { Object object = tooltipModel.getObject(); - if (object != null) { + if (object != null) + { tag.put("title", object.toString()); } } @@ -124,40 +138,45 @@ protected void onComponentTag(ComponentTag tag) { } @Override - public boolean isVisible() { + public boolean isVisible() + { return isCheckBoxVisible(model); } }; checkbox.setOutputMarkupId(true); add(checkbox); - checkbox.add(new AjaxFormSubmitBehavior(getGrid().getForm(), - "onclick") { + checkbox.add(new AjaxFormSubmitBehavior(getGrid().getForm(), "onclick") + { private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target) { + protected void onSubmit(AjaxRequestTarget target) + { } @Override - protected void onError(AjaxRequestTarget target) { + protected void onError(AjaxRequestTarget target) + { } @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { // preserve the entered values in form components Form form = getForm(); - form - .visitFormComponentsPostOrder(new IVisitor, Void>() { - public void component(FormComponent formComponent, - IVisit visit) { - if (formComponent.isVisibleInHierarchy()) { - formComponent.inputChanged(); - } - } - }); + form.visitFormComponentsPostOrder(new IVisitor, Void>() + { + public void component(FormComponent formComponent, IVisit visit) + { + if (formComponent.isVisibleInHierarchy()) + { + formComponent.inputChanged(); + } + } + }); boolean selected = getGrid().isItemSelected(model); getGrid().selectItem(model, !selected); @@ -165,13 +184,15 @@ public void component(FormComponent formComponent, } @Override - protected CharSequence getPreconditionScript() { - return "window.setTimeout(function(){this.checked=!this.checked}.bind(this),0);" - + super.getPreconditionScript(); + protected CharSequence getPreconditionScript() + { + return "window.setTimeout(function(){this.checked=!this.checked}.bind(this),0);" + + super.getPreconditionScript(); } @Override - protected IAjaxCallDecorator getAjaxCallDecorator() { + protected IAjaxCallDecorator getAjaxCallDecorator() + { return new CancelEventIfNoAjaxDecorator(); } }); @@ -180,24 +201,28 @@ protected IAjaxCallDecorator getAjaxCallDecorator() { } /** - * Panel that optionally displays checkbox for selecting all visible items / - * clearing selection of all item. + * Panel that optionally displays checkbox for selecting all visible items / clearing selection + * of all item. * * @author Matej Knopp */ - private class HeadPanel extends Panel { + private class HeadPanel extends Panel + { private static final long serialVersionUID = 1L; - private HeadPanel(String id) { + private HeadPanel(String id) + { super(id); - add(new HeadCheckBoxPanel("checkbox") { + add(new HeadCheckBoxPanel("checkbox") + { private static final long serialVersionUID = 1L; @Override - public boolean isVisible() { + public boolean isVisible() + { return getGrid().isAllowSelectMultiple(); } }); @@ -206,21 +231,26 @@ public boolean isVisible() { // takes the proper // height) // and also for displaying the tooltip - add(new WebMarkupContainer("space") { + add(new WebMarkupContainer("space") + { private static final long serialVersionUID = 1L; @Override - public boolean isVisible() { + public boolean isVisible() + { return !getGrid().isAllowSelectMultiple(); } @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); - if (getHeaderTooltipModel() != null) { + if (getHeaderTooltipModel() != null) + { Object object = getHeaderTooltipModel().getObject(); - if (object != null) { + if (object != null) + { tag.put("title", object.toString()); } } @@ -234,23 +264,29 @@ protected void onComponentTag(ComponentTag tag) { * * @author Matej Knopp */ - private class HeadCheckBoxPanel extends Panel { + private class HeadCheckBoxPanel extends Panel + { private static final long serialVersionUID = 1L; - private HeadCheckBoxPanel(String id) { + private HeadCheckBoxPanel(String id) + { super(id); - WebMarkupContainer checkbox = new WebMarkupContainer("checkbox") { + WebMarkupContainer checkbox = new WebMarkupContainer("checkbox") + { private static final long serialVersionUID = 1L; @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); - if (getHeaderTooltipModel() != null) { + if (getHeaderTooltipModel() != null) + { Object object = getHeaderTooltipModel().getObject(); - if (object != null) { + if (object != null) + { tag.put("title", object.toString()); } } @@ -258,35 +294,40 @@ protected void onComponentTag(ComponentTag tag) { }; add(checkbox); - checkbox.add(new AjaxFormSubmitBehavior(getGrid().getForm(), - "onclick") { + checkbox.add(new AjaxFormSubmitBehavior(getGrid().getForm(), "onclick") + { private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target) { + protected void onSubmit(AjaxRequestTarget target) + { } @Override - protected void onError(AjaxRequestTarget target) { + protected void onError(AjaxRequestTarget target) + { } @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { // preserve the entered values in form components Form form = getForm(); - form - .visitFormComponentsPostOrder(new IVisitor, Void>() { - public void component(FormComponent formComponent, - IVisit visit) { - if (formComponent.isVisibleInHierarchy()) { - formComponent.inputChanged(); - } - } - }); - - boolean checked = getRequest() - .getRequestParameters().getParameterValue("checked").toBoolean(); + form.visitFormComponentsPostOrder(new IVisitor, Void>() + { + public void component(FormComponent formComponent, IVisit visit) + { + if (formComponent.isVisibleInHierarchy()) + { + formComponent.inputChanged(); + } + } + }); + + boolean checked = getRequest().getRequestParameters() + .getParameterValue("checked") + .toBoolean(); if (checked) getGrid().selectAllVisibleItems(); else @@ -295,18 +336,21 @@ public void component(FormComponent formComponent, } @Override - public CharSequence getCallbackUrl() { + public CharSequence getCallbackUrl() + { return super.getCallbackUrl() + "&checked='+this.checked+'"; } @Override - protected CharSequence getPreconditionScript() { - return "window.setTimeout(function(){this.checked=!this.checked}.bind(this),0);" - + super.getPreconditionScript(); + protected CharSequence getPreconditionScript() + { + return "window.setTimeout(function(){this.checked=!this.checked}.bind(this),0);" + + super.getPreconditionScript(); } @Override - protected IAjaxCallDecorator getAjaxCallDecorator() { + protected IAjaxCallDecorator getAjaxCallDecorator() + { return new CancelEventIfNoAjaxDecorator(); } }); @@ -318,24 +362,26 @@ protected IAjaxCallDecorator getAjaxCallDecorator() { * {@inheritDoc} */ @Override - public String getCellCssClass(IModel rowModel, int rowNum) { + public String getCellCssClass(IModel rowModel, int rowNum) + { return "imxt-select"; } @Override - public String getHeaderCssClass() { + public String getHeaderCssClass() + { return "imxt-select"; } /** - * Overriding this method allows to specify a tooltip for checkbox in each - * row. + * Overriding this method allows to specify a tooltip for checkbox in each row. * * @param itemModel * model for item in given row * @return tooltip model or null */ - protected IModel getRowTooltipModel(IModel itemModel) { + protected IModel getRowTooltipModel(IModel itemModel) + { return null; } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/PropertyColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/PropertyColumn.java index ccdd5d6a95..bb115844ce 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/PropertyColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/PropertyColumn.java @@ -14,200 +14,190 @@ import com.inmethod.grid.IRenderable; /** - * A lightweight column that displays a property of row object specified by an - * property expression. + * A lightweight column that displays a property of row object specified by an property expression. * * @author Matej Knopp */ public class PropertyColumn extends AbstractLightWeightColumn { - private static final long serialVersionUID = 1L; - - private final String propertyExpression; - - /** - * Constructor. - * - * @param columnId - * column identified (must be unique within the grid) - * @param headerModel - * model for column header - * @param propertyExpression - * property expression used to get the displayed value for row - * object - * @param sortProperty - * optional string that will be returned by {@link ISortState} to - * indicate that the column is being sorted - */ - public PropertyColumn(String columnId, IModel headerModel, - String propertyExpression, String sortProperty) - { - super(columnId, headerModel, sortProperty); - this.propertyExpression = propertyExpression; - } - - /** - * Constructor. - * - * @param columnId - * column identified (must be unique within the grid) - * @param headerModel - * model for column header - * @param propertyExpression - * property expression used to get the displayed value for row - * object - */ - public PropertyColumn(String columnId, IModel headerModel, - String propertyExpression) - { - this(columnId, headerModel, propertyExpression, null); - } - - /** - * Constructor. The column id is omitted in this constructor, because the - * property expression is used as column id. - * - * @param headerModel - * model for column header - * @param propertyExpression - * property expression used to get the displayed value for row - * object - * @param sortProperty - * optional string that will be returned by {@link ISortState} to - * indicate that the column is being sorted - */ - public PropertyColumn(IModel headerModel, String propertyExpression, - String sortProperty) - { - this(propertyExpression, headerModel, propertyExpression, sortProperty); - } - - /** - * Constructor. The column id is omitted in this constructor, because the - * property expression is used as column id. - * - * @param headerModel - * model for column header - * @param propertyExpression - * property expression used to get the displayed value for row - * object - */ - public PropertyColumn(IModel headerModel, String propertyExpression) - { - this(propertyExpression, headerModel, propertyExpression); - } - - private boolean escapeMarkup = true; - - /** - * Sets whether the markup will be escaped. Set to false if the - * property contains html snippets that need to be rendered as html (without - * being escaped). - * - * @param escape - * @return this (useful for method chaining) - */ - public PropertyColumn setEscapeMarkup(boolean escape) - { - this.escapeMarkup = escape; - return this; - } - - /** - * Returns whether the markup will be escaped. - * - * @return - * truefalse - * otherwise - */ - public boolean isEscapeMarkup() - { - return escapeMarkup; - } - - protected Object getProperty(Object object, String propertyExpression) - { - return PropertyResolver.getValue(propertyExpression, object); - } - - protected Object getModelObject(IModel rowModel) - { - return rowModel.getObject(); - } - - private CharSequence getValue(IModel rowModel) - { - Object rowObject = getModelObject(rowModel); - Object property = null; - if (rowObject != null) - { - try - { - property = getProperty(rowObject, getPropertyExpression()); - } - catch (NullPointerException e) - { - - } - } - CharSequence string = convertToString(property); - if (isEscapeMarkup() && string != null) - { - string = Strings.escapeMarkup(string.toString()); - } - return string; - } - - protected IConverter getConverter(Class type) - { - return Application.get().getConverterLocator().getConverter(type); - } - - protected Locale getLocale() - { - return Session.get().getLocale(); - } - - protected CharSequence convertToString(Object object) - { - if (object != null) - { - IConverter converter = getConverter(object.getClass()); - return converter.convertToString(object, getLocale()); - } - else - { - return ""; - } - } - - /** - * {@inheritDoc} - */ - @Override - public IRenderable newCell(IModel rowModel) - { - return new IRenderable() - { - public void render(IModel rowModel, Response response) - { - CharSequence value = getValue(rowModel); - if (value != null) - { - response.write(value); - } - } - }; - } - - /** - * Returns the property expression. - * - * @return property expression - */ - public String getPropertyExpression() - { - return propertyExpression; - } + private static final long serialVersionUID = 1L; + + private final String propertyExpression; + + /** + * Constructor. + * + * @param columnId + * column identified (must be unique within the grid) + * @param headerModel + * model for column header + * @param propertyExpression + * property expression used to get the displayed value for row object + * @param sortProperty + * optional string that will be returned by {@link ISortState} to indicate that the + * column is being sorted + */ + public PropertyColumn(String columnId, IModel headerModel, String propertyExpression, + String sortProperty) + { + super(columnId, headerModel, sortProperty); + this.propertyExpression = propertyExpression; + } + + /** + * Constructor. + * + * @param columnId + * column identified (must be unique within the grid) + * @param headerModel + * model for column header + * @param propertyExpression + * property expression used to get the displayed value for row object + */ + public PropertyColumn(String columnId, IModel headerModel, String propertyExpression) + { + this(columnId, headerModel, propertyExpression, null); + } + + /** + * Constructor. The column id is omitted in this constructor, because the property expression is + * used as column id. + * + * @param headerModel + * model for column header + * @param propertyExpression + * property expression used to get the displayed value for row object + * @param sortProperty + * optional string that will be returned by {@link ISortState} to indicate that the + * column is being sorted + */ + public PropertyColumn(IModel headerModel, String propertyExpression, String sortProperty) + { + this(propertyExpression, headerModel, propertyExpression, sortProperty); + } + + /** + * Constructor. The column id is omitted in this constructor, because the property expression is + * used as column id. + * + * @param headerModel + * model for column header + * @param propertyExpression + * property expression used to get the displayed value for row object + */ + public PropertyColumn(IModel headerModel, String propertyExpression) + { + this(propertyExpression, headerModel, propertyExpression); + } + + private boolean escapeMarkup = true; + + /** + * Sets whether the markup will be escaped. Set to false if the property contains + * html snippets that need to be rendered as html (without being escaped). + * + * @param escape + * @return this (useful for method chaining) + */ + public PropertyColumn setEscapeMarkup(boolean escape) + { + escapeMarkup = escape; + return this; + } + + /** + * Returns whether the markup will be escaped. + * + * @return truefalse otherwise + */ + public boolean isEscapeMarkup() + { + return escapeMarkup; + } + + protected Object getProperty(Object object, String propertyExpression) + { + return PropertyResolver.getValue(propertyExpression, object); + } + + protected Object getModelObject(IModel rowModel) + { + return rowModel.getObject(); + } + + private CharSequence getValue(IModel rowModel) + { + Object rowObject = getModelObject(rowModel); + Object property = null; + if (rowObject != null) + { + try + { + property = getProperty(rowObject, getPropertyExpression()); + } + catch (NullPointerException e) + { + + } + } + CharSequence string = convertToString(property); + if (isEscapeMarkup() && string != null) + { + string = Strings.escapeMarkup(string.toString()); + } + return string; + } + + protected IConverter getConverter(Class type) + { + return Application.get().getConverterLocator().getConverter(type); + } + + protected Locale getLocale() + { + return Session.get().getLocale(); + } + + protected CharSequence convertToString(Object object) + { + if (object != null) + { + IConverter converter = getConverter(object.getClass()); + return converter.convertToString(object, getLocale()); + } + else + { + return ""; + } + } + + /** + * {@inheritDoc} + */ + @Override + public IRenderable newCell(IModel rowModel) + { + return new IRenderable() + { + public void render(IModel rowModel, Response response) + { + CharSequence value = getValue(rowModel); + if (value != null) + { + response.write(value); + } + } + }; + } + + /** + * Returns the property expression. + * + * @return property expression + */ + public String getPropertyExpression() + { + return propertyExpression; + } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/WicketColumnAdapter.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/WicketColumnAdapter.java index cee89ed887..298503b5d1 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/WicketColumnAdapter.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/WicketColumnAdapter.java @@ -29,7 +29,8 @@ * * @author Matej Knopp */ -public class WicketColumnAdapter extends AbstractColumn { +public class WicketColumnAdapter extends AbstractColumn +{ private static final long serialVersionUID = 1L; private final IColumn delegate; @@ -42,20 +43,25 @@ public class WicketColumnAdapter extends AbstractColumn { * @param column * {@link IColumn} implementation */ - public WicketColumnAdapter(String columnId, IColumn column) { + public WicketColumnAdapter(String columnId, IColumn column) + { super(columnId, null, null); - this.delegate = column; + delegate = column; } /** * {@inheritDoc} */ @Override - public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) { + public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) + { Item item; - if (getGrid() instanceof DataGrid) { + if (getGrid() instanceof DataGrid) + { item = parent.findParent(Item.class); - } else { + } + else + { item = new Item("temp", 0, rowModel); } delegate.populateItem(item, componentId, rowModel); @@ -68,7 +74,8 @@ public Component newCell(WebMarkupContainer parent, String componentId, IModel r * {@inheritDoc} */ @Override - public Component newHeader(String componentId) { + public Component newHeader(String componentId) + { return delegate.getHeader(componentId); } @@ -76,10 +83,14 @@ public Component newHeader(String componentId) { * {@inheritDoc} */ @Override - public String getCellCssClass(IModel rowModel, int rowNum) { - if (delegate instanceof IStyledColumn) { - return ((IStyledColumn) delegate).getCssClass(); - } else { + public String getCellCssClass(IModel rowModel, int rowNum) + { + if (delegate instanceof IStyledColumn) + { + return ((IStyledColumn)delegate).getCssClass(); + } + else + { return null; } } @@ -88,39 +99,46 @@ public String getCellCssClass(IModel rowModel, int rowNum) { * {@inheritDoc} */ @Override - public String getSortProperty() { - if (delegate.isSortable()) { + public String getSortProperty() + { + if (delegate.isSortable()) + { return delegate.getSortProperty(); - } else { + } + else + { return null; } } /** - * Returns the specified {@link IColumn} array as list of {@link WicketColumnAdapter}s that - * can be given to an {@link AbstractGrid}. The column identifiers are generated. + * Returns the specified {@link IColumn} array as list of {@link WicketColumnAdapter}s that can + * be given to an {@link AbstractGrid}. The column identifiers are generated. + * * @param columns - * array of {@link IColumn}s - * @return - * list of {@link IGridColumn}s + * array of {@link IColumn}s + * @return list of {@link IGridColumn}s */ - public static List wrapColumns(IColumn columns[]) { + public static List wrapColumns(IColumn columns[]) + { return wrapColumns(Arrays.asList(columns)); } - + /** - * Returns the specified {@link IColumn} list as list of {@link WicketColumnAdapter}s that - * can be given to an {@link AbstractGrid}. The column identifiers are generated. + * Returns the specified {@link IColumn} list as list of {@link WicketColumnAdapter}s that can + * be given to an {@link AbstractGrid}. The column identifiers are generated. + * * @param columns - * list of {@link IColumn}s - * @return - * list of {@link IGridColumn}s + * list of {@link IColumn}s + * @return list of {@link IGridColumn}s */ - public static List wrapColumns(List columns) { + public static List wrapColumns(List columns) + { List result = new ArrayList(columns.size()); int i = 0; - for (IColumn column : columns) { + for (IColumn column : columns) + { result.add(new WicketColumnAdapter("column" + i++, column)); } return result; diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditableCellPanel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditableCellPanel.java index e58b01d3d7..b8884ddb0f 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditableCellPanel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditableCellPanel.java @@ -12,47 +12,57 @@ import com.inmethod.grid.IGridColumn; import com.inmethod.grid.column.AbstractColumn; -public abstract class EditableCellPanel extends Panel { +public abstract class EditableCellPanel extends Panel +{ - private final AbstractColumn column; - - public EditableCellPanel(String id, AbstractColumn column, IModel rowModel) { + private final AbstractColumn column; + + public EditableCellPanel(String id, AbstractColumn column, IModel rowModel) + { super(id, rowModel); this.column = column; } - - public AbstractColumn getColumn() { + + public AbstractColumn getColumn() + { return column; } - + @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { super.onBeforeRender(); - + AjaxRequestTarget target = AjaxRequestTarget.get(); - + Component textField = get("textfield"); - - if (target != null && isFocusTextField()) { + + if (target != null && isFocusTextField()) + { target.focusComponent(textField); - } + } } - - protected boolean isFocusTextField() { - IGridColumn lastClickedColumn = getColumn().getGrid().getLastClickedColumn(); - if (lastClickedColumn == getColumn()) { + + protected boolean isFocusTextField() + { + IGridColumn lastClickedColumn = getColumn().getGrid().getLastClickedColumn(); + if (lastClickedColumn == getColumn()) + { getColumn().getGrid().cleanLastClickedColumn(); return true; - } else { + } + else + { return false; } } - + @Override - public boolean isVisible() { - return column.getGrid().isItemEdited(getDefaultModel()); + public boolean isVisible() + { + return column.getGrid().isItemEdited(getDefaultModel()); } - + protected abstract FormComponent getEditComponent(); - + } \ No newline at end of file diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyColumn.java index 2b8bfeab77..95e3cacb9f 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyColumn.java @@ -12,10 +12,12 @@ /** * Property column that uses a {@link TextFieldPanel} as cell component when the item is selected. + * * @author Matej Knopp - * + * */ -public class EditablePropertyColumn extends PropertyColumn { +public class EditablePropertyColumn extends PropertyColumn +{ private static final long serialVersionUID = 1L; @@ -32,7 +34,9 @@ public class EditablePropertyColumn extends PropertyColumn { * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public EditablePropertyColumn(String columnId, IModel headerModel, String propertyExpression, String sortProperty) { + public EditablePropertyColumn(String columnId, IModel headerModel, String propertyExpression, + String sortProperty) + { super(columnId, headerModel, propertyExpression, sortProperty); } @@ -46,7 +50,8 @@ public EditablePropertyColumn(String columnId, IModel headerModel, String proper * @param propertyExpression * property expression used to get the displayed value for row object */ - public EditablePropertyColumn(String columnId, IModel headerModel, String propertyExpression) { + public EditablePropertyColumn(String columnId, IModel headerModel, String propertyExpression) + { super(columnId, headerModel, propertyExpression); } @@ -62,7 +67,8 @@ public EditablePropertyColumn(String columnId, IModel headerModel, String proper * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public EditablePropertyColumn(IModel headerModel, String propertyExpression, String sortProperty) { + public EditablePropertyColumn(IModel headerModel, String propertyExpression, String sortProperty) + { super(headerModel, propertyExpression, sortProperty); } @@ -75,75 +81,90 @@ public EditablePropertyColumn(IModel headerModel, String propertyExpression, Str * @param propertyExpression * property expression used to get the displayed value for row object */ - public EditablePropertyColumn(IModel headerModel, String propertyExpression) { + public EditablePropertyColumn(IModel headerModel, String propertyExpression) + { super(headerModel, propertyExpression); } - + /** * {@inheritDoc} */ @Override - public boolean isLightWeight(IModel rowModel) { + public boolean isLightWeight(IModel rowModel) + { // when the item is selected, we need a textField component, thus // this method has to return false. return !getGrid().isItemEdited(rowModel); } - - protected IModel getFieldModel(IModel rowModel) { + + protected IModel getFieldModel(IModel rowModel) + { return new PropertyModel(rowModel, getPropertyExpression()); } - - protected EditableCellPanel newCellPanel(String componentId, IModel rowModel, IModel cellModel) { + + protected EditableCellPanel newCellPanel(String componentId, IModel rowModel, IModel cellModel) + { return new TextFieldPanel(componentId, cellModel, rowModel, this); } - + /** * {@inheritDoc} */ @Override - public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) { + public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) + { // when this method is called, it means that the row is not lightweight, which in turn // means the the row is selected (see implementation of #isLightWeight(IModel). - + EditableCellPanel panel = newCellPanel(componentId, rowModel, getFieldModel(rowModel)); addValidators(panel.getEditComponent()); return panel; - + // for lightweight rows (that are not selected) the lightweight #newCell(IModel) method - // is called that only displays the item + // is called that only displays the item } - - protected void addValidators(FormComponent component) { - + + protected void addValidators(FormComponent component) + { + } - + /** * {@inheritDoc} */ @Override - public String getCellCssClass(IModel rowModel, int rowNum) { + public String getCellCssClass(IModel rowModel, int rowNum) + { String prelight = isClickToEdit() ? "imxt-want-prelight" : ""; // for selected items we don't want the default cell item padding because we need - // to put a textfield in it, so the special "imxt-no-padding-cell" CSS class is used. - if (getGrid().isItemEdited(rowModel)) { + // to put a textfield in it, so the special "imxt-no-padding-cell" CSS class is used. + if (getGrid().isItemEdited(rowModel)) + { return "imxt-no-padding-cell " + prelight + " imxt-edited-cell"; - } else { + } + else + { return prelight; } } - + @Override - public boolean cellClicked(IModel rowModel) { - if (!isClickToEdit() || (getGrid().isClickRowToSelect() && getGrid().isSelectToEdit())) { + public boolean cellClicked(IModel rowModel) + { + if (!isClickToEdit() || (getGrid().isClickRowToSelect() && getGrid().isSelectToEdit())) + { return false; - } else { + } + else + { getGrid().setItemEdit(rowModel, true); getGrid().update(); return true; } } - - protected boolean isClickToEdit() { + + protected boolean isClickToEdit() + { return true; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyTreeColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyTreeColumn.java index 2e1bfe103a..303249a84e 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyTreeColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/EditablePropertyTreeColumn.java @@ -15,7 +15,8 @@ * * @author Matej Knopp */ -public class EditablePropertyTreeColumn extends PropertyTreeColumn { +public class EditablePropertyTreeColumn extends PropertyTreeColumn +{ private static final long serialVersionUID = 1L; @@ -32,8 +33,9 @@ public class EditablePropertyTreeColumn extends PropertyTreeColumn { * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public EditablePropertyTreeColumn(String columnId, IModel headerModel, String propertyExpression, - String sortProperty) { + public EditablePropertyTreeColumn(String columnId, IModel headerModel, + String propertyExpression, String sortProperty) + { super(columnId, headerModel, propertyExpression, sortProperty); } @@ -47,7 +49,8 @@ public EditablePropertyTreeColumn(String columnId, IModel headerModel, String pr * @param propertyExpression * property expression used to get the displayed value for row object */ - public EditablePropertyTreeColumn(String columnId, IModel headerModel, String propertyExpression) { + public EditablePropertyTreeColumn(String columnId, IModel headerModel, String propertyExpression) + { super(columnId, headerModel, propertyExpression); } @@ -63,7 +66,9 @@ public EditablePropertyTreeColumn(String columnId, IModel headerModel, String pr * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public EditablePropertyTreeColumn(IModel headerModel, String propertyExpression, String sortProperty) { + public EditablePropertyTreeColumn(IModel headerModel, String propertyExpression, + String sortProperty) + { super(headerModel, propertyExpression, sortProperty); } @@ -76,7 +81,8 @@ public EditablePropertyTreeColumn(IModel headerModel, String propertyExpression, * @param propertyExpression * property expression used to get the displayed value for row object */ - public EditablePropertyTreeColumn(IModel headerModel, String propertyExpression) { + public EditablePropertyTreeColumn(IModel headerModel, String propertyExpression) + { super(headerModel, propertyExpression); } @@ -84,7 +90,8 @@ public EditablePropertyTreeColumn(IModel headerModel, String propertyExpression) * {@inheritDoc} */ @Override - protected Component newNodeComponent(String id, IModel model) { + protected Component newNodeComponent(String id, IModel model) + { return new NodePanel(id, model); } @@ -95,7 +102,8 @@ protected Component newNodeComponent(String id, IModel model) { * @author Matej Knopp * */ - private class NodePanel extends Panel { + private class NodePanel extends Panel + { private static final long serialVersionUID = 1L; @@ -105,20 +113,23 @@ private class NodePanel extends Panel { * @param id * @param rowModel */ - public NodePanel(String id, final IModel rowModel) { + public NodePanel(String id, final IModel rowModel) + { super(id); - - add(new Label("label", new PropertyModel(rowModel, getPropertyExpression())) { + + add(new Label("label", new PropertyModel(rowModel, getPropertyExpression())) + { private static final long serialVersionUID = 1L; @Override - public boolean isVisible() { + public boolean isVisible() + { return !getGrid().isItemEdited(rowModel); } - + }); - + EditableCellPanel panel = newCellPanel("panel", rowModel, getFieldModel(rowModel)); addValidators(panel.getEditComponent()); add(panel); @@ -126,15 +137,18 @@ public boolean isVisible() { }; - protected void addValidators(FormComponent component) { + protected void addValidators(FormComponent component) + { } - protected IModel getFieldModel(IModel rowModel) { + protected IModel getFieldModel(IModel rowModel) + { return new PropertyModel(rowModel, getPropertyExpression()); } - protected EditableCellPanel newCellPanel(String componentId, IModel rowModel, IModel cellModel) { + protected EditableCellPanel newCellPanel(String componentId, IModel rowModel, IModel cellModel) + { return new TextFieldPanel(componentId, cellModel, rowModel, this); } @@ -142,35 +156,49 @@ protected EditableCellPanel newCellPanel(String componentId, IModel rowModel, IM * {@inheritDoc} */ @Override - public String getCellCssClass(IModel rowModel, int rowNum) { - if (isClickToEdit()) { - if (getGrid().isItemEdited(rowModel)) { + public String getCellCssClass(IModel rowModel, int rowNum) + { + if (isClickToEdit()) + { + if (getGrid().isItemEdited(rowModel)) + { return "imxt-want-prelight imxt-edited-cell"; - } else { + } + else + { return "imxt-want-prelight"; } - } else { - if (getGrid().isItemEdited(rowModel)) { + } + else + { + if (getGrid().isItemEdited(rowModel)) + { return "imxt-edited-cell"; } - else { + else + { return ""; } } } - + @Override - public boolean cellClicked(IModel rowModel) { - if (!isClickToEdit() || (getGrid().isClickRowToSelect() && getGrid().isSelectToEdit())) { + public boolean cellClicked(IModel rowModel) + { + if (!isClickToEdit() || (getGrid().isClickRowToSelect() && getGrid().isSelectToEdit())) + { return false; - } else { + } + else + { getGrid().setItemEdit(rowModel, true); getGrid().update(); return true; } } - - protected boolean isClickToEdit() { + + protected boolean isClickToEdit() + { return true; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelColumn.java index 9b1f6a9d87..bc0c15bd25 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelColumn.java @@ -10,81 +10,105 @@ import com.inmethod.grid.common.Icons; import com.inmethod.icon.Icon; -public class SubmitCancelColumn extends AbstractColumn { +public class SubmitCancelColumn extends AbstractColumn +{ private static final long serialVersionUID = 1L; - public SubmitCancelColumn(String columnId, IModel headerModel) { + public SubmitCancelColumn(String columnId, IModel headerModel) + { super(columnId, headerModel); - + setResizable(false); setSizeUnit(SizeUnit.PX); setInitialSize(44); } @Override - public Component newCell(WebMarkupContainer parent, String componentId, final IModel rowModel) { - return new SubmitCancelPanel(componentId, rowModel, getGrid()) { - + public Component newCell(WebMarkupContainer parent, String componentId, final IModel rowModel) + { + return new SubmitCancelPanel(componentId, rowModel, getGrid()) + { + private static final long serialVersionUID = 1L; - - private WebMarkupContainer getRowComponent() { + + private WebMarkupContainer getRowComponent() + { return getGrid().findParentRow(this); }; - + @Override - protected void onCancel(AjaxRequestTarget target) { + protected void onCancel(AjaxRequestTarget target) + { SubmitCancelColumn.this.onCancel(target, rowModel, getRowComponent()); } + @Override - protected void onError(AjaxRequestTarget target) { + protected void onError(AjaxRequestTarget target) + { SubmitCancelColumn.this.onError(target, rowModel, getRowComponent()); } + @Override - protected void onSubmitted(AjaxRequestTarget target) { + protected void onSubmitted(AjaxRequestTarget target) + { SubmitCancelColumn.this.onSubmitted(target, rowModel, getRowComponent()); } - + @Override - protected Icon getSubmitIcon() { + protected Icon getSubmitIcon() + { return SubmitCancelColumn.this.getSubmitIcon(); } - + @Override - protected Icon getCancelIcon() { + protected Icon getCancelIcon() + { return SubmitCancelColumn.this.getCancelIcon(); - } + } }; } - - protected Icon getSubmitIcon() { + + protected Icon getSubmitIcon() + { return Icons.OK; } - - protected Icon getCancelIcon() { + + protected Icon getCancelIcon() + { return Icons.CANCEL; } - protected void onCancel(AjaxRequestTarget target, IModel rowModel, WebMarkupContainer rowComponent) { + protected void onCancel(AjaxRequestTarget target, IModel rowModel, + WebMarkupContainer rowComponent) + { getGrid().setItemEdit(rowModel, false); getGrid().update(); } - - protected void onError(AjaxRequestTarget target, IModel rowModel, WebMarkupContainer rowComponent) { + + protected void onError(AjaxRequestTarget target, IModel rowModel, + WebMarkupContainer rowComponent) + { // just update the row target.add(rowComponent); } - - protected void onSubmitted(AjaxRequestTarget target, IModel rowModel, WebMarkupContainer rowComponent) { + + protected void onSubmitted(AjaxRequestTarget target, IModel rowModel, + WebMarkupContainer rowComponent) + { getGrid().setItemEdit(rowModel, false); - getGrid().update(); + getGrid().update(); } @Override - public boolean cellClicked(IModel rowModel) { - if (getGrid().isClickRowToSelect() && getGrid().isSelectToEdit()) { + public boolean cellClicked(IModel rowModel) + { + if (getGrid().isClickRowToSelect() && getGrid().isSelectToEdit()) + { return false; - } else { + } + else + { getGrid().setItemEdit(rowModel, true); getGrid().update(); return true; @@ -92,8 +116,9 @@ public boolean cellClicked(IModel rowModel) { } @Override - public String getCellCssClass(IModel rowModel, int rowNum) { + public String getCellCssClass(IModel rowModel, int rowNum) + { return getGrid().isItemEdited(rowModel) ? "imxt-edit" : "imxt-want-prelight imxt-edit"; } - + } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelPanel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelPanel.java index 0e01f9af34..c7c23c265c 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelPanel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/SubmitCancelPanel.java @@ -15,98 +15,119 @@ import com.inmethod.icon.Icon; import com.inmethod.icon.IconImage; -abstract class SubmitCancelPanel extends Panel { +abstract class SubmitCancelPanel extends Panel +{ private static final long serialVersionUID = 1L; - private AbstractGrid getGrid() { + private AbstractGrid getGrid() + { return grid; } private final AbstractGrid grid; - - SubmitCancelPanel(String id, final IModel model, AbstractGrid grid) { + + SubmitCancelPanel(String id, final IModel model, AbstractGrid grid) + { super(id); - + this.grid = grid; - AjaxSubmitLink submit = new SubmitLink("submit") { + AjaxSubmitLink submit = new SubmitLink("submit") + { private static final long serialVersionUID = 1L; @Override - public boolean isVisible() { + public boolean isVisible() + { return getGrid().isItemEdited(model); } }; - + submit.setDefaultFormProcessing(false); add(submit); - + submit.add(new IconImage("icon", getSubmitIcon())); - - AjaxLink cancel = new AjaxLink("cancel") { - + + AjaxLink cancel = new AjaxLink("cancel") + { + private static final long serialVersionUID = 1L; @Override - public void onClick(AjaxRequestTarget target) { + public void onClick(AjaxRequestTarget target) + { onCancel(target); } - + @Override - public boolean isVisible() { + public boolean isVisible() + { return getGrid().isItemEdited(model); - } + } }; - + add(cancel); - + cancel.add(new IconImage("icon", getCancelIcon())); - + } - + protected abstract void onSubmitted(AjaxRequestTarget target); protected abstract void onError(AjaxRequestTarget target); protected abstract void onCancel(AjaxRequestTarget target); - + protected abstract Icon getSubmitIcon(); - + protected abstract Icon getCancelIcon(); - - private class SubmitLink extends AjaxSubmitLink { - public SubmitLink(String id) { + private class SubmitLink extends AjaxSubmitLink + { + + public SubmitLink(String id) + { super(id, getGrid().getForm()); } private static final long serialVersionUID = 1L; - private boolean formComponentActive(FormComponent formComponent) { - return formComponent.isVisibleInHierarchy() && formComponent.isValid() && formComponent.isEnabled() - && formComponent.isEnableAllowed(); + private boolean formComponentActive(FormComponent formComponent) + { + return formComponent.isVisibleInHierarchy() && formComponent.isValid() && + formComponent.isEnabled() && formComponent.isEnableAllowed(); } @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { + protected void onSubmit(AjaxRequestTarget target, Form form) + { WebMarkupContainer gridRow = getGrid().findParentRow(SubmitCancelPanel.this); final Boolean[] error = { false }; - + // first iteration - validate components - gridRow.visitChildren(FormComponent.class, new IVisitor, Void>() { - public void component(FormComponent formComponent, IVisit visit) { - - if (formComponentActive(formComponent)) { + gridRow.visitChildren(FormComponent.class, new IVisitor, Void>() + { + public void component(FormComponent formComponent, IVisit visit) + { + + if (formComponentActive(formComponent)) + { formComponent.validate(); - if (formComponent.isValid()) { - if (formComponent.processChildren()) { + if (formComponent.isValid()) + { + if (formComponent.processChildren()) + { return; - } else { + } + else + { visit.dontGoDeeper(); return; } - } else { + } + else + { error[0] = true; visit.dontGoDeeper(); } @@ -115,38 +136,48 @@ public void component(FormComponent formComponent, IVisit visit) { }); // second iteration - update models if the validation passed - if (error[0] == false) { - gridRow.visitChildren(FormComponent.class, new IVisitor, Void>() { - public void component(FormComponent formComponent, IVisit visit) { + if (error[0] == false) + { + gridRow.visitChildren(FormComponent.class, new IVisitor, Void>() + { + public void component(FormComponent formComponent, IVisit visit) + { - if (formComponentActive(formComponent)) { + if (formComponentActive(formComponent)) + { formComponent.updateModel(); - if (formComponent.processChildren()) { + if (formComponent.processChildren()) + { return; - } else { + } + else + { visit.dontGoDeeper(); return; } } } }); - + onSubmitted(target); - } else { + } + else + { SubmitCancelPanel.this.onError(target); } - - + + } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target, Form form) + { // TODO Auto-generated method stub - + } }; - + } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/TextFieldPanel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/TextFieldPanel.java index b26a0e5ce7..94cbfd5529 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/TextFieldPanel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/editable/TextFieldPanel.java @@ -12,37 +12,44 @@ import com.inmethod.grid.column.AbstractColumn; /** - * Panel with a TextField that updates the property of the row immediately after - * user leaves the field. + * Panel with a TextField that updates the property of the row immediately after user leaves the + * field. * * @author Matej Knopp */ -public class TextFieldPanel extends EditableCellPanel { +public class TextFieldPanel extends EditableCellPanel +{ /** * Constructor + * * @param id - * component id + * component id * @param model - * model for the field + * model for the field * @param column - * column to which this panel belongs + * column to which this panel belongs */ - public TextFieldPanel(String id, final IModel model, IModel rowModel, AbstractColumn column) { + public TextFieldPanel(String id, final IModel model, IModel rowModel, AbstractColumn column) + { super(id, column, rowModel); - - TextField tf = new TextField("textfield", model) { - + + TextField tf = new TextField("textfield", model) + { + private static final long serialVersionUID = 1L; @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); - - if (isValid() == false) { + + if (isValid() == false) + { tag.put("class", "imxt-invalid"); FeedbackMessage message = getFeedbackMessage(); - if (message != null) { + if (message != null) + { tag.put("title", message.getMessage().toString()); } } @@ -50,14 +57,15 @@ protected void onComponentTag(ComponentTag tag) { }; tf.setOutputMarkupId(true); tf.setLabel(column.getHeaderModel()); - add(tf); + add(tf); } - + @Override - protected FormComponent getEditComponent() { - return (FormComponent) get("textfield"); + protected FormComponent getEditComponent() + { + return (FormComponent)get("textfield"); } - + private static final long serialVersionUID = 1L; - + } \ No newline at end of file diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/AbstractTreeColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/AbstractTreeColumn.java index 721a5a106b..77a5200639 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/AbstractTreeColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/AbstractTreeColumn.java @@ -14,11 +14,12 @@ import com.inmethod.icon.Icon; /** - * Base class for {@link TreeGrid} column that contains the actual tree. + * Base class for {@link TreeGrid} column that contains the actual tree. * * @author Matej Knopp */ -public abstract class AbstractTreeColumn extends BaseTreeColumn { +public abstract class AbstractTreeColumn extends BaseTreeColumn +{ /** * Creates instance with specified column id, header model and sort property. @@ -31,7 +32,8 @@ public abstract class AbstractTreeColumn extends BaseTreeColumn { * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public AbstractTreeColumn(String columnId, IModel headerModel, String sortProperty) { + public AbstractTreeColumn(String columnId, IModel headerModel, String sortProperty) + { super(columnId, headerModel, sortProperty); } @@ -43,7 +45,8 @@ public AbstractTreeColumn(String columnId, IModel headerModel, String sortProper * @param headerModel * model for column title */ - public AbstractTreeColumn(String columnId, IModel headerModel) { + public AbstractTreeColumn(String columnId, IModel headerModel) + { super(columnId, headerModel); } @@ -51,18 +54,24 @@ public AbstractTreeColumn(String columnId, IModel headerModel) { * {@inheritDoc} */ @Override - protected Icon getIcon(IModel model) { - TreeModel treeModel = (TreeModel) getTreeGrid().getTree().getDefaultModelObject(); + protected Icon getIcon(IModel model) + { + TreeModel treeModel = (TreeModel)getTreeGrid().getTree().getDefaultModelObject(); Object node = model.getObject(); - if (treeModel.isLeaf(node)) { + if (treeModel.isLeaf(node)) + { return Icons.ITEM; - } else if (getTreeGrid().getTreeState().isNodeExpanded(node)) { - return Icons.FOLDER_OPEN; - } else { + } + else if (getTreeGrid().getTreeState().isNodeExpanded(node)) + { + return Icons.FOLDER_OPEN; + } + else + { return Icons.FOLDER_CLOSED; } } - + /** * {@inheritDoc} */ @@ -73,15 +82,17 @@ protected Icon getIcon(IModel model) { * {@inheritDoc} */ @Override - public final Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) { + public final Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) + { return super.newCell(parent, componentId, rowModel); } - + /** * {@inheritDoc} */ @Override - public final IRenderable newCell(IModel rowModel) { + public final IRenderable newCell(IModel rowModel) + { return super.newCell(rowModel); } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/PropertyTreeColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/PropertyTreeColumn.java index 1c7e5e1fc7..cc95da9fd8 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/PropertyTreeColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/column/tree/PropertyTreeColumn.java @@ -15,7 +15,8 @@ * @see AbstractTreeColumn * @author Matej Knopp */ -public class PropertyTreeColumn extends AbstractTreeColumn { +public class PropertyTreeColumn extends AbstractTreeColumn +{ private static final long serialVersionUID = 1L; private final String propertyExpression; @@ -33,7 +34,9 @@ public class PropertyTreeColumn extends AbstractTreeColumn { * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public PropertyTreeColumn(String columnId, IModel headerModel, String propertyExpression, String sortProperty) { + public PropertyTreeColumn(String columnId, IModel headerModel, String propertyExpression, + String sortProperty) + { super(columnId, headerModel, sortProperty); this.propertyExpression = propertyExpression; } @@ -48,7 +51,8 @@ public PropertyTreeColumn(String columnId, IModel headerModel, String propertyEx * @param propertyExpression * property expression used to get the displayed value for row object */ - public PropertyTreeColumn(String columnId, IModel headerModel, String propertyExpression) { + public PropertyTreeColumn(String columnId, IModel headerModel, String propertyExpression) + { this(columnId, headerModel, propertyExpression, null); } @@ -64,7 +68,8 @@ public PropertyTreeColumn(String columnId, IModel headerModel, String propertyEx * optional string that will be returned by {@link ISortState} to indicate that the * column is being sorted */ - public PropertyTreeColumn(IModel headerModel, String propertyExpression, String sortProperty) { + public PropertyTreeColumn(IModel headerModel, String propertyExpression, String sortProperty) + { this(propertyExpression, headerModel, propertyExpression, sortProperty); } @@ -77,7 +82,8 @@ public PropertyTreeColumn(IModel headerModel, String propertyExpression, String * @param propertyExpression * property expression used to get the displayed value for row object */ - public PropertyTreeColumn(IModel headerModel, String propertyExpression) { + public PropertyTreeColumn(IModel headerModel, String propertyExpression) + { this(propertyExpression, headerModel, propertyExpression); } @@ -85,7 +91,8 @@ public PropertyTreeColumn(IModel headerModel, String propertyExpression) { * {@inheritDoc} */ @Override - protected Component newNodeComponent(String id, IModel model) { + protected Component newNodeComponent(String id, IModel model) + { return new Label(id, new PropertyModel(model, getPropertyExpression())); } @@ -94,7 +101,8 @@ protected Component newNodeComponent(String id, IModel model) { * * @return property expression. */ - protected String getPropertyExpression() { + protected String getPropertyExpression() + { return propertyExpression; } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGrid.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGrid.java index bd2fb1b227..0e4ff6b6a4 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGrid.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGrid.java @@ -46,19 +46,21 @@ /** * Provides common functionality for {@link DataGrid} and {@link TreeGrid}. - * + * * @author Matej Knopp */ -public abstract class AbstractGrid extends Panel implements IHeaderContributor { +public abstract class AbstractGrid extends Panel implements IHeaderContributor +{ /** * Creates new {@link AbstractGrid} instance - * + * * @param id * @param model * @param columns */ - public AbstractGrid(String id, IModel model, List columns) { + public AbstractGrid(String id, IModel model, List columns) + { super(id, model); setVersioned(false); @@ -74,15 +76,19 @@ public AbstractGrid(String id, IModel model, List columns) { Form form = new Form("form"); add(form); - WebMarkupContainer bodyContainer = new WebMarkupContainer("bodyContainer") { + WebMarkupContainer bodyContainer = new WebMarkupContainer("bodyContainer") + { private static final long serialVersionUID = 1L; @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); - if (getContentHeight() > 0 && getContentHeightSizeUnit() != null) { - tag.put("style", "height:" + getContentHeight() + getContentHeightSizeUnit().getValue()); + if (getContentHeight() > 0 && getContentHeightSizeUnit() != null) + { + tag.put("style", "height:" + getContentHeight() + + getContentHeightSizeUnit().getValue()); } } }; @@ -96,11 +102,13 @@ protected void onComponentTag(ComponentTag tag) { add(headerToolbarContainer = new RepeatingView("headerToolbarContainer")); // renders the initialization javascript right after the grid itself - add(new Behavior() { + add(new Behavior() + { private static final long serialVersionUID = 1L; @Override - public void afterRender(Component component) { + public void afterRender(Component component) + { renderInitializationJavascript(getResponse()); } }); @@ -110,48 +118,60 @@ public void afterRender(Component component) { add(submitColumnStateBehavior); } - public Form getForm() { - return (Form) get("form"); + public Form getForm() + { + return (Form)get("form"); }; /** * Checks whether the column is a valid grid column - * + * * @param column */ - protected void columnSanityCheck(IGridColumn column) { + protected void columnSanityCheck(IGridColumn column) + { String id = column.getId(); - if (Strings.isEmpty(id)) { + if (Strings.isEmpty(id)) + { throw new IllegalStateException("Column id must be a non-empty string."); } - for (int i = 0; i < id.length(); ++i) { + for (int i = 0; i < id.length(); ++i) + { char c = id.charAt(i); - if (!Character.isLetterOrDigit(c) && c != '.' && c != '-' && c != '_') { + if (!Character.isLetterOrDigit(c) && c != '.' && c != '-' && c != '_') + { throw new IllegalStateException("Column id contains invalid character(s)."); } } - if (column.isResizable() && column.getSizeUnit() != SizeUnit.PX) { + if (column.isResizable() && column.getSizeUnit() != SizeUnit.PX) + { throw new IllegalStateException("Resizable columns size must be in the PX unit."); } } /** * Checks whether the columns have proper values. - * + * * @param columns */ - private void columnsSanityCheck(List columns) { - for (int i = 0; i < columns.size(); ++i) { + private void columnsSanityCheck(List columns) + { + for (int i = 0; i < columns.size(); ++i) + { IGridColumn column = columns.get(i); columnSanityCheck(column); } - for (int i = 0; i < columns.size(); ++i) { + for (int i = 0; i < columns.size(); ++i) + { IGridColumn column = columns.get(i); - for (int j = 0; j < columns.size(); ++j) { - if (i != j) { + for (int j = 0; j < columns.size(); ++j) + { + if (i != j) + { IGridColumn otherColumn = columns.get(j); - if (column.getId().equals(otherColumn.getId())) { + if (column.getId().equals(otherColumn.getId())) + { throw new IllegalStateException("Each column must have unique id"); } } @@ -160,12 +180,12 @@ private void columnsSanityCheck(List columns) { } /** - * Invoked when client change the column state (e.g. resize or reorder a - * column). - * + * Invoked when client change the column state (e.g. resize or reorder a column). + * * @see #getColumnState() */ - public void onColumnStateChanged() { + public void onColumnStateChanged() + { } @@ -173,17 +193,21 @@ public void onColumnStateChanged() { /** * Ajax behavior that submits column state to server - * + * * @author Matej Knopp */ - private class SubmitColumnStateBehavior extends AbstractDefaultAjaxBehavior { + private class SubmitColumnStateBehavior extends AbstractDefaultAjaxBehavior + { private static final long serialVersionUID = 1L; @Override - protected void respond(AjaxRequestTarget target) { + protected void respond(AjaxRequestTarget target) + { // get the columnState request parameter (set by javascript) - String state = getRequest().getRequestParameters().getParameterValue("columnState").toString(); + String state = getRequest().getRequestParameters() + .getParameterValue("columnState") + .toString(); // apply it to current state columnState.updateColumnsState(state); @@ -195,10 +219,12 @@ protected void respond(AjaxRequestTarget target) { * {@inheritDoc} */ @Override - public CharSequence getCallbackScript() { + public CharSequence getCallbackScript() + { // this assumes presence of columnState variable in the surrounding // javacript context - return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() + "&columnState=' + columnState"); + return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() + + "&columnState=' + columnState"); } }; @@ -210,60 +236,70 @@ public CharSequence getCallbackScript() { /** * Returns the column state. - * + * * @see ColumnsState * @return state of columns */ - public ColumnsState getColumnState() { + public ColumnsState getColumnState() + { return columnState; } /** - * Sets a new column state. The state must not be null and must match - * current set of columns, i.e. for every column in grid there must be entry - * in the given state. - * + * Sets a new column state. The state must not be null and must match current set of columns, + * i.e. for every column in grid there must be entry in the given state. + * * @see ColumnsState * @param columnState * new column state */ - public void setColumnState(ColumnsState columnState) { - if (columnState == null) { + public void setColumnState(ColumnsState columnState) + { + if (columnState == null) + { throw new IllegalArgumentException("ColumnStateManager may not be null."); } - if (!columnState.matches(columns)) { + if (!columnState.matches(columns)) + { throw new IllegalArgumentException("ColumnStateManager doesn't match current columns."); } this.columnState = columnState; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.wicket.Component#onInitialize() */ @Override - protected void onInitialize() { + protected void onInitialize() + { super.onInitialize(); - for (IGridColumn column : columns) { + for (IGridColumn column : columns) + { column.setGrid(this); } } @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { setFlag(FLAG_RENDERING, true); super.onBeforeRender(); } @Override - protected void onAfterRender() { + protected void onAfterRender() + { super.onAfterRender(); setFlag(FLAG_RENDERING, false); } - boolean isRendering() { + boolean isRendering() + { return getFlag(FLAG_RENDERING); } @@ -273,12 +309,14 @@ boolean isRendering() { /** * Adds toolbar to specified container - * + * * @param toolbar * @param container */ - private void addToolbar(AbstractToolbar toolbar, RepeatingView container) { - if (toolbar == null) { + private void addToolbar(AbstractToolbar toolbar, RepeatingView container) + { + if (toolbar == null) + { throw new IllegalArgumentException("argument 'toolbar' cannot be null"); } @@ -292,35 +330,37 @@ private void addToolbar(AbstractToolbar toolbar, RepeatingView container) { /** * Adds a toolbar to the top section (above the grid header). - * + * * @see AbstractToolbar * @param toolbar * toolbar instance */ - public void addTopToolbar(AbstractToolbar toolbar) { + public void addTopToolbar(AbstractToolbar toolbar) + { addToolbar(toolbar, topToolbarContainer); } /** * Adds a toolbar to the bottom section (below the actual data). - * + * * @see AbstractToolbar * @param toolbar * toolbar instance */ - public void addBottomToolbar(AbstractToolbar toolbar) { + public void addBottomToolbar(AbstractToolbar toolbar) + { addToolbar(toolbar, bottomToolbarContainer); } /** - * Ads a toolbar to the header section (below the grid header, above the - * actual data). - * + * Ads a toolbar to the header section (below the grid header, above the actual data). + * * @see AbstractToolbar * @param toolbar * toolbar instance */ - public void addHeaderToolbar(AbstractHeaderToolbar toolbar) { + public void addHeaderToolbar(AbstractHeaderToolbar toolbar) + { addToolbar(toolbar, headerToolbarContainer); } @@ -332,21 +372,24 @@ public void addHeaderToolbar(AbstractHeaderToolbar toolbar) { static public final String INTERNAL_TOOLBAR_ITEM_ID = "item"; /** - * Model for the markup of empty row (first data row that has zero height). - * The empty row is needed for maintaining layout of the other rows. - * + * Model for the markup of empty row (first data row that has zero height). The empty row is + * needed for maintaining layout of the other rows. + * * @author Matej Knopp */ - private class EmptyRowModel extends Model { + private class EmptyRowModel extends Model + { private static final long serialVersionUID = 1L; /** * {@inheritDoc} */ @Override - public Serializable getObject() { + public Serializable getObject() + { StringBuilder result = new StringBuilder(); - for (int i = 0; i < getActiveColumns().size(); ++i) { + for (int i = 0; i < getActiveColumns().size(); ++i) + { result.append(""); } return result.toString(); @@ -355,25 +398,29 @@ public Serializable getObject() { /** * Component that represents the grid header. - * + * * @see ColumnsHeader * @author Matej Knopp */ - private class Header extends ColumnsHeader { + private class Header extends ColumnsHeader + { private static final long serialVersionUID = 1L; - private Header(String id) { + private Header(String id) + { super(id); } @Override - Collection getActiveColumns() { + Collection getActiveColumns() + { return AbstractGrid.this.getActiveColumns(); } @Override - int getColumnWidth(IGridColumn column) { + int getColumnWidth(IGridColumn column) + { int width = getColumnState().getColumnWidth(column.getId()); if (width != -1 && column.getSizeUnit() == SizeUnit.PX) return width; @@ -382,29 +429,32 @@ int getColumnWidth(IGridColumn column) { } @Override - protected void sortStateChanged(AjaxRequestTarget target) { - AbstractGrid.this.onSortStateChanged(target); + protected void sortStateChanged(AjaxRequestTarget target) + { + onSortStateChanged(target); } }; /** - * Invoked when sort state of this grid has changed (e.g. user clicked a - * sortable column header). By default refreshes the grid. - * + * Invoked when sort state of this grid has changed (e.g. user clicked a sortable column + * header). By default refreshes the grid. + * * @param target */ - protected void onSortStateChanged(AjaxRequestTarget target) { + protected void onSortStateChanged(AjaxRequestTarget target) + { target.add(this); } /** - * Renders the javascript required to initialize the client state for this - * grid instance. Called after every grid render. - * + * Renders the javascript required to initialize the client state for this grid instance. Called + * after every grid render. + * * @param response */ - private void renderInitializationJavascript(Response response) { + private void renderInitializationJavascript(Response response) + { JavaScriptUtils.writeOpenTag(response); response.write("(function() {\n"); @@ -412,7 +462,8 @@ private void renderInitializationJavascript(Response response) { response.write("var columns = [\n"); Collection columns = getActiveColumns(); int i = 0; - for (IGridColumn column : columns) { + for (IGridColumn column : columns) + { ++i; response.write(" {"); response.write(" minSize: " + column.getMinSize()); @@ -421,7 +472,8 @@ private void renderInitializationJavascript(Response response) { response.write(", resizable: " + column.isResizable()); response.write(", reorderable: " + column.isReorderable()); response.write(" }"); - if (i != columns.size()) { + if (i != columns.size()) + { response.write(","); } response.write("\n"); @@ -435,27 +487,29 @@ private void renderInitializationJavascript(Response response) { response.write(" }\n"); // initialization - response.write("InMethod.XTableManager.instance.register(\"" + getMarkupId() - + "\", columns, submitStateCallback);\n"); + response.write("InMethod.XTableManager.instance.register(\"" + getMarkupId() + + "\", columns, submitStateCallback);\n"); response.write("})();\n"); JavaScriptUtils.writeCloseTag(response); }; /** * Returns collection of currently visible columns. - * + * * @return collection of currently visible columns */ - public Collection getActiveColumns() { + public Collection getActiveColumns() + { return getColumnState().getVisibleColumns(columns); } /** * Returns the list of all columns in this grid. - * + * * @return list of columns */ - public List getAllColumns() { + public List getAllColumns() + { return Collections.unmodifiableList(columns); } @@ -466,14 +520,16 @@ public List getAllColumns() { /** * Returns the sort state of this grid. - * + * * @see IGridSortState * @see GridSortState - * + * * @return sort state */ - public GridSortState getSortState() { - if (sortState == null) { + public GridSortState getSortState() + { + if (sortState == null) + { sortState = new GridSortState(); } return sortState; @@ -487,24 +543,26 @@ public GridSortState getSortState() { private String theme = THEME_VISTA; /** - * Sets the grid theme. Grid theme is used as CSS style class for the grid. - * The theme itself consist of a proper style definition in stylesheet. For - * more information on custom theme creation see the custom theme example. - * + * Sets the grid theme. Grid theme is used as CSS style class for the grid. The theme itself + * consist of a proper style definition in stylesheet. For more information on custom theme + * creation see the custom theme example. + * * @param theme * theme identifier */ - public void setTheme(String theme) { + public void setTheme(String theme) + { this.theme = theme; } /** * Returns the theme identifier - * + * * @return theme identifier * @see #setTheme(String) */ - public String getTheme() { + public String getTheme() + { return theme; } @@ -515,14 +573,17 @@ public String getTheme() { * {@inheritDoc} */ @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); CharSequence klass = tag.getAttribute("class"); - if (klass == null) { + if (klass == null) + { klass = ""; } - if (klass.length() > 0) { + if (klass.length() > 0) + { klass = klass + " "; } @@ -532,27 +593,29 @@ protected void onComponentTag(ComponentTag tag) { tag.put("class", klass); - if (tag.getName().equals("table")) { + if (tag.getName().equals("table")) + { tag.setName("div"); } } - private static final JavaScriptResourceReference JS_YAHOO = new JavaScriptResourceReference(AbstractGrid.class, - "res/yahoo.js"); - private static final JavaScriptResourceReference JS_EVENT = new JavaScriptResourceReference(AbstractGrid.class, - "res/event.js"); - private static final JavaScriptResourceReference JS_DOM = new JavaScriptResourceReference(AbstractGrid.class, - "res/dom.js"); - private static final JavaScriptResourceReference JS_SCRIPT = new JavaScriptResourceReference(AbstractGrid.class, - "res/script.js"); - private static final CompressedResourceReference CSS = new CompressedResourceReference(AbstractGrid.class, - "res/style.css"); + private static final JavaScriptResourceReference JS_YAHOO = new JavaScriptResourceReference( + AbstractGrid.class, "res/yahoo.js"); + private static final JavaScriptResourceReference JS_EVENT = new JavaScriptResourceReference( + AbstractGrid.class, "res/event.js"); + private static final JavaScriptResourceReference JS_DOM = new JavaScriptResourceReference( + AbstractGrid.class, "res/dom.js"); + private static final JavaScriptResourceReference JS_SCRIPT = new JavaScriptResourceReference( + AbstractGrid.class, "res/script.js"); + private static final CompressedResourceReference CSS = new CompressedResourceReference( + AbstractGrid.class, "res/style.css"); /** * {@inheritDoc} */ @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { response.renderJavaScriptReference(WicketEventReference.INSTANCE); response.renderJavaScriptReference(WicketAjaxReference.INSTANCE); response.renderJavaScriptReference(JS_YAHOO); @@ -564,166 +627,174 @@ public void renderHead(IHeaderResponse response) { /** * Alters the selection state of item specified by the item model. - * + * * @param itemModel * item model * @param selected - * true if the item should be selected, - * false otherwise. + * true if the item should be selected, false otherwise. */ public abstract void selectItem(IModel itemModel, boolean selected); /** - * Marks all currently displayed items as selected. For {@link DataGrid} - * this selects all items on current page, for {@link TreeGrid} this selects - * all currently visible nodes. + * Marks all currently displayed items as selected. For {@link DataGrid} this selects all items + * on current page, for {@link TreeGrid} this selects all currently visible nodes. */ public abstract void selectAllVisibleItems(); /** - * Deselects all items. This method marks all items (not just visible items) - * as no selected. + * Deselects all items. This method marks all items (not just visible items) as no selected. */ public abstract void resetSelectedItems(); /** * Queries whether the item specified by itemModel is currently selected. - * + * * @param itemModel * item model - * @return true if the item is selected, false - * otherwise + * @return true if the item is selected, false otherwise */ public abstract boolean isItemSelected(IModel itemModel); /** * Returns the collection of models of all currently selected items. - * + * * @return collection of models of currently selected items */ public abstract Collection getSelectedItems(); /** * Sets whether user will be able to select more than one item. - * + * * @param value - * true if the user will be able to select more - * than one item at a time, false otherwise - * (single selection mode). + * true if the user will be able to select more than one item at a time, + * false otherwise (single selection mode). */ public abstract void setAllowSelectMultiple(boolean value); /** * Returns whether user will be able to select more than one item at a time. - * - * @return true if multiple items can be selected at a time, - * false otherwise. + * + * @return true if multiple items can be selected at a time, false + * otherwise. */ public abstract boolean isAllowSelectMultiple(); /** * During an Ajax request this method updates the changed grid rows. *

- * The definition of "changed" varies in {@link DataGrid} and - * {@link TreeGrid}. + * The definition of "changed" varies in {@link DataGrid} and {@link TreeGrid}. *

    - *
  • In both grids the items for which the selection state changed are - * considered changed. - *
  • In {@link TreeGrid} the changes to {@link TreeModel} itself are - * being tracked (assuming the proper listeners are fired) and all rows that - * need to be updated are also considered changed. - *
  • In {@link DataGrid} the items that need to be updated can be marked - * by {@link DataGrid#markItemDirty(IModel)} or - * {@link DataGrid#markAllItemsDirty()}. The grid itself doesn't track - * changes to specific items (apart from the selection state). + *
  • In both grids the items for which the selection state changed are considered changed. + *
  • In {@link TreeGrid} the changes to {@link TreeModel} itself are being tracked (assuming + * the proper listeners are fired) and all rows that need to be updated are also considered + * changed. + *
  • In {@link DataGrid} the items that need to be updated can be marked by + * {@link DataGrid#markItemDirty(IModel)} or {@link DataGrid#markAllItemsDirty()}. The grid + * itself doesn't track changes to specific items (apart from the selection state). *
*/ public abstract void update(); /** * Invoked when an item selection state has been changed. - * + * * @param item * item model * @param newValue - * true if the item became selected, - * false otherwise. + * true if the item became selected, false otherwise. */ - protected void onItemSelectionChanged(IModel item, boolean newValue) { + protected void onItemSelectionChanged(IModel item, boolean newValue) + { } private String lastClickedColumn = null; - public IGridColumn getLastClickedColumn() { - for (IGridColumn column : columns) { - if (column.getId().equals(lastClickedColumn)) { + public IGridColumn getLastClickedColumn() + { + for (IGridColumn column : columns) + { + if (column.getId().equals(lastClickedColumn)) + { return column; } } return null; } - public void cleanLastClickedColumn() { + public void cleanLastClickedColumn() + { lastClickedColumn = null; }; - protected boolean disableRowClickNotifications() { + protected boolean disableRowClickNotifications() + { return false; } /** - * Called after a grid row has been populated. This method allows adding - * behaviors to grid rows. - * + * Called after a grid row has been populated. This method allows adding behaviors to grid rows. + * * @param rowComponent */ - protected void onRowPopulated(final WebMarkupContainer rowComponent) { + protected void onRowPopulated(final WebMarkupContainer rowComponent) + { if (disableRowClickNotifications()) return; - rowComponent.add(new AjaxFormSubmitBehavior(getForm(), "onclick") { + rowComponent.add(new AjaxFormSubmitBehavior(getForm(), "onclick") + { private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target) { + protected void onSubmit(AjaxRequestTarget target) + { } @Override - protected void onError(AjaxRequestTarget target) { + protected void onError(AjaxRequestTarget target) + { } @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { // preserve the entered values in form components Form form = getForm(); - form.visitFormComponentsPostOrder(new IVisitor, Void>() { + form.visitFormComponentsPostOrder(new IVisitor, Void>() + { - public void component(FormComponent formComponent, - IVisit visit) { - if (formComponent.isVisibleInHierarchy()) { + public void component(FormComponent formComponent, IVisit visit) + { + if (formComponent.isVisibleInHierarchy()) + { formComponent.inputChanged(); } } }); - String column = getRequest().getRequestParameters().getParameterValue("column").toString(); + String column = getRequest().getRequestParameters() + .getParameterValue("column") + .toString(); lastClickedColumn = column; IModel model = rowComponent.getDefaultModel(); IGridColumn lastClickedColumn = getLastClickedColumn(); - if (lastClickedColumn != null) { - if (onCellClicked(target, model, lastClickedColumn) == true) { + if (lastClickedColumn != null) + { + if (onCellClicked(target, model, lastClickedColumn) == true) + { return; } - if (lastClickedColumn.cellClicked(model) == true) { + if (lastClickedColumn.cellClicked(model) == true) + { return; } } @@ -732,21 +803,27 @@ public void component(FormComponent formComponent, } @Override - public CharSequence getCallbackUrl() { + public CharSequence getCallbackUrl() + { return super.getCallbackUrl() + "&column='+col+'"; } @Override - protected IAjaxCallDecorator getAjaxCallDecorator() { - return new AjaxCallDecorator() { + protected IAjaxCallDecorator getAjaxCallDecorator() + { + return new AjaxCallDecorator() + { private static final long serialVersionUID = 1L; @Override - public CharSequence decorateScript(Component c, CharSequence script) { - return super.decorateScript(c, "if (InMethod.XTable.canSelectRow(event)) { " - + "var col=(this.imxtClickedColumn || ''); this.imxtClickedColumn='';" + script - + " }"); + public CharSequence decorateScript(Component c, CharSequence script) + { + return super.decorateScript( + c, + "if (InMethod.XTable.canSelectRow(event)) { " + + "var col=(this.imxtClickedColumn || ''); this.imxtClickedColumn='';" + + script + " }"); } }; } @@ -754,15 +831,19 @@ public CharSequence decorateScript(Component c, CharSequence script) { } - protected boolean onCellClicked(AjaxRequestTarget target, IModel rowModel, IGridColumn column) { + protected boolean onCellClicked(AjaxRequestTarget target, IModel rowModel, IGridColumn column) + { return false; } - protected void onRowClicked(AjaxRequestTarget target, IModel rowModel) { - if (isClickRowToSelect()) { + protected void onRowClicked(AjaxRequestTarget target, IModel rowModel) + { + if (isClickRowToSelect()) + { boolean selected = isItemSelected(rowModel); - if (selected == false || isClickRowToDeselect()) { + if (selected == false || isClickRowToDeselect()) + { selectItem(rowModel, !selected); update(); } @@ -773,49 +854,52 @@ protected void onRowClicked(AjaxRequestTarget target, IModel rowModel) { /** * Sets whether a click on grid row should select/deselect the row. - * + * * @see #setClickRowToDeselect(boolean) * @param clickRowToSelect - * true if the row selection state should be - * changed upon a mouse click, false otherwise. + * true if the row selection state should be changed upon a mouse click, + * false otherwise. * @return this (useful for method chaining) */ - public AbstractGrid setClickRowToSelect(boolean clickRowToSelect) { + public AbstractGrid setClickRowToSelect(boolean clickRowToSelect) + { this.clickRowToSelect = clickRowToSelect; return this; } /** * Returns whether a click on grid row should select/deselect the row. - * - * @return true if the row click should alter the row - * selection state, false otherwise. + * + * @return true if the row click should alter the row selection state, + * false otherwise. */ - public boolean isClickRowToSelect() { + public boolean isClickRowToSelect() + { return clickRowToSelect; } private boolean clickRowToDeselect = true; /** - * Sets whether a click on selected grid row should deselect it. This only - * applies when {@link #setClickRowToSelect(boolean)} is set to - * true. - * + * Sets whether a click on selected grid row should deselect it. This only applies when + * {@link #setClickRowToSelect(boolean)} is set to true. + * * @param clickRowToDeselect * whether clicking a selected row should deselect it */ - public void setClickRowToDeselect(boolean clickRowToDeselect) { + public void setClickRowToDeselect(boolean clickRowToDeselect) + { this.clickRowToDeselect = clickRowToDeselect; } /** * Returns whether clicking a selected row deselects it. - * - * @return true if clicking a selected row deselects it, - * false otherwise. + * + * @return true if clicking a selected row deselects it, false + * otherwise. */ - public boolean isClickRowToDeselect() { + public boolean isClickRowToDeselect() + { return clickRowToDeselect; } @@ -824,50 +908,53 @@ public boolean isClickRowToDeselect() { private SizeUnit contentHeightSizeUnit; /** - * Sets the height of grid content. Content is the part of grid displaying - * the actual data (rows), i.e. it doesn't cover the header part and - * toolbars. When the actual content height is bigger than specified height, - * a vertical scrollbar is displayed. - * + * Sets the height of grid content. Content is the part of grid displaying the actual data + * (rows), i.e. it doesn't cover the header part and toolbars. When the actual content height is + * bigger than specified height, a vertical scrollbar is displayed. + * * @param contentHeight - * desired height of the content or null is the - * height should be determined by the actual height (no scrollbar - * displayed, defalt value) + * desired height of the content or null is the height should be + * determined by the actual height (no scrollbar displayed, defalt value) * @param contentSizeUnit * size unit for the contentHeight */ - public void setContentHeight(Integer contentHeight, SizeUnit contentSizeUnit) { - if (contentHeight != null) { + public void setContentHeight(Integer contentHeight, SizeUnit contentSizeUnit) + { + if (contentHeight != null) + { this.contentHeight = contentHeight; - } else { + } + else + { this.contentHeight = 0; } - this.contentHeightSizeUnit = contentSizeUnit; + contentHeightSizeUnit = contentSizeUnit; } /** * Returns the content height. - * - * @return content height or 0 if the content height should be determined by - * the actual content. + * + * @return content height or 0 if the content height should be determined by the actual content. * @see #setContentHeight(Integer, SizeUnit) */ - public int getContentHeight() { + public int getContentHeight() + { return contentHeight; } /** * Returns the size unit for content height. - * + * * @return size unit */ - public SizeUnit getContentHeightSizeUnit() { + public SizeUnit getContentHeightSizeUnit() + { return contentHeightSizeUnit; } /** * Returns the row in DataTable that contains the child component - * + * * @param child * @return */ @@ -875,16 +962,16 @@ public SizeUnit getContentHeightSizeUnit() { /** * Returns the row component for specified item. - * + * * @param rowModel * @return */ protected abstract WebMarkupContainer findRowComponent(IModel rowModel); /** - * Marks the item from the given model as dirty. Dirty items are updated - * during Ajax requests when {@link AbstractGrid#update()} method is called. - * + * Marks the item from the given model as dirty. Dirty items are updated during Ajax requests + * when {@link AbstractGrid#update()} method is called. + * * @param itemModel * model used to access the item */ @@ -893,50 +980,58 @@ public SizeUnit getContentHeightSizeUnit() { private boolean selectToEdit = false; /** - * Determines whether selected items should also be editable. This should be - * set to false when the grid is both selectable and editable - * (independently). - * + * Determines whether selected items should also be editable. This should be set to + * false when the grid is both selectable and editable (independently). + * * @param selectToEdit * whether selected rows should be editable */ - public void setSelectToEdit(boolean selectToEdit) { + public void setSelectToEdit(boolean selectToEdit) + { this.selectToEdit = selectToEdit; } /** * Returns whether selected rows are also editable. - * + * * @return */ - public boolean isSelectToEdit() { + public boolean isSelectToEdit() + { return selectToEdit; } - private final static MetaDataKey EDITING = new MetaDataKey() { + private final static MetaDataKey EDITING = new MetaDataKey() + { private static final long serialVersionUID = 1L; }; /** - * Sets the edit mode of the row. If selectToEdit is true, this is same as - * calling {@link #selectItem(IModel, boolean)}. - * + * Sets the edit mode of the row. If selectToEdit is true, this is same as calling + * {@link #selectItem(IModel, boolean)}. + * * @see #setSelectToEdit(boolean) - * + * * @param rowModel * row model * @param edit - * true if the row should be in editable mode, - * false otherwise. + * true if the row should be in editable mode, false + * otherwise. */ - public void setItemEdit(IModel rowModel, boolean edit) { - if (isSelectToEdit()) { + public void setItemEdit(IModel rowModel, boolean edit) + { + if (isSelectToEdit()) + { selectItem(rowModel, edit); - } else { + } + else + { WebMarkupContainer rowComponent = findRowComponent(rowModel); - if (rowComponent != null) { + if (rowComponent != null) + { boolean editing = Boolean.TRUE.equals(rowComponent.getMetaData(EDITING)); - if (editing != edit) { + if (editing != edit) + { rowComponent.setMetaData(EDITING, edit); markItemDirty(rowModel); } @@ -946,19 +1041,25 @@ public void setItemEdit(IModel rowModel, boolean edit) { /** * Returns whether the row is in editable mode. - * + * * @param rowModel - * @return true if the row is in editable mode, - * false otherwise. + * @return true if the row is in editable mode, false otherwise. */ - public boolean isItemEdited(IModel rowModel) { - if (isSelectToEdit()) { + public boolean isItemEdited(IModel rowModel) + { + if (isSelectToEdit()) + { return isItemSelected(rowModel); - } else { + } + else + { WebMarkupContainer rowComponent = findRowComponent(rowModel); - if (rowComponent != null) { + if (rowComponent != null) + { return Boolean.TRUE.equals(rowComponent.getMetaData(EDITING)); - } else { + } + else + { return false; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGridRow.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGridRow.java index 93dbcffc0a..01226887ef 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGridRow.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractGridRow.java @@ -20,46 +20,55 @@ /** * Represents container of cell items in one row. - * + * * @author Matej Knopp */ -public abstract class AbstractGridRow extends WebMarkupContainer { +public abstract class AbstractGridRow extends WebMarkupContainer +{ private static final long serialVersionUID = 1L; /** * Constructor + * * @param id * @param model */ - public AbstractGridRow(String id, IModel model) { + public AbstractGridRow(String id, IModel model) + { super(id, model); } @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { // make sure that the child component match currently active columns Collection activeColumns = getActiveColumns(); // remove unneeded components - for (Iterator i = iterator(); i.hasNext();) { - Component component = (Component) i.next(); - if (isComponentNeeded(component.getId(), activeColumns) == false) { + for (Iterator i = iterator(); i.hasNext();) + { + Component component = (Component)i.next(); + if (isComponentNeeded(component.getId(), activeColumns) == false) + { i.remove(); } } List components = new ArrayList(activeColumns.size()); // create components that might be needed - for (IGridColumn column : activeColumns) { + for (IGridColumn column : activeColumns) + { String componentId = componentId(column.getId()); Component component = null; - if (!column.isLightWeight(getDefaultModel()) && (component = get(componentId)) == null) { + if (!column.isLightWeight(getDefaultModel()) && (component = get(componentId)) == null) + { component = column.newCell(this, componentId, getDefaultModel()); add(component); } - if (component != null) { + if (component != null) + { components.add(component); } } @@ -67,9 +76,12 @@ protected void onBeforeRender() { super.onBeforeRender(); // delay adding the actual behaviors - for (Component component : components) { - for (IGridColumn column : activeColumns) { - if (component.getId().equals(componentId(column.getId()))) { + for (Component component : components) + { + for (IGridColumn column : activeColumns) + { + if (component.getId().equals(componentId(column.getId()))) + { component.add(new InnerDivClassBehavior(column)); } } @@ -79,24 +91,30 @@ protected void onBeforeRender() { /** * Returns true if the column is currently being the one sorted with highest priority (i.e. the * most recent one the user clicked) - * + * * @param column * @return */ - private boolean isColumnBeingSorted(IGridColumn column) { - if (column.getSortProperty() != null) { + private boolean isColumnBeingSorted(IGridColumn column) + { + if (column.getSortProperty() != null) + { AbstractGrid dataGrid = findParent(AbstractGrid.class); IGridSortState sortState = dataGrid.getSortState(); - return (sortState.getColumns().size() > 0 && sortState.getColumns().get(0).getPropertyName().equals( - column.getSortProperty())); - } else { + return (sortState.getColumns().size() > 0 && sortState.getColumns() + .get(0) + .getPropertyName() + .equals(column.getSortProperty())); + } + else + { return false; } } /** * Renders the table cell opening tag. - * + * * @param column * @param i * column index in row @@ -107,21 +125,27 @@ private boolean isColumnBeingSorted(IGridColumn column) { * set) * @return */ - private int renderOpenTag(IGridColumn column, int i, int columnsSize, Response response, int hide) { + private int renderOpenTag(IGridColumn column, int i, int columnsSize, Response response, + int hide) + { int originalColspan = column.getColSpan(getDefaultModel()); int colspan = originalColspan; // render the opening tag - if (hide > 0) { + if (hide > 0) + { response.write(" max) colspan = max; - if (colspan > 1) { + if (colspan > 1) + { response.write(" colspan=\"" + colspan + "\""); hide = colspan - 1; } @@ -135,19 +159,22 @@ private int renderOpenTag(IGridColumn column, int i, int columnsSize, Response r String klass = column.getCellCssClass(getDefaultModel(), getRowNumber()); - if (klass != null) { + if (klass != null) + { css.append(" "); css.append(klass); } // the original colspan is used when reordering columns by javascript - if (originalColspan > 1) { + if (originalColspan > 1) + { css.append(" imxt-colspan-"); css.append(originalColspan); } // flag indicatign that the column is being sorted - if (isColumnBeingSorted(column)) { + if (isColumnBeingSorted(column)) + { css.append(" imxt-sorted"); } @@ -161,16 +188,18 @@ private int renderOpenTag(IGridColumn column, int i, int columnsSize, Response r /** * Behavior that sets the css class attribute to of the actual cell component. This behavior is * temporary (only lasts during render) and it's re-added on every request in onBeforeRender. - * + * * @author Matej Knopp */ - private class InnerDivClassBehavior extends Behavior { + private class InnerDivClassBehavior extends Behavior + { private static final long serialVersionUID = 1L; private final IGridColumn column; - private InnerDivClassBehavior(IGridColumn column) { + private InnerDivClassBehavior(IGridColumn column) + { this.column = column; } @@ -178,7 +207,8 @@ private InnerDivClassBehavior(IGridColumn column) { * {@inheritDoc} */ @Override - public void onComponentTag(Component component, ComponentTag tag) { + public void onComponentTag(Component component, ComponentTag tag) + { CharSequence klass = tag.getAttribute("class"); if (klass == null) klass = ""; @@ -192,7 +222,8 @@ public void onComponentTag(Component component, ComponentTag tag) { * {@inheritDoc} */ @Override - public boolean isTemporary(Component c) { + public boolean isTemporary(Component c) + { return true; } }; @@ -200,14 +231,18 @@ public boolean isTemporary(Component c) { /** * Returns the css class of cell component (which is attached to the first div element inside * the <td>) - * + * * @param column * @return */ - private String getInnerDivClass(IGridColumn column) { - if (column.getWrapText()) { + private String getInnerDivClass(IGridColumn column) + { + if (column.getWrapText()) + { return "imxt-a imxt-wrap"; - } else { + } + else + { return "imxt-a imxt-nowrap"; } } @@ -216,7 +251,8 @@ private String getInnerDivClass(IGridColumn column) { * Renders the actual cell components (or {@link IRenderable} instances). */ @Override - protected void onRender() { + protected void onRender() + { Response response = RequestCycle.get().getResponse(); @@ -224,25 +260,31 @@ protected void onRender() { int hide = 0; int i = 0; - for (IGridColumn column : columns) { + for (IGridColumn column : columns) + { hide = renderOpenTag(column, i, columns.size(), response, hide); - if (column.isLightWeight(getDefaultModel())) { + if (column.isLightWeight(getDefaultModel())) + { // for lightweight columns get the renderable instance and render it IRenderable renderable = column.newCell(getDefaultModel()); - if (renderable == null) { + if (renderable == null) + { throw new IllegalStateException( - "Lightweight columns must return valid IRenderable instance in newCell(IModel model)"); + "Lightweight columns must return valid IRenderable instance in newCell(IModel model)"); } response.write("
"); renderable.render(getDefaultModel(), response); response.write("
"); - } else { + } + else + { // for non-lightweight components get the actual component and render it Component component = get(column.getId()); - if (component == null) { + if (component == null) + { throw new IllegalStateException("Column ID has changed during rendering"); } IMarkupFragment componentMarkup = getMarkup(); @@ -255,7 +297,8 @@ protected void onRender() { } } - private String componentId(String columnId) { + private String componentId(String columnId) + { return columnId; } @@ -265,13 +308,19 @@ private String componentId(String columnId) { /** * Returns whether a component with given is needed for any of the columns. + * * @param componentId * @param activeColumns * @return */ - private boolean isComponentNeeded(final String componentId, Collection activeColumns) { - for (IGridColumn column : activeColumns) { - if (componentId(column.getId()).equals(componentId) && !column.isLightWeight(getDefaultModel())) { + private boolean isComponentNeeded(final String componentId, + Collection activeColumns) + { + for (IGridColumn column : activeColumns) + { + if (componentId(column.getId()).equals(componentId) && + !column.isLightWeight(getDefaultModel())) + { return true; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractPageableView.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractPageableView.java index 63885ff8d9..895d850de0 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractPageableView.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AbstractPageableView.java @@ -20,7 +20,8 @@ * * @author Matej Knopp */ -public abstract class AbstractPageableView extends RefreshingView implements IPageable { +public abstract class AbstractPageableView extends RefreshingView implements IPageable +{ private static final long serialVersionUID = 1L; @@ -30,7 +31,8 @@ public abstract class AbstractPageableView extends RefreshingView implements IPa * @param id * @param model */ - public AbstractPageableView(String id, IModel model) { + public AbstractPageableView(String id, IModel model) + { super(id, model); } @@ -39,7 +41,8 @@ public AbstractPageableView(String id, IModel model) { * * @param id */ - public AbstractPageableView(String id) { + public AbstractPageableView(String id) + { super(id); } @@ -54,7 +57,8 @@ public AbstractPageableView(String id) { * * @return total count of items or {@value #UNKOWN_COUNT} */ - public int getTotalRowCount() { + public int getTotalRowCount() + { initialize(); return realItemCount; @@ -65,7 +69,8 @@ public int getTotalRowCount() { * * @return count of items on current page */ - public int getCurrentPageItemCount() { + public int getCurrentPageItemCount() + { initialize(); return queryResult.itemCache.size(); @@ -77,12 +82,16 @@ public int getCurrentPageItemCount() { * * @return total number of items */ - private int getItemCount() { + private int getItemCount() + { initialize(); - if (realItemCount == UNKOWN_COUNT) { + if (realItemCount == UNKOWN_COUNT) + { return maxFirstItemReached + getRowsPerPage() + 1; - } else { + } + else + { return realItemCount; } } @@ -90,32 +99,38 @@ private int getItemCount() { /** * @return The current page that is or will be rendered. */ - public int getCurrentPage() { + public int getCurrentPage() + { return getCurrentPageFirstItem() / getRowsPerPage(); } @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { cachedPageCount = -1; - - super.onBeforeRender(); + + super.onBeforeRender(); } - + // we cache page count because paging navigator needs it even when items are not loaded private int cachedPageCount = -1; - + /** * Gets the total number of pages this pageable object has. * * @return The total number of pages this pageable object has */ - public int getPageCount() { + public int getPageCount() + { if (cachedPageCount == -1) { int count = getItemCount(); - if (count == 0) { + if (count == 0) + { cachedPageCount = 0; - } else { + } + else + { // if current item count is not dividable by the page size, subtract the mod int rowsPerPage = getRowsPerPage(); int mod = count % rowsPerPage; @@ -123,9 +138,9 @@ public int getPageCount() { // get the actual page count cachedPageCount = (count / rowsPerPage) + (mod > 0 ? 1 : 0); - } + } } - return cachedPageCount; + return cachedPageCount; } /** @@ -134,10 +149,12 @@ public int getPageCount() { * @param page * The page that should be rendered. */ - public void setCurrentPage(int page) { + public void setCurrentPage(int page) + { int pageCount = getPageCount(); - if (page < 0 || (page >= pageCount && pageCount > 0)) { + if (page < 0 || (page >= pageCount && pageCount > 0)) + { throw new IndexOutOfBoundsException("Argument page is out of bounds"); } @@ -157,8 +174,8 @@ public void setCurrentPage(int page) { /** * The actual count of items. This is set by either passing actual count of items to - * {@link IQueryResult#setTotalCount(int)}, or by passing the - * {@link IQueryResult#NO_MORE_ITEMS} constant as item count. + * {@link IQueryResult#setTotalCount(int)}, or by passing the {@link IQueryResult#NO_MORE_ITEMS} + * constant as item count. */ private int realItemCount = UNKOWN_COUNT; @@ -178,15 +195,18 @@ public void setCurrentPage(int page) { * @param original * @return */ - protected IQuery wrapQuery(IQuery original) { + protected IQuery wrapQuery(IQuery original) + { return original; } /** * Loads the {@link #queryResult} and initializes it if it's not already loaded. */ - private void initialize() { - if (queryResult == null) { + private void initialize() + { + if (queryResult == null) + { queryResult = new QueryResult(); Query query = new Query(queryResult); @@ -201,15 +221,18 @@ private void initialize() { queryResult.process(dataSource); // check for situation when we didn't get any items, but we know the real count - // this is not a case when there are no items at all, just the case when there are no items on current page + // this is not a case when there are no items at all, just the case when there are no +// items on current page // but possible items on previous pages - if (queryResult.itemCache.size() == 0 && realItemCount != UNKOWN_COUNT && - realItemCount != oldItemCount && realItemCount > 0) { - + if (queryResult.itemCache.size() == 0 && realItemCount != UNKOWN_COUNT && + realItemCount != oldItemCount && realItemCount > 0) + { + // the data must have changed, the number of items has been reduced. try move to // last page int page = getPageCount() - 1; - if (page < 0) { + if (page < 0) + { page = 0; } setCurrentPage(page); @@ -227,9 +250,9 @@ private void initialize() { else if (realItemCount == 0) { // this is the case with no items at all - QueryResult tmp = this.queryResult; + QueryResult tmp = queryResult; setCurrentPage(0); - this.queryResult = tmp; + queryResult = tmp; } } } @@ -238,17 +261,20 @@ else if (realItemCount == 0) * @see IQuery * @author Matej Knopp */ - private class Query implements IQuery { + private class Query implements IQuery + { QueryResult result; - private Query(QueryResult result) { + private Query(QueryResult result) + { this.result = result; } /** * {@inheritDoc} */ - public int getCount() { + public int getCount() + { int totalCount = getTotalCount(); int rowsPerPage = getRowsPerPage(); @@ -256,9 +282,12 @@ public int getCount() { // we try to get the real count (user might have called // IQueryResult.setTotalCount before calling getCount final int count; - if (totalCount != UNKOWN_COUNT) { + if (totalCount != UNKOWN_COUNT) + { count = Math.min(totalCount - getFrom(), rowsPerPage); - } else { + } + else + { // otherwise just return the number of rows per page count = rowsPerPage; } @@ -268,21 +297,24 @@ public int getCount() { /** * {@inheritDoc} */ - public int getFrom() { + public int getFrom() + { return getCurrentPageFirstItem(); } /** * {@inheritDoc} */ - public IGridSortState getSortState() { + public IGridSortState getSortState() + { return AbstractPageableView.this.getSortState(); } /** * {@inheritDoc} */ - public int getTotalCount() { + public int getTotalCount() + { return result.totalCount; } }; @@ -294,25 +326,29 @@ public int getTotalCount() { * * @param */ - private static class EmptyIterator implements Iterator { + private static class EmptyIterator implements Iterator + { /** * {@inheritDoc} */ - public boolean hasNext() { + public boolean hasNext() + { return false; } /** * {@inheritDoc} */ - public T next() { + public T next() + { throw new IndexOutOfBoundsException(); } /** * {@inheritDoc} */ - public void remove() { + public void remove() + { throw new UnsupportedOperationException(); } @@ -324,12 +360,13 @@ public void remove() { * * @author Matej Knopp */ - private class QueryResult implements IQueryResult { + private class QueryResult implements IQueryResult + { // start with empty items private Iterator items = EmptyIterator.INSTANCE; // and actual total count (could be UNKNOWN) - private int totalCount = AbstractPageableView.this.realItemCount; + private int totalCount = realItemCount; // process will put the actual item model's here private ArrayList itemCache = new ArrayList(); @@ -337,15 +374,17 @@ private class QueryResult implements IQueryResult { /** * @see IQueryResult#setItems(Iterator) */ - public void setItems(Iterator items) { + public void setItems(Iterator items) + { this.items = items; } /** * @see IQueryResult#setTotalCount(int) */ - public void setTotalCount(int count) { - this.totalCount = count; + public void setTotalCount(int count) + { + totalCount = count; } /** @@ -354,36 +393,45 @@ public void setTotalCount(int count) { * * @param source */ - public void process(IDataSource source) { + public void process(IDataSource source) + { // count the maximum number of items that should have been loaded int max = getRowsPerPage(); - if (totalCount > 0) { + if (totalCount > 0) + { max = Math.min(max, totalCount - getCurrentPageFirstItem()); } // wrap the loaded items as IModels and add them to itemCache - while (max > 0 && items.hasNext()) { + while (max > 0 && items.hasNext()) + { itemCache.add(source.model(items.next())); --max; } - if (itemCache.size() == 0 && totalCount < 0) { + if (itemCache.size() == 0 && totalCount < 0) + { // in case no items have been loaded // this is to have the last page displayed in paging navigator totalCount = getCurrentPageFirstItem() + 1; - } else if (totalCount == IQueryResult.NO_MORE_ITEMS) { + } + else if (totalCount == IQueryResult.NO_MORE_ITEMS) + { // if the reported count was NO_MORE_RESULT, these are all items // we can get, thus the totalCount can be counted properly totalCount = getCurrentPageFirstItem() + itemCache.size(); } - if (totalCount == IQueryResult.MORE_ITEMS && getCurrentPage() != getPageCount() - && AbstractPageableView.this.realItemCount != UNKOWN_COUNT) { + if (totalCount == IQueryResult.MORE_ITEMS && getCurrentPage() != getPageCount() && + realItemCount != UNKOWN_COUNT) + { // if we know the real item count and the page shown is not last page, we // don't allow MORE_ITEMS overwrite the real item count - } else { + } + else + { // update the real item count - AbstractPageableView.this.realItemCount = totalCount; + realItemCount = totalCount; } } }; @@ -392,7 +440,8 @@ public void process(IDataSource source) { * Cleanup */ @Override - protected void onDetach() { + protected void onDetach() + { super.onDetach(); queryResult = null; } @@ -407,7 +456,8 @@ protected void onDetach() { * @see RefreshingView#getItemModels() */ @Override - protected Iterator getItemModels() { + protected Iterator getItemModels() + { initialize(); return queryResult.itemCache.iterator(); } @@ -417,19 +467,23 @@ protected Iterator getItemModels() { * * @param currentItem */ - private void setCurrentPageFirstItem(int currentItem) { - if (this.currentPageFirstItem != currentItem) { + private void setCurrentPageFirstItem(int currentItem) + { + if (currentPageFirstItem != currentItem) + { - if (maxFirstItemReached < currentItem) { + if (maxFirstItemReached < currentItem) + { maxFirstItemReached = currentItem; } - this.currentPageFirstItem = currentItem; - this.queryResult = null; + currentPageFirstItem = currentItem; + queryResult = null; } } - private int getCurrentPageFirstItem() { + private int getCurrentPageFirstItem() + { int rowsPerPage = getRowsPerPage(); return currentPageFirstItem - (currentPageFirstItem % rowsPerPage); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AttachPrelightBehavior.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AttachPrelightBehavior.java index f9e1930674..d27cf5b060 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AttachPrelightBehavior.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/AttachPrelightBehavior.java @@ -16,18 +16,21 @@ * * @author Matej Knopp */ -public final class AttachPrelightBehavior extends Behavior { +public final class AttachPrelightBehavior extends Behavior +{ private static final long serialVersionUID = 1L; /** * {@inheritDoc} */ @Override - public void afterRender(Component component) { - WebRequest request = (WebRequest) RequestCycle.get().getRequest(); + public void afterRender(Component component) + { + WebRequest request = (WebRequest)RequestCycle.get().getRequest(); Response response = RequestCycle.get().getResponse(); AbstractGrid grid = component.findParent(AbstractGrid.class); - if (request.isAjax() && !grid.isRendering()) { + if (request.isAjax() && !grid.isRendering()) + { JavaScriptUtils.writeOpenTag(response); response.write("var e = Wicket.$('" + component.getMarkupId() + "');"); response.write("var id = '" + grid.getMarkupId() + "';"); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeader.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeader.java index a517dc2a77..e805718cf1 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeader.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeader.java @@ -10,48 +10,55 @@ /** * Panel that provides the markup for {@link ColumnsHeaderRepeater}. * - * @see ColumnsHeaderRepeater + * @see ColumnsHeaderRepeater * @author Matej Knopp */ -public abstract class ColumnsHeader extends Panel { +public abstract class ColumnsHeader extends Panel +{ private static final long serialVersionUID = 1L; /** * Constructor. + * * @param id */ - public ColumnsHeader(String id) { + public ColumnsHeader(String id) + { super(id); setRenderBodyOnly(true); - - add(new ColumnsHeaderRepeater("header") { + + add(new ColumnsHeaderRepeater("header") + { private static final long serialVersionUID = 1L; @Override - Collection getActiveColumns() { + Collection getActiveColumns() + { return ColumnsHeader.this.getActiveColumns(); } @Override - int getColumnWidth(IGridColumn column) { + int getColumnWidth(IGridColumn column) + { return ColumnsHeader.this.getColumnWidth(column); } - + @Override - protected void sortStateChanged(AjaxRequestTarget target) { + protected void sortStateChanged(AjaxRequestTarget target) + { ColumnsHeader.this.sortStateChanged(target); } - + }); } - + abstract protected void sortStateChanged(AjaxRequestTarget target); abstract Collection getActiveColumns(); - + abstract int getColumnWidth(IGridColumn column); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeaderRepeater.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeaderRepeater.java index 8bc9a311c3..d86f2b120b 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeaderRepeater.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsHeaderRepeater.java @@ -22,15 +22,18 @@ * * @author Matej Knopp */ -public abstract class ColumnsHeaderRepeater extends WebMarkupContainer { +public abstract class ColumnsHeaderRepeater extends WebMarkupContainer +{ private static final long serialVersionUID = 1L; /** * Constructor. + * * @param id */ - public ColumnsHeaderRepeater(String id) { + public ColumnsHeaderRepeater(String id) + { super(id); } @@ -38,42 +41,55 @@ public ColumnsHeaderRepeater(String id) { * {@inheritDoc} */ @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { // make sure that the child components match the columns // remove unneeded components - for (Iterator i = iterator(); i.hasNext();) { - Component component = (Component) i.next(); - if (isComponentNeeded(component.getId()) == false) { + for (Iterator i = iterator(); i.hasNext();) + { + Component component = (Component)i.next(); + if (isComponentNeeded(component.getId()) == false) + { i.remove(); } } // create components that might be needed - for (IGridColumn column : getActiveColumns()) { + for (IGridColumn column : getActiveColumns()) + { String componentId = componentId(column.getId()); - if (get(componentId) == null) { // if there is no component for given column, create it + if (get(componentId) == null) + { // if there is no component for given column, create it - if (column.getSortProperty() == null) { + if (column.getSortProperty() == null) + { // for non sortable properties just add the component Component component = column.newHeader(componentId); - if (component.getId().equals(componentId) == false) { + if (component.getId().equals(componentId) == false) + { throw new IllegalStateException("Invalid header component ID."); } add(component); - } else { + } + else + { // for sortable properties place the component inside SortableHeaderLinkPanel - SortableHeaderLinkPanel panel = new SortableHeaderLinkPanel(componentId, column.getSortProperty()) { + SortableHeaderLinkPanel panel = new SortableHeaderLinkPanel(componentId, + column.getSortProperty()) + { private static final long serialVersionUID = 1L; @Override - protected void sortStateChanged(AjaxRequestTarget target) { + protected void sortStateChanged(AjaxRequestTarget target) + { ColumnsHeaderRepeater.this.sortStateChanged(target); } }; Component component = column.newHeader(SortableHeaderLinkPanel.COMPONENT_ID); - if (component.getId().equals(SortableHeaderLinkPanel.COMPONENT_ID) == false) { + if (component.getId().equals(SortableHeaderLinkPanel.COMPONENT_ID) == false) + { throw new IllegalStateException("Invalid header component ID."); } panel.add(component); @@ -85,56 +101,69 @@ protected void sortStateChanged(AjaxRequestTarget target) { } abstract protected void sortStateChanged(AjaxRequestTarget target); - - private GridSortState getSortState() { + + private GridSortState getSortState() + { return (findParent(AbstractGrid.class)).getSortState(); } /** * Returns the sort direction for this panel. + * * @return */ - private IGridSortState.Direction getSortDirection(IGridColumn column) { + private IGridSortState.Direction getSortDirection(IGridColumn column) + { IGridSortState state = getSortState(); - // we are interested only in the column with highest priority and it must match this panel's sort property - if (state.getColumns().size() > 0 && state.getColumns().get(0).getPropertyName().equals(column.getSortProperty())) { + // we are interested only in the column with highest priority and it must match this panel's +// sort property + if (state.getColumns().size() > 0 && + state.getColumns().get(0).getPropertyName().equals(column.getSortProperty())) + { return state.getColumns().get(0).getDirection(); - } else { + } + else + { return null; } } @Override - protected void onRender() { - + protected void onRender() + { + Response response = RequestCycle.get().getResponse(); Collection columns = getActiveColumns(); - for (IGridColumn column : columns) { - // render the table header opening tag with proper width + for (IGridColumn column : columns) + { + // render the table header opening tag with proper width response.write(""); - + // render the inner divs response.write("
"); response.write("
"); // render the actual component Component component = get(componentId(column.getId())); - if (component == null) { + if (component == null) + { throw new IllegalStateException("Column ID has changed during rendering"); } IMarkupFragment componentMarkup = getParent().getParent().getMarkup(); @@ -143,9 +172,10 @@ protected void onRender() { // render closing tag response.write("
"); - + // if resizable, render the handle - if (column.isResizable()) { + if (column.isResizable()) + { response.write(""); } response.write("
"); @@ -153,20 +183,25 @@ protected void onRender() { } /** - * Returns whether a component with given is needed for any of the columns. + * Returns whether a component with given is needed for any of the columns. + * * @param componentId * @return */ - private boolean isComponentNeeded(final String componentId) { - for (IGridColumn column : getActiveColumns()) { - if (componentId(column.getId()).equals(componentId)) { + private boolean isComponentNeeded(final String componentId) + { + for (IGridColumn column : getActiveColumns()) + { + if (componentId(column.getId()).equals(componentId)) + { return true; } } return false; } - private String componentId(String columnId) { + private String componentId(String columnId) + { return columnId.replace(".", "-"); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsState.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsState.java index 7456184f7d..b14914d272 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsState.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/ColumnsState.java @@ -17,7 +17,8 @@ * * @author Matej Knopp */ -public class ColumnsState implements IClusterable { +public class ColumnsState implements IClusterable +{ private static final long serialVersionUID = 1L; @@ -26,7 +27,8 @@ public class ColumnsState implements IClusterable { * * @author Matej Knopp */ - public class Entry implements IClusterable { + public class Entry implements IClusterable + { private static final long serialVersionUID = 1L; @@ -39,7 +41,8 @@ public class Entry implements IClusterable { * * @param columnId */ - public Entry(String columnId) { + public Entry(String columnId) + { this.columnId = columnId; } @@ -49,7 +52,8 @@ public Entry(String columnId) { * * @return current column width */ - public int getCurrentWidth() { + public int getCurrentWidth() + { return currentWidth; } @@ -59,7 +63,8 @@ public int getCurrentWidth() { * * @param currentWidth */ - public void setCurrentWidth(int currentWidth) { + public void setCurrentWidth(int currentWidth) + { this.currentWidth = currentWidth; } @@ -68,7 +73,8 @@ public void setCurrentWidth(int currentWidth) { * * @return true if the column is visible, false otherwise. */ - public boolean isVisible() { + public boolean isVisible() + { return visible; } @@ -77,7 +83,8 @@ public boolean isVisible() { * * @param visible */ - public void setVisible(boolean visible) { + public void setVisible(boolean visible) + { this.visible = visible; } @@ -86,7 +93,8 @@ public void setVisible(boolean visible) { * * @return column id */ - public String getColumnId() { + public String getColumnId() + { return columnId; }; }; @@ -99,10 +107,12 @@ public String getColumnId() { * * @param columns */ - public ColumnsState(Collection columns) { + public ColumnsState(Collection columns) + { stateArray = new Entry[columns.size()]; int i = 0; - for (IGridColumn column : columns) { + for (IGridColumn column : columns) + { stateArray[i] = new Entry(column.getId()); ++i; } @@ -114,8 +124,9 @@ public ColumnsState(Collection columns) { * * @param columnStates */ - public ColumnsState(Entry[] columnStates) { - this.stateArray = columnStates; + public ColumnsState(Entry[] columnStates) + { + stateArray = columnStates; } /** @@ -124,9 +135,12 @@ public ColumnsState(Entry[] columnStates) { * @param id * @return */ - private int getEntryIndex(String id) { - for (int i = 0; i < stateArray.length; ++i) { - if (stateArray[i].getColumnId().equals(id)) { + private int getEntryIndex(String id) + { + for (int i = 0; i < stateArray.length; ++i) + { + if (stateArray[i].getColumnId().equals(id)) + { return i; } } @@ -141,7 +155,8 @@ private int getEntryIndex(String id) { * column id * @return entry or null */ - public Entry getEntry(String id) { + public Entry getEntry(String id) + { int i = getEntryIndex(id); return i != -1 ? stateArray[i] : null; } @@ -152,10 +167,13 @@ public Entry getEntry(String id) { * @param id * @return */ - private Entry getColumnStateChecked(String id) { + private Entry getColumnStateChecked(String id) + { Entry state = getEntry(id); - if (state == null) { - throw new IllegalArgumentException("Column state for column with id '" + id + "' not found."); + if (state == null) + { + throw new IllegalArgumentException("Column state for column with id '" + id + + "' not found."); } return state; } @@ -168,7 +186,8 @@ private Entry getColumnStateChecked(String id) { * @param newWidth * new width or -1 if initial column width should be used */ - public void setColumnWidth(String id, int newWidth) { + public void setColumnWidth(String id, int newWidth) + { Entry state = getColumnStateChecked(id); state.setCurrentWidth(newWidth); } @@ -180,7 +199,8 @@ public void setColumnWidth(String id, int newWidth) { * column id * @return column width or -1 if initial width should be used */ - public int getColumnWidth(String id) { + public int getColumnWidth(String id) + { Entry state = getColumnStateChecked(id); return state.getCurrentWidth(); } @@ -192,7 +212,8 @@ public int getColumnWidth(String id) { * column id * @param newValue */ - public void setColumnVisibility(String id, boolean newValue) { + public void setColumnVisibility(String id, boolean newValue) + { Entry state = getColumnStateChecked(id); state.setVisible(newValue); } @@ -204,7 +225,8 @@ public void setColumnVisibility(String id, boolean newValue) { * column id * @return true if the column is visible, false otherwise */ - public boolean getColumnVisibility(String id) { + public boolean getColumnVisibility(String id) + { Entry state = getColumnStateChecked(id); return state.isVisible(); } @@ -214,7 +236,8 @@ public boolean getColumnVisibility(String id) { * * @return collection of {@link Entry} instances */ - public Collection getColumnStates() { + public Collection getColumnStates() + { return Arrays.asList(stateArray); } @@ -228,23 +251,32 @@ public Collection getColumnStates() { * @param newIndex * new column index */ - public void setColumnIndex(String id, int newIndex) { + public void setColumnIndex(String id, int newIndex) + { int index = getEntryIndex(id); - if (index == -1) { - throw new IllegalArgumentException("Column state for column with id '" + id + "' not found."); + if (index == -1) + { + throw new IllegalArgumentException("Column state for column with id '" + id + + "' not found."); } - if (newIndex < 0 || newIndex > stateArray.length - 1) { + if (newIndex < 0 || newIndex > stateArray.length - 1) + { throw new IndexOutOfBoundsException("'newIndex' parameter is out of range."); } - if (newIndex > index) { + if (newIndex > index) + { Entry source = stateArray[index]; - for (int i = index; i < newIndex; ++i) { + for (int i = index; i < newIndex; ++i) + { stateArray[i] = stateArray[i + 1]; } stateArray[newIndex] = source; - } else if (newIndex < index) { + } + else if (newIndex < index) + { Entry source = stateArray[index]; - for (int i = index; i > newIndex; --i) { + for (int i = index; i > newIndex; --i) + { stateArray[i] = stateArray[i - 1]; } stateArray[newIndex] = source; @@ -253,11 +285,13 @@ public void setColumnIndex(String id, int newIndex) { /** * Returns deep copy of the object. + * * @return {@link ColumnsState} instance that is a deep copy of this instance */ @Override - public ColumnsState clone() { - return (ColumnsState) WicketObjects.cloneObject(this); + public ColumnsState clone() + { + return (ColumnsState)WicketObjects.cloneObject(this); } /** @@ -266,12 +300,16 @@ public ColumnsState clone() { * @param columns * @return */ - boolean matches(Collection columns) { - if (stateArray.length != columns.size()) { + boolean matches(Collection columns) + { + if (stateArray.length != columns.size()) + { return false; } - for (IGridColumn column : columns) { - if (getEntryIndex(column.getId()) == -1) { + for (IGridColumn column : columns) + { + if (getEntryIndex(column.getId()) == -1) + { return false; } } @@ -283,18 +321,22 @@ boolean matches(Collection columns) { * * @param state */ - void updateColumnsState(String state) { + void updateColumnsState(String state) + { // state is in format "columnId,width;columnId,width..." // columns not specified in state will not be touched List entries = new ArrayList(); Set indices = new TreeSet(); String segments[] = state.split(";"); - for (String segment : segments) { + for (String segment : segments) + { String parts[] = segment.split(","); - if (parts.length == 2) { + if (parts.length == 2) + { int index = getEntryIndex(parts[0]); - if (index != -1) { + if (index != -1) + { Entry entry = stateArray[index]; entry.setCurrentWidth(Integer.parseInt(parts[1])); entries.add(entry); @@ -304,7 +346,8 @@ void updateColumnsState(String state) { } int i = 0; - for (Integer index : indices) { + for (Integer index : indices) + { stateArray[index] = entries.get(i); ++i; } @@ -317,9 +360,12 @@ void updateColumnsState(String state) { * @param columns * @return */ - private IGridColumn getColumn(String id, Collection columns) { - for (IGridColumn column : columns) { - if (column.getId().equals(id)) { + private IGridColumn getColumn(String id, Collection columns) + { + for (IGridColumn column : columns) + { + if (column.getId().equals(id)) + { return column; } } @@ -334,12 +380,16 @@ private IGridColumn getColumn(String id, Collection columns) { * Collection to be filtered. * @return Collection of columns with visibility set to true. */ - public Collection getVisibleColumns(Collection allColumns) { + public Collection getVisibleColumns(Collection allColumns) + { List result = new ArrayList(); - for (Entry state : stateArray) { - if (state.isVisible()) { + for (Entry state : stateArray) + { + if (state.isVisible()) + { IGridColumn column = getColumn(state.getColumnId(), allColumns); - if (column != null) { + if (column != null) + { result.add(column); } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/GridSortState.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/GridSortState.java index ad862050b8..928440e56b 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/GridSortState.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/GridSortState.java @@ -15,7 +15,8 @@ * * @author Matej Knopp */ -public class GridSortState implements IGridSortState, IClusterable { +public class GridSortState implements IGridSortState, IClusterable +{ private static final long serialVersionUID = 1L; @@ -24,7 +25,8 @@ public class GridSortState implements IGridSortState, IClusterable { * * @author Matej Knopp */ - private class SortStateColumn implements ISortStateColumn, IClusterable { + private class SortStateColumn implements ISortStateColumn, IClusterable + { private static final long serialVersionUID = 1L; @@ -32,7 +34,8 @@ private class SortStateColumn implements ISortStateColumn, IClusterable { private final IGridSortState.Direction direction; - private SortStateColumn(String propertyName, IGridSortState.Direction direction) { + private SortStateColumn(String propertyName, IGridSortState.Direction direction) + { this.propertyName = propertyName; this.direction = direction; } @@ -40,14 +43,16 @@ private SortStateColumn(String propertyName, IGridSortState.Direction direction) /** * {@inheritDoc} */ - public String getPropertyName() { + public String getPropertyName() + { return propertyName; } /** * {@inheritDoc} */ - public IGridSortState.Direction getDirection() { + public IGridSortState.Direction getDirection() + { return direction; } @@ -61,10 +66,13 @@ public IGridSortState.Direction getDirection() { * @param propertyName * @return */ - private int getSortStateColumnIndex(String propertyName) { + private int getSortStateColumnIndex(String propertyName) + { int i = 0; - for (ISortStateColumn column : columns) { - if (column.getPropertyName().equals(propertyName)) { + for (ISortStateColumn column : columns) + { + if (column.getPropertyName().equals(propertyName)) + { return i; } ++i; @@ -75,7 +83,8 @@ private int getSortStateColumnIndex(String propertyName) { /** * Resets the entire sort state. */ - public void clearSortState() { + public void clearSortState() + { columns.clear(); } @@ -84,7 +93,8 @@ public void clearSortState() { * * @param propertyName */ - public void clearSortState(String propertyName) { + public void clearSortState(String propertyName) + { setSortState(propertyName, null); } @@ -93,14 +103,18 @@ public void clearSortState(String propertyName) { * such entry. * * @param propertyName - * @return {@link IGridSortState.ISortStateColumn} for given property or null if there is no such - * entry + * @return {@link IGridSortState.ISortStateColumn} for given property or null if there is no + * such entry */ - public IGridSortState.ISortStateColumn getSortStateForProperty(String propertyName) { + public IGridSortState.ISortStateColumn getSortStateForProperty(String propertyName) + { int i = getSortStateColumnIndex(propertyName); - if (i != -1) { + if (i != -1) + { return columns.get(i); - } else { + } + else + { return null; } } @@ -112,28 +126,34 @@ public IGridSortState.ISortStateColumn getSortStateForProperty(String propertyNa * @param direction * */ - public void setSortState(String propertyName, IGridSortState.Direction direction) { + public void setSortState(String propertyName, IGridSortState.Direction direction) + { - if (Strings.isEmpty(propertyName)) { + if (Strings.isEmpty(propertyName)) + { throw new IllegalArgumentException("'propertyName' must be a non-empty string."); } int index = getSortStateColumnIndex(propertyName); - if (index != -1) { + if (index != -1) + { columns.remove(index); } - if (direction != null) { + if (direction != null) + { SortStateColumn column = new SortStateColumn(propertyName, direction); columns.add(0, column); } }; - + /** * Returns all {@link IGridSortState.ISortStateColumn} instances in this state. + * * @return all {@link IGridSortState.ISortStateColumn} instances in this state */ - public List getColumns() { + public List getColumns() + { return columns; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/Icons.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/Icons.java index db09001599..6bf34d9fda 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/Icons.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/Icons.java @@ -8,27 +8,30 @@ * * @author Matej Knopp */ -public class Icons { - +public class Icons +{ + /** * Default icon for a closed folder. */ - public static final Icon FOLDER_CLOSED = new PackageIcon(Icons.class, "res/icons/folder-closed.gif"); - + public static final Icon FOLDER_CLOSED = new PackageIcon(Icons.class, + "res/icons/folder-closed.gif"); + /** * Default icon for an opened folder. */ public static final Icon FOLDER_OPEN = new PackageIcon(Icons.class, "res/icons/folder-open.gif"); - + /** * Default icon for a non-folder node. */ public static final Icon ITEM = new PackageIcon(Icons.class, "res/icons/item.gif"); - + public static final Icon OK = new PackageIcon(Icons.class, "res/icons/16-em-check.png"); - + public static final Icon CANCEL = new PackageIcon(Icons.class, "res/icons/16-em-cross.png"); - - private Icons() { + + private Icons() + { } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/SortableHeaderLinkPanel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/SortableHeaderLinkPanel.java index 001a41c916..20ad71fcf5 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/SortableHeaderLinkPanel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/common/SortableHeaderLinkPanel.java @@ -14,7 +14,8 @@ * * @author Matej Knopp */ -public abstract class SortableHeaderLinkPanel extends Panel { +public abstract class SortableHeaderLinkPanel extends Panel +{ private final String sortProperty; @@ -26,33 +27,42 @@ public abstract class SortableHeaderLinkPanel extends Panel { * @param sortProperty * sort property that will be reported by the {@link IGridSortState} */ - public SortableHeaderLinkPanel(String id, String sortProperty) { + public SortableHeaderLinkPanel(String id, String sortProperty) + { super(id); this.sortProperty = sortProperty; - add(new AjaxEventBehavior("onclick") { + add(new AjaxEventBehavior("onclick") + { private static final long serialVersionUID = 1L; @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { // change the direction IGridSortState.Direction direction = getSortDirection(); - - if (direction == IGridSortState.Direction.ASC) { + + if (direction == IGridSortState.Direction.ASC) + { // if the direction is already ascending, switch it to descending - getSortState().setSortState(SortableHeaderLinkPanel.this.sortProperty, IGridSortState.Direction.DESC); - } else { - // otherwise set direction to ascending - getSortState().setSortState(SortableHeaderLinkPanel.this.sortProperty, IGridSortState.Direction.ASC); + getSortState().setSortState(SortableHeaderLinkPanel.this.sortProperty, + IGridSortState.Direction.DESC); + } + else + { + // otherwise set direction to ascending + getSortState().setSortState(SortableHeaderLinkPanel.this.sortProperty, + IGridSortState.Direction.ASC); } sortStateChanged(target); } @Override - protected IAjaxCallDecorator getAjaxCallDecorator() { + protected IAjaxCallDecorator getAjaxCallDecorator() + { return new CancelEventIfNoAjaxDecorator(); } }); @@ -61,42 +71,58 @@ protected IAjaxCallDecorator getAjaxCallDecorator() { abstract protected void sortStateChanged(AjaxRequestTarget target); @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); tag.setName("a"); tag.put("href", "#"); tag.put("class", getStyleClass()); } - private GridSortState getSortState() { + private GridSortState getSortState() + { return (findParent(AbstractGrid.class)).getSortState(); } /** * Returns the sort direction for this panel. + * * @return */ - private IGridSortState.Direction getSortDirection() { + private IGridSortState.Direction getSortDirection() + { IGridSortState state = getSortState(); - // we are interested only in the column with highest priority and it must match this panel's sort property - if (state.getColumns().size() > 0 && state.getColumns().get(0).getPropertyName().equals(sortProperty)) { + // we are interested only in the column with highest priority and it must match this panel's +// sort property + if (state.getColumns().size() > 0 && + state.getColumns().get(0).getPropertyName().equals(sortProperty)) + { return state.getColumns().get(0).getDirection(); - } else { + } + else + { return null; } } /** * Returns the CSS class for the link element depending on the sort state. + * * @return */ - private String getStyleClass() { + private String getStyleClass() + { IGridSortState.Direction direction = getSortDirection(); - if (direction == IGridSortState.Direction.ASC) { + if (direction == IGridSortState.Direction.ASC) + { return "imxt-sort-header imxt-sort-header-asc"; - } else if (direction == IGridSortState.Direction.DESC) { + } + else if (direction == IGridSortState.Direction.DESC) + { return "imxt-sort-header imxt-sort-header-desc"; - } else { + } + else + { return "imxt-sort-header imxt-sort-header-none"; } }; diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGrid.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGrid.java index 5a8c009e47..3c2b4f9a39 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGrid.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGrid.java @@ -25,7 +25,8 @@ * * @author Matej Knopp */ -public class DataGrid extends AbstractGrid implements IPageable { +public class DataGrid extends AbstractGrid implements IPageable +{ private static final long serialVersionUID = 1L; @@ -39,7 +40,8 @@ public class DataGrid extends AbstractGrid implements IPageable { * @param columns * list of grid columns */ - public DataGrid(String id, IModel model, List columns) { + public DataGrid(String id, IModel model, List columns) + { super(id, model, columns); init(); } @@ -54,46 +56,55 @@ public DataGrid(String id, IModel model, List columns) { * @param columns * list of grid columns */ - public DataGrid(String id, IDataSource dataSource, List columns) { + public DataGrid(String id, IDataSource dataSource, List columns) + { this(id, new Model(dataSource), columns); } - private class Body extends DataGridBody { + private class Body extends DataGridBody + { private static final long serialVersionUID = 1L; - private Body(String id) { + private Body(String id) + { super(id); } @Override - protected Collection getActiveColumns() { + protected Collection getActiveColumns() + { return DataGrid.this.getActiveColumns(); } @Override - protected IDataSource getDataSource() { + protected IDataSource getDataSource() + { return DataGrid.this.getDataSource(); } @Override - protected int getRowsPerPage() { + protected int getRowsPerPage() + { return DataGrid.this.getRowsPerPage(); } @Override - protected IGridSortState getSortState() { + protected IGridSortState getSortState() + { return DataGrid.this.getSortState(); } @Override - protected boolean isItemSelected(IModel itemModel) { + protected boolean isItemSelected(IModel itemModel) + { return DataGrid.this.isItemSelected(itemModel); } @Override - protected void rowPopulated(WebMarkupContainer rowItem) { - DataGrid.this.onRowPopulated(rowItem); + protected void rowPopulated(WebMarkupContainer rowItem) + { + onRowPopulated(rowItem); } }; @@ -103,8 +114,9 @@ protected void rowPopulated(WebMarkupContainer rowItem) { * * @return {@link IDataSource} instance */ - public IDataSource getDataSource() { - return ((IDataSource) getDefaultModelObject()); + public IDataSource getDataSource() + { + return ((IDataSource)getDefaultModelObject()); } private int rowsPerPage = 20; @@ -116,7 +128,8 @@ public IDataSource getDataSource() { * how many rows (max) should be displayed on one page * @return this (useful for method chaining) */ - public DataGrid setRowsPerPage(int rowsPerPage) { + public DataGrid setRowsPerPage(int rowsPerPage) + { this.rowsPerPage = rowsPerPage; return this; } @@ -126,16 +139,19 @@ public DataGrid setRowsPerPage(int rowsPerPage) { * * @return count of rows per page */ - public int getRowsPerPage() { + public int getRowsPerPage() + { return rowsPerPage; } - private void init() { - ((WebMarkupContainer) get("form:bodyContainer")).add(new Body("body")); + private void init() + { + ((WebMarkupContainer)get("form:bodyContainer")).add(new Body("body")); }; - private Body getBody() { - return (Body) get("form:bodyContainer:body"); + private Body getBody() + { + return (Body)get("form:bodyContainer:body"); } /** @@ -144,14 +160,16 @@ private Body getBody() { * * @return total count of items or {@value AbstractPageableView#UNKOWN_COUNT} */ - public int getTotalRowCount() { + public int getTotalRowCount() + { return getBody().getTotalRowCount(); } /** * @return The current page that is or will be rendered. */ - public int getCurrentPage() { + public int getCurrentPage() + { return getBody().getCurrentPage(); } @@ -160,7 +178,8 @@ public int getCurrentPage() { * * @return The total number of pages this pageable object has */ - public int getPageCount() { + public int getPageCount() + { return getBody().getPageCount(); } @@ -170,10 +189,13 @@ public int getPageCount() { * @param page * The page that should be rendered. */ - public void setCurrentPage(int page) { - if (getBody().getCurrentPage() != page) { + public void setCurrentPage(int page) + { + if (getBody().getCurrentPage() != page) + { getBody().setCurrentPage(page); - if (isCleanSelectionOnPageChange()) { + if (isCleanSelectionOnPageChange()) + { resetSelectedItems(); } } @@ -182,7 +204,8 @@ public void setCurrentPage(int page) { /** * @return the amount of items on current page. */ - public int getCurrentPageItemCount() { + public int getCurrentPageItemCount() + { return getBody().getCurrentPageItemCount(); } @@ -192,7 +215,8 @@ public int getCurrentPageItemCount() { * {@inheritDoc} */ @Override - public Collection getSelectedItems() { + public Collection getSelectedItems() + { return Collections.unmodifiableSet(selectedItems); } @@ -202,7 +226,8 @@ public Collection getSelectedItems() { * {@inheritDoc} */ @Override - public boolean isAllowSelectMultiple() { + public boolean isAllowSelectMultiple() + { return allowSelectMultiple; } @@ -210,8 +235,9 @@ public boolean isAllowSelectMultiple() { * {@inheritDoc} */ @Override - public void setAllowSelectMultiple(boolean value) { - this.allowSelectMultiple = value; + public void setAllowSelectMultiple(boolean value) + { + allowSelectMultiple = value; } private boolean cleanSelectionOnPageChange = true; @@ -225,7 +251,8 @@ public void setAllowSelectMultiple(boolean value) { * whether the current page change should deselect all selected items * @return this (useful for method chaining) */ - public DataGrid setCleanSelectionOnPageChange(boolean cleanSelectionOnPageChange) { + public DataGrid setCleanSelectionOnPageChange(boolean cleanSelectionOnPageChange) + { this.cleanSelectionOnPageChange = cleanSelectionOnPageChange; return this; } @@ -233,7 +260,8 @@ public DataGrid setCleanSelectionOnPageChange(boolean cleanSelectionOnPageChange /** * @return whether the current page change cleans the selection */ - public boolean isCleanSelectionOnPageChange() { + public boolean isCleanSelectionOnPageChange() + { return cleanSelectionOnPageChange; } @@ -241,7 +269,8 @@ public boolean isCleanSelectionOnPageChange() { * {@inheritDoc} */ @Override - public boolean isItemSelected(IModel itemModel) { + public boolean isItemSelected(IModel itemModel) + { return selectedItems.contains(itemModel); } @@ -249,11 +278,13 @@ public boolean isItemSelected(IModel itemModel) { * {@inheritDoc} */ @Override - public void resetSelectedItems() { - markAllItemsDirty(); + public void resetSelectedItems() + { + markAllItemsDirty(); Set oldSelected = new HashSet(selectedItems); selectedItems.clear(); - for (IModel model : oldSelected) { + for (IModel model : oldSelected) + { onItemSelectionChanged(model, false); } } @@ -262,11 +293,14 @@ public void resetSelectedItems() { * {@inheritDoc} */ @Override - public void selectAllVisibleItems() { - WebMarkupContainer body = (WebMarkupContainer) get("form:bodyContainer:body:row"); - if (body != null) { - for (Iterator i = body.iterator(); i.hasNext();) { - Component component = (Component) i.next(); + public void selectAllVisibleItems() + { + WebMarkupContainer body = (WebMarkupContainer)get("form:bodyContainer:body:row"); + if (body != null) + { + for (Iterator i = body.iterator(); i.hasNext();) + { + Component component = (Component)i.next(); IModel model = component.getDefaultModel(); selectItem(model, true); } @@ -278,29 +312,35 @@ public void selectAllVisibleItems() { * {@inheritDoc} */ @Override - protected WebMarkupContainer findRowComponent(IModel rowModel) { - if (rowModel == null) { + protected WebMarkupContainer findRowComponent(IModel rowModel) + { + if (rowModel == null) + { throw new IllegalArgumentException("rowModel may not be null"); } - WebMarkupContainer body = (WebMarkupContainer) get("form:bodyContainer:body:row"); - if (body != null) { - for (Iterator i = body.iterator(); i.hasNext();) { - Component component = (Component) i.next(); + WebMarkupContainer body = (WebMarkupContainer)get("form:bodyContainer:body:row"); + if (body != null) + { + for (Iterator i = body.iterator(); i.hasNext();) + { + Component component = (Component)i.next(); IModel model = component.getDefaultModel(); - if (rowModel.equals(model)) { - return (WebMarkupContainer) component; + if (rowModel.equals(model)) + { + return (WebMarkupContainer)component; } } - } + } return null; } - + private transient Set dirtyItems = null; private static final Set DIRTY_ALL = new HashSet(); @Override - protected void onBeforeRender() { + protected void onBeforeRender() + { super.onBeforeRender(); dirtyItems = null; } @@ -313,19 +353,23 @@ protected void onBeforeRender() { * model used to access the item */ @Override - public void markItemDirty(IModel itemModel) { - if (dirtyItems != DIRTY_ALL) { - if (this.dirtyItems == null) { - this.dirtyItems = new HashSet(); + public void markItemDirty(IModel itemModel) + { + if (dirtyItems != DIRTY_ALL) + { + if (dirtyItems == null) + { + dirtyItems = new HashSet(); } - this.dirtyItems.add(itemModel); + dirtyItems.add(itemModel); } } /** * Makes the next call to {@link #update()} refresh the entire grid. */ - public void markAllItemsDirty() { + public void markAllItemsDirty() + { dirtyItems = DIRTY_ALL; } @@ -333,7 +377,8 @@ public void markAllItemsDirty() { * {@inheritDoc} */ @Override - public void onItemSelectionChanged(IModel item, boolean newValue) { + public void onItemSelectionChanged(IModel item, boolean newValue) + { markItemDirty(item); } @@ -341,17 +386,24 @@ public void onItemSelectionChanged(IModel item, boolean newValue) { * {@inheritDoc} */ @Override - public void update() { + public void update() + { AjaxRequestTarget target = AjaxRequestTarget.get(); - if (dirtyItems == DIRTY_ALL) { + if (dirtyItems == DIRTY_ALL) + { target.add(this); - } else if (dirtyItems != null) { - WebMarkupContainer body = (WebMarkupContainer) get("form:bodyContainer:body:row"); - if (body != null) { - for (Iterator i = body.iterator(); i.hasNext();) { - Component component = (Component) i.next(); + } + else if (dirtyItems != null) + { + WebMarkupContainer body = (WebMarkupContainer)get("form:bodyContainer:body:row"); + if (body != null) + { + for (Iterator i = body.iterator(); i.hasNext();) + { + Component component = (Component)i.next(); IModel model = component.getDefaultModel(); - if (dirtyItems.contains(model)) { + if (dirtyItems.contains(model)) + { target.add(component); } } @@ -364,21 +416,28 @@ public void update() { * {@inheritDoc} */ @Override - public void selectItem(IModel itemModel, boolean selected) { - if (isAllowSelectMultiple() == false && selectedItems.size() > 0) { - for (Iterator i = selectedItems.iterator(); i.hasNext();) { + public void selectItem(IModel itemModel, boolean selected) + { + if (isAllowSelectMultiple() == false && selectedItems.size() > 0) + { + for (Iterator i = selectedItems.iterator(); i.hasNext();) + { IModel current = i.next(); - if (current.equals(itemModel) == false) { + if (current.equals(itemModel) == false) + { i.remove(); onItemSelectionChanged(current, false); } } } - if (selected == true && selectedItems.contains(itemModel) == false) { + if (selected == true && selectedItems.contains(itemModel) == false) + { selectedItems.add(itemModel); onItemSelectionChanged(itemModel, selected); - } else if (selected == false && selectedItems.contains(itemModel) == true) { + } + else if (selected == false && selectedItems.contains(itemModel) == true) + { selectedItems.remove(itemModel); onItemSelectionChanged(itemModel, selected); } @@ -389,19 +448,21 @@ public void selectItem(IModel itemModel, boolean selected) { * * @author Matej Knopp */ - public interface IGridQuery extends IDataSource.IQuery { - + public interface IGridQuery extends IDataSource.IQuery + { + /** * @return data grid issuing the query */ public DataGrid getDataGrid(); }; - + /** * {@inheritDoc} */ @Override - public WebMarkupContainer findParentRow(Component child) { + public WebMarkupContainer findParentRow(Component child) + { return child.findParent(DataGridBody.Data.RowItem.class); } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGridBody.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGridBody.java index 5d1d7cfa95..6349c3db78 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGridBody.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DataGridBody.java @@ -20,18 +20,20 @@ /** * Contains data grid rows. - * + * * @author Matej Knopp */ -public abstract class DataGridBody extends Panel implements IPageable { +public abstract class DataGridBody extends Panel implements IPageable +{ /** * Constructor - * + * * @param id * component id */ - public DataGridBody(String id) { + public DataGridBody(String id) + { super(id); setRenderBodyOnly(true); @@ -50,100 +52,122 @@ public DataGridBody(String id) { protected abstract void rowPopulated(WebMarkupContainer rowItem); - private Data getData() { - return (Data) get("row"); + private Data getData() + { + return (Data)get("row"); } - int getTotalRowCount() { + int getTotalRowCount() + { return getData().getTotalRowCount(); } - int getCurrentPageItemCount() { + int getCurrentPageItemCount() + { return getData().getCurrentPageItemCount(); } /** * {@inheritDoc} */ - public int getCurrentPage() { + public int getCurrentPage() + { return getData().getCurrentPage(); } /** * {@inheritDoc} */ - public int getPageCount() { + public int getPageCount() + { return getData().getPageCount(); } /** * {@inheritDoc} */ - public void setCurrentPage(int page) { + public void setCurrentPage(int page) + { getData().setCurrentPage(page); } - class Data extends AbstractPageableView { + class Data extends AbstractPageableView + { private static final long serialVersionUID = 1L; - private Data(String id) { + private Data(String id) + { super(id); setItemReuseStrategy(ReuseIfModelsEqualStrategy.getInstance()); } @Override - protected IDataSource getDataSource() { + protected IDataSource getDataSource() + { return DataGridBody.this.getDataSource(); } @Override - protected int getRowsPerPage() { + protected int getRowsPerPage() + { return DataGridBody.this.getRowsPerPage(); } @Override - protected IGridSortState getSortState() { + protected IGridSortState getSortState() + { return DataGridBody.this.getSortState(); } @Override - protected IQuery wrapQuery(final IQuery original) { - return new DataGrid.IGridQuery() { - public int getCount() { + protected IQuery wrapQuery(final IQuery original) + { + return new DataGrid.IGridQuery() + { + public int getCount() + { return original.getCount(); } - public int getFrom() { + public int getFrom() + { return original.getFrom(); } - public IGridSortState getSortState() { + public IGridSortState getSortState() + { return original.getSortState(); } - public int getTotalCount() { + public int getTotalCount() + { return original.getTotalCount(); } - public DataGrid getDataGrid() { + public DataGrid getDataGrid() + { return DataGridBody.this.findParent(DataGrid.class); } }; } @Override - protected void populateItem(final Item item) { - item.add(new AbstractGridRow("item", item.getDefaultModel()) { + protected void populateItem(final Item item) + { + item.add(new AbstractGridRow("item", item.getDefaultModel()) + { private static final long serialVersionUID = 1L; @Override - protected Collection getActiveColumns() { + protected Collection getActiveColumns() + { return DataGridBody.this.getActiveColumns(); } @Override - protected int getRowNumber() { + protected int getRowNumber() + { return item.getIndex(); } }); @@ -151,35 +175,43 @@ protected int getRowNumber() { rowPopulated(item); } - protected class RowItem extends Item { + protected class RowItem extends Item + { private static final long serialVersionUID = 1L; - protected RowItem(String id, int index, IModel model) { + protected RowItem(String id, int index, IModel model) + { super(id, index, model); } @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); CharSequence klass = tag.getAttribute("class"); - if (klass == null) { + if (klass == null) + { klass = ""; } if (klass.length() > 0) klass = klass + " "; - if (getIndex() % 2 == 0) { + if (getIndex() % 2 == 0) + { klass = klass + "imxt-even"; - } else { + } + else + { klass = klass + "imxt-odd"; } klass = klass + " imxt-want-prelight imxt-grid-row"; - if (isItemSelected(getDefaultModel())) { + if (isItemSelected(getDefaultModel())) + { klass = klass + " imxt-selected"; } @@ -188,7 +220,8 @@ protected void onComponentTag(ComponentTag tag) { }; @Override - protected Item newItem(String id, final int index, final IModel model) { + protected Item newItem(String id, final int index, final IModel model) + { Item item = new RowItem(id, index, model); item.setOutputMarkupId(true); return item; diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DefaultDataGrid.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DefaultDataGrid.java index 6dda164d9a..6f17f22b19 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DefaultDataGrid.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/datagrid/DefaultDataGrid.java @@ -10,10 +10,13 @@ import com.inmethod.grid.toolbar.paging.PagingToolbar; /** - * Convenience implementation that adds {@link PagingToolbar} and {@link NoRecordsToolbar} to the grid. + * Convenience implementation that adds {@link PagingToolbar} and {@link NoRecordsToolbar} to the + * grid. + * * @author Matej Knopp */ -public class DefaultDataGrid extends DataGrid { +public class DefaultDataGrid extends DataGrid +{ private static final long serialVersionUID = 1L; @@ -27,7 +30,8 @@ public class DefaultDataGrid extends DataGrid { * @param columns * list of grid columns */ - public DefaultDataGrid(String id, IModel model, List columns) { + public DefaultDataGrid(String id, IModel model, List columns) + { super(id, model, columns); init(); } @@ -42,12 +46,14 @@ public DefaultDataGrid(String id, IModel model, List columns) { * @param columns * list of grid columns */ - public DefaultDataGrid(String id, IDataSource dataSource, List columns) { + public DefaultDataGrid(String id, IDataSource dataSource, List columns) + { super(id, dataSource, columns); init(); } - - private void init() { + + private void init() + { addBottomToolbar(new NoRecordsToolbar(this)); addBottomToolbar(new PagingToolbar(this)); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractHeaderToolbar.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractHeaderToolbar.java index 4c889a9060..02b2072635 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractHeaderToolbar.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractHeaderToolbar.java @@ -7,17 +7,20 @@ /** * Toolbars extending this class are displayed in table header right below the row displaying column * names. The toolbar must produce markup with structure such as + * *
  *   <th>column 1 data</th>
  *   <th>column 2 data</th>
  *   ...
  *   <th>column n data</th>
  * 
+ * * as it's put directly inside a table row. * * @author Matej Knopp */ -public abstract class AbstractHeaderToolbar extends AbstractToolbar { +public abstract class AbstractHeaderToolbar extends AbstractToolbar +{ /** * Constructor @@ -25,7 +28,8 @@ public abstract class AbstractHeaderToolbar extends AbstractToolbar { * @param dataGrid * @param model */ - public AbstractHeaderToolbar(AbstractGrid dataGrid, IModel model) { + public AbstractHeaderToolbar(AbstractGrid dataGrid, IModel model) + { super(dataGrid, model); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractToolbar.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractToolbar.java index 9f8e943dd8..a5b06aef86 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractToolbar.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/AbstractToolbar.java @@ -9,20 +9,23 @@ import com.inmethod.grid.common.AbstractGrid; /** - * Base for toolbar classes. + * Base for toolbar classes. * * @author Matej Knopp */ -public abstract class AbstractToolbar extends Panel { +public abstract class AbstractToolbar extends Panel +{ private final AbstractGrid grid; - + /** * Constructor + * * @param grid * @param model */ - public AbstractToolbar(AbstractGrid grid, IModel model) { + public AbstractToolbar(AbstractGrid grid, IModel model) + { super(AbstractGrid.INTERNAL_TOOLBAR_ITEM_ID, model); setRenderBodyOnly(true); this.grid = grid; @@ -30,17 +33,21 @@ public AbstractToolbar(AbstractGrid grid, IModel model) { /** * Returns the collection of currently displayed columns in grid. + * * @return collection of active columns. */ - public Collection getActiveColumns() { + public Collection getActiveColumns() + { return grid.getActiveColumns(); } - + /** * Returns the grid this toolbar belongs to. + * * @return grid this toolbar belongs to */ - public AbstractGrid getGrid() { + public AbstractGrid getGrid() + { return grid; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/NoRecordsToolbar.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/NoRecordsToolbar.java index 5c75593c7c..8d37e28477 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/NoRecordsToolbar.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/NoRecordsToolbar.java @@ -36,7 +36,7 @@ public class NoRecordsToolbar extends AbstractToolbar private static final long serialVersionUID = 1L; private static final IModel DEFAULT_MESSAGE_MODEL = new ResourceModel( - "datagrid.no-records-found", "No Records Found"); + "datagrid.no-records-found", "No Records Found"); /** * Constructor @@ -58,18 +58,20 @@ public NoRecordsToolbar(final DataGrid table) public NoRecordsToolbar(final DataGrid grid, IModel messageModel) { super(grid, null); - + add(new Label("msg", messageModel)); } - + /** * Returns the {@link DataGrid} instance this toolbar belongs to. + * * @return {@link DataGrid} instance this toolbar belongs to. */ - public DataGrid getDataGrid() { - return (DataGrid) super.getGrid(); + public DataGrid getDataGrid() + { + return (DataGrid)super.getGrid(); } - + /** * Only shows this toolbar when there are no rows * diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/NavigatorLabel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/NavigatorLabel.java index f96c94804e..c0ead7d55b 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/NavigatorLabel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/NavigatorLabel.java @@ -25,15 +25,16 @@ /** * Label that provides Showing x to y of z message given for a DataGrid. The message can be - * overridden using the NavigatorLabel property key, the default message is used is - * of the format Showing ${from} to ${to} of ${of}. The message can also be - * configured pragmatically by setting it as the model object of the label. + * overridden using the NavigatorLabel property key, the default message is used is of + * the format Showing ${from} to ${to} of ${of}. The message can also be configured + * pragmatically by setting it as the model object of the label. * * @author Igor Vaynberg (ivaynberg) * @author Matej Knopp * */ -public class NavigatorLabel extends Label { +public class NavigatorLabel extends Label +{ private static final long serialVersionUID = 1L; /** @@ -42,13 +43,15 @@ public class NavigatorLabel extends Label { * @param table * pageable view */ - public NavigatorLabel(final String id, final DataGrid table) { + public NavigatorLabel(final String id, final DataGrid table) + { super(id); - setDefaultModel(new StringResourceModel("NavigatorLabel", this, new Model(new LabelModelObject(table)), - "Showing ${from} to ${to} of ${of}")); + setDefaultModel(new StringResourceModel("NavigatorLabel", this, new Model( + new LabelModelObject(table)), "Showing ${from} to ${to} of ${of}")); } - private class LabelModelObject implements IClusterable { + private class LabelModelObject implements IClusterable + { private static final long serialVersionUID = 1L; private final DataGrid table; @@ -57,14 +60,16 @@ private class LabelModelObject implements IClusterable { * * @param table */ - public LabelModelObject(DataGrid table) { + public LabelModelObject(DataGrid table) + { this.table = table; } /** * @return "z" in "Showing x to y of z" */ - public String getOf() { + public String getOf() + { int total = table.getTotalRowCount(); return total != -1 ? "" + total : getString("unknown", null, "unknown"); } @@ -72,8 +77,10 @@ public String getOf() { /** * @return "x" in "Showing x to y of z" */ - public int getFrom() { - if (table.getTotalRowCount() == 0) { + public int getFrom() + { + if (table.getTotalRowCount() == 0) + { return 0; } return (table.getCurrentPage() * table.getRowsPerPage()) + 1; @@ -82,10 +89,14 @@ public int getFrom() { /** * @return "y" in "Showing x to y of z" */ - public int getTo() { - if (table.getTotalRowCount() == 0) { + public int getTo() + { + if (table.getTotalRowCount() == 0) + { return 0; - } else { + } + else + { int count = getFrom() + table.getCurrentPageItemCount() - 1; return count; } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingNavigator.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingNavigator.java index 0f2ee6e82f..01c6f23a8d 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingNavigator.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingNavigator.java @@ -10,31 +10,38 @@ * * @author Matej Knopp */ -public class PagingNavigator extends AjaxPagingNavigator { +public class PagingNavigator extends AjaxPagingNavigator +{ private static final long serialVersionUID = 1L; /** * Constructor + * * @param id * @param pageable * @param labelProvider */ - public PagingNavigator(String id, IPageable pageable, IPagingLabelProvider labelProvider) { + public PagingNavigator(String id, IPageable pageable, IPagingLabelProvider labelProvider) + { super(id, pageable, labelProvider); } /** * Constructor + * * @param id * @param pageable */ - public PagingNavigator(String id, IPageable pageable) { + public PagingNavigator(String id, IPageable pageable) + { super(id, pageable); } @Override - protected PagingNavigation newNavigation(final String id, IPageable pageable, IPagingLabelProvider labelProvider) { + protected PagingNavigation newNavigation(final String id, IPageable pageable, + IPagingLabelProvider labelProvider) + { PagingNavigation navigation = super.newNavigation(id, pageable, labelProvider); navigation.setViewSize(11); return navigation; diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingToolbar.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingToolbar.java index 04ca503563..d87b744360 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingToolbar.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/toolbar/paging/PagingToolbar.java @@ -14,44 +14,49 @@ * * @author Matej Knopp */ -public class PagingToolbar extends AbstractToolbar { +public class PagingToolbar extends AbstractToolbar +{ private static final long serialVersionUID = 1L; /** * Returns the {@link DataGrid} to which this toolbar belongs. + * * @return data grid */ - public DataGrid getDataGrid() { - return (DataGrid) super.getGrid(); + public DataGrid getDataGrid() + { + return (DataGrid)super.getGrid(); } /** * Constructor * * @param grid - * data grid + * data grid */ - public PagingToolbar(DataGrid grid) { + public PagingToolbar(DataGrid grid) + { super(grid, null); add(newPagingNavigator("navigator")); add(newNavigationLabel("navigationLabel")); } - protected Component newNavigationLabel(String id) { + protected Component newNavigationLabel(String id) + { return new NavigatorLabel(id, getDataGrid()); } - - protected Component newPagingNavigator(String id) { + + protected Component newPagingNavigator(String id) + { return new PagingNavigator(id, getDataGrid()); } /** - * Important to prevent early initialization of QueryResult at - * AbstractPageableView. The isVisible method can be called during an early - * step in the form process and the QuertyResult initialization can fail if - * it depend upon form components + * Important to prevent early initialization of QueryResult at AbstractPageableView. The + * isVisible method can be called during an early step in the form process and the QuertyResult + * initialization can fail if it depend upon form components */ @Override protected void onConfigure() diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/AbstractTreeGridRow.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/AbstractTreeGridRow.java index af3bb05248..b340254733 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/AbstractTreeGridRow.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/AbstractTreeGridRow.java @@ -9,26 +9,31 @@ * * @author Matej Knopp */ -public abstract class AbstractTreeGridRow extends AbstractGridRow { +public abstract class AbstractTreeGridRow extends AbstractGridRow +{ private final int level; - + /** * Constructor + * * @param id * @param model * @param level */ - public AbstractTreeGridRow(String id, IModel model, int level) { + public AbstractTreeGridRow(String id, IModel model, int level) + { super(id, model); this.level = level; } /** * Returns a depth level of the node belonging to this row. + * * @return tree node level */ - public int getLevel() { + public int getLevel() + { return level; } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/BaseTreeColumn.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/BaseTreeColumn.java index 2cb3e1e84f..4c9203b784 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/BaseTreeColumn.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/BaseTreeColumn.java @@ -16,29 +16,34 @@ /** * INTERNAL *

- * Base class for column containing the actual tree in {@link TreeGrid}. Users should not subclass this - * class directly. Rather than that the {@link AbstractTreeColumn} class should be used. - * + * Base class for column containing the actual tree in {@link TreeGrid}. Users should not subclass + * this class directly. Rather than that the {@link AbstractTreeColumn} class should be used. + * * @author Matej Knopp */ -public abstract class BaseTreeColumn extends AbstractColumn { +public abstract class BaseTreeColumn extends AbstractColumn +{ /** * Constructor. + * * @param columnId * @param headerModel * @param sortProperty */ - public BaseTreeColumn(String columnId, IModel headerModel, String sortProperty) { + public BaseTreeColumn(String columnId, IModel headerModel, String sortProperty) + { super(columnId, headerModel, sortProperty); } /** * Constructor. + * * @param columnId * @param headerModel */ - public BaseTreeColumn(String columnId, IModel headerModel) { + public BaseTreeColumn(String columnId, IModel headerModel) + { super(columnId, headerModel); } @@ -46,24 +51,29 @@ public BaseTreeColumn(String columnId, IModel headerModel) { * {@inheritDoc} */ @Override - public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) { - AbstractTreeGridRow row = (AbstractTreeGridRow) parent; - return new TreePanel(componentId, rowModel, row.getLevel()) { + public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) + { + AbstractTreeGridRow row = (AbstractTreeGridRow)parent; + return new TreePanel(componentId, rowModel, row.getLevel()) + { private static final long serialVersionUID = 1L; @Override - protected Component newNodeComponent(String id, IModel model) { + protected Component newNodeComponent(String id, IModel model) + { return BaseTreeColumn.this.newNodeComponent(id, model); } @Override - protected Icon getIcon(IModel model) { + protected Icon getIcon(IModel model) + { return BaseTreeColumn.this.getIcon(model); } @Override - protected void onJunctionLinkClicked(AjaxRequestTarget target, Object node) { + protected void onJunctionLinkClicked(AjaxRequestTarget target, Object node) + { getTreeGrid().onJunctionLinkClicked(target, node); } }; @@ -92,22 +102,28 @@ protected void onJunctionLinkClicked(AjaxRequestTarget target, Object node) { /** * Returns the {@link TreeGrid} this column belongs to. + * * @return {@link TreeGrid} this column belongs to. */ - public TreeGrid getTreeGrid() { - return (TreeGrid) getGrid(); + public TreeGrid getTreeGrid() + { + return (TreeGrid)getGrid(); } /** * {@inheritDoc} */ @Override - public void setGrid(AbstractGrid grid) { - if (getTreeGrid() != null && getTreeGrid() != grid) { - throw new IllegalStateException("One BaseTreeColumn can not be used with multiple TreeGrid instances"); + public void setGrid(AbstractGrid grid) + { + if (getTreeGrid() != null && getTreeGrid() != grid) + { + throw new IllegalStateException( + "One BaseTreeColumn can not be used with multiple TreeGrid instances"); } - if (grid instanceof TreeGrid == false) { + if (grid instanceof TreeGrid == false) + { throw new IllegalStateException("BaseTreeColumn can only be added to a TreeGrid."); } super.setGrid(grid); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGrid.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGrid.java index 6533a1adef..8fe5ec648e 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGrid.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGrid.java @@ -23,16 +23,17 @@ /** * Advanced grid with a tree. Supports resizable and reorderable columns. - * + * * @author Matej Knopp */ -public class TreeGrid extends AbstractGrid { +public class TreeGrid extends AbstractGrid +{ private static final long serialVersionUID = 1L; /** * Creates a new {@link TreeGrid} instance. - * + * * @param id * component id * @param model @@ -40,26 +41,31 @@ public class TreeGrid extends AbstractGrid { * @param columns * list of {@link IGridColumn}s. */ - public TreeGrid(String id, IModel model, List columns) { + public TreeGrid(String id, IModel model, List columns) + { super(id, model, columns); - WebMarkupContainer bodyContainer = (WebMarkupContainer) get("form:bodyContainer"); - bodyContainer.add(body = new TreeGridBody("body", model) { + WebMarkupContainer bodyContainer = (WebMarkupContainer)get("form:bodyContainer"); + bodyContainer.add(body = new TreeGridBody("body", model) + { private static final long serialVersionUID = 1L; @Override - protected Collection getActiveColumns() { + protected Collection getActiveColumns() + { return TreeGrid.this.getActiveColumns(); } @Override - protected void rowPopulated(WebMarkupContainer item) { + protected void rowPopulated(WebMarkupContainer item) + { TreeGrid.this.onRowPopulated(item); } @Override - protected ITreeState newTreeState() { + protected ITreeState newTreeState() + { return TreeGrid.this.newTreeState(); } }); @@ -67,19 +73,27 @@ protected ITreeState newTreeState() { getTreeState().addTreeStateListener(new TreeStateListener()); } - private ITreeState newTreeState() { - return new DefaultTreeState() { + private ITreeState newTreeState() + { + return new DefaultTreeState() + { @Override - public boolean isNodeSelected(Object node) { + public boolean isNodeSelected(Object node) + { - if (!isAutoSelectChildren()) { + if (!isAutoSelectChildren()) + { return super.isNodeSelected(node); - } else { + } + else + { // check if any parent of the node is selected Object parent = node; - while (parent != null) { - if (super.isNodeSelected(parent)) { + while (parent != null) + { + if (super.isNodeSelected(parent)) + { return true; } parent = getTree().getParentNode(parent); @@ -88,37 +102,49 @@ public boolean isNodeSelected(Object node) { return false; } - private void deselectChildNodes(Object node) { + private void deselectChildNodes(Object node) + { List toDeselect = new ArrayList(); - for (Object o : getSelectedNodes()) { + for (Object o : getSelectedNodes()) + { Object p = getTree().getParentNode(o); - while (p != null && !p.equals(node)) { + while (p != null && !p.equals(node)) + { p = getTree().getParentNode(p); } - if (p != null) { + if (p != null) + { toDeselect.add(o); } } - for (Object o : toDeselect) { + for (Object o : toDeselect) + { removeSelectedNodeSilent(o); } } @Override - public void selectNode(Object node, boolean selected) { - if (!isAutoSelectChildren()) { + public void selectNode(Object node, boolean selected) + { + if (!isAutoSelectChildren()) + { super.selectNode(node, selected); - } else { + } + else + { Object parent = getTree().getParentNode(node); - while (parent != null) { - if (super.isNodeSelected(parent)) { + while (parent != null) + { + if (super.isNodeSelected(parent)) + { return; } parent = getTree().getParentNode(parent); } deselectChildNodes(node); - if (super.isNodeSelected(node) != selected) { + if (super.isNodeSelected(node) != selected) + { super.selectNode(node, selected); getTree().markNodeChildrenDirty(node); } @@ -127,52 +153,59 @@ public void selectNode(Object node, boolean selected) { }; }; - private class TreeStateListener implements ITreeStateListener, Serializable { + private class TreeStateListener implements ITreeStateListener, Serializable + { private static final long serialVersionUID = 1L; /** * {@inheritDoc} */ - public void allNodesCollapsed() { + public void allNodesCollapsed() + { } /** * {@inheritDoc} */ - public void allNodesExpanded() { + public void allNodesExpanded() + { } /** * {@inheritDoc} */ - public void nodeCollapsed(Object node) { + public void nodeCollapsed(Object node) + { } /** * {@inheritDoc} */ - public void nodeExpanded(Object node) { + public void nodeExpanded(Object node) + { } /** * {@inheritDoc} */ - public void nodeSelected(Object node) { - onItemSelectionChanged(new Model((Serializable) node), true); + public void nodeSelected(Object node) + { + onItemSelectionChanged(new Model((Serializable)node), true); } /** * {@inheritDoc} */ - public void nodeUnselected(Object node) { - onItemSelectionChanged(new Model((Serializable) node), false); + public void nodeUnselected(Object node) + { + onItemSelectionChanged(new Model((Serializable)node), false); } }; /** * Creates a new {@link TreeGrid} instance. - * + * * @param id * component id * @param model @@ -180,27 +213,30 @@ public void nodeUnselected(Object node) { * @param columns * list of {@link IGridColumn}s. */ - public TreeGrid(String id, TreeModel model, List columns) { - this(id, new Model((Serializable) model), columns); + public TreeGrid(String id, TreeModel model, List columns) + { + this(id, new Model((Serializable)model), columns); } private TreeGridBody body; /** * Returns the inner tree of the {@link TreeGrid}. - * + * * @return inner tree */ - public AbstractTree getTree() { + public AbstractTree getTree() + { return body; } /** * Returns the tree state - * + * * @return tree state */ - public ITreeState getTreeState() { + public ITreeState getTreeState() + { return getTree().getTreeState(); } @@ -208,21 +244,23 @@ public ITreeState getTreeState() { * During Ajax request updates the changed parts of tree. */ @Override - public final void update() { + public final void update() + { getTree().updateTree(AjaxRequestTarget.get()); }; /** - * Callback function called after user clicked on an junction link. The node - * has already been expanded/collapsed (depending on previous status). - * + * Callback function called after user clicked on an junction link. The node has already been + * expanded/collapsed (depending on previous status). + * * @param target * Request target - may be null on non-ajax call - * + * * @param node * Node for which this callback is relevant */ - protected void onJunctionLinkClicked(AjaxRequestTarget target, Object node) { + protected void onJunctionLinkClicked(AjaxRequestTarget target, Object node) + { } /** @@ -230,11 +268,13 @@ protected void onJunctionLinkClicked(AjaxRequestTarget target, Object node) { */ @SuppressWarnings("unchecked") @Override - public Collection getSelectedItems() { + public Collection getSelectedItems() + { Collection nodes = getTreeState().getSelectedNodes(); Collection result = new ArrayList(nodes.size()); - for (Object node : nodes) { - result.add(new Model((Serializable) node)); + for (Object node : nodes) + { + result.add(new Model((Serializable)node)); } return result; } @@ -243,7 +283,8 @@ public Collection getSelectedItems() { * {@inheritDoc} */ @Override - public boolean isAllowSelectMultiple() { + public boolean isAllowSelectMultiple() + { return getTreeState().isAllowSelectMultiple(); } @@ -251,7 +292,8 @@ public boolean isAllowSelectMultiple() { * {@inheritDoc} */ @Override - public void setAllowSelectMultiple(boolean value) { + public void setAllowSelectMultiple(boolean value) + { getTreeState().setAllowSelectMultiple(value); } @@ -259,7 +301,8 @@ public void setAllowSelectMultiple(boolean value) { * {@inheritDoc} */ @Override - public boolean isItemSelected(IModel itemModel) { + public boolean isItemSelected(IModel itemModel) + { return getTreeState().isNodeSelected(itemModel.getObject()); } @@ -267,9 +310,11 @@ public boolean isItemSelected(IModel itemModel) { * {@inheritDoc} */ @Override - public void resetSelectedItems() { + public void resetSelectedItems() + { Collection nodes = getTreeState().getSelectedNodes(); - for (Object node : nodes) { + for (Object node : nodes) + { getTreeState().selectNode(node, false); } getTree().invalidateAll(); @@ -279,13 +324,17 @@ public void resetSelectedItems() { * {@inheritDoc} */ @Override - public void selectAllVisibleItems() { - WebMarkupContainer body = (WebMarkupContainer) get("form:bodyContainer:body:i"); - if (body != null) { + public void selectAllVisibleItems() + { + WebMarkupContainer body = (WebMarkupContainer)get("form:bodyContainer:body:i"); + if (body != null) + { boolean first = true; - for (Iterator i = body.iterator(); i.hasNext();) { - Component component = (Component) i.next(); - if (getTree().isRootLess() == false || first == false) { + for (Iterator i = body.iterator(); i.hasNext();) + { + Component component = (Component)i.next(); + if (getTree().isRootLess() == false || first == false) + { selectItem(component.getDefaultModel(), true); } first = false; @@ -295,17 +344,22 @@ public void selectAllVisibleItems() { } @Override - protected WebMarkupContainer findRowComponent(IModel rowModel) { - if (rowModel == null) { + protected WebMarkupContainer findRowComponent(IModel rowModel) + { + if (rowModel == null) + { throw new IllegalArgumentException("rowModel may not be null"); } - WebMarkupContainer body = (WebMarkupContainer) get("form:bodyContainer:body:i"); - if (body != null) { - for (Iterator i = body.iterator(); i.hasNext();) { - Component component = (Component) i.next(); + WebMarkupContainer body = (WebMarkupContainer)get("form:bodyContainer:body:i"); + if (body != null) + { + for (Iterator i = body.iterator(); i.hasNext();) + { + Component component = (Component)i.next(); IModel model = component.getDefaultModel(); - if (rowModel.equals(model)) { - return (WebMarkupContainer) component; + if (rowModel.equals(model)) + { + return (WebMarkupContainer)component; } } } @@ -313,7 +367,8 @@ protected WebMarkupContainer findRowComponent(IModel rowModel) { } @Override - public void markItemDirty(IModel model) { + public void markItemDirty(IModel model) + { Object node = model.getObject(); getTree().markNodeDirty(node); } @@ -322,41 +377,43 @@ public void markItemDirty(IModel model) { * {@inheritDoc} */ @Override - public void selectItem(IModel itemModel, boolean selected) { + public void selectItem(IModel itemModel, boolean selected) + { getTreeState().selectNode(itemModel.getObject(), selected); } @Override - public WebMarkupContainer findParentRow(Component child) { - if (child instanceof AbstractTreeGridRow == false) { + public WebMarkupContainer findParentRow(Component child) + { + if (child instanceof AbstractTreeGridRow == false) + { child = child.findParent(AbstractTreeGridRow.class); } - return (WebMarkupContainer) (child != null ? child.getParent() : null); + return (WebMarkupContainer)(child != null ? child.getParent() : null); } /** - * Sets whether children of selected node should automatically be treated as - * selected nodes (default true). Such children can not be - * deselected individually. Also {@link ITreeState#isNodeSelected(Object)} - * returns true if any of node parent is selected. On the - * contrary, {@link ITreeState#getSelectedNodes()} only returns "top level" + * Sets whether children of selected node should automatically be treated as selected nodes + * (default true). Such children can not be deselected individually. Also + * {@link ITreeState#isNodeSelected(Object)} returns true if any of node parent is + * selected. On the contrary, {@link ITreeState#getSelectedNodes()} only returns "top level" * selected nodes. - * + * * @param autoSelectChildren */ - public void setAutoSelectChildren(boolean autoSelectChildren) { + public void setAutoSelectChildren(boolean autoSelectChildren) + { this.autoSelectChildren = autoSelectChildren; } /** - * Returns whether children of selected nodes should be automatically - * treated as selected node. - * + * Returns whether children of selected nodes should be automatically treated as selected node. + * * @return */ - public boolean isAutoSelectChildren() { - return isAllowSelectMultiple() && !isSelectToEdit() - && autoSelectChildren; + public boolean isAutoSelectChildren() + { + return isAllowSelectMultiple() && !isSelectToEdit() && autoSelectChildren; } private boolean autoSelectChildren = true; diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGridBody.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGridBody.java index 39167ff6ba..fff74e8853 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGridBody.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreeGridBody.java @@ -19,7 +19,8 @@ * * @author Matej Knopp */ -public abstract class TreeGridBody extends AbstractTree { +public abstract class TreeGridBody extends AbstractTree +{ private static final long serialVersionUID = 1L; @@ -30,35 +31,43 @@ public abstract class TreeGridBody extends AbstractTree { * component id * @param model */ - public TreeGridBody(String id, IModel model) { + public TreeGridBody(String id, IModel model) + { super(id, model); setRenderBodyOnly(true); } @Override - protected void populateTreeItem(final WebMarkupContainer item, int level) { - AbstractGridRow row = new AbstractTreeGridRow("item", item.getDefaultModel(), level) { + protected void populateTreeItem(final WebMarkupContainer item, int level) + { + AbstractGridRow row = new AbstractTreeGridRow("item", item.getDefaultModel(), level) + { private static final long serialVersionUID = 1L; @Override - protected Collection getActiveColumns() { + protected Collection getActiveColumns() + { return TreeGridBody.this.getActiveColumns(); } @Override - protected int getRowNumber() { + protected int getRowNumber() + { return -1; } }; item.add(row); - item.add(new Behavior() { + item.add(new Behavior() + { private static final long serialVersionUID = 1L; @Override - public void onComponentTag(Component component, ComponentTag tag) { + public void onComponentTag(Component component, ComponentTag tag) + { CharSequence klass = "imxt-want-prelight imxt-grid-row"; - if (getTreeState().isNodeSelected(item.getDefaultModelObject())) { + if (getTreeState().isNodeSelected(item.getDefaultModelObject())) + { klass = klass + " imxt-selected"; } tag.put("class", klass); @@ -70,13 +79,17 @@ public void onComponentTag(Component component, ComponentTag tag) { } @Override - protected void addComponent(AjaxRequestTarget target, Component component) { - if (component == this) { + protected void addComponent(AjaxRequestTarget target, Component component) + { + if (component == this) + { // can't refresh this component directly because of setRenderBodyOnly(true) that's set // in // constructor target.add(findParent(TreeGrid.class)); - } else { + } + else + { super.addComponent(target, component); } } @@ -85,7 +98,8 @@ protected void addComponent(AjaxRequestTarget target, Component component) { * @see org.apache.wicket.markup.html.tree.AbstractTree#isForceRebuildOnSelectionChange() */ @Override - protected boolean isForceRebuildOnSelectionChange() { + protected boolean isForceRebuildOnSelectionChange() + { return false; } @@ -93,7 +107,7 @@ boolean isNodeExpanded2(Object object) { return super.isNodeExpanded(object); } - + protected abstract Collection getActiveColumns(); protected abstract void rowPopulated(WebMarkupContainer item); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreePanel.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreePanel.java index 5a7770584e..1fbfaa0ba7 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreePanel.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/grid/treegrid/TreePanel.java @@ -25,31 +25,35 @@ * * @author Matej Knopp */ -public abstract class TreePanel extends Panel { +public abstract class TreePanel extends Panel +{ private static final String JUNCTION_LINK_ID = "junctionLink"; private static final String NODE_COMPONENT_ID = "nodeComponent"; /** * Constructor. + * * @param id - * component id + * component id * @param model - * model to access the {@link TreeNode} + * model to access the {@link TreeNode} * @param level - * node depth level - */ - public TreePanel(String id, final IModel model, int level) { + * node depth level + */ + public TreePanel(String id, final IModel model, int level) + { super(id, model); this.level = level; } - + private final int level; - + @Override - protected void onInitialize() { + protected void onInitialize() + { super.onInitialize(); - + // add junction link Object node = getDefaultModelObject(); Component junctionLink = newJunctionLink(this, JUNCTION_LINK_ID, node); @@ -60,16 +64,18 @@ protected void onInitialize() { Component nodeComponent = newNodeComponent(NODE_COMPONENT_ID, getDefaultModel()); add(nodeComponent); - IconImage icon = new IconImage("icon", new IconModel()) { + IconImage icon = new IconImage("icon", new IconModel()) + { private static final long serialVersionUID = 1L; @Override - public boolean isVisible() { + public boolean isVisible() + { return getIcon() != null; } }; icon.add(IconBorder.INSTANCE); - add(icon); + add(icon); } /** @@ -77,8 +83,9 @@ public boolean isVisible() { * * @return icon component */ - public IconImage getIconComponent() { - return (IconImage) get("icon"); + public IconImage getIconComponent() + { + return (IconImage)get("icon"); } /** @@ -86,27 +93,31 @@ public IconImage getIconComponent() { * * @author Matej Knopp */ - private class IconModel implements IModel { + private class IconModel implements IModel + { private static final long serialVersionUID = 1L; /** * {@inheritDoc} */ - public Object getObject() { + public Object getObject() + { return getIcon(getDefaultModel()); } /** * {@inheritDoc} */ - public void setObject(Object object) { + public void setObject(Object object) + { throw new UnsupportedOperationException(); } /** * {@inheritDoc} */ - public void detach() { + public void detach() + { } }; @@ -131,13 +142,12 @@ public void detach() { protected abstract Component newNodeComponent(String id, IModel model); /** - * Very simple border that adds a proper - * - * around an icon + * Very simple border that adds a proper around an icon * * @author Matej Knopp */ - private static class IconBorder extends Behavior { + private static class IconBorder extends Behavior + { private static final long serialVersionUID = 1L; @@ -145,7 +155,8 @@ private static class IconBorder extends Behavior { * {@inheritDoc} */ @Override - public void beforeRender(Component component) { + public void beforeRender(Component component) + { RequestCycle.get().getResponse().write(""); } @@ -153,7 +164,8 @@ public void beforeRender(Component component) { * {@inheritDoc} */ @Override - public void afterRender(Component component) { + public void afterRender(Component component) + { RequestCycle.get().getResponse().write(""); } @@ -165,7 +177,8 @@ public void afterRender(Component component) { * * @author Matej Knopp */ - private static class JunctionBorder extends Behavior { + private static class JunctionBorder extends Behavior + { private static final long serialVersionUID = 1L; private final int level; @@ -176,7 +189,8 @@ private static class JunctionBorder extends Behavior { * @param node * @param level */ - public JunctionBorder(Object node, int level) { + public JunctionBorder(Object node, int level) + { this.level = level; } @@ -184,7 +198,8 @@ public JunctionBorder(Object node, int level) { * {@inheritDoc} */ @Override - public void afterRender(Component component) { + public void afterRender(Component component) + { RequestCycle.get().getResponse().write(""); } @@ -192,18 +207,21 @@ public void afterRender(Component component) { * {@inheritDoc} */ @Override - public void beforeRender(Component component) { + public void beforeRender(Component component) + { Response response = RequestCycle.get().getResponse(); - for (int i = level - 1; i >= 0; --i) { + for (int i = level - 1; i >= 0; --i) + { response.write(""); } response.write(""); - } + } }; - private TreeGridBody getTreeGridBody() { + private TreeGridBody getTreeGridBody() + { return findParent(TreeGridBody.class); }; @@ -219,45 +237,61 @@ private TreeGridBody getTreeGridBody() { * tree node for which the link should be created. * @return The link component */ - protected Component newJunctionLink(MarkupContainer parent, final String id, final Object node) { + protected Component newJunctionLink(MarkupContainer parent, final String id, final Object node) + { final MarkupContainer junctionLink; - TreeModel model = (TreeModel) getTreeGridBody().getDefaultModelObject(); - if (model.isLeaf(node) == false) { - junctionLink = newLink(id, new ILinkCallback() { + TreeModel model = (TreeModel)getTreeGridBody().getDefaultModelObject(); + if (model.isLeaf(node) == false) + { + junctionLink = newLink(id, new ILinkCallback() + { private static final long serialVersionUID = 1L; - public void onClick(AjaxRequestTarget target) { - if (getTreeGridBody().isNodeExpanded2(node)) { + public void onClick(AjaxRequestTarget target) + { + if (getTreeGridBody().isNodeExpanded2(node)) + { getTreeGridBody().getTreeState().collapseNode(node); - } else { + } + else + { getTreeGridBody().getTreeState().expandNode(node); } onJunctionLinkClicked(target, node); getTreeGridBody().updateTree(target); } }); - junctionLink.add(new Behavior() { + junctionLink.add(new Behavior() + { private static final long serialVersionUID = 1L; @Override - public void onComponentTag(Component component, ComponentTag tag) { - if (getTreeGridBody().isNodeExpanded2(node)) { + public void onComponentTag(Component component, ComponentTag tag) + { + if (getTreeGridBody().isNodeExpanded2(node)) + { tag.put("class", "imxt-junction-open"); - } else { + } + else + { tag.put("class", "imxt-junction-closed"); } } }); - } else { - junctionLink = new WebMarkupContainer(id) { + } + else + { + junctionLink = new WebMarkupContainer(id) + { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag) */ @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); tag.setName("span"); } @@ -273,7 +307,8 @@ protected void onComponentTag(ComponentTag tag) { * * @author Matej Knopp */ - public interface ILinkCallback extends IClusterable { + public interface ILinkCallback extends IClusterable + { /** * Called when the click is executed. * @@ -293,19 +328,23 @@ public interface ILinkCallback extends IClusterable { * The link call back * @return The link component */ - public MarkupContainer newLink(String id, final ILinkCallback callback) { - return new AjaxSubmitLink(id) { + public MarkupContainer newLink(String id, final ILinkCallback callback) + { + return new AjaxSubmitLink(id) + { private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { + protected void onSubmit(AjaxRequestTarget target, Form form) + { callback.onClick(target); } @Override - protected void onError(AjaxRequestTarget target, Form form) { - - } + protected void onError(AjaxRequestTarget target, Form form) + { + + } }.setDefaultFormProcessing(false); } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/Icon.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/Icon.java index c3e850ba02..81bc77d17a 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/Icon.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/Icon.java @@ -7,22 +7,26 @@ * * @author Matej Knopp */ -public interface Icon extends Serializable { - +public interface Icon extends Serializable +{ + /** * Returns the URL of icon image. + * * @return icon URL */ public CharSequence getUrl(); /** * Returns the icon width. + * * @return icon width (in pixels) or -1 if the width can not be determined */ public int getWidth(); /** * Returns the icon height. + * * @return icon height (in pixels) or -1 if the height can not be determined */ public int getHeight(); diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/IconImage.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/IconImage.java index 66cefc2cae..f6bb481b6d 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/IconImage.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/IconImage.java @@ -9,79 +9,90 @@ * Simple component that displays an icon. If the component is attached to an <img> tag, the * icon URL is passed as the src attribute, otherwise the icon is set by a CSS * background image property. - * + * * @author Matej Knopp - * + * */ -public class IconImage extends WebMarkupContainer { +public class IconImage extends WebMarkupContainer +{ private static final long serialVersionUID = 1L; /** * Creates a new icon instance. - * + * * @param id * component id */ - public IconImage(String id) { + public IconImage(String id) + { super(id); } /** * Creates a new icon instance. - * + * * @param id * component id * @param icon */ - public IconImage(String id, Icon icon) { + public IconImage(String id, Icon icon) + { this(id, new Model(icon)); } /** * Creates a a new icon instance. - * + * * @param id * component id * @param model * model used to obtain the {@link Icon} instance */ - public IconImage(String id, IModel model) { + public IconImage(String id, IModel model) + { super(id, model); } /** * Returns the icon instance associated with this component. - * + * * @return icon instance */ - public Icon getIcon() { - return (Icon) getDefaultModelObject(); + public Icon getIcon() + { + return (Icon)getDefaultModelObject(); } @Override - protected void onComponentTag(ComponentTag tag) { + protected void onComponentTag(ComponentTag tag) + { super.onComponentTag(tag); Icon icon = getIcon(); - if (tag.getName().toLowerCase().equals("img")) { + if (tag.getName().toLowerCase().equals("img")) + { int width = icon.getWidth(); int height = icon.getHeight(); tag.put("src", icon.getUrl()); - if (width != -1 && height != -1) { + if (width != -1 && height != -1) + { tag.put("width", width); tag.put("height", height); } - } else { + } + else + { CharSequence style = tag.getAttribute("style"); if (style == null) style = ""; else if (style.length() > 0) style = style + ";"; - style = style + "background-image: url('" + icon.getUrl() + "'); background-repeat: no-repeat;"; + style = style + "background-image: url('" + icon.getUrl() + + "'); background-repeat: no-repeat;"; tag.put("style", style); } } diff --git a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/PackageIcon.java b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/PackageIcon.java index 314e800d72..00d421e0ac 100644 --- a/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/PackageIcon.java +++ b/jdk-1.5-parent/inmethod-grid-parent/inmethod-grid/src/main/java/com/inmethod/icon/PackageIcon.java @@ -11,7 +11,8 @@ * * @author Matej Knopp */ -public class PackageIcon implements Icon { +public class PackageIcon implements Icon +{ private static final long serialVersionUID = 1L; @@ -23,7 +24,8 @@ public class PackageIcon implements Icon { * @param reference * resource reference that can be used to get the icon */ - public PackageIcon(ResourceReference reference) { + public PackageIcon(ResourceReference reference) + { this.reference = reference; } @@ -35,28 +37,32 @@ public PackageIcon(ResourceReference reference) { * @param name * Icon name relative to the scope class */ - public PackageIcon(Class scope, String name) { - this.reference = new PackageResourceReference(scope, name); + public PackageIcon(Class scope, String name) + { + reference = new PackageResourceReference(scope, name); } /** * {@inheritDoc} */ - public int getHeight() { + public int getHeight() + { return -1; } /** * {@inheritDoc} */ - public int getWidth() { + public int getWidth() + { return -1; } /** * {@inheritDoc} */ - public CharSequence getUrl() { + public CharSequence getUrl() + { return RequestCycle.get().urlFor(new ResourceReferenceRequestHandler(reference)); } diff --git a/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/HomePage.java b/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/HomePage.java index 96306bc779..960d48aeec 100644 --- a/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/HomePage.java +++ b/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/HomePage.java @@ -21,7 +21,8 @@ /** * Homepage */ -public class HomePage extends WebPage { +public class HomePage extends WebPage +{ private static final long serialVersionUID = 1L; @@ -35,11 +36,12 @@ public class HomePage extends WebPage { * @param parameters * Page parameters */ - public HomePage(final PageParameters parameters) { + public HomePage(final PageParameters parameters) + { // Add the simplest type of label add(new Label("message", - "If you see this message wicket is properly configured and running")); + "If you see this message wicket is properly configured and running")); // TODO Add your page's components here @@ -47,72 +49,82 @@ public HomePage(final PageParameters parameters) { final Label label = new Label("id", labelModel); label.setOutputMarkupId(true); add(label); - Form form = new Form("form") { + Form form = new Form("form") + { @Override - protected void onSubmit() { + protected void onSubmit() + { super.onSubmit(); labelModel.setObject("form was submitted"); } }; add(form); - Button button = new Button("button") { + Button button = new Button("button") + { /** * */ private static final long serialVersionUID = 1L; @Override - public void onSubmit() { + public void onSubmit() + { labelModel.setObject("std btn was clicked"); } }.setDefaultFormProcessing(false); - button.add(new InputBehavior(new KeyType[] { KeyType.b }, - EventType.click)); + button.add(new InputBehavior(new KeyType[] { KeyType.b }, EventType.click)); - form.add(new InputBehavior(new KeyType[] { KeyType.Ctrl, KeyType.a }, - EventType.submit)); + form.add(new InputBehavior(new KeyType[] { KeyType.Ctrl, KeyType.a }, EventType.submit)); form.add(button); Button button2 = new Button("button2").setDefaultFormProcessing(false); - button2.add(new AjaxEventBehavior("onClick") { + button2.add(new AjaxEventBehavior("onClick") + { /** * */ private static final long serialVersionUID = 1L; @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { labelModel.setObject("ajax was fired"); target.add(label); } }); button2.add(new InputBehavior(new KeyType[] { KeyType.c })); form.add(button2); - Link link = new Link("link") { + Link link = new Link("link") + { /** * */ private static final long serialVersionUID = 1L; @Override - public void onClick() { + public void onClick() + { labelModel.setObject("link clicked"); } }; form.add(new TextField("text", new Model("")).add(new InputBehavior( - new KeyType[] { KeyType.Ctrl,KeyType.f }, EventType.focus){ + new KeyType[] { KeyType.Ctrl, KeyType.f }, EventType.focus) + { /** * */ private static final long serialVersionUID = 1L; @Override - protected Boolean getDisable_in_input() { - //remember this for all input behaviors, elsewise the shortcut will be triggered in the text field - // not a problem if combination of keys though - return true; - }})); - + protected Boolean getDisable_in_input() + { + // remember this for all input behaviors, elsewise the shortcut will be triggered in +// the text field + // not a problem if combination of keys though + return true; + } + })); + link.add(new InputBehavior(new KeyType[] { KeyType.e })); add(link); @@ -120,44 +132,48 @@ protected Boolean getDisable_in_input() { add(ajaxContainer); // Counter - final Label counterLabel = new Label("counter", new PropertyModel(this, - "counter")); + final Label counterLabel = new Label("counter", new PropertyModel(this, "counter")); counterLabel.setOutputMarkupId(true); ajaxContainer.add(counterLabel); // Increase - Button increaseButton = new AjaxButton("increase") { + Button increaseButton = new AjaxButton("increase") + { private static final long serialVersionUID = 1L; @Override - public void onSubmit(AjaxRequestTarget target, Form form) { + public void onSubmit(AjaxRequestTarget target, Form form) + { counter++; target.add(counterLabel); } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target, Form form) + { } }; - increaseButton.add(new InputBehavior(new KeyType[] { KeyType.Up }, - EventType.click)); + increaseButton.add(new InputBehavior(new KeyType[] { KeyType.Up }, EventType.click)); ajaxContainer.add(increaseButton); // Refresh - Button refreshButton = new AjaxButton("refresh") { + Button refreshButton = new AjaxButton("refresh") + { private static final long serialVersionUID = 1L; @Override - protected void onSubmit(AjaxRequestTarget target, Form form) { - if (target == null) { - throw new NullPointerException( - "This must be an AJAX request."); + protected void onSubmit(AjaxRequestTarget target, Form form) + { + if (target == null) + { + throw new NullPointerException("This must be an AJAX request."); } target.add(ajaxContainer); } @Override - protected void onError(AjaxRequestTarget target, Form form) { + protected void onError(AjaxRequestTarget target, Form form) + { } }; ajaxContainer.add(refreshButton); diff --git a/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/WicketApplication.java b/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/WicketApplication.java index 2344fa533c..186eecb00d 100644 --- a/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/WicketApplication.java +++ b/jdk-1.5-parent/input-events-parent/input-events-examples/src/main/java/inputexample/WicketApplication.java @@ -3,23 +3,26 @@ 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. + * Application object for your web application. If you want to run this application without + * deploying, run the Start class. * * @see wicket.myproject.Start#main(String[]) */ -public class WicketApplication extends WebApplication { +public class WicketApplication extends WebApplication +{ /** * Constructor */ - public WicketApplication() { + public WicketApplication() + { } /** * @see wicket.Application#getHomePage() */ @Override - public Class getHomePage() { + public Class getHomePage() + { return HomePage.class; } diff --git a/jdk-1.5-parent/input-events-parent/input-events-examples/src/test/java/inputexample/Start.java b/jdk-1.5-parent/input-events-parent/input-events-examples/src/test/java/inputexample/Start.java index 083269265d..ea4fa37c0f 100644 --- a/jdk-1.5-parent/input-events-parent/input-events-examples/src/test/java/inputexample/Start.java +++ b/jdk-1.5-parent/input-events-parent/input-events-examples/src/test/java/inputexample/Start.java @@ -5,9 +5,11 @@ import org.eclipse.jetty.server.bio.SocketConnector; import org.eclipse.jetty.webapp.WebAppContext; -public class Start { +public class Start +{ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception + { Server server = new Server(); SocketConnector connector = new SocketConnector(); connector.setPort(8080); @@ -18,24 +20,28 @@ public static void main(String[] args) throws Exception { bb.setContextPath("/inputExamples"); bb.setWar("src/main/webapp"); - + // START JMX SERVER // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); // server.getContainer().addEventListener(mBeanContainer); // mBeanContainer.start(); - + server.setHandler(bb); - try { + try + { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); - while (System.in.available() == 0) { + while (System.in.available() == 0) + { Thread.sleep(5000); } server.stop(); server.join(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); System.exit(100); } diff --git a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/EventType.java b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/EventType.java index a01d453af6..505b870e10 100644 --- a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/EventType.java +++ b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/EventType.java @@ -14,21 +14,27 @@ * the License. */ package wicket.contrib.input.events; + /** * holds events + * * @author Nino Martinez Wael (nino.martinez@jayway.dk) - * + * */ -public enum EventType { - dbclick,click,focus,blur, change,submit, onclick; - +public enum EventType +{ + dbclick, click, focus, blur, change, submit, onclick; + private String eventType; - - private EventType() { - eventType=this.name(); - + + private EventType() + { + eventType = name(); + } - public String getEvent() { + + public String getEvent() + { return eventType; } diff --git a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/InputBehavior.java b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/InputBehavior.java index dd94b58d49..cb5e0512a4 100644 --- a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/InputBehavior.java +++ b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/InputBehavior.java @@ -35,64 +35,64 @@ /** * Add this to your button, link whatever to create a shortcut key.. - * - * WARNING:this behavior uses a special script for calling - * window.onload - * - * @author Nino Martinez (nino.martinez.wael *at* gmail *dot* com remember no - * stars) - * + * + * WARNING:this behavior uses a special script for calling window.onload + * + * @author Nino Martinez (nino.martinez.wael *at* gmail *dot* com remember no stars) + * */ -public class InputBehavior extends Behavior { +public class InputBehavior extends Behavior +{ private ResourceReference SHORTCUTS_JAVASCRIPT = new CompressedResourceReference( - InputBehavior.class, "shortcuts.js"); + InputBehavior.class, "shortcuts.js"); private final KeyType[] keyCombo; private EventType eventType; private boolean autoHook = false; private boolean linkUnbound = false; - private final TextTemplate shortcutJs = new PackageTextTemplate( - InputBehavior.class, "wicket-contrib-input-behavior.js"); - private final TextTemplate shortcutJsAutoHook = new PackageTextTemplate( - InputBehavior.class, "wicket-contrib-input-behavior-autohook.js"); + private final TextTemplate shortcutJs = new PackageTextTemplate(InputBehavior.class, + "wicket-contrib-input-behavior.js"); + private final TextTemplate shortcutJsAutoHook = new PackageTextTemplate(InputBehavior.class, + "wicket-contrib-input-behavior-autohook.js"); private final TextTemplate shortcutJsAutoHookLink = new PackageTextTemplate( - InputBehavior.class, - "wicket-contrib-input-behavior-autohook-link.js"); + InputBehavior.class, "wicket-contrib-input-behavior-autohook-link.js"); - public InputBehavior(KeyType[] keyCombo, EventType eventType) { + public InputBehavior(KeyType[] keyCombo, EventType eventType) + { this.keyCombo = keyCombo; this.eventType = eventType; } /** - * if using auto hook be sure to add this behavior last, otherwise it might - * not pickup the event.. Also it will only hook up to the last event if - * more are present (use other constructor to specify manually) - * - * + * if using auto hook be sure to add this behavior last, otherwise it might not pickup the + * event.. Also it will only hook up to the last event if more are present (use other + * constructor to specify manually) + * + * * Note on keyCombo - * - * The shortcut keys should be specified in this format ... - * Modifier[+Modifier..]+Key - * - * Meaning that you should specify in this order, modifier keys first like - * 'ctrl' and then normal keys like 'a' - * + * + * The shortcut keys should be specified in this format ... Modifier[+Modifier..]+Key + * + * Meaning that you should specify in this order, modifier keys first like 'ctrl' and then + * normal keys like 'a' + * * @param keyCombo * @param autoHook */ - public InputBehavior(KeyType[] keyCombo) { + public InputBehavior(KeyType[] keyCombo) + { this.keyCombo = keyCombo; - this.autoHook = true; + autoHook = true; } /** The target component. */ private Component component; @Override - public void bind(Component component) { + public void bind(Component component) + { super.bind(component); this.component = component; component.setOutputMarkupId(true); @@ -100,37 +100,44 @@ public void bind(Component component) { } /** - * Gets the escaped DOM id that the input will get attached to. All non word - * characters (\W) will be removed from the string. - * + * Gets the escaped DOM id that the input will get attached to. All non word characters (\W) + * will be removed from the string. + * * @return The DOM id of the input - same as the component's markup id} */ - protected final String getEscapedComponentMarkupId() { + protected final String getEscapedComponentMarkupId() + { return component.getMarkupId().replaceAll("\\W", ""); } @Override - public void renderHead(Component c, IHeaderResponse response) { + public void renderHead(Component c, IHeaderResponse response) + { super.renderHead(c, response); response.renderJavaScriptReference(SHORTCUTS_JAVASCRIPT); - if (!autoHook) { + if (!autoHook) + { response.renderOnLoadJavaScript(generateString(shortcutJs)); } } @Override - public void onComponentTag(Component component, ComponentTag tag) { + public void onComponentTag(Component component, ComponentTag tag) + { super.onComponentTag(component, tag); - if (autoHook) { + if (autoHook) + { IValueMap attribs = tag.getAttributes(); - for (String attrib : attribs.keySet()) { + for (String attrib : attribs.keySet()) + { List list = Arrays.asList(EventType.values()); - for (EventType e : list) { - if (attrib.toLowerCase().contains( - e.toString().toLowerCase())) { + for (EventType e : list) + { + if (attrib.toLowerCase().contains(e.toString().toLowerCase())) + { eventType = e; } @@ -138,7 +145,8 @@ public void onComponentTag(Component component, ComponentTag tag) { } // Try to bind to link so shortcut will work. Should only be done if // no other handlers were found - if (component instanceof Link && eventType == null) { + if (component instanceof Link && eventType == null) + { linkUnbound = true; return; } @@ -147,21 +155,27 @@ public void onComponentTag(Component component, ComponentTag tag) { } @Override - public void afterRender(Component component) { + public void afterRender(Component component) + { // TODO Auto-generated method stub super.afterRender(component); - if (autoHook) { + if (autoHook) + { Response response = component.getResponse(); - if (linkUnbound) { + if (linkUnbound) + { response.write(generateString(shortcutJsAutoHookLink)); - } else { + } + else + { response.write(generateString(shortcutJsAutoHook)); } } } - private String generateString(TextTemplate textTemplate) { + private String generateString(TextTemplate textTemplate) + { // variables for the initialization script HashMap variables = new HashMap(); String widgetId = getEscapedComponentMarkupId(); @@ -169,16 +183,21 @@ private String generateString(TextTemplate textTemplate) { String keyComboString = ""; boolean first = true; - for (KeyType keyType : keyCombo) { - if (first) { + for (KeyType keyType : keyCombo) + { + if (first) + { first = false; - } else { + } + else + { keyComboString += "+"; } keyComboString += keyType.getKeyCode(); } - if (eventType != null) { + if (eventType != null) + { variables.put("event", eventType.toString()); } variables.put("keys", keyComboString); @@ -195,41 +214,45 @@ private String generateString(TextTemplate textTemplate) { } /** - * If this is set to true, keyboard capture will be disabled in input and - * textarea fields. If these elements have focus, the keyboard shortcut will - * not work. This is very useful for single key shortcuts. Default: false - * + * If this is set to true, keyboard capture will be disabled in input and textarea fields. If + * these elements have focus, the keyboard shortcut will not work. This is very useful for + * single key shortcuts. Default: false + * * @return */ - protected Boolean getDisable_in_input() { + protected Boolean getDisable_in_input() + { return false; } /** * The event type - can be 'keydown','keyup','keypress'. Default: 'keydown' - * + * * @return */ - protected KeyHookOn getType() { + protected KeyHookOn getType() + { return KeyHookOn.keydown; } /** * Should the command be passed onto the browser afterwards? - * + * * @return */ - protected Boolean getPropagate() { + protected Boolean getPropagate() + { return false; } /** - * target - DOM Node The element that should be watched for the keyboard - * event. Default : document - * + * target - DOM Node The element that should be watched for the keyboard event. Default : + * document + * * @return */ - protected String getTarget() { + protected String getTarget() + { return "document"; } diff --git a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyHookOn.java b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyHookOn.java index d02f8f7326..6cdd680a1f 100644 --- a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyHookOn.java +++ b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyHookOn.java @@ -18,10 +18,12 @@ */ package wicket.contrib.input.events.key; -public enum KeyHookOn { +public enum KeyHookOn +{ keydown, keyup, keypress; - private KeyHookOn() { + private KeyHookOn() + { } } diff --git a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyType.java b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyType.java index 4744bad87a..4bd557f698 100644 --- a/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyType.java +++ b/jdk-1.5-parent/input-events-parent/input-events/src/main/java/wicket/contrib/input/events/key/KeyType.java @@ -18,33 +18,34 @@ /** * * @author Nino Martinez (nino.martinez.wael *at* gmail *dot* com remember no stars) - * + * */ -public enum KeyType { +public enum KeyType +{ - Ctrl, Shift, Alt, Meta, - a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, - zero("0"), one("1"), two("2"), three("3"), four("4"), five("5"), six("6"), seven("7"), eight("8"), nine("9"), - Escape, Tab, Space, Return, Enter, Backspace, - Scroll_lock, Caps_lock, Num_lock, Pause, - Insert, Delete, Home, End, Page_up, Page_down, - Left, Up, Right, Down, - F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12; + Ctrl, Shift, Alt, Meta, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, zero( + "0"), one("1"), two("2"), three("3"), four("4"), five("5"), six("6"), seven("7"), eight("8"), nine( + "9"), Escape, Tab, Space, Return, Enter, Backspace, Scroll_lock, Caps_lock, Num_lock, Pause, Insert, Delete, Home, End, Page_up, Page_down, Left, Up, Right, Down, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12; private final String keyCode; -/** - * future thing if keyCode should be used. - * @param keyCode - */ - private KeyType(String keyCode) { + + /** + * future thing if keyCode should be used. + * + * @param keyCode + */ + private KeyType(String keyCode) + { this.keyCode = keyCode; } - private KeyType() { - keyCode = this.name(); + private KeyType() + { + keyCode = name(); } - public String getKeyCode() { + public String getKeyCode() + { return keyCode; } diff --git a/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/InputEventsTest.java b/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/InputEventsTest.java index 3ba19d96ee..69c69e1b1f 100644 --- a/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/InputEventsTest.java +++ b/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/InputEventsTest.java @@ -15,8 +15,10 @@ */ package wicket.contrib.input.events; -public class InputEventsTest extends WicketTestCase { - public void testCorrectComponentBinding() { +public class InputEventsTest extends WicketTestCase +{ + public void testCorrectComponentBinding() + { tester.startPage(Page.class); tester.dumpPage(); } diff --git a/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/Page.java b/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/Page.java index f7244498aa..54d6e78f6b 100644 --- a/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/Page.java +++ b/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/Page.java @@ -28,60 +28,71 @@ * the License. */ -public class Page extends WebPage { +public class Page extends WebPage +{ /** * */ private static final long serialVersionUID = 1L; - public Page() { + public Page() + { Label label = new Label("id"); add(label); - Button button = new Button("button") { + Button button = new Button("button") + { /** * */ private static final long serialVersionUID = 1L; @Override - public void onSubmit() { + public void onSubmit() + { warn("you clicked me!"); } }; - button.add(new AjaxEventBehavior("onClick") { + button.add(new AjaxEventBehavior("onClick") + { @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { // TODO Auto-generated method stub } }); - button.add(new InputBehavior(new KeyType[] { KeyType.b }, - EventType.click)); + button.add(new InputBehavior(new KeyType[] { KeyType.b }, EventType.click)); add(button); - Button button2 = new Button("button2") { + Button button2 = new Button("button2") + { /** * */ private static final long serialVersionUID = 1L; @Override - public void onSubmit() { + public void onSubmit() + { warn("you clicked me!"); } }; - button2.add(new AjaxEventBehavior("onClick") { + button2.add(new AjaxEventBehavior("onClick") + { @Override - protected void onEvent(AjaxRequestTarget target) { + protected void onEvent(AjaxRequestTarget target) + { // TODO Auto-generated method stub } }); button2.add(new InputBehavior(new KeyType[] { KeyType.a })); add(button2); - Link link = new Link("link") { + Link link = new Link("link") + { @Override - public void onClick() { + public void onClick() + { } }; diff --git a/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/WicketTestCase.java b/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/WicketTestCase.java index 09d37cc675..87f91553b9 100644 --- a/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/WicketTestCase.java +++ b/jdk-1.5-parent/input-events-parent/input-events/src/test/java/wicket/contrib/input/events/WicketTestCase.java @@ -25,18 +25,20 @@ /** * Base class for tests which require comparing wicket response with a file. *

- * To create/replace the expected result file with the new content, define the - * system property like -Dwicket.replace.expected.results=true + * To create/replace the expected result file with the new content, define the system property like + * -Dwicket.replace.expected.results=true * */ -public abstract class WicketTestCase extends TestCase { +public abstract class WicketTestCase extends TestCase +{ /** */ public WicketTester tester; /** * Constructor */ - public WicketTestCase() { + public WicketTestCase() + { } /** @@ -45,7 +47,8 @@ public WicketTestCase() { * @param name * The test name */ - public WicketTestCase(String name) { + public WicketTestCase(String name) + { super(name); } @@ -53,7 +56,8 @@ public WicketTestCase(String name) { * @see junit.framework.TestCase#setUp() */ @Override - protected void setUp() throws Exception { + protected void setUp() throws Exception + { tester = new WicketTester(); } @@ -61,20 +65,21 @@ protected void setUp() throws Exception { * @see junit.framework.TestCase#tearDown() */ @Override - protected void tearDown() throws Exception { + protected void tearDown() throws Exception + { tester.destroy(); } /** - * Use -Dwicket.replace.expected.results=true to - * automatically replace the expected output file. + * Use -Dwicket.replace.expected.results=true to automatically replace the expected + * output file. * * @param pageClass * @param filename * @throws Exception */ - protected void executeTest(final Class pageClass, final String filename) - throws Exception { + protected void executeTest(final Class pageClass, final String filename) throws Exception + { System.out.println("=== " + pageClass.getName() + " ==="); tester.startPage(pageClass); tester.assertRenderedPage(pageClass); @@ -89,12 +94,13 @@ protected void executeTest(final Class pageClass, final String filename) * @param filename * @throws Exception */ - protected void executedListener(final Class clazz, - final Component component, final String filename) throws Exception { + protected void executedListener(final Class clazz, final Component component, + final String filename) throws Exception + { assertNotNull(component); - System.out.println("=== " + clazz.getName() + " : " - + component.getPageRelativePath() + " ==="); + System.out.println("=== " + clazz.getName() + " : " + component.getPageRelativePath() + + " ==="); tester.executeListener(component); tester.assertResultPage(clazz, filename); @@ -107,13 +113,12 @@ protected void executedListener(final Class clazz, * @param filename * @throws Exception */ - protected void executedBehavior(final Class clazz, - final AbstractAjaxBehavior behavior, final String filename) - throws Exception { + protected void executedBehavior(final Class clazz, final AbstractAjaxBehavior behavior, + final String filename) throws Exception + { assertNotNull(behavior); - System.out.println("=== " + clazz.getName() + " : " - + behavior.toString() + " ==="); + System.out.println("=== " + clazz.getName() + " : " + behavior.toString() + " ==="); tester.executeBehavior(behavior); tester.assertResultPage(clazz, filename); diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/Index.java b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/Index.java index 5edaf62066..21f3347c59 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/Index.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/Index.java @@ -19,10 +19,12 @@ * * @author Eelco Hillenius */ -public class Index extends WebPage { +public class Index extends WebPage +{ /** * Constructor */ - public Index() { + public Index() + { } } \ No newline at end of file diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/ReportLinksPage.java b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/ReportLinksPage.java index edc18827e6..fe6767298f 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/ReportLinksPage.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/ReportLinksPage.java @@ -35,33 +35,46 @@ * * @author Eelco Hillenius */ -public class ReportLinksPage extends WebPage { +public class ReportLinksPage extends WebPage +{ /** * Constructor. */ - public ReportLinksPage() { - ServletContext context = ((WebApplication) getApplication()).getServletContext(); + public ReportLinksPage() + { + ServletContext context = ((WebApplication)getApplication()).getServletContext(); final File reportFile = new File(context.getRealPath("/reports/WebappReport.jasper")); final Map parameters = new HashMap(); parameters.put("BaseDir", new File(context.getRealPath("/reports"))); - JRResource pdfResource = new JRConcreteResource(reportFile, new PdfResourceHandler()).setReportParameters(parameters).setReportDataSource(new WebappDataSource()); + JRResource pdfResource = new JRConcreteResource(reportFile, new PdfResourceHandler()).setReportParameters( + parameters) + .setReportDataSource(new WebappDataSource()); add(new ResourceLink("linkToPdf", pdfResource)); - JRResource rtfResource = new JRConcreteResource(reportFile, new RtfResourceHandler()).setReportParameters(parameters).setReportDataSource(new WebappDataSource()); + JRResource rtfResource = new JRConcreteResource(reportFile, new RtfResourceHandler()).setReportParameters( + parameters) + .setReportDataSource(new WebappDataSource()); add(new ResourceLink("linkToRtf", rtfResource)); - JRResource htmlResource = new JRConcreteResource(reportFile, new HtmlResourceHandler()).setReportParameters(parameters).setReportDataSource(new WebappDataSource()); + JRResource htmlResource = new JRConcreteResource(reportFile, new HtmlResourceHandler()).setReportParameters( + parameters) + .setReportDataSource(new WebappDataSource()); add(new ResourceLink("linkToHtml", htmlResource)); - JRResource textResource = new JRConcreteResource(reportFile, new TextResourceHandler()).setReportParameters(parameters).setReportDataSource(new WebappDataSource()); + JRResource textResource = new JRConcreteResource(reportFile, new TextResourceHandler()).setReportParameters( + parameters) + .setReportDataSource(new WebappDataSource()); add(new ResourceLink("linkToText", textResource)); - JRResource imageResource = new JRImageResource(reportFile).setReportParameters(parameters).setReportDataSource(new WebappDataSource()); + JRResource imageResource = new JRImageResource(reportFile).setReportParameters(parameters) + .setReportDataSource(new WebappDataSource()); add(new ResourceLink("linkToImage", imageResource)); - JRResource csvResource = new JRConcreteResource(reportFile, new CsvResourceHandler()).setReportParameters(parameters).setReportDataSource(new WebappDataSource()); + JRResource csvResource = new JRConcreteResource(reportFile, new CsvResourceHandler()).setReportParameters( + parameters) + .setReportDataSource(new WebappDataSource()); add(new ResourceLink("linkToCsv", csvResource)); } @@ -69,7 +82,8 @@ public ReportLinksPage() { * @see org.apache.wicket.Component#isVersioned() */ @Override - public boolean isVersioned() { + public boolean isVersioned() + { return false; } } \ No newline at end of file diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/SimplePdfPage.java b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/SimplePdfPage.java index 355d6436ef..920040e2af 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/SimplePdfPage.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/SimplePdfPage.java @@ -30,17 +30,21 @@ * * @author Eelco Hillenius */ -public class SimplePdfPage extends WebPage { +public class SimplePdfPage extends WebPage +{ /** * Constructor. */ - public SimplePdfPage() { - ServletContext context = ((WebApplication) getApplication()).getServletContext(); + public SimplePdfPage() + { + ServletContext context = ((WebApplication)getApplication()).getServletContext(); final File reportFile = new File(context.getRealPath("/reports/WebappReport.jasper")); final Map parameters = new HashMap(); parameters.put("BaseDir", new File(context.getRealPath("/reports"))); - JRResource pdfResource = new JRConcreteResource(reportFile, new PdfResourceHandler()).setReportParameters(parameters).setReportDataSource(new WebappDataSource()); + JRResource pdfResource = new JRConcreteResource(reportFile, new PdfResourceHandler()).setReportParameters( + parameters) + .setReportDataSource(new WebappDataSource()); add(new EmbeddedJRReport("report", pdfResource)); } @@ -48,7 +52,8 @@ public SimplePdfPage() { * @see org.apache.wicket.Component#isVersioned() */ @Override - public boolean isVersioned() { + public boolean isVersioned() + { return false; } } \ No newline at end of file diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/WebappDataSource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/WebappDataSource.java index 17f4e4d336..511cacb64c 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/WebappDataSource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/main/java/org/wicketstuff/jasperreports/examples/WebappDataSource.java @@ -45,42 +45,39 @@ public class WebappDataSource implements Serializable, JRDataSource /** * */ - private Object[][] data = - { - {"Berne", new Integer(22), "Bill Ott", "250 - 20th Ave."}, - {"Berne", new Integer(9), "James Schneider", "277 Seventh Av."}, - {"Boston", new Integer(32), "Michael Ott", "339 College Av."}, - {"Boston", new Integer(23), "Julia Heiniger", "358 College Av."}, - {"Chicago", new Integer(39), "Mary Karsen", "202 College Av."}, - {"Chicago", new Integer(35), "George Karsen", "412 College Av."}, - {"Chicago", new Integer(11), "Julia White", "412 Upland Pl."}, - {"Dallas", new Integer(47), "Janet Fuller", "445 Upland Pl."}, - {"Dallas", new Integer(43), "Susanne Smith", "2 Upland Pl."}, - {"Dallas", new Integer(40), "Susanne Miller", "440 - 20th Ave."}, - {"Dallas", new Integer(36), "John Steel", "276 Upland Pl."}, - {"Dallas", new Integer(37), "Michael Clancy", "19 Seventh Av."}, - {"Dallas", new Integer(19), "Susanne Heiniger", "86 - 20th Ave."}, - {"Dallas", new Integer(10), "Anne Fuller", "135 Upland Pl."}, - {"Dallas", new Integer(4), "Sylvia Ringer", "365 College Av."}, - {"Dallas", new Integer(0), "Laura Steel", "429 Seventh Av."}, - {"Lyon", new Integer(38), "Andrew Heiniger", "347 College Av."}, - {"Lyon", new Integer(28), "Susanne White", "74 - 20th Ave."}, - {"Lyon", new Integer(17), "Laura Ott", "443 Seventh Av."}, - {"Lyon", new Integer(2), "Anne Miller", "20 Upland Pl."}, - {"New York", new Integer(46), "Andrew May", "172 Seventh Av."}, - {"New York", new Integer(44), "Sylvia Ott", "361 College Av."}, - {"New York", new Integer(41), "Bill King", "546 College Av."}, - {"Oslo", new Integer(45), "Janet May", "396 Seventh Av."}, - {"Oslo", new Integer(42), "Robert Ott", "503 Seventh Av."}, - {"Paris", new Integer(25), "Sylvia Steel", "269 College Av."}, - {"Paris", new Integer(18), "Sylvia Fuller", "158 - 20th Ave."}, - {"Paris", new Integer(5), "Laura Miller", "294 Seventh Av."}, - {"San Francisco", new Integer(48), "Robert White", "549 Seventh Av."}, - {"San Francisco", new Integer(7), "James Peterson", "231 Upland Pl."} - }; + private Object[][] data = { { "Berne", new Integer(22), "Bill Ott", "250 - 20th Ave." }, + { "Berne", new Integer(9), "James Schneider", "277 Seventh Av." }, + { "Boston", new Integer(32), "Michael Ott", "339 College Av." }, + { "Boston", new Integer(23), "Julia Heiniger", "358 College Av." }, + { "Chicago", new Integer(39), "Mary Karsen", "202 College Av." }, + { "Chicago", new Integer(35), "George Karsen", "412 College Av." }, + { "Chicago", new Integer(11), "Julia White", "412 Upland Pl." }, + { "Dallas", new Integer(47), "Janet Fuller", "445 Upland Pl." }, + { "Dallas", new Integer(43), "Susanne Smith", "2 Upland Pl." }, + { "Dallas", new Integer(40), "Susanne Miller", "440 - 20th Ave." }, + { "Dallas", new Integer(36), "John Steel", "276 Upland Pl." }, + { "Dallas", new Integer(37), "Michael Clancy", "19 Seventh Av." }, + { "Dallas", new Integer(19), "Susanne Heiniger", "86 - 20th Ave." }, + { "Dallas", new Integer(10), "Anne Fuller", "135 Upland Pl." }, + { "Dallas", new Integer(4), "Sylvia Ringer", "365 College Av." }, + { "Dallas", new Integer(0), "Laura Steel", "429 Seventh Av." }, + { "Lyon", new Integer(38), "Andrew Heiniger", "347 College Av." }, + { "Lyon", new Integer(28), "Susanne White", "74 - 20th Ave." }, + { "Lyon", new Integer(17), "Laura Ott", "443 Seventh Av." }, + { "Lyon", new Integer(2), "Anne Miller", "20 Upland Pl." }, + { "New York", new Integer(46), "Andrew May", "172 Seventh Av." }, + { "New York", new Integer(44), "Sylvia Ott", "361 College Av." }, + { "New York", new Integer(41), "Bill King", "546 College Av." }, + { "Oslo", new Integer(45), "Janet May", "396 Seventh Av." }, + { "Oslo", new Integer(42), "Robert Ott", "503 Seventh Av." }, + { "Paris", new Integer(25), "Sylvia Steel", "269 College Av." }, + { "Paris", new Integer(18), "Sylvia Fuller", "158 - 20th Ave." }, + { "Paris", new Integer(5), "Laura Miller", "294 Seventh Av." }, + { "San Francisco", new Integer(48), "Robert White", "549 Seventh Av." }, + { "San Francisco", new Integer(7), "James Peterson", "231 Upland Pl." } }; private int index = -1; - + /** * @@ -107,9 +104,9 @@ public boolean next() throws JRException public Object getFieldValue(JRField field) throws JRException { Object value = null; - + String fieldName = field.getName(); - + if ("City".equals(fieldName)) { value = data[index][0]; @@ -126,7 +123,7 @@ else if ("Street".equals(fieldName)) { value = data[index][3]; } - + return value; } diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/test/java/org/wicketstuff/jasperreports/examples/StartExamples.java b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/test/java/org/wicketstuff/jasperreports/examples/StartExamples.java index e1c96dc172..b12f8cd836 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/test/java/org/wicketstuff/jasperreports/examples/StartExamples.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports-examples/src/test/java/org/wicketstuff/jasperreports/examples/StartExamples.java @@ -24,8 +24,10 @@ import org.eclipse.jetty.webapp.WebAppContext; -public class StartExamples { - public static void main(String[] args) { +public class StartExamples +{ + public static void main(String[] args) + { Server server = new Server(); SocketConnector connector = new SocketConnector(); connector.setPort(8080); @@ -37,9 +39,12 @@ public static void main(String[] args) { context.setWar("src/main/webapp"); server.setHandler(context); - try { + try + { server.start(); - } catch (Exception e) { + } + catch (Exception e) + { throw new RuntimeException(e); } diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/EmbeddedJRReport.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/EmbeddedJRReport.java index d353633f13..41c3a73517 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/EmbeddedJRReport.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/EmbeddedJRReport.java @@ -26,69 +26,65 @@ import org.apache.wicket.request.resource.ResourceReference; /** - * Component for embedding a jasper report in a page. This component must be - * attached to an <object> tag. If you don't want to embed the report, but - * have a link to it instead, use {@link ResourceReference}. - * + * Component for embedding a jasper report in a page. This component must be attached to an + * <object> tag. If you don't want to embed the report, but have a link to it instead, use + * {@link ResourceReference}. + * * @author Justin Lee */ -public final class EmbeddedJRReport extends WebComponent implements - IResourceListener +public final class EmbeddedJRReport extends WebComponent implements IResourceListener { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private final JRResource resource; + private final JRResource resource; - /** - * Construcxt. - * - * @param componentID - * component componentID - * @param resource - * the resource - */ - public EmbeddedJRReport(String componentID, JRResource resource) - { - super(componentID); - this.resource = resource; - } + /** + * Construcxt. + * + * @param componentID + * component componentID + * @param resource + * the resource + */ + public EmbeddedJRReport(String componentID, JRResource resource) + { + super(componentID); + this.resource = resource; + } - /** - * @see org.apache.wicket.IResourceListener#onResourceRequested() - */ - public void onResourceRequested() - { - PageParameters pageParams = null; - final Page page = findPage(); - if (page != null) - pageParams = page.getPageParameters(); + /** + * @see org.apache.wicket.IResourceListener#onResourceRequested() + */ + public void onResourceRequested() + { + PageParameters pageParams = null; + final Page page = findPage(); + if (page != null) + pageParams = page.getPageParameters(); - ResourceRequestHandler reqh = new ResourceRequestHandler(resource, - pageParams); + ResourceRequestHandler reqh = new ResourceRequestHandler(resource, pageParams); - reqh.respond(getRequestCycle()); - } + reqh.respond(getRequestCycle()); + } - /** - * Make sure we work only with object tags - * - * @param tag - * tag applied to component. - * @see org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag) - */ - @Override - protected void onComponentTag(ComponentTag tag) - { - if (!"object".equalsIgnoreCase(tag.getName())) - { - findMarkupStream().throwMarkupException( - "Component " + getId() - + " must be applied to a tag of type 'object' not " - + tag.toUserDebugString()); - } - tag.put("data", getResponse() - .encodeURL(urlFor(IResourceListener.INTERFACE))); - tag.put("type", resource.getContentType()); - super.onComponentTag(tag); - } + /** + * Make sure we work only with object tags + * + * @param tag + * tag applied to component. + * @see org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag) + */ + @Override + protected void onComponentTag(ComponentTag tag) + { + if (!"object".equalsIgnoreCase(tag.getName())) + { + findMarkupStream().throwMarkupException( + "Component " + getId() + " must be applied to a tag of type 'object' not " + + tag.toUserDebugString()); + } + tag.put("data", getResponse().encodeURL(urlFor(IResourceListener.INTERFACE))); + tag.put("type", resource.getContentType()); + super.onComponentTag(tag); + } } \ No newline at end of file diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/IDatabaseConnectionProvider.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/IDatabaseConnectionProvider.java index db78a62f8f..470795d421 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/IDatabaseConnectionProvider.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/IDatabaseConnectionProvider.java @@ -33,8 +33,7 @@ public interface IDatabaseConnectionProvider extends Serializable Connection get(); /** - * Called when the report is generated and the connection can be - * released again. + * Called when the report is generated and the connection can be released again. */ void release(); } \ No newline at end of file diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRConcreteResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRConcreteResource.java index c95242411f..a95663714c 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRConcreteResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRConcreteResource.java @@ -30,15 +30,17 @@ * * @author cdeal */ -public class JRConcreteResource extends JRResource { +public class JRConcreteResource extends JRResource +{ private H handler = null; - + /** * Constructor for JRConcreteResource * * @param handler */ - public JRConcreteResource(H handler) { + public JRConcreteResource(H handler) + { super(); setHandler(handler); } @@ -49,7 +51,8 @@ public JRConcreteResource(H handler) { * @param report * @param handler */ - public JRConcreteResource(InputStream report, H handler) { + public JRConcreteResource(InputStream report, H handler) + { super(report); setHandler(handler); } @@ -60,7 +63,8 @@ public JRConcreteResource(InputStream report, H handler) { * @param report * @param handler */ - public JRConcreteResource(URL report, H handler) { + public JRConcreteResource(URL report, H handler) + { super(report); setHandler(handler); } @@ -71,7 +75,8 @@ public JRConcreteResource(URL report, H handler) { * @param report * @param handler */ - public JRConcreteResource(File report, H handler) { + public JRConcreteResource(File report, H handler) + { super(report); setHandler(handler); } @@ -82,7 +87,8 @@ public JRConcreteResource(File report, H handler) { * @param factory * @param handler */ - public JRConcreteResource(IJasperReportFactory factory, H handler) { + public JRConcreteResource(IJasperReportFactory factory, H handler) + { super(factory); setHandler(handler); } @@ -91,7 +97,8 @@ public JRConcreteResource(IJasperReportFactory factory, H handler) { * @see org.wicketstuff.jasperreports.JRResource#getContentType() */ @Override - public final String getContentType() { + public final String getContentType() + { return handler.getContentType(); } @@ -99,7 +106,8 @@ public final String getContentType() { * @see org.wicketstuff.jasperreports.JRResource#getExtension() */ @Override - public final String getExtension() { + public final String getExtension() + { return handler.getExtension(); } @@ -107,22 +115,27 @@ public final String getExtension() { * @see org.wicketstuff.jasperreports.JRResource#newExporter() */ @Override - public final JRAbstractExporter newExporter() { + public final JRAbstractExporter newExporter() + { return handler.newExporter(); } /** * @return Returns the handler. */ - public final H getHandler() { + public final H getHandler() + { return handler; } /** - * @param handler The handler to set. + * @param handler + * The handler to set. */ - public final void setHandler(H handler) { - if (handler == null) { + public final void setHandler(H handler) + { + if (handler == null) + { throw new IllegalArgumentException("handler is reuqired!"); } this.handler = handler; diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRCsvResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRCsvResource.java index bd1e03c88f..708cdf98ea 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRCsvResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRCsvResource.java @@ -34,8 +34,7 @@ public final class JRCsvResource extends JRConcreteResource { /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRCsvResource() { diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRHtmlResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRHtmlResource.java index 7acf2fa833..4010b2691d 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRHtmlResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRHtmlResource.java @@ -34,8 +34,7 @@ public final class JRHtmlResource extends JRConcreteResource { /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRHtmlResource() { diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRImageResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRImageResource.java index 9ecc5a2666..1cd67f1bb3 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRImageResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRImageResource.java @@ -40,7 +40,7 @@ /** * Resource class for jasper reports PDF resources. - * + * * @author Eelco Hillenius */ public final class JRImageResource extends JRResource @@ -66,8 +66,7 @@ public final class JRImageResource extends JRResource private String format = "png"; /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRImageResource() { @@ -76,7 +75,7 @@ public JRImageResource() /** * Construct. - * + * * @param report * the report input stream */ @@ -87,7 +86,7 @@ public JRImageResource(InputStream report) /** * Construct. - * + * * @param report * the report input stream */ @@ -98,7 +97,7 @@ public JRImageResource(URL report) /** * Construct. - * + * * @param report * the report input stream */ @@ -111,43 +110,44 @@ public JRImageResource(File report) * @see org.wicketstuff.jasperreports.JRResource#newExporter() */ @Override - public final JRAbstractExporter newExporter() + public final JRAbstractExporter newExporter() { - try { + try + { return new JRGraphics2DExporter(); - } catch (JRException e) { + } + catch (JRException e) + { throw new RuntimeException(e); } } @Override - protected byte[] getExporterData(JasperPrint print, - JRAbstractExporter exporter) throws JRException + protected byte[] getExporterData(JasperPrint print, JRAbstractExporter exporter) + throws JRException { - // prepare a stream to trap the exporter's output - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); - exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); + // prepare a stream to trap the exporter's output + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); + exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); - // create an image object - int width = (int) (print.getPageWidth() * getZoomRatio()); - int height = (int) (print.getPageHeight() * getZoomRatio()); - BufferedImage image = new BufferedImage(width, height, type); - exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, image - .getGraphics()); - exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float( - zoomRatio)); + // create an image object + int width = (int)(print.getPageWidth() * getZoomRatio()); + int height = (int)(print.getPageHeight() * getZoomRatio()); + BufferedImage image = new BufferedImage(width, height, type); + exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, image.getGraphics()); + exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoomRatio)); - // execute the export and return the trapped result - exporter.exportReport(); - return toImageData(image); + // execute the export and return the trapped result + exporter.exportReport(); + return toImageData(image); } /** * @param image * The image to turn into data - * + * * @return The image data for this dynamic image */ protected byte[] toImageData(final BufferedImage image) @@ -158,8 +158,7 @@ protected byte[] toImageData(final BufferedImage image) final ByteArrayOutputStream out = new ByteArrayOutputStream(); // Get image writer for format - final ImageWriter writer = ImageIO.getImageWritersByFormatName( - format).next(); + final ImageWriter writer = ImageIO.getImageWritersByFormatName(format).next(); // Write out image writer.setOutput(ImageIO.createImageOutputStream(out)); @@ -170,8 +169,7 @@ protected byte[] toImageData(final BufferedImage image) } catch (IOException e) { - throw new WicketRuntimeException("Unable to convert dynamic image to stream", - e); + throw new WicketRuntimeException("Unable to convert dynamic image to stream", e); } } @@ -179,14 +177,14 @@ protected byte[] toImageData(final BufferedImage image) * @see org.wicketstuff.jasperreports.JRResource#getContentType() */ @Override - public String getContentType() + public String getContentType() { return "image/" + format; } /** * Gets the zoom ratio. - * + * * @return the zoom ratio used for the export. The default value is 1 */ public float getZoomRatio() @@ -196,18 +194,18 @@ public float getZoomRatio() /** * Sets the zoom ratio. - * + * * @param ratio * the zoom ratio used for the export. The default value is 1 */ public void setZoomRatio(float ratio) { - this.zoomRatio = ratio; + zoomRatio = ratio; } /** * Gets the image type. - * + * * @return the image type. The default value is 'png' */ public String getFormat() @@ -217,7 +215,7 @@ public String getFormat() /** * Sets the image type. - * + * * @param format * the image type. The default value is 'png' */ @@ -228,7 +226,7 @@ public void setFormat(String format) /** * Gets type of image (one of BufferedImage.TYPE_*). - * + * * @return type of image */ public int getType() @@ -238,7 +236,7 @@ public int getType() /** * Sets type of image (one of BufferedImage.TYPE_*). - * + * * @param type * type of image */ @@ -251,7 +249,7 @@ public void setType(int type) * @see org.wicketstuff.jasperreports.JRResource#getExtension() */ @Override - public String getExtension() + public String getExtension() { return getFormat(); } diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRPdfResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRPdfResource.java index 9ec8b4138f..5406f07317 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRPdfResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRPdfResource.java @@ -34,8 +34,7 @@ public final class JRPdfResource extends JRConcreteResource { /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRPdfResource() { diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRResource.java index 981aa2dbc5..5f34ae2b09 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRResource.java @@ -41,7 +41,7 @@ /** * Base class for jasper reports resources. - * + * * @author Eelco Hillenius * @author Matej Knopp * @author Luciano Montebove @@ -65,9 +65,8 @@ public abstract class JRResource extends AbstractResource private IJasperReportFactory jasperReportFactory; /** - * The compiled report this resource references. Made transient as we don't - * want our report to be serialized while we can recreate it at other - * servers at will using the factory. + * The compiled report this resource references. Made transient as we don't want our report to + * be serialized while we can recreate it at other servers at will using the factory. */ private transient JasperReport jasperReport; @@ -82,16 +81,14 @@ public abstract class JRResource extends AbstractResource private JRDataSource reportDataSource; /** - * When set, a header 'Content-Disposition: attachment; - * filename="${fileName}"' will be added to the response, resulting in a - * download dialog. No magical extensions are added, so you should make sure - * the file has the extension you want yourself. + * When set, a header 'Content-Disposition: attachment; filename="${fileName}"' will be added to + * the response, resulting in a download dialog. No magical extensions are added, so you should + * make sure the file has the extension you want yourself. */ private String fileName; /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRResource() { @@ -100,7 +97,7 @@ public JRResource() /** * Construct. - * + * * @param report * the report input stream */ @@ -110,7 +107,7 @@ public JRResource(final InputStream report) { public JasperReport newJasperReport() throws JRException { - return (JasperReport) JRLoader.loadObject(report); + return (JasperReport)JRLoader.loadObject(report); } ; @@ -119,7 +116,7 @@ public JasperReport newJasperReport() throws JRException /** * Construct. - * + * * @param report * the report input stream */ @@ -129,7 +126,7 @@ public JRResource(final URL report) { public JasperReport newJasperReport() throws JRException { - return (JasperReport) JRLoader.loadObject(report); + return (JasperReport)JRLoader.loadObject(report); } ; @@ -138,7 +135,7 @@ public JasperReport newJasperReport() throws JRException /** * Construct. - * + * * @param report * the report input stream */ @@ -148,7 +145,7 @@ public JRResource(final File report) { public JasperReport newJasperReport() throws JRException { - return (JasperReport) JRLoader.loadObject(report); + return (JasperReport)JRLoader.loadObject(report); } ; @@ -157,22 +154,21 @@ public JasperReport newJasperReport() throws JRException /** * Construct. - * + * * @param factory * report factory for lazy initialization */ public JRResource(IJasperReportFactory factory) { super(); - this.jasperReportFactory = factory; + jasperReportFactory = factory; } /** - * Gets jasperReport. This implementation uses an internal factory to lazily - * create the report. After creation the report is cached (set as the - * jasperReport property). Override this method in case you want to provide - * some alternative creation/ caching scheme. - * + * Gets jasperReport. This implementation uses an internal factory to lazily create the report. + * After creation the report is cached (set as the jasperReport property). Override this method + * in case you want to provide some alternative creation/ caching scheme. + * * @return jasperReport */ public JasperReport getJasperReport() @@ -194,44 +190,43 @@ public JasperReport getJasperReport() /** * Sets {bjasperReport. - * + * * @param report * report */ public final void setJasperReport(JasperReport report) { - this.jasperReport = report; + jasperReport = report; } /** - * Gets the report parameters. - * Returns a new copy of the reportParameters Map as JasperReports + * Gets the report parameters. Returns a new copy of the reportParameters Map as JasperReports * modifies it with not serializable objects - * + * * @return report parameters */ public Map getReportParameters() { - return new HashMap(reportParameters); + return new HashMap(reportParameters); } /** * Sets the report parameters. - * + * * @param params * report parameters - * + * * @return This */ public final JRResource setReportParameters(Map params) { - this.reportParameters = params; + reportParameters = params; return this; } /** * Gets the datasource if any for filling this report. - * + * * @return the datasource if any for filling this report */ public JRDataSource getReportDataSource() @@ -241,21 +236,21 @@ public JRDataSource getReportDataSource() /** * Sets the datasource if any for filling this report. - * + * * @param dataSource * the datasource if any for filling this report - * + * * @return This */ public JRResource setReportDataSource(JRDataSource dataSource) { - this.reportDataSource = dataSource; + reportDataSource = dataSource; return this; } /** * Gets the connection provider if any for filling this report. - * + * * @return the connection provider if any for filling this report */ public IDatabaseConnectionProvider getConnectionProvider() @@ -265,24 +260,24 @@ public IDatabaseConnectionProvider getConnectionProvider() /** * Sets the connection provider if any for filling this report. - * + * * @param provider * the connection provider if any for filling this report - * + * * @return This */ public final JRResource setConnectionProvider(IDatabaseConnectionProvider provider) { - this.connectionProvider = provider; + connectionProvider = provider; return this; } /** * Gets the file name. When set, a header 'Content-Disposition: attachment; - * filename="${fileName}"' will be added to the response, resulting in a - * download dialog. No magical extensions are added, so you should make sure - * the file has the extension you want yourself. - * + * filename="${fileName}"' will be added to the response, resulting in a download dialog. No + * magical extensions are added, so you should make sure the file has the extension you want + * yourself. + * * @return the file name */ public String getFileName() @@ -295,60 +290,59 @@ public String getFileName() } /** - * Sets the file name. When set, a header 'Content-Disposition: attachment; - * filename="${name}"' will be added to the response, resulting in a - * download dialog. No magical extensions are added, so you should make sure - * the file has the extension you want yourself. - * + * Sets the file name. When set, a header 'Content-Disposition: attachment; filename="${name}"' + * will be added to the response, resulting in a download dialog. No magical extensions are + * added, so you should make sure the file has the extension you want yourself. + * * @param name * the file name - * + * * @return This */ public final JRResource setFileName(String name) { - this.fileName = name; + fileName = name; return this; } /** * Called by getData to obtain an exporter instance. - * + * * @return an exporter instance */ public abstract JRAbstractExporter newExporter(); - /** * @return The content type of the reports */ public abstract String getContentType(); - /** The default is to return the content as an attachment. - * + /** + * The default is to return the content as an attachment. + * * @return The content disposition of the reports */ - public ContentDisposition getContentDisposition() { - return ContentDisposition.ATTACHMENT; + public ContentDisposition getContentDisposition() + { + return ContentDisposition.ATTACHMENT; } /** - * Returns the extension for the resource's file. This string should not - * contain the leading "." - * + * Returns the extension for the resource's file. This string should not contain the leading "." + * * @return The extension for the resource's file. */ public abstract String getExtension(); /** - * Creates a new {@link JasperPrint} instance. This instance is specific for - * this render, but it not yet designated for one output format only. - * + * Creates a new {@link JasperPrint} instance. This instance is specific for this render, but it + * not yet designated for one output format only. + * * @return a new {@link JasperPrint} instance. - * + * * @throws JRException */ protected JasperPrint newJasperPrint() throws JRException @@ -370,11 +364,10 @@ protected JasperPrint newJasperPrint() throws JRException if (provider == null) { throw new IllegalStateException( - "JasperReportsResources must either have a JRDataSource, " - + "or a JDBC Connection provided"); + "JasperReportsResources must either have a JRDataSource, " + + "or a JDBC Connection provided"); } - jasperPrint = JasperFillManager - .fillReport(report, params, provider.get()); + jasperPrint = JasperFillManager.fillReport(report, params, provider.get()); } finally { @@ -390,60 +383,61 @@ protected JasperPrint newJasperPrint() throws JRException @Override protected ResourceResponse newResourceResponse(Attributes attributes) { - ResourceResponse resp = new ResourceResponse(); - resp.disableCaching(); - resp.setContentType(getContentType()); - resp.setFileName(getFileName()); - resp.setContentDisposition(getContentDisposition()); - if (resp.dataNeedsToBeWritten(attributes)) { - resp.setWriteCallback(new WriteCallback() - { - - @Override - public void writeData(Attributes attributes) - { - try - { - long t1 = System.currentTimeMillis(); - // get a print instance for exporting - JasperPrint print = newJasperPrint(); - - // get a fresh instance of an exporter for this report - JRAbstractExporter exporter = newExporter(); - - - final byte[] data = getExporterData(print, exporter); - - attributes.getResponse().write(data); - if (log.isDebugEnabled()) - { - long t2 = System.currentTimeMillis(); - log.debug("loaded report data; bytes: " - + data.length + " in " + (t2 - t1) + " miliseconds"); - } - } - catch (JRException e) - { - throw new WicketRuntimeException(e); - } - } - }); - } - return resp; + ResourceResponse resp = new ResourceResponse(); + resp.disableCaching(); + resp.setContentType(getContentType()); + resp.setFileName(getFileName()); + resp.setContentDisposition(getContentDisposition()); + if (resp.dataNeedsToBeWritten(attributes)) + { + resp.setWriteCallback(new WriteCallback() + { + + @Override + public void writeData(Attributes attributes) + { + try + { + long t1 = System.currentTimeMillis(); + // get a print instance for exporting + JasperPrint print = newJasperPrint(); + + // get a fresh instance of an exporter for this report + JRAbstractExporter exporter = newExporter(); + + + final byte[] data = getExporterData(print, exporter); + + attributes.getResponse().write(data); + if (log.isDebugEnabled()) + { + long t2 = System.currentTimeMillis(); + log.debug("loaded report data; bytes: " + data.length + " in " + + (t2 - t1) + " miliseconds"); + } + } + catch (JRException e) + { + throw new WicketRuntimeException(e); + } + } + }); + } + return resp; } - protected byte[] getExporterData(JasperPrint print, - JRAbstractExporter exporter) throws JRException - { - // prepare a stream to trap the exporter's output - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); - exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); + protected byte[] getExporterData(JasperPrint print, JRAbstractExporter exporter) + throws JRException + { + // prepare a stream to trap the exporter's output + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); + exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); - // execute the export and return the trapped result - exporter.exportReport(); + // execute the export and return the trapped result + exporter.exportReport(); - return baos.toByteArray(); - } + return baos.toByteArray(); + } } \ No newline at end of file diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRRtfResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRRtfResource.java index 9d5b7d21d8..0fbf4dd3fe 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRRtfResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRRtfResource.java @@ -34,8 +34,7 @@ public final class JRRtfResource extends JRConcreteResource { /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRRtfResource() { diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRTextResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRTextResource.java index 15d6f67b8b..7244b64229 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRTextResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRTextResource.java @@ -34,8 +34,7 @@ public final class JRTextResource extends JRConcreteResource { /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRTextResource() { diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRXlsResource.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRXlsResource.java index f05f1d5ba3..45bce8ec3f 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRXlsResource.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/JRXlsResource.java @@ -11,14 +11,13 @@ * * @author Justin Lee * @author cdeal - * @deprecated Use JRConcreteResource(*, new XlsResourceHandler()) + * @deprecated Use JRConcreteResource(*, new XlsResourceHandler()) */ @Deprecated public final class JRXlsResource extends JRConcreteResource { /** - * Construct without a report. You must provide a report before you can use - * this resource. + * Construct without a report. You must provide a report before you can use this resource. */ public JRXlsResource() { diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/CsvResourceHandler.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/CsvResourceHandler.java index 1e21904010..c8712bd6db 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/CsvResourceHandler.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/CsvResourceHandler.java @@ -25,7 +25,8 @@ /** * @author cdeal */ -public class CsvResourceHandler implements IJRResourceHandler, Serializable { +public class CsvResourceHandler implements IJRResourceHandler, Serializable +{ /** * @see org.wicketstuff.jasperreports.handlers.IJRResourceHandler#newExporter() */ diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/HtmlResourceHandler.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/HtmlResourceHandler.java index 2d6e22c5bb..1cf65592a1 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/HtmlResourceHandler.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/HtmlResourceHandler.java @@ -25,7 +25,8 @@ /** * @author cdeal */ -public class HtmlResourceHandler implements IJRResourceHandler, Serializable { +public class HtmlResourceHandler implements IJRResourceHandler, Serializable +{ /** * @see org.wicketstuff.jasperreports.handlers.IJRResourceHandler#newExporter() */ diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/IJRResourceHandler.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/IJRResourceHandler.java index e5ff9a7771..708c50eaa6 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/IJRResourceHandler.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/IJRResourceHandler.java @@ -22,7 +22,8 @@ /** * @author cdeal */ -public interface IJRResourceHandler { +public interface IJRResourceHandler +{ /** * @see org.wicketstuff.jasperreports.JRResource#getContentType() */ diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/PdfResourceHandler.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/PdfResourceHandler.java index ce76a66523..e0bb6e69e1 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/PdfResourceHandler.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/PdfResourceHandler.java @@ -25,7 +25,8 @@ /** * @author cdeal */ -public class PdfResourceHandler implements IJRResourceHandler, Serializable { +public class PdfResourceHandler implements IJRResourceHandler, Serializable +{ /** * @see org.wicketstuff.jasperreports.handlers.IJRResourceHandler#newExporter() */ diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/RtfResourceHandler.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/RtfResourceHandler.java index e1815c3513..cc5e06bfe5 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/RtfResourceHandler.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/RtfResourceHandler.java @@ -25,7 +25,8 @@ /** * @author cdeal */ -public class RtfResourceHandler implements IJRResourceHandler, Serializable { +public class RtfResourceHandler implements IJRResourceHandler, Serializable +{ /** * @see org.wicketstuff.jasperreports.handlers.IJRResourceHandler#newExporter() */ diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/TextResourceHandler.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/TextResourceHandler.java index f352b0b96f..106334a948 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/TextResourceHandler.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/TextResourceHandler.java @@ -26,7 +26,8 @@ /** * @author cdeal */ -public class TextResourceHandler implements IJRResourceHandler, Serializable { +public class TextResourceHandler implements IJRResourceHandler, Serializable +{ /** * an integer representing the page width in characters. */ @@ -55,7 +56,7 @@ public int getPageHeight() */ public void setPageHeight(int height) { - this.pageHeight = height; + pageHeight = height; } /** @@ -76,7 +77,7 @@ public int getPageWidth() */ public void setPageWidth(int width) { - this.pageWidth = width; + pageWidth = width; } /** @@ -86,8 +87,7 @@ public JRAbstractExporter newExporter() { JRTextExporter exporter = new JRTextExporter(); exporter.setParameter(JRTextExporterParameter.PAGE_WIDTH, new Integer(pageWidth)); - exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT, - new Integer(pageHeight)); + exporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT, new Integer(pageHeight)); return exporter; } diff --git a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/XlsResourceHandler.java b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/XlsResourceHandler.java index f66a15c764..cb5712938c 100644 --- a/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/XlsResourceHandler.java +++ b/jdk-1.5-parent/jasperreports-parent/jasperreports/src/main/java/org/wicketstuff/jasperreports/handlers/XlsResourceHandler.java @@ -25,7 +25,8 @@ /** * @author cdeal */ -public class XlsResourceHandler implements IJRResourceHandler, Serializable { +public class XlsResourceHandler implements IJRResourceHandler, Serializable +{ /** * @see org.wicketstuff.jasperreports.handlers.IJRResourceHandler#newExporter() */ diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/Page4AjaxBackButton.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/Page4AjaxBackButton.java index fc9ef3522e..13f4e7be89 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/Page4AjaxBackButton.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/Page4AjaxBackButton.java @@ -5,55 +5,63 @@ import org.apache.wicket.markup.html.panel.FeedbackPanel; import org.wicketstuff.jquery.demo.PageSupport; -/** +/** * A demo page for the Ajax History Manager * - * To add Ajax back button history support to any page you have to do the following things: - * 1) Add {@code HistoryIFrame HistoryIFrame} to the page - * 2) Add {@code HistoryAjaxBehavior HistoryAjaxBehavior} to the page - * 3) For every Ajax component which should have to support back button call "historyAjaxBehavior.registerAjaxEvent(target, theComponentItself)" + * To add Ajax back button history support to any page you have to do the following things: 1) Add + * {@code HistoryIFrame HistoryIFrame} to the page 2) Add + * {@code HistoryAjaxBehavior HistoryAjaxBehavior} to the page 3) For every Ajax component which + * should have to support back button call + * "historyAjaxBehavior.registerAjaxEvent(target, theComponentItself)" * - * Note: This realization of Ajax back/forward button support doesn't work the same way as Wicket supports non-Ajax back button. - * Wicket support for back button works by saving/serializing the whole page instance into the page store - * HistoryAjaxBehavior don't use old instances but just notifies that back/forward button is clicked and the wicket id of - * the component which had triggered the previous Ajax history entry + * Note: This realization of Ajax back/forward button support doesn't work the same way as Wicket + * supports non-Ajax back button. Wicket support for back button works by saving/serializing the + * whole page instance into the page store HistoryAjaxBehavior don't use old instances but just + * notifies that back/forward button is clicked and the wicket id of the component which had + * triggered the previous Ajax history entry * * @author martin-g */ -public class Page4AjaxBackButton extends PageSupport { +public class Page4AjaxBackButton extends PageSupport +{ - public Page4AjaxBackButton() { + public Page4AjaxBackButton() + { /** - * The hidden (CSS position) iframe which will capture the back/forward button clicks + * The hidden (CSS position) iframe which will capture the back/forward button clicks */ final HistoryIFrame historyIFrame = new HistoryIFrame("historyIframe"); add(historyIFrame); - + /** * The Ajax behavior which will be called after each click on back/forward buttons */ - final HistoryAjaxBehavior historyAjaxBehavior = new HistoryAjaxBehavior() { + final HistoryAjaxBehavior historyAjaxBehavior = new HistoryAjaxBehavior() + { private static final long serialVersionUID = 1L; @Override @SuppressWarnings("unchecked") - public void onAjaxHistoryEvent(final AjaxRequestTarget target, final String componentId) { - - ((AjaxLink) Page4AjaxBackButton.this.get(componentId)).onClick(target); + public void onAjaxHistoryEvent(final AjaxRequestTarget target, final String componentId) + { + + ((AjaxLink)Page4AjaxBackButton.this.get(componentId)).onClick(target); } }; add(historyAjaxBehavior); - - final AjaxLink linkOne = new AjaxLink("linkOne") { + + final AjaxLink linkOne = new AjaxLink("linkOne") + { private static final long serialVersionUID = 1L; @Override - public void onClick(final AjaxRequestTarget target) { + public void onClick(final AjaxRequestTarget target) + { info("Link one has been clicked"); target.addChildren(getPage(), FeedbackPanel.class); historyAjaxBehavior.registerAjaxEvent(target, this); @@ -62,12 +70,14 @@ public void onClick(final AjaxRequestTarget target) { }; add(linkOne); - final AjaxLink linkTwo = new AjaxLink("linkTwo") { + final AjaxLink linkTwo = new AjaxLink("linkTwo") + { private static final long serialVersionUID = 1L; @Override - public void onClick(final AjaxRequestTarget target) { + public void onClick(final AjaxRequestTarget target) + { info("Link two has been clicked"); target.addChildren(getPage(), FeedbackPanel.class); historyAjaxBehavior.registerAjaxEvent(target, this); @@ -76,12 +86,14 @@ public void onClick(final AjaxRequestTarget target) { }; add(linkTwo); - final AjaxLink linkThree = new AjaxLink("linkThree") { + final AjaxLink linkThree = new AjaxLink("linkThree") + { private static final long serialVersionUID = 1L; @Override - public void onClick(final AjaxRequestTarget target) { + public void onClick(final AjaxRequestTarget target) + { info("Link three has been clicked"); target.addChildren(getPage(), FeedbackPanel.class); historyAjaxBehavior.registerAjaxEvent(target, this); diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/DemoApplication.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/DemoApplication.java index 15adf53417..a130b94f83 100755 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/DemoApplication.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/DemoApplication.java @@ -28,38 +28,43 @@ import org.wicketstuff.jquery.demo.dnd.Page4ClientSideOnly; import org.wicketstuff.jquery.demo.ui.Page4Slider; -public class DemoApplication extends WebApplication { +public class DemoApplication extends WebApplication +{ - @Override - protected void init() { - getMarkupSettings().setStripWicketTags(true); - mountPackage("/samples", Page4Block.class); - mountPackage("/backbutton", Page4AjaxBackButton.class); - mountPackage("/samples/dnd", Page4ClientSideOnly.class); - mountPackage("/ui", Page4Slider.class); - super.init(); - -// if (Application.DEVELOPMENT.equals(getConfigurationType())) { -// getDebugSettings().setOutputMarkupContainerClassName(true); -// } - } + @Override + protected void init() + { + getMarkupSettings().setStripWicketTags(true); + mountPackage("/samples", Page4Block.class); + mountPackage("/backbutton", Page4AjaxBackButton.class); + mountPackage("/samples/dnd", Page4ClientSideOnly.class); + mountPackage("/ui", Page4Slider.class); + super.init(); - @Override - public Class getHomePage() { - return Page4ClientSideOnly.class; - } +// if (Application.DEVELOPMENT.equals(getConfigurationType())) { +// getDebugSettings().setOutputMarkupContainerClassName(true); +// } + } - @Override - protected IConverterLocator newConverterLocator() { - ConverterLocator back = new ConverterLocator(); - back.set(Date.class, new DateConverter()); - return back; - } - - @Override - public RuntimeConfigurationType getConfigurationType() { - return RuntimeConfigurationType.DEPLOYMENT; -// return RuntimeConfigurationType.DEVELOPMENT; - } + @Override + public Class getHomePage() + { + return Page4ClientSideOnly.class; + } + + @Override + protected IConverterLocator newConverterLocator() + { + ConverterLocator back = new ConverterLocator(); + back.set(Date.class, new DateConverter()); + return back; + } + + @Override + public RuntimeConfigurationType getConfigurationType() + { + return RuntimeConfigurationType.DEPLOYMENT; +// return RuntimeConfigurationType.DEVELOPMENT; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Accordion.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Accordion.java index 376594549d..d944f3323b 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Accordion.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Accordion.java @@ -25,33 +25,43 @@ import org.apache.wicket.model.Model; import org.wicketstuff.jquery.accordion.JQAccordion; -public class Page4Accordion extends PageSupport { +public class Page4Accordion extends PageSupport +{ + + public Page4Accordion() throws Exception + { - public Page4Accordion() throws Exception { - super(); - - add(new JQAccordion("accordion1") { - + + add(new JQAccordion("accordion1") + { + private static final long serialVersionUID = 1L; - + @Override - protected Iterator> getItemModels() { - return new ArrayIteratorAdapter(new String[] { - "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus nec leo. Duis ultricies. In id ipsum vitae ante fringilla", - "volutpat. In pharetra. Ut ante. Vivamus tempus, leo a ullamcorper tincidunt, pede ipsum consectetuer nunc, at pellentesque", - "libero felis in metus. Pellentesque sollicitudin neque. Nulla facilisi. Sed hendrerit tempus orci. Aenean a nulla quis risus molestie vehicula."}) { + protected Iterator> getItemModels() + { + return new ArrayIteratorAdapter( + new String[] { + "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus nec leo. Duis ultricies. In id ipsum vitae ante fringilla", + "volutpat. In pharetra. Ut ante. Vivamus tempus, leo a ullamcorper tincidunt, pede ipsum consectetuer nunc, at pellentesque", + "libero felis in metus. Pellentesque sollicitudin neque. Nulla facilisi. Sed hendrerit tempus orci. Aenean a nulla quis risus molestie vehicula." }) + { @Override - protected IModel model(String obj) { + protected IModel model(String obj) + { return new Model(obj); } }; } + @Override - protected void populateItem(Item item) { - item.add(new Label("title", item.getDefaultModelObjectAsString().substring(0, 15)+" ...")); + protected void populateItem(Item item) + { + item.add(new Label("title", item.getDefaultModelObjectAsString().substring(0, 15) + + " ...")); item.add(new Label("content", item.getDefaultModelObjectAsString())); } }); - } + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Block.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Block.java index 19b74d1cb8..50e6842f74 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Block.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Block.java @@ -7,67 +7,82 @@ import org.wicketstuff.jquery.block.BlockingAjaxLink; @SuppressWarnings("serial") -public class Page4Block extends PageSupport { +public class Page4Block extends PageSupport +{ - public Page4Block() { + public Page4Block() + { - WebMarkupContainer body = new WebMarkupContainer( "demo" ); - add( body ); - - BlockOptions options = new BlockOptions(); - options.setMessage( "Hello!!!" ); - + WebMarkupContainer body = new WebMarkupContainer("demo"); + add(body); - body.add( new BlockingAjaxLink( "ajaxlink", "hello!" ) { - @Override - public void doClick(AjaxRequestTarget target) { - try { - Thread.sleep( 3000 ); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - info( "Clicked link: "+this.toString() ); - target.addChildren( getPage(), FeedbackPanel.class ); - } - }); - - body.add( new BlockingAjaxLink( "block2", "hello!" ) { - @Override - public void doClick(AjaxRequestTarget target) { - try { - Thread.sleep( 3000 ); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - info( "Clicked link: "+this.toString() ); - target.addChildren( getPage(), FeedbackPanel.class ); - } - - @Override - public CharSequence getBlockElementsSelector() { - return "div.blockMe"; - } - }); - - BlockOptions opts = new BlockOptions(); - opts.setFadeIn( 5000 ); - opts.setFadeOut( 0 ); - - body.add( new BlockingAjaxLink( "block3", opts ) { - @Override - public void doClick(AjaxRequestTarget target) { - try { - Thread.sleep( 5000 ); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - info( "Clicked link: "+this.toString() ); - target.addChildren( getPage(), FeedbackPanel.class ); - } - }); + BlockOptions options = new BlockOptions(); + options.setMessage("Hello!!!"); + + + body.add(new BlockingAjaxLink("ajaxlink", "hello!") + { + @Override + public void doClick(AjaxRequestTarget target) + { + try + { + Thread.sleep(3000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + info("Clicked link: " + this.toString()); + target.addChildren(getPage(), FeedbackPanel.class); + } + }); + + body.add(new BlockingAjaxLink("block2", "hello!") + { + @Override + public void doClick(AjaxRequestTarget target) + { + try + { + Thread.sleep(3000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + info("Clicked link: " + this.toString()); + target.addChildren(getPage(), FeedbackPanel.class); + } + + @Override + public CharSequence getBlockElementsSelector() + { + return "div.blockMe"; + } + }); + + BlockOptions opts = new BlockOptions(); + opts.setFadeIn(5000); + opts.setFadeOut(0); + + body.add(new BlockingAjaxLink("block3", opts) + { + @Override + public void doClick(AjaxRequestTarget target) + { + try + { + Thread.sleep(5000); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + info("Clicked link: " + this.toString()); + target.addChildren(getPage(), FeedbackPanel.class); + } + }); } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4DatePicker.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4DatePicker.java index 1078977acb..a4fd9cca56 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4DatePicker.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4DatePicker.java @@ -25,37 +25,44 @@ import org.wicketstuff.jquery.datepicker.DatePickerOptions; @SuppressWarnings("serial") -public class Page4DatePicker extends PageSupport { +public class Page4DatePicker extends PageSupport +{ private static final String DATE_PATTERN = "mm/dd/yyyy"; - + protected Date date01; - protected Date date02; - - public Page4DatePicker() throws Exception { - // note: a Converter for Date.class is registered (see DemoApplication) - - - final DateTextField date01TextField = new DateTextField("date01") { - - @Override - public String getTextFormat() { - return DATE_PATTERN; - } - }; - date01TextField.setMarkupId("date01"); - DatePickerOptions datePickerOptions = new DatePickerOptions().clickInput(true).allowDateInPast(true, DATE_PATTERN); - date01TextField.add(new DatePickerBehavior(datePickerOptions)); - - final Form form = new Form("myForm", new CompoundPropertyModel(this)) { - @Override - protected void onSubmit() { - info("Date is set to :" + date01); - } - }; - - add(form); - - form.add(date01TextField); - } + protected Date date02; + + public Page4DatePicker() throws Exception + { + // note: a Converter for Date.class is registered (see DemoApplication) + + + final DateTextField date01TextField = new DateTextField("date01") + { + + @Override + public String getTextFormat() + { + return DATE_PATTERN; + } + }; + date01TextField.setMarkupId("date01"); + DatePickerOptions datePickerOptions = new DatePickerOptions().clickInput(true) + .allowDateInPast(true, DATE_PATTERN); + date01TextField.add(new DatePickerBehavior(datePickerOptions)); + + final Form form = new Form("myForm", new CompoundPropertyModel(this)) + { + @Override + protected void onSubmit() + { + info("Date is set to :" + date01); + } + }; + + add(form); + + form.add(date01TextField); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4JGrowl.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4JGrowl.java index a984d37999..8486dfcb26 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4JGrowl.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4JGrowl.java @@ -6,9 +6,11 @@ import org.wicketstuff.jquery.jgrowl.JGrowlFeedbackPanel; @SuppressWarnings("serial") -public class Page4JGrowl extends PageSupport { +public class Page4JGrowl extends PageSupport +{ - public Page4JGrowl() { + public Page4JGrowl() + { final JGrowlFeedbackPanel feedback = new JGrowlFeedbackPanel("jgrowlFeedback"); add(feedback); @@ -25,10 +27,12 @@ public Page4JGrowl() { infoOptions.set("glue", "after"); feedback.setInfoMessageOptions(infoOptions); - final AjaxLink link = new AjaxLink("showButton") { + final AjaxLink link = new AjaxLink("showButton") + { @Override - public void onClick(final AjaxRequestTarget target) { + public void onClick(final AjaxRequestTarget target) + { error("An ERROR message"); diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Sparkline.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Sparkline.java index b13869f4e3..c3d7dae8fb 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Sparkline.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Sparkline.java @@ -17,88 +17,94 @@ import org.wicketstuff.jquery.sparkline.SparklineWrapper; @SuppressWarnings("serial") -public class Page4Sparkline extends PageSupport { - - public Page4Sparkline() { - - RepeatingView rv = new RepeatingView( "spot" ); - add( rv ); - - - WebMarkupContainer spot = new WebMarkupContainer( rv.newChildId() ); - Sparkline s = new Sparkline( "chart", 5,6,7,9,9,5,3,2,2,4,6,7 ); - spot.add( s ); - spot.add( new Label( "js", s.getSparklineJS().toString() ) ); - rv.add( spot ); - - // BAR - SparklineOptions options = new SparklineOptions( TYPE.bar ); - spot = new WebMarkupContainer( rv.newChildId() ); - s = new Sparkline( "chart", options, 5,6,7,2,0,-4,-2,4 ); - spot.add( s ); - spot.add( new Label( "js", s.getSparklineJS().toString() ) ); - rv.add( spot ); - - // TRISTATE - options = new SparklineOptions( TYPE.tristate ); - spot = new WebMarkupContainer( rv.newChildId() ); - s = new Sparkline( "chart", options, -1,1,1,2,0,-1,-2,1,1 ); - spot.add( s ); - spot.add( new Label( "js", s.getSparklineJS().toString() ) ); - rv.add( spot ); - - - // DISCRETE - options = new SparklineOptions( TYPE.discrete ); - spot = new WebMarkupContainer( rv.newChildId() ); - s = new Sparkline( "chart", options, 5,6,7,9,9,5,3,2,2,4,6,7 ); - spot.add( s ); - spot.add( new Label( "js", s.getSparklineJS().toString() ) ); - rv.add( spot ); - - - // PIE - options = new SparklineOptions( TYPE.pie ); - spot = new WebMarkupContainer( rv.newChildId() ); - s = new Sparkline( "chart", options, 1,2,4 ); - spot.add( s ); - spot.add( new Label( "js", s.getSparklineJS().toString() ) ); - rv.add( spot ); - - //-------------------------------- - options = new SparklineOptions( TYPE.line ); - final LinkedList values = new LinkedList(); - values.add( 5 ); - values.add( 6 ); - values.add( 8 ); - values.add( 5 ); - s = new Sparkline( SparklineWrapper.SPARKID, new AbstractReadOnlyModel>() { - @Override - public Collection getObject() { - return values; - } - }, options ); - final SparklineWrapper wrap = new SparklineWrapper( "animated", s ); - wrap.setOutputMarkupId( true ); - add( wrap ); - - - // Refresh the view every second... - add( new AbstractAjaxTimerBehavior(Duration.seconds(1)) - { - Random rand = new Random(); - - @Override - protected void onTimer(final AjaxRequestTarget target) - { - int last = values.getLast() + ( rand.nextInt(10)-5 ); - values.addLast(last); - if( values.size() > 100 ) { - values.removeFirst(); - } - target.add( wrap ); - } - }); +public class Page4Sparkline extends PageSupport +{ + + public Page4Sparkline() + { + + RepeatingView rv = new RepeatingView("spot"); + add(rv); + + + WebMarkupContainer spot = new WebMarkupContainer(rv.newChildId()); + Sparkline s = new Sparkline("chart", 5, 6, 7, 9, 9, 5, 3, 2, 2, 4, 6, 7); + spot.add(s); + spot.add(new Label("js", s.getSparklineJS().toString())); + rv.add(spot); + + // BAR + SparklineOptions options = new SparklineOptions(TYPE.bar); + spot = new WebMarkupContainer(rv.newChildId()); + s = new Sparkline("chart", options, 5, 6, 7, 2, 0, -4, -2, 4); + spot.add(s); + spot.add(new Label("js", s.getSparklineJS().toString())); + rv.add(spot); + + // TRISTATE + options = new SparklineOptions(TYPE.tristate); + spot = new WebMarkupContainer(rv.newChildId()); + s = new Sparkline("chart", options, -1, 1, 1, 2, 0, -1, -2, 1, 1); + spot.add(s); + spot.add(new Label("js", s.getSparklineJS().toString())); + rv.add(spot); + + + // DISCRETE + options = new SparklineOptions(TYPE.discrete); + spot = new WebMarkupContainer(rv.newChildId()); + s = new Sparkline("chart", options, 5, 6, 7, 9, 9, 5, 3, 2, 2, 4, 6, 7); + spot.add(s); + spot.add(new Label("js", s.getSparklineJS().toString())); + rv.add(spot); + + + // PIE + options = new SparklineOptions(TYPE.pie); + spot = new WebMarkupContainer(rv.newChildId()); + s = new Sparkline("chart", options, 1, 2, 4); + spot.add(s); + spot.add(new Label("js", s.getSparklineJS().toString())); + rv.add(spot); + + // -------------------------------- + options = new SparklineOptions(TYPE.line); + final LinkedList values = new LinkedList(); + values.add(5); + values.add(6); + values.add(8); + values.add(5); + s = new Sparkline(SparklineWrapper.SPARKID, + new AbstractReadOnlyModel>() + { + @Override + public Collection getObject() + { + return values; + } + }, options); + final SparklineWrapper wrap = new SparklineWrapper("animated", s); + wrap.setOutputMarkupId(true); + add(wrap); + + + // Refresh the view every second... + add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) + { + Random rand = new Random(); + + @Override + protected void onTimer(final AjaxRequestTarget target) + { + int last = values.getLast() + (rand.nextInt(10) - 5); + values.addLast(last); + if (values.size() > 100) + { + values.removeFirst(); + } + target.add(wrap); + } + }); } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Tabs.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Tabs.java index e1087c2261..be5e3a6d5f 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Tabs.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/Page4Tabs.java @@ -27,36 +27,44 @@ import org.wicketstuff.jquery.tabs.JQTabbedPanel; @SuppressWarnings("serial") -public class Page4Tabs extends PageSupport { - public Page4Tabs() throws Exception { - super(); +public class Page4Tabs extends PageSupport +{ + public Page4Tabs() throws Exception + { + super(); List tabs = new ArrayList(); - tabs.add(new AbstractTab(new Model("A")) { + tabs.add(new AbstractTab(new Model("A")) + { @Override - public Panel getPanel(String panelId) { - return new TextPanel(panelId, Model.of( - "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus nec leo. Duis ultricies. In id ipsum vitae ante fringilla" - )); + public Panel getPanel(String panelId) + { + return new TextPanel( + panelId, + Model.of("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus nec leo. Duis ultricies. In id ipsum vitae ante fringilla")); } }); - tabs.add(new AbstractTab(new Model("B")) { + tabs.add(new AbstractTab(new Model("B")) + { @Override - public Panel getPanel(String panelId) { - return new TextPanel(panelId, Model.of( - "volutpat. In pharetra. Ut ante. Vivamus tempus, leo a ullamcorper tincidunt, pede ipsum consectetuer nunc, at pellentesque" - )); + public Panel getPanel(String panelId) + { + return new TextPanel( + panelId, + Model.of("volutpat. In pharetra. Ut ante. Vivamus tempus, leo a ullamcorper tincidunt, pede ipsum consectetuer nunc, at pellentesque")); } }); - tabs.add(new AbstractTab(new Model("C")) { + tabs.add(new AbstractTab(new Model("C")) + { @Override - public Panel getPanel(String panelId) { - return new TextPanel(panelId, Model.of( - "libero felis in metus. Pellentesque sollicitudin neque. Nulla facilisi. Sed hendrerit tempus orci. Aenean a nulla quis risus molestie vehicula." - )); + public Panel getPanel(String panelId) + { + return new TextPanel( + panelId, + Model.of("libero felis in metus. Pellentesque sollicitudin neque. Nulla facilisi. Sed hendrerit tempus orci. Aenean a nulla quis risus molestie vehicula.")); } }); add(new TabbedPanel("tabs1", tabs)); add(new JQTabbedPanel("tabs2", tabs)); add(new JQTabbedPanel("tabs3", tabs, "{ fxFade: true }")); - } + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/PageSupport.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/PageSupport.java index ccf75d227e..8dcbed8071 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/PageSupport.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/PageSupport.java @@ -29,31 +29,35 @@ import org.wicketstuff.jquery.demo.lavalamp.Page4LavaLamp; import org.wicketstuff.jquery.demo.ui.Page4Slider; -public class PageSupport extends WebPage { - private transient Logger logger_; +public class PageSupport extends WebPage +{ + private transient Logger logger_; - public PageSupport() { - add(new BookmarkablePageLink("clientSideOnly", Page4ClientSideOnly.class)); - add(new BookmarkablePageLink("simpleList", Page4SimpleList.class)); - add(new BookmarkablePageLink("oneGroup", Page4OneGroup.class)); - add(new BookmarkablePageLink("multiGroup", Page4MultiGroup.class)); - add(new BookmarkablePageLink("accordion", Page4Accordion.class)); - add(new BookmarkablePageLink("tabs", Page4Tabs.class)); - add(new BookmarkablePageLink("datePicker", Page4DatePicker.class)); - add(new BookmarkablePageLink("jgrowl", Page4JGrowl.class)); - add(new BookmarkablePageLink("block", Page4Block.class)); - add(new BookmarkablePageLink("sparkline", Page4Sparkline.class)); - add(new BookmarkablePageLink("ajaxbackbutton", Page4AjaxBackButton.class)); - add(new BookmarkablePageLink("uislider", Page4Slider.class)); - add(new BookmarkablePageLink("lavalamp", Page4LavaLamp.class)); + public PageSupport() + { + add(new BookmarkablePageLink("clientSideOnly", Page4ClientSideOnly.class)); + add(new BookmarkablePageLink("simpleList", Page4SimpleList.class)); + add(new BookmarkablePageLink("oneGroup", Page4OneGroup.class)); + add(new BookmarkablePageLink("multiGroup", Page4MultiGroup.class)); + add(new BookmarkablePageLink("accordion", Page4Accordion.class)); + add(new BookmarkablePageLink("tabs", Page4Tabs.class)); + add(new BookmarkablePageLink("datePicker", Page4DatePicker.class)); + add(new BookmarkablePageLink("jgrowl", Page4JGrowl.class)); + add(new BookmarkablePageLink("block", Page4Block.class)); + add(new BookmarkablePageLink("sparkline", Page4Sparkline.class)); + add(new BookmarkablePageLink("ajaxbackbutton", Page4AjaxBackButton.class)); + add(new BookmarkablePageLink("uislider", Page4Slider.class)); + add(new BookmarkablePageLink("lavalamp", Page4LavaLamp.class)); - add(new FeedbackPanel("feedback").setOutputMarkupId(true)); - } + add(new FeedbackPanel("feedback").setOutputMarkupId(true)); + } - protected Logger logger() { - if (logger_ == null) { - logger_ = LoggerFactory.getLogger(this.getClass()); - } - return logger_; - } + protected Logger logger() + { + if (logger_ == null) + { + logger_ = LoggerFactory.getLogger(this.getClass()); + } + return logger_; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/TextPanel.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/TextPanel.java index 21d55bc2da..fc30d868c7 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/TextPanel.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/TextPanel.java @@ -4,10 +4,12 @@ import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.IModel; -public class TextPanel extends Panel { +public class TextPanel extends Panel +{ private static final long serialVersionUID = 1L; - public TextPanel(String id, IModel model) { + public TextPanel(String id, IModel model) + { super(id, model); add(new Label("label", model)); } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyFactory.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyFactory.java index 47b89b494e..215c6527bb 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyFactory.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyFactory.java @@ -19,35 +19,44 @@ import java.util.ArrayList; import java.util.List; -public class MyFactory { +public class MyFactory +{ - public static MyItem newMyItem(String base) throws Exception { - MyItem back = new MyItem(); - back.label = "label of " + base; - back.description = "description of " + base + "\norem ipsum dolor sit amet, consectetuer adipiscing elit"; - return back; - } + public static MyItem newMyItem(String base) throws Exception + { + MyItem back = new MyItem(); + back.label = "label of " + base; + back.description = "description of " + base + + "\norem ipsum dolor sit amet, consectetuer adipiscing elit"; + return back; + } - public static List newMyItemList(String base, int length) throws Exception { - ArrayList back = new ArrayList(length); - for(int i = 0; i < length; i++) { - back.add(newMyItem(base + " " + i)); - } - return back; - } + public static List newMyItemList(String base, int length) throws Exception + { + ArrayList back = new ArrayList(length); + for (int i = 0; i < length; i++) + { + back.add(newMyItem(base + " " + i)); + } + return back; + } - public static MyGroup newMyGroup(String base, int length) throws Exception { - MyGroup back = new MyGroup(); - back.label = "label of " + base; - back.items = newMyItemList(base + "Item", length); - return back; - } + public static MyGroup newMyGroup(String base, int length) throws Exception + { + MyGroup back = new MyGroup(); + back.label = "label of " + base; + back.items = newMyItemList(base + "Item", length); + return back; + } - public static List newMyGroupList(String base, int length, int nbItemPerGroup) throws Exception { - ArrayList back = new ArrayList(length); - for(int i = 0; i < length; i++) { - back.add(newMyGroup(base + " " + i, nbItemPerGroup)); - } - return back; - } + public static List newMyGroupList(String base, int length, int nbItemPerGroup) + throws Exception + { + ArrayList back = new ArrayList(length); + for (int i = 0; i < length; i++) + { + back.add(newMyGroup(base + " " + i, nbItemPerGroup)); + } + return back; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyGroup.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyGroup.java index 18ab6a001e..d749dec5c9 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyGroup.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyGroup.java @@ -21,7 +21,8 @@ import java.util.List; @SuppressWarnings("serial") -public class MyGroup implements Serializable { - public String label; - public List items = new LinkedList(); +public class MyGroup implements Serializable +{ + public String label; + public List items = new LinkedList(); } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyItem.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyItem.java index 4b2387495f..25ab54c348 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyItem.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/MyItem.java @@ -19,47 +19,62 @@ import java.io.Serializable; @SuppressWarnings("serial") -public class MyItem implements Serializable{ - public String label; - public String description; +public class MyItem implements Serializable +{ + public String label; + public String description; - // Generated + // Generated - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((label == null) ? 0 : label.hashCode()); - return result; - } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final MyItem other = (MyItem) obj; - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { - return false; - } - if (label == null) { - if (other.label != null) { - return false; - } - } else if (!label.equals(other.label)) { - return false; - } - return true; - } + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((label == null) ? 0 : label.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + final MyItem other = (MyItem)obj; + if (description == null) + { + if (other.description != null) + { + return false; + } + } + else if (!description.equals(other.description)) + { + return false; + } + if (label == null) + { + if (other.label != null) + { + return false; + } + } + else if (!label.equals(other.label)) + { + return false; + } + return true; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4ClientSideOnly.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4ClientSideOnly.java index 0958fdaf14..1f4f26c73d 100755 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4ClientSideOnly.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4ClientSideOnly.java @@ -23,29 +23,29 @@ import org.wicketstuff.jquery.dnd.DnDSortableHandler; @SuppressWarnings("serial") -public class Page4ClientSideOnly extends PageSupport { - public Page4ClientSideOnly() throws Exception { - super(); - add(new DnDSortableHandler("dnd0", - new Options() - .set("accept", "groupItem") - .set("containerclass", "groupWrapper") - //.set("helperclass", "sortHelper") - //.set("activeclass", "sortableactive") - //.set("hoverclass", "sortablehover") - //.set("handle", "div.itemHeader") - //.set("tolerance", "pointer") - ) { - @Override - public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, MarkupContainer destContainer, int destPos) { - System.out.format("srcContainer=%s, srcPos=%s, destContainer=%s, destPos=%s\n", - String.valueOf(srcContainer), - String.valueOf(srcPos), - String.valueOf(destContainer), - String.valueOf(destPos) - ); - return false; - } - }); - } +public class Page4ClientSideOnly extends PageSupport +{ + public Page4ClientSideOnly() throws Exception + { + super(); + add(new DnDSortableHandler("dnd0", new Options().set("accept", "groupItem").set( + "containerclass", "groupWrapper") + // .set("helperclass", "sortHelper") + // .set("activeclass", "sortableactive") + // .set("hoverclass", "sortablehover") + // .set("handle", "div.itemHeader") + // .set("tolerance", "pointer") + ) + { + @Override + public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, + int srcPos, MarkupContainer destContainer, int destPos) + { + System.out.format("srcContainer=%s, srcPos=%s, destContainer=%s, destPos=%s\n", + String.valueOf(srcContainer), String.valueOf(srcPos), + String.valueOf(destContainer), String.valueOf(destPos)); + return false; + } + }); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4MultiGroup.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4MultiGroup.java index fbd6030940..18f3b50564 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4MultiGroup.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4MultiGroup.java @@ -28,76 +28,99 @@ import org.wicketstuff.jquery.dnd.DnDSortableHandler; @SuppressWarnings("serial") -public class Page4MultiGroup extends PageSupport { - // Data (for demo purpose) - private static List myGroups = null; +public class Page4MultiGroup extends PageSupport +{ + // Data (for demo purpose) + private static List myGroups = null; - static { - try { - myGroups = MyFactory.newMyGroupList("multi", 5, 4); - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } + static + { + try + { + myGroups = MyFactory.newMyGroupList("multi", 5, 4); + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } - // Component - public Page4MultiGroup() throws Exception { - // define the action on DnD - final DnDSortableHandler dnd = new DnDSortableHandler("dnd") { - private int actionCnt_ = 0; + // Component + public Page4MultiGroup() throws Exception + { + // define the action on DnD + final DnDSortableHandler dnd = new DnDSortableHandler("dnd") + { + private int actionCnt_ = 0; - @Override - public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, MarkupContainer destContainer, int destPos) { - // apply modification on model - MyGroup srcGroup = (MyGroup) srcContainer.getDefaultModelObject(); - MyGroup destGroup = (MyGroup) destContainer.getDefaultModelObject(); - MyItem myItem = srcGroup.items.remove(srcPos); - destGroup.items.add(destPos, myItem); + @Override + public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, + int srcPos, MarkupContainer destContainer, int destPos) + { + // apply modification on model + MyGroup srcGroup = (MyGroup)srcContainer.getDefaultModelObject(); + MyGroup destGroup = (MyGroup)destContainer.getDefaultModelObject(); + MyItem myItem = srcGroup.items.remove(srcPos); + destGroup.items.add(destPos, myItem); - // update sizes - actionCnt_++; - updateContainerHeader(target, srcContainer, srcGroup); - if (srcContainer != destContainer) { - updateContainerHeader(target, destContainer, destGroup); - } + // update sizes + actionCnt_++; + updateContainerHeader(target, srcContainer, srcGroup); + if (srcContainer != destContainer) + { + updateContainerHeader(target, destContainer, destGroup); + } - // update feedback message - String msg = String.format("move '%s' from %d to %d", myItem.label, srcPos, destPos); - FeedbackPanel feedback = (FeedbackPanel) Page4MultiGroup.this.get("feedback"); - feedback.info(msg); - if (target != null) { - target.add(feedback); - } - return false; - } + // update feedback message + String msg = String.format("move '%s' from %d to %d", myItem.label, srcPos, destPos); + FeedbackPanel feedback = (FeedbackPanel)Page4MultiGroup.this.get("feedback"); + feedback.info(msg); + if (target != null) + { + target.add(feedback); + } + return false; + } - private void updateContainerHeader(AjaxRequestTarget target, MarkupContainer container, MyGroup group) { - Label itemCnt = (Label) container.getParent().get("itemCnt"); - itemCnt.setDefaultModelObject(group.items.size()); - target.add(itemCnt); + private void updateContainerHeader(AjaxRequestTarget target, MarkupContainer container, + MyGroup group) + { + Label itemCnt = (Label)container.getParent().get("itemCnt"); + itemCnt.setDefaultModelObject(group.items.size()); + target.add(itemCnt); - Label actionCnt = (Label) container.getParent().get("actionCnt"); - actionCnt.setDefaultModelObject(actionCnt_); - target.add(actionCnt); - } - }; + Label actionCnt = (Label)container.getParent().get("actionCnt"); + actionCnt.setDefaultModelObject(actionCnt_); + target.add(actionCnt); + } + }; - // add the DnD handler to the page - add(dnd); + // add the DnD handler to the page + add(dnd); - add(new ListView("myGroups", myGroups) { - @Override - protected void populateItem(ListItem listitem) { - try { - listitem.add(new Panel4MyGroup("myGroup", (MyGroup) listitem.getModelObject(), dnd)); - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } - }); - } + add(new ListView("myGroups", myGroups) + { + @Override + protected void populateItem(ListItem listitem) + { + try + { + listitem.add(new Panel4MyGroup("myGroup", (MyGroup)listitem.getModelObject(), + dnd)); + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } + }); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4OneGroup.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4OneGroup.java index 09e513ba97..7ab198f493 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4OneGroup.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4OneGroup.java @@ -24,65 +24,80 @@ import org.wicketstuff.jquery.dnd.DnDSortableHandler; @SuppressWarnings("serial") -public class Page4OneGroup extends PageSupport { - // Data (for demo purpose) - private static MyGroup myGroup = null; +public class Page4OneGroup extends PageSupport +{ + // Data (for demo purpose) + private static MyGroup myGroup = null; - static { - try { - myGroup = MyFactory.newMyGroup("one", 4); - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } + static + { + try + { + myGroup = MyFactory.newMyGroup("one", 4); + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } - // Component - public Page4OneGroup() throws Exception { - // define the action on DnD - final DnDSortableHandler dnd = new DnDSortableHandler("dnd") { - private int actionCnt_ = 0; + // Component + public Page4OneGroup() throws Exception + { + // define the action on DnD + final DnDSortableHandler dnd = new DnDSortableHandler("dnd") + { + private int actionCnt_ = 0; - @Override - public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, MarkupContainer destContainer, int destPos) { - // apply modification on model - MyGroup srcGroup = (MyGroup) srcContainer.getDefaultModelObject(); - MyGroup destGroup = (MyGroup) destContainer.getDefaultModelObject(); - MyItem myItem = srcGroup.items.remove(srcPos); - destGroup.items.add(destPos, myItem); + @Override + public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, + int srcPos, MarkupContainer destContainer, int destPos) + { + // apply modification on model + MyGroup srcGroup = (MyGroup)srcContainer.getDefaultModelObject(); + MyGroup destGroup = (MyGroup)destContainer.getDefaultModelObject(); + MyItem myItem = srcGroup.items.remove(srcPos); + destGroup.items.add(destPos, myItem); - // update sizes - actionCnt_++; - updateContainerHeader(target, srcContainer, srcGroup); - if (srcContainer != destContainer) { - updateContainerHeader(target, destContainer, destGroup); - } + // update sizes + actionCnt_++; + updateContainerHeader(target, srcContainer, srcGroup); + if (srcContainer != destContainer) + { + updateContainerHeader(target, destContainer, destGroup); + } - // update feedback message - String msg = String.format("move '%s' from %d to %d", myItem.label, srcPos, destPos); - FeedbackPanel feedback = (FeedbackPanel) Page4OneGroup.this.get("feedback"); - feedback.info(msg); - if (target != null) { - target.add(feedback); - } - return false; - } + // update feedback message + String msg = String.format("move '%s' from %d to %d", myItem.label, srcPos, destPos); + FeedbackPanel feedback = (FeedbackPanel)Page4OneGroup.this.get("feedback"); + feedback.info(msg); + if (target != null) + { + target.add(feedback); + } + return false; + } - private void updateContainerHeader(AjaxRequestTarget target, MarkupContainer container, MyGroup group) { - Label itemCnt = (Label) container.getParent().get("itemCnt"); - itemCnt.setDefaultModelObject(group.items.size()); - target.add(itemCnt); + private void updateContainerHeader(AjaxRequestTarget target, MarkupContainer container, + MyGroup group) + { + Label itemCnt = (Label)container.getParent().get("itemCnt"); + itemCnt.setDefaultModelObject(group.items.size()); + target.add(itemCnt); - Label actionCnt = (Label) container.getParent().get("actionCnt"); - actionCnt.setDefaultModelObject(actionCnt_); - target.add(actionCnt); - } - }; + Label actionCnt = (Label)container.getParent().get("actionCnt"); + actionCnt.setDefaultModelObject(actionCnt_); + target.add(actionCnt); + } + }; - // add the DnD handler to the page - add(dnd); + // add the DnD handler to the page + add(dnd); - add(new Panel4MyGroup("myGroup", myGroup, dnd)); - } + add(new Panel4MyGroup("myGroup", myGroup, dnd)); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleList.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleList.java index 9e0d7f3653..5d90fb50ed 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleList.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleList.java @@ -31,98 +31,127 @@ import org.wicketstuff.jquery.dnd.DnDSortableHandler; @SuppressWarnings("serial") -public class Page4SimpleList extends PageSupport { - // Data (for demo purpose) - protected static List dataList_ = null; +public class Page4SimpleList extends PageSupport +{ + // Data (for demo purpose) + protected static List dataList_ = null; - static { - try { - dataList_ = MyFactory.newMyItemList("simple", 4); - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } + static + { + try + { + dataList_ = MyFactory.newMyItemList("simple", 4); + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } - // Component - public Page4SimpleList() throws Exception { - // define the action on DnD - final DnDSortableHandler dnd = new DnDSortableHandler("dnd") { - @Override - public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, MarkupContainer destContainer, int destPos) { - // apply modification on model - MyItem myItem = dataList_.remove(srcPos); - dataList_.add(destPos, myItem); + // Component + public Page4SimpleList() throws Exception + { + // define the action on DnD + final DnDSortableHandler dnd = new DnDSortableHandler("dnd") + { + @Override + public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, + int srcPos, MarkupContainer destContainer, int destPos) + { + // apply modification on model + MyItem myItem = dataList_.remove(srcPos); + dataList_.add(destPos, myItem); - // update feedback message - String msg = String.format("move '%s' from %d to %d", myItem.label, srcPos, destPos); - FeedbackPanel feedback = (FeedbackPanel) Page4SimpleList.this.get("feedback"); - feedback.info(msg); - if (target != null) { - // target is null in testcase - target.add(feedback); - } - // false = don't need to keep in sync component, markupId on serverside and client side - return false; - } - }; + // update feedback message + String msg = String.format("move '%s' from %d to %d", myItem.label, srcPos, destPos); + FeedbackPanel feedback = (FeedbackPanel)Page4SimpleList.this.get("feedback"); + feedback.info(msg); + if (target != null) + { + // target is null in testcase + target.add(feedback); + } + // false = don't need to keep in sync component, markupId on serverside and client +// side + return false; + } + }; - // add the DnD handler to the page - add(dnd); - add(new Link("start_dnd") { - @Override - protected CharSequence getOnClickScript(CharSequence url) { - return dnd.getJSFunctionName4Start() + "();"; - } + // add the DnD handler to the page + add(dnd); + add(new Link("start_dnd") + { + @Override + protected CharSequence getOnClickScript(CharSequence url) + { + return dnd.getJSFunctionName4Start() + "();"; + } - @Override - protected CharSequence getURL() { - return "#"; - } + @Override + protected CharSequence getURL() + { + return "#"; + } - @Override - public void onClick() { - throw new UnsupportedOperationException("NOT CALLABLE"); - } + @Override + public void onClick() + { + throw new UnsupportedOperationException("NOT CALLABLE"); + } - }); - add(new Link("stop_dnd") { - @Override - protected CharSequence getOnClickScript(CharSequence url) { - return dnd.getJSFunctionName4Stop() + "();"; - } + }); + add(new Link("stop_dnd") + { + @Override + protected CharSequence getOnClickScript(CharSequence url) + { + return dnd.getJSFunctionName4Stop() + "();"; + } - @Override - protected CharSequence getURL() { - return "#"; - } + @Override + protected CharSequence getURL() + { + return "#"; + } - @Override - public void onClick() { - throw new UnsupportedOperationException("NOT CALLABLE"); - } + @Override + public void onClick() + { + throw new UnsupportedOperationException("NOT CALLABLE"); + } - }); + }); - // create a container - WebMarkupContainer webList = new WebMarkupContainer("myItemList"); - dnd.registerContainer(webList); - add(webList); + // create a container + WebMarkupContainer webList = new WebMarkupContainer("myItemList"); + dnd.registerContainer(webList); + add(webList); - // create items (add as children of the container) - webList.add(new ListView("myItem", dataList_) { - @Override - protected void populateItem(ListItem listitem) { - try { - listitem.add(new Label("myItemLabel", new PropertyModel(listitem.getModelObject(), "label"))); - dnd.registerItem(listitem); - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } - }); - } + // create items (add as children of the container) + webList.add(new ListView("myItem", dataList_) + { + @Override + protected void populateItem(ListItem listitem) + { + try + { + listitem.add(new Label("myItemLabel", new PropertyModel( + listitem.getModelObject(), "label"))); + dnd.registerItem(listitem); + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } + }); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Panel4MyGroup.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Panel4MyGroup.java index e9b7e54730..a39196f0c3 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Panel4MyGroup.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/dnd/Panel4MyGroup.java @@ -26,32 +26,42 @@ import org.wicketstuff.jquery.dnd.DnDSortableHandler; @SuppressWarnings("serial") -public class Panel4MyGroup extends Panel{ +public class Panel4MyGroup extends Panel +{ - public Panel4MyGroup(String id, MyGroup myGroup, final DnDSortableHandler dnd) throws Exception { - super(id); - add(new Label("label", myGroup.label)); - add(new Label("itemCnt", String.valueOf(myGroup.items.size())).setOutputMarkupId(true)); - add(new Label("actionCnt", "0").setOutputMarkupId(true)); + public Panel4MyGroup(String id, MyGroup myGroup, final DnDSortableHandler dnd) throws Exception + { + super(id); + add(new Label("label", myGroup.label)); + add(new Label("itemCnt", String.valueOf(myGroup.items.size())).setOutputMarkupId(true)); + add(new Label("actionCnt", "0").setOutputMarkupId(true)); - // create a container - WebMarkupContainer container = new WebMarkupContainer("myItemContainer", new Model(myGroup)); - dnd.registerContainer(container); - add(container); + // create a container + WebMarkupContainer container = new WebMarkupContainer("myItemContainer", new Model(myGroup)); + dnd.registerContainer(container); + add(container); - // create items (add as children of the container) - container.add(new ListView("myItem", myGroup.items) { - @Override - protected void populateItem(ListItem listitem) { - try { - listitem.add(new Label("myItemLabel", new PropertyModel(listitem.getModelObject(), "label"))); - dnd.registerItem(listitem); - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } - }); - } + // create items (add as children of the container) + container.add(new ListView("myItem", myGroup.items) + { + @Override + protected void populateItem(ListItem listitem) + { + try + { + listitem.add(new Label("myItemLabel", new PropertyModel( + listitem.getModelObject(), "label"))); + dnd.registerItem(listitem); + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } + }); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/APage.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/APage.java index e1bc9269ad..25f50f81b8 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/APage.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/APage.java @@ -5,15 +5,19 @@ import org.apache.wicket.request.resource.ResourceReference; import org.wicketstuff.jquery.lavalamp.LavaLampMenuPanel; -public final class APage extends WebPage { - public APage() { - add(new LavaLampMenuPanel("lavalampMenu", Utils.newMenuList()) { - private static final long serialVersionUID = 1L; +public final class APage extends WebPage +{ + public APage() + { + add(new LavaLampMenuPanel("lavalampMenu", Utils.newMenuList()) + { + private static final long serialVersionUID = 1L; - @Override - protected ResourceReference getCssResourceReference() { - return new CompressedResourceReference(APage.class, "apage.css"); - } - }); - } + @Override + protected ResourceReference getCssResourceReference() + { + return new CompressedResourceReference(APage.class, "apage.css"); + } + }); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/BPage.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/BPage.java index 01b15fb4dc..a8456c6620 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/BPage.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/BPage.java @@ -5,17 +5,21 @@ import org.apache.wicket.request.resource.ResourceReference; import org.wicketstuff.jquery.lavalamp.LavaLampMenuPanel; -public final class BPage extends WebPage { +public final class BPage extends WebPage +{ - public BPage() { - add(new LavaLampMenuPanel("lavalampMenu", Utils.newMenuListWithLinkStyles()) { - private static final long serialVersionUID = 1L; + public BPage() + { + add(new LavaLampMenuPanel("lavalampMenu", Utils.newMenuListWithLinkStyles()) + { + private static final long serialVersionUID = 1L; - @Override - protected ResourceReference getCssResourceReference() { - return new CompressedResourceReference(BPage.class, "bpage.css"); - } - }); - } + @Override + protected ResourceReference getCssResourceReference() + { + return new CompressedResourceReference(BPage.class, "bpage.css"); + } + }); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Page4LavaLamp.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Page4LavaLamp.java index da3161e907..b2f84ae6e3 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Page4LavaLamp.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Page4LavaLamp.java @@ -10,27 +10,33 @@ import org.wicketstuff.jquery.lavalamp.LavaLampMenuPanel; import org.wicketstuff.jquery.lavalamp.MenuItem; -public final class Page4LavaLamp extends PageSupport { - public Page4LavaLamp() { - super(); - IModel> model = new AbstractReadOnlyModel>() { - - private static final long serialVersionUID = 1L; - - @Override - public List getObject() { - return Utils.newMenuList(); - } - }; - - add(new LavaLampMenuPanel("lavalampMenu", model) { - private static final long serialVersionUID = 1L; - - @Override - protected ResourceReference getCssResourceReference() { - return new CompressedResourceReference(Page4LavaLamp.class, "lavalamp.css"); - } - }); - } +public final class Page4LavaLamp extends PageSupport +{ + public Page4LavaLamp() + { + super(); + IModel> model = new AbstractReadOnlyModel>() + { + + private static final long serialVersionUID = 1L; + + @Override + public List getObject() + { + return Utils.newMenuList(); + } + }; + + add(new LavaLampMenuPanel("lavalampMenu", model) + { + private static final long serialVersionUID = 1L; + + @Override + protected ResourceReference getCssResourceReference() + { + return new CompressedResourceReference(Page4LavaLamp.class, "lavalamp.css"); + } + }); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Utils.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Utils.java index 21fe02d80f..54a80cde12 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Utils.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/lavalamp/Utils.java @@ -16,130 +16,153 @@ import org.apache.wicket.model.Model; import org.wicketstuff.jquery.lavalamp.MenuItem; -final class Utils { - - private Utils() { - throw new IllegalStateException(); - } - - public static List newMenuList() { - final List result = new ArrayList(); - result.add(new MenuItem(new Link(MenuItem.LINK_ID) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick() { - - } - - }, new Label(MenuItem.CAPTION_ID, "One"))); - - final BookmarkablePageLink linkToAPage = new BookmarkablePageLink( - MenuItem.LINK_ID, APage.class); - result.add(new MenuItem(linkToAPage, new Label(MenuItem.CAPTION_ID, "APage"))); - - final BookmarkablePageLink linkToAPageWithPopupSettings = new BookmarkablePageLink( - MenuItem.LINK_ID, APage.class); - linkToAPageWithPopupSettings.setPopupSettings(new PopupSettings()); - result.add(new MenuItem(linkToAPageWithPopupSettings, new Label(MenuItem.CAPTION_ID, - "APage-popup"))); - - result.add(new MenuItem(new Link(MenuItem.LINK_ID) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick() { - - } - - }, new Label(MenuItem.CAPTION_ID, "Four"))); - return result; - } - - public static List newMenuListWithLinkStyles() { - final List result = new ArrayList(); - Link link1 = new Link(MenuItem.LINK_ID) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick() { - - } - - }; - link1.add(new AttributeAppender("class", true, new Model("link1"), " ")); - Label label1 = new Label(MenuItem.CAPTION_ID, "One"); - label1.setVisible(false); - - result.add(new MenuItem(link1, label1)); - - AjaxLink link2 = new AjaxLink(MenuItem.LINK_ID) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) { - - } - - @Override - protected IAjaxCallDecorator getAjaxCallDecorator() { - return new AjaxCallDecorator() { - private static final long serialVersionUID = 1L; - - @Override - public CharSequence decorateOnSuccessScript(Component component, CharSequence script) { - return "alert('Success');"; - } - - @Override - public CharSequence decorateOnFailureScript(Component component, CharSequence script) { - return "alert('Failure');"; - } - - @Override - public CharSequence decorateScript(Component component, CharSequence script) { - return "alert('Before ajax call');" + script; - } - }; - } - - }; - link2.add(new AttributeAppender("class", true, new Model("link2"), " ")); - Label label2 = new Label(MenuItem.CAPTION_ID, "One"); - label2.setVisible(false); - - result.add(new MenuItem(link2, label2)); - - Link link3 = new Link(MenuItem.LINK_ID) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick() { - } - - }; - link3.add(new AttributeAppender("class", true, new Model("link3"), " ")); - Label label3 = new Label(MenuItem.CAPTION_ID, "One"); - label3.setVisible(false); - - result.add(new MenuItem(link3, label3)); - - Link link4 = new Link(MenuItem.LINK_ID) { - private static final long serialVersionUID = 1L; - - @Override - public void onClick() { - - } - - }; - link4.add(new AttributeAppender("class", true, new Model("link4"), " ")); - Label label4 = new Label(MenuItem.CAPTION_ID, "One"); - label4.setVisible(false); - - result.add(new MenuItem(link4, label4)); - - return result; - } +final class Utils +{ + + private Utils() + { + throw new IllegalStateException(); + } + + public static List newMenuList() + { + final List result = new ArrayList(); + result.add(new MenuItem(new Link(MenuItem.LINK_ID) + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick() + { + + } + + }, new Label(MenuItem.CAPTION_ID, "One"))); + + final BookmarkablePageLink linkToAPage = new BookmarkablePageLink( + MenuItem.LINK_ID, APage.class); + result.add(new MenuItem(linkToAPage, new Label(MenuItem.CAPTION_ID, "APage"))); + + final BookmarkablePageLink linkToAPageWithPopupSettings = new BookmarkablePageLink( + MenuItem.LINK_ID, APage.class); + linkToAPageWithPopupSettings.setPopupSettings(new PopupSettings()); + result.add(new MenuItem(linkToAPageWithPopupSettings, new Label(MenuItem.CAPTION_ID, + "APage-popup"))); + + result.add(new MenuItem(new Link(MenuItem.LINK_ID) + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick() + { + + } + + }, new Label(MenuItem.CAPTION_ID, "Four"))); + return result; + } + + public static List newMenuListWithLinkStyles() + { + final List result = new ArrayList(); + Link link1 = new Link(MenuItem.LINK_ID) + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick() + { + + } + + }; + link1.add(new AttributeAppender("class", true, new Model("link1"), " ")); + Label label1 = new Label(MenuItem.CAPTION_ID, "One"); + label1.setVisible(false); + + result.add(new MenuItem(link1, label1)); + + AjaxLink link2 = new AjaxLink(MenuItem.LINK_ID) + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick(AjaxRequestTarget target) + { + + } + + @Override + protected IAjaxCallDecorator getAjaxCallDecorator() + { + return new AjaxCallDecorator() + { + private static final long serialVersionUID = 1L; + + @Override + public CharSequence decorateOnSuccessScript(Component component, + CharSequence script) + { + return "alert('Success');"; + } + + @Override + public CharSequence decorateOnFailureScript(Component component, + CharSequence script) + { + return "alert('Failure');"; + } + + @Override + public CharSequence decorateScript(Component component, CharSequence script) + { + return "alert('Before ajax call');" + script; + } + }; + } + + }; + link2.add(new AttributeAppender("class", true, new Model("link2"), " ")); + Label label2 = new Label(MenuItem.CAPTION_ID, "One"); + label2.setVisible(false); + + result.add(new MenuItem(link2, label2)); + + Link link3 = new Link(MenuItem.LINK_ID) + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick() + { + } + + }; + link3.add(new AttributeAppender("class", true, new Model("link3"), " ")); + Label label3 = new Label(MenuItem.CAPTION_ID, "One"); + label3.setVisible(false); + + result.add(new MenuItem(link3, label3)); + + Link link4 = new Link(MenuItem.LINK_ID) + { + private static final long serialVersionUID = 1L; + + @Override + public void onClick() + { + + } + + }; + link4.add(new AttributeAppender("class", true, new Model("link4"), " ")); + Label label4 = new Label(MenuItem.CAPTION_ID, "One"); + label4.setVisible(false); + + result.add(new MenuItem(link4, label4)); + + return result; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/ui/Page4Slider.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/ui/Page4Slider.java index 540eacbc11..3cf2e5401b 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/ui/Page4Slider.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/main/java/org/wicketstuff/jquery/demo/ui/Page4Slider.java @@ -14,16 +14,16 @@ * * @author Martin Grigorov */ -public class Page4Slider extends PageSupport { +public class Page4Slider extends PageSupport +{ - public Page4Slider() throws Exception { + public Page4Slider() throws Exception + { super(); - final SliderHandleOptions sliderOneHandleSettings = new SliderHandleOptions( - "uno", 0); + final SliderHandleOptions sliderOneHandleSettings = new SliderHandleOptions("uno", 0); - final SliderHandleOptions sliderTwoHandleSettings = new SliderHandleOptions( - "dos", 50); + final SliderHandleOptions sliderTwoHandleSettings = new SliderHandleOptions("dos", 50); sliderTwoHandleSettings.setStyle("left: 188px"); final SliderOptions sliderOptions = new SliderOptions(); @@ -39,12 +39,14 @@ public Page4Slider() throws Exception { // sliderOptions.setOnChange("console.log('ui: ' + ui.toSource());", "e", "ui"); @SuppressWarnings("serial") - final Slider slider = new Slider("slider", sliderOptions, sliderOneHandleSettings, sliderTwoHandleSettings) { + final Slider slider = new Slider("slider", sliderOptions, sliderOneHandleSettings, + sliderTwoHandleSettings) + { @Override - public void onChange(AjaxRequestTarget target, String handleId, int value) { - info(String.format("Handle with id '%s' changed its value to '%d'", - handleId, value)); + public void onChange(AjaxRequestTarget target, String handleId, int value) + { + info(String.format("Handle with id '%s' changed its value to '%d'", handleId, value)); target.addChildren(getPage(), FeedbackPanel.class); } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/RunWebApp.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/RunWebApp.java index 14e45c8551..cb5733ba53 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/RunWebApp.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/RunWebApp.java @@ -26,14 +26,17 @@ /** * Seperate startup class for people that want to run the examples directly. */ -public class RunWebApp { +public class RunWebApp +{ - /** - * Main function, starts the jetty server. - * - * @param args unused - */ - public static void main(String[] args) { + /** + * Main function, starts the jetty server. + * + * @param args + * unused + */ + public static void main(String[] args) + { Server server = new Server(); SocketConnector connector = new SocketConnector(); @@ -56,19 +59,22 @@ public static void main(String[] args) { server.setHandler(bb); - try { + try + { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); System.in.read(); System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); - // while (System.in.available() == 0) { - // Thread.sleep(5000); + // while (System.in.available() == 0) { + // Thread.sleep(5000); // } server.stop(); server.join(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); System.exit(100); } - } + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleListTest.java b/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleListTest.java index 3ff700007c..926e188275 100644 --- a/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleListTest.java +++ b/jdk-1.5-parent/jquery-parent/jquery-examples/src/test/java/org/wicketstuff/jquery/demo/dnd/Page4SimpleListTest.java @@ -12,71 +12,78 @@ import org.wicketstuff.jquery.dnd.DnDSortableHandler; @Test -public class Page4SimpleListTest { - - private WicketTester tester_; - - @BeforeClass - public void setUp() { - tester_ = new WicketTester(); - } - - @Test - public void testOnDnD() throws Exception { - Page4SimpleList page = new Page4SimpleList(); - // start and render the test page - tester_.startPage(page); - // assert rendered page class - tester_.assertRenderedPage(page.getClass()); - tester_.assertNoInfoMessage(); - - WebMarkupContainer webList = (WebMarkupContainer) page.get("myItemList"); - WebMarkupContainer list = (WebMarkupContainer) webList.get("myItem"); - ArrayList items = new ArrayList(); - for (Iterator it = list.iterator(); it.hasNext();) { - items.add(it.next()); - } - - ArrayList originalDataList = new ArrayList(); - for(MyItem myItem : Page4SimpleList.dataList_) { - originalDataList.add(myItem); - } - - - assertEquals(Page4SimpleList.dataList_.get(0), originalDataList.get(0)); - assertEquals(Page4SimpleList.dataList_.get(1), originalDataList.get(1)); - assertEquals(Page4SimpleList.dataList_.get(2), originalDataList.get(2)); - assertEquals(Page4SimpleList.dataList_.get(3), originalDataList.get(3)); - - DnDSortableHandler dnd = (DnDSortableHandler) page.get("dnd"); - dnd.onDnD(null, webList, 1, webList, 3); - - // model is updated - assertEquals(Page4SimpleList.dataList_.get(0), originalDataList.get(0)); - assertEquals(Page4SimpleList.dataList_.get(1), originalDataList.get(2)); - assertEquals(Page4SimpleList.dataList_.get(2), originalDataList.get(3)); - assertEquals(Page4SimpleList.dataList_.get(3), originalDataList.get(1)); - - // but wicket component isn't updated (wicket always component use the current) - assertEquals(Page4SimpleList.dataList_.get(0), (MyItem)items.get(0).getDefaultModelObject()); - assertEquals(Page4SimpleList.dataList_.get(1), (MyItem)items.get(1).getDefaultModelObject()); - assertEquals(Page4SimpleList.dataList_.get(2), (MyItem)items.get(2).getDefaultModelObject()); - assertEquals(Page4SimpleList.dataList_.get(3), (MyItem)items.get(3).getDefaultModelObject()); - - dnd.onDnD(null, webList, 1, webList, 3); - - // model is updated - assertEquals(Page4SimpleList.dataList_.get(0), originalDataList.get(0)); - assertEquals(Page4SimpleList.dataList_.get(1), originalDataList.get(3)); - assertEquals(Page4SimpleList.dataList_.get(2), originalDataList.get(1)); - assertEquals(Page4SimpleList.dataList_.get(3), originalDataList.get(2)); - - } - - protected void assertEquals(MyItem actual, MyItem expected) throws Exception { - if (actual != expected) { - Assert.assertEquals(actual.label, expected.label); - Assert.assertEquals(actual.description, expected.description); - } - } +public class Page4SimpleListTest +{ + + private WicketTester tester_; + + @BeforeClass + public void setUp() + { + tester_ = new WicketTester(); + } + + @Test + public void testOnDnD() throws Exception + { + Page4SimpleList page = new Page4SimpleList(); + // start and render the test page + tester_.startPage(page); + // assert rendered page class + tester_.assertRenderedPage(page.getClass()); + tester_.assertNoInfoMessage(); + + WebMarkupContainer webList = (WebMarkupContainer)page.get("myItemList"); + WebMarkupContainer list = (WebMarkupContainer)webList.get("myItem"); + ArrayList items = new ArrayList(); + for (Iterator it = list.iterator(); it.hasNext();) + { + items.add(it.next()); + } + + ArrayList originalDataList = new ArrayList(); + for (MyItem myItem : Page4SimpleList.dataList_) + { + originalDataList.add(myItem); + } + + + assertEquals(Page4SimpleList.dataList_.get(0), originalDataList.get(0)); + assertEquals(Page4SimpleList.dataList_.get(1), originalDataList.get(1)); + assertEquals(Page4SimpleList.dataList_.get(2), originalDataList.get(2)); + assertEquals(Page4SimpleList.dataList_.get(3), originalDataList.get(3)); + + DnDSortableHandler dnd = (DnDSortableHandler)page.get("dnd"); + dnd.onDnD(null, webList, 1, webList, 3); + + // model is updated + assertEquals(Page4SimpleList.dataList_.get(0), originalDataList.get(0)); + assertEquals(Page4SimpleList.dataList_.get(1), originalDataList.get(2)); + assertEquals(Page4SimpleList.dataList_.get(2), originalDataList.get(3)); + assertEquals(Page4SimpleList.dataList_.get(3), originalDataList.get(1)); + + // but wicket component isn't updated (wicket always component use the current) + assertEquals(Page4SimpleList.dataList_.get(0), (MyItem)items.get(0).getDefaultModelObject()); + assertEquals(Page4SimpleList.dataList_.get(1), (MyItem)items.get(1).getDefaultModelObject()); + assertEquals(Page4SimpleList.dataList_.get(2), (MyItem)items.get(2).getDefaultModelObject()); + assertEquals(Page4SimpleList.dataList_.get(3), (MyItem)items.get(3).getDefaultModelObject()); + + dnd.onDnD(null, webList, 1, webList, 3); + + // model is updated + assertEquals(Page4SimpleList.dataList_.get(0), originalDataList.get(0)); + assertEquals(Page4SimpleList.dataList_.get(1), originalDataList.get(3)); + assertEquals(Page4SimpleList.dataList_.get(2), originalDataList.get(1)); + assertEquals(Page4SimpleList.dataList_.get(3), originalDataList.get(2)); + + } + + protected void assertEquals(MyItem actual, MyItem expected) throws Exception + { + if (actual != expected) + { + Assert.assertEquals(actual.label, expected.label); + Assert.assertEquals(actual.description, expected.description); + } + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/FunctionString.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/FunctionString.java index 888eb313de..055535a389 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/FunctionString.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/FunctionString.java @@ -5,25 +5,31 @@ /** * * @author Edvin Syse - * + * */ -public class FunctionString implements Serializable { +public class FunctionString implements Serializable +{ private String value; - public FunctionString(String value) { + public FunctionString(String value) + { this.value = value; } - - public String getValue() { + + public String getValue() + { return value; } - public void setValue(String value) { + public void setValue(String value) + { this.value = value; } - - @Override public String toString() { - return this.value; + + @Override + public String toString() + { + return value; } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/JQueryBehavior.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/JQueryBehavior.java index 78f256c8bf..aee8e0016d 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/JQueryBehavior.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/JQueryBehavior.java @@ -29,105 +29,133 @@ import org.slf4j.LoggerFactory; /** - * + * * @author David Bernard (dwayne) * @created 2007-08-08 */ // http://jquery.com/plugins for a list a jquery plugins @SuppressWarnings("serial") -public class JQueryBehavior extends AbstractDefaultAjaxBehavior { +public class JQueryBehavior extends AbstractDefaultAjaxBehavior +{ + + // create a reference to the base javascript file. + // we use ResourceReference so that the included file will have + // its comments stripped and gzipped. + /** + * ResourceReference for jquery-1.2.6 (include by default when + * you add the current Behavior). + */ + public static final ResourceReference JQUERY_JS = new PackageResourceReference( + JQueryBehavior.class, "jquery.js"); + + /** + * ResourceReference for jquery.debug.js (include by + * default if wicket's configuration is "development") + */ + public static final ResourceReference JQUERY_DEBUG_JS = new PackageResourceReference( + JQueryBehavior.class, "jquery.debug.js"); - // create a reference to the base javascript file. - // we use ResourceReference so that the included file will have - // its comments stripped and gzipped. - /** - * ResourceReference for jquery-1.2.6 (include by default when you add the current Behavior). - */ - public static final ResourceReference JQUERY_JS = new PackageResourceReference(JQueryBehavior.class, "jquery.js"); + /** + * ResourceReference for interface-1.2.js (not include + * in reponse header) + */ + public static final ResourceReference INTERFACE_JS = new PackageResourceReference( + JQueryBehavior.class, "interface-1.2.js"); - /** - * ResourceReference for jquery.debug.js (include by default if wicket's configuration is "development") - */ - public static final ResourceReference JQUERY_DEBUG_JS = new PackageResourceReference(JQueryBehavior.class, "jquery.debug.js"); + /** + * ResourceReference for jquery.ui containing core, resizable, draggable, droppable, selectable + * jquery-ui-personalized.js + */ + public static final ResourceReference JQUERY_UI_JS = new PackageResourceReference( + JQueryBehavior.class, "jquery-ui-personalized.js"); - /** - * ResourceReference for interface-1.2.js (not include in reponse header) - */ - public static final ResourceReference INTERFACE_JS = new PackageResourceReference(JQueryBehavior.class, "interface-1.2.js"); + /** + * ResourceReference for jquery.bgiframe-2.1.1.js (not include + * in reponse header) + */ + public static final ResourceReference JQUERY_BGIFRAME_JS = new PackageResourceReference( + JQueryBehavior.class, "jquery.bgiframe-2.1.1.js"); - /** - * ResourceReference for jquery.ui containing core, resizable, draggable, droppable, selectable jquery-ui-personalized.js - */ - public static final ResourceReference JQUERY_UI_JS = new PackageResourceReference(JQueryBehavior.class, "jquery-ui-personalized.js"); + public static final Pattern JQUERY_REGEXP = Pattern.compile( + ".*\\<.*script.*src=\".*jquery.*\\.js\"\\>.*", Pattern.DOTALL); - /** - * ResourceReference for jquery.bgiframe-2.1.1.js (not include in reponse header) - */ - public static final ResourceReference JQUERY_BGIFRAME_JS = new PackageResourceReference(JQueryBehavior.class, "jquery.bgiframe-2.1.1.js"); + private transient Logger logger_; - public static final Pattern JQUERY_REGEXP = Pattern.compile(".*\\<.*script.*src=\".*jquery.*\\.js\"\\>.*", Pattern.DOTALL); - - private transient Logger logger_; + @Override + public void renderHead(Component component, IHeaderResponse response) + { + try + { + super.renderHead(component, response); + if (getIncludeJQueryJS(response)) + { + response.renderJavaScriptReference(JQUERY_JS); + if (Application.get().usesDevelopmentConfig()) + { + response.renderJavaScriptReference(JQUERY_DEBUG_JS); + } + } + CharSequence script = getOnReadyScript(); + if ((script != null) && (script.length() > 0)) + { + StringBuilder builder = new StringBuilder(); + builder.append(""); + response.renderString(builder.toString()); + } + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } - @Override - public void renderHead(Component component, IHeaderResponse response) { - try { - super.renderHead(component, response); - if(getIncludeJQueryJS(response)) { - response.renderJavaScriptReference(JQUERY_JS); - if (Application.get().usesDevelopmentConfig()) { - response.renderJavaScriptReference(JQUERY_DEBUG_JS); - } - } - CharSequence script = getOnReadyScript(); - if ((script != null) && (script.length() > 0)) { - StringBuilder builder = new StringBuilder(); - builder.append(""); - response.renderString(builder.toString()); - } - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } + /** + * to be overridden by subclass if you don't want to autodetect wether a jquery.js has already + * been added, and thus skip adding JQUERY_JS as a JavascriptReference. + * + * You can either simply return false, or implement your own check to see if a jquery.js + * reference has been added either as a HeaderContributor or in a tag of some page + * in the hierarchy. + * + * @param response + * The IHeaderResponse, containing the rendered headers until now + * @return true if you want renderHead to include the JQUERY_JS in the head. + */ + public boolean getIncludeJQueryJS(IHeaderResponse response) + { + return !JQUERY_REGEXP.matcher(response.getResponse().toString()).matches(); + } - /** - * to be overridden by subclass if you don't want to autodetect wether a jquery.js - * has already been added, and thus skip adding JQUERY_JS as a JavascriptReference. - * - * You can either simply return false, or implement your own check to see if a - * jquery.js reference has been added either as a HeaderContributor or in a - * tag of some page in the hierarchy. - * - * @param response The IHeaderResponse, containing the rendered headers until now - * @return true if you want renderHead to include the JQUERY_JS in the head. - */ - public boolean getIncludeJQueryJS(IHeaderResponse response) { - return !JQUERY_REGEXP.matcher(response.getResponse().toString()).matches(); - } - - /** - * to be override by subclass if need to run script when dom is ready. - * The returned script is wrapped by caller into <script> tag and the "$(document).ready(function(){...}" - * - * @return the script to execute when the dom is ready, or null (default) - */ - protected CharSequence getOnReadyScript() { - return null; - } + /** + * to be override by subclass if need to run script when dom is ready. The returned script is + * wrapped by caller into <script> tag and the "$(document).ready(function(){...}" + * + * @return the script to execute when the dom is ready, or null (default) + */ + protected CharSequence getOnReadyScript() + { + return null; + } - @Override - protected void respond(AjaxRequestTarget target) { - throw new UnsupportedOperationException("nothing to do"); - } + @Override + protected void respond(AjaxRequestTarget target) + { + throw new UnsupportedOperationException("nothing to do"); + } - protected Logger logger() { - if (logger_ == null) { - logger_ = LoggerFactory.getLogger(this.getClass()); - } - return logger_; - } + protected Logger logger() + { + if (logger_ == null) + { + logger_ = LoggerFactory.getLogger(this.getClass()); + } + return logger_; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/Options.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/Options.java index 5c402b9a07..fae9c89ecc 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/Options.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/Options.java @@ -21,17 +21,21 @@ import java.util.Map; @SuppressWarnings("serial") -public class Options implements Serializable { +public class Options implements Serializable +{ protected Map options_ = new HashMap(); - public Object get(String name) { + public Object get(String name) + { return options_.get(name); } - public Object get(String name, Object defaultValue) { + public Object get(String name, Object defaultValue) + { Object back = options_.get(name); - if (back == null) { + if (back == null) + { back = defaultValue; } return back; @@ -39,29 +43,38 @@ public Object get(String name, Object defaultValue) { /** * shortcut method, call set with overwrite = true. - * - * @param name name of the option - * @param value new value of the option (if null, then remove the option) + * + * @param name + * name of the option + * @param value + * new value of the option (if null, then remove the option) * @return this * @see #set(String,Object,boolean) */ - public Options set(String name, Object value) { + public Options set(String name, Object value) + { return set(name, value, true); } /** * set an option. - * - * @param name name of the option - * @param value new value of the option (if null, then remove the option) - * @param overwrite if false and the value is already set, then the option is unchanged + * + * @param name + * name of the option + * @param value + * new value of the option (if null, then remove the option) + * @param overwrite + * if false and the value is already set, then the option is unchanged * @return this */ - public Options set(String name, Object value, boolean overwrite) { - if (!overwrite && options_.containsKey(name)) { + public Options set(String name, Object value, boolean overwrite) + { + if (!overwrite && options_.containsKey(name)) + { return this; } - if ((value == null) && options_.containsKey(name)) { + if ((value == null) && options_.containsKey(name)) + { options_.remove(name); } options_.put(name, value); @@ -69,38 +82,45 @@ public Options set(String name, Object value, boolean overwrite) { } @Override - public String toString() { + public String toString() + { return toString(false).toString(); } - public CharSequence toString(boolean asFragment) { - if (options_.isEmpty()) { + public CharSequence toString(boolean asFragment) + { + if (options_.isEmpty()) + { return ""; } StringBuilder str = new StringBuilder(); - if (!asFragment) { + if (!asFragment) + { str.append("{\n"); } - for (Map.Entry entry : options_.entrySet()) { - str.append("\t'") - .append(escape(entry.getKey())) - .append("':"); + for (Map.Entry entry : options_.entrySet()) + { + str.append("\t'").append(escape(entry.getKey())).append("':"); // Don't surround function-strings in quotes Object val = entry.getValue(); - if (val instanceof FunctionString) { + if (val instanceof FunctionString) + { str.append(val.toString()); - } - else if( (val instanceof Boolean) || (val instanceof Number) ) { - str.append(val.toString()); - } - else { + } + else if ((val instanceof Boolean) || (val instanceof Number)) + { + str.append(val.toString()); + } + else + { str.append("'" + escape(val.toString()) + "'"); } str.append(",\n"); } - if (!asFragment) { + if (!asFragment) + { str.setLength(str.length() - 2); str.append("\n}\n"); } @@ -109,14 +129,18 @@ else if( (val instanceof Boolean) || (val instanceof Number) ) { /** * Escapes any occurrence of ' + * * @param input * @return escaped input */ - private String escape(final String input) { + private String escape(final String input) + { final StringBuilder output = new StringBuilder(); - for (final char ch : input.toCharArray()) { - if (ch == '\'') { + for (final char ch : input.toCharArray()) + { + if (ch == '\'') + { output.append('\\'); } output.append(ch); diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/accordion/JQAccordion.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/accordion/JQAccordion.java index c008d15641..0ae1e52f22 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/accordion/JQAccordion.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/accordion/JQAccordion.java @@ -33,34 +33,38 @@ /** * JQuery based implementation of client side accordion. *

- * This component uses JQuery and the accordion plugin to create client side - * accordion. Being client side, all content is rendered and sent to the client - * at first time. + * This component uses JQuery and the accordion plugin to create client side accordion. Being client + * side, all content is rendered and sent to the client at first time. *

- * This component is abstract and must be subclassed similarly to {@link RefreshingView}. - * Each accordion item to be populated must have two sub components: a 'title', and a 'content'. - * You can use Label for these, or for complex content use a {@link Panel} - * or a {@link WebMarkupContainer}. + * This component is abstract and must be subclassed similarly to {@link RefreshingView}. Each + * accordion item to be populated must have two sub components: a 'title', and a 'content'. You can + * use Label for these, or for complex content use a {@link Panel} or a {@link WebMarkupContainer}. * *

* Example: + * *

- * new JQAccordion("accordion1") {
- *    private static final long serialVersionUID = 1L;
- *			
- *    protected Iterator getItemModels() {
- *      return new ArrayIteratorAdapter(new Object[] {"A", "B", "C"}) {
- *					
- *        protected IModel model(Object obj) {
- *          return new Model((Serializable) obj);
- *        }
- *      };
- *    }
- *			
- *    protected void populateItem(Item item) {
- *      item.add(new Label("title", item.getModel()));
- *      item.add(new Label("content", item.getModelObjectAsString()+" content"));
- *    }
+ * new JQAccordion("accordion1")
+ * {
+ * 	private static final long serialVersionUID = 1L;
+ * 
+ * 	protected Iterator getItemModels()
+ * 	{
+ * 		return new ArrayIteratorAdapter(new Object[] { "A", "B", "C" })
+ * 		{
+ * 
+ * 			protected IModel model(Object obj)
+ * 			{
+ * 				return new Model((Serializable)obj);
+ * 			}
+ * 		};
+ * 	}
+ * 
+ * 	protected void populateItem(Item item)
+ * 	{
+ * 		item.add(new Label("title", item.getModel()));
+ * 		item.add(new Label("content", item.getModelObjectAsString() + " content"));
+ * 	}
  * }
  * 
* @@ -69,56 +73,67 @@ * * @author Xavier Hanin */ -public abstract class JQAccordion extends Panel { +public abstract class JQAccordion extends Panel +{ private static final long serialVersionUID = 1L; - + private String options; /** * Constructs an accordion component with the given id. * - * @param id the id of the component. Must not be null. + * @param id + * the id of the component. Must not be null. */ - public JQAccordion(String id) { - this (id, ""); + public JQAccordion(String id) + { + this(id, ""); } - + /** * Constructs an accordion component with the given id and options. *

- * See accordion plugin documentation - * for details about options. + * See accordion plugin + * documentation for details about options. * - * @param id the id of the component. Must not be null. - * @param options the options to use for the javascript accordion component. Must not be null. + * @param id + * the id of the component. Must not be null. + * @param options + * the options to use for the javascript accordion component. Must not be + * null. */ - public JQAccordion(String id, String options) { + public JQAccordion(String id, String options) + { super(id); this.options = options; - + add(new JQueryBehavior()); final WebMarkupContainer parent = new WebMarkupContainer("accordion"); parent.setOutputMarkupId(true); add(parent); - /* - * we inject the script in the component body and not as a header contribution - * because the script needs to be called each time the component is refreshed using wicket - * ajax support. + /* + * we inject the script in the component body and not as a header contribution because the + * script needs to be called each time the component is refreshed using wicket ajax support. */ - add(new Label("script", new Model(){ + add(new Label("script", new Model() + { private static final long serialVersionUID = 1L; @Override - public String getObject() { + public String getObject() + { String options = getOptions().trim(); - if (options.length() > 0) { - options = "header: 'h3', "+options; - } else { + if (options.length() > 0) + { + options = "header: 'h3', " + options; + } + else + { options = "header: 'h3'"; } - return "$('#"+parent.getMarkupId()+"').Accordion({"+options+"});"; + return "$('#" + parent.getMarkupId() + "').Accordion({" + options + "});"; } }).setEscapeModelStrings(false)); @@ -126,29 +141,37 @@ public String getObject() { } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { super.renderHead(response); - - response.renderCSSReference(new PackageResourceReference(JQAccordion.class, "jquery.accordion.css")); - response.renderJavaScriptReference(new PackageResourceReference(JQAccordion.class, "jquery.accordion.pack.js")); + + response.renderCSSReference(new PackageResourceReference(JQAccordion.class, + "jquery.accordion.css")); + response.renderJavaScriptReference(new PackageResourceReference(JQAccordion.class, + "jquery.accordion.pack.js")); } - protected String getOptions() { - return options ; + protected String getOptions() + { + return options; } - protected RefreshingView newRepeatingView(String id) { - return new RefreshingView(id) { + protected RefreshingView newRepeatingView(String id) + { + return new RefreshingView(id) + { private static final long serialVersionUID = 1L; @Override - protected Iterator> getItemModels() { + protected Iterator> getItemModels() + { return JQAccordion.this.getItemModels(); } - + @Override - protected void populateItem(Item item) { + protected void populateItem(Item item) + { JQAccordion.this.populateItem(item); } }; @@ -165,7 +188,8 @@ protected void populateItem(Item item) { * the content of the panel * * - * @param item the item to populate + * @param item + * the item to populate */ protected abstract void populateItem(Item item); diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryAjaxBehavior.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryAjaxBehavior.java index 3c5eeace4b..2cf59dbcaf 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryAjaxBehavior.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryAjaxBehavior.java @@ -12,52 +12,75 @@ /** * @author martin-g */ -public abstract class HistoryAjaxBehavior extends AbstractDefaultAjaxBehavior { - +public abstract class HistoryAjaxBehavior extends AbstractDefaultAjaxBehavior +{ + private static final long serialVersionUID = 1L; private static final String HISTORY_ITEM_PARAM = "hiId"; - + @Override - public final CharSequence getCallbackUrl() { - return super.getCallbackUrl() + "&"+ HISTORY_ITEM_PARAM +"=' + HistoryManager.getHistoryItem()"; + public final CharSequence getCallbackUrl() + { + return super.getCallbackUrl() + "&" + HISTORY_ITEM_PARAM + + "=' + HistoryManager.getHistoryItem()"; } - + @Override - public void renderHead(final Component component, final IHeaderResponse response) { - response.renderCSSReference(new PackageResourceReference(HistoryAjaxBehavior.class, "res/history-manager-iframe.css")); + public void renderHead(final Component component, final IHeaderResponse response) + { + response.renderCSSReference(new PackageResourceReference(HistoryAjaxBehavior.class, + "res/history-manager-iframe.css")); response.renderJavaScriptReference(JQueryBehavior.JQUERY_JS); - response.renderJavaScriptReference(new PackageResourceReference(HistoryAjaxBehavior.class, "res/history-manager.js")); - + response.renderJavaScriptReference(new PackageResourceReference(HistoryAjaxBehavior.class, + "res/history-manager.js")); + /* * Save the callback URL to this behavior to call it on back/forward button clicks */ - response.renderJavaScript("var notifyBackButton = function() { wicketAjaxGet('" + getCallbackUrl() + ", null, null, function() {return true;}.bind(this)); }", "history-manager-url"); + response.renderJavaScript("var notifyBackButton = function() { wicketAjaxGet('" + + getCallbackUrl() + ", null, null, function() {return true;}.bind(this)); }", + "history-manager-url"); } - + @Override - protected void respond(AjaxRequestTarget target) { - final StringValue componentId = RequestCycle.get().getRequest().getQueryParameters().getParameterValue(HistoryAjaxBehavior.HISTORY_ITEM_PARAM); + protected void respond(AjaxRequestTarget target) + { + final StringValue componentId = RequestCycle.get() + .getRequest() + .getQueryParameters() + .getParameterValue(HistoryAjaxBehavior.HISTORY_ITEM_PARAM); onAjaxHistoryEvent(target, componentId.toString()); } - + /** - * A callback method which will be invoked when the user presses the back/forward buttons of the browser + * A callback method which will be invoked when the user presses the back/forward buttons of the + * browser * - * @param target the current request target - * @param componentId the wicket:id of the component which had triggered the previous Ajax history entry + * @param target + * the current request target + * @param componentId + * the wicket:id of the component which had triggered the previous Ajax history entry */ public abstract void onAjaxHistoryEvent(final AjaxRequestTarget target, final String componentId); /** * Registers a new entry in the history if this request is not triggered by back/forward buttons * - * @param target the current request target - * @param component the component which triggered this Ajax request + * @param target + * the current request target + * @param component + * the component which triggered this Ajax request */ - public void registerAjaxEvent(final AjaxRequestTarget target, final Component component) { - if (RequestCycle.get().getRequest().getQueryParameters().getParameterValue(HistoryAjaxBehavior.HISTORY_ITEM_PARAM).isNull()) { - target.appendJavaScript("HistoryManager.addHistoryEntry('"+ component.getId() +"');"); + public void registerAjaxEvent(final AjaxRequestTarget target, final Component component) + { + if (RequestCycle.get() + .getRequest() + .getQueryParameters() + .getParameterValue(HistoryAjaxBehavior.HISTORY_ITEM_PARAM) + .isNull()) + { + target.appendJavaScript("HistoryManager.addHistoryEntry('" + component.getId() + "');"); } } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFrame.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFrame.java index 095329eb6a..f131986f2f 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFrame.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFrame.java @@ -5,13 +5,15 @@ /** * @author martin-g */ -public class HistoryIFrame extends InlineFrame { +public class HistoryIFrame extends InlineFrame +{ private static final long serialVersionUID = 1L; - public HistoryIFrame(final String wid) { + public HistoryIFrame(final String wid) + { super(wid, HistoryIFramePage.class); - + setOutputMarkupId(true); setMarkupId("historyIframe"); } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFramePage.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFramePage.java index d53d339436..c634186439 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFramePage.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ajaxbackbutton/HistoryIFramePage.java @@ -8,16 +8,19 @@ /** * @author martin-g */ -public class HistoryIFramePage extends WebPage implements IHeaderContributor { +public class HistoryIFramePage extends WebPage implements IHeaderContributor +{ private static final long serialVersionUID = 1L; - public HistoryIFramePage() { + public HistoryIFramePage() + { } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { response.renderJavaScriptReference(JQueryBehavior.JQUERY_JS); } - + } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockOptions.java index 73c395f6b6..c163ca08f8 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockOptions.java @@ -2,36 +2,43 @@ import org.wicketstuff.jquery.Options; -public class BlockOptions extends Options { +public class BlockOptions extends Options +{ private static final long serialVersionUID = 1L; - public BlockOptions setMessage(String message) { + public BlockOptions setMessage(String message) + { set("message", message); return this; } - public BlockOptions setCSS(Options css) { + public BlockOptions setCSS(Options css) + { set("css", css); return this; } - public BlockOptions setFadeIn(int ms) { + public BlockOptions setFadeIn(int ms) + { set("fadeIn", ms); return this; } - public BlockOptions setFadeOut(int ms) { + public BlockOptions setFadeOut(int ms) + { set("fadeOut", ms); return this; } - public BlockOptions setTimeout(int ms) { + public BlockOptions setTimeout(int ms) + { set("timeout", ms); return this; } - public BlockOptions setShowOverlay(boolean v) { + public BlockOptions setShowOverlay(boolean v) + { set("showOverlay", v); return this; } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockingAjaxLink.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockingAjaxLink.java index 5dc8551aab..373e1918ee 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockingAjaxLink.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/block/BlockingAjaxLink.java @@ -26,24 +26,27 @@ import org.apache.wicket.request.resource.ResourceReference; import org.wicketstuff.jquery.JQueryBehavior; -public abstract class BlockingAjaxLink extends AjaxLink implements - IHeaderContributor { +public abstract class BlockingAjaxLink extends AjaxLink implements IHeaderContributor +{ public static final ResourceReference BLOCK_JS = new PackageResourceReference( - BlockingAjaxLink.class, "jquery.blockUI.js"); + BlockingAjaxLink.class, "jquery.blockUI.js"); final BlockOptions options; - public BlockingAjaxLink(final String id, BlockOptions options) { + public BlockingAjaxLink(final String id, BlockOptions options) + { super(id, null); this.options = options; } - public BlockingAjaxLink(final String id, String message) { + public BlockingAjaxLink(final String id, String message) + { this(id, new BlockOptions().setMessage(message)); } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { response.renderJavaScriptReference(JQueryBehavior.JQUERY_JS); response.renderJavaScriptReference(BLOCK_JS); } @@ -54,46 +57,56 @@ public void renderHead(IHeaderResponse response) { * @return ajax call decorator */ @Override - protected IAjaxCallDecorator getAjaxCallDecorator() { - return new IAjaxCallDecorator() { + protected IAjaxCallDecorator getAjaxCallDecorator() + { + return new IAjaxCallDecorator() + { private static final long serialVersionUID = 1L; - public CharSequence decorateScript(Component component, CharSequence script) { + public CharSequence decorateScript(Component component, CharSequence script) + { StringBuilder js = new StringBuilder(); CharSequence sel = getBlockElementsSelector(); - if (sel != null) { + if (sel != null) + { js.append("$('").append(sel).append("').block( "); - } else { + } + else + { js.append("$.blockUI( "); } - return js.append(options.toString()).append(" ); ") - .append(script); + return js.append(options.toString()).append(" ); ").append(script); } - public CharSequence decorateOnSuccessScript(Component component, - CharSequence script) { + public CharSequence decorateOnSuccessScript(Component component, CharSequence script) + { return script; } - public CharSequence decorateOnFailureScript(Component component, - CharSequence script) { + public CharSequence decorateOnFailureScript(Component component, CharSequence script) + { return script; } }; } - public CharSequence getBlockElementsSelector() { + public CharSequence getBlockElementsSelector() + { return null; } @Override - final public void onClick(final AjaxRequestTarget target) { + final public void onClick(final AjaxRequestTarget target) + { doClick(target); CharSequence sel = getBlockElementsSelector(); - if (sel != null) { + if (sel != null) + { target.appendJavaScript("$('" + sel + "').unblock(); "); - } else { + } + else + { target.appendJavaScript("$.unblockUI(); "); } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressBehaviour.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressBehaviour.java index bb31fa7f86..23966dd42c 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressBehaviour.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressBehaviour.java @@ -8,50 +8,59 @@ import org.wicketstuff.minis.behavior.SimpleAttributeAppender; /** - * + * * @author Edvin Syse - * + * */ -public class CodepressBehaviour extends JQueryBehavior { - public static final ResourceReference CODEPRESS_JS = new PackageResourceReference(CodepressBehaviour.class, "jquery.codepress.js"); +public class CodepressBehaviour extends JQueryBehavior +{ + public static final ResourceReference CODEPRESS_JS = new PackageResourceReference( + CodepressBehaviour.class, "jquery.codepress.js"); - private CodepressOptions options_; + private CodepressOptions options_; - public CodepressBehaviour() { - this(new CodepressOptions()); + public CodepressBehaviour() + { + this(new CodepressOptions()); } - public CodepressBehaviour(CodepressOptions options) { - super(); - options_ = options != null ? options : new CodepressOptions(); - } + public CodepressBehaviour(CodepressOptions options) + { + super(); + options_ = options != null ? options : new CodepressOptions(); + } - @Override - public void renderHead(Component component, IHeaderResponse response) { - super.renderHead(component, response); - response.renderJavaScriptReference(CODEPRESS_JS); - } + @Override + public void renderHead(Component component, IHeaderResponse response) + { + super.renderHead(component, response); + response.renderJavaScriptReference(CODEPRESS_JS); + } - @Override protected CharSequence getOnReadyScript() { - StringBuilder onReady = new StringBuilder("$.codepress.config = "); - onReady.append(options_.toString(false)); - onReady.append("$('" + getComponent().getMarkupId() + "').codepress();"); + @Override + protected CharSequence getOnReadyScript() + { + StringBuilder onReady = new StringBuilder("$.codepress.config = "); + onReady.append(options_.toString(false)); + onReady.append("$('" + getComponent().getMarkupId() + "').codepress();"); - return onReady; - } + return onReady; + } - @Override protected void onBind() { - super.onBind(); - StringBuilder classes = new StringBuilder("codepress"); - if(options_.getFileType() != null) - classes.append(" " + options_.getFileType()); + @Override + protected void onBind() + { + super.onBind(); + StringBuilder classes = new StringBuilder("codepress"); + if (options_.getFileType() != null) + classes.append(" " + options_.getFileType()); - classes.append(" autocomplete-" + (options_.isAutoComplete() ? "on" : "off")); + classes.append(" autocomplete-" + (options_.isAutoComplete() ? "on" : "off")); - if(!options_.isLineNumbers()) - classes.append(" linenumbers-off"); + if (!options_.isLineNumbers()) + classes.append(" linenumbers-off"); - getComponent().add(new SimpleAttributeAppender("class", classes.toString(), " ")); - } + getComponent().add(new SimpleAttributeAppender("class", classes.toString(), " ")); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressOptions.java index 46c4e53c0b..8c0b46a63b 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/codepress/CodepressOptions.java @@ -5,48 +5,57 @@ /** * * @author Edvin Syse - * + * */ -public class CodepressOptions extends Options { +public class CodepressOptions extends Options +{ private String fileType; private boolean autoComplete; private boolean lineNumbers; - - public CodepressOptions() { + + public CodepressOptions() + { set("path", "/resources/org.wicketstuff.jquery.codepress.CodepressBehaviour/"); } - - public CodepressOptions height(int height) { + + public CodepressOptions height(int height) + { set("height", height); return this; } - public CodepressOptions lineNumbers(boolean lineNumbers) { + public CodepressOptions lineNumbers(boolean lineNumbers) + { this.lineNumbers = lineNumbers; return this; } - public CodepressOptions autoComplete(boolean autoComplete) { - if(!autoComplete) - set("autocomplete", "off"); - this.autoComplete = autoComplete; - return this; - } + public CodepressOptions autoComplete(boolean autoComplete) + { + if (!autoComplete) + set("autocomplete", "off"); + this.autoComplete = autoComplete; + return this; + } - public CodepressOptions fileType(String fileType) { + public CodepressOptions fileType(String fileType) + { this.fileType = fileType; return this; } - public String getFileType() { + public String getFileType() + { return fileType; } - public boolean isAutoComplete() { + public boolean isAutoComplete() + { return autoComplete; } - public boolean isLineNumbers() { + public boolean isLineNumbers() + { return lineNumbers; } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzBehaviour.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzBehaviour.java index 2a1f190819..0f79105407 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzBehaviour.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzBehaviour.java @@ -25,28 +25,36 @@ /** * * @author Edvin Syse - * + * */ -public class CornerzBehaviour extends JQueryBehavior { - public static final ResourceReference CORNERZ_JS = new PackageResourceReference(CornerzBehaviour.class, "jquery.cornerz.js"); - private CornerzOptions options_; - - public CornerzBehaviour() { - this(new CornerzOptions()); +public class CornerzBehaviour extends JQueryBehavior +{ + public static final ResourceReference CORNERZ_JS = new PackageResourceReference( + CornerzBehaviour.class, "jquery.cornerz.js"); + private CornerzOptions options_; + + public CornerzBehaviour() + { + this(new CornerzOptions()); + } + + public CornerzBehaviour(CornerzOptions options) + { + super(); + options_ = options != null ? options : new CornerzOptions(); + } + + @Override + public void renderHead(Component component, IHeaderResponse response) + { + super.renderHead(component, response); + response.renderJavaScriptReference(CORNERZ_JS); } - - public CornerzBehaviour(CornerzOptions options) { - super(); - options_ = options != null ? options : new CornerzOptions(); - } - - @Override - public void renderHead(Component component, IHeaderResponse response) { - super.renderHead(component, response); - response.renderJavaScriptReference(CORNERZ_JS); - } - @Override protected CharSequence getOnReadyScript() { - return "\t$('#" + getComponent().getMarkupId() + "').cornerz(" + options_.toString(false) + ");"; - } + @Override + protected CharSequence getOnReadyScript() + { + return "\t$('#" + getComponent().getMarkupId() + "').cornerz(" + options_.toString(false) + + ");"; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzOptions.java index bc09f08be1..7146842bcf 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/cornerz/CornerzOptions.java @@ -23,31 +23,37 @@ * @author Edvin Syse * */ -public class CornerzOptions extends Options { +public class CornerzOptions extends Options +{ - public CornerzOptions radius(int radius) { + public CornerzOptions radius(int radius) + { set("radius", radius); return this; } - - public CornerzOptions borderWidth(int borderWidth) { + + public CornerzOptions borderWidth(int borderWidth) + { set("borderWidth", borderWidth); return this; } - - public CornerzOptions background(String background) { + + public CornerzOptions background(String background) + { set("background", background); return this; } - - public CornerzOptions borderColor(String borderColor) { + + public CornerzOptions borderColor(String borderColor) + { set("borderColor", borderColor); return this; } - - public CornerzOptions corners(String corners) { + + public CornerzOptions corners(String corners) + { set("corners", corners); return this; } - + } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropBehaviour.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropBehaviour.java index 675bb19543..c2734a9950 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropBehaviour.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropBehaviour.java @@ -13,35 +13,53 @@ /** * * @author Edvin Syse - * + * */ -public class CropBehaviour extends JQueryBehavior { - public static final ResourceReference IRESIZABLE_JS = new PackageResourceReference(CropBehaviour.class, "iresizable.js"); - public static final ResourceReference IUTIL_JS = new PackageResourceReference(CropBehaviour.class, "iutil.js"); - public static final ResourceReference CROP_BG = new PackageResourceReference(CropBehaviour.class, "crop_bg.png"); +public class CropBehaviour extends JQueryBehavior +{ + public static final ResourceReference IRESIZABLE_JS = new PackageResourceReference( + CropBehaviour.class, "iresizable.js"); + public static final ResourceReference IUTIL_JS = new PackageResourceReference( + CropBehaviour.class, "iutil.js"); + public static final ResourceReference CROP_BG = new PackageResourceReference( + CropBehaviour.class, "crop_bg.png"); private CropOptions options; - public CropBehaviour() { + public CropBehaviour() + { this(new CropOptions()); } - public CropBehaviour(CropOptions options) { + public CropBehaviour(CropOptions options) + { super(); this.options = options != null ? options : new CropOptions(); } - @Override protected CharSequence getOnReadyScript() { - StringBuilder onReady = new StringBuilder("$('#" + getComponent().getMarkupId() + "').Resizable("); + @Override + protected CharSequence getOnReadyScript() + { + StringBuilder onReady = new StringBuilder("$('#" + getComponent().getMarkupId() + + "').Resizable("); options.set("onStop", new FunctionString("cropCallback")); options.set("onDragStop", new FunctionString("cropCallback")); - options.set("onResize", new FunctionString("function(size, position) {\n this.style.backgroundPosition = '-' + (position.left) + 'px -' + (position.top) + 'px'; \n}\n")); - options.set("onDrag", new FunctionString("function(x, y) {\n this.style.backgroundPosition = '-' + (x) + 'px -' + (y) + 'px'; \n}\n")); + options.set( + "onResize", + new FunctionString( + "function(size, position) {\n this.style.backgroundPosition = '-' + (position.left) + 'px -' + (position.top) + 'px'; \n}\n")); + options.set( + "onDrag", + new FunctionString( + "function(x, y) {\n this.style.backgroundPosition = '-' + (x) + 'px -' + (y) + 'px'; \n}\n")); + + options.set( + "handlers", + new FunctionString( + "{ se: '#resizeSE', e: '#resizeE', ne: '#resizeNE', n: '#resizeN', nw: '#resizeNW', w: '#resizeW', sw: '#resizeSW', s: '#resizeS' }\n")); - options.set("handlers", new FunctionString("{ se: '#resizeSE', e: '#resizeE', ne: '#resizeNE', n: '#resizeN', nw: '#resizeNW', w: '#resizeW', sw: '#resizeSW', s: '#resizeS' }\n")); - onReady.append(options.toString(false)); onReady.append(");"); @@ -49,35 +67,47 @@ public CropBehaviour(CropOptions options) { } @Override - protected CharSequence getCallbackScript() { + protected CharSequence getCallbackScript() + { String c = "$('#" + getComponent().getMarkupId() + "')"; - - return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() - + "&width=' + " + c + ".width() + '" - + "&height=' + " + c + ".height() + '" - + "&top=' + " + c + ".css('top') + '" - + "&left=' + " + c + ".css('left')"); + + return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() + "&width=' + " + c + + ".width() + '" + "&height=' + " + c + ".height() + '" + "&top=' + " + c + + ".css('top') + '" + "&left=' + " + c + ".css('left')"); } - @Override public void renderHead(Component component, IHeaderResponse response) { + @Override + public void renderHead(Component component, IHeaderResponse response) + { super.renderHead(component, response); response.renderJavaScriptReference(JQUERY_JS); response.renderJavaScriptReference(INTERFACE_JS); response.renderJavaScriptReference(IRESIZABLE_JS); response.renderJavaScriptReference(IUTIL_JS); - response.renderJavaScript("function cropCallback() {\n" + getCallbackScript() + "\n}\n", "crop-init-for-" + getComponent().getMarkupId()); + response.renderJavaScript("function cropCallback() {\n" + getCallbackScript() + "\n}\n", + "crop-init-for-" + getComponent().getMarkupId()); } - @Override protected void respond(AjaxRequestTarget target) { + @Override + protected void respond(AjaxRequestTarget target) + { Request req = RequestCycle.get().getRequest(); - onCropped(target, - req.getQueryParameters().getParameterValue("width").toInt(), - req.getQueryParameters().getParameterValue("height").toInt(), - Integer.parseInt(req.getQueryParameters().getParameterValue("top").toString().replace("px", "")), - Integer.parseInt(req.getQueryParameters().getParameterValue("left").toString().replace("px", ""))); + onCropped( + target, + req.getQueryParameters().getParameterValue("width").toInt(), + req.getQueryParameters().getParameterValue("height").toInt(), + Integer.parseInt(req.getQueryParameters() + .getParameterValue("top") + .toString() + .replace("px", "")), + Integer.parseInt(req.getQueryParameters() + .getParameterValue("left") + .toString() + .replace("px", ""))); } - public void onCropped(AjaxRequestTarget target, int width, int height, int top, int left) { + public void onCropped(AjaxRequestTarget target, int width, int height, int top, int left) + { System.out.println("Height: " + height); System.out.println("Width: " + width); System.out.println("Top: " + top); diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropOptions.java index 054fedab58..9ecc9dad96 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CropOptions.java @@ -5,55 +5,65 @@ /** * * @author Edvin Syse - * + * */ -public class CropOptions extends Options { +public class CropOptions extends Options +{ - public CropOptions dragHandle(Boolean dragHandle) { + public CropOptions dragHandle(Boolean dragHandle) + { if (dragHandle) set("dragHandle", true); return this; } - public CropOptions minWidth(int minWidth) { + public CropOptions minWidth(int minWidth) + { set("minWidth", minWidth); return this; } - - public CropOptions minHeight(int minHeight) { + + public CropOptions minHeight(int minHeight) + { set("minHeight", minHeight); return this; } - - public CropOptions maxWidth(int maxWidth) { + + public CropOptions maxWidth(int maxWidth) + { set("maxWidth", maxWidth); return this; } - - public CropOptions maxHeight(int maxHeight) { + + public CropOptions maxHeight(int maxHeight) + { set("maxHeight", maxHeight); return this; } - - public CropOptions minTop(int minTop) { + + public CropOptions minTop(int minTop) + { set("minTop", minTop); return this; } - - public CropOptions minLeft(int minLeft) { + + public CropOptions minLeft(int minLeft) + { set("minLeft", minLeft); return this; } - - public CropOptions maxRight(int maxRight) { + + public CropOptions maxRight(int maxRight) + { set("maxRight", maxRight); return this; } - - public CropOptions maxBottom(int maxBottom) { + + public CropOptions maxBottom(int maxBottom) + { set("maxBottom", maxBottom); return this; } - + } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CroppableImage.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CroppableImage.java index 8ba4d1b893..979b449a94 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CroppableImage.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/crop/CroppableImage.java @@ -11,20 +11,23 @@ /** * * @author Edvin Syse - * + * */ -public class CroppableImage extends Panel { +public class CroppableImage extends Panel +{ private WebMarkupContainer container; private WebMarkupContainer image; private final Map vars; - - public CroppableImage(String id, CropBehaviour behaviour, final String imageUrl, final int width, final int height) { + + public CroppableImage(String id, CropBehaviour behaviour, final String imageUrl, + final int width, final int height) + { super(id); container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); - + image = new WebMarkupContainer("image"); image.setOutputMarkupId(true); add(image); @@ -35,25 +38,25 @@ public CroppableImage(String id, CropBehaviour behaviour, final String imageUrl, vars.put("imageUrl", imageUrl); vars.put("width", width); vars.put("height", height); - vars.put("rwidth", width/2); - vars.put("rheight", height/2); + vars.put("rwidth", width / 2); + vars.put("rheight", height / 2); vars.put("cropBg", urlFor(CropBehaviour.CROP_BG, null)); - + image.add(behaviour); } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { super.renderHead(response); - + PackageTextTemplate template = new PackageTextTemplate(CroppableImage.class, "crop.css"); String css = template.interpolate(vars).asString(); - - response.renderCSS(css, "croppable-image."+getMarkupId()); + + response.renderCSS(css, "croppable-image." + getMarkupId()); } - - + } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerBehavior.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerBehavior.java index 006235d8a5..9367397c1a 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerBehavior.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerBehavior.java @@ -39,147 +39,181 @@ import org.wicketstuff.minis.behavior.SimpleAttributeAppender; /** - * Add support of the datePicker. - * + * Add support of the datePicker. + * * @author David Bernard (dwayne) * @created 2007-09-08 */ @SuppressWarnings(value = "serial") -public class DatePickerBehavior extends JQueryBehavior { - - public static final ResourceReference DATE_JS = new PackageResourceReference(DatePickerBehavior.class, "date.js"); - public static final ResourceReference JQUERY_DATEPICKER_JS = new PackageResourceReference(DatePickerBehavior.class, "jquery.datePicker.js"); - public static final ResourceReference DATEPICKER_CSS = new PackageResourceReference(DatePickerBehavior.class, "datePicker.css"); - private DatePickerOptions options_; - private String format_; +public class DatePickerBehavior extends JQueryBehavior +{ + + public static final ResourceReference DATE_JS = new PackageResourceReference( + DatePickerBehavior.class, "date.js"); + public static final ResourceReference JQUERY_DATEPICKER_JS = new PackageResourceReference( + DatePickerBehavior.class, "jquery.datePicker.js"); + public static final ResourceReference DATEPICKER_CSS = new PackageResourceReference( + DatePickerBehavior.class, "datePicker.css"); + private DatePickerOptions options_; + private String format_; private boolean includeJquery = true; - public boolean isIncludeJquery() { + public boolean isIncludeJquery() + { return includeJquery; } - public void setIncludeJquery(boolean includeJquery) { + public void setIncludeJquery(boolean includeJquery) + { this.includeJquery = includeJquery; } - public DatePickerBehavior() { - this(null); - } - - public DatePickerBehavior(DatePickerOptions options) { - if (options == null) { - options = new DatePickerOptions(); - } - options_ = options; - } - -// private void convertDateInOptions(IConverter cnv, String key, Locale locale) { -// Date date = (Date)options_.get(key); -// if (date != null) { -// options_.set(key, cnv.convertToString(date, locale)); -// } -// } - @Override - public void renderHead(Component component, IHeaderResponse response) { - if(includeJquery) + public DatePickerBehavior() + { + this(null); + } + + public DatePickerBehavior(DatePickerOptions options) + { + if (options == null) + { + options = new DatePickerOptions(); + } + options_ = options; + } + +// private void convertDateInOptions(IConverter cnv, String key, Locale locale) { +// Date date = (Date)options_.get(key); +// if (date != null) { +// options_.set(key, cnv.convertToString(date, locale)); +// } +// } + @Override + public void renderHead(Component component, IHeaderResponse response) + { + if (includeJquery) super.renderHead(component, response); - response.renderCSSReference(DATEPICKER_CSS); - response.renderJavaScriptReference(DATE_JS); - try { - WebClientInfo info = WebSession.get().getClientInfo(); - if (info.getUserAgent().contains("MSIE")) { - response.renderJavaScriptReference(JQUERY_BGIFRAME_JS); - } - } catch (ClassCastException exc) { - logger().info("can't find info about client", exc); - } - - // if (ie) { - // response.renderJavascriptReference(JQUERY_BGIFRAME_JS); - // } - response.renderJavaScriptReference(JQUERY_DATEPICKER_JS); - - /* Support localized messages in the datepicker clientside */ - if(options_.dynamicLocalizedMessages) { - Map lm = new HashMap(); - SimpleDateFormat sdf = new SimpleDateFormat("", getComponent().getLocale()); - lm.put("dayNames", new StringBuilder("Date.dayNames = [")); - lm.put("abbrDayNames", new StringBuilder("Date.abbrDayNames = [")); - lm.put("monthNames", new StringBuilder("Date.monthNames = [")); - lm.put("abbrMonthNames", new StringBuilder("Date.abbrMonthNames = [")); - - for(int i = 1; i < 8; i++) { - lm.get("dayNames").append(" '" + Strings.capitalize(sdf.getDateFormatSymbols().getWeekdays()[i])); - lm.get("abbrDayNames").append(" '" + Strings.capitalize(sdf.getDateFormatSymbols().getShortWeekdays()[i])); - - if(i < 7) { - lm.get("dayNames").append("',"); - lm.get("abbrDayNames").append("',"); - } - } - - for(int i = 0; i < 12; i++) { - lm.get("monthNames").append(" '" + Strings.capitalize(sdf.getDateFormatSymbols().getMonths()[i])); - lm.get("abbrMonthNames").append(" '" + Strings.capitalize(sdf.getDateFormatSymbols().getShortMonths()[i])); - - if(i < 11) { - lm.get("monthNames").append("',"); - lm.get("abbrMonthNames").append("',"); - } - } - - String locMess = lm.get("dayNames").toString() + "' ];\n" + - lm.get("abbrDayNames") + "' ];\n" + - lm.get("monthNames") + "' ];\n" + - lm.get("abbrMonthNames") + "' ];\n"; - - response.renderJavaScript(locMess, "localization_override" + getComponent().getMarkupId()); - } - } - - @Override - protected CharSequence getOnReadyScript() { - String selector = ".date-pick"; - Component component = getComponent(); - if (!(component instanceof Page)) { - selector = "#" + component.getMarkupId(); - } - return String.format("Date.format = '%s';$('%s').datePicker(%s)", format_, selector, options_.toString(false)); - } - - @Override - protected void onBind() { - super.onBind(); - Component component = getComponent(); - if (component instanceof TextField) { - component.setOutputMarkupId(true); - - if (component instanceof ITextFormatProvider) { - format_ = ((ITextFormatProvider) component).getTextFormat().toLowerCase(); - } else { - TextField tf = (TextField) component; - IConverter cnv = tf.getConverter(tf.getType()); - if ((cnv != null) && (DateConverter.class.isAssignableFrom(cnv.getClass()))) { - SimpleDateFormat sdf = (SimpleDateFormat) ((DateConverter) cnv).getDateFormat(component.getLocale()); - format_ = sdf.toPattern().toLowerCase(); - } - -// convertDateInOptions(cnv, "startDate", component.getLocale()); -// convertDateInOptions(cnv, "endDate", component.getLocale()); - } - - component.add(getDatePickerStyle()); - } else { - throw new RuntimeException("DatePicketBehavior is intended to be attached to a TextField component!"); - } - } - - public Behavior getDatePickerStyle() { - return new CompositeBehavior( - new SimpleAttributeAppender("class", "date-pick", " "), - new SimpleAttributeModifier("size", String.valueOf(format_.length())), - new SimpleAttributeModifier("maxlength", String.valueOf(format_.length())), - new SimpleAttributeModifier("title", format_) - ); - } + response.renderCSSReference(DATEPICKER_CSS); + response.renderJavaScriptReference(DATE_JS); + try + { + WebClientInfo info = WebSession.get().getClientInfo(); + if (info.getUserAgent().contains("MSIE")) + { + response.renderJavaScriptReference(JQUERY_BGIFRAME_JS); + } + } + catch (ClassCastException exc) + { + logger().info("can't find info about client", exc); + } + + // if (ie) { + // response.renderJavascriptReference(JQUERY_BGIFRAME_JS); + // } + response.renderJavaScriptReference(JQUERY_DATEPICKER_JS); + + /* Support localized messages in the datepicker clientside */ + if (options_.dynamicLocalizedMessages) + { + Map lm = new HashMap(); + SimpleDateFormat sdf = new SimpleDateFormat("", getComponent().getLocale()); + lm.put("dayNames", new StringBuilder("Date.dayNames = [")); + lm.put("abbrDayNames", new StringBuilder("Date.abbrDayNames = [")); + lm.put("monthNames", new StringBuilder("Date.monthNames = [")); + lm.put("abbrMonthNames", new StringBuilder("Date.abbrMonthNames = [")); + + for (int i = 1; i < 8; i++) + { + lm.get("dayNames").append( + " '" + Strings.capitalize(sdf.getDateFormatSymbols().getWeekdays()[i])); + lm.get("abbrDayNames").append( + " '" + Strings.capitalize(sdf.getDateFormatSymbols().getShortWeekdays()[i])); + + if (i < 7) + { + lm.get("dayNames").append("',"); + lm.get("abbrDayNames").append("',"); + } + } + + for (int i = 0; i < 12; i++) + { + lm.get("monthNames").append( + " '" + Strings.capitalize(sdf.getDateFormatSymbols().getMonths()[i])); + lm.get("abbrMonthNames").append( + " '" + Strings.capitalize(sdf.getDateFormatSymbols().getShortMonths()[i])); + + if (i < 11) + { + lm.get("monthNames").append("',"); + lm.get("abbrMonthNames").append("',"); + } + } + + String locMess = lm.get("dayNames").toString() + "' ];\n" + lm.get("abbrDayNames") + + "' ];\n" + lm.get("monthNames") + "' ];\n" + lm.get("abbrMonthNames") + "' ];\n"; + + response.renderJavaScript(locMess, "localization_override" + + getComponent().getMarkupId()); + } + } + + @Override + protected CharSequence getOnReadyScript() + { + String selector = ".date-pick"; + Component component = getComponent(); + if (!(component instanceof Page)) + { + selector = "#" + component.getMarkupId(); + } + return String.format("Date.format = '%s';$('%s').datePicker(%s)", format_, selector, + options_.toString(false)); + } + + @Override + protected void onBind() + { + super.onBind(); + Component component = getComponent(); + if (component instanceof TextField) + { + component.setOutputMarkupId(true); + + if (component instanceof ITextFormatProvider) + { + format_ = ((ITextFormatProvider)component).getTextFormat().toLowerCase(); + } + else + { + TextField tf = (TextField)component; + IConverter cnv = tf.getConverter(tf.getType()); + if ((cnv != null) && (DateConverter.class.isAssignableFrom(cnv.getClass()))) + { + SimpleDateFormat sdf = (SimpleDateFormat)((DateConverter)cnv).getDateFormat(component.getLocale()); + format_ = sdf.toPattern().toLowerCase(); + } + +// convertDateInOptions(cnv, "startDate", component.getLocale()); +// convertDateInOptions(cnv, "endDate", component.getLocale()); + } + + component.add(getDatePickerStyle()); + } + else + { + throw new RuntimeException( + "DatePicketBehavior is intended to be attached to a TextField component!"); + } + } + + public Behavior getDatePickerStyle() + { + return new CompositeBehavior(new SimpleAttributeAppender("class", "date-pick", " "), + new SimpleAttributeModifier("size", String.valueOf(format_.length())), + new SimpleAttributeModifier("maxlength", String.valueOf(format_.length())), + new SimpleAttributeModifier("title", format_)); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerOptions.java index fac9b34a4c..4769211c16 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/datepicker/DatePickerOptions.java @@ -27,113 +27,192 @@ * * @author dwayne (David Bernard) */ -public class DatePickerOptions extends Options{ - +public class DatePickerOptions extends Options +{ + private static final long serialVersionUID = 1L; - /*public static enum ShowHeader {NONE, SHORT, LONG,};*/ - public static enum VPos {TOP, BOTTOM}; - public static enum HPos {LEFT, RIGHT} + /* public static enum ShowHeader {NONE, SHORT, LONG,}; */ + public static enum VPos + { + TOP, BOTTOM + }; + public static enum HPos + { + LEFT, RIGHT + } - /* Set true to override the javascript localized messages shown in the datepicker by - * dynamically getting the fieldnames from a SimpleDateFormat object set to the current locale - * of the component. - */ + /* + * Set true to override the javascript localized messages shown in the datepicker by dynamically + * getting the fieldnames from a SimpleDateFormat object set to the current locale of the + * component. + */ public boolean dynamicLocalizedMessages = false; - - /** month (Number): The month to render when the date picker is opened (NOTE that months are zero based). Default is today's month.*/ - public DatePickerOptions month(int v) { - set("month", v); - return this; - } - /** year (Number): The year to render when the date picker is opened. Default is today's year. */ - public DatePickerOptions year(int v) { - set("year", v); - return this; - } - /** startDate (String): The first date date can be selected. */ - public DatePickerOptions startDate(String v) { - set("startDate", v); - return this; - } - /** endDate (String): The last date that can be selected. */ - public DatePickerOptions endDate(String v) { - set("endDate", v); - return this; - } - /** createButton (Boolean): Whether to create a .dp-choose-date anchor directly after the matched element which when clicked will trigger the showing of the date picker. Default is true. */ - public DatePickerOptions createButton(boolean v) { - set("createButton", v); - return this; - } - /** showYearNavigation (Boolean): Whether to display buttons which allow the user to navigate through the months a year at a time. Default is true. */ - public DatePickerOptions showYearNavigation(boolean v) { - set("showYearNavigation", v); - return this; - } - /** closeOnSelect (Boolean): Whether to close the date picker when a date is selected. Default is true.*/ - public DatePickerOptions closeOnSelect(boolean v) { - set("closeOnSelect", v); - return this; - } - /** displayClose (Boolean): Whether to create a "Close" button within the date picker popup. Default is false.*/ - public DatePickerOptions displayClose(boolean v) { - set("displayClose", v); - return this; - } - /** selectMultiple (Boolean): Whether a user should be able to select multiple dates with this date picker. Default is false.*/ - public DatePickerOptions selectMultiple(boolean v) { - set("selectMultiple", v); - return this; - } - /** clickInput (Boolean): If the matched element is an input type="text" and this option is true then clicking on the input will cause the date picker to appear.*/ - public DatePickerOptions clickInput(boolean v) { - set("clickInput", v); - return this; - } - /** verticalPosition (Number): The vertical alignment of the popped up date picker to the matched element. Default is TOP.*/ - public DatePickerOptions verticalPosition(VPos v) { - set("verticalPosition", v.ordinal()); - return this; - } - /** horizontalPosition (Number): The horizontal alignment of the popped up date picker to the matched element. One of $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT.*/ - public DatePickerOptions horizontalPosition(HPos v) { - set("horizontalPosition", v.ordinal()); - return this; - } - /** verticalOffset (Number): The number of pixels offset from the defined verticalPosition of this date picker that it should pop up in. Default in 0.*/ - public DatePickerOptions verticalOffset(int v) { - set("verticalOffset", v); - return this; - } - /** horizontalOffset (Number): The number of pixels offset from the defined horizontalPosition of this date picker that it should pop up in. Default in 0.*/ - public DatePickerOptions horizontalOffset(int v) { - set("horizontalOffset", v); - return this; - } - /** hoverClass (String): The class to attach to each cell when you hover over it (to allow you to use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than links). Default is dp-hover. Pass false if you don't want a hover class.*/ - public DatePickerOptions hoverClass(String v) { - set("hoverClass", v); - return this; - } - - /** allowing (or not) selection of Date in paste (default : false) */ - public DatePickerOptions allowDateInPast(final boolean allowInPast, final String datePattern) { - - final Date startDate; - if (allowInPast) { - startDate = new Date(0); - } else { - startDate = new Date(); - } - - final DateFormat dateFormat = new SimpleDateFormat(datePattern); - - return startDate(dateFormat.format(startDate)); - } - - public DatePickerOptions dynamicLocalizedMessages(boolean v) { - this.dynamicLocalizedMessages = v; - return this; - } + + /** + * month (Number): The month to render when the date picker is opened (NOTE that months are zero + * based). Default is today's month. + */ + public DatePickerOptions month(int v) + { + set("month", v); + return this; + } + + /** year (Number): The year to render when the date picker is opened. Default is today's year. */ + public DatePickerOptions year(int v) + { + set("year", v); + return this; + } + + /** startDate (String): The first date date can be selected. */ + public DatePickerOptions startDate(String v) + { + set("startDate", v); + return this; + } + + /** endDate (String): The last date that can be selected. */ + public DatePickerOptions endDate(String v) + { + set("endDate", v); + return this; + } + + /** + * createButton (Boolean): Whether to create a .dp-choose-date anchor directly after the matched + * element which when clicked will trigger the showing of the date picker. Default is true. + */ + public DatePickerOptions createButton(boolean v) + { + set("createButton", v); + return this; + } + + /** + * showYearNavigation (Boolean): Whether to display buttons which allow the user to navigate + * through the months a year at a time. Default is true. + */ + public DatePickerOptions showYearNavigation(boolean v) + { + set("showYearNavigation", v); + return this; + } + + /** + * closeOnSelect (Boolean): Whether to close the date picker when a date is selected. Default is + * true. + */ + public DatePickerOptions closeOnSelect(boolean v) + { + set("closeOnSelect", v); + return this; + } + + /** + * displayClose (Boolean): Whether to create a "Close" button within the date picker popup. + * Default is false. + */ + public DatePickerOptions displayClose(boolean v) + { + set("displayClose", v); + return this; + } + + /** + * selectMultiple (Boolean): Whether a user should be able to select multiple dates with this + * date picker. Default is false. + */ + public DatePickerOptions selectMultiple(boolean v) + { + set("selectMultiple", v); + return this; + } + + /** + * clickInput (Boolean): If the matched element is an input type="text" and this option is true + * then clicking on the input will cause the date picker to appear. + */ + public DatePickerOptions clickInput(boolean v) + { + set("clickInput", v); + return this; + } + + /** + * verticalPosition (Number): The vertical alignment of the popped up date picker to the matched + * element. Default is TOP. + */ + public DatePickerOptions verticalPosition(VPos v) + { + set("verticalPosition", v.ordinal()); + return this; + } + + /** + * horizontalPosition (Number): The horizontal alignment of the popped up date picker to the + * matched element. One of $.dpConst.POS_LEFT and $.dpConst.POS_RIGHT. + */ + public DatePickerOptions horizontalPosition(HPos v) + { + set("horizontalPosition", v.ordinal()); + return this; + } + + /** + * verticalOffset (Number): The number of pixels offset from the defined verticalPosition of + * this date picker that it should pop up in. Default in 0. + */ + public DatePickerOptions verticalOffset(int v) + { + set("verticalOffset", v); + return this; + } + + /** + * horizontalOffset (Number): The number of pixels offset from the defined horizontalPosition of + * this date picker that it should pop up in. Default in 0. + */ + public DatePickerOptions horizontalOffset(int v) + { + set("horizontalOffset", v); + return this; + } + + /** + * hoverClass (String): The class to attach to each cell when you hover over it (to allow you to + * use hover effects in IE6 which doesn't support the :hover pseudo-class on elements other than + * links). Default is dp-hover. Pass false if you don't want a hover class. + */ + public DatePickerOptions hoverClass(String v) + { + set("hoverClass", v); + return this; + } + + /** allowing (or not) selection of Date in paste (default : false) */ + public DatePickerOptions allowDateInPast(final boolean allowInPast, final String datePattern) + { + + final Date startDate; + if (allowInPast) + { + startDate = new Date(0); + } + else + { + startDate = new Date(); + } + + final DateFormat dateFormat = new SimpleDateFormat(datePattern); + + return startDate(dateFormat.format(startDate)); + } + + public DatePickerOptions dynamicLocalizedMessages(boolean v) + { + dynamicLocalizedMessages = v; + return this; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDBehaviour.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDBehaviour.java index c36adebc9d..de3a09269b 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDBehaviour.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDBehaviour.java @@ -11,28 +11,37 @@ import org.wicketstuff.jquery.Options; /** - * This implementation is really too simple, only supporting one drop-container etc, - * but it is an ok startingpoint to extend the functionality. + * This implementation is really too simple, only supporting one drop-container etc, but it is an ok + * startingpoint to extend the functionality. */ -public class DnDBehaviour extends JQueryBehavior implements IBehaviorListener { +public class DnDBehaviour extends JQueryBehavior implements IBehaviorListener +{ private Options droppableOptions; private Options draggableOptions; private String dropSelector; private String dragSelector; - public DnDBehaviour() { + public DnDBehaviour() + { super(); } /** - * - * @param draggableOptions (helper=clone to "leave a copy" of the object you are dragging. Doesn't work without helper argument.) - * @param droppableOptions (hoverClass=cssClass to set on hover over a droppable) - * @param dropSelector jquery selector setting what elements are droppable (example: #myListId li) - * @param dragSelector jquery selector setting what elements are draggable (example: .draggable) - * + * + * @param draggableOptions + * (helper=clone to "leave a copy" of the object you are dragging. Doesn't work + * without helper argument.) + * @param droppableOptions + * (hoverClass=cssClass to set on hover over a droppable) + * @param dropSelector + * jquery selector setting what elements are droppable (example: #myListId li) + * @param dragSelector + * jquery selector setting what elements are draggable (example: .draggable) + * */ - public DnDBehaviour(Options draggableOptions, Options droppableOptions, String dragSelector, String dropSelector) { + public DnDBehaviour(Options draggableOptions, Options droppableOptions, String dragSelector, + String dropSelector) + { super(); this.dropSelector = dropSelector; this.dragSelector = dragSelector; @@ -42,54 +51,66 @@ public DnDBehaviour(Options draggableOptions, Options droppableOptions, String d } /** - * @param dropSelector jquery selector setting what elements are droppable (example: #myListId li) - * @param dragSelector jquery selector setting what elements are draggable (example: .draggable) + * @param dropSelector + * jquery selector setting what elements are droppable (example: #myListId li) + * @param dragSelector + * jquery selector setting what elements are draggable (example: .draggable) */ - public DnDBehaviour(String dragSelector, String dropSelector) { + public DnDBehaviour(String dragSelector, String dropSelector) + { this(new Options(), new Options(), dragSelector, dropSelector); } @Override - public void renderHead(Component component, IHeaderResponse response) { + public void renderHead(Component component, IHeaderResponse response) + { droppableOptions.set("accept", dragSelector, false); droppableOptions.set("drop", new FunctionString(getDropScript())); response.renderJavaScriptReference(JQueryBehavior.JQUERY_UI_JS); super.renderHead(component, response); - } + } - public String getDropScript() { + public String getDropScript() + { return "function(ev, ui) {\n " + getCallbackScript() + "\n}\n"; } @Override - public final void respond(AjaxRequestTarget target) { + public final void respond(AjaxRequestTarget target) + { Request req = RequestCycle.get().getRequest(); - onDrop(req.getQueryParameters().getParameterValue("src").toString(), - req.getQueryParameters().getParameterValue("dest").toString(), target); + onDrop(req.getQueryParameters().getParameterValue("src").toString(), + req.getQueryParameters().getParameterValue("dest").toString(), target); } @Override - protected CharSequence getCallbackScript() { - return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() - + "&src=' + $(ui.draggable).attr('id') + '" - + "&dest=' + $(this).attr('id')"); + protected CharSequence getCallbackScript() + { + return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() + + "&src=' + $(ui.draggable).attr('id') + '" + "&dest=' + $(this).attr('id')"); } - public void onDrop(String srcId, String destId, AjaxRequestTarget target) { + public void onDrop(String srcId, String destId, AjaxRequestTarget target) + { } - - @Override protected CharSequence getOnReadyScript() { + + @Override + protected CharSequence getOnReadyScript() + { return getRebindScript(); } - public String getRebindScript() { + public String getRebindScript() + { StringBuffer sb = new StringBuffer(); - sb.append("\t$('" + dragSelector + "').draggable(" + draggableOptions.toString(false) + ");\n"); - sb.append("\t$('" + dropSelector + "').addClass('droppable-active').droppable(" + droppableOptions.toString(false) + ");\n"); + sb.append("\t$('" + dragSelector + "').draggable(" + draggableOptions.toString(false) + + ");\n"); + sb.append("\t$('" + dropSelector + "').addClass('droppable-active').droppable(" + + droppableOptions.toString(false) + ");\n"); return sb.toString(); } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableBehavior.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableBehavior.java index b69cad7546..c817e0deae 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableBehavior.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableBehavior.java @@ -36,229 +36,283 @@ // TODO: disable callback to serverside if clientsideonly @SuppressWarnings("serial") -public class DnDSortableBehavior extends JQueryBehavior implements IBehaviorListener { - public static final ResourceReference DNDSORTABLEBEHAVIOR_JS = new PackageResourceReference(DnDSortableBehavior.class, DnDSortableBehavior.class.getSimpleName() + ".js"); +public class DnDSortableBehavior extends JQueryBehavior implements IBehaviorListener +{ + public static final ResourceReference DNDSORTABLEBEHAVIOR_JS = new PackageResourceReference( + DnDSortableBehavior.class, DnDSortableBehavior.class.getSimpleName() + ".js"); protected Options options_; - protected ArrayList containers_; + protected ArrayList containers_; - public DnDSortableBehavior() { - this(null); - } + public DnDSortableBehavior() + { + this(null); + } /** - * Create a DnDSortableBehavior with default options override. - *

    - *
  • options include every optionsof the js component (see http://interface.eyecon.ro/docs/sort for the - * base list of options).
  • - *
  • "containerclass" : the CSS' class of every container to be sortable (default is bind component (handler) + "_dndContainer"
  • - *
  • "startOnLoad" : boolean, true => sortable feature is started on page load (default) else, the client side must call the JSFunctionName4Start.
  • - *
      - * - * @param options the overriden options to use - */ - public DnDSortableBehavior(Options options) { - super(); - if (options == null) { - options = new Options(); - } - options_ = options; - options_.set("accept", "dndItem", false) - .set("helperclass", "sortHelper", false) - .set("activeclass", "sortableactive", false) - .set("hoverclass", "sortablehover", false) - //.set("handle", ".dndItem", false) - .set("tolerance", "pointer", false) - .set("startOnLoad", Boolean.TRUE, false) - ; - containers_ = new ArrayList(); - } + * Create a DnDSortableBehavior with default options override. + *
        + *
      • options include every optionsof the js component (see http://interface.eyecon.ro/docs/sort for the + * base list of options).
      • + *
      • "containerclass" : the CSS' class of every container to be sortable (default is bind + * component (handler) + "_dndContainer"
      • + *
      • "startOnLoad" : boolean, true => sortable feature is started on page load (default) else, + * the client side must call the JSFunctionName4Start.
      • + *
          + * + * @param options + * the overriden options to use + */ + public DnDSortableBehavior(Options options) + { + super(); + if (options == null) + { + options = new Options(); + } + options_ = options; + options_.set("accept", "dndItem", false) + .set("helperclass", "sortHelper", false) + .set("activeclass", "sortableactive", false) + .set("hoverclass", "sortablehover", false) + // .set("handle", ".dndItem", false) + .set("tolerance", "pointer", false) + .set("startOnLoad", Boolean.TRUE, false); + containers_ = new ArrayList(); + } - @Override - public void renderHead(Component component, IHeaderResponse response) { - super.renderHead(component, response); - response.renderJavaScriptReference(INTERFACE_JS); - response.renderJavaScriptReference(DNDSORTABLEBEHAVIOR_JS); + @Override + public void renderHead(Component component, IHeaderResponse response) + { + super.renderHead(component, response); + response.renderJavaScriptReference(INTERFACE_JS); + response.renderJavaScriptReference(DNDSORTABLEBEHAVIOR_JS); response.renderString(getHead(false)); } - public CharSequence getRebindScript() { + public CharSequence getRebindScript() + { return getHead(true); } - private CharSequence getHead(boolean rebind) { - // load the css template we created form the res package - PackageTextTemplate template = new PackageTextTemplate( - DnDSortableBehavior.class, - DnDSortableBehavior.class.getSimpleName() + (rebind ? "-rebind.tmpl" : "-head.tmpl") - ); + private CharSequence getHead(boolean rebind) + { + // load the css template we created form the res package + PackageTextTemplate template = new PackageTextTemplate(DnDSortableBehavior.class, + DnDSortableBehavior.class.getSimpleName() + (rebind ? "-rebind.tmpl" : "-head.tmpl")); // create a variable subsitution map - CharSequence itemSelector = "." + options_.get("accept"); - CharSequence handleSelector = (CharSequence) options_.get("handle"); - if (handleSelector == null) { - //only for CSS - handleSelector = itemSelector; - } - HashMap params = new HashMap(); - params.put("containerSelector", "." + getContainerCSSClass()); - params.put("helperclass", options_.get("helperclass", "").toString()); - params.put("handleSelector", handleSelector); - params.put("itemSelector", itemSelector); - params.put("options", options_.toString(true)); - params.put("callbackUrl", getCallbackUrl()); - params.put("dndHandlerStart", getJSFunctionName4Start()); - params.put("dndHandlerStop", getJSFunctionName4Stop()); - // params.put("startOnLoad", options_.get("startOnLoad", "true").toString()); - // perform subsitution and return the result - return template.asString(params); - } + CharSequence itemSelector = "." + options_.get("accept"); + CharSequence handleSelector = (CharSequence)options_.get("handle"); + if (handleSelector == null) + { + // only for CSS + handleSelector = itemSelector; + } + HashMap params = new HashMap(); + params.put("containerSelector", "." + getContainerCSSClass()); + params.put("helperclass", options_.get("helperclass", "").toString()); + params.put("handleSelector", handleSelector); + params.put("itemSelector", itemSelector); + params.put("options", options_.toString(true)); + params.put("callbackUrl", getCallbackUrl()); + params.put("dndHandlerStart", getJSFunctionName4Start()); + params.put("dndHandlerStop", getJSFunctionName4Stop()); + // params.put("startOnLoad", options_.get("startOnLoad", "true").toString()); + // perform subsitution and return the result + return template.asString(params); + } - private CharSequence getContainerCSSClass() { - CharSequence back = (CharSequence) options_.get("containerclass", null); - if (back == null) { - back = getComponent().getId() + "_dndContainer"; - } - return back; - } - - @Override - public String getOnReadyScript() { - return "$( "+getJSFunctionName4Start()+" );"; - } + private CharSequence getContainerCSSClass() + { + CharSequence back = (CharSequence)options_.get("containerclass", null); + if (back == null) + { + back = getComponent().getId() + "_dndContainer"; + } + return back; + } - /** - * @return the name of the javascript function to start the behavior on client side. - */ - public CharSequence getJSFunctionName4Start() { - return getComponent().getId() + "_dndStart"; - } + @Override + public String getOnReadyScript() + { + return "$( " + getJSFunctionName4Start() + " );"; + } - /** - * @return the name of the javascript function to stop the behavior on client side. - */ - public CharSequence getJSFunctionName4Stop() { - return getComponent().getId() + "_dndStop"; - } + /** + * @return the name of the javascript function to start the behavior on client side. + */ + public CharSequence getJSFunctionName4Start() + { + return getComponent().getId() + "_dndStart"; + } - @Override - public final void respond(AjaxRequestTarget target) { - try { - Request req = RequestCycle.get().getRequest(); - if (logger().isDebugEnabled()) { - logger().debug("params : {}", req.getRequestParameters()); - } - onDnD(target, - //req.getParameter("itemId"), - req.getQueryParameters().getParameterValue("srcContainerId").toString(), - req.getQueryParameters().getParameterValue("srcPosition").toInt(), - req.getQueryParameters().getParameterValue("destContainerId").toString(), - req.getQueryParameters().getParameterValue("destPosition").toInt() - ); - } catch (RuntimeException exc) { - throw exc; - } catch (Exception exc) { - throw new RuntimeException("wrap: " + exc.getMessage(), exc); - } - } + /** + * @return the name of the javascript function to stop the behavior on client side. + */ + public CharSequence getJSFunctionName4Stop() + { + return getComponent().getId() + "_dndStop"; + } - /** - * Call when a component has been moved on client side. - * The default implementation log (as debug) the incomming parameters, - * search the component and forward to onDnD(AjaxRequestTarget target, String itemId, String srcContainerId, int srcPos, String destContainerId, int destPos). - * - * @param target a target, provide if a response, - * @param srcContainerId the html id of source container from where item come, (null if not previously registered by via registerContainer(...)). - * @param srcPos the position/index of item into srcContainer before moving. - * @param destContainerId the html id of destination container where item is, (null if not previously registered by via registerContainer(...)). - * @param destPos the position/index of item into srcContainer after moving. - */ - public void onDnD(AjaxRequestTarget target, String srcContainerId, int srcPos, String destContainerId, int destPos) { - if (logger().isDebugEnabled()) { - logger().debug("srcContainerId={}, srcPos={}, destContainerId={}, destPos={}", new Object[]{ - srcContainerId, - srcPos, - destContainerId, - destPos - }); - } - MarkupContainer srcContainer = null; - MarkupContainer destContainer = null; - for (MarkupContainer container : containers_) { - if ((srcContainerId != null) && srcContainerId.equals(container.getMarkupId())) { - srcContainer = container; - } - if ((destContainerId != null) && destContainerId.equals(container.getMarkupId())) { - destContainer = container; - } - if ((srcContainer != null) && (destContainer != null)) { - break; - } - } -// if (srcContainer != null) { -// item = findByMarkupId(srcContainer, itemId); -// } -// if ((item == null) && (destContainer != null)) { -// item = findByMarkupId(destContainer, itemId); -// } - boolean updateContainers = onDnD(target, srcContainer, srcPos, destContainer, destPos); - if (updateContainers && (target != null)) { - // target is null in testcase - // (optional) if you need to keep in sync component, markupId on serverside and client side - target.add(srcContainer); - if (srcContainer != destContainer) { - target.add(destContainer); - } - target.appendJavaScript(getJSFunctionName4Start() + "();"); - } - } + @Override + public final void respond(AjaxRequestTarget target) + { + try + { + Request req = RequestCycle.get().getRequest(); + if (logger().isDebugEnabled()) + { + logger().debug("params : {}", req.getRequestParameters()); + } + onDnD( + target, + // req.getParameter("itemId"), + req.getQueryParameters().getParameterValue("srcContainerId").toString(), + req.getQueryParameters().getParameterValue("srcPosition").toInt(), + req.getQueryParameters().getParameterValue("destContainerId").toString(), + req.getQueryParameters().getParameterValue("destPosition").toInt()); + } + catch (RuntimeException exc) + { + throw exc; + } + catch (Exception exc) + { + throw new RuntimeException("wrap: " + exc.getMessage(), exc); + } + } - /** - * Call when a component has been moved on client side (to be overwrited). - * The default implementation log (as debug) the incomming parameters. - * - * @param target a target, provide if a response, - * @param srcContainer the source container from where item come, (null if not previously registered by via registerContainer(...)). - * @param srcPos the position/index of item into srcContainer before moving. - * @param destContainer the destination container where item is, (null if not previously registered by via registerContainer(...)). - * @param destPos the position/index of item into srcContainer after moving. - * @return false if you don't need to keep in sync component, markupId on serverside and client side, - * else return true to send to client side the srcContainer and destContainer and to update the handler (consume more resource, server, network, client). - */ - public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, MarkupContainer destContainer, int destPos) { - if (logger().isDebugEnabled()) { - logger().debug("srcContainer={}, srcPos={}, destContainer={}, destPos={}", new Object[]{srcContainer, srcPos, destContainer, destPos}); - } - return false; - } + /** + * Call when a component has been moved on client side. The default implementation log (as + * debug) the incomming parameters, search the component and forward to onDnD(AjaxRequestTarget + * target, String itemId, String srcContainerId, int srcPos, String destContainerId, int + * destPos). + * + * @param target + * a target, provide if a response, + * @param srcContainerId + * the html id of source container from where item come, (null if not previously + * registered by via registerContainer(...)). + * @param srcPos + * the position/index of item into srcContainer before moving. + * @param destContainerId + * the html id of destination container where item is, (null if not previously + * registered by via registerContainer(...)). + * @param destPos + * the position/index of item into srcContainer after moving. + */ + public void onDnD(AjaxRequestTarget target, String srcContainerId, int srcPos, + String destContainerId, int destPos) + { + if (logger().isDebugEnabled()) + { + logger().debug("srcContainerId={}, srcPos={}, destContainerId={}, destPos={}", + new Object[] { srcContainerId, srcPos, destContainerId, destPos }); + } + MarkupContainer srcContainer = null; + MarkupContainer destContainer = null; + for (MarkupContainer container : containers_) + { + if ((srcContainerId != null) && srcContainerId.equals(container.getMarkupId())) + { + srcContainer = container; + } + if ((destContainerId != null) && destContainerId.equals(container.getMarkupId())) + { + destContainer = container; + } + if ((srcContainer != null) && (destContainer != null)) + { + break; + } + } +// if (srcContainer != null) { +// item = findByMarkupId(srcContainer, itemId); +// } +// if ((item == null) && (destContainer != null)) { +// item = findByMarkupId(destContainer, itemId); +// } + boolean updateContainers = onDnD(target, srcContainer, srcPos, destContainer, destPos); + if (updateContainers && (target != null)) + { + // target is null in testcase + // (optional) if you need to keep in sync component, markupId on serverside and client +// side + target.add(srcContainer); + if (srcContainer != destContainer) + { + target.add(destContainer); + } + target.appendJavaScript(getJSFunctionName4Start() + "();"); + } + } - /** - * Register a container as a container for draggable/droppable items. - * (add the css class and markupId to be find on clientside). - * - * @param v the container to register. - * @return this - */ - protected DnDSortableBehavior registerContainer(MarkupContainer v) { - v.add(new AttributeAppender("class", new Model(String.valueOf(getContainerCSSClass())), " ")); - v.setOutputMarkupId(true); - containers_.add(v); - return this; - } + /** + * Call when a component has been moved on client side (to be overwrited). The default + * implementation log (as debug) the incomming parameters. + * + * @param target + * a target, provide if a response, + * @param srcContainer + * the source container from where item come, (null if not previously registered by + * via registerContainer(...)). + * @param srcPos + * the position/index of item into srcContainer before moving. + * @param destContainer + * the destination container where item is, (null if not previously registered by via + * registerContainer(...)). + * @param destPos + * the position/index of item into srcContainer after moving. + * @return false if you don't need to keep in sync component, markupId on serverside and client + * side, else return true to send to client side the srcContainer and destContainer and + * to update the handler (consume more resource, server, network, client). + */ + public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, + MarkupContainer destContainer, int destPos) + { + if (logger().isDebugEnabled()) + { + logger().debug("srcContainer={}, srcPos={}, destContainer={}, destPos={}", + new Object[] { srcContainer, srcPos, destContainer, destPos }); + } + return false; + } - /** - * Register a component as draggable/moveable item. - * (add the css class and markupId to be find on clientside). - * - * @param v the component to register. - * @return this - */ - protected DnDSortableBehavior registerItem(Component v) { - v.add(new AttributeAppender("class", new Model(String.valueOf(options_.get("accept"))), " ")); - v.setOutputMarkupId(true); - return this; - } + /** + * Register a container as a container for draggable/droppable items. (add the css class and + * markupId to be find on clientside). + * + * @param v + * the container to register. + * @return this + */ + protected DnDSortableBehavior registerContainer(MarkupContainer v) + { + v.add(new AttributeAppender("class", new Model( + String.valueOf(getContainerCSSClass())), " ")); + v.setOutputMarkupId(true); + containers_.add(v); + return this; + } + + /** + * Register a component as draggable/moveable item. (add the css class and markupId to be find + * on clientside). + * + * @param v + * the component to register. + * @return this + */ + protected DnDSortableBehavior registerItem(Component v) + { + v.add(new AttributeAppender("class", new Model( + String.valueOf(options_.get("accept"))), " ")); + v.setOutputMarkupId(true); + return this; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableHandler.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableHandler.java index 192e152f71..3f0e981611 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableHandler.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/dnd/DnDSortableHandler.java @@ -23,84 +23,110 @@ import org.wicketstuff.jquery.Options; @SuppressWarnings("serial") -public abstract class DnDSortableHandler extends WebComponent { - private DnDSortableBehavior dnd_; +public abstract class DnDSortableHandler extends WebComponent +{ + private DnDSortableBehavior dnd_; - public DnDSortableHandler(String id) { - this(id, null); - } + public DnDSortableHandler(String id) + { + this(id, null); + } - /** - * the Sortable's options (see http://interface.eyecon.ro/docs/sort for the - * list of options).PropertyPlaceholderConfigurer - * - * @param id See Component - * @param options the undefault options - */ - public DnDSortableHandler(String id, Options options) { - super(id); - dnd_ = new DnDSortableBehavior(options) { - @Override - public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, MarkupContainer destContainer, int destPos) { - return ((DnDSortableHandler) getComponent()).onDnD(target, srcContainer, srcPos, destContainer, destPos); - } - }; - add(dnd_); - } + /** + * the Sortable's options (see http://interface.eyecon.ro/docs/sort for the + * list of options).PropertyPlaceholderConfigurer + * + * @param id + * See Component + * @param options + * the undefault options + */ + public DnDSortableHandler(String id, Options options) + { + super(id); + dnd_ = new DnDSortableBehavior(options) + { + @Override + public boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, + int srcPos, MarkupContainer destContainer, int destPos) + { + return ((DnDSortableHandler)getComponent()).onDnD(target, srcContainer, srcPos, + destContainer, destPos); + } + }; + add(dnd_); + } - /** - * Call when a component has been moved on client side. - * - * @param target a target, provide if a response, - * @param srcContainer the source container from where item come, (null if not previously registered by via registerContainer(...)). - * @param srcPos the position/index of item into srcContainer before moving. - * @param destContainer the destination container where item is, (null if not previously registered by via registerContainer(...)). - * @param destPos the position/index of item into srcContainer after moving. - * @return false if you don't need to keep in sync component, markupId on serverside and client side, - * else return true to send to client side the srcContainer and destContainer and to update the handler (consume more resource, server, network, client). - */ - public abstract boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, int srcPos, MarkupContainer destContainer, int destPos); + /** + * Call when a component has been moved on client side. + * + * @param target + * a target, provide if a response, + * @param srcContainer + * the source container from where item come, (null if not previously registered by + * via registerContainer(...)). + * @param srcPos + * the position/index of item into srcContainer before moving. + * @param destContainer + * the destination container where item is, (null if not previously registered by via + * registerContainer(...)). + * @param destPos + * the position/index of item into srcContainer after moving. + * @return false if you don't need to keep in sync component, markupId on serverside and client + * side, else return true to send to client side the srcContainer and destContainer and + * to update the handler (consume more resource, server, network, client). + */ + public abstract boolean onDnD(AjaxRequestTarget target, MarkupContainer srcContainer, + int srcPos, MarkupContainer destContainer, int destPos); - /** - * Register a container as a container for draggable/droppable items. - * (add the css class and markupId to be find on clientside). - * - * @param v the container to register. - * @return this - */ - public DnDSortableHandler registerContainer(MarkupContainer v) { - dnd_.registerContainer(v); - return this; - } + /** + * Register a container as a container for draggable/droppable items. (add the css class and + * markupId to be find on clientside). + * + * @param v + * the container to register. + * @return this + */ + public DnDSortableHandler registerContainer(MarkupContainer v) + { + dnd_.registerContainer(v); + return this; + } - /** - * Register a component as draggable/moveable item. - * (add the css class and markupId to be find on clientside). - * - * @param v the component to register. - * @return this - */ - public DnDSortableHandler registerItem(Component v) { - dnd_.registerItem(v); - return this; - } + /** + * Register a component as draggable/moveable item. (add the css class and markupId to be find + * on clientside). + * + * @param v + * the component to register. + * @return this + */ + public DnDSortableHandler registerItem(Component v) + { + dnd_.registerItem(v); + return this; + } - /** - * @return the name of the javascript function to start the behavior on client side. - */ - public CharSequence getJSFunctionName4Start() { - return dnd_.getJSFunctionName4Start(); - } + /** + * @return the name of the javascript function to start the behavior on client side. + */ + public CharSequence getJSFunctionName4Start() + { + return dnd_.getJSFunctionName4Start(); + } - /** - * @return the name of the javascript function to stop the behavior on client side. - */ - public CharSequence getJSFunctionName4Stop() { - return dnd_.getJSFunctionName4Stop(); - } + /** + * @return the name of the javascript function to stop the behavior on client side. + */ + public CharSequence getJSFunctionName4Stop() + { + return dnd_.getJSFunctionName4Stop(); + } - public CharSequence getRebindScript() { + public CharSequence getRebindScript() + { return dnd_.getRebindScript(); } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/hints/TitleAsHintBehavior.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/hints/TitleAsHintBehavior.java index 07eddbb162..15e9bf4a17 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/hints/TitleAsHintBehavior.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/hints/TitleAsHintBehavior.java @@ -23,22 +23,26 @@ import org.wicketstuff.jquery.JQueryBehavior; /** - * + * * @author dwayne */ @SuppressWarnings(value = "serial") -public class TitleAsHintBehavior extends JQueryBehavior { +public class TitleAsHintBehavior extends JQueryBehavior +{ + + public static final ResourceReference HINTS_JS = new PackageResourceReference( + TitleAsHintBehavior.class, "jquery.hints.js"); - public static final ResourceReference HINTS_JS = new PackageResourceReference(TitleAsHintBehavior.class, "jquery.hints.js"); + @Override + public void renderHead(Component component, IHeaderResponse response) + { + super.renderHead(component, response); + response.renderJavaScriptReference(HINTS_JS); + } - @Override - public void renderHead(Component component, IHeaderResponse response) { - super.renderHead(component, response); - response.renderJavaScriptReference(HINTS_JS); - } - - @Override - protected CharSequence getOnReadyScript() { - return "$('input:text').hint();"; - } + @Override + protected CharSequence getOnReadyScript() + { + return "$('input:text').hint();"; + } } \ No newline at end of file diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackMessage.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackMessage.java index df325ac31b..c6652a05da 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackMessage.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackMessage.java @@ -5,91 +5,103 @@ import org.wicketstuff.jquery.Options; /** - * A feedback message that will be shown as JGrowl message (http://www.stanlemon.net/projects/jgrowl.html) + * A feedback message that will be shown as JGrowl message + * (http://www.stanlemon.net/projects/jgrowl.html) * * @author martin-g */ -public class JGrowlFeedbackMessage implements IClusterable { +public class JGrowlFeedbackMessage implements IClusterable +{ private static final long serialVersionUID = 1L; private final String message; - + /** - * A list with all supported messages could be found at: (http://www.stanlemon.net/projects/jgrowl.html#options) + * A list with all supported messages could be found at: + * (http://www.stanlemon.net/projects/jgrowl.html#options) */ private final Options options; - - public JGrowlFeedbackMessage(final FeedbackMessage feedbackMessage) { - - this.message = feedbackMessage.getMessage().toString(); - - switch (feedbackMessage.getLevel()) { - case FeedbackMessage.ERROR: - this.options = newErrorOptions(); + + public JGrowlFeedbackMessage(final FeedbackMessage feedbackMessage) + { + + message = feedbackMessage.getMessage().toString(); + + switch (feedbackMessage.getLevel()) + { + case FeedbackMessage.ERROR : + options = newErrorOptions(); break; - case FeedbackMessage.FATAL: + case FeedbackMessage.FATAL : options = newFatalOptions(); - break; - case FeedbackMessage.DEBUG: + break; + case FeedbackMessage.DEBUG : options = newDebugOptions(); break; - case FeedbackMessage.WARNING: + case FeedbackMessage.WARNING : options = newWarningOptions(); - break; - case FeedbackMessage.INFO: + break; + case FeedbackMessage.INFO : options = newInfoOptions(); break; - default: + default : options = new Options(); - } + } } - - protected Options newFatalOptions() { + + protected Options newFatalOptions() + { return new Options(); } - protected Options newDebugOptions() { + protected Options newDebugOptions() + { return new Options(); } - protected Options newWarningOptions() { + protected Options newWarningOptions() + { return new Options(); } - protected Options newInfoOptions() { + protected Options newInfoOptions() + { final Options infoOptions = new Options(); - + return infoOptions; } - protected Options newErrorOptions() { + protected Options newErrorOptions() + { - return new Options(); + return new Options(); } /** - * Constructs the JGrowl invocation - * E.g.: '$.jGrowl("A message", {'option1' : 'value1', 'option2' : 'value2' })' + * Constructs the JGrowl invocation E.g.: '$.jGrowl("A message", {'option1' : 'value1', + * 'option2' : 'value2' })' * * @return the jGrowl JavaScript */ - public String toJavaScript() { - + public String toJavaScript() + { + final StringBuilder javaScript = new StringBuilder(); javaScript.append("$.jGrowl(\""); javaScript.append(message); javaScript.append("\""); - if (options != null) { + if (options != null) + { javaScript.append(", "); javaScript.append(options.toString()); } javaScript.append(");"); - - return javaScript.toString(); + + return javaScript.toString(); } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackPanel.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackPanel.java index b054c0a2f4..4e3d9ae9d4 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackPanel.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/jgrowl/JGrowlFeedbackPanel.java @@ -12,21 +12,23 @@ import org.wicketstuff.jquery.Options; /** - * A feedback panel that shows feedback messages with JGrowl (http://www.stanlemon.net/projects/jgrowl.html) + * A feedback panel that shows feedback messages with JGrowl + * (http://www.stanlemon.net/projects/jgrowl.html) * * @author martin-g */ @SuppressWarnings("serial") -public class JGrowlFeedbackPanel extends FeedbackPanel implements IHeaderContributor { +public class JGrowlFeedbackPanel extends FeedbackPanel implements IHeaderContributor +{ private static final long serialVersionUID = 1L; - + /** * The settings for the different feedback levels * * Full list of supported settings at: http://www.stanlemon.net/projects/jgrowl.html#options */ - + private Options errorOptions; private Options warningOptions; private Options fatalOptions; @@ -50,10 +52,10 @@ public JGrowlFeedbackPanel(final String id) public JGrowlFeedbackPanel(final String id, IFeedbackMessageFilter filter) { super(id, filter); - + // this feedback panel is intended to be used in JavaScript environment (AJAX) setOutputMarkupId(true); - + // needed to not escape apostrophes setEscapeModelStrings(false); } @@ -76,76 +78,90 @@ public JGrowlFeedbackPanel(final String id, IFeedbackMessageFilter filter) @Override protected Component newMessageDisplayComponent(final String id, final FeedbackMessage message) { - final JGrowlFeedbackMessage jgrowlFeedbackMessage = new JGrowlFeedbackMessage(message) { - + final JGrowlFeedbackMessage jgrowlFeedbackMessage = new JGrowlFeedbackMessage(message) + { + @Override - protected Options newFatalOptions() { + protected Options newFatalOptions() + { return fatalOptions; } - + @Override - protected Options newErrorOptions() { + protected Options newErrorOptions() + { return errorOptions; } - + @Override - protected Options newWarningOptions() { + protected Options newWarningOptions() + { return warningOptions; } - + @Override - protected Options newInfoOptions() { + protected Options newInfoOptions() + { return infoOptions; } - + @Override - protected Options newDebugOptions() { + protected Options newDebugOptions() + { return debugOptions; } }; - + final String jgrowlJavaScript = jgrowlFeedbackMessage.toJavaScript(); - + final Label label = new Label(id, jgrowlJavaScript); label.setEscapeModelStrings(JGrowlFeedbackPanel.this.getEscapeModelStrings()); return label; } @Override - public void renderHead(final IHeaderResponse response) { + public void renderHead(final IHeaderResponse response) + { - response.renderCSSReference(new PackageResourceReference(JGrowlFeedbackPanel.class, "res/jquery.jgrowl.css")); + response.renderCSSReference(new PackageResourceReference(JGrowlFeedbackPanel.class, + "res/jquery.jgrowl.css")); response.renderJavaScriptReference(JQueryBehavior.JQUERY_JS); - response.renderJavaScriptReference(new PackageResourceReference(JGrowlFeedbackPanel.class, "res/jquery.jgrowl.js")); + response.renderJavaScriptReference(new PackageResourceReference(JGrowlFeedbackPanel.class, + "res/jquery.jgrowl.js")); } - public JGrowlFeedbackPanel setErrorMessageOptions(final Options errorOptions) { + public JGrowlFeedbackPanel setErrorMessageOptions(final Options errorOptions) + { this.errorOptions = errorOptions; - + return this; } - - public JGrowlFeedbackPanel setFatalMessageOptions(final Options fatalOptions) { + + public JGrowlFeedbackPanel setFatalMessageOptions(final Options fatalOptions) + { this.fatalOptions = fatalOptions; - + return this; } - - public JGrowlFeedbackPanel setWarningMessageOptions(final Options warningOptions) { + + public JGrowlFeedbackPanel setWarningMessageOptions(final Options warningOptions) + { this.warningOptions = warningOptions; - + return this; } - - public JGrowlFeedbackPanel setInfoMessageOptions(final Options infoOptions) { + + public JGrowlFeedbackPanel setInfoMessageOptions(final Options infoOptions) + { this.infoOptions = infoOptions; - + return this; } - - public JGrowlFeedbackPanel setDebugMessageOptions(final Options debugOptions) { + + public JGrowlFeedbackPanel setDebugMessageOptions(final Options debugOptions) + { this.debugOptions = debugOptions; - + return this; } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/JQueryLavaLampBehavior.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/JQueryLavaLampBehavior.java index 312c28f7fe..5cbf6bfa92 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/JQueryLavaLampBehavior.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/JQueryLavaLampBehavior.java @@ -7,26 +7,31 @@ import org.apache.wicket.request.resource.ResourceReference; import org.wicketstuff.jquery.JQueryBehavior; -public class JQueryLavaLampBehavior extends JQueryBehavior { - private static final long serialVersionUID = -428199323406701848L; - - public static final ResourceReference JQUERY_EASING_JS = new PackageResourceReference( - JQueryLavaLampBehavior.class, "jquery.easing.1.1.js"); - public static final ResourceReference JQUERY_LAVALAMP_JS = new PackageResourceReference( - JQueryLavaLampBehavior.class, "jquery.lavalamp.js"); +public class JQueryLavaLampBehavior extends JQueryBehavior +{ + private static final long serialVersionUID = -428199323406701848L; - public JQueryLavaLampBehavior() { - super(); - } + public static final ResourceReference JQUERY_EASING_JS = new PackageResourceReference( + JQueryLavaLampBehavior.class, "jquery.easing.1.1.js"); + public static final ResourceReference JQUERY_LAVALAMP_JS = new PackageResourceReference( + JQueryLavaLampBehavior.class, "jquery.lavalamp.js"); - @Override - public void renderHead(Component component, IHeaderResponse response) { - super.renderHead(component, response); - response.renderJavaScriptReference(JQUERY_EASING_JS); - response.renderJavaScriptReference(JQUERY_LAVALAMP_JS); - } + public JQueryLavaLampBehavior() + { + super(); + } - @Override - protected void respond(AjaxRequestTarget target) {} + @Override + public void renderHead(Component component, IHeaderResponse response) + { + super.renderHead(component, response); + response.renderJavaScriptReference(JQUERY_EASING_JS); + response.renderJavaScriptReference(JQUERY_LAVALAMP_JS); + } + + @Override + protected void respond(AjaxRequestTarget target) + { + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/LavaLampMenuPanel.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/LavaLampMenuPanel.java index becc9c3c52..f64fa27f74 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/LavaLampMenuPanel.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/LavaLampMenuPanel.java @@ -15,50 +15,57 @@ import org.apache.wicket.request.resource.ResourceReference; @SuppressWarnings("serial") -public abstract class LavaLampMenuPanel extends Panel { - private final static String UL_CSS_CLASS = "lavaLamp"; +public abstract class LavaLampMenuPanel extends Panel +{ + private final static String UL_CSS_CLASS = "lavaLamp"; - public LavaLampMenuPanel(String id, final List linksList) { - this(id, new AbstractReadOnlyModel>() { - @Override - public List getObject() { - return linksList; - } - }); - } + public LavaLampMenuPanel(String id, final List linksList) + { + this(id, new AbstractReadOnlyModel>() + { + @Override + public List getObject() + { + return linksList; + } + }); + } - public LavaLampMenuPanel(String id, IModel> linksModel) { - super(id); - // Add JQuery JS libraries - add(new JQueryLavaLampBehavior()); - - final WebMarkupContainer listContainer = new WebMarkupContainer("list"); - listContainer.add(new AttributeAppender("class", true, - new Model(UL_CSS_CLASS), " ")); - final ListView lv = new ListView("lavaLampMenu", linksModel) { - @Override - protected void populateItem(ListItem item) { - item.add(item.getModelObject()); - } - }; - listContainer.add(lv); - add(listContainer); - } + public LavaLampMenuPanel(String id, IModel> linksModel) + { + super(id); + // Add JQuery JS libraries + add(new JQueryLavaLampBehavior()); - @Override - public void renderHead(IHeaderResponse response) { + final WebMarkupContainer listContainer = new WebMarkupContainer("list"); + listContainer.add(new AttributeAppender("class", true, new Model(UL_CSS_CLASS), " ")); + final ListView lv = new ListView("lavaLampMenu", linksModel) + { + @Override + protected void populateItem(ListItem item) + { + item.add(item.getModelObject()); + } + }; + listContainer.add(lv); + add(listContainer); + } + + @Override + public void renderHead(IHeaderResponse response) + { super.renderHead(response); - + response.renderJavaScriptReference(new PackageResourceReference(LavaLampMenuPanel.class, - "headlamp.js")); + "headlamp.js")); response.renderCSSReference(getCssResourceReference()); - } + } /** - * This method should return the reference for the CSS that will be used. - * - * @return ResourceReference - */ - protected abstract ResourceReference getCssResourceReference(); + * This method should return the reference for the CSS that will be used. + * + * @return ResourceReference + */ + protected abstract ResourceReference getCssResourceReference(); } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/MenuItem.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/MenuItem.java index deef2e47de..b78e3cec96 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/MenuItem.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lavalamp/MenuItem.java @@ -4,16 +4,18 @@ import org.apache.wicket.markup.html.link.AbstractLink; import org.apache.wicket.markup.html.panel.Panel; -public class MenuItem extends Panel { - private static final long serialVersionUID = 1628561736142317830L; - public final static String MENU_ITEM_ID = "menuItem"; - public final static String LINK_ID = "link"; - public final static String CAPTION_ID = "caption"; +public class MenuItem extends Panel +{ + private static final long serialVersionUID = 1628561736142317830L; + public final static String MENU_ITEM_ID = "menuItem"; + public final static String LINK_ID = "link"; + public final static String CAPTION_ID = "caption"; + + public MenuItem(AbstractLink link, Label captionLabel) + { + super(MENU_ITEM_ID); + link.add(captionLabel); + add(link); + } - public MenuItem(AbstractLink link, Label captionLabel) { - super(MENU_ITEM_ID); - link.add(captionLabel); - add(link); - } - } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxBehaviour.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxBehaviour.java index 5a482d8b32..f763be6153 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxBehaviour.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxBehaviour.java @@ -7,65 +7,80 @@ import org.wicketstuff.jquery.JQueryBehavior; /** - * - * Adds LightBox hehaviour to the selected component. The default - * is to look for li's with anchors in them and create lightbox from - * the href of the anchors. You can override this by using the + * + * Adds LightBox hehaviour to the selected component. The default is to look for li's with anchors + * in them and create lightbox from the href of the anchors. You can override this by using the * constructor that takes the css selector as an argument - * + * * @author Edvin Syse * @created 2008-06-26 - * + * */ -public class LightboxBehaviour extends JQueryBehavior { - private static final ResourceReference LIGHTBOX_JS = new CompressedResourceReference(LightboxBehaviour.class, "jquery.lightbox-0.5.js"); - private static final ResourceReference LIGHTBOX_CSS = new CompressedResourceReference(LightboxBehaviour.class, "jquery.lightbox-0.5.css"); +public class LightboxBehaviour extends JQueryBehavior +{ + private static final ResourceReference LIGHTBOX_JS = new CompressedResourceReference( + LightboxBehaviour.class, "jquery.lightbox-0.5.js"); + private static final ResourceReference LIGHTBOX_CSS = new CompressedResourceReference( + LightboxBehaviour.class, "jquery.lightbox-0.5.css"); private LightboxOptions options; private String selector = "li a"; - /* Default constructor, selects anchors inside an li as - * default lightbox target. */ - public LightboxBehaviour() { + /* + * Default constructor, selects anchors inside an li as default lightbox target. + */ + public LightboxBehaviour() + { options = new LightboxOptions(); } - /* Constructor that lets you override the css selector so you - * can choose what to convert to a lightbox. - */ - public LightboxBehaviour(String selector) { + /* + * Constructor that lets you override the css selector so you can choose what to convert to a + * lightbox. + */ + public LightboxBehaviour(String selector) + { this(); this.selector = selector; } - public LightboxOptions getOptions() { - return this.options; + public LightboxOptions getOptions() + { + return options; } - - @Override protected CharSequence getOnReadyScript() { - return "\t$('#" + getComponent().getMarkupId() + getSelector() + "').lightBox(" + options.toString(false) + ");"; + + @Override + protected CharSequence getOnReadyScript() + { + return "\t$('#" + getComponent().getMarkupId() + getSelector() + "').lightBox(" + + options.toString(false) + ");"; } - public String getSelector() { + public String getSelector() + { return " " + selector; } @Override - public void renderHead(Component component, IHeaderResponse response) { + public void renderHead(Component component, IHeaderResponse response) + { super.renderHead(component, response); response.renderJavaScriptReference(getLightboxJs()); response.renderCSSReference(getLightboxCss()); } @Override - protected void onBind() { + protected void onBind() + { getComponent().setOutputMarkupId(true); } - private ResourceReference getLightboxJs() { + private ResourceReference getLightboxJs() + { return LIGHTBOX_JS; } - public ResourceReference getLightboxCss() { + public ResourceReference getLightboxCss() + { return LIGHTBOX_CSS; } } \ No newline at end of file diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxOptions.java index 7a8b5e65f6..6e5a88e9b8 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/lightbox/LightboxOptions.java @@ -2,9 +2,11 @@ import org.wicketstuff.jquery.Options; -public class LightboxOptions extends Options { +public class LightboxOptions extends Options +{ - public LightboxOptions() { + public LightboxOptions() + { fixedNavigation(true); imageLoading("/resources/org.wicketstuff.jquery.lightbox.LightboxBehaviour/lightbox-ico-loading.gif"); imageBtnClose("/resources/org.wicketstuff.jquery.lightbox.LightboxBehaviour/lightbox-btn-close.gif"); @@ -13,32 +15,38 @@ public LightboxOptions() { imageBlank("/resources/org.wicketstuff.jquery.lightbox.LightboxBehaviour/lightbox-blank.gif"); } - public LightboxOptions fixedNavigation(boolean fixedNavigation) { + public LightboxOptions fixedNavigation(boolean fixedNavigation) + { set("fixedNaviation", fixedNavigation); return this; } - public LightboxOptions imageLoading(String imageLoading) { + public LightboxOptions imageLoading(String imageLoading) + { set("imageLoading", imageLoading); return this; } - public LightboxOptions imageBlank(String imageBlank) { + public LightboxOptions imageBlank(String imageBlank) + { set("imageBlank", imageBlank); return this; } - public LightboxOptions imageBtnClose(String imageBtnClose) { + public LightboxOptions imageBtnClose(String imageBtnClose) + { set("imageBtnClose", imageBtnClose); return this; } - public LightboxOptions imageBtnPrev(String imageBtnPrev) { + public LightboxOptions imageBtnPrev(String imageBtnPrev) + { set("imageBtnPrev", imageBtnPrev); return this; } - public LightboxOptions imageBtnNext(String imageBtnNext) { + public LightboxOptions imageBtnNext(String imageBtnNext) + { set("imageBtnNext", imageBtnNext); return this; } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeBehaviour.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeBehaviour.java index 0a729ee443..f3dc67f74d 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeBehaviour.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeBehaviour.java @@ -7,56 +7,66 @@ import org.apache.wicket.request.cycle.RequestCycle; import org.wicketstuff.jquery.FunctionString; import org.wicketstuff.jquery.JQueryBehavior; + /** * * @author Edvin Syse - * + * */ -public class ResizeBehaviour extends JQueryBehavior { - private ResizeOptions options; - - public ResizeBehaviour() { - this(new ResizeOptions()); +public class ResizeBehaviour extends JQueryBehavior +{ + private ResizeOptions options; + + public ResizeBehaviour() + { + this(new ResizeOptions()); + } + + public ResizeBehaviour(ResizeOptions options) + { + super(); + this.options = options != null ? options : new ResizeOptions(); + } + + @Override + protected CharSequence getOnReadyScript() + { + StringBuilder onReady = new StringBuilder("$('#" + getComponent().getMarkupId() + + "').resizable("); + + // Add callback method to options + options.set("stop", new FunctionString("function() {\n " + getCallbackScript() + "}\n")); + + onReady.append(options.toString(false)); + onReady.append(");"); + + return onReady; + } + + @Override + protected CharSequence getCallbackScript() + { + String mid = getComponent().getMarkupId(); + return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() + "&height=' + $('#" + + mid + "').height() + '" + "&width=' + $('#" + mid + "').width()"); } - - public ResizeBehaviour(ResizeOptions options) { - super(); - this.options = options != null ? options : new ResizeOptions(); - } - - @Override protected CharSequence getOnReadyScript() { - StringBuilder onReady = new StringBuilder("$('#" + getComponent().getMarkupId() + "').resizable("); - - // Add callback method to options - options.set("stop", new FunctionString("function() {\n " + getCallbackScript() + "}\n")); - - onReady.append(options.toString(false)); - onReady.append(");"); - - return onReady; - } - - @Override - protected CharSequence getCallbackScript() { - String mid = getComponent().getMarkupId(); - return generateCallbackScript("wicketAjaxGet('" + getCallbackUrl() + - "&height=' + $('#" + mid + "').height() + '" + - "&width=' + $('#" + mid + "').width()"); + + @Override + public void renderHead(Component component, IHeaderResponse response) + { + super.renderHead(component, response); + response.renderJavaScriptReference(JQueryBehavior.JQUERY_UI_JS); + } + + @Override + protected void respond(AjaxRequestTarget target) + { + Request req = RequestCycle.get().getRequest(); + onResizeStop(target, req.getQueryParameters().getParameterValue("height").toInt(), + req.getQueryParameters().getParameterValue("width").toInt()); } - @Override - public void renderHead(Component component, IHeaderResponse response) { - super.renderHead(component, response); - response.renderJavaScriptReference(JQueryBehavior.JQUERY_UI_JS); - } - - @Override protected void respond(AjaxRequestTarget target) { - Request req = RequestCycle.get().getRequest(); - onResizeStop(target, - req.getQueryParameters().getParameterValue("height").toInt(), - req.getQueryParameters().getParameterValue("width").toInt()); - } - - public void onResizeStop(AjaxRequestTarget target, int height, int width) { - } + public void onResizeStop(AjaxRequestTarget target, int height, int width) + { + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeOptions.java index 8470472c08..e0abaa887c 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/resize/ResizeOptions.java @@ -5,12 +5,14 @@ /** * * @author Edvin Syse - * + * */ -public class ResizeOptions extends Options { +public class ResizeOptions extends Options +{ public static final String ASPECTRATIO_PRESERVE = "preserve"; - - public ResizeOptions aspectRatio(String r) { + + public ResizeOptions aspectRatio(String r) + { set("aspectRatio", r); return this; } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/Sparkline.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/Sparkline.java index a4558a921d..b26af8d111 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/Sparkline.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/Sparkline.java @@ -31,125 +31,130 @@ public class Sparkline extends WebComponent implements IHeaderContributor { - public static final CompressedResourceReference SPARKLINE_JS - = new CompressedResourceReference(Sparkline.class, "jquery.sparkline-1.4.3.min.js"); - - final SparklineOptions options; - final IModel> model; - final CharSequence values; - boolean writeJSOnReady = true; - - public Sparkline(final String id, - IModel> values, - SparklineOptions options ) + public static final CompressedResourceReference SPARKLINE_JS = new CompressedResourceReference( + Sparkline.class, "jquery.sparkline-1.4.3.min.js"); + + final SparklineOptions options; + final IModel> model; + final CharSequence values; + boolean writeJSOnReady = true; + + public Sparkline(final String id, IModel> values, SparklineOptions options) { super(id); - this.setOutputMarkupId(true); - this.model = values; + setOutputMarkupId(true); + model = values; this.values = null; this.options = options; } - public Sparkline(final String id, - Collection values, - SparklineOptions options ) - { - super(id); - this.setOutputMarkupId(true); - this.model = null; - this.values = values.toString(); - this.options = options; - } - - public Sparkline(final String id, - SparklineOptions options, - int ... values ) - { - super(id); - this.setOutputMarkupId(true); - this.model = null; - this.options = options; - - StringBuilder v = new StringBuilder(); - v.append( '[' ); - for( int i=0; i 0 ) { - v.append(','); - } - v.append( values[i] ); - } - v.append( ']' ); - this.values = v; - } - - public Sparkline(final String id, - int ... values ) - { - this(id, null, values ); - } - - //--------------------------------------------------------------- - //--------------------------------------------------------------- - - public boolean isWriteJSOnReady() { - return writeJSOnReady; - } - - public Sparkline setWriteJSOnReady(boolean writeJSOnReady) { - this.writeJSOnReady = writeJSOnReady; - return this; - } - - public CharSequence getSparklineJS() { - StringBuilder js = new StringBuilder(); - js.append( "$('#" ).append( this.getMarkupId() ).append( "' ).sparkline( " ); - if( model != null ) { - Collection vals = model.getObject(); - js.append( '[' ); - Iterator iter = vals.iterator(); - while( iter.hasNext() ) { - js.append( iter.next() ); - if( iter.hasNext() ) { - js.append( ',' ); - } - } - js.append( ']' ); - } - else { - js.append( values ); - } - if( options != null ) { - js.append( ", " ).append( options.toString(false) ); - } - js.append( " );" ); - return js; - } - - @Override -public void renderHead(IHeaderResponse response) { - response.renderJavaScriptReference(JQueryBehavior.JQUERY_JS); - response.renderJavaScriptReference(SPARKLINE_JS); - - if( writeJSOnReady ) { - StringBuilder builder = new StringBuilder(); - builder.append("$(document).ready(function(){\n"); - builder.append(getSparklineJS()); - builder.append("\n});"); - response.renderJavaScript(builder, null ); - } - } - - @Override - public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) - { - replaceComponentTagBody(markupStream, openTag, "sparkline" ); - } - - @Override - protected void onComponentTag(ComponentTag tag) - { - super.onComponentTag(tag); - // always transform the tag to so even labels defined as render - tag.setType(XmlTag.TagType.OPEN); - } + public Sparkline(final String id, Collection values, SparklineOptions options) + { + super(id); + setOutputMarkupId(true); + model = null; + this.values = values.toString(); + this.options = options; + } + + public Sparkline(final String id, SparklineOptions options, int... values) + { + super(id); + setOutputMarkupId(true); + model = null; + this.options = options; + + StringBuilder v = new StringBuilder(); + v.append('['); + for (int i = 0; i < values.length; i++) + { + if (i > 0) + { + v.append(','); + } + v.append(values[i]); + } + v.append(']'); + this.values = v; + } + + public Sparkline(final String id, int... values) + { + this(id, null, values); + } + + // --------------------------------------------------------------- + // --------------------------------------------------------------- + + public boolean isWriteJSOnReady() + { + return writeJSOnReady; + } + + public Sparkline setWriteJSOnReady(boolean writeJSOnReady) + { + this.writeJSOnReady = writeJSOnReady; + return this; + } + + public CharSequence getSparklineJS() + { + StringBuilder js = new StringBuilder(); + js.append("$('#").append(this.getMarkupId()).append("' ).sparkline( "); + if (model != null) + { + Collection vals = model.getObject(); + js.append('['); + Iterator iter = vals.iterator(); + while (iter.hasNext()) + { + js.append(iter.next()); + if (iter.hasNext()) + { + js.append(','); + } + } + js.append(']'); + } + else + { + js.append(values); + } + if (options != null) + { + js.append(", ").append(options.toString(false)); + } + js.append(" );"); + return js; + } + + @Override + public void renderHead(IHeaderResponse response) + { + response.renderJavaScriptReference(JQueryBehavior.JQUERY_JS); + response.renderJavaScriptReference(SPARKLINE_JS); + + if (writeJSOnReady) + { + StringBuilder builder = new StringBuilder(); + builder.append("$(document).ready(function(){\n"); + builder.append(getSparklineJS()); + builder.append("\n});"); + response.renderJavaScript(builder, null); + } + } + + @Override + public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) + { + replaceComponentTagBody(markupStream, openTag, "sparkline"); + } + + @Override + protected void onComponentTag(ComponentTag tag) + { + super.onComponentTag(tag); + // always transform the tag to so even labels defined as render + tag.setType(XmlTag.TagType.OPEN); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineOptions.java index 19694a19bd..e90434156d 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineOptions.java @@ -3,60 +3,63 @@ import org.wicketstuff.jquery.Options; -public class SparklineOptions extends Options +public class SparklineOptions extends Options { - public enum TYPE { - line, - bar, - tristate, - discrete, - bullet, - pie, - box - }; - - public SparklineOptions() - { - super(); - } - - public SparklineOptions( TYPE type ) - { - super(); - set("type", type.name() ); - } - - public SparklineOptions setType(TYPE type) { - set("type", type.name() ); + public enum TYPE + { + line, bar, tristate, discrete, bullet, pie, box + }; + + public SparklineOptions() + { + super(); + } + + public SparklineOptions(TYPE type) + { + super(); + set("type", type.name()); + } + + public SparklineOptions setType(TYPE type) + { + set("type", type.name()); + return this; + } + + public SparklineOptions setWidth(String w) + { + set("width", w); + return this; + } + + public SparklineOptions setHeight(String h) + { + set("height", h); return this; } - public SparklineOptions setWidth(String w) { - set("width", w); - return this; - } - - public SparklineOptions setHeight(String h) { - set("height", h); - return this; - } - - public SparklineOptions setLineColor(String v) { - set("lineColor", v); - return this; - } - - public SparklineOptions setFillColor(String v) { - set("fillColor", v); - return this; - } - - public SparklineOptions setChartRangeMin(int v) { - set("chartRangeMin", v); - return this; - } - public SparklineOptions setChartRangeMax(int v) { - set("chartRangeMax", v); - return this; - } + public SparklineOptions setLineColor(String v) + { + set("lineColor", v); + return this; + } + + public SparklineOptions setFillColor(String v) + { + set("fillColor", v); + return this; + } + + public SparklineOptions setChartRangeMin(int v) + { + set("chartRangeMin", v); + return this; + } + + public SparklineOptions setChartRangeMax(int v) + { + set("chartRangeMax", v); + return this; + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineWrapper.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineWrapper.java index 75c0ce3e28..49a75072fd 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineWrapper.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/sparkline/SparklineWrapper.java @@ -7,28 +7,26 @@ public class SparklineWrapper extends Panel { - public static final String SPARKID = "sparkline"; - - /** - * Construct. - * - * @param id - */ - public SparklineWrapper(String id, final Sparkline line) - { - super(id); - line.setWriteJSOnReady(false); - - this.add( line ); - this.add( new Label( "js", new AbstractReadOnlyModel() { - @Override - public CharSequence getObject() { - return line.getSparklineJS(); - } - }).setEscapeModelStrings(false)); - } + public static final String SPARKID = "sparkline"; + + /** + * Construct. + * + * @param id + */ + public SparklineWrapper(String id, final Sparkline line) + { + super(id); + line.setWriteJSOnReady(false); + + this.add(line); + this.add(new Label("js", new AbstractReadOnlyModel() + { + @Override + public CharSequence getObject() + { + return line.getSparklineJS(); + } + }).setEscapeModelStrings(false)); + } } - - - - diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/tabs/JQTabbedPanel.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/tabs/JQTabbedPanel.java index d8305fa837..0a9dfd4298 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/tabs/JQTabbedPanel.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/tabs/JQTabbedPanel.java @@ -35,12 +35,12 @@ /** * JQuery based implementation of client side tabbed panel. *

          - * This component JQuery and the plugin tabs to create client side - * tabs. Being client side, all tabs will be rendered and sent to the client - * at first time, which can be useful in forms, for instance. + * This component JQuery and the plugin tabs to create client side tabs. Being client side, all tabs + * will be rendered and sent to the client at first time, which can be useful in forms, for + * instance. *

          - * The API of this component is the same as {@link TabbedPanel}, and - * can thus be used as a drop in replacement of {@link TabbedPanel}. + * The API of this component is the same as {@link TabbedPanel}, and can thus be used as a drop in + * replacement of {@link TabbedPanel}. *

          * * JQuery: http://jquery.com/
          @@ -50,7 +50,8 @@ * @author Xavier Hanin * @see TabbedPanel */ -public class JQTabbedPanel extends Panel { +public class JQTabbedPanel extends Panel +{ private static final long serialVersionUID = 1L; /** * id used for child panels @@ -59,8 +60,7 @@ public class JQTabbedPanel extends Panel { private String options; /** - * Constructs a JQTabbedPanel with the given id and - * list of tabs. + * Constructs a JQTabbedPanel with the given id and list of tabs. *

          * This constructor can be used as a drop in replacement of * new TabbedPanel(id, tabs) @@ -68,71 +68,79 @@ public class JQTabbedPanel extends Panel { * @param id * component id. Must not be null * @param tabs - * list of ITab objects used to represent tabs. - * Must not be null. + * list of ITab objects used to represent tabs. Must not be null. */ - public JQTabbedPanel(String id, List tabs) { + public JQTabbedPanel(String id, List tabs) + { this(id, tabs, ""); } + /** - * Constructs a JQTabbedPanel with the given id, - * list of tabs and options. + * Constructs a JQTabbedPanel with the given id, list of tabs and options. *

          * The options are used when initializing the tabs. *

          - * See tabs documentation - * for details on the available options. + * See tabs documentation for details on the + * available options. *

          * Some examples:
          * { fxSlide: true }
          * { fxFade: true, fxSpeed: 'fast' }
          * - * @param id the id of this component. Must not be null. - * @param tabs the list of tabs to use in this component. Must not be null. - * @param options the options to use to init the tabs component. May be null. + * @param id + * the id of this component. Must not be null. + * @param tabs + * the list of tabs to use in this component. Must not be null. + * @param options + * the options to use to init the tabs component. May be null. */ - public JQTabbedPanel(String id, List tabs, String options) { + public JQTabbedPanel(String id, List tabs, String options) + { super(id); - this.options = options==null?"":options; - + this.options = options == null ? "" : options; + add(new JQueryBehavior()); final WebMarkupContainer parent = new WebMarkupContainer("tabs"); parent.setOutputMarkupId(true); add(parent); - - /* - * we inject the script in the component body and not as a header contribution - * because the script needs to be called each time the component is refreshed using wicket - * ajax support. + + /* + * we inject the script in the component body and not as a header contribution because the + * script needs to be called each time the component is refreshed using wicket ajax support. */ - add(new Label("script", new Model(){ + add(new Label("script", new Model() + { private static final long serialVersionUID = 1L; @Override - public String getObject() { - return "$('#"+parent.getMarkupId()+"').tabs("+getTabsOptions()+");"; + public String getObject() + { + return "$('#" + parent.getMarkupId() + "').tabs(" + getTabsOptions() + ");"; } }).setEscapeModelStrings(false)); - + RepeatingView titles = new RepeatingView("tab"); parent.add(titles); RepeatingView contents = new RepeatingView("content"); parent.add(contents); - - - for (int i=0; i - * See tabs documentation - * for details on the available options. + * See tabs documentation for details on the + * available options. *

          - * Some examples: - * { fxSlide: true } - * { fxFade: true, fxSpeed: 'fast' } + * Some examples: { fxSlide: true } { fxFade: true, fxSpeed: 'fast' } * * @return the options to use to init the tabs */ - protected String getTabsOptions() { + protected String getTabsOptions() + { return options; } @Override - public void renderHead(IHeaderResponse response) { + public void renderHead(IHeaderResponse response) + { super.renderHead(response); - - response.renderCSSReference(new PackageResourceReference(JQTabbedPanel.class, "jquery.tabs.css")); - response.renderJavaScriptReference(new PackageResourceReference(JQTabbedPanel.class, "jquery.tabs.pack.js")); - + + response.renderCSSReference(new PackageResourceReference(JQTabbedPanel.class, + "jquery.tabs.css")); + response.renderJavaScriptReference(new PackageResourceReference(JQTabbedPanel.class, + "jquery.tabs.pack.js")); + } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/UIResources.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/UIResources.java index 73dddd827e..af970e8657 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/UIResources.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/UIResources.java @@ -3,9 +3,12 @@ import org.apache.wicket.request.resource.PackageResourceReference; import org.apache.wicket.request.resource.ResourceReference; -public abstract class UIResources { +public abstract class UIResources +{ - public static final ResourceReference FLORA_CSS = new PackageResourceReference(UIResources.class, "flora.css"); - - public static final ResourceReference FLORA_SLIDER_CSS = new PackageResourceReference(UIResources.class, "slider/flora.slider.css"); + public static final ResourceReference FLORA_CSS = new PackageResourceReference( + UIResources.class, "flora.css"); + + public static final ResourceReference FLORA_SLIDER_CSS = new PackageResourceReference( + UIResources.class, "slider/flora.slider.css"); } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/Slider.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/Slider.java index b353bdd6a8..99242c89e5 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/Slider.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/Slider.java @@ -5,19 +5,20 @@ import org.apache.wicket.markup.repeater.RepeatingView; /** - * An integration of JQuery UI Slider widget - * (http://docs.jquery.com/UI/Slider/slider) + * An integration of JQuery UI Slider widget (http://docs.jquery.com/UI/Slider/slider) * * @author Martin Grigorov */ -public abstract class Slider extends Panel { +public abstract class Slider extends Panel +{ private static final long serialVersionUID = 1L; private final SliderOptions sliderOptions; public Slider(final String wid, final SliderOptions sliderOptions, - final SliderHandleOptions... sliderHandlesOptions) { + final SliderHandleOptions... sliderHandlesOptions) + { super(wid); setOutputMarkupId(true); @@ -30,18 +31,22 @@ public Slider(final String wid, final SliderOptions sliderOptions, sliderHandles.setRenderBodyOnly(true); add(sliderHandles); - if (sliderHandlesOptions != null && sliderHandlesOptions.length > 0) { + if (sliderHandlesOptions != null && sliderHandlesOptions.length > 0) + { - for (int i = 0; i < sliderHandlesOptions.length; i++) { + for (int i = 0; i < sliderHandlesOptions.length; i++) + { final SliderHandleOptions sliderHandleSettings = sliderHandlesOptions[i]; - final SliderHandle sliderHandle = new SliderHandle( - sliderHandles.newChildId(), sliderHandleSettings); + final SliderHandle sliderHandle = new SliderHandle(sliderHandles.newChildId(), + sliderHandleSettings); sliderHandles.add(sliderHandle); } - } else { + } + else + { final SliderHandle sliderHandle = new SliderHandle("handle"); sliderHandles.add(sliderHandle); } @@ -49,13 +54,13 @@ public Slider(final String wid, final SliderOptions sliderOptions, add(new SliderBehavior()); } - public SliderOptions getOptions() { + public SliderOptions getOptions() + { return sliderOptions != null ? sliderOptions : new SliderOptions(); } /** - * A callback method which will be called when any of the handles change its - * value + * A callback method which will be called when any of the handles change its value * * @param target * the current request target @@ -64,7 +69,7 @@ public SliderOptions getOptions() { * @param newValue * the value of this handle */ - public abstract void onChange(final AjaxRequestTarget target, - final String handleId, final int newValue); + public abstract void onChange(final AjaxRequestTarget target, final String handleId, + final int newValue); } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderBehavior.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderBehavior.java index 958ce79be6..192b240d4b 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderBehavior.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderBehavior.java @@ -11,38 +11,41 @@ import org.wicketstuff.jquery.ui.UIResources; /** - * An integration of JQuery UI Slider widget - * (http://docs.jquery.com/UI/Slider/slider) + * An integration of JQuery UI Slider widget (http://docs.jquery.com/UI/Slider/slider) * * @author Martin Grigorov */ -public class SliderBehavior extends JQueryBehavior { +public class SliderBehavior extends JQueryBehavior +{ private static final long serialVersionUID = 1L; private static final ResourceReference UI_SLIDER_RESOURCE_REFERENCE = new CompressedResourceReference( - SliderBehavior.class, "ui.slider.js"); + SliderBehavior.class, "ui.slider.js"); public static final ResourceReference WICKET_SLIDER_JS = new CompressedResourceReference( - SliderBehavior.class, "wicket-jquery.slider.js"); + SliderBehavior.class, "wicket-jquery.slider.js"); - public SliderBehavior() { + public SliderBehavior() + { } @Override - protected CharSequence getOnReadyScript() { + protected CharSequence getOnReadyScript() + { final SliderOptions sliderOptions = getSlider().getOptions(); - if (sliderOptions.getOnChange() == null) { + if (sliderOptions.getOnChange() == null) + { final String body = getCallbackScript(); sliderOptions.setOnChange(body, "e", "ui"); } - final StringBuilder onReady = new StringBuilder("$('#" - + getSlider().getMarkupId() + "').slider("); + final StringBuilder onReady = new StringBuilder("$('#" + getSlider().getMarkupId() + + "').slider("); onReady.append(sliderOptions.toJSON()); onReady.append(");\n"); @@ -50,16 +53,16 @@ protected CharSequence getOnReadyScript() { } @Override - protected String getCallbackScript() { + protected String getCallbackScript() + { return generateCallbackScript( - "wicketAjaxGet('" - + getCallbackUrl() - + "&handleId=' + getHandleId(e, ui) + '&value=' + getValue(e, ui)") - .toString(); + "wicketAjaxGet('" + getCallbackUrl() + + "&handleId=' + getHandleId(e, ui) + '&value=' + getValue(e, ui)").toString(); } @Override - public void renderHead(Component component, IHeaderResponse response) { + public void renderHead(Component component, IHeaderResponse response) + { super.renderHead(component, response); response.renderCSSReference(UIResources.FLORA_CSS); response.renderCSSReference(UIResources.FLORA_SLIDER_CSS); @@ -69,15 +72,17 @@ public void renderHead(Component component, IHeaderResponse response) { } @Override - protected void respond(AjaxRequestTarget target) { + protected void respond(AjaxRequestTarget target) + { final Request req = RequestCycle.get().getRequest(); final String handleId = req.getQueryParameters().getParameterValue("handleId").toString(); final int newValue = req.getQueryParameters().getParameterValue("value").toInt(-1); getSlider().onChange(target, handleId, newValue); } - public Slider getSlider() { - return (Slider) getComponent(); + public Slider getSlider() + { + return (Slider)getComponent(); } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandle.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandle.java index 88ec1d6a4e..0b3d66868c 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandle.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandle.java @@ -6,21 +6,22 @@ import org.apache.wicket.model.Model; /** - * An integration of JQuery UI Slider widget - * (http://docs.jquery.com/UI/Slider/slider) + * An integration of JQuery UI Slider widget (http://docs.jquery.com/UI/Slider/slider) * * @author Martin Grigorov */ -public class SliderHandle extends Panel { +public class SliderHandle extends Panel +{ private static final long serialVersionUID = 1L; - public SliderHandle(final String wid) { + public SliderHandle(final String wid) + { this(wid, null); } - public SliderHandle(final String wid, - final SliderHandleOptions handleSettings) { + public SliderHandle(final String wid, final SliderHandleOptions handleSettings) + { super(wid); setRenderBodyOnly(true); @@ -30,10 +31,12 @@ public SliderHandle(final String wid, handle.setMarkupId(handleSettings.getId()); add(handle); - if (handleSettings != null) { - if (handleSettings.getStyle() != null) { - handle.add(new AttributeAppender("style", true, - new Model(handleSettings.getStyle()), " ")); + if (handleSettings != null) + { + if (handleSettings.getStyle() != null) + { + handle.add(new AttributeAppender("style", true, new Model( + handleSettings.getStyle()), " ")); } } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandleOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandleOptions.java index bc9b781ea8..746da6ca23 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandleOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderHandleOptions.java @@ -5,12 +5,12 @@ import org.apache.wicket.IClusterable; /** - * An integration of JQuery UI Slider widget - * (http://docs.jquery.com/UI/Slider/slider) + * An integration of JQuery UI Slider widget (http://docs.jquery.com/UI/Slider/slider) * * @author Martin Grigorov */ -public class SliderHandleOptions implements IClusterable { +public class SliderHandleOptions implements IClusterable +{ private static final long serialVersionUID = 1L; @@ -26,58 +26,70 @@ public class SliderHandleOptions implements IClusterable { private transient final JSONObject json; - public SliderHandleOptions(final String id, final Integer start) { - this.json = new JSONObject(); + public SliderHandleOptions(final String id, final Integer start) + { + json = new JSONObject(); setId(id); setStart(start); } - public void setStyle(final String style) { - this.cssStyle = style; + public void setStyle(final String style) + { + cssStyle = style; } - public String getStyle() { - return this.cssStyle; + public String getStyle() + { + return cssStyle; } - public SliderHandleOptions setId(final String id) { + public SliderHandleOptions setId(final String id) + { json.put(ID, id); return this; } - public String getId() { - return (String) json.get(ID); + public String getId() + { + return (String)json.get(ID); } - public SliderHandleOptions setStart(final Integer start) { + public SliderHandleOptions setStart(final Integer start) + { json.put(START, start); return this; } - public Integer getStart() { - return (Integer) json.get(START); + public Integer getStart() + { + return (Integer)json.get(START); } - public SliderHandleOptions setMin(final Integer min) { + public SliderHandleOptions setMin(final Integer min) + { json.put(MIN, min); return this; } - public Integer getMin() { - return (Integer) json.get(MIN); + public Integer getMin() + { + return (Integer)json.get(MIN); } - public SliderHandleOptions setMax(final Integer max) { + public SliderHandleOptions setMax(final Integer max) + { json.put(MAX, max); return this; } - public Integer getMax() { - return (Integer) json.get(MAX); + public Integer getMax() + { + return (Integer)json.get(MAX); } - public JSONObject getJSON() { + public JSONObject getJSON() + { return json; } } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderOptions.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderOptions.java index 09e61cc337..0839b5b7fa 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderOptions.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/ui/slider/SliderOptions.java @@ -7,15 +7,14 @@ import org.apache.wicket.IClusterable; /** - * An integration of JQuery UI Slider widget - * (http://docs.jquery.com/UI/Slider/slider) + * An integration of JQuery UI Slider widget (http://docs.jquery.com/UI/Slider/slider) * - * A Java representation of Slider's options - * (http://docs.jquery.com/UI/Slider/slider#options) + * A Java representation of Slider's options (http://docs.jquery.com/UI/Slider/slider#options) * * @author Martin Grigorov */ -public class SliderOptions implements IClusterable { +public class SliderOptions implements IClusterable +{ private static final long serialVersionUID = 1L; @@ -41,91 +40,105 @@ public class SliderOptions implements IClusterable { private transient final JSONObject json; - public SliderOptions() { - this.json = new JSONObject(); + public SliderOptions() + { + json = new JSONObject(); } - public SliderOptions setStepping(final Integer stepping) { + public SliderOptions setStepping(final Integer stepping) + { json.put(STEPPING, stepping); return this; } - public Integer getStepping() { - return (Integer) json.get(STEPPING); + public Integer getStepping() + { + return (Integer)json.get(STEPPING); } - public SliderOptions setMin(final Integer min) { + public SliderOptions setMin(final Integer min) + { json.put(MIN, min); return this; } - public Integer getMin() { - return (Integer) json.get(MIN); + public Integer getMin() + { + return (Integer)json.get(MIN); } - public SliderOptions setMax(final Integer max) { + public SliderOptions setMax(final Integer max) + { json.put(MAX, max); return this; } - public Integer getMax() { - return (Integer) json.get(MAX); + public Integer getMax() + { + return (Integer)json.get(MAX); } - public SliderOptions setRange(final Boolean range) { + public SliderOptions setRange(final Boolean range) + { json.put(RANGE, range); return this; } - public Boolean getRange() { - return (Boolean) json.get(RANGE); + public Boolean getRange() + { + return (Boolean)json.get(RANGE); } - public SliderOptions setAnimate(final Boolean animate) { + public SliderOptions setAnimate(final Boolean animate) + { json.put(ANIMATE, animate); return this; } - public Boolean getAnimate() { - return (Boolean) json.get(ANIMATE); + public Boolean getAnimate() + { + return (Boolean)json.get(ANIMATE); } - public SliderOptions setOnChange(final String body, - final String... parametersNames) { + public SliderOptions setOnChange(final String body, final String... parametersNames) + { putFunction(CHANGE, body, parametersNames); return this; } - public SliderOptions setOnStart(final String body, - final String... parametersNames) { + public SliderOptions setOnStart(final String body, final String... parametersNames) + { putFunction(START, body, parametersNames); return this; } - public SliderOptions setOnStop(final String body, - final String... parametersNames) { + public SliderOptions setOnStop(final String body, final String... parametersNames) + { putFunction(STOP, body, parametersNames); return this; } - public SliderOptions setOnSlide(final String body, - final String... parametersNames) { + public SliderOptions setOnSlide(final String body, final String... parametersNames) + { putFunction(SLIDE, body, parametersNames); return this; } - public JSONFunction getOnChange() { + public JSONFunction getOnChange() + { - return (JSONFunction) json.get(CHANGE); + return (JSONFunction)json.get(CHANGE); } - public SliderOptions setHandles( - final SliderHandleOptions... handlesSettings) { + public SliderOptions setHandles(final SliderHandleOptions... handlesSettings) + { - if (handlesSettings != null && handlesSettings.length > 0) { + if (handlesSettings != null && handlesSettings.length > 0) + { final JSONArray handlesArray = new JSONArray(); - for (final SliderHandleOptions sliderHandleSettings : handlesSettings) { + for (final SliderHandleOptions sliderHandleSettings : handlesSettings) + { handlesArray.add(sliderHandleSettings.getJSON()); } @@ -135,18 +148,22 @@ public SliderOptions setHandles( return this; } - public String toJSON() { + public String toJSON() + { return json.toString(); } - private void putFunction(final String keyName, final String body, - final String[] parametersNames) { + private void putFunction(final String keyName, final String body, final String[] parametersNames) + { final JSONFunction function; - if (parametersNames != null && parametersNames.length > 0) { + if (parametersNames != null && parametersNames.length > 0) + { function = new JSONFunction(parametersNames, body); - } else { + } + else + { function = new JSONFunction(body); } diff --git a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/validation/AjaxFormComponentValidatorBehaviour.java b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/validation/AjaxFormComponentValidatorBehaviour.java index 0255e2ca89..f670a5694e 100644 --- a/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/validation/AjaxFormComponentValidatorBehaviour.java +++ b/jdk-1.5-parent/jquery-parent/jquery/src/main/java/org/wicketstuff/jquery/validation/AjaxFormComponentValidatorBehaviour.java @@ -12,49 +12,52 @@ import org.wicketstuff.jquery.JQueryBehavior; /** - * - * Ajax validation behaviour that triggers when the selected event - * is fired. The default action is to add a css class to the parent - * element of the component and add any error messages in a span - * directly after the component. You can change this behaviour - * by overriding getErrorJavascript(). - * - * By default it uses JQuery to do the markup manipulation. You can - * either skip jquery or load another library by overriding the - * renderHead method. - * - * This behaviour will also update the model object when the selected - * client side event fires. - * + * + * Ajax validation behaviour that triggers when the selected event is fired. The default action is + * to add a css class to the parent element of the component and add any error messages in a span + * directly after the component. You can change this behaviour by overriding getErrorJavascript(). + * + * By default it uses JQuery to do the markup manipulation. You can either skip jquery or load + * another library by overriding the renderHead method. + * + * This behaviour will also update the model object when the selected client side event fires. + * * @author Edvin Syse * @created 2008-06-01 - * + * */ -public class AjaxFormComponentValidatorBehaviour extends AjaxFormComponentUpdatingBehavior { +public class AjaxFormComponentValidatorBehaviour extends AjaxFormComponentUpdatingBehavior +{ public static final String ERROR_COMPONENT_CLASS = "error"; public static final String ERROR_MESSAGE_CLASS = "error"; private boolean errorDetected; /* Default constructor, attaches to the onblur clientside event */ - public AjaxFormComponentValidatorBehaviour() { + public AjaxFormComponentValidatorBehaviour() + { this("onblur"); } - public AjaxFormComponentValidatorBehaviour(String event) { + public AjaxFormComponentValidatorBehaviour(String event) + { super(event); errorDetected = false; } /** - * When the component renders, onUpdate will remove the - * markup containing any previous error-message. + * When the component renders, onUpdate will remove the markup containing any previous + * error-message. + * * @param target */ @Override - protected void onUpdate(AjaxRequestTarget target) { - if(errorDetected) { + protected void onUpdate(AjaxRequestTarget target) + { + if (errorDetected) + { // Remove the error-class on the surrounding element - target.appendJavaScript("$('#" + getComponent().getMarkupId() + "').removeClass('" + ERROR_COMPONENT_CLASS + "');"); + target.appendJavaScript("$('#" + getComponent().getMarkupId() + "').removeClass('" + + ERROR_COMPONENT_CLASS + "');"); // Remove the previously added error-messages target.appendJavaScript(getRemovePreviousErrorsScript()); @@ -63,79 +66,92 @@ protected void onUpdate(AjaxRequestTarget target) { /** * Javascript used to remove previously shown error messages. - * + * * @return */ - protected String getRemovePreviousErrorsScript() { + protected String getRemovePreviousErrorsScript() + { return "$('#" + getComponent().getMarkupId() + "').next().remove();"; } /** - * Adds the error-javascript to the response since the component - * has errors. - * - * @param target The AjaxRequestTarget you can add components to - * @param e The exception if any + * Adds the error-javascript to the response since the component has errors. + * + * @param target + * The AjaxRequestTarget you can add components to + * @param e + * The exception if any */ @Override - protected void onError(AjaxRequestTarget target, RuntimeException e) { + protected void onError(AjaxRequestTarget target, RuntimeException e) + { super.onError(target, e); target.appendJavaScript(getErrorJavascript()); errorDetected = true; } /** - * Returns the javascript that will manipulate the markup to - * show the error message. Defaults to adding a CSS-class to the - * parent element (nice if you add a

          or

          around your - * label/component) + * Returns the javascript that will manipulate the markup to show the error message. Defaults to + * adding a CSS-class to the parent element (nice if you add a + *

          + * or

          around your label/component) + * * @return */ - protected String getErrorJavascript() { + protected String getErrorJavascript() + { StringBuilder b = new StringBuilder(); // Remove the previously added error-messages - if(errorDetected) + if (errorDetected) b.append(getRemovePreviousErrorsScript()); // Add the ERROR class to the sourrounding component - b.append("$('#" + getComponent().getMarkupId() + "').parent().addClass('" + ERROR_COMPONENT_CLASS + "');"); + b.append("$('#" + getComponent().getMarkupId() + "').parent().addClass('" + + ERROR_COMPONENT_CLASS + "');"); // Create list of error messages, separated by the chosen separator markup - List messages = Session.get().getFeedbackMessages().messages(new ComponentFeedbackMessageFilter(getComponent())); + List messages = Session.get() + .getFeedbackMessages() + .messages(new ComponentFeedbackMessageFilter(getComponent())); StringBuilder mb = new StringBuilder(""); - for(int i = 0; i < messages.size(); i++ ) { + for (int i = 0; i < messages.size(); i++) + { String msg = messages.get(i).getMessage().toString().replace("'", "\\'"); mb.append(msg); - if(i+1 < messages.size()) + if (i + 1 < messages.size()) mb.append(getErrorSeparator()); } // Add the span with the error messages - b.append("$('#" + getComponent().getMarkupId() + "').after('" + mb.toString() + "');"); + b.append("$('#" + getComponent().getMarkupId() + "').after('" + mb.toString() + "');"); return b.toString(); } /** - * The error separator is used to differentiate each error-message - * in case a component has more than one error message - * - * Defaults to separating using a
          tag. - * + * The error separator is used to differentiate each error-message in case a component has more + * than one error message + * + * Defaults to separating using a
          + * tag. + * * @return the markup for separating multiple error message */ - protected String getErrorSeparator() { + protected String getErrorSeparator() + { return "
          "; } - /** Add the JQuery library so we can use it in the onError method - * to manipulate the markup. - * + /** + * Add the JQuery library so we can use it in the onError method to manipulate the markup. + * * @param response */ @Override - public void renderHead(Component component, IHeaderResponse response) { + public void renderHead(Component component, IHeaderResponse response) + { super.renderHead(component, response); response.renderJavaScriptReference(JQueryBehavior.JQUERY_JS); } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example1.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example1.java index 990d9da997..75036383b5 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example1.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example1.java @@ -17,32 +17,32 @@ public class Example1 extends WebPage { - static class Data implements Serializable - { - @Email - String email; + static class Data implements Serializable + { + @Email + String email; - @Range(min = 18, max = 99) - int age; - } + @Range(min = 18, max = 99) + int age; + } - private final Data dummy = new Data(); + private final Data dummy = new Data(); - public Example1() - { - final Form form = new Form("form"); - add(form); - add(new FeedbackPanel("fb")); - add(new WebMarkupContainer("message") - { - @Override - public boolean isVisible() - { - return form.isSubmitted() && (!form.hasError()); - } - }); - form.add(new PropertyValidation()); - form.add(new TextField("email", new PropertyModel(this.dummy, "email"))); - form.add(new TextField("age", new PropertyModel(this.dummy, "age"))); - } + public Example1() + { + final Form form = new Form("form"); + add(form); + add(new FeedbackPanel("fb")); + add(new WebMarkupContainer("message") + { + @Override + public boolean isVisible() + { + return form.isSubmitted() && (!form.hasError()); + } + }); + form.add(new PropertyValidation()); + form.add(new TextField("email", new PropertyModel(dummy, "email"))); + form.add(new TextField("age", new PropertyModel(dummy, "age"))); + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example2.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example2.java index 7417155beb..a03661943a 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example2.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example2.java @@ -18,29 +18,29 @@ public class Example2 extends WebPage { - static class Data implements Serializable - { - @Email - @NotNull - String email = ""; - } + static class Data implements Serializable + { + @Email + @NotNull + String email = ""; + } - private final Data dummy = new Data(); + private final Data dummy = new Data(); - public Example2() - { - final Form form = new Form("form"); - add(form); - add(new FeedbackPanel("fb")); - add(new WebMarkupContainer("message") - { - @Override - public boolean isVisible() - { - return form.isSubmitted() && (!form.hasError()); - } - }); - form.add(new PropertyValidation()); - form.add(new TextField("email", new PropertyModel(this.dummy, "email"))); - } + public Example2() + { + final Form form = new Form("form"); + add(form); + add(new FeedbackPanel("fb")); + add(new WebMarkupContainer("message") + { + @Override + public boolean isVisible() + { + return form.isSubmitted() && (!form.hasError()); + } + }); + form.add(new PropertyValidation()); + form.add(new TextField("email", new PropertyModel(dummy, "email"))); + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example3.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example3.java index fb1cd31d55..7ac7b20733 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example3.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example3.java @@ -17,32 +17,32 @@ public class Example3 extends WebPage { - static class Data implements Serializable - { - @Email - String email; + static class Data implements Serializable + { + @Email + String email; - @Range(min = 18, max = 99) - int age; - } + @Range(min = 18, max = 99) + int age; + } - private final Data dummy = new Data(); + private final Data dummy = new Data(); - public Example3() - { - final Form form = new Form("form", new CompoundPropertyModel(this.dummy)); - add(form); - add(new FeedbackPanel("fb")); - add(new WebMarkupContainer("message") - { - @Override - public boolean isVisible() - { - return form.isSubmitted() && (!form.hasError()); - } - }); - form.add(new PropertyValidation()); - form.add(new TextField("email")); - form.add(new TextField("age")); - } + public Example3() + { + final Form form = new Form("form", new CompoundPropertyModel(dummy)); + add(form); + add(new FeedbackPanel("fb")); + add(new WebMarkupContainer("message") + { + @Override + public boolean isVisible() + { + return form.isSubmitted() && (!form.hasError()); + } + }); + form.add(new PropertyValidation()); + form.add(new TextField("email")); + form.add(new TextField("age")); + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example4.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example4.java index 2bb53c97c9..cd11f0919f 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example4.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example4.java @@ -19,43 +19,45 @@ public class Example4 extends WebPage { - static class Data implements Serializable - { - @Valid - ValidatedBean validatableBean = new ValidatedBean(); + static class Data implements Serializable + { + @Valid + ValidatedBean validatableBean = new ValidatedBean(); - NonValidatedBean nonValidatableBean = new NonValidatedBean(); - } - static class ValidatedBean implements Serializable - { - @Email - @NotNull - String email; - } - static class NonValidatedBean implements Serializable - { - @Email - @NotNull - String email; - } + NonValidatedBean nonValidatableBean = new NonValidatedBean(); + } + static class ValidatedBean implements Serializable + { + @Email + @NotNull + String email; + } + static class NonValidatedBean implements Serializable + { + @Email + @NotNull + String email; + } - private final Data dummy = new Data(); + private final Data dummy = new Data(); - public Example4() - { - final Form form = new Form("form"); - add(form); - add(new FeedbackPanel("fb")); - add(new WebMarkupContainer("message") - { - @Override - public boolean isVisible() - { - return form.isSubmitted() && (!form.hasError()); - } - }); - form.add(new PropertyValidation()); - form.add(new TextField("email1", new PropertyModel(this.dummy, "validatableBean.email"))); - form.add(new TextField("email2", new PropertyModel(this.dummy, "nonValidatableBean.email"))); - } + public Example4() + { + final Form form = new Form("form"); + add(form); + add(new FeedbackPanel("fb")); + add(new WebMarkupContainer("message") + { + @Override + public boolean isVisible() + { + return form.isSubmitted() && (!form.hasError()); + } + }); + form.add(new PropertyValidation()); + form.add(new TextField("email1", new PropertyModel(dummy, + "validatableBean.email"))); + form.add(new TextField("email2", new PropertyModel(dummy, + "nonValidatableBean.email"))); + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example5.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example5.java index 9d4ca875e4..2a558664d9 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example5.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example5.java @@ -15,58 +15,58 @@ public class Example5 extends WebPage { - @FooConstraint - static class Data implements Serializable, FieldBundle - { - public String getField1() - { - return this.field1; - } + @FooConstraint + static class Data implements Serializable, FieldBundle + { + public String getField1() + { + return field1; + } - public String getField2() - { - return this.field2; - } + public String getField2() + { + return field2; + } - String field1; - String field2; - } + String field1; + String field2; + } - private final Data dummy = new Data(); + private final Data dummy = new Data(); - public Example5() - { - final Form form = new Form("form", new CompoundPropertyModel(this.dummy)) - { - @Override - protected void onSubmit() - { - super.onSubmit(); + public Example5() + { + final Form form = new Form("form", new CompoundPropertyModel(dummy)) + { + @Override + protected void onSubmit() + { + super.onSubmit(); - if (!new BeanValidator(this).isValid(Example5.this.dummy)) - { - // execute... - } - else - { - // stay here... - } - } - }; + if (!new BeanValidator(this).isValid(dummy)) + { + // execute... + } + else + { + // stay here... + } + } + }; - add(form); + add(form); - add(new FeedbackPanel("fb")); - add(new WebMarkupContainer("message") - { - @Override - public boolean isVisible() - { - return form.isSubmitted() && (!form.hasError()); - } - }); + add(new FeedbackPanel("fb")); + add(new WebMarkupContainer("message") + { + @Override + public boolean isVisible() + { + return form.isSubmitted() && (!form.hasError()); + } + }); - form.add(new TextField("field1")); - form.add(new TextField("field2")); - } + form.add(new TextField("field1")); + form.add(new TextField("field2")); + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example6.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example6.java index f5ed36c471..bdde7076e3 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example6.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/Example6.java @@ -18,59 +18,59 @@ public class Example6 extends WebPage { - @FooConstraint - static class Data implements Serializable, FieldBundle - { - public String getField1() - { - return this.field1; - } + @FooConstraint + static class Data implements Serializable, FieldBundle + { + public String getField1() + { + return field1; + } - public String getField2() - { - return this.field2; - } + public String getField2() + { + return field2; + } - String field1; - @NotNull - String field2; - } + String field1; + @NotNull + String field2; + } - private final Data dummy = new Data(); + private final Data dummy = new Data(); - public Example6() - { - final Form form = new Form("form", new CompoundPropertyModel(this.dummy)) - { - @Override - protected void onSubmit() - { - super.onSubmit(); + public Example6() + { + final Form form = new Form("form", new CompoundPropertyModel(dummy)) + { + @Override + protected void onSubmit() + { + super.onSubmit(); - if (!new BeanValidator(this).isValid(Example6.this.dummy)) - { - // execute... - } - else - { - // stay here... - } - } - }; + if (!new BeanValidator(this).isValid(dummy)) + { + // execute... + } + else + { + // stay here... + } + } + }; - add(form); - form.add(new PropertyValidation()); - add(new FeedbackPanel("fb")); - add(new WebMarkupContainer("message") - { - @Override - public boolean isVisible() - { - return form.isSubmitted() && (!form.hasError()); - } - }); + add(form); + form.add(new PropertyValidation()); + add(new FeedbackPanel("fb")); + add(new WebMarkupContainer("message") + { + @Override + public boolean isVisible() + { + return form.isSubmitted() && (!form.hasError()); + } + }); - form.add(new TextField("field1")); - form.add(new TextField("field2")); - } + form.add(new TextField("field1")); + form.add(new TextField("field2")); + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FieldBundle.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FieldBundle.java index 6e75c7cb6a..42d7b7578b 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FieldBundle.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FieldBundle.java @@ -6,8 +6,8 @@ public interface FieldBundle { - String getField1(); + String getField1(); - String getField2(); + String getField2(); } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooConstraint.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooConstraint.java index 91cd748510..5ec9a5309f 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooConstraint.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooConstraint.java @@ -14,16 +14,15 @@ /** * @author doc */ -@Constraint(validatedBy = -{ FooValidator.class }) +@Constraint(validatedBy = { FooValidator.class }) @Retention(RetentionPolicy.RUNTIME) -@Target( -{ ElementType.TYPE }) -public @interface FooConstraint { +@Target({ ElementType.TYPE }) +public @interface FooConstraint +{ - String message() default "{example.FooConstraint.notEqual}"; + String message() default "{example.FooConstraint.notEqual}"; - Class[] groups() default {}; + Class[] groups() default { }; - Class[] payload() default {}; + Class[] payload() default { }; } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooValidator.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooValidator.java index 773b0f9b47..ff54c944f1 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooValidator.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/FooValidator.java @@ -9,19 +9,19 @@ // just a STUPID example ! public class FooValidator implements ConstraintValidator { - public void initialize(final FooConstraint constraintAnnotation) - { - } + public void initialize(final FooConstraint constraintAnnotation) + { + } - public boolean isValid(final FieldBundle value, final ConstraintValidatorContext context) - { - final String field1 = value.getField1(); - final String field2 = value.getField2(); - if ((field1 == null) || (field2 == null)) - { - return false; - } - return field1.equals(field2); - } + public boolean isValid(final FieldBundle value, final ConstraintValidatorContext context) + { + final String field1 = value.getField1(); + final String field2 = value.getField2(); + if ((field1 == null) || (field2 == null)) + { + return false; + } + return field1.equals(field2); + } } \ No newline at end of file diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/JSR303ExampleApplication.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/JSR303ExampleApplication.java index 8213adad45..776166c3d1 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/JSR303ExampleApplication.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/main/java/org/wicketstuff/jsr303/examples/JSR303ExampleApplication.java @@ -9,29 +9,30 @@ public class JSR303ExampleApplication extends WebApplication { - @Override - public Class getHomePage() - { - return IndexPage.class; - } - - /* - * (non-Javadoc) - * @see org.apache.wicket.protocol.http.WebApplication#init() - */ - @Override - protected void init() - { - super.init(); - - - mountPage("/e1", Example1.class); - mountPage("/e2", Example2.class); - mountPage("/e3", Example3.class); - mountPage("/e4", Example4.class); - mountPage("/e5", Example5.class); - mountPage("/e6", Example6.class); - - } + @Override + public Class getHomePage() + { + return IndexPage.class; + } + + /* + * (non-Javadoc) + * + * @see org.apache.wicket.protocol.http.WebApplication#init() + */ + @Override + protected void init() + { + super.init(); + + + mountPage("/e1", Example1.class); + mountPage("/e2", Example2.class); + mountPage("/e3", Example3.class); + mountPage("/e4", Example4.class); + mountPage("/e5", Example5.class); + mountPage("/e6", Example6.class); + + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/test/java/org/wicketstuff/jsr303/examples/Start.java b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/test/java/org/wicketstuff/jsr303/examples/Start.java index b1d449beee..1903b21dea 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/test/java/org/wicketstuff/jsr303/examples/Start.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303-examples/src/test/java/org/wicketstuff/jsr303/examples/Start.java @@ -5,9 +5,11 @@ import org.eclipse.jetty.server.bio.SocketConnector; import org.eclipse.jetty.webapp.WebAppContext; -public class Start { +public class Start +{ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception + { Server server = new Server(); SocketConnector connector = new SocketConnector(); // Set some timeout options to make debugging easier. @@ -21,24 +23,28 @@ public static void main(String[] args) throws Exception { bb.setContextPath("/"); bb.setWar("src/main/webapp"); - + // START JMX SERVER // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); // server.getContainer().addEventListener(mBeanContainer); // mBeanContainer.start(); - + server.setHandler(bb); - try { + try + { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); - while (System.in.available() == 0) { + while (System.in.available() == 0) + { Thread.sleep(5000); } server.stop(); server.join(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); System.exit(100); } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/BeanValidator.java b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/BeanValidator.java index d1bab41dc5..1bd988f3c0 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/BeanValidator.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/BeanValidator.java @@ -17,140 +17,144 @@ import org.apache.wicket.validation.IValidationError; /** - * BeanValidator is not actually a Wicket IValidator. The reason for this is the - * fact, that values must have been written back into the Bean for it to be able - * to validate. This is supposed to be used manually within the onSubmit call of - * a form, for example. It may report the error to the component being passed on - * construction. + * BeanValidator is not actually a Wicket IValidator. The reason for this is the fact, that values + * must have been written back into the Bean for it to be able to validate. This is supposed to be + * used manually within the onSubmit call of a form, for example. It may report the error to the + * component being passed on construction. */ public class BeanValidator { - private final Form context; - - public BeanValidator(final Form contextOrNull) - { - context = contextOrNull; - } - - public boolean isValid(final U e) - { - if (e == null) - { - return true; - } - - JSR303Validation.getInstance(); - final java.util.Set s = JSR303Validation.getValidator().validate(e); - if (s.isEmpty()) - { - return true; - } - - for (final Object v : s) - { - final ConstraintViolation violation = (ConstraintViolation) v; - if (context != null) - { - final IValidationError ve = new ViolationErrorBuilder.Bean((ConstraintViolation) v).createError(); - context.error(new ValidationErrorFeedback(ve, ve.getErrorMessage(new MessageSource()))); - } - } - return false; - } - class MessageSource implements IErrorMessageSource - { - private final Set triedKeys = new LinkedHashSet(); - - // basically copied from FormComponent, suggestions welcome - - public String getMessage(final String key) - { - - // Use the following log4j config for detailed logging on the - // property resolution - // process - // log4j.logger.org.apache.wicket.resource.loader=DEBUG - // log4j.logger.org.apache.wicket.Localizer=DEBUG - - final Localizer localizer = context.getLocalizer(); - - // retrieve prefix that will be used to construct message keys - final String prefix = context.getValidatorKeyPrefix(); - String message = null; - - // first try the full form of key [form-component-id].[key] - String resource = context.getId() + "." + prefix(prefix, key); - message = getString(localizer, resource, context); - - // if not found, try a more general form (without prefix) - // [form-component-id].[prefix].[key] - if (Strings.isEmpty(message) && Strings.isEmpty(prefix)) - { - resource = context.getId() + "." + key; - message = getString(localizer, resource, context); - } - - // If not found try a more general form [prefix].[key] - if (Strings.isEmpty(message)) - { - resource = prefix(prefix, key); - message = getString(localizer, resource, context); - } - - // If not found try the most general form [key] - if (Strings.isEmpty(message)) - { - // Try a variation of the resource key - message = getString(localizer, key, context); - } - - // convert empty string to null in case our default value of "" was - // returned from localizer - if (Strings.isEmpty(message)) - { - message = null; - } - return message; - } - - private String prefix(final String prefix, final String key) - { - if (!Strings.isEmpty(prefix)) - { - return prefix + "." + key; - } - else - { - return key; - } - } - - /** - * @param localizer - * @param key - * @param component - * @return string - */ - private String getString(final Localizer localizer, final String key, final Component component) - { - triedKeys.add(key); - - // Note: It is important that the default value of "" is - // provided to getString() not to throw a MissingResourceException - // or to - // return a default string like "[Warning: String ..." - return localizer.getString(key, component, ""); - } - - /** - * @see org.apache.wicket.validation.IErrorMessageSource#substitute(java.lang.String, - * java.util.Map) - */ - public String substitute(final String string, final Map vars) throws IllegalStateException - { - return new MapVariableInterpolator(string, vars, Application.get().getResourceSettings() - .getThrowExceptionOnMissingResource()).toString(); - } - - } + private final Form context; + + public BeanValidator(final Form contextOrNull) + { + context = contextOrNull; + } + + public boolean isValid(final U e) + { + if (e == null) + { + return true; + } + + JSR303Validation.getInstance(); + final java.util.Set s = JSR303Validation.getValidator().validate(e); + if (s.isEmpty()) + { + return true; + } + + for (final Object v : s) + { + final ConstraintViolation violation = (ConstraintViolation)v; + if (context != null) + { + final IValidationError ve = new ViolationErrorBuilder.Bean((ConstraintViolation)v).createError(); + context.error(new ValidationErrorFeedback(ve, + ve.getErrorMessage(new MessageSource()))); + } + } + return false; + } + + class MessageSource implements IErrorMessageSource + { + private final Set triedKeys = new LinkedHashSet(); + + // basically copied from FormComponent, suggestions welcome + + public String getMessage(final String key) + { + + // Use the following log4j config for detailed logging on the + // property resolution + // process + // log4j.logger.org.apache.wicket.resource.loader=DEBUG + // log4j.logger.org.apache.wicket.Localizer=DEBUG + + final Localizer localizer = context.getLocalizer(); + + // retrieve prefix that will be used to construct message keys + final String prefix = context.getValidatorKeyPrefix(); + String message = null; + + // first try the full form of key [form-component-id].[key] + String resource = context.getId() + "." + prefix(prefix, key); + message = getString(localizer, resource, context); + + // if not found, try a more general form (without prefix) + // [form-component-id].[prefix].[key] + if (Strings.isEmpty(message) && Strings.isEmpty(prefix)) + { + resource = context.getId() + "." + key; + message = getString(localizer, resource, context); + } + + // If not found try a more general form [prefix].[key] + if (Strings.isEmpty(message)) + { + resource = prefix(prefix, key); + message = getString(localizer, resource, context); + } + + // If not found try the most general form [key] + if (Strings.isEmpty(message)) + { + // Try a variation of the resource key + message = getString(localizer, key, context); + } + + // convert empty string to null in case our default value of "" was + // returned from localizer + if (Strings.isEmpty(message)) + { + message = null; + } + return message; + } + + private String prefix(final String prefix, final String key) + { + if (!Strings.isEmpty(prefix)) + { + return prefix + "." + key; + } + else + { + return key; + } + } + + /** + * @param localizer + * @param key + * @param component + * @return string + */ + private String getString(final Localizer localizer, final String key, + final Component component) + { + triedKeys.add(key); + + // Note: It is important that the default value of "" is + // provided to getString() not to throw a MissingResourceException + // or to + // return a default string like "[Warning: String ..." + return localizer.getString(key, component, ""); + } + + /** + * @see org.apache.wicket.validation.IErrorMessageSource#substitute(java.lang.String, + * java.util.Map) + */ + public String substitute(final String string, final Map vars) + throws IllegalStateException + { + return new MapVariableInterpolator(string, vars, Application.get() + .getResourceSettings() + .getThrowExceptionOnMissingResource()).toString(); + } + + } } \ No newline at end of file diff --git a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/JSR303Validation.java b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/JSR303Validation.java index fd79719814..18f4c70c47 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/JSR303Validation.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/JSR303Validation.java @@ -18,82 +18,83 @@ public class JSR303Validation { - public class WicketSessionLocaleMessageInterpolator implements MessageInterpolator - { - private final MessageInterpolator delegate; - - public WicketSessionLocaleMessageInterpolator(final MessageInterpolator delegate) - { - this.delegate = delegate; - Assert.parameterNotNull(delegate, "delegate"); - } - - public String interpolate(final String message, final Context context) - { - return delegate.interpolate(message, context, Session.get().getLocale()); - } - - public String interpolate(final String message, final Context context, final Locale locale) - { - return delegate.interpolate(message, context, Session.get().getLocale()); - } - } - - private synchronized ValidatorFactory createFactory() - { - - final Configuration configuration = Validation.byDefaultProvider().configure(); - // FIXME seems like needed for hib-val 4.0.2.? strange enough it does - // not respect the locale passed on interpolate call. Working on it. - - // geez. they screwed it up. - // http://opensource.atlassian.com/projects/hibernate/browse/HV-306 - // fixed in 4.1.0.beta2 ... Locale.setDefault(Session.get().getLocale()); - - final ValidatorFactory validationFactory = configuration.messageInterpolator( - new WicketSessionLocaleMessageInterpolator(configuration.getDefaultMessageInterpolator())) - .buildValidatorFactory(); - - return validationFactory; - } - - private static final JSR303Validation INSTANCE = new JSR303Validation(); - private static final MetaDataKey violationMessageRendererKey = new MetaDataKey() - { - private static final long serialVersionUID = 1L; - }; - - public static final JSR303Validation getInstance() - { - return INSTANCE; - } - - public static Validator getValidator() - { - return getInstance().createFactory().getValidator(); - } - - private JSR303Validation() - { - } - - synchronized static ViolationMessageRenderer getViolationMessageRenderer() - { - final Application app = Application.get(); - ViolationMessageRenderer renderer = app.getMetaData(violationMessageRendererKey); - if (renderer == null) - { - renderer = new ViolationMessageRenderer.Default(); - setViolationMessageRenderer(renderer); - } - return renderer; - } - - public synchronized static void setViolationMessageRenderer(final ViolationMessageRenderer renderer) - { - Assert.parameterNotNull(renderer, "renderer"); - final Application app = Application.get(); - app.setMetaData(violationMessageRendererKey, renderer); - } + public class WicketSessionLocaleMessageInterpolator implements MessageInterpolator + { + private final MessageInterpolator delegate; + + public WicketSessionLocaleMessageInterpolator(final MessageInterpolator delegate) + { + this.delegate = delegate; + Assert.parameterNotNull(delegate, "delegate"); + } + + public String interpolate(final String message, final Context context) + { + return delegate.interpolate(message, context, Session.get().getLocale()); + } + + public String interpolate(final String message, final Context context, final Locale locale) + { + return delegate.interpolate(message, context, Session.get().getLocale()); + } + } + + private synchronized ValidatorFactory createFactory() + { + + final Configuration configuration = Validation.byDefaultProvider().configure(); + // FIXME seems like needed for hib-val 4.0.2.? strange enough it does + // not respect the locale passed on interpolate call. Working on it. + + // geez. they screwed it up. + // http://opensource.atlassian.com/projects/hibernate/browse/HV-306 + // fixed in 4.1.0.beta2 ... Locale.setDefault(Session.get().getLocale()); + + final ValidatorFactory validationFactory = configuration.messageInterpolator( + new WicketSessionLocaleMessageInterpolator( + configuration.getDefaultMessageInterpolator())).buildValidatorFactory(); + + return validationFactory; + } + + private static final JSR303Validation INSTANCE = new JSR303Validation(); + private static final MetaDataKey violationMessageRendererKey = new MetaDataKey() + { + private static final long serialVersionUID = 1L; + }; + + public static final JSR303Validation getInstance() + { + return INSTANCE; + } + + public static Validator getValidator() + { + return getInstance().createFactory().getValidator(); + } + + private JSR303Validation() + { + } + + synchronized static ViolationMessageRenderer getViolationMessageRenderer() + { + final Application app = Application.get(); + ViolationMessageRenderer renderer = app.getMetaData(violationMessageRendererKey); + if (renderer == null) + { + renderer = new ViolationMessageRenderer.Default(); + setViolationMessageRenderer(renderer); + } + return renderer; + } + + public synchronized static void setViolationMessageRenderer( + final ViolationMessageRenderer renderer) + { + Assert.parameterNotNull(renderer, "renderer"); + final Application app = Application.get(); + app.setMetaData(violationMessageRendererKey, renderer); + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidation.java b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidation.java index 43275e42ca..5f3cc9b2ca 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidation.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidation.java @@ -10,75 +10,78 @@ import org.apache.wicket.util.visit.IVisitor; /** - * Behavior to be added to either a FormComponent or Form. If used on a - * FormComponent, it has to be bound to an AbstractPropertyModel. When used on a - * Form, this behavior will be added to all appropriate FormComponents. + * Behavior to be added to either a FormComponent or Form. If used on a FormComponent, it has to be + * bound to an AbstractPropertyModel. When used on a Form, this behavior will be added to all + * appropriate FormComponents. */ @SuppressWarnings("unchecked") public class PropertyValidation extends Behavior { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - class JSR303ValidatorFormComponentVisitor implements IVisitor - { - - - public void component(Component component, IVisit visit) { - - if (component instanceof FormComponent) - { - final FormComponent fc = (FormComponent) component; - final IModel model = fc.getModel(); - if (model != null) - { - if (model instanceof AbstractPropertyModel) - { - final AbstractPropertyModel pm = (AbstractPropertyModel) model; - PropertyValidator validator = new PropertyValidator(pm, fc); - fc.add(validator); - } - } - } - } - } + class JSR303ValidatorFormComponentVisitor implements IVisitor + { - private boolean assigned = false; - @Override - public synchronized void beforeRender(Component context) - { - if (!assigned) - { - assigned = true; - if (context instanceof Form) - { - final Form form = (Form) context; - form.visitChildren(new JSR303ValidatorFormComponentVisitor()); - } - else - { - if ((context instanceof FormComponent)) - { - final FormComponent fc = (FormComponent) context; - final IModel m = fc.getModel(); - if (m instanceof AbstractPropertyModel) - { - final AbstractPropertyModel apm = (AbstractPropertyModel) m; - fc.add(new PropertyValidator(apm, fc)); - } - else - { - throw new IllegalArgumentException("Expected something that provides an AbstractPropertyModel"); - } - } - else - { - throw new IllegalStateException("Can only be applied to Forms or FormComponents"); - } - } - } - super.beforeRender(context); - } + public void component(Component component, IVisit visit) + { + + if (component instanceof FormComponent) + { + final FormComponent fc = (FormComponent)component; + final IModel model = fc.getModel(); + if (model != null) + { + if (model instanceof AbstractPropertyModel) + { + final AbstractPropertyModel pm = (AbstractPropertyModel)model; + PropertyValidator validator = new PropertyValidator(pm, fc); + fc.add(validator); + } + } + } + } + } + + private boolean assigned = false; + + @Override + public synchronized void beforeRender(Component context) + { + if (!assigned) + { + assigned = true; + if (context instanceof Form) + { + final Form form = (Form)context; + form.visitChildren(new JSR303ValidatorFormComponentVisitor()); + } + else + { + if ((context instanceof FormComponent)) + { + final FormComponent fc = (FormComponent)context; + final IModel m = fc.getModel(); + if (m instanceof AbstractPropertyModel) + { + final AbstractPropertyModel apm = (AbstractPropertyModel)m; + fc.add(new PropertyValidator(apm, fc)); + } + else + { + throw new IllegalArgumentException( + "Expected something that provides an AbstractPropertyModel"); + } + } + else + { + throw new IllegalStateException( + "Can only be applied to Forms or FormComponents"); + } + } + } + super.beforeRender(context); + } } \ No newline at end of file diff --git a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidator.java b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidator.java index 72e1dbce90..b80531225a 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidator.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/PropertyValidator.java @@ -18,65 +18,68 @@ @SuppressWarnings("rawtypes") public class PropertyValidator implements INullAcceptingValidator, Serializable { - public static class Exclude extends Behavior - { - private static final long serialVersionUID = 1L; - } - - public void validate(final IValidatable validatable) - { - // skip, if propertyExpression is empty - if (propertyExpression == null || propertyExpression.trim().length() == 0) return; - - // skip, if marked as excluded - if (hasExclusionBehaviour()) return; - - final T value = validatable.getValue(); - - final Set violations = JSR303Validation.getValidator().validateValue(beanClass, propertyExpression, value); - for (final Object v : violations) - { - validatable.error(new ViolationErrorBuilder.Property((ConstraintViolation) v).createError()); - } - } - - private static final long serialVersionUID = 1L; - - private final Class beanClass; - private final String propertyExpression; - - private final FormComponent fc; - - public PropertyValidator(final AbstractPropertyModel apm, FormComponent componentToApplyTo) - { - this.fc = componentToApplyTo; - Assert.parameterNotNull(apm, "apm"); - this.beanClass = apm.getTarget().getClass(); - this.propertyExpression = apm.getPropertyExpression(); - } - - private boolean hasExclusionBehaviour() - { - List behaviors = fc.getBehaviors(); - for (Behavior iBehavior : behaviors) - { - if (iBehavior instanceof PropertyValidator.Exclude) - { - return true; - } - } - - return false; - } - - private static transient volatile Logger _transient_logger = LoggerFactory.getLogger(PropertyValidator.class); - - public static final Logger log() - { - if (_transient_logger == null) - { - _transient_logger = LoggerFactory.getLogger(PropertyValidator.class); - } - return _transient_logger; - } + public static class Exclude extends Behavior + { + private static final long serialVersionUID = 1L; + } + + public void validate(final IValidatable validatable) + { + // skip, if propertyExpression is empty + if (propertyExpression == null || propertyExpression.trim().length() == 0) + return; + + // skip, if marked as excluded + if (hasExclusionBehaviour()) + return; + + final T value = validatable.getValue(); + + final Set violations = JSR303Validation.getValidator().validateValue(beanClass, + propertyExpression, value); + for (final Object v : violations) + { + validatable.error(new ViolationErrorBuilder.Property((ConstraintViolation)v).createError()); + } + } + + private static final long serialVersionUID = 1L; + + private final Class beanClass; + private final String propertyExpression; + + private final FormComponent fc; + + public PropertyValidator(final AbstractPropertyModel apm, FormComponent componentToApplyTo) + { + this.fc = componentToApplyTo; + Assert.parameterNotNull(apm, "apm"); + this.beanClass = apm.getTarget().getClass(); + this.propertyExpression = apm.getPropertyExpression(); + } + + private boolean hasExclusionBehaviour() + { + List behaviors = fc.getBehaviors(); + for (Behavior iBehavior : behaviors) + { + if (iBehavior instanceof PropertyValidator.Exclude) + { + return true; + } + } + + return false; + } + + private static transient volatile Logger _transient_logger = LoggerFactory.getLogger(PropertyValidator.class); + + public static final Logger log() + { + if (_transient_logger == null) + { + _transient_logger = LoggerFactory.getLogger(PropertyValidator.class); + } + return _transient_logger; + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationErrorBuilder.java b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationErrorBuilder.java index 8616517e97..aaab2c5395 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationErrorBuilder.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationErrorBuilder.java @@ -7,68 +7,70 @@ abstract class ViolationErrorBuilder { - static class Property extends ViolationErrorBuilder - { - public Property(final ConstraintViolation violation) - { - super(violation); - } + static class Property extends ViolationErrorBuilder + { + public Property(final ConstraintViolation violation) + { + super(violation); + } - @Override - protected String render() - { - return JSR303Validation.getViolationMessageRenderer().renderPropertyViolation(this.violation); - } - } - static class Bean extends ViolationErrorBuilder - { + @Override + protected String render() + { + return JSR303Validation.getViolationMessageRenderer().renderPropertyViolation( + violation); + } + } + static class Bean extends ViolationErrorBuilder + { - public Bean(final ConstraintViolation violation) - { - super(violation); - } + public Bean(final ConstraintViolation violation) + { + super(violation); + } - @Override - protected String render() - { - return JSR303Validation.getViolationMessageRenderer().renderBeanViolation(this.violation); - } - } + @Override + protected String render() + { + return JSR303Validation.getViolationMessageRenderer().renderBeanViolation( + violation); + } + } - protected final ConstraintViolation violation; + protected final ConstraintViolation violation; - ViolationErrorBuilder(final ConstraintViolation violation) - { - Assert.parameterNotNull(violation, "violation"); - this.violation = violation; - } + ViolationErrorBuilder(final ConstraintViolation violation) + { + Assert.parameterNotNull(violation, "violation"); + this.violation = violation; + } - ValidationError createError() - { - final ValidationError ve = new ValidationError(); - ve.setMessage(render()); - final String messageTemplate = this.violation.getMessageTemplate(); - final String key = extractKey(messageTemplate); - if (key != null) - { - ve.addMessageKey(key); - } - return ve; - } + ValidationError createError() + { + final ValidationError ve = new ValidationError(); + ve.setMessage(render()); + final String messageTemplate = violation.getMessageTemplate(); + final String key = extractKey(messageTemplate); + if (key != null) + { + ve.addMessageKey(key); + } + return ve; + } - protected abstract String render(); + protected abstract String render(); - private static String extractKey(final String messageTemplate) - { - Assert.parameterNotNull(messageTemplate, "messageTemplate"); - final String key = messageTemplate.trim(); - if (key.startsWith("{") && key.endsWith("}")) - { - return key.substring(1, key.length() - 1); - } - else - { - return null; - } - } + private static String extractKey(final String messageTemplate) + { + Assert.parameterNotNull(messageTemplate, "messageTemplate"); + final String key = messageTemplate.trim(); + if (key.startsWith("{") && key.endsWith("}")) + { + return key.substring(1, key.length() - 1); + } + else + { + return null; + } + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationMessageRenderer.java b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationMessageRenderer.java index 022451f234..97745a4b54 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationMessageRenderer.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/ViolationMessageRenderer.java @@ -12,20 +12,20 @@ */ public interface ViolationMessageRenderer { - String renderPropertyViolation(ConstraintViolation violation); + String renderPropertyViolation(ConstraintViolation violation); - String renderBeanViolation(final ConstraintViolation violation); + String renderBeanViolation(final ConstraintViolation violation); - class Default implements ViolationMessageRenderer - { - public String renderPropertyViolation(final ConstraintViolation violation) - { - return "'${label}' " + violation.getMessage(); - } + class Default implements ViolationMessageRenderer + { + public String renderPropertyViolation(final ConstraintViolation violation) + { + return "'${label}' " + violation.getMessage(); + } - public String renderBeanViolation(final ConstraintViolation violation) - { - return violation.getMessage(); - } - } + public String renderBeanViolation(final ConstraintViolation violation) + { + return violation.getMessage(); + } + } } diff --git a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/util/Assert.java b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/util/Assert.java index 2e49599145..05e31f6eeb 100644 --- a/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/util/Assert.java +++ b/jdk-1.5-parent/jsr303-parent/jsr303/src/main/java/org/wicketstuff/jsr303/util/Assert.java @@ -15,148 +15,178 @@ * 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. - */package org.wicketstuff.jsr303.util; + */ +package org.wicketstuff.jsr303.util; import java.util.EnumSet; /** * A bunch of common Assertions. */ -public class Assert { - private static class AssertionFailedException extends RuntimeException { +public class Assert +{ + private static class AssertionFailedException extends RuntimeException + { private static final long serialVersionUID = 1L; - public AssertionFailedException(final String detail) { + public AssertionFailedException(final String detail) + { super(detail); } - public AssertionFailedException(final String detail, final Throwable e) { + public AssertionFailedException(final String detail, final Throwable e) + { super(detail, e); } } - public static > void enumContains( - final EnumSet supportedQueryMode, final T mode) { + public static > void enumContains(final EnumSet supportedQueryMode, + final T mode) + { Assert.isTrue(true, ""); } - public static void isEqual(final Object obj1, final Object obj2) { - if ((obj1 == null) && (obj2 == null)) { + public static void isEqual(final Object obj1, final Object obj2) + { + if ((obj1 == null) && (obj2 == null)) + { return; } - if ((obj1 != null) && (!obj1.equals(obj2))) { - Assert - .raiseError("'" + obj1 + "' and '" + obj2 - + "' are not equal"); + if ((obj1 != null) && (!obj1.equals(obj2))) + { + Assert.raiseError("'" + obj1 + "' and '" + obj2 + "' are not equal"); } } - public static final void isFalse(final boolean value) { + public static final void isFalse(final boolean value) + { Assert.isFalse(value, "Value was true"); } - public static final void isFalse(final boolean value, final String msg) { - if (value) { + public static final void isFalse(final boolean value, final String msg) + { + if (value) + { Assert.raiseError(msg); } } - public static final void isNotFalse(final boolean value) { + public static final void isNotFalse(final boolean value) + { Assert.isNotFalse(value, "Value was false"); } - public static final void isNotFalse(final boolean value, final String msg) { - if (!value) { + public static final void isNotFalse(final boolean value, final String msg) + { + if (!value) + { Assert.raiseError(msg); } } - public static final void isNotNull(final Object reference) { + public static final void isNotNull(final Object reference) + { Assert.isNotNull(reference, "Reference was null"); } - public static final void isNotNull(final Object reference, final String msg) { - if (reference == null) { + public static final void isNotNull(final Object reference, final String msg) + { + if (reference == null) + { Assert.raiseError(msg); } } - public static final void isNotNullAndNotEmpty(final String reference) { + public static final void isNotNullAndNotEmpty(final String reference) + { Assert.isNotNullAndNotEmpty(reference, "Reference was null or empty"); } - public static final void isNotNullAndNotEmpty(final String reference, - final String msg) { - if ((reference == null) || (reference.length() == 0)) { + public static final void isNotNullAndNotEmpty(final String reference, final String msg) + { + if ((reference == null) || (reference.length() == 0)) + { Assert.raiseError(msg); } } - public static final void isNotTrue(final boolean value) { + public static final void isNotTrue(final boolean value) + { Assert.isNotTrue(value, "Value was true"); } - public static final void isNotTrue(final boolean value, final String msg) { - if (value) { + public static final void isNotTrue(final boolean value, final String msg) + { + if (value) + { Assert.raiseError(msg); } } - public static void isNull(final Object object, final String string) { - if (object != null) { + public static void isNull(final Object object, final String string) + { + if (object != null) + { Assert.raiseError(string); } } - public static final void isTrue(final boolean value) { + public static final void isTrue(final boolean value) + { Assert.isTrue(value, "Value was false"); } - public static final void isTrue(final boolean value, final String msg) { - if (!value) { + public static final void isTrue(final boolean value, final String msg) + { + if (!value) + { Assert.raiseError(msg); } } - public static void parameterInRange(final int value, final int min, - final int max, final String string) { - Assert.isTrue((min <= value) && (value <= max), "Parameter '" + string - + "' must be in range of " + min + " <= " + string + " <= " - + max + ". Current value was " + value); + public static void parameterInRange(final int value, final int min, final int max, + final String string) + { + Assert.isTrue((min <= value) && (value <= max), "Parameter '" + string + + "' must be in range of " + min + " <= " + string + " <= " + max + + ". Current value was " + value); } - public static void parameterLegal(final boolean condition, - final String parameter) { + public static void parameterLegal(final boolean condition, final String parameter) + { Assert.isTrue(condition, "Parameter '" + parameter + "' is not legal."); } - public static void parameterNotEmpty(final String reference, - final String nameOfParameter) { + public static void parameterNotEmpty(final String reference, final String nameOfParameter) + { - if ("".equals(reference)) { - Assert.raiseError("Parameter '" + nameOfParameter - + "' is not expected to be empty."); + if ("".equals(reference)) + { + Assert.raiseError("Parameter '" + nameOfParameter + "' is not expected to be empty."); } } - public static void parameterNotNull(final Object reference, - final String nameOfParameter) { - if (reference == null) { - Assert.raiseError("Parameter '" + nameOfParameter - + "' is not expected to be null."); + public static void parameterNotNull(final Object reference, final String nameOfParameter) + { + if (reference == null) + { + Assert.raiseError("Parameter '" + nameOfParameter + "' is not expected to be null."); } } - public static final void raiseError(final String error) { + public static final void raiseError(final String error) + { throw new AssertionFailedException(error); } - public static final void raiseError(final String error, final Exception e) { + public static final void raiseError(final String error, final Exception e) + { throw new AssertionFailedException(error, e); } - private Assert() { + private Assert() + { // hide } } diff --git a/jdk-1.5-parent/maven-support/src/main/java/org/wicketstuff/maven/MavenDevResourceStreamLocator.java b/jdk-1.5-parent/maven-support/src/main/java/org/wicketstuff/maven/MavenDevResourceStreamLocator.java index fa366629c8..6374a0a327 100644 --- a/jdk-1.5-parent/maven-support/src/main/java/org/wicketstuff/maven/MavenDevResourceStreamLocator.java +++ b/jdk-1.5-parent/maven-support/src/main/java/org/wicketstuff/maven/MavenDevResourceStreamLocator.java @@ -27,61 +27,53 @@ * Get resources from maven project directory. * * Usage: - * - * + * + * * class MyApp extends WebApplication * { - * @Override - * protected void init() - * { - * ... - * if (DEVELOPMENT.equals(getConfigurationType())) - * { - * getResourceSettings().setResourceStreamLocator(new MavenDevResourceStreamLocator()); - * } - * ... - * } - * } - * + * + * @Override protected void init() { ... if (DEVELOPMENT.equals(getConfigurationType())) { + * getResourceSettings().setResourceStreamLocator(new MavenDevResourceStreamLocator()); } + * ... } } * * @author mosmann - * + * */ public class MavenDevResourceStreamLocator extends ResourceStreamLocator { private static final Logger _logger = LoggerFactory.getLogger(MavenDevResourceStreamLocator.class); - - final static String MAVEN_RESOURCE_PATH="src/main/resources/"; - final static String MAVEN_JAVASOURCE_PATH="src/main/java/"; - + + final static String MAVEN_RESOURCE_PATH = "src/main/resources/"; + final static String MAVEN_JAVASOURCE_PATH = "src/main/java/"; + @Override public IResourceStream locate(final Class clazz, final String path) { - IResourceStream located=getFileSysResourceStream(MAVEN_RESOURCE_PATH,path); - if (located==null) + IResourceStream located = getFileSysResourceStream(MAVEN_RESOURCE_PATH, path); + if (located == null) { - located=getFileSysResourceStream(MAVEN_JAVASOURCE_PATH,path); + located = getFileSysResourceStream(MAVEN_JAVASOURCE_PATH, path); } if (located != null) { - _logger.info("Locate: {} in {} -> {}",new Object[] {clazz,path,located}); + _logger.info("Locate: {} in {} -> {}", new Object[] { clazz, path, located }); return located; } - located=super.locate(clazz, path); - _logger.info("Locate: {} in {} -> {}(Fallback)",new Object[] {clazz,path,located}); + located = super.locate(clazz, path); + _logger.info("Locate: {} in {} -> {}(Fallback)", new Object[] { clazz, path, located }); return located; } private static IResourceStream getFileSysResourceStream(String prefix, String path) { - File f=new File(prefix+path); + File f = new File(prefix + path); if ((f.exists()) && (f.isFile())) { return new FileResourceStream(f); } else { - _logger.debug("Could not get File: {}",f.getAbsolutePath()); + _logger.debug("Could not get File: {}", f.getAbsolutePath()); } return null; } diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/main/java/org/wicketstuff/mbeanview/examples/WicketApplication.java b/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/main/java/org/wicketstuff/mbeanview/examples/WicketApplication.java index 3d04bff97f..304e54304e 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/main/java/org/wicketstuff/mbeanview/examples/WicketApplication.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/main/java/org/wicketstuff/mbeanview/examples/WicketApplication.java @@ -3,19 +3,20 @@ 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. + * Application object for your web application. If you want to run this application without + * deploying, run the Start class. * * @see org.wicketstuff.mbeanview.examples.Start#main(String[]) */ public class WicketApplication extends WebApplication -{ - /** - * Constructor - */ +{ + /** + * Constructor + */ public WicketApplication() { } - + /** * @see org.apache.wicket.Application#getHomePage() */ diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/test/java/org/wicketstuff/mbeanview/examples/Start.java b/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/test/java/org/wicketstuff/mbeanview/examples/Start.java index 934238bcf8..67a3d891b6 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/test/java/org/wicketstuff/mbeanview/examples/Start.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview-examples/src/test/java/org/wicketstuff/mbeanview/examples/Start.java @@ -6,12 +6,14 @@ import org.eclipse.jetty.webapp.WebAppContext; -public class Start { +public class Start +{ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception + { Server server = new Server(); SocketConnector connector = new SocketConnector(); - + // Set some timeout options to make debugging easier. connector.setMaxIdleTime(1000 * 60 * 60); connector.setSoLingerTime(-1); @@ -22,26 +24,29 @@ public static void main(String[] args) throws Exception { bb.setServer(server); bb.setContextPath("/"); bb.setWar("src/main/webapp"); - + // START JMX SERVER // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); // server.getContainer().addEventListener(mBeanContainer); // mBeanContainer.start(); - + server.setHandler(bb); - try { + try + { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); System.in.read(); - System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); - // while (System.in.available() == 0) { - // Thread.sleep(5000); + System.out.println(">>> STOPPING EMBEDDED JETTY SERVER"); + // while (System.in.available() == 0) { + // Thread.sleep(5000); // } server.stop(); server.join(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); System.exit(100); } diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/AttributeValuesPanel.java b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/AttributeValuesPanel.java index 08c33e6352..5551bdef63 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/AttributeValuesPanel.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/AttributeValuesPanel.java @@ -55,7 +55,7 @@ public class AttributeValuesPanel extends Panel private ModalWindow modalOutput; public AttributeValuesPanel(String id, final ObjectName objectName, - MBeanAttributeInfo[] beanAttributeInfos, final MbeanServerLocator mbeanServerLocator) + MBeanAttributeInfo[] beanAttributeInfos, final MbeanServerLocator mbeanServerLocator) { super(id); add(modalOutput = new ModalWindow("modalOutput")); @@ -79,7 +79,7 @@ protected void populateItem(ListItem item) try { value = mbeanServerLocator.get().getAttribute(objectName, - info.getName()); + info.getName()); } catch (RuntimeMBeanException e) { @@ -96,7 +96,7 @@ protected void populateItem(ListItem item) public void onClick(AjaxRequestTarget target) { modalOutput.setContent(new DataViewPanel(modalOutput.getContentId(), - getModelObject())); + getModelObject())); modalOutput.setTitle(info.getName()); modalOutput.show(target); } @@ -104,9 +104,8 @@ public void onClick(AjaxRequestTarget target) @Override public boolean isEnabled() { - return (getModelObject() instanceof Collection) - || (getModelObject() != null && getModelObject().getClass() - .isArray()); + return (getModelObject() instanceof Collection) || + (getModelObject() != null && getModelObject().getClass().isArray()); } @Override @@ -118,7 +117,7 @@ public boolean isVisible() }); link.add(new Label("label", value == null ? null : value.toString())); item.add(new TextField("editableValue", new AttributeModel(info, - mbeanServerLocator, objectName)) + mbeanServerLocator, objectName)) { @Override public boolean isVisible() @@ -152,7 +151,7 @@ public class AttributeModel implements IModel private ObjectName objectName; public AttributeModel(MBeanAttributeInfo attributeInfo, - MbeanServerLocator mbeanServerLocator, ObjectName objectName) + MbeanServerLocator mbeanServerLocator, ObjectName objectName) { this.attributeInfo = attributeInfo; this.mbeanServerLocator = mbeanServerLocator; @@ -166,7 +165,7 @@ public Object getObject() try { return mbeanServerLocator.get().getAttribute(objectName, - attributeInfo.getName()); + attributeInfo.getName()); } catch (AttributeNotFoundException e) { @@ -204,9 +203,8 @@ public void setObject(Object object) Class clazz = DataUtil.getClassFromInfo(attributeInfo); paramWithCorrectType = DataUtil.tryParseToType(object, clazz); } - attribute = new Attribute(attributeInfo.getName(), object == null - ? null - : paramWithCorrectType); + attribute = new Attribute(attributeInfo.getName(), object == null ? null + : paramWithCorrectType); mbeanServerLocator.get().setAttribute(objectName, attribute); } catch (Exception e) diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataUtil.java b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataUtil.java index d9dbd1d129..7a227b8d02 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataUtil.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataUtil.java @@ -27,56 +27,76 @@ /** * @author Pedro Henrique Oliveira dos Santos - * + * */ -public class DataUtil { +public class DataUtil +{ - public static Object tryParseToType(Object object, Class clazz) { - try { - return clazz.getConstructor(new Class[] { String.class }) - .newInstance(object.toString()); - } catch (Exception e) { - return object; + public static Object tryParseToType(Object object, Class clazz) + { + try + { + return clazz.getConstructor(new Class[] { String.class }) + .newInstance(object.toString()); + } + catch (Exception e) + { + return object; + } } - } - public static Class getClassFromInfo(MBeanAttributeInfo attributeInfo) - throws ClassNotFoundException { - return getClassFromInfo(attributeInfo.getType()); - } + public static Class getClassFromInfo(MBeanAttributeInfo attributeInfo) + throws ClassNotFoundException + { + return getClassFromInfo(attributeInfo.getType()); + } - public static Class getClassFromInfo(String jmxType) throws ClassNotFoundException { - Class clazz = null; - if ("boolean".equals(jmxType)) { - clazz = Boolean.class; - } else if ("int".equals(jmxType)) { - clazz = Integer.class; - } else if ("double".equals(jmxType)) { - clazz = Double.class; - } else if ("long".equals(jmxType)) { - clazz = Long.class; - } else { - clazz = Class.forName(jmxType); + public static Class getClassFromInfo(String jmxType) throws ClassNotFoundException + { + Class clazz = null; + if ("boolean".equals(jmxType)) + { + clazz = Boolean.class; + } + else if ("int".equals(jmxType)) + { + clazz = Integer.class; + } + else if ("double".equals(jmxType)) + { + clazz = Double.class; + } + else if ("long".equals(jmxType)) + { + clazz = Long.class; + } + else + { + clazz = Class.forName(jmxType); + } + return clazz; } - return clazz; - } - public static Object getCompatibleData(Object object, MBeanParameterInfo beanParameterInfo) - throws ClassNotFoundException { - return tryParseToType(object, getClassFromInfo(beanParameterInfo.getType())); - } + public static Object getCompatibleData(Object object, MBeanParameterInfo beanParameterInfo) + throws ClassNotFoundException + { + return tryParseToType(object, getClassFromInfo(beanParameterInfo.getType())); + } - public static Set> parseToPropsSet(Set domainNames) { - Set result = new HashSet(); - for (Iterator i = domainNames.iterator(); i.hasNext();) { - ObjectName names = (ObjectName) i.next(); - Set propValue = new HashSet(); - for (Iterator it = names.getKeyPropertyList().entrySet().iterator(); it.hasNext();) { - Entry entry = (Entry) it.next(); - propValue.add(entry.getKey() + "=" + entry.getValue()); - } - result.add(propValue); - } - return result; - } + public static Set> parseToPropsSet(Set domainNames) + { + Set result = new HashSet(); + for (Iterator i = domainNames.iterator(); i.hasNext();) + { + ObjectName names = (ObjectName)i.next(); + Set propValue = new HashSet(); + for (Iterator it = names.getKeyPropertyList().entrySet().iterator(); it.hasNext();) + { + Entry entry = (Entry)it.next(); + propValue.add(entry.getKey() + "=" + entry.getValue()); + } + result.add(propValue); + } + return result; + } } diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataViewPanel.java b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataViewPanel.java index 4b4afcd3de..298b55812b 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataViewPanel.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/DataViewPanel.java @@ -29,39 +29,55 @@ * @author Pedro Henrique Oliveira dos Santos * */ -public class DataViewPanel extends Panel { - private static final String OUTPUT_ID = "output"; +public class DataViewPanel extends Panel +{ + private static final String OUTPUT_ID = "output"; - public DataViewPanel(String id, Object param) { - super(id); - List contents = null; - if (param == null) { - // - } else if (param instanceof List) { - contents = (List) param; - } else if (param.getClass().isArray()) { - int lenght = Array.getLength(param); - if (lenght > 0) { - contents = new ArrayList(); - for (int i = 0; i < lenght; i++) { - contents.add(Array.get(param, i)); + public DataViewPanel(String id, Object param) + { + super(id); + List contents = null; + if (param == null) + { + // } - } - } else { - contents = new ArrayList(); - contents.add(param); - } - ListView contentsRepeater = new ListView("contents", contents) { - @Override - protected void populateItem(ListItem item) { - Object value = item.getModelObject(); - if (value == null || (value instanceof String) || value.getClass().isPrimitive()) { - item.add(new Label(OUTPUT_ID, value == null ? null : value.toString())); - } else { - item.add(new ObjectViewPanel(OUTPUT_ID, value)); + else if (param instanceof List) + { + contents = (List)param; + } + else if (param.getClass().isArray()) + { + int lenght = Array.getLength(param); + if (lenght > 0) + { + contents = new ArrayList(); + for (int i = 0; i < lenght; i++) + { + contents.add(Array.get(param, i)); + } + } } - } - }; - add(contentsRepeater); - } + else + { + contents = new ArrayList(); + contents.add(param); + } + ListView contentsRepeater = new ListView("contents", contents) + { + @Override + protected void populateItem(ListItem item) + { + Object value = item.getModelObject(); + if (value == null || (value instanceof String) || value.getClass().isPrimitive()) + { + item.add(new Label(OUTPUT_ID, value == null ? null : value.toString())); + } + else + { + item.add(new ObjectViewPanel(OUTPUT_ID, value)); + } + } + }; + add(contentsRepeater); + } } diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MBeansPanel.java b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MBeansPanel.java index 3d44cfdf8d..96b193ea50 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MBeansPanel.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MBeansPanel.java @@ -67,7 +67,7 @@ public class MBeansPanel extends Panel implements IHeaderContributor public static final String VIEW_PANEL_ID = "view"; private static final ResourceReference CSS = new PackageResourceReference(MBeansPanel.class, - "css/MBeansPanel.css"); + "css/MBeansPanel.css"); public MBeansPanel(String id) { @@ -123,10 +123,9 @@ protected Component newNodeIcon(MarkupContainer parent, String id, TreeNode node if (node instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode mutableNode = (DefaultMutableTreeNode)node; - if (mutableNode.getChildCount() > 0 - && ((mutableNode.getChildAt(0) instanceof AttributeNode) - || (mutableNode.getChildAt(0) instanceof OperationNode) || (mutableNode - .getChildAt(0) instanceof NotificationNode))) + if (mutableNode.getChildCount() > 0 && + ((mutableNode.getChildAt(0) instanceof AttributeNode) || + (mutableNode.getChildAt(0) instanceof OperationNode) || (mutableNode.getChildAt(0) instanceof NotificationNode))) { return new EmptyPanel(id).add(new SimpleAttributeModifier("style", "width:0;")); } @@ -136,8 +135,8 @@ protected Component newNodeIcon(MarkupContainer parent, String id, TreeNode node } private TreeModel getTreeModel(MbeanServerLocator reachMbeanServer) - throws MalformedObjectNameException, NullPointerException, InstanceNotFoundException, - IntrospectionException, ReflectionException + throws MalformedObjectNameException, NullPointerException, InstanceNotFoundException, + IntrospectionException, ReflectionException { DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("root"); TreeModel model = new DefaultTreeModel(rootNode); @@ -147,7 +146,7 @@ private TreeModel getTreeModel(MbeanServerLocator reachMbeanServer) MbeanNode domainNode = new MbeanNode(domains[i]); rootNode.add(domainNode); Set domainNames = reachMbeanServer.get().queryNames(null, - new ObjectName(domains[i] + ":*")); + new ObjectName(domains[i] + ":*")); addDomainsCildrens(domainNode, DataUtil.parseToPropsSet(domainNames)); Enumeration enumeration = domainNode.postorderEnumeration(); Set nodes = new HashSet(); @@ -173,7 +172,7 @@ private TreeModel getTreeModel(MbeanServerLocator reachMbeanServer) } } Set mBeans = reachMbeanServer.get().queryMBeans(null, - new ObjectName(query)); + new ObjectName(query)); if (mBeans.size() > 0) { for (Iterator it = mBeans.iterator(); it.hasNext();) @@ -261,18 +260,18 @@ public MbeanNode(ObjectInstance objectInstance, String keyValue) public MbeanNode(MbeanNode parent) { - this.objectInstance = parent.objectInstance; - this.mBeanServerLocator = parent.mBeanServerLocator; - this.objectInstance = parent.objectInstance; - this.keyValue = parent.keyValue; + objectInstance = parent.objectInstance; + mBeanServerLocator = parent.mBeanServerLocator; + objectInstance = parent.objectInstance; + keyValue = parent.keyValue; } public void setObjectInstance(ObjectInstance objectInstance, - MbeanServerLocator reachMbeanServer) throws InstanceNotFoundException, - IntrospectionException, ReflectionException + MbeanServerLocator reachMbeanServer) throws InstanceNotFoundException, + IntrospectionException, ReflectionException { this.objectInstance = objectInstance; - this.mBeanServerLocator = reachMbeanServer; + mBeanServerLocator = reachMbeanServer; MBeanInfo info = reachMbeanServer.get().getMBeanInfo(objectInstance.getObjectName()); MBeanAttributeInfo[] beanAttributeInfos = info.getAttributes(); MBeanOperationInfo[] beanOperationInfos = info.getOperations(); @@ -288,7 +287,7 @@ public void setObjectInstance(ObjectInstance objectInstance, if (beanNotificationInfos.length > 0) { DefaultMutableTreeNode notificationsNode = new DefaultMutableTreeNode( - "Notification"); + "Notification"); add(notificationsNode); for (int i = 0; i < beanNotificationInfos.length; i++) { @@ -332,7 +331,7 @@ public AttributesNode(MbeanNode parent, MBeanAttributeInfo[] beanAttributeInfos) public Component getView(String id) { return new AttributeValuesPanel(id, objectInstance.getObjectName(), beanAttributeInfos, - mBeanServerLocator); + mBeanServerLocator); } @Override @@ -349,14 +348,14 @@ private class AttributeNode extends MbeanNode public AttributeNode(MbeanNode parent, MBeanAttributeInfo mBeanAttributeInfo) { super(parent); - this.attributeInfo = mBeanAttributeInfo; + attributeInfo = mBeanAttributeInfo; } @Override public Component getView(String wicketId) { return new AttributeValuesPanel(wicketId, objectInstance.getObjectName(), - new MBeanAttributeInfo[] { attributeInfo }, mBeanServerLocator); + new MBeanAttributeInfo[] { attributeInfo }, mBeanServerLocator); } @Override @@ -384,7 +383,7 @@ public OperationsNode(MbeanNode parent, MBeanOperationInfo[] beanOperationInfos) public Component getView(String id) { return new OperationsPanel(id, objectInstance.getObjectName(), beanOperationInfos, - mBeanServerLocator); + mBeanServerLocator); } @Override @@ -401,14 +400,14 @@ private class OperationNode extends MbeanNode public OperationNode(OperationsNode parent, MBeanOperationInfo mBeanOperationInfo) { super(parent); - this.beanOperationInfo = mBeanOperationInfo; + beanOperationInfo = mBeanOperationInfo; } @Override public Component getView(String wicketId) { return new OperationsPanel(wicketId, objectInstance.getObjectName(), - new MBeanOperationInfo[] { beanOperationInfo }, mBeanServerLocator); + new MBeanOperationInfo[] { beanOperationInfo }, mBeanServerLocator); } @Override @@ -425,7 +424,7 @@ private class NotificationNode extends MbeanNode public NotificationNode(MbeanNode parent, MBeanNotificationInfo mBeanNotificationInfo) { super(parent); - this.beanNotificationInfo = mBeanNotificationInfo; + beanNotificationInfo = mBeanNotificationInfo; } @Override diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MbeanServerLocator.java b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MbeanServerLocator.java index 858bea5ee3..5e48c0c0c1 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MbeanServerLocator.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/MbeanServerLocator.java @@ -22,8 +22,9 @@ /** * @author Pedro Henrique Oliveira dos Santos - * + * */ -public interface MbeanServerLocator extends Serializable { - MBeanServer get(); +public interface MbeanServerLocator extends Serializable +{ + MBeanServer get(); } \ No newline at end of file diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/ObjectViewPanel.java b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/ObjectViewPanel.java index d14f8ef2bd..d3c24090be 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/ObjectViewPanel.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/ObjectViewPanel.java @@ -29,38 +29,47 @@ * @author Pedro Henrique Oliveira dos Santos * */ -public class ObjectViewPanel extends Panel { - public static class PropValue implements Serializable { +public class ObjectViewPanel extends Panel +{ + public static class PropValue implements Serializable + { String property; Object value; } - public ObjectViewPanel(String id, Object object) { + public ObjectViewPanel(String id, Object object) + { super(id); add(new Label("className", object.getClass().getName())); add(new Label("toString", object.toString())); ArrayList properties = new ArrayList(); Method[] methods = object.getClass().getMethods(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().startsWith("get") - && methods[i].getParameterTypes().length == 0) { + for (int i = 0; i < methods.length; i++) + { + if (methods[i].getName().startsWith("get") && + methods[i].getParameterTypes().length == 0) + { PropValue prop = new PropValue(); - try { + try + { prop.property = methods[i].getName(); - prop.value = methods[i].invoke(object, (Object[]) null); - } catch (Exception e) { + prop.value = methods[i].invoke(object, (Object[])null); + } + catch (Exception e) + { e.printStackTrace(); } properties.add(prop); } } - add(new ListView("properties", properties) { + add(new ListView("properties", properties) + { @Override - protected void populateItem(ListItem item) { + protected void populateItem(ListItem item) + { item.add(new Label("property", item.getModelObject().property)); - item.add(new Label("value", - item.getModelObject().value == null ? null : item - .getModelObject().value.toString())); + item.add(new Label("value", item.getModelObject().value == null ? null + : item.getModelObject().value.toString())); } }); } diff --git a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/OperationsPanel.java b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/OperationsPanel.java index 1e7b235be4..418e8a2477 100644 --- a/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/OperationsPanel.java +++ b/jdk-1.5-parent/mbeanview-parent/mbeanview/src/main/java/org/wicketstuff/mbeanview/OperationsPanel.java @@ -55,7 +55,7 @@ public class OperationsPanel extends Panel private ModalWindow modalOutput; public OperationsPanel(String id, final ObjectName objectName, - MBeanOperationInfo[] beanOperationInfos, final MbeanServerLocator beanServerLocator) + MBeanOperationInfo[] beanOperationInfos, final MbeanServerLocator beanServerLocator) { super(id); this.beanServerLocator = beanServerLocator; @@ -89,7 +89,7 @@ protected void populateItem(final ListItem item) } item.add(new Label("return", returnLbl)); final ParameterRepeater parameterRepeater = new ParameterRepeater("parameters", - info.getSignature()); + info.getSignature()); item.add(parameterRepeater); final FeedbackPanel feedback = new ComponentFeedbackPanel("feedback", item); feedback.setOutputMarkupId(true); @@ -133,7 +133,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) try { returnObj = beanServerLocator.get().invoke(objectName, info.getName(), - parameterRepeater.getParams(), parameterRepeater.getSignatures()); + parameterRepeater.getParams(), parameterRepeater.getSignatures()); onSuccessful(returnObj, target); } catch (Exception e) @@ -157,7 +157,7 @@ protected void onSubmit(AjaxRequestTarget target, Form form) @Override protected void onError(AjaxRequestTarget target, Form form) { - + } } @@ -189,8 +189,9 @@ public Object[] getParams() { try { - params[i] = DataUtil.getCompatibleData(parametersValues.get( - beanParameterInfos[i]).getObject(), beanParameterInfos[i]); + params[i] = DataUtil.getCompatibleData( + parametersValues.get(beanParameterInfos[i]).getObject(), + beanParameterInfos[i]); } catch (ClassNotFoundException e) { diff --git a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/HomePage.java b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/HomePage.java index c7b95a3310..7879ed853c 100644 --- a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/HomePage.java +++ b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/HomePage.java @@ -6,7 +6,8 @@ /** * Homepage */ -public class HomePage extends WebPage { +public class HomePage extends WebPage +{ private static final long serialVersionUID = 1L; @@ -18,7 +19,8 @@ public class HomePage extends WebPage { * @param parameters * Page parameters */ - public HomePage(final PageParameters parameters) { + public HomePage(final PageParameters parameters) + { } } diff --git a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/ListViewFormComponentReuseManagerPage.java b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/ListViewFormComponentReuseManagerPage.java index b76764b8c2..74cd67e1a2 100644 --- a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/ListViewFormComponentReuseManagerPage.java +++ b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/ListViewFormComponentReuseManagerPage.java @@ -75,7 +75,7 @@ public void onSubmit() public void onClick() { IRequestHandler handler = new TableComponentAsXlsHandler(form.get("rowsList"), - "example.xls"); + "example.xls"); RequestCycle.get().scheduleRequestHandlerAfterCurrent(handler); } }); @@ -95,9 +95,9 @@ public Integer getObject() } })); ListViewFormComponentReuseManager.addOrReuse(item, new RequiredTextField( - "key", new PropertyModel(row, "key"))); + "key", new PropertyModel(row, "key"))); ListViewFormComponentReuseManager.addOrReuse(item, new TextField("value", - new PropertyModel(row, "value"))); + new PropertyModel(row, "value"))); item.add(new SubmitLink("removeRowLink") { diff --git a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/MooTipPage.java b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/MooTipPage.java index 1452a87746..37278a3b8e 100644 --- a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/MooTipPage.java +++ b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/MooTipPage.java @@ -10,7 +10,8 @@ /** * Homepage */ -public class MooTipPage extends HomePage { +public class MooTipPage extends HomePage +{ private static final long serialVersionUID = 1L; @@ -22,26 +23,25 @@ public class MooTipPage extends HomePage { * @param parameters * Page parameters */ - public MooTipPage(final PageParameters parameters) { + public MooTipPage(final PageParameters parameters) + { super(parameters); // Add the simplest type of label - add(new Label("tooltip01", "this is tool tip 01") - .add(new MootipBehaviour( - "This is my tool tip", - "I can be very long and even have formatting like
          and be strong"))); + add(new Label("tooltip01", "this is tool tip 01").add(new MootipBehaviour( + "This is my tool tip", + "I can be very long and even have formatting like
          and be strong"))); + + // add mootippanelajaxplaceholder: - //add mootippanelajaxplaceholder: - add(new MootipPanel()); - - - MootipSettings mooSettings=new MootipSettings(); + + + MootipSettings mooSettings = new MootipSettings(); mooSettings.setEvalAlways(true); - MootipBehaviour behaviour=new MootipBehaviour(new MooPanel()); + MootipBehaviour behaviour = new MootipBehaviour(new MooPanel()); behaviour.setMootipSettings(mooSettings); - - add(new Label("tooltip02", "this is tool tip 02") - .add(behaviour)); + + add(new Label("tooltip02", "this is tool tip 02").add(behaviour)); } } diff --git a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/WicketApplication.java b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/WicketApplication.java index 9c1dfe23ee..c0b618b440 100644 --- a/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/WicketApplication.java +++ b/jdk-1.5-parent/minis-parent/minis-examples/src/main/java/org/wicketstuff/minis/WicketApplication.java @@ -3,19 +3,20 @@ 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. + * Application object for your web application. If you want to run this application without + * deploying, run the Start class. * * @see org.wicketstuff.minis.Start#main(String[]) */ public class WicketApplication extends WebApplication -{ - /** - * Constructor - */ +{ + /** + * Constructor + */ public WicketApplication() { } - + /** * @see org.apache.wicket.Application#getHomePage() */ diff --git a/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/Start.java b/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/Start.java index b2b4c58868..eee8e57f07 100644 --- a/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/Start.java +++ b/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/Start.java @@ -5,9 +5,11 @@ import org.eclipse.jetty.server.bio.SocketConnector; import org.eclipse.jetty.webapp.WebAppContext; -public class Start { +public class Start +{ - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception + { Server server = new Server(); SocketConnector connector = new SocketConnector(); // Set some timeout options to make debugging easier. @@ -21,24 +23,28 @@ public static void main(String[] args) throws Exception { bb.setContextPath("/"); bb.setWar("src/main/webapp"); - + // START JMX SERVER // MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); // MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); // server.getContainer().addEventListener(mBeanContainer); // mBeanContainer.start(); - + server.setHandler(bb); - try { + try + { System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP"); server.start(); - while (System.in.available() == 0) { + while (System.in.available() == 0) + { Thread.sleep(5000); } server.stop(); server.join(); - } catch (Exception e) { + } + catch (Exception e) + { e.printStackTrace(); System.exit(100); } diff --git a/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/TestHomePage.java b/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/TestHomePage.java index 2defbda48e..237b71ddc3 100644 --- a/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/TestHomePage.java +++ b/jdk-1.5-parent/minis-parent/minis-examples/src/test/java/org/wicketstuff/minis/TestHomePage.java @@ -19,13 +19,14 @@ public void setUp() public void testRenderMyPage() { - //start and render the test page + // start and render the test page tester.startPage(HomePage.class); - //assert rendered page class + // assert rendered page class tester.assertRenderedPage(HomePage.class); - //assert rendered label component - tester.assertLabel("message", "If you see this message wicket is properly configured and running"); + // assert rendered label component + tester.assertLabel("message", + "If you see this message wicket is properly configured and running"); } } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayout.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayout.java index f00ddb03e5..26225c69ec 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayout.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayout.java @@ -37,9 +37,8 @@ */ public class GridLayout implements ILayout { - private static class GridConstraintIterator - implements - Iterator> + private static class GridConstraintIterator implements + Iterator> { private final Iterator> iterator; private int currentRow = 0; diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayoutConstraint.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayoutConstraint.java index f81c4a8cbb..d6900c03f4 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayoutConstraint.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/GridLayoutConstraint.java @@ -17,12 +17,11 @@ package org.wicketstuff.minis.behavior.apanel; /** - * Specifies position of a component for {@link org.wicketstuff.minis.behavior.apanel.GridLayout} and - * optionally column/row span. + * Specifies position of a component for {@link org.wicketstuff.minis.behavior.apanel.GridLayout} + * and optionally column/row span. */ -public class GridLayoutConstraint extends ConstraintBehavior - implements - Comparable +public class GridLayoutConstraint extends ConstraintBehavior implements + Comparable { private static final long serialVersionUID = 1L; diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/IComponentRenderer.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/IComponentRenderer.java index fcce60ea4f..c86d29127c 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/IComponentRenderer.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/IComponentRenderer.java @@ -25,9 +25,10 @@ public interface IComponentRenderer extends Serializable { /** * Creates wicket markup for a specified component. - * - * @param component component (generic parameter is used only - * for convenience of this method implementation) + * + * @param component + * component (generic parameter is used only for convenience of this method + * implementation) * @return wicket markup */ CharSequence getMarkup(T component); diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/RenderersList.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/RenderersList.java index 75528b0052..2e2c23c607 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/RenderersList.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/apanel/RenderersList.java @@ -291,7 +291,8 @@ public RenderersList(final List> renderers) * * @param aClass * class of the component - * @return {@link org.wicketstuff.minis.behavior.apanel.IComponentRenderer} for specified component class + * @return {@link org.wicketstuff.minis.behavior.apanel.IComponentRenderer} for specified + * component class */ @SuppressWarnings({ "unchecked" }) IComponentRenderer findRendererForClass(final Class aClass) diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/AbstractImageDimensionProvider.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/AbstractImageDimensionProvider.java index fe03d044d5..974026e2b9 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/AbstractImageDimensionProvider.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/AbstractImageDimensionProvider.java @@ -6,19 +6,18 @@ /** *

          - * This behavior can be added to {@link Image} components to render width and - * height attributes in the markup. The exact way to retrieve the dimension - * information is left for the subclasses. + * This behavior can be added to {@link Image} components to render width and height attributes in + * the markup. The exact way to retrieve the dimension information is left for the subclasses. *

          - * + * *

          - * Providing dimension information for elements makes page rendering - * faster. + * Providing dimension information for elements makes page rendering faster. *

          - * + * * @author akiraly */ -public abstract class AbstractImageDimensionProvider extends Behavior { +public abstract class AbstractImageDimensionProvider extends Behavior +{ private static final long serialVersionUID = 2659926396935426159L; /** @@ -33,20 +32,21 @@ public abstract class AbstractImageDimensionProvider extends Behavior { /** * Getter. - * + * * @return the width of the image */ public abstract String getWidth(); /** * Getter. - * + * * @return the height of the image */ public abstract String getHeight(); @Override - public void onComponentTag(Component component, ComponentTag tag) { + public void onComponentTag(Component component, ComponentTag tag) + { super.onComponentTag(component, tag); tag.put(WIDTH, getWidth()); diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/ImageDimensionProvider.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/ImageDimensionProvider.java index 7ea33a6925..835285e3d3 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/ImageDimensionProvider.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/image/ImageDimensionProvider.java @@ -1,12 +1,13 @@ package org.wicketstuff.minis.behavior.image; /** - * Static implementation of {@link AbstractImageDimensionProvider}. Width and - * height information is provided at object construction time. - * + * Static implementation of {@link AbstractImageDimensionProvider}. Width and height information is + * provided at object construction time. + * * @author akiraly */ -public class ImageDimensionProvider extends AbstractImageDimensionProvider { +public class ImageDimensionProvider extends AbstractImageDimensionProvider +{ private static final long serialVersionUID = -5997818865070010585L; private final String width; @@ -15,25 +16,28 @@ public class ImageDimensionProvider extends AbstractImageDimensionProvider { /** * Constructor. - * + * * @param width * width of the image * @param height * height of the image */ - public ImageDimensionProvider(String width, String height) { + public ImageDimensionProvider(String width, String height) + { super(); this.width = width; this.height = height; } @Override - public final String getWidth() { + public final String getWidth() + { return width; } @Override - public final String getHeight() { + public final String getHeight() + { return height; } } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/mootip/MootipBehaviour.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/mootip/MootipBehaviour.java index aa1fe95726..605165a2f8 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/mootip/MootipBehaviour.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/mootip/MootipBehaviour.java @@ -29,9 +29,9 @@ /** * Mootip behavior, implements integration with this http://www.uhleeka.com/dev/mootips/ - * + * * The component you add this behavior to will be the component which the tooltip appears for - * + * * @author nino.martinez @ jayway.dk */ public class MootipBehaviour extends Behavior @@ -59,7 +59,7 @@ public class MootipBehaviour extends Behavior /** * Ajax ToolTip, retrieves the panel with an ajax call. Requests the panel on each tooltip * display - * + * * @param panel */ public MootipBehaviour(final MootipPanel panel) @@ -71,7 +71,7 @@ public MootipBehaviour(final MootipPanel panel) /** * Ajax ToolTip, retrieves the panel with an ajax call. Requests the panel on each tooltip * display - * + * * @param panel */ public MootipBehaviour(final MootipPanel panel, final boolean contribute) @@ -84,7 +84,7 @@ public MootipBehaviour(final MootipPanel panel, final boolean contribute) /** * simple tooltip, using title as tool tip it uses this syntax for splitting * title='this will be title:this will be content' - * + * * @param title * @param content */ @@ -98,7 +98,7 @@ public MootipBehaviour(final String title, final String content) /** * simple tooltip, using title as tool tip it uses this syntax for splitting * title='this will be title:this will be content' - * + * * @param title * @param content */ @@ -156,7 +156,7 @@ private String generateJS(final TextTemplate textTemplate) /** * Gets the escaped DOM id that the input will get attached to. All non word characters (\W) * will be removed from the string. - * + * * @return The DOM id of the input - same as the component's markup id} */ protected final String getEscapedComponentMarkupId() @@ -171,9 +171,9 @@ public boolean isAjax() /** * Add the required css and js files to the page - * + * * Also add the javascript to create the tooltip - * + * * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse) */ @Override diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/JS_TYPE.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/JS_TYPE.java index 07af9acd2e..b406edb71b 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/JS_TYPE.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/JS_TYPE.java @@ -21,6 +21,7 @@ * * @author Richard Wilkinson */ -public enum JS_TYPE { +public enum JS_TYPE +{ NORMAL, MIN } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipBehaviour.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipBehaviour.java index 2dd70938d1..8e3f17d4c5 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipBehaviour.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipBehaviour.java @@ -31,7 +31,7 @@ * * * @author Richard Wilkinson - * + * */ public class PrototipBehaviour extends Behavior { @@ -46,13 +46,14 @@ public class PrototipBehaviour extends Behavior protected boolean onLoad = true; /** - * Made this static as it is very unlikely that you would want different versions of prototip.js across your site + * Made this static as it is very unlikely that you would want different versions of prototip.js + * across your site */ protected static JS_TYPE selectedJsType = JS_TYPE.MIN; /** - * Default constructor - * If you use this then you must set either a string, or a component manually + * Default constructor If you use this then you must set either a string, or a component + * manually */ public PrototipBehaviour() { @@ -60,6 +61,7 @@ public PrototipBehaviour() /** * Provide a simple string as a tooltip + * * @param tooltip */ public PrototipBehaviour(String tooltip) @@ -69,26 +71,27 @@ public PrototipBehaviour(String tooltip) /** * Provide a component to show as the tool tip (eg a panel) + * * @param panel */ public PrototipBehaviour(Component panel) { - this.tooltipComponent = panel; + tooltipComponent = panel; panel.setOutputMarkupId(true); } /** - * Add the required css and js files to the page - * Permission to distribute prototip files given by prototip creator Nick Stakenburg (http://www.nickstakenburg.com) + * Add the required css and js files to the page Permission to distribute prototip files given + * by prototip creator Nick Stakenburg (http://www.nickstakenburg.com) * * Also add the javascript to create the tooltip * - * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse) + * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse) */ @Override public void renderHead(Component c, IHeaderResponse response) { - if(onLoad) + if (onLoad) { response.renderOnLoadJavaScript(toJavascript()); } @@ -96,40 +99,45 @@ public void renderHead(Component c, IHeaderResponse response) { response.renderOnDomReadyJavaScript(toJavascript()); } - if(!overrideHeaderContributor) + if (!overrideHeaderContributor) { - response.renderCSSReference(new CompressedResourceReference(PrototipBehaviour.class, "prototip.css"), "screen"); - switch(selectedJsType) + response.renderCSSReference(new CompressedResourceReference(PrototipBehaviour.class, + "prototip.css"), "screen"); + switch (selectedJsType) { - case NORMAL: - response.renderJavaScriptReference(new CompressedResourceReference(PrototipBehaviour.class, "prototip.js")); - break; - case MIN: - response.renderJavaScriptReference(new CompressedResourceReference(PrototipBehaviour.class, "prototip-min.js")); - break; + case NORMAL : + response.renderJavaScriptReference(new CompressedResourceReference( + PrototipBehaviour.class, "prototip.js")); + break; + case MIN : + response.renderJavaScriptReference(new CompressedResourceReference( + PrototipBehaviour.class, "prototip-min.js")); + break; } } } /** - * override bind so that the component you add this behavior to becomes the component the tooltip applies to + * override bind so that the component you add this behavior to becomes the component the + * tooltip applies to * */ @Override - public void bind(Component component) + public void bind(Component component) { super.bind(component); - this.source = component; + source = component; source.setOutputMarkupId(true); } /** * Given an ajax request target, remove this tip from the page + * * @param target */ - public void remove(AjaxRequestTarget target) + public void remove(AjaxRequestTarget target) { - if(source != null) + if (source != null) { StringBuilder removeJs = new StringBuilder(); removeJs.append("Tips.remove($('").append(source.getMarkupId()).append("'));"); @@ -139,9 +147,10 @@ public void remove(AjaxRequestTarget target) /** * Given an ajax request target, hide this tip on the page + * * @param target */ - public void hide(AjaxRequestTarget target ) + public void hide(AjaxRequestTarget target) { if (source != null) { @@ -153,25 +162,34 @@ public void hide(AjaxRequestTarget target ) /** * Get string to add the prototip to the page + * * @return the String */ protected String toJavascript() { StringBuilder script = new StringBuilder(); String optionString = null; - if(settings != null) + if (settings != null) { optionString = settings.getOptionsString(title); } - if(tooltip != null) + if (tooltip != null) { - script.append("new Tip($('").append(source.getMarkupId()).append("'),'").append(tooltip).append("'"); + script.append("new Tip($('") + .append(source.getMarkupId()) + .append("'),'") + .append(tooltip) + .append("'"); } else if (tooltipComponent != null) { - script.append("new Tip($('").append(source.getMarkupId()).append("'),$('").append(tooltipComponent.getMarkupId()).append("')"); + script.append("new Tip($('") + .append(source.getMarkupId()) + .append("'),$('") + .append(tooltipComponent.getMarkupId()) + .append("')"); } - if(optionString != null && !optionString.equals("")) + if (optionString != null && !optionString.equals("")) { script.append(", ").append(optionString); } @@ -182,15 +200,18 @@ else if (tooltipComponent != null) /** * @return the source */ - public Component getSource() { + public Component getSource() + { return source; } /** - * @param source the source to set + * @param source + * the source to set * @return this object */ - public PrototipBehaviour setSource(Component source) { + public PrototipBehaviour setSource(Component source) + { this.source = source; return this; } @@ -198,15 +219,18 @@ public PrototipBehaviour setSource(Component source) { /** * @return the tooltip */ - public String getTooltip() { + public String getTooltip() + { return tooltip; } /** - * @param tooltip the tooltip to set + * @param tooltip + * the tooltip to set * @return this object */ - public PrototipBehaviour setTooltip(String tooltip) { + public PrototipBehaviour setTooltip(String tooltip) + { this.tooltip = tooltip; tooltipComponent = null; return this; @@ -215,15 +239,18 @@ public PrototipBehaviour setTooltip(String tooltip) { /** * @return the tooltip component */ - public Component getTooltipComponent() { + public Component getTooltipComponent() + { return tooltipComponent; } /** - * @param panel the panel to set + * @param panel + * the panel to set * @return this object */ - public PrototipBehaviour setTooltipComponent(Component tooltipComponent) { + public PrototipBehaviour setTooltipComponent(Component tooltipComponent) + { this.tooltipComponent = tooltipComponent; this.tooltipComponent.setOutputMarkupId(true); tooltip = null; @@ -233,15 +260,18 @@ public PrototipBehaviour setTooltipComponent(Component tooltipComponent) { /** * @return the settings */ - public PrototipSettings getSettings() { + public PrototipSettings getSettings() + { return settings; } /** - * @param settings the settings to set + * @param settings + * the settings to set * @return this object */ - public PrototipBehaviour setSettings(PrototipSettings settings) { + public PrototipBehaviour setSettings(PrototipSettings settings) + { this.settings = settings; return this; } @@ -249,16 +279,21 @@ public PrototipBehaviour setSettings(PrototipSettings settings) { /** * @return the overrideHeaderContributor */ - public boolean isOverrideHeaderContributor() { + public boolean isOverrideHeaderContributor() + { return overrideHeaderContributor; } /** - * If you do not want this behavour to add the required javascript and css files to the header set this to true (default false) - * @param overrideHeaderContributor the overrideHeaderContributor to set + * If you do not want this behavour to add the required javascript and css files to the header + * set this to true (default false) + * + * @param overrideHeaderContributor + * the overrideHeaderContributor to set * @return this object */ - public PrototipBehaviour setOverrideHeaderContributor(boolean overrideHeaderContributor) { + public PrototipBehaviour setOverrideHeaderContributor(boolean overrideHeaderContributor) + { this.overrideHeaderContributor = overrideHeaderContributor; return this; } @@ -272,7 +307,8 @@ public String getTitle() } /** - * @param title the title to set + * @param title + * the title to set * @return this object */ public PrototipBehaviour setTitle(String title) @@ -284,40 +320,46 @@ public PrototipBehaviour setTitle(String title) /** * @return the selectedJsType */ - public static JS_TYPE getSelectedJsType() { + public static JS_TYPE getSelectedJsType() + { return selectedJsType; } /** - * There are 3 different js files which can be included: - * a normal uncompressed one - * a minified one - * a minified and gziped one - * - * To override the default (the minified one) set this parameter - * - * This is a static method and as such affects all PrototipBehaviour in the system, - * this is so that you do not have to set the type for every PrototipBehaviour that you use (which is tedious) - * - * @param selectedJsType the selectedJsType to set + * There are 3 different js files which can be included: a normal uncompressed one a minified + * one a minified and gziped one + * + * To override the default (the minified one) set this parameter + * + * This is a static method and as such affects all PrototipBehaviour in the system, this is so + * that you do not have to set the type for every PrototipBehaviour that you use (which is + * tedious) + * + * @param selectedJsType + * the selectedJsType to set */ - public static void setSelectedJsType(JS_TYPE selectedJsType) { + public static void setSelectedJsType(JS_TYPE selectedJsType) + { PrototipBehaviour.selectedJsType = selectedJsType; } /** * Is the javascript set to load 'onload' if false then it will be 'ondomready' + * * @return */ - public boolean isOnLoad() { + public boolean isOnLoad() + { return onLoad; } /** * Is the javascript set to load 'onload' if false then it will be 'ondomready' + * * @param onLoad */ - public void setOnLoad(boolean onLoad) { + public void setOnLoad(boolean onLoad) + { this.onLoad = onLoad; } } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipSettings.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipSettings.java index 106a8a88f0..6317add640 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipSettings.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/prototip/PrototipSettings.java @@ -19,22 +19,24 @@ import java.io.Serializable; /** - * This is a class for creating settings to be used with the prototip lib (the optional third argument) + * This is a class for creating settings to be used with the prototip lib (the optional third + * argument) * * in all cases you do not need to worry about enclosing your strings in ' ' * - * There is logic in place so that if you enter false or true (ie the boolean), or a number - * it will not enclose your string in '', where as any other string it will + * There is logic in place so that if you enter false or true (ie the boolean), or a number it will + * not enclose your string in '', where as any other string it will * - * see http://www.nickstakenburg.com/projects/prototip/ for a better description of the options that prototip uses + * see http://www.nickstakenburg.com/projects/prototip/ for a better description of the options that + * prototip uses * * @author Richard Wilkinson - * + * */ public class PrototipSettings implements Serializable { private static final long serialVersionUID = 1L; - + private String className; private String closeButton; private String duration; @@ -51,7 +53,7 @@ public class PrototipSettings implements Serializable private String viewpoint; private String extraOptions; private String fixed; - + /** * Generates the correct Javascript code to add as the third parameter to a prototip tooltip * @@ -64,157 +66,195 @@ public class PrototipSettings implements Serializable public String getOptionsString(String title) { StringBuilder options = new StringBuilder(); - if(className != null) + if (className != null) { options.append("className").append(": ").append(className); } - if(closeButton != null) + if (closeButton != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("closeButton").append(":").append(closeButton); } - if(duration != null) + if (duration != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("duration").append(":").append(duration); } - if(delay != null) + if (delay != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("delay").append(":").append(delay); } - if(effect != null) + if (effect != null) { - if(options.length() > 0) options.append(", "); - options.append("effect").append(": ").append(effect);; + if (options.length() > 0) + options.append(", "); + options.append("effect").append(": ").append(effect); + ; } - if(hideAfter != null) + if (hideAfter != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("hideAfter").append(":").append(hideAfter); } - if(hideOn != null) + if (hideOn != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("hideOn").append(":").append(hideOn); } - if(hook != null) + if (hook != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("hook").append(":").append(hook); } - if(offset_x != null && offset_y != null) + if (offset_x != null && offset_y != null) { - if(options.length() > 0) options.append(", "); - options.append("offset").append(": { x:").append(offset_x).append(", y: ").append(offset_y).append("}"); + if (options.length() > 0) + options.append(", "); + options.append("offset") + .append(": { x:") + .append(offset_x) + .append(", y: ") + .append(offset_y) + .append("}"); } - if(showOn != null) + if (showOn != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("showOn").append(": ").append(showOn); } - if(target != null) + if (target != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("target").append(": ").append(target); } - if(title != null) + if (title != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("title").append(": '").append(title).append("'"); } - else if(this.title != null) + else if (this.title != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("title").append(": ").append(this.title); } - if(viewpoint != null) + if (viewpoint != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("viewpoint").append(":").append(viewpoint); } - if(fixed != null) + if (fixed != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append("fixed").append(":").append(fixed); } - if(extraOptions != null) + if (extraOptions != null) { - if(options.length() > 0) options.append(", "); + if (options.length() > 0) + options.append(", "); options.append(extraOptions); } - if(options.length() > 0) + if (options.length() > 0) { options.insert(0, "{ "); options.append(" }"); } - + return options.toString(); } - + /** * @return the className */ - public String getClassName() { + public String getClassName() + { return className; } + /** * you do not need to include the ' ' * - * @param className the className to set + * @param className + * the className to set * @return this */ - public PrototipSettings setClassName(String className) { + public PrototipSettings setClassName(String className) + { this.className = "'" + className + "'"; return this; } + /** * @return the closeButton */ - public String getCloseButton() { + public String getCloseButton() + { return closeButton; } + /** * either false or true * - * @param closeButton the closeButton to set + * @param closeButton + * the closeButton to set * @return this */ - public PrototipSettings setCloseButton(String closeButton) { + public PrototipSettings setCloseButton(String closeButton) + { this.closeButton = closeButton; return this; } + /** * @return the duration */ - public String getDuration() { + public String getDuration() + { return duration; } + /** - * duration of the effect, if used - * eg 0.3 + * duration of the effect, if used eg 0.3 * - * @param duration the duration to set + * @param duration + * the duration to set * @return this */ - public PrototipSettings setDuration(String duration) { + public PrototipSettings setDuration(String duration) + { this.duration = duration; return this; } + /** * @return the fixed */ - public String getFixed() { + public String getFixed() + { return fixed; } /** * eg false or true * - * @param fixed the fixed to set + * @param fixed + * the fixed to set * @return this */ - public PrototipSettings setFixed(String fixed) { + public PrototipSettings setFixed(String fixed) + { this.fixed = fixed; return this; } @@ -222,158 +262,201 @@ public PrototipSettings setFixed(String fixed) { /** * @return the delay */ - public String getDelay() { + public String getDelay() + { return delay; } + /** - * seconds before tooltip appears - * eg 0.2 + * seconds before tooltip appears eg 0.2 * - * @param delay the delay to set + * @param delay + * the delay to set * @return this */ - public PrototipSettings setDelay(String delay) { + public PrototipSettings setDelay(String delay) + { this.delay = delay; return this; } + /** * @return the effect */ - public String getEffect() { + public String getEffect() + { return effect; } + /** * you do not need to include the ' ' * * false, appear or blind, or others if they get enabled * - * @param effect the effect to set + * @param effect + * the effect to set * @return this */ public PrototipSettings setEffect(String effect) { - if(!effect.equals("false")) + if (!effect.equals("false")) { effect = "'" + effect + "'"; } this.effect = effect; return this; } + /** * @return the hideAfter */ - public String getHideAfter() { + public String getHideAfter() + { return hideAfter; } + /** * false or a number eg 1.5 * - * @param hideAfter the hideAfter to set + * @param hideAfter + * the hideAfter to set * @return this */ - public PrototipSettings setHideAfter(String hideAfter) { + public PrototipSettings setHideAfter(String hideAfter) + { this.hideAfter = hideAfter; return this; } + /** * @return the hideOn */ - public String getHideOn() { + public String getHideOn() + { return hideOn; } + /** * any event eg mouseout or false * - * @param hideOn the hideOn to set + * @param hideOn + * the hideOn to set * @return this */ - public PrototipSettings setHideOn(String hideOn) { - if(!hideOn.equals("false")) + public PrototipSettings setHideOn(String hideOn) + { + if (!hideOn.equals("false")) { hideOn = "'" + hideOn + "'"; } this.hideOn = hideOn; return this; } + /** - * eg: - * { element: 'element|target|tip|closeButton|.close', - * event: 'click|mouseover|mousemove' } + * eg: { element: 'element|target|tip|closeButton|.close', event: 'click|mouseover|mousemove' } * * @param element * @param event * @return this */ - public PrototipSettings setHideOn(String element, String event) { - this.hideOn = new StringBuilder("{ ").append("element: '").append(element).append("', event: '") - .append(event).append("' }").toString(); + public PrototipSettings setHideOn(String element, String event) + { + hideOn = new StringBuilder("{ ").append("element: '") + .append(element) + .append("', event: '") + .append(event) + .append("' }") + .toString(); return this; } + /** * @return the hook */ - public String getHook() { + public String getHook() + { return hook; } + /** - * @param hook the hook to set + * @param hook + * the hook to set * @return this */ - public PrototipSettings setHookFalse() { - this.hook = "false"; + public PrototipSettings setHookFalse() + { + hook = "false"; return this; } + /** - * Set the hook, where you want + * Set the hook, where you want * * eg: * * { target: 'topLeft|topRight|bottomLeft|bottomRight| - * topMiddle|bottomMiddle|leftMiddle|rightMiddle', - * tip: 'topLeft|topRight|bottomLeft|bottomRight| - * topMiddle|bottomMiddle|leftMiddle|rightMiddle' } - * - * for false use setHookFalse() + * topMiddle|bottomMiddle|leftMiddle|rightMiddle', tip: + * 'topLeft|topRight|bottomLeft|bottomRight| topMiddle|bottomMiddle|leftMiddle|rightMiddle' } + * + * for false use setHookFalse() * * @param target * @param tip * @return this */ - public PrototipSettings setHook(String target, String tip) { - this.hook = new StringBuilder("{ ").append("target: '").append(target).append("', tip: '") - .append(tip).append("' }").toString(); + public PrototipSettings setHook(String target, String tip) + { + hook = new StringBuilder("{ ").append("target: '") + .append(target) + .append("', tip: '") + .append(tip) + .append("' }") + .toString(); return this; } + /** * @return the offset_x */ - public String getOffset_x() { + public String getOffset_x() + { return offset_x; } + /** - * @param offset_x the offset_x to set + * @param offset_x + * the offset_x to set * @return this */ - public PrototipSettings setOffset_x(String offset_x) { + public PrototipSettings setOffset_x(String offset_x) + { this.offset_x = offset_x; return this; } + /** * @return the offset_y */ - public String getOffset_y() { + public String getOffset_y() + { return offset_y; } + /** - * @param offset_y the offset_y to set + * @param offset_y + * the offset_y to set * @return this */ - public PrototipSettings setOffset_y(String offset_y) { + public PrototipSettings setOffset_y(String offset_y) + { this.offset_y = offset_y; return this; } + /** * Set both x and y offsets + * * @param offset_x * @param offset_y * @return this @@ -384,62 +467,82 @@ public PrototipSettings setOffset(String offset_x, String offset_y) this.offset_y = offset_y; return this; } + /** * @return the showOn */ - public String getShowOn() { + public String getShowOn() + { return showOn; } + /** - * @param showOn the showOn to set + * @param showOn + * the showOn to set * @return this */ - public PrototipSettings setShowOn(String showOn) { + public PrototipSettings setShowOn(String showOn) + { this.showOn = "'" + showOn + "'"; return this; } + /** * @return the target */ - public String getTarget() { + public String getTarget() + { return target; } + /** - * @param target the target to set + * @param target + * the target to set * @return this */ - public PrototipSettings setTarget(String target) { + public PrototipSettings setTarget(String target) + { this.target = "'" + target + "'"; return this; } + /** * @return the title */ - public String getTitle() { + public String getTitle() + { return title; } + /** - * @param title the title to set + * @param title + * the title to set */ - public PrototipSettings setTitle(String title) { - if(!title.equals("false")) + public PrototipSettings setTitle(String title) + { + if (!title.equals("false")) { title = "'" + title + "'"; } this.title = title; return this; } + /** * @return the viewpoint */ - public String getViewpoint() { + public String getViewpoint() + { return viewpoint; } + /** - * @param viewpoint the viewpoint to set + * @param viewpoint + * the viewpoint to set * @return this */ - public PrototipSettings setViewpoint(String viewpoint) { + public PrototipSettings setViewpoint(String viewpoint) + { this.viewpoint = viewpoint; return this; } @@ -447,146 +550,180 @@ public PrototipSettings setViewpoint(String viewpoint) { /** * @return the extraOptions */ - public String getExtraOptions() { + public String getExtraOptions() + { return extraOptions; } /** - * Futureproofing - this allows you at add any string as an option (note you will need to take care of ' and { } yourself + * Futureproofing - this allows you at add any string as an option (note you will need to take + * care of ' and { } yourself * - * @param extraOptions the extraOptions to set + * @param extraOptions + * the extraOptions to set * @return this */ - public PrototipSettings setExtraOptions(String extraOptions) { + public PrototipSettings setExtraOptions(String extraOptions) + { this.extraOptions = extraOptions; return this; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#hashCode() */ @Override - public int hashCode() { + public int hashCode() + { final int prime = 31; int result = 1; - result = prime * result - + ((className == null) ? 0 : className.hashCode()); - result = prime * result - + ((closeButton == null) ? 0 : closeButton.hashCode()); + result = prime * result + ((className == null) ? 0 : className.hashCode()); + result = prime * result + ((closeButton == null) ? 0 : closeButton.hashCode()); result = prime * result + ((delay == null) ? 0 : delay.hashCode()); - result = prime * result - + ((duration == null) ? 0 : duration.hashCode()); + result = prime * result + ((duration == null) ? 0 : duration.hashCode()); result = prime * result + ((effect == null) ? 0 : effect.hashCode()); - result = prime * result - + ((extraOptions == null) ? 0 : extraOptions.hashCode()); + result = prime * result + ((extraOptions == null) ? 0 : extraOptions.hashCode()); result = prime * result + ((fixed == null) ? 0 : fixed.hashCode()); - result = prime * result - + ((hideAfter == null) ? 0 : hideAfter.hashCode()); + result = prime * result + ((hideAfter == null) ? 0 : hideAfter.hashCode()); result = prime * result + ((hideOn == null) ? 0 : hideOn.hashCode()); result = prime * result + ((hook == null) ? 0 : hook.hashCode()); - result = prime * result - + ((offset_x == null) ? 0 : offset_x.hashCode()); - result = prime * result - + ((offset_y == null) ? 0 : offset_y.hashCode()); + result = prime * result + ((offset_x == null) ? 0 : offset_x.hashCode()); + result = prime * result + ((offset_y == null) ? 0 : offset_y.hashCode()); result = prime * result + ((showOn == null) ? 0 : showOn.hashCode()); result = prime * result + ((target == null) ? 0 : target.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); - result = prime * result - + ((viewpoint == null) ? 0 : viewpoint.hashCode()); + result = prime * result + ((viewpoint == null) ? 0 : viewpoint.hashCode()); return result; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#equals(java.lang.Object) */ @Override - public boolean equals(Object obj) { + public boolean equals(Object obj) + { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; - final PrototipSettings other = (PrototipSettings) obj; - if (className == null) { + final PrototipSettings other = (PrototipSettings)obj; + if (className == null) + { if (other.className != null) return false; - } else if (!className.equals(other.className)) + } + else if (!className.equals(other.className)) return false; - if (closeButton == null) { + if (closeButton == null) + { if (other.closeButton != null) return false; - } else if (!closeButton.equals(other.closeButton)) + } + else if (!closeButton.equals(other.closeButton)) return false; - if (delay == null) { + if (delay == null) + { if (other.delay != null) return false; - } else if (!delay.equals(other.delay)) + } + else if (!delay.equals(other.delay)) return false; - if (duration == null) { + if (duration == null) + { if (other.duration != null) return false; - } else if (!duration.equals(other.duration)) + } + else if (!duration.equals(other.duration)) return false; - if (effect == null) { + if (effect == null) + { if (other.effect != null) return false; - } else if (!effect.equals(other.effect)) + } + else if (!effect.equals(other.effect)) return false; - if (extraOptions == null) { + if (extraOptions == null) + { if (other.extraOptions != null) return false; - } else if (!extraOptions.equals(other.extraOptions)) + } + else if (!extraOptions.equals(other.extraOptions)) return false; - if (fixed == null) { + if (fixed == null) + { if (other.fixed != null) return false; - } else if (!fixed.equals(other.fixed)) + } + else if (!fixed.equals(other.fixed)) return false; - if (hideAfter == null) { + if (hideAfter == null) + { if (other.hideAfter != null) return false; - } else if (!hideAfter.equals(other.hideAfter)) + } + else if (!hideAfter.equals(other.hideAfter)) return false; - if (hideOn == null) { + if (hideOn == null) + { if (other.hideOn != null) return false; - } else if (!hideOn.equals(other.hideOn)) + } + else if (!hideOn.equals(other.hideOn)) return false; - if (hook == null) { + if (hook == null) + { if (other.hook != null) return false; - } else if (!hook.equals(other.hook)) + } + else if (!hook.equals(other.hook)) return false; - if (offset_x == null) { + if (offset_x == null) + { if (other.offset_x != null) return false; - } else if (!offset_x.equals(other.offset_x)) + } + else if (!offset_x.equals(other.offset_x)) return false; - if (offset_y == null) { + if (offset_y == null) + { if (other.offset_y != null) return false; - } else if (!offset_y.equals(other.offset_y)) + } + else if (!offset_y.equals(other.offset_y)) return false; - if (showOn == null) { + if (showOn == null) + { if (other.showOn != null) return false; - } else if (!showOn.equals(other.showOn)) + } + else if (!showOn.equals(other.showOn)) return false; - if (target == null) { + if (target == null) + { if (other.target != null) return false; - } else if (!target.equals(other.target)) + } + else if (!target.equals(other.target)) return false; - if (title == null) { + if (title == null) + { if (other.title != null) return false; - } else if (!title.equals(other.title)) + } + else if (!title.equals(other.title)) return false; - if (viewpoint == null) { + if (viewpoint == null) + { if (other.viewpoint != null) return false; - } else if (!viewpoint.equals(other.viewpoint)) + } + else if (!viewpoint.equals(other.viewpoint)) return false; return true; } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/reflection/ReflectionBehavior.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/reflection/ReflectionBehavior.java index 868ec5786a..88aedb5799 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/reflection/ReflectionBehavior.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/behavior/reflection/ReflectionBehavior.java @@ -28,23 +28,23 @@ import org.apache.wicket.util.string.AppendingStringBuffer; /** - * Behavior for adding reflections to an image. Uses reflection.js (v1.6), - * licensed under a MIT license. + * Behavior for adding reflections to an image. Uses reflection.js (v1.6), licensed under a MIT + * license. *

          - * Add this behavior to your image to generate a reflection. You can change the - * height and opacity of the reflection using the provided setters. + * Add this behavior to your image to generate a reflection. You can change the height and opacity + * of the reflection using the provided setters. *

          - * Ultimately the markup you attach this behavior to must be an image, but it - * need not be a Wicket {@link Image} component, a markup container will - * suffice, provided the tag is an img-tag. + * Ultimately the markup you attach this behavior to must be an image, but it need not be a Wicket + * {@link Image} component, a markup container will suffice, provided the tag is an img-tag. *

          - * You can also use this class to generate add and remove reflection scriptlets - * for use in Ajax request targets or any other place you want. All you need to - * do is ensure the reflection.js is added to the head of the document. You can - * use the {@link #REFLECTION_JS} resource reference for that. + * You can also use this class to generate add and remove reflection scriptlets for use in Ajax + * request targets or any other place you want. All you need to do is ensure the reflection.js is + * added to the head of the document. You can use the {@link #REFLECTION_JS} resource reference for + * that. *

          * The reflection.js library and more documentation can be found here http://cow.neondragon.net/stuff/reflection/ + * href="http://cow.neondragon.net/stuff/reflection/" + * >http://cow.neondragon.net/stuff/reflection/ * * @author Martijn Dashorst */ diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanel.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanel.java index fd78f570d2..90ac17bcc0 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanel.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanel.java @@ -5,45 +5,48 @@ /** *

          - * A simple {@link FeedbackPanel} variant which is only visible if there are - * messages attached to it. + * A simple {@link FeedbackPanel} variant which is only visible if there are messages attached to + * it. *

          - * + * *

          - * Useful if your designer is putting always visible elements (like border, sign - * image) on your feedback panels. + * Useful if your designer is putting always visible elements (like border, sign image) on your + * feedback panels. *

          - * + * * @author akiraly */ -public class DefaultInvisibleFeedbackPanel extends FeedbackPanel { +public class DefaultInvisibleFeedbackPanel extends FeedbackPanel +{ private static final long serialVersionUID = -7309405061061951309L; /** * Constructor. Delegates to super. - * + * * @param id * not-null id of this component * @param filter * used to filter messages relevant for this panel, can be null */ - public DefaultInvisibleFeedbackPanel(String id, - IFeedbackMessageFilter filter) { + public DefaultInvisibleFeedbackPanel(String id, IFeedbackMessageFilter filter) + { super(id, filter); } /** * Constructor. Delegates to super. - * + * * @param id * not-null id of this component */ - public DefaultInvisibleFeedbackPanel(String id) { + public DefaultInvisibleFeedbackPanel(String id) + { super(id); } @Override - protected void onConfigure() { + protected void onConfigure() + { super.onConfigure(); setVisible(anyMessage()); } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/CellExporter.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/CellExporter.java index ff891041d5..bfdf750856 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/CellExporter.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/CellExporter.java @@ -24,9 +24,9 @@ import org.apache.wicket.markup.parser.XmlTag; /** - * Function interface to access the component table data and set in the - * {@link Cell}. A general purpose one is provided, but it can be customized by - * setting {@link TableComponentAsXlsHandler#setCellExporter(CellExporter)} + * Function interface to access the component table data and set in the {@link Cell}. A general + * purpose one is provided, but it can be customized by setting + * {@link TableComponentAsXlsHandler#setCellExporter(CellExporter)} * * @author Pedro Santos */ @@ -36,8 +36,7 @@ public interface CellExporter * @param tag * HTML tag * @param parser - * the {@link XmlPullParser} in use, can be useful to parse - * nested elements + * the {@link XmlPullParser} in use, can be useful to parse nested elements * @param cell * the target cell, where the value needs to be set * @param tableComponent @@ -45,5 +44,5 @@ public interface CellExporter * @throws ParseException */ public void exportCell(XmlTag tag, XmlPullParser parser, Cell cell, Component tableComponent) - throws ParseException; + throws ParseException; } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/GeneralPurposeExporter.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/GeneralPurposeExporter.java index 218d749d0e..50e826f1d0 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/GeneralPurposeExporter.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/GeneralPurposeExporter.java @@ -26,8 +26,8 @@ import org.apache.wicket.markup.parser.XmlTag; /** - * Fist try to get the most nested component in the table data tag, if not - * possible set the most nested value in markup as a {@link String}. + * Fist try to get the most nested component in the table data tag, if not possible set the most + * nested value in markup as a {@link String}. * * @author Pedro Santos */ @@ -35,7 +35,7 @@ public class GeneralPurposeExporter implements CellExporter { public void exportCell(XmlTag tag, XmlPullParser parser, Cell cell, Component gridComponent) - throws ParseException + throws ParseException { XmlTag firstMostNestedTag = tag; // find the most inner tag value @@ -50,12 +50,11 @@ public void exportCell(XmlTag tag, XmlPullParser parser, Cell cell, Component gr break; } } - CharSequence possibleComponentReference = firstMostNestedTag - .getAttribute(TableComponentAsXlsHandler.OutputPathBehavior.PATH_ATTRIBUTE); + CharSequence possibleComponentReference = firstMostNestedTag.getAttribute(TableComponentAsXlsHandler.OutputPathBehavior.PATH_ATTRIBUTE); if (possibleComponentReference != null) { Component firstMostNestedComponent = gridComponent.getPage().get( - possibleComponentReference.toString()); + possibleComponentReference.toString()); Object modelValue = firstMostNestedComponent.getDefaultModelObject(); if (modelValue != null) { @@ -93,8 +92,8 @@ else if (modelValue instanceof Date) { // simply set the first most nested tag value String value = parser.getInput( - firstMostNestedTag.getPos() + firstMostNestedTag.getLength(), tag.getPos()) - .toString(); + firstMostNestedTag.getPos() + firstMostNestedTag.getLength(), tag.getPos()) + .toString(); cell.setCellValue(value); } } diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/TableComponentAsXlsHandler.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/TableComponentAsXlsHandler.java index 7855a6d622..779e218e23 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/TableComponentAsXlsHandler.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/component/excel/TableComponentAsXlsHandler.java @@ -50,8 +50,7 @@ * Request handler that respond the specified table component as a XLS file. *

          *

          - * An possible {@link Link} onClick method implementation seting this handler - * could be: + * An possible {@link Link} onClick method implementation seting this handler could be: *

          * * public void onClick() {
          @@ -105,7 +104,7 @@ public void respond(IRequestCycle requestCycle) resource.setFileName(filename); resource.setContentDisposition(ContentDisposition.ATTACHMENT); IResource.Attributes a = new IResource.Attributes(requestCycle.getRequest(), - requestCycle.getResponse()); + requestCycle.getResponse()); resource.respond(a); } catch (Exception e) @@ -116,7 +115,7 @@ public void respond(IRequestCycle requestCycle) public void detach(IRequestCycle requestCycle) { - this.tableComponent = null; + tableComponent = null; } protected Sheet createSheet() @@ -130,7 +129,7 @@ public void setCellExporter(CellExporter cellExporter) } private final void parse(Sheet sheet) throws IOException, ResourceStreamNotFoundException, - ParseException + ParseException { try { @@ -152,7 +151,7 @@ private final void parse(Sheet sheet) throws IOException, ResourceStreamNotFound * @throws ParseException */ protected void parseImplementation(Sheet sheet, CharSequence gridComponentMarkup) - throws IOException, ResourceStreamNotFoundException, ParseException + throws IOException, ResourceStreamNotFoundException, ParseException { XmlPullParser parser = new XmlPullParser(); parser.parse(gridComponentMarkup); @@ -214,16 +213,16 @@ private void beforeParse() private void afterParse() { tableComponent.getPage().endComponentRender(tableComponent); - Application.get().getComponentPreOnBeforeRenderListeners() - .remove(PathSetupListener.INSTANCE); + Application.get() + .getComponentPreOnBeforeRenderListeners() + .remove(PathSetupListener.INSTANCE); RequestCycle.get().setResponse(originalResponse); originalResponse = null; mockResponse = null; } /** - * We try to maintain a relation between the HTML tag and its Wicket - * component. + * We try to maintain a relation between the HTML tag and its Wicket component. */ private static class PathSetupListener implements IComponentOnBeforeRenderListener { diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/IDetachCodec.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/IDetachCodec.java index 4fee248181..388d8c35bb 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/IDetachCodec.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/IDetachCodec.java @@ -19,10 +19,9 @@ import java.io.Serializable; /** - * A codec used to convert an object between its attached and detached - * representations. Detached representation should be something small so it is - * suitable for storage inside session. For example, in a database entity the - * detached state would be the primary key of that entity. + * A codec used to convert an object between its attached and detached representations. Detached + * representation should be something small so it is suitable for storage inside session. For + * example, in a database entity the detached state would be the primary key of that entity. * * @author Igor Vaynberg (ivaynberg) * @@ -39,13 +38,11 @@ public interface IDetachCodec Serializable detach(T object); /** - * Converts an object into its attached representation. Usually the returned - * object is equal to the object that was passed into - * {@link #detach(Object)} method to obtain the detached state. + * Converts an object into its attached representation. Usually the returned object is equal to + * the object that was passed into {@link #detach(Object)} method to obtain the detached state. * * @param detached - * detached representation obtained via a previous call to - * {@link #detach(Object)} + * detached representation obtained via a previous call to {@link #detach(Object)} * @return attached representation */ T attach(Serializable detached); diff --git a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/collection/AbstractDetachableCollection.java b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/collection/AbstractDetachableCollection.java index 3568fac503..5e7a6ef582 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/collection/AbstractDetachableCollection.java +++ b/jdk-1.5-parent/minis-parent/minis/src/main/java/org/wicketstuff/minis/model/collection/AbstractDetachableCollection.java @@ -81,11 +81,8 @@ * * @param */ -public abstract class AbstractDetachableCollection - implements - Collection, - IDetachable, - Serializable +public abstract class AbstractDetachableCollection implements Collection, IDetachable, + Serializable { private static final long serialVersionUID = 1L; diff --git a/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/apanel/TestGridLayoutConstraint.java b/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/apanel/TestGridLayoutConstraint.java index 858738477f..4d82833073 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/apanel/TestGridLayoutConstraint.java +++ b/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/apanel/TestGridLayoutConstraint.java @@ -24,7 +24,8 @@ public class TestGridLayoutConstraint @Test public void testContaining() { - final GridLayoutConstraint constraint = new GridLayoutConstraint(1, 1).setColSpan(3).setRowSpan(3); + final GridLayoutConstraint constraint = new GridLayoutConstraint(1, 1).setColSpan(3) + .setRowSpan(3); for (int col = 1; col < 4; col++) { for (int row = 1; row < 4; row++) @@ -41,7 +42,8 @@ public void testContaining() @Test public void testIntersection() { - final GridLayoutConstraint constraint = new GridLayoutConstraint(1, 1).setColSpan(3).setRowSpan(3); + final GridLayoutConstraint constraint = new GridLayoutConstraint(1, 1).setColSpan(3) + .setRowSpan(3); Assert.assertFalse(constraint.intersectsWith(new GridLayoutConstraint(0, 0))); Assert.assertTrue(constraint.intersectsWith(new GridLayoutConstraint(1, 1))); Assert.assertTrue(constraint.intersectsWith(new GridLayoutConstraint(2, 2))); diff --git a/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/image/ImageDimensionProviderTest.java b/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/image/ImageDimensionProviderTest.java index 2ba255899b..5a10a024ec 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/image/ImageDimensionProviderTest.java +++ b/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/behavior/image/ImageDimensionProviderTest.java @@ -12,26 +12,28 @@ /** * Tests for {@link ImageDimensionProvider}. - * + * * @author akiraly */ -public class ImageDimensionProviderTest { +public class ImageDimensionProviderTest +{ private WicketTester tester = new WicketTester(); @After - public void after() { + public void after() + { tester.destroy(); } @Test - public void testDimensions() { + public void testDimensions() + { Image image = new Image("foo", AbstractDefaultAjaxBehavior.INDICATOR); ImageDimensionProvider dimensionProvider = new ImageDimensionProvider( - Integer.toString(200), Integer.toString(70)); + Integer.toString(200), Integer.toString(70)); image.add(dimensionProvider); - IMarkupFragment markup = Markup.of("
          "); + IMarkupFragment markup = Markup.of("
          "); tester.startComponent(image, markup); @@ -39,8 +41,8 @@ public void testDimensions() { Assert.assertNotNull(tagTester); Assert.assertEquals(dimensionProvider.getWidth(), - tagTester.getAttribute(AbstractImageDimensionProvider.WIDTH)); + tagTester.getAttribute(AbstractImageDimensionProvider.WIDTH)); Assert.assertEquals(dimensionProvider.getHeight(), - tagTester.getAttribute(AbstractImageDimensionProvider.HEIGHT)); + tagTester.getAttribute(AbstractImageDimensionProvider.HEIGHT)); } } diff --git a/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanelTest.java b/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanelTest.java index f6fd05b347..ab69eab70c 100644 --- a/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanelTest.java +++ b/jdk-1.5-parent/minis-parent/minis/src/test/java/org/wicketstuff/minis/component/DefaultInvisibleFeedbackPanelTest.java @@ -7,21 +7,23 @@ /** * Tests for {@link DefaultInvisibleFeedbackPanel}. - * + * * @author akiraly */ -public class DefaultInvisibleFeedbackPanelTest { +public class DefaultInvisibleFeedbackPanelTest +{ private WicketTester tester = new WicketTester(); @After - public void after() { + public void after() + { tester.destroy(); } @Test - public void testVisibility() { - FeedbackPanel feedbackPanel = new DefaultInvisibleFeedbackPanel( - "foo"); + public void testVisibility() + { + FeedbackPanel feedbackPanel = new DefaultInvisibleFeedbackPanel("foo"); tester.startComponent(feedbackPanel, null); tester.assertInvisible(""); diff --git a/jdk-1.5-parent/mootools-meiomask-parent/mootools-meiomask-examples/src/main/java/org/wicketstuff/mootools/meiomask/examples/HomePage.java b/jdk-1.5-parent/mootools-meiomask-parent/mootools-meiomask-examples/src/main/java/org/wicketstuff/mootools/meiomask/examples/HomePage.java index 12ae1ef59a..06899ad592 100644 --- a/jdk-1.5-parent/mootools-meiomask-parent/mootools-meiomask-examples/src/main/java/org/wicketstuff/mootools/meiomask/examples/HomePage.java +++ b/jdk-1.5-parent/mootools-meiomask-parent/mootools-meiomask-examples/src/main/java/org/wicketstuff/mootools/meiomask/examples/HomePage.java @@ -1,6 +1,7 @@ package org.wicketstuff.mootools.meiomask.examples; import java.util.Date; + import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.panel.FeedbackPanel; @@ -11,45 +12,50 @@ import org.wicketstuff.mootools.meiomask.MeioMaskField; -public class HomePage extends WebPage { +public class HomePage extends WebPage +{ + + private static final long serialVersionUID = 1L; + private TestModel testModel = new TestModel(); + + public HomePage(final PageParameters parameters) + { - private static final long serialVersionUID = 1L; - private TestModel testModel = new TestModel(); + FeedbackPanel feedbackPanel = new FeedbackPanel("feedBack"); + add(feedbackPanel); - public HomePage(final PageParameters parameters) { + Form form = new Form("form", new CompoundPropertyModel( + testModel)) + { - FeedbackPanel feedbackPanel = new FeedbackPanel("feedBack"); - add(feedbackPanel); + @Override + protected void onSubmit() + { + info("fixed-phone: " + getModelObject().getFixedPhone()); + info("fixed-phone-us: " + getModelObject().getFixedPhoneUs()); + info("fixed-cpf: " + getModelObject().getFixedCpf()); + info("fixed-cnpj: " + getModelObject().getFixedCnpj()); + info("fixed-cep: " + getModelObject().getFixedCep()); + info("fixed-cc: " + getModelObject().getFixedCc()); + info("fixed-date: " + getModelObject().getFixedDate()); + info("reverse.integer: " + getModelObject().getReverseInteger()); - Form form = new Form("form", new CompoundPropertyModel(testModel)) { + } + }; - @Override - protected void onSubmit() { - info("fixed-phone: " + getModelObject().getFixedPhone()); - info("fixed-phone-us: " + getModelObject().getFixedPhoneUs()); - info("fixed-cpf: " + getModelObject().getFixedCpf()); - info("fixed-cnpj: " + getModelObject().getFixedCnpj()); - info("fixed-cep: " + getModelObject().getFixedCep()); - info("fixed-cc: " + getModelObject().getFixedCc()); - info("fixed-date: " + getModelObject().getFixedDate()); - info("reverse.integer: " + getModelObject().getReverseInteger()); - - } - }; + add(form); - add(form); + form.add(new MeioMaskField("fixedPhone", MaskType.FixedPhone)); + form.add(new MeioMaskField("fixedPhoneUs", MaskType.FixedPhoneUs)); + form.add(new MeioMaskField("fixedCpf", MaskType.FixedCpf)); + form.add(new MeioMaskField("fixedCnpj", MaskType.FixedCnpj)); + form.add(new MeioMaskField("fixedCep", MaskType.FixedCep)); + form.add(new MeioMaskField