MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / openDnDResource

Method openDnDResource

src/test/LoaderTest.java:194–239  ·  view source on GitHub ↗
(String target, String fileName)

Source from the content-addressed store, hash-verified

192 }
193
194 private void openDnDResource(String target, String fileName) {
195 boolean loadFailed = false;
196 try {
197 // download target to osp cache
198 if (target.indexOf("document/ServeFile.cfm?") >= 0) {
199 try {
200 target = ResourceLoader.downloadToOSPCache(target, fileName, false).toURI().toString();
201 } catch (Exception ex) {
202 loadFailed = true;
203 }
204 }
205 if (target == null) {
206 loadFailed = true;
207 }
208 if (loadFailed) {
209 String name = fileName;
210 if (name == null || "".equals(name))
211 name = "Unknown";
212 String s = "No resource could be downloaded for node " + name;
213 JOptionPane.showMessageDialog(libraryBrowser, s, "Error",
214 JOptionPane.WARNING_MESSAGE);
215 return;
216 }
217 if (!isZip(target)) {
218 String msg = XML.getName(target)+ " is not a zip file.";
219 JOptionPane.showMessageDialog(frame, msg, "Wrong File Type",
220 JOptionPane.WARNING_MESSAGE);
221 return;
222 }
223 else {
224 // check target to make sure it is a readable zip file
225 Map<String, ZipEntry> contents = ResourceLoader.getZipContents(target, true);
226 if (contents.isEmpty()) {
227 String msg = XML.getName(target)+ " is empty.";
228 JOptionPane.showMessageDialog(frame, msg, "Empty File",
229 JOptionPane.WARNING_MESSAGE);
230 return;
231 }
232// loadIntoEditor(target);
233 new AsyncLoader(target).executeAsync();
234 return;
235 }
236 } finally {
237 libraryBrowser.setCursor(Cursor.getDefaultCursor());
238 }
239 }
240
241 private void openLibraryResource(LibraryResource record) {
242 boolean loadFailed = false;

Callers

nothing calls this directly

Calls 10

downloadToOSPCacheMethod · 0.95
isZipMethod · 0.95
getNameMethod · 0.95
getZipContentsMethod · 0.95
showMessageDialogMethod · 0.80
executeAsyncMethod · 0.80
equalsMethod · 0.65
setCursorMethod · 0.65
toStringMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected