From fcaf637431fee2cdd5ccab79b6de1edf44bac777 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 3 Aug 2015 15:13:14 +1200 Subject: Remove files and update readme --- .../web/client/controller/ArchiveController.java | 98 ------------- .../web/client/controller/ContentController.java | 26 ---- .../web/client/controller/DeviceController.java | 139 ------------------- .../web/client/controller/LoginController.java | 101 -------------- .../web/client/controller/MapController.java | 138 ------------------- .../web/client/controller/SettingsController.java | 151 --------------------- .../web/client/controller/StateController.java | 57 -------- 7 files changed, 710 deletions(-) delete mode 100644 src/org/traccar/web/client/controller/ArchiveController.java delete mode 100644 src/org/traccar/web/client/controller/ContentController.java delete mode 100644 src/org/traccar/web/client/controller/DeviceController.java delete mode 100644 src/org/traccar/web/client/controller/LoginController.java delete mode 100644 src/org/traccar/web/client/controller/MapController.java delete mode 100644 src/org/traccar/web/client/controller/SettingsController.java delete mode 100644 src/org/traccar/web/client/controller/StateController.java (limited to 'src/org/traccar/web/client/controller') diff --git a/src/org/traccar/web/client/controller/ArchiveController.java b/src/org/traccar/web/client/controller/ArchiveController.java deleted file mode 100644 index 9a0c18d0..00000000 --- a/src/org/traccar/web/client/controller/ArchiveController.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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.traccar.web.client.controller; - -import java.util.Date; -import java.util.List; - -import org.traccar.web.client.Application; -import org.traccar.web.client.model.BaseAsyncCallback; -import org.traccar.web.client.model.PositionProperties; -import org.traccar.web.client.view.ArchiveView; -import org.traccar.web.shared.model.Device; -import org.traccar.web.shared.model.Position; - -import com.google.gwt.core.client.GWT; -import com.sencha.gxt.data.shared.ListStore; -import com.sencha.gxt.widget.core.client.ContentPanel; -import com.sencha.gxt.widget.core.client.box.AlertMessageBox; - -public class ArchiveController implements ContentController, ArchiveView.ArchiveHandler { - - public interface ArchiveHandler { - public void onSelected(Position position); - } - - private ArchiveHandler archiveHandler; - - private ListStore positionStore; - - private ArchiveView archiveView; - - public ArchiveController(ArchiveHandler archiveHandler, ListStore deviceStore) { - this.archiveHandler = archiveHandler; - PositionProperties positionProperties = GWT.create(PositionProperties.class); - positionStore = new ListStore(positionProperties.id()); - archiveView = new ArchiveView(this, positionStore, deviceStore); - } - - public ListStore getPositionStore() { - return positionStore; - } - - @Override - public ContentPanel getView() { - return archiveView.getView(); - } - - @Override - public void run() { - } - - @Override - public void onSelected(Position position) { - archiveHandler.onSelected(position); - } - - @Override - public void onLoad(Device device, Date from, Date to) { - if (device != null && from != null && to != null) { - Application.getDataService().getPositions(device, from, to, new BaseAsyncCallback>() { - @Override - public void onSuccess(List result) { - positionStore.clear(); - if (result.isEmpty()) { - new AlertMessageBox("Error", "No results found for selected period").show(); - } else { - positionStore.addAll(result); - } - } - }); - } else { - new AlertMessageBox("Error", "All form fields must be filled first").show(); - } - } - - @Override - public void onClear() { - positionStore.clear(); - } - - public void selectPosition(Position position) { - archiveView.selectPosition(position); - } - -} diff --git a/src/org/traccar/web/client/controller/ContentController.java b/src/org/traccar/web/client/controller/ContentController.java deleted file mode 100644 index 4fdea7c8..00000000 --- a/src/org/traccar/web/client/controller/ContentController.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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.traccar.web.client.controller; - -import com.sencha.gxt.widget.core.client.ContentPanel; - -public interface ContentController { - - public ContentPanel getView(); - - public void run(); - -} diff --git a/src/org/traccar/web/client/controller/DeviceController.java b/src/org/traccar/web/client/controller/DeviceController.java deleted file mode 100644 index 599f7565..00000000 --- a/src/org/traccar/web/client/controller/DeviceController.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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.traccar.web.client.controller; - -import java.util.List; - -import org.traccar.web.client.Application; -import org.traccar.web.client.model.BaseAsyncCallback; -import org.traccar.web.client.model.DeviceProperties; -import org.traccar.web.client.view.DeviceDialog; -import org.traccar.web.client.view.DeviceView; -import org.traccar.web.shared.model.Device; - -import com.google.gwt.core.client.GWT; -import com.sencha.gxt.data.shared.ListStore; -import com.sencha.gxt.widget.core.client.ContentPanel; -import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton; -import com.sencha.gxt.widget.core.client.box.AlertMessageBox; -import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox; -import com.sencha.gxt.widget.core.client.event.DialogHideEvent; - -public class DeviceController implements ContentController, DeviceView.DeviceHandler { - - public interface DeviceHandler { - public void onSelected(Device device); - } - - private DeviceHandler deviceHandler; - - private ListStore deviceStore; - - private DeviceView deviceView; - - public DeviceController(DeviceHandler deviceHandler, DeviceView.SettingsHandler settingsHandler) { - this.deviceHandler = deviceHandler; - DeviceProperties deviceProperties = GWT.create(DeviceProperties.class); - deviceStore = new ListStore(deviceProperties.id()); - deviceView = new DeviceView(this, settingsHandler, deviceStore); - } - - public ListStore getDeviceStore() { - return deviceStore; - } - - @Override - public ContentPanel getView() { - return deviceView.getView(); - } - - @Override - public void run() { - Application.getDataService().getDevices(new BaseAsyncCallback>() { - @Override - public void onSuccess(List result) { - deviceStore.addAll(result); - } - }); - } - - @Override - public void onSelected(Device device) { - deviceHandler.onSelected(device); - } - - @Override - public void onAdd() { - new DeviceDialog(new Device(), new DeviceDialog.DeviceHandler() { - @Override - public void onSave(Device device) { - Application.getDataService().addDevice(device, new BaseAsyncCallback() { - @Override - public void onSuccess(Device result) { - deviceStore.add(result); - } - @Override - public void onFailure(Throwable caught) { - new AlertMessageBox("Error", "Device with this Unique ID already exists").show(); - } - }); - } - }).show(); - } - - @Override - public void onEdit(Device device) { - new DeviceDialog(new Device(device), new DeviceDialog.DeviceHandler() { - @Override - public void onSave(Device device) { - Application.getDataService().updateDevice(device, new BaseAsyncCallback() { - @Override - public void onSuccess(Device result) { - deviceStore.update(result); - } - @Override - public void onFailure(Throwable caught) { - new AlertMessageBox("Error", "Device with this Unique ID already exists").show(); - } - }); - } - }).show(); - } - - @Override - public void onRemove(final Device device) { - final ConfirmMessageBox dialog = new ConfirmMessageBox("Confirm", "Are you sure you want remove device?"); - dialog.addDialogHideHandler(new DialogHideEvent.DialogHideHandler() { - @Override - public void onDialogHide(DialogHideEvent event) { - if (event.getHideButton() == PredefinedButton.YES) { - Application.getDataService().removeDevice(device, new BaseAsyncCallback() { - @Override - public void onSuccess(Device result) { - deviceStore.remove(device); - } - }); - } - } - }); - dialog.show(); - } - - public void selectDevice(Device device) { - deviceView.selectDevice(device); - } - -} diff --git a/src/org/traccar/web/client/controller/LoginController.java b/src/org/traccar/web/client/controller/LoginController.java deleted file mode 100644 index 1aa152b8..00000000 --- a/src/org/traccar/web/client/controller/LoginController.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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.traccar.web.client.controller; - -import org.traccar.web.client.Application; -import org.traccar.web.client.ApplicationContext; -import org.traccar.web.client.model.BaseAsyncCallback; -import org.traccar.web.client.view.LoginDialog; -import org.traccar.web.shared.model.User; - -import com.sencha.gxt.widget.core.client.box.AlertMessageBox; - -public class LoginController implements LoginDialog.LoginHandler { - - private LoginDialog dialog; - - public interface LoginHandler { - public void onLogin(); - } - - private LoginHandler loginHandler; - - public void login(final LoginHandler loginHandler) { - this.loginHandler = loginHandler; - - Application.getDataService().authenticated(new BaseAsyncCallback() { - @Override - public void onSuccess(User result) { - ApplicationContext.getInstance().setUser(result); - loginHandler.onLogin(); - } - @Override - public void onFailure(Throwable caught) { - dialog = new LoginDialog(LoginController.this); - dialog.show(); - } - }); - } - - private boolean validate(String login, String password) { - if (login == null || login.isEmpty() || password == null || password.isEmpty()) { - new AlertMessageBox("Error", "User name and password must not be empty").show(); - return false; - } - return true; - } - - @Override - public void onLogin(String login, String password) { - if (validate(login, password)) { - Application.getDataService().login(login, password, new BaseAsyncCallback() { - @Override - public void onSuccess(User result) { - ApplicationContext.getInstance().setUser(result); - if (loginHandler != null) { - dialog.hide(); - loginHandler.onLogin(); - } - } - @Override - public void onFailure(Throwable caught) { - new AlertMessageBox("Error", "User name or password is invalid").show(); - } - }); - } - } - - @Override - public void onRegister(String login, String password) { - if (validate(login, password)) { - Application.getDataService().register(login, password, new BaseAsyncCallback() { - @Override - public void onSuccess(User result) { - ApplicationContext.getInstance().setUser(result); - if (loginHandler != null) { - dialog.hide(); - loginHandler.onLogin(); - } - } - @Override - public void onFailure(Throwable caught) { - new AlertMessageBox("Error", "Username is already taken").show(); - } - }); - } - } - -} diff --git a/src/org/traccar/web/client/controller/MapController.java b/src/org/traccar/web/client/controller/MapController.java deleted file mode 100644 index 13c736f5..00000000 --- a/src/org/traccar/web/client/controller/MapController.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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.traccar.web.client.controller; - -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.traccar.web.client.Application; -import org.traccar.web.client.view.MapView; -import org.traccar.web.shared.model.Device; -import org.traccar.web.shared.model.Position; - -import com.google.gwt.user.client.Timer; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.sencha.gxt.widget.core.client.ContentPanel; - -public class MapController implements ContentController, MapView.MapHandler { - - private static final int UPDATE_INTERVAL = 15000; - - public interface MapHandler { - public void onDeviceSelected(Device device); - public void onArchivePositionSelected(Position position); - } - - private MapHandler mapHandler; - - private MapView mapView; - - public MapController(MapHandler mapHandler) { - this.mapHandler = mapHandler; - mapView = new MapView(this); - } - - @Override - public ContentPanel getView() { - return mapView.getView(); - } - - private Timer updateTimer; - - @Override - public void run() { - updateTimer = new Timer() { - @Override - public void run() { - update(); - } - }; - update(); - } - - private Map latestPositionMap = new HashMap(); - - public void update() { - updateTimer.cancel(); - Application.getDataService().getLatestPositions(new AsyncCallback>() { - @Override - public void onSuccess(List result) { - mapView.showLatestPositions(result); - for (Position position : result) { - latestPositionMap.put(position.getDevice().getId(), position); - } - for (Map.Entry entry : positionUpdateMap.entrySet()) { - entry.getValue().onUpdate(latestPositionMap.get(entry.getKey())); - } - updateTimer.schedule(UPDATE_INTERVAL); - } - @Override - public void onFailure(Throwable caught) { - updateTimer.schedule(UPDATE_INTERVAL); - } - }); - } - - public void selectDevice(Device device) { - mapView.selectDevice(device); - } - - public void showArchivePositions(List positions) { - List sortedPositions = new LinkedList(positions); - Collections.sort(sortedPositions, new Comparator() { - @Override - public int compare(Position o1, Position o2) { - return o1.getTime().compareTo(o2.getTime()); - } - }); - mapView.showArchivePositions(sortedPositions); - } - - public void selectArchivePosition(Position position) { - mapView.selectArchivePosition(position); - } - - public interface PositionUpdateHandler { - public void onUpdate(Position position); - } - - private Map positionUpdateMap = new HashMap(); - - - public void registerPositionUpdate(Device device, PositionUpdateHandler handler) { - positionUpdateMap.put(device.getId(), handler); - handler.onUpdate(latestPositionMap.get(device.getId())); - } - - public void unregisterPositionUpdate(Device device) { - positionUpdateMap.remove(device.getId()); - } - - @Override - public void onPositionSelected(Position position) { - mapHandler.onDeviceSelected(position.getDevice()); - } - - @Override - public void onArchivePositionSelected(Position position) { - mapHandler.onArchivePositionSelected(position); - } - -} diff --git a/src/org/traccar/web/client/controller/SettingsController.java b/src/org/traccar/web/client/controller/SettingsController.java deleted file mode 100644 index bd20288b..00000000 --- a/src/org/traccar/web/client/controller/SettingsController.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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.traccar.web.client.controller; - -import java.util.List; - -import org.traccar.web.client.Application; -import org.traccar.web.client.ApplicationContext; -import org.traccar.web.client.model.BaseAsyncCallback; -import org.traccar.web.client.model.UserProperties; -import org.traccar.web.client.view.ApplicationSettingsDialog; -import org.traccar.web.client.view.DeviceView; -import org.traccar.web.client.view.UserDialog; -import org.traccar.web.client.view.UserSettingsDialog; -import org.traccar.web.client.view.UsersDialog; -import org.traccar.web.shared.model.ApplicationSettings; -import org.traccar.web.shared.model.User; -import org.traccar.web.shared.model.UserSettings; - -import com.google.gwt.core.client.GWT; -import com.sencha.gxt.data.shared.ListStore; -import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton; -import com.sencha.gxt.widget.core.client.box.AlertMessageBox; -import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox; -import com.sencha.gxt.widget.core.client.event.DialogHideEvent; - -public class SettingsController implements DeviceView.SettingsHandler { - - @Override - public void onAccountSelected() { - new UserDialog( - ApplicationContext.getInstance().getUser(), - new UserDialog.UserHandler() { - @Override - public void onSave(User user) { - Application.getDataService().updateUser(user, new BaseAsyncCallback() { - @Override - public void onSuccess(User result) { - ApplicationContext.getInstance().setUser(result); - } - }); - } - }).show(); - } - - @Override - public void onPreferencesSelected() { - new UserSettingsDialog( - ApplicationContext.getInstance().getUserSettings(), - new UserSettingsDialog.UserSettingsHandler() { - @Override - public void onSave(UserSettings userSettings) { - ApplicationContext.getInstance().setUserSettings(userSettings); - User user = ApplicationContext.getInstance().getUser(); - Application.getDataService().updateUser(user, new BaseAsyncCallback() { - @Override - public void onSuccess(User result) { - ApplicationContext.getInstance().setUser(result); - } - }); - } - }).show(); - } - - @Override - public void onUsersSelected() { - Application.getDataService().getUsers(new BaseAsyncCallback>() { - @Override - public void onSuccess(List result) { - UserProperties userProperties = GWT.create(UserProperties.class); - final ListStore userStore = new ListStore(userProperties.id()); - userStore.addAll(result); - - new UsersDialog(userStore, new UsersDialog.UserHandler() { - - @Override - public void onAdd() { - new UserDialog( - new User(), - new UserDialog.UserHandler() { - @Override - public void onSave(User user) { - Application.getDataService().addUser(user, new BaseAsyncCallback() { - @Override - public void onSuccess(User result) { - userStore.add(result); - } - @Override - public void onFailure(Throwable caught) { - new AlertMessageBox("Error", "Username is already taken").show(); - } - }); - } - }).show(); - } - - @Override - public void onRemove(final User user) { - final ConfirmMessageBox dialog = new ConfirmMessageBox("Confirm", "Are you sure you want remove user?"); - dialog.addDialogHideHandler(new DialogHideEvent.DialogHideHandler() { - @Override - public void onDialogHide(DialogHideEvent event) { - if (event.getHideButton() == PredefinedButton.YES) { - Application.getDataService().removeUser(user, new BaseAsyncCallback() { - @Override - public void onSuccess(User result) { - userStore.remove(user); - } - }); - } - } - }); - dialog.show(); - } - - }).show(); - } - }); - } - - @Override - public void onApplicationSelected() { - new ApplicationSettingsDialog( - ApplicationContext.getInstance().getApplicationSettings(), - new ApplicationSettingsDialog.ApplicationSettingsHandler() { - @Override - public void onSave(ApplicationSettings applicationSettings) { - Application.getDataService().updateApplicationSettings(applicationSettings, new BaseAsyncCallback() { - @Override - public void onSuccess(ApplicationSettings result) { - ApplicationContext.getInstance().setApplicationSettings(result); - } - }); - } - }).show(); - } - -} diff --git a/src/org/traccar/web/client/controller/StateController.java b/src/org/traccar/web/client/controller/StateController.java deleted file mode 100644 index a19bec81..00000000 --- a/src/org/traccar/web/client/controller/StateController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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.traccar.web.client.controller; - -import org.traccar.web.client.model.StateItem; -import org.traccar.web.client.model.StateItemProperties; -import org.traccar.web.client.model.StateReader; -import org.traccar.web.client.view.StateView; -import org.traccar.web.shared.model.Position; - -import com.google.gwt.core.client.GWT; -import com.sencha.gxt.data.shared.ListStore; -import com.sencha.gxt.widget.core.client.ContentPanel; - -public class StateController implements ContentController { - - private ListStore stateStore; - - private StateView stateView; - - public StateController() { - StateItemProperties stateItemProperties = GWT.create(StateItemProperties.class); - stateStore = new ListStore(stateItemProperties.id()); - stateView = new StateView(stateStore); - } - - @Override - public ContentPanel getView() { - return stateView.getView(); - } - - @Override - public void run() { - } - - public void showState(Position position) { - if (position != null) { - stateStore.replaceAll(StateReader.getState(position)); - } else { - stateStore.clear(); - } - } - -} -- cgit v1.2.3