experimental
relu91 10 years ago
parent ba848391dd
commit 81ba23a2e2
  1. 2
      sdk/jme3-gui/nbproject/project.properties
  2. BIN
      sdk/jme3-gui/release/modules/ext/Nifty-Editor0.5.9.jar
  3. 22
      sdk/jme3-gui/src/com/jme3/gde/gui/Navigator.java
  4. 41
      sdk/jme3-gui/src/com/jme3/gde/gui/NiftyGuiVisualElement.java
  5. 15
      sdk/jme3-gui/src/com/jme3/gde/gui/nodes/GElementNode.java

@ -6,4 +6,4 @@ license.file=../license-jme.txt
nbm.homepage=http://www.jmonkeyengine.com nbm.homepage=http://www.jmonkeyengine.com
nbm.module.author=Normen Hansen,Cristiano Aguzzi nbm.module.author=Normen Hansen,Cristiano Aguzzi
nbm.needs.restart=true nbm.needs.restart=true
spec.version.base=3.1.5 spec.version.base=3.2

@ -6,11 +6,9 @@ package com.jme3.gde.gui;
import com.jme3.gde.gui.nodes.GElementNode; import com.jme3.gde.gui.nodes.GElementNode;
import com.jme3.gde.gui.nodes.GUINode; import com.jme3.gde.gui.nodes.GUINode;
import com.jme3.gde.gui.nodes.ScreenChildFactory;
import jada.ngeditor.controller.CommandProcessor; import jada.ngeditor.controller.CommandProcessor;
import jada.ngeditor.controller.GUIEditor; import jada.ngeditor.controller.GUIEditor;
import jada.ngeditor.controller.commands.SelectCommand; import jada.ngeditor.controller.commands.SelectCommand;
import jada.ngeditor.listeners.events.ReloadGuiEvent;
import jada.ngeditor.listeners.events.SelectionChanged; import jada.ngeditor.listeners.events.SelectionChanged;
import jada.ngeditor.model.GUI; import jada.ngeditor.model.GUI;
import jada.ngeditor.model.GuiEditorModel; import jada.ngeditor.model.GuiEditorModel;
@ -28,15 +26,10 @@ import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils; import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.BeanTreeView; import org.openide.explorer.view.BeanTreeView;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener;
import org.openide.util.Utilities;
import org.openide.util.lookup.ProxyLookup; import org.openide.util.lookup.ProxyLookup;
import org.openide.windows.TopComponent;
/** /**
* *
@ -47,9 +40,6 @@ public class Navigator extends javax.swing.JPanel implements NavigatorPanel,Expl
private Lookup lookup; private Lookup lookup;
private ExplorerManager mgr = new ExplorerManager(); private ExplorerManager mgr = new ExplorerManager();
private final BeanTreeView beanTreeView; private final BeanTreeView beanTreeView;
private GUIEditor editor;
private Lookup context;
private boolean lock;
/** /**
* Creates new form Navigator * Creates new form Navigator
*/ */
@ -58,7 +48,16 @@ public class Navigator extends javax.swing.JPanel implements NavigatorPanel,Expl
setLayout(new BorderLayout()); setLayout(new BorderLayout());
beanTreeView = new BeanTreeView(); beanTreeView = new BeanTreeView();
add(beanTreeView, BorderLayout.CENTER); add(beanTreeView, BorderLayout.CENTER);
CommandProcessor.getInstance().getObservable().addObserver(this); 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);
}
}
} }
@ -170,7 +169,6 @@ public class Navigator extends javax.swing.JPanel implements NavigatorPanel,Expl
SelectCommand command = CommandProcessor.getInstance().getCommand(SelectCommand.class); SelectCommand command = CommandProcessor.getInstance().getCommand(SelectCommand.class);
command.setElement(element); command.setElement(element);
try { try {
lock = true;
CommandProcessor.getInstance().excuteCommand(command); CommandProcessor.getInstance().excuteCommand(command);
} catch (Exception ex) { } catch (Exception ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);

@ -4,7 +4,9 @@
*/ */
package com.jme3.gde.gui; package com.jme3.gde.gui;
import com.jme3.app.Application;
import com.jme3.gde.core.assets.ProjectAssetManager; import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.gui.nodes.GElementNode;
import com.jme3.gde.gui.nodes.GUINode; import com.jme3.gde.gui.nodes.GUINode;
import de.lessvoid.nifty.Nifty; import de.lessvoid.nifty.Nifty;
import jada.ngeditor.controller.CommandProcessor; import jada.ngeditor.controller.CommandProcessor;
@ -29,8 +31,11 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.ActionMap; import javax.swing.ActionMap;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
@ -54,6 +59,9 @@ import org.openide.nodes.Node;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.NbBundle.Messages; 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.openide.windows.TopComponent;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import sun.rmi.runtime.Log; import sun.rmi.runtime.Log;
@ -67,7 +75,7 @@ import sun.rmi.runtime.Log;
position = 2000) position = 2000)
@Messages("LBL_NiftyGui_VISUAL=Visual") @Messages("LBL_NiftyGui_VISUAL=Visual")
public final class NiftyGuiVisualElement extends JPanel implements MultiViewElement , ExplorerManager.Provider,Observer, PropertyChangeListener { 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 NiftyGuiDataObject obj;
private JToolBar toolbar = new JToolBar(); private JToolBar toolbar = new JToolBar();
private transient MultiViewElementCallback callback; private transient MultiViewElementCallback callback;
@ -78,7 +86,8 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
private final ExplorerManager nodesManager; private final ExplorerManager nodesManager;
private final UndoRedo.Manager undoSupport; private final UndoRedo.Manager undoSupport;
private int guiID; private int guiID;
private final InstanceContent content = new InstanceContent();
private Lookup lookup;
public NiftyGuiVisualElement(Lookup lkp) { public NiftyGuiVisualElement(Lookup lkp) {
obj = lkp.lookup(NiftyGuiDataObject.class); obj = lkp.lookup(NiftyGuiDataObject.class);
@ -101,6 +110,8 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
this.createToolbar(); this.createToolbar();
this.undoSupport = new UndoRedo.Manager(); this.undoSupport = new UndoRedo.Manager();
CommandProcessor.getInstance().setUndoManager(undoSupport); CommandProcessor.getInstance().setUndoManager(undoSupport);
this.content.set(Collections.singleton(obj.getNodeDelegate()), null);
lookup = new AbstractLookup(content);
} }
/** /**
* Old code * Old code
@ -184,7 +195,7 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
@Override @Override
public Lookup getLookup() { public Lookup getLookup() {
return ExplorerUtils.createLookup(nodesManager, new ActionMap()); return this.lookup ;
} }
/** /**
* Raw implementation , just to prototype the editor * Raw implementation , just to prototype the editor
@ -228,9 +239,13 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
@Override @Override
public void componentActivated() { public void componentActivated() {
try{
GuiEditorModel model = (GuiEditorModel) CommandProcessor.getInstance().getObservable(); GuiEditorModel model = (GuiEditorModel) CommandProcessor.getInstance().getObservable();
model.setCurrentGUI(guiID); model.setCurrentGUI(guiID);
CommandProcessor.getInstance().setUndoManager(undoSupport); CommandProcessor.getInstance().setUndoManager(undoSupport);
}catch(java.lang.IllegalArgumentException ex){
logger.log(Level.SEVERE,"Can't load your gui", ex);
}
} }
@Override @Override
@ -264,25 +279,9 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
if(event.getNewSelection().isEmpty()){ if(event.getNewSelection().isEmpty()){
return; return;
} }
ArrayList<String> path = new ArrayList<String>();
GElement parent = event.getElement(); GElement parent = event.getElement();
while(parent!=null){ GElementNode node = new GElementNode(parent);
path.add(parent.getID()); this.content.set(Collections.singleton(node), null);
parent = parent.getParent();
}
Node result = nodesManager.getRootContext();
for(int i=path.size()-1;i>=0 && result!=null;i--){
result = result.getChildren().findChild(path.get(i));
}
try {
if(result!=null){
nodesManager.setSelectedNodes(new Node[]{result});
}
} catch (PropertyVetoException ex) {
Exceptions.printStackTrace(ex);
}
} }
} }

@ -6,14 +6,18 @@ package com.jme3.gde.gui.nodes;
import com.jme3.gde.gui.propertyeditors.ResourceEditor; import com.jme3.gde.gui.propertyeditors.ResourceEditor;
import com.jme3.gde.gui.propertyeditors.SizeEditor; import com.jme3.gde.gui.propertyeditors.SizeEditor;
import jada.ngeditor.controller.CommandProcessor;
import jada.ngeditor.controller.commands.EditAttributeCommand;
import jada.ngeditor.model.elements.GElement; import jada.ngeditor.model.elements.GElement;
import java.beans.PropertyEditor; import java.beans.PropertyEditor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.swing.JOptionPane;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.Exceptions;
import sun.beans.editors.BoolEditor; import sun.beans.editors.BoolEditor;
import sun.beans.editors.BooleanEditor; import sun.beans.editors.BooleanEditor;
@ -110,8 +114,15 @@ public class GElementNode extends AbstractNode{
@Override @Override
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException { public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException {
element.addAttribute(attributeName, val.toString()); try {
element.refresh(); EditAttributeCommand command = CommandProcessor.getInstance().getCommand(EditAttributeCommand.class);
command.setAttribute(attributeName);
command.setValue(val.toString());
CommandProcessor.getInstance().excuteCommand(command);
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex);
}
} }
}; };
} }

Loading…
Cancel
Save