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' into rhbz819691
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed May 30, 2012
2 parents f3fc8ca + 2b949ed commit 8e014bf
Show file tree
Hide file tree
Showing 17 changed files with 403 additions and 124 deletions.
Expand Up @@ -77,6 +77,7 @@
import org.zanata.webtrans.shared.rpc.GetTransUnitListResult;
import org.zanata.webtrans.shared.rpc.GetTransUnitsNavigation;
import org.zanata.webtrans.shared.rpc.GetTransUnitsNavigationResult;
import org.zanata.webtrans.shared.rpc.TransUnitUpdated.UpdateType;
import org.zanata.webtrans.shared.rpc.UpdateTransUnit;
import org.zanata.webtrans.shared.rpc.UpdateTransUnitResult;

Expand Down Expand Up @@ -350,9 +351,23 @@ public void onTransUnitUpdated(TransUnitUpdatedEvent event)
// assume update was successful
if (documentId != null && documentId.equals(event.getUpdateInfo().getDocumentId()))
{
boolean editing = targetContentsPresenter.isEditing();
navigationService.updateMap(event.getUpdateInfo().getTransUnit().getId().getId(), event.getUpdateInfo().getTransUnit().getStatus());
// if its different user,
if (!event.getEditorClientId().equals(identity.getEditorClientId()))
// if save-as-fuzzy on same tab
if (event.getEditorClientId().equals(identity.getEditorClientId()) && event.getUpdateType() == UpdateType.WebEditorSaveFuzzy)
{
Integer rowIndex = navigationService.getRowIndex(event.getUpdateInfo().getTransUnit(), isFiltering(), display.getRowValues());
if (rowIndex != null)
{
TransUnit rowValue = display.getRowValue(rowIndex);
if (rowValue != null)
{
rowValue.OverrideWith(event.getUpdateInfo().getTransUnit());
display.getTableModel().clearCache();
}
}
}
else
{
if (selectedTransUnit != null && selectedTransUnit.getId().equals(event.getUpdateInfo().getTransUnit().getId()))
{
Expand All @@ -368,14 +383,9 @@ public void onTransUnitUpdated(TransUnitUpdatedEvent event)
display.getTableModel().setRowValueOverride(rowIndex, event.getUpdateInfo().getTransUnit());
}
}
else
if (editing)
{
Integer rowIndex = navigationService.getRowIndex(event.getUpdateInfo().getTransUnit(), isFiltering(), display.getRowValues());
if (rowIndex != null)
{
display.getRowValue(rowIndex).OverrideWith(event.getUpdateInfo().getTransUnit());
display.getTableModel().clearCache();
}
gotoCurrentRow();
}
}
}
Expand Down Expand Up @@ -682,7 +692,9 @@ else if (caught instanceof AuthorizationError)
@Override
public boolean onSetRowValue(int row, TransUnit rowValue)
{
final UpdateTransUnit updateTransUnit = new UpdateTransUnit(new TransUnitUpdateRequest(rowValue.getId(), rowValue.getTargets(), rowValue.getStatus(), rowValue.getVerNum()));
UpdateType updateType = rowValue.getStatus() == ContentState.Approved ? UpdateType.WebEditorSave : UpdateType.WebEditorSaveFuzzy;
Log.debug("row updated, calculated update type: " + updateType);
final UpdateTransUnit updateTransUnit = new UpdateTransUnit(new TransUnitUpdateRequest(rowValue.getId(), rowValue.getTargets(), rowValue.getStatus(), rowValue.getVerNum()), updateType);
eventBus.fireEvent(new NotificationEvent(Severity.Info, messages.notifySaving()));
dispatcher.execute(updateTransUnit, new AsyncCallback<UpdateTransUnitResult>()
{
Expand Down
Expand Up @@ -23,6 +23,7 @@
import org.zanata.webtrans.shared.auth.EditorClientId;
import org.zanata.webtrans.shared.model.TransUnitUpdateInfo;
import org.zanata.webtrans.shared.rpc.HasTransUnitUpdatedData;
import org.zanata.webtrans.shared.rpc.TransUnitUpdated.UpdateType;

import com.google.gwt.event.shared.GwtEvent;

Expand Down Expand Up @@ -51,11 +52,13 @@ public static Type<TransUnitUpdatedEventHandler> getType()

private TransUnitUpdateInfo tuUpdateInfo;
private EditorClientId editorClientId;
private UpdateType updateType;

public TransUnitUpdatedEvent(HasTransUnitUpdatedData data)
{
this.tuUpdateInfo = data.getUpdateInfo();
this.editorClientId = data.getEditorClientId();
this.updateType = data.getUpdateType();
}

@Override
Expand All @@ -82,4 +85,10 @@ public EditorClientId getEditorClientId()
return editorClientId;
}

@Override
public UpdateType getUpdateType()
{
return updateType;
}

}
Expand Up @@ -32,6 +32,8 @@
import org.zanata.webtrans.client.events.DocumentStatsUpdatedEventHandler;
import org.zanata.webtrans.client.events.NotificationEvent;
import org.zanata.webtrans.client.events.NotificationEvent.Severity;
import org.zanata.webtrans.client.events.KeyShortcutEvent;
import org.zanata.webtrans.client.events.KeyShortcutEventHandler;
import org.zanata.webtrans.client.events.NotificationEventHandler;
import org.zanata.webtrans.client.events.ProjectStatsUpdatedEvent;
import org.zanata.webtrans.client.events.ProjectStatsUpdatedEventHandler;
Expand All @@ -40,6 +42,8 @@
import org.zanata.webtrans.client.history.History;
import org.zanata.webtrans.client.history.HistoryToken;
import org.zanata.webtrans.client.history.Window;
import org.zanata.webtrans.client.keys.KeyShortcut;
import org.zanata.webtrans.client.keys.ShortcutContext;
import org.zanata.webtrans.client.resources.WebTransMessages;
import org.zanata.webtrans.client.ui.HasCommand;
import org.zanata.webtrans.shared.auth.Identity;
Expand Down Expand Up @@ -340,6 +344,58 @@ public void onPresenterRevealed(PresenterRevealedEvent event)
}
}));

