package org.sagebionetworks.web.client.view;

import org.sagebionetworks.web.client.context.SynapseContextPropsProvider;
import org.sagebionetworks.web.client.jsinterop.EmptyProps;
import org.sagebionetworks.web.client.jsinterop.React;
import org.sagebionetworks.web.client.jsinterop.ReactDOM;
import org.sagebionetworks.web.client.jsinterop.ReactElement;
import org.sagebionetworks.web.client.jsinterop.SRC;
import org.sagebionetworks.web.client.presenter.OAuthClientEditorPresenter;
import org.sagebionetworks.web.client.widget.ReactComponentDiv;
import org.sagebionetworks.web.client.widget.header.Header;

import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

public class OAuthClientEditorViewImpl implements OAuthClientEditorView {
    ReactComponentDiv container;
    public interface OAuthClientEditorViewImplUiBinder extends UiBinder<Widget, OAuthClientEditorViewImpl>{}

    private OAuthClientEditorPresenter presenter;
    private SynapseContextPropsProvider propsProvider;
    private Header headerWidget;

    Widget widget;

    @Inject
    public OAuthClientEditorViewImpl(OAuthClientEditorViewImplUiBinder binder, Header headerWidget, SynapseContextPropsProvider propsProvider) {
        container = new ReactComponentDiv();
        widget = binder.createAndBindUi(this);
        this.headerWidget = headerWidget;
        this.propsProvider = propsProvider;
        headerWidget.configure();
    }

    @Override
    public void setPresenter(OAuthClientEditorPresenter presenter) {
        this.presenter =presenter;
        headerWidget.configure();
        headerWidget.refresh();
        Window.scrollTo(0,0);
        render();
    }

    @Override
    public Widget asWidget() { return container.asWidget(); }

    @Override
    public void render() {
        EmptyProps props = EmptyProps.create();
        ReactElement component = React.createElementWithSynapseContext(SRC.SynapseComponents.OAuthManagement, props, propsProvider.getJsInteropContextProps());
        ReactDOM.render(component, container.getElement());
    }
}

@@ -607,56 +607,8 @@
 r;%0A%0A
-import com.google.gwt.uibinder.client.UiBinder;%0A
 impo
@@ -834,117 +834,8 @@
 ner;
-%0A    public interface OAuthClientEditorViewImplUiBinder extends UiBinder%3CWidget, OAuthClientEditorViewImpl%3E%7B%7D
 %0A%0A  
@@ -975,28 +975,8 @@
 t;%0A%0A
-    Widget widget;%0A%0A
     
@@ -1024,50 +1024,8 @@
 mpl(
-OAuthClientEditorViewImplUiBinder binder, 
 Head
@@ -1135,55 +1135,8 @@
 ();%0A
-        widget = binder.createAndBindUi(this);%0A
     

remove binder