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

Commit

Permalink
Merge branch 'master' of github.com:zanata/zanata
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Munoz committed Dec 5, 2011
2 parents ffc0931 + 37c811d commit 7fe1bfc
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 164 deletions.
Expand Up @@ -164,7 +164,7 @@ public static LocaleId getLocaleId()

public static void redirectToLogin()
{
redirectToUrl(getModuleParentBaseUrl() + "account/sign_in?continue=" + URL.encodeComponent(Window.Location.getHref()));
redirectToUrl(getModuleParentBaseUrl() + "account/sign_in?continue=" + URL.encodeQueryString(Window.Location.getHref()));
}

public static void redirectToLogout()
Expand Down
Expand Up @@ -45,12 +45,9 @@ interface TransFilterViewUiBinder extends UiBinder<Widget, TransFilterView>
@UiField(provided = true)
ClearableTextBox filterTextBox;

private final TransFilterMessages messages;

@Inject
public TransFilterView(final Resources resources, final TransFilterMessages messages, final UiMessages uiMessages)
{
this.messages = messages;
this.filterTextBox = new ClearableTextBox(resources, uiMessages);
filterTextBox.setEmptyText(messages.findSourceOrTargetString());
initWidget(uiBinder.createAndBindUi(this));
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.zanata.webtrans.client.events.NavTransUnitEvent.NavigationType;
import org.zanata.webtrans.client.resources.NavigationMessages;
import org.zanata.webtrans.client.ui.UserConfigConstants;

import org.zanata.webtrans.shared.model.TransUnit;

import com.allen_sauer.gwt.log.client.Log;
Expand All @@ -49,7 +48,6 @@
import com.google.gwt.gen2.table.client.CellEditor;
import com.google.gwt.gen2.table.override.client.HTMLTable;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
Expand Down
Expand Up @@ -45,12 +45,9 @@ public class SourcePanel extends Composite implements HasValue<TransUnit>, HasCl
private final Label sourceLabel;
private TransUnit value;

private final NavigationMessages messages;

public SourcePanel(TransUnit value, NavigationMessages messages)
{
this.value = value;
this.messages = messages;
panel = new HorizontalPanel();
panel.setSize("100%", "100%");

Expand Down
Expand Up @@ -43,17 +43,20 @@ public static HistoryToken fromTokenString(String token)

String[] pair;

try
if (!token.isEmpty() && token != null)
{
for (String pairString : token.split(PAIR_SEPARATOR))
try
{
pair = pairString.split(KEY_VALUE_SEPARATOR);
historyToken.members.put(pair[0], pair[1]);
for (String pairString : token.split(PAIR_SEPARATOR))
{
pair = pairString.split(KEY_VALUE_SEPARATOR);
historyToken.members.put(pair[0], pair[1]);
}
}
catch (IllegalArgumentException e)
{
throw new IllegalArgumentException("token must be a list of key-value pairs in the form key1:value1,key2:value2,...", e);
}
}
catch (IllegalArgumentException e)
{
throw new IllegalArgumentException("token must be a list of key-value pairs in the form key1:value1,key2:value2,...", e);
}

return historyToken;
Expand Down
Expand Up @@ -183,7 +183,7 @@ public void onNotification(NotificationEvent event)
@Override
public void onDocumentSelected(DocumentSelectionEvent event)
{
DocumentInfo docInfo = documentListPresenter.getDisplay().getDocumentInfo(event.getDocumentId());
DocumentInfo docInfo = documentListPresenter.getDocumentInfo(event.getDocumentId());

if (docInfo != null && (selectedDocument == null || !event.getDocumentId().equals(selectedDocument.getId())))
{
Expand Down
Expand Up @@ -21,6 +21,7 @@
package org.zanata.webtrans.client.presenter;

import java.util.ArrayList;
import java.util.HashMap;

import net.customware.gwt.dispatch.client.DispatchAsync;
import net.customware.gwt.presenter.client.EventBus;
Expand All @@ -40,6 +41,7 @@
import org.zanata.webtrans.client.presenter.AppPresenter.Display.MainView;
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.rpc.CachingDispatchAsync;
import org.zanata.webtrans.client.ui.DocumentNode;
import org.zanata.webtrans.shared.model.DocumentId;
import org.zanata.webtrans.shared.model.DocumentInfo;
import org.zanata.webtrans.shared.model.WorkspaceContext;
Expand All @@ -57,44 +59,47 @@
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.view.client.HasData;
import com.google.gwt.view.client.ListDataProvider;
import com.google.inject.Inject;

public class DocumentListPresenter extends WidgetPresenter<DocumentListPresenter.Display> implements HasDocumentSelectionHandlers
{

public interface Display extends WidgetDisplay
{
void setList(ArrayList<DocumentInfo> sortedList);

void clearSelection();

void setSelection(DocumentId documentId);

void setFilter(ContentFilter<DocumentInfo> filter);

void removeFilter();
void setPageSize(int pageSize);

HasValue<String> getFilterTextBox();

HasSelectionHandlers<DocumentInfo> getDocumentList();

TransUnitUpdatedEventHandler getDocumentNode(DocumentId docId);
HasData<DocumentNode> getDocumentListTable();

DocumentInfo getDocumentInfo(DocumentId docId);
ListDataProvider<DocumentNode> getDataProvider();
}

private final DispatchAsync dispatcher;
private final WorkspaceContext workspaceContext;
private DocumentInfo currentDocument;
private DocumentNode currentSelection;
private final WebTransMessages messages;

private ListDataProvider<DocumentNode> dataProvider;
private HashMap<DocumentId, DocumentNode> nodes;
private ContentFilter<DocumentInfo> filter;

@Inject
public DocumentListPresenter(Display display, EventBus eventBus, WorkspaceContext workspaceContext, CachingDispatchAsync dispatcher, final WebTransMessages messages)
{
super(display, eventBus);
this.workspaceContext = workspaceContext;
this.dispatcher = dispatcher;
this.messages = messages;

dataProvider = display.getDataProvider();
nodes = new HashMap<DocumentId, DocumentNode>();

Log.info("DocumentListPresenter()");
}

Expand Down Expand Up @@ -148,7 +153,7 @@ public void onDocumentSelected(DocumentSelectionEvent event)
// from history
if (event.getDocumentId() != (currentDocument == null ? null : currentDocument.getId()))
{
display.setSelection(event.getDocumentId());
setSelection(event.getDocumentId());
}
}
}));
Expand All @@ -161,12 +166,12 @@ public void onValueChange(ValueChangeEvent<String> event)
{
if (event.getValue().isEmpty())
{
display.removeFilter();
removeFilter();
}
else
{
basicContentFilter.setPattern(event.getValue());
display.setFilter(basicContentFilter);
setFilter(basicContentFilter);
}
}
}));
Expand All @@ -177,7 +182,7 @@ public void onValueChange(ValueChangeEvent<String> event)
public void onTransUnitUpdated(TransUnitUpdatedEvent event)
{
DocumentId docId = event.getDocumentId();
TransUnitUpdatedEventHandler handler = display.getDocumentNode(docId);
TransUnitUpdatedEventHandler handler = nodes.get(docId);
if (handler != null)
handler.onTransUnitUpdated(event);
}
Expand Down Expand Up @@ -244,7 +249,7 @@ public void onSuccess(GetDocumentListResult result)
long start = System.currentTimeMillis();
final ArrayList<DocumentInfo> documents = result.getDocuments();
Log.info("Received doc list for " + result.getProjectIterationId() + ": " + documents.size() + " elements");
display.setList(documents);
setList(documents);
Log.info("Time to load docs into DocListView: " + String.valueOf(System.currentTimeMillis() - start) + "ms");
start = System.currentTimeMillis();

