|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.beaninfo.editors; import java.beans.*; import java.util.Enumeration; import org.openide.ServiceType; import org.openide.explorer.propertysheet.*; import org.openide.util.Lookup; /** Support for property editor for Executor. * * @author Jaroslav Tulach */ public class ServiceTypeEditor extends java.beans.PropertyEditorSupport implements ExPropertyEditor { /** Name of the custom property that can be passed in PropertyEnv. */ private static final String PROPERTY_NEW_TYPE = "createNew"; // NOI18N /** Name of the custom property that can be passed in PropertyEnv. */ private static final String PROPERTY_SUPERCLASS = "superClass"; // NOI18N /** tagx */ private String[] tags; /** class to work on */ private Class clazz; /** message key to be used in custom editor */ private String message; /** Environment passed to the ExPropertyEditor*/ private PropertyEnv env; /** * This variable can be read in attachEnv. Defaults to false, * false - we are selecting from the registered service types, true - creating * new instances of the services */ private boolean createNewInstance = false; /** constructs new property editor. */ public ServiceTypeEditor() { this (ServiceType.class, "LAB_ChooseServiceType"); // NOI18N } /** constructs new property editor. * @param clazz the class to use * @param message the message for custom editor */ public ServiceTypeEditor(Class clazz, String message) { this.clazz = clazz; this.message = message; } /** * This method is called by the IDE to pass * the environment to the property editor. * @param env Environment passed by the ide. */ public void attachEnv(PropertyEnv env) { this.env = env; Object newObj = env.getFeatureDescriptor().getValue(PROPERTY_NEW_TYPE); if (newObj instanceof Boolean) { createNewInstance = ((Boolean)newObj).booleanValue(); } Object sup = env.getFeatureDescriptor().getValue(PROPERTY_SUPERCLASS); if (sup instanceof Class) { clazz = (Class)sup; } } /** Updates the list of executors. */ private void updateTags () { java.util.LinkedList names = new java.util.LinkedList (); ServiceType.Registry registry = (ServiceType.Registry)Lookup.getDefault () .lookup (ServiceType.Registry.class); Enumeration ee = registry.services (clazz); while (ee.hasMoreElements()) { ServiceType e = (ServiceType) ee.nextElement(); names.add(e.getName()); } names.toArray(tags = new String[names.size()]); } //---------------------------------------------------------------------- /** * @return The property value as a human editable string. * |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.