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

Commit

Permalink
implicit save(hide save button by default, make it visible when start…
Browse files Browse the repository at this point in the history
… typing or copy src, save as approved, save on exit)
  • Loading branch information
jamesni committed Jul 6, 2011
1 parent f2ae513 commit 1608f26
Showing 1 changed file with 27 additions and 7 deletions.
Expand Up @@ -77,6 +77,7 @@ public void onClick(ClickEvent event)
textArea.setText(cellValue.getSource());
textArea.setFocus(true);
autoSize();
showSaveButton();
Log.info("InlineTargetCellEditor.java: Clone action.");
}
};
Expand All @@ -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.

Copy link
@seanf

seanf Jul 6, 2011

Contributor

I think "saveButton" is more understandable, and it fits in with your other method names.


/**
* The click listener used to accept.
Expand All @@ -115,7 +118,7 @@ public void onClick(ClickEvent event)
public void onClick(ClickEvent event)
{
acceptEdit();
gotoNextRow(curRow);
// gotoNextRow(curRow);
}
};

Expand Down Expand Up @@ -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.

Copy link
@seanf

seanf Jul 6, 2011

Contributor

I think we should go to the next row, even if there are no changes to save.

}
else if (keyCode == KeyCodes.KEY_ESCAPE)
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1608f26

Please sign in to comment.