Expand All @@ -264,4 +269,86 @@ public void onSuccess(GetDocumentListResult result)
});
}

private void setList(ArrayList<DocumentInfo> sortedList)
{
dataProvider.getList().clear();
nodes = new HashMap<DocumentId, DocumentNode>(sortedList.size());
int counter = 0;
long start = System.currentTimeMillis();
for (DocumentInfo doc : sortedList)
{
Log.info("Loading document: " + ++counter + " ");
DocumentNode node = new DocumentNode(messages, doc, eventBus, dataProvider);
if (filter != null)
{
node.setVisible(filter.accept(doc));
}
if (node.isVisible())
{
dataProvider.getList().add(node);
}
nodes.put(doc.getId(), node);
}
Log.info("Time to create DocumentNodes: " + String.valueOf(System.currentTimeMillis() - start) + "ms");
display.setPageSize(dataProvider.getList().size());
dataProvider.addDataDisplay(display.getDocumentListTable());
}

private void setFilter(ContentFilter<DocumentInfo> filter)
{
this.filter = filter;
dataProvider.getList().clear();
for (DocumentNode docNode : nodes.values())
{
docNode.setVisible(filter.accept(docNode.getDocInfo()));
if (docNode.isVisible())
{
dataProvider.getList().add(docNode);
}
}
dataProvider.refresh();
}

