Merge commit '3cbb158b81a53190ba4074bc3ae0b6b5a0f515d1'

Nifty-Editor prototype
experimental
relu91 10 years ago
commit 415090e989
  1. 16
      sdk/jme3-gui/build.xml
  2. 11
      sdk/jme3-gui/manifest.mf
  3. 90
      sdk/jme3-gui/nbproject/build-impl.xml
  4. BIN
      sdk/jme3-gui/release/modules/ext/Nifty-Editor0.5.7.jar
  5. 10
      sdk/jme3-gui/src/com/jme3/gde/gui/EmptyNiftyGui.xml
  6. 126
      sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiDataObject.java
  7. 29
      sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiVisualElement.form
  8. 263
      sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiVisualElement.java
  9. 89
      sdk/jme3-gui/src/com/jme3/gde/gui/OldNiftyGuiDataObject.java
  10. 154
      sdk/jme3-gui/src/com/jme3/gde/gui/layer.xml
  11. 6
      sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyPreviewPanel.java
  12. 4
      sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewToolbarElement.java
  13. 6
      sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewView.java
  14. 10
      sdk/jme3-gui/src/com/jme3/gde/gui/package-info.java

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
<!-- for some information on what you could do (e.g. targets to override). -->
<!-- If you delete this file and reopen the project it will be recreated. -->
<project name="com.jme3.gde.gui" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project com.jme3.gde.gui.</description>
<import file="nbproject/build-impl.xml"/>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
<!-- for some information on what you could do (e.g. targets to override). -->
<!-- If you delete this file and reopen the project it will be recreated. -->
<project name="com.jme3.gde.gui" default="netbeans" basedir=".">
<description>Builds, tests, and runs the project com.jme3.gde.gui.</description>
<import file="nbproject/build-impl.xml"/>
</project>

@ -1,6 +1,5 @@
Manifest-Version: 1.0
OpenIDE-Module: com.jme3.gde.gui/1
OpenIDE-Module-Implementation-Version: 0
OpenIDE-Module-Layer: com/jme3/gde/gui/layer.xml
OpenIDE-Module-Localizing-Bundle: com/jme3/gde/gui/Bundle.properties
Manifest-Version: 1.0
OpenIDE-Module: com.jme3.gde.gui/1
OpenIDE-Module-Implementation-Version: 0
OpenIDE-Module-Localizing-Bundle: com/jme3/gde/gui/Bundle.properties

@ -1,45 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM project.xml - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
-->
<project name="com.jme3.gde.gui-impl" basedir="..">
<fail message="Please build using Ant 1.7.1 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
</not>
</condition>
</fail>
<property file="nbproject/private/suite-private.properties"/>
<property file="nbproject/suite.properties"/>
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
<property file="${suite.dir}/nbproject/private/platform-private.properties"/>
<property file="${suite.dir}/nbproject/platform.properties"/>
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="property"/>
<attribute name="value"/>
<sequential>
<property name="@{property}" value="@{value}"/>
</sequential>
</macrodef>
<property file="${user.properties.file}"/>
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
<condition>
<not>
<contains string="${cluster.path.evaluated}" substring="platform"/>
</not>
</condition>
</fail>
<import file="${harness.dir}/build.xml"/>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
*** GENERATED FROM project.xml - DO NOT EDIT ***
*** EDIT ../build.xml INSTEAD ***
-->
<project name="com.jme3.gde.gui-impl" basedir="..">
<fail message="Please build using Ant 1.7.1 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
</not>
</condition>
</fail>
<property file="nbproject/private/suite-private.properties"/>
<property file="nbproject/suite.properties"/>
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
<property file="${suite.dir}/nbproject/private/platform-private.properties"/>
<property file="${suite.dir}/nbproject/platform.properties"/>
<macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="name"/>
<attribute name="value"/>
<sequential>
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="property"/>
<attribute name="value"/>
<sequential>
<property name="@{property}" value="@{value}"/>
</sequential>
</macrodef>
<property file="${user.properties.file}"/>
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
<condition>
<not>
<contains string="${cluster.path.evaluated}" substring="platform"/>
</not>
</condition>
</fail>
<import file="${harness.dir}/build.xml"/>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd">
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<!-- start screen -->
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<screen id="GScreen0" controller="mygame.Main">
<layer id="GLayer0" childLayout="absolute">
</layer>
</screen>
</nifty>

