📄 datacapture.java
字号:
//import superwaba.ext.xplat.sql.pdb.pdbx.LitebaseConnection;
//import superwaba.ext.xplat.sql.pdb.pdbx.ResultSet;
import litebase.*;
import waba.fx.Color;
import waba.fx.Sound;
import waba.sys.Convert;
import waba.sys.Time;
import waba.sys.Vm;
import waba.ui.Button;
import waba.ui.ComboBox;
import waba.ui.Container;
import waba.ui.ControlEvent;
import waba.ui.Edit;
import waba.ui.Event;
import waba.ui.Label;
import waba.ui.MessageBox;
import waba.ui.ScrollBar;
import waba.ui.Timer;
public class dataCapture extends Container{
locationEdit locationEdit;
speciesEdit speciesEdit;
dataEdit dataEdit;
dataGps dataGps;
gpsDataLogger gpsDataLogger;
Edit edCumulative, edLastRecord, edTime, edBattery,edTrackLogIndicator,edPositionFix;
Edit edSky,edWater,edOverall;
Label lblLastRecord, lblCumulative, lblSpecies, lblLocation, lblTerrain,lblSky,lblWater,lblOverall,lblTime,lblBattery,lblTrackLogIndicator,lblPositionFix;
Button btnToggleLocation, btnCountOne, btnCountTen, btnCountOneHundred, btnCountOneThousand;
Button btnDeleteLastRecord, btnCreateZeroCountRecord;
ComboBox cbSpecies,cbLocation,cbTerrain,cbLive;
MessageBox mbDeleteLastRecord, mbCreateZeroCountRecord;
ScrollBar sbSky, sbWater,sbOverall;
String []szTerrain = {"stream","bay","ocean"};
String []szLive = {"Live","Carcasses"};
String szSpeciesTemp,szLocation,szSpecies,szCount,szLatitude,szLatns,szLongitude,szLongew, szSky, szWater, szOverall;
String szSignal;
LitebaseConnection driver = LitebaseConnection.getInstance("AZoe");
private Timer batteryTimer;
int iBattery;
static Color Red = new Color(255, 0, 0);
static Color White = new Color(255, 255, 255);
static Color Green = new Color(0, 255, 0);
public void onStart(){
//Vm.interceptSystemKeys(Vm.SK_ALL | Vm.SK_LAUNCH);
int iTmpWidth=this.width;
batteryTimer = addTimer(100);
lblSpecies = new Label("Species:");
add (lblSpecies,LEFT,TOP+3);
cbSpecies = new ComboBox(gpsDataLogger.szSpeciesLookup);
add(cbSpecies);
cbSpecies.setRect(AFTER+2,SAME,iTmpWidth/8*3,PREFERRED);
cbSpecies.select(0);
cbSpecies.setEnabled(true);
cbLive = new ComboBox(szLive);
add(cbLive);
cbLive.setRect(AFTER+2,SAME,50,PREFERRED);
cbLive.select(0);
cbLive.setEnabled(true);
//pops up 3-second window allowing user to create count of zero
btnCreateZeroCountRecord = new Button("ZERO");
//btnCreateZeroOrNoCountRecord.setGap(10);
btnCreateZeroCountRecord.setBorder(Button.BORDER_3D);
btnCreateZeroCountRecord.setBackColor(Green);
//btnCreateZeroCountRecord.setBackColor(Red);
add (btnCreateZeroCountRecord,RIGHT-5,SAME);
edCumulative = new Edit();
add(edCumulative);
edCumulative.setRect(iTmpWidth/8*5, AFTER+2,iTmpWidth/3,PREFERRED);
edCumulative.setEditable(false);
lblCumulative = new Label("Total Number Counted:");
add (lblCumulative,BEFORE-2,SAME);
edLastRecord = new Edit();
add(edLastRecord);
edLastRecord.setRect(iTmpWidth/8*5, AFTER+2,iTmpWidth/3,PREFERRED);
edLastRecord.setEditable(false);
lblLastRecord = new Label("Last Number Entered:");
add (lblLastRecord,BEFORE-2,SAME);
cbLocation = new ComboBox(gpsDataLogger.szLocationLookup);
add(cbLocation);
cbLocation.setRect(iTmpWidth/8*2,AFTER+2,iTmpWidth/8*6-4,PREFERRED);
cbLocation.select(0);
cbLocation.setEnabled(true);
lblLocation = new Label("Location:");
add (lblLocation,BEFORE-2,SAME);
cbTerrain = new ComboBox(szTerrain);
add(cbTerrain);
cbTerrain.setRect(iTmpWidth/8*3,AFTER+2,iTmpWidth/8*5-4,PREFERRED);
cbTerrain.select(0);
cbTerrain.setEnabled(true);
lblTerrain = new Label("Select terrain:");
add (lblTerrain,BEFORE-2,SAME);
lblSky = new Label("Sky:");
add (lblSky,LEFT+2,AFTER+2);
add(sbSky = new ScrollBar(ScrollBar.HORIZONTAL));
Button.commonGap = 1;
sbSky.setLiveScrolling(true);
sbSky.setRect(AFTER+1,SAME+1, iTmpWidth/8*5, PREFERRED);
sbSky.setUnitIncrement(15);
edSky = new Edit();
add(edSky);
edSky.setRect(AFTER+1,SAME,15,PREFERRED-2);
edSky.setEditable(true);
edSky.setText("1");
lblWater = new Label("Water:");
add (lblWater,LEFT+2,AFTER+2);
add(sbWater = new ScrollBar(ScrollBar.HORIZONTAL));
Button.commonGap = 1;
sbWater.setLiveScrolling(true);
sbWater.setRect(AFTER+1,SAME+1, iTmpWidth/8*5, PREFERRED);
sbWater.setUnitIncrement(15);
edWater = new Edit();
add(edWater);
edWater.setRect(AFTER+1,SAME,15,PREFERRED-2);
edWater.setEditable(true);
edWater.setText("1");
lblOverall = new Label("Overall:");
add (lblOverall,LEFT+2,AFTER+2);
add(sbOverall = new ScrollBar(ScrollBar.HORIZONTAL));
Button.commonGap = 1;
sbOverall.setLiveScrolling(true);
sbOverall.setRect(AFTER+1,SAME+1, iTmpWidth/8*5, PREFERRED);
sbOverall.setUnitIncrement(15);
edOverall = new Edit();
add(edOverall);
edOverall.setRect(AFTER+1,SAME,15,PREFERRED-2);
edOverall.setEditable(true);
edOverall.setText("1");
lblTime = new Label("Satellite time:");
add (lblTime,LEFT+4,AFTER+2);
edTime = new Edit();
add(edTime);
edTime.setRect(AFTER,SAME,70,PREFERRED);
edTime.setEditable(false);
lblBattery = new Label("Batt:");
add (lblBattery,AFTER,SAME);
edBattery = new Edit();
add(edBattery);
edBattery.setRect(AFTER,SAME,40,PREFERRED);
edBattery.setEditable(false);
lblTrackLogIndicator = new Label("TrackLog:");
add (lblTrackLogIndicator,LEFT+2,AFTER+2);
edTrackLogIndicator = new Edit();
add(edTrackLogIndicator);
edTrackLogIndicator.setRect(AFTER,SAME,25,PREFERRED);
edTrackLogIndicator.setEditable(false);
btnDeleteLastRecord = new Button("Delete Last Count");
btnDeleteLastRecord.setGap(10);
btnDeleteLastRecord.setBorder(Button.BORDER_3D);
btnDeleteLastRecord.setBackColor(Red);
add (btnDeleteLastRecord,RIGHT-5,SAME);
lblPositionFix = new Label("Position fix:");
add (lblPositionFix,LEFT+4,AFTER-18);
edPositionFix = new Edit();
add(edPositionFix);
edPositionFix.setRect(AFTER,SAME,40,PREFERRED);
edPositionFix.setEditable(false);
LoadTrackLogIndicator();
/*
* Below buttons are for devices without obvious hardware buttons: these will be hardware buttons
* on screen that the user can access to count items, or toggle between fields.
*
* Java, PalmOS, PalmOS/SDL, WindowsCE, PocketPC, MS_SmartPhone, Win32, Symbian, Linux, Posix
*/
if ((gpsDataLogger.szPlatform.compareTo("Win32")==0)||
(gpsDataLogger.szPlatform.compareTo("Linux")==0)||
(gpsDataLogger.szPlatform.compareTo("Java")==0)){
btnCountOne = new Button("(1)");
btnCountOne.setGap(2);
btnCountOne.setBorder(Button.BORDER_3D);
add (btnCountOne,CENTER-iTmpWidth/16*7,BOTTOM-5);
//add (btnCountOne,iTmpWidth/2,BOTTOM-5);
btnCountTen = new Button("(10)");
btnCountTen.setGap(2);
btnCountTen.setBorder(Button.BORDER_3D);
add (btnCountTen,AFTER+2,SAME);
btnToggleLocation = new Button("|*|");
btnToggleLocation.setGap(2);
btnToggleLocation.setBorder(Button.BORDER_3D);
add (btnToggleLocation,AFTER+2,SAME);
btnCountOneHundred = new Button("(100)");
btnCountOneHundred.setGap(2);
btnCountOneHundred.setBorder(Button.BORDER_3D);
add (btnCountOneHundred,AFTER+2,SAME);
btnCountOneThousand = new Button("(1,000)");
btnCountOneThousand.setGap(2);
btnCountOneThousand.setBorder(Button.BORDER_3D);
add (btnCountOneThousand,AFTER+2,SAME);
}else{
}
}
/*updateLocationComboBox();
updateSpeciesComboBox();
}*/
/****************************************************************************
* Note: *
* UpdateComboBox() sets ComboBox shown field to string[0] in array. *
* While this IS done by default when a ComboBox is created, when the *
* .add fuction is used this does not happen. Instead the shown field *
* in the combobox is blank. *
* *
* On selecting the dataCapture tab: *
* -Immediately after startup, the combobox cbLocation is cleared *
* and reloaded, (iFirstIteration = 0) *
* -during operation, (iFirstIteration = 1) cbLocation is not *
* refreshed. *
* -After the lookup table has been modified, (iFirstIteration = 2)*
* cbLocation is cleared and reloaded and iFirstIteration is set to 1. *
* *
* Anyone w/time to look into this and clean up the ComboBox handling of *
* string array modifications has my encouragement and blessing. -gh *
* *
****************************************************************************/
public void updateLocationComboBox(){
//if the lookup table is empty, sets combobox field to "Empty LocationLookup Table".
Object objLocation = cbLocation.getSelectedItem();
szLocation = objLocation.toString();
if ((gpsDataLogger.iEmptyLocationLookupTable == 1)||(szLocation.compareTo("")==0)){
((ComboBox)cbLocation).removeAll();
((ComboBox)cbLocation).add("Empty Location Lookup Table");
cbLocation.select(0);
clear();
}
else if (gpsDataLogger.iFirstLocationIteration == 0){
((ComboBox)cbLocation).removeAll();
((ComboBox)cbLocation).add(gpsDataLogger.szLocationLookup);
cbLocation.select(0);
gpsDataLogger.iFirstLocationIteration = 1;
// new MessageBox("Attention","Array reloaded, | iFirstIteration = 0").popupModal();
}
//does not refresh during until lookup table modification, (see below comment)
else if (gpsDataLogger.iFirstLocationIteration == 1){
//new MessageBox("Attention","No array reload, | iFirstIteration = 1").popupModal();
}
//refreshes ComboBox after modification of lookup table
else if (gpsDataLogger.iFirstLocationIteration == 2){
((ComboBox)cbLocation).removeAll();
((ComboBox)cbLocation).add(gpsDataLogger.szLocationLookup);
cbLocation.select(0);
gpsDataLogger.iFirstLocationIteration = 1;
// new MessageBox("Attention","Array reloaded |iFirstIteration = 2").popupModal();
}
}
public void updateSpeciesComboBox(){
//if the lookup table is empty, sets combobox field to "Empty SpeciesLookup Table".
Object objSpecies = cbSpecies.getSelectedItem();
szSpecies = objSpecies.toString();
if ((gpsDataLogger.iEmptySpeciesLookupTable == 1)||(szSpecies.compareTo("")==0)){
((ComboBox)cbSpecies).removeAll();
((ComboBox)cbSpecies).add("Empty Species Lookup Table");
cbSpecies.select(0);
clear();
}
else if (gpsDataLogger.iFirstSpeciesIteration == 0){
((ComboBox)cbSpecies).removeAll();
((ComboBox)cbSpecies).add(gpsDataLogger.szSpeciesLookup);
cbSpecies.select(0);
gpsDataLogger.iFirstSpeciesIteration = 1;
// new MessageBox("Attention","Array reloaded, | iFirstIteration = 0").popupModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -