|
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.project.ui; import java.awt.Component; import java.io.IOException; import java.util.Collections; import java.util.Set; import javax.swing.JComponent; import javax.swing.event.ChangeListener; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectUtils; import org.netbeans.api.project.Sources; import org.netbeans.spi.project.ui.templates.support.Templates; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; import org.openide.loaders.DataFolder; import org.openide.loaders.DataObject; /** Iterator useful for NewFileWizard. Implements WD.InstantiatingIterator, * rest of methods delegates to WD.ArrayIterator created only with SimpleTargetChooserPanel. * * @author Jiri Rechtacek */ public class NewFileIterator implements WizardDescriptor.InstantiatingIterator { private static final long serialVersionUID = 1L; private transient boolean isLibrary; private transient WizardDescriptor.Iterator simpleIterator; private transient WizardDescriptor.Panel[] panels; private transient WizardDescriptor wiz; private transient Project currentProject; private transient boolean isFolder; /** Create a new wizard iterator. */ private NewFileIterator (boolean isFolderIterator) { isFolder = isFolderIterator; } public static NewFileIterator genericFileIterator () { return new NewFileIterator (false); } public static NewFileIterator folderIterator () { return new NewFileIterator (true); } public static NewFileIterator emptyFileIterator () { return new NewFileIterator (false); } private WizardDescriptor.Iterator getSimpleIterator () { if (simpleIterator == null) { assert panels != null && panels.length > 0; simpleIterator = new WizardDescriptor.ArrayIterator (panels); } return simpleIterator; } private WizardDescriptor.Panel[] getPanels (WizardDescriptor wizardDescriptor) { Project project = Templates.getProject( wizardDescriptor ); assert project != null : wizardDescriptor; if (!project.equals (currentProject) || panels == null) { currentProject = project; Sources sources = ProjectUtils.getSources(project); if (isFolder) { panels = new WizardDescriptor.Panel[] { new SimpleTargetChooserPanel (project, sources.getSourceGroups (Sources.TYPE_GENERIC), null, true) }; } else { panels = new WizardDescriptor.Panel[] { Templates.createSimpleTargetChooser (project, sources.getSourceGroups (Sources.TYPE_GENERIC)) }; } } return panels; } private String[] createSteps (String[] before) { assert panels != null; if (before == null) { before = new String[0]; } String[] res = new String[ (before.length - 1) + panels.length]; for (int i = 0; i < res.length; i++) { if (i < (before.length - 1)) { res[i] = before[i]; } else { res[i] = panels[i - before.length + 1].getComponent ().getName (); } } return res; } public Set/* |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.