Example usage for com.vaadin.server FontAwesome ARROW_LEFT

List of usage examples for com.vaadin.server FontAwesome ARROW_LEFT

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome ARROW_LEFT.

Prototype

FontAwesome ARROW_LEFT

To view the source code for com.vaadin.server FontAwesome ARROW_LEFT.

Click Source Link

Usage

From source file:de.metas.procurement.webui.ui.component.DateNavigation.java

License:Open Source License

public DateNavigation() {
    super();/* w  ww .  j  a v a  2 s.c  o  m*/
    Application.autowire(this);

    setSizeFull();
    addStyleName(STYLE);

    prevDateButton = new Button();
    prevDateButton.setEnabled(false);
    prevDateButton.setIcon(FontAwesome.ARROW_LEFT);
    prevDateButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            onPrevDate();
        }
    });

    nextDateButton = new Button();
    nextDateButton.setEnabled(false);
    nextDateButton.setIcon(FontAwesome.ARROW_RIGHT);
    nextDateButton.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            onNextDate();
        }
    });

    dateLabel = new Label();
    dateLabel.setSizeFull();
    dateLabel.addStyleName(STYLE_DayLabel);

    addComponents(prevDateButton, dateLabel, nextDateButton);
    setExpandRatio(dateLabel, 1.0f);
}

From source file:fi.semantum.strategia.Main.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {

    getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {
        public void uriFragmentChanged(UriFragmentChangedEvent source) {
            applyFragment(source.getUriFragment(), true);
        }//from w ww.j a v  a  2  s.  c o m
    });

    String pathInfo = request.getPathInfo();
    if (pathInfo.startsWith("/"))
        pathInfo = pathInfo.substring(1);
    if (pathInfo.endsWith("/"))
        pathInfo = pathInfo.substring(0, pathInfo.length() - 1);

    String databaseId = validatePathInfo(pathInfo);

    setWindowWidth(Page.getCurrent().getBrowserWindowWidth(), Page.getCurrent().getBrowserWindowHeight());

    // Find the application directory
    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

    // Image as a file resource
    redResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_red.png"));
    greenResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_green.png"));
    blackResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_black.png"));
    mapMagnify = new FileResource(new File(basepath + "/WEB-INF/images/map_magnify.png"));

    abs = new AbsoluteLayout();

    final VerticalLayout vs = new VerticalLayout();
    vs.setSizeFull();

    abs.addComponent(vs);
    setContent(abs);

    // This will set the login cookie
    Wiki.login(this);

    // Make sure that the printing directory exists
    new File(Main.baseDirectory(), "printing").mkdirs();

    database = Database.load(this, databaseId);
    database.getOrCreateTag("Tavoite");
    database.getOrCreateTag("Painopiste");

    for (Strategiakartta map : Strategiakartta.enumerate(database)) {
        Strategiakartta parent = map.getPossibleParent(database);
        if (parent == null)
            uiState.setCurrentMap(parent);
    }

    if (uiState.getCurrentMap() == null)
        uiState.setCurrentMap(database.getRoot());

    uiState.currentPosition = uiState.getCurrentMap();

    uiState.currentItem = uiState.getCurrentMap();

    setPollInterval(10000);

    addPollListener(new PollListener() {

        @Override
        public void poll(PollEvent event) {

            if (database.checkChanges()) {
                String curr = uiState.getCurrentMap().uuid;
                database = Database.load(Main.this, database.getDatabaseId());
                uiState.setCurrentMap((Strategiakartta) database.find(curr));
                Updates.updateJS(Main.this, false);
            }

        }

    });

    js.addListener(new MapListener(this, false));
    js2.addListener(new MapListener(this, true));

    browser_.addListener(new BrowserListener() {

        @Override
        public void select(double x, double y, String uuid) {
            Base b = database.find(uuid);
            Actions.selectAction(Main.this, x, y, null, b);
        }

        @Override
        public void save(String name, Map<String, BrowserNodeState> states) {

            UIState state = getUIState().duplicate(name);
            state.browserStates = states;

            account.uiStates.add(state);

            Updates.update(Main.this, true);

        }

    });

    Page.getCurrent().addBrowserWindowResizeListener(new BrowserWindowResizeListener() {

        @Override
        public void browserWindowResized(BrowserWindowResizeEvent event) {
            setWindowWidth(event.getWidth(), event.getHeight());
            Updates.updateJS(Main.this, false);
        }
    });

    modeLabel = new Label("Katselutila");
    modeLabel.setWidth("95px");
    modeLabel.addStyleName("viewMode");

    mode = new Button();
    mode.setDescription("Siirry tiedon sytttilaan");
    mode.setIcon(FontAwesome.EYE);
    mode.addStyleName(ValoTheme.BUTTON_TINY);

    mode.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            if ("Siirry tiedon sytttilaan".equals(mode.getDescription())) {

                mode.setDescription("Siirry katselutilaan");
                mode.setIcon(FontAwesome.PENCIL);
                modeLabel.setValue("Sytttila");
                modeLabel.removeStyleName("viewMode");
                modeLabel.addStyleName("editMode");

                UIState s = uiState.duplicate(Main.this);
                s.input = true;
                setFragment(s, true);

            } else {

                mode.setDescription("Siirry tiedon sytttilaan");
                mode.setIcon(FontAwesome.EYE);
                modeLabel.setValue("Katselutila");
                modeLabel.removeStyleName("editMode");
                modeLabel.addStyleName("viewMode");

                UIState s = uiState.duplicate(Main.this);
                s.input = false;
                setFragment(s, true);

            }

        }

    });

    meterMode = new Button();
    meterMode.setDescription("Vaihda toteumamittareihin");
    meterMode.setCaption("Ennuste");
    meterMode.addStyleName(ValoTheme.BUTTON_TINY);

    meterMode.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            if ("Vaihda toteumamittareihin".equals(meterMode.getDescription())) {

                meterMode.setDescription("Vaihda ennustemittareihin");
                meterMode.setCaption("Toteuma");

                UIState s = uiState.duplicate(Main.this);
                s.setActualMeters();
                setFragment(s, true);

            } else {

                meterMode.setDescription("Vaihda toteumamittareihin");
                meterMode.setCaption("Ennuste");

                UIState s = uiState.duplicate(Main.this);
                s.setForecastMeters();
                setFragment(s, true);

            }

        }

    });

    pdf = new PDFButton();
    pdf.setDescription("Tallenna kartta PDF-muodossa");
    pdf.setIcon(FontAwesome.PRINT);
    pdf.addStyleName(ValoTheme.BUTTON_TINY);

    pdf.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            Utils.print(Main.this);

        }

    });

    propertyExcelButton = new Button();
    propertyExcelButton.setDescription("Tallenna tiedot Excel-tiedostona");
    propertyExcelButton.setIcon(FontAwesome.PRINT);
    propertyExcelButton.addStyleName(ValoTheme.BUTTON_TINY);

    OnDemandFileDownloader dl = new OnDemandFileDownloader(new OnDemandStreamSource() {

        private static final long serialVersionUID = 981769438054780731L;

        File f;
        Date date = new Date();

        @Override
        public InputStream getStream() {

            String uuid = UUID.randomUUID().toString();
            File printing = new File(Main.baseDirectory(), "printing");
            f = new File(printing, uuid + ".xlsx");

            Workbook w = new XSSFWorkbook();
            Sheet sheet = w.createSheet("Sheet1");
            int row = 1;
            for (List<String> cells : propertyCells) {
                Row r = sheet.createRow(row++);
                for (int i = 0; i < cells.size(); i++) {
                    String value = cells.get(i);
                    r.createCell(i).setCellValue(value);
                }
            }

            try {
                FileOutputStream s = new FileOutputStream(f);
                w.write(s);
                s.close();
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                return new FileInputStream(f);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }

            throw new IllegalStateException();

        }

        @Override
        public void onRequest() {
        }

        @Override
        public long getFileSize() {
            return f.length();
        }

        @Override
        public String getFileName() {
            return "Strategiakartta_" + Utils.dateString(date) + ".xlsx";
        }

    });

    dl.getResource().setCacheTime(0);
    dl.extend(propertyExcelButton);

    states = new ComboBox();
    states.setWidth("250px");
    states.addStyleName(ValoTheme.COMBOBOX_TINY);
    states.setInvalidAllowed(false);
    states.setNullSelectionAllowed(false);

    states.addValueChangeListener(statesListener);

    saveState = new Button();
    saveState.setEnabled(false);
    saveState.setDescription("Tallenna nykyinen nkym");
    saveState.setIcon(FontAwesome.BOOKMARK);
    saveState.addStyleName(ValoTheme.BUTTON_TINY);
    saveState.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Utils.saveCurrentState(Main.this);
        }

    });

    class SearchTextField extends TextField {
        public boolean hasFocus = false;
    }

    final SearchTextField search = new SearchTextField();
    search.setWidth("100%");
    search.addStyleName(ValoTheme.TEXTFIELD_TINY);
    search.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    search.setInputPrompt("hae vapaasanahaulla valitun asian alta");
    search.setId("searchTextField");
    search.addShortcutListener(new ShortcutListener("Shortcut Name", ShortcutAction.KeyCode.ENTER, null) {
        @Override
        public void handleAction(Object sender, Object target) {

            if (!search.hasFocus)
                return;

            String text = search.getValue().toLowerCase();
            try {

                Map<String, String> content = new HashMap<String, String>();
                List<String> hits = Lucene.search(database.getDatabaseId(), text + "*");
                for (String uuid : hits) {
                    Base b = database.find(uuid);
                    if (b != null) {
                        String report = "";
                        Map<String, String> map = b.searchMap(database);
                        for (Map.Entry<String, String> e : map.entrySet()) {
                            if (e.getValue().contains(text)) {
                                if (!report.isEmpty())
                                    report += ", ";
                                report += e.getKey();
                            }
                        }
                        if (!report.isEmpty())
                            content.put(uuid, report);
                    }
                }

                uiState.setCurrentFilter(new SearchFilter(Main.this, content));

                Updates.updateJS(Main.this, false);

                switchToBrowser();

            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    });
    search.addFocusListener(new FocusListener() {

        @Override
        public void focus(FocusEvent event) {
            search.hasFocus = true;
        }
    });
    search.addBlurListener(new BlurListener() {

        @Override
        public void blur(BlurEvent event) {
            search.hasFocus = false;
        }
    });

    hallinnoi = new Button("Hallinnoi");
    hallinnoi.setWidthUndefined();
    hallinnoi.setVisible(false);
    hallinnoi.addStyleName(ValoTheme.BUTTON_TINY);
    hallinnoi.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (account != null) {
                if (account.isAdmin()) {
                    Utils.manage(Main.this);
                }
            }
        }

    });

    tili = new Button("Kyttjtili");
    tili.setWidthUndefined();
    tili.setVisible(false);
    tili.addStyleName(ValoTheme.BUTTON_TINY);
    tili.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (account != null) {
                Utils.modifyAccount(Main.this);
            }
        }

    });

    duplicate = new Button("Avaa ikkunassa");
    duplicate2 = new Button("Avaa alas");

    duplicate.setWidthUndefined();
    duplicate.addStyleName(ValoTheme.BUTTON_TINY);
    duplicate.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            MapVis model = js2.getModel();
            if (model == null) {

                UIState s = uiState.duplicate(Main.this);
                s.reference = s.current;

                mapDialog = new Window(s.reference.getText(database), new VerticalLayout());
                mapDialog.setWidth(dialogWidth());
                mapDialog.setHeight(dialogHeight());
                mapDialog.setResizable(true);
                mapDialog.setContent(js2Container);
                mapDialog.setVisible(true);
                mapDialog.setResizeLazy(false);
                mapDialog.addCloseListener(new CloseListener() {

                    @Override
                    public void windowClose(CloseEvent e) {

                        duplicate.setCaption("Avaa ikkunassa");
                        duplicate2.setVisible(true);

                        UIState s = uiState.duplicate(Main.this);
                        mapDialog.close();
                        mapDialog = null;
                        s.reference = null;
                        setFragment(s, true);

                    }

                });
                mapDialog.addResizeListener(new ResizeListener() {

                    @Override
                    public void windowResized(ResizeEvent e) {
                        Updates.updateJS(Main.this, false);
                    }

                });

                setFragment(s, true);

                addWindow(mapDialog);

                duplicate.setCaption("Sulje referenssi");
                duplicate2.setVisible(false);

            } else {

                UIState s = uiState.duplicate(Main.this);
                if (mapDialog != null) {
                    mapDialog.close();
                    mapDialog = null;
                }

                panelLayout.removeComponent(js2Container);

                s.reference = null;
                setFragment(s, true);

                duplicate.setCaption("Avaa ikkunassa");
                duplicate2.setVisible(true);

            }

        }

    });

    duplicate2.setWidthUndefined();
    duplicate2.addStyleName(ValoTheme.BUTTON_TINY);
    duplicate2.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            MapVis model = js2.getModel();
            assert (model == null);

            UIState s = uiState.duplicate(Main.this);
            s.reference = s.current;
            setFragment(s, true);

            panelLayout.addComponent(js2Container);

            duplicate.setCaption("Sulje referenssi");
            duplicate2.setVisible(false);

        }

    });

    login = new Button("Kirjaudu");
    login.setWidthUndefined();
    login.addStyleName(ValoTheme.BUTTON_TINY);
    login.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (account != null) {
                account = null;
                hallinnoi.setVisible(false);
                tili.setVisible(false);
                Updates.update(Main.this, true);
                login.setCaption("Kirjaudu");
            } else {
                Login.login(Main.this);
            }
        }

    });

    times = new ComboBox();
    times.setWidth("130px");
    times.addStyleName(ValoTheme.COMBOBOX_SMALL);
    times.addItem(Property.AIKAVALI_KAIKKI);
    times.addItem("2016");
    times.addItem("2017");
    times.addItem("2018");
    times.addItem("2019");
    times.select("2016");
    times.setInvalidAllowed(false);
    times.setNullSelectionAllowed(false);

    times.addValueChangeListener(timesListener);

    final HorizontalLayout hl0 = new HorizontalLayout();
    hl0.setWidth("100%");
    hl0.setHeight("32px");
    hl0.setSpacing(true);

    hl0.addComponent(pdf);
    hl0.setComponentAlignment(pdf, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(pdf, 0.0f);

    hl0.addComponent(propertyExcelButton);
    hl0.setComponentAlignment(propertyExcelButton, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(propertyExcelButton, 0.0f);

    hl0.addComponent(states);
    hl0.setComponentAlignment(states, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(states, 0.0f);

    hl0.addComponent(saveState);
    hl0.setComponentAlignment(saveState, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(saveState, 0.0f);

    hl0.addComponent(times);
    hl0.setComponentAlignment(times, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(times, 0.0f);

    hl0.addComponent(search);
    hl0.setComponentAlignment(search, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(search, 1.0f);

    hl0.addComponent(modeLabel);
    hl0.setComponentAlignment(modeLabel, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(modeLabel, 0.0f);

    hl0.addComponent(mode);
    hl0.setComponentAlignment(mode, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(mode, 0.0f);

    hl0.addComponent(meterMode);
    hl0.setComponentAlignment(meterMode, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(meterMode, 0.0f);

    hl0.addComponent(hallinnoi);
    hl0.setComponentAlignment(hallinnoi, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(hallinnoi, 0.0f);

    hl0.addComponent(tili);
    hl0.setComponentAlignment(tili, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(tili, 0.0f);

    hl0.addComponent(duplicate);
    hl0.setComponentAlignment(duplicate, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(duplicate, 0.0f);

    hl0.addComponent(duplicate2);
    hl0.setComponentAlignment(duplicate2, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(duplicate2, 0.0f);

    hl0.addComponent(login);
    hl0.setComponentAlignment(login, Alignment.MIDDLE_LEFT);
    hl0.setExpandRatio(login, 0.0f);

    propertiesPanel = new Panel();
    propertiesPanel.setSizeFull();

    properties = new VerticalLayout();
    properties.setSpacing(true);
    properties.setMargin(true);

    propertiesPanel.setContent(properties);
    propertiesPanel.setVisible(false);

    tags = new VerticalLayout();
    tags.setSpacing(true);
    Updates.updateTags(this);

    AbsoluteLayout tabs = new AbsoluteLayout();
    tabs.setSizeFull();

    {
        panel = new Panel();
        panel.addStyleName(ValoTheme.PANEL_BORDERLESS);
        panel.setSizeFull();
        panel.setId("mapContainer1");
        panelLayout = new VerticalLayout();
        panelLayout.addComponent(js);
        panelLayout.setHeight("100%");

        js2Container = new VerticalLayout();
        js2Container.setHeight("100%");
        js2Container.addComponent(new Label("<hr />", ContentMode.HTML));
        js2Container.addComponent(js2);

        panel.setContent(panelLayout);
        tabs.addComponent(panel);
    }

    wiki = new BrowserFrame();
    wiki.setSource(new ExternalResource(Wiki.wikiAddress() + "/"));
    wiki.setWidth("100%");
    wiki.setHeight("100%");

    {

        wiki_ = new VerticalLayout();
        wiki_.setSizeFull();
        Button b = new Button("Palaa sovellukseen");
        b.setWidth("100%");
        b.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                applyFragment(backFragment, true);
                String content = Wiki.get(wikiPage);
                if (content == null)
                    return;
                int first = content.indexOf("<rev contentformat");
                if (first == -1)
                    return;
                content = content.substring(first);
                int term = content.indexOf(">");
                content = content.substring(term + 1);
                int end = content.indexOf("</rev>");
                content = content.substring(0, end);
                if (wikiBase.modifyMarkup(Main.this, content)) {
                    Updates.update(Main.this, true);
                }
            }
        });
        wiki_.addComponent(b);
        wiki_.addComponent(wiki);
        wiki_.setVisible(false);

        wiki_.setExpandRatio(b, 0.0f);
        wiki_.setExpandRatio(wiki, 1.0f);

        tabs.addComponent(wiki_);

    }

    hs = new HorizontalSplitPanel();
    hs.setSplitPosition(0, Unit.PIXELS);
    hs.setHeight("100%");
    hs.setWidth("100%");

    browser = new VerticalLayout();
    browser.setSizeFull();

    HorizontalLayout browserWidgets = new HorizontalLayout();
    browserWidgets.setWidth("100%");

    hori = new Button();
    hori.setDescription("Nyt asiat taulukkona");
    hori.setEnabled(true);
    hori.setIcon(FontAwesome.ARROW_RIGHT);
    hori.addStyleName(ValoTheme.BUTTON_TINY);
    hori.addClickListener(new ClickListener() {

        boolean right = false;

        @Override
        public void buttonClick(ClickEvent event) {
            if (right) {
                hs.setSplitPosition(0, Unit.PIXELS);
                hori.setIcon(FontAwesome.ARROW_RIGHT);
                hori.setDescription("Nyt asiat taulukkona");
                right = false;
            } else {
                hs.setSplitPosition(windowWidth / 2, Unit.PIXELS);
                hori.setIcon(FontAwesome.ARROW_LEFT);
                hori.setDescription("Piilota taulukko");
                right = true;
            }
        }

    });

    more = new Button();
    more.setDescription("Laajenna nytettvien asioiden joukkoa");
    more.setIcon(FontAwesome.PLUS_SQUARE);
    more.addStyleName(ValoTheme.BUTTON_TINY);
    more.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            uiState.level++;
            Updates.updateJS(Main.this, false);
            if (uiState.level >= 2)
                less.setEnabled(true);
        }

    });

    less = new Button();
    less.setDescription("Supista nytettvien asioiden joukkoa");
    less.setIcon(FontAwesome.MINUS_SQUARE);
    less.addStyleName(ValoTheme.BUTTON_TINY);
    less.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (uiState.level > 1) {
                uiState.level--;
                Updates.updateJS(Main.this, false);
            }
            if (uiState.level <= 1)
                less.setEnabled(false);
        }

    });

    reportAllButton = new Button();
    reportAllButton.setCaption("Nkyvt tulokset");
    reportAllButton.addStyleName(ValoTheme.BUTTON_TINY);
    reportAllButton.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (uiState.reportAll) {
                reportAllButton.setCaption("Nkyvt tulokset");
                uiState.reportAll = false;
            } else {
                reportAllButton.setCaption("Kaikki tulokset");
                uiState.reportAll = true;
            }
            Updates.updateJS(Main.this, false);
        }

    });

    reportStatus = new Label("0 tulosta.");
    reportStatus.setWidth("100px");

    filter = new ComboBox();
    filter.setWidth("100%");
    filter.addStyleName(ValoTheme.COMBOBOX_SMALL);
    filter.setInvalidAllowed(false);
    filter.setNullSelectionAllowed(false);

    filter.addValueChangeListener(filterListener);

    browserWidgets.addComponent(hori);
    browserWidgets.setComponentAlignment(hori, Alignment.MIDDLE_LEFT);
    browserWidgets.setExpandRatio(hori, 0.0f);

    browserWidgets.addComponent(more);
    browserWidgets.setComponentAlignment(more, Alignment.MIDDLE_LEFT);
    browserWidgets.setExpandRatio(more, 0.0f);

    browserWidgets.addComponent(less);
    browserWidgets.setComponentAlignment(less, Alignment.MIDDLE_LEFT);
    browserWidgets.setExpandRatio(less, 0.0f);

    browserWidgets.addComponent(reportAllButton);
    browserWidgets.setComponentAlignment(reportAllButton, Alignment.MIDDLE_LEFT);
    browserWidgets.setExpandRatio(reportAllButton, 0.0f);

    browserWidgets.addComponent(reportStatus);
    browserWidgets.setComponentAlignment(reportStatus, Alignment.MIDDLE_LEFT);
    browserWidgets.setExpandRatio(reportStatus, 0.0f);

    browserWidgets.addComponent(filter);
    browserWidgets.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);
    browserWidgets.setExpandRatio(filter, 1.0f);

    browser.addComponent(browserWidgets);
    browser.addComponent(hs);

    browser.setExpandRatio(browserWidgets, 0.0f);
    browser.setExpandRatio(hs, 1.0f);

    browser.setVisible(false);

    tabs.addComponent(browser);

    {
        gridPanelLayout = new VerticalLayout();
        gridPanelLayout.setMargin(false);
        gridPanelLayout.setSpacing(false);
        gridPanelLayout.setSizeFull();
        hs.addComponent(gridPanelLayout);
    }

    CssLayout browserLayout = new CssLayout();

    browserLayout.setSizeFull();

    browserLayout.addComponent(browser_);

    hs.addComponent(browserLayout);

    tabs.addComponent(propertiesPanel);

    vs.addComponent(hl0);
    vs.addComponent(tabs);

    vs.setExpandRatio(hl0, 0.0f);
    vs.setExpandRatio(tabs, 1.0f);

    // Ground state
    fragments.put("", uiState);

    setCurrentItem(uiState.currentItem, (Strategiakartta) uiState.currentItem);

}

