Skip to content
Snippets Groups Projects
Commit 35925edf authored by George Adrian Stoica's avatar George Adrian Stoica
Browse files

show both properties and tags in the editor

parent dc7204df
No related branches found
No related tags found
1 merge request!6Issue 11 allow user to enter and update metadata about the latlong points
package simpleex.ui;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventType;
......@@ -10,9 +16,12 @@ import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.TableColumn.CellDataFeatures;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Callback;
import javafx.util.Pair;
import simpleex.core.LatLong;
import simpleex.core.MetaData;
import simpleex.ui.tags.TagsBar;
......@@ -44,13 +53,13 @@ public class MetaDataEditorController {
private TextArea descriptionInput;
@FXML
private TableView<?> propertiesTableView;
private TableView<Pair<String,String>> propertiesTableView;
@FXML
private TableColumn<?, ?> propertyNamesColumn;
private TableColumn<Pair<String, String>, String> propertyNamesColumn;
@FXML
private TableColumn<?, ?> propertyValuesColumn;
private TableColumn<Pair<String, String>, String> propertyValuesColumn;
@FXML
private TagsBar tagsBar;
......@@ -58,6 +67,20 @@ public class MetaDataEditorController {
@FXML
private Label coordinatesLabel;
@FXML
private void initialize() {
propertyNamesColumn.setCellValueFactory(
cellData -> new SimpleStringProperty(
((Pair<String, String>) (cellData.getValue())).getKey()
));
propertyValuesColumn.setCellValueFactory(
cellData -> new SimpleStringProperty(
((Pair<String, String>) (cellData.getValue())).getValue()
));
}
@FXML
void onCancel(ActionEvent event) {
closeDialog(event);
......@@ -93,7 +116,31 @@ public class MetaDataEditorController {
descriptionInput.setText(latlong.getMetaData().getProperty(MetaData.DESCRIPTION_PROPERTY));
coordinatesLabel.setText(latlong.toString());
//propertiesTableView.setItems(latlong.getMetaData().propertyNames());
MetaData metaData = latlong.getMetaData();
final Iterator<String> propertyNames = metaData.propertyNames();
Collection<Pair<String, String>> locationProperties = new ArrayList<Pair<String,String>>();
if( propertyNames.hasNext()) {
while(propertyNames.hasNext()) {
final String propertyName = propertyNames.next();
if ((propertyName == MetaData.NAME_PROPERTY) ||
(propertyName == MetaData.DESCRIPTION_PROPERTY)) {
continue;
} else {
Pair<String,String> p = new Pair<String, String>(propertyName, metaData.getProperty(propertyName));
locationProperties.add(p);
}
}
propertiesTableView.getItems().addAll(locationProperties);
}
final Iterator<String> tags = metaData.tags();
if(tags.hasNext()) {
while(tags.hasNext()) {
final String tag = tags.next();
tagsBar.addTag(tag);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment