Search in sources :

Example 6 with HandlerRegistration

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);
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) ActivePartChangedHandler(org.eclipse.che.ide.api.event.ActivePartChangedHandler) Call(org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.Call) CallbackPromiseHelper.createFromCallback(org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.createFromCallback) Callback(com.google.gwt.core.client.Callback) ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Example 7 with HandlerRegistration

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);
    }
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) DocumentHandle(org.eclipse.che.ide.api.editor.document.DocumentHandle)

Example 8 with 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);
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration)

Example 9 with HandlerRegistration

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;
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) AnchorListItem(org.gwtbootstrap3.client.ui.AnchorListItem)

Example 10 with HandlerRegistration

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;
}
Also used : HandlerRegistration(com.google.web.bindery.event.shared.HandlerRegistration) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FileReader(com.googlecode.gwtphonegap.client.file.FileReader)

Aggregations

HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)10 Callback (com.google.gwt.core.client.Callback)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 FileReader (com.googlecode.gwtphonegap.client.file.FileReader)1 Call (org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.Call)1 CallbackPromiseHelper.createFromCallback (org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.createFromCallback)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 DocumentHandle (org.eclipse.che.ide.api.editor.document.DocumentHandle)1 ActivePartChangedEvent (org.eclipse.che.ide.api.event.ActivePartChangedEvent)1 ActivePartChangedHandler (org.eclipse.che.ide.api.event.ActivePartChangedHandler)1 AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)1 BookmarkListGroupItem (org.ovirt.engine.ui.webadmin.widget.bookmark.BookmarkListGroupItem)1