diff -r e049ab8b07f3 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategory.java --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategory.java Thu Jun 12 15:08:23 2008 +0400 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/SourceCategory.java Mon Jun 16 17:05:32 2008 +0200 @@ -45,6 +45,7 @@ public enum SourceCategory { NONE, SCRIPTS, SRC, WEBAPP, - LIB; + LIB, + PLUGIN; } diff -r e049ab8b07f3 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/Bundle.properties --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/Bundle.properties Thu Jun 12 15:08:23 2008 +0400 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/Bundle.properties Mon Jun 16 17:05:32 2008 +0200 @@ -1,6 +1,7 @@ CTL_CreateViewAction=Create view CTL_CreateViewAction=Create view LBL_process_problem=There was a problem creating the grails process: CTL_GenerateAllAction=Generate all +CTL_CreatePluginAction=Create plugin MSG_Runtime_Not_Configured=The Grails Home has not been set.
\ Use menu Tools/Options/Groovy to set the environment. \ No newline at end of file diff -r e049ab8b07f3 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/CreatePluginAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/CreatePluginAction.java Mon Jun 16 17:05:32 2008 +0200 @@ -0,0 +1,117 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2008 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.groovy.grailsproject.actions; + +import java.awt.Dialog; +import java.awt.event.ActionEvent; +import java.util.Set; +import java.util.logging.Logger; +import javax.swing.AbstractAction; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.modules.extexecution.api.input.LineProcessor; +import org.netbeans.modules.groovy.grails.api.GrailsProjectConfig; +import org.netbeans.modules.groovy.grails.api.GrailsRuntime; +import org.netbeans.modules.groovy.grailsproject.GrailsProject; +import org.netbeans.modules.groovy.grailsproject.SourceCategory; +import org.netbeans.modules.groovy.grailsproject.ui.wizards.NewArtifactWizardIterator; +import org.openide.DialogDisplayer; +import org.openide.WizardDescriptor; + +/** + * + * @author david + */ +public class CreatePluginAction extends AbstractAction { + + private static final Logger LOG = Logger.getLogger(CreatePluginAction.class.getName()); + + private final GrailsProject prj; + + private final GrailsProjectConfig prjConfig; + + public CreatePluginAction(Project prj) { + super("Create plugin"); + this.prj = (GrailsProject) prj; + prjConfig = GrailsProjectConfig.forProject(prj); + } + + @Override + public boolean isEnabled(){ + return true; + } + + public void actionPerformed(ActionEvent arg0) { + final GrailsRuntime runtime = GrailsRuntime.getInstance(); + if (!runtime.isConfigured()) { + ConfigSupport.showConfigurationWarning(runtime); + return; + } + + //DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class); + + WizardDescriptor wiz = null; + + //String artifactName = dataObject.getPrimaryFile().getName(); + NewArtifactWizardIterator it = new NewArtifactWizardIterator(prj, SourceCategory.PLUGIN, "Grails Plugin"); + + wiz = new WizardDescriptor(it); + + assert wiz != null; + + wiz.putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); // NOI18N + wiz.putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); // NOI18N + wiz.putProperty("WizardPanel_contentNumbered", Boolean.TRUE); // NOI18N + + wiz.setTitleFormat(new java.text.MessageFormat("{0}")); // NOI18N + + Dialog dlg = DialogDisplayer.getDefault().createDialog(wiz); + + try { + dlg.setVisible(true); + if (wiz.getValue() == WizardDescriptor.FINISH_OPTION) { + Set result = wiz.getInstantiatedObjects(); + } + } finally { + dlg.dispose(); + } + } + +} diff -r e049ab8b07f3 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/GrailsCommandAction.java --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/GrailsCommandAction.java Thu Jun 12 15:08:23 2008 +0400 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/actions/GrailsCommandAction.java Mon Jun 16 17:05:32 2008 +0200 @@ -39,6 +39,7 @@ public class GrailsCommandAction extends public class GrailsCommandAction extends AbstractAction implements Presenter.Popup { private final JMenu grailsCommandMenu = new JMenu("Grails"); + private final JMenu grailsPluginsMenu = new JMenu("Plugins"); private final Project project; @@ -49,6 +50,9 @@ public class GrailsCommandAction extends grailsCommandMenu.add(new GrailsTargetAction(project, "Compile", "compile")); grailsCommandMenu.add(new GrailsTargetAction(project, "Statistics", "stats")); grailsCommandMenu.add(new GrailsTargetAction(project, "Upgrade", "upgrade")); + + grailsPluginsMenu.add(new CreatePluginAction(project)); + grailsCommandMenu.add(grailsPluginsMenu); List cmdlist = GrailsCustomScriptProvider.forProject(project).getCustomScripts(); diff -r e049ab8b07f3 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/Bundle.properties --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/Bundle.properties Thu Jun 12 15:08:23 2008 +0400 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/Bundle.properties Mon Jun 16 17:05:32 2008 +0200 @@ -48,6 +48,8 @@ WIZARD_TITLE_VIEWS=View name WIZARD_TITLE_VIEWS=View name WIZARD_TITLE_TAGLIB=Taglib name WIZARD_TITLE_SCRIPTS=Script name +WIZARD_TITLE_CREATE_PLUGIN=Create plugin +WIZARD_LABEL_PLUGIN_NAME=Plugin name: GetProjectLocationPanel.FileChooserTitle=Select Project Location GetProjectLocationPanel.setAsMainCheckBox.text=Set as Main Project diff -r e049ab8b07f3 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/GetArtifactNamePanel.java --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/GetArtifactNamePanel.java Thu Jun 12 15:08:23 2008 +0400 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/GetArtifactNamePanel.java Mon Jun 16 17:05:32 2008 +0200 @@ -96,7 +96,12 @@ public class GetArtifactNamePanel extend case SCRIPTS: setName(NbBundle.getMessage(GetArtifactNamePanel.class,"WIZARD_TITLE_SCRIPTS")); // NOI18N subDirName = "scripts"; - break; + break; + case PLUGIN: + setName(NbBundle.getMessage(GetArtifactNamePanel.class,"WIZARD_TITLE_CREATE_PLUGIN")); // NOI18N + classNameLabel.setText(NbBundle.getMessage(GetArtifactNamePanel.class,"WIZARD_LABEL_PLUGIN_NAME")); // NOI18N + subDirName = ""; + break; } // populate the panel with some stuff @@ -105,10 +110,13 @@ public class GetArtifactNamePanel extend projectTextField.setText(project.getProjectDirectory().getName()); - baseDir = FileUtil.getFileDisplayName(project.getProjectDirectory()) + - File.separatorChar + dirPrefix + subDirName; + baseDir = FileUtil.getFileDisplayName(project.getProjectDirectory()); + if (subDirName.length() > 0) { + baseDir += File.separatorChar + dirPrefix + subDirName; + } createdFileTextField.setText(baseDir + File.separatorChar ); + // register event listeners to auto-update some fields. @@ -208,8 +216,10 @@ public class GetArtifactNamePanel extend Document doc = e.getDocument(); if ( doc == classNameTextField.getDocument() ) { - - fileName = baseDir + File.separatorChar + classNameTextField.getText() + suffix + ".groovy"; + fileName = baseDir + File.separatorChar + classNameTextField.getText(); + if (!cat.equals(SourceCategory.PLUGIN)) { + fileName += suffix + ".groovy"; + } createdFileTextField.setText(fileName); projectTextField.setText(project.getProjectDirectory().getName()); diff -r e049ab8b07f3 groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/NewArtifactWizardIterator.java --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/NewArtifactWizardIterator.java Thu Jun 12 15:08:23 2008 +0400 +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/wizards/NewArtifactWizardIterator.java Mon Jun 16 17:05:32 2008 +0200 @@ -103,7 +103,11 @@ public class NewArtifactWizardIterator i case SCRIPTS: wizardTitle = NbBundle.getMessage(NewArtifactWizardIterator.class,"WIZARD_TITLE_SCRIPTS"); serverCommand = "create-script"; // NOI18N - break; + break; + case PLUGIN: + wizardTitle = NbBundle.getMessage(NewArtifactWizardIterator.class,"WIZARD_TITLE_CREATE_PLUGIN"); + serverCommand = "create-plugin"; // NOI18N + break; } } @@ -177,7 +181,9 @@ public class NewArtifactWizardIterator i Component c = pls.getComponent(); - pls.setArtifactName(artifactName); + if (!cat.equals(SourceCategory.PLUGIN)) { + pls.setArtifactName(artifactName); + } if (c instanceof JComponent) { // assume Swing components JComponent jc = (JComponent)c;