basic support for multiple cache lists
This commit is contained in:
@@ -52,7 +52,7 @@ dependencies {
|
|||||||
//compile group: 'org.jfxtras', name: 'jfxtras-labs', version: '8.0-r1-SNAPSHOT' this is not an actual version and the map part is missing
|
//compile group: 'org.jfxtras', name: 'jfxtras-labs', version: '8.0-r1-SNAPSHOT' this is not an actual version and the map part is missing
|
||||||
compile files('lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT.jar', 'lib/ScenicView/ScenicView.jar')
|
compile files('lib/JFXtras/jfxtras-labs-8.0-r1-SNAPSHOT.jar', 'lib/ScenicView/ScenicView.jar')
|
||||||
compile group: 'org.jdom', name: 'jdom2', version: '2.0.5'
|
compile group: 'org.jdom', name: 'jdom2', version: '2.0.5'
|
||||||
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.0.5'
|
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.0.6'
|
||||||
compile group: 'com.h2database', name: 'h2', version: '1.4.178'
|
compile group: 'com.h2database', name: 'h2', version: '1.4.178'
|
||||||
compile group: 'org.eclipse.persistence', name: 'eclipselink', version: '2.5.0'
|
compile group: 'org.eclipse.persistence', name: 'eclipselink', version: '2.5.0'
|
||||||
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.2.1'
|
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.2.1'
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<class>de.geofroggerfx.model.Type</class>
|
<class>de.geofroggerfx.model.Type</class>
|
||||||
<class>de.geofroggerfx.model.User</class>
|
<class>de.geofroggerfx.model.User</class>
|
||||||
<class>de.geofroggerfx.model.Waypoint</class>
|
<class>de.geofroggerfx.model.Waypoint</class>
|
||||||
|
<class>de.geofroggerfx.model.CacheList</class>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
|
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ import de.geofroggerfx.fx.components.MapPaneWrapper;
|
|||||||
import de.geofroggerfx.fx.components.GeocachingIcons;
|
import de.geofroggerfx.fx.components.GeocachingIcons;
|
||||||
import de.geofroggerfx.fx.components.IconManager;
|
import de.geofroggerfx.fx.components.IconManager;
|
||||||
import de.geofroggerfx.model.Cache;
|
import de.geofroggerfx.model.Cache;
|
||||||
|
import de.geofroggerfx.model.CacheList;
|
||||||
|
import de.geofroggerfx.service.CacheService;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
@@ -49,6 +53,7 @@ import javax.inject.Inject;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,6 +95,9 @@ public class CacheDetailsController implements Initializable, SessionContextList
|
|||||||
private CheckBox shortDescriptionHtml;
|
private CheckBox shortDescriptionHtml;
|
||||||
@FXML
|
@FXML
|
||||||
private CheckBox longDescriptionHtml;
|
private CheckBox longDescriptionHtml;
|
||||||
|
@FXML
|
||||||
|
private MenuButton addToListMenuButton;
|
||||||
|
|
||||||
|
|
||||||
private ImageView icon;
|
private ImageView icon;
|
||||||
private FadeTransition ft;
|
private FadeTransition ft;
|
||||||
@@ -101,6 +109,9 @@ public class CacheDetailsController implements Initializable, SessionContextList
|
|||||||
@Inject
|
@Inject
|
||||||
private SessionContext sessionContext;
|
private SessionContext sessionContext;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private CacheService cacheService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the controller class.
|
* Initializes the controller class.
|
||||||
*
|
*
|
||||||
@@ -119,11 +130,11 @@ public class CacheDetailsController implements Initializable, SessionContextList
|
|||||||
longDescriptionWebView = new WebView();
|
longDescriptionWebView = new WebView();
|
||||||
shortDescriptionField = new TextArea();
|
shortDescriptionField = new TextArea();
|
||||||
longDescriptionField = new TextArea();
|
longDescriptionField = new TextArea();
|
||||||
|
|
||||||
editableForm(false);
|
editableForm(false);
|
||||||
initFading();
|
initFading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sessionContextChanged() {
|
public void sessionContextChanged() {
|
||||||
Cache currentCache = (Cache) sessionContext.getData("current-cache");
|
Cache currentCache = (Cache) sessionContext.getData("current-cache");
|
||||||
@@ -136,8 +147,35 @@ public class CacheDetailsController implements Initializable, SessionContextList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void editCache(final ActionEvent actionEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setSessionListener() {
|
private void setSessionListener() {
|
||||||
sessionContext.addListener("current-cache", this);
|
sessionContext.addListener("current-cache", this);
|
||||||
|
sessionContext.addListener("cache-lists", () -> Platform.runLater(this::refreshCacheListMenu));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void refreshCacheListMenu() {
|
||||||
|
List<CacheList> cacheLists = (List<CacheList>) sessionContext.getData("cache-lists");
|
||||||
|
addToListMenuButton.getItems().clear();
|
||||||
|
cacheLists.stream().forEach(this::addToListMenuItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addToListMenuItem(CacheList cacheList) {
|
||||||
|
final MenuItem listItem = new MenuItem(cacheList.getName());
|
||||||
|
addToListMenuButton.getItems().add(listItem);
|
||||||
|
listItem.setOnAction(actionEvent -> addCacheAction(cacheList)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCacheAction(CacheList cacheList) {
|
||||||
|
Cache currentCache = (Cache) sessionContext.getData("current-cache");
|
||||||
|
cacheList.addCache(currentCache);
|
||||||
|
cacheService.storeCacheList(cacheList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFading() {
|
private void initFading() {
|
||||||
|
|||||||
@@ -12,14 +12,21 @@
|
|||||||
<HBox alignment="CENTER_LEFT" prefHeight="40.0" prefWidth="-1.0" styleClass="details-header"
|
<HBox alignment="CENTER_LEFT" prefHeight="40.0" prefWidth="-1.0" styleClass="details-header"
|
||||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
|
<Label fx:id="detailsIconHeader" alignment="CENTER_LEFT" maxWidth="-1.0" text="" textAlignment="LEFT"
|
||||||
|
wrapText="false" HBox.hgrow="ALWAYS"/>
|
||||||
|
|
||||||
<Label fx:id="cacheNameHeader" maxWidth="1.7976931348623157E308" text="" textFill="WHITE" underline="false"
|
<Label fx:id="cacheNameHeader" maxWidth="1.7976931348623157E308" text="" textFill="WHITE" underline="false"
|
||||||
HBox.hgrow="ALWAYS">
|
HBox.hgrow="ALWAYS">
|
||||||
<font>
|
<font>
|
||||||
<Font size="16.0"/>
|
<Font size="16.0"/>
|
||||||
</font>
|
</font>
|
||||||
</Label>
|
</Label>
|
||||||
<Label fx:id="detailsIconHeader" alignment="CENTER_RIGHT" maxWidth="-1.0" text="" textAlignment="LEFT"
|
<AnchorPane prefHeight="40.0">
|
||||||
wrapText="false" HBox.hgrow="ALWAYS"/>
|
<children>
|
||||||
|
<MenuButton fx:id="addToListMenuButton" mnemonicParsing="false" text="Add to list" AnchorPane.rightAnchor="10.0" />
|
||||||
|
<Button mnemonicParsing="false" onAction="#editCache" text="Edit coordinates" AnchorPane.rightAnchor="100.0" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
<padding>
|
||||||
<Insets left="16.0" right="16.0"/>
|
<Insets left="16.0" right="16.0"/>
|
||||||
|
|||||||
@@ -26,11 +26,11 @@
|
|||||||
package de.geofroggerfx.fx.cachelist;
|
package de.geofroggerfx.fx.cachelist;
|
||||||
|
|
||||||
import de.geofroggerfx.application.SessionContext;
|
import de.geofroggerfx.application.SessionContext;
|
||||||
import de.geofroggerfx.application.SessionContextListener;
|
|
||||||
import de.geofroggerfx.fx.components.CacheListCell;
|
import de.geofroggerfx.fx.components.CacheListCell;
|
||||||
import de.geofroggerfx.fx.components.IconManager;
|
import de.geofroggerfx.fx.components.IconManager;
|
||||||
import de.geofroggerfx.fx.components.SortingMenuItem;
|
import de.geofroggerfx.fx.components.SortingMenuItem;
|
||||||
import de.geofroggerfx.model.Cache;
|
import de.geofroggerfx.model.Cache;
|
||||||
|
import de.geofroggerfx.model.CacheList;
|
||||||
import de.geofroggerfx.service.CacheService;
|
import de.geofroggerfx.service.CacheService;
|
||||||
import de.geofroggerfx.service.CacheSortField;
|
import de.geofroggerfx.service.CacheSortField;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@@ -38,10 +38,7 @@ import javafx.beans.value.ChangeListener;
|
|||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.ListView;
|
|
||||||
import javafx.scene.control.Menu;
|
|
||||||
import javafx.scene.control.MenuButton;
|
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
|
|
||||||
@@ -58,7 +55,7 @@ import static de.geofroggerfx.service.CacheSortField.*;
|
|||||||
*
|
*
|
||||||
* @author Andreas
|
* @author Andreas
|
||||||
*/
|
*/
|
||||||
public class CacheListController implements Initializable, SessionContextListener {
|
public class CacheListController implements Initializable {
|
||||||
|
|
||||||
private static final String CACHE_LIST_ACTION_ICONS = "cache-list-action-icons";
|
private static final String CACHE_LIST_ACTION_ICONS = "cache-list-action-icons";
|
||||||
|
|
||||||
@@ -79,6 +76,9 @@ public class CacheListController implements Initializable, SessionContextListene
|
|||||||
@FXML
|
@FXML
|
||||||
private MenuButton menuIcon;
|
private MenuButton menuIcon;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ComboBox cacheListComboBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the controller class.
|
* Initializes the controller class.
|
||||||
*
|
*
|
||||||
@@ -96,19 +96,11 @@ public class CacheListController implements Initializable, SessionContextListene
|
|||||||
sessionContext.setData("current-cache", newValue)
|
sessionContext.setData("current-cache", newValue)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
initCacheListComboBox();
|
||||||
initListMenuButton(rb);
|
initListMenuButton(rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void sessionContextChanged() {
|
|
||||||
List<Cache> caches = (List<Cache>) sessionContext.getData("cache-list");
|
|
||||||
Platform.runLater(() -> {
|
|
||||||
cacheNumber.setText("(" + caches.size() + ")");
|
|
||||||
cacheListView.getItems().setAll(caches);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCellFactory() {
|
private void setCellFactory() {
|
||||||
cacheListView.setCellFactory(
|
cacheListView.setCellFactory(
|
||||||
(Callback<ListView<Cache>, CacheListCell>)
|
(Callback<ListView<Cache>, CacheListCell>)
|
||||||
@@ -116,7 +108,45 @@ public class CacheListController implements Initializable, SessionContextListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setSessionListener() {
|
private void setSessionListener() {
|
||||||
sessionContext.addListener("cache-list", this);
|
sessionContext.addListener("cache-list", () -> Platform.runLater(this::resetCacheList));
|
||||||
|
sessionContext.addListener("cache-lists", () -> Platform.runLater(this::refreshCacheListComboAndSelectFirst));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void resetCacheList() {
|
||||||
|
List<Cache> caches = (List<Cache>) sessionContext.getData("cache-list");
|
||||||
|
cacheNumber.setText("(" + caches.size() + ")");
|
||||||
|
cacheListView.getItems().setAll(caches);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private void refreshCacheListComboAndSelectFirst() {
|
||||||
|
List<CacheList> cacheLists = (List<CacheList>) sessionContext.getData("cache-lists");
|
||||||
|
cacheListComboBox.getItems().clear();
|
||||||
|
cacheListComboBox.getItems().add("All caches");
|
||||||
|
cacheListComboBox.getItems().addAll(cacheLists);
|
||||||
|
cacheListComboBox.getSelectionModel().selectFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initCacheListComboBox() {
|
||||||
|
cacheListComboBox.setOnAction(actionEvent -> {
|
||||||
|
final Object selectedItem = cacheListComboBox.getSelectionModel().getSelectedItem();
|
||||||
|
Platform.runLater(() -> cacheListSelectAction(selectedItem));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cacheListSelectAction(Object selectedItem) {
|
||||||
|
if (selectedItem != null) {
|
||||||
|
if (selectedItem.equals("All caches")) {
|
||||||
|
loadAllCaches();
|
||||||
|
} else{
|
||||||
|
CacheList cacheList = (CacheList)selectedItem;
|
||||||
|
sessionContext.setData("cache-list", cacheList.getCaches());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cacheListComboBox.getSelectionModel().selectFirst();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initListMenuButton(final ResourceBundle rb) {
|
private void initListMenuButton(final ResourceBundle rb) {
|
||||||
@@ -150,12 +180,14 @@ public class CacheListController implements Initializable, SessionContextListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentSortingButton.setSelected(true);
|
currentSortingButton.setSelected(true);
|
||||||
sessionContext.setData("cache-list", cacheService.getAllCaches(currentSortingButton.getField(), currentSortingButton.getSortDirection()));
|
loadAllCaches();
|
||||||
});
|
});
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadAllCaches() {
|
||||||
|
sessionContext.setData("cache-list", cacheService.getAllCaches(currentSortingButton.getField(), currentSortingButton.getSortDirection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<Label fx:id="cacheNumber" alignment="CENTER_LEFT" minWidth="60.0" prefWidth="-1.0" maxWidth="Infinity"
|
<Label fx:id="cacheNumber" alignment="CENTER_LEFT" minWidth="60.0" prefWidth="-1.0" maxWidth="Infinity"
|
||||||
style=" " text="(0)" textAlignment="LEFT" textFill="WHITE" wrapText="false" HBox.hgrow="ALWAYS">
|
style=" " text="(0)" textAlignment="LEFT" textFill="WHITE" wrapText="false" HBox.hgrow="ALWAYS">
|
||||||
</Label>
|
</Label>
|
||||||
|
<ComboBox fx:id="cacheListComboBox"/>
|
||||||
<MenuButton fx:id="menuIcon"/>
|
<MenuButton fx:id="menuIcon"/>
|
||||||
</children>
|
</children>
|
||||||
<padding>
|
<padding>
|
||||||
|
|||||||
@@ -1,3 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Andreas Billmann <abi@geofroggerfx.de>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
package de.geofroggerfx.fx.components;
|
package de.geofroggerfx.fx.components;
|
||||||
|
|
||||||
import de.geofroggerfx.service.CacheSortField;
|
import de.geofroggerfx.service.CacheSortField;
|
||||||
|
|||||||
@@ -39,8 +39,11 @@ import javafx.concurrent.Service;
|
|||||||
import javafx.concurrent.Task;
|
import javafx.concurrent.Task;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.layout.BorderPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import org.controlsfx.dialog.Dialog;
|
import org.controlsfx.dialog.Dialog;
|
||||||
|
|
||||||
@@ -101,6 +104,7 @@ public class GeofroggerController implements Initializable {
|
|||||||
private SessionContext sessionContext;
|
private SessionContext sessionContext;
|
||||||
private final LoadCachesFromFileService loadService = new LoadCachesFromFileService();
|
private final LoadCachesFromFileService loadService = new LoadCachesFromFileService();
|
||||||
private final LoadCachesFromDatabaseService loadFromDBService = new LoadCachesFromDatabaseService();
|
private final LoadCachesFromDatabaseService loadFromDBService = new LoadCachesFromDatabaseService();
|
||||||
|
private final LoadCacheListsFromDatabaseService loadListsFromDBService = new LoadCacheListsFromDatabaseService();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private GPXReader gpxReader;
|
private GPXReader gpxReader;
|
||||||
@@ -120,6 +124,13 @@ public class GeofroggerController implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private Menu pluginsMenu;
|
private Menu pluginsMenu;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private BorderPane mainPane;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private SplitPane contentPane;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the controller class.
|
* Initializes the controller class.
|
||||||
*
|
*
|
||||||
@@ -138,6 +149,7 @@ public class GeofroggerController implements Initializable {
|
|||||||
|
|
||||||
gpxReader.addListener((ProgressEvent event) -> updateStatus(event.getMessage(), event.getProgress()));
|
gpxReader.addListener((ProgressEvent event) -> updateStatus(event.getMessage(), event.getProgress()));
|
||||||
cacheService.addListener((ProgressEvent event) -> updateStatus(event.getMessage(), event.getProgress()));
|
cacheService.addListener((ProgressEvent event) -> updateStatus(event.getMessage(), event.getProgress()));
|
||||||
|
loadListsFromDBService.start();
|
||||||
loadFromDBService.start();
|
loadFromDBService.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +176,13 @@ public class GeofroggerController implements Initializable {
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void showSettings(ActionEvent actionEvent) {
|
||||||
|
// mainPane.setCenter();
|
||||||
|
|
||||||
|
// FXMLLoader.load()
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void exit(ActionEvent actionEvent) {
|
public void exit(ActionEvent actionEvent) {
|
||||||
Platform.exit();
|
Platform.exit();
|
||||||
@@ -176,6 +195,25 @@ public class GeofroggerController implements Initializable {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class LoadCacheListsFromDatabaseService extends Service {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Task createTask() {
|
||||||
|
return new Task() {
|
||||||
|
@Override
|
||||||
|
protected Void call() throws Exception {
|
||||||
|
updateStatus("Load cache lists from database.", ProgressIndicator.INDETERMINATE_PROGRESS);
|
||||||
|
sessionContext.setData("cache-lists", cacheService.getAllCacheLists());
|
||||||
|
updateStatus("All cache lists loaded.", 0);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private class LoadCachesFromDatabaseService extends Service {
|
private class LoadCachesFromDatabaseService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,12 +21,15 @@
|
|||||||
<Menu fx:id="pluginsMenu" mnemonicParsing="false" text="%menu.title.plugins"/>
|
<Menu fx:id="pluginsMenu" mnemonicParsing="false" text="%menu.title.plugins"/>
|
||||||
<Menu mnemonicParsing="false" text="%menu.title.help">
|
<Menu mnemonicParsing="false" text="%menu.title.help">
|
||||||
<items>
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#showSettings" text="%menu.title.settings"/>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#showAboutDialog" text="%menu.title.about"/>
|
<MenuItem mnemonicParsing="false" onAction="#showAboutDialog" text="%menu.title.about"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
</MenuBar>
|
</MenuBar>
|
||||||
<SplitPane dividerPositions="0.3779342723004695" focusTraversable="true" prefHeight="-1.0" prefWidth="-1.0"
|
<BorderPane fx:id="mainPane" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||||
|
<center>
|
||||||
|
<SplitPane fx:id="contentPane" dividerPositions="0.3779342723004695" focusTraversable="true" prefHeight="-1.0" prefWidth="-1.0"
|
||||||
VBox.vgrow="ALWAYS">
|
VBox.vgrow="ALWAYS">
|
||||||
<items>
|
<items>
|
||||||
<fx:include source="/de/geofroggerfx/fx/cachelist/cache_list.fxml" fx:id="cacheListContent"/>
|
<fx:include source="/de/geofroggerfx/fx/cachelist/cache_list.fxml" fx:id="cacheListContent"/>
|
||||||
@@ -37,6 +40,8 @@
|
|||||||
</ScrollPane>
|
</ScrollPane>
|
||||||
</items>
|
</items>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
||||||
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER">
|
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER">
|
||||||
<children>
|
<children>
|
||||||
<Pane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS"/>
|
<Pane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS"/>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ menu.title.import.gpx = Importiere GPX
|
|||||||
menu.title.file = Datei
|
menu.title.file = Datei
|
||||||
menu.title.quit = Beenden
|
menu.title.quit = Beenden
|
||||||
menu.title.help = Hilfe
|
menu.title.help = Hilfe
|
||||||
|
menu.title.settings = Einstellungen
|
||||||
menu.title.about = \u00dcber GeoFroggerFX
|
menu.title.about = \u00dcber GeoFroggerFX
|
||||||
menu.title.plugins = Plugins
|
menu.title.plugins = Plugins
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ menu.title.import.gpx = Import GPX
|
|||||||
menu.title.file = File
|
menu.title.file = File
|
||||||
menu.title.quit = Quit
|
menu.title.quit = Quit
|
||||||
menu.title.help = Help
|
menu.title.help = Help
|
||||||
|
menu.title.settings = Settings
|
||||||
menu.title.about = About GeoFroggerFX
|
menu.title.about = About GeoFroggerFX
|
||||||
menu.title.plugins = Plugins
|
menu.title.plugins = Plugins
|
||||||
|
|
||||||
|
|||||||
7
src/de/geofroggerfx/fx/settings/SettingsController.java
Normal file
7
src/de/geofroggerfx/fx/settings/SettingsController.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package de.geofroggerfx.fx.settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: change this
|
||||||
|
*/
|
||||||
|
public class SettingsController {
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
<?import java.net.URL?>
|
||||||
|
<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="de.geofroggerfx.fx.cachelist.CacheListController">
|
||||||
|
<children>
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="40.0" prefWidth="-1.0" styleClass="cache-header"
|
||||||
|
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
|
<children>
|
||||||
|
<Label alignment="CENTER_LEFT" minWidth="60.0" prefWidth="-1.0" style=" " text="%label.text.cache.list"
|
||||||
|
textAlignment="LEFT" textFill="WHITE" wrapText="false">
|
||||||
|
</Label>
|
||||||
|
<Label fx:id="cacheNumber" alignment="CENTER_LEFT" minWidth="60.0" prefWidth="-1.0" maxWidth="Infinity"
|
||||||
|
style=" " text="(0)" textAlignment="LEFT" textFill="WHITE" wrapText="false" HBox.hgrow="ALWAYS">
|
||||||
|
</Label>
|
||||||
|
<MenuButton fx:id="menuIcon"/>
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets left="16.0" right="16.0" fx:id="x2"/>
|
||||||
|
</padding>
|
||||||
|
</HBox>
|
||||||
|
<ListView fx:id="cacheListView" prefHeight="507.0" prefWidth="221.0" AnchorPane.bottomAnchor="0.0"
|
||||||
|
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="40.0"/>
|
||||||
|
</children>
|
||||||
|
<stylesheets>
|
||||||
|
<URL value="@/de/geofroggerfx/fx/geofrogger.css"/>
|
||||||
|
</stylesheets>
|
||||||
|
</AnchorPane>
|
||||||
@@ -240,6 +240,23 @@ public class Cache {
|
|||||||
this.found = found;
|
this.found = found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
Cache cache = (Cache) o;
|
||||||
|
|
||||||
|
if (id != null ? !id.equals(cache.id) : cache.id != null) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return id != null ? id.hashCode() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Cache{"
|
return "Cache{"
|
||||||
|
|||||||
91
src/de/geofroggerfx/model/CacheList.java
Normal file
91
src/de/geofroggerfx/model/CacheList.java
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014, Andreas Billmann <abi@geofroggerfx.de>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||||
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package de.geofroggerfx.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andreas Billmann
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
public class CacheList {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<Cache> caches;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@OneToMany(fetch= FetchType.LAZY)
|
||||||
|
public List<Cache> getCaches() {
|
||||||
|
return caches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaches(List<Cache> caches) {
|
||||||
|
this.caches = caches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCache(Cache cache) {
|
||||||
|
if (!getCaches().contains(cache)) {
|
||||||
|
getCaches().add(cache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
CacheList cacheList = (CacheList) o;
|
||||||
|
|
||||||
|
if (!name.equals(cacheList.name)) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return name.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CacheList{" +
|
||||||
|
"name='" + name + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ package de.geofroggerfx.service;
|
|||||||
|
|
||||||
import de.geofroggerfx.application.ProgressListener;
|
import de.geofroggerfx.application.ProgressListener;
|
||||||
import de.geofroggerfx.model.Cache;
|
import de.geofroggerfx.model.Cache;
|
||||||
|
import de.geofroggerfx.model.CacheList;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -35,9 +36,36 @@ import java.util.List;
|
|||||||
* @author Andreas
|
* @author Andreas
|
||||||
*/
|
*/
|
||||||
public interface CacheService {
|
public interface CacheService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the whole list of caches
|
||||||
|
* @param caches list of caches
|
||||||
|
*/
|
||||||
void storeCaches(List<Cache> caches);
|
void storeCaches(List<Cache> caches);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive all caches from the database
|
||||||
|
* @param sortField sort the list based on the field
|
||||||
|
* @param direction sort direction (ASC/DESC)
|
||||||
|
* @return sorted list of caches
|
||||||
|
*/
|
||||||
List<Cache> getAllCaches(CacheSortField sortField, SortDirection direction);
|
List<Cache> getAllCaches(CacheSortField sortField, SortDirection direction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a ProgressListener to inform about loading/storing progress.
|
||||||
|
* @param listener progress listener
|
||||||
|
*/
|
||||||
void addListener(ProgressListener listener);
|
void addListener(ProgressListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive all cache lists
|
||||||
|
* @return list of available cachelists
|
||||||
|
*/
|
||||||
|
List<CacheList> getAllCacheLists();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores a cache list
|
||||||
|
* @param list list of caches
|
||||||
|
*/
|
||||||
|
void storeCacheList(CacheList list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ package de.geofroggerfx.service;
|
|||||||
|
|
||||||
import de.geofroggerfx.application.ProgressEvent;
|
import de.geofroggerfx.application.ProgressEvent;
|
||||||
import de.geofroggerfx.application.ProgressListener;
|
import de.geofroggerfx.application.ProgressListener;
|
||||||
import de.geofroggerfx.model.Attribute;
|
import de.geofroggerfx.model.*;
|
||||||
import de.geofroggerfx.model.Cache;
|
|
||||||
import de.geofroggerfx.model.Log;
|
|
||||||
import de.geofroggerfx.model.TravelBug;
|
|
||||||
import de.geofroggerfx.sql.DatabaseService;
|
import de.geofroggerfx.sql.DatabaseService;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -99,6 +96,7 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
public List<Cache> getAllCaches(CacheSortField sortField, SortDirection direction) {
|
public List<Cache> getAllCaches(CacheSortField sortField, SortDirection direction) {
|
||||||
|
|
||||||
List<Cache> caches = new ArrayList<>();
|
List<Cache> caches = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
EntityManager em = dbService.getEntityManager();
|
EntityManager em = dbService.getEntityManager();
|
||||||
String query = "select c from Cache c order by c."+sortField.getFieldName()+" "+direction.toString();
|
String query = "select c from Cache c order by c."+sortField.getFieldName()+" "+direction.toString();
|
||||||
@@ -117,6 +115,39 @@ public class CacheServiceImpl implements CacheService {
|
|||||||
listeners.stream().forEach((l) -> l.progress(event));
|
listeners.stream().forEach((l) -> l.progress(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive all cache lists
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<CacheList> getAllCacheLists() {
|
||||||
|
List<CacheList> lists = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
EntityManager em = dbService.getEntityManager();
|
||||||
|
String query = "select l from CacheList l order by l.name";
|
||||||
|
List<CacheList> result = em.createQuery(query).getResultList();
|
||||||
|
if (result != null) {
|
||||||
|
lists = result;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return lists;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void storeCacheList(CacheList list) {
|
||||||
|
EntityManager em = dbService.getEntityManager();
|
||||||
|
try {
|
||||||
|
em.getTransaction().begin();
|
||||||
|
em.persist(list);
|
||||||
|
em.getTransaction().commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
em.getTransaction().rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user