Updates: jMonkeyEngine SDK is updated to version {0}
\n
URL_ON_IMG=http://jmonkeyengine.org/
From 6471addf80b5cd231c8b5508dda35b7de29ddf38 Mon Sep 17 00:00:00 2001
From: Toni Helenius
Date: Sat, 21 Jan 2023 15:22:21 +0200
Subject: [PATCH 008/224] Use the newer tangent generator, fixes the shiny
sphere template
---
.../scene/JmePaletteShinySphere.java | 3 +-
.../nodes/actions/impl/Bundle.properties | 2 -
.../actions/impl/GenerateTangentsTool.java | 62 ++----------
.../impl/GenerateTangentsVisualPanel1.form | 66 -------------
.../impl/GenerateTangentsVisualPanel1.java | 97 -------------------
.../impl/GenerateTangentsWizardPanel1.java | 93 ------------------
.../materials/MaterialPreviewRenderer.java | 11 ++-
.../scenecomposer/SceneEditorController.java | 38 ++++----
8 files changed, 34 insertions(+), 338 deletions(-)
delete mode 100644 jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.form
delete mode 100644 jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.java
delete mode 100644 jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsWizardPanel1.java
diff --git a/jme3-codepalette/src/com/jme3/gde/codepalette/scene/JmePaletteShinySphere.java b/jme3-codepalette/src/com/jme3/gde/codepalette/scene/JmePaletteShinySphere.java
index 4ebc5d606..78948e12d 100644
--- a/jme3-codepalette/src/com/jme3/gde/codepalette/scene/JmePaletteShinySphere.java
+++ b/jme3-codepalette/src/com/jme3/gde/codepalette/scene/JmePaletteShinySphere.java
@@ -47,10 +47,11 @@ public JmePaletteShinySphere() {
private String createBody() {
- String body = "/** Illuminated bumpy rock with shiny effect. \n * Uses Texture from jme3-test-data library! Needs light source! */\nSphere sphereMesh = new Sphere(32,32, 2f);\nGeometry shinyGeo = new Geometry(\"Shiny rock\", sphereMesh);\nrock.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres\nTangentBinormalGenerator.generate(rock); // for lighting effect\nMaterial shinyMat = new Material( assetManager, \"Common/MatDefs/Light/Lighting.j3md\");\nshinyMat.setTexture(\"DiffuseMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond.png\"));\nshinyMat.setTexture(\"NormalMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond_normal.png\"));\n//shinyMat.setTexture(\"GlowMap\", assetManager.loadTexture(\"Textures/glowmap.png\")); // requires glow filter!\nshinyMat.setBoolean(\"UseMaterialColors\",true); // needed for shininess\nshinyMat.setColor(\"Specular\", ColorRGBA.White); // needed for shininess\nshinyMat.setColor(\"Diffuse\", ColorRGBA.White); // needed for shininess\nshinyMat.setFloat(\"Shininess\", 5f); // shininess from 1-128\nshinyGeo.setMaterial(shinyMat);\nrootNode.attachChild(shinyGeo);";
+ String body = "/** Illuminated bumpy rock with shiny effect. \n * Uses Texture from jme3-test-data library! Needs light source! */\nSphere sphereMesh = new Sphere(32,32, 2f);\nGeometry shinyGeo = new Geometry(\"Shiny rock\", sphereMesh);\nsphereMesh.setTextureMode(Sphere.TextureMode.Projected); // better quality on spheres\nMikktspaceTangentGenerator.generate(shinyGeo); // for lighting effect\nMaterial shinyMat = new Material( assetManager, \"Common/MatDefs/Light/Lighting.j3md\");\nshinyMat.setTexture(\"DiffuseMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond.jpg\"));\nshinyMat.setTexture(\"NormalMap\", assetManager.loadTexture(\"Textures/Terrain/Pond/Pond_normal.png\"));\n//shinyMat.setTexture(\"GlowMap\", assetManager.loadTexture(\"Textures/glowmap.png\")); // requires glow filter!\nshinyMat.setBoolean(\"UseMaterialColors\",true); // needed for shininess\nshinyMat.setColor(\"Specular\", ColorRGBA.White); // needed for shininess\nshinyMat.setColor(\"Diffuse\", ColorRGBA.White); // needed for shininess\nshinyMat.setFloat(\"Shininess\", 5f); // shininess from 1-128\nshinyGeo.setMaterial(shinyMat);\nrootNode.attachChild(shinyGeo);";
return body;
}
+ @Override
public boolean handleTransfer(JTextComponent targetComponent) {
String body = createBody();
try {
diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties
index 635951963..f535a0313 100644
--- a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties
+++ b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/Bundle.properties
@@ -1,8 +1,6 @@
NewCustomControlVisualPanel1.jTextField1.text=com.mycompany.mygame.MyControl
NewCustomControlVisualPanel1.jLabel1.text=Class Name:
AtlasBatchGeometryVisualPanel1.jTextArea1.text=Note that all the textures of the batched geometry have to fit in the atlas texture, else not all will be added to the atlas. There is no scaling happening!\n\nAlso note that when batching geometry with normal maps you have to make sure the current normal map and color/diffuse map etc. match in size for each geometry. \nE.g. a model with a diffuse map of 256x256 has to use a normal map with 256x256 pixels as well.
-GenerateTangentsVisualPanel1.jTextPane1.text=Warning this will likely modify the mesh by adding vertices.\nUse this if your normal map has mirrored parts.
-GenerateTangentsVisualPanel1.splitMirrored.text=Split vertices with mirrored UVs
GenerateLODVisualPanel1.jPanel1.border.title=Reduction method
GenerateLODVisualPanel1.jPanel2.border.title=Reduction values
GenerateLODVisualPanel1.jLabel1.text=Type a value for each desired level
diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java
index 590309802..b124c0f3b 100644
--- a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java
+++ b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsTool.java
@@ -34,27 +34,18 @@
import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
import com.jme3.gde.core.sceneexplorer.nodes.JmeGeometry;
import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction;
-import com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolWizardAction;
import com.jme3.gde.core.sceneexplorer.nodes.actions.ToolAction;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type;
-import com.jme3.util.TangentBinormalGenerator;
-import java.awt.Component;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.JComponent;
-import org.openide.DialogDisplayer;
-import org.openide.WizardDescriptor;
-import org.openide.nodes.Node;
+import com.jme3.util.mikktspace.MikktspaceTangentGenerator;
/**
*
* @author normenhansen
*/
@org.openide.util.lookup.ServiceProvider(service = ToolAction.class)
-public class GenerateTangentsTool extends AbstractToolWizardAction {
+public class GenerateTangentsTool extends AbstractToolAction {
public GenerateTangentsTool() {
name = "Generate Tangents";
@@ -75,55 +66,18 @@ protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject)
}
}
+ @Override
public Class> getNodeClass() {
return JmeGeometry.class;
}
@Override
- protected Object showWizard(Node node) {
- List> panels = new ArrayList>();
- panels.add(new GenerateTangentsWizardPanel1());
- for (int i = 0; i < panels.size(); i++) {
- Component c = panels.get(i).getComponent();
- if (c instanceof JComponent) { // assume Swing components
- JComponent jc = (JComponent) c;
- jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
- jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
- jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
- jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
- }
- }
- WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator(panels));
- // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
- wiz.setTitleFormat(new MessageFormat("{0}"));
- wiz.setTitle("Generate tangents for this model");
- if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
- // do something
- return wiz;
- }
- return null;
- }
-
- @Override
- protected Object doApplyTool(AbstractSceneExplorerNode rootNode, Object settings) {
- WizardDescriptor wiz = (WizardDescriptor)settings;
+ protected Object doApplyTool(AbstractSceneExplorerNode rootNode) {
Geometry geom = rootNode.getLookup().lookup(Geometry.class);
- boolean splitMirrored = (Boolean)wiz.getProperties().get("splitMirrored");
-
- Mesh mesh = geom.getMesh();
- Mesh keptMesh = null;
- if (mesh != null) {
- if(splitMirrored){
- keptMesh = mesh.deepClone();
- }
- TangentBinormalGenerator.generate(geom, splitMirrored);
-
- }
- if(keptMesh == null){
- return splitMirrored;
- }else{
- return keptMesh;
- }
+
+ MikktspaceTangentGenerator.generate(geom);
+
+ return false;
}
}
diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.form b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.form
deleted file mode 100644
index bc3570176..000000000
--- a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.form
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.java b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.java
deleted file mode 100644
index 606957597..000000000
--- a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsVisualPanel1.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2009-2010 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jme3.gde.core.sceneexplorer.nodes.actions.impl;
-
-import javax.swing.JPanel;
-
-public final class GenerateTangentsVisualPanel1 extends JPanel {
-
- /**
- * Creates new form GenerateTangentsVisualPanel1
- */
- public GenerateTangentsVisualPanel1() {
- initComponents();
- }
-
- @Override
- public String getName() {
- return "Tangent generation options";
- }
-
- public boolean isSplitMirrored(){
- return splitMirrored.isSelected();
- }
-
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- // //GEN-BEGIN:initComponents
- private void initComponents() {
-
- splitMirrored = new javax.swing.JCheckBox();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTextPane1 = new javax.swing.JTextPane();
-
- org.openide.awt.Mnemonics.setLocalizedText(splitMirrored, org.openide.util.NbBundle.getMessage(GenerateTangentsVisualPanel1.class, "GenerateTangentsVisualPanel1.splitMirrored.text")); // NOI18N
-
- jTextPane1.setText(org.openide.util.NbBundle.getMessage(GenerateTangentsVisualPanel1.class, "GenerateTangentsVisualPanel1.jTextPane1.text")); // NOI18N
- jScrollPane1.setViewportView(jTextPane1);
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
- .addComponent(splitMirrored, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(15, 15, 15)
- .addComponent(splitMirrored)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- }// //GEN-END:initComponents
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTextPane jTextPane1;
- private javax.swing.JCheckBox splitMirrored;
- // End of variables declaration//GEN-END:variables
-}
diff --git a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsWizardPanel1.java b/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsWizardPanel1.java
deleted file mode 100644
index fac4fc138..000000000
--- a/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/impl/GenerateTangentsWizardPanel1.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2009-2010 jMonkeyEngine
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package com.jme3.gde.core.sceneexplorer.nodes.actions.impl;
-
-import javax.swing.event.ChangeListener;
-import org.openide.WizardDescriptor;
-import org.openide.util.HelpCtx;
-
-public class GenerateTangentsWizardPanel1 implements WizardDescriptor.Panel {
-
- /**
- * The visual component that displays this panel. If you need to access the
- * component from this class, just use getComponent().
- */
- private GenerateTangentsVisualPanel1 component;
-
- // Get the visual component for the panel. In this template, the component
- // is kept separate. This can be more efficient: if the wizard is created
- // but never displayed, or not all panels are displayed, it is better to
- // create only those which really need to be visible.
- @Override
- public GenerateTangentsVisualPanel1 getComponent() {
- if (component == null) {
- component = new GenerateTangentsVisualPanel1();
- }
- return component;
- }
-
- @Override
- public HelpCtx getHelp() {
- // Show no Help button for this panel:
- return HelpCtx.DEFAULT_HELP;
- // If you have context help:
- // return new HelpCtx("help.key.here");
- }
-
- @Override
- public boolean isValid() {
- // If it is always OK to press Next or Finish, then:
- return true;
- // If it depends on some condition (form filled out...) and
- // this condition changes (last form field filled in...) then
- // use ChangeSupport to implement add/removeChangeListener below.
- // WizardDescriptor.ERROR/WARNING/INFORMATION_MESSAGE will also be useful.
- }
-
- @Override
- public void addChangeListener(ChangeListener l) {
- }
-
- @Override
- public void removeChangeListener(ChangeListener l) {
- }
-
- @Override
- public void readSettings(WizardDescriptor wiz) {
- // use wiz.getProperty to retrieve previous panel state
- }
-
- @Override
- public void storeSettings(WizardDescriptor wiz) {
- wiz.putProperty("splitMirrored", component.isSplitMirrored());
- }
-}
diff --git a/jme3-materialeditor/src/com/jme3/gde/materials/MaterialPreviewRenderer.java b/jme3-materialeditor/src/com/jme3/gde/materials/MaterialPreviewRenderer.java
index 321e4fd39..45a4625e0 100644
--- a/jme3-materialeditor/src/com/jme3/gde/materials/MaterialPreviewRenderer.java
+++ b/jme3-materialeditor/src/com/jme3/gde/materials/MaterialPreviewRenderer.java
@@ -22,7 +22,7 @@
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Quad;
import com.jme3.scene.shape.Sphere;
-import com.jme3.util.TangentBinormalGenerator;
+import com.jme3.util.mikktspace.MikktspaceTangentGenerator;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.logging.Level;
@@ -63,21 +63,22 @@ private void init() {
Sphere sphMesh = new Sphere(32, 32, 2.5f);
sphMesh.setTextureMode(Sphere.TextureMode.Projected);
sphMesh.updateGeometry(32, 32, 2.5f, false, false);
- Logger log = Logger.getLogger(TangentBinormalGenerator.class.getName());
+ Logger log = Logger.getLogger(MikktspaceTangentGenerator.class.getName());
log.setLevel(Level.SEVERE);
- TangentBinormalGenerator.generate(sphMesh);
sphere = new Geometry("previewSphere", sphMesh);
sphere.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_X));
+ MikktspaceTangentGenerator.generate(sphere);
Box boxMesh = new Box(1.75f, 1.75f, 1.75f);
- TangentBinormalGenerator.generate(boxMesh);
box = new Geometry("previewBox", boxMesh);
box.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.DEG_TO_RAD * 30, Vector3f.UNIT_X).multLocal(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y)));
+ MikktspaceTangentGenerator.generate(box);
Quad quadMesh = new Quad(4.5f, 4.5f);
- TangentBinormalGenerator.generate(quadMesh);
quad = new Geometry("previewQuad", quadMesh);
quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));
+ MikktspaceTangentGenerator.generate(quad);
+
currentGeom = sphere;
init = true;
}
diff --git a/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java b/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java
index 705f1e977..cde4ec16f 100644
--- a/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java
+++ b/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java
@@ -23,14 +23,13 @@
import com.jme3.renderer.Camera;
import com.jme3.scene.AssetLinkNode;
import com.jme3.scene.Geometry;
-import com.jme3.scene.Mesh;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.control.Control;
import com.jme3.util.TangentBinormalGenerator;
+import com.jme3.util.mikktspace.MikktspaceTangentGenerator;
import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -335,29 +334,28 @@ public Object call() throws Exception {
public void doCreateTangents(Spatial selected) {
if (selected instanceof Geometry) {
Geometry geom = (Geometry) selected;
- Mesh mesh = geom.getMesh();
- if (mesh != null) {
- TangentBinormalGenerator.generate(mesh);
- createTrangentsUndo(mesh);
- }
+ MikktspaceTangentGenerator.generate(geom);
+ createTangentsUndo(geom);
}
}
- private void createTrangentsUndo(final Mesh mesh) {
- if (mesh != null) {
- Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
+ private void createTangentsUndo(final Geometry geometry) {
+ if (geometry == null) {
+ return;
+ }
- @Override
- public void sceneUndo() throws CannotUndoException {
- mesh.clearBuffer(Type.Tangent);
- }
+ Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
- @Override
- public void sceneRedo() throws CannotRedoException {
- TangentBinormalGenerator.generate(mesh);
- }
- });
- }
+ @Override
+ public void sceneUndo() throws CannotUndoException {
+ geometry.getMesh().clearBuffer(Type.Tangent);
+ }
+
+ @Override
+ public void sceneRedo() throws CannotRedoException {
+ TangentBinormalGenerator.generate(geometry);
+ }
+ });
}
public void createPhysicsMeshForSelectedSpatial() {
From 55644d3d400e19a79cce036437f54f44c6d82887 Mon Sep 17 00:00:00 2001
From: Toni Helenius
Date: Sat, 21 Jan 2023 20:37:42 +0200
Subject: [PATCH 009/224] Use interfaces to standardize the library...
interface
---
.../files/freemarker/build.gradle.ftl | 16 +--
.../GradleDesktopGameGuiPanelVisual.java | 2 +-
.../options/AdditionalLibrary.java | 99 ++++++++++++-------
.../gradledesktop/options/GUILibrary.java | 76 ++++++++------
.../gradledesktop/options/MavenArtifact.java | 60 +++++++++++
.../options/NetworkingLibrary.java | 79 +++++++++------
.../gradledesktop/options/PhysicsLibrary.java | 76 ++++++++------
.../options/TemplateLibrary.java | 46 +++++++++
8 files changed, 313 insertions(+), 141 deletions(-)
create mode 100644 jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java
create mode 100644 jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java
diff --git a/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl b/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl
index 15b0f9cf0..96c22b2c7 100644
--- a/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl
+++ b/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl
@@ -47,36 +47,36 @@ dependencies {
// GUI Library
<#if guiLibrary.isCoreJmeLibrary == true>
- implementation "${guiLibrary.artifact}:$jmeVer"
+ implementation "${guiLibrary.groupId}:${guiLibrary.artifactId}:$jmeVer"
<#else>
- implementation "${guiLibrary.artifact}"
+ implementation "${guiLibrary.groupId}:${guiLibrary.artifactId}:${guiLibrary.version}"
#if>
#if>
<#if physicsLibrary.label != "">
// Physics Library
<#if physicsLibrary.isCoreJmeLibrary == true>
- implementation "${physicsLibrary.artifact}:$jmeVer"
+ implementation "${physicsLibrary.groupId}:${physicsLibrary.artifactId}:$jmeVer"
<#else>
- implementation "${physicsLibrary.artifact}"
+ implementation "${physicsLibrary.groupId}:${physicsLibrary.artifactId}:${physicsLibrary.version}"
#if>
#if>
<#if networkingLibrary.label != "">
// Networking Library
<#if networkingLibrary.isCoreJmeLibrary == true>
- implementation "${networkingLibrary.artifact}:$jmeVer"
+ implementation "${networkingLibrary.groupId}:${networkingLibrary.artifactId}:$jmeVer"
<#else>
- implementation "${networkingLibrary.artifact}"
+ implementation "${networkingLibrary.groupId}:${networkingLibrary.artifactId}:${networkingLibrary.version}"
#if>
#if>
// Additional Libraries
<#list additionalLibraries as additionalLibrary>
<#if additionalLibrary.isCoreJmeLibrary == true>
- implementation "${additionalLibrary.artifact}:$jmeVer"
+ implementation "${additionalLibrary.groupId}:${additionalLibrary.artifactId}:$jmeVer"
<#else>
- implementation "${additionalLibrary.artifact}"
+ implementation "${additionalLibrary.groupId}:${additionalLibrary.artifactId}:${additionalLibrary.version}"
#if>
#list>
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java
index 91429de00..81c3bae8a 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java
@@ -50,7 +50,7 @@
import org.openide.util.NbBundle;
/**
- * UI Compoment for the New Gradle Game Wizard GUI panel.
+ * UI Component for the New Gradle Game Wizard GUI panel.
*
* @author peedeeboy
*/
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
index 3e0c894b0..a87759657 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
@@ -65,45 +65,53 @@
*
* @author peedeeboy
*/
-public enum AdditionalLibrary {
+public enum AdditionalLibrary implements TemplateLibrary {
JME3_EFFECTS("jMonkeyEngine Effects (jme3-effects)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-effects.description"),
- "org.jmonkeyengine:jme3-effects", true),
+ "org.jmonkeyengine", "jme3-effects",
+ null, true),
JME3_TERRAIN("jMonkeyEngine TerraMonkey (jme3-terrain)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-terrain.description"),
- "org.jmonkeyengine:jme3-terrain", true),
+ "org.jmonkeyengine", "jme3-terrain",
+ null, true),
JME3_TESTDATA("jMonkeyEngine Test Data (jme3-testdata)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-testdata.description"),
- "org.jmonkeyengine:jme3-testdata", true),
+ "org.jmonkeyengine", "jme3-testdata",
+ null, true),
JME3_VR("jMonkeyEngine Virtual Reality (jme3-vr)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-vr.description"),
- "org.jmonkeyengine:jme3-vr", true),
+ "org.jmonkeyengine", "jme3-vr",
+ null, true),
HEART("Heart Library", NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.heart.description"),
- "com.github.stephengold:Heart:8.1.0", false),
+ "com.github.stephengold", "Heart",
+ "8.1.0", false),
PARTICLE_MONKEY("Particle Monkey",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.particlemonkey.description"),
- "com.github.Jeddic:particlemonkey:1.0.2", false),
+ "com.github.Jeddic", "particlemonkey",
+ "1.0.2", false),
SHADERBLOW_EX("ShaderBlowEx", NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.shaderblowex.description"),
- "com.github.polincdev:ShaderBlowEx:master-SNAPSHOT", false),
+ "com.github.polincdev", "ShaderBlowEx",
+ "master-SNAPSHOT", false),
SIO2("SiO2", NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.sio2.description"),
- "com.simsilica:sio2:1.7.0", false),
+ "com.simsilica", "sio2",
+ "1.7.0", false),
ZAY_ES("Zay-ES Entity Component System",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.zayes.description"),
- "com.simsilica:zay-es:1.4.0", false),
+ "com.simsilica", "zay-es", "1.4.0", false),
ZAY_ES_NET("Zay-ES-Net Networking Extension",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.zayesnet.description"),
- "com.simsilica:zay-es-net:1.5.0", false),;
+ "com.simsilica", "zay-es-net", "1.5.0", false);
/**
* The name of the library. This will be displayed in the jComboBox in the
@@ -116,13 +124,17 @@ public enum AdditionalLibrary {
*/
private final String description;
/**
- * Gradle artifact string. If this is not a core JME
- * library, then the artifact string should include the version number. If
- * the library is a core JME library, then the version
- * should be omitted, as they jMonkeyEngine version will be appended
- * automatically by the template.
+ * Maven artifact ID
*/
- private final String artifact;
+ private final String artifactId;
+ /**
+ * Maven group ID
+ */
+ private final String groupId;
+ /**
+ * Default artifact version to be used
+ */
+ private final String defaultVersion;
/**
* Is this library a core jMonkeyEngine library? True if the library is a
* part of jMonkeyengine, false if it is 3rd party.
@@ -134,14 +146,19 @@ public enum AdditionalLibrary {
*
* @param label The name of the library.
* @param description Long description of the library.
- * @param artifact Gradle artifact string.
+ * @param groupId Maven group ID.
+ * @param artifactId Maven artifact ID.
+ * @param defaultVersion Default version is used if no version info is found
+ * from Maven
* @param isCoreJmeLibrary Is this library a core jMonkeyEngine library?
*/
- AdditionalLibrary(String label, String description, String artifact,
- boolean isCoreJmeLibrary) {
+ AdditionalLibrary(String label, String description, String groupId,
+ String artifactId, String defaultVersion, boolean isCoreJmeLibrary) {
this.label = label;
this.description = description;
- this.artifact = artifact;
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.defaultVersion = defaultVersion;
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
@@ -164,31 +181,37 @@ public String getDescription() {
}
/**
- * Get the Gradle artifact string.
+ * Override the toString() method to return the label, so that
+ * this enum will display nicely in a jComboBox.
*
- * @return the Gradle artifact string.
+ * @return label as a String
*/
- public String getArtifact() {
- return artifact;
+ @Override
+ public String toString() {
+ return label;
}
- /**
- * Is this a Core jMonkeyEngine library?
- *
- * @return true if this is a core jMonkeyEngine library.
- */
+ public String getDefaultVersion() {
+ return defaultVersion;
+ }
+
+ @Override
+ public String getGroupId() {
+ return groupId;
+ }
+
+ @Override
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ @Override
public boolean getIsCoreJmeLibrary() {
return isCoreJmeLibrary;
}
- /**
- * Override the toString() method to return the label, so that
- * this enum will display nicely in a jComboBox.
- *
- * @return label as a String
- */
@Override
- public String toString() {
- return label;
+ public String getVersion() {
+ return defaultVersion;
}
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
index 31e59d1a1..18369ba43 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
@@ -64,16 +64,19 @@
*
* @author peedeeboy
*/
-public enum GUILibrary {
+public enum GUILibrary implements TemplateLibrary {
NONE("", NbBundle.getMessage(GUILibrary.class,
- "guilibrary.none.description"), "", false),
+ "guilibrary.none.description"), null, null,
+ null, false),
NIFTY("Nifty", NbBundle.getMessage(GUILibrary.class,
"guilibrary.nifty.description"),
- "org.jmonkeyengine:jme3-niftygui", true),
+ "org.jmonkeyengine", "jme3-niftygui",
+ null, true),
LEMUR("Lemur", NbBundle.getMessage(GUILibrary.class,
"guilibrary.lemur.description"),
- "com.simsilica:lemur:1.16.0", false);
+ "com.simsilica", "lemur",
+ "1.16.0", false);
/**
* The name of the library. This will be displayed in the jComboBox in the
@@ -86,13 +89,17 @@ public enum GUILibrary {
*/
private final String description;
/**
- * Gradle artifact string. If this is not a core JME
- * library, then the artifact string should include the version number. If
- * the library is a core JME library, then the version
- * should be omitted, as they jMonkeyEngine version will be appended
- * automatically by the template.
+ * Maven artifact ID
*/
- private final String artifact;
+ private final String artifactId;
+ /**
+ * Maven group ID
+ */
+ private final String groupId;
+ /**
+ * Default artifact version to be used
+ */
+ private final String defaultVersion;
/**
* Is this library a core jMonkeyEngine library? True if the library is a
* part of jMonkeyengine, false if it is 3rd party.
@@ -104,14 +111,19 @@ public enum GUILibrary {
*
* @param label The name of the library.
* @param description Long description of the library.
- * @param artifact Gradle artifact string.
+ * @param groupId Maven group ID.
+ * @param artifactId Maven artifact ID.
+ * @param defaultVersion Default version is used if no version info is found
+ * from Maven
* @param isCoreJmeLibrary Is this library a core jMonkeyEngine library?
*/
- GUILibrary(String label, String description, String artifact,
- boolean isCoreJmeLibrary) {
+ GUILibrary(String label, String description, String groupId,
+ String artifactId, String defaultVersion, boolean isCoreJmeLibrary) {
this.label = label;
this.description = description;
- this.artifact = artifact;
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.defaultVersion = defaultVersion;
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
@@ -134,31 +146,33 @@ public String getDescription() {
}
/**
- * Get the Gradle artifact string.
+ * Override the toString() method to return the label, so that
+ * this enum will display nicely in a jComboBox.
*
- * @return the Gradle artifact string.
+ * @return label as a String
*/
- public String getArtifact() {
- return artifact;
+ @Override
+ public String toString() {
+ return label;
}
- /**
- * Is this a Core jMonkeyEngine library?
- *
- * @return true if this is a core jMonkeyEngine library.
- */
+ @Override
+ public String getGroupId() {
+ return groupId;
+ }
+
+ @Override
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ @Override
public boolean getIsCoreJmeLibrary() {
return isCoreJmeLibrary;
}
- /**
- * Override the toString() method to return the label, so that
- * this enum will display nicely in a jComboBox.
- *
- * @return label as a String
- */
@Override
- public String toString() {
- return label;
+ public String getVersion() {
+ return defaultVersion;
}
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java
new file mode 100644
index 000000000..f27da7a35
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.gradledesktop.options;
+
+/**
+ * Represents Maven artifact
+ */
+public interface MavenArtifact {
+
+ /**
+ * Get the Maven group ID
+ *
+ * @return group ID
+ */
+ String getGroupId();
+
+ /**
+ * Get the Maven artifact ID
+ *
+ * @return artifact ID
+ */
+ String getArtifactId();
+
+ /**
+ * Get the artifact version string
+ *
+ * @return version string
+ */
+ String getVersion();
+
+}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
index cdef6825e..dc307716e 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
@@ -63,19 +63,23 @@
*
* @author peedeeboy
*/
-public enum NetworkingLibrary {
+public enum NetworkingLibrary implements TemplateLibrary {
NONE("", NbBundle.getMessage(NetworkingLibrary.class,
- "networkinglibrary.none.description"), "", false),
+ "networkinglibrary.none.description"), null, null,
+ null, false),
SPIDERMONKEY("SpiderMonkey", NbBundle.getMessage(NetworkingLibrary.class,
"networkinglibrary.spidermonkey.description"),
- "org.jmonkeyengine:jme3-networking", true),
+ "org.jmonkeyengine", "jme3-networking",
+ null, true),
MONKEYNETTY("MonkeyNetty", NbBundle.getMessage(NetworkingLibrary.class,
"networkinglibrary.monkeynetty.description"),
- "io.tlf.monkeynetty:monkey-netty:0.1.1", false),
+ "io.tlf.monkeynetty", "monkey-netty",
+ "0.1.1", false),
SIMETHEREAL("SimEthereal", NbBundle.getMessage(NetworkingLibrary.class,
"networkinglibrary.simethereal.description"),
- "com.simsilica:sim-ethereal:1.7.0", false);
+ "com.simsilica", "sim-ethereal",
+ "1.7.0", false);
/**
* The name of the library. This will be displayed in the jComboBox in the
@@ -88,13 +92,17 @@ public enum NetworkingLibrary {
*/
private final String description;
/**
- * Gradle artifact string. If this is not a core JME
- * library, then the artifact string should include the version number. If
- * the library is a core JME library, then the version
- * should be omitted, as they jMonkeyEngine version will be appended
- * automatically by the template.
+ * Maven artifact ID
*/
- private final String artifact;
+ private final String artifactId;
+ /**
+ * Maven group ID
+ */
+ private final String groupId;
+ /**
+ * Default artifact version to be used
+ */
+ private final String defaultVersion;
/**
* Is this library a core jMonkeyEngine library? True if the library is a
* part of jMonkeyengine, false if it is 3rd party.
@@ -106,14 +114,19 @@ public enum NetworkingLibrary {
*
* @param label The name of the library.
* @param description Long description of the library.
- * @param artifact Gradle artifact string.
+ * @param groupId Maven group ID.
+ * @param artifactId Maven artifact ID.
+ * @param defaultVersion Default version is used if no version info is found
+ * from Maven
* @param isCoreJmeLibrary Is this library a core jMonkeyEngine library?
*/
- NetworkingLibrary(String label, String description, String artifact,
- boolean isCoreJmeLibrary) {
+ NetworkingLibrary(String label, String description, String groupId,
+ String artifactId, String defaultVersion, boolean isCoreJmeLibrary) {
this.label = label;
this.description = description;
- this.artifact = artifact;
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.defaultVersion = defaultVersion;
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
@@ -136,31 +149,33 @@ public String getDescription() {
}
/**
- * Get the Gradle artifact string.
+ * Override the toString() method to return the label, so that
+ * this enum will display nicely in a jComboBox.
*
- * @return the Gradle artifact string.
+ * @return label as a String
*/
- public String getArtifact() {
- return artifact;
+ @Override
+ public String toString() {
+ return this.label;
}
- /**
- * Is this a Core jMonkeyEngine library?
- *
- * @return true if this is a core jMonkeyEngine library
- */
+ @Override
+ public String getGroupId() {
+ return groupId;
+ }
+
+ @Override
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ @Override
public boolean getIsCoreJmeLibrary() {
return isCoreJmeLibrary;
}
- /**
- * Override the toString() method to return the label, so that
- * this enum will display nicely in a jComboBox.
- *
- * @return label as a String
- */
@Override
- public String toString() {
- return this.label;
+ public String getVersion() {
+ return defaultVersion;
}
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
index eb8970b7c..3b4bb6ec7 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
@@ -63,16 +63,19 @@
*
* @author peedeeboy
*/
-public enum PhysicsLibrary {
+public enum PhysicsLibrary implements TemplateLibrary {
NONE("", NbBundle.getMessage(GUILibrary.class,
- "physicslibrary.none.description"), "", false),
+ "physicslibrary.none.description"), null, null,
+ null, false),
JBULLET("jBullet", NbBundle.getMessage(GUILibrary.class,
"physicslibrary.jbullet.description"),
- "org.jmonkeyengine:jme3-jbullet", true),
+ "org.jmonkeyengine", "jme3-jbullet",
+ null, true),
MINIE("Minie", NbBundle.getMessage(PhysicsLibrary.class,
"physicslibrary.minie.description"),
- "com.github.stephengold:Minie:5.0.0", false);
+ "com.github.stephengold", "Minie",
+ "5.0.0", false);
/**
* The name of the library. This will be displayed in the jComboBox in the
@@ -85,13 +88,17 @@ public enum PhysicsLibrary {
*/
private final String description;
/**
- * Gradle artifact string. If this is not a core JME
- * library, then the artifact string should include the version number. If
- * the library is a core JME library, then the version
- * should be omitted, as they jMonkeyEngine version will be appended
- * automatically by the template.
+ * Maven artifact ID
*/
- private final String artifact;
+ private final String artifactId;
+ /**
+ * Maven group ID
+ */
+ private final String groupId;
+ /**
+ * Default artifact version to be used
+ */
+ private final String defaultVersion;
/**
* Is this library a core jMonkeyEngine library? True if the library is a
* part of jMonkeyengine, false if it is 3rd party.
@@ -103,14 +110,19 @@ public enum PhysicsLibrary {
*
* @param label The name of the library.
* @param description Long description of the library.
- * @param artifact Gradle artifact string.
+ * @param groupId Maven group ID.
+ * @param artifactId Maven artifact ID.
+ * @param defaultVersion Default version is used if no version info is found
+ * from Maven
* @param isCoreJmeLibrary Is this library a core jMonkeyEngine library?
*/
- PhysicsLibrary(String label, String description, String artifact,
- boolean isCoreJmeLibrary) {
+ PhysicsLibrary(String label, String description, String groupId,
+ String artifactId, String defaultVersion, boolean isCoreJmeLibrary) {
this.label = label;
this.description = description;
- this.artifact = artifact;
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.defaultVersion = defaultVersion;
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
@@ -133,31 +145,33 @@ public String getDescription() {
}
/**
- * Get the Gradle artifact string.
+ * Override the toString() method to return the label, so that
+ * this enum will display nicely in a jComboBox.
*
- * @return the Gradle artifact string.
+ * @return label as a String
*/
- public String getArtifact() {
- return artifact;
+ @Override
+ public String toString() {
+ return this.label;
}
- /**
- * Is this a Core jMonkeyEngine library?
- *
- * @return true if this is a core jMonkeyEngine library
- */
+ @Override
+ public String getGroupId() {
+ return groupId;
+ }
+
+ @Override
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ @Override
public boolean getIsCoreJmeLibrary() {
return isCoreJmeLibrary;
}
- /**
- * Override the toString() method to return the label, so that
- * this enum will display nicely in a jComboBox.
- *
- * @return label as a String
- */
@Override
- public String toString() {
- return this.label;
+ public String getVersion() {
+ return defaultVersion;
}
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java
new file mode 100644
index 000000000..b0158428f
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.gradledesktop.options;
+
+/**
+ * Our Gradle template library
+ */
+public interface TemplateLibrary extends MavenArtifact {
+
+ /**
+ * Is this a Core jMonkeyEngine library?
+ *
+ * @return true if this is a core jMonkeyEngine library
+ */
+ boolean getIsCoreJmeLibrary();
+
+}
From 7c8efbdc899f38e40b90e246b222d8a5b0f20e88 Mon Sep 17 00:00:00 2001
From: Toni Helenius
Date: Sat, 21 Jan 2023 20:43:05 +0200
Subject: [PATCH 010/224] Added all the common methods to the interface
---
.../gradledesktop/options/AdditionalLibrary.java | 12 ++----------
.../gradledesktop/options/GUILibrary.java | 12 ++----------
.../gradledesktop/options/NetworkingLibrary.java | 12 ++----------
.../gradledesktop/options/PhysicsLibrary.java | 12 ++----------
.../gradledesktop/options/TemplateLibrary.java | 14 ++++++++++++++
5 files changed, 22 insertions(+), 40 deletions(-)
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
index a87759657..ab0c958e7 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
@@ -162,20 +162,12 @@ public enum AdditionalLibrary implements TemplateLibrary {
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
- /**
- * Get the label for this Additional Library.
- *
- * @return the label for this Additional Library.
- */
+ @Override
public String getLabel() {
return label;
}
- /**
- * Get the long description for this Additional Library.
- *
- * @return the long description for this Additional Library.
- */
+ @Override
public String getDescription() {
return description;
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
index 18369ba43..b13958d25 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
@@ -127,20 +127,12 @@ public enum GUILibrary implements TemplateLibrary {
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
- /**
- * Get the label for this GUI Library.
- *
- * @return the label for this GUI Library.
- */
+ @Override
public String getLabel() {
return label;
}
- /**
- * Get the long description for this GUI Library.
- *
- * @return the long description for this GUI Library.
- */
+ @Override
public String getDescription() {
return description;
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
index dc307716e..08f68153c 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
@@ -130,20 +130,12 @@ public enum NetworkingLibrary implements TemplateLibrary {
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
- /**
- * Get the label for this Networking Library.
- *
- * @return the label for this Networking Library.
- */
+ @Override
public String getLabel() {
return label;
}
- /**
- * Get the long description for this Networking Library.
- *
- * @return the long description for this Networking Library.
- */
+ @Override
public String getDescription() {
return description;
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
index 3b4bb6ec7..03f309bd1 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
@@ -126,20 +126,12 @@ public enum PhysicsLibrary implements TemplateLibrary {
this.isCoreJmeLibrary = isCoreJmeLibrary;
}
- /**
- * Get the label for this Physics Library.
- *
- * @return the label for this Physics Library.
- */
+ @Override
public String getLabel() {
return label;
}
- /**
- * Get the long description for this Physics Library.
- *
- * @return the long description for this Physics Library.
- */
+ @Override
public String getDescription() {
return description;
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java
index b0158428f..05e4cb023 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/TemplateLibrary.java
@@ -36,6 +36,20 @@
*/
public interface TemplateLibrary extends MavenArtifact {
+ /**
+ * Get the label for this library.
+ *
+ * @return the label for this library.
+ */
+ public String getLabel();
+
+ /**
+ * Get the long description for this library.
+ *
+ * @return the long description for this library.
+ */
+ public String getDescription();
+
/**
* Is this a Core jMonkeyEngine library?
*
From 773a7f19ad2e3148c498aed3d1f5894a59b76140 Mon Sep 17 00:00:00 2001
From: Toni Helenius
Date: Sun, 22 Jan 2023 13:31:48 +0200
Subject: [PATCH 011/224] LWJGL as TemplateLibrary too, added generics and
some cleanups
---
.../files/freemarker/build.gradle.ftl | 6 +-
...topGameAdditionalLibrariesPanelVisual.java | 18 ++---
.../GradleDesktopGameGuiPanelVisual.form | 12 ++--
.../GradleDesktopGameGuiPanelVisual.java | 30 ++++----
...radleDesktopGameJMEVersionPanelVisual.form | 4 +-
...radleDesktopGameJMEVersionPanelVisual.java | 16 ++---
.../GradleDesktopGameWizardIterator.java | 17 +++--
.../GradleDesktopGameWizardPanel.java | 13 +++-
.../options/AdditionalLibrary.java | 10 +--
.../gradledesktop/options/GUILibrary.java | 4 +-
.../{LWJGLVersion.java => LWJGLLibrary.java} | 71 ++++++++++---------
.../gradledesktop/options/MavenArtifact.java | 2 +
.../options/NetworkingLibrary.java | 4 +-
.../gradledesktop/options/PhysicsLibrary.java | 4 +-
14 files changed, 114 insertions(+), 97 deletions(-)
rename jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/{LWJGLVersion.java => LWJGLLibrary.java} (73%)
diff --git a/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl b/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl
index 96c22b2c7..cd7cbf2fc 100644
--- a/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl
+++ b/jme3-templates/src/com/jme3/gde/templates/files/freemarker/build.gradle.ftl
@@ -38,7 +38,11 @@ dependencies {
// Core JME
implementation "org.jmonkeyengine:jme3-core:$jmeVer"
implementation "org.jmonkeyengine:jme3-desktop:$jmeVer"
- implementation "${lwjglArtifact}:$jmeVer"
+ <#if lwjglLibrary.isCoreJmeLibrary == true>
+ implementation "${lwjglLibrary.groupId}:${lwjglLibrary.artifactId}:$jmeVer"
+ <#else>
+ implementation "${lwjglLibrary.groupId}:${lwjglLibrary.artifactId}:${lwjglLibrary.version}"
+ #if>
// Suppress errors / warnings building in SDK
implementation "org.jmonkeyengine:jme3-jogg:$jmeVer"
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameAdditionalLibrariesPanelVisual.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameAdditionalLibrariesPanelVisual.java
index 9cb472337..5118a68e0 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameAdditionalLibrariesPanelVisual.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameAdditionalLibrariesPanelVisual.java
@@ -33,6 +33,7 @@
package com.jme3.gde.templates.gradledesktop;
import com.jme3.gde.templates.gradledesktop.options.AdditionalLibrary;
+import com.jme3.gde.templates.gradledesktop.options.TemplateLibrary;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
@@ -84,7 +85,7 @@ private void populateLibraryTable() {
Object[][] tableData = new Object[noRows][2];
int row = 0;
- for (AdditionalLibrary library : AdditionalLibrary.values()) {
+ for (TemplateLibrary library : AdditionalLibrary.values()) {
tableData[row][0] = Boolean.FALSE;
tableData[row][1] = library;
row++;
@@ -107,8 +108,7 @@ private void updateLibraryDescription() {
if (selectedRow == -1) {
libraryDescriptionTextArea.setText("");
} else {
- AdditionalLibrary selectedLibrary = (AdditionalLibrary)
- additionalLibraryTable.getValueAt(selectedRow, 1);
+ TemplateLibrary selectedLibrary = (TemplateLibrary) additionalLibraryTable.getValueAt(selectedRow, 1);
libraryDescriptionTextArea.setText(selectedLibrary
.getDescription());
}
@@ -117,8 +117,8 @@ private void updateLibraryDescription() {
protected void store(WizardDescriptor d) {
AdditionalLibraryTableModel model = (AdditionalLibraryTableModel)
additionalLibraryTable.getModel();
- List selectedLibraries =
- model.getSelectedLibraries();
+ List selectedLibraries
+ = model.getSelectedLibraries();
d.putProperty("additionalLibraries", selectedLibraries);
}
@@ -202,7 +202,7 @@ public Class> getColumnClass(int columnIndex) {
case 0:
return Boolean.class;
case 1:
- return String.class;
+ return TemplateLibrary.class;
default:
return super.getColumnClass(columnIndex);
}
@@ -213,11 +213,11 @@ public boolean isCellEditable(int row, int column) {
return column == 0;
}
- public List getSelectedLibraries() {
- List selectedLibraries = new ArrayList<>();
+ public List getSelectedLibraries() {
+ List selectedLibraries = new ArrayList<>();
for (int i = 0; i < getRowCount(); i++) {
if ((Boolean) getValueAt(i, 0)) {
- selectedLibraries.add((AdditionalLibrary) getValueAt(i, 1));
+ selectedLibraries.add((TemplateLibrary) getValueAt(i, 1));
}
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.form b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.form
index d4167f889..02c7dabfb 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.form
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.form
@@ -95,14 +95,14 @@
-
+
-
+
@@ -138,14 +138,14 @@
-
+
-
+
@@ -181,14 +181,14 @@
-
+
-
+
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java
index 81c3bae8a..9f3cdc3d4 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameGuiPanelVisual.java
@@ -34,6 +34,7 @@
import com.jme3.gde.templates.gradledesktop.options.GUILibrary;
import com.jme3.gde.templates.gradledesktop.options.NetworkingLibrary;
import com.jme3.gde.templates.gradledesktop.options.PhysicsLibrary;
+import com.jme3.gde.templates.gradledesktop.options.TemplateLibrary;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.DefaultComboBoxModel;
@@ -56,39 +57,36 @@
*/
public class GradleDesktopGameGuiPanelVisual extends JPanel {
- private final GradleDesktopGameGuiPanel panel;
-
/**
* Creates new form GradleDesktopGameGuiPanelVisual
*/
public GradleDesktopGameGuiPanelVisual(GradleDesktopGameGuiPanel panel) {
initComponents();
+
updateGuiLibraryDescription();
updatePhysicsLibraryDescription();
updateNetworkingLibraryDescription();
-
- this.panel = panel;
}
private void updateGuiLibraryDescription() {
- GUILibrary selectedGuiLibrary = (GUILibrary) guiComboBox.getSelectedItem();
+ TemplateLibrary selectedGuiLibrary = guiComboBox.getItemAt(guiComboBox.getSelectedIndex());
guiDescriptionTextArea.setText(selectedGuiLibrary.getDescription());
}
private void updatePhysicsLibraryDescription() {
- PhysicsLibrary selectedPhysicsLibrary = (PhysicsLibrary) physicsEngineComboBox.getSelectedItem();
+ TemplateLibrary selectedPhysicsLibrary = physicsEngineComboBox.getItemAt(physicsEngineComboBox.getSelectedIndex());
physicsEngineDescriptionTextArea.setText(selectedPhysicsLibrary.getDescription());
}
private void updateNetworkingLibraryDescription() {
- NetworkingLibrary selectedNetworkingLibrary = (NetworkingLibrary) networkingComboBox.getSelectedItem();
+ TemplateLibrary selectedNetworkingLibrary = networkingComboBox.getItemAt(networkingComboBox.getSelectedIndex());
networkingDescriptionTextArea.setText(selectedNetworkingLibrary.getDescription());
}
protected void store(WizardDescriptor d) {
- GUILibrary selectedGuiLibrary = (GUILibrary) guiComboBox.getSelectedItem();
- PhysicsLibrary selectedPhysicsLibrary = (PhysicsLibrary) physicsEngineComboBox.getSelectedItem();
- NetworkingLibrary selectedNetworkingLibrary = (NetworkingLibrary) networkingComboBox.getSelectedItem();
+ TemplateLibrary selectedGuiLibrary = guiComboBox.getItemAt(guiComboBox.getSelectedIndex());
+ TemplateLibrary selectedPhysicsLibrary = physicsEngineComboBox.getItemAt(physicsEngineComboBox.getSelectedIndex());
+ TemplateLibrary selectedNetworkingLibrary = networkingComboBox.getItemAt(networkingComboBox.getSelectedIndex());
d.putProperty("guiLibrary", selectedGuiLibrary);
d.putProperty("physicsLibrary", selectedPhysicsLibrary);
@@ -122,7 +120,7 @@ private void initComponents() {
guiLabel.setLabelFor(guiComboBox);
Mnemonics.setLocalizedText(guiLabel, NbBundle.getMessage(GradleDesktopGameGuiPanelVisual.class, "GradleDesktopGameGuiPanelVisual.guiLabel.text")); // NOI18N
- guiComboBox.setModel(new DefaultComboBoxModel(GUILibrary.values()));
+ guiComboBox.setModel(new DefaultComboBoxModel(GUILibrary.values()));
guiComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
guiComboBoxActionPerformed(evt);
@@ -139,7 +137,7 @@ public void actionPerformed(ActionEvent evt) {
physicsEngineLabel.setLabelFor(physicsEngineComboBox);
Mnemonics.setLocalizedText(physicsEngineLabel, NbBundle.getMessage(GradleDesktopGameGuiPanelVisual.class, "GradleDesktopGameGuiPanelVisual.physicsEngineLabel.text")); // NOI18N
- physicsEngineComboBox.setModel(new DefaultComboBoxModel(PhysicsLibrary.values()));
+ physicsEngineComboBox.setModel(new DefaultComboBoxModel(PhysicsLibrary.values()));
physicsEngineComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
physicsEngineComboBoxActionPerformed(evt);
@@ -156,7 +154,7 @@ public void actionPerformed(ActionEvent evt) {
networkingLabel.setLabelFor(networkingComboBox);
Mnemonics.setLocalizedText(networkingLabel, NbBundle.getMessage(GradleDesktopGameGuiPanelVisual.class, "GradleDesktopGameGuiPanelVisual.networkingLabel.text")); // NOI18N
- networkingComboBox.setModel(new DefaultComboBoxModel(NetworkingLibrary.values()));
+ networkingComboBox.setModel(new DefaultComboBoxModel(NetworkingLibrary.values()));
networkingComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
networkingComboBoxActionPerformed(evt);
@@ -239,17 +237,17 @@ private void networkingComboBoxActionPerformed(ActionEvent evt) {//GEN-FIRST:eve
// Variables declaration - do not modify//GEN-BEGIN:variables
- private JComboBox guiComboBox;
+ private JComboBox guiComboBox;
private JScrollPane guiDescriptionScrollPane;
private JTextArea guiDescriptionTextArea;
private JLabel guiLabel;
private JSeparator jSeparator1;
private JSeparator jSeparator2;
- private JComboBox networkingComboBox;
+ private JComboBox networkingComboBox;
private JScrollPane networkingDescriptionScrollPane;
private JTextArea networkingDescriptionTextArea;
private JLabel networkingLabel;
- private JComboBox physicsEngineComboBox;
+ private JComboBox physicsEngineComboBox;
private JScrollPane physicsEngineDescriptionScrollPane;
private JTextArea physicsEngineDescriptionTextArea;
private JLabel physicsEngineLabel;
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.form b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.form
index 1124f9671..db25145cb 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.form
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.form
@@ -140,7 +140,7 @@
-
+
@@ -150,7 +150,7 @@
-
+
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.java
index 66da0cf53..6bc895d1d 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameJMEVersionPanelVisual.java
@@ -33,7 +33,8 @@
package com.jme3.gde.templates.gradledesktop;
import com.jme3.gde.templates.gradledesktop.options.JMEVersion;
-import com.jme3.gde.templates.gradledesktop.options.LWJGLVersion;
+import com.jme3.gde.templates.gradledesktop.options.LWJGLLibrary;
+import com.jme3.gde.templates.gradledesktop.options.TemplateLibrary;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
@@ -124,19 +125,16 @@ private void loadPatchNotes() {
}
private void updateLWJGLdescription() {
- LWJGLVersion lwjglVersion = (LWJGLVersion) lwjglComboBox
- .getSelectedItem();
+ TemplateLibrary lwjglVersion = lwjglComboBox.getItemAt(lwjglComboBox.getSelectedIndex());
lwjglTextArea.setText(lwjglVersion.getDescription());
}
protected void store(WizardDescriptor d) {
String jmeVersion = jmeVersionComboBox.getSelectedItem().toString();
- LWJGLVersion lwjglVersion = (LWJGLVersion) lwjglComboBox
- .getSelectedItem();
- String lwjglArtifact = lwjglVersion.getArtifact();
+ TemplateLibrary lwjglLibrary = lwjglComboBox.getItemAt(lwjglComboBox.getSelectedIndex());
d.putProperty("jmeVersion", jmeVersion);
- d.putProperty("lwjglArtifact", lwjglArtifact);
+ d.putProperty("lwjglLibrary", lwjglLibrary);
}
/**
@@ -184,7 +182,7 @@ public void actionPerformed(ActionEvent evt) {
lwjglVersionLabel.setLabelFor(lwjglComboBox);
Mnemonics.setLocalizedText(lwjglVersionLabel, NbBundle.getMessage(GradleDesktopGameJMEVersionPanelVisual.class, "GradleDesktopGameJMEVersionPanelVisual.lwjglVersionLabel.text")); // NOI18N
- lwjglComboBox.setModel(new DefaultComboBoxModel(LWJGLVersion.values()));
+ lwjglComboBox.setModel(new DefaultComboBoxModel(LWJGLLibrary.values()));
lwjglComboBox.setMaximumSize(new Dimension(100, 25));
lwjglComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
@@ -257,7 +255,7 @@ private void jmeVersionComboBoxActionPerformed(ActionEvent evt) {//GEN-FIRST:eve
JScrollPane jmeVersionDescriptionScrollPane;
JTextPane jmeVersionDescriptionTextPane;
JLabel jmeVersionLabel;
- JComboBox lwjglComboBox;
+ JComboBox lwjglComboBox;
JScrollPane lwjglDescriptionScrollPane;
JTextArea lwjglTextArea;
JLabel lwjglVersionLabel;
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardIterator.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardIterator.java
index 40c785ccd..72d4b7529 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardIterator.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardIterator.java
@@ -32,6 +32,8 @@
package com.jme3.gde.templates.gradledesktop;
import java.awt.Component;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -42,7 +44,7 @@
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.Enumeration;
@@ -127,7 +129,7 @@ private String[] createSteps() {
File gradleBuildFile = new File(dirF, "build.gradle");
Map buildFileBindings = new HashMap<>();
buildFileBindings.put("jmeVersion", wiz.getProperty("jmeVersion"));
- buildFileBindings.put("lwjglArtifact", wiz.getProperty("lwjglArtifact"));
+ buildFileBindings.put("lwjglLibrary", wiz.getProperty("lwjglLibrary"));
buildFileBindings.put("guiLibrary", wiz.getProperty("guiLibrary"));
buildFileBindings.put("physicsLibrary", wiz.getProperty("physicsLibrary"));
buildFileBindings.put("networkingLibrary", wiz.getProperty("networkingLibrary"));
@@ -245,13 +247,10 @@ private void createFileFromTemplate(File target, String templateResourcePath, Ma
// Process template
try {
FileObject targetFO = FileUtil.toFileObject(target);
- Writer os = new OutputStreamWriter(targetFO.getOutputStream(), Charset.forName("UTF-8"));
- engine.getContext().setWriter(os);
- Reader is = new InputStreamReader(GradleDesktopGameWizardIterator.class.getResourceAsStream("/" + templateResourcePath));
- engine.eval(is);
-
- os.close();
- is.close();
+ try (Writer os = new BufferedWriter(new OutputStreamWriter(targetFO.getOutputStream(), StandardCharsets.UTF_8)); Reader is = new BufferedReader(new InputStreamReader(GradleDesktopGameWizardIterator.class.getResourceAsStream("/" + templateResourcePath)));) {
+ engine.getContext().setWriter(os);
+ engine.eval(is);
+ }
} catch (IOException | ScriptException ex) {
throw new IOException(ex.getMessage(), ex);
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardPanel.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardPanel.java
index d8477e77d..ab563ca6c 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardPanel.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/GradleDesktopGameWizardPanel.java
@@ -54,6 +54,7 @@ public class GradleDesktopGameWizardPanel implements WizardDescriptor.Panel,
public GradleDesktopGameWizardPanel() {
}
+ @Override
public Component getComponent() {
if (component == null) {
component = new GradleDesktopGamePanelVisual(this);
@@ -62,22 +63,26 @@ public Component getComponent() {
return component;
}
+ @Override
public HelpCtx getHelp() {
return new HelpCtx("sdk.project_creation");
}
+ @Override
public boolean isValid() {
getComponent();
return component.valid(wizardDescriptor);
}
- private final Set listeners = new HashSet(1); // or can use ChangeSupport in NB 6.0
+ private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0
+ @Override
public final void addChangeListener(ChangeListener l) {
synchronized (listeners) {
listeners.add(l);
}
}
+ @Override
public final void removeChangeListener(ChangeListener l) {
synchronized (listeners) {
listeners.remove(l);
@@ -87,7 +92,7 @@ public final void removeChangeListener(ChangeListener l) {
protected final void fireChangeEvent() {
Set ls;
synchronized (listeners) {
- ls = new HashSet(listeners);
+ ls = new HashSet<>(listeners);
}
ChangeEvent ev = new ChangeEvent(this);
for (ChangeListener l : ls) {
@@ -95,20 +100,24 @@ protected final void fireChangeEvent() {
}
}
+ @Override
public void readSettings(Object settings) {
wizardDescriptor = (WizardDescriptor) settings;
component.read(wizardDescriptor);
}
+ @Override
public void storeSettings(Object settings) {
WizardDescriptor d = (WizardDescriptor) settings;
component.store(d);
}
+ @Override
public boolean isFinishPanel() {
return false;
}
+ @Override
public void validate() throws WizardValidationException {
getComponent();
component.validate(wizardDescriptor);
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
index ab0c958e7..5d4352587 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/AdditionalLibrary.java
@@ -70,22 +70,22 @@ public enum AdditionalLibrary implements TemplateLibrary {
JME3_EFFECTS("jMonkeyEngine Effects (jme3-effects)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-effects.description"),
- "org.jmonkeyengine", "jme3-effects",
+ null, "jme3-effects",
null, true),
JME3_TERRAIN("jMonkeyEngine TerraMonkey (jme3-terrain)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-terrain.description"),
- "org.jmonkeyengine", "jme3-terrain",
+ null, "jme3-terrain",
null, true),
JME3_TESTDATA("jMonkeyEngine Test Data (jme3-testdata)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-testdata.description"),
- "org.jmonkeyengine", "jme3-testdata",
+ null, "jme3-testdata",
null, true),
JME3_VR("jMonkeyEngine Virtual Reality (jme3-vr)",
NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.jme3-vr.description"),
- "org.jmonkeyengine", "jme3-vr",
+ null, "jme3-vr",
null, true),
HEART("Heart Library", NbBundle.getMessage(AdditionalLibrary.class,
"additionalLibrary.heart.description"),
@@ -189,7 +189,7 @@ public String getDefaultVersion() {
@Override
public String getGroupId() {
- return groupId;
+ return isCoreJmeLibrary ? JME_GROUP_ID : groupId;
}
@Override
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
index b13958d25..44c8a31e0 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/GUILibrary.java
@@ -71,7 +71,7 @@ public enum GUILibrary implements TemplateLibrary {
null, false),
NIFTY("Nifty", NbBundle.getMessage(GUILibrary.class,
"guilibrary.nifty.description"),
- "org.jmonkeyengine", "jme3-niftygui",
+ null, "jme3-niftygui",
null, true),
LEMUR("Lemur", NbBundle.getMessage(GUILibrary.class,
"guilibrary.lemur.description"),
@@ -150,7 +150,7 @@ public String toString() {
@Override
public String getGroupId() {
- return groupId;
+ return isCoreJmeLibrary ? JME_GROUP_ID : groupId;
}
@Override
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/LWJGLVersion.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/LWJGLLibrary.java
similarity index 73%
rename from jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/LWJGLVersion.java
rename to jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/LWJGLLibrary.java
index c27b549c8..ab649dc00 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/LWJGLVersion.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/LWJGLLibrary.java
@@ -59,12 +59,12 @@
*
* @author peedeeboy
*/
-public enum LWJGLVersion {
+public enum LWJGLLibrary implements TemplateLibrary {
- LWJGL_3("LWJGL 3.x", NbBundle.getMessage(LWJGLVersion.class,
- "lwjgl.lwjgl3.description"), "org.jmonkeyengine:jme3-lwjgl3"),
- LWJGL_2("LWJGL 2.x", NbBundle.getMessage(LWJGLVersion.class,
- "lwjgl.lwjgl2.description"), "org.jmonkeyengine:jme3-lwjgl");
+ LWJGL_3("LWJGL 3.x", NbBundle.getMessage(LWJGLLibrary.class,
+ "lwjgl.lwjgl3.description"), "jme3-lwjgl3"),
+ LWJGL_2("LWJGL 2.x", NbBundle.getMessage(LWJGLLibrary.class,
+ "lwjgl.lwjgl2.description"), "jme3-lwjgl");
/**
* The name of the LWJGL library. This will be displayed in the jComboBox in
@@ -77,51 +77,38 @@ public enum LWJGLVersion {
*/
private final String description;
/**
- * Gradle artifact string. This should exclude the jMonkeyEngine version, as
- * this will be added by the template.
+ * Maven artifact ID
*/
- private final String artifact;
+ private final String artifactId;
+ /**
/**
* Private constructor to create an instance of this enum.
*
- * @param label The name of the LWJGL library.
- * @param description Long description of the LWJGL version.
- * @param artifact Gradle artifact string.
+ * @param label The name of the library.
+ * @param description Long description of the library.
+ * @param groupId Maven group ID.
+ * @param artifactId Maven artifact ID.
+ * @param defaultVersion Default version is used if no version info is found
+ * from Maven
*/
- LWJGLVersion(String label, String description, String artifact) {
+ LWJGLLibrary(String label, String description,
+ String artifactId) {
this.label = label;
this.description = description;
- this.artifact = artifact;
+ this.artifactId = artifactId;
}
- /**
- * Get the label for this LWJGL version.
- *
- * @return the label for this LWJGL version.
- */
+ @Override
public String getLabel() {
return label;
}
- /**
- * Get the long description for this LWJGL version.
- *
- * @return the long description for this LWJGL version.
- */
+ @Override
public String getDescription() {
return description;
}
- /**
- * Get the Gradle artifact string.
- *
- * @return the Gradle artifact string.
- */
- public String getArtifact() {
- return artifact;
- }
-
/**
* Override the toString() method to return the label, so that
* this enum will display nicely in a jComboBox.
@@ -132,4 +119,24 @@ public String getArtifact() {
public String toString() {
return this.label;
}
+
+ @Override
+ public boolean getIsCoreJmeLibrary() {
+ return true;
+ }
+
+ @Override
+ public String getGroupId() {
+ return JME_GROUP_ID;
+ }
+
+ @Override
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ @Override
+ public String getVersion() {
+ return null;
+ }
}
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java
index f27da7a35..a37ffe7bc 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/MavenArtifact.java
@@ -36,6 +36,8 @@
*/
public interface MavenArtifact {
+ String JME_GROUP_ID = "org.jmonkeyengine";
+
/**
* Get the Maven group ID
*
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
index 08f68153c..45f71ecd8 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/NetworkingLibrary.java
@@ -70,7 +70,7 @@ public enum NetworkingLibrary implements TemplateLibrary {
null, false),
SPIDERMONKEY("SpiderMonkey", NbBundle.getMessage(NetworkingLibrary.class,
"networkinglibrary.spidermonkey.description"),
- "org.jmonkeyengine", "jme3-networking",
+ null, "jme3-networking",
null, true),
MONKEYNETTY("MonkeyNetty", NbBundle.getMessage(NetworkingLibrary.class,
"networkinglibrary.monkeynetty.description"),
@@ -153,7 +153,7 @@ public String toString() {
@Override
public String getGroupId() {
- return groupId;
+ return isCoreJmeLibrary ? JME_GROUP_ID : groupId;
}
@Override
diff --git a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
index 03f309bd1..428103da7 100644
--- a/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
+++ b/jme3-templates/src/com/jme3/gde/templates/gradledesktop/options/PhysicsLibrary.java
@@ -70,7 +70,7 @@ public enum PhysicsLibrary implements TemplateLibrary {
null, false),
JBULLET("jBullet", NbBundle.getMessage(GUILibrary.class,
"physicslibrary.jbullet.description"),
- "org.jmonkeyengine", "jme3-jbullet",
+ null, "jme3-jbullet",
null, true),
MINIE("Minie", NbBundle.getMessage(PhysicsLibrary.class,
"physicslibrary.minie.description"),
@@ -149,7 +149,7 @@ public String toString() {
@Override
public String getGroupId() {
- return groupId;
+ return isCoreJmeLibrary ? JME_GROUP_ID : groupId;
}
@Override
From e700cacea2b6c5e20a37db9eaf8e9adbdd67750f Mon Sep 17 00:00:00 2001
From: Pete Whelpton
Date: Sun, 22 Jan 2023 18:46:28 +0000
Subject: [PATCH 012/224] Do not overwrite Editor Profile on every load
---
.../src/org/jme3/netbeans/plaf/darkmonkey/Installer.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/jme3-dark-laf/src/org/jme3/netbeans/plaf/darkmonkey/Installer.java b/jme3-dark-laf/src/org/jme3/netbeans/plaf/darkmonkey/Installer.java
index e25cd49a6..1db3816c4 100644
--- a/jme3-dark-laf/src/org/jme3/netbeans/plaf/darkmonkey/Installer.java
+++ b/jme3-dark-laf/src/org/jme3/netbeans/plaf/darkmonkey/Installer.java
@@ -12,6 +12,8 @@
public class Installer extends ModuleInstall {
+ private static boolean isFirstInstallation = false;
+
@Override
public void restored() {
DarkMonkeyLookAndFeel darkMonkeyLaf = new DarkMonkeyLookAndFeel();
@@ -36,8 +38,10 @@ public void restored() {
};
DMUtils.loadFontsFromJar(this, fontsToLoad);
- EditorSettings setting = org.netbeans.modules.editor.settings.storage.api.EditorSettings.getDefault();
- setting.setCurrentFontColorProfile("Dark Monkey");
+ if(isFirstInstallation) {
+ EditorSettings setting = org.netbeans.modules.editor.settings.storage.api.EditorSettings.getDefault();
+ setting.setCurrentFontColorProfile("Dark Monkey");
+ }
}
@Override
@@ -47,6 +51,7 @@ public void validate() throws IllegalStateException {
if (LaF == null) {
/* Did the user already set a LaF? */
NbPreferences.root().node("laf").put("laf", "com.formdev.flatlaf.FlatDarkLaf"); // Set Flatlaf Dark as default LaF
+ isFirstInstallation = true;
}
}
From 9d17f66b7b8d7ae79cdd08e0a8094a8e58da7f8b Mon Sep 17 00:00:00 2001
From: Toni Helenius
Date: Mon, 23 Jan 2023 21:52:40 +0200
Subject: [PATCH 013/224] Working Maven version search implementation
---
.../mavensearch/MavenApiVersionChecker.java | 122 ++++++++++++++++++
.../mavensearch/MavenVersionChecker.java | 46 +++++++
.../mavensearch/models/DownloadLink.java | 38 ++++++
.../utils/mavensearch/models/SearchDoc.java | 52 ++++++++
.../mavensearch/models/SearchResponse.java | 42 ++++++
.../mavensearch/models/SearchResult.java | 41 ++++++
.../mavensearch/models/SearchSpellcheck.java | 40 ++++++
7 files changed, 381 insertions(+)
create mode 100644 jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenApiVersionChecker.java
create mode 100644 jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenVersionChecker.java
create mode 100644 jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/DownloadLink.java
create mode 100644 jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchDoc.java
create mode 100644 jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResponse.java
create mode 100644 jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResult.java
create mode 100644 jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchSpellcheck.java
diff --git a/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenApiVersionChecker.java b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenApiVersionChecker.java
new file mode 100644
index 000000000..795b80105
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenApiVersionChecker.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.utils.mavensearch;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializer;
+import com.jme3.gde.templates.utils.mavensearch.models.SearchResult;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse.BodyHandlers;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Checks versions from the Maven Search API
+ */
+public class MavenApiVersionChecker implements MavenVersionChecker {
+
+ private static final String API_URL = "https://search.maven.org/solrsearch/select";
+
+ private static final Gson gson;
+
+ static {
+ JsonDeserializer instantDeserializer = (jSon, typeOfT, context) -> jSon == null ? null : Instant.ofEpochMilli(jSon.getAsLong());
+
+ gson = new GsonBuilder()
+ .registerTypeAdapter(Instant.class, instantDeserializer).create();
+ }
+
+ @Override
+ public CompletableFuture> getAllVersions(String groupId, String artifactId) {
+ Map queryParams = new HashMap<>();
+ queryParams.put("q", String.format("g:%s AND a:%s", groupId, artifactId));
+ queryParams.put("core", "gav");
+ queryParams.put("rows", "50");
+ queryParams.put("wt", "json");
+
+ try {
+ return callApi(queryParams, SearchResult.class).thenApply((result) -> result.response.docs.stream().map((doc) -> doc.v).collect(Collectors.toList()));
+ } catch (Exception ex) {
+ throw new RuntimeException("Failed to get version info!", ex);
+ }
+ }
+
+ @Override
+ public CompletableFuture getLatestVersion(String groupId, String artifactId) {
+ Map queryParams = new HashMap<>();
+ queryParams.put("q", String.format("g:%s AND a:%s", groupId, artifactId));
+ queryParams.put("wt", "json");
+
+ try {
+ return callApi(queryParams, SearchResult.class).thenApply((result) -> result.response.docs.get(0).latestVersion);
+ } catch (Exception ex) {
+ throw new RuntimeException("Failed to get latest version info!", ex);
+ }
+ }
+
+ private static CompletableFuture callApi(Map queryParams, Class clazz) throws InterruptedException, ExecutionException {
+ String encodedURL = queryParams.keySet().stream()
+ .map(key -> key + "=" + encodeValue(queryParams.get(key)))
+ .collect(joining("&", API_URL + "?", ""));
+
+ HttpClient client = HttpClient.newHttpClient();
+ HttpRequest request = HttpRequest.newBuilder()
+ .uri(URI.create(encodedURL))
+ .build();
+
+ CompletableFuture result = client.sendAsync(request, BodyHandlers.ofString())
+ .thenApply((t) -> gson.fromJson(t.body(), clazz));
+
+ return result;
+ }
+
+ private static String encodeValue(String value) {
+ try {
+ return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
+ } catch (UnsupportedEncodingException ex) {
+ throw new RuntimeException("Failed to encode value!", ex);
+ }
+ }
+
+}
diff --git a/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenVersionChecker.java b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenVersionChecker.java
new file mode 100644
index 000000000..4a112a383
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/MavenVersionChecker.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.utils.mavensearch;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Search Maven Central for versions
+ */
+public interface MavenVersionChecker {
+
+ CompletableFuture> getAllVersions(String groupId, String artifactId);
+
+ CompletableFuture getLatestVersion(String groupId, String artifactId);
+
+}
diff --git a/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/DownloadLink.java b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/DownloadLink.java
new file mode 100644
index 000000000..b34cc0ed5
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/DownloadLink.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.utils.mavensearch.models;
+
+public class DownloadLink {
+
+ public String name;
+ public String link;
+}
diff --git a/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchDoc.java b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchDoc.java
new file mode 100644
index 000000000..a95ca9fd4
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchDoc.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.utils.mavensearch.models;
+
+import java.time.Instant;
+import java.util.List;
+
+public class SearchDoc {
+
+ public String id;
+ public String g;
+ public String a;
+ public String v;
+ public String latestVersion;
+ public String repositoryId;
+ public String p;
+ public Instant timestamp;
+ public Integer versionCount;
+ public List text;
+ public List ec;
+ public List downloadLinks;
+
+}
diff --git a/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResponse.java b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResponse.java
new file mode 100644
index 000000000..8e2d35501
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResponse.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.utils.mavensearch.models;
+
+import java.util.List;
+
+public class SearchResponse {
+
+ public List docs;
+ public Integer numFound;
+ public Integer start;
+
+}
diff --git a/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResult.java b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResult.java
new file mode 100644
index 000000000..9abf1eb5a
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchResult.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.utils.mavensearch.models;
+
+/**
+ * Main level response from Maven Search API
+ */
+public class SearchResult {
+ public SearchResponse response;
+ public Object responseHeader;
+ public SearchSpellcheck spellcheck;
+}
diff --git a/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchSpellcheck.java b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchSpellcheck.java
new file mode 100644
index 000000000..27dd4c919
--- /dev/null
+++ b/jme3-templates/src/com/jme3/gde/templates/utils/mavensearch/models/SearchSpellcheck.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.gde.templates.utils.mavensearch.models;
+
+import java.util.List;
+
+public class SearchSpellcheck {
+
+ public List