Scheduler

Hello Everyone,
I’m new to Vaadin, so it would be nice if you could answer some of my questions. I would like to make a Scheduler that looks like this:
You should be able to click on the field, where you want to add a new activity. After clicking a new window opens where you can enter the name of the activity and the description.
It should also be connected to a sql database, where the activities are stored.
I would like to know, what the best way to realize this, or just a few tips(like if using a Table would be the best). Thanks!

I am not a vaadin expert but I have been fiddling with it for some time now.

I would use a table for the main scheduler.

For linking to the DB, you can use a
SQL container
to link the table directly to the DB. I haven’t used it myself but it seems easy to set up. Personally I use an ORM framework so all the DB ends up in beans which are easy to handle but the overhead might be too much for a simple scheduler.

You will need to disable selection on the table (by default user clicks select whole lines) and add a click listener on the table to have the effect you want.

Click handler demo
(click on ‘see the source’ and look for “table.addListener(new ItemClickListener()” for some code)
Then from the click handler you can open a modal subwindow with your second form.

How to open a modal sub window

Don’t forget to go through
the book
for more details on the tables, event handlers, sub windows and containers. And come back to the forum for any question.

Ok, thank you very much for your answer! I will post if I have any question.:smiley:

Hey guys, I have a few questions regarding the SQLContainer.
This are my current classes for the Scheduler.

The main Window:


public class SchedulerApplication extends Application {
	
	@Override
	public void init() {
		
		Window main = new Window("The Main Window"); 
	    setMainWindow(main);
	    main.addComponent(new SchedulerTable(main));
	
	 }

}

The Scheduler with Listener:


public class SchedulerTable extends Table{
	
	
	private Window fenster;
	private GridLayout grid = new GridLayout(2,3);
	private Window main;
	
	public SchedulerTable(Window main) {
		this.main = main;
		setSizeFull();
		addTableContent();
		addTableListener();
		
	}
	
	public void addTableContent(){
		
		addContainerProperty("Monday", String.class, null);
		addContainerProperty("Tuesday", String.class, null);
		addContainerProperty("Wednesday", String.class, null);
		addContainerProperty("Thursday", String.class, null);
		addContainerProperty("Friday", String.class, null);
		addContainerProperty("Saturday", String.class, null);
		addContainerProperty("Sunday", String.class, null);
		addItem(new Object[]{"7:00", "sleep", "sleep","school","sleep","jogging",".."}
                                           ,new Integer(1));
		setSelectable(false);
		setImmediate(true);

	}
	
	public void addTableListener(){
		
		addListener(new ItemClickListener() {
			public void itemClick(ItemClickEvent event) {
				if (event.getButton() == ItemClickEvent.BUTTON_LEFT) {
                	System.out.println("Hallo");
                	new EntryWindow(main);
				}
			}
		});
	}

}

And the Window, where the user can add a new Acticity:


public class EntryWindow extends Window {
	
	private GridLayout grid = new GridLayout(2,3);
	private Window main;
	
	public EntryWindow(Window main){
		
		/* Create a new window. */
		this.main = main;
		new Window("Please enter Activity and Descrition", new GridLayout());
		this.center();
		this.addComponent(grid);
		grid.addComponent(new Label("Activity: "));
    	grid.addComponent(new TextField());
    	grid.addComponent(new Label("Description: "));
    	grid.addComponent(new TextField());
    	grid.addComponent(new Button("Ok"));
    	grid.addComponent(new Button("Cancel"));
    	
    	this.setHeight("200px");
    	this.setWidth("300px");
        
    	this.setModal(true);
   		/* Add the window inside the main window. */
    	main.addWindow(this);
	}
}

And the DatabaseHelper.class from the SQLContainer.class.

First I would like to know how to Create the tables. I don’t get how they initialized the tables in the tutorial. I think two tables would be the best:

  1. date: day, time, activityname
  2. activity: activityname, description

The second thing that I’m not sure about is how to get the content of a field displayed in my EntryWindow and then saved (if it has been changed).

Is it enough to have the hsqldb.jar running as server?
I appreciate any help, maybe someone has a download link to a project that similar! Thanks.