Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'rhbz803572' of github.com:zanata/zanata into rhbz803572

Conflicts:
	server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsView.java
  • Loading branch information...
commit 5161f12d96e252fa0a725c2623e4afd0dbedc5af 2 parents c2db0ac + fcf730f
@seanf seanf authored
Showing with 383 additions and 193 deletions.
  1. +8 −26 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java
  2. +4 −13 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorPresenter.java
  3. +3 −0  server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableResources.java
  4. +12 −2 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsDisplay.java
  5. +163 −63 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsPresenter.java
  6. +23 −5 server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsView.java
  7. +7 −2 server/zanata-war/src/main/java/org/zanata/webtrans/client/events/UserConfigChangeEvent.java
  8. +18 −21 server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/OptionsPanelPresenter.java
  9. +1 −1  server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TransUnitNavigationPresenter.java
  10. +4 −2 server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/TranslationEditorPresenter.java
  11. +94 −0 server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/UserConfigHolder.java
  12. +1 −1  server/zanata-war/src/main/java/org/zanata/webtrans/client/resources/NavigationMessages.java
  13. +27 −34 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/Editor.java
  14. +1 −1  server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/Editor.ui.xml
  15. +5 −1 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/ToggleEditor.java
  16. +11 −20 server/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransUnitNavigationView.java
  17. BIN  .../zanata-war/src/main/resources/org/zanata/webtrans/images/crystal_project/_16x16/actions/move_task_down.png
  18. +1 −1  server/zanata-war/src/test/java/org/zanata/webtrans/client/presenter/OptionsPanelPresenterTest.java
