refactoring

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8194 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Logneon
2008-02-05 14:52:28 +00:00
parent 4b2c2ef988
commit 589fa4023c
2 changed files with 47 additions and 63 deletions

View File

@@ -1,25 +1,40 @@
package org.alfresco.web.bean.coci; /*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
import java.io.Serializable; * This program is distributed in the hope that it will be useful,
import java.util.Map; * but WITHOUT ANY WARRANTY; without even the implied warranty of
import java.util.StringTokenizer; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.web.bean.coci;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
public class UploadNewVersionDialog extends CheckinCheckoutDialog public class UploadNewVersionDialog extends CCDoneEditingDialog
{ {
private final static String MSG_DONE = "done";
private final static String MSG_UPLOAD_NEW_VERSION = "upload_new_version"; private final static String MSG_UPLOAD_NEW_VERSION = "upload_new_version";
private final static String MSG_OF = "of"; private final static String MSG_OF = "of";
private boolean finishedEditing; private boolean finishedEditing = false;
public void setFinishedEditing(boolean finished) public void setFinishedEditing(boolean finished)
{ {
@@ -31,55 +46,12 @@ public class UploadNewVersionDialog extends CheckinCheckoutDialog
return finishedEditing; return finishedEditing;
} }
/**
* @return Returns label for new version with major changes
*/
public String getMajorNewVersionLabel()
{
String label = getCurrentVersionLabel();
StringTokenizer st = new StringTokenizer(label, ".");
return (Integer.valueOf(st.nextToken()) + 1) + ".0";
}
/**
* @return Returns label for new version with minor changes
*/
public String getMinorNewVersionLabel()
{
String label = getCurrentVersionLabel();
StringTokenizer st = new StringTokenizer(label, ".");
return st.nextToken() + "." + (Integer.valueOf(st.nextToken()) + 1);
}
/**
* @return version label for source node for working copy.
*/
private String getCurrentVersionLabel()
{
NodeRef workingCopyNodeRef = property.getDocument().getNodeRef();
if (this.nodeService.hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
{
Map<QName, Serializable> workingCopyProperties = nodeService.getProperties(workingCopyNodeRef);
NodeRef nodeRef = (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE);
Version curVersion = property.getVersionQueryService().getCurrentVersion(nodeRef);
return curVersion.getVersionLabel();
}
return null;
}
@Override @Override
public boolean getFinishButtonDisabled() public boolean getFinishButtonDisabled()
{ {
return property.getFile() == null; return property.getFile() == null;
} }
@Override
public String getFinishButtonLabel()
{
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_DONE);
}
@Override @Override
public String getContainerTitle() public String getContainerTitle()
@@ -94,5 +66,12 @@ public class UploadNewVersionDialog extends CheckinCheckoutDialog
property.setKeepCheckedOut(!finishedEditing); property.setKeepCheckedOut(!finishedEditing);
return checkinFileOK(context, outcome); return checkinFileOK(context, outcome);
} }
@Override
public void resetState()
{
super.resetState();
finishedEditing = false;
}
} }

View File

@@ -77,10 +77,6 @@ if (fileUploaded)
<h:column id="upload_empty" rendered="#{empty DialogManager.bean.fileName}"> <h:column id="upload_empty" rendered="#{empty DialogManager.bean.fileName}">
<r:upload id="uploader" value="#{DialogManager.bean.fileName}" framework="dialog"/> <r:upload id="uploader" value="#{DialogManager.bean.fileName}" framework="dialog"/>
</h:column> </h:column>
<h:column id="upload_not_empty" rendered="#{!empty DialogManager.bean.fileName}">
<h:outputText id="upload_name" value="#{DialogManager.bean.fileName}" style="padding-right:8px"/>
<a:actionLink id="upload_remove" image="/images/icons/delete.gif" value="#{msg.remove}" action="#{DialogManager.bean.removeUploadedFile}" showLink="false"/>
</h:column>
</h:panelGrid> </h:panelGrid>
<f:verbatim> <f:verbatim>
</td> </td>
@@ -91,7 +87,11 @@ if (fileUploaded)
<tr> <tr>
<td> <td>
</f:verbatim> </f:verbatim>
<a:booleanEvaluator value="#{DialogManager.bean.versionable && !empty DialogManager.bean.fileName}" > <%
if (fileUploaded)
{
%>
<a:booleanEvaluator value="#{DialogManager.bean.versionable}" >
<f:verbatim> <f:verbatim>
<table cellpadding="2" cellspacing="2" border="0" width="100%"> <table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr> <tr>
@@ -106,11 +106,12 @@ if (fileUploaded)
</tr> </tr>
<tr> <tr>
<td> </f:verbatim> <td> </f:verbatim>
<h:selectOneRadio id="vvvv" value="#{CCProperties.minorChange}" required="true" layout="pageDirection" rendered="#{DialogManager.bean.versionable && !empty DialogManager.bean.fileName}"> <h:selectOneRadio id="vvvv" value="#{CCProperties.minorChange}" required="true" layout="pageDirection" rendered="#{DialogManager.bean.versionable}">
<f:selectItem itemValue="#{true}" itemLabel="#{msg.minor_changes} (#{DialogManager.bean.minorNewVersionLabel})" /> <f:selectItem itemValue="#{true}" itemLabel="#{msg.minor_changes} (#{DialogManager.bean.minorNewVersionLabel})" />
<f:selectItem itemValue="#{false}" itemLabel="#{msg.major_changes} (#{DialogManager.bean.majorNewVersionLabel})" /> <f:selectItem itemValue="#{false}" itemLabel="#{msg.major_changes} (#{DialogManager.bean.majorNewVersionLabel})" />
</h:selectOneRadio> </h:selectOneRadio>
<h:message for="vvvv"></h:message> <h:message for="vvvv"></h:message>
<f:verbatim> <f:verbatim>
</span> <br/> </span> <br/>
</td> </td>
@@ -130,13 +131,14 @@ if (fileUploaded)
</tr> </tr>
</table> </f:verbatim> </table> </f:verbatim>
</a:booleanEvaluator> </a:booleanEvaluator>
<f:verbatim> <f:verbatim>
</td> </td>
</tr> </tr>
</f:verbatim> </f:verbatim>
<a:booleanEvaluator value="#{!empty DialogManager.bean.fileName}">
<f:verbatim> <f:verbatim>
<tr> <tr>
<td class="wizardSectionHeading"></f:verbatim><h:outputText value="#{msg.other_options}" /><f:verbatim></td> <td class="wizardSectionHeading"></f:verbatim><h:outputText value="#{msg.other_options}" /><f:verbatim></td>
@@ -149,7 +151,10 @@ if (fileUploaded)
</td> </td>
</tr> </tr>
</f:verbatim> </f:verbatim>
</a:booleanEvaluator>
<%
}
%>
<f:verbatim> <f:verbatim>
</table> </table>
</f:verbatim> </f:verbatim>