Example usage for com.vaadin.ui CssLayout addComponent

List of usage examples for com.vaadin.ui CssLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui CssLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:dhbw.clippinggorilla.userinterface.views.InterestProfileView.java

public InterestProfileView() {
    User user = UserUtils.getCurrent();//from   ww w  . ja v  a2  s .  c o  m
    Set<InterestProfile> profiles = UserUtils.getAllInterestProfiles(user);

    CssLayout newProfileGroup = new CssLayout();
    newProfileGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

    TextField textFieldNewProfileName = new TextField();
    Language.setCustom(Word.PROFILE_NAME, s -> textFieldNewProfileName.setPlaceholder(s));
    textFieldNewProfileName.setWidth("260px");
    textFieldNewProfileName.setMaxLength(255);
    newProfileGroup.addComponent(textFieldNewProfileName);

    Button buttonNewProfile = new Button();
    buttonNewProfile.setIcon(VaadinIcons.PLUS);
    buttonNewProfile.addStyleName(ValoTheme.BUTTON_PRIMARY);
    buttonNewProfile.addClickListener(e -> {
        Tab newTab = accordion.addTab(createTab(createEmptyProfile(textFieldNewProfileName.getValue())),
                textFieldNewProfileName.getValue());
        accordion.setSelectedTab(newTab);
        accordion.setWidth("100%");
        textFieldNewProfileName.clear();
    });
    newProfileGroup.addComponent(buttonNewProfile);
    textFieldNewProfileName
            .addFocusListener(f -> buttonNewProfile.setClickShortcut(ShortcutAction.KeyCode.ENTER, null));
    textFieldNewProfileName.addBlurListener(f -> buttonNewProfile.removeClickShortcut());

    profiles.forEach((InterestProfile profile) -> {
        accordion.addTab(createTab(profile), profile.getName());
    });
    addComponents(newProfileGroup, accordion);
    SESSIONS.put(user, this);
}

From source file:edu.nps.moves.mmowgliMobile.ui.GameDataCategoriesView2.java

License:Open Source License

public GameDataCategoriesView2() {
    HSess.init();//from   w ww . j a  va2  s .  c om
    setCaption(Game.getTL().getTitle());
    setWidth("100%");
    setHeight("100%");

    CssLayout root = new CssLayout();

    VerticalComponentGroup accounts = new VerticalComponentGroup();

    // Cards
    NavigationButton butt = new NavigationButton("Idea Cards");
    butt.setIcon(VaadinIcons.LIGHTBULB); //cardsIcon);
    butt.addStyleName("m-touchkit-blueicon");
    accounts.addComponent(butt);
    butt.addClickListener(new NavigationButton.NavigationButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(NavigationButtonClickEvent event) {
            HSess.init();
            Folder[] fa = new Folder[2];
            CardType posTyp = CardType.getCurrentPositiveIdeaCardTypeTL(); // CardTypeManager.getPositiveIdeaCardTypeTL();
            Container cntr = new CardsByTypeContainer<Card>(posTyp);
            fa[0] = new Folder(posTyp.getTitle(), cntr, Card.class);
            fa[0].addParam(CardType.class.getSimpleName(), posTyp);

            CardType negTyp = CardType.getCurrentNegativeIdeaCardTypeTL(); //CardTypeManager.getNegativeIdeaCardTypeTL();
            cntr = new CardsByTypeContainer<Card>(negTyp);
            fa[1] = new Folder(negTyp.getTitle(), cntr, Card.class);
            fa[1].addParam(CardType.class.getSimpleName(), negTyp);

            // Go to a FolderView
            FolderView2 v = new FolderView2(fa, "Top Level Cards");
            getNavigationManager().navigateTo(v);
            HSess.close();
        }
    });

    // Action Plans
    butt = new NavigationButton("Action Plans");
    butt.setIcon(VaadinIcons.LIST);//apIcon
    butt.addStyleName("m-touchkit-blueicon");
    accounts.addComponent(butt);
    butt.addClickListener(new NavigationButton.NavigationButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(NavigationButtonClickEvent event) {
            // go to a ListView
            Folder f = new Folder("Action Plans", new AllActionPlansContainer<Object>(), ActionPlan.class);
            getNavigationManager().navigateTo(new ListView2(f));
        }
    });

    butt = new NavigationButton("Player Profiles");
    butt.setIcon(VaadinIcons.USERS); //usersIcon);
    butt.addStyleName("m-touchkit-blueicon");
    accounts.addComponent(butt);
    butt.addClickListener(new NavigationButton.NavigationButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(NavigationButtonClickEvent event) {
            // go to a ListView
            Folder f = new Folder("Player Profiles", new AllUsersContainer<Object>(), User.class);
            getNavigationManager().navigateTo(new ListView2(f));
        }
    });

    root.addComponent(accounts);
    setContent(root);
    setToolbar(new MmowgliFooter2());

    HSess.close();
}

