Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add common components

  • Loading branch information...
commit 8abe1dffc408e6c40ae235c02f523a8cd15aef7b 1 parent ba508a1
@mkristian authored
Showing with 1,079 additions and 0 deletions.
  1. +7 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/IxtlanGWT.gwt.xml
  2. +41 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AbstractAuditListViewImpl.java
  3. +73 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/Audit.java
  4. +44 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEditor.java
  5. +30 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEditor.ui.xml
  6. +32 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEvent.java
  7. +7 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEventHandler.java
  8. +76 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditRemoteReadOnly.java
  9. +25 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditsRestService.java
  10. +50 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/Domain.java
  11. +32 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainEvent.java
  12. +7 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainEventHandler.java
  13. +76 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainRemoteReadOnly.java
  14. +25 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainRestService.java
  15. +123 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/Error.java
  16. +55 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEditor.java
  17. +50 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEditor.ui.xml
  18. +32 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEvent.java
  19. +7 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEventHandler.java
  20. +76 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorRemoteReadOnly.java
  21. +23 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorsRestService.java
  22. +50 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/Locale.java
  23. +32 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocaleEvent.java
  24. +7 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocaleEventHandler.java
  25. +76 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocaleRemoteReadOnly.java
  26. +23 −0 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocalesRestService.java
