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 3094513ad..babb7c174 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 @@ -31,22 +31,27 @@ */ package com.jme3.gde.core.filters; +import com.jme3.gde.core.filters.actions.EnableFiterAction; import com.jme3.gde.core.properties.SceneExplorerProperty; import com.jme3.gde.core.properties.ScenePropertyChangeListener; import com.jme3.gde.core.util.PropertyUtils; import com.jme3.post.Filter; + +import java.awt.Image; import java.beans.PropertyDescriptor; import java.io.IOException; import java.lang.reflect.Field; -import java.lang.reflect.Method; import javax.swing.Action; import org.openide.actions.DeleteAction; +import org.openide.actions.RenameAction; +import org.openide.awt.Actions; import org.openide.loaders.DataObject; 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 org.openide.util.ImageUtilities; import org.openide.util.actions.SystemAction; /** @@ -59,6 +64,31 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN protected boolean readOnly = false; protected DataObject dataObject; protected Filter filter; + private static Image icon; + private static final String ICON_ENABLED = "com/jme3/gde/core/filters/icons/eye.gif"; + private static final String ICON_DISABLED = "com/jme3/gde/core/filters/icons/crossedEye.gif"; + + @Override + public Image getIcon(int type) { + return icon; + + } + + @Override + public Image getOpenedIcon(int type) { + return icon; + } + + public void toggleIcon(boolean enabled) { + if (enabled) { + icon = ImageUtilities.loadImage(ICON_ENABLED); + + } else { + icon = ImageUtilities.loadImage(ICON_DISABLED); + + } + fireIconChange(); + } public AbstractFilterNode() { super(Children.LEAF); @@ -68,18 +98,27 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN super(Children.LEAF); this.filter = filter; setName(filter.getName()); + icon = ImageUtilities.loadImage(ICON_ENABLED); + setIconBaseWithExtension(ICON_ENABLED); + } @Override public Action[] getActions(boolean context) { return new Action[]{ - SystemAction.get(DeleteAction.class) + SystemAction.get(RenameAction.class), + Actions.alwaysEnabled(SystemAction.get(DeleteAction.class), "Delete", "", false), + Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false) }; } + @Override + public Action getPreferredAction() { + return Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false); + } + @Override public boolean canDestroy() { -// return !readOnly; return true; } @@ -88,6 +127,7 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN super.destroy(); FilterPostProcessorNode nod = (FilterPostProcessorNode) getParentNode(); nod.removeFilter(filter); + fireSave(true); } protected void fireSave(boolean modified) { @@ -168,18 +208,25 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN protected void createFields(Class c, Sheet.Set set, Object obj) throws SecurityException { for (Field field : c.getDeclaredFields()) { - PropertyDescriptor prop=PropertyUtils.getPropertyDescriptor(c, field); - if(prop!=null){ - set.put(makeProperty(obj, prop.getPropertyType() , prop.getReadMethod().getName(), prop.getWriteMethod().getName(), prop.getDisplayName())); + PropertyDescriptor prop = PropertyUtils.getPropertyDescriptor(c, field); + if (prop != null) { + set.put(makeProperty(obj, prop.getPropertyType(), prop.getReadMethod().getName(), prop.getWriteMethod().getName(), prop.getDisplayName())); } } } public void propertyChange(final String name, final Object before, final Object after) { + if (name.equals("Enabled")) { + toggleIcon((Boolean)after); + } fireSave(true); firePropertyChange(name, before, after); } + public Filter getFilter() { + return filter; + } + public abstract Class getExplorerObjectClass(); public abstract Node[] createNodes(Object key, DataObject dataObject, boolean readOnly); 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 c22d2aa8e..6ac330f68 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 @@ -56,7 +56,7 @@ import org.openide.nodes.Node; @ConvertAsProperties(dtd = "-//com.jme3.gde.core.filters//FilterExplorer//EN", autostore = false) @TopComponent.Description(preferredID = "FilterExplorerTopComponent", -iconBase = "com/jme3/gde/core/objects_082.gif", +iconBase = "com/jme3/gde/core/filters/icons/eye.gif", persistenceType = TopComponent.PERSISTENCE_ALWAYS) @TopComponent.Registration(mode = "navigator", openAtStartup = true) @ActionID(category = "Window", id = "com.jme3.gde.core.filters.FilterExplorerTopComponent") 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 9900dca22..642a61f40 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 @@ -58,7 +58,7 @@ public class FilterPostProcessorNode extends AbstractNode { private FilterDataObject dataObject; private static Image smallImage = - ImageUtilities.loadImage("com/jme3/gde/core/objects_082.gif"); + ImageUtilities.loadImage("com/jme3/gde/core/filters/icons/eye.gif"); private FilterPostProcessor fpp; public FilterPostProcessorNode(FilterDataObject dataObject) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/actions/EnableFiterAction.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/actions/EnableFiterAction.java new file mode 100644 index 000000000..61d48b99d --- /dev/null +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/actions/EnableFiterAction.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2009-2010 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.gde.core.filters.actions; + +/** + * + * @author Nehon + */ +import com.jme3.gde.core.filters.AbstractFilterNode; +import com.jme3.gde.core.scene.SceneApplication; +import com.jme3.post.Filter; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.util.concurrent.Callable; +import java.util.logging.Logger; + +public class EnableFiterAction implements ActionListener { + + private final AbstractFilterNode context; + + public EnableFiterAction(AbstractFilterNode context) { + this.context = context; + } + + public void actionPerformed(ActionEvent ev) { + + SceneApplication.getApplication().enqueue(new Callable() { + + public Void call() throws Exception { + Filter filter=context.getFilter(); + filter.setEnabled(!filter.isEnabled()); + Logger.getLogger(EnableFiterAction.class.getName()).info( (filter.isEnabled()?"Enabled":"Disabled")+" "+filter.getName()); + context.propertyChange("Enabled", !filter.isEnabled(), filter.isEnabled()); + + return null; + } + }); + } +} diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/icons/crossedEye.gif b/sdk/jme3-core/src/com/jme3/gde/core/filters/icons/crossedEye.gif new file mode 100644 index 000000000..9721567d5 Binary files /dev/null and b/sdk/jme3-core/src/com/jme3/gde/core/filters/icons/crossedEye.gif differ diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/icons/eye.gif b/sdk/jme3-core/src/com/jme3/gde/core/filters/icons/eye.gif new file mode 100644 index 000000000..4a724bb78 Binary files /dev/null and b/sdk/jme3-core/src/com/jme3/gde/core/filters/icons/eye.gif differ diff --git a/sdk/jme3-core/src/com/jme3/gde/core/layer.xml b/sdk/jme3-core/src/com/jme3/gde/core/layer.xml index d6de1295e..76ebc2ae6 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/layer.xml +++ b/sdk/jme3-core/src/com/jme3/gde/core/layer.xml @@ -188,7 +188,7 @@ - + diff --git a/sdk/jme3-core/src/com/jme3/gde/core/objects_082.gif b/sdk/jme3-core/src/com/jme3/gde/core/objects_082.gif deleted file mode 100644 index d3b22ce4f..000000000 Binary files a/sdk/jme3-core/src/com/jme3/gde/core/objects_082.gif and /dev/null differ diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.form b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.form index 0dd8d7a34..a019274f3 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.form +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.form @@ -53,7 +53,7 @@ - + diff --git a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java index 4365b5e45..54a589367 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/sceneviewer/SceneViewerTopComponent.java @@ -118,7 +118,7 @@ public final class SceneViewerTopComponent extends TopComponent { }); jToolBar1.add(enableCamLight); - jToggleButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/core/objects_082.gif"))); // NOI18N + jToggleButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/core/filters/icons/eye.gif"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(jToggleButton1, org.openide.util.NbBundle.getMessage(SceneViewerTopComponent.class, "SceneViewerTopComponent.jToggleButton1.text")); // NOI18N jToggleButton1.setToolTipText(org.openide.util.NbBundle.getMessage(SceneViewerTopComponent.class, "SceneViewerTopComponent.jToggleButton1.toolTipText")); // NOI18N jToggleButton1.setFocusable(false);