keyShortcutPresenter.registerKeyShortcut(new KeyShortcut(
KeyShortcut.ALT_KEY, 'L',
ShortcutContext.Application,
messages.showDocumentListKeyShortcut(),
new KeyShortcutEventHandler()
{
@Override
public void onKeyShortcut(KeyShortcutEvent event)
{
HistoryToken token = history.getHistoryToken();
token.setView(MainView.Documents);
history.newItem(token.toTokenString());
}
}));

keyShortcutPresenter.registerKeyShortcut(new KeyShortcut(
KeyShortcut.ALT_KEY, 'O',
ShortcutContext.Application,
messages.showEditorKeyShortcut(),
new KeyShortcutEventHandler()
{
@Override
public void onKeyShortcut(KeyShortcutEvent event)
{
if (selectedDocument == null)
{
eventBus.fireEvent(new NotificationEvent(Severity.Warning, messages.noDocumentSelected()));
}
else
{
HistoryToken token = history.getHistoryToken();
token.setView(MainView.Editor);
history.newItem(token.toTokenString());
}
}
}));

keyShortcutPresenter.registerKeyShortcut(new KeyShortcut(
KeyShortcut.ALT_KEY, 'P',
ShortcutContext.Application,
messages.showProjectWideSearch(),
new KeyShortcutEventHandler()
{
@Override
public void onKeyShortcut(KeyShortcutEvent event)
{
HistoryToken token = history.getHistoryToken();
token.setView(MainView.Search);
history.newItem(token.toTokenString());
}
}));

display.setUserLabel(identity.getPerson().getName());
String workspaceTitle = windowLocation.getParameter(WORKSPACE_TITLE_QUERY_PARAMETER_KEY);
display.setWorkspaceNameLabel(workspaceContext.getWorkspaceName(), workspaceTitle);
Expand Down
Expand Up @@ -114,7 +114,7 @@ public void onPreviewNativeEvent(NativePreviewEvent event)
});

// could try to use ?, although this is not as simple as passing character '?'
registerKeyShortcut(new KeyShortcut(KeyShortcut.ALT_KEY, 'K',
registerKeyShortcut(new KeyShortcut(KeyShortcut.ALT_KEY, 'Y',
ShortcutContext.Application,
messages.showAvailableKeyShortcuts(),
new KeyShortcutEventHandler()
Expand Down

0 comments on commit 8e014bf

Please sign in to comment.