From ab5b1c785a1c311d4db8f29911a1e08c7b563ced Mon Sep 17 00:00:00 2001 From: Steve Swinsburg Date: Sun, 16 Nov 2014 23:28:11 +1100 Subject: [PATCH] initial commit of prototype using editable grid component --- .gitignore | 1 + pom.xml | 54 +++++++ tool/.classpath | 29 ++++ tool/.project | 14 ++ tool/.settings/org.eclipse.jdt.core.prefs | 5 + tool/pom.xml | 92 ++++++++++++ .../gradebookng/GradebookNgApplication.java | 142 ++++++++++++++++++ .../GradebookNgApplication.properties | 4 + .../gradebookng/tool/model/StudentGrades.java | 64 ++++++++ .../gradebookng/tool/pages/BasePage.html | 24 +++ .../gradebookng/tool/pages/BasePage.java | 140 +++++++++++++++++ .../gradebookng/tool/pages/FirstPage.html | 15 ++ .../gradebookng/tool/pages/GradebookPage.html | 13 ++ .../gradebookng/tool/pages/GradebookPage.java | 80 ++++++++++ .../gradebookng/tool/pages/SecondPage.html | 15 ++ .../gradebookng/tool/pages/SecondPage.java | 19 +++ tool/src/resources/log4j.properties | 12 ++ .../src/webapp/WEB-INF/applicationContext.xml | 8 + tool/src/webapp/WEB-INF/web.xml | 58 +++++++ tool/src/webapp/tools/sakai.gradebookng.xml | 20 +++ 20 files changed, 809 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 tool/.classpath create mode 100644 tool/.project create mode 100644 tool/.settings/org.eclipse.jdt.core.prefs create mode 100644 tool/pom.xml create mode 100644 tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java create mode 100644 tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/model/StudentGrades.java create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.java create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/pages/FirstPage.html create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.html create mode 100644 tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.java create mode 100644 tool/src/resources/log4j.properties create mode 100644 tool/src/webapp/WEB-INF/applicationContext.xml create mode 100644 tool/src/webapp/WEB-INF/web.xml create mode 100644 tool/src/webapp/tools/sakai.gradebookng.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..9f970225adb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000000..a25f17aa0bc3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + GradebookNG + The Next Generation Gradebook for the Sakai CLE + + org.sakaiproject.gradebookng + gradebookng + 1.0-SNAPSHOT + + pom + + + org.sakaiproject + master + 11-SNAPSHOT + ../master/pom.xml + + + + UTF-8 + + + + + + + + org.apache.wicket + wicket + 6.16.0 + pom + + + org.apache.wicket + wicket-spring + 6.16.0 + + + org.wicketstuff + wicketstuff-inmethod-grid + 6.16.0 + + + + + + + + tool + + \ No newline at end of file diff --git a/tool/.classpath b/tool/.classpath new file mode 100644 index 000000000000..c8fa98b204f3 --- /dev/null +++ b/tool/.classpath @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tool/.project b/tool/.project new file mode 100644 index 000000000000..e8b892d0a9fc --- /dev/null +++ b/tool/.project @@ -0,0 +1,14 @@ + + + gradebookng-tool + The Next Generation Gradebook for the Sakai CLE. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/tool/.settings/org.eclipse.jdt.core.prefs b/tool/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000000..12ca141eac98 --- /dev/null +++ b/tool/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Sun Nov 16 23:00:46 EST 2014 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/tool/pom.xml b/tool/pom.xml new file mode 100644 index 000000000000..5c37b2eb5e2a --- /dev/null +++ b/tool/pom.xml @@ -0,0 +1,92 @@ + + + + 4.0.0 + + GradebookNG :: Tool + org.sakaiproject.gradebookng + gradebookng-tool + + + org.sakaiproject.gradebookng + gradebookng + 1.0-SNAPSHOT + + + war + + + + + + org.apache.wicket + wicket + pom + + + org.apache.wicket + wicket-spring + + + org.slf4j + slf4j-log4j12 + + + org.slf4j + slf4j-api + + + log4j + log4j + + + org.projectlombok + lombok + + + javax.servlet + servlet-api + + + org.sakaiproject.kernel + sakai-kernel-api + + + org.sakaiproject.kernel + sakai-component-manager + + + org.sakaiproject.kernel + sakai-kernel-util + + + org.wicketstuff + wicketstuff-inmethod-grid + + + + + + + + + + src/java + + ** + + + **/*.java + + + + + src/resources + + *.properties + + + + + + diff --git a/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java b/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java new file mode 100644 index 000000000000..11a07bd39318 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java @@ -0,0 +1,142 @@ +package org.sakaiproject.gradebookng; + +import org.apache.wicket.protocol.http.WebApplication; +import org.apache.wicket.request.IRequestHandler; +import org.apache.wicket.request.Url; +import org.apache.wicket.request.cycle.IRequestCycleListener; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.spring.injection.annot.SpringComponentInjector; +import org.sakaiproject.gradebookng.tool.pages.GradebookPage; + +/** + * Main application class + * + * @author Steve Swinsburg (steve.swinsburg@gmail.com) + * + */ +public class GradebookNgApplication extends WebApplication { + + @Override + protected void init() { + + //Configure for Spring injection + getComponentInstantiationListeners().add(new SpringComponentInjector(this)); + + //Don't throw an exception if we are missing a property, just fallback + getResourceSettings().setThrowExceptionOnMissingResource(false); + + //Remove the wicket specific tags from the generated markup + getMarkupSettings().setStripWicketTags(true); + + //Don't add any extra tags around a disabled link (default is ) + getMarkupSettings().setDefaultBeforeDisabledLink(null); + getMarkupSettings().setDefaultAfterDisabledLink(null); + + // On Wicket session timeout, redirect to main page + //getApplicationSettings().setPageExpiredErrorPage(FirstPage.class); + //getApplicationSettings().setAccessDeniedPage(FirstPage.class); + + getRequestCycleListeners().add(new IRequestCycleListener() { + + public void onBeginRequest() + { + // optionally do something at the beginning of the request + } + + public void onEndRequest() + { + // optionally do something at the end of the request + } + + public IRequestHandler onException(RequestCycle cycle, Exception ex) + { + // optionally do something here when there's an exception + + // then, return the appropriate IRequestHandler, or "null" + // to let another listener handle the exception + ex.printStackTrace(); + return null; + } + + @Override + public void onBeginRequest(RequestCycle arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void onDetach(RequestCycle arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void onEndRequest(RequestCycle arg0) { + // TODO Auto-generated method stub + + } + + @Override + public void onExceptionRequestHandlerResolved( + RequestCycle arg0, IRequestHandler arg1, Exception arg2) { + // TODO Auto-generated method stub + + } + + @Override + public void onRequestHandlerExecuted(RequestCycle arg0, + IRequestHandler arg1) { + // TODO Auto-generated method stub + + } + + @Override + public void onRequestHandlerResolved(RequestCycle arg0, + IRequestHandler arg1) { + // TODO Auto-generated method stub + + } + + @Override + public void onRequestHandlerScheduled(RequestCycle arg0, + IRequestHandler arg1) { + // TODO Auto-generated method stub + + } + + @Override + public void onUrlMapped(RequestCycle arg0, + IRequestHandler arg1, Url arg2) { + // TODO Auto-generated method stub + + } + }); + + + + + //to put this app into deployment mode, see web.xml + } + + + + /** + * The main page for our app + * + * @see org.apache.wicket.Application#getHomePage() + */ + public Class getHomePage() { + return GradebookPage.class; + } + + + /** + * Constructor + */ + public GradebookNgApplication() + { + } + + + +} diff --git a/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties b/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties new file mode 100644 index 000000000000..22d538385097 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.properties @@ -0,0 +1,4 @@ +app.title = GradebookNG + +link.gradebook = Gradebook +link.gradebook.tooltip = Go to the gradebook diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/model/StudentGrades.java b/tool/src/java/org/sakaiproject/gradebookng/tool/model/StudentGrades.java new file mode 100644 index 000000000000..ac0003615d88 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/model/StudentGrades.java @@ -0,0 +1,64 @@ +package org.sakaiproject.gradebookng.tool.model; + +import java.io.Serializable; +import java.util.List; + +public class StudentGrades implements Serializable +{ + private static final long serialVersionUID = 1L; + + private long id; + private String studentName; + private String studentEid; + private String courseGrade; + + private List assignments; + + public StudentGrades(){ + } + + public StudentGrades(long id, String studentName, String studentEid, String courseGrade, List assignments) + { + this.id = id; + this.studentName = studentName; + this.studentEid = studentEid; + this.courseGrade = courseGrade; + this.assignments = assignments; + + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getFirstName() { + return studentName; + } + + public void setFirstName(String firstName) { + this.studentName = firstName; + } + + public String getStudentEid() { + return studentEid; + } + + public void setgetStudentEid(String studentEid) { + this.studentEid = studentEid; + } + + public String getCourseGrade() { + return courseGrade; + } + + public void setCourseGrade(String courseGrade) { + this.courseGrade = courseGrade; + } + + + +} diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html new file mode 100644 index 000000000000..0ef0403a573a --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html @@ -0,0 +1,24 @@ + + + + + <wicket:message key="app.title" /> + + +
+ + + feedbackmessages will be put here + + + +
+ + \ No newline at end of file diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.java b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.java new file mode 100644 index 000000000000..0f511c6796c4 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.java @@ -0,0 +1,140 @@ +package org.sakaiproject.gradebookng.tool.pages; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.Component; +import org.apache.wicket.behavior.AttributeAppender; +import org.apache.wicket.feedback.FeedbackMessage; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.OnLoadHeaderItem; +import org.apache.wicket.markup.head.StringHeaderItem; +import org.apache.wicket.markup.html.IHeaderContributor; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.markup.html.panel.FeedbackPanel; +import org.apache.wicket.model.Model; +import org.apache.wicket.model.ResourceModel; +import org.apache.wicket.model.StringResourceModel; +import org.apache.wicket.spring.injection.annot.SpringBean; + + +/** + * Base page for our app + * + * @author Steve Swinsburg (steve.swinsburg@gmail.com) + * + */ +public class BasePage extends WebPage implements IHeaderContributor { + + private static final Logger log = Logger.getLogger(BasePage.class); + + //@SpringBean(name="com.steve.logic.SakaiProxy") + //protected SakaiProxy sakaiProxy; + + //@SpringBean(name="com.steve.logic.ProjectLogic") + //protected ProjectLogic projectLogic; + + Link gradebookPageLink; + + FeedbackPanel feedbackPanel; + + public BasePage() { + + log.debug("BasePage()"); + + + //first link + gradebookPageLink = new Link("gradebookPageLink") { + private static final long serialVersionUID = 1L; + public void onClick() { + + setResponsePage(new GradebookPage()); + } + }; + add(gradebookPageLink); + + // Add a FeedbackPanel for displaying our messages + feedbackPanel = new FeedbackPanel("feedback"){ + + @Override + protected Component newMessageDisplayComponent(final String id, final FeedbackMessage message) { + final Component newMessageDisplayComponent = super.newMessageDisplayComponent(id, message); + + if(message.getLevel() == FeedbackMessage.ERROR || + message.getLevel() == FeedbackMessage.DEBUG || + message.getLevel() == FeedbackMessage.FATAL || + message.getLevel() == FeedbackMessage.WARNING){ + add(AttributeModifier.replace("class", "alertMessage")); + } else if(message.getLevel() == FeedbackMessage.INFO){ + add(AttributeModifier.replace("class", "success")); + } + + return newMessageDisplayComponent; + } + }; + add(feedbackPanel); + + } + + /** + * Helper to clear the feedbackpanel display. + * @param f FeedBackPanel + */ + public void clearFeedback(FeedbackPanel f) { + if(!f.hasFeedbackMessage()) { + f.add(AttributeModifier.replace("class", "")); + } + } + + + + + + + + + + + + + + + + + + + + /** + * This block adds the required wrapper markup to style it like a Sakai tool. + * Add to this any additional CSS or JS references that you need. + * + */ + public void renderHead(IHeaderResponse response) { + //get the Sakai skin header fragment from the request attribute + HttpServletRequest request = (HttpServletRequest)getRequest().getContainerRequest(); + + response.render(StringHeaderItem.forString((String)request.getAttribute("sakai.html.head"))); + response.render(OnLoadHeaderItem.forScript("setMainFrameHeight( window.name )")); + + + //Tool additions (at end so we can override if required) + response.render(StringHeaderItem.forString("")); + //response.renderCSSReference("css/my_tool_styles.css"); + //response.renderJavascriptReference("js/my_tool_javascript.js"); + } + + + /** + * Helper to disable a link. Add the Sakai class 'current'. + */ + protected void disableLink(Link l) { + l.add(new AttributeAppender("class", new Model("current"), " ")); + l.setEnabled(false); + } + + + +} diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/pages/FirstPage.html b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/FirstPage.html new file mode 100644 index 000000000000..68d3c4a537d7 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/FirstPage.html @@ -0,0 +1,15 @@ + + + + + + +

Hello,

+ +

+ + + + + + diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html new file mode 100644 index 000000000000..2dc96e99eff2 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html @@ -0,0 +1,13 @@ + + + + + + +

+
+
+ +
+ + diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java new file mode 100644 index 000000000000..aab2f89535a3 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java @@ -0,0 +1,80 @@ +package org.sakaiproject.gradebookng.tool.pages; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.wicket.markup.html.form.Form; +import org.apache.wicket.markup.repeater.data.ListDataProvider; +import org.apache.wicket.model.Model; +import org.sakaiproject.gradebookng.tool.model.StudentGrades; + +import com.inmethod.grid.DataProviderAdapter; +import com.inmethod.grid.IGridColumn; +import com.inmethod.grid.column.PropertyColumn; +import com.inmethod.grid.column.editable.EditablePropertyColumn; +import com.inmethod.grid.column.editable.SubmitCancelColumn; +import com.inmethod.grid.datagrid.DataGrid; +import com.inmethod.grid.datagrid.DefaultDataGrid; + +/** + * GB3 tester + * + * @author Steve Swinsburg (steve.swinsburg@gmail.com) + * + */ +public class GradebookPage extends BasePage { + + public GradebookPage() { + disableLink(this.gradebookPageLink); + + Form form = new Form("form"); + add(form); + + final List personList = getGradebookItems(); + final ListDataProvider listDataProvider = new ListDataProvider(personList); + + + List cols = new ArrayList(); + + cols.add(new PropertyColumn(new Model("Student Name"), "studentName").setReorderable(false)); + cols.add(new PropertyColumn(new Model("Student ID"), "studentEid").setReorderable(false)); + cols.add(new PropertyColumn(new Model("Course Grade"), "courseGrade").setReorderable(false)); + + + //TODO lookup how many assignments we have and iterate here + cols.add(new EditablePropertyColumn(new Model("Assignment 1"), "assignments.0")); + cols.add(new EditablePropertyColumn(new Model("Assignment 2"), "assignments.1")); + cols.add(new EditablePropertyColumn(new Model("Mid Term"), "assignments.2")); + + + EditablePropertyColumn test1 = new EditablePropertyColumn(new Model("Assignment 4"), "assignments.3"); + + cols.add(test1); + + //cols.add(new SubmitCancelColumn("form", Model.of(""))); + + + DataGrid grid = new DefaultDataGrid("grid", new DataProviderAdapter(listDataProvider), cols); + form.add(grid); + + grid.setAllowSelectMultiple(false); + grid.setSelectToEdit(false); + grid.setClickRowToSelect(true); + grid.setClickRowToDeselect(true); + + + + } + + private List getGradebookItems(){ + List items = new ArrayList(); + items.add(new StudentGrades(1, "Student 1","stdnt1","85", Arrays.asList("67", "", "", ""))); + items.add(new StudentGrades(2, "Student 2","stdnt2","78", Arrays.asList("56", "67", "", ""))); + items.add(new StudentGrades(3, "Student 3","stdnt3","56", Arrays.asList("73", "", "", ""))); + items.add(new StudentGrades(4, "Student 4","stdnt4","42", Arrays.asList("49", "", "", ""))); + items.add(new StudentGrades(5, "Student 5","stdnt5","93", Arrays.asList("44", "", "", ""))); + items.add(new StudentGrades(6, "Student 6","stdnt6","87", Arrays.asList("76", "", "", ""))); + return items; + } +} diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.html b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.html new file mode 100644 index 000000000000..b5eb05ffd2c3 --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.html @@ -0,0 +1,15 @@ + + + + + + +

This is the second page

+ + + + + +
+ + diff --git a/tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.java b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.java new file mode 100644 index 000000000000..7dea2e21bedc --- /dev/null +++ b/tool/src/java/org/sakaiproject/gradebookng/tool/pages/SecondPage.java @@ -0,0 +1,19 @@ +package org.sakaiproject.gradebookng.tool.pages; + +import org.apache.wicket.markup.html.link.Link; + +/** + * An example page + * + * @author Steve Swinsburg (steve.swinsburg@gmail.com) + * + */ +public class SecondPage extends BasePage { + + Link toThirdPageLink; + + public SecondPage() { + + + } +} diff --git a/tool/src/resources/log4j.properties b/tool/src/resources/log4j.properties new file mode 100644 index 000000000000..05cd58a3bb0e --- /dev/null +++ b/tool/src/resources/log4j.properties @@ -0,0 +1,12 @@ +log4j.appender.Stdout=org.apache.log4j.ConsoleAppender +log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n + +log4j.rootLogger=INFO,Stdout + +log4j.logger.org.apache.wicket=INFO +log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO +log4j.logger.org.apache.wicket.version=INFO +log4j.logger.org.apache.wicket.RequestCycle=INFO + + diff --git a/tool/src/webapp/WEB-INF/applicationContext.xml b/tool/src/webapp/WEB-INF/applicationContext.xml new file mode 100644 index 000000000000..4d5a40dd75df --- /dev/null +++ b/tool/src/webapp/WEB-INF/applicationContext.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tool/src/webapp/WEB-INF/web.xml b/tool/src/webapp/WEB-INF/web.xml new file mode 100644 index 000000000000..77c32cfc4825 --- /dev/null +++ b/tool/src/webapp/WEB-INF/web.xml @@ -0,0 +1,58 @@ + + + + sakai.gradebookng + + + + sakai.gradebookng + org.apache.wicket.protocol.http.WicketServlet + + applicationClassName + org.sakaiproject.gradebookng.GradebookNgApplication + + 1 + + + sakai.gradebookng + /* + + + + + configuration + development + + + + + + + sakai.request + org.sakaiproject.util.RequestFilter + + + sakai.request + sakai.gradebookng + REQUEST + FORWARD + INCLUDE + + + + + + org.sakaiproject.util.ToolListener + + + + + org.sakaiproject.util.ContextLoaderListener + + + + + diff --git a/tool/src/webapp/tools/sakai.gradebookng.xml b/tool/src/webapp/tools/sakai.gradebookng.xml new file mode 100644 index 000000000000..0b9b7ba69e95 --- /dev/null +++ b/tool/src/webapp/tools/sakai.gradebookng.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + +