package com.dungeonstory.ui.view.character;

import com.dungeonstory.backend.data.Character;
import com.dungeonstory.backend.data.User;
import com.dungeonstory.backend.service.Services;
import com.dungeonstory.ui.authentication.CurrentUser;
import com.dungeonstory.ui.util.ViewConfig;
import com.dungeonstory.ui.util.ViewConfig.CreateMode;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;

@ViewConfig(uri = CharacterView.URI, displayName = "characterView.caption", createMode = CreateMode.ALWAYS_NEW)
public class CharacterView extends VerticalLayout implements View {

    private static final long serialVersionUID = 3904939774479485709L;

    public static final String URI = "character";

    private TabSheet tabsheet;

    public CharacterView() {
        tabsheet = new TabSheet();
    }

    @Override
    public void enter(ViewChangeEvent event) {

        CharacterInfoForm infoForm = new CharacterInfoForm();
        User user = Services.getUserService().read(CurrentUser.get().getId());
        Services.getUserService().refresh(user);
        Character character = user.getCharacter();
        infoForm.setEntity(character);
        tabsheet.addTab(infoForm, "Informations");

//        EquipmentList equipment = new EquipmentList();
//        tabsheet.addTab(equipment, "Équipement");

        ProficiencyList proficiencies = new ProficiencyList(character);
        tabsheet.addTab(proficiencies, "Maitrises");

        ClassFeatureList features = new ClassFeatureList(character);
        tabsheet.addTab(features, "Dons");

        addComponent(tabsheet);

    }

}

@@ -271,79 +271,250 @@
 .ui.
-util.ViewConfig;%0D%0Aimport com.dungeonstory.ui.util.ViewConfig.CreateMode
+event.EventBus;%0D%0Aimport com.dungeonstory.ui.event.NavigationEvent;%0D%0Aimport com.dungeonstory.ui.util.ViewConfig;%0D%0Aimport com.dungeonstory.ui.util.ViewConfig.CreateMode;%0D%0Aimport com.vaadin.fluent.ui.FButton;%0D%0Aimport com.vaadin.icons.VaadinIcons
 ;%0D%0Ai
@@ -681,16 +681,56 @@
 Layout;%0D
+%0Aimport com.vaadin.ui.themes.ValoTheme;%0D
 %0A%0D%0A@View
@@ -1213,71 +1213,8 @@
 %0D%0A%0D%0A
-        CharacterInfoForm infoForm = new CharacterInfoForm();%0D%0A
     
@@ -1386,24 +1386,629 @@
 haracter();%0D
+%0A%0D%0A        if (character.getExperience() %3E= character.getLevel().getMaxExperience()) %7B%0D%0A            FButton levelUpButton = new FButton(%22Niveau%22).withIcon(VaadinIcons.ARROW_UP)%0D%0A                                                         .withStyleName(ValoTheme.BUTTON_LARGE)%0D%0A                                                         .withStyleName(ValoTheme.BUTTON_FRIENDLY);%0D%0A            levelUpButton.addClickListener(e -%3E EventBus.post(new NavigationEvent(LevelUpView.LEVEL_UP_URI)));%0D%0A            addComponent(levelUpButton);%0D%0A        %7D%0D%0A%0D%0A        CharacterInfoForm infoForm = new CharacterInfoForm();%0D
 %0A        inf

add level up button on CharacterView