Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions jme3-assetbrowser/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>3.6.0</specification-version>
<specification-version>3.9.0</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand All @@ -21,7 +21,7 @@
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>3.6.0</specification-version>
<specification-version>3.9.0</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand All @@ -30,7 +30,7 @@
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>3.6.0</specification-version>
<specification-version>3.9.0</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand All @@ -39,7 +39,7 @@
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>3.6.0</specification-version>
<specification-version>3.9.0</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand All @@ -48,7 +48,7 @@
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>3.6.0</specification-version>
<specification-version>3.9.0</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand All @@ -57,7 +57,7 @@
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>3.6.0</specification-version>
<specification-version>3.9.0</specification-version>
</run-dependency>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.jme3.gde.materials.JMEMaterialDataObject;
import com.jme3.gde.materials.multiview.MaterialOpenSupport;
import com.jme3.gde.scenecomposer.SceneComposerTopComponent;
import com.jme3.gde.textureeditor.ImageEditorTopComponent;
import com.jme3.gde.textureeditor.JmeTextureDataObject;
import com.jme3.gde.textureeditor.OpenTexture;
import com.jme3.scene.Spatial;
Expand All @@ -70,6 +71,8 @@
import org.openide.filesystems.FileRenameEvent;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.CookieSet;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;

/**
Expand Down Expand Up @@ -487,8 +490,9 @@ public void openAsset(AssetPreviewWidget widget) {
} else if (widget instanceof TexturePreview) {
try {
JmeTextureDataObject textureObject = (JmeTextureDataObject) DataObject.find(pf);
OpenTexture openTexture = new OpenTexture(textureObject);
openTexture.actionPerformed(null);
DataObject dobj = textureObject.getPrimaryEntry().getDataObject();
FileObject file = dobj.getPrimaryFile();
ImageEditorTopComponent display = new ImageEditorTopComponent(file);
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
Expand Down
2 changes: 1 addition & 1 deletion jme3-texture-editor/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license.file=../license-jme.txt
nbm.homepage=https://www.jmonkeyengine.org
nbm.module.author=pgi
nbm.needs.restart=true
spec.version.base=3.5.2
spec.version.base=3.9.0
9 changes: 9 additions & 0 deletions jme3-texture-editor/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
<code-name-base>com.jme3.gde.textureeditor</code-name-base>
<suite-component/>
<module-dependencies>
<dependency>
<code-name-base>com.jme3.gde.core</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>3.9.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.api.templates</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
CTL_ImageEditorAction=ImageEditor
CTL_ImageEditorTopComponent=ImageEditor Window
CTL_OpenTexture=Edit Texture
CTL_SomeAction=sfefe
HINT_ImageEditorTopComponent=This is a ImageEditor window
LBL_JmeTexture_loader_name=JmeTexture Files
OpenIDE-Module-Display-Category=jMonkeyEngine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
* Copyright (c) 2009-2026 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.textureeditor;

Expand All @@ -16,22 +43,28 @@
import org.openide.util.ImageUtilities;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
import org.openide.util.lookup.AbstractLookup;
import org.openide.windows.CloneableTopComponent;

/**
* Top component which displays something.
* Top component which displays a Texture.
*/
@ConvertAsProperties(dtd = "-//com.jme3.gde.textureeditor//ImageEditor//EN",
autostore = false)
public final class ImageEditorTopComponent extends TopComponent {
public final class ImageEditorTopComponent extends CloneableTopComponent {

private static ImageEditorTopComponent instance;
/** path to the icon used by the component and its open action */
static final String ICON_PATH = Icons.TEXTURE_GREEN;
private static final String PREFERRED_ID = "ImageEditorTopComponent";
private final ImageEditorComponent EDITOR = ImageEditorComponent.create();

public ImageEditorTopComponent() {

}

public ImageEditorTopComponent(FileObject currentFile) {
initComponents();
setName(NbBundle.getMessage(ImageEditorTopComponent.class, "CTL_ImageEditorTopComponent"));
setToolTipText(NbBundle.getMessage(ImageEditorTopComponent.class, "HINT_ImageEditorTopComponent"));
Expand All @@ -40,6 +73,11 @@ public ImageEditorTopComponent() {

//Add the dynamic object to the TopComponent Lookup:
associateLookup(new AbstractLookup(EDITOR.getContent()));
try {
setEditedImage(currentFile);
} catch (IOException | URISyntaxException ex) {
Exceptions.printStackTrace(ex);
}
}

/** This method is called from within the constructor to
Expand All @@ -59,6 +97,7 @@ private void initComponents() {
* Gets default instance. Do not use directly: reserved for *.settings files only,
* i.e. deserialization routines; otherwise you could get a non-deserialized instance.
* To obtain the singleton instance, use {@link #findInstance}.
* @return
*/
public static synchronized ImageEditorTopComponent getDefault() {
if (instance == null) {
Expand All @@ -69,6 +108,7 @@ public static synchronized ImageEditorTopComponent getDefault() {

/**
* Obtain the ImageEditorTopComponent instance. Never call {@link #getDefault} directly!
* @return
*/
public static synchronized ImageEditorTopComponent findInstance() {
TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
Expand All @@ -77,8 +117,8 @@ public static synchronized ImageEditorTopComponent findInstance() {
"Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
return getDefault();
}
if (win instanceof ImageEditorTopComponent) {
return (ImageEditorTopComponent) win;
if (win instanceof ImageEditorTopComponent imageEditorTopComponent) {
return imageEditorTopComponent;
}
Logger.getLogger(ImageEditorTopComponent.class.getName()).warning(
"There seem to be multiple components with the '" + PREFERRED_ID
Expand All @@ -93,22 +133,20 @@ public int getPersistenceType() {

@Override
public void componentOpened() {
// TODO add custom code on component opening
}

@Override
public void componentClosed() {
// TODO add custom code on component closing
}

void writeProperties(java.util.Properties p) {
public void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
// TODO store your settings
}

Object readProperties(java.util.Properties p) {
public Object readProperties(java.util.Properties p) {
if (instance == null) {
instance = this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package com.jme3.gde.textureeditor;

import com.jme3.gde.core.assets.AssetDataObject;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.textureeditor.icons.Icons;
import java.io.IOException;
import org.openide.awt.ActionID;
Expand All @@ -18,6 +20,7 @@
import org.openide.loaders.MultiFileLoader;
import org.openide.nodes.Node;
import org.openide.nodes.Children;
import org.openide.nodes.CookieSet;
import org.openide.util.Lookup;

@MIMEResolver.ExtensionRegistration(
Expand All @@ -26,40 +29,15 @@
extension = {"png", "bmp", "jpg", "PNG", "BMP", "JPG", "jpeg", "JPEG", "tga", "TGA"}
)
@DataObject.Registration(displayName = "jME3 Texture", mimeType = "image/x-jmetexture", iconBase = Icons.TEXTURE_BLUE)
@ActionReferences(value = {
@ActionReference(id =
@ActionID(category = "JME3", id = "com.jme3.gde.textureeditor.OpenTexture"), path = "Loaders/image/x-jmetexture/Actions", position = 0),
@ActionReference(id =
@ActionID(category = "Edit", id = "org.openide.actions.CutAction"), path = "Loaders/image/x-jmetexture/Actions", position = 200, separatorBefore = 100),
@ActionReference(id =
@ActionID(category = "Edit", id = "org.openide.actions.CopyAction"), path = "Loaders/image/x-jmetexture/Actions", position = 300, separatorAfter = 400),
@ActionReference(id =
@ActionID(category = "Edit", id = "org.openide.actions.DeleteAction"), path = "Loaders/image/x-jmetexture/Actions", position = 500),
@ActionReference(id =
@ActionID(category = "System", id = "org.openide.actions.RenameAction"), path = "Loaders/image/x-jmetexture/Actions", position = 600, separatorAfter = 700),
@ActionReference(id =
@ActionID(category = "System", id = "org.openide.actions.SaveAsTemplateAction"), path = "Loaders/image/x-jmetexture/Actions", position = 800, separatorAfter = 900),
@ActionReference(id =
@ActionID(category = "System", id = "org.openide.actions.FileSystemAction"), path = "Loaders/image/x-jmetexture/Actions", position = 1000, separatorAfter = 1100),
@ActionReference(id =
@ActionID(category = "System", id = "org.openide.actions.ToolsAction"), path = "Loaders/image/x-jmetexture/Actions", position = 1200),
@ActionReference(id =
@ActionID(category = "System", id = "org.openide.actions.PropertiesAction"), path = "Loaders/image/x-jmetexture/Actions", position = 1300)
})
public class JmeTextureDataObject extends MultiDataObject {
public class JmeTextureDataObject extends AssetDataObject {

public JmeTextureDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
CookieSet cookies = getCookieSet();
if (getLookup().lookup(ProjectAssetManager.class) != null) {
cookies.add((Node.Cookie) new OpenTexture(getPrimaryEntry()));
}

}

@Override
protected Node createNodeDelegate() {
return new DataNode(this, Children.LEAF, getLookup());
}

@Override
public Lookup getLookup() {
return getCookieSet().getLookup();
}
}
Loading