. Fix to issue with Create Web Content form initialised with the correct form template in the drop-down

. UI action and dialog framework for Snapshot Sandbox action

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4395 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-11-20 15:00:35 +00:00
parent 19facbdd97
commit 97cb403335
12 changed files with 148 additions and 24 deletions

View File

@@ -880,8 +880,7 @@ public class AVMBrowseBean implements IContextListener
if (node != null)
{
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
List<Pair<Integer, String>> versionPaths =
new ArrayList<Pair<Integer, String>>();
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
versionPaths.add(new Pair<Integer, String>(-1, path));
args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths);
Action action = this.actionService.createAction(AVMUndoSandboxListAction.NAME, args);
@@ -926,8 +925,7 @@ public class AVMBrowseBean implements IContextListener
// calcluate the list of differences between the user store and the staging area
List<AVMDifference> diffs = this.avmSyncService.compare(-1, store + ":/", -1, getStagingStore() + ":/");
List<Pair<Integer, String>> versionPaths =
new ArrayList<Pair<Integer, String>>();
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
for (AVMDifference diff : diffs)
{
versionPaths.add(new Pair<Integer, String>(-1, diff.getSourcePath()));
@@ -974,8 +972,7 @@ public class AVMBrowseBean implements IContextListener
tx = Repository.getUserTransaction(context, false);
tx.begin();
List<Pair<Integer, String>> versionPaths =
new ArrayList<Pair<Integer, String>>();
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
for (AVMNodeDescriptor node : selected)
{
versionPaths.add(new Pair<Integer, String>(-1, node.getPath()));
@@ -1016,7 +1013,7 @@ public class AVMBrowseBean implements IContextListener
{
UIActionLink link = (UIActionLink)event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("form-id");
String id = params.get(UIUserSandboxes.PARAM_FORM_ID);
// pass form ID to the wizard - to be picked up in init()
FacesContext fc = FacesContext.getCurrentInstance();

View File

@@ -22,7 +22,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -36,18 +35,26 @@ import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.BaseContentWizard;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.data.QuickSort;
import org.alfresco.web.forms.*;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.FormInstanceData;
import org.alfresco.web.forms.FormInstanceDataImpl;
import org.alfresco.web.forms.FormProcessor;
import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition;
import org.alfresco.web.ui.wcm.component.UIUserSandboxes;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
@@ -104,11 +111,13 @@ public class CreateWebContentWizard extends BaseContentWizard
this.mimeType = MimetypeMap.MIMETYPE_XML;
// check for a form ID being passed in as a parameter
if (this.parameters.get("form-id") != null)
if (this.parameters.get(UIUserSandboxes.PARAM_FORM_ID) != null)
{
// it is used to init the dialog to a specific template
String formId = parameters.get("form-id");
Form form = FormsService.getInstance().getForm(new NodeRef(Repository.getStoreRef(), formId));
String webFormId = parameters.get(UIUserSandboxes.PARAM_FORM_ID);
NodeRef webFormRef = new NodeRef(Repository.getStoreRef(), webFormId);
String formName = (String)this.nodeService.getProperty(webFormRef, ContentModel.PROP_FORMNAME);
Form form = FormsService.getInstance().getForm(formName);
if (form != null)
{
this.formName = form.getName();
@@ -226,20 +235,32 @@ public class CreateWebContentWizard extends BaseContentWizard
}
/**
* @return the available forms that can be created.
* @return the available forms from this web project that can be created.
*/
public List<SelectItem> getFormChoices()
{
final Collection<Form> ttl = FormsService.getInstance().getForms();
final List<SelectItem> sil = new ArrayList<SelectItem>(ttl.size());
for (Form tt : ttl)
Node website = this.avmBrowseBean.getWebsite();
if (website == null)
{
sil.add(new SelectItem(tt.getName(), tt.getName()));
throw new IllegalStateException("CreateWebContentWizard must be called within a Web Project context!");
}
List<ChildAssociationRef> webFormRefs = this.nodeService.getChildAssocs(
website.getNodeRef(), ContentModel.ASSOC_WEBFORM, RegexQNamePattern.MATCH_ALL);
List<SelectItem> items = new ArrayList<SelectItem>(webFormRefs.size());
for (ChildAssociationRef ref : webFormRefs)
{
String formName = (String)this.nodeService.getProperty(ref.getChildRef(), ContentModel.PROP_FORMNAME);
Form form = FormsService.getInstance().getForm(formName);
if (form != null)
{
items.add(new SelectItem(formName, formName));
}
}
final QuickSort sorter = new QuickSort(sil, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
final QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return sil;
return items;
}
/**

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Kevin Roast
*/
public class SnapshotSandboxDialog extends BaseDialogBean
{
private static final Log logger = LogFactory.getLog(SnapshotSandboxDialog.class);
protected AVMService avmService;
protected AVMBrowseBean avmBrowseBean;
/**
* @param avmBrowseBean The avmBrowseBean to set.
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param avmService The avmService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
*/
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
return null;
}
}

View File

@@ -107,6 +107,8 @@ public class UIUserSandboxes extends SelfRenderingComponent
private static final String SPACE_ICON = "/images/icons/" + BrowseBean.SPACE_SMALL_DEFAULT + ".gif";
public static final String PARAM_FORM_ID = "form-id";
/** website to show sandboxes for */
private NodeRef value;
@@ -690,7 +692,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
// create content action passes the ID of the Form to uses
Map<String, String> params = new HashMap<String, String>(1, 1.0f);
// setup a data-binding param for the Form ID
params.put("form-id", "#{" + REQUEST_FORM_REF + ".id}");
params.put(PARAM_FORM_ID, "#{" + REQUEST_FORM_REF + ".id}");
action = createAction(fc, userStorePrefix, username, ACT_CREATE_FORM_CONTENT,
"/images/icons/new_content.gif", "#{AVMBrowseBean.createFormContent}", null, null, params);
}