From source file:fr.univlorraine.mondossierweb.views.CalendrierMobileView.java

License:Apache License

public void refresh() {
    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();/*w  ww . j  ava 2  s. c  o  m*/

        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        if (userController.isEnseignant()) {
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(ListeInscritsMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToListeInscrits();
                }

                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToRecherche(null);
                }
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);
        }

        //Title
        Label labelNavBar = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelNavBar.setStyleName("v-label-navbar");
        navbar.addComponent(labelNavBar);
        navbar.setComponentAlignment(labelNavBar, Alignment.MIDDLE_CENTER);

        navbar.setExpandRatio(labelNavBar, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        //globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);
        globalLayout.setStyleName("v-scrollableelement");

        if (MdwTouchkitUI.getCurrent().getEtudiant() != null
                && MdwTouchkitUI.getCurrent().getEtudiant().getCalendrier() != null
                && MdwTouchkitUI.getCurrent().getEtudiant().getCalendrier().size() > 0) {

            List<Examen> listeExam = MdwTouchkitUI.getCurrent().getEtudiant().getCalendrier();

            for (Examen exam : listeExam) {
                Panel panelCalendrier = new Panel();
                panelCalendrier.setSizeFull();
                HorizontalLayout labelExamenLayout = new HorizontalLayout();
                labelExamenLayout.setMargin(true);
                labelExamenLayout.setSpacing(true);
                labelExamenLayout.setSizeFull();

                //Dtail de l'preuve
                VerticalLayout detailLayout = new VerticalLayout();
                detailLayout.setSizeFull();
                //ajout de la date
                Label dateLabel = new Label(exam.getDatedeb());
                dateLabel.setStyleName(ValoTheme.LABEL_BOLD);
                detailLayout.addComponent(dateLabel);
                dateLabel.addStyleName("v-label-align-right");

                //ajout de l'heure
                Label heureLabel = new Label(exam.getHeure());
                detailLayout.addComponent(heureLabel);
                heureLabel.setStyleName("v-label-align-right");

                //ajout de la salle
                Label salleLabel = new Label(exam.getLibsalle());
                detailLayout.addComponent(salleLabel);
                salleLabel.setStyleName("v-label-align-right");

                //ajout du batiment
                Label batimentLabel = new Label(exam.getBatiment());
                detailLayout.addComponent(batimentLabel);
                batimentLabel.setStyleName("v-label-align-right");

                //Libelle de l'preuve
                VerticalLayout libelleLayout = new VerticalLayout();
                libelleLayout.setSizeFull();
                Label libLabel = new Label(exam.getEpreuve());
                libLabel.setSizeFull();
                libLabel.setStyleName(ValoTheme.LABEL_BOLD);
                libelleLayout.addComponent(new Label(""));
                libelleLayout.addComponent(libLabel);

                //Ajout des 2 layouts dans le layout principal 
                labelExamenLayout.addComponent(detailLayout);
                labelExamenLayout.addComponent(libelleLayout);

                //Ajout du layout principal dans le panel
                panelCalendrier.setContent(labelExamenLayout);

                //Ajout du panel  la vue
                globalLayout.addComponent(panelCalendrier);

            }

        } else {
            Panel panelCalendrier = new Panel();
            panelCalendrier.setSizeFull();
            HorizontalLayout labelExamenLayout = new HorizontalLayout();
            labelExamenLayout.setMargin(true);
            labelExamenLayout.setSizeFull();
            Label aucunExamen = new Label(
                    applicationContext.getMessage(NAME + ".examen.aucun", null, getLocale()));
            aucunExamen.setStyleName(ValoTheme.LABEL_COLORED);
            aucunExamen.addStyleName(ValoTheme.LABEL_BOLD);
            aucunExamen.setWidth("100%");
            aucunExamen.addStyleName("label-centre");
            labelExamenLayout.addComponent(aucunExamen);
            panelCalendrier.setContent(labelExamenLayout);
            globalLayout.addComponent(panelCalendrier);
        }

        addComponent(globalLayout);
        setExpandRatio(globalLayout, 1);
    }
}

From source file:fr.univlorraine.mondossierweb.views.InformationsAnnuellesMobileView.java

License:Apache License

