001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 2004-2005 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.jmx.examples;
043:
044: import java.io.File;
045: import java.util.Collections;
046: import java.util.NoSuchElementException;
047: import javax.swing.JComponent;
048: import org.openide.WizardDescriptor;
049: import org.openide.filesystems.FileObject;
050: import org.openide.loaders.DataObject;
051: import org.openide.loaders.TemplateWizard;
052: import org.openide.util.NbBundle;
053:
054: /**
055: *
056: * @author Martin Grebac
057: */
058: public class JMXSampleProjectIterator implements
059: TemplateWizard.Iterator {
060:
061: private static final long serialVersionUID = 4L;
062:
063: int currentIndex;
064: PanelConfigureProject basicPanel;
065: private transient WizardDescriptor wiz;
066:
067: static Object create() {
068: return new JMXSampleProjectIterator();
069: }
070:
071: public JMXSampleProjectIterator() {
072: }
073:
074: public void addChangeListener(
075: javax.swing.event.ChangeListener changeListener) {
076: }
077:
078: public void removeChangeListener(
079: javax.swing.event.ChangeListener changeListener) {
080: }
081:
082: public org.openide.WizardDescriptor.Panel current() {
083: return basicPanel;
084: }
085:
086: public boolean hasNext() {
087: return false;
088: }
089:
090: public boolean hasPrevious() {
091: return false;
092: }
093:
094: public void initialize(
095: org.openide.loaders.TemplateWizard templateWizard) {
096: this .wiz = templateWizard;
097: String name = templateWizard.getTemplate().getNodeDelegate()
098: .getDisplayName();
099: if (name != null) {
100: name = name.replaceAll(" ", ""); //NOI18N
101: }
102: templateWizard.putProperty(WizardProperties.NAME, name);
103: basicPanel = new PanelConfigureProject();
104: currentIndex = 0;
105: updateStepsList();
106: }
107:
108: public void uninitialize(
109: org.openide.loaders.TemplateWizard templateWizard) {
110: basicPanel = null;
111: currentIndex = -1;
112: this .wiz.putProperty("projdir", null); //NOI18N
113: this .wiz.putProperty("name", null); //NOI18N
114: }
115:
116: public java.util.Set instantiate(
117: org.openide.loaders.TemplateWizard templateWizard)
118: throws java.io.IOException {
119: File projectLocation = (File) wiz
120: .getProperty(WizardProperties.PROJECT_DIR);
121: String name = (String) wiz.getProperty(WizardProperties.NAME);
122:
123: FileObject prjLoc = null;
124: prjLoc = JMXSampleProjectGenerator.createProjectFromTemplate(
125: templateWizard.getTemplate().getPrimaryFile(),
126: projectLocation, name);
127: return Collections.singleton(DataObject.find(prjLoc));
128: }
129:
130: public String name() {
131: return current().getComponent().getName();
132: }
133:
134: public void nextPanel() {
135: throw new NoSuchElementException();
136: }
137:
138: public void previousPanel() {
139: throw new NoSuchElementException();
140: }
141:
142: void updateStepsList() {
143: JComponent component = (JComponent) current().getComponent();
144: if (component == null) {
145: return;
146: }
147: String[] list;
148: list = new String[] { NbBundle.getMessage(
149: PanelConfigureProject.class,
150: "LBL_NWP1_ProjectTitleName"), // NOI18N
151: };
152: component.putClientProperty("WizardPanel_contentData", list); // NOI18N
153: component.putClientProperty("WizardPanel_contentSelectedIndex",
154: new Integer(currentIndex)); // NOI18N
155: }
156:
157: }
|