This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implicit save(hide save button by default, make it visible when start…
… typing or copy src, save as approved, save on exit)
- Loading branch information
Showing
1 changed file
with
27 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
/** | ||
* 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); | ||
This comment has been minimized.
Sorry, something went wrong.
seanf
Contributor
|
||
} | ||
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; | ||
|
I think "saveButton" is more understandable, and it fits in with your other method names.