Changeset 34229 in osm for applications
- Timestamp:
- 2018-05-30T10:04:11+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/PTWizardAction.java
r34203 r34229 32 32 import javax.swing.JCheckBox; 33 33 import javax.swing.JLabel; 34 import javax.swing.JOptionPane; 34 35 import javax.swing.JPanel; 35 36 import javax.swing.JScrollPane; … … 46 47 import org.openstreetmap.josm.gui.MainApplication; 47 48 import org.openstreetmap.josm.gui.MainMenu; 49 import org.openstreetmap.josm.gui.Notification; 48 50 import org.openstreetmap.josm.gui.download.UserQueryList.SelectorItem; 49 51 import org.openstreetmap.josm.gui.io.CustomConfigurator; … … 58 60 59 61 public boolean noDialogBox; 62 private int closeCheck = 0; 60 63 /** 61 64 * Constructs a new {@code PTWizardAction} … … 97 100 } else { 98 101 action = true; 102 String pages = Main.pref.get("pt_assistant.wizard.pages"); 103 if (pages.isEmpty()) { 104 readPreferencesFromXML(); 105 addDefaultValues(); 106 } 99 107 } 100 108 … … 104 112 panel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); 105 113 106 ExtendedDialog ed = new ExtendedDialog(Main.parent, 107 tr("PT Wizard"), 108 tr("OK"), tr("Close")); 109 ed.setPreferredSize(new Dimension(250, 300)); 110 ed.setButtonIcons("ok", "cancel"); 114 DoubleSplitDialog dsd = new DoubleSplitDialog(); 115 dsd.setPreferredSize(new Dimension(250, 300)); 116 dsd.setButtonIcons("ok", "cancel"); 111 117 JScrollPane scrollPanel = new JScrollPane(panel); 112 ed.setContent(scrollPanel, false); 113 ed.setUndecorated(true); 114 118 dsd.setContent(scrollPanel, false); 115 119 nextAct(0, panel); 116 117 120 String pages = Main.pref.get("pt_assistant.wizard.pages"); 118 121 int lastCheck = -1; 119 122 try { 120 123 for(int i=1;i<=Integer.parseInt(pages)+1;i++) { 121 ExtendedDialog dialog = ed.showDialog(); 124 if (lastCheck == closeCheck) 125 return; 126 else 127 lastCheck = closeCheck; 128 ExtendedDialog dialog = dsd.showDialog(); 122 129 switch (dialog.getValue()) { 123 130 case 1: nextAct(i, panel); break; … … 136 143 try { 137 144 CachedFile cf = getCachedFile(); 145 if (cf == null) 146 return; 138 147 List<String> lines = new ArrayList<>(); 139 148 try (BufferedReader in = cf.getContentReader()){ … … 166 175 167 176 @SuppressWarnings("resource") 168 public CachedFile getCachedFile() throws IOException { 169 return new CachedFile("https://josm.openstreetmap.de/wiki/Plugin/PT_Assistant/Wizard?format=txt").setHttpAccept("text"); 177 public CachedFile getCachedFile() { 178 try { 179 return new CachedFile("https://josm.openstreetmap.de/wiki/Plugin/PT_Assistant/Wizard?format=txt").setHttpAccept("text"); 180 } catch (Exception e) { 181 new Notification(tr("Unable to connect to https://josm.openstreetmap.de/wiki/Plugin/PT_Assistant/Wizard")).setIcon(JOptionPane.WARNING_MESSAGE).show(); 182 } 183 return null; 170 184 } 171 185 … … 357 371 panel.add(new JLabel("<html><br></html>"),GBC.eol().fill(GBC.HORIZONTAL)); 358 372 panel.add(checkBoxPanel, GBC.eol().fill(GBC.HORIZONTAL)); 359 360 373 } 361 374 … … 633 646 } 634 647 } 648 649 private class DoubleSplitDialog extends ExtendedDialog { 650 651 public DoubleSplitDialog() { 652 super(Main.parent, tr("PT Wizard"), new String[] { tr("Ok"), tr("Cancel") }, 653 true); 654 } 655 656 @Override 657 protected void buttonAction(int buttonIndex, ActionEvent evt) { 658 closeCheck++; 659 super.buttonAction(buttonIndex, evt); 660 } 661 662 } 635 663 }
Note:
See TracChangeset
for help on using the changeset viewer.