SDK - Filter Editor :

- Fixed Delete menu
- Filters can now be reordered by rightclick on the node> move up, move down

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7811 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent 65de002a7a
commit 14aa1dfec3
  1. 14
      sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java
  2. 12
      sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java
  3. 74
      sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java
  4. 15
      sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java

@ -43,7 +43,8 @@ import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import javax.swing.Action; import javax.swing.Action;
import org.openide.actions.DeleteAction; 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.awt.Actions;
import org.openide.loaders.DataObject; import org.openide.loaders.DataObject;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
@ -106,9 +107,12 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN
@Override @Override
public Action[] getActions(boolean context) { public Action[] getActions(boolean context) {
return new Action[]{ return new Action[]{
SystemAction.get(RenameAction.class), Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false),
Actions.alwaysEnabled(SystemAction.get(DeleteAction.class), "Delete", "", false), SystemAction.get(MoveUpAction.class),
Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false) 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) { public void propertyChange(final String name, final Object before, final Object after) {
if (name.equals("Enabled")) { if (name.equals("Enabled")) {
toggleIcon((Boolean)after); toggleIcon((Boolean) after);
} }
fireSave(true); fireSave(true);
firePropertyChange(name, before, after); firePropertyChange(name, before, after);

@ -39,10 +39,13 @@ import java.util.Iterator;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.ActionMap;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.windows.TopComponent; import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager; import org.openide.windows.WindowManager;
import org.netbeans.api.settings.ConvertAsProperties; 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.ActionID;
import org.openide.awt.ActionReference; import org.openide.awt.ActionReference;
import org.openide.explorer.ExplorerManager; import org.openide.explorer.ExplorerManager;
@ -77,9 +80,16 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex
initComponents(); initComponents();
setName(NbBundle.getMessage(FilterExplorerTopComponent.class, "CTL_FilterExplorerTopComponent")); setName(NbBundle.getMessage(FilterExplorerTopComponent.class, "CTL_FilterExplorerTopComponent"));
setToolTipText(NbBundle.getMessage(FilterExplorerTopComponent.class, "HINT_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 /** This method is called from within the constructor to
* initialize the form. * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is

@ -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<Object>() {
public Object call() throws Exception {
List<Filter> filters=new ArrayList<Filter>();
for (Iterator<Filter> 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();
}
});
}
}

@ -45,10 +45,12 @@ import java.util.concurrent.ExecutionException;
import javax.swing.Action; import javax.swing.Action;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Index;
import org.openide.nodes.Node; import org.openide.nodes.Node;
import org.openide.util.Exceptions; import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities; import org.openide.util.ImageUtilities;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups;
/** /**
* *
@ -62,10 +64,15 @@ public class FilterPostProcessorNode extends AbstractNode {
private FilterPostProcessor fpp; private FilterPostProcessor fpp;
public FilterPostProcessorNode(FilterDataObject dataObject) { public FilterPostProcessorNode(FilterDataObject dataObject) {
super(new FilterChildren(dataObject)); super(new FilterChildren(dataObject),Lookups.singleton(new FilterIndexSupport()));
//Lookups.singleton(new FilterIndexSupport((FilterChildren)this.getChildren()));
this.dataObject = dataObject; this.dataObject = dataObject;
setName(dataObject.getName()); setName(dataObject.getName());
getLookup().lookup(FilterIndexSupport.class).setFilterPostProcessorNode(this);
((FilterChildren) getChildren()).setFilterPostProcessorNode(this); ((FilterChildren) getChildren()).setFilterPostProcessorNode(this);
} }
@Override @Override
@ -160,6 +167,10 @@ public class FilterPostProcessorNode extends AbstractNode {
refresh(); refresh();
} }
protected void reorderNotify() {
setKeys(createKeys());
}
protected List<Object> createKeys() { protected List<Object> createKeys() {
try { try {
return SceneApplication.getApplication().enqueue(new Callable<List<Object>>() { return SceneApplication.getApplication().enqueue(new Callable<List<Object>>() {
@ -194,5 +205,7 @@ public class FilterPostProcessorNode extends AbstractNode {
} }
return new Node[]{}; return new Node[]{};
} }
} }
} }

Loading…
Cancel
Save