fix some swing improvements
git-svn-id: https://osmand.googlecode.com/svn/trunk@119 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
b9f82208aa
commit
3833f018f2
7 changed files with 180 additions and 47 deletions
|
@ -6,7 +6,7 @@ com.osmand.level = ALL
|
||||||
|
|
||||||
java.util.logging.FileHandler.pattern=%h/Application Data/Osmand/osmand.log
|
java.util.logging.FileHandler.pattern=%h/Application Data/Osmand/osmand.log
|
||||||
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
|
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
|
||||||
java.util.logging.FileHandler.append = false
|
java.util.logging.FileHandler.append = true
|
||||||
java.util.logging.FileHandler.limit = 100000
|
java.util.logging.FileHandler.limit = 100000
|
||||||
|
|
||||||
java.util.logging.ConsoleHandler.level=ALL
|
java.util.logging.ConsoleHandler.level=ALL
|
||||||
|
|
|
@ -13,14 +13,11 @@ public class ToDoConstants {
|
||||||
|
|
||||||
|
|
||||||
// TODO ANDROID in release 0.1
|
// TODO ANDROID in release 0.1
|
||||||
// 25. POI search near to map location (show categories & type). Second cut. (implement incremental search)
|
|
||||||
// 29. Show opened/closed amenities (in search poi).
|
// 29. Show opened/closed amenities (in search poi).
|
||||||
// 13. Save point as favorite & introduce favorite points dialog
|
// 13. Save point as favorite & introduce favorite points dialog
|
||||||
|
|
||||||
// 3. Revise osmand UI. Preparing new icons (revise UI 18, 2, ). Main application icon, back to location icon.
|
// 3. Revise osmand UI. Preparing new icons (revise UI 18, 2, ). Main application icon, back to location icon.
|
||||||
// 14. Show zoom level on map
|
// 14. Show zoom level on map
|
||||||
|
|
||||||
|
|
||||||
// NOT in release 0.1
|
// NOT in release 0.1
|
||||||
// 8. Enable change POI directly on map (requires OSM login)
|
// 8. Enable change POI directly on map (requires OSM login)
|
||||||
// 16. Support open street bugs api.
|
// 16. Support open street bugs api.
|
||||||
|
@ -32,40 +29,17 @@ public class ToDoConstants {
|
||||||
// FIXME Bugs Android :
|
// FIXME Bugs Android :
|
||||||
// 6. Understand concept of application where to save/restore global setting.
|
// 6. Understand concept of application where to save/restore global setting.
|
||||||
// (for example reset navigate to point, reset link map with location). It should be reset after user call exit.
|
// (for example reset navigate to point, reset link map with location). It should be reset after user call exit.
|
||||||
// Call ResourceManager.close when it is needed (+).
|
// Call ResourceManager.close when it is needed (+)
|
||||||
// 10. Notification is gone after clear all notifications
|
// 10. Notification is gone after clear all notifications
|
||||||
|
|
||||||
// Performance improvements Android :
|
// Performance improvements Android :
|
||||||
// 2. Introducing cache of file names that are on disk (creating new File() consumes a lot of memory) (+)
|
// 2. Introducing cache of file names that are on disk (creating new File() consumes a lot of memory) (+)
|
||||||
|
|
||||||
|
|
||||||
// TODO SWING : in release 0.1
|
// TODO swing NOT in release 0.1
|
||||||
// 6. Implement renaming/deleting street/building/city (+)
|
|
||||||
// 7. Implement saving bundle of tiles in different folder (+)
|
|
||||||
|
|
||||||
// NOT in release 0.1
|
|
||||||
// 1. Download tiles without using dir tiles
|
// 1. Download tiles without using dir tiles
|
||||||
|
|
||||||
|
|
||||||
// DONE ANDROID :
|
// DONE ANDROID :
|
||||||
// 27. Search intersection of streets
|
|
||||||
// 24. Implement ResourceManager, load cities/streets/buildings on Low memory (clear previous all addresses cities).
|
|
||||||
// 28. Implement transliteration search for android version
|
|
||||||
// 5. Search for city/streets/buildings
|
|
||||||
// 15. Investigate interruption of any long running operation & implement where it is needed.
|
|
||||||
// ProgressDialogImplementation should support setOnCancelListener or obtain CANCEL message &
|
|
||||||
// throw InterruptedException in all methods (remaining, progress, startTask, ...) when call it.
|
|
||||||
// Otherwise thread could be stopped however it is not good method.
|
|
||||||
// 21. Implement zooming tile (if tile doesn't exist local, we can zoom in previous tile).
|
|
||||||
// 11. Print out additional info speed, altitude, number of satellites
|
|
||||||
// 19. Show how map is rotated where north/south on map (do not consider compass)
|
|
||||||
// 23. Implement moving point from center to bottom (for rotating map)
|
|
||||||
// 17. Enable go to location by specifying coordinates
|
|
||||||
// 9. Configure file log & see log from file (when exception happened to see from device)
|
|
||||||
// 2. Showing compass on the map : use device compass if exists(?)
|
|
||||||
// 18. Implement go to point
|
|
||||||
|
|
||||||
// DONE SWING
|
// DONE SWING
|
||||||
// 8. Implement basic transliteration version
|
|
||||||
// 2. Configure file log & see log from file (add uncaught exception handling)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,6 +148,14 @@ public class DataTileManager<T> {
|
||||||
return evTile(tileX, tileY);
|
return evTile(tileX, tileY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unregisterObject(double latitude, double longitude, T object){
|
||||||
|
String tile = evaluateTile(latitude, longitude);
|
||||||
|
if(objects.containsKey(tile)){
|
||||||
|
objects.get(tile).remove(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public String registerObject(double latitude, double longitude, T object){
|
public String registerObject(double latitude, double longitude, T object){
|
||||||
String tile = evaluateTile(latitude, longitude);
|
String tile = evaluateTile(latitude, longitude);
|
||||||
if(!objects.containsKey(tile)){
|
if(!objects.containsKey(tile)){
|
||||||
|
|
|
@ -137,6 +137,14 @@ public class Region extends MapObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unregisterCity(City city){
|
||||||
|
if(city != null && city.getType() != null){
|
||||||
|
LatLon l = city.getLocation();
|
||||||
|
cityManager.unregisterObject(l.getLatitude(), l.getLongitude(), city);
|
||||||
|
cities.get(city.getType()).remove(city);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public City registerCity(Node c){
|
public City registerCity(Node c){
|
||||||
City city = new City(c);
|
City city = new City(c);
|
||||||
if(city.getType() != null && !Algoritms.isEmpty(city.getName())){
|
if(city.getType() != null && !Algoritms.isEmpty(city.getName())){
|
||||||
|
|
|
@ -61,6 +61,10 @@ public class Street extends MapObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRegisteredInCity(){
|
||||||
|
return city.getStreet(getName()) == this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
if (name.equals(getName())) {
|
if (name.equals(getName())) {
|
||||||
|
@ -69,7 +73,11 @@ public class Street extends MapObject {
|
||||||
if (city.getStreet(getName()) == this) {
|
if (city.getStreet(getName()) == this) {
|
||||||
city.unregisterStreet(getName());
|
city.unregisterStreet(getName());
|
||||||
super.setName(name);
|
super.setName(name);
|
||||||
city.registerStreet(this);
|
Street s = city.registerStreet(this);
|
||||||
|
if(s != this){
|
||||||
|
// that case means that street unregistered
|
||||||
|
// city = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
super.setName(name);
|
super.setName(name);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +88,10 @@ public class Street extends MapObject {
|
||||||
return wayNodes;
|
return wayNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public City getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
public void doDataPreparation() {
|
public void doDataPreparation() {
|
||||||
Collections.sort(buildings, new Comparator<Building>(){
|
Collections.sort(buildings, new Comparator<Building>(){
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.awt.Container;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -24,6 +26,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
|
import javax.swing.Action;
|
||||||
import javax.swing.DefaultListCellRenderer;
|
import javax.swing.DefaultListCellRenderer;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
@ -37,6 +40,7 @@ import javax.swing.JMenuBar;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
@ -56,6 +60,7 @@ import javax.swing.tree.DefaultTreeCellEditor;
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.TreeCellEditor;
|
import javax.swing.tree.TreeCellEditor;
|
||||||
|
import javax.swing.tree.TreePath;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -130,6 +135,7 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public OsmExtractionUI(final Region r){
|
public OsmExtractionUI(final Region r){
|
||||||
this.region = r;
|
this.region = r;
|
||||||
createUI();
|
createUI();
|
||||||
|
@ -144,7 +150,7 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
DefaultMutableTreeNode root = new DataExtractionTreeNode(name, region);
|
DefaultMutableTreeNode root = new DataExtractionTreeNode(name, region);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
amenitiesTree = new DataExtractionTreeNode("Closest amenities", region);
|
amenitiesTree = new DataExtractionTreeNode("Amenities", region);
|
||||||
amenitiesTree.add(new DataExtractionTreeNode("First 15", region));
|
amenitiesTree.add(new DataExtractionTreeNode("First 15", region));
|
||||||
for (AmenityType type : AmenityType.values()) {
|
for (AmenityType type : AmenityType.values()) {
|
||||||
amenitiesTree.add(new DataExtractionTreeNode(Algoritms.capitalizeFirstLetterAndLowercase(type.toString()), type));
|
amenitiesTree.add(new DataExtractionTreeNode(Algoritms.capitalizeFirstLetterAndLowercase(type.toString()), type));
|
||||||
|
@ -235,7 +241,15 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
JMenuBar bar = new JMenuBar();
|
JMenuBar bar = new JMenuBar();
|
||||||
fillMenuWithActions(bar);
|
fillMenuWithActions(bar);
|
||||||
|
|
||||||
|
JPopupMenu popupMenu = new JPopupMenu();
|
||||||
|
fillPopupMenuWithActions(popupMenu);
|
||||||
|
treePlaces.add(popupMenu);
|
||||||
|
treePlaces.addMouseListener(new PopupTrigger(popupMenu));
|
||||||
|
|
||||||
|
|
||||||
frame.setJMenuBar(bar);
|
frame.setJMenuBar(bar);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public JTree createTree(Container content) {
|
public JTree createTree(Container content) {
|
||||||
|
@ -283,16 +297,21 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
|
|
||||||
treeModelListener = new TreeModelListener() {
|
treeModelListener = new TreeModelListener() {
|
||||||
public void treeNodesChanged(TreeModelEvent e) {
|
public void treeNodesChanged(TreeModelEvent e) {
|
||||||
DefaultMutableTreeNode node;
|
for (Object node : e.getChildren()) {
|
||||||
node = (DefaultMutableTreeNode)
|
|
||||||
(e.getTreePath().getLastPathComponent());
|
|
||||||
if (node instanceof DataExtractionTreeNode) {
|
if (node instanceof DataExtractionTreeNode) {
|
||||||
if(((DataExtractionTreeNode) node).getModelObject() instanceof Region){
|
DataExtractionTreeNode n = ((DataExtractionTreeNode) node);
|
||||||
Region r = (Region) ((DataExtractionTreeNode) node).getModelObject();
|
if (n.getModelObject() instanceof MapObject) {
|
||||||
r.setName(node.getUserObject().toString());
|
MapObject r = (MapObject) n.getModelObject();
|
||||||
} else if(((DataExtractionTreeNode) node).getModelObject() instanceof MapObject){
|
String newName = n.getUserObject().toString();
|
||||||
MapObject r = (MapObject) ((DataExtractionTreeNode) node).getModelObject();
|
if(!r.getName().equals(newName)){
|
||||||
r.setName(node.getUserObject().toString());
|
r.setName(n.getUserObject().toString());
|
||||||
|
}
|
||||||
|
if (r instanceof Street && !((Street) r).isRegisteredInCity()) {
|
||||||
|
DefaultMutableTreeNode parent = ((DefaultMutableTreeNode) n.getParent());
|
||||||
|
parent.remove(n);
|
||||||
|
((DefaultTreeModel) treePlaces.getModel()).nodeStructureChanged(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,6 +326,8 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
return treePlaces;
|
return treePlaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void updateButtonsBar() {
|
protected void updateButtonsBar() {
|
||||||
generateDataButton.setEnabled(region != null);
|
generateDataButton.setEnabled(region != null);
|
||||||
normalizingStreets.setVisible(region == null);
|
normalizingStreets.setVisible(region == null);
|
||||||
|
@ -380,6 +401,7 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
builder.writeAddress();
|
builder.writeAddress();
|
||||||
msg.append(", Address index ").append("successfully created");
|
msg.append(", Address index ").append("successfully created");
|
||||||
}
|
}
|
||||||
|
|
||||||
// new DataIndexReader().testIndex(new File(
|
// new DataIndexReader().testIndex(new File(
|
||||||
// DataExtractionSettings.getSettings().getDefaultWorkingDir(),
|
// DataExtractionSettings.getSettings().getDefaultWorkingDir(),
|
||||||
// IndexConstants.ADDRESS_INDEX_DIR+region.getName()+IndexConstants.ADDRESS_INDEX_EXT));
|
// IndexConstants.ADDRESS_INDEX_DIR+region.getName()+IndexConstants.ADDRESS_INDEX_EXT));
|
||||||
|
@ -467,6 +489,64 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void fillPopupMenuWithActions(JPopupMenu menu) {
|
||||||
|
Action delete = new AbstractAction("Delete") {
|
||||||
|
private static final long serialVersionUID = 7476603434847164396L;
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
TreePath[] p = treePlaces.getSelectionPaths();
|
||||||
|
if(p != null &&
|
||||||
|
JOptionPane.OK_OPTION ==
|
||||||
|
JOptionPane.showConfirmDialog(frame, "Are you sure about deleting " +p.length + " resources ? ")){
|
||||||
|
for(TreePath path : treePlaces.getSelectionPaths()){
|
||||||
|
Object node = path.getLastPathComponent();
|
||||||
|
if (node instanceof DataExtractionTreeNode) {
|
||||||
|
DataExtractionTreeNode n = ((DataExtractionTreeNode) node);
|
||||||
|
if(n.getParent() instanceof DataExtractionTreeNode){
|
||||||
|
DataExtractionTreeNode parent = ((DataExtractionTreeNode) n.getParent());
|
||||||
|
boolean remove = false;
|
||||||
|
if (n.getModelObject() instanceof Street) {
|
||||||
|
((City)parent.getModelObject()).unregisterStreet(((Street)n.getModelObject()).getName());
|
||||||
|
remove = true;
|
||||||
|
} else if (n.getModelObject() instanceof Building) {
|
||||||
|
((Street)parent.getModelObject()).getBuildings().remove(n.getModelObject());
|
||||||
|
remove = true;
|
||||||
|
} else if (n.getModelObject() instanceof City) {
|
||||||
|
Region r = (Region) ((DataExtractionTreeNode)parent.getParent()).getModelObject();
|
||||||
|
r.unregisterCity((City) n.getModelObject());
|
||||||
|
remove = true;
|
||||||
|
} else if (n.getModelObject() instanceof Amenity) {
|
||||||
|
Region r = (Region) ((DataExtractionTreeNode)parent.getParent().getParent()).getModelObject();
|
||||||
|
Amenity am = (Amenity) n.getModelObject();
|
||||||
|
r.getAmenityManager().unregisterObject(am.getLocation().getLatitude(), am.getLocation().getLongitude(), am);
|
||||||
|
remove = true;
|
||||||
|
}
|
||||||
|
if(remove){
|
||||||
|
parent.remove(n);
|
||||||
|
((DefaultTreeModel) treePlaces.getModel()).nodeStructureChanged(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
menu.add(delete);
|
||||||
|
Action rename= new AbstractAction("Rename") {
|
||||||
|
private static final long serialVersionUID = -8257594433235073767L;
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
TreePath path = treePlaces.getSelectionPath();
|
||||||
|
if(path != null){
|
||||||
|
treePlaces.startEditingAtPath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
menu.add(rename);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void fillMenuWithActions(JMenuBar bar){
|
public void fillMenuWithActions(JMenuBar bar){
|
||||||
JMenu menu = new JMenu("File");
|
JMenu menu = new JMenu("File");
|
||||||
bar.add(menu);
|
bar.add(menu);
|
||||||
|
@ -501,11 +581,15 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
File file = new File(OsmExtractionUI.LOG_PATH);
|
File file = new File(OsmExtractionUI.LOG_PATH);
|
||||||
if (file != null && file.exists()) {
|
if (file != null && file.exists()) {
|
||||||
|
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(new String[] { "notepad.exe", file.getAbsolutePath() }); //$NON-NLS-1$
|
Runtime.getRuntime().exec(new String[] { "notepad.exe", file.getAbsolutePath() }); //$NON-NLS-1$
|
||||||
} catch (IOException es) {
|
} catch (IOException es) {
|
||||||
ExceptionHandler.handle("Failed to open log file ", es);
|
ExceptionHandler.handle("Failed to open log file ", es);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(frame, "Open log file manually " + LOG_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ExceptionHandler.handle("Log file is not found");
|
ExceptionHandler.handle("Log file is not found");
|
||||||
|
@ -842,5 +926,29 @@ public class OsmExtractionUI implements IMapLocationListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class PopupTrigger extends MouseAdapter {
|
||||||
|
|
||||||
|
private final JPopupMenu popupMenu;
|
||||||
|
|
||||||
|
public PopupTrigger(JPopupMenu popupMenu) {
|
||||||
|
this.popupMenu = popupMenu;
|
||||||
|
}
|
||||||
|
public void mouseReleased(MouseEvent e)
|
||||||
|
{
|
||||||
|
if (e.isPopupTrigger())
|
||||||
|
{
|
||||||
|
int x = e.getX();
|
||||||
|
int y = e.getY();
|
||||||
|
TreePath path = treePlaces.getPathForLocation(x, y);
|
||||||
|
if (path != null) {
|
||||||
|
if(!treePlaces.getSelectionModel().isPathSelected(path)){
|
||||||
|
treePlaces.setSelectionPath(path);
|
||||||
|
}
|
||||||
|
popupMenu.show(treePlaces, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
@ -43,8 +44,10 @@ public class TileBundleDownloadDialog extends JDialog {
|
||||||
private JSpinner endSpinner;
|
private JSpinner endSpinner;
|
||||||
private JButton downloadButton;
|
private JButton downloadButton;
|
||||||
private JButton cancelButton;
|
private JButton cancelButton;
|
||||||
|
private JButton specifyFolder;
|
||||||
private File tilesLocation;
|
private File tilesLocation;
|
||||||
|
|
||||||
|
|
||||||
public TileBundleDownloadDialog(Component parent, MapPanel panel){
|
public TileBundleDownloadDialog(Component parent, MapPanel panel){
|
||||||
super(JOptionPane.getFrameForComponent(parent), true);
|
super(JOptionPane.getFrameForComponent(parent), true);
|
||||||
map = panel.getMap();
|
map = panel.getMap();
|
||||||
|
@ -104,6 +107,9 @@ public class TileBundleDownloadDialog extends JDialog {
|
||||||
JPanel buttonControls = new JPanel();
|
JPanel buttonControls = new JPanel();
|
||||||
buttonControls.setLayout(new BoxLayout(buttonControls, BoxLayout.X_AXIS));
|
buttonControls.setLayout(new BoxLayout(buttonControls, BoxLayout.X_AXIS));
|
||||||
buttonControls.add(Box.createHorizontalGlue());
|
buttonControls.add(Box.createHorizontalGlue());
|
||||||
|
specifyFolder = new JButton("Specify different folder");
|
||||||
|
buttonControls.add(specifyFolder);
|
||||||
|
buttonControls.add(Box.createHorizontalStrut(3));
|
||||||
downloadButton = new JButton("Download tiles");
|
downloadButton = new JButton("Download tiles");
|
||||||
buttonControls.add(downloadButton);
|
buttonControls.add(downloadButton);
|
||||||
buttonControls.add(Box.createHorizontalStrut(3));
|
buttonControls.add(Box.createHorizontalStrut(3));
|
||||||
|
@ -144,6 +150,23 @@ public class TileBundleDownloadDialog extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
specifyFolder.addActionListener(new ActionListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.setDialogTitle("Choose working directory");
|
||||||
|
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
if(tilesLocation != null){
|
||||||
|
fc.setCurrentDirectory(tilesLocation);
|
||||||
|
}
|
||||||
|
if(fc.showOpenDialog(TileBundleDownloadDialog.this) == JFileChooser.APPROVE_OPTION && fc.getSelectedFile() != null &&
|
||||||
|
fc.getSelectedFile().isDirectory()){
|
||||||
|
tilesLocation = fc.getSelectedFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue