|
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.web.dd.wizards; import java.awt.Component; import java.io.IOException; import java.util.Collections; import java.util.NoSuchElementException; import java.util.Set; import javax.swing.JComponent; import javax.swing.event.ChangeListener; import java.text.MessageFormat; import org.openide.ErrorManager; import org.openide.NotifyDescriptor; import org.openide.filesystems.FileObject; import org.openide.WizardDescriptor; import org.openide.cookies.OpenCookie; import org.openide.cookies.SaveCookie; import org.openide.loaders.*; import org.openide.util.NbBundle; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.web.dd.*; import org.openide.DialogDisplayer; import org.openide.src.ClassElement; import org.openide.src.SourceException; import org.netbeans.spi.project.ui.templates.support.Templates; import org.netbeans.api.project.Project; import org.netbeans.api.project.Sources; import org.netbeans.api.project.SourceGroup; import org.netbeans.modules.web.api.webmodule.WebProjectConstants; import org.netbeans.spi.java.project.support.ui.templates.JavaTemplates; import org.netbeans.api.java.project.JavaProjectConstants; /** A template wizard iterator (sequence of panels). * Used to fill in the second and subsequent panels in the New wizard. * Associate this to a template inside a layer using the * Sequence of Panels extra property. * Create one or more panels from template as needed too. * * @author mk115033 */ public class ListenerIterator implements TemplateWizard.Iterator { // CHANGEME vvv //private static final long serialVersionUID = ...L; // You should define what panels you want to use here: private ListenerPanel panel; protected WizardDescriptor.Panel[] createPanels (TemplateWizard wizard) { Project project = Templates.getProject( wiz ); Sources sources = (Sources) project.getLookup().lookup(Sources.class); SourceGroup[] sourceGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); //NOI18N panel = new ListenerPanel(wizard); return new WizardDescriptor.Panel[] { // Assuming you want to keep the default 2nd panel: JavaTemplates.createPackageChooser(project,sourceGroups,panel) }; } public Set instantiate (TemplateWizard wiz) throws IOException/*, IllegalStateException*/ { // Here is the default plain behavior. Simply takes the selected // template (you need to have included the standard second panel // in createPanels(), or at least set the properties targetName and // targetFolder correctly), instantiates it in the provided // position, and returns the result. // More advanced wizards can create multiple objects from template // (return them all in the result of this method), populate file // contents on the fly, etc. DataFolder targetFolder = wiz.getTargetFolder (); FileObject folder = wiz.getTargetFolder().getPrimaryFile(); ClassPath classPath = ClassPath.getClassPath(folder,ClassPath.SOURCE); String listenerName = wiz.getTargetName(); DataObject result=null; if (classPath!=null && "src".equals(classPath.findOwnerRoot(folder).getName())) { //NOI18N DataObject template = wiz.getTemplate (); if (listenerName==null) { // Default name. result = template.createFromTemplate (targetFolder); } else { result = template.createFromTemplate (targetFolder, listenerName); } String className = classPath.getResourceName(result.getPrimaryFile(),'.',false); if (result!=null && panel.createElementInDD()){ FileObject webAppFo=DeployData.getWebAppFor(folder); WebApp webApp=null; if (webAppFo!=null) { webApp = DDProvider.getDefault().getDDRoot(webAppFo); } if (webApp!=null) { Listener[] oldListeners = webApp.getListener(); boolean found=false; for (int i=0;i |
... 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.