@ -5,36 +5,99 @@
package com.jme3.gde.gui;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.gui.multiview.PreviewView;
import java.io.IOException;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.modules.xml.multiview.DesignMultiViewDesc;
import org.netbeans.modules.xml.multiview.XmlMultiViewDataObject;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.MIMEResolver;
import org.openide.loaders.DataNode;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectExistsException;
import org.openide.loaders.MultiDataObject;
import org.openide.loaders.MultiFileLoader;
import org.openide.nodes.Node;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
import org.openide.util.lookup.ProxyLookup;
public class NiftyGuiDataObject extends XmlMultiViewDataObject {
import org.openide.util.NbBundle.Messages;
import org.openide.windows.TopComponent;
private static final int TYPE_TOOLBAR = 0;
protected final Lookup lookup;
protected final InstanceContent lookupContents = new InstanceContent();
@Messages({
"LBL_NiftyGui_LOADER=Files of NiftyGui"
})
@MIMEResolver.Registration(
displayName = "#LBL_NiftyGui_LOADER",
resource = "NiftyGuiResolver.xml")
@DataObject.Registration(
mimeType = "text/x-niftygui+xml",
iconBase = "com/jme3/gde/gui/Computer_File_043.gif",
displayName = "#LBL_NiftyGui_LOADER",
position = 300)
@ActionReferences({
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "System", id = "org.openide.actions.OpenAction"),
position = 100,
separatorAfter = 200),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "Edit", id = "org.openide.actions.CutAction"),
position = 300),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "Edit", id = "org.openide.actions.CopyAction"),
position = 400,
separatorAfter = 500),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "Edit", id = "org.openide.actions.DeleteAction"),
position = 600),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "System", id = "org.openide.actions.RenameAction"),
position = 700,
separatorAfter = 800),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "System", id = "org.openide.actions.SaveAsTemplateAction"),
position = 900,
separatorAfter = 1000),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "System", id = "org.openide.actions.FileSystemAction"),
position = 1100,
separatorAfter = 1200),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "System", id = "org.openide.actions.ToolsAction"),
position = 1300),
@ActionReference(
path = "Loaders/text/x-niftygui+xml/Actions",
id =
@ActionID(category = "System", id = "org.openide.actions.PropertiesAction"),
position = 1400)
})
public class NiftyGuiDataObject extends MultiDataObject {
public NiftyGuiDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
lookup = new ProxyLookup(getCookieSet().getLookup(), new AbstractLookup(getLookupContents()));
registerEditor("text/x-niftygui+xml", true);
findAssetManager();
}
protected void findAssetManager() {
protected final void findAssetManager() {
FileObject file = getPrimaryFile();
ProjectManager pm = ProjectManager.getDefault();
while (file != null) {
@ -44,7 +107,7 @@ public class NiftyGuiDataObject extends XmlMultiViewDataObject {
if (project != null) {
ProjectAssetManager mgr = project.getLookup().lookup(ProjectAssetManager.class);
if (mgr != null) {
getLookupContents().add(mgr);
this.getCookieSet().assign(mgr.getClass(),mgr);
return;
}
}
@ -56,34 +119,27 @@ public class NiftyGuiDataObject extends XmlMultiViewDataObject {
}
}
@Override
public Lookup getLookup() {
return lookup;
}
public InstanceContent getLookupContents() {
return lookupContents;
}
@Override
protected Node createNodeDelegate() {
DataNode node = new DataNode(this, Children.LEAF, getLookup());
node.setIconBaseWithExtension("com/jme3/gde/gui/Computer_File_043.gif");
return node;
}
@Override
protected DesignMultiViewDesc[] getMultiViewDesc() {
if (getLookup().lookup(ProjectAssetManager.class) == null) {
return new DesignMultiViewDesc[]{};
} else {
return new DesignMultiViewDesc[]{new PreviewView(this, TYPE_TOOLBAR)};
}
protected int associateLookup() {
return 1;
}
@Override
protected String getPrefixMark() {
return "Nifty";
@MultiViewElement.Registration(
displayName = "#LBL_NiftyGui_EDITOR",
iconBase = "com/jme3/gde/gui/Computer_File_043.gif",
mimeType = "text/x-niftygui+xml",
persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED,
preferredID = "NiftyGui",
position = 1000)
@Messages("LBL_NiftyGui_EDITOR=XML")
public static MultiViewEditorElement createEditor(Lookup lkp) {
return new MultiViewEditorElement(lkp);
}
}

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollArea">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
</SubComponents>
</Form>

@ -0,0 +1,263 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.gui;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.core.scene.SceneApplication;
import de.lessvoid.nifty.Nifty;
import jada.ngeditor.controller.GUIEditor;
import jada.ngeditor.guiviews.DND.PaletteDropTarget;
import jada.ngeditor.guiviews.DND.TrasferHandling;
import jada.ngeditor.guiviews.J2DNiftyView;
import jada.ngeditor.model.elements.GLayer;
import jada.ngeditor.model.exception.NoProductException;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.Callable;
import javax.swing.Action;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.xml.bind.JAXBException;
import javax.xml.parsers.ParserConfigurationException;
import org.netbeans.core.spi.multiview.CloseOperationState;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.netbeans.core.spi.multiview.MultiViewElementCallback;
import org.openide.awt.UndoRedo;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.NbBundle.Messages;
import org.openide.windows.TopComponent;
import org.xml.sax.SAXException;
@MultiViewElement.Registration(
displayName = "#LBL_NiftyGui_VISUAL",
iconBase = "com/jme3/gde/gui/Computer_File_043.gif",
mimeType = "text/x-niftygui+xml",
persistenceType = TopComponent.PERSISTENCE_NEVER,
preferredID = "NiftyGuiVisual",
position = 2000)
@Messages("LBL_NiftyGui_VISUAL=Visual")
public final class NiftyGuiVisualElement extends JPanel implements MultiViewElement {
private NiftyGuiDataObject obj;
private JToolBar toolbar = new JToolBar();
private transient MultiViewElementCallback callback;
private GUIEditor editor;
private final Nifty nifty;
private final J2DNiftyView view;
private final JComboBox layers = new JComboBox();
public NiftyGuiVisualElement(Lookup lkp) {
obj = lkp.lookup(NiftyGuiDataObject.class);
assert obj != null;
initComponents();
view = new J2DNiftyView(800, 600);
view.init();
this.scrollArea.getViewport().addChangeListener(view);
this.scrollArea.setViewportView(view);
TrasferHandling tranf = new TrasferHandling();
PaletteDropTarget tmp = new PaletteDropTarget();
editor = new GUIEditor();
nifty = view.getNifty();
view.setTransferHandler(tranf);
view.setDropTarget(tmp);
editor.addObserver(view);
editor.addObserver(tranf);
editor.addObserver(tmp);
this.createToolbar();
}
/**
* Old code
* @author normenhansen
*/
private void createToolbar() {
toolbar.setPreferredSize(new Dimension(10000, 24));
toolbar.setMaximumSize(new Dimension(10000, 24));
toolbar.setFloatable(false);
JComboBox comboBox = new JComboBox(new String[]{"640x480", "480x800", "800x480", "800x600", "1024x768", "1280x720"});
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
String string = (String) e.getItem();
if ("640x480".equals(string)) {
view.setResoltion(640, 480);
} else if ("1024x768".equals(string)) {
view.setResoltion(1024, 768);
} else if ("1280x720".equals(string)) {
view.setResoltion(1280, 720);
} else if ("800x600".equals(string)) {
view.setResoltion(800, 600);
} else if ("800x480".equals(string)) {
view.setResoltion(800, 480);
} else if ("480x800".equals(string)) {
view.setResoltion(480, 800);
} else {
view.setResoltion(800, 600);
}
}
});
toolbar.add(comboBox);
comboBox.setSelectedItem("800x600");
layers.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
GLayer item = (GLayer) e.getItem();
editor.selectElement(item);
}
});
toolbar.add(layers);
}
@Override
public String getName() {
return "NiftyGuiVisualElement";
}
/**
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
scrollArea = new javax.swing.JScrollPane();
setLayout(new java.awt.BorderLayout());
add(scrollArea, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane scrollArea;
// End of variables declaration//GEN-END:variables
@Override
public JComponent getVisualRepresentation() {
return this;
}
@Override
public JComponent getToolbarRepresentation() {
return toolbar;
}
@Override
public Action[] getActions() {
return new Action[0];
}
@Override
public Lookup getLookup() {
return obj.getLookup();
}
/**
* Raw implementation , just to prototype the editor
*/
@Override
public void componentOpened() {
try {
String path = this.obj.getPrimaryFile().getPath();
ProjectAssetManager mgr = this.getLookup().lookup(ProjectAssetManager.class);
String assetPath = mgr.getAssetFolder().getPath();
this.editor.createNewGui(nifty,new File(path),new File(assetPath));
Collection<GLayer> layers1 = this.editor.getGui().getLayers();
DefaultComboBoxModel<GLayer> model = new DefaultComboBoxModel<GLayer>(layers1.toArray(new GLayer[0]));
layers.setModel(model);
layers.setSelectedItem(this.editor.getCurrentLayer());
} catch (ParserConfigurationException ex) {
Exceptions.printStackTrace(ex);
} catch (JAXBException ex) {
Exceptions.printStackTrace(ex);
} catch (ClassNotFoundException ex) {
Exceptions.printStackTrace(ex);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
} catch (NoProductException ex) {
Exceptions.printStackTrace(ex);
} catch (SAXException ex) {
Exceptions.printStackTrace(ex);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
@Override
public void componentClosed() {
}
/**
* Raw implementation , just to prototype the editor
*/
@Override
public void componentShowing() {
try {
String path = this.obj.getPrimaryFile().getPath();
ProjectAssetManager mgr = this.getLookup().lookup(ProjectAssetManager.class);
String assetPath = mgr.getAssetFolder().getPath();
this.editor.createNewGui(nifty,new File(path),new File(assetPath));
Collection<GLayer> layers1 = this.editor.getGui().getLayers();
DefaultComboBoxModel<GLayer> model = new DefaultComboBoxModel<GLayer>(layers1.toArray(new GLayer[0]));
layers.setModel(model);
layers.setSelectedItem(this.editor.getCurrentLayer());
} catch (ParserConfigurationException ex) {
Exceptions.printStackTrace(ex);
} catch (JAXBException ex) {
Exceptions.printStackTrace(ex);
} catch (ClassNotFoundException ex) {
Exceptions.printStackTrace(ex);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
} catch (NoProductException ex) {
Exceptions.printStackTrace(ex);
} catch (SAXException ex) {
Exceptions.printStackTrace(ex);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
}
/**
* Raw implementation , just to prototype the editor
*/
@Override
public void componentHidden() {
String path = this.obj.getPrimaryFile().getPath();
try {
this.editor.saveGui(path);
} catch (FileNotFoundException ex) {
Exceptions.printStackTrace(ex);
} catch (JAXBException ex) {
Exceptions.printStackTrace(ex);
}
}
@Override
public void componentActivated() {
}
@Override
public void componentDeactivated() {
}
@Override
public UndoRedo getUndoRedo() {
return UndoRedo.NONE;
}
@Override
public void setMultiViewCallback(MultiViewElementCallback callback) {
this.callback = callback;
}
@Override
public CloseOperationState canCloseElement() {
return CloseOperationState.STATE_OK;
}
}

@ -0,0 +1,89 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.jme3.gde.gui;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.gui.multiview.PreviewView;
import java.io.IOException;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.modules.xml.multiview.DesignMultiViewDesc;
import org.netbeans.modules.xml.multiview.XmlMultiViewDataObject;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataNode;
import org.openide.loaders.DataObjectExistsException;
import org.openide.loaders.MultiFileLoader;
import org.openide.nodes.Node;
import org.openide.nodes.Children;
import org.openide.util.Lookup;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
import org.openide.util.lookup.ProxyLookup;
public class OldNiftyGuiDataObject extends XmlMultiViewDataObject {
private static final int TYPE_TOOLBAR = 0;
protected final Lookup lookup;
protected final InstanceContent lookupContents = new InstanceContent();
public OldNiftyGuiDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
lookup = new ProxyLookup(getCookieSet().getLookup(), new AbstractLookup(getLookupContents()));
findAssetManager();
}
protected void findAssetManager() {
FileObject file = getPrimaryFile();
ProjectManager pm = ProjectManager.getDefault();
while (file != null) {
if (file.isFolder() && pm.isProject(file)) {
try {
Project project = ProjectManager.getDefault().findProject(file);
if (project != null) {
ProjectAssetManager mgr = project.getLookup().lookup(ProjectAssetManager.class);
if (mgr != null) {
getLookupContents().add(mgr);
return;
}
}
} catch (IOException ex) {
} catch (IllegalArgumentException ex) {
}
}
file = file.getParent();
}
}
@Override
public Lookup getLookup() {
return lookup;
}
public InstanceContent getLookupContents() {
return lookupContents;
}
@Override
protected Node createNodeDelegate() {
DataNode node = new DataNode(this, Children.LEAF, getLookup());
node.setIconBaseWithExtension("com/jme3/gde/gui/Computer_File_043.gif");
return node;
}
@Override
protected DesignMultiViewDesc[] getMultiViewDesc() {
if (getLookup().lookup(ProjectAssetManager.class) == null) {
return new DesignMultiViewDesc[]{};
} else {
return new DesignMultiViewDesc[]{new PreviewView(this, TYPE_TOOLBAR)};
}
}
@Override
protected String getPrefixMark() {
return "Nifty";
}
}

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="Loaders">
<folder name="text">
<folder name="x-niftygui+xml">
<folder name="Actions">
<file name="org-openide-actions-CopyAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CopyAction.instance"/>
<attr name="position" intvalue="400"/>
</file>
<file name="org-openide-actions-CutAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
<attr name="position" intvalue="300"/>
</file>
<file name="org-openide-actions-DeleteAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-DeleteAction.instance"/>
<attr name="position" intvalue="600"/>
</file>
<file name="org-openide-actions-FileSystemAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-FileSystemAction.instance"/>
<attr name="position" intvalue="1100"/>
</file>
<file name="org-openide-actions-OpenAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-OpenAction.instance"/>
<attr name="position" intvalue="100"/>
</file>
<file name="org-openide-actions-PropertiesAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-PropertiesAction.instance"/>
<attr name="position" intvalue="1400"/>
</file>
<file name="org-openide-actions-RenameAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-RenameAction.instance"/>
<attr name="position" intvalue="700"/>
</file>
<file name="org-openide-actions-SaveAsTemplateAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-SaveAsTemplateAction.instance"/>
<attr name="position" intvalue="900"/>
</file>
<file name="org-openide-actions-ToolsAction.shadow">
<attr name="originalFile" stringvalue="Actions/System/org-openide-actions-ToolsAction.instance"/>
<attr name="position" intvalue="1300"/>
</file>
<file name="sep-1.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="200"/>
</file>
<file name="sep-2.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="500"/>
</file>
<file name="sep-3.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="800"/>
</file>
<file name="sep-4.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="1000"/>
</file>
<file name="sep-5.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="1200"/>
</file>
</folder>
<folder name="Factories">
<file name="NiftyGuiDataLoader.instance">
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/com/jme3/gde/gui/Computer_File_043.gif"/>
<attr name="dataObjectClass" stringvalue="com.jme3.gde.gui.NiftyGuiDataObject"/>
<attr name="instanceCreate" methodvalue="org.openide.loaders.DataLoaderPool.factory"/>
<attr name="mimeType" stringvalue="text/x-niftygui+xml"/>
</file>
</folder>
</folder>
</folder>
</folder>
<folder name="Services">
<folder name="MIMEResolver">
<file name="NiftyGuiResolver.xml" url="NiftyGuiResolver.xml">
<attr name="displayName" bundlevalue="com.jme3.gde.gui.Bundle#Services/MIMEResolver/NiftyGuiResolver.xml"/>
</file>
</folder>
</folder>
<folder name="Templates">
<folder name="GUI">
<file name="NiftyGui.xml" url="NiftyGui.xml">
<attr name="displayName" bundlevalue="com.jme3.gde.gui.Bundle#Templates/Other/NiftyGuiTemplate.xml"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="button.xml" url="examples/01-button.xml">
<attr name="displayName" stringvalue="Button Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="chat.xml" url="examples/02-chat.xml">
<attr name="displayName" stringvalue="Chat Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="checkbox.xml" url="examples/03-checkbox.xml">
<attr name="displayName" stringvalue="Checkbox Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="console.xml" url="examples/04-console.xml">
<attr name="displayName" stringvalue="Console Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="dropdown.xml" url="examples/05-dropdown.xml">
<attr name="displayName" stringvalue="Dropdown Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="imageselect.xml" url="examples/06-imageselect.xml">
<attr name="displayName" stringvalue="Imageselect Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="label.xml" url="examples/07-label.xml">
<attr name="displayName" stringvalue="Label Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="dropdown.xml" url="examples/08-dropdown.xml">
<attr name="displayName" stringvalue="Dropdown Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="radiobutton.xml" url="examples/09-radiobutton.xml">
<attr name="displayName" stringvalue="Radiobutton Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="scrollbar.xml" url="examples/10-scrollbar.xml">
<attr name="displayName" stringvalue="Scrollbar Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="scrollpanel.xml" url="examples/11-scrollpanel.xml">
<attr name="displayName" stringvalue="Scrollpanel Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="slider.xml" url="examples/12-slider.xml">
<attr name="displayName" stringvalue="Slider Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="textfield.xml" url="examples/13-textfield.xml">
<attr name="displayName" stringvalue="Textfield Example"/>
<attr name="template" boolvalue="true"/>
</file>
<file name="window.xml" url="examples/14-window.xml">
<attr name="displayName" stringvalue="Window Example"/>
<attr name="template" boolvalue="true"/>
</file>
</folder>
</folder>
<folder name="NiftyGUIPalette">
<folder name="Basic">
<file name="Screen.xml" url="nbresloc:/com/jme3/gde/gui/palette/Screen.xml">
<attr name="position" intvalue="150"/>
</file>
</folder>
</folder>
</filesystem>

@ -8,7 +8,7 @@ import com.jme3.audio.AudioRenderer;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.core.scene.OffScenePanel;
import com.jme3.gde.core.scene.SceneApplication;
import com.jme3.gde.gui.NiftyGuiDataObject;
import com.jme3.gde.gui.OldNiftyGuiDataObject;
import com.jme3.renderer.ViewPort;
import de.lessvoid.nifty.Nifty;
import java.awt.Dimension;
@ -50,7 +50,7 @@ import org.xml.sax.SAXParseException;
*/
public class NiftyPreviewPanel extends PanelView implements ErrorHandler {
private NiftyGuiDataObject niftyObject;
private OldNiftyGuiDataObject niftyObject;
private OffScenePanel offPanel;
private Nifty nifty;
private Document doc;
@ -62,7 +62,7 @@ public class NiftyPreviewPanel extends PanelView implements ErrorHandler {
private int width = 640, height = 480;
private ErrorPanel errors;
public NiftyPreviewPanel(NiftyGuiDataObject niftyObject, ToolBarDesignEditor comp) {
public NiftyPreviewPanel(OldNiftyGuiDataObject niftyObject, ToolBarDesignEditor comp) {
super();
setRoot(Node.EMPTY);
this.niftyObject = niftyObject;

@ -5,7 +5,7 @@
package com.jme3.gde.gui.multiview;
import com.jme3.gde.gui.NiftyGuiDataObject;
import com.jme3.gde.gui.OldNiftyGuiDataObject;
import org.netbeans.modules.xml.multiview.ToolBarMultiViewElement;
import org.netbeans.modules.xml.multiview.ui.SectionView;
import org.netbeans.modules.xml.multiview.ui.ToolBarDesignEditor;
@ -20,7 +20,7 @@ public class PreviewToolbarElement extends ToolBarMultiViewElement {
private ToolBarDesignEditor comp;
private NiftyPreviewPanel viewPanel;
public PreviewToolbarElement(NiftyGuiDataObject dObj) {
public PreviewToolbarElement(OldNiftyGuiDataObject dObj) {
super(dObj);
// this.dObj = dObj;
comp = new ToolBarDesignEditor();

@ -4,7 +4,7 @@
*/
package com.jme3.gde.gui.multiview;
import com.jme3.gde.gui.NiftyGuiDataObject;
import com.jme3.gde.gui.OldNiftyGuiDataObject;
import org.netbeans.modules.xml.multiview.DesignMultiViewDesc;
/**
@ -15,13 +15,13 @@ public class PreviewView extends DesignMultiViewDesc {
private int type;
public PreviewView(NiftyGuiDataObject dObj, int type) {
public PreviewView(OldNiftyGuiDataObject dObj, int type) {
super(dObj, "Design");
this.type = type;
}
public org.netbeans.core.spi.multiview.MultiViewElement createElement() {
NiftyGuiDataObject dObj = (NiftyGuiDataObject) getDataObject();
OldNiftyGuiDataObject dObj = (OldNiftyGuiDataObject) getDataObject();
return new PreviewToolbarElement(dObj);
}

@ -0,0 +1,10 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
@TemplateRegistrations(value = {@TemplateRegistration(folder = "GUI", displayName = "Empty Gui",content = "EmptyNiftyGui.xml"),
@TemplateRegistration(folder = "GUI", displayName = "HelloJme",content = "NiftyGui.xml")})
package com.jme3.gde.gui;
import org.netbeans.api.templates.TemplateRegistration;
import org.netbeans.api.templates.TemplateRegistrations;
Loading…
Cancel
Save