From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropHorizontalSplitPanelDemo.java

License:Apache License

@Override
public Component getLayout() {
    // start-source
    CssLayout root = new CssLayout();
    root.setSizeFull();/*  ww  w . jav a  2s  .c  o  m*/

    Label lbl = new Label("To the left are some buttons, and to the right is a horizontal split panel. "
            + "Try dragging the buttons on to the splitpanel. If a component already exists in the SplitPanel it is replaced with the dragged one.");
    root.addComponent(lbl);

    // Wrapping components in a horizontal layout
    HorizontalLayout inner = new HorizontalLayout();
    inner.setMargin(true);
    inner.setSizeFull();
    inner.setSpacing(true);
    root.addComponent(inner);

    // Add some buttons to a vertical layout with dragging enabled
    final DDVerticalLayout btns = new DDVerticalLayout();
    btns.setDragMode(LayoutDragMode.CLONE);
    btns.setSizeUndefined();
    btns.setSpacing(true);
    String caption = "Button ";
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    btns.addComponent(new Button(caption + buttonCount++));
    inner.addComponent(btns);

    // Create a drag & drop horizontal split panel
    final DDHorizontalSplitPanel panel = new DDHorizontalSplitPanel();
    panel.setSizeFull();

    inner.addComponent(panel);
    inner.setExpandRatio(panel, 1);

    // Enable dragging
    panel.setDragMode(LayoutDragMode.CLONE);

    // Enable dropping
    panel.setDropHandler(new DefaultHorizontalSplitPanelDropHandler());

    // end-source
    return root;
}

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  w  w. j  av  a2s .  com*/
    });

    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.amapj.view.engine.menu.MenuPart.java

License:Open Source License

