diff --git a/sdk/jme3-gui/release/modules/ext/Nifty-Editor0.5.9.jar b/sdk/jme3-gui/release/modules/ext/Nifty-Editor0.5.9.jar index 368008604..5f7166746 100644 Binary files a/sdk/jme3-gui/release/modules/ext/Nifty-Editor0.5.9.jar and b/sdk/jme3-gui/release/modules/ext/Nifty-Editor0.5.9.jar differ diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/Navigator.form b/sdk/jme3-gui/src/com/jme3/gde/gui/Navigator.form deleted file mode 100644 index b3657640a..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/Navigator.form +++ /dev/null @@ -1,28 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiDataObject.java b/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiDataObject.java index 35c97ba72..1c5bc7446 100644 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiDataObject.java +++ b/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiDataObject.java @@ -36,7 +36,7 @@ import org.openide.windows.TopComponent; resource = "NiftyGuiResolver.xml") @DataObject.Registration( mimeType = "text/x-niftygui+xml", - iconBase = "com/jme3/gde/gui/Computer_File_043.gif", + iconBase = "com/jme3/gde/gui/multiview/icons/Computer_File_043.gif", displayName = "#LBL_NiftyGui_LOADER", position = 300) @ActionReferences({ @@ -125,7 +125,7 @@ public class NiftyGuiDataObject extends MultiDataObject { @Override protected Node createNodeDelegate() { DataNode node = new DataNode(this, Children.LEAF, getLookup()); - node.setIconBaseWithExtension("com/jme3/gde/gui/Computer_File_043.gif"); + node.setIconBaseWithExtension("com/jme3/gde/gui/multiview/icons/Computer_File_043.gif"); return node; } @@ -136,7 +136,7 @@ public class NiftyGuiDataObject extends MultiDataObject { @MultiViewElement.Registration( displayName = "#LBL_NiftyGui_EDITOR", - iconBase = "com/jme3/gde/gui/Computer_File_043.gif", + iconBase = "com/jme3/gde/gui/multiview/icons/Computer_File_043.gif", mimeType = "text/x-niftygui+xml", persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED, preferredID = "NiftyGui", diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiResolver.xml b/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiResolver.xml index cab60462a..4076cc28c 100644 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiResolver.xml +++ b/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiResolver.xml @@ -1,8 +1,4 @@ - diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiVisualElement.form b/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiVisualElement.form deleted file mode 100644 index add7a2637..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiVisualElement.form +++ /dev/null @@ -1,29 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/OldNiftyGuiDataObject.java b/sdk/jme3-gui/src/com/jme3/gde/gui/OldNiftyGuiDataObject.java deleted file mode 100644 index 7b06694e9..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/OldNiftyGuiDataObject.java +++ /dev/null @@ -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"; - } -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/Bundle.properties b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/Bundle.properties deleted file mode 100644 index 7a6ba8e9c..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/Bundle.properties +++ /dev/null @@ -1,4 +0,0 @@ - -PreviewPanel.jLabel1.text=jLabel1 -ErrorPanel.jLabel1.text=jLabel1 -ErrorPanel.jLabel2.text=\ Errors diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/ErrorPanel.form b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/ErrorPanel.form deleted file mode 100644 index ae4ae89ae..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/ErrorPanel.form +++ /dev/null @@ -1,62 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/ErrorPanel.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/ErrorPanel.java deleted file mode 100644 index 94a62d5a4..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/ErrorPanel.java +++ /dev/null @@ -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. - */ - // //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); - }// //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 -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/MouseInputEvent.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/MouseInputEvent.java deleted file mode 100644 index 71a37d433..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/MouseInputEvent.java +++ /dev/null @@ -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; - } - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyFileChildren.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyFileChildren.java deleted file mode 100644 index ee70aa1d8..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyFileChildren.java +++ /dev/null @@ -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 xmlNode; - - public NiftyFileChildren(Element xmlNode) { - this.xmlNode = xmlNode; - } - - @Override - protected void addNotify() { - super.addNotify(); - setKeys(createKeys()); - } - - protected List createKeys() { - LinkedList ret = new LinkedList(); - 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"))}; - } -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyFileNode.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyFileNode.java deleted file mode 100644 index a3d15f188..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyFileNode.java +++ /dev/null @@ -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)); - } - - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyJmeDisplay.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyJmeDisplay.java deleted file mode 100644 index a76eec721..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyJmeDisplay.java +++ /dev/null @@ -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 key = new AssetKey(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(); - } - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyPreviewInputHandler.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyPreviewInputHandler.java deleted file mode 100644 index a0174a23f..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyPreviewInputHandler.java +++ /dev/null @@ -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 mouseEvents = new LinkedList(); - private List keyEvents = new LinkedList(); - - public synchronized void forwardEvents(NiftyInputConsumer nic) { - for (Iterator 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 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) { - } - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyPreviewPanel.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyPreviewPanel.java deleted file mode 100644 index 5f887b400..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyPreviewPanel.java +++ /dev/null @@ -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() { - - 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() { - - public Object call() throws Exception { - - try { - nifty.fromXml(pm.getRelativeAssetPath(niftyObject.getPrimaryFile().getPath()), screen); - if (screen == null || screen.length() == 0) { - Collection screens = nifty.getAllScreensName(); - for (Iterator 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() { - - 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() { - - public Object call() throws Exception { - nifty.gotoScreen(screen); - return null; - } - }); - } - - public void cleanup() { - offPanel.stopPreview(); - SceneApplication.getApplication().enqueue(new Callable() { - - 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()); - } -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyScreenNode.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyScreenNode.java deleted file mode 100644 index f6a9fa08f..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/NiftyScreenNode.java +++ /dev/null @@ -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); - } - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewToolbarElement.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewToolbarElement.java deleted file mode 100644 index 54ebf7999..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewToolbarElement.java +++ /dev/null @@ -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(); - } - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewView.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewView.java deleted file mode 100644 index db63baa03..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/PreviewView.java +++ /dev/null @@ -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); - } -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/XmlHelper.java b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/XmlHelper.java deleted file mode 100644 index b58865d7c..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/XmlHelper.java +++ /dev/null @@ -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; - } - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/icons/Computer_File_043.gif b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/icons/Computer_File_043.gif new file mode 100644 index 000000000..421d54335 Binary files /dev/null and b/sdk/jme3-gui/src/com/jme3/gde/gui/multiview/icons/Computer_File_043.gif differ diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/package-info.java b/sdk/jme3-gui/src/com/jme3/gde/gui/package-info.java index dc6ffbc7a..a7022bf6f 100644 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/package-info.java +++ b/sdk/jme3-gui/src/com/jme3/gde/gui/package-info.java @@ -2,8 +2,8 @@ * 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")}) +@TemplateRegistrations(value = {@TemplateRegistration(folder = "GUI", displayName = "Empty Gui",content = "templates/EmptyNiftyGui.xml"), +@TemplateRegistration(folder = "GUI", displayName = "HelloJme",content = "templates/NiftyGui.xml")}) package com.jme3.gde.gui; import org.netbeans.api.templates.TemplateRegistration; diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/palette/JmePaletteUtilities.java b/sdk/jme3-gui/src/com/jme3/gde/gui/palette/JmePaletteUtilities.java deleted file mode 100644 index 9f508b349..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/palette/JmePaletteUtilities.java +++ /dev/null @@ -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; - - } - -} \ No newline at end of file diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/palette/Screen.java b/sdk/jme3-gui/src/com/jme3/gde/gui/palette/Screen.java deleted file mode 100644 index 5a442cf62..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/palette/Screen.java +++ /dev/null @@ -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 = ""; - return body; - } - - public boolean handleTransfer(JTextComponent targetComponent) { - String body = createBody(); - try { - JmePaletteUtilities.insert(body, targetComponent); - } catch (BadLocationException ble) { - return false; - } - return true; - } - -} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/palette/Screen.xml b/sdk/jme3-gui/src/com/jme3/gde/gui/palette/Screen.xml deleted file mode 100644 index 1445bab56..000000000 --- a/sdk/jme3-gui/src/com/jme3/gde/gui/palette/Screen.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - Screen - Nifty-gui Screen - - \ No newline at end of file diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/templates/EmptyNiftyGui.xml b/sdk/jme3-gui/src/com/jme3/gde/gui/templates/EmptyNiftyGui.xml new file mode 100644 index 000000000..2e51c89de --- /dev/null +++ b/sdk/jme3-gui/src/com/jme3/gde/gui/templates/EmptyNiftyGui.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/templates/NiftyGui.xml b/sdk/jme3-gui/src/com/jme3/gde/gui/templates/NiftyGui.xml new file mode 100644 index 000000000..ec0bd6e31 --- /dev/null +++ b/sdk/jme3-gui/src/com/jme3/gde/gui/templates/NiftyGui.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/view/Navigator.java b/sdk/jme3-gui/src/com/jme3/gde/gui/view/Navigator.java new file mode 100644 index 000000000..11bd4c0c4 --- /dev/null +++ b/sdk/jme3-gui/src/com/jme3/gde/gui/view/Navigator.java @@ -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") + // //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) + ); + }// //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 path = new ArrayList(); + 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); + + } +} diff --git a/sdk/jme3-gui/src/com/jme3/gde/gui/view/NiftyGuiVisualElement.java b/sdk/jme3-gui/src/com/jme3/gde/gui/view/NiftyGuiVisualElement.java new file mode 100644 index 000000000..a459a2553 --- /dev/null +++ b/sdk/jme3-gui/src/com/jme3/gde/gui/view/NiftyGuiVisualElement.java @@ -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. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + scrollArea = new javax.swing.JScrollPane(); + + setLayout(new java.awt.BorderLayout()); + add(scrollArea, java.awt.BorderLayout.CENTER); + }// //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 layers1 = this.editor.getGui().getLayers(); + guiID = this.editor.getGui().getGUIid(); + this.editor.getGui().addObserver(this); + DefaultComboBoxModel model = new DefaultComboBoxModel(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(); + } + +} +}