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

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix: save as fuzzy leaves editor open: https://bugzilla.redhat.com/sh…
  • Loading branch information
Alex Eng committed Oct 20, 2011
1 parent 386c492 commit 0085dc7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 21 deletions.
Expand Up @@ -201,6 +201,7 @@ public void onFocus(FocusEvent event)
}
});

// KeyDown is used to override browser event
textArea.addKeyDownHandler(new KeyDownHandler()
{
@Override
Expand Down Expand Up @@ -532,6 +533,7 @@ else if (cellValue.getStatus() == ContentState.New)
restoreView();
textArea.setFocus(false);
isOpened = false;
isFocused = false;

// Send the new cell value to the callback
curCallback.onComplete(curCellEditInfo, cellValue);
Expand Down Expand Up @@ -578,6 +580,32 @@ public void cancelEdit()
clearSelection();
}

public void cancelEdit(boolean closeEditor)
{
// Fire the event
if (!onCancel())
{
return;
}

if (closeEditor)
{
restoreView();
textArea.setFocus(false);
}
isOpened = false;
isFocused = false;

// Call the callback
if (curCallback != null)
{
// curCallback.onCancel(curCellEditInfo);
cancelCallback.onCancel(cellValue);
}

clearSelection();
}

public void clearSelection()
{
curCallback = null;
Expand Down
Expand Up @@ -335,12 +335,8 @@ public void onTransUnitUpdated(TransUnitUpdatedEvent event)
// TODO this test never succeeds
if (selectedTransUnit != null && selectedTransUnit.getId().equals(event.getTransUnit().getId()))
{
// handle change in current selection
// eventBus.fireEvent(new NotificationEvent(Severity.Warning,
// "Someone else updated this translation unit. you're in trouble..."));
// display.getTableModel().setRowValue(row, rowValue);
Log.info("selected TU updated; cancelling edit");
display.getTargetCellEditor().cancelEdit();
// Log.info("selected TU updated; cancelling edit");
// display.getTargetCellEditor().cancelEdit(false);

// TODO reload page and return
}
Expand Down Expand Up @@ -522,19 +518,7 @@ public void onPreviewNativeEvent(NativePreviewEvent event)

if (event.getNativeEvent().getType().equals("keyup"))
{
if (checkKey.isPreviousEntryKey())
{
Log.info("Go to previous entry");
stopDefaultAction(event);
tableModelHandler.gotoPrevRow(false);
}
else if (checkKey.isNextEntryKey())
{
Log.info("Go to next entry");
stopDefaultAction(event);
tableModelHandler.gotoNextRow(false);
}
else if (checkKey.isCopyFromSourceKey())
if (checkKey.isCopyFromSourceKey())
{
if (selectedTransUnit != null)
{
Expand All @@ -557,6 +541,21 @@ else if (checkKey.isEnterKey())
}
}
}
if (event.getNativeEvent().getType().equals("keydown"))
{
if (checkKey.isPreviousEntryKey())
{
Log.info("Go to previous entry");
stopDefaultAction(event);
tableModelHandler.gotoPrevRow(false);
}
else if (checkKey.isNextEntryKey())
{
Log.info("Go to next entry");
stopDefaultAction(event);
tableModelHandler.gotoNextRow(false);
}
}
}
}
});
Expand Down Expand Up @@ -666,8 +665,12 @@ public void onCancel(TransUnit rowValue)
public void updatePageAndRowIndex()
{
curPage = display.getCurrentPage();
updateRowIndex(curPage);
}

// Convert row number to row Index in table
@Override
public void updateRowIndex(int curPage)
{
curRowIndex = curPage * TableConstants.PAGE_SIZE + display.getSelectedRowNumber();
Log.info("Current Row Index" + curRowIndex);
}
Expand Down Expand Up @@ -1083,7 +1086,7 @@ public DocumentId getDocumentId()
*/
public void selectTransUnit(TransUnit transUnit)
{
tableModelHandler.updatePageAndRowIndex();
tableModelHandler.updateRowIndex(display.getCurrentPage());
if (selectedTransUnit == null || !transUnit.getId().equals(selectedTransUnit.getId()))
{
selectedTransUnit = transUnit;
Expand Down
Expand Up @@ -47,4 +47,5 @@ protected boolean onRowRemoved(int row)

abstract void updatePageAndRowIndex();

abstract void updateRowIndex(int curPage);
}

0 comments on commit 0085dc7

Please sign in to comment.