src/main/java/ru/indvdum/mywork/vaadin/EditDayDialog.java
changeset 12 93ea5ae33f02
parent 11 e576975e68f7
child 14 1d1d4c94d251
     1.1 --- a/src/main/java/ru/indvdum/mywork/vaadin/EditDayDialog.java	Tue Aug 23 14:48:38 2011 +0300
     1.2 +++ b/src/main/java/ru/indvdum/mywork/vaadin/EditDayDialog.java	Tue Aug 23 16:21:44 2011 +0300
     1.3 @@ -32,15 +32,16 @@
     1.4  	private PopupDateField dayDate = null;
     1.5  	private TextField dayHours = null;
     1.6  
     1.7 -	public EditDayDialog(MyWorkApplication myApp, EditState state, Day day) throws Exception {
     1.8 +	public EditDayDialog(MyWorkApplication myApp, Day day) throws Exception {
     1.9  		super();
    1.10  		this.myApp = myApp;
    1.11 -		this.state = state;
    1.12 +		if(day == null)
    1.13 +			state = EditState.CREATE;
    1.14 +		else
    1.15 +			state = EditState.EDIT;
    1.16  		switch(state){
    1.17  		case CREATE:
    1.18  			setCaption("Creating new day");
    1.19 -			if(day != null)
    1.20 -				throw new Exception("Illegal argument: day must be null in creating state.");
    1.21  			day = new Day();
    1.22  			Calendar calDay = Calendar.getInstance();
    1.23  			calDay.set(Calendar.HOUR_OF_DAY, 0);
    1.24 @@ -65,8 +66,6 @@
    1.25  			break;
    1.26  		case EDIT:
    1.27  			setCaption("Editing day");
    1.28 -			if(day == null)
    1.29 -				throw new Exception("Illegal argument: day must be not null in editing state.");
    1.30  			this.day = day;
    1.31  			break;
    1.32  		}