Changeset 30122 in osm for applications/editors/josm
- Timestamp:
- 2013-12-10T00:35:06+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/OpeningHoursEditor
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/OpeningHoursEditor/build.xml
r30112 r30122 15 15 <import file="../build-common.xml"/> 16 16 17 <property name="javacc.home" location="../ ../core/tools"/>17 <property name="javacc.home" location="../00_core_tools"/> 18 18 <property name="parser.dir" location="${plugin.src.dir}/org/openstreetmap/josm/plugins/ohe/parser"/> 19 19 -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheDialogPanel.java
r30116 r30122 24 24 import org.openstreetmap.josm.plugins.ohe.parser.ParseException; 25 25 import org.openstreetmap.josm.plugins.ohe.parser.SyntaxException; 26 import org.openstreetmap.josm.plugins.ohe.parser.TokenMgrError; 26 27 import org.openstreetmap.josm.tools.GBC; 27 28 … … 99 100 toolsPanel.add(Box.createGlue(), GBC.std().fill(GBC.HORIZONTAL)); 100 101 toolsPanel.add(actualPostionLabel, GBC.eop()); 101 102 102 103 editorPanel = new OheEditor(this); 103 104 … … 132 133 time = OpeningTimeUtils.convert(compiler.startCompile()); 133 134 } catch (Throwable t) { 135 Main.warn(t); 136 134 137 int tColumns[] = null; 135 String info = null;138 String info = t.getMessage(); 136 139 137 140 if (t instanceof ParseException) { … … 141 144 SyntaxException syntaxError = (SyntaxException) t; 142 145 tColumns = new int[] { syntaxError.getStartColumn(), syntaxError.getEndColumn() }; 143 info = syntaxError.getMessage(); 144 } else { 145 info = t.getMessage(); 146 Main.warn(t); 146 } else if (t instanceof TokenMgrError) { 147 try { 148 // With JavaCC 6 Message is: "Lexical error at line 1, column 20. Encountered: "P" (80), after : "" 149 int idx = info.indexOf("column "); 150 if (idx > -1) { 151 int col = Integer.parseInt(info.substring(idx+"column ".length(), info.indexOf('.', idx))); 152 tColumns = new int[] { col - 1, col + 1 }; 153 } 154 } catch (IndexOutOfBoundsException e) { 155 Main.warn(e); 156 } catch (NumberFormatException e) { 157 Main.warn(e); 158 } 147 159 } 148 160 149 161 // shows a Information Dialog, where the Error occurred 150 if (tColumns != null) { 151 int first = Math.max(0, tColumns[0]); 152 int last = Math.min(value.length(), tColumns[1]); 153 String begin = value.substring(0, first); 154 String middle = value.substring(first, last); 155 String end = value.substring(last); 156 valueField.setCaretPosition(first); 157 // TODO focus on the valueField 158 String message = "<html>" + tr("There is something wrong in the value near:") + "<br>" + begin 159 + "<span style='background-color:red;'>" + middle + "</span>" + end; 160 if (info != null) 161 message += "<br>" + tr("Info: {0}", tr(info)); 162 message += "<br>" + tr("Correct the value manually and than press Enter."); 163 message += "</html>"; 164 JOptionPane.showMessageDialog(this, message, tr("Error in timeformat"), 165 JOptionPane.INFORMATION_MESSAGE); 162 if (tColumns != null || info != null) { 163 String message = "<html>"; 164 if (tColumns != null) { 165 int first = Math.max(0, tColumns[0]); 166 int last = Math.min(value.length(), tColumns[1]); 167 String begin = value.substring(0, first); 168 String middle = value.substring(first, last); 169 String end = value.substring(last); 170 valueField.setCaretPosition(first); 171 // TODO focus on the valueField 172 message += tr("There is something wrong in the value near:") + "<br>" + begin 173 + "<span style='background-color:red;'>" + middle + "</span>" + end; 174 } 175 if (info != null) { 176 if (tColumns != null) { 177 message += "<br>"; 178 } 179 message += tr("Info: {0}", tr(info)); 180 } 181 message += "<br>" + tr("Correct the value manually and than press Enter.") + "</html>"; 182 JOptionPane.showMessageDialog(this, message, tr("Error in timeformat"), JOptionPane.INFORMATION_MESSAGE); 166 183 } 167 184
Note:
See TracChangeset
for help on using the changeset viewer.