Author: snjeza
Date: 2008-07-19 21:48:38 -0400 (Sat, 19 Jul 2008)
New Revision: 9188
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/.classpath
trunk/portlet/plugins/org.jboss.tools.portlet.ui/.project
trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF
trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.html
trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.ini
trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.mappings
trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.properties
trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties
trunk/portlet/plugins/org.jboss.tools.portlet.ui/icons/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/icons/portlet_wiz.gif
trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml
trunk/portlet/plugins/org.jboss.tools.portlet.ui/rhds_wiz.png
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/CreatePortletTemplateModel.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/NewPortletClassOperation.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/INewPortletClassDataModelProperties.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/IPortletUIConstants.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/PortletFacetInstallPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddJBossPortletWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddPortletWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_class.template
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_constructors.template
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_flags.template
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_imports.template
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_methods.template
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_package.template
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/portlet.javajet
Log:
JBIDE-2233 Ability to create a new "Portlet" project
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/.classpath
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/.classpath
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/.classpath 2008-07-20 01:48:38 UTC
(rev 9188)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/.project
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/.project (rev
0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/.project 2008-07-20 01:48:38 UTC (rev
9188)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.portlet.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss Portlet
+Bundle-SymbolicName: org.jboss.tools.portlet.ui;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.portlet.ui.PortletUIActivator
+Bundle-Vendor: Red Hat, Inc.
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.common.frameworks.ui,
+ org.eclipse.core.resources,
+ org.eclipse.jst.servlet.ui,
+ org.eclipse.jst.j2ee.web,
+ org.eclipse.jst.j2ee.core,
+ org.eclipse.jst.j2ee.ui,
+ org.eclipse.jst.jee.ui,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.jdt.core,
+ org.eclipse.jst.j2ee,
+ org.eclipse.jem.util,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.edit,
+ org.jboss.tools.portlet.core,
+ org.eclipse.emf.codegen,
+ org.eclipse.wst.xml.core,
+ org.eclipse.wst.sse.core
+Bundle-ActivationPolicy: lazy
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.html
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.html
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.html 2008-07-20 01:48:38 UTC
(rev 9188)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
+<title>JBoss Portlet</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>JBoss Portlet</h1>
+
+<p>
+This plugin is part of the JBoss Tools developed by the <a
href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a
href="http://www.jboss.org/tools">JBoss Tools project
page</a></p>
+
+<p>
+This software is distributed under the terms of the Eclipse Public License - v 1.0
+(see <a
href="www.eclipse.org/legal/epl-v10.html">Eclipse Public License
- Version 1.0</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.ini
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.ini
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.ini 2008-07-20 01:48:38 UTC
(rev 9188)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog
(translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=rhds_wiz.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which
the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.mappings
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.mappings
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.mappings 2008-07-20 01:48:38
UTC (rev 9188)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.properties
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.properties
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/about.properties 2008-07-20 01:48:38
UTC (rev 9188)
@@ -0,0 +1,7 @@
+blurb=JBoss Portlet\n\
+\n\
+Version: {featureVersion}\n\
+\n\
+(c) Copyright JBoss Inc. contributors and others 2004 - 2008. All rights reserved.\n\
+Visit
http://jboss.org/tools
+
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties 2008-07-20 01:48:38
UTC (rev 9188)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/icons/portlet_wiz.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/icons/portlet_wiz.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml 2008-07-20 01:48:38 UTC
(rev 9188)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <!--
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.wizardPages">
+ <wizard-pages action="jboss.portlet.install">
+ <page
class="org.jboss.tools.portlet.ui.internal.project.facet.PortletFacetInstallPage"/>
+ </wizard-pages>
+ </extension>
+ -->
+
+ <!-- New Java Portlet wizard -->
+ <extension point="org.eclipse.ui.newWizards">
+ <category id="org.jboss.tools.portlet"
+ name="Portlet"
+ parentCategory="org.jboss.tools.jst.web">
+ </category>
+ <wizard
+ id="org.jboss.tools.portlet.ui.wizard.NewJavaPortletWizard"
+ name="Java Portlet"
+ class="org.jboss.tools.portlet.ui.internal.wizard.NewPortletWizard"
+ category="org.jboss.tools.jst.web/org.jboss.tools.portlet"
+ icon="icons/portlet_wiz.gif">
+ <description>Create a new Java Portlet</description>
+ <selection class="org.eclipse.core.resources.IResource" />
+ </wizard>
+ </extension>
+
+</plugin>
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/rhds_wiz.png
===================================================================
(Binary files differ)
Property changes on: trunk/portlet/plugins/org.jboss.tools.portlet.ui/rhds_wiz.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,273 @@
+package org.jboss.tools.portlet.operations;
+
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.TITLE;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.VIEW_MODE;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.EDIT_MODE;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.HELP_MODE;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.INSTANCE_NAME;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.WINDOW_NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.IF_EXISTS;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PAGE_REGION;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PARENT_PORTAL;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PORTLET_HEIGHT;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jst.j2ee.internal.common.operations.NewJavaEEArtifactClassOperation;
+import org.eclipse.jst.j2ee.internal.web.operations.AddWebClassOperation;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import
org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditProviderOperation;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+/**
+ * @author snjeza
+ */
+public class AddPortletOperation extends AddWebClassOperation {
+
+ /**
+ * This is the constructor which should be used when creating the operation.
+ * It will not accept null parameter. It will not return null.
+ *
+ * @see ArtifactEditProviderOperation#ArtifactEditProviderOperation(IDataModel)
+ *
+ * @param dataModel
+ * @return AddPortletOperation
+ */
+ public AddPortletOperation(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+ @Override
+ protected NewJavaEEArtifactClassOperation getNewClassOperation() {
+ return new NewPortletClassOperation(getDataModel());
+ }
+
+ protected void generateMetaData(IDataModel aModel, String qualifiedClassName) {
+ // update the portlet.xml file
+ updatePortletXml(aModel);
+
+ // generate/update portlet-instances.xml
+ updatePortletInstance(aModel);
+
+ // generate/update *.object.xml
+ updatePortletObject(aModel);
+ }
+
+ private void updatePortletObject(IDataModel model) {
+
+ String name = model.getStringProperty(NAME);
+ String instanceId = model.getStringProperty(INSTANCE_NAME);
+ String windowName = model.getStringProperty(WINDOW_NAME);
+ String ifExists = model.getStringProperty(IF_EXISTS);
+ String parent = model.getStringProperty(PARENT_PORTAL);;
+ String region = model.getStringProperty(PAGE_REGION);
+ String height = model.getStringProperty(PORTLET_HEIGHT);
+
+ String fileName = name.toLowerCase() + "-object.xml";
+
+ IProject project = getTargetProject();
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFile portletVirtualFile =
component.getRootFolder().getFolder("WEB-INF").getFile(
+ fileName);
+
+ if (!portletVirtualFile.getUnderlyingFile().exists()) {
+ try {
+ PortletCoreActivator.createPortletObject(project,portletVirtualFile.getUnderlyingFile());
+ } catch (Exception e) {
+ PortletCoreActivator.log(e);
+ return;
+ }
+ }
+
+ IFile portletFile = portletVirtualFile.getUnderlyingFile();
+ IDOMModel domModel = null;
+ try {
+ domModel = (IDOMModel) StructuredModelManager.getModelManager()
+ .getModelForEdit(portletFile);
+ Document document = domModel.getDocument();
+ Element element = document.getDocumentElement();
+
+ Element deployment = document.createElement("deployment");
+ element.appendChild(deployment);
+
+ addNode(document,deployment,"if-exists",ifExists);
+ addNode(document,deployment,"parent-ref",parent);
+
+ Element window = addNode(document,deployment,"window",null);
+
+ addNode(document,window,"window-name",windowName);
+ addNode(document,window,"instance-ref",instanceId);
+ addNode(document,window,"region",region);
+ addNode(document,window,"height",height);
+
+ domModel.save();
+ } catch (Exception e) {
+ PortletCoreActivator.getDefault().log(e);
+ } finally {
+ if (domModel != null) {
+ domModel.releaseFromEdit();
+ }
+ }
+
+ try {
+ new FormatProcessorXML().formatFile(portletFile);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ private void updatePortletInstance(IDataModel model) {
+
+ String name = model.getStringProperty(NAME);
+ String instanceId = model.getStringProperty(INSTANCE_NAME);
+
+ IProject project = getTargetProject();
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFile portletVirtualFile = component.getRootFolder().getFile(
+ IPortletConstants.PORTLET_INSTANCES_FILE);
+
+ if (!portletVirtualFile.getUnderlyingFile().exists()) {
+ try {
+ PortletCoreActivator.createPortletInstances(project,portletVirtualFile.getUnderlyingFile());
+ } catch (Exception e) {
+ PortletCoreActivator.log(e);
+ return;
+ }
+ }
+
+ IFile portletFile = portletVirtualFile.getUnderlyingFile();
+ IDOMModel domModel = null;
+ try {
+ domModel = (IDOMModel) StructuredModelManager.getModelManager()
+ .getModelForEdit(portletFile);
+ Document document = domModel.getDocument();
+ Element element = document.getDocumentElement();
+
+ Element deployment = document.createElement("deployment");
+ element.appendChild(deployment);
+
+ Element instance = addNode(document,deployment,"instance",null);
+ addNode(document,instance,"instance-id",instanceId);
+ addNode(document,instance,"portlet-ref",name);
+ domModel.save();
+ } catch (Exception e) {
+ PortletCoreActivator.getDefault().log(e);
+ } finally {
+ if (domModel != null) {
+ domModel.releaseFromEdit();
+ }
+ }
+
+ try {
+ new FormatProcessorXML().formatFile(portletFile);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ private void updatePortletXml(IDataModel aModel) {
+ String displayName = aModel.getStringProperty(DISPLAY_NAME);
+ String name = aModel.getStringProperty(NAME);
+ String title = aModel.getStringProperty(TITLE);
+ String description = aModel.getStringProperty(DESCRIPTION);
+ String className =
aModel.getStringProperty(INewPortletClassDataModelProperties.QUALIFIED_CLASS_NAME);
+
+ IProject project = getTargetProject();
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFile portletVirtualFile = component.getRootFolder().getFile(
+ IPortletConstants.CONFIG_PATH);
+
+ if (!portletVirtualFile.getUnderlyingFile().exists()) {
+ PortletCoreActivator.getDefault().log(new RuntimeException("The portlet.xml file
doesn't exist"));
+ return;
+ }
+
+ IFile portletFile = portletVirtualFile.getUnderlyingFile();
+ IDOMModel domModel = null;
+ try {
+ domModel = (IDOMModel) StructuredModelManager.getModelManager()
+ .getModelForEdit(portletFile);
+ Document document = domModel.getDocument();
+ Element element = document.getDocumentElement();
+
+ Element portlet = document.createElement("portlet");
+ element.appendChild(portlet);
+ // description
+ if (description != null && description.trim().length() > 0) {
+ addNode(document,portlet,"description",description);
+ }
+
+ // portlet-name
+ addNode(document,portlet,"portlet-name",name);
+
+ // display-name
+ if (displayName != null && displayName.trim().length() > 0) {
+ addNode(document,portlet,"display-name",displayName);
+ }
+ // portlet-class
+ addNode(document,portlet,"portlet-class",className);
+
+ // supports
+ Element supports = addNode(document,portlet,"supports",null);
+
+ addNode(document,supports,"mime-type","text/html");
+ if (aModel.getBooleanProperty(VIEW_MODE)) {
+ addNode(document,supports,"portlet-mode","VIEW");
+ }
+ if (aModel.getBooleanProperty(EDIT_MODE)) {
+ addNode(document,supports,"portlet-mode","EDIT");
+ }
+ if (aModel.getBooleanProperty(HELP_MODE)) {
+ addNode(document,supports,"portlet-mode","HELP");
+ }
+
+ // portlet-info
+ Element portletInfo = addNode(document,portlet,"portlet-info",null);
+ addNode(document,portletInfo,"title", title);
+
+ domModel.save();
+
+ } catch (Exception e) {
+ PortletCoreActivator.getDefault().log(e);
+ } finally {
+ if (domModel != null) {
+ domModel.releaseFromEdit();
+ }
+ }
+
+ try {
+ new FormatProcessorXML().formatFile(portletFile);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ private Element addNode(Document document,Element element, String tagName, String value)
{
+ Element node = document.createElement(tagName);
+ if (value != null) {
+ Text text = document.createTextNode(value);
+ node.appendChild(text);
+ }
+ element.appendChild(node);
+ return node;
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/CreatePortletTemplateModel.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/CreatePortletTemplateModel.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/CreatePortletTemplateModel.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,224 @@
+package org.jboss.tools.portlet.operations;
+
+import static
org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.ABSTRACT_METHODS;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.DESTROY;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.DO_VIEW;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.DO_EDIT;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.DO_HELP;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.DO_DISPATCH;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PROCESS_ACTION;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.RENDER;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.GET_PORTLET_CONFIG;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.INIT;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.INIT_PARAM;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.DESTROY_SIGNATURE;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.PORTLET_INIT_SIGNATURE;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.DO_DISPATCH_SIGNATURE;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.DO_EDIT_SIGNATURE;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.DO_VIEW_SIGNATURE;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.DO_HELP_SIGNATURE;
+import static
org.jboss.tools.portlet.ui.IPortletUIConstants.GET_PORTLET_CONFIG_SIGNATURE;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.PROCESS_ACTION_SIGNATURE;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.RENDER_SIGNATURE;
+
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_DESTROY;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_INIT;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_GET_PORTLET_CONFIG;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_DO_DISPATCH;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_DO_EDIT;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_DO_HELP;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_DO_VIEW;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_PROCESS_ACTION;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_RENDER;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.METHOD_TO_STRING;
+
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_PORTLET_CONFIG;
+import static
org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_PORTLET_EXCEPTION;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_IO_EXCEPTION;
+import static
org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_SECURITY_EXCEPTION;
+import static
org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_UNAVALIABLE_EXCEPTION;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_PRINTWRITER;
+
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_PORTLET_REQUEST;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_PORTLET_RESPONSE;
+
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_ACTION_REQUEST;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.QUALIFIED_ACTION_RESPONSE;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jst.j2ee.internal.common.operations.Method;
+import org.eclipse.jst.j2ee.internal.web.operations.CreateWebClassTemplateModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+/**
+ * @author snjeza
+ */
+public class CreatePortletTemplateModel extends CreateWebClassTemplateModel {
+
+ public static final int NAME = 0;
+ public static final int VALUE = 1;
+ public static final int DESCRIPTION = 2;
+
+ public CreatePortletTemplateModel(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+ public Collection<String> getImports() {
+ Collection<String> collection = super.getImports();
+
+ if (shouldGenInit()) {
+ collection.add(QUALIFIED_PORTLET_EXCEPTION);
+ }
+
+ if (shouldGenGetPortletConfig()) {
+ collection.add(QUALIFIED_PORTLET_CONFIG);
+ }
+
+ if (shouldGenDoHelp() || shouldGenDoEdit()
+ || shouldGenDoDispatch() || shouldGenRender()) {
+
+ collection.add(QUALIFIED_PORTLET_REQUEST);
+ collection.add(QUALIFIED_PORTLET_RESPONSE);
+ collection.add(QUALIFIED_PORTLET_EXCEPTION);
+ collection.add(QUALIFIED_IO_EXCEPTION);
+ collection.add(QUALIFIED_SECURITY_EXCEPTION);
+ }
+
+ if (shouldGenDoView()) {
+ collection.add(QUALIFIED_PORTLET_REQUEST);
+ collection.add(QUALIFIED_PORTLET_RESPONSE);
+ collection.add(QUALIFIED_PORTLET_EXCEPTION);
+ collection.add(QUALIFIED_IO_EXCEPTION);
+ collection.add(QUALIFIED_UNAVALIABLE_EXCEPTION);
+ collection.add(QUALIFIED_PRINTWRITER);
+ }
+
+ if (shouldGenProcessAction()) {
+ collection.add(QUALIFIED_ACTION_REQUEST);
+ collection.add(QUALIFIED_ACTION_RESPONSE);
+ collection.add(QUALIFIED_PORTLET_EXCEPTION);
+ collection.add(QUALIFIED_IO_EXCEPTION);
+ collection.add(QUALIFIED_SECURITY_EXCEPTION);
+ }
+
+ return collection;
+ }
+
+ public boolean shouldGenInit() {
+ return implementImplementedMethod(METHOD_INIT);
+ }
+
+ public boolean shouldGenDestroy() {
+ return implementImplementedMethod(METHOD_DESTROY);
+ }
+
+ public boolean shouldGenGetPortletConfig() {
+ return implementImplementedMethod(METHOD_GET_PORTLET_CONFIG);
+ }
+
+ public boolean shouldGenDoView() {
+ return implementImplementedMethod(METHOD_DO_VIEW);
+ }
+
+ public boolean shouldGenDoEdit() {
+ return implementImplementedMethod(METHOD_DO_EDIT);
+ }
+
+ public boolean shouldGenDoHelp() {
+ return implementImplementedMethod(METHOD_DO_HELP);
+ }
+
+ public boolean shouldGenDoDispatch() {
+ return implementImplementedMethod(METHOD_DO_DISPATCH);
+ }
+
+ public boolean shouldGenRender() {
+ return implementImplementedMethod(METHOD_RENDER);
+ }
+
+ public boolean shouldGenProcessAction() {
+ return implementImplementedMethod(METHOD_PROCESS_ACTION);
+ }
+
+ public boolean shouldGenToString() {
+ return implementImplementedMethod(METHOD_TO_STRING);
+ }
+
+ public boolean isGenericPortletSuperclass() {
+ return true;
+ }
+
+ public List<String[]> getInitParams() {
+ return (List) dataModel.getProperty(INIT_PARAM);
+ }
+
+ public String getInitParam(int index, int type) {
+ List<String[]> params = getInitParams();
+ if (index < params.size()) {
+ String[] stringArray = params.get(index);
+ return stringArray[type];
+ }
+ return null;
+ }
+
+ protected boolean implementImplementedMethod(String methodName) {
+ if (dataModel.getBooleanProperty(ABSTRACT_METHODS)) {
+ if (methodName.equals(METHOD_INIT))
+ return dataModel.getBooleanProperty(INIT);
+ else if (methodName.equals(METHOD_DESTROY))
+ return dataModel.getBooleanProperty(DESTROY);
+ else if (methodName.equals(METHOD_GET_PORTLET_CONFIG))
+ return dataModel.getBooleanProperty(GET_PORTLET_CONFIG);
+ else if (methodName.equals(METHOD_DO_EDIT))
+ return dataModel.getBooleanProperty(DO_EDIT);
+ else if (methodName.equals(METHOD_DO_VIEW))
+ return dataModel.getBooleanProperty(DO_VIEW);
+ else if (methodName.equals(METHOD_DO_HELP))
+ return dataModel.getBooleanProperty(DO_HELP);
+ else if (methodName.equals(METHOD_DO_DISPATCH))
+ return dataModel.getBooleanProperty(DO_DISPATCH);
+ else if (methodName.equals(METHOD_RENDER))
+ return dataModel.getBooleanProperty(RENDER);
+ else if (methodName.equals(METHOD_PROCESS_ACTION))
+ return dataModel.getBooleanProperty(PROCESS_ACTION);
+ }
+ return false;
+ }
+
+ @Override
+ public Collection<Method> getUnimplementedMethods() {
+ Collection<Method> unimplementedMethods = super
+ .getUnimplementedMethods();
+ Iterator<Method> iterator = unimplementedMethods.iterator();
+
+ while (iterator.hasNext()) {
+ Method method = iterator.next();
+ if ((METHOD_INIT.equals(method.getName()) && PORTLET_INIT_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_DESTROY.equals(method.getName()) && DESTROY_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_GET_PORTLET_CONFIG.equals(method.getName()) &&
GET_PORTLET_CONFIG_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_DO_VIEW.equals(method.getName()) && DO_VIEW_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_DO_EDIT.equals(method.getName()) && DO_EDIT_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_DO_HELP.equals(method.getName()) && DO_HELP_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_DO_DISPATCH.equals(method.getName()) && DO_DISPATCH_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_RENDER.equals(method.getName()) && RENDER_SIGNATURE
+ .equals(method.getSignature()))
+ || (METHOD_PROCESS_ACTION.equals(method.getName()) &&
PROCESS_ACTION_SIGNATURE
+ .equals(method.getSignature()))) {
+ iterator.remove();
+ }
+ }
+
+ return unimplementedMethods;
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/NewPortletClassOperation.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/NewPortletClassOperation.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/NewPortletClassOperation.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,56 @@
+package org.jboss.tools.portlet.operations;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.jet.JETException;
+import org.eclipse.jdt.core.IPackageFragment;
+import
org.eclipse.jst.j2ee.internal.common.operations.CreateJavaEEArtifactTemplateModel;
+import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin;
+import org.eclipse.jst.j2ee.internal.project.WTPJETEmitter;
+import org.eclipse.jst.j2ee.internal.web.operations.NewWebClassOperation;
+import
org.eclipse.wst.common.componentcore.internal.operation.ArtifactEditProviderOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.WTPPlugin;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+
+/**
+ *
+ * @see org.eclipse.jst.j2ee.internal.web.operations.NewServletClassOperation
+ *
+ */
+public class NewPortletClassOperation extends NewWebClassOperation {
+
+ protected static final String TEMPLATE_DIR = "/templates/"; //$NON-NLS-1$
+
+ protected static final String TEMPLATE_FILE = "/templates/portlet.javajet";
//$NON-NLS-1$
+
+
+ public NewPortletClassOperation(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+ @Override
+ protected CreatePortletTemplateModel createTemplateModel() {
+ return new CreatePortletTemplateModel(model);
+ }
+
+ @Override
+ protected String getTemplateFile() {
+ return TEMPLATE_FILE;
+ }
+
+ @Override
+ protected String generateTemplateSource(WTPPlugin plugin,
CreateJavaEEArtifactTemplateModel tempModel, String template_file, IProgressMonitor
monitor) throws JETException {
+ URL templateURL = FileLocator.find(PortletUIActivator.getDefault().getBundle(), new
Path(template_file), null);
+ cleanUpOldEmitterProject();
+ WTPJETEmitter emitter = new WTPJETEmitter(templateURL.toString(),
this.getClass().getClassLoader());
+ emitter.setIntelligentLinkingEnabled(true);
+ emitter.addVariable(J2EEPlugin.getPlugin().getPluginID(),
J2EEPlugin.getPlugin().getPluginID());
+ emitter.addVariable(plugin.getPluginID(), plugin.getPluginID());
+ emitter.addVariable(PortletUIActivator.PLUGIN_ID, PortletUIActivator.PLUGIN_ID);
+ return emitter.generate(monitor, new Object[] { tempModel });
+ }
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/INewPortletClassDataModelProperties.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/INewPortletClassDataModelProperties.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/INewPortletClassDataModelProperties.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,44 @@
+package org.jboss.tools.portlet.ui;
+
+import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties;
+
+public interface INewPortletClassDataModelProperties extends
+ INewServletClassDataModelProperties {
+
+ static final String GET_PORTLET_CONFIG =
"NewPortletClassDataModel.GET_PORTLET_CONFIG"; //$NON-NLS-1$
+
+ static final String DO_DISPATCH = "NewPortletClassDataModel.DO_DISPATCH";
//$NON-NLS-1$
+
+ static final String DO_EDIT = "NewPortletClassDataModel.DO_EDIT";
//$NON-NLS-1$
+
+ static final String DO_VIEW = "NewPortletClassDataModel.DO_VIEW";
//$NON-NLS-1$
+
+ static final String DO_HELP = "NewPortletClassDataModel.DO_HELP";
//$NON-NLS-1$
+
+ static final String PROCESS_ACTION =
"NewPortletClassDataModel.PROCESS_ACTION"; //$NON-NLS-1$
+
+ static final String RENDER = "NewPortletClassDataModel.RENDER"; //$NON-NLS-1$
+
+ static final String NAME = "NewPortletClassDataModel.NAME"; //$NON-NLS-1$
+
+ static final String TITLE = "NewPortletClassDataModel.TITLE"; //$NON-NLS-1$
+
+ static final String VIEW_MODE = "NewPortletClassDataModel.VIEW_MODE";
+
+ static final String EDIT_MODE = "NewPortletClassDataModel.EDIT_MODE";
+
+ static final String HELP_MODE = "NewPortletClassDataModel.HELP_MODE";
+
+ static final String INSTANCE_NAME = "NewPortletClassDataModel.INSTANCE_NAME";
+
+ static final String WINDOW_NAME = "NewPortletClassDataModel.WINDOW_NAME";
+
+ static final String PARENT_PORTAL = "NewPortletClassDataModel.PARENT_PORTAL";
+
+ static final String PAGE_REGION = "NewPortletClassDataModel.PAGE_REGION";
+
+ static final String PORTLET_HEIGHT =
"NewPortletClassDataModel.PORTLET_HEIGHT";
+
+ static final String IF_EXISTS = "NewPortletClassDataModel.IF_EXISTS";
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/IPortletUIConstants.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/IPortletUIConstants.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/IPortletUIConstants.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,61 @@
+package org.jboss.tools.portlet.ui;
+
+/**
+ * @author snjeza
+ */
+public interface IPortletUIConstants {
+
+ static final String NEW_PORTLET_WIZARD_PAGE_TITLE = "Create Portlet";
+ static final String ADD_PORTLET_WIZARD_PAGE_DESC = "Enter portlet deployment
descriptor specific information.";
+
+ static final String ADD_JBOSS_PORTLET_WIZARD_PAGE_TITLE = "Create Portlet";
+ static final String ADD_JBOSS_PORTLET_WIZARD_PAGE_DESC = "Enter JBoss portlet
specific information";
+
+ static final String DISPLAY_NAME_LABEL = "Display name:";
+ static final String TITLE_LABEL = "Title:";
+
+ static final String QUALIFIED_PORTLET = "javax.portlet.Portlet";
//$NON-NLS-1$
+ static final String QUALIFIED_GENERIC_PORTLET =
"javax.portlet.GenericServlet"; //$NON-NLS-1$
+
+ static final String QUALIFIED_PORTLET_EXCEPTION =
"javax.portlet.PortletException"; //$NON-NLS-1$
+ static final String QUALIFIED_IO_EXCEPTION = "java.io.IOException";
//$NON-NLS-1$
+ static final String QUALIFIED_SECURITY_EXCEPTION =
"javax.portlet.PortletSecurityException"; //$NON-NLS-1$
+ static final String QUALIFIED_UNAVALIABLE_EXCEPTION =
"javax.portlet.UnavailableException"; //$NON-NLS-1$
+ static final String QUALIFIED_PRINTWRITER = "java.io.PrintWriter";
//$NON-NLS-1$
+
+ static final String QUALIFIED_PORTLET_CONFIG = "javax.portlet.PortletConfig";
//$NON-NLS-1$
+ static final String QUALIFIED_PORTLET_REQUEST = "javax.portlet.RenderRequest";
//$NON-NLS-1$
+ static final String QUALIFIED_PORTLET_RESPONSE =
"javax.portlet.RenderResponse"; //$NON-NLS-1$
+ static final String QUALIFIED_ACTION_REQUEST = "javax.portlet.ActionRequest";
//$NON-NLS-1$
+ static final String QUALIFIED_ACTION_RESPONSE =
"javax.portlet.ActionResponse"; //$NON-NLS-1$
+
+
+ static final String METHOD_INIT = "init"; //$NON-NLS-1$
+ static final String METHOD_DESTROY = "destroy"; //$NON-NLS-1$
+ static final String METHOD_GET_PORTLET_CONFIG = "getPortletConfig";
//$NON-NLS-1$
+ static final String METHOD_DO_EDIT = "doEdit"; //$NON-NLS-1$
+ static final String METHOD_DO_VIEW = "doView"; //$NON-NLS-1$
+ static final String METHOD_DO_HELP = "doHelp"; //$NON-NLS-1$
+ static final String METHOD_DO_DISPATCH = "doDispatch"; //$NON-NLS-1$
+ static final String METHOD_PROCESS_ACTION = "doProcessAction"; //$NON-NLS-1$
+ static final String METHOD_RENDER = "render"; //$NON-NLS-1$
+ static final String METHOD_TO_STRING = "toString"; //$NON-NLS-1$
+
+ static final String PORTLET_INIT_SIGNATURE =
"(Ljavax/portlet/PortletConfig;)V"; //$NON-NLS-1$
+ static final String DESTROY_SIGNATURE = "()V"; //$NON-NLS-1$
+ static final String GET_PORTLET_CONFIG_SIGNATURE =
"()Ljavax/portlet/PortletConfig;"; //$NON-NLS-1$
+ static final String DO_VIEW_SIGNATURE =
"(Ljavax/portlet/RenderRequest;Ljavax/portlet/RenderResponse;)V"; //$NON-NLS-1$
+ static final String DO_EDIT_SIGNATURE =
"(Ljavax/portlet/RenderRequest;Ljavax/portlet/RenderResponse;)V"; //$NON-NLS-1$
+ static final String DO_HELP_SIGNATURE =
"(Ljavax/portlet/RenderRequest;Ljavax/portlet/RenderResponse;)V"; //$NON-NLS-1$
+ static final String DO_DISPATCH_SIGNATURE =
"(Ljavax/portlet/RenderRequest;Ljavax/portlet/RenderResponse;)V"; //$NON-NLS-1$
+ static final String RENDER_SIGNATURE =
"(Ljavax/portlet/RenderRequest;Ljavax/portlet/RenderResponse;)V"; //$NON-NLS-1$
+ static final String PROCESS_ACTION_SIGNATURE =
"(Ljavax/portlet/ActionRequest;Ljavax/portlet/ActionResponse;)V"; //$NON-NLS-1$
+
+ static final String INSTANCE_NAME_LABEL = "Instance Name:";
+ static final String WINDOW_NAME_LABEL = "Window Name:";
+ static final String PARENT_PORTAL_LABEL = "Parent Reference:";
+ static final String PAGE_REGION_LABEL = "Region:";
+ static final String PORTLET_HEIGHT_LABEL = "Height:";
+ static final String IF_EXISTS_LABEL = "If Exists:";
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,50 @@
+package org.jboss.tools.portlet.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class PortletUIActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.portlet.ui";
+
+ // The shared instance
+ private static PortletUIActivator plugin;
+
+ /**
+ * The constructor
+ */
+ public PortletUIActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static PortletUIActivator getDefault() {
+ return plugin;
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/PortletFacetInstallPage.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/PortletFacetInstallPage.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/PortletFacetInstallPage.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,61 @@
+package org.jboss.tools.portlet.ui.internal.project.facet;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
+import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
+import org.eclipse.wst.common.project.facet.ui.IWizardContext;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+
+/**
+ * @author snjeza
+ */
+public class PortletFacetInstallPage extends DataModelWizardPage implements
+ IFacetWizardPage {
+
+ private IDialogSettings dialogSettings;
+
+ public PortletFacetInstallPage() {
+ super(DataModelFactory.createDataModel(new AbstractDataModelProvider() {
+ }), "jboss.portal.facet.install.page");
+ setTitle("JBoss Portlet Capabilities");
+ setDescription("Add JBoss Portlet capabilities to this Web Project");
+ dialogSettings = PortletUIActivator.getDefault().getDialogSettings();
+ }
+
+ @Override
+ protected Composite createTopLevelComposite(Composite parent) {
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NONE);
+ return composite;
+ }
+
+ @Override
+ protected String[] getValidationPropertyNames() {
+ return new String[0];
+ }
+
+ public void setConfig(Object config) {
+ model.removeListener(this);
+ synchHelper.dispose();
+
+ model = (IDataModel) config;
+ model.addListener(this);
+ synchHelper = initializeSynchHelper(model);
+ }
+
+ public void setWizardContext(IWizardContext context) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void transferStateToConfig() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddJBossPortletWizardPage.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddJBossPortletWizardPage.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddJBossPortletWizardPage.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,177 @@
+package org.jboss.tools.portlet.ui.internal.wizard;
+
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.INIT_PARAM;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME;
+
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_BUTTON_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_TITLE;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.EDIT_BUTTON_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_TITLE;
+import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_LABEL;
+import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_TITLE;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NO_WEB_PROJECTS;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.REMOVE_BUTTON_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_TITLE;
+import static
org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.TITLE;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.INSTANCE_NAME;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.WINDOW_NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.IF_EXISTS;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PAGE_REGION;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PARENT_PORTAL;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PORTLET_HEIGHT;
+
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.INSTANCE_NAME_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.WINDOW_NAME_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.IF_EXISTS_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.PAGE_REGION_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.PARENT_PORTAL_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.PORTLET_HEIGHT_LABEL;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jst.j2ee.internal.wizard.StringArrayTableWizardSection;
+import org.eclipse.jst.servlet.ui.internal.wizard.StringArrayTableWizardSectionCallback;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import
org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
+import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
+import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
+import org.jboss.tools.portlet.ui.IPortletUIConstants;
+
+/**
+ * JBoss Portlet Wizard Setting Page
+ *
+ * @author snjeza
+ */
+public class AddJBossPortletWizardPage extends DataModelWizardPage {
+
+ public AddJBossPortletWizardPage(IDataModel model, String pageName) {
+ super(model, pageName);
+ setDescription(IPortletUIConstants.ADD_JBOSS_PORTLET_WIZARD_PAGE_DESC);
+ setTitle(IPortletUIConstants.ADD_JBOSS_PORTLET_WIZARD_PAGE_TITLE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#getValidationPropertyNames()
+ */
+ protected String[] getValidationPropertyNames() {
+ return new String[] { INSTANCE_NAME, WINDOW_NAME };
+ }
+
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = 300;
+ composite.setLayoutData(data);
+
+ createComponents(composite);
+
+ IStatus projectStatus = validateProjectName();
+ if (!projectStatus.isOK()) {
+ setErrorMessage(projectStatus.getMessage());
+ composite.setEnabled(false);
+ }
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+
+ protected IStatus validateProjectName() {
+ // check for empty
+ if (model.getStringProperty(PROJECT_NAME) == null ||
model.getStringProperty(PROJECT_NAME).trim().length() == 0) {
+ return WTPCommonPlugin.createErrorStatus(NO_WEB_PROJECTS);
+ }
+ return WTPCommonPlugin.OK_STATUS;
+ }
+
+ protected void createComponents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ // if exists
+ Label ifExistsLabel = new Label(composite, SWT.LEFT);
+ ifExistsLabel.setText(IF_EXISTS_LABEL);
+ ifExistsLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Combo ifExistsCombo = new Combo(composite,SWT.NONE);
+ ifExistsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ ifExistsCombo.setItems(new String[] {"overwrite","keep"});
+ synchHelper.synchCombo(ifExistsCombo, IF_EXISTS, null);
+
+ // instance name
+ Label instanceNameLabel = new Label(composite, SWT.LEFT);
+ instanceNameLabel.setText(INSTANCE_NAME_LABEL);
+ instanceNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text instanceNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ instanceNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(instanceNameText, INSTANCE_NAME, null);
+
+ // window name
+ Label windowNameLabel = new Label(composite, SWT.LEFT);
+ windowNameLabel.setText(WINDOW_NAME_LABEL);
+ windowNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text windowNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ windowNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(windowNameText, WINDOW_NAME, null);
+
+ // parent reference
+ Label parentReferenceLabel = new Label(composite, SWT.LEFT);
+ parentReferenceLabel.setText(PARENT_PORTAL_LABEL);
+ parentReferenceLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text parentReferenceText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ parentReferenceText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(parentReferenceText, PARENT_PORTAL, null);
+
+ // region
+ Label regionLabel = new Label(composite, SWT.LEFT);
+ regionLabel.setText(PAGE_REGION_LABEL);
+ regionLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text regionText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ regionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(regionText, PAGE_REGION, null);
+
+ // height
+ Label heightLabel = new Label(composite, SWT.LEFT);
+ heightLabel.setText(PORTLET_HEIGHT_LABEL);
+ heightLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text heightText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ heightText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(heightText, PORTLET_HEIGHT, null);
+
+ }
+
+ public boolean canFlipToNextPage() {
+ if (model.getBooleanProperty(USE_EXISTING_CLASS))
+ return false;
+ return super.canFlipToNextPage();
+ }
+
+ @Override
+ protected boolean showValidationErrorsOnEnter() {
+ return true;
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddPortletWizardPage.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddPortletWizardPage.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddPortletWizardPage.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,185 @@
+package org.jboss.tools.portlet.ui.internal.wizard;
+
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties.INIT_PARAM;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME;
+
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.ADD_BUTTON_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DESCRIPTION_TITLE;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.EDIT_BUTTON_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.INIT_PARAM_TITLE;
+import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_LABEL;
+import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NAME_TITLE;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NO_WEB_PROJECTS;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.REMOVE_BUTTON_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.VALUE_TITLE;
+import static
org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties.PROJECT_NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.TITLE;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jst.j2ee.internal.wizard.StringArrayTableWizardSection;
+import org.eclipse.jst.servlet.ui.internal.wizard.StringArrayTableWizardSectionCallback;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
+import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
+import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
+import org.jboss.tools.portlet.ui.IPortletUIConstants;
+
+/**
+ * Portlet Wizard Setting Page
+ */
+public class AddPortletWizardPage extends DataModelWizardPage {
+
+ private Text nameText;
+
+ public AddPortletWizardPage(IDataModel model, String pageName) {
+ super(model, pageName);
+ setDescription(IPortletUIConstants.ADD_PORTLET_WIZARD_PAGE_DESC);
+ this.setTitle(IPortletUIConstants.NEW_PORTLET_WIZARD_PAGE_TITLE);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#getValidationPropertyNames()
+ */
+ protected String[] getValidationPropertyNames() {
+ return new String[] { DISPLAY_NAME, INIT_PARAM };
+ }
+
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+ GridData data = new GridData(GridData.FILL_BOTH);
+ data.widthHint = 300;
+ composite.setLayoutData(data);
+
+ createNameDescription(composite);
+
+ createModesComposite(composite);
+
+ StringArrayTableWizardSectionCallback callback = new
StringArrayTableWizardSectionCallback();
+ StringArrayTableWizardSection initSection = new StringArrayTableWizardSection(
+ composite,
+ INIT_PARAM_LABEL,
+ INIT_PARAM_TITLE,
+ ADD_BUTTON_LABEL,
+ EDIT_BUTTON_LABEL,
+ REMOVE_BUTTON_LABEL,
+ new String[] { NAME_TITLE, VALUE_TITLE, DESCRIPTION_TITLE },
+ new String[] { NAME_LABEL, VALUE_LABEL, DESCRIPTION_LABEL },
+ null,// WebPlugin.getDefault().getImage("initializ_parameter"),
+ model,
+ INIT_PARAM);
+ initSection.setCallback(callback);
+
+ String text = nameText.getText();
+
+ nameText.setFocus();
+
+ IStatus projectStatus = validateProjectName();
+ if (!projectStatus.isOK()) {
+ setErrorMessage(projectStatus.getMessage());
+ composite.setEnabled(false);
+ }
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+
+ private void createModesComposite(Composite parent) {
+ Group composite = new Group(parent,SWT.NULL);
+ composite.setLayout(new GridLayout(3,false));
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setText("Portlet Modes");
+
+ Button viewModeButton = new Button(composite,SWT.CHECK);
+ viewModeButton.setText("View");
+ synchHelper.synchCheckbox(viewModeButton,
INewPortletClassDataModelProperties.VIEW_MODE, null);
+
+ Button editModeButton = new Button(composite,SWT.CHECK);
+ editModeButton.setText("Edit");
+ synchHelper.synchCheckbox(editModeButton,
INewPortletClassDataModelProperties.EDIT_MODE, null);
+
+ Button helpModeButton = new Button(composite,SWT.CHECK);
+ helpModeButton.setText("Help");
+ synchHelper.synchCheckbox(helpModeButton,
INewPortletClassDataModelProperties.HELP_MODE, null);
+
+ }
+
+ protected IStatus validateProjectName() {
+ // check for empty
+ if (model.getStringProperty(PROJECT_NAME) == null ||
model.getStringProperty(PROJECT_NAME).trim().length() == 0) {
+ return WTPCommonPlugin.createErrorStatus(NO_WEB_PROJECTS);
+ }
+ return WTPCommonPlugin.OK_STATUS;
+ }
+
+ protected void createNameDescription(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ // name
+ Label nameLabel = new Label(composite, SWT.LEFT);
+ nameLabel.setText(NAME_LABEL);
+ nameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ nameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(nameText, NAME, null);
+
+ // display name
+ Label displayNameLabel = new Label(composite, SWT.LEFT);
+ displayNameLabel.setText(IPortletUIConstants.DISPLAY_NAME_LABEL);
+ displayNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text displayNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ displayNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(displayNameText, DISPLAY_NAME, null);
+
+ // title
+ Label titleLabel = new Label(composite, SWT.LEFT);
+ titleLabel.setText(IPortletUIConstants.TITLE_LABEL);
+ titleLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text titleText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ titleText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(titleText, TITLE, null);
+
+ // description
+ Label descLabel = new Label(composite, SWT.LEFT);
+ descLabel.setText(DESCRIPTION_LABEL);
+ descLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ Text descText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ descText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(descText, DESCRIPTION, null);
+ }
+
+ public String getDisplayName() {
+ return nameText.getText();
+ }
+
+ public boolean canFlipToNextPage() {
+ if (model.getBooleanProperty(USE_EXISTING_CLASS))
+ return false;
+ return super.canFlipToNextPage();
+ }
+
+ @Override
+ protected boolean showValidationErrorsOnEnter() {
+ return true;
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,278 @@
+package org.jboss.tools.portlet.ui.internal.wizard;
+
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties;
+import org.eclipse.jst.j2ee.internal.web.operations.NewServletClassDataModelProvider;
+import org.eclipse.jst.j2ee.internal.web.operations.NewServletClassOperation;
+import org.eclipse.jst.j2ee.internal.web.operations.NewWebClassDataModelProvider;
+import org.eclipse.jst.j2ee.internal.web.operations.WebMessages;
+import org.eclipse.jst.j2ee.web.validation.UrlPattern;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
+import org.jboss.tools.portlet.operations.AddPortletOperation;
+import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
+
+/**
+ *
+ * @see NewServletClassDataModelProvider
+ *
+ */
+public class NewPortletClassDataModelProvider extends
+ NewWebClassDataModelProvider implements INewPortletClassDataModelProperties{
+
+ /**
+ * The fully qualified default portlet superclass: GenericPortlet.
+ */
+ private final static String PORTLET_SUPERCLASS =
"javax.portlet.GenericPortlet";
+
+ /**
+ * String array of the default, minimum required fully qualified Portlet
+ * interfaces
+ */
+ private final static String QUALIFIED_PORTLET = "javax.portlet.Portlet";
+ private final static String[] PORTLET_INTERFACES = { QUALIFIED_PORTLET };
+
+ private final static String ANNOTATED_TEMPLATE_DEFAULT = "portlet.javajet";
//$NON-NLS-1$
+
+ private final static String NON_ANNOTATED_TEMPLATE_DEFAULT =
"portlet.javajet"; //$NON-NLS-1$
+
+ /**
+ * Subclasses may extend this method to provide their own default operation
+ * for this data model provider. This implementation uses the
+ * AddPortletOperation to drive the portlet creation. It will not return
+ * null.
+ *
+ * @see IDataModel#getDefaultOperation()
+ *
+ * @return IDataModelOperation AddPortletOperation
+ */
+ @Override
+ public IDataModelOperation getDefaultOperation() {
+ return new AddPortletOperation(model);
+ }
+
+ /**
+ * Subclasses may extend this method to add their own data model's
+ * properties as valid base properties.
+ *
+ * @see
org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#getPropertyNames()
+ */
+ @Override
+ public Set getPropertyNames() {
+ // Add portlet specific properties defined in this data model
+ Set propertyNames = super.getPropertyNames();
+
+ propertyNames.add(INIT);
+ propertyNames.add(DESTROY);
+ propertyNames.add(GET_PORTLET_CONFIG);
+ propertyNames.add(DO_DISPATCH);
+ propertyNames.add(DO_EDIT);
+ propertyNames.add(DO_VIEW);
+ propertyNames.add(DO_HELP);
+ propertyNames.add(PROCESS_ACTION);
+ propertyNames.add(RENDER);
+ propertyNames.add(TO_STRING);
+ propertyNames.add(INIT_PARAM);
+ propertyNames.add(NAME);
+ propertyNames.add(TITLE);
+ propertyNames.add(VIEW_MODE);
+ propertyNames.add(EDIT_MODE);
+ propertyNames.add(HELP_MODE);
+ propertyNames.add(NON_ANNOTATED_TEMPLATE_FILE);
+ propertyNames.add(TEMPLATE_FILE);
+ propertyNames.add(INSTANCE_NAME);
+ propertyNames.add(WINDOW_NAME);
+ propertyNames.add(PARENT_PORTAL);
+ propertyNames.add(PAGE_REGION);
+ propertyNames.add(PORTLET_HEIGHT);
+ propertyNames.add(IF_EXISTS);
+
+ return propertyNames;
+ }
+
+ @Override
+ public boolean isPropertyEnabled(String propertyName) {
+ if (ABSTRACT_METHODS.equals(propertyName)) {
+ return true;
+ } else if (INIT.equals(propertyName) ||
+ DESTROY.equals(propertyName) ||
+ GET_PORTLET_CONFIG.equals(propertyName) ||
+ DO_DISPATCH.equals(propertyName) ||
+ DO_EDIT.equals(propertyName) ||
+ DO_VIEW.equals(propertyName) ||
+ DO_HELP.equals(propertyName) ||
+ PROCESS_ACTION.equals(propertyName) ||
+ RENDER.equals(propertyName) ||
+ INIT_PARAM.equals(propertyName)) {
+ boolean inherit = model.getBooleanProperty(ABSTRACT_METHODS);
+ return inherit;
+ }
+
+ // Otherwise return super implementation
+ return super.isPropertyEnabled(propertyName);
+ }
+
+ @Override
+ public Object getDefaultProperty(String propertyName) {
+
+ if (propertyName.equals(DO_VIEW)) {
+ return Boolean.TRUE;
+ }
+ if (propertyName.equals(DO_EDIT) || propertyName.equals(DO_HELP) ||
propertyName.equals(INIT) || propertyName.equals(DESTROY) ||
+ propertyName.equals(GET_PORTLET_CONFIG)) {
+ return Boolean.FALSE;
+ }
+
+ if (propertyName.equals(DISPLAY_NAME)) {
+ String className = getStringProperty(CLASS_NAME);
+ className = Signature.getSimpleName(className);
+ return className;
+ }
+ if (propertyName.equals(NAME)) {
+ String className = getStringProperty(CLASS_NAME);
+ className = Signature.getSimpleName(className);
+ return className;
+ }
+ if (propertyName.equals(TITLE)) {
+ String className = getStringProperty(CLASS_NAME);
+ className = Signature.getSimpleName(className);
+ return className;
+ }
+
+ if (propertyName.equals(VIEW_MODE)) {
+ return Boolean.TRUE;
+ }
+ if (propertyName.equals(EDIT_MODE)) {
+ return Boolean.FALSE;
+ }
+ if (propertyName.equals(HELP_MODE)) {
+ return Boolean.FALSE;
+ }
+ if (propertyName.equals(INTERFACES))
+ return getPortletInterfaces();
+ if (propertyName.equals(SUPERCLASS))
+ return PORTLET_SUPERCLASS;
+ if (propertyName.equals(TEMPLATE_FILE))
+ return ANNOTATED_TEMPLATE_DEFAULT;
+ if (propertyName.equals(NON_ANNOTATED_TEMPLATE_FILE))
+ return NON_ANNOTATED_TEMPLATE_DEFAULT;
+ if (propertyName.equals(CONSTRUCTOR))
+ return Boolean.FALSE;
+
+ if (propertyName.equals(INSTANCE_NAME)) {
+ return getDefaultProperty(NAME) + "Instance";
+ }
+ if (propertyName.equals(WINDOW_NAME)) {
+ return getDefaultProperty(NAME) + "Window";
+ }
+ if (propertyName.equals(PORTLET_HEIGHT)) {
+ return "1";
+ }
+ if (propertyName.equals(PAGE_REGION)) {
+ return "center";
+ }
+ if (propertyName.equals(PARENT_PORTAL)) {
+ return "default.default";
+ }
+ if (propertyName.equals(IF_EXISTS)) {
+ return "overwrite";
+ }
+
+ // Otherwise check super for default value for property
+ return super.getDefaultProperty(propertyName);
+ }
+
+ @Override
+ public IStatus validate(String propertyName) {
+ // Validate super class
+ if (propertyName.equals(SUPERCLASS))
+ return validateSuperClassName(getStringProperty(propertyName));
+
+ // Otherwise defer to super to validate the property
+ return super.validate(propertyName);
+ }
+
+ @Override
+ public boolean propertySet(String propertyName, Object propertyValue) {
+ boolean result = false;
+
+ if (SUPERCLASS.equals(propertyName)) {
+ model.notifyPropertyChange(ABSTRACT_METHODS, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(INIT, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(DESTROY, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(GET_PORTLET_CONFIG, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(DO_VIEW, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(DO_EDIT, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(DO_HELP, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(DO_DISPATCH, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(RENDER, IDataModel.ENABLE_CHG);
+ model.notifyPropertyChange(PROCESS_ACTION, IDataModel.ENABLE_CHG);
+
+ if (!hasSuperClass()) {
+ model.setProperty(ABSTRACT_METHODS, null);
+ model.setProperty(INIT, null);
+ model.setProperty(DESTROY, null);
+ model.setProperty(GET_PORTLET_CONFIG, null);
+ model.setProperty(DO_VIEW, null);
+ model.setProperty(DO_EDIT, null);
+ model.setProperty(DO_HELP, null);
+ model.setProperty(DO_DISPATCH, null);
+ model.setProperty(RENDER, null);
+ model.setProperty(PROCESS_ACTION, null);
+ }
+
+ model.notifyPropertyChange(ABSTRACT_METHODS, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(INIT, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(DESTROY, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(GET_PORTLET_CONFIG, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(DO_VIEW, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(DO_EDIT, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(DO_HELP, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(DO_DISPATCH, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(RENDER, IDataModel.DEFAULT_CHG);
+ model.notifyPropertyChange(PROCESS_ACTION, IDataModel.DEFAULT_CHG);
+
+ List ifaces = (List) model.getProperty(INTERFACES);
+ ifaces.add(QUALIFIED_SERVLET);
+
+ }
+
+ return result || super.propertySet(propertyName, propertyValue);
+ }
+
+ protected IStatus validateSuperClassName(String superclassName) {
+
+ // Check the super class as a java class
+ IStatus status = null;
+ if (superclassName.trim().length() > 0) {
+ status = super.validate(SUPERCLASS);
+ if (status.getSeverity() == IStatus.ERROR)
+ return status;
+ }
+
+ return status;
+ }
+
+ private List getPortletInterfaces() {
+ if (interfaceList == null) {
+ interfaceList = new ArrayList();
+ for (int i = 0; i < PORTLET_INTERFACES.length; i++) {
+ interfaceList.add(PORTLET_INTERFACES[i]);
+ }
+ interfaceList.remove(QUALIFIED_PORTLET);
+
+ }
+ return interfaceList;
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,148 @@
+package org.jboss.tools.portlet.ui.internal.wizard;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties;
+import org.eclipse.jst.servlet.ui.internal.wizard.NewWebClassOptionsWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
+
+public class NewPortletClassOptionsWizardPage extends
+ NewWebClassOptionsWizardPage implements ISelectionChangedListener {
+
+ protected Button initButton;
+ protected Button destroyButton;
+ protected Button getConfigButton;
+ protected Button doViewButton;
+ protected Button doEditButton;
+ protected Button doHelpButton;
+ protected Button doDispatchButton;
+ protected Button processActionButton;
+ protected Button renderButton;
+
+ public NewPortletClassOptionsWizardPage(IDataModel model, String pageName, String
pageDesc, String pageTitle) {
+ super(model, pageName, pageDesc, pageTitle);
+ }
+
+ /**
+ * Create the composite with all the stubs
+ */
+ @Override
+ protected void createStubsComposite(Composite parent) {
+ super.createStubsComposite(parent);
+
+ inheritButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ boolean enable = inheritButton.getSelection();
+ enablePortletButtons(enable);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //Do nothing
+ }
+
+ private void enablePortletButtons(boolean enable) {
+ initButton.setEnabled(enable);
+ destroyButton.setEnabled(enable);
+ getConfigButton.setEnabled(enable);
+ doDispatchButton.setEnabled(enable);
+ doEditButton.setEnabled(enable);
+ doViewButton.setEnabled(true);
+ doHelpButton.setEnabled(true);
+ processActionButton.setEnabled(true);
+ renderButton.setEnabled(true);
+ }
+
+ });
+
+ Composite comp = new Composite(methodStubs, SWT.NULL);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginWidth = 0;
+ layout.makeColumnsEqualWidth = true;
+ comp.setLayout(layout);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ comp.setLayoutData(data);
+
+ initButton = new Button(comp, SWT.CHECK);
+ initButton.setText("&init"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(initButton, INewServletClassDataModelProperties.INIT, null);
+
+ destroyButton = new Button(comp, SWT.CHECK);
+ destroyButton.setText("destro&y"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(destroyButton, INewServletClassDataModelProperties.DESTROY,
null);
+
+ getConfigButton = new Button(comp, SWT.CHECK);
+ getConfigButton.setText("getPortlet&Config"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(getConfigButton,
INewPortletClassDataModelProperties.GET_PORTLET_CONFIG, null);
+
+ doViewButton = new Button(comp, SWT.CHECK);
+ doViewButton.setText("doView"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(doViewButton, INewPortletClassDataModelProperties.DO_VIEW,
null);
+
+ doEditButton = new Button(comp, SWT.CHECK);
+ doEditButton.setText("doEdit"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(doEditButton, INewPortletClassDataModelProperties.DO_EDIT,
null);
+
+ doHelpButton = new Button(comp, SWT.CHECK);
+ doHelpButton.setText("doHelp"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(doHelpButton, INewPortletClassDataModelProperties.DO_HELP,
null);
+
+ doDispatchButton = new Button(comp, SWT.CHECK);
+ doDispatchButton.setText("doDispatch"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(doDispatchButton,
INewPortletClassDataModelProperties.DO_DISPATCH, null);
+
+ doDispatchButton = new Button(comp, SWT.CHECK);
+ doDispatchButton.setText("doDispatch"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(doDispatchButton,
INewPortletClassDataModelProperties.DO_DISPATCH, null);
+
+ processActionButton = new Button(comp, SWT.CHECK);
+ processActionButton.setText("processAction"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(processActionButton,
INewPortletClassDataModelProperties.PROCESS_ACTION, null);
+
+ renderButton = new Button(comp, SWT.CHECK);
+ renderButton.setText("render"); //$NON-NLS-1$
+ synchHelper.synchCheckbox(renderButton, INewPortletClassDataModelProperties.RENDER,
null);
+
+ interfaceViewer.addSelectionChangedListener(this);
+
+ Dialog.applyDialogFont(parent);
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ removeButton.setEnabled(canRemoveSelectedInterfaces(selection));
+ }
+
+ protected KeyListener getInterfaceKeyListener() {
+ return new KeyListener() {
+
+ public void keyPressed(KeyEvent e) {
+ }
+
+ public void keyReleased(KeyEvent e) {
+ if (e.keyCode == SWT.DEL) {
+ IStructuredSelection selection = (IStructuredSelection)
interfaceViewer.getSelection();
+ if (canRemoveSelectedInterfaces(selection)) {
+ handleInterfaceRemoveButtonSelected();
+ }
+ }
+ }
+
+ };
+ }
+
+ private boolean canRemoveSelectedInterfaces(IStructuredSelection selection) {
+ return true;
+ }
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ *
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Kaloyan Raev, kaloyan.raev(a)sap.com
+ *******************************************************************************/
+package org.jboss.tools.portlet.ui.internal.wizard;
+import static
org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.PROJECT;
+import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.j2ee.internal.war.ui.util.WebServletGroupItemProvider;
+import org.eclipse.jst.j2ee.webapplication.WebApp;
+import org.eclipse.jst.jee.ui.internal.navigator.web.GroupServletItemProvider;
+import org.eclipse.jst.jee.ui.internal.navigator.web.WebAppProvider;
+import
org.eclipse.jst.servlet.ui.internal.wizard.MultiSelectFilteredFileSelectionDialog;
+import org.eclipse.jst.servlet.ui.internal.wizard.NewWebClassWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+import org.eclipse.wst.common.project.facet.core.internal.FacetedProject;
+import org.jboss.tools.portlet.core.IPortletConstants;
+
+public class NewPortletClassWizardPage extends NewWebClassWizardPage {
+
+ public NewPortletClassWizardPage(IDataModel model, String pageName, String pageDesc,
String pageTitle, String moduleType) {
+ super(model, pageName, pageDesc, pageTitle, moduleType);
+ }
+
+ @Override
+ protected boolean isProjectValid(IProject project) {
+ boolean result = super.isProjectValid(project);
+ if (result == false) {
+ return result;
+ }
+ try {
+ result = FacetedProjectFramework.hasProjectFacet(project,
IPortletConstants.PORTLET_FACET_ID);
+ } catch (CoreException ce) {
+ result = false;
+ }
+ return result;
+ }
+ @Override
+ protected String getUseExistingCheckboxText() {
+ return "Use an existing Portlet class";
+ }
+
+ @Override
+ protected String getUseExistingProperty() {
+ return USE_EXISTING_CLASS;
+ }
+
+ @Override
+ protected IProject getExtendedSelectedProject(Object selection) {
+ if (selection instanceof WebServletGroupItemProvider) {
+ WebApp webApp = (WebApp) ((WebServletGroupItemProvider) selection).getParent();
+ return ProjectUtilities.getProject(webApp);
+ } else if(selection instanceof WebAppProvider){
+ return ((WebAppProvider) selection).getProject();
+ } else if(selection instanceof GroupServletItemProvider){
+ org.eclipse.jst.javaee.web.WebApp webApp = (org.eclipse.jst.javaee.web.WebApp)
((GroupServletItemProvider) selection).getJavaEEObject();
+ return ProjectUtilities.getProject(webApp);
+ }
+
+ return super.getExtendedSelectedProject(selection);
+ }
+
+ @Override
+ protected void handleClassButtonSelected() {
+ getControl().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT));
+ IProject project = (IProject) model.getProperty(PROJECT);
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ MultiSelectFilteredFileSelectionDialog ms = new
MultiSelectFilteredFileSelectionDialog(
+ getShell(),
+ "New Portlet",
+ "Choose a portlet class:",
+ new String[0],
+ false,
+ project);
+ IContainer root = component.getRootFolder().getUnderlyingFolder();
+ ms.setInput(root);
+ ms.open();
+ if (ms.getReturnCode() == Window.OK) {
+ String qualifiedClassName = ""; //$NON-NLS-1$
+ existingClassText.setText(qualifiedClassName);
+ }
+ getControl().setCursor(null);
+ }
+
+}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,77 @@
+package org.jboss.tools.portlet.ui.internal.wizard;
+
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.NEW_JAVA_CLASS_OPTIONS_WIZARD_PAGE_DESC;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jst.servlet.ui.IWebUIContextIds;
+import org.eclipse.jst.servlet.ui.internal.wizard.NewServletClassOptionsWizardPage;
+import org.eclipse.jst.servlet.ui.internal.wizard.NewWebArtifactWizard;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
+import org.jboss.tools.portlet.ui.IPortletUIConstants;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+
+/**
+ * New portlet wizard
+ */
+public class NewPortletWizard extends NewWebArtifactWizard {
+
+ protected static final String PAGE_FOUR = "pageFour";
+
+ public NewPortletWizard() {
+ this(null);
+ }
+
+ public NewPortletWizard(IDataModel model) {
+ super(model);
+ }
+
+ @Override
+ protected String getTitle() {
+ return IPortletUIConstants.NEW_PORTLET_WIZARD_PAGE_TITLE;
+ }
+
+ @Override
+ protected ImageDescriptor getImage() {
+ return PortletUIActivator.imageDescriptorFromPlugin(PortletUIActivator.PLUGIN_ID,
"/icons/portlet_wiz.gif");
+ }
+
+ @Override
+ public void doAddPages() {
+ NewPortletClassWizardPage page1 = new NewPortletClassWizardPage(
+ getDataModel(),
+ PAGE_ONE,
+ NEW_JAVA_CLASS_DESTINATION_WIZARD_PAGE_DESC,
+ IPortletUIConstants.NEW_PORTLET_WIZARD_PAGE_TITLE, IModuleConstants.JST_WEB_MODULE);
+ page1.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_1);
+ addPage(page1);
+ AddPortletWizardPage page2 = new AddPortletWizardPage(getDataModel(), PAGE_TWO);
+ page2.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_2);
+ addPage(page2);
+ NewPortletClassOptionsWizardPage page3 = new NewPortletClassOptionsWizardPage(
+ getDataModel(),
+ PAGE_THREE,
+ "Specify modifiers, interfaces to implement and method stubs to
generate.",
+ IPortletUIConstants.NEW_PORTLET_WIZARD_PAGE_TITLE);
+ page3.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_3);
+ addPage(page3);
+ AddJBossPortletWizardPage page4 = new AddJBossPortletWizardPage(getDataModel(),
PAGE_FOUR);
+ addPage(page4);
+ }
+
+ @Override
+ protected void postPerformFinish() throws InvocationTargetException {
+ // open new servlet class in java editor
+ openJavaClass();
+ }
+
+ @Override
+ protected IDataModelProvider getDefaultProvider() {
+ return new NewPortletClassDataModelProvider();
+ }
+
+}
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_class.template
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_class.template
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_class.template 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,40 @@
+<%
+ if (model.isPublic()) {
+%>
+public
+<%
+ }
+
+ if (model.isAbstract()) {
+%>abstract
+<%
+ }
+
+ if (model.isFinal()) {
+%>final
+<%
+ }
+%>class <%= model.getClassName() %>
+<%
+ String superClass = model.getSuperclassName();
+ if (superClass != null && superClass.length() > 0) {
+%> extends <%= superClass %>
+<%
+ }
+
+ List<String> interfaces = model.getInterfaces();
+ if ( interfaces.size() > 0) {
+%> implements
+<%
+ }
+
+ for (int i = 0; i < interfaces.size(); i++) {
+ String INTERFACE = (String) interfaces.get(i);
+ if (i > 0) {
+%>,
+<%
+ }
+%><%= INTERFACE %>
+<%
+ }
+%> {
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_constructors.template
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_constructors.template
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_constructors.template 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,31 @@
+<%
+ if (!model.hasEmptySuperclassConstructor()) {
+%>
+
+ /**
+ * Default constructor.
+ */
+ public <%= model.getClassName() %>() {
+ // TODO Auto-generated constructor stub
+ }
+<%
+ }
+
+ if (model.shouldGenSuperclassConstructors()) {
+ List<Constructor> constructors = model.getConstructors();
+ for (Constructor constructor : constructors) {
+ if (constructor.isPublic() || constructor.isProtected()) {
+%>
+
+ /**
+ * @see <%= model.getSuperclassName() %>#<%= model.getSuperclassName()
%>(<%= constructor.getParamsForJavadoc() %>)
+ */
+ public <%= model.getClassName() %>(<%= constructor.getParamsForDeclaration()
%>) {
+ super(<%= constructor.getParamsForCall() %>);
+ // TODO Auto-generated constructor stub
+ }
+<%
+ }
+ }
+ }
+%>
\ No newline at end of file
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_flags.template
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_flags.template
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_flags.template 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,3 @@
+<%
+ model.removeFlags(CreateJavaEEArtifactTemplateModel.FLAG_QUALIFIED_SUPERCLASS_NAME);
+%>
\ No newline at end of file
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_imports.template
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_imports.template
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_imports.template 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,9 @@
+<%
+ Collection<String> imports = model.getImports();
+ for (String anImport : imports) {
+%>
+import <%= anImport %>;
+<%
+ }
+%>
+
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_methods.template
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_methods.template
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_methods.template 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,23 @@
+<%
+ if (model.shouldImplementAbstractMethods()) {
+ for (Method method : model.getUnimplementedMethods()) {
+%>
+
+ /**
+ * @see <%= method.getContainingJavaClass() %>#<%= method.getName()
%>(<%= method.getParamsForJavadoc() %>)
+ */
+ public <%= method.getReturnType() %> <%= method.getName() %>(<%=
method.getParamsForDeclaration() %>) {
+ // TODO Auto-generated method stub
+<%
+ String defaultReturnValue = method.getDefaultReturnValue();
+ if (defaultReturnValue != null) {
+%>
+ return <%= defaultReturnValue %>;
+<%
+ }
+%>
+ }
+<%
+ }
+ }
+%>
\ No newline at end of file
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_package.template
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_package.template
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/_package.template 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,8 @@
+<%
+ if (model.getJavaPackageName() != null && model.getJavaPackageName().length()
> 0) {
+%>
+package <%= model.getJavaPackageName() %>;
+<%
+ }
+%>
+
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/portlet.javajet
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/portlet.javajet
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/templates/portlet.javajet 2008-07-20
01:48:38 UTC (rev 9188)
@@ -0,0 +1,119 @@
+<%@ jet package="org.jboss.tools.portlet.ui"
+ imports="java.util.* org.eclipse.jst.j2ee.internal.common.operations.*
org.eclipse.jst.j2ee.internal.web.operations.* org.jboss.tools.portlet.operations.*
org.jboss.tools.portlet.ui.*"
+ class="PortletTemplate"
+%>
+<% CreatePortletTemplateModel model = (CreatePortletTemplateModel) argument; %>
+<%@ include file="_flags.template" %>
+<%@ include file="_package.template" %>
+<%@ include file="_imports.template" %>
+<%@ include file="_class.template" %>
+<%@ include file="_constructors.template" %>
+<%@ include file="_methods.template" %>
+<% if (model.shouldGenInit()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.Portlet#init()
+ */
+ @Override
+ public void init() throws PortletException {
+ // TODO Auto-generated method stub
+ super.init();
+ }
+<% } %>
+<% if (model.shouldGenDestroy()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.Portlet#destroy()
+ */
+ @Override
+ public void destroy() {
+ // TODO Auto-generated method stub
+ super.destroy();
+ }
+<% } %>
+<% if (model.shouldGenGetPortletConfig()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.GenericPortlet#getPortletConfig()
+ */
+ @Override
+ public PortletConfig getPortletConfig() {
+ // TODO Auto-generated method stub
+ return super.getPortletConfig();
+ }
+<% } %>
+<% if (model.shouldGenDoView()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
+ */
+ @Override
+ protected void doView(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException, UnavailableException {
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.write("Hello World!");
+ writer.close();
+ }
+<% } %>
+<% if (model.shouldGenDoEdit()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.GenericPortlet#doEdit(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
+ */
+ @Override
+ protected void doEdit(RenderRequest request, RenderResponse response)
+ throws PortletException, PortletSecurityException, IOException {
+ // TODO Auto-generated method stub
+ super.doEdit(request, response);
+ }
+<% } %>
+<% if (model.shouldGenDoHelp()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.GenericPortlet#doHelp(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
+ */
+ @Override
+ protected void doHelp(RenderRequest request, RenderResponse response)
+ throws PortletException, PortletSecurityException, IOException {
+ // TODO Auto-generated method stub
+ super.doHelp(request, response);
+ }
+<% } %>
+<% if (model.shouldGenDoDispatch()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.GenericPortlet#doDispatch(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
+ */
+ @Override
+ protected void doDispatch(RenderRequest arg0, RenderResponse arg1)
+ throws PortletException, PortletSecurityException, IOException {
+ // TODO Auto-generated method stub
+ super.doDispatch(arg0, arg1);
+ }
+<% } %>
+<% if (model.shouldGenRender()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.Portlet#render(javax.portlet.RenderRequest,
javax.portlet.RenderResponse)
+ */
+ @Override
+ public void render(RenderRequest request, RenderResponse response)
+ throws PortletException, PortletSecurityException, IOException {
+ // TODO Auto-generated method stub
+ super.render(request, response);
+ }
+<% } %>
+<% if (model.shouldGenProcessAction()) { %>
+
+ /* (non-Javadoc)
+ * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest,
javax.portlet.ActionResponse)
+ */
+ @Override
+ public void processAction(ActionRequest request, ActionResponse response)
+ throws PortletException, PortletSecurityException, IOException {
+ // TODO Auto-generated method stub
+ super.processAction(request, response);
+ }
+<% } %>
+}