Changeset 34189 in osm for applications
- Timestamp:
- 2018-05-13T11:38:49+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r33579 r34189 12 12 import java.awt.GridBagConstraints; 13 13 import java.awt.GridBagLayout; 14 import java.awt.GridLayout;15 14 import java.awt.event.ActionEvent; 16 15 import java.awt.event.ActionListener; … … 61 60 import org.openstreetmap.josm.gui.progress.swing.SwingRenderingProgressMonitor; 62 61 import org.openstreetmap.josm.gui.util.WindowGeometry; 62 import org.openstreetmap.josm.spi.preferences.Config; 63 63 import org.openstreetmap.josm.tools.ImageProvider; 64 64 import org.openstreetmap.josm.tools.Logging; … … 115 115 } 116 116 117 private File fileName;117 private File pdfFile; 118 118 private PathOptimizer data; 119 119 private OsmDataLayer layer; … … 242 242 } 243 243 244 JPanel projectionPanel = null; 245 JPanel okCancelPanel = null; 246 244 247 private void buildGUI() { 245 248 GridBagConstraints c = new GridBagConstraints(); 246 249 c.gridheight = 1; c.gridwidth = 1; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; 250 c.insets = new java.awt.Insets(0,0,0,0); 251 // c.ipadx = 1; c.ipady = 1; 247 252 248 253 this.projectionCombo = new JComboBox<>(); … … 356 361 357 362 358 JPanelprojectionPanel = new JPanel(new GridBagLayout());363 projectionPanel = new JPanel(new GridBagLayout()); 359 364 projectionPanel.setBorder(BorderFactory.createTitledBorder(tr("Bind to coordinates"))); 365 // projectionPanel.setVisible(false); 360 366 361 367 JPanel projectionSubPanel = new JPanel(); … … 365 371 projectionSubPanel.add(this.projectionCombo); 366 372 projectionSubPanel.add(this.projectionPreferencesButton); 373 this.projectionPreferencesButton.setEnabled(false); // ToDo: disabled do avoid bugs 374 367 375 c.gridx = 0; c.gridy = 0; c.gridwidth = 3; 368 376 projectionPanel.add(projectionSubPanel, c); … … 403 411 projectionPanel.add(this.getMaxButton, c); 404 412 405 JPanel okCancelPanel = new JPanel(new GridLayout(1, 3)); 413 okCancelPanel = new JPanel(new FlowLayout()); 414 // okCancelPanel.setVisible(false); 406 415 okCancelPanel.add(this.cancelButton); 407 416 okCancelPanel.add(this.showButton); … … 412 421 c.gridx = 0; c.gridy = 0; c.gridwidth = 1; 413 422 panel.add(configPanel, c); 414 c.gridx = 0; c.gridy = 1; c.gridwidth = 1; 423 c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; 415 424 panel.add(loadFileButton, c); 416 425 c.gridx = 0; c.gridy = 2; c.gridwidth = 1; … … 418 427 c.gridx = 0; c.gridy = 3; c.gridwidth = 1; 419 428 panel.add(okCancelPanel, c); 420 c.gridx = 0; c.gridy = 4; c.gridwidth = 1; 429 c.gridx = 0; c.gridy = 4; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTH; c.fill = GridBagConstraints.HORIZONTAL; 421 430 panel.add(this.loadProgress, c); 422 431 … … 556 565 public void run() { 557 566 //async part 567 LoadPdfDialog.this.loadProgress.setVisible(true); 558 568 SwingRenderingProgressMonitor monitor = new SwingRenderingProgressMonitor(progressRenderer); 559 569 monitor.beginTask("Loading file", 1000); … … 577 587 if (data != null) { 578 588 LoadPdfDialog.this.placeLayer(newLayer, new FilePlacement()); 579 fileName = newFileName;589 pdfFile = newFileName; 580 590 newLayer = null; 581 LoadPdfDialog.this.loadFileButton.setText(tr("Loaded") );591 LoadPdfDialog.this.loadFileButton.setText(tr("Loaded") + ": " + LoadPdfDialog.this.pdfFile.getName()); 582 592 LoadPdfDialog.this.loadFileButton.setEnabled(true); 583 593 FilePlacement placement = LoadPdfDialog.this.loadPlacement(); … … 619 629 public void run() { 620 630 //async part 631 LoadPdfDialog.this.loadProgress.setVisible(true); 621 632 SwingRenderingProgressMonitor monitor = new SwingRenderingProgressMonitor(progressRenderer); 622 633 LoadPdfDialog.this.newLayer = LoadPdfDialog.this.makeLayer( 623 tr("Imported PDF: ") + fileName, placement, OsmBuilder.Mode.Final, monitor);634 tr("Imported PDF: ") + pdfFile, placement, OsmBuilder.Mode.Final, monitor); 624 635 progressRenderer.finish(); 625 636 } … … 722 733 } 723 734 735 private static JFileChooser loadChooser = null; 736 724 737 private java.io.File chooseFile() { 725 //get file name 726 JFileChooser fc = new JFileChooser(); 727 fc.setAcceptAllFileFilterUsed(false); 728 fc.setMultiSelectionEnabled(false); 729 fc.setSelectedFile(this.fileName); 730 fc.setFileFilter(new FileFilter() { 731 @Override 732 public boolean accept(java.io.File pathname) { 733 return pathname.isDirectory() || pathname.getName().endsWith(".pdf"); 734 } 735 736 @Override 737 public String getDescription() { 738 return tr("PDF files"); 739 } 740 }); 741 int result = fc.showOpenDialog(Main.parent); 738 //get PDF file to load 739 if (loadChooser == null) { 740 loadChooser = new JFileChooser(Config.getPref().get("plugins.pdfimport.loadDir")); 741 loadChooser.setAcceptAllFileFilterUsed(false); 742 loadChooser.setMultiSelectionEnabled(false); 743 loadChooser.setFileFilter(new FileFilter() { 744 @Override 745 public boolean accept(java.io.File pathname) { 746 return pathname.isDirectory() || pathname.getName().endsWith(".pdf"); 747 } 748 749 @Override 750 public String getDescription() { 751 return tr("PDF files"); 752 } 753 }); 754 } else { 755 loadChooser.rescanCurrentDirectory(); 756 } 757 int result = loadChooser.showOpenDialog(this); 742 758 743 759 if (result != JFileChooser.APPROVE_OPTION) { 744 760 return null; 745 761 } else { 746 return fc.getSelectedFile();762 return loadChooser.getSelectedFile(); 747 763 } 748 764 } … … 993 1009 this.minNorthField.setText(Double.toString(placement.minNorth)); 994 1010 this.maxNorthField.setText(Double.toString(placement.maxNorth)); 1011 projectionPanel.setEnabled(true); 1012 okCancelPanel.setEnabled(true);; 1013 this.showButton.setEnabled(true); 1014 this.saveButton.setEnabled(true); 1015 this.okButton.setEnabled(true); 1016 this.getMaxButton.setEnabled(true); 1017 this.getMinButton.setEnabled(true); 995 1018 } 996 1019 … … 998 1021 FilePlacement pl = null; 999 1022 //load saved transformation 1000 File propertiesFile = new File( fileName.getAbsoluteFile()+ ".placement");1023 File propertiesFile = new File(pdfFile.getAbsoluteFile() + ".placement"); 1001 1024 try { 1002 1025 … … 1017 1040 private void savePlacement(FilePlacement pl) { 1018 1041 //load saved transformation 1019 File propertiesFile = new File( fileName.getAbsoluteFile()+ ".placement");1042 File propertiesFile = new File(pdfFile.getAbsoluteFile()+ ".placement"); 1020 1043 try { 1021 1044 Properties p = pl.toProperties(); … … 1052 1075 this.layer = null; 1053 1076 } 1077 // projectionPanel.setVisible(false); 1078 // okCancelPanel.setVisible(false); 1079 // loadProgress.setVisible(false); 1080 this.showButton.setEnabled(false); 1081 this.saveButton.setEnabled(false); 1082 this.okButton.setEnabled(false); 1083 this.getMaxButton.setEnabled(false); 1084 this.getMinButton.setEnabled(false); 1085 1054 1086 } 1055 1087
Note:
See TracChangeset
for help on using the changeset viewer.