public void refresh() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {
        removeAllComponents();/* w  ww. ja  v a2  s  .  c o  m*/

        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        if (userController.isEnseignant()) {
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(ListeInscritsMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToListeInscrits();
                } else {

                    if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                            .getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                        MdwTouchkitUI.getCurrent().navigateToRecherche(null);
                    }
                }
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);
        }

        //Title
        Label labelTrombi = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        if (userController.isEnseignant()) {
            //Si on ne peut pas dj revenir sur la recherche via le bouton 'retour'
            if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() == null
                    || !MdwTouchkitUI.getCurrent().getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                //Bouton Search
                Button searchButton = new Button();
                searchButton.setIcon(FontAwesome.SEARCH);
                searchButton.setStyleName("v-nav-button");
                navbar.addComponent(searchButton);
                navbar.setComponentAlignment(searchButton, Alignment.MIDDLE_RIGHT);
                searchButton.addClickListener(e -> {
                    ((MdwTouchkitUI) MdwTouchkitUI.getCurrent()).navigateToRecherche(NAME);
                });
            }
        }

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        //globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);
        globalLayout.setStyleName("v-scrollableelement");

        VerticalLayout slimLayout = new VerticalLayout();
        slimLayout.setSpacing(false);
        slimLayout.setMargin(false);
        //slimLayout.setStyleName("v-scrollableelement");

        String mail = MdwTouchkitUI.getCurrent().getEtudiant().getEmail();
        if (StringUtils.hasText(mail)) {
            Panel mailPanel = new Panel();
            mailPanel.setStyleName("panel-without-bottom-line-separator");
            HorizontalLayout mailLayout = new HorizontalLayout();
            mailLayout.setSizeFull();
            mailLayout.setHeight("25px");
            Label mailLabel = new Label();

            mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>";
            mailLabel.setValue(mail);
            mailLabel.setContentMode(ContentMode.HTML);

            mailLabel.setSizeFull();
            mailLabel.addStyleName("label-centre");
            mailLayout.addComponent(mailLabel);
            mailLayout.setComponentAlignment(mailLabel, Alignment.MIDDLE_CENTER);
            mailPanel.setContent(mailLayout);
            slimLayout.addComponent(mailPanel);
            slimLayout.setComponentAlignment(mailPanel, Alignment.MIDDLE_CENTER);
        }

        Panel etuPanel = new Panel();
        HorizontalLayout photoLayout = new HorizontalLayout();
        photoLayout.setId(MdwTouchkitUI.getCurrent().getEtudiant().getCod_ind());
        photoLayout.setSizeFull();
        if (MdwTouchkitUI.getCurrent().getEtudiant().getPhoto() != null) {
            Image fotoEtudiant = new Image(null,
                    new ExternalResource(MdwTouchkitUI.getCurrent().getEtudiant().getPhoto()));
            fotoEtudiant.setWidth("120px");
            fotoEtudiant.setStyleName(ValoTheme.BUTTON_LINK);
            photoLayout.addComponent(fotoEtudiant);

        }
        VerticalLayout nomCodeLayout = new VerticalLayout();
        //nomCodeLayout.setSizeFull();
        nomCodeLayout.setSpacing(false);

        Label labelNomEtudiant = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelNomEtudiant.setSizeFull();
        labelNomEtudiant.setStyleName(ValoTheme.LABEL_BOLD);
        labelNomEtudiant.addStyleName("label-centre");
        nomCodeLayout.addComponent(labelNomEtudiant);
        nomCodeLayout.setComponentAlignment(labelNomEtudiant, Alignment.MIDDLE_CENTER);
        //nomCodeLayout.setExpandRatio(labelNomEtudiant, 1);

        Label codetuLabel = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getCod_etu());
        codetuLabel.setSizeFull();
        codetuLabel.setStyleName(ValoTheme.LABEL_TINY);
        codetuLabel.addStyleName("label-centre");
        nomCodeLayout.addComponent(codetuLabel);
        nomCodeLayout.setComponentAlignment(codetuLabel, Alignment.MIDDLE_CENTER);

        photoLayout.addComponent(nomCodeLayout);
        photoLayout.setComponentAlignment(nomCodeLayout, Alignment.MIDDLE_CENTER);
        photoLayout.setExpandRatio(nomCodeLayout, 1);

        etuPanel.setContent(photoLayout);

        slimLayout.addComponent(etuPanel);
        slimLayout.setComponentAlignment(etuPanel, Alignment.MIDDLE_CENTER);

        globalLayout.addComponent(slimLayout);

        Panel panelInfos = new Panel(applicationContext.getMessage(NAME + ".infos.title", null, getLocale())
                + " " + Utils.getAnneeUniversitaireEnCours(
                        etudiantController.getAnneeUnivEnCours(MdwTouchkitUI.getCurrent())));
        panelInfos.setStyleName("centertitle-panel");
        panelInfos.addStyleName("v-colored-panel-caption");

        //Si l'tudiant est inscrit pour l'anne en cours
        if (MdwTouchkitUI.getCurrent().getEtudiant().isInscritPourAnneeEnCours()) {

            FormLayout formInfosLayout = new FormLayout();
            formInfosLayout.setSpacing(true);
            formInfosLayout.setMargin(true);

            //Numro Anonymat visible que si l'utilisateur est tudiant
            List<Anonymat> lano = null;
            if (!userController.isEnseignant() && userController.isEtudiant()) {
                lano = MdwTouchkitUI.getCurrent().getEtudiant().getNumerosAnonymat();
                if (lano != null) {
                    //Si l'tudiant n'a qu'un seul numro d'anonymat
                    if (lano.size() == 1) {
                        String captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymat.title",
                                null, getLocale());
                        TextField fieldNumAnonymat = new TextField(captionNumAnonymat, MdwTouchkitUI
                                .getCurrent().getEtudiant().getNumerosAnonymat().get(0).getCod_etu_ano());
                        formatTextField(fieldNumAnonymat);
                        //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE);
                        //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale()));
                        formInfosLayout.addComponent(fieldNumAnonymat);
                    }
                    //Si l'tudiant a plusieurs numros d'anonymat
                    if (lano.size() > 1) {
                        int i = 0;
                        for (Anonymat ano : lano) {
                            String captionNumAnonymat = "";
                            if (i == 0) {
                                //Pour le premier numro affich on affiche le libell du champ
                                captionNumAnonymat = applicationContext.getMessage(NAME + ".numanonymats.title",
                                        null, getLocale());
                            }
                            TextField fieldNumAnonymat = new TextField(captionNumAnonymat,
                                    ano.getCod_etu_ano() + " (" + ano.getLib_man() + ")");
                            formatTextField(fieldNumAnonymat);
                            if (i == 0) {
                                //Pour le premier numro affich on affiche l'info bulle
                                //fieldNumAnonymat.setIcon(FontAwesome.INFO_CIRCLE);
                                //fieldNumAnonymat.setDescription(applicationContext.getMessage(NAME+".numanonymat.description", null, getLocale()));
                            }
                            formInfosLayout.addComponent(fieldNumAnonymat);
                            i++;
                        }
                    }
                }
            }

            String captionBousier = applicationContext.getMessage(NAME + ".boursier.title", null, getLocale());
            TextField fieldNumBoursier = new TextField(captionBousier,
                    MdwTouchkitUI.getCurrent().getEtudiant().isBoursier()
                            ? applicationContext.getMessage(NAME + ".boursier.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".boursier.non", null, getLocale()));
            formatTextField(fieldNumBoursier);
            formInfosLayout.addComponent(fieldNumBoursier);

            String captionSalarie = applicationContext.getMessage(NAME + ".salarie.title", null, getLocale());
            TextField fieldSalarie = new TextField(captionSalarie,
                    MdwTouchkitUI.getCurrent().getEtudiant().isTemSalarie() == true
                            ? applicationContext.getMessage(NAME + ".salarie.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".salarie.non", null, getLocale()));
            formatTextField(fieldSalarie);
            formInfosLayout.addComponent(fieldSalarie);

            String captionAmenagementEtude = applicationContext.getMessage(NAME + ".amenagementetude.title",
                    null, getLocale());
            TextField fieldAmenagementEtude = new TextField(captionAmenagementEtude,
                    MdwTouchkitUI.getCurrent().getEtudiant().isTemAmenagementEtude() == true
                            ? applicationContext.getMessage(NAME + ".amenagementetude.oui", null, getLocale())
                            : applicationContext.getMessage(NAME + ".amenagementetude.non", null, getLocale()));
            formatTextField(fieldAmenagementEtude);
            formInfosLayout.addComponent(fieldAmenagementEtude);

            panelInfos.setContent(formInfosLayout);
        } else {

            HorizontalLayout labelNonInscritLayout = new HorizontalLayout();
            labelNonInscritLayout.setMargin(true);
            labelNonInscritLayout.setSizeFull();
            Label labelNonInscrit = new Label(
                    applicationContext.getMessage(NAME + ".inscrit.non", null, getLocale()));
            labelNonInscrit.setStyleName(ValoTheme.LABEL_COLORED);
            labelNonInscrit.addStyleName(ValoTheme.LABEL_BOLD);
            labelNonInscrit.setWidth("100%");
            labelNonInscrit.addStyleName("label-centre");
            labelNonInscritLayout.addComponent(labelNonInscrit);
            panelInfos.setContent(labelNonInscritLayout);

        }
        globalLayout.addComponent(panelInfos);

        addComponent(globalLayout);
        setExpandRatio(globalLayout, 1);

    }
}

From source file:fr.univlorraine.mondossierweb.views.ListeInscritsMobileView.java

License:Apache License

/**
 * Initialise la vue//from   w  w w  . jav  a 2 s . c o  m
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        // On rinitialise la vue
        removeAllComponents();

        // Style
        setSizeFull();
        addStyleName("v-noscrollableelement");

        // On rcupre le favori  afficher
        typeFavori = MdwTouchkitUI.getCurrent().getTypeObjListInscrits();
        libelleObj = "";
        if (typeIsVet() && MdwTouchkitUI.getCurrent().getEtapeListeInscrits() != null) {
            libelleObj = MdwTouchkitUI.getCurrent().getEtapeListeInscrits().getLibelle();
        }
        if (typeIsElp() && MdwTouchkitUI.getCurrent().getElpListeInscrits() != null) {
            libelleObj = MdwTouchkitUI.getCurrent().getElpListeInscrits().getLibelle();
        }

        //Rcupration de la liste des inscrits
        List<Inscrit> linscrits = MdwTouchkitUI.getCurrent().getListeInscrits();

        //Rcupration du nombre d'inscrit par page
        nbEtuParPage = configController.getTrombiMobileNbEtuParPage();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        returnButton = new Button();
        returnButton.setIcon(FontAwesome.ARROW_LEFT);
        returnButton.setStyleName("v-nav-button");
        returnButton.addClickListener(e -> {
            if (MdwTouchkitUI.getCurrent().getTrombinoscopeFromView() != null
                    && MdwTouchkitUI.getCurrent().getTrombinoscopeFromView().equals(FavorisMobileView.NAME)) {
                MdwTouchkitUI.getCurrent().navigateTofavoris();
            }
            if (MdwTouchkitUI.getCurrent().getTrombinoscopeFromView() != null
                    && MdwTouchkitUI.getCurrent().getTrombinoscopeFromView().equals(RechercheMobileView.NAME)) {
                MdwTouchkitUI.getCurrent().navigateToRecherche(null);
            }
        });
        navbar.addComponent(returnButton);
        navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelTrombi = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        // bouton pour ajouter en favori si ce n'est pas dj le cas
        List<Favoris> lfav = favorisController.getFavoris();
        FavorisPK favpk = new FavorisPK();
        favpk.setLogin(userController.getCurrentUserName());
        favpk.setIdfav(MdwTouchkitUI.getCurrent().getCodeObjListInscrits());
        favpk.setTypfav(typeFavori);
        Favoris favori = new Favoris();
        favori.setId(favpk);
        //Si l'objet n'est pas dj en favori
        if (lfav != null && !lfav.contains(favori)) {
            //Cration du bouton pour ajouter l'objet aux favoris
            Button btnAjoutFavori = new Button("+");
            btnAjoutFavori.setIcon(FontAwesome.STAR_O);
            btnAjoutFavori.setStyleName("v-nav-button");
            btnAjoutFavori.addClickListener(e -> {

                //creation du favori en base sur le clic du bouton
                favorisController.saveFavori(favori);

                //On cache le bouton de mise en favori
                btnAjoutFavori.setVisible(false);

                //Affichage d'un message de confirmation
                Notification.show(
                        applicationContext.getMessage(NAME + ".message.favoriAjoute", null, getLocale()),
                        Type.TRAY_NOTIFICATION);
            });

            //Ajout du bouton  l'interface
            navbar.addComponent(btnAjoutFavori);
        }

        //Bouton Filtre
        //On a la possibilit de filtrer le trombinoscope que si on est positionn sur un ELP
        if (typeIsElp()) {
            FiltreInscritsMobileWindow w = new FiltreInscritsMobileWindow();
            //Si on a des lments  afficher dans la popup filtre
            if ((w.getListeEtapes() != null && w.getListeEtapes().size() > 0)
                    || (w.getListeGroupes() != null && w.getListeGroupes().size() > 0)) {
                filterButton = new Button();
                filterButton.setIcon(FontAwesome.ELLIPSIS_V);
                filterButton.setStyleName("v-nav-button");

                filterButton.addClickListener(e -> {
                    w.addCloseListener(f -> {
                        //Si la personne a ferm la popup en appuyant sur le bouton FILTRER
                        if (w.isDemandeFiltrage()) {
                            vetSelectionnee = w.getVetSelectionnee();
                            groupeSelectionne = w.getGroupeSelectionne();
                            displayTrombinoscope(false);
                        }
                    });
                    UI.getCurrent().addWindow(w);

                });
                navbar.addComponent(filterButton);
                navbar.setComponentAlignment(filterButton, Alignment.MIDDLE_RIGHT);
            }
        }

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        //Test si la liste contient des tudiants
        if (linscrits != null && linscrits.size() > 0) {

            pageEnCours = 1;
            //Calcul du nombre maxi de page
            if (nbEtuParPage > 0 && linscrits.size() > nbEtuParPage) {
                pageMax = (linscrits.size() / nbEtuParPage) + 1;
            } else {
                //On affiche tous les inscrits sur une seule page
                pageMax = 1;
            }

            infoLayout = new VerticalLayout();
            infoLayout.setSizeFull();
            infoLayout.setMargin(true);
            infoLayout.setSpacing(true);
            infoLayout.addStyleName("v-scrollableelement");

            //Layout avec le Libelle
            HorizontalLayout resumeLayout = new HorizontalLayout();
            resumeLayout.setWidth("100%");
            resumeLayout.setHeight("20px");
            //Label affichant le nb d'inscrits
            infoLibelleObj = new Label(libelleObj);
            infoLibelleObj.setStyleName(ValoTheme.LABEL_SMALL);
            infoLibelleObj.setSizeFull();
            resumeLayout.addComponent(infoLibelleObj);
            resumeLayout.setComponentAlignment(infoLibelleObj, Alignment.TOP_CENTER);
            infoLayout.addComponent(resumeLayout);

            //Layout qui contient la liste des inscrits et le trombinoscope
            dataLayout = new VerticalLayout();
            dataLayout.setSizeFull();

            //Layout contenant le gridLayout correspondant au trombinoscope
            verticalLayoutForTrombi = new VerticalLayout();
            verticalLayoutForTrombi.setSizeFull();
            verticalLayoutForTrombi.addStyleName("v-scrollablepanel");

            //Cration du trombinoscope
            displayTrombinoscope(false);

            verticalLayoutForTrombi.addComponent(trombiLayout);
            verticalLayoutForTrombi.setSizeFull();
            verticalLayoutForTrombi.setHeight(null);

            if (pageMax > 1) {
                HorizontalLayout layoutPagination = new HorizontalLayout();
                layoutPagination.setWidth("100%");
                layoutPagination.setMargin(true);
                if (pageEnCours < pageMax) {
                    Button btnNext = new Button(
                            applicationContext.getMessage(NAME + ".btn.affichersuite", null, getLocale()));
                    btnNext.setStyleName(ValoTheme.BUTTON_PRIMARY);
                    btnNext.addStyleName("v-popover-button");
                    btnNext.addClickListener(e -> {
                        pageEnCours++;
                        displayTrombinoscope(true);
                        if (pageEnCours >= pageMax) {
                            btnNext.setVisible(false);
                        }
                    });
                    layoutPagination.addComponent(btnNext);
                    layoutPagination.setComponentAlignment(btnNext, Alignment.MIDDLE_CENTER);
                    layoutPagination.setExpandRatio(btnNext, 1);
                }
                verticalLayoutForTrombi.addComponent(layoutPagination);

            }

            //Le layout contient le trombi  afficher
            dataLayout.addComponent(verticalLayoutForTrombi);

            infoLayout.addComponent(dataLayout);
            infoLayout.setExpandRatio(dataLayout, 1);

            addComponent(infoLayout);

            setExpandRatio(infoLayout, 1);
        } else {
            // Layout contenant le label du message indiquant aucun inscrit
            infoLayout = new VerticalLayout();
            infoLayout.setMargin(true);
            infoLayout.setSpacing(true);

            // Label du message indiquant aucun inscrit
            Label infoAucuninscrit = new Label(
                    applicationContext.getMessage(NAME + ".message.aucuninscrit", null, getLocale()));
            infoAucuninscrit.setSizeFull();

            // Ajout du label au layout
            infoLayout.addComponent(infoAucuninscrit);
            addComponent(infoLayout);
            setExpandRatio(infoLayout, 1);
        }

    }

}

From source file:fr.univlorraine.mondossierweb.views.NotesDetailMobileView.java

License:Apache License

@SuppressWarnings("deprecation")
public void refresh(Etape etapeToDisplay, String codetuToDisplay) {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {

        //On repassera dans la cration que si on n'a pas dej cr la vue
        if (codetu == null || !codetuToDisplay.equals(codetu)) {
            codetu = null;//from  w  w w  .j  a va2s  .  c  om
        }
        //On repassera dans la cration que si on n'a pas dej cr la vue
        if (etape == null || !etapeToDisplay.getAnnee().equals(etape.getAnnee())
                || !etapeToDisplay.getCode().equals(etape.getCode())
                || !etapeToDisplay.getVersion().equals(etape.getVersion())) {
            etape = null;
        }
        //On repassera dans la cration que si on n'a pas dej cr la vue
        if (codetu == null || etape == null) {
            compteurElp = 0;

            removeAllComponents();

            /* Style */
            setMargin(false);
            setSpacing(false);
            setSizeFull();

            //Test si user enseignant
            if (userController.isEnseignant()) {
                //On recupere les notes pour un enseignant
                etudiantController.renseigneDetailNotesEtResultatsEnseignant(etapeToDisplay);
            } else {
                //On rcupre les notes pour un tudiant
                etudiantController.renseigneDetailNotesEtResultats(etapeToDisplay);
            }

            //NAVBAR
            HorizontalLayout navbar = new HorizontalLayout();
            navbar.setSizeFull();
            navbar.setHeight("40px");
            navbar.setStyleName("navigation-bar");

            //Bouton retour
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                MdwTouchkitUI.getCurrent().navigateToResumeNotes();
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

            //Titre
            Label labelNavBar = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
            labelNavBar.setStyleName("v-label-navbar");
            navbar.addComponent(labelNavBar);
            navbar.setComponentAlignment(labelNavBar, Alignment.MIDDLE_CENTER);

            navbar.setExpandRatio(labelNavBar, 1);

            //Significations
            if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
                significationButton = new Button();
                significationButton.setIcon(FontAwesome.INFO_CIRCLE);
                significationButton.setStyleName("v-nav-button");
                significationButton.addClickListener(e -> {
                    //afficher les significations
                    SignificationsMobileWindow w = new SignificationsMobileWindow(true);
                    UI.getCurrent().addWindow(w);
                });
                navbar.addComponent(significationButton);
                navbar.setComponentAlignment(significationButton, Alignment.MIDDLE_RIGHT);
            }

            addComponent(navbar);

            layoutList = new HashMap<String, LinkedList<HorizontalLayout>>();

            etape = etapeToDisplay;
            codetu = codetuToDisplay;

            /* Layout */
            VerticalLayout layout = new VerticalLayout();
            layout.setSizeFull();
            layout.setMargin(true);
            layout.setSpacing(true);
            layout.setStyleName("v-scrollableelement");

            /* Titre */
            setCaption(applicationContext.getMessage(NAME + ".title", null, getLocale()));

            List<ElementPedagogique> lelp = MdwTouchkitUI.getCurrent().getEtudiant().getElementsPedagogiques();

            if (lelp != null && lelp.size() > 0) {
                //Panel notesPanel = new Panel();
                //notesPanel.setSizeFull();

                VerticalLayout notesLayout = new VerticalLayout();
                //notesLayout.setSpacing(true);

                HorizontalLayout libSessionLayout = new HorizontalLayout();
                libSessionLayout.setSizeFull();
                libSessionLayout.addComponent(new Label());

                HorizontalLayout sessionLayout = new HorizontalLayout();
                sessionLayout.setSizeFull();
                Label session1 = new Label("Session1");
                session1.setStyleName("label-bold-with-bottom");
                sessionLayout.addComponent(session1);
                Label session2 = new Label("Session2");
                session2.setStyleName("label-bold-with-bottom");
                sessionLayout.addComponent(session2);

                libSessionLayout.addComponent(sessionLayout);

                notesLayout.addComponent(libSessionLayout);

                boolean blueLevel = false;

                compteurElp = 0;
                elpPere = "";

                HorizontalLayout layoutPere = null;
                int nbFils = 0;

                for (ElementPedagogique elp : lelp) {

                    compteurElp++;

                    //Si on est sur un element de niveau 1, diffrent du premier element de la liste (qui est un rappel de l'etape)
                    if (elp.getLevel() == 1 && compteurElp > 1) {
                        blueLevel = !blueLevel;
                    }
                    HorizontalLayout libElpLayout = new HorizontalLayout();

                    if (compteurElp > 1) {
                        if (elp.getLevel() == 1) {

                            //Si le pere prcdent n'avait aucun fils
                            if (layoutPere != null && nbFils == 0) {
                                layoutPere.setStyleName("layout-bottom-line-separator");
                            }

                            layoutPere = libElpLayout;
                            nbFils = 0;
                            //Sur un elp de niveau 1, il est sur fond sombre
                            libElpLayout.addStyleName("main-layout-bottom-line-separator");

                            //ajout dans la hashMap
                            layoutList.put(elp.getCode(), new LinkedList<HorizontalLayout>());
                            elpPere = elp.getCode();

                            libElpLayout.setId("layout_pere_" + elp.getCode());

                        } else {
                            nbFils++;
                            libElpLayout.addStyleName("layout-bottom-line-separator");
                            libElpLayout.setId(compteurElp + "_" + elp.getCode() + "_layout_fils_" + elpPere);
                            //ajout dans la hashMap
                            layoutList.get(elpPere).add(libElpLayout);

                        }
                    } else {
                        //on affiche la racine (qui est un rappel de l'etape) en blanc sur un fond trs sombre
                        libElpLayout.addStyleName("root-layout-bottom-line-separator");
                    }
                    libElpLayout.setSizeFull();
                    libElpLayout.setHeight("100%");

                    VerticalLayout libVerticalLayout = new VerticalLayout();

                    Label libElpLabel = new Label(elp.getLibelle());
                    if (elp.isEpreuve()) {
                        libElpLabel.setStyleName("bold-italic-label");
                    } else {
                        libElpLabel.setStyleName("bold-label");
                    }
                    libVerticalLayout.addComponent(libElpLabel);

                    //Si on n'est pas sur le premier elp de la liste (rappel de l'tape) on affiche un indicateur de niveau
                    if (compteurElp > 1) {
                        HorizontalLayout levelMainLayout = new HorizontalLayout();
                        levelMainLayout.setSizeFull();
                        levelMainLayout.setSpacing(true);
                        levelMainLayout.setStyleName("level-indicator-layout");

                        int k = 0;
                        for (int i = 0; i < elp.getLevel(); i++) {
                            //Ajout d'un level
                            k++;
                            Label libLevelLayout = new Label();
                            libLevelLayout.setSizeFull();
                            libLevelLayout.setHeight("8px");
                            if (blueLevel) {
                                libLevelLayout.setStyleName("layout-level-blue-indicator");
                            } else {
                                libLevelLayout.setStyleName("layout-level-green-indicator");
                            }
                            levelMainLayout.addComponent(libLevelLayout);
                        }
                        //On pense avoir 7 level maxi 
                        for (int j = k; j < 8; j++) {
                            Label libLevelSpaceLayout = new Label();
                            libLevelSpaceLayout.setSizeFull();
                            libLevelSpaceLayout.setHeight("8px");
                            levelMainLayout.addComponent(libLevelSpaceLayout);
                        }

                        libVerticalLayout.addComponent(levelMainLayout);
                    }
                    libElpLayout.addComponent(libVerticalLayout);

                    HorizontalLayout noteLayout = new HorizontalLayout();
                    noteLayout.setSizeFull();

                    VerticalLayout vlsession1 = new VerticalLayout();
                    Label note1 = new Label(elp.getNote1());
                    if (!StringUtils.hasText(elp.getNote2())) {
                        if (elp.isEpreuve()) {
                            note1.setStyleName("bold-italic-label");
                        } else {
                            note1.setStyleName("bold-label");
                        }
                    }
                    vlsession1.addComponent(note1);
                    if (StringUtils.hasText(elp.getRes1())) {
                        Label adm1 = new Label(elp.getRes1());
                        if (!StringUtils.hasText(elp.getRes2())) {
                            if (elp.isEpreuve()) {
                                adm1.setStyleName("bold-italic-label");
                            } else {
                                adm1.setStyleName("bold-label");
                            }
                        }
                        vlsession1.addComponent(adm1);
                    }
                    noteLayout.addComponent(vlsession1);

                    VerticalLayout vlsession2 = new VerticalLayout();
                    Label note2 = new Label(elp.getNote2());
                    if (StringUtils.hasText(elp.getNote2())) {
                        if (elp.isEpreuve()) {
                            note2.setStyleName("bold-italic-label");
                        } else {
                            note2.setStyleName("bold-label");
                        }
                    }
                    vlsession2.addComponent(note2);
                    if (StringUtils.hasText(elp.getRes2())) {
                        Label adm2 = new Label(elp.getRes2());
                        if (StringUtils.hasText(elp.getRes2())) {
                            if (elp.isEpreuve()) {
                                adm2.setStyleName("bold-italic-label");
                            } else {
                                adm2.setStyleName("bold-label");
                            }
                        }
                        vlsession2.addComponent(adm2);
                    }
                    noteLayout.addComponent(vlsession2);

                    libElpLayout.addComponent(noteLayout);

                    notesLayout.addComponent(libElpLayout);

                    //Au dpart, on cache les lments de niveau suprieur  1
                    if (compteurElp > 1 && elp.getLevel() > 1) {
                        //libElpLayout.setVisible(false);
                        Page.getCurrent().getJavaScript().execute("document.getElementById('"
                                + libElpLayout.getId() + "').style.display=\"none\";");

                    }
                }

                //Cas o le dernier lment tait un lment le pere qui n'avait aucun fils
                if (layoutPere != null && nbFils == 0) {
                    layoutPere.setStyleName("layout-bottom-line-separator");
                }

                //Ajout du javascript
                for (Entry<String, LinkedList<HorizontalLayout>> entry : layoutList.entrySet()) {
                    String pere = entry.getKey();
                    LinkedList<HorizontalLayout> listeLayoutFils = entry.getValue();
                    // traitements
                    if (listeLayoutFils != null && listeLayoutFils.size() > 0) {
                        String affichagejavascriptfils = "";
                        for (HorizontalLayout hl : listeLayoutFils) {
                            affichagejavascriptfils += "if(document.getElementById('" + hl.getId()
                                    + "').style.display==\"none\"){document.getElementById('" + hl.getId()
                                    + "').style.display = \"block\";}else{document.getElementById('"
                                    + hl.getId() + "').style.display = \"none\";}";
                        }
                        //sur le clic du layout pere, on affiche les fils
                        Page.getCurrent().getJavaScript().execute("document.getElementById('" + "layout_pere_"
                                + pere + "').onclick=function(){ " + affichagejavascriptfils + "};");
                    }
                }

                layout.addComponent(notesLayout);
                layout.setExpandRatio(notesLayout, 1);

            } else {
                setHeight(30, Unit.PERCENTAGE);
                HorizontalLayout messageLayout = new HorizontalLayout();
                messageLayout.setSpacing(true);
                messageLayout.setMargin(true);
                Label labelAucunResultat = new Label(
                        applicationContext.getMessage(NAME + ".message.aucuneresultat", null, getLocale()));
                labelAucunResultat.setStyleName(ValoTheme.LABEL_BOLD);
                messageLayout.addComponent(labelAucunResultat);
                layout.addComponent(messageLayout);

            }

            addComponent(layout);

            setExpandRatio(layout, 1);

        } else {
            refreshJavascript();
        }
    }
}

