Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz870876 allow download of po zip for offline translation for non-p…
Browse files Browse the repository at this point in the history
…o projects in editor document list
  • Loading branch information
davidmason committed Mar 18, 2013
1 parent d2f359c commit 5d9ac53
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ public interface WebTransMessages extends Messages

@DefaultMessage("Editor navigation")
String navigationScope();

@DefaultMessage("Translation memory")
String tmScope();

@DefaultMessage("Glossary")
String glossaryScope();

Expand Down Expand Up @@ -499,13 +499,20 @@ public interface WebTransMessages extends Messages

@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();

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ interface Listener

void stopGetDownloadStatus();

void setDownloadZipButtonText(String text);

void setDownloadZipButtonTitle(String title);

void setEnableDownloadZip(boolean enabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class DocumentListView extends Composite implements DocumentListDisplay

@UiField
PushButton downloadAllFiles;

@UiField(provided = true)
DocumentListPager pager;

Expand All @@ -91,9 +91,9 @@ public class DocumentListView extends Composite implements DocumentListDisplay
private final UserWorkspaceContext userworkspaceContext;

private ListDataProvider<DocumentNode> dataProvider;

private final LoadingPanel loadingPanel;

private Timer timer = new Timer()
{
public void run()
Expand All @@ -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());
Expand Down Expand Up @@ -193,7 +191,7 @@ public void onDownloadAllFilesClick(ClickEvent event)
{
confirmationBox.center();
}

@Override
public void setStatsFilter(String option)
{
Expand Down Expand Up @@ -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()
{
Expand All @@ -382,6 +380,12 @@ public void setEnableDownloadZip(boolean enabled)

}

@Override
public void setDownloadZipButtonText(String text)
{
downloadAllFiles.setText(text);
}

@Override
public void setDownloadZipButtonTitle(String title)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}">
Expand Down Expand Up @@ -86,5 +87,4 @@
</g:layer>
</g:LayoutPanel>


</ui:UiBinder>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ public class DownloadAllFilesAction implements DispatchAction<DownloadAllFilesRe
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()
Expand All @@ -57,4 +61,9 @@ public String getLocaleId()
return localeId;
}

public boolean isOfflinePo()
{
return offlinePo;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -454,7 +453,7 @@ public void getDocumentId()

documentListPresenter.bind();
documentListPresenter.setDocuments(buildSampleDocumentArray());

verify(mockDataProvider).refresh();

// third document from buildSampleDocumentArray()
Expand All @@ -471,7 +470,7 @@ public void getDocumentInfo()
{
when(mockDisplay.getDataProvider()).thenReturn(mockDataProvider);
when(mockDataProvider.getList()).thenReturn(dataProviderList);

documentListPresenter.bind();
documentListPresenter.setDocuments(buildSampleDocumentArray());

Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 5d9ac53

Please sign in to comment.