diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java index babb7c174..40cf0ce43 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java @@ -43,7 +43,8 @@ import java.io.IOException; import java.lang.reflect.Field; import javax.swing.Action; import org.openide.actions.DeleteAction; -import org.openide.actions.RenameAction; +import org.openide.actions.MoveDownAction; +import org.openide.actions.MoveUpAction; import org.openide.awt.Actions; import org.openide.loaders.DataObject; import org.openide.nodes.AbstractNode; @@ -106,9 +107,12 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN @Override public Action[] getActions(boolean context) { return new Action[]{ - SystemAction.get(RenameAction.class), - Actions.alwaysEnabled(SystemAction.get(DeleteAction.class), "Delete", "", false), - Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false) + Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false), + SystemAction.get(MoveUpAction.class), + SystemAction.get(MoveDownAction.class), + null, + SystemAction.get(DeleteAction.class), + }; } @@ -217,7 +221,7 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN public void propertyChange(final String name, final Object before, final Object after) { if (name.equals("Enabled")) { - toggleIcon((Boolean)after); + toggleIcon((Boolean) after); } fireSave(true); firePropertyChange(name, before, after); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java index 6ac330f68..bfafb8505 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java @@ -39,10 +39,13 @@ import java.util.Iterator; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.ActionMap; import org.openide.util.NbBundle; import org.openide.windows.TopComponent; import org.openide.windows.WindowManager; import org.netbeans.api.settings.ConvertAsProperties; +import org.openide.actions.MoveDownAction; +import org.openide.actions.MoveUpAction; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.explorer.ExplorerManager; @@ -77,8 +80,15 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex initComponents(); setName(NbBundle.getMessage(FilterExplorerTopComponent.class, "CTL_FilterExplorerTopComponent")); setToolTipText(NbBundle.getMessage(FilterExplorerTopComponent.class, "HINT_FilterExplorerTopComponent")); - associateLookup(ExplorerUtils.createLookup(explorerManager, getActionMap())); + ActionMap map=getActionMap(); + map.put("delete", ExplorerUtils.actionDelete(explorerManager, true)); + map.put("moveup", new MoveUpAction()); + map.put("movedown", new MoveDownAction()); + associateLookup(ExplorerUtils.createLookup(explorerManager, map)); + } + + /** This method is called from within the constructor to * initialize the form. @@ -142,7 +152,7 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex } public void loadFile(FilterDataObject object) { - explorerManager.setRootContext(object.getLookup().lookup(FilterPostProcessorNode.class)); + explorerManager.setRootContext(object.getLookup().lookup(FilterPostProcessorNode.class)); node = object.getLookup().lookup(FilterPostProcessorNode.class); setActivatedNodes(new Node[]{object.getNodeDelegate()}); open(); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java new file mode 100644 index 000000000..04ac36e20 --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java @@ -0,0 +1,74 @@ +package com.jme3.gde.core.filters; + +import com.jme3.gde.core.filters.FilterPostProcessorNode.FilterChildren; +import com.jme3.gde.core.scene.SceneApplication; +import com.jme3.post.Filter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.Callable; +import org.openide.nodes.Index; +import org.openide.nodes.Node; + +/** + * + * @author Nehon + */ +public class FilterIndexSupport extends Index.Support { + + FilterPostProcessorNode fppNode; + FilterChildren children; + + public FilterIndexSupport() { + + + } + + @Override + public Node[] getNodes() { + return fppNode.getChildren().getNodes(); + } + + @Override + public int getNodesCount() { + return fppNode.getChildren().getNodesCount(); + } + + public FilterPostProcessorNode getFilterPostProcessorNode() { + return fppNode; + } + + public void setFilterPostProcessorNode(FilterPostProcessorNode fppNode) { + this.fppNode = fppNode; + } + + + @Override + public void reorder(final int[] perm) { + + SceneApplication.getApplication().enqueue(new Callable() { + + public Object call() throws Exception { + List filters=new ArrayList(); + for (Iterator it = fppNode.getFilterPostProcessor().getFilterIterator(); it.hasNext();) { + Filter f = it.next(); + filters.add(f); + } + System.err.println("reordering"); + fppNode.getFilterPostProcessor().removeAllFilters(); + for (int i = 0; i < perm.length; i++) { + fppNode.getFilterPostProcessor().addFilter(filters.get(perm[i])); + } + return null; + } + }); + java.awt.EventQueue.invokeLater(new Runnable() { + + public void run() { + ((FilterChildren) fppNode.getChildren()).reorderNotify(); + ((FilterChildren) fppNode.getChildren()).doRefresh(); + } + }); + + } +} \ No newline at end of file diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java index 642a61f40..5c94b6d12 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java @@ -45,10 +45,12 @@ import java.util.concurrent.ExecutionException; import javax.swing.Action; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; +import org.openide.nodes.Index; import org.openide.nodes.Node; import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; import org.openide.util.Lookup; +import org.openide.util.lookup.Lookups; /** * @@ -61,11 +63,16 @@ public class FilterPostProcessorNode extends AbstractNode { ImageUtilities.loadImage("com/jme3/gde/core/filters/icons/eye.gif"); private FilterPostProcessor fpp; - public FilterPostProcessorNode(FilterDataObject dataObject) { - super(new FilterChildren(dataObject)); + public FilterPostProcessorNode(FilterDataObject dataObject) { + super(new FilterChildren(dataObject),Lookups.singleton(new FilterIndexSupport())); + + //Lookups.singleton(new FilterIndexSupport((FilterChildren)this.getChildren())); this.dataObject = dataObject; - setName(dataObject.getName()); + setName(dataObject.getName()); + getLookup().lookup(FilterIndexSupport.class).setFilterPostProcessorNode(this); ((FilterChildren) getChildren()).setFilterPostProcessorNode(this); + + } @Override @@ -159,7 +166,11 @@ public class FilterPostProcessorNode extends AbstractNode { protected void doRefresh() { refresh(); } - + + protected void reorderNotify() { + setKeys(createKeys()); + } + protected List createKeys() { try { return SceneApplication.getApplication().enqueue(new Callable>() { @@ -194,5 +205,7 @@ public class FilterPostProcessorNode extends AbstractNode { } return new Node[]{}; } + } + }