mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 23:45:17 -04:00
scan of library only at startup
This commit is contained in:
parent
d1b5eccc51
commit
da3f2311e5
@ -67,7 +67,6 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
|||||||
private final LibraryNode root;
|
private final LibraryNode root;
|
||||||
private ShapeFactory shapeFactory;
|
private ShapeFactory shapeFactory;
|
||||||
private ElementLibraryFolder custom;
|
private ElementLibraryFolder custom;
|
||||||
private ElementLibraryFolder library;
|
|
||||||
private File rootLibraryPath;
|
private File rootLibraryPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,7 +160,10 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
|||||||
populateNodeMap();
|
populateNodeMap();
|
||||||
|
|
||||||
custom = new ElementLibraryFolder(root, Lang.get("menu_custom"));
|
custom = new ElementLibraryFolder(root, Lang.get("menu_custom"));
|
||||||
library = new ElementLibraryFolder(root, Lang.get("menu_library"));
|
|
||||||
|
File libPath = Settings.getInstance().get(Keys.SETTINGS_LIBRARY_PATH);
|
||||||
|
if (libPath != null && libPath.exists())
|
||||||
|
new ElementLibraryFolder(root, Lang.get("menu_library")).scanFolder(libPath);
|
||||||
|
|
||||||
isProgrammable.clear();
|
isProgrammable.clear();
|
||||||
root.traverse(libraryNode -> {
|
root.traverse(libraryNode -> {
|
||||||
@ -296,22 +298,12 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
|||||||
|
|
||||||
private void rescanFolder() throws IOException {
|
private void rescanFolder() throws IOException {
|
||||||
LOGGER.debug("rescan folder");
|
LOGGER.debug("rescan folder");
|
||||||
File libPath = Settings.getInstance().get(Keys.SETTINGS_LIBRARY_PATH);
|
LibraryNode cn = custom.scanFolder(rootLibraryPath);
|
||||||
if (libPath != null && !libPath.exists()) libPath = null;
|
|
||||||
|
|
||||||
LibraryNode cn1 = library.scanFolder(libPath);
|
|
||||||
LibraryNode cn2 = custom.scanFolder(rootLibraryPath);
|
|
||||||
|
|
||||||
populateNodeMap();
|
populateNodeMap();
|
||||||
|
|
||||||
if (cn1 == root || cn2 == root) {
|
if (cn != null)
|
||||||
fireLibraryChanged(root);
|
fireLibraryChanged(cn);
|
||||||
} else {
|
|
||||||
if (cn1 != null)
|
|
||||||
fireLibraryChanged(cn1);
|
|
||||||
if (cn2 != null)
|
|
||||||
fireLibraryChanged(cn2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,15 +37,6 @@ public class ElementLibraryFolder {
|
|||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasChanged(File path) {
|
|
||||||
File lp = lastPath;
|
|
||||||
lastPath = path;
|
|
||||||
|
|
||||||
if (lp == path) return false;
|
|
||||||
|
|
||||||
return lp == null || !lp.equals(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scans the given folder
|
* scans the given folder
|
||||||
*
|
*
|
||||||
@ -54,7 +45,6 @@ public class ElementLibraryFolder {
|
|||||||
*/
|
*/
|
||||||
public LibraryNode scanFolder(File path) {
|
public LibraryNode scanFolder(File path) {
|
||||||
LibraryNode changedNode = null;
|
LibraryNode changedNode = null;
|
||||||
if (hasChanged(path)) {
|
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
node = new LibraryNode(menuTitle);
|
node = new LibraryNode(menuTitle);
|
||||||
@ -71,7 +61,6 @@ public class ElementLibraryFolder {
|
|||||||
node = null;
|
node = null;
|
||||||
changedNode = root;
|
changedNode = root;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return changedNode;
|
return changedNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user