addComponent(optionPanel);
try {
StatusDAO s = df.getStatusDAO();
Status st = s.getStatusByStatusID(p.getCurrentStatusID());
statusValue.setValue(st.getStatusName());
} catch (DAOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (StatusNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
user.setHeight("100px");
user.setImmediate(true);
user.setSelectable(true);
ArrayList<Resource> userArray = null;
final ResourceDAO userDAO = df.getResourceDAO();
try {
userArray = userDAO.getWorkersByProject(p);
user.addContainerProperty("User ID", String.class, null);
user.addContainerProperty("User Name", String.class, null);
// list.setVisibleColumns(new Object[] { "Type Name" });
for (int i = 0; i < userArray.size(); i++) {
Resource resUser = userArray.get(i);
user.addItem(
new Object[] {
Integer.toString(resUser.getResourceID()),
resUser.getResourceName() }, i);
}
} catch (DAOException e) {
e.printStackTrace();
}
leader.setHeight("100px");
leader.setImmediate(true);
leader.setSelectable(true);
ArrayList<Resource> leaderArray = null;
final ResourceDAO leaderDAO = df.getResourceDAO();
try {
leaderArray = userDAO.getLeadersByProject(p);
leader.addContainerProperty("Leader ID", String.class, null);
leader.addContainerProperty("Leader Name", String.class, null);
// list.setVisibleColumns(new Object[] { "Type Name" });
for (int i = 0; i < leaderArray.size(); i++) {
Resource resLeader = leaderArray.get(i);
leader.addItem(
new Object[] {
Integer.toString(resLeader.getResourceID()),
resLeader.getResourceName() }, i);
}
} catch (DAOException e) {
e.printStackTrace();
}
add.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = 1200365843348797837L;
public void buttonClick(ClickEvent event) {
try {
userDAO.updateUserTask(
Integer.parseInt(user.getItem(user.getValue())
.getItemProperty("User ID").toString()),
p.getProjectID(), true);
// me.getApplication().getMainWindow().setContent(new
// ProjectOptionsPageUI(u, p));
leader.removeAllItems();
ArrayList<Resource> leaderArray2 = null;
try {
leaderArray2 = userDAO.getLeadersByProject(p);
leader.addContainerProperty("Leader ID", String.class,
null);
leader.addContainerProperty("Leader Name",
String.class, null);
// list.setVisibleColumns(new Object[] { "Type Name" });
for (int i = 0; i < leaderArray2.size(); i++) {
Resource resLeader = leaderArray2.get(i);
leader.addItem(
new Object[] {
Integer.toString(resLeader
.getResourceID()),
resLeader.getResourceName() }, i);
}
} catch (DAOException e) {
e.printStackTrace();
}
user.removeAllItems();
ArrayList<Resource> userArray2 = null;
try {
userArray2 = userDAO.getWorkersByProject(p);
user.addContainerProperty("User ID", String.class, null);
user.addContainerProperty("User Name", String.class,
null);
// list.setVisibleColumns(new Object[] { "Type Name" });
for (int i = 0; i < userArray2.size(); i++) {
Resource resUser = userArray2.get(i);
user.addItem(
new Object[] {
Integer.toString(resUser
.getResourceID()),
resUser.getResourceName() }, i);
}
} catch (DAOException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DAOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProjectNeedsActiveLeaderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
remove.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = -8636303013936005088L;
public void buttonClick(ClickEvent event) {
try {
leaderDAO.updateUserTask(
Integer.parseInt(leader.getItem(leader.getValue())
.getItemProperty("Leader ID").toString()),
p.getProjectID(), false);
leader.removeAllItems();
ArrayList<Resource> leaderArray2 = null;
try {
leaderArray2 = userDAO.getLeadersByProject(p);
leader.addContainerProperty("Leader ID", String.class,
null);
leader.addContainerProperty("Leader Name",
String.class, null);
// list.setVisibleColumns(new Object[] { "Type Name" });
for (int i = 0; i < leaderArray2.size(); i++) {
Resource resLeader = leaderArray2.get(i);
leader.addItem(
new Object[] {
Integer.toString(resLeader
.getResourceID()),
resLeader.getResourceName() }, i);
}
} catch (DAOException e) {
e.printStackTrace();
}
user.removeAllItems();
ArrayList<Resource> userArray2 = null;
try {
userArray2 = userDAO.getWorkersByProject(p);
user.addContainerProperty("User ID", String.class, null);
user.addContainerProperty("User Name", String.class,
null);
// list.setVisibleColumns(new Object[] { "Type Name" });
for (int i = 0; i < userArray2.size(); i++) {
Resource resUser = userArray2.get(i);
user.addItem(
new Object[] {
Integer.toString(resUser
.getResourceID()),
resUser.getResourceName() }, i);
}
} catch (DAOException e) {
e.printStackTrace();
}
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DAOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ProjectNeedsActiveLeaderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
me.getApplication().getMainWindow()
.showNotification("Don't have enough leader!");
}
}
});
ok.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = -8855153433214641114L;
public void buttonClick(ClickEvent event) {
me.getApplication().getMainWindow().removeWindow(me);
}
});
save.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = 3532989396210830103L;
public void buttonClick(ClickEvent event) {
Date projectStart = p.getStartDate();
Date projectEnd = (Date) date.getValue();
Date dateNow = new Date();
System.out.println(projectEnd.toString());
if (projectEnd.after(projectStart) && projectEnd.after(dateNow)) {
BookingDAO bookDAO = df.getBookingDAO();
int maxweek;
int weeknow = Timestamp.toInt(projectEnd);
try {
Booking bmax = bookDAO.getMaxBookingByProject(p);
maxweek = bmax.getWeek();
if (weeknow > maxweek) { // lehet updatelni
try {
p.setDeadLineDate(projectEnd);
df.getProjectDAO().updateProject(p);
me.getApplication().getMainWindow()
.showNotification("The date is saved!");
} catch (ProjectNameExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
me.getApplication().getMainWindow()
.showNotification("Date error!");
}
}
} catch (DAOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
me.getApplication().getMainWindow()
.showNotification("Database error!");
} catch (ProjectNotBookedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
if (projectEnd.after(projectStart)
&& projectEnd.after(dateNow)) {
try {
p.setDeadLineDate(projectEnd);
df.getProjectDAO().updateProject(p);
me.getApplication().getMainWindow()
.showNotification("The date is saved!");
} catch (ProjectNameExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
me.getApplication().getMainWindow()
.showNotification("Database error!");
}
}
else{
me.getApplication().getMainWindow()
.showNotification("Date error!");
}
}
} else {
me.getApplication().getMainWindow()
.showNotification("Date error!");
}
}
});
cancel.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = -2793959129253646481L;
public void buttonClick(ClickEvent event) {
date.setValue(p.getDeadLineDate());
}
});
editStatus.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = -3498888774206256806L;
public void buttonClick(ClickEvent event) {
final Window editWindow = new Window("Edit");
list.setHeight("100px");
list.setImmediate(true);
list.setSelectable(true);
ArrayList<Status> statusArray = null;
StatusDAO statusDAO = df.getStatusDAO();
try {
statusArray = statusDAO.getAllStatuses();
list.addContainerProperty("Status ID", String.class, null);
list.addContainerProperty("Status Name", String.class, null);
// list.setVisibleColumns(new Object[] { "Type Name" });
for (int i = 0; i < statusArray.size(); i++) {
Status status = statusArray.get(i);
list.addItem(
new Object[] {
Integer.toString(status.getStatusID()),
status.getStatusName() }, i);
}
} catch (DAOException e) {
e.printStackTrace();
me.getApplication().getMainWindow()
.showNotification("Database error!");
}
editWindow.addComponent(list);
Button saveButton2 = new Button("Save");
editWindow.addComponent(saveButton2);
editWindow.setWidth("400");
editWindow.setImmediate(true);
saveButton2.setImmediate(true);
saveButton2.addListener(new ClickListener() {
/**
*
*/
private static final long serialVersionUID = 5003260962276510754L;
public void buttonClick(ClickEvent event) {
if (Integer.parseInt(list.getItem(list.getValue())
.getItemProperty("Status ID").toString()) != 0) {
p.setCurrentStatusID(Integer.parseInt(list
.getItem(list.getValue())
.getItemProperty("Status ID").toString()));
}
System.out.println(p.getCurrentStatusID());
try {
df.getProjectDAO().updateProject(p);
} catch (ProjectNameExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
me.getApplication().getMainWindow()
.showNotification("Database error!");
}
me.getApplication().getMainWindow()
.removeWindow(editWindow);
try {
Status stat = df
.getStatusDAO()
.getStatusByStatusID(p.getCurrentStatusID());
statusValue.setValue(stat.getStatusName());
} catch (DAOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (StatusNotFoundException e) {
// TODO Auto-generated catch block