private CssLayout buildMenu(CssLayout menu, CssLayout menuItemsLayout, List<MenuDescription> allMenus,
        Navigator navigator, AmapUI ui) {

    final HorizontalLayout top = new HorizontalLayout();
    top.setWidth("100%");
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName("valo-menu-title");
    menu.addComponent(top);

    final Button showMenu = new Button("Menu", new ClickListener() {
        @Override//ww w  .  j  a va 2s.  c o  m
        public void buttonClick(final ClickEvent event) {
            if (menu.getStyleName().contains("valo-menu-visible")) {
                menu.removeStyleName("valo-menu-visible");
            } else {
                menu.addStyleName("valo-menu-visible");
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName("valo-menu-toggle");
    showMenu.setIcon(FontAwesome.LIST);
    menu.addComponent(showMenu);

    String nomAmap = new ParametresService().getParametres().nomAmap;
    Label title = new Label("<h2>" + nomAmap + "</h2>", ContentMode.HTML);
    title.setSizeUndefined();
    top.addComponent(title);
    top.setExpandRatio(title, 1);

    final MenuBar settings = new MenuBar();
    settings.addStyleName("user-menu");

    SessionParameters p = SessionManager.getSessionParameters();
    MenuItem settingsItem = settings.addItem(p.userPrenom + " " + p.userNom, null, null);
    settingsItem.addItem("Se dconnecter", new MenuBar.Command() {
        @Override
        public void menuSelected(MenuItem selectedItem) {
            new PasswordManager().disconnect();
            ui.buildLoginView(null, null, null);
        }
    });

    menu.addComponent(settings);

    menuItemsLayout.setPrimaryStyleName("valo-menuitems");
    menu.addComponent(menuItemsLayout);

    boolean first = true;
    String firstEntry = null;
    Button firstButton = null;

    for (MenuDescription menuDescription : allMenus) {
        final String view = menuDescription.getMenuName().name().toLowerCase();
        final String titleView = menuDescription.getMenuName().getTitle();

        if (menuDescription.getCategorie() != null) {
            Label l = new Label(menuDescription.getCategorie(), ContentMode.HTML);
            l.setPrimaryStyleName("valo-menu-subtitle");
            l.addStyleName("h4");
            l.setSizeUndefined();
            menuItemsLayout.addComponent(l);
        }

        final Button b = new Button(titleView, new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                setSelected(event.getButton(), menuItemsLayout);
                navigator.navigateTo("/" + view);
            }
        });

        b.setId("amapj.menu." + view);
        b.setHtmlContentAllowed(true);
        b.setPrimaryStyleName("valo-menu-item");
        b.setIcon(menuDescription.getMenuName().getFont());
        menuItemsLayout.addComponent(b);

        viewNameToMenuButton.put("/" + view, b);

        if (first) {
            first = false;
            firstButton = b;
            firstEntry = view;
        }
    }

    // Gestion de l'url
    String f = Page.getCurrent().getUriFragment();
    if (f != null && f.startsWith("!")) {
        f = f.substring(1);
    }
    if (f == null || f.equals("") || f.equals("/")) {
        navigateWithProtect(navigator, "/" + firstEntry);
        setSelected(firstButton, menuItemsLayout);
    } else {
        navigateWithProtect(navigator, f);
        setSelected(viewNameToMenuButton.get(f), menuItemsLayout);
    }

    return menu;
}

From source file:fr.amapj.view.views.login.LoginPart.java

License:Open Source License

public void buildLoginView(ValoMenuLayout root, AmapUI ui, String loginFromUrl, String passwordFromUrl,
        String sudo) {//  w  w w . j ava 2  s.c o  m
    this.ui = ui;
    CssLayout loginAera = root.prepareForLoginPage();

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

    loginAera.setStyleName("login-backgroundimage");
    loginAera.addComponent(loginLayout);

    // Recuperation des parametres
    String nomAmap = new ParametresService().getParametres().nomAmap;
    ui.getPage().setTitle(nomAmap);

    // Zone de saisie login/password 
    MyLoginForm myLoginForm = new MyLoginForm(loginFromUrl, passwordFromUrl, sudo, nomAmap);
    myLoginForm.addStyleName("login-layout");
    loginLayout.addComponent(myLoginForm);
    loginLayout.setComponentAlignment(myLoginForm, Alignment.MIDDLE_CENTER);
    loginLayout.setExpandRatio(myLoginForm, 10);

    Label l1 = new Label("Application fonctionnant avec AmapJ - ");
    Link link = new Link("Plus d'infos", new ExternalResource("http://amapj.fr"));
    link.setTargetName("_blank");

    HorizontalLayout hL = new HorizontalLayout();
    hL.addComponent(l1);
    hL.setComponentAlignment(l1, Alignment.MIDDLE_CENTER);
    hL.addComponent(link);
    hL.setComponentAlignment(link, Alignment.MIDDLE_CENTER);
    hL.setMargin(true);

    loginLayout.addComponent(hL);
    loginLayout.setComponentAlignment(hL, Alignment.BOTTOM_CENTER);
    loginLayout.setExpandRatio(hL, 1);

    // Si les deux champs ont t remplis on tente une validation automatique
    if ((passwordFromUrl != null) && (loginFromUrl != null)) {
        myLoginForm.login(loginFromUrl, passwordFromUrl);
    }

}

From source file:fr.ortec.dsi.pointage.presentation.ihm.view.TextFields.java

License:Apache License

public TextFields() {
    setMargin(true);//w ww. j a v  a2  s .c om
    setSpacing(true);

    Label h1 = new Label("Text Fields");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(row);

    TextField tf = new TextField("Normal");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Custom color");
    tf.addStyleName("color1");
    row.addComponent(tf);

    tf = new TextField("User Color");
    tf.addStyleName("color2");
    row.addComponent(tf);

    tf = new TextField("Themed");
    tf.addStyleName("color3");
    row.addComponent(tf);

    tf = new TextField("Error");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(tf);

    tf = new TextField("Error, borderless");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    row.addComponent(tf);

    tf = new TextField("Small");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    row.addComponent(tf);

    tf = new TextField("Large");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    tf.setIcon(testIcon.get(true));
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Font, no caption");
    tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Image, no caption");
    tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    CssLayout group = new CssLayout();
    group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    row.addComponent(group);

    Button button = new Button("Do It");
    // button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    group.addComponent(button);

    tf = new TextField("Right-aligned");
    tf.setValue("1,234");
    tf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    row.addComponent(tf);

    tf = new TextField("Tiny");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_TINY);
    row.addComponent(tf);

    tf = new TextField("Huge");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_HUGE);
    row.addComponent(tf);

    h1 = new Label("Text Areas");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(row);

    RichTextArea rta = new RichTextArea();
    rta.setValue("<b>Some</b> <i>rich</i> content");
    row.addComponent(rta);

    rta = new RichTextArea("Read-only");
    rta.setValue("<b>Some</b> <i>rich</i> content");
    rta.setReadOnly(true);
    row.addComponent(rta);
}

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

License:Apache License

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

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

        /* Style */
        setMargin(true);
        setSpacing(true);

        /* Titre */
        Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
        title.addStyleName(ValoTheme.LABEL_H1);
        addComponent(title);

        VerticalLayout globalLayout = new VerticalLayout();
        globalLayout.setSizeFull();
        globalLayout.setSpacing(true);

        //Layout avec les infos etatcivil et contact
        CssLayout idLayout = new CssLayout();
        idLayout.setSizeFull();
        idLayout.setStyleName("flexwrap");

        globalLayout.addComponent(idLayout);
        // Enable Responsive CSS selectors for the layout
        Responsive.makeResponsive(idLayout);

        if (MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {

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

            Panel panelAdresseAnnuelle = new Panel(
                    applicationContext.getMessage(NAME + ".adresseannuelle.title", null, getLocale()) + " "
                            + MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAnnee());

            String captionAdresseAnnuelle = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseAnnuelle = new Label();
            formatLabel(fieldAdresseAnnuelle, captionAdresseAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse1());
            formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle);

            String annuelle2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresse3());
            if (annuelle2 != null) {
                Label fieldAdresseAnnuelle2 = new Label();
                formatLabel(fieldAdresseAnnuelle2, null, annuelle2);
                formAdresseAnnuelleLayout.addComponent(fieldAdresseAnnuelle2);
            }
            String captionVilleAnnuelle = applicationContext.getMessage(NAME + ".ville.title", null,
                    getLocale());
            Label fieldVilleAnnuelle = new Label();
            formatLabel(fieldVilleAnnuelle, captionVilleAnnuelle,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getVille()));
            formAdresseAnnuelleLayout.addComponent(fieldVilleAnnuelle);

            String captionPaysAnnuelle = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysAnnuelle = new Label();
            formatLabel(fieldPaysAnnuelle, captionPaysAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getPays());
            formAdresseAnnuelleLayout.addComponent(fieldPaysAnnuelle);

            String captionTelephoneAnnuelle = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneAnnuelle = new Label();
            formatLabel(fieldTelephoneAnnuelle, captionTelephoneAnnuelle,
                    MainUI.getCurrent().getEtudiant().getAdresseAnnuelle().getNumerotel());
            formAdresseAnnuelleLayout.addComponent(fieldTelephoneAnnuelle);

            panelAdresseAnnuelle.setContent(formAdresseAnnuelleLayout);

            HorizontalLayout adresseAnnuelleGlobalLayout = new HorizontalLayout();
            adresseAnnuelleGlobalLayout.setSizeUndefined();
            adresseAnnuelleGlobalLayout.setStyleName("firstitembox");
            adresseAnnuelleGlobalLayout.addComponent(panelAdresseAnnuelle);
            adresseAnnuelleGlobalLayout.setExpandRatio(panelAdresseAnnuelle, 1);
            idLayout.addComponent(adresseAnnuelleGlobalLayout);
        }

        if (MainUI.getCurrent().getEtudiant().getAdresseFixe() != null) {
            FormLayout formAdresseFixeLayout = new FormLayout();
            formAdresseFixeLayout.setSpacing(true);
            formAdresseFixeLayout.setMargin(true);

            Panel panelAdresseFixe = new Panel(
                    applicationContext.getMessage(NAME + ".adressefixe.title", null, getLocale()));

            String captionAdresseFixe = applicationContext.getMessage(NAME + ".adresse.title", null,
                    getLocale());
            Label fieldAdresseFixe = new Label();
            formatLabel(fieldAdresseFixe, captionAdresseFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse1());
            formAdresseFixeLayout.addComponent(fieldAdresseFixe);

            String adfixe2 = valuateTextFieldFromMultipleValues(
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse2(),
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresse3());
            if (adfixe2 != null) {
                Label fieldAdresseFixe2 = new Label();
                formatLabel(fieldAdresseFixe2, null, adfixe2);
                formAdresseFixeLayout.addComponent(fieldAdresseFixe2);
            }

            String captionVilleFixe = applicationContext.getMessage(NAME + ".ville.title", null, getLocale());
            Label fieldVilleFixe = new Label();
            formatLabel(fieldVilleFixe, captionVilleFixe,
                    valuateTextFieldFromMultipleValues(
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getAdresseetranger(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getCodePostal(),
                            MainUI.getCurrent().getEtudiant().getAdresseFixe().getVille()));
            formAdresseFixeLayout.addComponent(fieldVilleFixe);

            String captionPaysFixe = applicationContext.getMessage(NAME + ".pays.title", null, getLocale());
            Label fieldPaysFixe = new Label();
            formatLabel(fieldPaysFixe, captionPaysFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getPays());
            formAdresseFixeLayout.addComponent(fieldPaysFixe);

            String captionTelephoneFixe = applicationContext.getMessage(NAME + ".telephone.title", null,
                    getLocale());
            Label fieldTelephoneFixe = new Label();
            formatLabel(fieldTelephoneFixe, captionTelephoneFixe,
                    MainUI.getCurrent().getEtudiant().getAdresseFixe().getNumerotel());
            formAdresseFixeLayout.addComponent(fieldTelephoneFixe);

            panelAdresseFixe.setContent(formAdresseFixeLayout);

            HorizontalLayout adresseFixeGlobalLayout = new HorizontalLayout();
            adresseFixeGlobalLayout.setSizeUndefined();
            adresseFixeGlobalLayout.setStyleName("itembox");
            adresseFixeGlobalLayout.addComponent(panelAdresseFixe);
            adresseFixeGlobalLayout.setExpandRatio(panelAdresseFixe, 1);
            idLayout.addComponent(adresseFixeGlobalLayout);

        }

        addComponent(globalLayout);

        if (userController.isEtudiant() && configController.isModificationAdressesAutorisee()
                && MainUI.getCurrent().getEtudiant().getAdresseAnnuelle() != null) {
            HorizontalLayout btnLayout = new HorizontalLayout();
            btnLayout.setSizeFull();
            btnLayout.setSpacing(true);

            Button btnModifAdresses = new Button(
                    applicationContext.getMessage(NAME + ".bouton.modifieradresses", null, getLocale()));
            btnModifAdresses.setStyleName(ValoTheme.BUTTON_PRIMARY);
            btnModifAdresses.setIcon(FontAwesome.EDIT);
            btnModifAdresses.addClickListener(e -> {
                ModificationAdressesWindow maw = new ModificationAdressesWindow(
                        MainUI.getCurrent().getEtudiant());
                maw.addCloseListener(f -> {
                    init();
                });
                UI.getCurrent().addWindow(maw);
            });
            btnLayout.addComponent(btnModifAdresses);
            btnLayout.setComponentAlignment(btnModifAdresses, Alignment.MIDDLE_LEFT);
            addComponent(btnLayout);
        }
    }
}

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

License:Apache License

/**
 * Initialise la vue//  www. ja v  a  2 s .  co  m
 */
@PostConstruct
public void init() {

    LOG.debug(userController.getCurrentUserName() + " EtatCivilView");

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

            LOG.debug(userController.getCurrentUserName() + " init EtatCivilView");

            /* Style */
            setMargin(true);
            setSpacing(true);

            /* Titre */
            Label title = new Label(applicationContext.getMessage(NAME + ".title", null, getLocale()));
            title.addStyleName(ValoTheme.LABEL_H1);
            addComponent(title);

            VerticalLayout globalLayout = new VerticalLayout();
            globalLayout.setSizeFull();
            globalLayout.setSpacing(true);

            //Layout avec les infos etatcivil et contact
            CssLayout idLayout = new CssLayout();
            idLayout.setSizeFull();
            idLayout.setStyleName("flexwrap");

            globalLayout.addComponent(idLayout);
            // Enable Responsive CSS selectors for the layout
            Responsive.makeResponsive(idLayout);

            /* Generalites */
            FormLayout formGeneralitesLayout = new FormLayout();
            formGeneralitesLayout.setSpacing(true);
            formGeneralitesLayout.setMargin(true);

            Panel panelGeneralites = new Panel(
                    applicationContext.getMessage(NAME + ".generalites.title", null, getLocale()));

            String captionNumDossier = applicationContext.getMessage(NAME + ".numdossier.title", null,
                    getLocale());
            Label fieldNumDossier = new Label();
            formatLabel(fieldNumDossier, captionNumDossier, MainUI.getCurrent().getEtudiant().getCod_etu());
            formGeneralitesLayout.addComponent(fieldNumDossier);

            String captionNNE = applicationContext.getMessage(NAME + ".nne.title", null, getLocale());
            Label fieldNNE = new Label();
            formatLabel(fieldNNE, captionNNE, MainUI.getCurrent().getEtudiant().getCod_nne());
            formGeneralitesLayout.addComponent(fieldNNE);

            String captionNom = applicationContext.getMessage(NAME + ".nom.title", null, getLocale());
            Label fieldNom = new Label();
            formatLabel(fieldNom, captionNom, MainUI.getCurrent().getEtudiant().getNom());
            formGeneralitesLayout.addComponent(fieldNom);

            String captionMail = applicationContext.getMessage(NAME + ".mail.title", null, getLocale());
            Label mailLabel = new Label();
            mailLabel.setCaption(captionMail);
            String mail = MainUI.getCurrent().getEtudiant().getEmail();
            if (StringUtils.hasText(mail)) {
                mail = "<a href=\"mailto:" + mail + "\">" + mail + "</a>";
                mailLabel.setValue(mail);
                mailLabel.setContentMode(ContentMode.HTML);
            }
            mailLabel.setSizeFull();
            formGeneralitesLayout.addComponent(mailLabel);

            String captionNationalite = applicationContext.getMessage(NAME + ".nationalite.title", null,
                    getLocale());
            Label fieldNationalite = new Label();
            formatLabel(fieldNationalite, captionNationalite,
                    MainUI.getCurrent().getEtudiant().getNationalite());
            formGeneralitesLayout.addComponent(fieldNationalite);

            String captionDateNaissance = applicationContext.getMessage(NAME + ".naissance.title", null,
                    getLocale());
            Label fieldDateNaissance = new Label();
            formatLabel(fieldDateNaissance, captionDateNaissance,
                    MainUI.getCurrent().getEtudiant().getDatenaissance());
            formGeneralitesLayout.addComponent(fieldDateNaissance);

            String captionLieuNaissance = applicationContext.getMessage(NAME + ".lieunaissance.title", null,
                    getLocale());
            Label fieldLieuNaissance = new Label();
            formatLabel(fieldLieuNaissance, captionLieuNaissance,
                    MainUI.getCurrent().getEtudiant().getLieunaissance());
            formGeneralitesLayout.addComponent(fieldLieuNaissance);

            String captionDepNaissance = applicationContext.getMessage(NAME + ".depnaissance.title", null,
                    getLocale());
            Label fieldDepNaissance = new Label();
            formatLabel(fieldDepNaissance, captionDepNaissance,
                    MainUI.getCurrent().getEtudiant().getDepartementnaissance());
            formGeneralitesLayout.addComponent(fieldDepNaissance);

            panelGeneralites.setContent(formGeneralitesLayout);

            HorizontalLayout generalitesGlobalLayout = new HorizontalLayout();
            generalitesGlobalLayout.setSizeUndefined();
            generalitesGlobalLayout.setStyleName("firstitembox");
            generalitesGlobalLayout.addComponent(panelGeneralites);
            generalitesGlobalLayout.setExpandRatio(panelGeneralites, 1);
            idLayout.addComponent(generalitesGlobalLayout);

            /* Bac */

            Panel panelBac = new Panel(applicationContext.getMessage(NAME + ".bac.title", null, getLocale()));

            //Si plusieurs bac
            if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                    && MainUI.getCurrent().getEtudiant().getListeBac().size() > 1) {
                panelBac.setCaption(applicationContext.getMessage(NAME + ".bacs.title", null, getLocale()));
                TabSheet bacTabSheet = new TabSheet();
                VerticalLayout vBacLayout = new VerticalLayout();
                vBacLayout.setSizeFull();
                bacTabSheet.setSizeFull();
                bacTabSheet.addStyleName(ValoTheme.TABSHEET_FRAMED);
                for (BacEtatCivil bec : MainUI.getCurrent().getEtudiant().getListeBac()) {

                    FormLayout tabBacLayout = new FormLayout();
                    tabBacLayout.setSizeFull();
                    tabBacLayout.setMargin(false);
                    ajouterBacToView(tabBacLayout, bec);
                    bacTabSheet.addTab(tabBacLayout, bec.getCod_bac(), FontAwesome.GRADUATION_CAP);

                }
                vBacLayout.addComponent(bacTabSheet);
                panelBac.setContent(vBacLayout);
            } else {
                //Si un seul bac
                FormLayout formBacLayout = new FormLayout();
                formBacLayout.setSizeFull();
                if (MainUI.getCurrent().getEtudiant().getListeBac() != null
                        && MainUI.getCurrent().getEtudiant().getListeBac().size() == 1) {
                    formBacLayout.setSpacing(true);
                    formBacLayout.setMargin(true);
                    ajouterBacToView(formBacLayout, MainUI.getCurrent().getEtudiant().getListeBac().get(0));
                }
                panelBac.setContent(formBacLayout);
            }

            HorizontalLayout bacGlobalLayout = new HorizontalLayout();
            bacGlobalLayout.setSizeUndefined();
            bacGlobalLayout.setStyleName("itembox");
            bacGlobalLayout.addComponent(panelBac);
            bacGlobalLayout.setExpandRatio(panelBac, 1);
            idLayout.addComponent(bacGlobalLayout);

            /* Info de contact */
            panelContact = new Panel(applicationContext.getMessage(NAME + ".contact.title", null, getLocale()));
            renseignerPanelContact();
            globalLayout.addComponent(panelContact);

            addComponent(globalLayout);

        } else {
            /* Erreur */
            addComponent(new BasicErreurMessageLayout(applicationContext));
        }
    }
}

From source file:gov.va.ds4p.ds4pmobileportal.ui.AuditLogs.java

License:Open Source License

public void buildView() {
    CssLayout content = new CssLayout();
    content.setWidth("100%");
    setCaption("Access Control Decisioning Logs - "
            + AdminContext.getSessionAttributes().getSelectedPatientName());

    table = new Table();
    table.setWidth("100%");
    table.setHeight("350px");
    table.setMultiSelect(false);//from ww w . j  av  a  2  s  .  c o  m
    table.setSelectable(true);
    table.setImmediate(true); // react at once when something is selected
    table.setEditable(false);
    table.setWriteThrough(true);
    table.setContainerDataSource(populateAuthorizationRequests());

    table.setColumnReorderingAllowed(true);
    table.setColumnCollapsingAllowed(false);
    table.setVisibleColumns(new Object[] { "msgDate", "healthcareObject", "purposeOfUse", "requestor",
            "uniqueIdentifier", "decision", "responsetime", "messageId" });
    table.setColumnHeaders(new String[] { "Date", "Resource", "POU", "Recipient", "Patient ID", "PDP Decision",
            "Resp. Time(ms)", "Message ID" });

    content.addComponent(table);

    Button obligationsBTN = new Button("Obligations");
    Button rulesGeneratedBTN = new Button("SLS - Rules Generated");
    Button rulesExecutedBTN = new Button("SLS - Rules Executed");

    HorizontalComponentGroup hGroup = new HorizontalComponentGroup();
    hGroup.setWidth("100%");

    hGroup.addComponent(obligationsBTN);
    hGroup.addComponent(rulesGeneratedBTN);
    hGroup.addComponent(rulesExecutedBTN);

    content.addComponent(hGroup);

    obligationsBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            AuthLog log = getAuthLogObject();
            if (log != null) {
                String drl = log.getObligations();
                Popover popover = getPopoverTextArea(drl, "XACML Response - Obligations");
                popover.showRelativeTo(getNavigationBar());
            }
        }
    });

    rulesGeneratedBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            AuthLog log = getAuthLogObject();
            if (log != null) {
                String drl = log.getGenDrl();
                Popover popover = getPopoverTextArea(drl, "Generated DRL (Annotation Rules)");
                popover.showRelativeTo(getNavigationBar());
            }
        }
    });

    rulesExecutedBTN.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            AuthLog log = getAuthLogObject();
            if (log != null) {
                String drl = log.getExecRules();
                Popover popover = getPopoverTextArea(drl, "Executed Annotation Rules");
                popover.showRelativeTo(getNavigationBar());
            }
        }
    });

    setContent(content);
}