Other [tool] [B4X] Snippets For B4X - a B4J app

Yes, another code snippet manager, but slightly different. It uses the TreeView and TreeViewExtended view and code.
So you can search on the TreeView, using the TreeViewExtended search feature.

Screen shot of the B4J desktop app:
ScreenShot.png


Current Features:
- comes with the main Categories: B4A, B4J, B4i, JAVA, and WWW Links. Of course, you can add your own category, as many as you want.
- Category - they have snippets. A snippet contains such things as Snippet Name, URL to a web site that you got the code snipppet from, the code snippet, Keywords, and Libraries.
- Button Bar - the main functionalities of the app are defined in the buttons of the Button Bar. Each has a hint text. Some buttons work with a hot key: Ctrl-S for save, Ctrl-N for a new snippet
- Status Bar - shows, for example, which is the currently selected Category, app version number, and the app resizer
- Split Pane divider - allows the user to adjust the divider to see more or less of the treeview and the snippet code
- SQLite database - all data is stored in a local database, in the app folder.
- Context Menus for the TreeView - depending on which tree item you have selected, the context menu is associated to the treeview. So for the Category treeview selected item, the context menu has different menu selections compared to a selected Snippet treeview item.
- URL Link - saving a URL with the snippet, allows the user to launch that URL into the default browser, with the Launch URL button.
- App Settings - allows the user to expand all treeview items, or not, on app startup.
- Save Form dimensions - this allows the user to set the app size and have the app save those dimensions on closing of the app. On app startup, the app reads those dimensions from the database and are applied to the form Window size properties, including the splitter position.

Future Features:
- Printing snippet code - clicking the Print Preview button will display the snippet content in an HTML format, in the default browser. From there, you can print the HTML content to a printer, such as saving it to a PDF file, if you have that PDF driver installed.
- Export Snippet - this would allow the user to create a JSON formatted file with the content of the selected snippet.
- Import Snippet - with an exported JSON formatted file, that was exported using the app, the user could import that file into the app. This would allow user-to-user transporting of code snippets.

Comments:
At this time, the app is only available as a .JAR file, as I would ask for testing, enhancement requests, and bug reporting.
I'm not sure if that's OK with everyone, but I'd like to start out that way.
That would allow me to fix issues and apply requested enhancements.
Eventually, I would release the app project to the community with those fixes and enhancements.
That way, everyone wins who would want the app.
[Edit]: I contacted Erel about using "B4X" in the name of the app, and he said it was OK to use it.

Download link to the app Version 1.35: HERE
 
Last edited:

mfstuart

Active Member
Licensed User
Longtime User
Snippets Manager For B4X - Version 1.2
This is a UI update.

Download: link in post #1

1. Replaced my statusbar (Panel) with jControlsFX StatusBar (existing library)
2. Keywords and Libraries TextFields moved to below Snippet code field. Gives more viewing area for the TreeView items.
3. Added splitPane to the right area of the form.
4. TreeView now has more viewing area
5. Keywords and Libraries fields are in their own splitPane, with the snippet code and other fields and labels above it, in their own splitPane.
6. Category and Snipppets count added below TreeView

1614634449527.png


My thoughts on adding features, besides what I've mentioned in post #1:
1. Add capability to add as many URL Links to the same Snippet as you want. Accessed from a combobox.
2. CCS Style snippet code field. I've looked at the "org.fxmisc.richtext.CodeArea" in @steveL example, but requires a lot more features added to it, to make it a viable option. Like vertical scrollbar, Context Menu, at least. I searched the internet for this control and it can be extended, but I have no knowledge of JAVA to do that. Steve, would you be so kind to add these features?
3. Keywords - add button to read the snippet code and extract the B4X keywords, properties and methods. These would be appended to the Keywords field.
4. Libraries - make it a checkbox list. It would come with the system list of libraries and possibly read the Additional Libraries folder to get the others. Also a button to maintain the list, in case the library you are wanting to check, is not on the list.

Your thoughts on this would be appreciated, as they can be added as well.

Thanx,
Mark Stuart
 
Last edited:

mfstuart

Active Member
Licensed User
Longtime User
Snippets Manager For B4X - Version 1.3
This is a UI and database update.

Download link in post #1

UI Updates:
1. the app now supports more than one URL link for each snippet
2. Main Form - changed out the URL TextField for a ComboBox that contains the URL Links for the selected snippet
3. Main Form - select a URL from the dropdown and click the "Launch URL in Browser" button to open the URL in the default browser
4. URL Links - a new form to manage the URL Links for the selected snippet (see screen shot)

Database Updates:
1. New Table: URLLinks - it will contain all snippet URL Links records
2. Table is auto-added in this version, so if you are using a prior version it will be taken care of by the new app version.
2. Holds a one-to-many URL record for each snippet
3. Table and its data is managed on the URL Links form

Main Form - URL Links access:
1614821816517.png


URL Links screen shot:
1614821412455.png


Thanx for downloading this app. I will be adding more features each week/as I get them completed and tested.

Any bugs or requests, please reply to this thread.

Regards,
Mark Stuart
 

stevel05

Expert
Licensed User
Longtime User
Steve, would you be so kind to add these features?
Sorry I missed the post.

I am no longer using RichTextFX for my own code highlighting, I have moved all my apps to CodeMirror. It seems more robust. Take a look at that and see if it does what you want.
 
Last edited:

mfstuart

Active Member
Licensed User
Longtime User
Hi @stevel05 ,
I incorrectly typed your name/handle in my post. Most likely why you missed it.
Sorry about that chief.

I downloaded all the files from the CodeMirror post and ran it. Very impressive. Thank you for your hard work on that.
It seems you have quite the grasp on Java and JavaFX! I don't, haven't had to until now.

On opening of the B4J Codemirror project, the IDE displays an error in the Log...
[IDE message - 10:02:47]
An error occurred.
Missing jar file for library: CodeMirrorWrapper.xml

I placed all the .B4XLib and .XML files into the B4J Additional Libraries folder. But still the error occurs.
Any ideas why that may be?
But the app does run without any problem.

If I were to implement CodeMirror into my Snippets app, would that be OK with you?
My concern with 3rd party libraries, and such, is the support of such libraries.
What if when there's an issue with the libraries, could I get the support needed in a timely manner?

That even goes for my apps as well. Support has to be there when needed.

Thanx Steve.

Regards,
Mark Stuart
 

mfstuart

Active Member
Licensed User
Longtime User
Snippets Manager For B4X - Version 1.31
This is a UI update.

Download link in post #1
1. Fixed UI and functionality issues on URL Links form
 

stevel05

Expert
Licensed User
Longtime User
Hi Mark,

Any ideas why that may be?

Yes, the CodeMirrorWrapper.xml file is not part of the library, it is the documentation for the B4xlib. Just remove it from your additional libraries folder. The IDE is looking for a corresponding .jar file as it thinks it's looking for a java library.

Feel free to use any of my libraries as you wish.

As with any wrapped library found on the forum, the final result is only as good as the underlying library be it Java or in this case javascript. If there is a problem with this wrapper, then obviously I would be able to help. If it's the underlying library, then it may not be possible to make the required changes.

We all need to be mindful of this when adding 3rd party libraries to our projects and test them thoroughly before committing to them. If it is a commercial project, then as a developer, you need to be comfortable with how the wrapper and library has been created, In this case, from what I have read, the code mirror library is used extensively in the javascript world and wouldn't expect any nasty surprises, but don't just take my word for it.

Finally, as these wrappers are provided at no cost, there can be no guarantee of timely support. I'm sure we will all try to help as much as possible with the libraries we provide. but It may be that you find an issue when the author has just gone on a three week holiday. Even more reason to understand how the wrapper was written and how it works. It'll still save you a lot of time over doing it yourself, but at least you will be able to fix minor bugs, or make improvements yourself if it's necessary.

I should add that some library developers may not like you looking at the code, even in a b4xlib library. For my libraries, feel free to unzip them and look inside.
 
Last edited:

mfstuart

Active Member
Licensed User
Longtime User
Snippets Manager For B4X - Version 1.32
This is a code update.

Download link in post #1

Code Updates:

1. Deleting, Editing, and adding URL Links - this was quite a challenge, as it must not only manage the URLs on the URL Link form, but also must update the Combobox on the main form.
2. Setting the Preferred URL Link - managing this in code, based in item #1

