dhis-mobile-devs team mailing list archive
-
dhis-mobile-devs team
-
Mailing list archive
-
Message #00437
[Branch ~dhis-mobile-devs/dhis-mobile/lwuit-tracking] Rev 242: Add a create new event button
------------------------------------------------------------
revno: 242
committer: sherylyn.marie
branch nick: lwuit-tracking
timestamp: Mon 2014-11-03 10:28:04 +0800
message:
Add a create new event button
modified:
src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java
src/org/hisp/dhis/mobile/ui/Text.java
src/org/hisp/dhis/mobile/view/ProgramStageListView.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
=== modified file 'src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java'
--- src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java 2014-06-24 03:59:44 +0000
+++ src/org/hisp/dhis/mobile/midlet/NameBasedMIDlet.java 2014-11-03 02:28:04 +0000
@@ -24,6 +24,7 @@
import org.hisp.dhis.mobile.model.ProgramStage;
import org.hisp.dhis.mobile.view.AddingRelationshipView;
import org.hisp.dhis.mobile.view.AnonymousProgramListView;
+import org.hisp.dhis.mobile.view.CreateProgramStageView;
import org.hisp.dhis.mobile.view.DashboardLinkView;
import org.hisp.dhis.mobile.view.FeedbackContentView;
import org.hisp.dhis.mobile.view.FeedbackView;
@@ -69,6 +70,8 @@
private FindBeneficiaryView findBeneficiaryView;
private PersonDashboardView personDashboardView;
+
+ private CreateProgramStageView createProgramStageView;
private TrackingDataEntryView trackingDataEntryView;
@@ -190,6 +193,15 @@
}
return personDashboardView;
}
+
+ public CreateProgramStageView getCreateProgramStageView()
+ {
+ if ( createProgramStageView == null )
+ {
+ createProgramStageView = new CreateProgramStageView( this );
+ }
+ return createProgramStageView;
+ }
public TrackingDataEntryView getTrackingDataEntryView()
{
=== modified file 'src/org/hisp/dhis/mobile/ui/Text.java'
--- src/org/hisp/dhis/mobile/ui/Text.java 2014-10-29 08:50:00 +0000
+++ src/org/hisp/dhis/mobile/ui/Text.java 2014-11-03 02:28:04 +0000
@@ -688,4 +688,8 @@
public static String ADD_NEW_INSTANCE() {
return get((short) 151, "Add New Instance");
}
+
+ public static String CREATE_NEW_EVENT() {
+ return get((short) 152, "Create new event");
+ }
}
=== modified file 'src/org/hisp/dhis/mobile/view/ProgramStageListView.java'
--- src/org/hisp/dhis/mobile/view/ProgramStageListView.java 2014-10-27 08:15:42 +0000
+++ src/org/hisp/dhis/mobile/view/ProgramStageListView.java 2014-11-03 02:28:04 +0000
@@ -10,6 +10,7 @@
import org.hisp.dhis.mobile.model.Program;
import org.hisp.dhis.mobile.model.ProgramInstance;
import org.hisp.dhis.mobile.model.ProgramStage;
+import org.hisp.dhis.mobile.recordstore.ProgramRecordStore;
import org.hisp.dhis.mobile.ui.Text;
import com.sun.lwuit.Command;
@@ -24,167 +25,226 @@
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.Style;
-public class ProgramStageListView extends AbstractView implements
- ActionListener {
- private static final String CLASS_TAG = "ProgramStageListView";
- private NameBasedMIDlet nameBasedMIDlet;
-
- private Form personProgramStageListForm;
-
- private Command backCommand;
-
- private Patient patient;
-
- private Program program;
-
- private ProgramInstance programInstance;
-
- public ProgramStageListView(DHISMIDlet dhisMIDlet) {
- super(dhisMIDlet);
- this.nameBasedMIDlet = (NameBasedMIDlet) dhisMIDlet;
- }
-
- public void prepareView() {
- System.gc();
- getPersonProgramStageListForm();
- personProgramStageListForm.removeAll();
-
- Style labelStyle = new Style();
- labelStyle.setBgColor(0xcccccc);
-
- this.prepareProgramStageList();
-
- }
-
- public void prepareProgramStageList() {
- for (int j = 0; j < programInstance.getProgramStageInstances().size(); j++) {
- final ProgramStage programStage = (ProgramStage) programInstance
- .getProgramStageInstances().elementAt(j);
- if (programStage.isSingleEvent() == false) {
- String programStageText = programStage.getName();
-
- if (!programStage.getReportDate().equals("")) {
- programStageText += " (" + programStage.getReportDate()
- + ")";
- } else if (!programStage.getDueDate().equals("")) {
- programStageText += " (" + programStage.getDueDate() + ")";
- }
- LinkButton programStageLink = new LinkButton(programStageText);
- if (programStage.isCompleted()) {
- try {
- Image image = Image.createImage("/sent.gif");
- Label sentLabel = new Label(image);
-
- Container c = new Container(new BorderLayout());
- c.addComponent(BorderLayout.CENTER, programStageLink);
- c.addComponent(BorderLayout.EAST, sentLabel);
-
- personProgramStageListForm.addComponent(c);
- } catch (IOException e) {
- LogMan.log("UI," + CLASS_TAG, e);
- e.printStackTrace();
- }
- } else {
- personProgramStageListForm.addComponent(programStageLink);
- }
- programStageLink.addActionListener(new ActionListener() {
-
- public void actionPerformed(ActionEvent arg0) {
- if (programStage.getSections().size() > 0) {
- nameBasedMIDlet.getSectionListView().setPatient(
- patient);
- nameBasedMIDlet.getSectionListView()
- .setProgramStage(programStage);
- nameBasedMIDlet.getSectionListView().showView();
- } else {
- nameBasedMIDlet.getTrackingDataEntryView()
- .setPatient(patient);
- nameBasedMIDlet.getTrackingDataEntryView()
- .setProgramStage(programStage);
- nameBasedMIDlet.getTrackingDataEntryView()
- .setTitle(programStage.getName());
- nameBasedMIDlet.getTrackingDataEntryView()
- .showView();
- }
-
- }
- });
- }
- }
- System.gc();
- }
-
- public void showView() {
- this.prepareView();
- this.getPersonProgramStageListForm().show();
-
- }
-
- public Form getPersonProgramStageListForm() {
- if (personProgramStageListForm == null) {
- personProgramStageListForm = new Form("Program Stages");
- personProgramStageListForm
- .setLayout(new BoxLayout(BoxLayout.Y_AXIS));
- personProgramStageListForm.setScrollableY(true);
- personProgramStageListForm
- .setTransitionOutAnimator(CommonTransitions.createSlide(
- CommonTransitions.SLIDE_HORIZONTAL, true, 200));
- personProgramStageListForm.addCommand(this.getBackCommand());
- personProgramStageListForm.addCommandListener(this);
-
- }
- return personProgramStageListForm;
- }
-
- public void setPersonProgramStageListForm(Form personProgramStageListForm) {
- this.personProgramStageListForm = personProgramStageListForm;
- }
-
- public void actionPerformed(ActionEvent ae) {
- if (ae.getCommand().getCommandName().equals(Text.BACK())) {
- nameBasedMIDlet.getPersonDashboardView().setPatient(patient);
- nameBasedMIDlet.getPersonDashboardView().showView();
-
- personProgramStageListForm = null;
- backCommand = null;
- patient = null;
- System.gc();
- }
- }
-
- public Command getBackCommand() {
- if (backCommand == null) {
- backCommand = new Command(Text.BACK());
- }
- return backCommand;
- }
-
- public void setBackCommand(Command backCommand) {
- this.backCommand = backCommand;
- }
-
- public Patient getPatient() {
- return patient;
- }
-
- public void setPatient(Patient patient) {
- this.patient = patient;
- }
-
- public Program getProgram() {
- return program;
- }
-
- public void setProgram(Program program) {
- this.program = program;
- }
-
- public ProgramInstance getProgramInstance() {
- return programInstance;
- }
-
- public void setProgramInstance(ProgramInstance programInstance) {
- this.programInstance = programInstance;
- }
+public class ProgramStageListView
+ extends AbstractView
+ implements ActionListener
+{
+ private static final String CLASS_TAG = "ProgramStageListView";
+
+ private NameBasedMIDlet nameBasedMIDlet;
+
+ private Form personProgramStageListForm;
+
+ private Command backCommand;
+
+ private Command addCommand;
+
+ private Patient patient;
+
+ private Program program;
+
+ private ProgramInstance programInstance;
+
+ public ProgramStageListView( DHISMIDlet dhisMIDlet )
+ {
+ super( dhisMIDlet );
+ this.nameBasedMIDlet = (NameBasedMIDlet) dhisMIDlet;
+ }
+
+ public void prepareView()
+ {
+ System.gc();
+ getPersonProgramStageListForm();
+ personProgramStageListForm.removeAll();
+
+ Style labelStyle = new Style();
+ labelStyle.setBgColor( 0xcccccc );
+
+ this.prepareProgramStageList();
+ }
+
+ public void prepareProgramStageList()
+ {
+ for ( int j = 0; j < programInstance.getProgramStageInstances().size(); j++ )
+ {
+ final ProgramStage programStage = (ProgramStage) programInstance.getProgramStageInstances().elementAt( j );
+ if ( programStage.isSingleEvent() == false )
+ {
+ String programStageText = programStage.getName();
+
+ if ( !programStage.getReportDate().equals( "" ) )
+ {
+ programStageText += " (" + programStage.getReportDate() + ")";
+ }
+ else if ( !programStage.getDueDate().equals( "" ) )
+ {
+ programStageText += " (" + programStage.getDueDate() + ")";
+ }
+ LinkButton programStageLink = new LinkButton( programStageText );
+ if ( programStage.isCompleted() )
+ {
+ try
+ {
+ Image image = Image.createImage( "/sent.gif" );
+ Label sentLabel = new Label( image );
+
+ Container c = new Container( new BorderLayout() );
+ c.addComponent( BorderLayout.CENTER, programStageLink );
+ c.addComponent( BorderLayout.EAST, sentLabel );
+
+ personProgramStageListForm.addComponent( c );
+ }
+ catch ( IOException e )
+ {
+ LogMan.log( "UI," + CLASS_TAG, e );
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ personProgramStageListForm.addComponent( programStageLink );
+ }
+ programStageLink.addActionListener( new ActionListener()
+ {
+
+ public void actionPerformed( ActionEvent arg0 )
+ {
+ if ( programStage.getSections().size() > 0 )
+ {
+ nameBasedMIDlet.getSectionListView().setPatient( patient );
+ nameBasedMIDlet.getSectionListView().setProgramStage( programStage );
+ nameBasedMIDlet.getSectionListView().showView();
+ }
+ else
+ {
+ nameBasedMIDlet.getTrackingDataEntryView().setPatient( patient );
+ nameBasedMIDlet.getTrackingDataEntryView().setProgramStage( programStage );
+ nameBasedMIDlet.getTrackingDataEntryView().setTitle( programStage.getName() );
+ nameBasedMIDlet.getTrackingDataEntryView().showView();
+ }
+
+ }
+ } );
+ }
+ }
+ System.gc();
+ }
+
+ public void showView()
+ {
+ this.prepareView();
+ this.getPersonProgramStageListForm().show();
+
+ }
+
+ public Form getPersonProgramStageListForm()
+ {
+ if ( personProgramStageListForm == null )
+ {
+ personProgramStageListForm = new Form( "Program Stages" );
+ personProgramStageListForm.setLayout( new BoxLayout( BoxLayout.Y_AXIS ) );
+ personProgramStageListForm.setScrollableY( true );
+ personProgramStageListForm.setTransitionOutAnimator( CommonTransitions.createSlide(
+ CommonTransitions.SLIDE_HORIZONTAL, true, 200 ) );
+ personProgramStageListForm.addCommand( this.getBackCommand() );
+ personProgramStageListForm.addCommand( this.getCreateNewEventCommand() );
+ personProgramStageListForm.addCommandListener( this );
+
+ }
+ return personProgramStageListForm;
+ }
+
+ public void setPersonProgramStageListForm( Form personProgramStageListForm )
+ {
+ this.personProgramStageListForm = personProgramStageListForm;
+ }
+
+ public void actionPerformed( ActionEvent ae )
+ {
+ if ( ae.getCommand().getCommandName().equals( Text.BACK() ) )
+ {
+ nameBasedMIDlet.getPersonDashboardView().setPatient( patient );
+ nameBasedMIDlet.getPersonDashboardView().showView();
+
+ personProgramStageListForm = null;
+ backCommand = null;
+ addCommand = null;
+ patient = null;
+ System.gc();
+ }
+ else if ( ae.getCommand().getCommandName().equals( Text.CREATE_NEW_EVENT() ) )
+ {
+ try
+ {
+ nameBasedMIDlet.getCreateProgramStageView().setProgram(
+ ProgramRecordStore.getProgram( programInstance.getProgramId() ) );
+ nameBasedMIDlet.getCreateProgramStageView().setProgramInstance( programInstance );
+ nameBasedMIDlet.getCreateProgramStageView().showView();
+
+ personProgramStageListForm = null;
+ backCommand = null;
+ addCommand = null;
+ patient = null;
+ System.gc();
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public Command getBackCommand()
+ {
+ if ( backCommand == null )
+ {
+ backCommand = new Command( Text.BACK() );
+ }
+ return backCommand;
+ }
+
+ public void setBackCommand( Command backCommand )
+ {
+ this.backCommand = backCommand;
+ }
+
+ public Command getCreateNewEventCommand()
+ {
+ if ( addCommand == null )
+ {
+ addCommand = new Command( Text.CREATE_NEW_EVENT() );
+ }
+ return addCommand;
+ }
+
+ public Patient getPatient()
+ {
+ return patient;
+ }
+
+ public void setPatient( Patient patient )
+ {
+ this.patient = patient;
+ }
+
+ public Program getProgram()
+ {
+ return program;
+ }
+
+ public void setProgram( Program program )
+ {
+ this.program = program;
+ }
+
+ public ProgramInstance getProgramInstance()
+ {
+ return programInstance;
+ }
+
+ public void setProgramInstance( ProgramInstance programInstance )
+ {
+ this.programInstance = programInstance;
+ }
}