From source file:fr.univlorraine.mondossierweb.views.NotesMobileView.java

License:Apache License

public void refresh() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI
            && (userController.isEnseignant() || userController.isEtudiant())
            && MdwTouchkitUI.getCurrent() != null && MdwTouchkitUI.getCurrent().getEtudiant() != null) {

        removeAllComponents();/* w w w .j  av  a 2  s .  co m*/

        /* Style */
        setMargin(false);
        setSpacing(false);
        setSizeFull();

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        if (userController.isEnseignant()) {
            returnButton = new Button();
            returnButton.setIcon(FontAwesome.ARROW_LEFT);
            //returnButton.setStyleName(ValoTheme.BUTTON_ICON_ONLY);
            returnButton.setStyleName("v-nav-button");
            returnButton.addClickListener(e -> {
                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(ListeInscritsMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToListeInscrits();
                }

                if (MdwTouchkitUI.getCurrent().getDossierEtuFromView() != null && MdwTouchkitUI.getCurrent()
                        .getDossierEtuFromView().equals(RechercheMobileView.NAME)) {
                    MdwTouchkitUI.getCurrent().navigateToRecherche(null);
                }
            });
            navbar.addComponent(returnButton);
            navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);
        }

        //Titre
        Label labelNavBar = new Label(MdwTouchkitUI.getCurrent().getEtudiant().getNom());
        labelNavBar.setStyleName("v-label-navbar");
        navbar.addComponent(labelNavBar);
        navbar.setComponentAlignment(labelNavBar, Alignment.MIDDLE_CENTER);

        navbar.setExpandRatio(labelNavBar, 1);

        //Significations
        if (MdwTouchkitUI.getCurrent().getEtudiant().isSignificationResultatsUtilisee()) {
            significationButton = new Button();
            significationButton.setIcon(FontAwesome.INFO_CIRCLE);
            significationButton.setStyleName("v-nav-button");
            significationButton.addClickListener(e -> {
                //afficher les significations
                SignificationsMobileWindow w = new SignificationsMobileWindow(false);
                UI.getCurrent().addWindow(w);
            });
            navbar.addComponent(significationButton);
            navbar.setComponentAlignment(significationButton, Alignment.MIDDLE_RIGHT);
        }

        addComponent(navbar);

        VerticalLayout globalLayout = new VerticalLayout();
        //globalLayout.setSizeFull();
        globalLayout.setSpacing(true);
        globalLayout.setMargin(true);
        globalLayout.setStyleName("v-scrollableelement");

        List<Diplome> ldiplomes = MdwTouchkitUI.getCurrent().getEtudiant().getDiplomes();
        if (ldiplomes != null && ldiplomes.size() > 0) {
            Panel diplomesPanel = new Panel(
                    applicationContext.getMessage(NAME + ".table.diplomes", null, getLocale()));
            diplomesPanel.setStyleName("centertitle-panel");
            diplomesPanel.addStyleName("v-colored-panel-caption");
            VerticalLayout diplomesLayout = new VerticalLayout();
            for (Diplome diplome : ldiplomes) {
                Panel panelEnCours = null;

                panelEnCours = new Panel(diplome.getAnnee());
                panelEnCours.setStyleName("v-panel-caption-centertitle-panel");

                HorizontalLayout noteLayout = new HorizontalLayout();
                noteLayout.setSizeFull();
                noteLayout.setSpacing(true);

                VerticalLayout libelleLayout = new VerticalLayout();
                libelleLayout.setSizeFull();

                Label libelleButton = new Label(diplome.getLib_web_vdi());
                libelleButton.setHeight("100%");
                libelleButton.setWidth("100%");
                libelleButton.addStyleName("label-centre");

                //Appel de la window contenant le dtail des notes
                if (diplome.getResultats() != null && diplome.getResultats().size() > 0) {
                    libelleLayout.addComponent(new Label(""));
                }
                libelleLayout.addComponent(libelleButton);
                libelleLayout.setComponentAlignment(libelleButton, Alignment.MIDDLE_CENTER);

                HorizontalLayout notesessionLayout = new HorizontalLayout();
                notesessionLayout.setSizeFull();
                notesessionLayout.setSpacing(true);

                if (diplome.getResultats() != null && diplome.getResultats().size() > 0) {
                    int i = 0;
                    for (Resultat r : diplome.getResultats()) {
                        i++;
                        VerticalLayout resultatLayout = new VerticalLayout();
                        resultatLayout.setSizeFull();
                        Label session = new Label(r.getSession());
                        session.setStyleName("label-bold-with-bottom");
                        resultatLayout.addComponent(session);
                        Label note = new Label(r.getNote());
                        resultatLayout.addComponent(note);
                        Label resultat = new Label(r.getAdmission());
                        resultatLayout.addComponent(resultat);
                        //Si c'est la dernire session
                        if (i == diplome.getResultats().size()) {
                            //On affiche les infos en gras
                            note.setStyleName(ValoTheme.LABEL_BOLD);
                            resultat.setStyleName(ValoTheme.LABEL_BOLD);
                        }
                        notesessionLayout.addComponent(resultatLayout);
                    }
                } else {
                    Label resultat = new Label("Aucun rsultat");
                    resultat.setStyleName(ValoTheme.LABEL_SMALL);
                    notesessionLayout.addComponent(resultat);
                }

                noteLayout.addComponent(libelleLayout);

                noteLayout.addComponent(notesessionLayout);

                panelEnCours.setContent(noteLayout);
                diplomesLayout.addComponent(panelEnCours);
            }
            diplomesPanel.setContent(diplomesLayout);
            globalLayout.addComponent(diplomesPanel);
        }

        List<Etape> letapes = MdwTouchkitUI.getCurrent().getEtudiant().getEtapes();

        if (letapes != null && letapes.size() > 0) {
            Panel elpsPanel = new Panel(
                    applicationContext.getMessage(NAME + ".table.etapes", null, getLocale()));
            elpsPanel.setStyleName("centertitle-panel");
            elpsPanel.addStyleName("v-colored-panel-caption");
            VerticalLayout elpsLayout = new VerticalLayout();

            for (Etape etape : letapes) {
                Panel panelEnCours = null;

                panelEnCours = new Panel(etape.getAnnee());
                panelEnCours.setStyleName("v-panel-caption-centertitle-panel");

                HorizontalLayout noteLayout = new HorizontalLayout();
                noteLayout.setSizeFull();
                noteLayout.setSpacing(true);

                VerticalLayout libelleLayout = new VerticalLayout();
                libelleLayout.setSizeFull();

                Button libelleButton = new Button(etape.getLibelle());
                Utils.setButtonStyle(libelleButton);
                libelleButton.setHeight("100%");
                libelleButton.setWidth("100%");

                //Appel de la window contenant le dtail des notes
                prepareBoutonAppelDetailDesNotes(libelleButton, etape);
                if (etape.getResultats() != null && etape.getResultats().size() > 0) {
                    libelleLayout.addComponent(new Label(""));
                }
                libelleLayout.addComponent(libelleButton);
                libelleLayout.setComponentAlignment(libelleButton, Alignment.MIDDLE_CENTER);

                HorizontalLayout notesessionLayout = new HorizontalLayout();
                notesessionLayout.setSizeFull();
                notesessionLayout.setSpacing(true);

                if (etape.getResultats() != null && etape.getResultats().size() > 0) {
                    int i = 0;
                    for (Resultat r : etape.getResultats()) {
                        i++;
                        VerticalLayout resultatLayout = new VerticalLayout();
                        resultatLayout.setSizeFull();
                        Label session = new Label(r.getSession());
                        session.setStyleName("label-bold-with-bottom");
                        resultatLayout.addComponent(session);
                        Label note = new Label(r.getNote());
                        resultatLayout.addComponent(note);
                        Label resultat = new Label(r.getAdmission());
                        resultatLayout.addComponent(resultat);
                        //Si c'est la dernire session
                        if (i == etape.getResultats().size()) {
                            //On affiche les infos en gras
                            note.setStyleName(ValoTheme.LABEL_BOLD);
                            resultat.setStyleName(ValoTheme.LABEL_BOLD);
                        }
                        notesessionLayout.addComponent(resultatLayout);
                    }
                } else {
                    Label resultat = new Label("Aucun rsultat");
                    resultat.setStyleName(ValoTheme.LABEL_SMALL);
                    notesessionLayout.addComponent(resultat);
                }

                noteLayout.addComponent(libelleLayout);

                noteLayout.addComponent(notesessionLayout);

                panelEnCours.setContent(noteLayout);
                elpsLayout.addComponent(panelEnCours);
            }
            elpsPanel.setContent(elpsLayout);
            globalLayout.addComponent(elpsPanel);

        }

        addComponent(globalLayout);
        setExpandRatio(globalLayout, 1);
    }
}

