UserListModel implementiert, um Daten für eine Dropdownliste zur

Verfügung stellen zu können.
This commit is contained in:
Servicepoint
2014-11-05 18:06:17 +01:00
parent ac90334cf1
commit e21589c002
14 changed files with 307 additions and 243 deletions

View File

@@ -55,16 +55,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="7" language="java" name="de.katho.kBorrow.gui.PanelUser" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/PanelUser.java" binary="false" corner="BOTTOM_RIGHT">
<position height="351" width="211" x="623" y="37"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="8" language="java" name="de.katho.kBorrow.listener.NewLendingTableButton" project="kBorrow"
<class id="7" language="java" name="de.katho.kBorrow.listener.NewLendingTableButton" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/listener/NewLendingTableButton.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="302" x="882" y="428"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -73,7 +64,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="9" language="java" name="de.katho.kBorrow.listener.ArticleDeleteTableButton" project="kBorrow"
<class id="8" language="java" name="de.katho.kBorrow.listener.ArticleDeleteTableButton" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/listener/ArticleDeleteTableButton.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="352" x="1874" y="428"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -82,7 +73,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="10" language="java" name="de.katho.kBorrow.db.SqlConnector" project="kBorrow"
<class id="9" language="java" name="de.katho.kBorrow.db.SqlConnector" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/db/SqlConnector.java" binary="false" corner="BOTTOM_RIGHT">
<position height="243" width="217" x="1389" y="639"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -91,7 +82,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="11" language="java" name="de.katho.kBorrow.controller.ArticleController" project="kBorrow"
<class id="10" language="java" name="de.katho.kBorrow.controller.ArticleController" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/controller/ArticleController.java" binary="false" corner="BOTTOM_RIGHT">
<position height="135" width="235" x="2837" y="428"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -100,8 +91,8 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="12" language="java" name="de.katho.kBorrow.gui.PanelManageLendings" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/PanelManageLendings.java" binary="false" corner="BOTTOM_RIGHT">
<class id="11" language="java" name="de.katho.kBorrow.gui.ManageLendingsPanel" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/ManageLendingsPanel.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="205" x="43" y="37"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@@ -109,7 +100,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="13" language="java" name="de.katho.kBorrow.listener.TableButton" project="kBorrow"
<class id="12" language="java" name="de.katho.kBorrow.listener.TableButton" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/listener/TableButton.java" binary="false" corner="BOTTOM_RIGHT">
<position height="207" width="421" x="1591" y="37"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -118,7 +109,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="14" language="java" name="de.katho.kBorrow.listener.ArticleEditTableButton" project="kBorrow"
<class id="13" language="java" name="de.katho.kBorrow.listener.ArticleEditTableButton" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/listener/ArticleEditTableButton.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="259" x="2266" y="428"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -127,7 +118,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="15" language="java" name="de.katho.kBorrow.models.UserModel" project="kBorrow"
<class id="14" language="java" name="de.katho.kBorrow.models.UserModel" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/models/UserModel.java" binary="false" corner="BOTTOM_RIGHT">
<position height="351" width="162" x="623" y="639"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -136,8 +127,8 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="16" language="java" name="de.katho.kBorrow.gui.PanelNewLending" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/PanelNewLending.java" binary="false" corner="BOTTOM_RIGHT">
<class id="15" language="java" name="de.katho.kBorrow.gui.NewLendingPanel" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/NewLendingPanel.java" binary="false" corner="BOTTOM_RIGHT">
<position height="171" width="232" x="2565" y="428"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@@ -145,7 +136,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="17" language="java" name="de.katho.kBorrow.listener.UserDeleteTableButton" project="kBorrow"
<class id="16" language="java" name="de.katho.kBorrow.listener.UserDeleteTableButton" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/listener/UserDeleteTableButton.java" binary="false" corner="BOTTOM_RIGHT">
<position height="99" width="327" x="1224" y="428"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -154,16 +145,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="18" language="java" name="de.katho.kBorrow.gui.PanelArticle" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/PanelArticle.java" binary="false" corner="BOTTOM_RIGHT">
<position height="351" width="219" x="2874" y="37"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="19" language="java" name="de.katho.kBorrow.gui.MainWindow" project="kBorrow"
<class id="17" language="java" name="de.katho.kBorrow.gui.MainWindow" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/MainWindow.java" binary="false" corner="BOTTOM_RIGHT">
<position height="135" width="153" x="430" y="639"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -172,7 +154,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="20" language="java" name="de.katho.kBorrow.db.SqliteConnector" project="kBorrow"
<class id="18" language="java" name="de.katho.kBorrow.db.SqliteConnector" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/db/SqliteConnector.java" binary="false" corner="BOTTOM_RIGHT">
<position height="369" width="301" x="1048" y="639"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -181,7 +163,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="21" language="java" name="de.katho.kBorrow.data.KArticle" project="kBorrow"
<class id="19" language="java" name="de.katho.kBorrow.data.KArticle" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/data/KArticle.java" binary="false" corner="BOTTOM_RIGHT">
<position height="225" width="154" x="2701" y="1066"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -190,7 +172,7 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="22" language="java" name="de.katho.kBorrow.gui.MyFocusTraversalPolicy" project="kBorrow"
<class id="20" language="java" name="de.katho.kBorrow.gui.MyFocusTraversalPolicy" project="kBorrow"
file="/kBorrow/src/de/katho/kBorrow/gui/MyFocusTraversalPolicy.java" binary="false" corner="BOTTOM_RIGHT">
<position height="189" width="295" x="288" y="37"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
@@ -199,166 +181,156 @@
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<association id="23">
<bendpoint x="592" y="428"/>
<end type="SOURCE" refId="7" navigable="false">
<attribute id="24" name="userModel"/>
<multiplicity id="25" minimum="0" maximum="1"/>
<association id="21">
<end type="SOURCE" refId="17" navigable="false">
<attribute id="22" name="set">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="23" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="15" navigable="true"/>
<end type="TARGET" refId="1" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="26">
<end type="SOURCE" refId="20"/>
<end type="TARGET" refId="2"/>
</realization>
<generalization id="27">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="13"/>
</generalization>
<association id="28">
<end type="SOURCE" refId="15" navigable="false">
<attribute id="29" name="dbCon"/>
<multiplicity id="30" minimum="0" maximum="1"/>
<association id="24">
<end type="SOURCE" refId="14" navigable="false">
<attribute id="25" name="dbCon">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="26" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="31">
<end type="SOURCE" refId="32" navigable="false">
<attribute id="33" name="dbCon"/>
<multiplicity id="34" minimum="0" maximum="1"/>
<realization id="27">
<end type="SOURCE" refId="18"/>
<end type="TARGET" refId="2"/>
</realization>
<generalization id="28">
<end type="SOURCE" refId="13"/>
<end type="TARGET" refId="12"/>
</generalization>
<association id="29">
<bendpoint x="1017" y="639"/>
<end type="SOURCE" refId="4" navigable="false">
<attribute id="30" name="dbCon">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="31" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="32">
<end type="SOURCE" refId="17" navigable="false">
<attribute id="33" name="dbCon">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="34" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="35">
<end type="SOURCE" refId="15" navigable="false">
<attribute id="36" name="data"/>
<multiplicity id="37" minimum="0" maximum="2147483647"/>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<generalization id="38">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="13"/>
</generalization>
<association id="39">
<end type="SOURCE" refId="19" navigable="false">
<attribute id="40" name="dbCon"/>
<multiplicity id="41" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="42">
<end type="SOURCE" refId="5" navigable="false">
<attribute id="43" name="dbCon"/>
<multiplicity id="44" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="45">
<end type="SOURCE" refId="32" navigable="false">
<attribute id="46" name="data"/>
<multiplicity id="47" minimum="0" maximum="2147483647"/>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="48">
<end type="SOURCE" refId="7" navigable="false">
<attribute id="49" name="userController"/>
<multiplicity id="50" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="4" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="51">
<end type="SOURCE" refId="4" navigable="false">
<attribute id="52" name="userModel"/>
<multiplicity id="53" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="15" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="54">
<end type="SOURCE" refId="11" navigable="false">
<attribute id="55" name="articleModel"/>
<multiplicity id="56" minimum="0" maximum="1"/>
<end type="SOURCE" refId="10" navigable="false">
<attribute id="36" name="articleModel">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="37" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="5" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="57">
<bendpoint x="1017" y="639"/>
<association id="38">
<end type="SOURCE" refId="4" navigable="false">
<attribute id="58" name="dbCon"/>
<multiplicity id="59" minimum="0" maximum="1"/>
<attribute id="39" name="userModel">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="40" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<end type="TARGET" refId="14" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="60">
<end type="SOURCE" refId="10"/>
<generalization id="41">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="12"/>
</generalization>
<realization id="42">
<end type="SOURCE" refId="9"/>
<end type="TARGET" refId="2"/>
</realization>
<generalization id="61">
<end type="SOURCE" refId="17"/>
<end type="TARGET" refId="13"/>
</generalization>
<association id="62">
<bendpoint x="3102" y="428"/>
<end type="SOURCE" refId="18" navigable="false">
<attribute id="63" name="articleModel"/>
<multiplicity id="64" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="5" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="65">
<association id="43">
<end type="SOURCE" refId="5" navigable="false">
<attribute id="66" name="data"/>
<multiplicity id="67" minimum="0" maximum="2147483647"/>
</end>
<end type="TARGET" refId="21" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="68">
<end type="SOURCE" refId="18" navigable="false">
<attribute id="69" name="articleController"/>
<multiplicity id="70" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="11" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<generalization id="71">
<end type="SOURCE" refId="9"/>
<end type="TARGET" refId="13"/>
</generalization>
<generalization id="72">
<end type="SOURCE" refId="14"/>
<end type="TARGET" refId="13"/>
</generalization>
<association id="73">
<end type="SOURCE" refId="19" navigable="false">
<attribute id="74" name="set"/>
<multiplicity id="75" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="1" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="76">
<bendpoint x="2798" y="639"/>
<end type="SOURCE" refId="11" navigable="false">
<attribute id="77" name="dbCon"/>
<multiplicity id="78" minimum="0" maximum="1"/>
<attribute id="44" name="dbCon">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="45" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="46">
<bendpoint x="2798" y="639"/>
<end type="SOURCE" refId="10" navigable="false">
<attribute id="47" name="dbCon">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="48" minimum="0" maximum="1">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="49">
<end type="SOURCE" refId="14" navigable="false">
<attribute id="50" name="data">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="51" minimum="0" maximum="2147483647">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="52">
<end type="SOURCE" refId="5" navigable="false">
<attribute id="53" name="data">
<position height="0" width="0" x="0" y="0"/>
</attribute>
<multiplicity id="54" minimum="0" maximum="2147483647">
<position height="0" width="0" x="0" y="0"/>
</multiplicity>
</end>
<end type="TARGET" refId="19" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<generalization id="55">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="12"/>
</generalization>
<generalization id="56">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="12"/>
</generalization>
<generalization id="57">
<end type="SOURCE" refId="16"/>
<end type="TARGET" refId="12"/>
</generalization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>

View File

@@ -1,15 +1,20 @@
package de.katho.kBorrow.controller;
import java.util.HashMap;
import de.katho.kBorrow.db.DbConnector;
import de.katho.kBorrow.models.ArticleModel;
import de.katho.kBorrow.models.FreeArticleModel;
public class ArticleController {
private DbConnector dbCon;
private ArticleModel articleModel;
private FreeArticleModel freeArticleModel;
public ArticleController(DbConnector pDbCon, ArticleModel pModel){
public ArticleController(DbConnector pDbCon, HashMap<String, Object> pModels){
dbCon = pDbCon;
articleModel = pModel;
articleModel = (ArticleModel)pModels.get("articlemodel");
freeArticleModel = (FreeArticleModel)pModels.get("freearticlemodel");
}
/**
@@ -24,7 +29,8 @@ public class ArticleController {
public int createArticle(String pName, String pDesc) {
int status = dbCon.createArticle(pName, pDesc);
articleModel.updateTable();
articleModel.updateModel();
freeArticleModel.updateModel();
return status;
}
@@ -43,11 +49,8 @@ public class ArticleController {
int status = this.dbCon.editArticle(pId, pName, pDesc);
if(status == 0){
int row = articleModel.getRowFromId(pId);
articleModel.getArticleByRow(row).setName(pName);
articleModel.getArticleByRow(row).setDescription(pDesc);
articleModel.fireTableRowsUpdated(row, row);
articleModel.updateModel();
freeArticleModel.updateModel();
}
return status;
@@ -61,8 +64,8 @@ public class ArticleController {
*/
public boolean deleteArticle(int id) {
if(this.dbCon.deleteArticle(id)){
int row = articleModel.getRowFromId(id);
articleModel.removeRow(row);
articleModel.updateModel();
freeArticleModel.updateModel();
return true;
}

View File

@@ -0,0 +1,5 @@
package de.katho.kBorrow.controller;
public class NewLendingController {
}

View File

@@ -1,22 +1,28 @@
package de.katho.kBorrow.controller;
import java.util.HashMap;
import de.katho.kBorrow.db.DbConnector;
import de.katho.kBorrow.models.UserModel;
import de.katho.kBorrow.models.UserListModel;
public class UserController {
private DbConnector dbCon;
private UserModel userModel;
private UserListModel userListModel;
public UserController(DbConnector pDbCon, UserModel pModel) {
public UserController(DbConnector pDbCon, HashMap<String, Object> pModels) {
dbCon = pDbCon;
userModel = pModel;
userModel = (UserModel)pModels.get("usermodel");
userListModel = (UserListModel)pModels.get("userlistmodel");
}
public int createUser(String pName, String pSurname){
int status = dbCon.createUser(pName, pSurname);
userModel.updateTable();
userModel.updateModel();
userListModel.updateModel();
return status;
}
@@ -25,11 +31,8 @@ public class UserController {
int status = dbCon.editUser(pId, pName, pSurname);
if(status == 0){
int row = userModel.getRowFromId(pId);
userModel.getUserByRow(row).setName(pName);
userModel.getUserByRow(row).setSurname(pSurname);
userModel.fireTableRowsUpdated(row, row);
userModel.updateModel();
userListModel.updateModel();
}
return status;
@@ -37,9 +40,8 @@ public class UserController {
public boolean deleteUser(int id){
if(dbCon.deleteUser(id)){
int row = userModel.getRowFromId(id);
userModel.removeRow(row);
userModel.updateModel();
userListModel.updateModel();
return true;
}

View File

@@ -9,6 +9,7 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;
import java.util.HashMap;
import java.util.Vector;
import javax.swing.BorderFactory;
@@ -31,7 +32,6 @@ import de.katho.kBorrow.models.ArticleModel;
public class ArticlePanel extends JPanel implements ActionListener, KeyListener {
private static final long serialVersionUID = -8511924597640457608L;
private ArticleModel articleModel;
private ArticleController articleController;
private JTextArea textAreaArticleDescription;
private JTextField textFieldArticleName;
@@ -40,16 +40,18 @@ public class ArticlePanel extends JPanel implements ActionListener, KeyListener
private JLabel lblArticleStatus;
private boolean articleModeEdit;
private int articleEditId;
private ArticleModel articleModel;
/**
* Create the panel.
* @throws IOException
*/
public ArticlePanel(final DbConnector dbCon) throws IOException {
public ArticlePanel(final DbConnector dbCon, HashMap<String, Object> pModels) throws IOException {
super();
this.setLayout(null);
articleModel = new ArticleModel(dbCon);
articleController = new ArticleController(dbCon, articleModel);
articleModel = (ArticleModel)pModels.get("articlemodel");
articleController = new ArticleController(dbCon, pModels);
/*
* Tabelle und drumherum

View File

@@ -9,11 +9,16 @@ import javax.swing.UnsupportedLookAndFeelException;
import java.awt.BorderLayout;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import de.katho.kBorrow.Settings;
import de.katho.kBorrow.db.DbConnector;
import de.katho.kBorrow.db.SqlConnector;
import de.katho.kBorrow.db.SqliteConnector;
import de.katho.kBorrow.models.ArticleModel;
import de.katho.kBorrow.models.FreeArticleModel;
import de.katho.kBorrow.models.UserModel;
import de.katho.kBorrow.models.UserListModel;
public class MainWindow {
@@ -26,6 +31,7 @@ public class MainWindow {
private Settings set;
private HashMap<String, Object> models;
/**
* Create the application.
@@ -51,12 +57,18 @@ public class MainWindow {
}
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
models = new HashMap<String, Object>();
models.put("usermodel", new UserModel(dbCon));
models.put("userlistmodel", new UserListModel(dbCon));
models.put("articlemodel", new ArticleModel(dbCon));
models.put("freearticlemodel", new FreeArticleModel(dbCon));
this.tabbedPane = new JTabbedPane(JTabbedPane.TOP);
this.frame.getContentPane().add(this.tabbedPane, BorderLayout.CENTER);
this.tabbedPane.addTab("Neue Ausleihe", new PanelNewLending(this.dbCon));
this.tabbedPane.addTab("Ausleihen verwalten", new PanelManageLendings(this.dbCon));
this.tabbedPane.addTab("Artikel verwalten", new ArticlePanel(this.dbCon));
this.tabbedPane.addTab("Benutzer verwalten", new UserPanel(this.dbCon));
this.tabbedPane.addTab("Neue Ausleihe", new NewLendingPanel(this.dbCon, models));
this.tabbedPane.addTab("Ausleihen verwalten", new ManageLendingsPanel(this.dbCon, models));
this.tabbedPane.addTab("Artikel verwalten", new ArticlePanel(this.dbCon, models));
this.tabbedPane.addTab("Benutzer verwalten", new UserPanel(this.dbCon, models));
}
catch(ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | UnsupportedLookAndFeelException | SQLException e) {

View File

@@ -1,10 +1,12 @@
package de.katho.kBorrow.gui;
import java.util.HashMap;
import javax.swing.JPanel;
import de.katho.kBorrow.db.DbConnector;
public class PanelManageLendings extends JPanel {
public class ManageLendingsPanel extends JPanel {
/**
*
@@ -15,7 +17,7 @@ public class PanelManageLendings extends JPanel {
* Create the panel.
* @param dbCon
*/
public PanelManageLendings(DbConnector dbCon) {
public ManageLendingsPanel(DbConnector dbCon, HashMap<String, Object> pModels) {
}

View File

@@ -5,6 +5,7 @@ import javax.swing.JPanel;
import de.katho.kBorrow.db.DbConnector;
import de.katho.kBorrow.listener.NewLendingTableButton;
import de.katho.kBorrow.models.FreeArticleModel;
import de.katho.kBorrow.models.UserListModel;
import javax.swing.border.TitledBorder;
import javax.swing.JScrollPane;
@@ -12,6 +13,7 @@ import javax.swing.JTable;
import java.awt.BorderLayout;
import java.io.IOException;
import java.util.HashMap;
import javax.swing.JLabel;
import javax.swing.JComboBox;
@@ -22,7 +24,7 @@ import javax.swing.UIManager;
import java.awt.Color;
public class PanelNewLending extends JPanel {
public class NewLendingPanel extends JPanel {
/**
*
@@ -32,17 +34,20 @@ public class PanelNewLending extends JPanel {
private JTextField tfName;
private JTextField tfSurname;
private JTextField tfStudentNumber;
private UserListModel userListModel;
/**
* Create the panel.
* @param dbCon
* @throws IOException
*/
public PanelNewLending(final DbConnector dbCon) throws IOException {
this.setLayout(null);
public NewLendingPanel(final DbConnector dbCon, HashMap<String, Object> pModel) throws IOException {
setLayout(null);
// FreeArticleTable
this.freeArticleModel = new FreeArticleModel(dbCon);
freeArticleModel = (FreeArticleModel)pModel.get("freearticlemodel");
userListModel = (UserListModel)pModel.get("userlistmodel");
JTable freeArticleTable = new JTable(freeArticleModel);
freeArticleTable.setRowHeight(30);
@@ -101,7 +106,7 @@ public class PanelNewLending extends JPanel {
lblBenutzer.setBounds(350, 20, 70, 20);
panelNewLending.add(lblBenutzer);
JComboBox comboBox = new JComboBox();
JComboBox<String> comboBox = new JComboBox<String>(userListModel);
comboBox.setBounds(430, 20, 130, 20);
panelNewLending.add(comboBox);

View File

@@ -7,6 +7,7 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;
import java.util.HashMap;
import java.util.Vector;
import javax.swing.JButton;
@@ -37,11 +38,11 @@ public class UserPanel extends JPanel implements ActionListener, KeyListener {
private UserModel userModel;
private UserController userController;
public UserPanel(final DbConnector dbCon) throws IOException{
public UserPanel(final DbConnector dbCon, HashMap<String, Object> pModels) throws IOException{
super();
this.setLayout(null);
this.userModel = new UserModel(dbCon);
this.userController = new UserController(dbCon, this.userModel);
setLayout(null);
userModel = (UserModel)pModels.get("usermodel");
userController = new UserController(dbCon, pModels);
//Tabelle und drumherum
JTable userTable = new JTable(userModel);

View File

@@ -9,7 +9,7 @@ import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JTable;
import de.katho.kBorrow.gui.PanelNewLending;
import de.katho.kBorrow.gui.NewLendingPanel;
import de.katho.kBorrow.models.FreeArticleModel;
public class NewLendingTableButton extends TableButton {
@@ -19,7 +19,7 @@ public class NewLendingTableButton extends TableButton {
*/
private static final long serialVersionUID = 7492272258718253745L;
public NewLendingTableButton(String pLabel, final JTable pTable, final PanelNewLending pPanel) throws IOException {
public NewLendingTableButton(String pLabel, final JTable pTable, final NewLendingPanel pPanel) throws IOException {
super(pLabel);
ImageIcon icon = new ImageIcon(ImageIO.read(new File("assets/icons/go-down.png")));

View File

@@ -20,17 +20,16 @@ public class ArticleModel extends AbstractTableModel {
public ArticleModel(DbConnector pDbCon){
header = new String [] {"ID", "Artikelname", "Artikelbeschreibung", "", ""};
this.dbCon = pDbCon;
this.updateTable();
this.updateModel();
}
public String getColumnName(int index){
return header[index];
}
public void updateTable() {
public void updateModel() {
this.data = this.dbCon.getArticleList();
this.fireTableDataChanged();
}
public int getColumnCount() {
@@ -46,13 +45,13 @@ public class ArticleModel extends AbstractTableModel {
public Object getValueAt(int pRow, int pCol) {
switch(pCol){
case 0:
return String.valueOf(this.data.get(pRow).getId());
return String.valueOf(data.get(pRow).getId());
case 1:
return this.data.get(pRow).getName();
return data.get(pRow).getName();
case 2:
return this.data.get(pRow).getDescription();
return data.get(pRow).getDescription();
default:
return null;
@@ -108,16 +107,6 @@ public class ArticleModel extends AbstractTableModel {
return -1;
}
/**
* Entfernt die gegebene Zeile aus der ArrayList
*
* @param pRow Zeile, die gel<65>scht wird.
*/
public void removeRow(int pRow){
data.remove(pRow);
fireTableRowsDeleted(pRow, pRow);
}
/**
* Gibt das Article-Objekt der <20>bergebenen Zeile zur<75>ck.
*

View File

@@ -14,10 +14,10 @@ public class FreeArticleModel extends ArticleModel {
super(pDbCon);
this.header = new String[] {"ID", "Artikelname", "Artikelbeschreibung", ""};
updateTable();
updateModel();
}
public void updateTable(){
public void updateModel(){
data = dbCon.getFreeArticleList();
fireTableDataChanged();
}

View File

@@ -0,0 +1,78 @@
package de.katho.kBorrow.models;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import de.katho.kBorrow.data.KUser;
import de.katho.kBorrow.db.DbConnector;
public class UserListModel extends DefaultComboBoxModel<String> {
/**
*
*/
private static final long serialVersionUID = -8653066929273274524L;
private DbConnector dbCon;
private Vector<KUser> list;
private KUser selectedItem = null;
public UserListModel(DbConnector pDbCon){
super();
dbCon = pDbCon;
updateModel();
}
public void updateModel() {
list = new Vector<KUser>();
ArrayList<KUser> data = dbCon.getUserList();
for(KUser elem : data){
list.add(elem);
}
setSelectedItem(list.firstElement());
fireIntervalAdded(this, 0, list.size()-1);
}
public void setSelectedItem(KUser object) {
if(selectedItem == null && object == null) return;
if(selectedItem != null && selectedItem.equals(object)) return;
if(object!= null && getIndexOf(object) == -1) return;
selectedItem = object;
fireContentsChanged(this, -1, -1);
}
public String getSelectedItem(){
if(selectedItem != null ) return selectedItem.getName()+" "+selectedItem.getSurname();
return "";
}
public String getElementAt(int index){
if(index < 0 || index >= list.size()) return null;
KUser obj = list.elementAt(index);
return obj.getName()+" "+obj.getSurname();
}
public int getSize(){
return list.size();
}
public void addElement(KUser object) {
list.addElement(object);
int index = list.size() - 1;
fireIntervalAdded(this, index, index);
if (list.size() == 1 && selectedItem == null)
setSelectedItem(object);
}
public int getIndexOf(KUser obj){
return list.indexOf(obj);
}
}

View File

@@ -18,8 +18,8 @@ public class UserModel extends AbstractTableModel {
private ArrayList<KUser> data = new ArrayList<KUser>();
public UserModel(DbConnector pDbCon){
this.dbCon = pDbCon;
this.updateTable();
dbCon = pDbCon;
updateModel();
}
@Override
@@ -53,9 +53,9 @@ public class UserModel extends AbstractTableModel {
return header[index];
}
public void updateTable(){
this.data = this.dbCon.getUserList();
this.fireTableDataChanged();
public void updateModel(){
data = dbCon.getUserList();
fireTableDataChanged();
}
// Die Funktion muss differenzierter werden
@@ -98,11 +98,4 @@ public class UserModel extends AbstractTableModel {
}
return null;
}
public void removeRow(int pRow){
data.remove(pRow);
fireTableRowsDeleted(pRow, pRow);
}
}