View
34 ...ata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java
@@ -506,36 +506,18 @@ protected boolean onCancel()
}
- public void setShowOperationButtons(boolean showButtons)
- {
-// operationsPanel.setVisible(showButtons);
- }
-
public void updateKeyBehaviour(Map<String, Boolean> configMap)
{
- if (configMap.containsKey(EditorConfigConstants.BUTTON_FUZZY) && configMap.containsKey(EditorConfigConstants.BUTTON_UNTRANSLATED))
- {
- untranslatedMode = configMap.get(EditorConfigConstants.BUTTON_UNTRANSLATED);
- fuzzyMode = configMap.get(EditorConfigConstants.BUTTON_FUZZY);
- }
-
-// if (configMap.containsKey(EditorConfigConstants.BUTTON_ENTER))
+// if (configMap.containsKey(EditorConfigConstants.BUTTON_FUZZY) && configMap.containsKey(EditorConfigConstants.BUTTON_UNTRANSLATED))
// {
-// isEnterKeySavesEnabled = configMap.get(EditorConfigConstants.BUTTON_ENTER);
-// if (isEnterKeySavesEnabled)
-// {
-// saveButton.setTitle(saveButtonwithEnterShortcuts);
-// }
-// else
-// {
-// saveButton.setTitle(saveButtonShortcuts);
-// }
+// untranslatedMode = configMap.get(EditorConfigConstants.BUTTON_UNTRANSLATED);
+// fuzzyMode = configMap.get(EditorConfigConstants.BUTTON_FUZZY);
+// }
+//
+// if (configMap.containsKey(EditorConfigConstants.BUTTON_ESC))
+// {
+// isEscKeyCloseEditor = configMap.get(EditorConfigConstants.BUTTON_ESC);
// }
-
- if (configMap.containsKey(EditorConfigConstants.BUTTON_ESC))
- {
- isEscKeyCloseEditor = configMap.get(EditorConfigConstants.BUTTON_ESC);
- }
}
View
17 ...anata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableEditorPresenter.java
@@ -308,10 +308,10 @@ protected void onBind()
{
display.setTableModelHandler(tableModelHandler);
display.setPageSize(TableConstants.PAGE_SIZE);
- if (workspaceContext.isReadOnly())
- {
- display.getTargetCellEditor().setShowOperationButtons(false);
- }
+// if (workspaceContext.isReadOnly())
+// {
+// display.getTargetCellEditor().setShowOperationButtons(false);
+// }
registerHandler(filterViewConfirmationPanel.getSaveChangesAndFilterButton().addClickHandler(new ClickHandler()
{
@@ -567,15 +567,6 @@ public void onOpenEditor(OpenEditorEvent event)
}
}));
- registerHandler(eventBus.addHandler(ButtonDisplayChangeEvent.getType(), new ButtonDisplayChangeEventHandler()
- {
- @Override
- public void onButtonDisplayChange(ButtonDisplayChangeEvent event)
- {
- display.getTargetCellEditor().setShowOperationButtons(event.isShowButtons());
- }
- }));
-
registerHandler(eventBus.addHandler(WorkspaceContextUpdateEvent.getType(), new WorkspaceContextUpdateEventHandler()
{
@Override
View
3  server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TableResources.java
@@ -36,6 +36,9 @@
@Source("org/zanata/webtrans/images/crystal_project/_16x16/actions/3floppy_unmount.png")
ImageResource cellEditorAccept();
+ @Source("org/zanata/webtrans/images/crystal_project/_16x16/actions/move_task_down.png")
+ ImageResource cellEditorMoveDown();
+
@Source("org/zanata/webtrans/images/crystal_project/_16x16/actions/button_cancel.png")
ImageResource cellEditorCancel();
View
14 ...nata-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsDisplay.java
@@ -19,6 +19,8 @@
import org.zanata.webtrans.client.ui.ToggleEditor;
+import com.google.gwt.event.dom.client.KeyDownEvent;
+
import net.customware.gwt.presenter.client.widget.WidgetDisplay;
public interface TargetContentsDisplay extends WidgetDisplay, Iterable<ToggleEditor>
@@ -26,11 +28,15 @@
void openEditorAndCloseOthers(int currentEditor);
+ void setSaveButtonTitle(String title);
+
+ void showButtons(boolean displayButtons);
+
interface Listener
{
void validate(ToggleEditor editor);
- void saveAsApproved(ToggleEditor editor);
+ void saveAsApproved(int editorIndex);
void copySource(ToggleEditor editor);
@@ -40,7 +46,11 @@
void onCancel(ToggleEditor editor);
- void saveAsFuzzy(ToggleEditor editor);
+ void saveAsFuzzy();
+
+ boolean isDisplayButtons();
+
+ void onTextAreaKeyDown(KeyDownEvent event, ToggleEditor editor);
}
void setTargets(ArrayList<String> targets);
View
226 ...ta-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsPresenter.java
@@ -21,6 +21,8 @@
import net.customware.gwt.presenter.client.EventBus;
+import org.zanata.webtrans.client.editor.CheckKey;
+import org.zanata.webtrans.client.editor.CheckKeyImpl;
import org.zanata.webtrans.client.events.CopyDataToEditorEvent;
import org.zanata.webtrans.client.events.CopyDataToEditorHandler;
import org.zanata.webtrans.client.events.InsertStringInEditorEvent;
@@ -33,26 +35,42 @@
import org.zanata.webtrans.client.events.RunValidationEvent;
import org.zanata.webtrans.client.events.UpdateValidationWarningsEvent;
import org.zanata.webtrans.client.events.UpdateValidationWarningsEventHandler;
+import org.zanata.webtrans.client.events.UserConfigChangeEvent;
+import org.zanata.webtrans.client.events.UserConfigChangeHandler;
import org.zanata.webtrans.client.presenter.SourceContentsPresenter;
+import org.zanata.webtrans.client.presenter.UserConfigHolder;
+import org.zanata.webtrans.client.resources.NavigationMessages;
import org.zanata.webtrans.client.resources.TableEditorMessages;
import org.zanata.webtrans.client.ui.ToggleEditor;
import org.zanata.webtrans.client.ui.ToggleEditor.ViewMode;
import org.zanata.webtrans.client.ui.ValidationMessagePanel;
import org.zanata.webtrans.shared.model.TransUnit;
+import org.zanata.webtrans.shared.model.WorkspaceContext;
import com.allen_sauer.gwt.log.client.Log;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
+import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@Singleton
-public class TargetContentsPresenter implements TargetContentsDisplay.Listener
+public class TargetContentsPresenter implements TargetContentsDisplay.Listener,
+ UserConfigChangeHandler,
+ UpdateValidationWarningsEventHandler,
+ RequestValidationEventHandler,
+ InsertStringInEditorHandler,
+ CopyDataToEditorHandler
{
private static final int NO_OPEN_EDITOR = -1;
private final EventBus eventBus;
private final TableEditorMessages messages;
private final SourceContentsPresenter sourceContentsPresenter;
+ private final UserConfigHolder configHolder;
+ private final CheckKey checkKey;
+
+ private NavigationMessages navMessages;
+ private WorkspaceContext workspaceContext;
private final ValidationMessagePanel validationMessagePanel;
private TargetContentsDisplay currentDisplay;
@@ -63,70 +81,26 @@
private TransUnitsEditModel cellEditor;
@Inject
- public TargetContentsPresenter(Provider<TargetContentsDisplay> displayProvider, final EventBus eventBus, final TableEditorMessages messages, final SourceContentsPresenter sourceContentsPresenter)
+ public TargetContentsPresenter(Provider<TargetContentsDisplay> displayProvider, final EventBus eventBus,
+ final TableEditorMessages messages,
+ final SourceContentsPresenter sourceContentsPresenter, UserConfigHolder configHolder,
+ NavigationMessages navMessages, WorkspaceContext workspaceContext)
{
this.displayProvider = displayProvider;
this.eventBus = eventBus;
this.messages = messages;
this.sourceContentsPresenter = sourceContentsPresenter;
+ this.configHolder = configHolder;
+ this.navMessages = navMessages;
+ this.workspaceContext = workspaceContext;
+ checkKey = new CheckKeyImpl(CheckKeyImpl.Context.Edit);
validationMessagePanel = new ValidationMessagePanel(true, messages);
-
- eventBus.addHandler(UpdateValidationWarningsEvent.getType(), new UpdateValidationWarningsEventHandler()
- {
- @Override
- public void onUpdate(UpdateValidationWarningsEvent event)
- {
- validationMessagePanel.setContent(event.getErrors());
- }
- });
-
- eventBus.addHandler(RequestValidationEvent.getType(), new RequestValidationEventHandler()
- {
- @Override
- public void onRequestValidation(RequestValidationEvent event)
- {
- if (isEditing())
- {
- eventBus.fireEvent(new RunValidationEvent(sourceContentsPresenter.getSelectedSource(),
- getCurrentEditor().getText(), false));
- }
- }
- });
-
- eventBus.addHandler(InsertStringInEditorEvent.getType(), new InsertStringInEditorHandler()
- {
- @Override
- public void onInsertString(InsertStringInEditorEvent event)
- {
- if (isEditing())
- {
- getCurrentEditor().insertTextInCursorPosition(event.getSuggestion());
- eventBus.fireEvent(new NotificationEvent(Severity.Info, messages.notifyCopied()));
- }
- else
- {
- eventBus.fireEvent(new NotificationEvent(Severity.Error, messages.notifyUnopened()));
- }
- }
- });
-
- eventBus.addHandler(CopyDataToEditorEvent.getType(), new CopyDataToEditorHandler()
- {
- @Override
- public void onTransMemoryCopy(CopyDataToEditorEvent event)
- {
- if (isEditing())
- {
- getCurrentEditor().setText(event.getTargetResult());
- eventBus.fireEvent(new NotificationEvent(Severity.Info, messages.notifyCopied()));
- }
- else
- {
- eventBus.fireEvent(new NotificationEvent(Severity.Error, messages.notifyUnopened()));
- }
- }
- });
+ eventBus.addHandler(UserConfigChangeEvent.getType(), this);
+ eventBus.addHandler(UpdateValidationWarningsEvent.getType(), this);
+ eventBus.addHandler(RequestValidationEvent.getType(), this);
+ eventBus.addHandler(InsertStringInEditorEvent.getType(), this);
+ eventBus.addHandler(CopyDataToEditorEvent.getType(), this);
}
private ToggleEditor getCurrentEditor()
@@ -173,7 +147,7 @@ public void showEditors(int rowIndex)
if (currentEditorIndex != NO_OPEN_EDITOR)
{
currentDisplay.openEditorAndCloseOthers(currentEditorIndex);
- Log.info("show editors at row:" + rowIndex + " current editor:" + currentEditorIndex);
+ Log.debug("show editors at row:" + rowIndex + " current editor:" + currentEditorIndex);
}
}
@@ -186,9 +160,20 @@ public TargetContentsDisplay getNextTargetContentsDisplay(int rowIndex, TransUni
}
result.setTargets(transUnit.getTargets());
+ result.setSaveButtonTitle(decideButtonTitle());
+ if (workspaceContext.isReadOnly())
+ {
+ Log.debug("read only mode. Hide buttons");
+ result.showButtons(false);
+ }
return result;
}
+ private String decideButtonTitle()
+ {
+ return (configHolder.isButtonEnter()) ? navMessages.editSaveWithEnterShortcut() : navMessages.editSaveShortcut();
+ }
+
public void initWidgets(int pageSize)
{
displayList = Lists.newArrayList();
@@ -212,9 +197,8 @@ public void validate(ToggleEditor editor)
}
@Override
- public void saveAsApproved(ToggleEditor editor)
+ public void saveAsApproved(int editorIndex)
{
- int editorIndex = currentEditors.indexOf(editor);
if (editorIndex + 1 < currentEditors.size())
{
currentDisplay.openEditorAndCloseOthers(editorIndex + 1);
@@ -227,13 +211,19 @@ public void saveAsApproved(ToggleEditor editor)
}
@Override
- public void saveAsFuzzy(ToggleEditor editor)
+ public void saveAsFuzzy()
{
Preconditions.checkState(cellEditor != null, "InlineTargetCellEditor must be set for triggering table save event");
cellEditor.acceptFuzzyEdit();
}
@Override
+ public boolean isDisplayButtons()
+ {
+ return configHolder.isDisplayButtons();
+ }
+
+ @Override
public void onCancel(ToggleEditor editor)
{
editor.setViewMode(ViewMode.VIEW);
@@ -257,7 +247,7 @@ public void toggleView(ToggleEditor editor)
//still in the same trans unit. won't trigger transunit selection or edit cell event
currentDisplay.openEditorAndCloseOthers(currentEditorIndex);
}
- Log.info("current display:" + currentDisplay);
+ Log.debug("current display:" + currentDisplay);
//else, it's clicking an editor outside current selection. the table selection event will trigger and showEditors will take care of the rest
}
@@ -277,4 +267,114 @@ public void setCellEditor(TransUnitsEditModel cellEditor)
{
this.cellEditor = cellEditor;
}
+
+ @Override
+ public void onValueChanged(UserConfigChangeEvent event)
+ {
+ String title = decideButtonTitle();
+ for (TargetContentsDisplay display : displayList)
+ {
+ display.setSaveButtonTitle(title);
+ display.showButtons(configHolder.isDisplayButtons());
+ }
+ }
+
+ @Override
+ public void onUpdate(UpdateValidationWarningsEvent event)
+ {
+ validationMessagePanel.setContent(event.getErrors());
+ }
+
+ @Override
+ public void onRequestValidation(RequestValidationEvent event)
+ {
+ if (isEditing())
+ {
+ eventBus.fireEvent(new RunValidationEvent(sourceContentsPresenter.getSelectedSource(),
+ getCurrentEditor().getText(), false));
+ }
+ }
+
+ @Override
+ public void onInsertString(InsertStringInEditorEvent event)
+ {
+ if (isEditing())
+ {
+ getCurrentEditor().insertTextInCursorPosition(event.getSuggestion());
+ eventBus.fireEvent(new NotificationEvent(Severity.Info, messages.notifyCopied()));
+ }
+ else
+ {
+ eventBus.fireEvent(new NotificationEvent(Severity.Error, messages.notifyUnopened()));
+ }
+ }
+
+ @Override
+ public void onTransMemoryCopy(CopyDataToEditorEvent event)
+ {
+ if (isEditing())
+ {
+ getCurrentEditor().setText(event.getTargetResult());
+ eventBus.fireEvent(new NotificationEvent(Severity.Info, messages.notifyCopied()));
+ }
+ else
+ {
+ eventBus.fireEvent(new NotificationEvent(Severity.Error, messages.notifyUnopened()));
+ }
+ }
+
+
+
+ @Override
+ public void onTextAreaKeyDown(KeyDownEvent event, ToggleEditor editor)
+ {
+ checkKey.init(event.getNativeEvent());
+
+ if (checkKey.isCopyFromSourceKey())
+ {
+ copySource(editor);
+ }
+ else if (checkKey.isNextEntryKey())
+ {
+ // See editCell() for saving event
+ // saveAsApproved(editor);
+ }
+ else if (checkKey.isPreviousEntryKey())
+ {
+ // See editCell() for saving event
+ // saveAndMoveRow(NavigationType.PrevEntry);
+ }
+ else if (checkKey.isNextStateEntryKey())
+ {
+ // saveAndMoveNextState(NavigationType.NextEntry);
+ }
+ else if (checkKey.isPreviousStateEntryKey())
+ {
+ // saveAndMoveNextState(NavigationType.PrevEntry);
+ }
+ else if (checkKey.isSaveAsFuzzyKey())
+ {
+ event.stopPropagation();
+ event.preventDefault(); // stop browser save
+ // acceptFuzzyEdit();
+ }
+ // else if (checkKey.isSaveAsApprovedKey(isEnterKeySavesEnabled))
+ // {
+ // event.stopPropagation();
+ // event.preventDefault();
+ // saveApprovedAndMoveRow(NavigationType.NextEntry);
+ // }
+ // else if (checkKey.isCloseEditorKey(isEscKeyCloseEditor))
+ // {
+ // cancelEdit();
+ // }
+ // else if (checkKey.isUserTyping() && !checkKey.isBackspace())
+ // {
+ // growSize();
+ // }
+ // else if (checkKey.isUserTyping() && checkKey.isBackspace())
+ // {
+ // shrinkSize(false);
+ // }
+ }
}
View
28 .../zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/TargetContentsView.java
@@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Iterator;
+import com.google.common.base.Preconditions;
import org.zanata.webtrans.client.ui.Editor;
import org.zanata.webtrans.client.ui.ToggleEditor;
@@ -53,6 +54,27 @@ public void openEditorAndCloseOthers(int currentEditor)
}
@Override
+ public void setSaveButtonTitle(String title)
+ {
+ Preconditions.checkState(editors.size() > 0);
+ lastEditor().setSaveButtonTitle(title);
+ }
+
+ private ToggleEditor lastEditor()
+ {
+ return editors.get(editors.size() - 1);
+ }
+
+ @Override
+ public void showButtons(boolean displayButtons)
+ {
+ for (ToggleEditor editor : editors)
+ {
+ editor.showButtons(displayButtons);
+ }
+ }
+
+ @Override
public void setTargets(ArrayList<String> targets)
{
editors.clear();
@@ -66,7 +88,6 @@ public void setTargets(ArrayList<String> targets)
editor.setText("");
editorGrid.setWidget(rowIndex, 0, editor);
editors.add(editor);
- editor.setSaveButtonTitle("Save as approved");
}
else
{
@@ -78,11 +99,8 @@ public void setTargets(ArrayList<String> targets)
editors.add(editor);
rowIndex++;
}
-
- // TODO last one has different title. The title should be in
- // NavigationMessages not hardcoded string
- editors.get(editors.size() - 1).setSaveButtonTitle("Save and go to next");
}
+ lastEditor().setAsLastEditor();
}
@Override
View
9 server/zanata-war/src/main/java/org/zanata/webtrans/client/events/UserConfigChangeEvent.java
@@ -13,6 +13,10 @@
*/
private static Type<UserConfigChangeHandler> TYPE;
+ public UserConfigChangeEvent()
+ {
+ }
+
/**
* Gets the type associated with this event.
*
@@ -27,11 +31,12 @@
return TYPE;
}
- private HashMap<String, Boolean> configMap;
+ private Map<String, Boolean> configMap;
public UserConfigChangeEvent(Map<String, Boolean> configMap)
{
- this.configMap = (HashMap<String, Boolean>) configMap;
+ //TODO instead of passing config map around, all receivers should directly reference UserConfigHolder to get value
+ this.configMap = configMap;
}
public Map<String, Boolean> getConfigMap()
View
39 .../zanata-war/src/main/java/org/zanata/webtrans/client/presenter/OptionsPanelPresenter.java
@@ -80,20 +80,16 @@
private final ValidationOptionsPresenter validationOptionsPresenter;
- private Map<String, Boolean> configMap = new HashMap<String, Boolean>();
private final WorkspaceContext workspaceContext;
+ private UserConfigHolder configHolder;
@Inject
- public OptionsPanelPresenter(final Display display, final EventBus eventBus, final ValidationOptionsPresenter validationDetailsPresenter, final WorkspaceContext workspaceContext)
+ public OptionsPanelPresenter(final Display display, final EventBus eventBus, final ValidationOptionsPresenter validationDetailsPresenter, final WorkspaceContext workspaceContext, UserConfigHolder configHolder)
{
super(display, eventBus);
this.validationOptionsPresenter = validationDetailsPresenter;
this.workspaceContext = workspaceContext;
-
- configMap.put(EditorConfigConstants.BUTTON_ENTER, false);
- configMap.put(EditorConfigConstants.BUTTON_ESC, false);
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
+ this.configHolder = configHolder;
}
private final ValueChangeHandler<Boolean> filterChangeHandler = new ValueChangeHandler<Boolean>()
@@ -153,7 +149,8 @@ public void onFilterView(FilterViewEvent event)
public void onValueChange(ValueChangeEvent<Boolean> event)
{
Log.info("Show editor buttons: " + event.getValue());
- eventBus.fireEvent(new ButtonDisplayChangeEvent(event.getValue()));
+ configHolder.setDisplayButtons(event.getValue());
+ eventBus.fireEvent(new UserConfigChangeEvent());
}
}));
@@ -163,8 +160,8 @@ public void onValueChange(ValueChangeEvent<Boolean> event)
public void onValueChange(ValueChangeEvent<Boolean> event)
{
Log.info("Enable 'Enter' Key to save and move to next string: " + event.getValue());
- configMap.put(EditorConfigConstants.BUTTON_ENTER, event.getValue());
- eventBus.fireEvent(new UserConfigChangeEvent(configMap));
+ configHolder.setButtonEnter(event.getValue());
+ eventBus.fireEvent(new UserConfigChangeEvent(configHolder.getConfigMap()));
}
}));
@@ -174,15 +171,15 @@ public void onValueChange(ValueChangeEvent<Boolean> event)
public void onValueChange(ValueChangeEvent<Boolean> event)
{
Log.info("Enable 'Esc' Key to close editor: " + event.getValue());
- configMap.put(EditorConfigConstants.BUTTON_ESC, event.getValue());
- eventBus.fireEvent(new UserConfigChangeEvent(configMap));
+ configHolder.setButtonEsc(event.getValue());
+ eventBus.fireEvent(new UserConfigChangeEvent(configHolder.getConfigMap()));
}
}));
// editor buttons always shown by default
display.getEditorButtonsChk().setValue(true, false);
- display.getEnterChk().setValue(configMap.get(EditorConfigConstants.BUTTON_ENTER), false);
- display.getEscChk().setValue(configMap.get(EditorConfigConstants.BUTTON_ESC), false);
+ display.getEnterChk().setValue(configHolder.isButtonEnter(), false);
+ display.getEscChk().setValue(configHolder.isButtonEsc(), false);
registerHandler(display.getModalNavigationOptionsSelect().addChangeHandler(new ChangeHandler()
{
@@ -192,20 +189,20 @@ public void onChange(ChangeEvent event)
String selectedOption = display.getSelectedFilter();
if (selectedOption.equals(Display.KEY_FUZZY_UNTRANSLATED))
{
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
+ configHolder.setButtonUntranslated(true);
+ configHolder.setButtonFuzzy(true);
}
else if (selectedOption.equals(Display.KEY_FUZZY))
{
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, true);
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, false);
+ configHolder.setButtonFuzzy(true);
+ configHolder.setButtonUntranslated(false);
}
else if (selectedOption.equals(Display.KEY_UNTRANSLATED))
{
- configMap.put(EditorConfigConstants.BUTTON_FUZZY, false);
- configMap.put(EditorConfigConstants.BUTTON_UNTRANSLATED, true);
+ configHolder.setButtonFuzzy(false);
+ configHolder.setButtonUntranslated(true);
}
- eventBus.fireEvent(new UserConfigChangeEvent(configMap));
+ eventBus.fireEvent(new UserConfigChangeEvent(configHolder.getConfigMap()));
}
}));
View
2  ...-war/src/main/java/org/zanata/webtrans/client/presenter/TransUnitNavigationPresenter.java
@@ -56,7 +56,7 @@
HasClickHandlers getNextStateButton();
- void setNavModeTooltip(Map<String, Boolean> configMap);
+ void setNavModeTooltip(boolean isButtonFuzzy, boolean isButtonUntranslated);
void setModalNavVisible(boolean visible);
}
View
6 ...ta-war/src/main/java/org/zanata/webtrans/client/presenter/TranslationEditorPresenter.java
@@ -65,16 +65,18 @@
private final TableEditorPresenter tableEditorPresenter;
// private final UndoRedoPresenter undoRedoPresenter;
private final TransFilterPresenter transFilterPresenter;
+ private UserConfigHolder configHolder;
@Inject
- public TranslationEditorPresenter(Display display, EventBus eventBus, final CachingDispatchAsync dispatcher, final TableEditorPresenter tableEditorPresenter, final TransUnitNavigationPresenter transUnitNavigationPresenter, final UndoRedoPresenter undoRedoPresenter, final TransFilterPresenter transFilterPresenter)
+ public TranslationEditorPresenter(Display display, EventBus eventBus, final CachingDispatchAsync dispatcher, final TableEditorPresenter tableEditorPresenter, final TransUnitNavigationPresenter transUnitNavigationPresenter, final UndoRedoPresenter undoRedoPresenter, final TransFilterPresenter transFilterPresenter, UserConfigHolder configHolder)
{
super(display, eventBus);
this.tableEditorPresenter = tableEditorPresenter;
this.transUnitNavigationPresenter = transUnitNavigationPresenter;
// this.undoRedoPresenter = undoRedoPresenter;
this.transFilterPresenter = transFilterPresenter;
+ this.configHolder = configHolder;
}
@Override
@@ -130,7 +132,7 @@ public void onPageCountChange(PageCountChangeEvent event)
@Override
public void onValueChanged(UserConfigChangeEvent event)
{
- transUnitNavigationPresenter.getDisplay().setNavModeTooltip(event.getConfigMap());
+ transUnitNavigationPresenter.getDisplay().setNavModeTooltip(configHolder.isButtonFuzzy(), configHolder.isButtonUntranslated());
tableEditorPresenter.getDisplay().getTargetCellEditor().updateKeyBehaviour(event.getConfigMap());
}
}));
View
94 server/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/UserConfigHolder.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.zanata.webtrans.client.presenter;
+
+import java.util.Map;
+
+import org.zanata.webtrans.client.resources.EditorConfigConstants;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Singleton;
+
+
+@Singleton
+public class UserConfigHolder
+{
+ private boolean buttonEnter = false;
+ private boolean buttonEsc = false;
+ private boolean buttonFuzzy = true;
+ private boolean buttonUntranslated = true;
+ private boolean displayButtons = true;
+
+ public boolean isButtonEnter()
+ {
+ return buttonEnter;
+ }
+
+ void setButtonEnter(boolean buttonEnter)
+ {
+ this.buttonEnter = buttonEnter;
+ }
+
+ public boolean isButtonEsc()
+ {
+ return buttonEsc;
+ }
+
+ void setButtonEsc(boolean buttonEsc)
+ {
+ this.buttonEsc = buttonEsc;
+ }
+
+ public boolean isButtonFuzzy()
+ {
+ return buttonFuzzy;
+ }
+
+ void setButtonFuzzy(boolean buttonFuzzy)
+ {
+ this.buttonFuzzy = buttonFuzzy;
+ }
+
+ public boolean isButtonUntranslated()
+ {
+ return buttonUntranslated;
+ }
+
+ void setButtonUntranslated(boolean buttonUntranslated)
+ {
+ this.buttonUntranslated = buttonUntranslated;
+ }
+
+ public boolean isDisplayButtons()
+ {
+ return displayButtons;
+ }
+
+ void setDisplayButtons(boolean displayButtons)
+ {
+ this.displayButtons = displayButtons;
+ }
+
+ Map<String, Boolean> getConfigMap()
+ {
+ return ImmutableMap.<String, Boolean>builder()
+ .put(EditorConfigConstants.BUTTON_ENTER, buttonEnter)
+ .put(EditorConfigConstants.BUTTON_ESC, buttonEsc)
+ .put(EditorConfigConstants.BUTTON_FUZZY, buttonFuzzy)
+ .put(EditorConfigConstants.BUTTON_UNTRANSLATED, buttonUntranslated)
+ .build();
+ }
+}
View
2  server/zanata-war/src/main/java/org/zanata/webtrans/client/resources/NavigationMessages.java
@@ -75,7 +75,7 @@
String editSaveShortcut();
@DefaultMessage("Save as Approved (Enter)")
- String editSavewithEnterShortcut();
+ String editSaveWithEnterShortcut();
@DefaultMessage("Move to next")
String editMoveToNext();
View
61 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/Editor.java
@@ -1,19 +1,17 @@
package org.zanata.webtrans.client.ui;
-import com.google.common.base.Objects;
-import com.google.gwt.event.dom.client.MouseDownEvent;
import org.zanata.webtrans.client.editor.table.EditorTextArea;
import org.zanata.webtrans.client.editor.table.TableResources;
import org.zanata.webtrans.client.editor.table.TargetContentsDisplay;
import org.zanata.webtrans.client.resources.NavigationMessages;
-import com.allen_sauer.gwt.log.client.Log;
+import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
+import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiBinder;
@@ -23,6 +21,7 @@
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.Widget;
@@ -85,9 +84,8 @@ public Editor(String displayString, String findMessage, int index, final TargetC
this.index = index;
initWidget(uiBinder.createAndBindUi(this));
- saveButton.addClickHandler(acceptHandler);
-
- fuzzyButton.addClickHandler(fuzzyHandler);
+ //determine whether to show or hide buttons
+ showButtons(listener.isDisplayButtons());
label.setText(displayString);
if (displayString == null || displayString.isEmpty())
@@ -177,6 +175,12 @@ private void fireValidationEvent()
}
}
+ @UiHandler("textArea")
+ public void onKeyDown(KeyDownEvent event)
+ {
+ listener.onTextAreaKeyDown(event, this);
+ }
+
@UiHandler("copySourceButton")
public void onCopySource(ClickEvent event)
{
@@ -192,14 +196,14 @@ public void onValidation(ClickEvent event)
@UiHandler("saveButton")
public void onSaveAsApproved(ClickEvent event)
{
- listener.saveAsApproved(this);
+ listener.saveAsApproved(index);
event.stopPropagation();
}
@UiHandler("fuzzyButton")
public void onSaveAsFuzzy(ClickEvent event)
{
- listener.saveAsFuzzy(this);
+ listener.saveAsFuzzy();
event.stopPropagation();
}
@@ -215,8 +219,6 @@ public void onCancel(ClickEvent event)
public void onLabelClick(MouseDownEvent event)
{
listener.toggleView(this);
-// event.stopPropagation();
- // toggleView();
}
@Override
@@ -243,7 +245,7 @@ public void setViewMode(ViewMode viewMode)
fireValidationEvent();
textArea.setFocus(true);
}
- buttons.setVisible(viewMode == ViewMode.EDIT);
+ buttons.setVisible(viewMode == ViewMode.EDIT && listener.isDisplayButtons());
//sync label and text area
label.setText(textArea.getText());
}
@@ -261,28 +263,6 @@ public String getText()
return textArea.getText();
}
- /**
- * The click listener used to save as fuzzy.
- */
- private ClickHandler fuzzyHandler = new ClickHandler()
- {
- public void onClick(ClickEvent event)
- {
- // acceptFuzzyEdit();
- }
- };
-
- /**
- * The click listener used to accept.
- */
- private ClickHandler acceptHandler = new ClickHandler()
- {
- public void onClick(ClickEvent event)
- {
- // saveApprovedAndMoveRow(NavigationType.NextEntry);
- }
- };
-
@Override
public void setSaveButtonTitle(String title)
{
@@ -374,4 +354,17 @@ public int getIndex()
{
return index;
}
+
+ @Override
+ public void showButtons(boolean displayButtons)
+ {
+ copySourceButton.setVisible(displayButtons);
+ buttons.setVisible(getViewMode() == ViewMode.EDIT && displayButtons);
+ }
+
+ @Override
+ public void setAsLastEditor()
+ {
+ saveButton.getUpFace().setImage(new Image(images.cellEditorAccept()));
+ }
}
View
2  server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/Editor.ui.xml
@@ -43,7 +43,7 @@
<g:upFace image="{images.cellEditorValidate}" />
</g:PushButton>
<g:PushButton ui:field="saveButton" styleName="gwt-Button" title="{messages.editMoveToNext}">
- <g:upFace image="{images.cellEditorAccept}" />
+ <g:upFace image="{images.cellEditorMoveDown}" />
</g:PushButton>
<g:PushButton ui:field="fuzzyButton" styleName="gwt-Button" title="{messages.saveAsFuzzy}">
<g:upFace image="{images.cellEditorFuzzy}" />
View
6 server/zanata-war/src/main/java/org/zanata/webtrans/client/ui/ToggleEditor.java
@@ -19,7 +19,11 @@
void addValidationMessagePanel(IsWidget validationMessagePanel);
int getIndex();
-
+
+ void showButtons(boolean displayButtons);
+
+ void setAsLastEditor();
+
static enum ViewMode
{
VIEW, EDIT
View
31 server/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransUnitNavigationView.java
@@ -20,9 +20,6 @@
*/
package org.zanata.webtrans.client.view;
-import java.util.Map;
-
-import org.zanata.webtrans.client.editor.table.TableResources;
import org.zanata.webtrans.client.presenter.TransUnitNavigationPresenter;
import org.zanata.webtrans.client.resources.EditorConfigConstants;
import org.zanata.webtrans.client.resources.NavigationMessages;
@@ -77,25 +74,19 @@ public TransUnitNavigationView(final NavigationMessages messages, final Resource
setFuzzyUntranslatedModeTooltip();
}
- public void setNavModeTooltip(Map<String, Boolean> configMap)
+ public void setNavModeTooltip(boolean fuzzyMode, boolean untranslatedMode)
{
- if (configMap.containsKey(EditorConfigConstants.BUTTON_FUZZY) && configMap.containsKey(EditorConfigConstants.BUTTON_UNTRANSLATED))
+ if (fuzzyMode && !untranslatedMode)
+ {
+ setFuzzyModeTooltip();
+ }
+ else if (untranslatedMode && !fuzzyMode)
+ {
+ setUntranslatedModeTooltip();
+ }
+ else if (untranslatedMode && fuzzyMode)
{
- boolean fuzzyMode = configMap.get(EditorConfigConstants.BUTTON_FUZZY);
- boolean untranslatedMode = configMap.get(EditorConfigConstants.BUTTON_UNTRANSLATED);
-
- if (fuzzyMode && !untranslatedMode)
- {
- setFuzzyModeTooltip();
- }
- else if (untranslatedMode && !fuzzyMode)
- {
- setUntranslatedModeTooltip();
- }
- else if (untranslatedMode && fuzzyMode)
- {
- setFuzzyUntranslatedModeTooltip();
- }
+ setFuzzyUntranslatedModeTooltip();
}
}
View
BIN  ...in/resources/org/zanata/webtrans/images/crystal_project/_16x16/actions/move_task_down.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  ...ata-war/src/test/java/org/zanata/webtrans/client/presenter/OptionsPanelPresenterTest.java
@@ -656,6 +656,6 @@ private void verifyAllMocks()
*/
private OptionsPanelPresenter newOptionsPanelPresenter()
{
- return new OptionsPanelPresenter(mockDisplay, mockEventBus, mockValidationDetailsPresenter, mockWorkspaceContext);
+ return new OptionsPanelPresenter(mockDisplay, mockEventBus, mockValidationDetailsPresenter, mockWorkspaceContext, new UserConfigHolder());
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.