added an experimental library path

This commit is contained in:
hneemann 2017-07-17 08:58:26 +02:00
parent 9755e42d75
commit 9baf1a5b82
2 changed files with 18 additions and 2 deletions

View File

@ -45,6 +45,21 @@ import java.util.*;
public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer> {
private static final Logger LOGGER = LoggerFactory.getLogger(ElementLibrary.class);
/**
* @return the additional library path
*/
public static String getLibPath() {
String path = ElementLibrary.class.getProtectionDomain().getCodeSource().getLocation().getPath().replace('\\', '/');
if (path.endsWith("/target/classes/"))
return path.substring(0, path.length() - 16) + "/src/main/dig/lib";
if (path.endsWith("/target/Digital.jar"))
return path.substring(0, path.length() - 19) + "/src/main/dig/lib";
if (path.endsWith("Digital.jar"))
return path.substring(0, path.length() - 12) + "/examples/lib";
return null;
}
private final HashMap<String, LibraryNode> map = new HashMap<>();
private final HashSet<String> isProgrammable = new HashSet<>();
private final ArrayList<LibraryListener> listeners = new ArrayList<>();
@ -276,6 +291,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
private void rescanFolder() throws IOException {
LOGGER.debug("rescan folder");
LOGGER.info("library " + getLibPath());
LibraryNode changedNode = null;
if (rootLibraryPath != null) {
if (customNode == null) {
@ -311,7 +327,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
l.libraryChanged(node);
}
private int scanFolder(File path, LibraryNode node) {
private static int scanFolder(File path, LibraryNode node) {
int num = 0;
File[] list = path.listFiles();
if (list != null) {

View File

@ -234,7 +234,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
getContentPane().add(toolBar, BorderLayout.NORTH);
setJMenuBar(menuBar);
JMenu help = InfoDialog.getInstance().addToFrame(this, MESSAGE);
JMenu help = InfoDialog.getInstance().addToFrame(this, MESSAGE+"\n\nlib: "+ElementLibrary.getLibPath());
help.add(new ToolTipAction(Lang.get("menu_help_elements")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {