Add biomech window#31
Conversation
remove licensekey ref and download prebuilt jar instead
…r' into opensim-gui-jxbrowser7
…serve for downloads
… the module jar file
…utes of a trial (name, segments, .... etc.) and use to enable users to select actions accordingly.
…tiple segment trials
…TopComponent add cleanup on exit
…ad prematurely, also guard against missing grf file(s)
|
This PR adds the AddBiomechanics window to the OpenSim GUI allowing users to download and handle zip files on OpenSim format. |
There was a problem hiding this comment.
Pull request overview
This PR introduces an “AddBiomechanics” window built on the existing embedded JxBrowser integration, adds UI/resources to support downloading and importing datasets from addbiomechanics.org, and updates a couple of documentation links/notes.
Changes:
- Added a new
AddBiomechanicsTopComponentthat embeds JxBrowser and wires download handling into an “import” flow. - Added
org.opensim.addBiomechclasses to unpack downloaded zips, discover models/trials, and load motions into the app. - Updated JxBrowser engine initialization/caching and refreshed README / welcome page links.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates note about JxBrowser7 license. |
| jxbrowser/src/org/opensim/javabrowser/welcome.html | Updates “What’s New” link to OpenSim 4.6 page. |
| jxbrowser/src/org/opensim/javabrowser/jxBrowserTopComponent.java | Refactors Engine creation into a shared cached engine and tweaks model-change event handling. |
| jxbrowser/src/org/opensim/javabrowser/Bundle.properties | Adds localized strings for the new AddBiomechanics window UI. |
| jxbrowser/src/org/opensim/javabrowser/AddBiomechanicsTopComponent.java | New TopComponent embedding JxBrowser with download callbacks. |
| jxbrowser/src/org/opensim/javabrowser/AddBiomechanicsTopComponent.form | NetBeans form definition for the new TopComponent. |
| jxbrowser/src/org/opensim/addBiomech/Installer.java | Module shutdown hook to clean up downloads directory. |
| jxbrowser/src/org/opensim/addBiomech/Bundle.properties | UI strings for the download-handling panel. |
| jxbrowser/src/org/opensim/addBiomech/AddBiomechPrefs.java | Preferences helper for download directory location. |
| jxbrowser/src/org/opensim/addBiomech/AddBiomechanicsTrial.java | Trial abstraction + “stitching” helpers for multi-segment downloads. |
| jxbrowser/src/org/opensim/addBiomech/AddBiomechanicsHandleDownloadJPanel.java | Zip extraction + UI flow to open/associate downloaded content. |
| jxbrowser/src/org/opensim/addBiomech/AddBiomechanicsHandleDownloadJPanel.form | NetBeans form definition for the download-handling panel. |
| jxbrowser/nbproject/project.xml | Adds module dependencies needed for dialogs/UI and modeling/logger usage. |
| jxbrowser/manifest.mf | Registers module installer and changes public package exports. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| If you would like to use JxBrowser in your development, please contact TeamDev. | ||
|
|
||
| Upgraded to jXBrowser7 in 10/25 | ||
| Upgraded to jXBrowser7 in 10/25 with new dedicated project license rather then OpenSource one. |
| Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.OFF_SCREEN) | ||
| .licenseKey("4UNGXAXTRYIHI4S4DZYH52OM3U0NQ188QVOUJDS0M7QMDCF0RKIL1YBWQJT0U6L5GCDZK7J949904OT7JYQUSHQ7ETBOBK9A3RD2ENRJK48F9HH2F8CWAD3MAP1BZKBN4ZVYC0D9R89R75KTYLN") | ||
| .addSwitch("--js-flags=--max-old-space-size=256") // JS heap in MB |
| package org.opensim.addBiomech; | ||
|
|
||
| import org.opensim.utils.TheApp; | ||
| import static org.opensim.utils.TheApp.getCurrentVersionPreferences; | ||
|
|
||
| /** | ||
| * | ||
| * @author ayman | ||
| */ | ||
| public final class AddBiomechPrefs { | ||
| public static String getDownloadsDir() { | ||
| return getCurrentVersionPreferences().get("AddBiomechDownloadFolder", TheApp.getInstallDir()+"/"+"AddBiomechDownloads"); | ||
| } | ||
| } |
| @Override | ||
| public void close() { | ||
| // Called when shutdown is confirmed — do your cleanup here | ||
| deleteTempFiles(); | ||
| } | ||
|
|
||
| private void deleteTempFiles() { | ||
| Path downloadPath = Paths.get(AddBiomechPrefs.getDownloadsDir()); | ||
| File tempDir = new File(downloadPath.toString()); | ||
| deleteRecursively(tempDir); | ||
| } | ||
|
|
||
| private void deleteRecursively(File f) { | ||
| if (f.isDirectory()) { | ||
| for (File child : f.listFiles()) { | ||
| deleteRecursively(child); | ||
| } | ||
| } | ||
| f.delete(); | ||
| } |
| browser.navigation().loadUrl("addbiomechanics.org/login"); | ||
| setName(Bundle.CTL_AddBiomechanicsTopComponent()); |
| int[] indices = jTrialsList.getSelectedIndices(); | ||
|
|
||
| for (int i : indices) { // Single select | ||
| selectedTrialIndex = i; | ||
| } |
| if (grfPath != null) | ||
| MotionsDB.getInstance().loadMotionFile(grfPath, false); | ||
| trialLoadingStatus = 2; | ||
| } | ||
| }); | ||
| }}); | ||
|
|
| private String getSegmentFileName(String firstSegmentFilename, int segNumber) { | ||
| // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody | ||
| if (segNumber == -1) | ||
| return (firstSegmentFilename.replace("_0", "_all")); | ||
| return (firstSegmentFilename.replace("_0", "_"+String.valueOf(segNumber))); | ||
| } |
| javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); | ||
| this.setLayout(layout); | ||
| layout.setHorizontalGroup( | ||
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
| .addComponent(jScrollPane) | ||
| ); | ||
| layout.setVerticalGroup( | ||
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | ||
| .addComponent(jScrollPane) | ||
| ); |
| OpenIDE-Module-Requires: org.openide.windows.WindowManager | ||
| OpenIDE-Module-Specification-Version: 1.0 | ||
|
|
||
| OpenIDE-Module-Public-Packages: org.opensim.javabrowser.* |
| public void update(Observable o, Object arg) { | ||
| if (arg instanceof ObjectSetCurrentEvent){ | ||
| ObjectSetCurrentEvent ev = (ObjectSetCurrentEvent) arg; | ||
| //System.out.println("jxBrowserTC.update "+arg.toString()); |
There was a problem hiding this comment.
Is this commented line needed for debugging?
| if (cacheEngine==null){ | ||
| // This is the hardcoded trial license, eventually this will go into private repo | ||
| Engine engine = Engine.newInstance(EngineOptions.newBuilder(RenderingMode.OFF_SCREEN) | ||
| .licenseKey("4UNGXAXTRYIHI4S4DZYH52OM3U0NQ188QVOUJDS0M7QMDCF0RKIL1YBWQJT0U6L5GCDZK7J949904OT7JYQUSHQ7ETBOBK9A3RD2ENRJK48F9HH2F8CWAD3MAP1BZKBN4ZVYC0D9R89R75KTYLN") |
There was a problem hiding this comment.
Is it ok to have this license key in this public repo?
There was a problem hiding this comment.
That's the eval license key we had since we upgraded. The real key is embedded in an nbm file
There was a problem hiding this comment.
Sounds good to me then. I though that to be a stale license, but just wanted to make sure. I will test this branch on the GUI next then.
… to troubleshoot a build on ci
No description provided.