src/main/java/ru/indvdum/mywork/vaadin/EditTaskDialog.java
changeset 12 93ea5ae33f02
parent 11 e576975e68f7
child 14 1d1d4c94d251
equal deleted inserted replaced
11:e576975e68f7 12:93ea5ae33f02
    20 	private EditState state = null;
    20 	private EditState state = null;
    21 	private Task task = null;
    21 	private Task task = null;
    22 	private TextField taskName = null;
    22 	private TextField taskName = null;
    23 	private RichTextArea taskDescription = null;
    23 	private RichTextArea taskDescription = null;
    24 
    24 
    25 	public EditTaskDialog(MyWorkApplication myApp, EditState state, Task task) throws Exception {
    25 	public EditTaskDialog(MyWorkApplication myApp, Task task) throws Exception {
    26 		super();
    26 		super();
    27 		this.myApp = myApp;
    27 		this.myApp = myApp;
    28 		this.state = state;
    28 		if(task == null)
       
    29 			state = EditState.CREATE;
       
    30 		else 
       
    31 			state = EditState.EDIT;
    29 		switch(state){
    32 		switch(state){
    30 		case CREATE:
    33 		case CREATE:
    31 			setCaption("Creating new task");
    34 			setCaption("Creating new task");
    32 			if(task != null)
       
    33 				throw new Exception("Illegal argument: task must be null in creating state.");
       
    34 			task = new Task();
    35 			task = new Task();
    35 			task.setName("");
    36 			task.setName("");
    36 			task.setDescription("");
    37 			task.setDescription("");
    37 			this.task = task;
    38 			this.task = task;
    38 			break;
    39 			break;
    39 		case EDIT:
    40 		case EDIT:
    40 			setCaption("Editing task");
    41 			setCaption("Editing task");
    41 			if(task == null)
       
    42 				throw new Exception("Illegal argument: task must be not null in editing state.");
       
    43 			this.task = task;
    42 			this.task = task;
    44 			break;
    43 			break;
    45 		}
    44 		}
    46 		init();
    45 		init();
    47 	}
    46 	}