|
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-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.java.ui.nodes.editors; import org.netbeans.jmi.javamodel.TypeParameter; import org.netbeans.jmi.javamodel.JavaModelPackage; import org.netbeans.modules.javacore.internalapi.JavaMetamodel; import org.netbeans.modules.java.ui.nodes.elements.ElementNode; import org.openide.ErrorManager; import org.openide.explorer.propertysheet.ExPropertyEditor; import org.openide.explorer.propertysheet.PropertyEnv; import javax.jmi.reflect.JmiException; import java.beans.PropertyEditorSupport; /** Property editor for array of {@link org.netbeans.jmi.javamodel.TypeParameter} class * * @author Jan Pokorsky */ public final class TypeParameterArrayEditor extends PropertyEditorSupport implements ExPropertyEditor { private JavaModelPackage model; public String getAsText() { TypeParameter[] tps = (TypeParameter[]) getValue(); StringBuffer text = new StringBuffer(); try { JavaMetamodel.getDefaultRepository().beginTrans(false); try { for (int i = 0; i < tps.length; i++) { TypeParameter tp = tps[i]; if (i > 0) { text.append(", "); // NOI18N } text.append(param2String(tp)); } } finally { JavaMetamodel.getDefaultRepository().endTrans(); } } catch (JmiException e) { ErrorManager.getDefault().notify(e); } return text.toString(); } public void setAsText(String text) throws IllegalArgumentException { throw new UnsupportedOperationException(); } public boolean supportsCustomEditor() { return false; } public static String params2String(TypeParameter[] params, String delimiter) { StringBuffer buf = new StringBuffer(30); for (int i = 0; i < params.length; i++) { if (i > 0) buf.append(delimiter); // NOI18N buf.append(param2String(params[i])); } return buf.toString(); } private static String param2String(TypeParameter tp) { int start = tp.getStartOffset(); int end = tp.getEndOffset(); return tp.getResource().getSourceText().substring(start, end); } public void attachEnv(PropertyEnv env) { model = ElementNode.getModel(env.getFeatureDescriptor()); } } |
... 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.