From source file:fr.univlorraine.mondossierweb.views.RechercheMobileView.java

License:Apache License

/**
 * Initialise la vue//from   w  w  w.  jav a2  s .c o m
 */
@PostConstruct
public void init() {

    //On vrifie le droit d'accder  la vue
    if (UI.getCurrent() instanceof MdwTouchkitUI && userController.isEnseignant()) {
        // On rinitialise la vue
        removeAllComponents();

        // Style
        setSizeFull();
        addStyleName("v-noscrollableelement");

        //NAVBAR
        HorizontalLayout navbar = new HorizontalLayout();
        navbar.setSizeFull();
        navbar.setHeight("40px");
        navbar.setStyleName("navigation-bar");

        //Bouton retour
        returnButton = new Button();
        returnButton.setIcon(FontAwesome.ARROW_LEFT);
        returnButton.setStyleName("v-nav-button");
        returnButton.addClickListener(e -> {
            MdwTouchkitUI.getCurrent().backFromSearch();
        });
        navbar.addComponent(returnButton);
        navbar.setComponentAlignment(returnButton, Alignment.MIDDLE_LEFT);

        //Title
        Label labelTrombi = new Label(applicationContext.getMessage(NAME + ".title.label", null, getLocale()));
        labelTrombi.setStyleName("v-label-navbar");
        navbar.addComponent(labelTrombi);
        navbar.setComponentAlignment(labelTrombi, Alignment.MIDDLE_CENTER);

        navbar.setExpandRatio(labelTrombi, 1);
        addComponent(navbar);

        //BOUTON DE RECHERCHE
        btnRecherche = new Button();
        btnRecherche.setIcon(FontAwesome.SEARCH);
        btnRecherche.setStyleName(ValoTheme.BUTTON_PRIMARY);
        btnRecherche.addStyleName("v-popover-button");
        btnRecherche.addStyleName("v-button-without-padding");
        btnRecherche.setEnabled(true);
        btnRecherche.addClickListener(e -> search(false));

        //CHAMP DE RECHERCHE
        champRechercheLayout = new HorizontalLayout();
        champRechercheLayout.setWidth("100%");
        mainVerticalLayout = new VerticalLayout();
        mainVerticalLayout.setImmediate(true);
        mainVerticalLayout.setSizeFull();

        //Init connexion  ES, pour gain perf au premiere lettre tapes
        if (ElasticSearchService.initConnexion(true)) {

            //Cration du champ autoComplete
            champRecherche = new AutoComplete();
            champRecherche.setWidth(100, Unit.PERCENTAGE);
            champRecherche.setEnabled(true);
            champRecherche.setImmediate(true);
            champRecherche.focus();
            champRecherche.setTextChangeEventMode(TextChangeEventMode.EAGER);
            champRecherche.addTextChangeListener(new TextChangeListener() {
                @Override
                public void textChange(TextChangeEvent event) {
                    /*if(event.getText()!=null){
                    resetButton.setIcon(FontAwesome.TIMES);
                    }*/

                    champRecherche.showChoices(quickSearch(event.getText()), mainVerticalLayout, btnRecherche,
                            true);

                }
            });
            champRecherche.setImmediate(true);
            champRecherche.addShortcutListener(
                    new ShortcutListener("Enter Shortcut", ShortcutAction.KeyCode.ENTER, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                //Si on tait sur une ligne propose sous le champ de recherche
                                if (champRecherche.getSelectedItem() > 0) {
                                    //On remplie d'abord le champ avec la ligne slectionne
                                    champRecherche.setValue(champRecherche.getChoices()
                                            .getItem(champRecherche.getSelectedItem()).getItemProperty("lib")
                                            .getValue().toString());
                                }
                                search(false);
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Bottom Arrow", ShortcutAction.KeyCode.ARROW_DOWN, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    champRecherche.getChoices().setValue(champRecherche.getNextItem());

                                }
                            }
                        }
                    });

            champRecherche.addShortcutListener(
                    new ShortcutListener("Top Arrow", ShortcutAction.KeyCode.ARROW_UP, null) {
                        @Override
                        public void handleAction(Object sender, Object target) {
                            if (target == champRecherche) {
                                if (champRecherche.getChoices().getItemIds() != null) {
                                    champRecherche.getChoicesPopup().setVisible(true);
                                    Integer champSelectionne = champRecherche.getPreviousItem();
                                    if (champSelectionne > 0) {
                                        champRecherche.getChoices().setValue(champSelectionne);
                                    } else {
                                        champRecherche.getChoices().setValue(null);
                                    }

                                }
                            }
                        }
                    });

            champRechercheLayout.addComponent(champRecherche);
            champRechercheLayout.setComponentAlignment(champRecherche, Alignment.MIDDLE_LEFT);

            //BOUTON RESET
            champRecherche.addStyleName("textfield-resetable");
            resetButton = new Button();
            resetButton.setIcon(FontAwesome.TIMES);
            resetButton.setStyleName(ValoTheme.BUTTON_BORDERLESS);
            resetButton.addStyleName("v-popover-button");
            resetButton.addStyleName("v-button-without-padding");
            resetButton.addStyleName("btn-reset");
            resetButton.addClickListener(e -> {
                champRecherche.setValue("");
                //search1.setValue("");
                resetButton.setIcon(FontAwesome.TIMES);
                champRecherche.focus();
            });
            champRechercheLayout.addComponent(resetButton);
            champRechercheLayout.setComponentAlignment(resetButton, Alignment.MIDDLE_LEFT);

            //Ajout du bouton de recherche au layout
            champRechercheLayout.addComponent(btnRecherche);
            mainVerticalLayout.addComponent(champRechercheLayout);
            mainVerticalLayout.setComponentAlignment(champRechercheLayout, Alignment.MIDDLE_LEFT);
            champRechercheLayout.setMargin(true);
            champRechercheLayout.setExpandRatio(champRecherche, 1);

            HorizontalLayout checkBoxVetLayout = new HorizontalLayout();
            Label etapeLabel = new Label(
                    applicationContext.getMessage(NAME + ".etapes.checkbox", null, getLocale()));
            etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxVetLayout.addComponent(etapeLabel);

            HorizontalLayout checkBoxElpLayout = new HorizontalLayout();
            Label elpLabel = new Label(
                    applicationContext.getMessage(NAME + ".elps.checkbox", null, getLocale()));
            elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxElpLayout.addComponent(elpLabel);

            HorizontalLayout checkBoxEtuLayout = new HorizontalLayout();
            Label etuLabel = new Label(
                    applicationContext.getMessage(NAME + ".etudiants.checkbox", null, getLocale()));
            etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            checkBoxEtuLayout.addComponent(etuLabel);

            checkBoxVetLayout.setSizeFull();
            checkBoxElpLayout.setSizeFull();
            checkBoxEtuLayout.setSizeFull();

            if (casesAcocherVet) {
                checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                etapeLabel.addStyleName("label-line-through");
            }

            if (casesAcocherElp) {
                checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                elpLabel.addStyleName("label-line-through");
            }

            if (casesAcocherEtudiant) {
                checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
            } else {
                checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                etuLabel.addStyleName("label-line-through");
            }

            checkBoxVetLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherVet) {
                        casesAcocherVet = false;
                        checkBoxVetLayout.setStyleName("layout-checkbox-unchecked");
                        etapeLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherVet = true;
                        checkBoxVetLayout.setStyleName("layout-checkbox-checked");
                        etapeLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxElpLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherElp) {
                        casesAcocherElp = false;
                        checkBoxElpLayout.setStyleName("layout-checkbox-unchecked");
                        elpLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherElp = true;
                        checkBoxElpLayout.setStyleName("layout-checkbox-checked");
                        elpLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            checkBoxEtuLayout.addListener(new LayoutClickListener() {
                public void layoutClick(LayoutClickEvent event) {
                    if (casesAcocherEtudiant) {
                        casesAcocherEtudiant = false;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-unchecked");
                        etuLabel.addStyleName("label-line-through");
                    } else {
                        casesAcocherEtudiant = true;
                        checkBoxEtuLayout.setStyleName("layout-checkbox-checked");
                        etuLabel.setStyleName(ValoTheme.LABEL_SMALL);
                    }
                    tuneSearch();
                }
            });

            HorizontalLayout checkBoxLayout = new HorizontalLayout();
            checkBoxLayout.setWidth("100%");
            checkBoxLayout.setHeight("50px");
            checkBoxLayout.setMargin(true);
            checkBoxLayout.setSpacing(true);
            checkBoxLayout.addComponent(checkBoxVetLayout);
            checkBoxLayout.addComponent(checkBoxElpLayout);
            checkBoxLayout.addComponent(checkBoxEtuLayout);

            mainVerticalLayout.addComponent(checkBoxLayout);

            //TABLE DE RESULTATS
            rrContainer = new HierarchicalContainer();
            rrContainer.addContainerProperty("lib", String.class, "");
            rrContainer.addContainerProperty("code", String.class, "");
            rrContainer.addContainerProperty("type", String.class, "");
            tableResultats = new TreeTable();
            tableResultats.setWidth("100%");
            tableResultats.setSelectable(false);
            tableResultats.setMultiSelect(false);
            tableResultats.setImmediate(true);
            columnHeaders = new String[FIELDS_ORDER.length];
            for (int fieldIndex = 0; fieldIndex < FIELDS_ORDER.length; fieldIndex++) {
                columnHeaders[fieldIndex] = applicationContext
                        .getMessage("result.table." + FIELDS_ORDER[fieldIndex], null, Locale.getDefault());
            }

            tableResultats.addGeneratedColumn("type", new DisplayTypeColumnGenerator());
            tableResultats.addGeneratedColumn("lib", new DisplayNameColumnGenerator());
            tableResultats.setContainerDataSource(rrContainer);
            tableResultats.setVisibleColumns(FIELDS_ORDER);
            tableResultats.setStyleName("nohscrollabletable");
            tableResultats.setColumnHeaders(columnHeaders);
            tableResultats.setColumnHeaderMode(Table.ColumnHeaderMode.HIDDEN);
            tableResultats.setColumnWidth("type", 100);

            /*mainVerticalLayout.addComponent(searchBoxFilter);
            mainVerticalLayout.setComponentAlignment(searchBoxFilter, Alignment.MIDDLE_RIGHT);*/
            VerticalLayout tableVerticalLayout = new VerticalLayout();
            tableVerticalLayout.setMargin(true);
            tableVerticalLayout.setSizeFull();
            tableVerticalLayout.addComponent(tableResultats);
            mainVerticalLayout.addComponent(tableVerticalLayout);
            mainVerticalLayout.setExpandRatio(tableVerticalLayout, 1);
            tableResultats.setVisible(false);

            addComponent(mainVerticalLayout);
            setExpandRatio(mainVerticalLayout, 1);
        } else {
            //Message fonctionnalit indisponible
            addComponent(
                    new Label(applicationContext.getMessage(NAME + ".indisponible.message", null, getLocale()),
                            ContentMode.HTML));
        }
    }
}

