package lib.morkim.mfw.ui;

import java.util.Observable;
import java.util.Observer;

import lib.morkim.mfw.app.AppContext;
import lib.morkim.mfw.app.MorkimApp;
import lib.morkim.mfw.domain.Model;
import lib.morkim.mfw.usecase.UseCase;
import lib.morkim.mfw.usecase.UseCaseProgress;
import lib.morkim.mfw.usecase.UseCaseResult;
import lib.morkim.mfw.usecase.UseCaseStateListener;

public abstract class Presenter implements Observer, UseCaseStateListener {

	private AppContext appContext;
	protected Viewable viewable;

	public Presenter(Viewable viewable) {
		
		this.viewable = viewable;
	}
	
	void initialize(AppContext appContext) {

		this.appContext = appContext;
	}

	public void unbindViewModel() {

//		viewModel.unregister();
	}

	public void bindViewModel(Viewable viewable) {

//		viewModel.register(viewable);
//		viewModel.notifyView();
	}

	@Override
	public void update(Observable observable, Object data) {
		synchronized (this) {
//			onUpdate(observable, data, viewModel);
//			if (viewModel.hasListener())
//				viewModel.notifyUiView();
		}
	}

	protected void onUpdate(Observable observable, Object data,
			ViewModel viewModel) {
	}

//	public ViewModel getViewModel() {
//		return viewModel;
//	}
//
//	public void setViewModel(ViewModel viewModel) {
//		this.viewModel = viewModel;
//	}

	protected Controller getController() {
		return viewable.getController();
	}

	public AppContext getAppContext() {
		return appContext;
	}

	public void setAppContext(AppContext appContext) {
		this.appContext = appContext;
	}

	protected String string(int resource) {
		return ((MorkimApp) appContext).getString(resource);
	}

	protected String string(int resource, Object ... args) {
		return ((MorkimApp) appContext).getString(resource, args);
	}
	
	protected Model getModel() {
		return appContext.getModel();
	}

	@Override
	public void onUseCaseStart(UseCase useCase) {}

	@Override
	public void onUseCaseUpdate(UseCaseProgress response) {}

	@Override
	public void onUseCaseComplete(UseCaseResult response) {}

	@Override
	public void onUseCaseCancel() {}
}
@@ -587,56 +587,8 @@
 le;%0A
-%09%7D%0A%09%0A%09void initialize(AppContext appContext) %7B%0A%0A
 %09%09th
@@ -599,34 +599,51 @@
 ppContext = 
-app
+viewable.getMorkim
 Context
+()
 ;%0A%09%7D%0A%0A%09publi

Remove view model in presenter