Package org.mbhcare.client.presenter

Source Code of org.mbhcare.client.presenter.DiagnosisPresenter

/**
*
*/
package org.mbhcare.client.presenter;

import org.mbhcare.client.view.diagnosis.DiagnosisEditViewImpl;
import org.mbhcare.client.view.diagnosis.DiagnosisListViewImpl;
import org.mbhcare.client.view.diagnosis.DiagnosisView;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.HasWidgets;

/**
* @author MCOSTA
*
*/
public class DiagnosisPresenter implements Presenter, DiagnosisView.Presenter{
 
private static final String VIEW = MainPresenter.VIEW_DIAGNOSIS;
 
  private static DiagnosisListViewImpl diagnosisListView = null;
  private static DiagnosisEditViewImpl diagnosisEditView = null
 
  private final DiagnosisView view;

  /**
   * @param view
   */
  public DiagnosisPresenter(DiagnosisView view) {
    this.view = view;
  }


  @Override
  public void go(final HasWidgets container) {
    container.clear();
    container.add(view.asWidget());
   
    processHistoryToken();
  }
 
  public void processHistoryToken() {
    String token = History.getToken();
   
    if(token != null) {
      if (token.startsWith(VIEW + "/edit")) {
        String[] parts = token.split("/");
        String id = null;
       
        if(diagnosisEditView == null)
          diagnosisEditView = new DiagnosisEditViewImpl();
       
        // is a edit statement?
        if(parts.length > 3) id = parts[parts.length - 1];
       
        new DiagnosisEditPresenter(diagnosisEditView, id).
          go(view.getContent());
     
      } else if (token.startsWith(VIEW + "/new")) {//invoked from patient screen
        String[] parts = token.split("/");
        String id = null;
       
        if(diagnosisEditView == null)
          diagnosisEditView = new DiagnosisEditViewImpl();
       
        // is a edit statement?
        if(parts.length > 3) id = parts[parts.length - 1];
       
        new DiagnosisEditPresenter(diagnosisEditView, null, id).
          go(view.getContent());
       
      } else {
        if(diagnosisListView == null)
          diagnosisListView = new DiagnosisListViewImpl();
       
        new DiagnosisListPresenter(diagnosisListView).
          go(view.getContent());
      }
    }
  }
}
TOP

Related Classes of org.mbhcare.client.presenter.DiagnosisPresenter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.