changed the package name to the domain name
This commit is contained in:
97
src/de/geofroggerfx/fx/GeoFroggerFXMain.java
Normal file
97
src/de/geofroggerfx/fx/GeoFroggerFXMain.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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;
|
||||
|
||||
import de.geofroggerfx.application.ServiceManager;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.stage.Stage;
|
||||
import org.scenicview.ScenicView;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author Andreas
|
||||
*/
|
||||
public class GeoFroggerFXMain extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
loadCustomFonts();
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("geofrogger/geofrogger.fxml"), ResourceBundle.getBundle("de.geofroggerfx.fx.geofrogger"));
|
||||
Parent root = (Parent)fxmlLoader.load();
|
||||
Scene scene = new Scene(root);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
||||
scene.setOnKeyPressed(keyEvent -> {
|
||||
if (isScenicViewShortcutPressed(keyEvent)) {
|
||||
ScenicView.show(scene);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadCustomFonts() {
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraMonoOT-Bold.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraMonoOT-Regular.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-Bold.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-BoldItalic.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-Light.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-LightItalic.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-Medium.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-MediumItalic.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-Regular.otf").toExternalForm(), 12);
|
||||
Font.loadFont(GeoFroggerFXMain.class.getResource("/fonts/FiraSansOT-RegularItalic.otf").toExternalForm(), 12);
|
||||
}
|
||||
|
||||
private boolean isScenicViewShortcutPressed(final KeyEvent keyEvent) {
|
||||
return keyEvent.isAltDown() && keyEvent.isControlDown() && keyEvent.getCode().equals(KeyCode.V);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
ServiceManager.getInstance().getDatabaseService().getEntityManager().close();
|
||||
super.stop();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The main() method is ignored in correctly deployed JavaFX application.
|
||||
* main() serves only as fallback in case the application can not be
|
||||
* launched through deployment artifacts, e.g., in IDEs with limited FX
|
||||
* support. NetBeans ignores main().
|
||||
*
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
247
src/de/geofroggerfx/fx/cachedetails/CacheDetailsController.java
Normal file
247
src/de/geofroggerfx/fx/cachedetails/CacheDetailsController.java
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.cachedetails;
|
||||
|
||||
import de.geofroggerfx.application.SessionContext;
|
||||
import de.geofroggerfx.application.SessionContextListener;
|
||||
import de.geofroggerfx.fx.components.MapPaneWrapper;
|
||||
import de.geofroggerfx.fx.components.GeocachingIcons;
|
||||
import de.geofroggerfx.fx.components.IconManager;
|
||||
import de.geofroggerfx.model.Cache;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
import javafx.util.Duration;
|
||||
import jfxtras.labs.map.render.ImageMapMarker;
|
||||
import jfxtras.labs.map.render.MapMarkable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* FXML Controller class
|
||||
*
|
||||
* @author Andreas
|
||||
*/
|
||||
public class CacheDetailsController implements Initializable, SessionContextListener {
|
||||
|
||||
@FXML
|
||||
private AnchorPane cacheDetailPane;
|
||||
@FXML
|
||||
private Label cacheNameHeader;
|
||||
@FXML
|
||||
private Label detailsIconHeader;
|
||||
@FXML
|
||||
private TextField cacheName;
|
||||
@FXML
|
||||
private Slider difficultySlider;
|
||||
@FXML
|
||||
private Slider terrainSlider;
|
||||
@FXML
|
||||
private TextField placedByTextfield;
|
||||
@FXML
|
||||
private TextField ownerTextfield;
|
||||
@FXML
|
||||
private MapPaneWrapper mapPaneWrapper;
|
||||
@FXML
|
||||
private DatePicker date;
|
||||
@FXML
|
||||
private TextField typeTextfield;
|
||||
@FXML
|
||||
private TextField containerTextfield;
|
||||
@FXML
|
||||
private BorderPane shortDescriptionPane;
|
||||
@FXML
|
||||
private BorderPane longDescriptionPane;
|
||||
@FXML
|
||||
private CheckBox shortDescriptionHtml;
|
||||
@FXML
|
||||
private CheckBox longDescriptionHtml;
|
||||
|
||||
private ImageView icon;
|
||||
private FadeTransition ft;
|
||||
private TextArea shortDescriptionField;
|
||||
private TextArea longDescriptionField;
|
||||
private WebView shortDescriptionWebView;
|
||||
private WebView longDescriptionWebView;
|
||||
|
||||
private final SessionContext sessionContext = SessionContext.getInstance();
|
||||
|
||||
/**
|
||||
* Initializes the controller class.
|
||||
*
|
||||
* @param url
|
||||
* @param rb
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
setSessionListener();
|
||||
cacheNameHeader.textProperty().bind(cacheName.textProperty());
|
||||
detailsIconHeader.getStyleClass().add("cache-list-icon");
|
||||
icon = new ImageView();
|
||||
detailsIconHeader.setGraphic(icon);
|
||||
cacheDetailPane.setOpacity(0.3);
|
||||
shortDescriptionWebView = new WebView();
|
||||
longDescriptionWebView = new WebView();
|
||||
shortDescriptionField = new TextArea();
|
||||
longDescriptionField = new TextArea();
|
||||
editableForm(false);
|
||||
initFading();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sessionContextChanged() {
|
||||
Cache currentCache = (Cache) sessionContext.getData("current-cache");
|
||||
if (currentCache != null) {
|
||||
fillForm(currentCache);
|
||||
fadeIn();
|
||||
} else {
|
||||
resetForm();
|
||||
fadeOut();
|
||||
}
|
||||
}
|
||||
|
||||
private void setSessionListener() {
|
||||
sessionContext.addListener("current-cache", this);
|
||||
}
|
||||
|
||||
private void initFading() {
|
||||
ft = new FadeTransition(Duration.millis(1000), cacheDetailPane);
|
||||
ft.setCycleCount(1);
|
||||
ft.setAutoReverse(false);
|
||||
}
|
||||
|
||||
private void fadeIn() {
|
||||
ft.setFromValue(0.3);
|
||||
ft.setToValue(1.0);
|
||||
ft.playFromStart();
|
||||
}
|
||||
|
||||
private void fadeOut() {
|
||||
ft.setFromValue(1.0);
|
||||
ft.setToValue(0.3);
|
||||
ft.playFromStart();
|
||||
}
|
||||
|
||||
private void resetForm() {
|
||||
cacheName.setText("");
|
||||
difficultySlider.setValue(1.0);
|
||||
terrainSlider.setValue(1.0);
|
||||
detailsIconHeader.setText("");
|
||||
placedByTextfield.setText("");
|
||||
ownerTextfield.setText("");
|
||||
date.setValue(LocalDate.now());
|
||||
typeTextfield.setText("");
|
||||
containerTextfield.setText("");
|
||||
shortDescriptionPane.setCenter(null);
|
||||
longDescriptionPane.setCenter(null);
|
||||
// final double lat = currentCache.getMainWayPoint().getLatitude();
|
||||
// final double lon = currentCache.getMainWayPoint().getLongitude();
|
||||
// mapPaneWrapper.setDisplayPositionByLatLon(lat, lon, 15);
|
||||
//
|
||||
// MapMarkable marker = new ImageMapMarker(GeocachingIcons.getMapIcon(currentCache, IconManager.IconSize.BIG), lat, lon);
|
||||
// mapPaneWrapper.setMapMarkerList(Arrays.asList(marker));
|
||||
}
|
||||
|
||||
private void fillForm(Cache currentCache) throws NumberFormatException {
|
||||
cacheName.setText(currentCache.getName());
|
||||
difficultySlider.setValue(Double.parseDouble(currentCache.getDifficulty()));
|
||||
terrainSlider.setValue(Double.parseDouble(currentCache.getTerrain()));
|
||||
icon.setImage(GeocachingIcons.getIcon(currentCache));
|
||||
placedByTextfield.setText(currentCache.getPlacedBy());
|
||||
ownerTextfield.setText(currentCache.getOwner().getName());
|
||||
date.setValue(currentCache.getMainWayPoint().getTime().toLocalDate());
|
||||
typeTextfield.setText(currentCache.getType().toGroundspeakString());
|
||||
containerTextfield.setText(currentCache.getContainer());
|
||||
fillShortDescription(currentCache);
|
||||
fillLongDescription(currentCache);
|
||||
|
||||
fillMap(currentCache);
|
||||
}
|
||||
|
||||
private void fillMap(Cache currentCache) {
|
||||
final double lat = currentCache.getMainWayPoint().getLatitude();
|
||||
final double lon = currentCache.getMainWayPoint().getLongitude();
|
||||
mapPaneWrapper.setDisplayPositionByLatLon(lat, lon, 15);
|
||||
|
||||
MapMarkable marker = new ImageMapMarker(GeocachingIcons.getMapIcon(currentCache, IconManager.IconSize.BIG), lat, lon);
|
||||
mapPaneWrapper.setMapMarkerList(Arrays.asList(marker));
|
||||
}
|
||||
|
||||
private void fillShortDescription(Cache currentCache) {
|
||||
Node shortDescriptionNode;
|
||||
if (currentCache.isShortDescriptionHtml()) {
|
||||
final WebEngine webEngine = shortDescriptionWebView.getEngine();
|
||||
webEngine.loadContent(currentCache.getShortDescription());
|
||||
shortDescriptionNode = shortDescriptionWebView;
|
||||
} else {
|
||||
shortDescriptionField.setText(currentCache.getShortDescription());
|
||||
shortDescriptionNode = shortDescriptionField;
|
||||
}
|
||||
shortDescriptionPane.setCenter(shortDescriptionNode);
|
||||
shortDescriptionHtml.setSelected(currentCache.isShortDescriptionHtml());
|
||||
}
|
||||
|
||||
private void fillLongDescription(Cache currentCache) {
|
||||
Node longDescriptionNode;
|
||||
if (currentCache.isLongDescriptionHtml()) {
|
||||
final WebEngine webEngine = longDescriptionWebView.getEngine();
|
||||
webEngine.loadContent(currentCache.getLongDescription());
|
||||
longDescriptionNode = longDescriptionWebView;
|
||||
} else {
|
||||
longDescriptionField.setText(currentCache.getLongDescription());
|
||||
longDescriptionNode = longDescriptionField;
|
||||
}
|
||||
longDescriptionPane.setCenter(longDescriptionNode);
|
||||
longDescriptionHtml.setSelected(currentCache.isLongDescriptionHtml());
|
||||
}
|
||||
|
||||
private void editableForm(boolean editable) {
|
||||
cacheName.setEditable(editable);
|
||||
difficultySlider.setDisable(!editable);
|
||||
terrainSlider.setDisable(!editable);
|
||||
placedByTextfield.setEditable(editable);
|
||||
ownerTextfield.setEditable(editable);
|
||||
date.setDisable(!editable);
|
||||
typeTextfield.setEditable(editable);
|
||||
containerTextfield.setEditable(editable);
|
||||
shortDescriptionHtml.setDisable(!editable);
|
||||
longDescriptionHtml.setDisable(!editable);
|
||||
shortDescriptionField.setEditable(editable);
|
||||
longDescriptionField.setEditable(editable);
|
||||
}
|
||||
|
||||
}
|
||||
147
src/de/geofroggerfx/fx/cachedetails/cache_details.fxml
Normal file
147
src/de/geofroggerfx/fx/cachedetails/cache_details.fxml
Normal file
@@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import de.geofroggerfx.fx.components.MapPaneWrapper?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import java.net.URL?>
|
||||
<AnchorPane fx:id="cacheDetailPane" styleClass="details-pane" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="de.geofroggerfx.fx.cachedetails.CacheDetailsController">
|
||||
<children>
|
||||
<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">
|
||||
<children>
|
||||
<Label fx:id="cacheNameHeader" maxWidth="1.7976931348623157E308" text="" textFill="WHITE" underline="false"
|
||||
HBox.hgrow="ALWAYS">
|
||||
<font>
|
||||
<Font size="16.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
<Label fx:id="detailsIconHeader" alignment="CENTER_RIGHT" maxWidth="-1.0" text="" textAlignment="LEFT"
|
||||
wrapText="false" HBox.hgrow="ALWAYS"/>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets left="16.0" right="16.0"/>
|
||||
</padding>
|
||||
</HBox>
|
||||
<TabPane side="BOTTOM" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
||||
AnchorPane.topAnchor="40.0">
|
||||
<Tab closable="false" text="%tab.text.general">
|
||||
<content>
|
||||
<AnchorPane>
|
||||
<GridPane alignment="TOP_LEFT" gridLinesVisible="false" hgap="16.0" snapToPixel="true" styleClass="form"
|
||||
vgap="16.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
||||
AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Label text="%label.text.name" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
|
||||
<TextField fx:id="cacheName" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="0"/>
|
||||
|
||||
<Label text="%label.text.difficulty" GridPane.columnIndex="0" GridPane.rowIndex="1"/>
|
||||
<Slider fx:id="difficultySlider" blockIncrement="0.5" majorTickUnit="1.0" max="5.0" min="1.0"
|
||||
minorTickCount="1" showTickLabels="true" showTickMarks="true" snapToTicks="true" value="1.0"
|
||||
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="%label.text.terrain" GridPane.columnIndex="2" GridPane.rowIndex="1"/>
|
||||
<Slider fx:id="terrainSlider" blockIncrement="0.5" majorTickUnit="1.0" max="5.0" min="1.0"
|
||||
minorTickCount="1" showTickLabels="true" showTickMarks="true" snapToTicks="true"
|
||||
GridPane.columnIndex="3" GridPane.rowIndex="1"/>
|
||||
|
||||
<Label text="%label.text.placedBy" GridPane.columnIndex="0" GridPane.rowIndex="2">
|
||||
<labelFor>
|
||||
<TextField fx:id="placedByTextfield" prefWidth="200.0" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="2"/>
|
||||
</labelFor>
|
||||
</Label>
|
||||
<fx:reference source="placedByTextfield"/>
|
||||
|
||||
<Label text="%label.text.owner" GridPane.columnIndex="2" GridPane.rowIndex="2">
|
||||
<labelFor>
|
||||
<TextField fx:id="ownerTextfield" prefWidth="200.0" GridPane.columnIndex="3" GridPane.rowIndex="2"/>
|
||||
</labelFor>
|
||||
</Label>
|
||||
<fx:reference source="ownerTextfield"/>
|
||||
|
||||
<Label text="%label.text.date" GridPane.columnIndex="0" GridPane.rowIndex="3"/>
|
||||
<DatePicker fx:id="date" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
|
||||
<Label text="%label.text.type" GridPane.columnIndex="0" GridPane.rowIndex="4">
|
||||
<labelFor>
|
||||
<TextField fx:id="typeTextfield" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="4"/>
|
||||
</labelFor>
|
||||
</Label>
|
||||
<fx:reference source="typeTextfield"/>
|
||||
|
||||
<Label text="%label.text.container" GridPane.columnIndex="2" GridPane.rowIndex="4">
|
||||
<labelFor>
|
||||
<TextField fx:id="containerTextfield" prefWidth="200.0" GridPane.columnIndex="3"
|
||||
GridPane.rowIndex="4"/>
|
||||
</labelFor>
|
||||
</Label>
|
||||
<fx:reference source="containerTextfield"/>
|
||||
|
||||
|
||||
</children>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="NEVER" prefWidth="-1.0"/>
|
||||
<ColumnConstraints fillWidth="true" hgrow="ALWAYS"/>
|
||||
<ColumnConstraints halignment="RIGHT" hgrow="NEVER" prefWidth="-1.0"/>
|
||||
<ColumnConstraints fillWidth="true" hgrow="ALWAYS"/>
|
||||
</columnConstraints>
|
||||
<padding>
|
||||
<Insets bottom="16.0" left="16.0" right="16.0" top="16.0"/>
|
||||
</padding>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="TOP" vgrow="NEVER"/>
|
||||
<RowConstraints minHeight="-Infinity" prefHeight="-1.0" valignment="TOP" vgrow="NEVER"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="TOP" vgrow="NEVER"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="TOP" vgrow="NEVER"/>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="TOP" vgrow="NEVER"/>
|
||||
</rowConstraints>
|
||||
</GridPane>
|
||||
<MapPaneWrapper fx:id="mapPaneWrapper" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="18.0"
|
||||
AnchorPane.leftAnchor="18.0" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="260.0"/>
|
||||
</AnchorPane>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab closable="false" text="%tab.text.descriptions">
|
||||
<content>
|
||||
<GridPane alignment="TOP_LEFT" gridLinesVisible="false" hgap="16.0" snapToPixel="true" styleClass="form"
|
||||
vgap="16.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
||||
AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<Label text="%label.text.shortdescription" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
|
||||
<CheckBox fx:id="shortDescriptionHtml" text="%label.text.htmldescription" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="0"/>
|
||||
<BorderPane fx:id="shortDescriptionPane" GridPane.columnSpan="2" GridPane.columnIndex="0"
|
||||
GridPane.rowIndex="1"/>
|
||||
<Label text="%label.text.longdescription" GridPane.columnIndex="0" GridPane.rowIndex="2"/>
|
||||
<CheckBox fx:id="longDescriptionHtml" text="%label.text.htmldescription" GridPane.columnIndex="1"
|
||||
GridPane.rowIndex="2"/>
|
||||
<BorderPane fx:id="longDescriptionPane" GridPane.columnSpan="2" GridPane.columnIndex="0"
|
||||
GridPane.rowIndex="3"/>
|
||||
</children>
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints fillWidth="true" hgrow="NEVER"/>
|
||||
<ColumnConstraints fillWidth="true" hgrow="ALWAYS"/>
|
||||
</columnConstraints>
|
||||
<padding>
|
||||
<Insets bottom="16.0" left="16.0" right="16.0" top="16.0"/>
|
||||
</padding>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="16" valignment="TOP" vgrow="NEVER"/>
|
||||
<RowConstraints minHeight="150" valignment="TOP" vgrow="ALWAYS"/>
|
||||
<RowConstraints minHeight="16" valignment="TOP" vgrow="NEVER"/>
|
||||
<RowConstraints minHeight="350" valignment="TOP" vgrow="ALWAYS"/>
|
||||
</rowConstraints>
|
||||
</GridPane>
|
||||
</content>
|
||||
</Tab>
|
||||
</TabPane>
|
||||
</children>
|
||||
<stylesheets>
|
||||
<URL value="@../geofrogger.css"/>
|
||||
</stylesheets>
|
||||
</AnchorPane>
|
||||
154
src/de/geofroggerfx/fx/cachelist/CacheListController.java
Normal file
154
src/de/geofroggerfx/fx/cachelist/CacheListController.java
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.cachelist;
|
||||
|
||||
import de.geofroggerfx.application.ServiceManager;
|
||||
import de.geofroggerfx.application.SessionContext;
|
||||
import de.geofroggerfx.application.SessionContextListener;
|
||||
import de.geofroggerfx.fx.components.CacheListCell;
|
||||
import de.geofroggerfx.fx.components.IconManager;
|
||||
import de.geofroggerfx.fx.components.SortingMenuItem;
|
||||
import de.geofroggerfx.model.Cache;
|
||||
import de.geofroggerfx.service.CacheService;
|
||||
import de.geofroggerfx.service.CacheSortField;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.util.Callback;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static de.geofroggerfx.fx.utils.JavaFXUtils.addClasses;
|
||||
import static de.geofroggerfx.service.CacheSortField.*;
|
||||
|
||||
/**
|
||||
* FXML Controller class
|
||||
*
|
||||
* @author Andreas
|
||||
*/
|
||||
public class CacheListController implements Initializable, SessionContextListener {
|
||||
|
||||
private static final String CACHE_LIST_ACTION_ICONS = "cache-list-action-icons";
|
||||
|
||||
private final SessionContext sessionContext = SessionContext.getInstance();
|
||||
private final CacheService cacheService = ServiceManager.getInstance().getCacheService();
|
||||
private SortingMenuItem currentSortingButton = null;
|
||||
|
||||
@FXML
|
||||
private ListView cacheListView;
|
||||
|
||||
@FXML
|
||||
private Label cacheNumber;
|
||||
|
||||
@FXML
|
||||
private MenuButton menuIcon;
|
||||
|
||||
/**
|
||||
* Initializes the controller class.
|
||||
*
|
||||
* @param url
|
||||
* @param rb
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
setSessionListener();
|
||||
setCellFactory();
|
||||
|
||||
cacheListView.getSelectionModel().selectedItemProperty().addListener(
|
||||
(ChangeListener<Cache>) (ObservableValue<? extends Cache> ov, Cache oldValue, Cache newValue) ->
|
||||
sessionContext.setData("current-cache", newValue)
|
||||
);
|
||||
|
||||
initListMenuButton(rb);
|
||||
}
|
||||
|
||||
@Override
|
||||
@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() {
|
||||
cacheListView.setCellFactory(
|
||||
(Callback<ListView<Cache>, CacheListCell>)
|
||||
(ListView<Cache> p) -> new CacheListCell());
|
||||
}
|
||||
|
||||
private void setSessionListener() {
|
||||
sessionContext.addListener("cache-list", this);
|
||||
}
|
||||
|
||||
private void initListMenuButton(final ResourceBundle rb) {
|
||||
addClasses(menuIcon, CACHE_LIST_ACTION_ICONS);
|
||||
menuIcon.setGraphic(new ImageView(IconManager.getIcon("iconmonstr-menu-icon.png", IconManager.IconSize.SMALL)));
|
||||
menuIcon.getItems().addAll(createSortMenu(rb));
|
||||
}
|
||||
|
||||
private Menu createSortMenu(final ResourceBundle rb) {
|
||||
Menu sortMenu = new Menu(rb.getString("menu.title.sort"));
|
||||
currentSortingButton = createSortButton(rb, NAME);
|
||||
currentSortingButton.setSelected(true);
|
||||
sortMenu.getItems().addAll(
|
||||
currentSortingButton,
|
||||
createSortButton(rb, TYPE),
|
||||
createSortButton(rb, DIFFICULTY),
|
||||
createSortButton(rb, TERRAIN),
|
||||
createSortButton(rb, OWNER),
|
||||
createSortButton(rb, PLACEDBY));
|
||||
return sortMenu;
|
||||
}
|
||||
|
||||
private SortingMenuItem createSortButton(final ResourceBundle rb, final CacheSortField field) {
|
||||
SortingMenuItem button = new SortingMenuItem(rb.getString("sort.cache."+field.getFieldName()), field);
|
||||
button.setOnAction(actionEvent -> {
|
||||
|
||||
// if there was another button selected, change the selection
|
||||
if (!currentSortingButton.equals(button)) {
|
||||
currentSortingButton.setSelected(false);
|
||||
currentSortingButton = button;
|
||||
}
|
||||
|
||||
currentSortingButton.setSelected(true);
|
||||
sessionContext.setData("cache-list", cacheService.getAllCaches(currentSortingButton.getField(), currentSortingButton.getSortDirection()));
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
31
src/de/geofroggerfx/fx/cachelist/cache_list.fxml
Normal file
31
src/de/geofroggerfx/fx/cachelist/cache_list.fxml
Normal file
@@ -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="@../geofrogger.css"/>
|
||||
</stylesheets>
|
||||
</AnchorPane>
|
||||
144
src/de/geofroggerfx/fx/components/CacheListCell.java
Normal file
144
src/de/geofroggerfx/fx/components/CacheListCell.java
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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;
|
||||
|
||||
import de.geofroggerfx.model.Cache;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.ColumnConstraints;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
import static de.geofroggerfx.fx.utils.JavaFXUtils.addClasses;
|
||||
import static de.geofroggerfx.fx.utils.JavaFXUtils.removeClasses;
|
||||
|
||||
/**
|
||||
* Multi-Column-Row list cell to shows the most important data in a list.
|
||||
*
|
||||
* @author Andreas
|
||||
*/
|
||||
public class CacheListCell extends ListCell<Cache> {
|
||||
private static final String CACHE_LIST_FOUND_CLASS = "cache-list-found";
|
||||
private static final String CACHE_LIST_NOT_FOUND_CLASS = "cache-list-not-found";
|
||||
private static final String CACHE_LIST_NAME_CLASS = "cache-list-name";
|
||||
private static final String CACHE_LIST_DT_CLASS = "cache-list-dt";
|
||||
private static final String CACHE_LIST_ICON_CLASS = "cache-list-icon";
|
||||
|
||||
private final GridPane grid = new GridPane();
|
||||
private final ImageView icon = new ImageView();
|
||||
private final Label name = new Label();
|
||||
private final Label dt = new Label();
|
||||
private final Label owner = new Label();
|
||||
private final ImageView foundIcon = new ImageView();
|
||||
|
||||
public CacheListCell() {
|
||||
configureGrid();
|
||||
configureIcon();
|
||||
configureName();
|
||||
configureDifficultyTerrain();
|
||||
addControlsToGrid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateItem(Cache cache, boolean empty) {
|
||||
super.updateItem(cache, empty);
|
||||
if (empty) {
|
||||
clearContent();
|
||||
} else {
|
||||
addContent(cache);
|
||||
}
|
||||
}
|
||||
|
||||
private void configureGrid() {
|
||||
grid.setHgap(10);
|
||||
grid.setVgap(4);
|
||||
grid.setPadding(new Insets(0, 10, 0, 10));
|
||||
|
||||
ColumnConstraints column1 = new ColumnConstraints(32);
|
||||
ColumnConstraints column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE);
|
||||
column2.setHgrow(Priority.ALWAYS);
|
||||
ColumnConstraints column3 = new ColumnConstraints(100, 100, 200);
|
||||
column3.setHgrow(Priority.SOMETIMES);
|
||||
ColumnConstraints column4 = new ColumnConstraints(32);
|
||||
grid.getColumnConstraints().addAll(column1, column2, column3, column4);
|
||||
}
|
||||
|
||||
private void configureIcon() {
|
||||
icon.getStyleClass().add(CACHE_LIST_ICON_CLASS);
|
||||
}
|
||||
|
||||
private void configureName() {
|
||||
name.getStyleClass().add(CACHE_LIST_NAME_CLASS);
|
||||
}
|
||||
|
||||
private void configureDifficultyTerrain() {
|
||||
dt.getStyleClass().add(CACHE_LIST_DT_CLASS);
|
||||
}
|
||||
|
||||
private void addControlsToGrid() {
|
||||
grid.add(icon, 0, 0, 1, 2);
|
||||
grid.add(name, 1, 0, 2, 1);
|
||||
grid.add(dt, 2, 1);
|
||||
grid.add(owner, 1, 1);
|
||||
grid.add(foundIcon, 3, 0);
|
||||
}
|
||||
|
||||
private void clearContent() {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
}
|
||||
|
||||
private void addContent(Cache cache) {
|
||||
setText(null);
|
||||
icon.setImage(GeocachingIcons.getIcon(cache));
|
||||
name.setText(cache.getName());
|
||||
dt.setText("D: " + cache.getDifficulty() + " / T:" + cache.getTerrain());
|
||||
|
||||
String ownerText = cache.getPlacedBy().equals(cache.getOwner().getName()) ? cache.getPlacedBy() : cache.getPlacedBy() + " (" + cache.getOwner().getName() + ")";
|
||||
owner.setText(ownerText);
|
||||
|
||||
if (cache.isFound()) {
|
||||
foundIcon.setImage(IconManager.getIcon("iconmonstr-check-mark-11-icon.png", IconManager.IconSize.SMALL));
|
||||
} else {
|
||||
foundIcon.setImage(null);
|
||||
}
|
||||
|
||||
setStyleClassDependingOnFoundState(cache);
|
||||
setGraphic(grid);
|
||||
}
|
||||
|
||||
private void setStyleClassDependingOnFoundState(Cache cache) {
|
||||
if (cache.isFound()) {
|
||||
addClasses(this, CACHE_LIST_FOUND_CLASS);
|
||||
removeClasses(this, CACHE_LIST_NOT_FOUND_CLASS);
|
||||
} else {
|
||||
addClasses(this, CACHE_LIST_NOT_FOUND_CLASS);
|
||||
removeClasses(this, CACHE_LIST_FOUND_CLASS);
|
||||
}
|
||||
}
|
||||
}
|
||||
99
src/de/geofroggerfx/fx/components/GeocachingIcons.java
Normal file
99
src/de/geofroggerfx/fx/components/GeocachingIcons.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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;
|
||||
|
||||
import de.geofroggerfx.model.Cache;
|
||||
import javafx.scene.image.Image;
|
||||
|
||||
/**
|
||||
* @author Andreas
|
||||
*/
|
||||
public class GeocachingIcons {
|
||||
|
||||
public static Image getIcon(Cache cache) {
|
||||
return getIcon(cache, IconManager.IconSize.MIDDLE);
|
||||
}
|
||||
|
||||
public static Image getIcon(Cache cache, IconManager.IconSize size) {
|
||||
String iconName = "iconmonstr-map-5-icon.png";
|
||||
|
||||
switch (cache.getType()) {
|
||||
case MULTI_CACHE:
|
||||
iconName = "iconmonstr-map-6-icon.png";
|
||||
break;
|
||||
|
||||
case TRADITIONAL_CACHE:
|
||||
iconName = "iconmonstr-map-5-icon.png";
|
||||
break;
|
||||
|
||||
case UNKNOWN_CACHE:
|
||||
iconName = "iconmonstr-help-3-icon.png";
|
||||
break;
|
||||
|
||||
case EARTH_CACHE:
|
||||
iconName = "iconmonstr-globe-4-icon.png";
|
||||
break;
|
||||
|
||||
case LETTERBOX:
|
||||
iconName = "iconmonstr-email-4-icon.png";
|
||||
break;
|
||||
|
||||
case EVENT:
|
||||
case CITO_EVENT:
|
||||
case MEGA_EVENT:
|
||||
iconName = "iconmonstr-calendar-4-icon.png";
|
||||
break;
|
||||
|
||||
case WHERIGO:
|
||||
iconName = "iconmonstr-navigation-6-icon.png";
|
||||
break;
|
||||
|
||||
case WEBCAM_CACHE:
|
||||
iconName = "iconmonstr-webcam-3-icon.png";
|
||||
break;
|
||||
|
||||
case VIRTUAL_CACHE:
|
||||
iconName = "iconmonstr-network-2-icon.png";
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println(cache.getType());
|
||||
}
|
||||
|
||||
|
||||
return IconManager.getIcon(iconName, size);
|
||||
}
|
||||
|
||||
public static Image getMapIcon(Cache cache) {
|
||||
return getMapIcon(cache, IconManager.IconSize.MIDDLE);
|
||||
}
|
||||
|
||||
public static Image getMapIcon(Cache cache, IconManager.IconSize size) {
|
||||
String iconName = "iconmonstr-location-icon.png";
|
||||
return IconManager.getIcon(iconName, size);
|
||||
}
|
||||
|
||||
}
|
||||
68
src/de/geofroggerfx/fx/components/IconManager.java
Normal file
68
src/de/geofroggerfx/fx/components/IconManager.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Andreas
|
||||
*/
|
||||
public class IconManager {
|
||||
|
||||
private static final Map<String, Image> container = new HashMap<>();
|
||||
|
||||
public enum IconSize {
|
||||
|
||||
SMALL(16.0),
|
||||
MIDDLE(32.0),
|
||||
BIG(64.0);
|
||||
|
||||
private final double size;
|
||||
|
||||
private IconSize(double size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
public static Image getIcon(String iconName, IconSize size) {
|
||||
final Image image;
|
||||
String key = iconName + "_" + size;
|
||||
if (container.containsKey(key)) {
|
||||
image = container.get(key);
|
||||
} else {
|
||||
image = new Image("/icons/"+(int)size.getValue()+"/"+iconName, size.getValue(), size.getValue(), true, true);
|
||||
container.put(key, image);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
}
|
||||
82
src/de/geofroggerfx/fx/components/MapPaneWrapper.java
Normal file
82
src/de/geofroggerfx/fx/components/MapPaneWrapper.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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;
|
||||
|
||||
import de.geofroggerfx.fx.utils.JavaFXUtils;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.scene.layout.Pane;
|
||||
import jfxtras.labs.map.MapPane;
|
||||
import jfxtras.labs.map.render.MapMarkable;
|
||||
import jfxtras.labs.map.tile.OsmTileSourceFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Andreas Billmann <abi@geofroggerfx.de>
|
||||
*/
|
||||
public class MapPaneWrapper extends Pane {
|
||||
public static final String MAP_PANE_WRAPPER_CLASS = "map-pane-wrapper";
|
||||
|
||||
private final MapPane mapPane;
|
||||
|
||||
public MapPaneWrapper() {
|
||||
mapPane = new MapPane(new OsmTileSourceFactory().create());
|
||||
|
||||
JavaFXUtils.addClasses(this, MAP_PANE_WRAPPER_CLASS);
|
||||
|
||||
setSizeListener();
|
||||
this.getChildren().add(mapPane);
|
||||
setDisplayPositionByLatLon(32.81729, -117.215905, 9);
|
||||
mapPane.setMapMarkerVisible(true);
|
||||
}
|
||||
|
||||
public final void setDisplayPositionByLatLon(double lat, double lon, int zoom) {
|
||||
mapPane.setDisplayPositionByLatLon(lat, lon, zoom);
|
||||
}
|
||||
|
||||
public final void setMapMarkerList(List<MapMarkable> mapMarkerList) {
|
||||
mapPane.setMapMarkerList(mapMarkerList);
|
||||
}
|
||||
|
||||
private void setSizeListener() {
|
||||
this.widthProperty().addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
|
||||
Double width = (Double) newValue;
|
||||
mapPane.setMapWidth(width);
|
||||
}
|
||||
});
|
||||
|
||||
this.heightProperty().addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
|
||||
Double height = (Double) newValue;
|
||||
mapPane.setMapHeight(height);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
55
src/de/geofroggerfx/fx/components/SortingMenuItem.java
Normal file
55
src/de/geofroggerfx/fx/components/SortingMenuItem.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package de.geofroggerfx.fx.components;
|
||||
|
||||
import de.geofroggerfx.service.CacheSortField;
|
||||
import de.geofroggerfx.service.SortDirection;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.scene.control.MenuItem;
|
||||
|
||||
import static de.geofroggerfx.service.SortDirection.ASC;
|
||||
import static de.geofroggerfx.service.SortDirection.DESC;
|
||||
|
||||
/**
|
||||
* MenuItem with a ASC and DESC arrow when selected
|
||||
*/
|
||||
public class SortingMenuItem extends MenuItem {
|
||||
|
||||
private static final String BLACK_UP_POINTING_TRIANGLE = " \u25B2";
|
||||
private static final String BLACK_DOWN_POINTING_TRIANGLE = " \u25BC";
|
||||
|
||||
private boolean oldValue = false;
|
||||
private ObjectProperty<CacheSortField> field = new SimpleObjectProperty<>();
|
||||
private ObjectProperty<SortDirection> sortDirection = new SimpleObjectProperty<>(ASC);
|
||||
|
||||
public SortingMenuItem(final String text, final CacheSortField field) {
|
||||
super(text);
|
||||
this.field.setValue(field);
|
||||
}
|
||||
|
||||
public void setSelected(boolean newValue) {
|
||||
final StringBuilder text = new StringBuilder(getText());
|
||||
String triangle = BLACK_UP_POINTING_TRIANGLE;
|
||||
|
||||
if (newValue && oldValue) {
|
||||
sortDirection.set(sortDirection.get().equals(ASC) ? DESC : ASC);
|
||||
triangle = sortDirection.get().equals(ASC) ? BLACK_UP_POINTING_TRIANGLE : BLACK_DOWN_POINTING_TRIANGLE;
|
||||
text.delete(text.length() - 2, text.length());
|
||||
text.append(triangle);
|
||||
} else if (newValue) {
|
||||
text.append(triangle);
|
||||
} else {
|
||||
text.delete(text.length() - 2, text.length());
|
||||
}
|
||||
|
||||
setText(text.toString());
|
||||
oldValue = newValue;
|
||||
}
|
||||
|
||||
public CacheSortField getField() {
|
||||
return field.get();
|
||||
}
|
||||
|
||||
public SortDirection getSortDirection() {
|
||||
return sortDirection.get();
|
||||
}
|
||||
}
|
||||
69
src/de/geofroggerfx/fx/geofrogger.css
Normal file
69
src/de/geofroggerfx/fx/geofrogger.css
Normal file
@@ -0,0 +1,69 @@
|
||||
.root{
|
||||
-fx-font-size: 10pt;
|
||||
-fx-font-family: "Fira Sans";
|
||||
}
|
||||
|
||||
.menu-bar {
|
||||
-fx-background-color: #aeb5ba, linear-gradient(to bottom, #ecf4fa 0%, #ced4d9 100%);
|
||||
-fx-background-insets: 0, 0 0 1 0;
|
||||
}
|
||||
|
||||
.menu-bar .menu .label {
|
||||
-fx-text-fill: #2d3e4c;
|
||||
}
|
||||
|
||||
.split-pane > .split-pane-divider {
|
||||
-fx-background-color: linear-gradient(to right, #ecf4fa 0%, #ced4d9 100%);
|
||||
-fx-padding: 0 3 0 3;
|
||||
}
|
||||
|
||||
.scroll-pane {
|
||||
-fx-background-insets: 0, 0;
|
||||
-fx-padding: 0;
|
||||
}
|
||||
|
||||
.form {
|
||||
-fx-background-color: #aeb5ba, linear-gradient(to bottom, #ecf4fa 0%, #ced4d9 100%);
|
||||
}
|
||||
|
||||
.details-header,
|
||||
.cache-header {
|
||||
-fx-background-color: linear-gradient(to bottom, #aaaaaa 0%, #888888 100%);
|
||||
}
|
||||
|
||||
.cache-list-name {
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.cache-list-icon {
|
||||
-fx-text-fill: #444444;
|
||||
-fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.4), 3, 0.0, 1, 1);
|
||||
}
|
||||
|
||||
.cache-list-found .cache-list-icon {
|
||||
-fx-text-fill: #669900;
|
||||
}
|
||||
|
||||
.cache-list-action-icons {
|
||||
-fx-padding: 4;
|
||||
-fx-text-fill: #ffffff;
|
||||
}
|
||||
|
||||
.text-input:readonly,
|
||||
.combo-box-base:disabled,
|
||||
.text-input:disabled {
|
||||
-fx-opacity: 0.9;
|
||||
-fx-background-color: linear-gradient(to bottom, #eeeeee 0%, #dddddd 100%);
|
||||
}
|
||||
|
||||
.slider:disabled {
|
||||
-fx-opacity: 0.8;
|
||||
}
|
||||
|
||||
.menu-button.cache-list-action-icons {
|
||||
-fx-padding: 0 0 0 0;
|
||||
}
|
||||
|
||||
.menu-button.cache-list-action-icons .label{
|
||||
-fx-padding: 2 2 2 2;
|
||||
}
|
||||
233
src/de/geofroggerfx/fx/geofrogger/GeofroggerController.java
Normal file
233
src/de/geofroggerfx/fx/geofrogger/GeofroggerController.java
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.geofrogger;
|
||||
|
||||
import de.geofroggerfx.application.ProgressEvent;
|
||||
import de.geofroggerfx.application.ServiceManager;
|
||||
import de.geofroggerfx.application.SessionContext;
|
||||
import de.geofroggerfx.gpx.GPXReader;
|
||||
import de.geofroggerfx.model.Cache;
|
||||
import de.geofroggerfx.plugins.Plugin;
|
||||
import de.geofroggerfx.plugins.PluginService;
|
||||
import de.geofroggerfx.service.CacheService;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.concurrent.Service;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static de.geofroggerfx.service.CacheSortField.*;
|
||||
import static de.geofroggerfx.service.SortDirection.*;
|
||||
|
||||
/**
|
||||
* FXML Controller class
|
||||
*
|
||||
* @author Andreas
|
||||
*/
|
||||
public class GeofroggerController implements Initializable {
|
||||
|
||||
private static final String LICENSE = "/*\n" +
|
||||
" * Copyright (c) 2013, Andreas Billmann <abi@geofroggerfx.de>\n" +
|
||||
" * All rights reserved.\n" +
|
||||
" *\n" +
|
||||
" * Redistribution and use in source and binary forms, with or without\n" +
|
||||
" * modification, are permitted provided that the following conditions are met:\n" +
|
||||
" *\n" +
|
||||
" * * Redistributions of source code must retain the above copyright notice, this\n" +
|
||||
" * list of conditions and the following disclaimer.\n" +
|
||||
" * * Redistributions in binary form must reproduce the above copyright notice,\n" +
|
||||
" * this list of conditions and the following disclaimer in the documentation\n" +
|
||||
" * and/or other materials provided with the distribution.\n" +
|
||||
" *\n" +
|
||||
" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n" +
|
||||
" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n" +
|
||||
" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n" +
|
||||
" * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n" +
|
||||
" * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n" +
|
||||
" * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n" +
|
||||
" * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n" +
|
||||
" * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n" +
|
||||
" * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n" +
|
||||
" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n" +
|
||||
" * POSSIBILITY OF SUCH DAMAGE.\n" +
|
||||
" */";
|
||||
|
||||
private static final String MASTHEAD_TEXT = "GeoFroggerFX by Andreas Billmann <abi@geofroggerfx.de>";
|
||||
private static final String ABOUT_TEXT = "Used libs:\n"
|
||||
+ "\t- JFXtras 8.0 r1\n"
|
||||
+ "\t- ControlsFX 8.0.2 developer preview 1\n"
|
||||
+ "\t- jdom 2.x\n"
|
||||
+ "\t- H2 1.3.173\n"
|
||||
+ "\t- Icons by http://iconmonstr.com/\n";
|
||||
|
||||
private final SessionContext sessionContext = SessionContext.getInstance();
|
||||
private final LoadCachesFromFileService loadService = new LoadCachesFromFileService();
|
||||
private final LoadCachesFromDatabaseService loadFromDBService = new LoadCachesFromDatabaseService();
|
||||
|
||||
private final GPXReader gpxReader = ServiceManager.getInstance().getGPXReader();
|
||||
private final CacheService cacheService = ServiceManager.getInstance().getCacheService();
|
||||
private final PluginService pluginService = ServiceManager.getInstance().getPluginService();
|
||||
|
||||
@FXML
|
||||
private Label leftStatus;
|
||||
|
||||
@FXML
|
||||
private ProgressBar progress;
|
||||
|
||||
@FXML
|
||||
private Menu pluginsMenu;
|
||||
|
||||
/**
|
||||
* Initializes the controller class.
|
||||
*
|
||||
* @param url
|
||||
* @param rb
|
||||
*/
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
|
||||
List<Plugin> plugins = pluginService.getAllPlugins();
|
||||
for (Plugin plugin: plugins) {
|
||||
MenuItem menuItem = new MenuItem(plugin.getName()+" ("+plugin.getVersion()+")");
|
||||
menuItem.setOnAction(actionEvent -> pluginService.executePlugin(plugin));
|
||||
pluginsMenu.getItems().add(menuItem);
|
||||
}
|
||||
|
||||
gpxReader.addListener((ProgressEvent event) -> updateStatus(event.getMessage(), event.getProgress()));
|
||||
cacheService.addListener((ProgressEvent event) -> updateStatus(event.getMessage(), event.getProgress()));
|
||||
loadFromDBService.start();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void importGpx(ActionEvent actionEvent) {
|
||||
final FileChooser fileChooser = new FileChooser();
|
||||
|
||||
//Set extension filter
|
||||
final FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("GPX files (*.gpx)", "*.gpx");
|
||||
fileChooser.getExtensionFilters().add(extFilter);
|
||||
|
||||
//Show open file dialog
|
||||
final File file = fileChooser.showOpenDialog(null);
|
||||
loadService.setFile(file);
|
||||
loadService.restart();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void showAboutDialog(ActionEvent actionEvent) {
|
||||
Dialog dialog = new Dialog(null, "About");
|
||||
dialog.setMasthead(MASTHEAD_TEXT);
|
||||
dialog.setContent(ABOUT_TEXT);
|
||||
dialog.setExpandableContent(new TextArea(LICENSE));
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void exit(ActionEvent actionEvent) {
|
||||
Platform.exit();
|
||||
}
|
||||
|
||||
private void updateStatus(String text, double progressValue) {
|
||||
Platform.runLater(() -> {
|
||||
leftStatus.setText(text);
|
||||
progress.setProgress(progressValue);
|
||||
});
|
||||
}
|
||||
|
||||
private class LoadCachesFromDatabaseService extends Service {
|
||||
|
||||
@Override
|
||||
protected Task createTask() {
|
||||
return new Task() {
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
updateStatus("Load caches from database.", ProgressIndicator.INDETERMINATE_PROGRESS);
|
||||
sessionContext.setData("cache-list", cacheService.getAllCaches(NAME, ASC));
|
||||
updateStatus("All caches loaded.", 0);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class LoadCachesFromFileService extends Service {
|
||||
|
||||
private final ObjectProperty<File> file = new SimpleObjectProperty();
|
||||
|
||||
public final void setFile(File value) {
|
||||
file.set(value);
|
||||
}
|
||||
|
||||
public final File getFile() {
|
||||
return file.get();
|
||||
}
|
||||
|
||||
public final ObjectProperty<File> fileProperty() {
|
||||
return file;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Task createTask() {
|
||||
return new Task() {
|
||||
@Override
|
||||
protected Void call() throws Exception {
|
||||
try {
|
||||
final List<Cache> cacheList = gpxReader.load(file.get().getAbsolutePath());
|
||||
if (cacheList != null && !cacheList.isEmpty()) {
|
||||
|
||||
updateStatus("Store caches in database", ProgressIndicator.INDETERMINATE_PROGRESS);
|
||||
cacheService.storeCaches(cacheList);
|
||||
updateStatus("All caches are stored in database", 0);
|
||||
|
||||
updateStatus("Load caches from database.", ProgressIndicator.INDETERMINATE_PROGRESS);
|
||||
sessionContext.setData("cache-list", cacheService.getAllCaches(NAME, ASC));
|
||||
updateStatus("All caches loaded.", 0);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(GeofroggerController.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
61
src/de/geofroggerfx/fx/geofrogger/geofrogger.fxml
Normal file
61
src/de/geofroggerfx/fx/geofrogger/geofrogger.fxml
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.Color?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import java.net.URL?>
|
||||
<VBox prefHeight="800.0" prefWidth="1280.0" minHeight="600.0" minWidth="800.0" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="de.geofroggerfx.fx.geofrogger.GeofroggerController">
|
||||
<children>
|
||||
<MenuBar VBox.vgrow="NEVER">
|
||||
<menus>
|
||||
<Menu mnemonicParsing="false" text="%menu.title.file">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#importGpx" text="%menu.title.import.gpx"/>
|
||||
<SeparatorMenuItem mnemonicParsing="false"/>
|
||||
<MenuItem mnemonicParsing="false" onAction="#exit" text="%menu.title.quit"/>
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu fx:id="pluginsMenu" mnemonicParsing="false" text="%menu.title.plugins"/>
|
||||
<Menu mnemonicParsing="false" text="%menu.title.help">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#showAboutDialog" text="%menu.title.about"/>
|
||||
</items>
|
||||
</Menu>
|
||||
</menus>
|
||||
</MenuBar>
|
||||
<SplitPane dividerPositions="0.3779342723004695" focusTraversable="true" prefHeight="-1.0" prefWidth="-1.0"
|
||||
VBox.vgrow="ALWAYS">
|
||||
<items>
|
||||
<fx:include source="../cachelist/cache_list.fxml" fx:id="cacheListContent"/>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" pannable="false" prefHeight="-1.0" prefWidth="-1.0">
|
||||
<content>
|
||||
<fx:include source="../cachedetails/cache_details.fxml" fx:id="cacheDetailsContent"/>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</items>
|
||||
</SplitPane>
|
||||
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER">
|
||||
<children>
|
||||
<Pane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS"/>
|
||||
<Label fx:id="leftStatus" maxHeight="1.7976931348623157E308" maxWidth="-1.0" text="" HBox.hgrow="ALWAYS">
|
||||
<font>
|
||||
<Font size="11.0" fx:id="x3"/>
|
||||
</font>
|
||||
<textFill>
|
||||
<Color blue="0.625" green="0.625" red="0.625" fx:id="x4"/>
|
||||
</textFill>
|
||||
</Label>
|
||||
<ProgressBar fx:id="progress" prefWidth="300.0" progress="0" HBox.hgrow="ALWAYS"/>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
|
||||
</padding>
|
||||
</HBox>
|
||||
</children>
|
||||
<stylesheets>
|
||||
<URL value="@../geofrogger.css"/>
|
||||
</stylesheets>
|
||||
</VBox>
|
||||
32
src/de/geofroggerfx/fx/geofrogger_de.properties
Normal file
32
src/de/geofroggerfx/fx/geofrogger_de.properties
Normal file
@@ -0,0 +1,32 @@
|
||||
menu.title.import.gpx = Importiere GPX
|
||||
menu.title.file = Datei
|
||||
menu.title.quit = Beenden
|
||||
menu.title.help = Hilfe
|
||||
menu.title.about = \u00dcber GeoFroggerFX
|
||||
menu.title.plugins = Plugins
|
||||
|
||||
menu.title.sort = Sortieren
|
||||
menu.title.filter = Filtern
|
||||
|
||||
label.text.cache.list=Caches
|
||||
label.text.name=Name:
|
||||
label.text.difficulty=Schwierigkeit:
|
||||
label.text.terrain=Gel\u00E4nde
|
||||
label.text.placedBy=Platziert von:
|
||||
label.text.owner=Betreut von:
|
||||
label.text.date=Datum:
|
||||
label.text.type=Typ:
|
||||
label.text.container=Gr\u00F6\u00dfe:
|
||||
label.text.shortdescription=Kurze Beschreibung:
|
||||
label.text.htmldescription=HTML Beschreibung
|
||||
label.text.longdescription=Lange Beschreibung:
|
||||
|
||||
tab.text.descriptions=Beschreibungen
|
||||
tab.text.general=Allgemein
|
||||
|
||||
sort.cache.name = GC Code
|
||||
sort.cache.type = Art
|
||||
sort.cache.difficulty = Schwierigkeitsgrad
|
||||
sort.cache.terrain = Gel\u00E4nde
|
||||
sort.cache.placedBy = Platziert von
|
||||
sort.cache.owner = Betreut von
|
||||
32
src/de/geofroggerfx/fx/geofrogger_en.properties
Normal file
32
src/de/geofroggerfx/fx/geofrogger_en.properties
Normal file
@@ -0,0 +1,32 @@
|
||||
menu.title.import.gpx = Import GPX
|
||||
menu.title.file = File
|
||||
menu.title.quit = Quit
|
||||
menu.title.help = Help
|
||||
menu.title.about = About GeoFroggerFX
|
||||
menu.title.plugins = Plugins
|
||||
|
||||
menu.title.sort = Sort
|
||||
menu.title.filter = Filter
|
||||
|
||||
label.text.cache.list=Caches
|
||||
label.text.name=Name:
|
||||
label.text.difficulty=Difficulty:
|
||||
label.text.terrain=Terrain:
|
||||
label.text.placedBy=Placed By:
|
||||
label.text.owner=Owner:
|
||||
label.text.date=Date:
|
||||
label.text.type=Type:
|
||||
label.text.container=Container:
|
||||
label.text.shortdescription=Short description:
|
||||
label.text.htmldescription=HTML Description
|
||||
label.text.longdescription=Long description:
|
||||
|
||||
tab.text.descriptions=Descriptions
|
||||
tab.text.general=General
|
||||
|
||||
sort.cache.name = GC Code
|
||||
sort.cache.type = Type
|
||||
sort.cache.difficulty = Difficulty
|
||||
sort.cache.terrain = Terrain
|
||||
sort.cache.placedBy = Placed by
|
||||
sort.cache.owner = Owner
|
||||
0
src/de/geofroggerfx/fx/settings/settings.fxml
Normal file
0
src/de/geofroggerfx/fx/settings/settings.fxml
Normal file
54
src/de/geofroggerfx/fx/utils/JavaFXUtils.java
Normal file
54
src/de/geofroggerfx/fx/utils/JavaFXUtils.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.utils;
|
||||
|
||||
import javafx.scene.Node;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Andreas Billmann <abi@geofroggerfx.de>
|
||||
*/
|
||||
public class JavaFXUtils {
|
||||
|
||||
public static void addClasses(Node node, String... classes) {
|
||||
for (String styleClass : classes) {
|
||||
List<String> nodeClasses = node.getStyleClass();
|
||||
if (!nodeClasses.contains(styleClass)) {
|
||||
nodeClasses.add(styleClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeClasses(Node node, String... classes) {
|
||||
for (String styleClass : classes) {
|
||||
List<String> nodeClasses = node.getStyleClass();
|
||||
if (nodeClasses.contains(styleClass)) {
|
||||
nodeClasses.remove(styleClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user