(JMenu menu, final Record rec,
String sketchbookPath)
| 139 | |
| 140 | |
| 141 | static private void updateMenuRecord(JMenu menu, final Record rec, |
| 142 | String sketchbookPath) { |
| 143 | try { |
| 144 | String recPath = new File(rec.getPath()).getParent(); |
| 145 | String purtyPath = null; |
| 146 | |
| 147 | if (recPath.startsWith(sketchbookPath)) { |
| 148 | purtyPath = "sketchbook \u2192 " + |
| 149 | recPath.substring(sketchbookPath.length() + 1); |
| 150 | } else { |
| 151 | List<Mode> modes = base.getModeList(); |
| 152 | for (Mode mode : modes) { |
| 153 | File examplesFolder = mode.getExamplesFolder(); |
| 154 | String examplesPath = examplesFolder.getAbsolutePath(); |
| 155 | if (recPath.startsWith(examplesPath)) { |
| 156 | String modePrefix = mode.getTitle() + " "; |
| 157 | if (mode.getTitle().equals("Standard")) { |
| 158 | modePrefix = ""; // "Standard examples" is dorky |
| 159 | } |
| 160 | purtyPath = modePrefix + "examples \u2192 " + |
| 161 | recPath.substring(examplesPath.length() + 1); |
| 162 | break; |
| 163 | } |
| 164 | |
| 165 | if (mode.coreLibraries != null) { |
| 166 | for (Library lib : mode.coreLibraries) { |
| 167 | examplesFolder = lib.getExamplesFolder(); |
| 168 | examplesPath = examplesFolder.getAbsolutePath(); |
| 169 | if (recPath.startsWith(examplesPath)) { |
| 170 | purtyPath = lib.getName() + " examples \u2192 " + |
| 171 | recPath.substring(examplesPath.length() + 1); |
| 172 | break; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if (mode.contribLibraries != null) { |
| 178 | for (Library lib : mode.contribLibraries) { |
| 179 | examplesFolder = lib.getExamplesFolder(); |
| 180 | examplesPath = examplesFolder.getAbsolutePath(); |
| 181 | if (recPath.startsWith(examplesPath)) { |
| 182 | purtyPath = lib.getName() + " examples \u2192 " + |
| 183 | recPath.substring(examplesPath.length() + 1); |
| 184 | break; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | if (purtyPath == null) { |
| 191 | String homePath = System.getProperty("user.home"); |
| 192 | if (recPath.startsWith(homePath)) { |
| 193 | // Not localized, but this is gravy. It'll work on OS X & EN Windows |
| 194 | String desktopPath = homePath + File.separator + "Desktop"; |
| 195 | if (recPath.startsWith(desktopPath)) { |
| 196 | purtyPath = "Desktop \u2192 " + recPath.substring(desktopPath.length() + 1); |
| 197 | } else { |
| 198 | //purtyPath = "\u2302 \u2192 " + recPath.substring(homePath.length() + 1); |
no test coverage detected