I cleaned a bit the code creating some other packages and deleting old unused classesexperimental
parent
5033f7eb2d
commit
74c14377e2
Binary file not shown.
@ -1,28 +0,0 @@ |
|||||||
<?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="false"/> |
|
||||||
<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"/> |
|
||||||
</AuxValues> |
|
||||||
|
|
||||||
<Layout> |
|
||||||
<DimensionLayout dim="0"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<EmptySpace min="0" pref="244" max="32767" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
<DimensionLayout dim="1"> |
|
||||||
<Group type="103" groupAlignment="0" attributes="0"> |
|
||||||
<EmptySpace min="0" pref="274" max="32767" attributes="0"/> |
|
||||||
</Group> |
|
||||||
</DimensionLayout> |
|
||||||
</Layout> |
|
||||||
</Form> |
|
@ -1,29 +0,0 @@ |
|||||||
<?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> |
|
@ -1,89 +0,0 @@ |
|||||||
/* |
|
||||||
* 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,4 +0,0 @@ |
|||||||
|
|
||||||
PreviewPanel.jLabel1.text=jLabel1 |
|
||||||
ErrorPanel.jLabel1.text=jLabel1 |
|
||||||
ErrorPanel.jLabel2.text=\ Errors |
|
@ -1,62 +0,0 @@ |
|||||||
<?xml version="1.1" encoding="UTF-8" ?> |
|
||||||
|
|
||||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.PanelFormInfo"> |
|
||||||
<NonVisualComponents> |
|
||||||
<Component class="javax.swing.JLabel" name="jLabel1"> |
|
||||||
<Properties> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/gui/multiview/Bundle.properties" key="ErrorPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
</Component> |
|
||||||
</NonVisualComponents> |
|
||||||
<AuxValues> |
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> |
|
||||||
<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="false"/> |
|
||||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> |
|
||||||
<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,0,93,0,0,3,24"/> |
|
||||||
</AuxValues> |
|
||||||
|
|
||||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> |
|
||||||
<SubComponents> |
|
||||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1"> |
|
||||||
<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"/> |
|
||||||
<SubComponents> |
|
||||||
<Component class="javax.swing.JList" name="jList1"> |
|
||||||
<Properties> |
|
||||||
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
|
||||||
<Connection code="errors" type="code"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
</Component> |
|
||||||
</SubComponents> |
|
||||||
</Container> |
|
||||||
<Component class="javax.swing.JLabel" name="jLabel2"> |
|
||||||
<Properties> |
|
||||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> |
|
||||||
<Color blue="c8" green="c8" red="c8" type="rgb"/> |
|
||||||
</Property> |
|
||||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> |
|
||||||
<ResourceString bundle="com/jme3/gde/gui/multiview/Bundle.properties" key="ErrorPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
|
||||||
</Property> |
|
||||||
</Properties> |
|
||||||
<Constraints> |
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> |
|
||||||
<BorderConstraints direction="North"/> |
|
||||||
</Constraint> |
|
||||||
</Constraints> |
|
||||||
</Component> |
|
||||||
</SubComponents> |
|
||||||
</Form> |
|
@ -1,114 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
|
|
||||||
/* |
|
||||||
* ErrorPanel.java |
|
||||||
* |
|
||||||
* Created on 23 janv. 2012, 22:19:24 |
|
||||||
*/ |
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
import java.awt.Component; |
|
||||||
import javax.swing.DefaultListCellRenderer; |
|
||||||
import javax.swing.DefaultListModel; |
|
||||||
import javax.swing.ImageIcon; |
|
||||||
import javax.swing.JLabel; |
|
||||||
import javax.swing.JList; |
|
||||||
import javax.swing.SwingConstants; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author Nehon |
|
||||||
*/ |
|
||||||
public class ErrorPanel extends java.awt.Panel { |
|
||||||
|
|
||||||
private DefaultListModel errors = new DefaultListModel(); |
|
||||||
private static ImageIcon fatalImage = null, nonFatalImage = null; |
|
||||||
|
|
||||||
/** Creates new form ErrorPanel */ |
|
||||||
public ErrorPanel() { |
|
||||||
initComponents(); |
|
||||||
jList1.setCellRenderer(new DefaultListCellRenderer() { |
|
||||||
|
|
||||||
@Override |
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
||||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
||||||
if (value instanceof JLabel) { |
|
||||||
setIcon(((JLabel) value).getIcon()); |
|
||||||
setText(((JLabel) value).getText()); |
|
||||||
} |
|
||||||
return this; |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
private static ImageIcon getFatalErrorIcon() { |
|
||||||
if (fatalImage == null) { |
|
||||||
fatalImage = new ImageIcon(ErrorPanel.class.getResource("/com/jme3/gde/gui/multiview/icons/error.png")); //NOI18N
|
|
||||||
} |
|
||||||
return fatalImage; |
|
||||||
} |
|
||||||
|
|
||||||
private static ImageIcon getNonfatalErrorIcon() { |
|
||||||
if (nonFatalImage == null) { |
|
||||||
nonFatalImage = new ImageIcon(ErrorPanel.class.getResource("/com/jme3/gde/gui/multiview/icons/warning.png")); //NOI18N
|
|
||||||
} |
|
||||||
return nonFatalImage; |
|
||||||
} |
|
||||||
|
|
||||||
public void addError(String error) { |
|
||||||
errors.addElement(new JLabel( |
|
||||||
error, |
|
||||||
getFatalErrorIcon(), |
|
||||||
SwingConstants.LEFT)); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void addWarning(String error) { |
|
||||||
errors.addElement(new JLabel( |
|
||||||
error, |
|
||||||
getNonfatalErrorIcon(), |
|
||||||
SwingConstants.LEFT)); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void clear(){ |
|
||||||
errors.clear(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** 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() { |
|
||||||
|
|
||||||
jLabel1 = new javax.swing.JLabel(); |
|
||||||
jScrollPane1 = new javax.swing.JScrollPane(); |
|
||||||
jList1 = new javax.swing.JList(); |
|
||||||
jLabel2 = new javax.swing.JLabel(); |
|
||||||
|
|
||||||
jLabel1.setText(org.openide.util.NbBundle.getMessage(ErrorPanel.class, "ErrorPanel.jLabel1.text")); // NOI18N
|
|
||||||
|
|
||||||
setLayout(new java.awt.BorderLayout()); |
|
||||||
|
|
||||||
jList1.setModel(errors); |
|
||||||
jScrollPane1.setViewportView(jList1); |
|
||||||
|
|
||||||
add(jScrollPane1, java.awt.BorderLayout.CENTER); |
|
||||||
|
|
||||||
jLabel2.setBackground(new java.awt.Color(200, 200, 200)); |
|
||||||
jLabel2.setText(org.openide.util.NbBundle.getMessage(ErrorPanel.class, "ErrorPanel.jLabel2.text")); // NOI18N
|
|
||||||
add(jLabel2, java.awt.BorderLayout.NORTH); |
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
||||||
private javax.swing.JLabel jLabel1; |
|
||||||
private javax.swing.JLabel jLabel2; |
|
||||||
private javax.swing.JList jList1; |
|
||||||
private javax.swing.JScrollPane jScrollPane1; |
|
||||||
// End of variables declaration//GEN-END:variables
|
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
|
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class MouseInputEvent { |
|
||||||
int x; |
|
||||||
int y; |
|
||||||
int button; |
|
||||||
int huh; |
|
||||||
boolean pressed; |
|
||||||
|
|
||||||
public MouseInputEvent(int x, int y, int button, int huh, boolean pressed) { |
|
||||||
this.x = x; |
|
||||||
this.y = y; |
|
||||||
this.button = button; |
|
||||||
this.huh = huh; |
|
||||||
this.pressed = pressed; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,55 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
import java.util.LinkedList; |
|
||||||
import java.util.List; |
|
||||||
import org.openide.nodes.Children; |
|
||||||
import org.openide.nodes.Node; |
|
||||||
import org.w3c.dom.Element; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class NiftyFileChildren extends Children.Keys<Element> { |
|
||||||
|
|
||||||
Element xmlNode; |
|
||||||
|
|
||||||
public NiftyFileChildren(Element xmlNode) { |
|
||||||
this.xmlNode = xmlNode; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void addNotify() { |
|
||||||
super.addNotify(); |
|
||||||
setKeys(createKeys()); |
|
||||||
} |
|
||||||
|
|
||||||
protected List<Element> createKeys() { |
|
||||||
LinkedList<Element> ret = new LinkedList<Element>(); |
|
||||||
Element curElement = XmlHelper.findFirstChildElement(xmlNode); |
|
||||||
while (curElement != null) { |
|
||||||
if (checkElement(curElement)) { |
|
||||||
ret.add(curElement); |
|
||||||
} |
|
||||||
curElement = XmlHelper.findNextSiblingElement(curElement); |
|
||||||
} |
|
||||||
|
|
||||||
return ret; |
|
||||||
} |
|
||||||
|
|
||||||
private boolean checkElement(Element curElement) { |
|
||||||
if (!"screen".equals(curElement.getTagName())) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected Node[] createNodes(Element key) { |
|
||||||
return new Node[]{new NiftyScreenNode(key.getAttribute("id"))}; |
|
||||||
} |
|
||||||
} |
|
@ -1,22 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
|
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
import org.openide.nodes.AbstractNode; |
|
||||||
import org.w3c.dom.Element; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class NiftyFileNode extends AbstractNode{ |
|
||||||
|
|
||||||
public NiftyFileNode(Element xmlNode) { |
|
||||||
super(new NiftyFileChildren(xmlNode)); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -1,167 +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.gui.multiview; |
|
||||||
|
|
||||||
import com.jme3.asset.AssetInfo; |
|
||||||
import com.jme3.asset.AssetKey; |
|
||||||
import com.jme3.asset.AssetManager; |
|
||||||
import com.jme3.asset.AssetNotFoundException; |
|
||||||
import com.jme3.asset.DesktopAssetManager; |
|
||||||
import com.jme3.audio.AudioRenderer; |
|
||||||
import com.jme3.niftygui.RenderDeviceJme; |
|
||||||
import com.jme3.niftygui.SoundDeviceJme; |
|
||||||
import com.jme3.post.SceneProcessor; |
|
||||||
import com.jme3.renderer.RenderManager; |
|
||||||
import com.jme3.renderer.Renderer; |
|
||||||
import com.jme3.renderer.ViewPort; |
|
||||||
import com.jme3.renderer.queue.RenderQueue; |
|
||||||
import com.jme3.texture.FrameBuffer; |
|
||||||
import de.lessvoid.nifty.Nifty; |
|
||||||
import de.lessvoid.nifty.spi.input.InputSystem; |
|
||||||
import de.lessvoid.nifty.tools.TimeProvider; |
|
||||||
import de.lessvoid.nifty.tools.resourceloader.ResourceLocation; |
|
||||||
import java.io.InputStream; |
|
||||||
import java.net.URL; |
|
||||||
|
|
||||||
public class NiftyJmeDisplay extends com.jme3.niftygui.NiftyJmeDisplay implements SceneProcessor { |
|
||||||
|
|
||||||
protected class ResourceLocationJmp implements ResourceLocation { |
|
||||||
|
|
||||||
public InputStream getResourceAsStream(String path) { |
|
||||||
AssetKey<Object> key = new AssetKey<Object>(path); |
|
||||||
AssetInfo info = assetManager.locateAsset(key); |
|
||||||
if (info != null){ |
|
||||||
return info.openStream(); |
|
||||||
}else{ |
|
||||||
throw new AssetNotFoundException(path); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public URL getResource(String path) { |
|
||||||
throw new UnsupportedOperationException(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private ResourceLocation resourceLocation = new ResourceLocationJmp(); |
|
||||||
|
|
||||||
public NiftyJmeDisplay(AssetManager assetManager, |
|
||||||
InputSystem inputManager, |
|
||||||
AudioRenderer audioRenderer, |
|
||||||
ViewPort vp){ |
|
||||||
this.assetManager = assetManager; |
|
||||||
//TODO: move
|
|
||||||
((DesktopAssetManager)assetManager).clearCache(); |
|
||||||
w = vp.getCamera().getWidth(); |
|
||||||
h = vp.getCamera().getHeight(); |
|
||||||
|
|
||||||
soundDev = new SoundDeviceJme(assetManager, audioRenderer); |
|
||||||
renderDev = new RenderDeviceJme(this); |
|
||||||
nifty = new Nifty(renderDev, soundDev, inputManager, new TimeProvider()); |
|
||||||
nifty.getResourceLoader().addResourceLocation(resourceLocation); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void initialize(RenderManager rm, ViewPort vp) { |
|
||||||
this.renderManager = rm; |
|
||||||
renderDev.setRenderManager(rm); |
|
||||||
inited = true; |
|
||||||
this.vp = vp; |
|
||||||
this.renderer = rm.getRenderer(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public Nifty getNifty() { |
|
||||||
return nifty; |
|
||||||
} |
|
||||||
|
|
||||||
RenderDeviceJme getRenderDevice() { |
|
||||||
return renderDev; |
|
||||||
} |
|
||||||
|
|
||||||
AssetManager getAssetManager() { |
|
||||||
return assetManager; |
|
||||||
} |
|
||||||
|
|
||||||
RenderManager getRenderManager() { |
|
||||||
return renderManager; |
|
||||||
} |
|
||||||
|
|
||||||
int getHeight() { |
|
||||||
return h; |
|
||||||
} |
|
||||||
|
|
||||||
int getWidth() { |
|
||||||
return w; |
|
||||||
} |
|
||||||
|
|
||||||
Renderer getRenderer(){ |
|
||||||
return renderer; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void reshape(ViewPort vp, int w, int h) { |
|
||||||
this.w = w; |
|
||||||
this.h = h; |
|
||||||
nifty.resolutionChanged(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public boolean isInitialized() { |
|
||||||
return inited; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void preFrame(float tpf) { |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void postQueue(RenderQueue rq) { |
|
||||||
// render nifty before anything else
|
|
||||||
renderManager.setCamera(vp.getCamera(), true); |
|
||||||
nifty.render(false); |
|
||||||
renderManager.setCamera(vp.getCamera(), false); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void postFrame(FrameBuffer out) { |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void cleanup() { |
|
||||||
nifty.getResourceLoader().removeResourceLocation(resourceLocation); |
|
||||||
inited = false; |
|
||||||
// nifty.exit();
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,53 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
import de.lessvoid.nifty.NiftyInputConsumer; |
|
||||||
import de.lessvoid.nifty.input.keyboard.KeyboardInputEvent; |
|
||||||
import de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.LinkedList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class NiftyPreviewInputHandler implements de.lessvoid.nifty.spi.input.InputSystem { |
|
||||||
|
|
||||||
private List<MouseInputEvent> mouseEvents = new LinkedList<MouseInputEvent>(); |
|
||||||
private List<KeyboardInputEvent> keyEvents = new LinkedList<KeyboardInputEvent>(); |
|
||||||
|
|
||||||
public synchronized void forwardEvents(NiftyInputConsumer nic) { |
|
||||||
for (Iterator<MouseInputEvent> it = mouseEvents.iterator(); it.hasNext();) { |
|
||||||
MouseInputEvent mouseInputEvent = it.next(); |
|
||||||
nic.processMouseEvent(mouseInputEvent.x, mouseInputEvent.y, mouseInputEvent.button, mouseInputEvent.huh, mouseInputEvent.pressed); |
|
||||||
it.remove(); |
|
||||||
} |
|
||||||
for (Iterator<KeyboardInputEvent> it = keyEvents.iterator(); it.hasNext();) { |
|
||||||
KeyboardInputEvent keyInputEvent = it.next(); |
|
||||||
nic.processKeyboardEvent(keyInputEvent); |
|
||||||
it.remove(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public synchronized void addMouseEvent(int newMouseX, int newMouseY, boolean mouseDown) { |
|
||||||
MouseInputEvent event = new MouseInputEvent(newMouseX, newMouseY, 0, 0, mouseDown); |
|
||||||
mouseEvents.add(event); |
|
||||||
} |
|
||||||
|
|
||||||
public synchronized void addKeyEvent(int newKey, char newCharacter, boolean newKeyDown, boolean newShiftDown, boolean newControlDown) { |
|
||||||
KeyboardInputEvent event = new KeyboardInputEvent(newKey, newCharacter, newKeyDown, newShiftDown, newControlDown); |
|
||||||
keyEvents.add(event); |
|
||||||
} |
|
||||||
|
|
||||||
public void setMousePosition(int i, int i1) { |
|
||||||
// throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
} |
|
||||||
|
|
||||||
public void setResourceLoader(NiftyResourceLoader nrl) { |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,335 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
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.OldNiftyGuiDataObject; |
|
||||||
import com.jme3.renderer.ViewPort; |
|
||||||
import de.lessvoid.nifty.Nifty; |
|
||||||
import java.awt.Dimension; |
|
||||||
import java.awt.event.ItemEvent; |
|
||||||
import java.awt.event.ItemListener; |
|
||||||
import java.awt.event.KeyEvent; |
|
||||||
import java.awt.event.KeyListener; |
|
||||||
import java.awt.event.MouseEvent; |
|
||||||
import java.awt.event.MouseListener; |
|
||||||
import java.awt.event.MouseMotionListener; |
|
||||||
import java.io.IOException; |
|
||||||
import java.io.InputStream; |
|
||||||
import java.util.Collection; |
|
||||||
import java.util.Iterator; |
|
||||||
import java.util.concurrent.Callable; |
|
||||||
import java.util.logging.Level; |
|
||||||
import java.util.logging.Logger; |
|
||||||
import javax.swing.JComboBox; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import javax.swing.JScrollPane; |
|
||||||
import javax.swing.JToolBar; |
|
||||||
import org.netbeans.modules.xml.multiview.Error; |
|
||||||
import org.netbeans.modules.xml.multiview.ui.PanelView; |
|
||||||
import org.netbeans.modules.xml.multiview.ui.ToolBarDesignEditor; |
|
||||||
import org.openide.NotifyDescriptor; |
|
||||||
import org.openide.NotifyDescriptor.Message; |
|
||||||
import org.openide.nodes.Node; |
|
||||||
import org.openide.util.Exceptions; |
|
||||||
import org.openide.xml.XMLUtil; |
|
||||||
import org.w3c.dom.Document; |
|
||||||
import org.xml.sax.ErrorHandler; |
|
||||||
import org.xml.sax.InputSource; |
|
||||||
import org.xml.sax.SAXException; |
|
||||||
import org.xml.sax.SAXParseException; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class NiftyPreviewPanel extends PanelView implements ErrorHandler { |
|
||||||
|
|
||||||
private OldNiftyGuiDataObject niftyObject; |
|
||||||
private OffScenePanel offPanel; |
|
||||||
private Nifty nifty; |
|
||||||
private Document doc; |
|
||||||
private ToolBarDesignEditor comp; |
|
||||||
private String screen = ""; |
|
||||||
private NiftyPreviewInputHandler inputHandler; |
|
||||||
private NiftyJmeDisplay niftyDisplay; |
|
||||||
private JScrollPane scrollPanel; |
|
||||||
private int width = 640, height = 480; |
|
||||||
private ErrorPanel errors; |
|
||||||
|
|
||||||
public NiftyPreviewPanel(OldNiftyGuiDataObject niftyObject, ToolBarDesignEditor comp) { |
|
||||||
super(); |
|
||||||
setRoot(Node.EMPTY); |
|
||||||
this.niftyObject = niftyObject; |
|
||||||
this.comp = comp; |
|
||||||
comp.setContentView(this); |
|
||||||
preparePreview(); |
|
||||||
updatePreView(); |
|
||||||
} |
|
||||||
|
|
||||||
private void createToolbar() { |
|
||||||
JToolBar toolBar = new JToolBar(); |
|
||||||
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)) { |
|
||||||
width = 640; |
|
||||||
height = 480; |
|
||||||
} else if ("1024x768".equals(string)) { |
|
||||||
width = 1024; |
|
||||||
height = 768; |
|
||||||
} else if ("1280x720".equals(string)) { |
|
||||||
width = 1280; |
|
||||||
height = 720; |
|
||||||
} else if ("800x600".equals(string)) { |
|
||||||
width = 800; |
|
||||||
height = 600; |
|
||||||
} else if ("800x480".equals(string)) { |
|
||||||
width = 800; |
|
||||||
height = 480; |
|
||||||
} else if ("480x800".equals(string)) { |
|
||||||
width = 480; |
|
||||||
height = 800; |
|
||||||
} else { |
|
||||||
width = 640; |
|
||||||
height = 480; |
|
||||||
} |
|
||||||
offPanel.resizeGLView(width, height); |
|
||||||
|
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() { |
|
||||||
|
|
||||||
public Object call() throws Exception { |
|
||||||
niftyDisplay.reshape(offPanel.getViewPort(), width, height); |
|
||||||
return null; |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
// updatePreView();
|
|
||||||
} |
|
||||||
}); |
|
||||||
toolBar.add(comboBox); |
|
||||||
toolBar.add(new JPanel()); |
|
||||||
setLayout(new java.awt.BorderLayout()); |
|
||||||
add(toolBar, java.awt.BorderLayout.NORTH); |
|
||||||
errors = new ErrorPanel(); |
|
||||||
errors.setPreferredSize(new Dimension(0, 80)); |
|
||||||
|
|
||||||
|
|
||||||
add(errors, java.awt.BorderLayout.SOUTH); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public void updatePreView() { |
|
||||||
updatePreView(screen); |
|
||||||
} |
|
||||||
|
|
||||||
public void updatePreView(final String screen) { |
|
||||||
errors.clear(); |
|
||||||
final ProjectAssetManager pm = niftyObject.getLookup().lookup(ProjectAssetManager.class); |
|
||||||
if (pm == null) { |
|
||||||
Logger.getLogger(NiftyPreviewPanel.class.getName()).log(Level.WARNING, "No Project AssetManager found!"); |
|
||||||
} |
|
||||||
InputStream stream = null; |
|
||||||
try { |
|
||||||
stream = niftyObject.getPrimaryFile().getInputStream(); |
|
||||||
doc = XMLUtil.parse(new InputSource(stream), false, false, this, null); |
|
||||||
NiftyFileNode rootContext = new NiftyFileNode(doc.getDocumentElement()); |
|
||||||
setRoot(rootContext); |
|
||||||
comp.setRootContext(rootContext); |
|
||||||
} catch (Exception ex) { |
|
||||||
// Message msg = new NotifyDescriptor.Message(
|
|
||||||
// "Error parsing File:" + ex,
|
|
||||||
// NotifyDescriptor.ERROR_MESSAGE);
|
|
||||||
// DialogDisplayer.getDefault().notifyLater(msg);
|
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
// return;
|
|
||||||
} finally { |
|
||||||
try { |
|
||||||
if (stream != null) { |
|
||||||
stream.close(); |
|
||||||
} |
|
||||||
} catch (IOException ex) { |
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
} |
|
||||||
} |
|
||||||
try { |
|
||||||
|
|
||||||
if (nifty != null) { |
|
||||||
nifty.validateXml(niftyObject.getPrimaryFile().getPath()); |
|
||||||
|
|
||||||
} |
|
||||||
} catch (Exception e) { |
|
||||||
if (e instanceof SAXParseException) { |
|
||||||
SAXParseException spe = (SAXParseException) e; |
|
||||||
errors.addError("Line " + spe.getLineNumber() + " col :" + spe.getColumnNumber() + " : " + spe.getMessage()); |
|
||||||
} else { |
|
||||||
errors.addError(e.getMessage()); |
|
||||||
} |
|
||||||
Exceptions.printStackTrace(e); |
|
||||||
} |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() { |
|
||||||
|
|
||||||
public Object call() throws Exception { |
|
||||||
|
|
||||||
try { |
|
||||||
nifty.fromXml(pm.getRelativeAssetPath(niftyObject.getPrimaryFile().getPath()), screen); |
|
||||||
if (screen == null || screen.length() == 0) { |
|
||||||
Collection<String> screens = nifty.getAllScreensName(); |
|
||||||
for (Iterator<String> it = screens.iterator(); it.hasNext();) { |
|
||||||
String string = it.next(); |
|
||||||
nifty.gotoScreen(string); |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} catch (Exception ex) { |
|
||||||
Message msg = new NotifyDescriptor.Message( |
|
||||||
"Error opening File:" + ex, |
|
||||||
NotifyDescriptor.ERROR_MESSAGE); |
|
||||||
// DialogDisplayer.getDefault().notifyLater(msg);
|
|
||||||
Exceptions.printStackTrace(ex); |
|
||||||
errors.addError(ex.getMessage()); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
}); |
|
||||||
// java.awt.EventQueue.invokeLater(new Runnable() {
|
|
||||||
//
|
|
||||||
// public void run() {
|
|
||||||
// validateTree();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void initComponents() { |
|
||||||
super.initComponents(); |
|
||||||
setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); |
|
||||||
createToolbar(); |
|
||||||
scrollPanel = new JScrollPane(); |
|
||||||
offPanel = new OffScenePanel(640, 480); |
|
||||||
scrollPanel.getViewport().add(offPanel); |
|
||||||
add(scrollPanel); |
|
||||||
offPanel.startPreview(); |
|
||||||
prepareInputHandler(); |
|
||||||
} |
|
||||||
|
|
||||||
private void prepareInputHandler() { |
|
||||||
inputHandler = new NiftyPreviewInputHandler(); |
|
||||||
offPanel.addMouseMotionListener(new MouseMotionListener() { |
|
||||||
|
|
||||||
public void mouseDragged(MouseEvent e) { |
|
||||||
inputHandler.addMouseEvent(e.getX(), e.getY(), e.getButton() == MouseEvent.NOBUTTON ? false : true); |
|
||||||
} |
|
||||||
|
|
||||||
public void mouseMoved(MouseEvent e) { |
|
||||||
inputHandler.addMouseEvent(e.getX(), e.getY(), e.getButton() == MouseEvent.NOBUTTON ? false : true); |
|
||||||
} |
|
||||||
}); |
|
||||||
offPanel.addMouseListener(new MouseListener() { |
|
||||||
|
|
||||||
public void mouseClicked(MouseEvent e) { |
|
||||||
} |
|
||||||
|
|
||||||
public void mousePressed(MouseEvent e) { |
|
||||||
inputHandler.addMouseEvent(e.getX(), e.getY(), e.getButton() == MouseEvent.NOBUTTON ? false : true); |
|
||||||
} |
|
||||||
|
|
||||||
public void mouseReleased(MouseEvent e) { |
|
||||||
} |
|
||||||
|
|
||||||
public void mouseEntered(MouseEvent e) { |
|
||||||
} |
|
||||||
|
|
||||||
public void mouseExited(MouseEvent e) { |
|
||||||
} |
|
||||||
}); |
|
||||||
offPanel.addKeyListener(new KeyListener() { |
|
||||||
|
|
||||||
public void keyTyped(KeyEvent e) { |
|
||||||
} |
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e) { |
|
||||||
inputHandler.addKeyEvent(e.getKeyCode(), e.getKeyChar(), true, e.isShiftDown(), e.isControlDown()); |
|
||||||
} |
|
||||||
|
|
||||||
public void keyReleased(KeyEvent e) { |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
private void preparePreview() { |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() { |
|
||||||
|
|
||||||
public Object call() throws Exception { |
|
||||||
ViewPort guiViewPort = offPanel.getViewPort(); |
|
||||||
ProjectAssetManager pm = niftyObject.getLookup().lookup(ProjectAssetManager.class); |
|
||||||
if (pm == null) { |
|
||||||
Logger.getLogger(NiftyPreviewPanel.class.getName()).log(Level.WARNING, "No Project AssetManager found!"); |
|
||||||
return null; |
|
||||||
} |
|
||||||
AudioRenderer audioRenderer = SceneApplication.getApplication().getAudioRenderer(); |
|
||||||
niftyDisplay = new NiftyJmeDisplay(pm, |
|
||||||
inputHandler, |
|
||||||
audioRenderer, |
|
||||||
guiViewPort); |
|
||||||
nifty = niftyDisplay.getNifty(); |
|
||||||
|
|
||||||
// attach the nifty display to the gui view port as a processor
|
|
||||||
guiViewPort.addProcessor(niftyDisplay); |
|
||||||
return null; |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected Error validateView() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void showSelection(Node[] nodes) { |
|
||||||
this.screen = nodes[0].getName(); |
|
||||||
final String screen = this.screen; |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() { |
|
||||||
|
|
||||||
public Object call() throws Exception { |
|
||||||
nifty.gotoScreen(screen); |
|
||||||
return null; |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
public void cleanup() { |
|
||||||
offPanel.stopPreview(); |
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() { |
|
||||||
|
|
||||||
public Object call() throws Exception { |
|
||||||
ViewPort guiViewPort = offPanel.getViewPort(); |
|
||||||
guiViewPort.removeProcessor(niftyDisplay); |
|
||||||
return null; |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
public void warning(SAXParseException exception) throws SAXException { |
|
||||||
//errors.addWarning("Line " + exception.getLineNumber() + " : " + exception.getMessage());
|
|
||||||
} |
|
||||||
|
|
||||||
public void error(SAXParseException exception) throws SAXException { |
|
||||||
//errors.addError("Line " + exception.getLineNumber() + " : " + exception.getMessage());
|
|
||||||
} |
|
||||||
|
|
||||||
public void fatalError(SAXParseException exception) throws SAXException { |
|
||||||
//errors.addError("Line " + exception.getLineNumber() + " : " + exception.getMessage());
|
|
||||||
} |
|
||||||
} |
|
@ -1,22 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
|
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
import org.openide.nodes.AbstractNode; |
|
||||||
import org.openide.nodes.Children; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class NiftyScreenNode extends AbstractNode{ |
|
||||||
|
|
||||||
public NiftyScreenNode(String name) { |
|
||||||
super(Children.LEAF); |
|
||||||
setName(name); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,48 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
|
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
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; |
|
||||||
import org.openide.nodes.Node; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class PreviewToolbarElement extends ToolBarMultiViewElement { |
|
||||||
// private NiftyGuiDataObject dObj;
|
|
||||||
private ToolBarDesignEditor comp; |
|
||||||
private NiftyPreviewPanel viewPanel; |
|
||||||
|
|
||||||
public PreviewToolbarElement(OldNiftyGuiDataObject dObj) { |
|
||||||
super(dObj); |
|
||||||
// this.dObj = dObj;
|
|
||||||
comp = new ToolBarDesignEditor(); |
|
||||||
setVisualEditor(comp); |
|
||||||
viewPanel=new NiftyPreviewPanel(dObj, comp); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public SectionView getSectionView() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void componentShowing() { |
|
||||||
super.componentShowing(); |
|
||||||
viewPanel.updatePreView(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void componentClosed() { |
|
||||||
super.componentClosed(); |
|
||||||
viewPanel.cleanup(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,35 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
import com.jme3.gde.gui.OldNiftyGuiDataObject; |
|
||||||
import org.netbeans.modules.xml.multiview.DesignMultiViewDesc; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class PreviewView extends DesignMultiViewDesc { |
|
||||||
|
|
||||||
private int type; |
|
||||||
|
|
||||||
public PreviewView(OldNiftyGuiDataObject dObj, int type) { |
|
||||||
super(dObj, "Design"); |
|
||||||
this.type = type; |
|
||||||
} |
|
||||||
|
|
||||||
public org.netbeans.core.spi.multiview.MultiViewElement createElement() { |
|
||||||
OldNiftyGuiDataObject dObj = (OldNiftyGuiDataObject) getDataObject(); |
|
||||||
return new PreviewToolbarElement(dObj); |
|
||||||
} |
|
||||||
|
|
||||||
public java.awt.Image getIcon() { |
|
||||||
return org.openide.util.Utilities.loadImage("com/jme3/gde/gui/Computer_File_043.gif"); //NOI18N
|
|
||||||
} |
|
||||||
|
|
||||||
public String preferredID() { |
|
||||||
return "Toc_multiview_design" + String.valueOf(type); |
|
||||||
} |
|
||||||
} |
|
@ -1,73 +0,0 @@ |
|||||||
/* |
|
||||||
* To change this template, choose Tools | Templates |
|
||||||
* and open the template in the editor. |
|
||||||
*/ |
|
||||||
|
|
||||||
package com.jme3.gde.gui.multiview; |
|
||||||
|
|
||||||
import org.w3c.dom.Element; |
|
||||||
import org.w3c.dom.Node; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen |
|
||||||
*/ |
|
||||||
public class XmlHelper { |
|
||||||
public static Element findFirstChildElement(Element parent) { |
|
||||||
org.w3c.dom.Node ret = parent.getFirstChild(); |
|
||||||
while (ret != null && (!(ret instanceof Element))) { |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
} |
|
||||||
return (Element) ret; |
|
||||||
} |
|
||||||
|
|
||||||
public static Element findChildElement(Element parent, String name) { |
|
||||||
if (parent == null) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
org.w3c.dom.Node ret = parent.getFirstChild(); |
|
||||||
while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) { |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
} |
|
||||||
return (Element) ret; |
|
||||||
} |
|
||||||
|
|
||||||
public static Element findNextElement(Node ret, String name) { |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) { |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
} |
|
||||||
return (Element) ret; |
|
||||||
} |
|
||||||
|
|
||||||
public static Element findChildElementWithAttribute(Element parent, String name, String attribute, String value) { |
|
||||||
if (parent == null) { |
|
||||||
return null; |
|
||||||
} |
|
||||||
org.w3c.dom.Node ret = parent.getFirstChild(); |
|
||||||
while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name) || ((Element)ret).getAttribute(attribute)==null || !((Element)ret).getAttribute(attribute).equals(value))) { |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
} |
|
||||||
return (Element) ret; |
|
||||||
} |
|
||||||
|
|
||||||
public static Element findNextElementWithAttribute(Node ret, String name, String attribute, String value) { |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name) || ((Element)ret).getAttribute(attribute)==null || !((Element)ret).getAttribute(attribute).equals(value))) { |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
} |
|
||||||
return (Element) ret; |
|
||||||
} |
|
||||||
|
|
||||||
public static Element findNextSiblingElement(Element current) { |
|
||||||
org.w3c.dom.Node ret = current.getNextSibling(); |
|
||||||
while (ret != null) { |
|
||||||
if (ret instanceof Element) { |
|
||||||
return (Element) ret; |
|
||||||
} |
|
||||||
ret = ret.getNextSibling(); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
After Width: | Height: | Size: 386 B |
@ -1,88 +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.gui.palette; |
|
||||||
|
|
||||||
import javax.swing.text.BadLocationException; |
|
||||||
import javax.swing.text.Caret; |
|
||||||
import javax.swing.text.Document; |
|
||||||
import javax.swing.text.JTextComponent; |
|
||||||
import javax.swing.text.StyledDocument; |
|
||||||
import org.openide.text.NbDocument; |
|
||||||
|
|
||||||
public class JmePaletteUtilities { |
|
||||||
|
|
||||||
public static void insert(final String s,final JTextComponent target) throws BadLocationException { |
|
||||||
|
|
||||||
final StyledDocument doc = (StyledDocument)target.getDocument(); |
|
||||||
|
|
||||||
class AtomicChange implements Runnable { |
|
||||||
|
|
||||||
public void run() { |
|
||||||
Document value = target.getDocument(); |
|
||||||
if (value == null) |
|
||||||
return; |
|
||||||
try { |
|
||||||
insert(s, target, doc); |
|
||||||
} catch (BadLocationException e) {} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
try { |
|
||||||
NbDocument.runAtomicAsUser(doc, new AtomicChange()); |
|
||||||
} catch (BadLocationException ex) {} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
private static int insert(String s, JTextComponent target, Document doc) throws BadLocationException { |
|
||||||
|
|
||||||
int start = -1; |
|
||||||
|
|
||||||
try { |
|
||||||
|
|
||||||
//firstly, find selected text range:
|
|
||||||
Caret caret = target.getCaret(); |
|
||||||
int p0 = Math.min(caret.getDot(), caret.getMark()); |
|
||||||
int p1 = Math.max(caret.getDot(), caret.getMark()); |
|
||||||
doc.remove(p0, p1 - p0); |
|
||||||
|
|
||||||
//then, replace selected text range with the inserted one:
|
|
||||||
start = caret.getDot(); |
|
||||||
doc.insertString(start, s, null); |
|
||||||
|
|
||||||
} catch (BadLocationException ble) {} |
|
||||||
|
|
||||||
return start; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,63 +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.gui.palette; |
|
||||||
import javax.swing.text.BadLocationException; |
|
||||||
import javax.swing.text.JTextComponent; |
|
||||||
import org.openide.text.ActiveEditorDrop; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* @author normenhansen, zathras |
|
||||||
*/ |
|
||||||
public class Screen implements ActiveEditorDrop { |
|
||||||
|
|
||||||
public Screen() { |
|
||||||
} |
|
||||||
|
|
||||||
private String createBody() { |
|
||||||
|
|
||||||
String body = "<screen></screen>"; |
|
||||||
return body; |
|
||||||
} |
|
||||||
|
|
||||||
public boolean handleTransfer(JTextComponent targetComponent) { |
|
||||||
String body = createBody(); |
|
||||||
try { |
|
||||||
JmePaletteUtilities.insert(body, targetComponent); |
|
||||||
} catch (BadLocationException ble) { |
|
||||||
return false; |
|
||||||
} |
|
||||||
return true; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,16 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<!DOCTYPE editor_palette_item PUBLIC "-//NetBeans//Editor Palette Item 1.1//EN" |
|
||||||
"http://www.netbeans.org/dtds/editor-palette-item-1_1.dtd"> |
|
||||||
|
|
||||||
<editor_palette_item version="1.0"> |
|
||||||
|
|
||||||
<class name="com.jme3.gde.gui.palette.Screen" /> |
|
||||||
|
|
||||||
<icon16 urlvalue="com/jme3/gde/core/sceneviewer/jme-logo.png" /> |
|
||||||
<icon32 urlvalue="com/jme3/gde/core/sceneviewer/jme-logo.png" /> |
|
||||||
|
|
||||||
<inline-description> |
|
||||||
<display-name>Screen</display-name> |
|
||||||
<tooltip>Nifty-gui Screen</tooltip> |
|
||||||
</inline-description> |
|
||||||
</editor_palette_item> |
|
@ -0,0 +1,10 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<nifty xmlns="http://nifty-gui.lessvoid.com/nifty-gui" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd"> |
||||||
|
<!-- +++++++++++++++++++++++++++++++++++++++ --> |
||||||
|
<!-- start screen --> |
||||||
|
<!-- +++++++++++++++++++++++++++++++++++++++ --> |
||||||
|
<screen id="GScreen0" controller="mygame.Main"> |
||||||
|
<layer id="GLayer0" childLayout="absolute"> |
||||||
|
</layer> |
||||||
|
</screen> |
||||||
|
</nifty> |
@ -0,0 +1,19 @@ |
|||||||
|
<?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="start" controller="mygame.Main"> |
||||||
|
<layer id="layer" backgroundColor="#003f" childLayout="center"> |
||||||
|
<panel id="panel" height="25%" width="35%" align="center" valign="center" backgroundColor="#f60f" childLayout="center" visibleToMouse="true"> |
||||||
|
<interact onClick="quit()"/> |
||||||
|
<effect> |
||||||
|
<onStartScreen name="move" mode="in" direction="top" length="300" startDelay="0" inherit="true"/> |
||||||
|
<onEndScreen name="move" mode="out" direction="bottom" length="300" startDelay="0" inherit="true"/> |
||||||
|
<onHover name="pulsate" scaleFactor="0.008" startColor="#f600" endColor="#ffff" post="true"/> |
||||||
|
</effect> |
||||||
|
<text id="text" font="aurulent-sans-17.fnt" color="#000f" text="Hello World!" align="center" valign="center" /> |
||||||
|
</panel> |
||||||
|
</layer> |
||||||
|
</screen> |
||||||
|
</nifty> |
@ -0,0 +1,200 @@ |
|||||||
|
/* |
||||||
|
* To change this template, choose Tools | Templates |
||||||
|
* and open the template in the editor. |
||||||
|
*/ |
||||||
|
package com.jme3.gde.gui.view; |
||||||
|
|
||||||
|
import com.jme3.gde.gui.nodes.GElementNode; |
||||||
|
import com.jme3.gde.gui.nodes.GUINode; |
||||||
|
import jada.ngeditor.controller.CommandProcessor; |
||||||
|
import jada.ngeditor.controller.GUIEditor; |
||||||
|
import jada.ngeditor.controller.commands.SelectCommand; |
||||||
|
import jada.ngeditor.listeners.events.SelectionChanged; |
||||||
|
import jada.ngeditor.model.GUI; |
||||||
|
import jada.ngeditor.model.GuiEditorModel; |
||||||
|
import jada.ngeditor.model.elements.GElement; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.beans.PropertyChangeEvent; |
||||||
|
import java.beans.PropertyChangeListener; |
||||||
|
import java.beans.PropertyVetoException; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Observable; |
||||||
|
import java.util.Observer; |
||||||
|
import javax.swing.JComponent; |
||||||
|
import org.netbeans.spi.navigator.NavigatorPanel; |
||||||
|
import org.openide.explorer.ExplorerManager; |
||||||
|
import org.openide.explorer.ExplorerUtils; |
||||||
|
import org.openide.explorer.view.BeanTreeView; |
||||||
|
import org.openide.nodes.AbstractNode; |
||||||
|
import org.openide.nodes.Node; |
||||||
|
import org.openide.util.Exceptions; |
||||||
|
import org.openide.util.Lookup; |
||||||
|
import org.openide.util.lookup.ProxyLookup; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author cris |
||||||
|
*/ |
||||||
|
@NavigatorPanel.Registration(mimeType = "text/x-niftygui+xml", displayName="Gui View") |
||||||
|
public class Navigator extends javax.swing.JPanel implements NavigatorPanel,ExplorerManager.Provider , Observer, PropertyChangeListener{ |
||||||
|
private Lookup lookup; |
||||||
|
private ExplorerManager mgr = new ExplorerManager(); |
||||||
|
private final BeanTreeView beanTreeView; |
||||||
|
/** |
||||||
|
* Creates new form Navigator |
||||||
|
*/ |
||||||
|
public Navigator() { |
||||||
|
initComponents(); |
||||||
|
setLayout(new BorderLayout()); |
||||||
|
beanTreeView = new BeanTreeView(); |
||||||
|
add(beanTreeView, BorderLayout.CENTER); |
||||||
|
final GuiEditorModel model = (GuiEditorModel) CommandProcessor.getInstance().getObservable(); |
||||||
|
model.addObserver(this); |
||||||
|
if(model.getCurrent() != null){ |
||||||
|
try { |
||||||
|
this.intNavigator(model.getCurrent()); |
||||||
|
} catch (PropertyVetoException ex) { |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 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. |
||||||
|
*/ |
||||||
|
@SuppressWarnings("unchecked") |
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() { |
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
||||||
|
this.setLayout(layout); |
||||||
|
layout.setHorizontalGroup( |
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
||||||
|
.addGap(0, 244, Short.MAX_VALUE) |
||||||
|
); |
||||||
|
layout.setVerticalGroup( |
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
||||||
|
.addGap(0, 274, Short.MAX_VALUE) |
||||||
|
); |
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
|
@Override |
||||||
|
public String getDisplayName() { |
||||||
|
return "GuiView"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getDisplayHint() { |
||||||
|
return "Easy view for your gui"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JComponent getComponent() { |
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void panelActivated(Lookup context) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void panelDeactivated() { |
||||||
|
ExplorerUtils.activateActions(mgr, false); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Lookup getLookup() { |
||||||
|
return lookup; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ExplorerManager getExplorerManager() { |
||||||
|
return mgr; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update(Observable o, Object arg) { |
||||||
|
if(o instanceof GuiEditorModel){ |
||||||
|
try { |
||||||
|
GuiEditorModel model = (GuiEditorModel) o; |
||||||
|
model.getCurrent().addObserver(this); |
||||||
|
model.getCurrent().getSelection().addObserver(this); |
||||||
|
this.intNavigator(model.getCurrent()); |
||||||
|
} catch (PropertyVetoException ex) { |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if(arg instanceof SelectionChanged){ |
||||||
|
SelectionChanged event = (SelectionChanged) arg; |
||||||
|
if(event.getNewSelection().isEmpty()){ |
||||||
|
return; |
||||||
|
} |
||||||
|
ArrayList<String> path = new ArrayList<String>(); |
||||||
|
GElement parent = ((SelectionChanged)arg).getElement(); |
||||||
|
while(parent!=null){ |
||||||
|
path.add(parent.getID()); |
||||||
|
parent = parent.getParent(); |
||||||
|
} |
||||||
|
Node result = mgr.getRootContext(); |
||||||
|
for(int i=path.size()-1;i>=0;i--){ |
||||||
|
result = result.getChildren().findChild(path.get(i)); |
||||||
|
} |
||||||
|
try { |
||||||
|
mgr.setSelectedNodes(new Node[]{result}); |
||||||
|
} catch (PropertyVetoException ex) { |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} |
||||||
|
} |
||||||
|
beanTreeView.updateUI(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void propertyChange(PropertyChangeEvent evt) { |
||||||
|
if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) { |
||||||
|
Node[] newValue = (Node[]) evt.getNewValue(); |
||||||
|
if (newValue.length > 0) { |
||||||
|
AbstractNode firstSelected = (AbstractNode) newValue[0]; |
||||||
|
if (firstSelected instanceof GElementNode) { |
||||||
|
GElement element = ((GElementNode) firstSelected).getGelement(); |
||||||
|
GUI gui = ((GUINode)mgr.getRootContext()).getGui(); |
||||||
|
gui.getSelection().deleteObserver(this); // I don't wont to get notified about this selection change
|
||||||
|
SelectCommand command = CommandProcessor.getInstance().getCommand(SelectCommand.class); |
||||||
|
command.setElement(element); |
||||||
|
try { |
||||||
|
CommandProcessor.getInstance().excuteCommand(command); |
||||||
|
} catch (Exception ex) { |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} |
||||||
|
gui.getSelection().addObserver(this); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void intNavigator(GUI gui) throws PropertyVetoException { |
||||||
|
|
||||||
|
|
||||||
|
ExplorerUtils.activateActions(mgr, true); |
||||||
|
|
||||||
|
|
||||||
|
AbstractNode guiRoot = new GUINode(gui); |
||||||
|
guiRoot.setName("Gui"); |
||||||
|
this.mgr.setRootContext(guiRoot); |
||||||
|
this.beanTreeView.updateUI(); |
||||||
|
mgr.addPropertyChangeListener(this); |
||||||
|
this.mgr.setSelectedNodes(new Node[]{guiRoot}); |
||||||
|
Lookup lookup1 = ExplorerUtils.createLookup(mgr, getActionMap()); |
||||||
|
lookup = new ProxyLookup(lookup1); |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,404 @@ |
|||||||
|
/* |
||||||
|
* To change this template, choose Tools | Templates |
||||||
|
* and open the template in the editor. |
||||||
|
*/ |
||||||
|
package com.jme3.gde.gui.view; |
||||||
|
|
||||||
|
import com.jme3.app.Application; |
||||||
|
import com.jme3.gde.core.assets.ProjectAssetManager; |
||||||
|
import com.jme3.gde.gui.NiftyGuiDataObject; |
||||||
|
import com.jme3.gde.gui.nodes.GElementNode; |
||||||
|
import com.jme3.gde.gui.nodes.GUINode; |
||||||
|
import de.lessvoid.nifty.Nifty; |
||||||
|
import jada.ngeditor.controller.CommandProcessor; |
||||||
|
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.listeners.events.SelectionChanged; |
||||||
|
import jada.ngeditor.model.GUI; |
||||||
|
import jada.ngeditor.model.GuiEditorModel; |
||||||
|
import jada.ngeditor.model.elements.GElement; |
||||||
|
import jada.ngeditor.model.elements.GLayer; |
||||||
|
import jada.ngeditor.model.exception.NoProductException; |
||||||
|
import jada.ngeditor.persistence.GUIWriter; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.event.ItemEvent; |
||||||
|
import java.awt.event.ItemListener; |
||||||
|
import java.beans.PropertyChangeEvent; |
||||||
|
import java.beans.PropertyChangeListener; |
||||||
|
import java.beans.PropertyVetoException; |
||||||
|
import java.io.File; |
||||||
|
import java.io.FileNotFoundException; |
||||||
|
import java.io.IOException; |
||||||
|
import java.io.InputStream; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.Collection; |
||||||
|
import java.util.Collections; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Observable; |
||||||
|
import java.util.Observer; |
||||||
|
import java.util.logging.Level; |
||||||
|
import java.util.logging.Logger; |
||||||
|
import javax.swing.Action; |
||||||
|
import javax.swing.ActionMap; |
||||||
|
import javax.swing.DefaultComboBoxModel; |
||||||
|
import javax.swing.JComboBox; |
||||||
|
import javax.swing.JComponent; |
||||||
|
import javax.swing.JLabel; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.JToolBar; |
||||||
|
import javax.xml.bind.JAXBException; |
||||||
|
import javax.xml.parsers.ParserConfigurationException; |
||||||
|
import org.netbeans.api.progress.ProgressHandle; |
||||||
|
import org.netbeans.api.progress.ProgressHandleFactory; |
||||||
|
import org.netbeans.core.spi.multiview.CloseOperationState; |
||||||
|
import org.netbeans.core.spi.multiview.MultiViewElement; |
||||||
|
import org.netbeans.core.spi.multiview.MultiViewElementCallback; |
||||||
|
import org.netbeans.spi.actions.AbstractSavable; |
||||||
|
import org.openide.awt.UndoRedo; |
||||||
|
import org.openide.explorer.ExplorerManager; |
||||||
|
import org.openide.explorer.ExplorerUtils; |
||||||
|
import org.openide.loaders.DataObject; |
||||||
|
import org.openide.nodes.Node; |
||||||
|
import org.openide.util.Exceptions; |
||||||
|
import org.openide.util.Lookup; |
||||||
|
import org.openide.util.NbBundle.Messages; |
||||||
|
import org.openide.util.lookup.AbstractLookup; |
||||||
|
import org.openide.util.lookup.InstanceContent; |
||||||
|
import org.openide.util.lookup.ProxyLookup; |
||||||
|
import org.openide.windows.TopComponent; |
||||||
|
import org.xml.sax.SAXException; |
||||||
|
import sun.rmi.runtime.Log; |
||||||
|
|
||||||
|
@MultiViewElement.Registration( |
||||||
|
displayName = "#LBL_NiftyGui_VISUAL", |
||||||
|
iconBase = "com/jme3/gde/gui/multiview/icons/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 , ExplorerManager.Provider,Observer, PropertyChangeListener { |
||||||
|
private static final Logger logger = Logger.getLogger(NiftyGuiVisualElement.class.getName()); |
||||||
|
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(); |
||||||
|
private final ExplorerManager nodesManager; |
||||||
|
private final UndoRedo.Manager undoSupport; |
||||||
|
private int guiID; |
||||||
|
private final InstanceContent content = new InstanceContent(); |
||||||
|
private Lookup lookup; |
||||||
|
|
||||||
|
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 = obj.getLookup().lookup(GUIEditor.class); |
||||||
|
nodesManager = new ExplorerManager(); |
||||||
|
nifty = view.getNifty(); |
||||||
|
view.setTransferHandler(tranf); |
||||||
|
view.setDropTarget(tmp); |
||||||
|
// editor.addObserver(view);
|
||||||
|
// editor.addObserver(tranf);
|
||||||
|
this.obj.addPropertyChangeListener(this); |
||||||
|
this.createToolbar(); |
||||||
|
this.undoSupport = new UndoRedo.Manager(); |
||||||
|
CommandProcessor.getInstance().setUndoManager(undoSupport); |
||||||
|
this.content.set(Collections.singleton(obj.getNodeDelegate()), null); |
||||||
|
lookup = new AbstractLookup(content); |
||||||
|
} |
||||||
|
/** |
||||||
|
* Old code |
||||||
|
* @author normenhansen |
||||||
|
*/ |
||||||
|
private void createToolbar() { |
||||||
|
toolbar.setPreferredSize(new Dimension(10000, 24)); |
||||||
|
toolbar.setMaximumSize(new Dimension(10000, 24)); |
||||||
|
toolbar.setFloatable(false); |
||||||
|
toolbar.add(new JLabel("Change Resolution")); |
||||||
|
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"); |
||||||
|
toolbar.add(new JLabel("Current Layer")); |
||||||
|
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 this.lookup ; |
||||||
|
} |
||||||
|
/** |
||||||
|
* Raw implementation , just to prototype the editor |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void componentOpened() { |
||||||
|
loadGui(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void componentClosed() { |
||||||
|
|
||||||
|
} |
||||||
|
/** |
||||||
|
* Raw implementation , just to prototype the editor |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void componentShowing() { |
||||||
|
if(!this.obj.isModified()){ |
||||||
|
return; |
||||||
|
} |
||||||
|
loadGui(); |
||||||
|
|
||||||
|
} |
||||||
|
/** |
||||||
|
* 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); |
||||||
|
} catch (NullPointerException ex){ |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void componentActivated() { |
||||||
|
try{ |
||||||
|
GuiEditorModel model = (GuiEditorModel) CommandProcessor.getInstance().getObservable(); |
||||||
|
model.setCurrentGUI(guiID); |
||||||
|
model.getCurrent().addObserver(this); |
||||||
|
CommandProcessor.getInstance().setUndoManager(undoSupport); |
||||||
|
}catch(java.lang.IllegalArgumentException ex){ |
||||||
|
logger.log(Level.SEVERE,"Can't load your gui", ex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void componentDeactivated() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public UndoRedo getUndoRedo() { |
||||||
|
return this.undoSupport; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setMultiViewCallback(MultiViewElementCallback callback) { |
||||||
|
this.callback = callback; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public CloseOperationState canCloseElement() { |
||||||
|
return CloseOperationState.STATE_OK; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ExplorerManager getExplorerManager() { |
||||||
|
return nodesManager; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update(Observable o, Object arg) { |
||||||
|
if(arg instanceof SelectionChanged ){ |
||||||
|
SelectionChanged event = (SelectionChanged) arg; |
||||||
|
if(event.getNewSelection().isEmpty()){ |
||||||
|
return; |
||||||
|
} |
||||||
|
GElement parent = event.getElement(); |
||||||
|
GElementNode node = new GElementNode(parent); |
||||||
|
this.content.set(Collections.singleton(node), null); |
||||||
|
|
||||||
|
}else if(o instanceof GUI){ |
||||||
|
//Add a save. We don't add multible savable because they cointains the same
|
||||||
|
//information about editing.
|
||||||
|
GuiSavable savable = this.lookup.lookup(GuiSavable.class); |
||||||
|
if(savable == null){ |
||||||
|
String path = this.obj.getPrimaryFile().getPath(); |
||||||
|
final GuiSavable guiSavable = new NiftyGuiVisualElement.GuiSavable(((GUI)o),path); |
||||||
|
this.content.add(guiSavable); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void propertyChange(PropertyChangeEvent evt) { |
||||||
|
if(evt.getPropertyName().equals(DataObject.PROP_MODIFIED)){ |
||||||
|
boolean old = (Boolean)evt.getOldValue(); |
||||||
|
boolean nev = (Boolean)evt.getNewValue(); |
||||||
|
if(old && !nev){ |
||||||
|
this.loadGui(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void loadGui() { |
||||||
|
try { |
||||||
|
ProgressHandle handle = ProgressHandleFactory.createHandle("Loading the gui file"); |
||||||
|
InputStream is = this.obj.getPrimaryFile().getInputStream(); |
||||||
|
handle.start(); |
||||||
|
ProjectAssetManager mgr = this.obj.getLookup().lookup(ProjectAssetManager.class); |
||||||
|
String assetPath = mgr.getAssetFolder().getPath(); |
||||||
|
this.editor.createNewGui(nifty,is,new File(assetPath)); |
||||||
|
this.view.newGui(this.editor.getGui()); |
||||||
|
nodesManager.setRootContext(new GUINode(this.editor.getGui())); |
||||||
|
this.editor.getGui().getSelection().addObserver(this); |
||||||
|
Collection<GLayer> layers1 = this.editor.getGui().getLayers(); |
||||||
|
guiID = this.editor.getGui().getGUIid(); |
||||||
|
this.editor.getGui().addObserver(this); |
||||||
|
DefaultComboBoxModel<GLayer> model = new DefaultComboBoxModel<GLayer>(layers1.toArray(new GLayer[0])); |
||||||
|
layers.setModel(model); |
||||||
|
layers.setSelectedItem(this.editor.getCurrentLayer()); |
||||||
|
|
||||||
|
handle.finish(); |
||||||
|
} 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); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private class GuiSavable extends AbstractSavable { |
||||||
|
private final GUI gui; |
||||||
|
|
||||||
|
private final String filename; |
||||||
|
|
||||||
|
public GuiSavable(GUI gui,String filename){ |
||||||
|
|
||||||
|
this.gui = gui; |
||||||
|
this.filename = filename; |
||||||
|
this.register(); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
@Override |
||||||
|
protected String findDisplayName() { |
||||||
|
return "Save "+ this.gui + " changes"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void handleSave() throws IOException { |
||||||
|
try { |
||||||
|
GUIWriter writer = new GUIWriter(this.gui); |
||||||
|
writer.writeGUI(filename); |
||||||
|
NiftyGuiVisualElement.this.content.remove(this); |
||||||
|
|
||||||
|
|
||||||
|
} catch (FileNotFoundException ex) { |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} catch (JAXBException ex) { |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} catch (ClassNotFoundException ex) { |
||||||
|
Exceptions.printStackTrace(ex); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object obj) { |
||||||
|
if(obj instanceof com.jme3.gde.gui.view.NiftyGuiVisualElement.GuiSavable){ |
||||||
|
return this.gui.equals(((com.jme3.gde.gui.view.NiftyGuiVisualElement.GuiSavable)obj).gui); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
return this.gui.hashCode(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue