MCPcopy Index your code
hub / github.com/processing/processing / doInBackground

Method doInBackground

app/src/processing/app/Sketch.java:1070–1108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1068 new SwingWorker<Void, Void>() {
1069
1070 @Override
1071 protected Void doInBackground() throws Exception {
1072 addPropertyChangeListener(new PropertyChangeListener() {
1073 public void propertyChange(PropertyChangeEvent evt) {
1074 if ("progress".equals(evt.getPropertyName())) {
1075 progressBar.setValue((Integer) evt.getNewValue());
1076 }
1077 }
1078 });
1079
1080 long totalSize = 0;
1081 for (File copyable : copyItems) {
1082 totalSize += Util.calcSize(copyable);
1083 }
1084
1085 long progress = 0;
1086 setProgress(0);
1087 for (File copyable : copyItems) {
1088 if (copyable.isDirectory()) {
1089 copyDir(copyable,
1090 new File(newFolder, copyable.getName()),
1091 progress, totalSize);
1092 progress += Util.calcSize(copyable);
1093 } else {
1094 copyFile(copyable,
1095 new File(newFolder, copyable.getName()),
1096 progress, totalSize);
1097 if (Util.calcSize(copyable) < 512 * 1024) {
1098 // If the file length > 0.5MB, the copyFile() function has
1099 // been redesigned to change progress every 0.5MB so that
1100 // the progress bar doesn't stagnate during that time
1101 progress += Util.calcSize(copyable);
1102 setProgress((int) (progress * 100L / totalSize));
1103 }
1104 }
1105 }
1106 saving.set(false);
1107 return null;
1108 }
1109
1110
1111 /**

Callers

nothing calls this directly

Calls 6

calcSizeMethod · 0.95
copyDirMethod · 0.95
copyFileMethod · 0.95
setMethod · 0.65
setProgressMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected