Javafx .forTableColumn()); //创建了一个可在整个代码接口中重用的自定义日期选择器回调 Datecol.setOnEditCommit((CellEditEvent t)->{ //生成临时变量以将返回的LocalDate转换为SimpleObject属性 ObjectProperty temp=newsimpleobjectproperty(t.getNewValue()); //将新值存储到对象的模型中 t、 getRowValue().setUserDate(临时); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); //向程序发出改变的信号 isChanged=true; }); //作业列设置 Jobcol.setCellValueFactory(新属性值工厂(“作业”)); Jobcol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getJobComboBox()); /*创建一个组合框,其中填充在屏幕初始化时找到的填充项 用户输入将自动提交 */ Jobcol.setOnEditCommit((CellEditEvent t)->{ SimpleStringProperty ssp=新的SimpleStringProperty(t.getNewValue()); //将选择存储到对象的模型(未处理),因此值将显示类似“6002:Kobota”的内容 t、 getRowValue().setJob(ssp); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); cmbxJobCatT.getItems().clear(); cmbxJobCatT.getItems().addAll(cmbxPopulator.getJobCatComboBox(t.getRowValue().getJob()); //发出改变的信号 isChanged=true; }); jobCatCol.setCellValueFactory(新属性值工厂(“JobCat”); jobCatCol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getJobCatComboBox(cmbxJobT.getValue())); jobCatCol.setOnEditCommit((CellEditEvent t)->{ SimpleStringProperty ssp=新的SimpleStringProperty(t.getNewValue()); //将选择存储到对象的模型(未处理),因此值将显示类似“6002:Kobota”的内容 t、 getRowValue().setJob(ssp); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); cmbxLaborT.getItems().clear(); cmbxLaborT.getItems().addAll(cmbxPopulator.getLaborComboBox(t.getRowValue().getJob()); //发出改变的信号 isChanged=true; }); //“人工”列设置的工作方式与“作业”列相同 Laborcol.setCellValueFactory(新财产价值工厂(“劳工”)); Laborcol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getLaborComboBox(cmbxJobCatT.getValue())); laboralcol.setOnEditCommit((CellEditEvent t)->{ SimpleStringProperty ssp=新的SimpleStringProperty(t.getNewValue()); t、 getRowValue().setLabor(ssp); Helper_timshargen.addToedItemMatrix(t.getRowValue()); t、 getTableView().getItems().get(t.getTablePosition().getRow()).setLabor(ssp); isChanged=true; }); //时间列设置。 Timecol.setCellValueFactory(新属性ValueFactory(“时间”)); Timecol.setCellFactory(TextFieldTableCell.forTableColumn(新的FloatStringConverter()); Timecol.setOnEditCommit((CellEditEvent t)->{ //温度变量初始化 float-token=t.getNewValue(); //生成一个临时变量以将浮点返回转换为SimpleFloatProperty SimpleFloatProperty temp=新的SimpleFloatProperty(令牌); //现在更新行的对象 t、 getRowValue().setTime(临时); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); isChanged=true; }); //将tableView设置为可编辑 tblviewTime.setEditable(true); //将tableView设置为允许多行选择 TableViewSelectionModel tvt=tblviewTime.getSelectionModel(); tvt.setSelectionMode(SelectionMode.MULTIPLE); /*检查是否进行了编辑。如果有编辑,则提交到 在擦除ArrayList和更新表之前*/ 如果(isChanged==true){ /*确保arraylist.抛出中没有重复的条目 以前的编辑并采用最新的*/ Helper_timshargen.validateMatrix入口(); //提交更改并重置“isChanged”值。 isChanged=Helper\u TimShArrGen.confirmChanges(Vuser、jobTbl、jobCatTbl、laborTbl、isChanged); } /*告诉工具包运行使用用户输入数据的querytime方法 和用户数据来搜索时间表表并返回用户的时间*/ 如果(isChanged==false){ 试一试{ rs=userData.queryTime(Vuser.getConn(),Vuser.getLogin_ID()); }catch(SQLException-ex){ 系统输出打印项次(ex); } }否则{ 返回; } //设置tableview的observablelist setTableView(tblviewTime); ObservableList n=renderable.generatable(jobTbl、jobCatTbl、laborTbl、rs、vuser.getConn()); //在屏幕上呈现数据` tblviewTime.setItems(n); Helper_TimeBreakDown=新Helper_TimeBreakDown(); 故障。设置报警(n); BreakDwnTim(); lblMonTim.setText(String.valueOf(breakdown.getMon()); lblTuesTim.setText(String.valueOf(breakdown.getTues()); lblWedsTim.setText(String.valueOf(breakdown.getWeds()); lblThursTim.setText(String.valueOf(breakdown.getThurs()); lblFriTim.setText(String.valueOf(breakdown.getFri()); lblSatTim.setText(String.valueOf(breakdown.getSat()); lblSunTim.setText(String.valueOf(breakdown.getSun()); lblWkTim.setText(String.valueOf(breakdown.getWeek()); }
这是来自处理进入列表的数据的类的段Javafx .forTableColumn()); //创建了一个可在整个代码接口中重用的自定义日期选择器回调 Datecol.setOnEditCommit((CellEditEvent t)->{ //生成临时变量以将返回的LocalDate转换为SimpleObject属性 ObjectProperty temp=newsimpleobjectproperty(t.getNewValue()); //将新值存储到对象的模型中 t、 getRowValue().setUserDate(临时); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); //向程序发出改变的信号 isChanged=true; }); //作业列设置 Jobcol.setCellValueFactory(新属性值工厂(“作业”)); Jobcol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getJobComboBox()); /*创建一个组合框,其中填充在屏幕初始化时找到的填充项 用户输入将自动提交 */ Jobcol.setOnEditCommit((CellEditEvent t)->{ SimpleStringProperty ssp=新的SimpleStringProperty(t.getNewValue()); //将选择存储到对象的模型(未处理),因此值将显示类似“6002:Kobota”的内容 t、 getRowValue().setJob(ssp); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); cmbxJobCatT.getItems().clear(); cmbxJobCatT.getItems().addAll(cmbxPopulator.getJobCatComboBox(t.getRowValue().getJob()); //发出改变的信号 isChanged=true; }); jobCatCol.setCellValueFactory(新属性值工厂(“JobCat”); jobCatCol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getJobCatComboBox(cmbxJobT.getValue())); jobCatCol.setOnEditCommit((CellEditEvent t)->{ SimpleStringProperty ssp=新的SimpleStringProperty(t.getNewValue()); //将选择存储到对象的模型(未处理),因此值将显示类似“6002:Kobota”的内容 t、 getRowValue().setJob(ssp); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); cmbxLaborT.getItems().clear(); cmbxLaborT.getItems().addAll(cmbxPopulator.getLaborComboBox(t.getRowValue().getJob()); //发出改变的信号 isChanged=true; }); //“人工”列设置的工作方式与“作业”列相同 Laborcol.setCellValueFactory(新财产价值工厂(“劳工”)); Laborcol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getLaborComboBox(cmbxJobCatT.getValue())); laboralcol.setOnEditCommit((CellEditEvent t)->{ SimpleStringProperty ssp=新的SimpleStringProperty(t.getNewValue()); t、 getRowValue().setLabor(ssp); Helper_timshargen.addToedItemMatrix(t.getRowValue()); t、 getTableView().getItems().get(t.getTablePosition().getRow()).setLabor(ssp); isChanged=true; }); //时间列设置。 Timecol.setCellValueFactory(新属性ValueFactory(“时间”)); Timecol.setCellFactory(TextFieldTableCell.forTableColumn(新的FloatStringConverter()); Timecol.setOnEditCommit((CellEditEvent t)->{ //温度变量初始化 float-token=t.getNewValue(); //生成一个临时变量以将浮点返回转换为SimpleFloatProperty SimpleFloatProperty temp=新的SimpleFloatProperty(令牌); //现在更新行的对象 t、 getRowValue().setTime(临时); //将行的对象存储到更改列表 Helper_timshargen.addToedItemMatrix(t.getRowValue()); isChanged=true; }); //将tableView设置为可编辑 tblviewTime.setEditable(true); //将tableView设置为允许多行选择 TableViewSelectionModel tvt=tblviewTime.getSelectionModel(); tvt.setSelectionMode(SelectionMode.MULTIPLE); /*检查是否进行了编辑。如果有编辑,则提交到 在擦除ArrayList和更新表之前*/ 如果(isChanged==true){ /*确保arraylist.抛出中没有重复的条目 以前的编辑并采用最新的*/ Helper_timshargen.validateMatrix入口(); //提交更改并重置“isChanged”值。 isChanged=Helper\u TimShArrGen.confirmChanges(Vuser、jobTbl、jobCatTbl、laborTbl、isChanged); } /*告诉工具包运行使用用户输入数据的querytime方法 和用户数据来搜索时间表表并返回用户的时间*/ 如果(isChanged==false){ 试一试{ rs=userData.queryTime(Vuser.getConn(),Vuser.getLogin_ID()); }catch(SQLException-ex){ 系统输出打印项次(ex); } }否则{ 返回; } //设置tableview的observablelist setTableView(tblviewTime); ObservableList n=renderable.generatable(jobTbl、jobCatTbl、laborTbl、rs、vuser.getConn()); //在屏幕上呈现数据` tblviewTime.setItems(n); Helper_TimeBreakDown=新Helper_TimeBreakDown(); 故障。设置报警(n); BreakDwnTim(); lblMonTim.setText(String.valueOf(breakdown.getMon()); lblTuesTim.setText(String.valueOf(breakdown.getTues()); lblWedsTim.setText(String.valueOf(breakdown.getWeds()); lblThursTim.setText(String.valueOf(breakdown.getThurs()); lblFriTim.setText(String.valueOf(breakdown.getFri()); lblSatTim.setText(String.valueOf(breakdown.getSat()); lblSunTim.setText(String.valueOf(breakdown.getSun()); lblWkTim.setText(String.valueOf(breakdown.getWeek()); },javafx,combobox,tableview,javafx-8,tablecell,Javafx,Combobox,Tableview,Javafx 8,Tablecell,这是来自处理进入列表的数据的类的段 public ObservableList<String> getJobComboBox(){ //clear the jobList to clean out junk data between calls jobList.clear(); //looks at the job table to determine if the job is active. If active, it reads the entry
public ObservableList<String> getJobComboBox(){
//clear the jobList to clean out junk data between calls
jobList.clear();
//looks at the job table to determine if the job is active. If active, it reads the entry
for (count=0; count<= jobTbl.getTblArray().size()-1; count++){
if(jobTbl.getTblArray().get(count).isActive()){
/*here we scroll through the JobIDList and match the IDs to the jobtbl
data. When a match is hit, we grab up the number on the job and the description
this is added to another array that will become the combobox's list
*/
for(inCount = 0; inCount <= jobIDList.size()-1; inCount++){
if(jobIDList.get(inCount).getCol2ID() == jobTbl.getTblArray().get(count).getID()){
jobList.add(jobTbl.getNumById(jobIDList.get(inCount).getCol2ID())
+ ": " + jobTbl.getDescById(jobIDList.get(inCount).getCol2ID()));
}
}
}
}
/* there's probably a better dataset to use that won't allow duplicates
due to my lack of knowledge at this time, I elected to create a hashset, pass the arrayList
to the hashset to wipe out duplicates, and then pass it back to the arrayList to be used in the combobox
*/
Set<String> tmp = new HashSet();
tmp.addAll(jobList);
jobList.clear();
jobList.addAll(tmp);
jobList.add(null);
return jobList;
}
/**
*
* @param job Argument for the selected Job String
* @return returns the ObservableList of strings for the Job Category ComboBox
*/
public ObservableList<String> getJobCatComboBox(String job){
//clearing out old artifact data from the previous selection
jobCatList.clear();
//splitting the user's string selection apart (number as string, description as string)
int jID=0;
if (job != null){
if (job.contains(": ")){
String[] tmp = job.split(": ");
job = tmp[1];
}
}
// here we comb the job Table for a matching description and vacuum up the associated ID number
for(count=0; count<=jobTbl.getTblArray().size()-1; count++){
if(jobTbl.getTblArray().get(count).getDesc().equals(job)){
jID = jobTbl.getTblArray().get(count).getID();
}
}
/*using that jobID number to examine the fKey in the category table.
once we match the JobID to the fKey ID in the jobCat table, we scoop up the
the job Category code and description to create a list for the combobox
*/
for (count=0; count<= jobCTbl.getTblArray().size()-1; count++){
for(inCount = 0; inCount <= jobCatIDList.size()-1; inCount++){
if(jobCatIDList.get(inCount).getID() == jobCTbl.getTblArray().get(count).getID()){
if(jobCTbl.getTblArray().get(count).getfKeyId() == jID){
jobCatList.add(jobCTbl.getNumById(jobCatIDList.get(inCount).getID())
+ ": " + jobCTbl.getDescById(jobCatIDList.get(inCount).getID()));
}
}
}
}
//same house keeping to remove duplicates as described above
Set<String> tmp = new HashSet();
tmp.addAll(jobCatList);
jobCatList.clear();
jobCatList.addAll(tmp);
jobCatList.add(null);
return jobCatList;
}
/**
*
* @param jobCat Argument for the selected Job Category String
* @return ObservableList of strings for the Labor ComboBox
*/
public ObservableList<String> getLaborComboBox(String jobCat){
//temp arrays I needed to decode the affiliated connections
ArrayList<Integer> jCID = new ArrayList();
ArrayList<Integer> laborID = new ArrayList();
//house keeping to remove artifact data from previous selections
if(jCID != null){
jCID.clear();
}
if(laborID != null){
laborID.clear();
}
if(laborList !=null){
laborList.clear();
}
//split user's string selection for the job category (numerical code as sting, description as string)
if(jobCat != null){
if (jobCat.contains(": ")){
String[] tmp = jobCat.split(": ");
jobCat = tmp[1];
}
}
//use the description to find the affiliated job category ID
for(count=0; count<=jobCTbl.getTblArray().size()-1; count++){
if(jobCTbl.getTblArray().get(count).getDesc().equals(jobCat)){
jCID.add(jobCTbl.getTblArray().get(count).getID());
}
}
//use the job category ID to find the associated labor IDs from the associate entity table
for(count=0; count<=jCLTbl.getTblArray().size()-1; count++){
for(inCount=0; inCount<=jCID.size()-1; inCount++){
if(jCLTbl.getTblArray().get(count).getCol1ID() == jCID.get(inCount)){
laborID.add(jCLTbl.getTblArray().get(count).getCol2ID());
}
}
}
//use the labor ID to look up the needed data from the labor table.
for (count=0; count<= laborTbl.getTblArray().size()-1; count++){
for(inCount = 0; inCount <= laborID.size()-1; inCount++){
if(laborID.get(inCount) == laborTbl.getTblArray().get(count).getID()){
laborList.add(laborTbl.getNumById(laborID.get(inCount))
+ ": " + laborTbl.getDescById(laborID.get(inCount)));
}
}
}
//more housekeeping to remove duplicate entries.
Set<String> tmp = new HashSet();
tmp.addAll(laborList);
laborList.clear();
laborList.addAll(tmp);
laborList.add(null);
return laborList;
}
publicobservableList getJobComboBox(){
//清除作业列表以清除通话之间的垃圾数据
乔布里
public void btnTimeSearch(ActionEvent event){
//makes an instance of the toolkit needed to query user time.
Database_RetrievesTime userData = new Database_RetrievesTime();
//grabs data from the userinput fields to set the toolkit
userData.setDateSelect(lblPickDateT.getValue());
userData.setJobBoxSelect(jobTbl.getIdByDesc(cmbxJobT.getValue()));
userData.setLaborBoxSelect(laborTbl.getIdByDesc(cmbxLaborT.getValue()));
userData.setJobCatSelect(jobCatTbl.getIdByDesc(cmbxJobCatT.getValue()));
/*creates cell factories in each column and maps the cell values to the
observable array list's IDs. The section also sets the columns up for user
editing to be available and the methods to execute upon an editted cell
being committed to entry.
**NOTE: The values are retrieved by the model class's getter methods.
Changing a name in the model class requires the user to update the getters.
Naming convention does apply. So for example: a variable
named cscHelp is added, it would need to have a getter called getCscHelp otherwise
the corresponding column will return blanks.*/
//setup ID column
IDcol.setCellValueFactory(new PropertyValueFactory<>("ID"));
//setup Datecol
Datecol.setCellValueFactory(new PropertyValueFactory<>("userDate"));
Datecol.setCellFactory(DatePickerTableCell.forTableColumn());
//created a custom datepicker callback that can be reused throughout the code's interfaces
Datecol.setOnEditCommit((CellEditEvent<Model_Time,LocalDate> t) -> {
//generate a temporary variable to convert the LocalDate returned into a SimpleObjectProperty
ObjectProperty<LocalDate> temp = new SimpleObjectProperty(t.getNewValue());
//store the new value to the object's model
t.getRowValue().setUserDate(temp);
//store row's object to the change list
Helper_TimShArrGen.addToEditedMatrix(t.getRowValue());
//signaling to the program that a change had been made
isChanged = true;
});
//job column setup
Jobcol.setCellValueFactory(new PropertyValueFactory<>("Job"));
Jobcol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getJobComboBox()));
/*creates a combobox filled with the populated items found at initialization of the screen
user inputs are automatically commited
*/
Jobcol.setOnEditCommit((CellEditEvent<Model_Time,String> t) -> {
SimpleStringProperty ssp = new SimpleStringProperty(t.getNewValue());
//store selection to the object's model (unprocessed so values will show something like '6002: Kobota'
t.getRowValue().setJob(ssp);
//store row's object to the change list
Helper_TimShArrGen.addToEditedMatrix(t.getRowValue());
cmbxJobCatT.getItems().clear();
cmbxJobCatT.getItems().addAll(cmbxPopulator.getJobCatComboBox(t.getRowValue().getJob()));
//signaling a change has been made
isChanged = true;
});
jobCatCol.setCellValueFactory(new PropertyValueFactory<>("JobCat"));
jobCatCol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getJobCatComboBox(cmbxJobT.getValue())));
jobCatCol.setOnEditCommit((CellEditEvent<Model_Time,String> t)->{
SimpleStringProperty ssp = new SimpleStringProperty(t.getNewValue());
//store selection to the object's model (unprocessed so values will show something like '6002: Kobota'
t.getRowValue().setJob(ssp);
//store row's object to the change list
Helper_TimShArrGen.addToEditedMatrix(t.getRowValue());
cmbxLaborT.getItems().clear();
cmbxLaborT.getItems().addAll(cmbxPopulator.getLaborComboBox(t.getRowValue().getJob()));
//signaling a change has been made
isChanged = true;
});
//labor column setup works just like the job column
Laborcol.setCellValueFactory(new PropertyValueFactory<>("Labor"));
Laborcol.setCellFactory(ComboBoxTableCell.forTableColumn(cmbxPopulator.getLaborComboBox(cmbxJobCatT.getValue())));
Laborcol.setOnEditCommit((CellEditEvent<Model_Time,String> t) -> {
SimpleStringProperty ssp = new SimpleStringProperty(t.getNewValue());
t.getRowValue().setLabor(ssp);
Helper_TimShArrGen.addToEditedMatrix(t.getRowValue());
t.getTableView().getItems().get(t.getTablePosition().getRow()).setLabor(ssp);
isChanged = true;
});
//time column setup.
Timecol.setCellValueFactory(new PropertyValueFactory<>("Time"));
Timecol.setCellFactory(TextFieldTableCell.<Model_Time, Float>forTableColumn(new FloatStringConverter()));
Timecol.setOnEditCommit((CellEditEvent<Model_Time,Float> t) -> {
//temp variable initialiation
float token = t.getNewValue();
//generate a temporary variable to convert the float return to a SimpleFloatProperty
SimpleFloatProperty temp = new SimpleFloatProperty(token);
//now update the row's object
t.getRowValue().setTime(temp);
//store row's object to the change list
Helper_TimShArrGen.addToEditedMatrix(t.getRowValue());
isChanged = true;
});
//set tableView editable
tblviewTime.setEditable(true);
//sets tableView to allow multiline selection
TableViewSelectionModel<Model_Time> tvt = tblviewTime.getSelectionModel();
tvt.setSelectionMode(SelectionMode.MULTIPLE);
/* checks if edits have been made. If there are edits, it commits to the
database before wiping the arraylists and updating the table*/
if (isChanged == true){
/*makes sure there are no duplicate entries in the arraylist. Throws out
previous edits and takes the most recent*/
Helper_TimShArrGen.validateMatrixEntries();
//commits changes and resets the "isChanged" value.
isChanged = Helper_TimShArrGen.confirmChanges(vUsers, jobTbl, jobCatTbl, laborTbl, isChanged);
}
/*tells the kit to run the querytime Method which uses the user input data
and user data to search the timesheet tables and returns the user's time.*/
if (isChanged == false){
try {
rs = userData.queryTime(vUsers.getConn(), vUsers.getLogin_ID());
} catch (SQLException ex) {
System.out.println(ex);
}
} else {
return;
}
//sets up the observablelist for the tableview
renderTable.setTableView(tblviewTime);
ObservableList n = renderTable.generateTable(jobTbl, jobCatTbl, laborTbl, rs, vUsers.getConn());
//renders the data on the screen`
tblviewTime.setItems(n);
Helper_TimeBreakDown breakdown = new Helper_TimeBreakDown();
breakdown.setTblArr(n);
breakdown.BreakDwnTim();
lblMonTim.setText(String.valueOf(breakdown.getMon()));
lblTuesTim.setText(String.valueOf(breakdown.getTues()));
lblWedsTim.setText(String.valueOf(breakdown.getWeds()));
lblThursTim.setText(String.valueOf(breakdown.getThurs()));
lblFriTim.setText(String.valueOf(breakdown.getFri()));
lblSatTim.setText(String.valueOf(breakdown.getSat()));
lblSunTim.setText(String.valueOf(breakdown.getSun()));
lblWkTim.setText(String.valueOf(breakdown.getWeek()));
}
public ObservableList<String> getJobComboBox(){
//clear the jobList to clean out junk data between calls
jobList.clear();
//looks at the job table to determine if the job is active. If active, it reads the entry
for (count=0; count<= jobTbl.getTblArray().size()-1; count++){
if(jobTbl.getTblArray().get(count).isActive()){
/*here we scroll through the JobIDList and match the IDs to the jobtbl
data. When a match is hit, we grab up the number on the job and the description
this is added to another array that will become the combobox's list
*/
for(inCount = 0; inCount <= jobIDList.size()-1; inCount++){
if(jobIDList.get(inCount).getCol2ID() == jobTbl.getTblArray().get(count).getID()){
jobList.add(jobTbl.getNumById(jobIDList.get(inCount).getCol2ID())
+ ": " + jobTbl.getDescById(jobIDList.get(inCount).getCol2ID()));
}
}
}
}
/* there's probably a better dataset to use that won't allow duplicates
due to my lack of knowledge at this time, I elected to create a hashset, pass the arrayList
to the hashset to wipe out duplicates, and then pass it back to the arrayList to be used in the combobox
*/
Set<String> tmp = new HashSet();
tmp.addAll(jobList);
jobList.clear();
jobList.addAll(tmp);
jobList.add(null);
return jobList;
}
/**
*
* @param job Argument for the selected Job String
* @return returns the ObservableList of strings for the Job Category ComboBox
*/
public ObservableList<String> getJobCatComboBox(String job){
//clearing out old artifact data from the previous selection
jobCatList.clear();
//splitting the user's string selection apart (number as string, description as string)
int jID=0;
if (job != null){
if (job.contains(": ")){
String[] tmp = job.split(": ");
job = tmp[1];
}
}
// here we comb the job Table for a matching description and vacuum up the associated ID number
for(count=0; count<=jobTbl.getTblArray().size()-1; count++){
if(jobTbl.getTblArray().get(count).getDesc().equals(job)){
jID = jobTbl.getTblArray().get(count).getID();
}
}
/*using that jobID number to examine the fKey in the category table.
once we match the JobID to the fKey ID in the jobCat table, we scoop up the
the job Category code and description to create a list for the combobox
*/
for (count=0; count<= jobCTbl.getTblArray().size()-1; count++){
for(inCount = 0; inCount <= jobCatIDList.size()-1; inCount++){
if(jobCatIDList.get(inCount).getID() == jobCTbl.getTblArray().get(count).getID()){
if(jobCTbl.getTblArray().get(count).getfKeyId() == jID){
jobCatList.add(jobCTbl.getNumById(jobCatIDList.get(inCount).getID())
+ ": " + jobCTbl.getDescById(jobCatIDList.get(inCount).getID()));
}
}
}
}
//same house keeping to remove duplicates as described above
Set<String> tmp = new HashSet();
tmp.addAll(jobCatList);
jobCatList.clear();
jobCatList.addAll(tmp);
jobCatList.add(null);
return jobCatList;
}
/**
*
* @param jobCat Argument for the selected Job Category String
* @return ObservableList of strings for the Labor ComboBox
*/
public ObservableList<String> getLaborComboBox(String jobCat){
//temp arrays I needed to decode the affiliated connections
ArrayList<Integer> jCID = new ArrayList();
ArrayList<Integer> laborID = new ArrayList();
//house keeping to remove artifact data from previous selections
if(jCID != null){
jCID.clear();
}
if(laborID != null){
laborID.clear();
}
if(laborList !=null){
laborList.clear();
}
//split user's string selection for the job category (numerical code as sting, description as string)
if(jobCat != null){
if (jobCat.contains(": ")){
String[] tmp = jobCat.split(": ");
jobCat = tmp[1];
}
}
//use the description to find the affiliated job category ID
for(count=0; count<=jobCTbl.getTblArray().size()-1; count++){
if(jobCTbl.getTblArray().get(count).getDesc().equals(jobCat)){
jCID.add(jobCTbl.getTblArray().get(count).getID());
}
}
//use the job category ID to find the associated labor IDs from the associate entity table
for(count=0; count<=jCLTbl.getTblArray().size()-1; count++){
for(inCount=0; inCount<=jCID.size()-1; inCount++){
if(jCLTbl.getTblArray().get(count).getCol1ID() == jCID.get(inCount)){
laborID.add(jCLTbl.getTblArray().get(count).getCol2ID());
}
}
}
//use the labor ID to look up the needed data from the labor table.
for (count=0; count<= laborTbl.getTblArray().size()-1; count++){
for(inCount = 0; inCount <= laborID.size()-1; inCount++){
if(laborID.get(inCount) == laborTbl.getTblArray().get(count).getID()){
laborList.add(laborTbl.getNumById(laborID.get(inCount))
+ ": " + laborTbl.getDescById(laborID.get(inCount)));
}
}
}
//more housekeeping to remove duplicate entries.
Set<String> tmp = new HashSet();
tmp.addAll(laborList);
laborList.clear();
laborList.addAll(tmp);
laborList.add(null);
return laborList;
}
t.getRowValue().setJob(ssp);
t.getRowValue().setJobCat(ssp);
public class JobComboBoxCell extends TableCell<Model_Time, String>
{
private ComboBox<String> comboBox;
private Helper_UserSpecificTimDat cmbxPopulator = new Helper_UserSpecificTimDat();
public JobComboBoxCell(Helper_UserSpecificTimDat cmbxPopulator)
{
comboBox = new ComboBox<>();
this.cmbxPopulator = cmbxPopulator;
}
@Override
public void startEdit()
{
if ( !isEmpty() )
{
super.startEdit();
comboBox.setItems( cmbxPopulator.getJobComboBox() );
comboBox.getSelectionModel().select( this.getItem() );
comboBox.focusedProperty().addListener( new ChangeListener<Boolean>()
{
@Override
public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue )
{
if ( !newValue )
{
commitEdit( comboBox.getSelectionModel().getSelectedItem() );
}
}
} );
setText( null );
setGraphic( comboBox );
}
}
@Override
public void cancelEdit()
{
super.cancelEdit();
setText( ( String ) this.getItem() );
setGraphic( null );
}
@Override
public void updateItem( String item, boolean empty )
{
super.updateItem( item, empty );
if ( empty )
{
setText( null );
setGraphic( null );
}
else
{
if ( isEditing() )
{
setText( null );
setGraphic( comboBox );
}
else
{
setText( this.getItem() );
setGraphic( null );
}
}
}
}