From fdebc0f3b0453f7898090be98a3edf9664083471 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 16 Feb 2013 19:10:15 +1300 Subject: Created settings classes --- src/org/traccar/web/client/Context.java | 42 ++++++++++++++++++++++ .../web/shared/model/ApplicationSettings.java | 28 +++++++++++++++ src/org/traccar/web/shared/model/UserSettings.java | 37 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 src/org/traccar/web/client/Context.java create mode 100644 src/org/traccar/web/shared/model/ApplicationSettings.java create mode 100644 src/org/traccar/web/shared/model/UserSettings.java diff --git a/src/org/traccar/web/client/Context.java b/src/org/traccar/web/client/Context.java new file mode 100644 index 00000000..6cc6f0c4 --- /dev/null +++ b/src/org/traccar/web/client/Context.java @@ -0,0 +1,42 @@ +package org.traccar.web.client; + +import org.traccar.web.shared.model.ApplicationSettings; +import org.traccar.web.shared.model.UserSettings; + +public class Context { + + private static final Context context = new Context(); + + public Context getInstance() { + return context; + } + + private ApplicationSettings applicationSettings; + + public void setApplicationSettings(ApplicationSettings applicationSettings) { + this.applicationSettings = applicationSettings; + } + + public ApplicationSettings getApplicationSettings() { + if (applicationSettings != null) { + return applicationSettings; + } else { + return new ApplicationSettings(); // default settings + } + } + + private UserSettings userSettings; + + public void setUserSettings(UserSettings userSettings) { + this.userSettings = userSettings; + } + + public UserSettings getUserSettings() { + if (userSettings != null) { + return userSettings; + } else { + return new UserSettings(); // default settings + } + } + +} diff --git a/src/org/traccar/web/shared/model/ApplicationSettings.java b/src/org/traccar/web/shared/model/ApplicationSettings.java new file mode 100644 index 00000000..ecbd1832 --- /dev/null +++ b/src/org/traccar/web/shared/model/ApplicationSettings.java @@ -0,0 +1,28 @@ +package org.traccar.web.shared.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name="application_settings") +public class ApplicationSettings implements Serializable { + + private static final long serialVersionUID = 1; + + public ApplicationSettings() { + registrationEnabled = true; + } + + private boolean registrationEnabled; + + public void setRegistrationEnabled(boolean registrationEnabled) { + this.registrationEnabled = registrationEnabled; + } + + public boolean getRegistrationEnabled() { + return registrationEnabled; + } + +} diff --git a/src/org/traccar/web/shared/model/UserSettings.java b/src/org/traccar/web/shared/model/UserSettings.java new file mode 100644 index 00000000..f7163a16 --- /dev/null +++ b/src/org/traccar/web/shared/model/UserSettings.java @@ -0,0 +1,37 @@ +package org.traccar.web.shared.model; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Table; + +@Entity +@Table(name="user_settings") +public class UserSettings implements Serializable { + + private static final long serialVersionUID = 1; + + public UserSettings() { + speedUnit = SpeedUnit.knots; + } + + public enum SpeedUnit { + knots, + kilometersPerHour, + milesPerHour + } + + @Enumerated(EnumType.STRING) + private SpeedUnit speedUnit; + + public void setSpeedUnit(SpeedUnit speedUnit) { + this.speedUnit = speedUnit; + } + + public SpeedUnit getSpeedUnit() { + return speedUnit; + } + +} -- cgit v1.2.3