From 1608f2699a7cdd2d8b4b70ff4a734b38fb94f8f8 Mon Sep 17 00:00:00 2001 From: James Ni Date: Wed, 6 Jul 2011 15:37:11 +0800 Subject: [PATCH] implicit save(hide save button by default, make it visible when start typing or copy src, save as approved, save on exit) --- .../editor/table/InlineTargetCellEditor.java | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java b/server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java index 9d888409fe..ffddce694f 100644 --- a/server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java +++ b/server/zanata-war/src/main/java/org/zanata/webtrans/client/editor/table/InlineTargetCellEditor.java @@ -77,6 +77,7 @@ public void onClick(ClickEvent event) textArea.setText(cellValue.getSource()); textArea.setFocus(true); autoSize(); + showSaveButton(); Log.info("InlineTargetCellEditor.java: Clone action."); } }; @@ -102,10 +103,12 @@ public void onClick(ClickEvent event) public void onClick(ClickEvent event) { cancelEdit(); + hideSaveButton(); } }; private final CheckBox toggleFuzzy; + private final PushButton acceptButton; /** * The click listener used to accept. @@ -115,7 +118,7 @@ public void onClick(ClickEvent event) public void onClick(ClickEvent event) { acceptEdit(); - gotoNextRow(curRow); + // gotoNextRow(curRow); } }; @@ -218,8 +221,10 @@ public void onKeyUp(KeyUpEvent event) // NB: if you change these, please change NavigationConsts too! if (event.isControlKeyDown() && keyCode == KeyCodes.KEY_ENTER) { - acceptEdit(); - gotoNextRow(curRow); + // only when accept button is visible, the shortcuts is available + if (acceptButton.isVisible()) + acceptEdit(); + // gotoNextRow(curRow); } else if (keyCode == KeyCodes.KEY_ESCAPE) { @@ -271,9 +276,9 @@ else if (event.isAltKeyDown() && keyCode == KEY_N) } else if (!event.isAltKeyDown() && !event.isControlKeyDown()) { - // remove fuzzy state when typing and not pressing alt and ctrl - // key + // remove fuzzy state and show save button when start typing removeFuzzyState(); + showSaveButton(); } autoSize(); @@ -320,9 +325,10 @@ else if (!event.isAltKeyDown() && !event.isControlKeyDown()) cancelButton.setTitle(messages.editCancelShortcut()); operationsPanel.add(cancelButton); - PushButton acceptButton = new PushButton(images.cellEditorAccept().createImage(), acceptHandler); + acceptButton = new PushButton(images.cellEditorAccept().createImage(), acceptHandler); acceptButton.setText(messages.editSave()); acceptButton.setTitle(messages.editSaveShortcut()); + acceptButton.setVisible(false); operationsPanel.add(acceptButton); } @@ -460,8 +466,10 @@ protected void acceptEdit() if (cellValue.getTarget().isEmpty()) cellValue.setStatus(ContentState.New); else - cellValue.setStatus(toggleFuzzy.getValue() ? ContentState.NeedReview : ContentState.Approved); + // mark the content as approved + cellValue.setStatus(ContentState.Approved); restoreView(); + hideSaveButton(); // Send the new cell value to the callback curCallback.onComplete(curCellEditInfo, cellValue); @@ -551,6 +559,18 @@ public void removeFuzzyState() toggleFuzzy.setValue(false); } + private void showSaveButton() + { + if (!acceptButton.isVisible()) + acceptButton.setVisible(true); + } + + private void hideSaveButton() + { + if (acceptButton.isVisible()) + acceptButton.setVisible(false); + } + public void autoSize() { int initialLines = 3;