View
7 rails-gwt/src/main/java/de/mkristian/ixtlan/IxtlanGWT.gwt.xml
@@ -0,0 +1,7 @@
+<module>
+
+ <inherits name='de.mkristian.gwt.RailsGWT' />
+
+ <source path="gwt"/>
+
+</module>
View
41 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AbstractAuditListViewImpl.java
@@ -0,0 +1,41 @@
+package de.mkristian.ixtlan.gwt.audits;
+
+import static de.mkristian.gwt.rails.places.RestfulActionEnum.SHOW;
+
+import java.util.List;
+
+import com.google.gwt.place.shared.PlaceController;
+
+import de.mkristian.gwt.rails.views.ReadOnlyListViewImpl;
+
+public abstract class AbstractAuditListViewImpl
+ extends ReadOnlyListViewImpl<Audit> {
+
+ public AbstractAuditListViewImpl(String title, PlaceController places) {
+ super(title, places);
+ }
+
+ public void reset(List<Audit> models) {
+ list.removeAllRows();
+ list.setText(0, 0, "Id");
+ list.setText(0, 1, "Login");
+ list.setText(0, 2, "Message");
+ list.getRowFormatter().addStyleName(0, "gwt-rails-model-list-header");
+ if (models != null) {
+ int row = 1;
+ for(Audit model: models){
+ setRow(row, model);
+ row++;
+ }
+ }
+ }
+
+ private void setRow(int row, Audit model) {
+ list.setText(row, 0, model.getId() + "");
+ list.setText(row, 1, model.getLogin() + "");
+ list.setText(row, 2, model.getMessage() + "");
+
+ list.setWidget(row, 3, newButton(SHOW, model));
+ }
+
+}
View
73 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/Audit.java
@@ -0,0 +1,73 @@
+package de.mkristian.ixtlan.gwt.audits;
+
+
+import java.util.Date;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.fusesource.restygwt.client.Json;
+import org.fusesource.restygwt.client.Json.Style;
+
+import de.mkristian.gwt.rails.models.HasToDisplay;
+import de.mkristian.gwt.rails.models.Identifiable;
+
+@Json(style = Style.RAILS)
+public class Audit implements HasToDisplay, Identifiable {
+
+ public final int id;
+
+ @Json(name = "created_at")
+ private final Date createdAt;
+
+ private String login;
+
+ private String message;
+
+ public Audit(){
+ this(0, null);
+ }
+
+ @JsonCreator
+ public Audit(@JsonProperty("id") int id,
+ @JsonProperty("createdAt") Date createdAt){
+ this.id = id;
+ this.createdAt = createdAt;
+ }
+
+ public int getId(){
+ return id;
+ }
+
+ public Date getCreatedAt(){
+ return createdAt;
+ }
+
+ public String getLogin(){
+ return login;
+ }
+
+ public void setLogin(String value){
+ login = value;
+ }
+
+ public String getMessage(){
+ return message;
+ }
+
+ public void setMessage(String value){
+ message = value;
+ }
+
+ public int hashCode(){
+ return id;
+ }
+
+ public boolean equals(Object other){
+ return (other instanceof Audit) &&
+ ((Audit)other).id == id;
+ }
+
+ public String toDisplay() {
+ return login;
+ }
+}
View
44 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEditor.java
@@ -0,0 +1,44 @@
+package de.mkristian.ixtlan.gwt.audits;
+
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.DateLabel;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.NumberLabel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+import de.mkristian.gwt.rails.editors.EnabledEditor;
+
+
+public class AuditEditor extends EnabledEditor<Audit>{
+
+ interface Binder extends UiBinder<Widget, AuditEditor> {}
+
+ private static final Binder BINDER = GWT.create(Binder.class);
+
+ @Ignore @UiField FlowPanel signature;
+
+ @UiField NumberLabel<Integer> id;
+ @UiField DateLabel createdAt;
+
+ @UiField TextBox login;
+
+ @UiField TextBox message;
+
+ public AuditEditor() {
+ initWidget(BINDER.createAndBindUi(this));
+ }
+
+ public void resetVisibility() {
+ this.signature.setVisible(id.getValue() != null && id.getValue() > 0);
+ }
+
+ public void setEnabled(boolean enabled) {
+ resetVisibility();
+ this.login.setEnabled(enabled);
+ this.message.setEnabled(enabled);
+ }
+}
View
30 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEditor.ui.xml
@@ -0,0 +1,30 @@
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder
+ xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui"
+ xmlns:d="urn:import:com.google.gwt.user.datepicker.client"
+ xmlns:r="urn:import:de.mkristian.gwt.rails.editors">
+
+ <g:FlowPanel>
+
+ <g:FlowPanel ui:field="signature" styleName="gwt-rails-model-signature">
+ <g:Label>id: </g:Label>
+ <g:NumberLabel ui:field="id" />
+ <g:Label>created at: </g:Label>
+ <g:DateLabel ui:field="createdAt" predefinedFormat="DATE_TIME_MEDIUM"/>
+ </g:FlowPanel>
+
+ <g:FlowPanel styleName="gwt-rails-model-fields">
+ <g:HTMLPanel>
+ <label name="login">Login</label>
+ <g:TextBox ui:field="login"/>
+ </g:HTMLPanel>
+ <g:HTMLPanel>
+ <label name="message">Message</label>
+ <g:TextBox ui:field="message"/>
+ </g:HTMLPanel>
+ </g:FlowPanel>
+
+ </g:FlowPanel>
+
+</ui:UiBinder>
View
32 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEvent.java
@@ -0,0 +1,32 @@
+package de.mkristian.ixtlan.gwt.audits;
+
+import java.util.List;
+
+import org.fusesource.restygwt.client.Method;
+
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public class AuditEvent extends ModelEvent<Audit> {
+
+ public static final Type<ModelEventHandler<Audit>> TYPE = new Type<ModelEventHandler<Audit>>();
+
+ public AuditEvent( Method method, Audit model,
+ ModelEvent.Action action) {
+ super( method, model, action );
+ }
+
+ public AuditEvent( Method method, List<Audit> models,
+ ModelEvent.Action action) {
+ super( method, models, action );
+ }
+
+ public AuditEvent( Method method, Throwable e ) {
+ super( method, e );
+ }
+
+ @Override
+ public Type<ModelEventHandler<Audit>> getAssociatedType() {
+ return TYPE;
+ }
+}
View
7 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditEventHandler.java
@@ -0,0 +1,7 @@
+package de.mkristian.ixtlan.gwt.audits;
+
+
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public interface AuditEventHandler extends ModelEventHandler<Audit> {
+}
View
76 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditRemoteReadOnly.java
@@ -0,0 +1,76 @@
+/*
+ * ixtlan_gettext - helper to use fast_gettext with datamapper/ixtlan
+ * Copyright (C) 2012 Christian Meier
+ *
+ * This file is part of ixtlan_gettext.
+ *
+ * ixtlan_gettext is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * ixtlan_gettext is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with ixtlan_gettext. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.mkristian.ixtlan.gwt.audits;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.fusesource.restygwt.client.Method;
+
+import com.google.gwt.event.shared.EventBus;
+
+import de.mkristian.gwt.rails.RemoteNotifier;
+import de.mkristian.gwt.rails.caches.RemoteReadOnlyAdapter;
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEvent.Action;
+
+@Singleton
+public class AuditRemoteReadOnly extends RemoteReadOnlyAdapter<Audit> {
+
+ private final AuditsRestService restService;
+
+ @Inject
+ protected AuditRemoteReadOnly( RemoteNotifier notifier,
+ EventBus eventBus,
+ AuditsRestService restService ) {
+ super( eventBus, notifier );
+ this.restService = restService;
+ }
+
+ @Override
+ protected ModelEvent<Audit> newEvent(Method method, List<Audit> models, Action action) {
+ return new AuditEvent( method, models, action );
+ }
+
+ @Override
+ protected ModelEvent<Audit> newEvent(Method method, Audit model, Action action) {
+ return new AuditEvent( method, model, action );
+ }
+
+ @Override
+ protected ModelEvent<Audit> newEvent(Method method, Throwable e) {
+ return new AuditEvent( method, e );
+ }
+
+ @Override
+ public void retrieveAll() {
+ notifier.loading();
+ restService.index(newRetrieveAllCallback());
+ }
+
+ @Override
+ public void retrieve(int id) {
+ notifier.loading();
+ restService.show(id, newRetrieveCallback());
+ }
+}
View
25 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/audits/AuditsRestService.java
@@ -0,0 +1,25 @@
+package de.mkristian.ixtlan.gwt.audits;
+
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.fusesource.restygwt.client.MethodCallback;
+import org.fusesource.restygwt.client.Options;
+import org.fusesource.restygwt.client.RestService;
+
+import de.mkristian.gwt.rails.dispatchers.DefaultDispatcherSingleton;
+
+
+@Options(dispatcher = DefaultDispatcherSingleton.class)
+public interface AuditsRestService extends RestService {
+
+ @GET @Path("/audits")
+ void index(MethodCallback<List<Audit>> callback);
+
+ @GET @Path("/audits/{id}")
+ void show(@PathParam("id") int id, MethodCallback<Audit> callback);
+
+}
View
50 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/Domain.java
@@ -0,0 +1,50 @@
+package de.mkristian.ixtlan.gwt.domains;
+
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.fusesource.restygwt.client.Json;
+import org.fusesource.restygwt.client.Json.Style;
+
+import de.mkristian.gwt.rails.models.HasToDisplay;
+import de.mkristian.gwt.rails.models.Identifiable;
+
+@Json(style = Style.RAILS)
+public class Domain implements HasToDisplay, Identifiable {
+
+ private final int id;
+
+ private final String name;
+
+ public Domain(){
+ this(0, null);
+ }
+
+ @JsonCreator
+ public Domain(@JsonProperty("id") int id,
+ @JsonProperty("name") String name){
+ this.id = id;
+ this.name = name;
+ }
+
+ public int getId(){
+ return id;
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ public int hashCode(){
+ return id;
+ }
+
+ public boolean equals(Object other){
+ return (other instanceof Domain) &&
+ ((Domain)other).id == id;
+ }
+
+ public String toDisplay() {
+ return name;
+ }
+}
View
32 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainEvent.java
@@ -0,0 +1,32 @@
+package de.mkristian.ixtlan.gwt.domains;
+
+import java.util.List;
+
+import org.fusesource.restygwt.client.Method;
+
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public class DomainEvent extends ModelEvent<Domain> {
+
+ public static final Type<ModelEventHandler<Domain>> TYPE = new Type<ModelEventHandler<Domain>>();
+
+ public DomainEvent( Method method, Domain model,
+ ModelEvent.Action action ) {
+ super( method, model, action );
+ }
+
+ public DomainEvent( Method method, List<Domain> models,
+ ModelEvent.Action action ) {
+ super( method, models, action );
+ }
+
+ public DomainEvent( Method method, Throwable e) {
+ super( method, e );
+ }
+
+ @Override
+ public Type<ModelEventHandler<Domain>> getAssociatedType() {
+ return TYPE;
+ }
+}
View
7 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainEventHandler.java
@@ -0,0 +1,7 @@
+package de.mkristian.ixtlan.gwt.domains;
+
+
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public interface DomainEventHandler extends ModelEventHandler<Domain> {
+}
View
76 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainRemoteReadOnly.java
@@ -0,0 +1,76 @@
+/*
+ * ixtlan_gettext - helper to use fast_gettext with datamapper/ixtlan
+ * Copyright (C) 2012 Christian Meier
+ *
+ * This file is part of ixtlan_gettext.
+ *
+ * ixtlan_gettext is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * ixtlan_gettext is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with ixtlan_gettext. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.mkristian.ixtlan.gwt.domains;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.fusesource.restygwt.client.Method;
+
+import com.google.gwt.event.shared.EventBus;
+
+import de.mkristian.gwt.rails.RemoteNotifier;
+import de.mkristian.gwt.rails.caches.RemoteReadOnlyAdapter;
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEvent.Action;
+
+@Singleton
+public class DomainRemoteReadOnly extends RemoteReadOnlyAdapter<Domain> {
+
+ private final DomainRestService restService;
+
+ @Inject
+ protected DomainRemoteReadOnly( RemoteNotifier notifier,
+ EventBus eventBus,
+ DomainRestService restService ) {
+ super( eventBus, notifier );
+ this.restService = restService;
+ }
+
+ @Override
+ protected ModelEvent<Domain> newEvent(Method method, List<Domain> models, Action action) {
+ return new DomainEvent( method, models, action );
+ }
+
+ @Override
+ protected ModelEvent<Domain> newEvent(Method method, Domain model, Action action) {
+ return new DomainEvent( method, model, action );
+ }
+
+ @Override
+ protected DomainEvent newEvent(Method method, Throwable e) {
+ return new DomainEvent( method, e );
+ }
+
+ @Override
+ public void retrieveAll() {
+ notifier.loading();
+ restService.index(newRetrieveAllCallback());
+ }
+
+ @Override
+ public void retrieve(int id) {
+ notifier.loading();
+ restService.show(id, newRetrieveCallback());
+ }
+}
View
25 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/domains/DomainRestService.java
@@ -0,0 +1,25 @@
+package de.mkristian.ixtlan.gwt.domains;
+
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+
+import org.fusesource.restygwt.client.MethodCallback;
+import org.fusesource.restygwt.client.Options;
+import org.fusesource.restygwt.client.RestService;
+
+import de.mkristian.gwt.rails.dispatchers.DefaultDispatcherSingleton;
+
+
+@Options(dispatcher = DefaultDispatcherSingleton.class)
+public interface DomainRestService extends RestService {
+
+ @GET @Path("/domains")
+ void index(MethodCallback<List<Domain>> callback);
+
+ @GET @Path("/domains/{id}")
+ void show(@PathParam("id") int id, MethodCallback<Domain> callback);
+
+}
View
123 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/Error.java
@@ -0,0 +1,123 @@
+package de.mkristian.ixtlan.gwt.errors;
+
+
+import java.util.Date;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.fusesource.restygwt.client.Json;
+import org.fusesource.restygwt.client.Json.Style;
+
+import de.mkristian.gwt.rails.models.HasToDisplay;
+import de.mkristian.gwt.rails.models.Identifiable;
+
+@Json(style = Style.RAILS)
+public class Error implements HasToDisplay, Identifiable {
+
+ public final int id;
+
+ @Json(name = "created_at")
+ private final Date createdAt;
+
+ private String message;
+
+ private String request;
+
+ private String response;
+
+ private String session;
+
+ private String parameters;
+
+ private String clazz;
+
+ private String backtrace;
+
+ public Error(){
+ this(0, null);
+ }
+
+ @JsonCreator
+ public Error(@JsonProperty("id") int id,
+ @JsonProperty("createdAt") Date createdAt){
+ this.id = id;
+ this.createdAt = createdAt;
+ }
+
+ public int getId(){
+ return id;
+ }
+
+ public Date getCreatedAt(){
+ return createdAt;
+ }
+
+ public String getMessage(){
+ return message;
+ }
+
+ public void setMessage(String value){
+ message = value;
+ }
+
+ public String getRequest(){
+ return request;
+ }
+
+ public void setRequest(String value){
+ request = value;
+ }
+
+ public String getResponse(){
+ return response;
+ }
+
+ public void setResponse(String value){
+ response = value;
+ }
+
+ public String getSession(){
+ return session;
+ }
+
+ public void setSession(String value){
+ session = value;
+ }
+
+ public String getParameters(){
+ return parameters;
+ }
+
+ public void setParameters(String value){
+ parameters = value;
+ }
+
+ public String getClazz(){
+ return clazz;
+ }
+
+ public void setClazz(String value){
+ clazz = value;
+ }
+
+ public String getBacktrace(){
+ return backtrace;
+ }
+
+ public void setBacktrace(String value){
+ backtrace = value;
+ }
+
+ public int hashCode(){
+ return id;
+ }
+
+ public boolean equals(Object other){
+ return (other instanceof Error) &&
+ ((Error)other).id == id;
+ }
+
+ public String toDisplay() {
+ return message;
+ }
+}
View
55 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEditor.java
@@ -0,0 +1,55 @@
+package de.mkristian.ixtlan.gwt.errors;
+
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.DateLabel;
+import com.google.gwt.user.client.ui.FlowPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.NumberLabel;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+import de.mkristian.gwt.rails.editors.EnabledEditor;
+
+
+public class ErrorEditor extends EnabledEditor<Error>{
+
+ interface Binder extends UiBinder<Widget, ErrorEditor> {}
+
+ private static final Binder BINDER = GWT.create(Binder.class);
+
+ @Ignore @UiField FlowPanel signature;
+
+ @UiField NumberLabel<Integer> id;
+ @UiField DateLabel createdAt;
+
+ @UiField TextBox message;
+
+ @UiField Label request;
+
+ @UiField Label response;
+
+ @UiField Label session;
+
+ @UiField Label parameters;
+
+ @UiField TextBox clazz;
+
+ @UiField Label backtrace;
+
+ public ErrorEditor() {
+ initWidget(BINDER.createAndBindUi(this));
+ }
+
+ public void resetVisibility() {
+ this.signature.setVisible(id.getValue() != null && id.getValue() > 0);
+ }
+
+ public void setEnabled(boolean enabled) {
+ resetVisibility();
+ this.message.setEnabled(enabled);
+ this.clazz.setEnabled(enabled);
+ }
+}
View
50 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEditor.ui.xml
@@ -0,0 +1,50 @@
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder
+ xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui"
+ xmlns:d="urn:import:com.google.gwt.user.datepicker.client"
+ xmlns:r="urn:import:de.mkristian.gwt.rails.editors">
+
+ <g:FlowPanel>
+
+ <g:FlowPanel ui:field="signature" styleName="gwt-rails-model-signature">
+ <g:Label>id: </g:Label>
+ <g:NumberLabel ui:field="id" />
+ <g:Label>created at: </g:Label>
+ <g:DateLabel ui:field="createdAt" predefinedFormat="DATE_TIME_MEDIUM"/>
+ </g:FlowPanel>
+
+ <g:FlowPanel styleName="gwt-rails-model-fields">
+ <g:HTMLPanel>
+ <label name="message">Message</label>
+ <g:TextBox ui:field="message"/>
+ </g:HTMLPanel>
+ <g:HTMLPanel>
+ <label name="request">Request</label>
+ <pre><g:Label ui:field="request"/></pre>
+ </g:HTMLPanel>
+ <g:HTMLPanel>
+ <label name="response">Response</label>
+ <pre><g:Label ui:field="response"/></pre>
+ </g:HTMLPanel>
+ <g:HTMLPanel>
+ <label name="session">Session</label>
+ <pre><g:Label ui:field="session"/></pre>
+ </g:HTMLPanel>
+ <g:HTMLPanel>
+ <label name="parameters">Parameters</label>
+ <pre><g:Label ui:field="parameters"/></pre>
+ </g:HTMLPanel>
+ <g:HTMLPanel>
+ <label name="clazz">Clazz</label>
+ <g:TextBox ui:field="clazz"/>
+ </g:HTMLPanel>
+ <g:HTMLPanel>
+ <label name="backtrace">Backtrace</label>
+ <pre><g:Label ui:field="backtrace"/></pre>
+ </g:HTMLPanel>
+ </g:FlowPanel>
+
+ </g:FlowPanel>
+
+</ui:UiBinder>
View
32 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEvent.java
@@ -0,0 +1,32 @@
+package de.mkristian.ixtlan.gwt.errors;
+
+import java.util.List;
+
+import org.fusesource.restygwt.client.Method;
+
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public class ErrorEvent extends ModelEvent<Error> {
+
+ public static final Type<ModelEventHandler<Error>> TYPE = new Type<ModelEventHandler<Error>>();
+
+ public ErrorEvent( Method method, Error model,
+ ModelEvent.Action action ) {
+ super( method, model, action );
+ }
+
+ public ErrorEvent( Method method, List<Error> models,
+ ModelEvent.Action action ) {
+ super( method, models, action );
+ }
+
+ public ErrorEvent( Method method, Throwable e) {
+ super( method, e );
+ }
+
+ @Override
+ public Type<ModelEventHandler<Error>> getAssociatedType() {
+ return TYPE;
+ }
+}
View
7 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorEventHandler.java
@@ -0,0 +1,7 @@
+package de.mkristian.ixtlan.gwt.errors;
+
+
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public interface ErrorEventHandler extends ModelEventHandler<Error> {
+}
View
76 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorRemoteReadOnly.java
@@ -0,0 +1,76 @@
+/*
+ * ixtlan_gettext - helper to use fast_gettext with datamapper/ixtlan
+ * Copyright (C) 2012 Christian Meier
+ *
+ * This file is part of ixtlan_gettext.
+ *
+ * ixtlan_gettext is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * ixtlan_gettext is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with ixtlan_gettext. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.mkristian.ixtlan.gwt.errors;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.fusesource.restygwt.client.Method;
+
+import com.google.gwt.event.shared.EventBus;
+
+import de.mkristian.gwt.rails.RemoteNotifier;
+import de.mkristian.gwt.rails.caches.RemoteReadOnlyAdapter;
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEvent.Action;
+
+@Singleton
+public class ErrorRemoteReadOnly extends RemoteReadOnlyAdapter<Error> {
+
+ private final ErrorsRestService restService;
+
+ @Inject
+ protected ErrorRemoteReadOnly( RemoteNotifier notifier,
+ EventBus eventBus,
+ ErrorsRestService restService ) {
+ super( eventBus, notifier );
+ this.restService = restService;
+ }
+
+ @Override
+ protected ModelEvent<Error> newEvent(Method method, List<Error> models, Action action) {
+ return new ErrorEvent( method, models, action );
+ }
+
+ @Override
+ protected ModelEvent<Error> newEvent(Method method, Error model, Action action) {
+ return new ErrorEvent( method, model, action );
+ }
+
+ @Override
+ protected ErrorEvent newEvent(Method method, Throwable e) {
+ return new ErrorEvent( method, e );
+ }
+
+ @Override
+ public void retrieveAll() {
+ notifier.loading();
+ restService.index(newRetrieveAllCallback());
+ }
+
+ @Override
+ public void retrieve(int id) {
+ notifier.loading();
+ restService.show(id, newRetrieveCallback());
+ }
+}
View
23 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/errors/ErrorsRestService.java
@@ -0,0 +1,23 @@
+package de.mkristian.ixtlan.gwt.errors;
+
+import de.mkristian.gwt.rails.dispatchers.DefaultDispatcherSingleton;
+
+import java.util.List;
+
+import javax.ws.rs.*;
+
+import org.fusesource.restygwt.client.MethodCallback;
+import org.fusesource.restygwt.client.Options;
+import org.fusesource.restygwt.client.RestService;
+
+
+@Options(dispatcher = DefaultDispatcherSingleton.class)
+public interface ErrorsRestService extends RestService {
+
+ @GET @Path("/errors")
+ void index(MethodCallback<List<Error>> callback);
+
+ @GET @Path("/errors/{id}")
+ void show(@PathParam("id") int id, MethodCallback<Error> callback);
+
+}
View
50 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/Locale.java
@@ -0,0 +1,50 @@
+package de.mkristian.ixtlan.gwt.locales;
+
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.fusesource.restygwt.client.Json;
+import org.fusesource.restygwt.client.Json.Style;
+
+import de.mkristian.gwt.rails.models.HasToDisplay;
+import de.mkristian.gwt.rails.models.Identifiable;
+
+@Json(style = Style.RAILS)
+public class Locale implements HasToDisplay, Identifiable {
+
+ private final int id;
+
+ private final String code;
+
+ public Locale(){
+ this(0, null);
+ }
+
+ @JsonCreator
+ public Locale(@JsonProperty("id") int id,
+ @JsonProperty("code") String code){
+ this.id = id;
+ this.code = code;
+ }
+
+ public int getId(){
+ return id;
+ }
+
+ public String getCode(){
+ return code;
+ }
+
+ public int hashCode(){
+ return id;
+ }
+
+ public boolean equals(Object other){
+ return (other instanceof Locale) &&
+ ((Locale)other).id == id;
+ }
+
+ public String toDisplay() {
+ return code;
+ }
+}
View
32 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocaleEvent.java
@@ -0,0 +1,32 @@
+package de.mkristian.ixtlan.gwt.locales;
+
+import java.util.List;
+
+import org.fusesource.restygwt.client.Method;
+
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public class LocaleEvent extends ModelEvent<Locale> {
+
+ public static final Type<ModelEventHandler<Locale>> TYPE = new Type<ModelEventHandler<Locale>>();
+
+ public LocaleEvent( Method method, Locale model,
+ ModelEvent.Action action ) {
+ super( method, model, action );
+ }
+
+ public LocaleEvent( Method method, List<Locale> models,
+ ModelEvent.Action action ) {
+ super( method, models, action );
+ }
+
+ public LocaleEvent( Method method, Throwable e) {
+ super( method, e );
+ }
+
+ @Override
+ public Type<ModelEventHandler<Locale>> getAssociatedType() {
+ return TYPE;
+ }
+}
View
7 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocaleEventHandler.java
@@ -0,0 +1,7 @@
+package de.mkristian.ixtlan.gwt.locales;
+
+
+import de.mkristian.gwt.rails.events.ModelEventHandler;
+
+public interface LocaleEventHandler extends ModelEventHandler<Locale> {
+}
View
76 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocaleRemoteReadOnly.java
@@ -0,0 +1,76 @@
+/*
+ * ixtlan_gettext - helper to use fast_gettext with datamapper/ixtlan
+ * Copyright (C) 2012 Christian Meier
+ *
+ * This file is part of ixtlan_gettext.
+ *
+ * ixtlan_gettext is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * ixtlan_gettext is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with ixtlan_gettext. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package de.mkristian.ixtlan.gwt.locales;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.fusesource.restygwt.client.Method;
+
+import com.google.gwt.event.shared.EventBus;
+
+import de.mkristian.gwt.rails.RemoteNotifier;
+import de.mkristian.gwt.rails.caches.RemoteReadOnlyAdapter;
+import de.mkristian.gwt.rails.events.ModelEvent;
+import de.mkristian.gwt.rails.events.ModelEvent.Action;
+
+@Singleton
+public class LocaleRemoteReadOnly extends RemoteReadOnlyAdapter<Locale> {
+
+ private final LocalesRestService restService;
+
+ @Inject
+ protected LocaleRemoteReadOnly( RemoteNotifier notifier,
+ EventBus eventBus,
+ LocalesRestService restService ) {
+ super( eventBus, notifier );
+ this.restService = restService;
+ }
+
+ @Override
+ protected ModelEvent<Locale> newEvent(Method method, List<Locale> models, Action action) {
+ return new LocaleEvent( method, models, action );
+ }
+
+ @Override
+ protected ModelEvent<Locale> newEvent(Method method, Locale model, Action action) {
+ return new LocaleEvent( method, model, action );
+ }
+
+ @Override
+ protected LocaleEvent newEvent(Method method, Throwable e) {
+ return new LocaleEvent( method, e );
+ }
+
+ @Override
+ public void retrieveAll() {
+ notifier.loading();
+ restService.index(newRetrieveAllCallback());
+ }
+
+ @Override
+ public void retrieve(int id) {
+ notifier.loading();
+ restService.show(id, newRetrieveCallback());
+ }
+}
View
23 rails-gwt/src/main/java/de/mkristian/ixtlan/gwt/locales/LocalesRestService.java
@@ -0,0 +1,23 @@
+package de.mkristian.ixtlan.gwt.locales;
+
+import de.mkristian.gwt.rails.dispatchers.DefaultDispatcherSingleton;
+
+import java.util.List;
+
+import javax.ws.rs.*;
+
+import org.fusesource.restygwt.client.MethodCallback;
+import org.fusesource.restygwt.client.Options;
+import org.fusesource.restygwt.client.RestService;
+
+
+@Options(dispatcher = DefaultDispatcherSingleton.class)
+public interface LocalesRestService extends RestService {
+
+ @GET @Path("/locales")
+ void index(MethodCallback<List<Locale>> callback);
+
+ @GET @Path("/locales/{id}")
+ void show(@PathParam("id") int id, MethodCallback<Locale> callback);
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.