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

Commit

Permalink
add title and document parameters to query string
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Dec 6, 2011
1 parent 456b012 commit cb89cf6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
Expand Up @@ -99,7 +99,7 @@ enum StatsType

void setUserLabel(String userLabel);

void setWorkspaceNameLabel(String workspaceNameLabel);
void setWorkspaceNameLabel(String workspaceNameLabel, String workspaceTitle);

void setSelectedDocument(DocumentInfo document);

Expand Down Expand Up @@ -143,6 +143,8 @@ enum StatsType
private final TranslationStats selectedDocumentStats = new TranslationStats();
private final TranslationStats projectStats = new TranslationStats();

private static final String WORKSPACE_TITLE_QUERY_PARAMETER_KEY = "title";

@Inject
public AppPresenter(Display display, EventBus eventBus, CachingDispatchAsync dispatcher, final TranslationPresenter translationPresenter, final DocumentListPresenter documentListPresenter, final Identity identity, final WorkspaceContext workspaceContext, final WebTransMessages messages)
{
Expand Down Expand Up @@ -253,7 +255,9 @@ public void onClick(ClickEvent event)

display.setUserLabel(identity.getPerson().getName());

display.setWorkspaceNameLabel(workspaceContext.getWorkspaceName());
String workspaceTitle = Window.Location.getParameter(WORKSPACE_TITLE_QUERY_PARAMETER_KEY);

display.setWorkspaceNameLabel(workspaceContext.getWorkspaceName(), workspaceTitle);

Window.setTitle(messages.windowTitle(workspaceContext.getWorkspaceName(), workspaceContext.getLocaleName()));

Expand Down
Expand Up @@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import net.customware.gwt.dispatch.client.DispatchAsync;
import net.customware.gwt.presenter.client.EventBus;
Expand Down Expand Up @@ -58,6 +59,7 @@
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.view.client.HasData;
Expand Down Expand Up @@ -97,6 +99,8 @@ public interface Display extends WidgetDisplay
// used to determine whether to re-run filter
private HistoryToken currentHistoryState = null;

private static final String PRE_FILTER_QUERY_PARAMETER_KEY = "doc";

@Inject
public DocumentListPresenter(Display display, EventBus eventBus, WorkspaceContext workspaceContext, CachingDispatchAsync dispatcher, final WebTransMessages messages)
{
Expand Down Expand Up @@ -369,9 +373,16 @@ public void fireEvent(GwtEvent<?> event)

private void loadDocumentList()
{
// generate filter from query string if present
ArrayList<String> filterDocs = null;
List<String> queryDocs = Window.Location.getParameterMap().get(PRE_FILTER_QUERY_PARAMETER_KEY);
if (queryDocs != null && !queryDocs.isEmpty())
{
filterDocs = new ArrayList<String>(queryDocs);
}

// switch doc list to the new project
// TODO this is the place to add document pre-filter parameters
dispatcher.execute(new GetDocumentList(workspaceContext.getWorkspaceId().getProjectIterationId()), new AsyncCallback<GetDocumentListResult>()
dispatcher.execute(new GetDocumentList(workspaceContext.getWorkspaceId().getProjectIterationId(), filterDocs), new AsyncCallback<GetDocumentListResult>()
{
@Override
public void onFailure(Throwable caught)
Expand Down
Expand Up @@ -195,9 +195,12 @@ public void setUserLabel(String userLabel)
}

@Override
public void setWorkspaceNameLabel(String workspaceNameLabel)
public void setWorkspaceNameLabel(String workspaceNameLabel, String workspaceTitle)
{
documentsLink.setText(workspaceNameLabel);
if (workspaceTitle == null || workspaceTitle.length() == 0)
documentsLink.setText(workspaceNameLabel);
else
documentsLink.setText(workspaceNameLabel + " - " + workspaceTitle);
}

@Override
Expand Down

0 comments on commit cb89cf6

Please sign in to comment.