use of org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler in project rstudio by rstudio.
the class TextEditingTarget method onRenameInScope.
@Handler
void onRenameInScope() {
docDisplay_.focus();
// Save folds (we need to remove them temporarily for the rename helper)
final JsArray<AceFold> folds = docDisplay_.getFolds();
docDisplay_.unfoldAll();
int matches = renameHelper_.renameInScope();
if (matches <= 0) {
if (!docDisplay_.getSelectionValue().isEmpty()) {
String message = "No matches for '" + docDisplay_.getSelectionValue() + "'";
view_.getStatusBar().showMessage(message, 1000);
}
for (AceFold fold : JsUtil.asIterable(folds)) docDisplay_.addFold(fold.getRange());
return;
}
String message = "Found " + matches;
if (matches == 1)
message += " match";
else
message += " matches";
String selectedItem = docDisplay_.getSelectionValue();
message += " for " + selectedItem + ".";
docDisplay_.disableSearchHighlight();
view_.getStatusBar().showMessage(message, new HideMessageHandler() {
private boolean onRenameFinished(boolean value) {
for (AceFold fold : JsUtil.asIterable(folds)) docDisplay_.addFold(fold.getRange());
return value;
}
@Override
public boolean onNativePreviewEvent(NativePreviewEvent preview) {
int type = preview.getTypeInt();
if (docDisplay_.isPopupVisible())
return false;
// End if the user clicks somewhere
if (type == Event.ONCLICK) {
docDisplay_.exitMultiSelectMode();
docDisplay_.clearSelection();
docDisplay_.enableSearchHighlight();
return onRenameFinished(true);
} else // Otherwise, handle key events
if (type == Event.ONKEYDOWN) {
switch(preview.getNativeEvent().getKeyCode()) {
case KeyCodes.KEY_ENTER:
preview.cancel();
case KeyCodes.KEY_UP:
case KeyCodes.KEY_DOWN:
case KeyCodes.KEY_ESCAPE:
docDisplay_.exitMultiSelectMode();
docDisplay_.clearSelection();
docDisplay_.enableSearchHighlight();
return onRenameFinished(true);
}
}
return false;
}
});
}
Aggregations