private void removeFilter()
{
dataProvider.getList().clear();
for (DocumentNode docNode : nodes.values())
{
docNode.setVisible(true);
dataProvider.getList().add(docNode);
}
dataProvider.refresh();
}

public DocumentInfo getDocumentInfo(DocumentId docId)
{
DocumentNode node = nodes.get(docId);
return (node == null ? null : node.getDocInfo());
}

private void clearSelection()
{
if (currentSelection == null)
{
return;
}
currentSelection = null;
}

private void setSelection(final DocumentId documentId)
{
if (currentSelection != null && currentSelection.getDocInfo().getId() == documentId)
{
return;
}
clearSelection();
DocumentNode node = nodes.get(documentId);
if (node != null)
{
currentSelection = node;
// required to have document selected in doclist when loading from
// bookmarked history token
display.getDocumentListTable().getSelectionModel().setSelected(node, true);
}
}
}
Expand Up @@ -19,14 +19,12 @@

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.DecoratedPopupPanel;
import com.google.inject.Inject;

public class WorkspaceUsersPresenter extends WidgetPresenter<WorkspaceUsersPresenter.Display>
{

private final DispatchAsync dispatcher;
private final WorkspaceContext workspaceContext;

public interface Display extends WidgetDisplay
{
Expand All @@ -37,7 +35,6 @@ public interface Display extends WidgetDisplay
public WorkspaceUsersPresenter(final Display display, final EventBus eventBus, CachingDispatchAsync dispatcher, WorkspaceContext workspaceContext)
{
super(display, eventBus);
this.workspaceContext = workspaceContext;
this.dispatcher = dispatcher;
// loadTranslatorList();
}
Expand All @@ -46,8 +43,6 @@ public WorkspaceUsersPresenter(final Display display, final EventBus eventBus, C
protected void onBind()
{

final DecoratedPopupPanel userPopupPanel = new DecoratedPopupPanel(true);

registerHandler(eventBus.addHandler(ExitWorkspaceEvent.getType(), new ExitWorkspaceEventHandler()
{
@Override
Expand Down
Expand Up @@ -10,7 +10,7 @@ public interface WebTransMessages extends Messages
{

@DefaultMessage("{0} participants")
@PluralText({ "one", "One participant" })
@AlternateMessage({ "one", "One participant" })
@Description("Title of the minimized users panel")
String nUsersOnline(@PluralCount int numUsers);

Expand Down
Expand Up @@ -5,10 +5,8 @@

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.uibinder.client.UiBinder;
Expand Down
Expand Up @@ -17,7 +17,6 @@
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
Expand Down

0 comments on commit 7fe1bfc

Please sign in to comment.