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.module.author=Normen Hansen,Cristiano Aguzzi
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.GUINode;
import com.jme3.gde.gui.nodes.ScreenChildFactory;
import jada.ngeditor.controller.CommandProcessor;
import jada.ngeditor.controller.GUIEditor;
import jada.ngeditor.controller.commands.SelectCommand;
import jada.ngeditor.listeners.events.ReloadGuiEvent;
import jada.ngeditor.listeners.events.SelectionChanged;
import jada.ngeditor.model.GUI;
import jada.ngeditor.model.GuiEditorModel;
@ -28,15 +26,10 @@ 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.Children;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
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.windows.TopComponent;
/**
*
@ -47,9 +40,6 @@ public class Navigator extends javax.swing.JPanel implements NavigatorPanel,Expl
private Lookup lookup;
private ExplorerManager mgr = new ExplorerManager();
private final BeanTreeView beanTreeView;
private GUIEditor editor;
private Lookup context;
private boolean lock;
/**
* Creates new form Navigator
*/
@ -58,7 +48,16 @@ public class Navigator extends javax.swing.JPanel implements NavigatorPanel,Expl
setLayout(new BorderLayout());
beanTreeView = new BeanTreeView();
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);
command.setElement(element);
try {
lock = true;
CommandProcessor.getInstance().excuteCommand(command);
} catch (Exception ex) {
Exceptions.printStackTrace(ex);

@ -4,7 +4,9 @@
*/
package com.jme3.gde.gui;
import com.jme3.app.Application;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.gui.nodes.GElementNode;
import com.jme3.gde.gui.nodes.GUINode;
import de.lessvoid.nifty.Nifty;
import jada.ngeditor.controller.CommandProcessor;
@ -29,8 +31,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
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;
@ -54,6 +59,9 @@ 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;
@ -67,7 +75,7 @@ import sun.rmi.runtime.Log;
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;
@ -78,7 +86,8 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
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);
@ -101,6 +110,8 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
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
@ -184,7 +195,7 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
@Override
public Lookup getLookup() {
return ExplorerUtils.createLookup(nodesManager, new ActionMap());
return this.lookup ;
}
/**
* Raw implementation , just to prototype the editor
@ -228,9 +239,13 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
@Override
public void componentActivated() {
try{
GuiEditorModel model = (GuiEditorModel) CommandProcessor.getInstance().getObservable();
model.setCurrentGUI(guiID);
CommandProcessor.getInstance().setUndoManager(undoSupport);
}catch(java.lang.IllegalArgumentException ex){
logger.log(Level.SEVERE,"Can't load your gui", ex);
}
}
@Override
@ -264,25 +279,9 @@ public final class NiftyGuiVisualElement extends JPanel implements MultiViewElem
if(event.getNewSelection().isEmpty()){
return;
}
ArrayList<String> path = new ArrayList<String>();
GElement parent = event.getElement();
while(parent!=null){
path.add(parent.getID());
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);
}
GElementNode node = new GElementNode(parent);
this.content.set(Collections.singleton(node), null);
}
}

@ -6,14 +6,18 @@ package com.jme3.gde.gui.nodes;
import com.jme3.gde.gui.propertyeditors.ResourceEditor;
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 java.beans.PropertyEditor;
import java.lang.reflect.InvocationTargetException;
import java.util.Map.Entry;
import javax.swing.JOptionPane;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.nodes.Sheet;
import org.openide.util.Exceptions;
import sun.beans.editors.BoolEditor;
import sun.beans.editors.BooleanEditor;
@ -110,8 +114,15 @@ public class GElementNode extends AbstractNode{
@Override
public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException {
element.addAttribute(attributeName, val.toString());
element.refresh();
try {
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