Permalink
Browse files

rhbz870876 allow download of po zip for offline translation for non-p…

…o projects in editor document list
  • Loading branch information...
1 parent d2f359c commit 5d9ac53899582f6607250fc150089dc6baec9483 @davidmason davidmason committed Mar 18, 2013
@@ -131,40 +131,52 @@ protected void onBind()
registerHandler(eventBus.addHandler(UserConfigChangeEvent.TYPE, this));
registerHandler(eventBus.addHandler(WorkspaceContextUpdateEvent.getType(), this));
registerHandler(eventBus.addHandler(RunDocValidationEvent.getType(), this));
-
+
display.updatePageSize(userOptionsService.getConfigHolder().getState().getDocumentListPageSize());
display.setLayout(userOptionsService.getConfigHolder().getState().getDisplayTheme().name());
- ProjectType projectType = userWorkspaceContext.getWorkspaceContext().getWorkspaceId().getProjectIterationId().getProjectType();
- setupDownloadZipButton(projectType);
+ setupDownloadZipButton(getProjectType());
+ }
+
+ private ProjectType getProjectType()
+ {
+ return userWorkspaceContext.getWorkspaceContext().getWorkspaceId().getProjectIterationId().getProjectType();
}
public void setupDownloadZipButton(ProjectType projectType)
{
- if (!isZipFileDownloadAllowed(projectType))
+ if (isZipFileDownloadAllowed(projectType))
{
- display.setEnableDownloadZip(false);
- if (projectType == null)
+ display.setEnableDownloadZip(true);
+ if (isPoProject(projectType))
{
- display.setDownloadZipButtonTitle(messages.projectTypeNotSet());
+ display.setDownloadZipButtonText(messages.downloadAllAsZip());
+ display.setDownloadZipButtonTitle(messages.downloadAllAsZipDescription());
}
else
{
- display.setDownloadZipButtonTitle(messages.projectTypeNotAllowed());
+ display.setDownloadZipButtonText(messages.downloadAllAsOfflinePoZip());
+ display.setDownloadZipButtonTitle(messages.downloadAllAsOfflinePoZipDescription());
}
}
else
{
- display.setEnableDownloadZip(true);
- display.setDownloadZipButtonTitle(messages.downloadAllTranslatedFiles());
+ display.setEnableDownloadZip(false);
+ display.setDownloadZipButtonText(messages.downloadAllAsZip());
+ display.setDownloadZipButtonTitle(messages.projectTypeNotSet());
}
}
- public boolean isZipFileDownloadAllowed(ProjectType projectType)
+ private boolean isPoProject(ProjectType projectType)
{
return projectType == ProjectType.Gettext || projectType == ProjectType.Podir;
}
+ protected boolean isZipFileDownloadAllowed(ProjectType projectType)
+ {
+ return projectType != null;
+ }
+
@Override
public void fireDocumentSelection(DocumentInfo doc)
{
@@ -403,7 +415,7 @@ public void onUserConfigChanged(UserConfigChangeEvent event)
public void downloadAllFiles()
{
WorkspaceId workspaceId = userWorkspaceContext.getWorkspaceContext().getWorkspaceId();
- dispatcher.execute(new DownloadAllFilesAction(workspaceId.getProjectIterationId().getProjectSlug(), workspaceId.getProjectIterationId().getIterationSlug(), workspaceId.getLocaleId().getId()), new AsyncCallback<DownloadAllFilesResult>()
+ dispatcher.execute(new DownloadAllFilesAction(workspaceId.getProjectIterationId().getProjectSlug(), workspaceId.getProjectIterationId().getIterationSlug(), workspaceId.getLocaleId().getId(), !isPoProject(getProjectType())), new AsyncCallback<DownloadAllFilesResult>()
{
@Override
public void onFailure(Throwable caught)
@@ -553,7 +565,7 @@ public void onSuccess(RunDocValidationResult result)
{
Boolean hasError = entry.getValue();
DocumentInfo hasErrorDoc = getDocumentInfo(entry.getKey());
-
+
if (hasError != null && hasErrorDoc != null)
{
hasErrorDoc.setHasValidationError(hasError.booleanValue());
@@ -290,10 +290,10 @@
@DefaultMessage("Editor navigation")
String navigationScope();
-
+
@DefaultMessage("Translation memory")
String tmScope();
-
+
@DefaultMessage("Glossary")
String glossaryScope();
@@ -499,13 +499,20 @@
@DefaultMessage("Only display Translation Unit Details when there is meta data otherwise hide it")
String showTransUnitDetailsTooltip();
-
+
+ @DefaultMessage("Download all files (zip)")
+ String downloadAllAsZip();
+
+ @DefaultMessage("Download all translated files.")
+ String downloadAllAsZipDescription();
+
+ @DefaultMessage("Download all files (offline po zip)")
+ String downloadAllAsOfflinePoZip();
+
+ @DefaultMessage("Download all translated files in po format for offline translation.")
+ String downloadAllAsOfflinePoZipDescription();
+
@DefaultMessage("The project type for this iteration has not been set. Contact the project maintainer.")
String projectTypeNotSet();
-
- @DefaultMessage("The project type must be set to 'Gettext' or 'Podir'. Contact the project maintainer.")
- String projectTypeNotAllowed();
-
- @DefaultMessage("Download all translated files.")
- String downloadAllTranslatedFiles();
+
}
@@ -107,6 +107,8 @@
void stopGetDownloadStatus();
+ void setDownloadZipButtonText(String text);
+
void setDownloadZipButtonTitle(String title);
void setEnableDownloadZip(boolean enabled);
@@ -77,7 +77,7 @@
@UiField
PushButton downloadAllFiles;
-
+
@UiField(provided = true)
DocumentListPager pager;
@@ -91,9 +91,9 @@
private final UserWorkspaceContext userworkspaceContext;
private ListDataProvider<DocumentNode> dataProvider;
-
+
private final LoadingPanel loadingPanel;
-
+
private Timer timer = new Timer()
{
public void run()
@@ -119,8 +119,6 @@ public DocumentListView(Resources resources, WebTransMessages messages, UserWork
initWidget(uiBinder.createAndBindUi(this));
- downloadAllFiles.setText("Download all files (zip)");
-
caseSensitiveCheckBox.setTitle(messages.docListFilterCaseSensitiveDescription());
exactSearchCheckBox.setTitle(messages.docListFilterExactMatchDescription());
statsByMsg.setText(messages.byMessage());
@@ -193,7 +191,7 @@ public void onDownloadAllFilesClick(ClickEvent event)
{
confirmationBox.center();
}
-
+
@Override
public void setStatsFilter(String option)
{
@@ -357,18 +355,18 @@ public void submitUploadForm()
{
fileUploadDialog.submitForm();
}
-
+
@Override
public void startGetDownloadStatus(int periodMillis)
{
timer.scheduleRepeating(periodMillis);
}
-
+
public void getDownloadStatus()
{
listener.updateDownloadFileProgress();
}
-
+
@Override
public void stopGetDownloadStatus()
{
@@ -383,6 +381,12 @@ public void setEnableDownloadZip(boolean enabled)
}
@Override
+ public void setDownloadZipButtonText(String text)
+ {
+ downloadAllFiles.setText(text);
+ }
+
+ @Override
public void setDownloadZipButtonTitle(String title)
{
downloadAllFiles.setTitle(title);
@@ -14,19 +14,19 @@
.mainPanel {
background-color: #ffffff;
}
-
+
.optionStyle
{
font-size:13px;
color:#595959;
}
-
+
.statsOption
{
display:inline-block;
text-align:left;
}
-
+
.topBar
{
border-bottom:1px solid lightGrey;
@@ -36,20 +36,21 @@
padding-left:10px;
padding-right:10px;
}
-
+
.listContainer
{
padding:10px;
}
-
+
.downloadAllFilesButton
{
- width:135px;
+ width:200px;
display:inline-block;
+ text-align: center;
margin-left:3px;
}
-
</ui:style>
+
<g:LayoutPanel>
<g:layer top="0px" bottom="0px">
<g:LayoutPanel styleName="{style.mainPanel}">
@@ -86,5 +87,4 @@
</g:layer>
</g:LayoutPanel>
-
</ui:UiBinder>
@@ -79,6 +79,7 @@ public DownloadAllFilesResult execute(DownloadAllFilesAction action, ExecutionCo
processHandle.setIterationSlug(action.getVersionSlug());
processHandle.setLocaleId(action.getLocaleId());
processHandle.setInitiatingUserName(Identity.instance().getCredentials().getUsername());
+ processHandle.setOfflinePo(action.isOfflinePo());
// Fire the zip file building process and wait until it is ready to
// return
@@ -30,16 +30,20 @@
private static final long serialVersionUID = 1L;
private String projectSlug, versionSlug, localeId;
+
+ private boolean offlinePo;
+
@SuppressWarnings("unused")
private DownloadAllFilesAction()
{
}
- public DownloadAllFilesAction(String projectSlug, String versionSlug, String localeId)
+ public DownloadAllFilesAction(String projectSlug, String versionSlug, String localeId, boolean offlinePo)
{
this.projectSlug = projectSlug;
this.versionSlug = versionSlug;
this.localeId = localeId;
+ this.offlinePo = offlinePo;
}
public String getProjectSlug()
@@ -57,4 +61,9 @@ public String getLocaleId()
return localeId;
}
+ public boolean isOfflinePo()
+ {
+ return offlinePo;
+ }
+
}
@@ -125,8 +125,7 @@ public void beforeMethod()
when(mockWorkspaceContext.getWorkspaceId()).thenReturn(workspaceId);
when(mockMessages.projectTypeNotSet()).thenReturn("Project not set");
- when(mockMessages.projectTypeNotAllowed()).thenReturn("Project type not allow");
- when(mockMessages.downloadAllTranslatedFiles()).thenReturn("Download all translation file");
+ when(mockMessages.downloadAllAsZipDescription()).thenReturn("Download all translation file");
}
@Test
@@ -454,7 +453,7 @@ public void getDocumentId()
documentListPresenter.bind();
documentListPresenter.setDocuments(buildSampleDocumentArray());
-
+
verify(mockDataProvider).refresh();
// third document from buildSampleDocumentArray()
@@ -471,7 +470,7 @@ public void getDocumentInfo()
{
when(mockDisplay.getDataProvider()).thenReturn(mockDataProvider);
when(mockDataProvider.getList()).thenReturn(dataProviderList);
-
+
documentListPresenter.bind();
documentListPresenter.setDocuments(buildSampleDocumentArray());
@@ -513,7 +512,7 @@ public void onWorkspaceContextUpdated()
{
WorkspaceContextUpdateEvent event = new WorkspaceContextUpdateEvent(workplaceContextData(true, ProjectType.Gettext));
documentListPresenter.onWorkspaceContextUpdated(event);
-
+
verify(mockDisplay).setEnableDownloadZip(documentListPresenter.isZipFileDownloadAllowed(event.getProjectType()));
verify(mockDisplay).setDownloadZipButtonTitle(isA(String.class));
}

0 comments on commit 5d9ac53

Please sign in to comment.