Author: snjeza
Date: 2008-08-01 09:41:55 -0400 (Fri, 01 Aug 2008)
New Revision: 9470
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/
trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/edit.jsp
trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/help.jsp
trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/view.jsp
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/MultiSelectFilteredFileSelectionDialog.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewJSFPortletClassWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewJSFPortletWizard.java
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF
trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties
trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml
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/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/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/NewPortletClassWizardPage.java
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java
Log:
JBIDE-2574 Support for JSF portlets
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF 2008-08-01
13:10:43 UTC (rev 9469)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/META-INF/MANIFEST.MF 2008-08-01
13:41:55 UTC (rev 9470)
@@ -24,5 +24,7 @@
org.jboss.tools.portlet.core,
org.eclipse.emf.codegen,
org.eclipse.wst.xml.core,
- org.eclipse.wst.sse.core
+ org.eclipse.wst.sse.core,
+ org.eclipse.jdt.ui,
+ org.eclipse.ui.ide
Bundle-ActivationPolicy: lazy
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties 2008-08-01 13:10:43
UTC (rev 9469)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/build.properties 2008-08-01 13:41:55
UTC (rev 9470)
@@ -3,4 +3,11 @@
bin.includes = META-INF/,\
.,\
plugin.xml,\
- icons/
+ icons/,\
+ resources/,\
+ rhds_wiz.png,\
+ templates/,\
+ about.html,\
+ about.ini,\
+ about.mappings,\
+ about.properties
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml 2008-08-01 13:10:43 UTC
(rev 9469)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/plugin.xml 2008-08-01 13:41:55 UTC
(rev 9470)
@@ -11,6 +11,13 @@
</extension>
-->
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.wizardPages">
+ <wizard-pages action="jboss.jsfportlet.install">
+ <page
class="org.jboss.tools.portlet.ui.internal.project.facet.JSFPortletFacetInstallPage"/>
+ </wizard-pages>
+ </extension>
+
<!-- New Java Portlet wizard -->
<extension point="org.eclipse.ui.newWizards">
<category id="org.jboss.tools.portlet"
@@ -26,6 +33,15 @@
<description>Create a new Java Portlet</description>
<selection class="org.eclipse.core.resources.IResource" />
</wizard>
+ <wizard
+ id="org.jboss.tools.portlet.ui.wizard.NewJSFPortletWizard"
+ name="JBoss JSF Portlet"
+ class="org.jboss.tools.portlet.ui.internal.wizard.NewJSFPortletWizard"
+ category="org.jboss.tools.jst.web/org.jboss.tools.portlet"
+ icon="icons/portlet_wiz.gif">
+ <description>Create a new JBoss JSF Portlet</description>
+ <selection class="org.eclipse.core.resources.IResource" />
+ </wizard>
</extension>
</plugin>
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/edit.jsp
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/edit.jsp
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/edit.jsp 2008-08-01
13:41:55 UTC (rev 9470)
@@ -0,0 +1,8 @@
+ <ui:composition
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html">
+
+ Edit Mode
+</ui:composition>
\ No newline at end of file
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/help.jsp
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/help.jsp
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/help.jsp 2008-08-01
13:41:55 UTC (rev 9470)
@@ -0,0 +1,8 @@
+ <ui:composition
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html">
+
+ Help Mode
+</ui:composition>
\ No newline at end of file
Added: trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/view.jsp
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/view.jsp
(rev 0)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.ui/resources/jsf/view.jsp 2008-08-01
13:41:55 UTC (rev 9470)
@@ -0,0 +1,8 @@
+ <ui:composition
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html">
+
+ View Mode
+</ui:composition>
\ No newline at end of file
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -1,33 +1,60 @@
package org.jboss.tools.portlet.operations;
+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.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.ADD_JBOSS_APP;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.ADD_JBOSS_PORTLET;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.ADD_PORTLET;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.COPY_JSF_TEMPLATES;
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.IF_EXISTS;
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.IS_JSF_PORTLET;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.JBOSS_APP;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.NAME;
+import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.PAGE_NAME;
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.INewPortletClassDataModelProperties.ADD_PORTLET;
+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.WINDOW_NAME;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.io.File;
+import java.io.FileFilter;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaEEArtifactClassOperation;
import org.eclipse.jst.j2ee.internal.web.operations.AddWebClassOperation;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
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.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.enablement.nonui.WFTWrappedException;
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;
@@ -35,8 +62,10 @@
import org.jboss.tools.portlet.core.PortletCoreActivator;
import org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties;
import org.jboss.tools.portlet.ui.PortletUIActivator;
+import org.osgi.framework.Bundle;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
/**
@@ -44,6 +73,13 @@
*/
public class AddPortletOperation extends AddWebClassOperation {
+ public static final IOverwriteQuery OVERWRITE_NO_QUERY = new IOverwriteQuery()
+ {
+ public String queryOverwrite(String pathString)
+ {
+ return IOverwriteQuery.NO_ALL;
+ }
+ };
/**
* This is the constructor which should be used when creating the operation.
* It will not accept null parameter. It will not return null.
@@ -59,7 +95,27 @@
@Override
protected NewJavaEEArtifactClassOperation getNewClassOperation() {
- return new NewPortletClassOperation(getDataModel());
+ boolean isJSFPortlet = model.getBooleanProperty(IS_JSF_PORTLET);
+ if (!isJSFPortlet) {
+ return new NewPortletClassOperation(getDataModel());
+ }
+ NewJavaEEArtifactClassOperation op = new
NewJavaEEArtifactClassOperation(getDataModel()) {
+
+ @Override
+ protected void generateUsingTemplates(IProgressMonitor monitor,
+ IPackageFragment fragment) throws WFTWrappedException,
+ CoreException {
+
+ }
+
+ @Override
+ public IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return Status.OK_STATUS;
+ }
+
+ };
+ return op;
}
protected void generateMetaData(IDataModel aModel, String qualifiedClassName) {
@@ -74,13 +130,147 @@
// generate/update *.object.xml
updatePortletObject(aModel);
}
+ boolean addJBossApp = model.getBooleanProperty(ADD_JBOSS_APP);
+ if (addJBossApp) {
+ updateJBossApp(aModel);
+ }
+ boolean addJBossPortlet = model.getBooleanProperty(ADD_JBOSS_PORTLET);
+ if (addJBossPortlet) {
+ updateJBossPortlet(aModel);
+ }
+
+ boolean copyJSFTemplates = model.getBooleanProperty(COPY_JSF_TEMPLATES);
+ if (copyJSFTemplates) {
+ try {
+ copyJSFTemplates(aModel);
+ } catch (Exception e) {
+ PortletUIActivator.log(e);
+ }
+ }
}
+ private void updateJBossPortlet(IDataModel model) {
+ IProject project = getTargetProject();
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFile portletVirtualFile = component.getRootFolder().getFile(
+ IPortletConstants.JBOSS_PORTLET_FILE);
+
+ if (!portletVirtualFile.getUnderlyingFile().exists()) {
+ try {
+ PortletCoreActivator.createJBossPortlet(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();
+
+ String name = model.getStringProperty(NAME);
+ Element portlet = addNode(document,element,"portlet",null);
+ addNode(document,portlet,"portlet-name",name);
+ addNode(document,portlet,"header-content",null);
+
+ 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 copyJSFTemplates(IDataModel model) throws Exception {
+ IProject project = getTargetProject();
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFolder jsfFolder = component.getRootFolder().getFolder("jsf");
+ if (!jsfFolder.exists()) {
+ jsfFolder.create(IResource.FORCE, new NullProgressMonitor());
+ }
+ IContainer folder = jsfFolder.getUnderlyingFolder();
+
+ Bundle bundle = Platform.getBundle(PortletUIActivator.PLUGIN_ID);
+ URL jsfURL = bundle.getEntry("/resources/jsf");
+ String jsfFolderName = FileLocator.toFileURL(jsfURL).getFile();
+ File source = new File(jsfFolderName);
+ File[] files = source.listFiles(new FileFilter() {
+
+ public boolean accept(File pathname) {
+ return pathname.isFile();
+ }
+
+ });
+ List<File> filesToImport = Arrays.asList(files);
+ ImportOperation importOperation = new ImportOperation(folder
+ .getFullPath(), source, FileSystemStructureProvider.INSTANCE,
+ OVERWRITE_NO_QUERY, filesToImport);
+ importOperation.setCreateContainerStructure(false);
+ IProgressMonitor monitor = new NullProgressMonitor();
+ importOperation.run(monitor);
+ }
+
+ private void updateJBossApp(IDataModel model) {
+ IProject project = getTargetProject();
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFile portletVirtualFile = component.getRootFolder().getFile(
+ IPortletConstants.JBOSS_APP_FILE);
+
+ if (!portletVirtualFile.getUnderlyingFile().exists()) {
+ try {
+ PortletCoreActivator.createJBossApp(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();
+
+ NodeList appNameNodes = element.getElementsByTagName("app-name");
+ if (appNameNodes.getLength() <= 0) {
+ String appName = model.getStringProperty(JBOSS_APP);
+ addNode(document, element, "app-name", appName);
+ 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 updatePortletObject(IDataModel model) {
- String name = model.getStringProperty(NAME);
String instanceId = model.getStringProperty(INSTANCE_NAME);
String windowName = model.getStringProperty(WINDOW_NAME);
+ String pageName = model.getStringProperty(PAGE_NAME);
String ifExists = model.getStringProperty(IF_EXISTS);
String parent = model.getStringProperty(PARENT_PORTAL);;
String region = model.getStringProperty(PAGE_REGION);
@@ -114,8 +304,16 @@
addNode(document,deployment,"parent-ref",parent);
addNode(document,deployment,"if-exists",ifExists);
- Element window = addNode(document,deployment,"window",null);
+ Element page = null;
+ if (pageName != null && pageName.trim().length() > 0) {
+ page = addNode(document,deployment,"page",null);
+ addNode(document,page,"page-name",pageName);
+ } else {
+ page=deployment;
+ }
+ Element window = addNode(document,page,"window",null);
+
addNode(document,window,"window-name",windowName);
addNode(document,window,"instance-ref",instanceId);
addNode(document,window,"region",region);
@@ -194,16 +392,10 @@
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"));
+ IFile portletFile = PortletUIActivator.getPortletXmlFile(project);
+ if (portletFile == null) {
return;
}
-
- IFile portletFile = portletVirtualFile.getUnderlyingFile();
IDOMModel domModel = null;
try {
domModel = (IDOMModel) StructuredModelManager.getModelManager()
@@ -228,6 +420,20 @@
// portlet-class
addNode(document,portlet,"portlet-class",className);
+ // init-param
+ List initParamList = (List) aModel.getProperty(INIT_PARAM);
+ if (initParamList != null) {
+ for (Iterator iterator = initParamList.iterator(); iterator
+ .hasNext();) {
+ String[] arrayString = (String[]) iterator.next();
+ Element initParam = addNode(document,portlet,"init-param",null);
+ addNode(document,initParam,"name",arrayString[0]);
+ addNode(document,initParam,"value",arrayString[1]);
+ if (arrayString[2] != null && arrayString[2].length() > 0) {
+ addNode(document,initParam,"description",arrayString[2]);
+ }
+ }
+ }
// supports
Element supports = addNode(document,portlet,"supports",null);
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/INewPortletClassDataModelProperties.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -33,6 +33,8 @@
static final String WINDOW_NAME = "NewPortletClassDataModel.WINDOW_NAME";
+ static final String PAGE_NAME = "NewPortletClassDataModel.PAGE_NAME";
+
static final String PARENT_PORTAL = "NewPortletClassDataModel.PARENT_PORTAL";
static final String PAGE_REGION = "NewPortletClassDataModel.PAGE_REGION";
@@ -43,4 +45,13 @@
static final String ADD_PORTLET = "NewPortletClassDataModel.ADD_PORTLET";
+ static final String ADD_JBOSS_APP = "NewPortletClassDataModel.ADD_JBOSS_APP";
+
+ static final String ADD_JBOSS_PORTLET =
"NewPortletClassDataModel.ADD_JBOSS_PORTLET";
+
+ static final String JBOSS_APP = "NewPortletClassDataModel.JBOSS_APP";
+
+ static final String IS_JSF_PORTLET =
"NewPortletClassDataModel.IS_JSF_PORTLET";
+
+ static final String COPY_JSF_TEMPLATES =
"NewPortletClassDataModel.COPY_JSF_TEMPLATES";
}
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/IPortletUIConstants.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -9,6 +9,7 @@
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_JSF_PORTLET_WIZARD_PAGE_TITLE = "Create JBoss JSF
Portlet";
static final String ADD_JBOSS_PORTLET_WIZARD_PAGE_DESC = "Enter JBoss portlet
specific information";
static final String DISPLAY_NAME_LABEL = "Display name:";
@@ -54,9 +55,20 @@
static final String ADD_PORTLET_LABEL = "Create Portlet Instance";
static final String INSTANCE_NAME_LABEL = "Instance Name:";
static final String WINDOW_NAME_LABEL = "Window Name:";
+ static final String PAGE_NAME_LABEL = "Page 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:";
+ static final String NEW_JBOSS_JSF_PORTLET_WIZARD_PAGE_DESC = "Specify class file
information";
+ static final String JBOSS_JSF_PORTLET_CLASS =
"javax.portlet.faces.GenericFacesPortlet";
+ static final String JBOSS_JSF_PORTLET_NAME = "riPortlet";
+ static final String JBOSS_JSF_DISPLAY_PORTLET_NAME = "JBoss JSF Portlet";
+ static final String JBOSS_JSF_PORTLET_TITLE = "JBoss JSF Portlet";
+ static final String JBOSS_APP_LABEL = "JBoss Application Name:";
+ static final String ADD_JBOSS_APP_LABEL = "Create JBoss Application";
+ static final String ADD_JBOSS_PORTLET_LABEL = "Add the jboss-portlet.xml
file";
+ static final String COPY_JSF_TEMPLATES_LABEL = "Copy JSF Templates";
+
}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/MultiSelectFilteredFileSelectionDialog.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/MultiSelectFilteredFileSelectionDialog.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/MultiSelectFilteredFileSelectionDialog.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -0,0 +1,609 @@
+package org.jboss.tools.portlet.ui;
+
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.DEFAULT_PACKAGE;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.ui.ISharedImages;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jst.j2ee.internal.dialogs.FilteredFileSelectionDialog;
+import org.eclipse.jst.j2ee.internal.dialogs.TwoArrayQuickSorter;
+import org.eclipse.jst.j2ee.internal.dialogs.TypedFileViewerFilter;
+import org.eclipse.jst.j2ee.internal.web.providers.WebAppEditResourceHandler;
+import org.eclipse.jst.servlet.ui.internal.wizard.SimpleTypedElementSelectionValidator;
+import org.eclipse.jst.servlet.ui.internal.wizard.StringMatcher;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+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.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.part.PageBook;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+/**
+ * Insert the type's description here.
+ * Creation date: (7/30/2001 11:16:36 AM)
+ */
+public class MultiSelectFilteredFileSelectionDialog extends
+ FilteredFileSelectionDialog implements SelectionListener {
+
+
+ private static class PackageRenderer extends LabelProvider {
+ private final Image PACKAGE_ICON =
JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_PACKAGE);
+
+ public String getText(Object element) {
+ IType type = (IType) element;
+ String p = type.getPackageFragment().getElementName();
+ if ("".equals(p)) //$NON-NLS-1$
+ p = DEFAULT_PACKAGE;
+ return (p + " - " +
type.getPackageFragment().getParent().getPath().toString()); //$NON-NLS-1$
+ }
+ public Image getImage(Object element) {
+ return PACKAGE_ICON;
+ }
+ }
+
+ private static class TypeRenderer extends LabelProvider {
+ private final Image CLASS_ICON =
JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_CLASS);
+
+ public String getText(Object element) {
+ IType e = ((IType) element);
+ return e.getElementName();
+ }
+
+ public Image getImage(Object element) {
+ return CLASS_ICON;
+ }
+
+ }
+
+ protected PageBook fPageBook = null;
+ protected Control fPortletControl = null;
+ protected Composite fChild = null;
+ // construction parameters
+ protected IRunnableContext fRunnableContext;
+ protected ILabelProvider fElementRenderer;
+ protected ILabelProvider fQualifierRenderer;
+ private Object[] fElements;
+ private boolean fIgnoreCase = true;
+ private String fUpperListLabel;
+ private String fLowerListLabel;
+ // SWT widgets
+ private Table fUpperList;
+ private Table fLowerList;
+ protected Text fText;
+ private IType[] fIT;
+ private String[] fRenderedStrings;
+ private int[] fElementMap;
+ private Integer[] fQualifierMap;
+
+ private ISelectionStatusValidator fLocalValidator = null;
+ /**
+ * MultiSelectFilteredFileSelectionDialog constructor comment.
+ * @param parent Shell
+ * @param title String
+ * @param message String
+ * @parent extensions String[]
+ * @param allowMultiple boolean
+ */
+ public MultiSelectFilteredFileSelectionDialog(Shell parent, String title, String
message, String[] extensions, boolean allowMultiple, IProject project) {
+ super(parent, title, message, extensions, allowMultiple);
+ setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
+
+ if (title == null)
+ setTitle(WebAppEditResourceHandler.getString("File_Selection_UI_"));
//$NON-NLS-1$
+ if (message == null)
+ message = WebAppEditResourceHandler.getString("Select_a_file__UI_");
//$NON-NLS-1$
+ setMessage(message);
+ setExtensions(extensions);
+ addFilter(new TypedFileViewerFilter(extensions));
+ fLocalValidator = new SimpleTypedElementSelectionValidator(new Class[] { IFile.class },
allowMultiple);
+ setValidator(fLocalValidator);
+
+ //StatusInfo currStatus = new StatusInfo();
+ //currStatus.setOK();
+ Status currStatus = new Status(Status.OK, PortletCoreActivator.PLUGIN_ID, Status.OK,
"", null);
+
+ updateStatus(currStatus);
+ fElementRenderer = new TypeRenderer();
+ fQualifierRenderer = new PackageRenderer();
+ fRunnableContext = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ try {
+ IJavaElement jelem = null;
+ IProject proj = null;
+ jelem = (IJavaElement) project.getAdapter(IJavaElement.class);
+ if (jelem == null) {
+ IResource resource = (IResource) project.getAdapter(IResource.class);
+ if (resource != null) {
+ proj = resource.getProject();
+ if (proj != null) {
+ jelem = org.eclipse.jdt.core.JavaCore.create(proj);
+ }
+ }
+ }
+ IJavaProject jp = jelem.getJavaProject();
+
+ IType portletType = jp.findType(IPortletUIConstants.QUALIFIED_PORTLET);
+ // next 3 lines fix defect 177686
+ if (portletType == null) {
+ return;
+ }
+
+ ArrayList portletClasses = new ArrayList();
+ ITypeHierarchy tH = portletType.newTypeHierarchy(jp, null);
+ IType[] types = tH.getAllSubtypes(portletType);
+ for (int i = 0; i < types.length; i++) {
+ if (types[i].isClass() && !portletClasses.contains(types[i]))
+ portletClasses.add(types[i]);
+ }
+ fIT = (IType[]) portletClasses.toArray(new IType[portletClasses.size()]);
+ portletClasses = null;
+
+ } catch (Exception e) {
+ PortletCoreActivator.log(e);
+ }
+ }
+
+ /**
+ * @private
+ */
+ protected void computeResult() {
+ IType type = (IType) getWidgetSelection();
+ if (type != null) {
+ if (type == null) {
+ String title = WebAppEditResourceHandler
+ .getString("Select_Class_UI_"); //$NON-NLS-1$ = "Select Class"
+ String message = WebAppEditResourceHandler
+ .getString("Could_not_uniquely_map_the_ERROR_"); //$NON-NLS-1$ =
"Could not uniquely map the class name to a class."
+ MessageDialog.openError(getShell(), title, message);
+ setResult(null);
+ } else {
+ java.util.List result = new ArrayList(1);
+ result.add(type);
+ setResult(result);
+ }
+ }
+ }
+
+ public void create() {
+ super.create();
+ fText.setFocus();
+ rematch(""); //$NON-NLS-1$
+ updateOkState();
+ }
+
+ /**
+ * Creates and returns the contents of this dialog's
+ * button bar.
+ * <p>
+ * The <code>Dialog</code> implementation of this framework method
+ * lays out a button bar and calls the
<code>createButtonsForButtonBar</code>
+ * framework method to populate it. Subclasses may override.
+ * </p>
+ *
+ * @param parent the parent composite to contain the button bar
+ * @return the button bar control
+ */
+ protected Control createButtonBar(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+
+ layout.numColumns = 2;
+
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite composite2 = new Composite(composite, SWT.NONE);
+
+ // create a layout with spacing and margins appropriate for the font size.
+ layout = new GridLayout();
+ layout.numColumns = 0; // this is incremented by createButton
+ layout.makeColumnsEqualWidth = true;
+ layout.marginWidth =
convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_MARGIN);
+ layout.marginHeight =
convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_MARGIN);
+ layout.horizontalSpacing =
convertHorizontalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.HORIZONTAL_SPACING);
+ layout.verticalSpacing =
convertVerticalDLUsToPixels(org.eclipse.jface.dialogs.IDialogConstants.VERTICAL_SPACING);
+
+ composite2.setLayout(layout);
+
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END |
GridData.VERTICAL_ALIGN_CENTER);
+ composite2.setLayoutData(data);
+
+ composite2.setFont(parent.getFont());
+
+ // Add the buttons to the button bar.
+ super.createButtonsForButtonBar(composite2);
+
+ return composite;
+ }
+
+ /*
+ * @private
+ */
+ protected Control createDialogArea(Composite parent) {
+ GridData gd = new GridData();
+
+ fChild = new Composite(parent, SWT.NONE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(fChild,
"com.ibm.etools.webapplicationedit.webx2010"); //$NON-NLS-1$
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ gl.marginHeight = 0;
+ fChild.setLayout(gl);
+
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessVerticalSpace = true;
+ fChild.setLayoutData(gd);
+
+ fPageBook = new PageBook(fChild, SWT.NONE);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalSpan = 2;
+ fPageBook.setLayoutData(gd);
+ fPortletControl = super.createDialogArea(fPageBook);
+
+ Composite composite = new Composite(fPageBook, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+ layout.marginWidth =
convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.verticalSpacing =
convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ layout.horizontalSpacing =
convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ composite.setFont(parent.getFont());
+
+ Label messageLabel = new Label(composite, SWT.NONE);
+ gd = new GridData();
+ messageLabel.setLayoutData(gd);
+ messageLabel.setText("Choose a portlet"); //$NON-NLS-1$
+
+ fText = createText(composite);
+
+ messageLabel = new Label(composite, SWT.NONE);
+ gd = new GridData();
+ messageLabel.setLayoutData(gd);
+ messageLabel.setText("Matching portlets"); //$NON-NLS-1$
+
+ fUpperList = createUpperList(composite);
+
+ messageLabel = new Label(composite, SWT.NONE);
+ gd = new GridData();
+ messageLabel.setLayoutData(gd);
+ messageLabel.setText(WebAppEditResourceHandler.getString("Qualifier__3"));
//$NON-NLS-1$
+
+ fLowerList = createLowerList(composite);
+
+ fPortletControl = composite;
+ fPageBook.showPage(fPortletControl);
+ return parent;
+ }
+
+ /**
+ * Creates the list widget and sets layout data.
+ * @return org.eclipse.swt.widgets.List
+ */
+ private Table createLowerList(Composite parent) {
+ if (fLowerListLabel != null)
+ (new Label(parent, SWT.NONE)).setText(fLowerListLabel);
+
+ Table list = new Table(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ list.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event evt) {
+ handleLowerSelectionChanged();
+ }
+ });
+ list.addListener(SWT.MouseDoubleClick, new Listener() {
+ public void handleEvent(Event evt) {
+ handleLowerDoubleClick();
+ }
+ });
+ list.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ fQualifierRenderer.dispose();
+ }
+ });
+ GridData spec = new GridData();
+ spec.widthHint = convertWidthInCharsToPixels(50);
+ spec.heightHint = convertHeightInCharsToPixels(5);
+ spec.grabExcessVerticalSpace = true;
+ spec.grabExcessHorizontalSpace = true;
+ spec.horizontalAlignment = GridData.FILL;
+ spec.verticalAlignment = GridData.FILL;
+ list.setLayoutData(spec);
+ return list;
+ }
+
+ /**
+ * Creates the text widget and sets layout data.
+ * @return org.eclipse.swt.widgets.Text
+ */
+ private Text createText(Composite parent) {
+ Text text = new Text(parent, SWT.BORDER);
+ GridData spec = new GridData();
+ spec.grabExcessVerticalSpace = false;
+ spec.grabExcessHorizontalSpace = true;
+ spec.horizontalAlignment = GridData.FILL;
+ spec.verticalAlignment = GridData.BEGINNING;
+ text.setLayoutData(spec);
+ Listener l = new Listener() {
+ public void handleEvent(Event evt) {
+ rematch(fText.getText());
+ }
+ };
+ text.addListener(SWT.Modify, l);
+ return text;
+ }
+
+ /**
+ * Creates the list widget and sets layout data.
+ * @return org.eclipse.swt.widgets.List
+ */
+ private Table createUpperList(Composite parent) {
+ if (fUpperListLabel != null)
+ (new Label(parent, SWT.NONE)).setText(fUpperListLabel);
+
+ Table list = new Table(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ list.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event evt) {
+ handleUpperSelectionChanged();
+ }
+ });
+ list.addListener(SWT.MouseDoubleClick, new Listener() {
+ public void handleEvent(Event evt) {
+ handleUpperDoubleClick();
+ }
+ });
+ list.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ fElementRenderer.dispose();
+ }
+ });
+ GridData spec = new GridData();
+ spec.widthHint = convertWidthInCharsToPixels(50);
+ spec.heightHint = convertHeightInCharsToPixels(15);
+ spec.grabExcessVerticalSpace = true;
+ spec.grabExcessHorizontalSpace = true;
+ spec.horizontalAlignment = GridData.FILL;
+ spec.verticalAlignment = GridData.FILL;
+ list.setLayoutData(spec);
+ return list;
+ }
+
+ /**
+ * @return the ID of the button that is 'pressed' on doubleClick in the lists.
+ * By default it is the OK button.
+ * Override to change this setting.
+ */
+ protected int getDefaultButtonID() {
+ return IDialogConstants.OK_ID;
+ }
+
+ protected Object getWidgetSelection() {
+ int i = fLowerList.getSelectionIndex();
+ if (fQualifierMap != null) {
+ if (fQualifierMap.length == 1)
+ i = 0;
+ if (i < 0) {
+ return null;
+ }
+ Integer index = fQualifierMap[i];
+ return fElements[index.intValue()];
+ }
+ return null;
+ }
+
+ protected final void handleLowerDoubleClick() {
+ if (getWidgetSelection() != null)
+ buttonPressed(getDefaultButtonID());
+ }
+
+ protected final void handleLowerSelectionChanged() {
+ updateOkState();
+ }
+
+ protected final void handleUpperDoubleClick() {
+ if (getWidgetSelection() != null)
+ buttonPressed(getDefaultButtonID());
+ }
+
+ protected final void handleUpperSelectionChanged() {
+ int selection = fUpperList.getSelectionIndex();
+ if (selection >= 0) {
+ int i = fElementMap[selection];
+ int k = i;
+ int length = fRenderedStrings.length;
+ while (k < length && fRenderedStrings[k].equals(fRenderedStrings[i])) {
+ k++;
+ }
+ updateLowerListWidget(i, k);
+ } else
+ updateLowerListWidget(0, 0);
+ }
+
+ public int open() {
+
+ if (fIT == null || fIT.length == 0) {
+ MessageDialog.openInformation(getShell(),
WebAppEditResourceHandler.getString("Empty_List_1"), "No portlets exist to
add");
+ return CANCEL;
+ }
+
+ setElements(fIT);
+ setInitialSelection(""); //$NON-NLS-1$
+ return super.open();
+ }
+
+ /**
+ * update the list to reflect a new match string.
+ * @param matchString java.lang.String
+ */
+ protected final void rematch(String matchString) {
+ int k = 0;
+ String text = fText.getText();
+ StringMatcher matcher = new StringMatcher(text + "*", fIgnoreCase, false);
//$NON-NLS-1$
+ String lastString = null;
+ int length = fElements.length;
+ for (int i = 0; i < length; i++) {
+ while (i < length && fRenderedStrings[i].equals(lastString))
+ i++;
+ if (i < length) {
+ lastString = fRenderedStrings[i];
+ if (matcher.match(fRenderedStrings[i])) {
+ fElementMap[k] = i;
+ k++;
+ }
+ }
+ }
+ fElementMap[k] = -1;
+
+ updateUpperListWidget(fElementMap, k);
+ }
+
+ /**
+ *
+ * @return java.lang.String[]
+ * @param p org.eclipse.jface.elements.IIndexedProperty
+ */
+ private String[] renderStrings(Object[] p) {
+ String[] strings = new String[p.length];
+ int size = strings.length;
+ for (int i = 0; i < size; i++) {
+ strings[i] = fElementRenderer.getText(p[i]);
+ }
+ new TwoArrayQuickSorter(fIgnoreCase).sort(strings, p);
+ return strings;
+ }
+
+ public void setElements(Object[] elements) {
+ fElements = elements;
+ fElementMap = new int[fElements.length + 1];
+ fRenderedStrings = renderStrings(fElements);
+ }
+
+ private void updateLowerListWidget(int from, int to) {
+ fLowerList.removeAll();
+ fQualifierMap = new Integer[to - from];
+ String[] qualifiers = new String[to - from];
+ for (int i = from; i < to; i++) {
+ // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer
+ qualifiers[i - from] = fQualifierRenderer.getText(fElements[i]);
+ fQualifierMap[i - from] = new Integer(i);
+ }
+
+ new TwoArrayQuickSorter(fIgnoreCase).sort(qualifiers, fQualifierMap);
+
+ for (int i = 0; i < to - from; i++) {
+ TableItem ti = new TableItem(fLowerList, i);
+ ti.setText(qualifiers[i]);
+ // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer
+ Image img = fQualifierRenderer.getImage(fElements[from + i]);
+ if (img != null)
+ ti.setImage(img);
+ }
+
+ if (fLowerList.getItemCount() > 0)
+ fLowerList.setSelection(0);
+ updateOkState();
+ }
+
+ private void updateOkState() {
+ Button okButton = getOkButton();
+ if (okButton != null)
+ okButton.setEnabled(getWidgetSelection() != null);
+ }
+
+ private void updateUpperListWidget(int[] indices, int size) {
+ fUpperList.setRedraw(false);
+ int itemCount = fUpperList.getItemCount();
+ if (size < itemCount)
+ fUpperList.remove(0, itemCount - size - 1);
+ TableItem[] items = fUpperList.getItems();
+ for (int i = 0; i < size; i++) {
+ TableItem ti = null;
+ if (i < itemCount)
+ ti = items[i];
+ else
+ ti = new TableItem(fUpperList, i);
+ ti.setText(fRenderedStrings[indices[i]]);
+ // XXX: 1G65LDG: JFUIF:WIN2000 - ILabelProvider used outside a viewer
+ Image img = fElementRenderer.getImage(fElements[indices[i]]);
+ if (img != null)
+ ti.setImage(img);
+ }
+ if (fUpperList.getItemCount() > 0)
+ fUpperList.setSelection(0);
+ fUpperList.setRedraw(true);
+ handleUpperSelectionChanged();
+ }
+
+ /**
+ * Sent when default selection occurs in the control.
+ * <p>
+ * For example, on some platforms default selection occurs
+ * in a List when the user double-clicks an item or types
+ * return in a Text.
+ * </p>
+ *
+ * @param e an event containing information about the default selection
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // Do nothing
+ }
+
+ /**
+ * Sent when selection occurs in the control.
+ * <p>
+ * For example, on some platforms selection occurs in
+ * a List when the user selects an item or items.
+ * </p>
+ *
+ * @param e an event containing information about the selection
+ */
+ public void widgetSelected(SelectionEvent e) {
+
+ }
+
+ /**
+ * @see ElementTreeSelectionDialog#updateOKStatus()
+ */
+ protected void updateOKStatus() {
+ super.updateOKStatus();
+ Button okButton = getOkButton();
+ if (okButton != null)
+ okButton.setEnabled(fLocalValidator.validate(getResult()).isOK());
+ }
+
+}
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/PortletUIActivator.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -1,6 +1,15 @@
package org.jboss.tools.portlet.ui;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
import org.osgi.framework.BundleContext;
/**
@@ -46,5 +55,28 @@
public static PortletUIActivator getDefault() {
return plugin;
}
+
+ public static IFile getPortletXmlFile(IProject project) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFile portletVirtualFile = component.getRootFolder().getFile(
+ IPortletConstants.CONFIG_PATH);
+ if (!portletVirtualFile.getUnderlyingFile().exists()) {
+ log(new RuntimeException("The portlet.xml file doesn't exist"));
+ return null;
+ }
+
+ IFile portletFile = portletVirtualFile.getUnderlyingFile();
+ return portletFile;
+ }
+
+ public static void log(Exception e, String message) {
+ IStatus status = new Status(IStatus.ERROR,PLUGIN_ID,message,e);
+ PortletCoreActivator.getDefault().getLog().log(status);
+ }
+
+ public static void log(Throwable e) {
+ IStatus status = new Status(IStatus.ERROR,PLUGIN_ID,e.getLocalizedMessage(),e);
+ PortletCoreActivator.getDefault().getLog().log(status);
+ }
}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/project/facet/JSFPortletFacetInstallPage.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -0,0 +1,71 @@
+package org.jboss.tools.portlet.ui.internal.project.facet;
+
+
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+
+/**
+ * @author snjeza
+ */
+public class JSFPortletFacetInstallPage extends AbstractFacetWizardPage {
+
+ private IDialogSettings dialogSettings;
+ private IDataModel model;
+ private IDialogSettings jsfSection;
+
+ public JSFPortletFacetInstallPage() {
+ super("JSFPortletProjectConfigurationWizardPage");
+ setTitle("JBoss JSF Portlet Capabilities");
+ setDescription("Add JBoss JSF Portlet capabilities to this Web Project");
+ //ImageDescriptor imageDesc = getDefaultPageImageDescriptor( );
+ //if ( imageDesc != null )
+ // setImageDescriptor( imageDesc );
+ dialogSettings = PortletUIActivator.getDefault().getDialogSettings();
+ }
+
+ public void createControl(Composite parent) {
+ initializeDialogUnits(parent);
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1,false));
+
+ final Button btn = new Button(composite,SWT.CHECK);
+ btn.setText("Deploy jars to WEB-INF/lib");
+ jsfSection = dialogSettings.getSection(IPortletConstants.JSF_SECTION);
+ boolean deployJars;
+ if (jsfSection == null) {
+ jsfSection = dialogSettings.addNewSection(IPortletConstants.JSF_SECTION);
+ deployJars = true;
+ } else {
+ deployJars = jsfSection.getBoolean(IPortletConstants.DEPLOY_JARS);
+ }
+ btn.setSelection(deployJars);
+ jsfSection.put(IPortletConstants.DEPLOY_JARS, btn.getSelection());
+ btn.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ model.setBooleanProperty(IPortletConstants.DEPLOY_JARS, btn.getSelection());
+ jsfSection.put(IPortletConstants.DEPLOY_JARS, btn.getSelection());
+ }
+
+ });
+ setControl( composite );
+ }
+
+ public void setConfig(Object config) {
+ this.model = (IDataModel) config;
+ }
+
+
+
+}
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddJBossPortletWizardPage.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -18,22 +18,33 @@
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.IS_JSF_PORTLET;
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.PAGE_NAME;
import static org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.IF_EXISTS;
import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.ADD_PORTLET;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.ADD_JBOSS_APP;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.ADD_JBOSS_PORTLET;
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.INewPortletClassDataModelProperties.JBOSS_APP;
+import static
org.jboss.tools.portlet.ui.INewPortletClassDataModelProperties.COPY_JSF_TEMPLATES;
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.PAGE_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 static org.jboss.tools.portlet.ui.IPortletUIConstants.JBOSS_APP_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.ADD_JBOSS_APP_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.ADD_JBOSS_PORTLET_LABEL;
+import static org.jboss.tools.portlet.ui.IPortletUIConstants.COPY_JSF_TEMPLATES_LABEL;
import static org.jboss.tools.portlet.ui.IPortletUIConstants.ADD_PORTLET_LABEL;
import org.eclipse.core.runtime.IStatus;
@@ -140,6 +151,14 @@
synchHelper.synchText(instanceNameText, INSTANCE_NAME, null);
// window name
+ Label pageNameLabel = new Label(composite, SWT.LEFT);
+ pageNameLabel.setText(PAGE_NAME_LABEL);
+ pageNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ final Text pageNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ pageNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(pageNameText, PAGE_NAME, null);
+
+ // window name
Label windowNameLabel = new Label(composite, SWT.LEFT);
windowNameLabel.setText(WINDOW_NAME_LABEL);
windowNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
@@ -171,17 +190,9 @@
heightText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(heightText, PORTLET_HEIGHT, null);
- addPortlet.addSelectionListener(new SelectionListener() {
+ addPortlet.addSelectionListener(new SelectionAdapter() {
- public void widgetDefaultSelected(SelectionEvent e) {
- //enableComponents();
- }
-
public void widgetSelected(SelectionEvent e) {
- enableComponents();
- }
-
- private void enableComponents() {
boolean enable = addPortlet.getSelection();
ifExistsCombo.setEnabled(enable);
instanceNameText.setEnabled(enable);
@@ -192,6 +203,45 @@
}
});
+ if (isJSFPortlet()) {
+ final Button addJBossApp = new Button(composite, SWT.CHECK);
+ addJBossApp.setText(ADD_JBOSS_APP_LABEL);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalSpan = 2;
+ addJBossApp.setLayoutData(gd);
+ synchHelper.synchCheckbox(addJBossApp, ADD_JBOSS_APP, null);
+
+ // JBoss Application Name
+ Label jbossAppLabel = new Label(composite, SWT.LEFT);
+ jbossAppLabel.setText(JBOSS_APP_LABEL);
+ jbossAppLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ final Text jbossAppText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ jbossAppText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(jbossAppText, JBOSS_APP, null);
+
+ addJBossApp.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ boolean enable = addJBossApp.getSelection();
+ jbossAppText.setEnabled(enable);
+
+ }
+ });
+
+ final Button addJBossPortlet = new Button(composite, SWT.CHECK);
+ addJBossPortlet.setText(ADD_JBOSS_PORTLET_LABEL);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalSpan = 2;
+ addJBossPortlet.setLayoutData(gd);
+ synchHelper.synchCheckbox(addJBossPortlet, ADD_JBOSS_PORTLET, null);
+
+ final Button copyJSFTemplates = new Button(composite, SWT.CHECK);
+ copyJSFTemplates.setText(COPY_JSF_TEMPLATES_LABEL);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalSpan = 2;
+ copyJSFTemplates.setLayoutData(gd);
+ synchHelper.synchCheckbox(copyJSFTemplates, COPY_JSF_TEMPLATES, null);
+ }
}
public boolean canFlipToNextPage() {
@@ -205,4 +255,7 @@
return true;
}
+ protected boolean isJSFPortlet() {
+ return model.getBooleanProperty(IS_JSF_PORTLET);
+ }
}
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddPortletWizardPage.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -4,6 +4,9 @@
import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION;
import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME;
+import java.util.ArrayList;
+import java.util.List;
+
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;
@@ -20,6 +23,7 @@
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.IS_JSF_PORTLET;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.Dialog;
@@ -34,6 +38,8 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
@@ -89,6 +95,30 @@
INIT_PARAM);
initSection.setCallback(callback);
+ if (isJSFPortlet()) {
+ List<String[]> initParamList = new ArrayList<String[]>();
+ String[] arrayString = new String[3];
+ arrayString[0]="javax.portlet.faces.defaultViewId.view";
+ arrayString[1]="/jsf/view.jsp";
+ arrayString[2]="";
+ initParamList.add(arrayString);
+
+ arrayString = new String[3];
+ arrayString[0]="javax.portlet.faces.defaultViewId.edit";
+ arrayString[1]="/jsf/edit.jsp";
+ arrayString[2]="";
+ initParamList.add(arrayString);
+
+ arrayString = new String[3];
+ arrayString[0]="javax.portlet.faces.defaultViewId.help";
+ arrayString[1]="/jsf/help.jsp";
+ arrayString[2]="";
+ initParamList.add(arrayString);
+
+ initSection.setInput(initParamList);
+
+ }
+
String text = nameText.getText();
nameText.setFocus();
@@ -141,6 +171,9 @@
nameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(nameText, NAME, null);
+ if (isJSFPortlet()) {
+ nameText.setText(IPortletUIConstants.JBOSS_JSF_PORTLET_NAME);
+ }
// display name
Label displayNameLabel = new Label(composite, SWT.LEFT);
@@ -149,7 +182,9 @@
Text displayNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
displayNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(displayNameText, DISPLAY_NAME, null);
-
+ if (isJSFPortlet()) {
+ displayNameText.setText(IPortletUIConstants.JBOSS_JSF_DISPLAY_PORTLET_NAME);
+ }
// title
Label titleLabel = new Label(composite, SWT.LEFT);
titleLabel.setText(IPortletUIConstants.TITLE_LABEL);
@@ -157,7 +192,9 @@
Text titleText = new Text(composite, SWT.SINGLE | SWT.BORDER);
titleText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(titleText, TITLE, null);
-
+ if (isJSFPortlet()) {
+ titleText.setText(IPortletUIConstants.JBOSS_JSF_PORTLET_TITLE);
+ }
// description
Label descLabel = new Label(composite, SWT.LEFT);
descLabel.setText(DESCRIPTION_LABEL);
@@ -182,4 +219,7 @@
return true;
}
+ protected boolean isJSFPortlet() {
+ return model.getBooleanProperty(IS_JSF_PORTLET);
+ }
}
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewJSFPortletClassWizardPage.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewJSFPortletClassWizardPage.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewJSFPortletClassWizardPage.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -0,0 +1,264 @@
+package org.jboss.tools.portlet.ui.internal.wizard;
+
+import static
org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CLASS_NAME;
+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 static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.BROWSE_BUTTON_LABEL;
+import static
org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.CLASS_NAME_LABEL;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
+import org.eclipse.jst.j2ee.internal.wizard.NewJavaClassWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Cursor;
+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.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import
org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties;
+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.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.ui.IPortletUIConstants;
+import org.jboss.tools.portlet.ui.MultiSelectFilteredFileSelectionDialog;
+
+/**
+ * JBoss Portlet Wizard Setting Page
+ *
+ * @author snjeza
+ */
+public class NewJSFPortletClassWizardPage extends NewJavaClassWizardPage {
+
+ protected Label projectNameLabel;
+ private Combo projectNameCombo;
+ private String projectName;
+ private Label existingClassLabel;
+ private Text existingClassText;
+ private Button existingClassButton;
+
+ public NewJSFPortletClassWizardPage(IDataModel model, String pageName, String pageDesc,
String pageTitle,
+ String moduleType) {
+ super(model, pageName, pageDesc,pageTitle,moduleType);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jem.util.ui.wizard.WTPWizardPage#getValidationPropertyNames()
+ */
+ protected String[] getValidationPropertyNames() {
+ return new String[] { IArtifactEditOperationDataModelProperties.PROJECT_NAME};
+ }
+
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ composite.setLayout(layout);
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ data.widthHint = 300;
+ composite.setLayoutData(data);
+ Dialog.applyDialogFont(parent);
+
+ addProjectNameGroup(composite);
+
+ createUseExistingGroup(composite);
+
+ return composite;
+ }
+
+ private void createUseExistingGroup(Composite composite) {
+
+ existingClassLabel = new Label(composite, SWT.LEFT);
+ existingClassLabel.setText(CLASS_NAME_LABEL);
+ existingClassLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ existingClassText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
+ existingClassText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ synchHelper.synchText(existingClassText, CLASS_NAME, null);
+ existingClassText.setText(IPortletUIConstants.JBOSS_JSF_PORTLET_CLASS);
+
+ existingClassButton = new Button(composite, SWT.PUSH);
+ existingClassButton.setText(BROWSE_BUTTON_LABEL);
+ existingClassButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ existingClassButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleClassButtonSelected();
+ }
+ });
+ }
+
+ private 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 JSF Portlet",
+ "Choose a JSF 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$
+ IType type = (IType) ms.getFirstResult();
+ if (type != null) {
+ qualifiedClassName = type.getFullyQualifiedName();
+ }
+ existingClassText.setText(qualifiedClassName);
+ }
+ getControl().setCursor(null);
+ }
+
+ /**
+ * Add project group
+ */
+ private void addProjectNameGroup(Composite parent) {
+ // set up project name label
+ projectNameLabel = new Label(parent, SWT.NONE);
+ projectNameLabel.setText(J2EEUIMessages.getResourceString(J2EEUIMessages.MODULES_DEPENDENCY_PAGE_TABLE_PROJECT));
//$NON-NLS-1$
+ GridData data = new GridData();
+ projectNameLabel.setLayoutData(data);
+ // set up project name entry field
+ projectNameCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint = 300;
+ data.horizontalSpan = 1;
+ projectNameCombo.setLayoutData(data);
+
+ synchHelper.synchCombo(projectNameCombo,
IArtifactEditOperationDataModelProperties.PROJECT_NAME, null);
+ initializeProjectList();
+ new Label(parent, SWT.NONE);
+ }
+
+ /**
+ *
+ */
+ private void initializeProjectList() {
+ IProject[] workspaceProjects = ProjectUtilities.getAllProjects();
+ List items = new ArrayList();
+ for (int i = 0; i < workspaceProjects.length; i++) {
+ IProject project = workspaceProjects[i];
+ if (isProjectValid(project))
+ items.add(project.getName());
+ }
+ if (items.isEmpty()) return;
+ String[] names = new String[items.size()];
+ for (int i = 0; i < items.size(); i++) {
+ names[i] = (String) items.get(i);
+ }
+ projectNameCombo.setItems(names);
+ IProject selectedProject = null;
+ try {
+ if (model !=null) {
+ String projectNameFromModel =
model.getStringProperty(IArtifactEditOperationDataModelProperties.COMPONENT_NAME);
+ if (projectNameFromModel!=null && projectNameFromModel.length()>0)
+ selectedProject = ProjectUtilities.getProject(projectNameFromModel);
+ }
+ } catch (Exception e) {};
+ try {
+ if (selectedProject == null)
+ selectedProject = getSelectedProject();
+ if (selectedProject != null && selectedProject.isAccessible()
+ && selectedProject.hasNature(IModuleConstants.MODULE_NATURE_ID)) {
+ projectNameCombo.setText(selectedProject.getName());
+ model.setProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME,
selectedProject.getName());
+ }
+ } catch (CoreException ce) {
+ // Ignore
+ }
+ if (projectName == null && names.length > 0)
+ projectName = names[0];
+
+ if ((projectNameCombo.getText() == null || projectNameCombo.getText().length() == 0)
&& projectName != null) {
+ projectNameCombo.setText(projectName);
+ model.setProperty(IArtifactEditOperationDataModelProperties.PROJECT_NAME,
projectName);
+ }
+
+ }
+
+ /**
+ * @return
+ */
+ private IProject getSelectedProject() {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window == null)
+ return null;
+ ISelection selection = window.getSelectionService().getSelection();
+ if (selection == null)
+ return null;
+ if (!(selection instanceof IStructuredSelection))
+ return null;
+ IStructuredSelection stucturedSelection = (IStructuredSelection) selection;
+ if (stucturedSelection.getFirstElement() instanceof EObject)
+ return ProjectUtilities.getProject(stucturedSelection.getFirstElement());
+ IJavaElement element = getInitialJavaElement(selection);
+ if (element != null && element.getJavaProject() != null)
+ return element.getJavaProject().getProject();
+ return getExtendedSelectedProject(stucturedSelection.getFirstElement());
+ }
+
+ /**
+ * This method is used by the project list initializer. The method checks
+ * if the specified project is valid to include it in the project list.
+ *
+ * <p>Subclasses of this wizard page should override this method to
+ * adjust filtering of the projects to their needs. </p>
+ *
+ * @param project reference to the project to be checked
+ *
+ * @return <code>true</code> if the project is valid to be included in
+ * the project list, <code>false</code> - otherwise.
+ */
+ protected boolean isProjectValid(IProject project) {
+ boolean result = super.isProjectValid(project);
+ if (!result)
+ return result;
+ try {
+ result = FacetedProjectFramework.hasProjectFacet(project,
IPortletConstants.JSFPORTLET_FACET_ID);
+ } catch (CoreException ce) {
+ result = false;
+ }
+ return result;
+ }
+
+ 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/NewJSFPortletWizard.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewJSFPortletWizard.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewJSFPortletWizard.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -0,0 +1,85 @@
+package org.jboss.tools.portlet.ui.internal.wizard;
+
+import static
org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.PROJECT;
+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.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.INewPortletClassDataModelProperties;
+import org.jboss.tools.portlet.ui.IPortletUIConstants;
+import org.jboss.tools.portlet.ui.PortletUIActivator;
+
+/**
+ * New portlet wizard
+ */
+public class NewJSFPortletWizard extends NewWebArtifactWizard {
+
+ //protected static final String PAGE_FOUR = "pageFour";
+
+ public NewJSFPortletWizard() {
+ this(null);
+ }
+
+ public NewJSFPortletWizard(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() {
+ NewJSFPortletClassWizardPage page1 = new NewJSFPortletClassWizardPage(
+ 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_THREE);
+ addPage(page4);
+ }
+
+ @Override
+ protected void postPerformFinish() throws InvocationTargetException {
+ // open the portlet.xml file
+ IProject project = (IProject) getDataModel().getProperty(PROJECT);
+ IFile portletFile = PortletUIActivator.getPortletXmlFile(project);
+ if (portletFile == null) {
+ return;
+ }
+ openEditor(portletFile);
+ }
+
+ @Override
+ protected IDataModelProvider getDefaultProvider() {
+ return new NewPortletClassDataModelProvider(true);
+ }
+
+}
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -1,12 +1,13 @@
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.core.runtime.Status;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties;
import org.eclipse.jst.j2ee.internal.web.operations.NewServletClassDataModelProvider;
@@ -46,6 +47,16 @@
private final static String NON_ANNOTATED_TEMPLATE_DEFAULT =
"portlet.javajet"; //$NON-NLS-1$
+ private boolean isJSFPortlet;
+
+ public NewPortletClassDataModelProvider(boolean isJSFPortlet) {
+ this.isJSFPortlet = isJSFPortlet;
+ }
+
+ public NewPortletClassDataModelProvider() {
+ this(false);
+ }
+
/**
* Subclasses may extend this method to provide their own default operation
* for this data model provider. This implementation uses the
@@ -92,11 +103,17 @@
propertyNames.add(TEMPLATE_FILE);
propertyNames.add(INSTANCE_NAME);
propertyNames.add(WINDOW_NAME);
+ propertyNames.add(PAGE_NAME);
propertyNames.add(PARENT_PORTAL);
propertyNames.add(PAGE_REGION);
propertyNames.add(PORTLET_HEIGHT);
propertyNames.add(IF_EXISTS);
propertyNames.add(ADD_PORTLET);
+ propertyNames.add(ADD_JBOSS_APP);
+ propertyNames.add(ADD_JBOSS_PORTLET);
+ propertyNames.add(JBOSS_APP);
+ propertyNames.add(IS_JSF_PORTLET);
+ propertyNames.add(COPY_JSF_TEMPLATES);
return propertyNames;
}
@@ -126,12 +143,30 @@
@Override
public Object getDefaultProperty(String propertyName) {
+ if (propertyName.equals(IS_JSF_PORTLET)) {
+ if (isJSFPortlet)
+ return Boolean.TRUE;
+ return Boolean.FALSE;
+ }
+ if (propertyName.equals(COPY_JSF_TEMPLATES)) {
+ return Boolean.FALSE;
+ }
if (propertyName.equals(ADD_PORTLET)) {
return Boolean.TRUE;
}
+ if (propertyName.equals(ADD_JBOSS_APP)) {
+ return Boolean.TRUE;
+ }
+ if (propertyName.equals(ADD_JBOSS_PORTLET)) {
+ return Boolean.TRUE;
+ }
if (propertyName.equals(DO_VIEW)) {
return Boolean.TRUE;
}
+ if (isJSFPortlet) {
+ if (propertyName.equals(EDIT_MODE) || propertyName.equals(HELP_MODE))
+ 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;
@@ -179,9 +214,15 @@
if (propertyName.equals(WINDOW_NAME)) {
return getDefaultProperty(NAME) + "Window";
}
+ if (propertyName.equals(PAGE_NAME)) {
+ return "";
+ }
if (propertyName.equals(PORTLET_HEIGHT)) {
return "1";
}
+ if (propertyName.equals(JBOSS_APP)) {
+ return "riPortletApp";
+ }
if (propertyName.equals(PAGE_REGION)) {
return "center";
}
@@ -202,6 +243,12 @@
if (propertyName.equals(SUPERCLASS))
return validateSuperClassName(getStringProperty(propertyName));
+ if (isJSFPortlet && propertyName.equals(CLASS_NAME)) {
+ if (getStringProperty(propertyName).length()!=0) {
+ return Status.OK_STATUS;
+ }
+
+ }
// Otherwise defer to super to validate the property
return super.validate(propertyName);
}
@@ -247,7 +294,7 @@
model.notifyPropertyChange(PROCESS_ACTION, IDataModel.DEFAULT_CHG);
List ifaces = (List) model.getProperty(INTERFACES);
- ifaces.add(QUALIFIED_SERVLET);
+ ifaces.add(QUALIFIED_PORTLET);
}
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassWizardPage.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -11,6 +11,7 @@
*******************************************************************************/
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.INewServletClassDataModelProperties.IS_SERVLET_TYPE;
import static
org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
import org.eclipse.core.resources.IContainer;
@@ -26,7 +27,6 @@
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;
@@ -37,6 +37,7 @@
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;
+import org.jboss.tools.portlet.ui.MultiSelectFilteredFileSelectionDialog;
public class NewPortletClassWizardPage extends NewWebClassWizardPage {
@@ -99,6 +100,10 @@
ms.open();
if (ms.getReturnCode() == Window.OK) {
String qualifiedClassName = ""; //$NON-NLS-1$
+ IType type = (IType) ms.getFirstResult();
+ if (type != null) {
+ qualifiedClassName = type.getFullyQualifiedName();
+ }
existingClassText.setText(qualifiedClassName);
}
getControl().setCursor(null);
Modified:
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 2008-08-01
13:10:43 UTC (rev 9469)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletWizard.java 2008-08-01
13:41:55 UTC (rev 9470)
@@ -47,17 +47,17 @@
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);
+ //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);
+ //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);
+ //page3.setInfopopID(IWebUIContextIds.WEBEDITOR_SERVLET_PAGE_ADD_SERVLET_WIZARD_3);
addPage(page3);
AddJBossPortletWizardPage page4 = new AddJBossPortletWizardPage(getDataModel(),
PAGE_FOUR);
addPage(page4);
@@ -65,7 +65,7 @@
@Override
protected void postPerformFinish() throws InvocationTargetException {
- // open new servlet class in java editor
+ // open new portlet class in java editor
openJavaClass();
}