!7 sclass ImageInfo extends DynModule { S path; bool allowedToLook; Bool exists; Pt size; transient JComboBox cbAllowedToLook; transient BufferedImage image; File file() { ret newFile(path); } void start { ownTimer(doEvery(2.0, r fullUpdate)); // TODO: watch service } JComponent visualize() { if (dir == null) ret jcenteredbutton("Load image...", r { selectFile("Load image", voidfunc(File f) { setField(path := f2s(f)); revisualize(); }); }); if (cbAllowedToLook == null) cbAllowedToLook = yesNoComboBox(allowedToLook, voidfunc(bool b) { setField(allowedToLook := b) }); ret makeForm( "Image location" := path, allowedToLook := cbAllowedToLook, +exists, "Size", size == null ? null : size.x + "*" + size.y, "Loaded" := image != null, "Files contained", filesContained == null ? "Unknown" : l(filesContained)); } void fullUpdate { update(); } void update { lock lock; if (dir != null && allowedToLook) { File dirObject = dirObject(); setField(exists := dirObject.isDirectory()); setField(isFile := dirObject.isFile()); if (setField(filesContained := listFileNames(dirObject))) revisualize(); } else if (setFields(exists := null, isFile := null, filesContained := null)) revisualize(); } // API for other modules S getDir() { ret dir; } L getFiles() { ret filesContained; } }