MCPcopy Index your code
hub / github.com/arduino/Arduino / importData

Method importData

app/src/processing/app/Editor.java:396–446  ·  view source on GitHub ↗
(JComponent src, Transferable transferable)

Source from the content-addressed store, hash-verified

394 }
395
396 @SuppressWarnings("unchecked")
397 public boolean importData(JComponent src, Transferable transferable) {
398 int successful = 0;
399
400 try {
401 DataFlavor uriListFlavor =
402 new DataFlavor("text/uri-list;class=java.lang.String");
403
404 if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
405 List<File> list = (List<File>)
406 transferable.getTransferData(DataFlavor.javaFileListFlavor);
407 for (File file : list) {
408 if (sketchController.addFile(file)) {
409 successful++;
410 }
411 }
412 } else if (transferable.isDataFlavorSupported(uriListFlavor)) {
413 // Some platforms (Mac OS X and Linux, when this began) preferred
414 // this method of moving files.
415 String data = (String)transferable.getTransferData(uriListFlavor);
416 String[] pieces = PApplet.splitTokens(data, "\r\n");
417 for (String piece : pieces) {
418 if (piece.startsWith("#")) continue;
419
420 String path = null;
421 if (piece.startsWith("file:///")) {
422 path = piece.substring(7);
423 } else if (piece.startsWith("file:/")) {
424 path = piece.substring(5);
425 }
426 if (sketchController.addFile(new File(path))) {
427 successful++;
428 }
429 }
430 }
431 } catch (Exception e) {
432 e.printStackTrace();
433 return false;
434 }
435
436 if (successful == 0) {
437 statusError(tr("No files were added to the sketch."));
438
439 } else if (successful == 1) {
440 statusNotice(tr("One file added to the sketch."));
441
442 } else {
443 statusNotice(I18n.format(tr("{0} files added to the sketch."), successful));
444 }
445 return true;
446 }
447 }
448
449 private void setPlacement(int[] storedLocation, int[] defaultLocation) {

Callers

nothing calls this directly

Calls 7

splitTokensMethod · 0.95
formatMethod · 0.95
printStackTraceMethod · 0.80
trMethod · 0.80
statusErrorMethod · 0.65
statusNoticeMethod · 0.65
addFileMethod · 0.45

Tested by

no test coverage detected