use of com.google.web.bindery.event.shared.HandlerRegistration in project che by eclipse.
the class OpenFileAction method promise.
@Override
public Promise<Void> promise(final ActionEvent actionEvent) {
if (actionEvent.getParameters() == null) {
return Promises.reject(JsPromiseError.create(localization.canNotOpenFileWithoutParams()));
}
final String pathToOpen = actionEvent.getParameters().get(FILE_PARAM_ID);
if (pathToOpen == null) {
return Promises.reject(JsPromiseError.create(localization.fileToOpenIsNotSpecified()));
}
final Call<Void, Throwable> call = new Call<Void, Throwable>() {
HandlerRegistration handlerRegistration;
@Override
public void makeCall(final Callback<Void, Throwable> callback) {
actionCompletedCallback = callback;
handlerRegistration = eventBus.addHandler(ActivePartChangedEvent.TYPE, new ActivePartChangedHandler() {
@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
if (event.getActivePart() instanceof EditorPartPresenter) {
EditorPartPresenter editor = (EditorPartPresenter) event.getActivePart();
handlerRegistration.removeHandler();
if (Path.valueOf(pathToOpen).equals(editor.getEditorInput().getFile().getLocation())) {
callback.onSuccess(null);
}
}
}
});
actionPerformed(actionEvent);
}
};
return createFromCallback(call);
}
use of com.google.web.bindery.event.shared.HandlerRegistration in project che by eclipse.
the class EditorGroupSynchronizationImpl method addEditor.
@Override
public void addEditor(EditorPartPresenter editor) {
DocumentHandle documentHandle = getDocumentHandleFor(editor);
if (documentHandle != null) {
HandlerRegistration handlerRegistration = documentHandle.getDocEventBus().addHandler(DocumentChangeEvent.TYPE, this);
synchronizedEditors.put(editor, handlerRegistration);
}
}
use of com.google.web.bindery.event.shared.HandlerRegistration in project webprotege by protegeproject.
the class HandlerRegistrationManager method registerHandler.
/**
*/
public <H> void registerHandler(Event.Type<H> type, H handler) {
HandlerRegistration registration = eventBus.addHandler(type, handler);
addHandlerRegistration(registration);
}
use of com.google.web.bindery.event.shared.HandlerRegistration in project ovirt-engine by oVirt.
the class SearchPanelView method addAvailableBookmarks.
@Override
public HandlerRegistration addAvailableBookmarks(Bookmark bookmark, ClickHandler handler) {
AnchorListItem bookmarkItem = new AnchorListItem();
bookmarkItem.setText(bookmark.getName());
HandlerRegistration registration = bookmarkItem.addClickHandler(handler);
searchBoxBookmarkListDropDown.add(bookmarkItem);
searchBoxBookmarkListDropDownButton.setEnabled(searchBoxBookmarkListDropDown.getWidgetCount() > 0);
return registration;
}
use of com.google.web.bindery.event.shared.HandlerRegistration in project gwtphonegap by dankurka.
the class CameraBrowserFileInput method getPicture.
@Override
public CameraPopoverHandle getPicture(final PictureOptions options, final PictureCallback callback) {
if (!input.isAttached()) {
callback.onFailure("after #cleanUp(), this instance is no longer useful");
return popoverHandle;
}
@SuppressWarnings("unused") final ChangeHandler handler = new ChangeHandler() {
private final HandlerRegistration reg = input.addChangeHandler(this);
@Override
public void onChange(ChangeEvent event) {
reg.removeHandler();
if (options.getDestinationType() == PictureOptions.DESTINATION_TYPE_DATA_URL) {
getBase64(new ReaderCallback<FileReader>() {
@Override
public void onCallback(FileReader result) {
callback.onSuccess(result.getResult());
}
});
} else {
callback.onSuccess(getFileUri());
}
}
};
open(input.getElement());
return popoverHandle;
}
Aggregations