From source file:lifetime.component.VerticalLinksLayout.java

License:Apache License

/**
 * Adds a new link/*ww w  . ja v a 2s. co  m*/
 * @param caption   The visible link
 * @param target    The view we should travel to
 */
public void addLink(String caption, String target) {
    LifetimeButtonLink link = new LifetimeButtonLink(caption, null, FontAwesome.ARROW_LEFT);
    addComponent(link);
}

From source file:qbic.vaadincomponents.SelectFileComponent.java

License:Open Source License

public SelectFileComponent(String mainCaption, String info, String sourceCaption, String destinationCaption,
        BeanItemContainer<?> source, BeanItemContainer<?> destination) {
    setCaption(mainCaption);/*from   w ww  .j  av  a2  s.c  o m*/

    VerticalLayout files = new VerticalLayout();
    files.setSpacing(true);

    // info label
    Label rawFilesInfo = new Label(info);
    rawFilesInfo.addStyleName(ValoTheme.LABEL_COLORED);
    files.addComponent(rawFilesInfo);
    files.setWidth("100%");

    // available files in openbis
    available = new Grid(source);
    available.setCaption(sourceCaption);
    available.setSelectionMode(SelectionMode.MULTI);

    // selected files for anaylsis
    selected = new Grid(destination);

    if (mainCaption.equals("Raw files")) {
        available.removeColumn("fullPath");
        available.removeColumn("openbisCode");
    }

    else if (mainCaption.equals("")) {
        available.removeColumn("name");
        available.removeColumn("path");
        selected.removeColumn("name");
        selected.removeColumn("path");
    }

    selected.setCaption(destinationCaption);
    selected.setSelectionMode(SelectionMode.MULTI);

    for (Grid.Column col : available.getColumns()) {
        col.setWidthUndefined();
    }

    // selectedFiles.set
    // buttons to add or remove files
    VerticalLayout buttons = new VerticalLayout();
    toLeft = new Button();
    toLeft.setIcon(FontAwesome.ARROW_LEFT);

    toRight = new Button();
    toRight.setIcon(FontAwesome.ARROW_RIGHT);
    buttons.addComponent(toRight);
    buttons.addComponent(toLeft);

    GridLayout grids = new GridLayout(3, 1);
    grids.setWidth("100%");

    // grids.setSpacing(true);
    grids.addComponent(available, 0, 0);

    available.setWidth("100%");
    grids.addComponent(buttons, 1, 0);
    grids.addComponent(selected, 2, 0);
    grids.setColumnExpandRatio(0, 0.45f);
    grids.setColumnExpandRatio(1, 0.029f);
    grids.setColumnExpandRatio(2, 0.45f);
    grids.setSpacing(false);
    grids.setComponentAlignment(buttons, com.vaadin.ui.Alignment.MIDDLE_CENTER);

    selected.setWidth("100%");

    files.addComponent(grids);

    this.setCompositionRoot(files);
    files.setMargin(new MarginInfo(true, true, true, false));
    this.setWidth("100%");

}