SDK - Filter Editor :
- Added a disable/enable filter item in the context menu in the filter explorer (default action) - Changed filter icon and created a propper package for filter related icons - Filter icon now switch from enabled to disabled git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7805 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
542108d108
commit
1809a23f44
@ -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);
|
||||
|
@ -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")
|
||||
|
@ -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) {
|
||||
|
@ -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<Void>() {
|
||||
|
||||
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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
BIN
sdk/jme3-core/src/com/jme3/gde/core/filters/icons/crossedEye.gif
Normal file
BIN
sdk/jme3-core/src/com/jme3/gde/core/filters/icons/crossedEye.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1022 B |
BIN
sdk/jme3-core/src/com/jme3/gde/core/filters/icons/eye.gif
Normal file
BIN
sdk/jme3-core/src/com/jme3/gde/core/filters/icons/eye.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 990 B |
@ -188,7 +188,7 @@
|
||||
</folder>
|
||||
<folder name="Factories">
|
||||
<file name="FilterPostProcessorDataLoader.instance">
|
||||
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/com/jme3/gde/core/objects_082.gif"/>
|
||||
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:com/jme3/gde/core/filters/icons/eye.gif"/>
|
||||
<attr name="dataObjectClass" stringvalue="com.jme3.gde.core.assets.FilterDataObject"/>
|
||||
<attr name="instanceCreate" methodvalue="org.openide.loaders.DataLoaderPool.factory"/>
|
||||
<attr name="mimeType" stringvalue="application/jme3filterpostprocessor"/>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 225 B |
@ -53,7 +53,7 @@
|
||||
<Component class="javax.swing.JToggleButton" name="jToggleButton1">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/jme3/gde/core/objects_082.gif"/>
|
||||
<Image iconType="3" name="com/jme3/gde/core/filters/icons/eye.gif"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="com/jme3/gde/core/sceneviewer/Bundle.properties" key="SceneViewerTopComponent.jToggleButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user