use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.
the class DocumentDetailsDialog method nextItem.
/**
* Navigates to next item in the list of content for the current Space
*/
public void nextItem(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id != null && id.length() != 0) {
List<Node> nodes = this.browseBean.getContent();
if (nodes.size() > 1) {
String currentSortColumn = this.browseBean.getContentRichList().getCurrentSortColumn();
if (currentSortColumn != null) {
boolean currentSortDescending = this.browseBean.getContentRichList().isCurrentSortDescending();
Collections.sort(nodes, new NodePropertyComparator(currentSortColumn, !currentSortDescending));
}
Node next = NodeListUtils.nextItem(nodes, id);
getRecentNodeRefsStack().clear();
this.browseBean.setupContentAction(next.getId(), false);
}
}
}
use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.
the class DocumentDetailsDialog method previousItem.
/**
* Navigates to the previous item in the list of content for the current Space
*/
public void previousItem(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id != null && id.length() != 0) {
List<Node> nodes = this.browseBean.getContent();
if (nodes.size() > 1) {
String currentSortColumn = this.browseBean.getContentRichList().getCurrentSortColumn();
if (currentSortColumn != null) {
boolean currentSortDescending = this.browseBean.getContentRichList().isCurrentSortDescending();
Collections.sort(nodes, new NodePropertyComparator(currentSortColumn, !currentSortDescending));
}
Node previous = NodeListUtils.previousItem(nodes, id);
getRecentNodeRefsStack().clear();
this.browseBean.setupContentAction(previous.getId(), false);
}
}
}
use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.
the class BaseDetailsBean method approve.
/**
* Event handler called to handle the approve step of the simple workflow
*
* @param event The event that was triggered
*/
public void approve(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
if (id == null || id.length() == 0) {
throw new AlfrescoRuntimeException("approve called without an id");
}
final NodeRef docNodeRef = new NodeRef(Repository.getStoreRef(), id);
try {
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>() {
public Object execute() throws Throwable {
// call the service to perform the approve
WorkflowUtil.approve(docNodeRef, getNodeService(), getCopyService());
return null;
}
};
txnHelper.doInTransaction(callback);
// if this was called via the node details dialog we need to reset the node
if (getNode() != null) {
getNode().reset();
}
// also make sure the UI will get refreshed
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
} catch (Throwable e) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_WORKFLOW_APPROVE), e.getMessage()), e);
ReportedException.throwIfNecessary(e);
}
}
use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.
the class BrowseBean method deleteFile.
/**
* Event handler used when a file is being deleted, checks that the node
* does not have an associated working copy.
*
* @param event The event
*/
public void deleteFile(ActionEvent event) {
setupContentAction(event);
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String ref = params.get("ref");
if (ref != null && ref.length() > 0) {
NodeRef nodeRef = new NodeRef(ref);
NodeRef workingCopyNodeRef = getCheckOutCheckInService().getWorkingCopy(nodeRef);
if (workingCopyNodeRef != null) {
// if node has a working copy setup error message and return
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), MSG_CANNOT_DELETE_NODE_HAS_WORKING_COPY), new Object[] { getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME) }));
return;
}
// if there isn't a working copy go to normal delete dialog
boolean hasMultipleParents = false;
boolean showDeleteAssocDialog = false;
// get type of node being deleted
Node node = this.getDocument();
QName type = node.getType();
TypeDefinition typeDef = this.dictionaryService.getType(type);
// determine if the node being delete has multiple parents
if (!type.equals(ContentModel.TYPE_MULTILINGUAL_CONTAINER) && !node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION) && !node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_DOCUMENT) && !type.equals(ContentModel.TYPE_LINK) && !this.dictionaryService.isSubClass(typeDef.getName(), ContentModel.TYPE_LINK)) {
List<ChildAssociationRef> parents = this.nodeService.getParentAssocs(node.getNodeRef(), ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
if (parents != null && parents.size() > 1) {
hasMultipleParents = true;
}
}
// determine which delete dialog to display
if (this.navigator.getSearchContext() == null && hasMultipleParents) {
// if we are not in a search and the node has multiple parents
// see if the current node has the primary parent association
NodeRef parentSpace = this.navigator.getCurrentNode().getNodeRef();
ChildAssociationRef assoc = this.nodeService.getPrimaryParent(node.getNodeRef());
// show delete assoc dialog if the current space is not the primary parent for the node
showDeleteAssocDialog = !parentSpace.equals(assoc.getParentRef());
}
// show the appropriate dialog
FacesContext fc = FacesContext.getCurrentInstance();
if (showDeleteAssocDialog) {
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteFileAssoc");
} else {
final Map<String, String> dialogParams = new HashMap<String, String>(1);
dialogParams.put("hasMultipleParents", Boolean.toString(hasMultipleParents));
Application.getDialogManager().setupParameters(dialogParams);
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:deleteFile");
}
}
}
use of org.alfresco.web.ui.common.component.UIActionLink in project acs-community-packaging by Alfresco.
the class BrowseBean method setupSpaceAction.
/**
* Action event called by all Browse actions that need to setup a Space context
* before an action page/wizard is called. The context will be a Node in setActionSpace() which
* can be retrieved on the action page from BrowseBean.getActionSpace().
*
* @param event ActionEvent
*/
public void setupSpaceAction(ActionEvent event) {
UIActionLink link = (UIActionLink) event.getComponent();
Map<String, String> params = link.getParameterMap();
String id = params.get("id");
setupSpaceAction(id, true);
}
Aggregations