()
| 2282 | } |
| 2283 | |
| 2284 | public void handlePlotter() { |
| 2285 | if(serialMonitor != null) { |
| 2286 | if(serialMonitor.isClosed()) { |
| 2287 | serialMonitor = null; |
| 2288 | } else { |
| 2289 | statusError(tr("Plotter not available while serial monitor is open")); |
| 2290 | return; |
| 2291 | } |
| 2292 | } |
| 2293 | |
| 2294 | if (serialPlotter != null) { |
| 2295 | // The serial plotter already exists |
| 2296 | |
| 2297 | if (serialPlotter.isClosed()) { |
| 2298 | // If it's closed, clear the refrence to the existing |
| 2299 | // plotter and create a new one |
| 2300 | serialPlotter.dispose(); |
| 2301 | serialPlotter = null; |
| 2302 | } |
| 2303 | else { |
| 2304 | // If it's not closed, give it the focus |
| 2305 | try { |
| 2306 | serialPlotter.toFront(); |
| 2307 | serialPlotter.requestFocus(); |
| 2308 | return; |
| 2309 | } catch (Exception e) { |
| 2310 | // noop |
| 2311 | } |
| 2312 | } |
| 2313 | } |
| 2314 | |
| 2315 | BoardPort port = Base.getDiscoveryManager().find(PreferencesData.get("serial.port")); |
| 2316 | |
| 2317 | if (port == null) { |
| 2318 | statusError(I18n.format(tr("Board at {0} is not available"), PreferencesData.get("serial.port"))); |
| 2319 | return; |
| 2320 | } |
| 2321 | |
| 2322 | serialPlotter = new SerialPlotter(port); |
| 2323 | Base.setIcon(serialPlotter); |
| 2324 | |
| 2325 | // If currently uploading, disable the plotter (it will be later |
| 2326 | // enabled when done uploading) |
| 2327 | if (uploading) { |
| 2328 | try { |
| 2329 | serialPlotter.suspend(); |
| 2330 | } catch (Exception e) { |
| 2331 | statusError(e); |
| 2332 | } |
| 2333 | } |
| 2334 | |
| 2335 | boolean success = false; |
| 2336 | do { |
| 2337 | if (serialPlotter.requiresAuthorization() && !PreferencesData.has(serialPlotter.getAuthorizationKey())) { |
| 2338 | PasswordAuthorizationDialog dialog = new PasswordAuthorizationDialog(this, tr("Type board password to access its console")); |
| 2339 | dialog.setLocationRelativeTo(this); |
| 2340 | dialog.setVisible(true); |
| 2341 |
no test coverage detected