← Back to team overview

dhis-mobile-devs team mailing list archive

[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 154: add missing file

 

------------------------------------------------------------
revno: 154
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: lwuit-tracking
timestamp: Tue 2013-09-24 14:33:57 +0700
message:
  add missing file
added:
  src/org/hisp/dhis/mobile/view/PersonRegistrationProgramSelectView.java


--
lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking
https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking

Your team DHIS mobile developers is subscribed to branch lp:~dhis-mobile-devs/dhis-mobile/lwuit-tracking.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis-mobile-devs/dhis-mobile/lwuit-tracking/+edit-subscription
=== added file 'src/org/hisp/dhis/mobile/view/PersonRegistrationProgramSelectView.java'
--- src/org/hisp/dhis/mobile/view/PersonRegistrationProgramSelectView.java	1970-01-01 00:00:00 +0000
+++ src/org/hisp/dhis/mobile/view/PersonRegistrationProgramSelectView.java	2013-09-24 07:33:57 +0000
@@ -0,0 +1,134 @@
+package org.hisp.dhis.mobile.view;
+
+import java.util.Vector;
+
+import org.hisp.dhis.mobile.connection.ConnectionManager;
+import org.hisp.dhis.mobile.midlet.DHISMIDlet;
+import org.hisp.dhis.mobile.midlet.NameBasedMIDlet;
+import org.hisp.dhis.mobile.model.LinkButton;
+import org.hisp.dhis.mobile.recordstore.PatientAttributeRecordStore;
+import org.hisp.dhis.mobile.recordstore.PatientIdentifierRecordStore;
+import org.hisp.dhis.mobile.ui.Text;
+
+import com.sun.lwuit.Command;
+import com.sun.lwuit.Form;
+import com.sun.lwuit.animations.CommonTransitions;
+import com.sun.lwuit.events.ActionEvent;
+import com.sun.lwuit.events.ActionListener;
+import com.sun.lwuit.layouts.BoxLayout;
+
+public class PersonRegistrationProgramSelectView
+    extends AbstractView
+    implements ActionListener
+{
+    private Form mainForm;
+    
+    private Vector programInfos;
+
+    private Command backCommand;
+
+    private NameBasedMIDlet nameBasedMIDlet;
+
+    public PersonRegistrationProgramSelectView( DHISMIDlet dhisMIDlet )
+    {
+        super( dhisMIDlet );
+        this.nameBasedMIDlet = (NameBasedMIDlet) this.dhisMIDlet;
+    }
+
+    public void actionPerformed( ActionEvent ae )
+    {
+        if ( ae.getCommand().getCommandName().equals( Text.BACK() ) )
+        {
+            nameBasedMIDlet.getOrgUnitSelectView().setProgramType( "1" );
+            nameBasedMIDlet.getOrgUnitSelectView().showView();
+        }
+    }
+
+    public void prepareView()
+    {
+        System.gc();
+        getMainForm();
+        mainForm.removeAll();
+        
+        for ( int i = 0; i < programInfos.size(); i++ )
+        {
+            String patientInfo = (String) programInfos.elementAt( i );
+
+            final String id = patientInfo.substring( 0, patientInfo.indexOf( "/" ) );
+            String programName = patientInfo.substring( patientInfo.indexOf( "/" ) + 1, patientInfo.length() );
+            
+            LinkButton programLink = new LinkButton( programName );
+            programLink.addActionListener( new ActionListener()
+            {
+                public void actionPerformed( ActionEvent ae )
+                {
+                    nameBasedMIDlet.getWaitingView().showView();
+                    try
+                    {
+                        if ( PatientIdentifierRecordStore.loadPatientIdentifiers().size() == 0
+                            && PatientAttributeRecordStore.loadPatientAttribute().size() == 0 )
+                        {
+                            ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
+                            ConnectionManager.getVariesInfo( String.valueOf( id ) );
+                        }
+                        else
+                        {
+                            ConnectionManager.setUrl( nameBasedMIDlet.getCurrentOrgUnit().getGetVariesInfoUrl() );
+                            nameBasedMIDlet.getPersonRegistrationView().prepareView();
+                            nameBasedMIDlet.getPersonRegistrationView().showView();
+                        }
+                    }
+                    catch ( Exception e )
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            });
+            mainForm.addComponent( programLink );
+        }
+    }
+
+    public void showView()
+    {
+        prepareView();
+        mainForm.show();
+    }
+
+    public Command getBackCommand()
+    {
+        if ( backCommand == null )
+        {
+            backCommand = new Command( Text.BACK() );
+        }
+        return backCommand;
+    }
+
+    public Form getMainForm()
+    {
+        if ( mainForm == null )
+        {
+            mainForm = new Form( "Select Program" );
+            mainForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
+            mainForm.setTransitionOutAnimator( CommonTransitions.createSlide(
+                CommonTransitions.SLIDE_HORIZONTAL, true, 200 ) );
+            mainForm.addCommandListener( this );
+            mainForm.addCommand( new Command( "Back" ) );
+        }
+        return mainForm;
+    }
+
+    public void setMainForm( Form mainForm )
+    {
+        this.mainForm = mainForm;
+    }
+
+    public Vector getProgramInfos()
+    {
+        return programInfos;
+    }
+
+    public void setProgramInfos( Vector programInfos )
+    {
+        this.programInfos = programInfos;
+    }
+}