changed the package name to the domain name

This commit is contained in:
2014-05-17 07:18:37 +02:00
parent 471b532290
commit 2af2f56ade
48 changed files with 116 additions and 127 deletions

View 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);
}
}

View 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>