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. 14
      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. 21
      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 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);

@ -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();

@ -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 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<Object> createKeys() {
try {
return SceneApplication.getApplication().enqueue(new Callable<List<Object>>() {
@ -194,5 +205,7 @@ public class FilterPostProcessorNode extends AbstractNode {
}
return new Node[]{};
}
}
}

Loading…
Cancel
Save