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

Commit

Permalink
rhbz844820 - fix bug
Browse files Browse the repository at this point in the history
- keyboard shortcut context is not set correctly
- undo icon insertion
- ensure row selection before copy source action
  • Loading branch information
Patrick Huang committed Aug 31, 2012
1 parent 16b0e11 commit 4e50c64
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
Expand Up @@ -67,7 +67,7 @@ interface Listener

void saveAsApprovedAndMoveNext(TransUnitId transUnitId);

void copySource(ToggleEditor editor);
void copySource(ToggleEditor editor, TransUnitId id);

void onCancel(TransUnitId transUnitId);

Expand Down
Expand Up @@ -161,15 +161,6 @@ public TargetContentsPresenter(Provider<TargetContentsDisplay> displayProvider,
this.historyPresenter = historyPresenter;
this.historyPresenter.setCurrentValueHolder(this);

if (userWorkspaceContext.hasReadOnlyAccess())
{
concealDisplay();
}
else
{
revealDisplay();
}

bindEventHandlers();

keyShortcutPresenter.register(new KeyShortcut(Keys.setOf(new Keys(Keys.CTRL_ALT_KEYS, Keys.KEY_1), new Keys(Keys.CTRL_ALT_KEYS, Keys.KEY_NUM_1)), ShortcutContext.Edit, messages.copyFromTM(1), new KeyShortcutEventHandler()
Expand Down Expand Up @@ -330,7 +321,7 @@ public void onKeyShortcut(KeyShortcutEvent event)
{
if (getCurrentEditor().isFocused())
{
copySource(getCurrentEditor());
copySource(getCurrentEditor(), currentTransUnitId);
}
}
}));
Expand Down Expand Up @@ -392,11 +383,13 @@ public void showEditors(final TransUnitId currentTransUnitId)
if (userWorkspaceContext.hasReadOnlyAccess())
{
display.setToMode(ViewMode.VIEW);
concealDisplay();
}
else
{
display.focusEditor(currentEditorIndex);
updateTranslators();
revealDisplay();
}
}

Expand Down Expand Up @@ -575,8 +568,9 @@ private void ensureRowSelection(TransUnitId transUnitId)
}

@Override
public void copySource(ToggleEditor editor)
public void copySource(ToggleEditor editor, TransUnitId id)
{
ensureRowSelection(id);
currentEditorIndex = editor.getIndex();
editor.setTextAndValidate(sourceContentsPresenter.getSelectedSource());
editor.setFocus();
Expand Down
Expand Up @@ -30,7 +30,6 @@
import org.zanata.webtrans.client.ui.ValidationMessagePanelView;
import org.zanata.webtrans.shared.model.TransUnit;
import org.zanata.webtrans.shared.model.TransUnitId;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -79,6 +78,8 @@ interface Binder extends UiBinder<HorizontalPanel, TargetContentsView>
InlineLabel historyIcon;
@UiField
Styles style;
@UiField
SimplePanel undoContainer;

private HorizontalPanel rootPanel;
private String findMessage;
Expand Down Expand Up @@ -138,10 +139,10 @@ public void preUndo()
@Override
public void postUndoSuccess()
{
undoLink.removeFromParent();
undoContainer.remove(undoLink);
}
});
buttons.add(undoLink);
undoContainer.setWidget(undoLink);
}

@Override
Expand Down
Expand Up @@ -24,6 +24,7 @@
{
cursor: pointer;
font-size: 18px;
height: 24px;
}
</ui:style>

Expand All @@ -35,11 +36,12 @@
</g:FlowPanel>
</g:cell>
<g:cell verticalAlignment="ALIGN_TOP" horizontalAlignment="ALIGN_RIGHT" width="30px">
<g:VerticalPanel ui:field="buttons" spacing="2" height="120px">
<g:VerticalPanel ui:field="buttons" height="120px">
<g:InlineLabel ui:field="saveIcon" title="{messages.editSaveShortcut}" styleName="icon-install {style.button}"/>
<g:InlineLabel ui:field="fuzzyIcon" title="{messages.saveAsFuzzy}" styleName="icon-flag-1 {style.button}" />
<g:InlineLabel ui:field="cancelIcon" title="{messages.editCancelShortcut}" styleName="icon-cancel-circle {style.button}" />
<g:InlineLabel ui:field="historyIcon" title="{messages.history}" styleName="icon-back-in-time {style.button}" />
<g:SimplePanel ui:field="undoContainer" />
</g:VerticalPanel>
</g:cell>
</g:HorizontalPanel>
Expand Down
Expand Up @@ -44,6 +44,8 @@ interface Styles extends CssResource
String translatorList();

String hasValidationError();

String copyButton();
}

private static EditorUiBinder uiBinder = GWT.create(EditorUiBinder.class);
Expand Down Expand Up @@ -172,7 +174,7 @@ public void onKeyDownTextArea(KeyDownEvent event)
@UiHandler("copyIcon")
public void onCopySource(ClickEvent event)
{
listener.copySource(this);
listener.copySource(this, id);
}

@Override
Expand Down
Expand Up @@ -48,8 +48,6 @@ public interface UndoLink extends InlineLink, HasText

void setUndoCallback(UndoCallback callback);

void removeFromParent();

interface UndoCallback
{
void preUndo();
Expand Down
Expand Up @@ -188,9 +188,14 @@ public void canSaveAsFuzzy()
@Test
public void canCopySource()
{
// Given: selected one trans unit
selectedTU = currentPageRows.get(0);
when(display.getId()).thenReturn(selectedTU.getId());
when(display.getEditors()).thenReturn(Lists.newArrayList(editor));
presenter.showEditors(selectedTU.getId());
when(sourceContentPresenter.getSelectedSource()).thenReturn("source");

presenter.copySource(editor);
presenter.copySource(editor, selectedTU.getId());

verify(editor).setTextAndValidate("source");
verify(editor).setFocus();
Expand Down

0 comments on commit 4e50c64

Please sign in to comment.