Testing on Mac:
I'm testing the app on a MacBook Pro laptop. To get the app onto the laptop, I'm using the download link in Post #1. I had to install JRE onto the laptop for this.
1. URL Links form - "Test URL" button did not display the "globe" icon as it does on the main form - fixed (had to make it a little bigger)
2. URL's on the Mac - the URL MUST be prepended with the http:// for the code to make a successful launch to the browser. Without it, you'll get an error.

Testing on Linux:
I don't have that OS to test the app. Anyone with it and would like to test it, please let me know.
 

RauchG

Active Member
Licensed User
Longtime User
i would like to try the snippet manager. I loaded the jar and unzipped it with WinRar.

How can I call it up now?
 

inakigarm

Well-Known Member
Licensed User
Longtime User
if your windows have the association between *.jar extension and java, doubleclick on the jar file;
If not, open Cmd, test:
B4X:
java -version
to test if Java is in path and which version you have
In Cmd, write this command (you can write a bat file to automate it):
B4X:
java -jar SnippetsForB4X.jar
 

mfstuart

Active Member
Licensed User
Longtime User
Snippets Manager For B4X - Version 1.33
This is a new feature release: Export and Import Snippets.

Download link in post #1

New Feature:
Ever wanted to share B4X and other code snippets with other developers?
Now you can. The "Snippets Manager For B4X" app now supports this wish list feature.

[EDIT] I should note that you will have to give or send - by email - the exported JSON file to the other person.
It doesn't happen automatically ;)

Screen Shot of new buttons on the button bar:
1615318788431.png


Export - select the snippet in the app and click the export button on the button bar. The app will prompt you with a Save As dialog window. The filename defaults to the Snippet Name, with .json as the filename extension.
The exported file content has every field from the stored record, including the Snippet ID. It is not imported when using the Import feature, but there for reference.

Import - this feature allows you to import a JSON formatted file that has been exported using the "Snippets Manager For B4X". It is specially formatted using the B4X JSONGenerator and therefore certain characters are suffixed with the "\" character. After the successful import, the new snippet will appear under the Snippet Category that was in the JSON file.
If the Category in the JSON file does not exist in your app, it will be added to the Categories table and then appear in the treeview list of snippets. The imported snippet will appear under that new category.

Testing:
Windows 10 - passed March 9, 2021
Macbook Pro: passed March 10, 2021
 
Last edited:

mfstuart

Active Member
Licensed User
Longtime User
Snippets Manager For B4X - Version 1.34
This release contains: New Features, Updates, and Bug Fixes.

Download link in post #1

New Features:
1. Find Keywords - this new feature allows you to find B4X and Java keywords in your Snippet code. Select the Snippet tree entry and click the "Find Keywords" button. The found words will be appended to the existing list of Keywords.
2. Manage Keywords - a Button Bar option to allow you to Activate or Deactivate selected Keywords. eg: sometimes you just don't want the app to find every "If" word in your snippet code. So you would select the "If" word in the Keywords type list and select the Active = No option. Click the Update and then Save Changes buttons.
3. About dialog added - shows App Icon, App Title, App Version, DB Version, and Copyright message.

Find Keywords option:
1615852903995.png


Manage Keywords and About - Button Bar options:
1615853003233.png


Manage Keywords Form:
1615853103511.png


About form:
1615852806806.png


Updates:
1. New Table: Version - this keeps the database version for changes to the database.
2. Trigger added - Categories gets an AFTER DELETE ON trigger to manage deletion of Snippets records when the user deletes a Category.
3. Trigger added - Snippets gets an AFTER DELETE ON trigger to manage deletion of URLLinks records when a user deletes a Snippet.
4. TreeView Context Menu icons - increased size of icons (from 18 to 22)
5. Search category Clear button - change out icon for the word "Clear".

Bug Fixes:
1. URLLinks form - when no URL Link records, Preferred URL combobox shows null.
2. SetFormSize - Upon very first-time startup of app, the form size did not get set.
If the form size settings have no values, the default form size is set to: 40, 40, 1200, 800.
3. Delete Snippet - Yes action did not clear the snippet form controls of values
4. Delete Category - Yes action did not clear the snippet form controls of values
 
Top