summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authoryvesf <yvesf-git@xapek.org>2011-03-20 11:41:44 +0100
committeryvesf <yvesf-git@xapek.org>2011-03-20 11:41:44 +0100
commitfd2320acfc56d3ab9ed9542c362055ffb95f3904 (patch)
tree104a32ea2e74981ce446063ca75ba0ba65757438 /src/main
parent8c2bbf8d2284f0e8dcd46d8bc5a147c6fdd45b62 (diff)
downloaddhbw-calendar-fd2320acfc56d3ab9ed9542c362055ffb95f3904.tar.gz
dhbw-calendar-fd2320acfc56d3ab9ed9542c362055ffb95f3904.zip
vaadin/web-ui Table Contents (closes gh-6) and disable CSS/JavaScript
in WebClient
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/dhbw/horb/calendar/ui/LoginWorker.java61
-rw-r--r--src/main/java/de/dhbw/horb/calendar/ui/StundenplanComponent.java11
2 files changed, 65 insertions, 7 deletions
diff --git a/src/main/java/de/dhbw/horb/calendar/ui/LoginWorker.java b/src/main/java/de/dhbw/horb/calendar/ui/LoginWorker.java
index aa2c9b7..34941c0 100644
--- a/src/main/java/de/dhbw/horb/calendar/ui/LoginWorker.java
+++ b/src/main/java/de/dhbw/horb/calendar/ui/LoginWorker.java
@@ -1,9 +1,18 @@
package de.dhbw.horb.calendar.ui;
import java.io.IOException;
+import java.net.URL;
+
+import org.w3c.css.sac.CSSException;
+import org.w3c.css.sac.CSSParseException;
+import org.w3c.css.sac.ErrorHandler;
import com.gargoylesoftware.htmlunit.ElementNotFoundException;
+import com.gargoylesoftware.htmlunit.IncorrectnessListener;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.StatusHandler;
import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HTMLParserListener;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
@@ -29,6 +38,56 @@ class LoginWorker implements Runnable {
this.password = password;
client = new WebClient();
+ client.setIncorrectnessListener(new IncorrectnessListener() {
+ @Override
+ public void notify(String message, Object origin) {
+ System.out.println("=======");
+ System.out.println(origin.getClass());
+ }
+ });
+ // not used while setCssEnabled(false)
+ client.setCssErrorHandler(new ErrorHandler() {
+ @Override
+ public void warning(CSSParseException exception)
+ throws CSSException {
+ System.out.println("CSS Exception: " + exception.getMessage());
+ }
+
+ @Override
+ public void fatalError(CSSParseException exception)
+ throws CSSException {
+ System.out.println("CSS Exception: " + exception.getMessage());
+ }
+
+ @Override
+ public void error(CSSParseException exception) throws CSSException {
+ System.out.println("CSS Exception: " + exception.getMessage());
+ }
+ });
+ client.setStatusHandler(new StatusHandler() {
+ @Override
+ public void statusMessageChanged(Page page, String message) {
+ System.out
+ .println("DualisConnection.getEvents().new StatusHandler() {...}.statusMessageChanged()");
+ }
+ });
+ client.setHTMLParserListener(new HTMLParserListener() {
+ @Override
+ public void warning(String message, URL url, int line, int column,
+ String key) {
+ // ignore silently
+ }
+
+ @Override
+ public void error(String message, URL url, int line, int column,
+ String key) {
+ // ignore silently
+ }
+ });
+ client.setPrintContentOnFailingStatusCode(false);
+ client.setJavaScriptEnabled(false);
+ client.setCssEnabled(false);
+
}
private void step1() throws Exception {
@@ -72,7 +131,7 @@ class LoginWorker implements Runnable {
listener.setProgress(0.8, "Prüfe Login");
step4();
listener.setProgress(1.0, "Erfolgreich");
-
+
listener.success(username,password);
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/main/java/de/dhbw/horb/calendar/ui/StundenplanComponent.java b/src/main/java/de/dhbw/horb/calendar/ui/StundenplanComponent.java
index ba3cc1c..0357610 100644
--- a/src/main/java/de/dhbw/horb/calendar/ui/StundenplanComponent.java
+++ b/src/main/java/de/dhbw/horb/calendar/ui/StundenplanComponent.java
@@ -2,10 +2,10 @@ package de.dhbw.horb.calendar.ui;
import java.util.Date;
+import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Alignment;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.ProgressIndicator;
import com.vaadin.ui.Table;
@@ -36,8 +36,8 @@ public class StundenplanComponent extends FormLayout {
try {
for (VEvent vevent : dualisConnection.getEvents()) {
synchronized (getApplication()) {
- table.addItem(new Object[] { vevent.dtstart,
- vevent.dtend, vevent.summary,
+ table.addItem(new Object[] { vevent.dtstart.getTime(),
+ vevent.dtend.getTime(), vevent.summary,
vevent.location },
vevent.dtstart.getTime());
}
@@ -81,6 +81,7 @@ public class StundenplanComponent extends FormLayout {
table.addContainerProperty("end", Date.class, "");
table.addContainerProperty("summary", String.class, "");
table.addContainerProperty("location", String.class, "");
+
}
}
@@ -95,8 +96,6 @@ public class StundenplanComponent extends FormLayout {
layout.setSizeFull();
addComponent(layout);
- layout.setComponentAlignment(
- buttonFetch,
- Alignment.MIDDLE_CENTER);
+ layout.setComponentAlignment(buttonFetch, Alignment.MIDDLE_CENTER);
}
} \ No newline at end of file