Author: snjeza
Date: 2008-07-23 18:58:08 -0400 (Wed, 23 Jul 2008)
New Revision: 9255
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/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/internal/wizard/AddJBossPortletWizardPage.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
Log:
JBIDE-2233 Ability to create a new "Portlet" project - Thomas's suggestions
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-07-23
21:47:32 UTC (rev 9254)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/operations/AddPortletOperation.java 2008-07-23
22:58:08 UTC (rev 9255)
@@ -13,6 +13,7 @@
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 java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -63,13 +64,16 @@
protected void generateMetaData(IDataModel aModel, String qualifiedClassName) {
// update the portlet.xml file
- updatePortletXml(aModel);
+ updatePortletXml(aModel);
- // generate/update portlet-instances.xml
- updatePortletInstance(aModel);
-
- // generate/update *.object.xml
- updatePortletObject(aModel);
+ boolean addPortlet = model.getBooleanProperty(ADD_PORTLET);
+ if (addPortlet) {
+ // generate/update portlet-instances.xml
+ updatePortletInstance(aModel);
+
+ // generate/update *.object.xml
+ updatePortletObject(aModel);
+ }
}
private void updatePortletObject(IDataModel model) {
@@ -82,12 +86,10 @@
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);
+ IVirtualFile portletVirtualFile = component.getRootFolder().getFile(
+ IPortletConstants.PORTLET_OBJECT_FILE);
if (!portletVirtualFile.getUnderlyingFile().exists()) {
try {
@@ -136,6 +138,7 @@
}
private void updatePortletInstance(IDataModel model) {
+
String name = model.getStringProperty(NAME);
String instanceId = model.getStringProperty(INSTANCE_NAME);
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-07-23
21:47:32 UTC (rev 9254)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/INewPortletClassDataModelProperties.java 2008-07-23
22:58:08 UTC (rev 9255)
@@ -41,4 +41,6 @@
static final String IF_EXISTS = "NewPortletClassDataModel.IF_EXISTS";
+ static final String ADD_PORTLET = "NewPortletClassDataModel.ADD_PORTLET";
+
}
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-07-23
21:47:32 UTC (rev 9254)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/IPortletUIConstants.java 2008-07-23
22:58:08 UTC (rev 9255)
@@ -51,6 +51,7 @@
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 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 PARENT_PORTAL_LABEL = "Parent Reference:";
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-07-23
21:47:32 UTC (rev 9254)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/AddJBossPortletWizardPage.java 2008-07-23
22:58:08 UTC (rev 9255)
@@ -23,6 +23,7 @@
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.ADD_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;
@@ -33,6 +34,7 @@
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.ADD_PORTLET_LABEL;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
@@ -44,6 +46,7 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
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;
@@ -112,11 +115,18 @@
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ final Button addPortlet = new Button(composite,SWT.CHECK);
+ addPortlet.setText(ADD_PORTLET_LABEL);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalSpan = 2;
+ addPortlet.setLayoutData(gd);
+ synchHelper.synchCheckbox(addPortlet, ADD_PORTLET, null);
+
// 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);
+ final 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);
@@ -125,7 +135,7 @@
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);
+ final Text instanceNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
instanceNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(instanceNameText, INSTANCE_NAME, null);
@@ -133,7 +143,7 @@
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);
+ final Text windowNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
windowNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(windowNameText, WINDOW_NAME, null);
@@ -141,7 +151,7 @@
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);
+ final Text parentReferenceText = new Text(composite, SWT.SINGLE | SWT.BORDER);
parentReferenceText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(parentReferenceText, PARENT_PORTAL, null);
@@ -149,7 +159,7 @@
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);
+ final Text regionText = new Text(composite, SWT.SINGLE | SWT.BORDER);
regionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(regionText, PAGE_REGION, null);
@@ -157,10 +167,31 @@
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);
+ final Text heightText = new Text(composite, SWT.SINGLE | SWT.BORDER);
heightText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
synchHelper.synchText(heightText, PORTLET_HEIGHT, null);
+ addPortlet.addSelectionListener(new SelectionListener() {
+
+ 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);
+ windowNameText.setEnabled(enable);
+ parentReferenceText.setEnabled(enable);
+ regionText.setEnabled(enable);
+ heightText.setEnabled(enable);
+ }
+ });
+
}
public boolean canFlipToNextPage() {
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-07-23
21:47:32 UTC (rev 9254)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassDataModelProvider.java 2008-07-23
22:58:08 UTC (rev 9255)
@@ -96,6 +96,7 @@
propertyNames.add(PAGE_REGION);
propertyNames.add(PORTLET_HEIGHT);
propertyNames.add(IF_EXISTS);
+ propertyNames.add(ADD_PORTLET);
return propertyNames;
}
@@ -125,6 +126,9 @@
@Override
public Object getDefaultProperty(String propertyName) {
+ if (propertyName.equals(ADD_PORTLET)) {
+ return Boolean.TRUE;
+ }
if (propertyName.equals(DO_VIEW)) {
return Boolean.TRUE;
}
Modified:
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 2008-07-23
21:47:32 UTC (rev 9254)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.ui/src/org/jboss/tools/portlet/ui/internal/wizard/NewPortletClassOptionsWizardPage.java 2008-07-23
22:58:08 UTC (rev 9255)
@@ -58,10 +58,10 @@
getConfigButton.setEnabled(enable);
doDispatchButton.setEnabled(enable);
doEditButton.setEnabled(enable);
- doViewButton.setEnabled(true);
- doHelpButton.setEnabled(true);
- processActionButton.setEnabled(true);
- renderButton.setEnabled(true);
+ doViewButton.setEnabled(enable);
+ doHelpButton.setEnabled(enable);
+ processActionButton.setEnabled(enable);
+ renderButton.setEnabled(enable);
}
});
@@ -97,10 +97,6 @@
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$