From c66d969c2e67d7d89b9468ce73a0b3eb4de1d55a Mon Sep 17 00:00:00 2001 From: saf Date: Wed, 3 Jun 2020 16:58:15 +0200 Subject: [PATCH 1/4] add library name as section name for user imported libraries --- .../kit/library/user/LibraryFolderWatcher.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java index 2ce1c0530..3e60a38ff 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java @@ -411,9 +411,19 @@ private Collection makeLibraryItems(JarReport jarOrFolderReport) th final String canonicalName = e.getKlass().getCanonicalName(); if (!excludedItems.contains(canonicalName) && !artifactsFilter.contains(canonicalName)) { - final String name = e.getKlass().getSimpleName(); - final String fxmlText = JarExplorer.makeFxmlText(e.getKlass()); - result.add(new LibraryItem(name, UserLibrary.TAG_USER_DEFINED, fxmlText, iconURL, library)); + + final String name = e.getKlass().getSimpleName(); + String sectionName =jarOrFolderReport.getJar().toString(); + + // if some os don't use '/' for folder path (don't know if there is) + if (sectionName.lastIndexOf("\\")==-1) + sectionName=UserLibrary.TAG_USER_DEFINED; + else + sectionName=sectionName.substring(sectionName.lastIndexOf("\\")+1, + sectionName.lastIndexOf(".")); + + final String fxmlText = JarExplorer.makeFxmlText(e.getKlass()); + result.add(new LibraryItem(name, sectionName, fxmlText, iconURL, library)); } } } From 914d85a44f42f39c9f316682004a25cf2dfa9aca Mon Sep 17 00:00:00 2001 From: saf Date: Wed, 24 Mar 2021 00:50:38 +0100 Subject: [PATCH 2/4] taking possible errors into account --- .../library/user/LibraryFolderWatcher.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java index 3e60a38ff..bad75b5ff 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java @@ -411,18 +411,15 @@ private Collection makeLibraryItems(JarReport jarOrFolderReport) th final String canonicalName = e.getKlass().getCanonicalName(); if (!excludedItems.contains(canonicalName) && !artifactsFilter.contains(canonicalName)) { - - final String name = e.getKlass().getSimpleName(); - String sectionName =jarOrFolderReport.getJar().toString(); - - // if some os don't use '/' for folder path (don't know if there is) - if (sectionName.lastIndexOf("\\")==-1) - sectionName=UserLibrary.TAG_USER_DEFINED; - else - sectionName=sectionName.substring(sectionName.lastIndexOf("\\")+1, - sectionName.lastIndexOf(".")); - - final String fxmlText = JarExplorer.makeFxmlText(e.getKlass()); + final String name = e.getKlass().getSimpleName(); + String sectionName; + try{ + sectionName=jarOrFolderReport.getJar().toFile().getName().replace(".jar", ""); + }catch(Exception exception){ + //if getJar returns null or toFile not finding path + sectionName=UserLibrary.TAG_USER_DEFINED; + } + final String fxmlText = BuiltinLibrary.makeFxmlText(e.getKlass()); result.add(new LibraryItem(name, sectionName, fxmlText, iconURL, library)); } } From 9ad272a856c5e8bdc35cb248206a5a32abcb669c Mon Sep 17 00:00:00 2001 From: saf Date: Fri, 2 Apr 2021 09:54:53 +0200 Subject: [PATCH 3/4] move sectionName creation to function --- .../kit/library/user/LibraryFolderWatcher.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java index d58c8dc06..89bc6f59c 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java @@ -438,13 +438,7 @@ private Collection makeLibraryItems(JarReport jarOrFolderReport) th if (!excludedItems.contains(canonicalName) && !artifactsFilter.contains(canonicalName)) { final String name = e.getKlass().getSimpleName(); - String sectionName; - try{ - sectionName=jarOrFolderReport.getJar().toFile().getName().replace(".jar", ""); - }catch(Exception exception){ - //if getJar returns null or toFile not finding path - sectionName=UserLibrary.TAG_USER_DEFINED; - } + final String sectionName = createSectionName(jarOrFolderReport); final String fxmlText = BuiltinLibrary.makeFxmlText(e.getKlass()); result.add(new LibraryItem(name, sectionName, fxmlText, iconURL, library)); } @@ -453,7 +447,13 @@ private Collection makeLibraryItems(JarReport jarOrFolderReport) th return result; } - + private String createSectionName(JarReport jarReport) { + try { + return jarReport.getJar().toFile().getName().replace(".jar", ""); + } catch (Exception e) { + return UserLibrary.TAG_USER_DEFINED; + } + } private URL[] makeURLArrayFromPaths(Collection paths) { final URL[] result = new URL[paths.size()]; From 1044fbfdec8f7989002a2951a605eebf538cae04 Mon Sep 17 00:00:00 2001 From: saf Date: Fri, 2 Apr 2021 10:30:44 +0200 Subject: [PATCH 4/4] updating license year --- .../scenebuilder/kit/library/user/LibraryFolderWatcher.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java index 89bc6f59c..c56733768 100644 --- a/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java +++ b/kit/src/main/java/com/oracle/javafx/scenebuilder/kit/library/user/LibraryFolderWatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Gluon and/or its affiliates. + * Copyright (c) 2017, 2021, Gluon and/or its affiliates. * Copyright (c) 2012, 2014, Oracle and/or its affiliates. * All rights reserved. Use is subject to license terms. *