src/main/java/ru/indvdum/mywork/vaadin/EditWorkDialog.java
changeset 12 93ea5ae33f02
parent 11 e576975e68f7
child 14 1d1d4c94d251
equal deleted inserted replaced
11:e576975e68f7 12:93ea5ae33f02
    34 	private ComboBox workDay = null;
    34 	private ComboBox workDay = null;
    35 	private ComboBox workTask = null;
    35 	private ComboBox workTask = null;
    36 	private TextField workHours = null;
    36 	private TextField workHours = null;
    37 	private RichTextArea workResult = null;
    37 	private RichTextArea workResult = null;
    38 
    38 
    39 	public EditWorkDialog(MyWorkApplication myApp, EditState state, Work work) throws Exception {
    39 	public EditWorkDialog(MyWorkApplication myApp, Work work) throws Exception {
    40 		super();
    40 		super();
    41 		this.myApp = myApp;
    41 		this.myApp = myApp;
    42 		this.state = state;
    42 		if(work == null)
       
    43 			state = EditState.CREATE;
       
    44 		else
       
    45 			state = EditState.EDIT;
    43 		switch(state){
    46 		switch(state){
    44 		case CREATE:
    47 		case CREATE:
    45 			setCaption("Creating new work");
    48 			setCaption("Creating new work");
    46 			if(work != null)
       
    47 				throw new Exception("Illegal argument: work must be null in creating state.");
       
    48 			work = new Work();
    49 			work = new Work();
    49 			work.setHours(0f);
    50 			work.setHours(0f);
    50 			work.setResult("");
    51 			work.setResult("");
    51 			this.work = work;
    52 			this.work = work;
    52 			break;
    53 			break;
    53 		case EDIT:
    54 		case EDIT:
    54 			setCaption("Editing work");
    55 			setCaption("Editing work");
    55 			if(work == null)
       
    56 				throw new Exception("Illegal argument: work must be not null in editing state.");
       
    57 			this.work = work;
    56 			this.work = work;
    58 			break;
    57 			break;
    59 		}
    58 		}
    60 		init();
    59 		init();
    61 	}
    60 	}