Example usage for com.vaadin.ui HorizontalSplitPanel HorizontalSplitPanel

List of usage examples for com.vaadin.ui HorizontalSplitPanel HorizontalSplitPanel

Introduction

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

Prototype

public HorizontalSplitPanel() 

Source Link

Document

Creates an empty horizontal split panel.

Usage

From source file:fi.jasoft.feedreader.ui.ReaderUI.java

License:Apache License

@Override
protected void init(WrappedRequest request) {

    // Create data tables
    feedTable = createFeedsTable();/* ww w  . j  a v  a2  s.  c  o m*/
    entryTable = createEntriesTable();

    // Create the main horizontal split panel
    HorizontalSplitPanel content = new HorizontalSplitPanel();
    content.setStyleName(Reindeer.SPLITPANEL_SMALL);
    content.setSizeFull();
    setContent(content);

    // Create the content of the left part of the main split panel
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    vl.addComponent(feedTable);

    Button addFeedBtn = new Button("Add RSS/Atom feed", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            addFeed();
        }
    });
    addFeedBtn.setWidth("100%");
    vl.addComponent(addFeedBtn);
    vl.setExpandRatio(feedTable, 1);

    content.setFirstComponent(vl);
    content.setSplitPosition(30);

    // Create and set the content of the right part of the main split panel
    VerticalSplitPanel rightPane = new VerticalSplitPanel();
    rightPane.setStyleName(Reindeer.SPLITPANEL_SMALL);
    rightPane.setSizeFull();

    rightPane.addComponent(entryTable);

    entryPanel.setSizeFull();
    rightPane.addComponent(entryPanel);

    content.addComponent(rightPane);
    rightPane.setSplitPosition(30);

    if (feeds.size() > 0) {
        feedTable.setValue(feeds.getItemIds().iterator().next());
    }
}

From source file:fi.jasoft.qrcode.demo.QRCodeDemo.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();//w w w .j  a v a2 s.c o m
    setContent(content);

    Label header = new Label("QR Code Generator");
    header.setStyleName(ValoTheme.LABEL_H2);
    content.addComponent(header);

    HorizontalSplitPanel root = new HorizontalSplitPanel();
    root.setSizeFull();
    root.setSplitPosition(50, Unit.PERCENTAGE);
    root.setLocked(true);

    Panel panel = new Panel(root);
    panel.setSizeFull();
    content.addComponent(panel);
    content.setExpandRatio(panel, 1);

    VerticalLayout first = new VerticalLayout();
    first.setSizeFull();
    root.setFirstComponent(first);

    first.addComponent(
            new HorizontalLayout(createPrimaryColorSelect(), createSecondaryColorSelect(), createSizeSelect()));

    code = new QRCode();
    code.setWidth("100px");
    code.setHeight("100px");

    final TextArea text = new TextArea("Text embedded in QR Code");
    text.setPlaceholder("Type the message of the QR code here");
    text.setSizeFull();
    text.setValueChangeMode(ValueChangeMode.LAZY);
    text.addValueChangeListener(e -> {
        code.setValue(e.getValue());
    });

    first.addComponent(text);
    first.setExpandRatio(text, 1);

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

    vl.addComponent(code);
    vl.setComponentAlignment(code, Alignment.MIDDLE_CENTER);

    root.setSecondComponent(vl);
}

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);
        }//  w  ww . j a  v  a 2s.  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:hu.fnf.devel.wishbox.ui.MainPage.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    PropertysetItem item = new PropertysetItem();
    item.addItemProperty("name", new ObjectProperty<String>("Zaphod"));
    item.addItemProperty("age", new ObjectProperty<Integer>(42));

    // Have some layout
    FormLayout form = new FormLayout();
    HorizontalLayout footer = new HorizontalLayout();
    footer.addComponent(new Button("cica"));
    footer.addComponent(new Button("kutya"));

    // Now create a binder that can also create the fields
    // using the default field factory
    FieldGroup binder = new FieldGroup(item);

    form.addComponent(binder.buildAndBind("Name", "name"));
    form.addComponent(binder.buildAndBind("Age", "age"));

    HorizontalSplitPanel sample = new HorizontalSplitPanel();
    sample.setSizeFull();//from   ww w  .  j av  a 2  s. com

    VerticalSplitPanel verticalSplitPanel = new VerticalSplitPanel();
    verticalSplitPanel.setFirstComponent(form);
    verticalSplitPanel.setSecondComponent(new Label("masodik"));

    sample.setSecondComponent(verticalSplitPanel);

    Table grid = new Table();

    grid.setSizeFull();
    for (Object i : getItemContiner().getItemIds()) {
        System.out.println("item ids: " + i.toString());
    }
    grid.setContainerDataSource(getItemContiner());
    grid.setSelectable(true);
    grid.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            final String valueString = String.valueOf(valueChangeEvent.getProperty().getValue());
            Notification.show("Value changed:", valueString, Notification.Type.TRAY_NOTIFICATION);
        }
    });
    sample.setFirstComponent(grid);

    setContent(sample);

    //            Main window is the primary browser window
    final Window main = new Window("Hello window");
    addWindow(main);
    // "Hello world" text is added to window as a Label component
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();

    if (user != null) {
        String email = user.getEmail();
    } else {
        // no user logged in
    }
    assert user != null;

    main.setContent(new Label(user.getUserId()));
}

From source file:info.magnolia.sample.app.main.SampleMainViewImpl.java

License:Open Source License

@Inject
public SampleMainViewImpl() {
    layout = new HorizontalSplitPanel();
    layout.setSplitPosition(50);
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private Layout getSplitPreviews() {
    Layout grid = getPreviewLayout("Split panels");

    AbstractSplitPanel panel = new VerticalSplitPanel();
    panel.setWidth("230px");
    panel.setHeight("130px");
    grid.addComponent(panel);//from   ww w. j av  a  2 s.  c o  m

    panel = new VerticalSplitPanel();
    panel.setWidth("230px");
    panel.setHeight("130px");
    panel.setStyleName("small");
    grid.addComponent(panel);

    panel = new HorizontalSplitPanel();
    panel.setWidth("230px");
    panel.setHeight("130px");
    grid.addComponent(panel);

    panel = new HorizontalSplitPanel();
    panel.setWidth("230px");
    panel.setHeight("130px");
    panel.setStyleName("small");
    grid.addComponent(panel);

    return grid;
}

From source file:myGroup.gwt.client.ui.MyUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    HorizontalSplitPanel sample = new HorizontalSplitPanel();
    sample.setSizeFull();/*from  w  ww .j  av a 2 s .  com*/
    //        sample.setSplitPosition(150.0f, PIXELS);

    sample.setSecondComponent(new Label("korte"));

    setContent(sample);

    Table grid = new Table();

    grid.setSizeFull();
    for (Object i : getItemContiner().getItemIds()) {
        System.out.println(i.toString());
    }
    grid.setContainerDataSource(getItemContiner());
    grid.setSelectable(true);
    grid.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            final String valueString = String.valueOf(valueChangeEvent.getProperty().getValue());
            Notification.show("Value changed:", valueString, Notification.Type.TRAY_NOTIFICATION);
        }
    });
    sample.setFirstComponent(grid);

    //            Main window is the primary browser window
    final Window main = new Window("Hello window");
    addWindow(main);
    // "Hello world" text is added to window as a Label component
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();

    if (user != null) {
        String email = user.getEmail();
    } else {
        // no user logged in
    }
    assert user != null;

    main.setContent(new Label(user.getUserId()));
}

From source file:net.javaforge.netty.vaadin.AddressbookUI.java

License:Apache License

private void initLayout() {

    /* Root of the user interface component tree is set */
    HorizontalSplitPanel splitPanel = new HorizontalSplitPanel();
    setContent(splitPanel);//from w w  w  .java  2  s.  com

    /* Build the component tree */
    VerticalLayout leftLayout = new VerticalLayout();
    splitPanel.addComponent(leftLayout);
    splitPanel.addComponent(editorLayout);
    leftLayout.addComponent(contactList);
    HorizontalLayout bottomLeftLayout = new HorizontalLayout();
    leftLayout.addComponent(bottomLeftLayout);
    bottomLeftLayout.addComponent(searchField);
    bottomLeftLayout.addComponent(addNewContactButton);

    /* Set the contents in the left of the split panel to use all the space */
    leftLayout.setSizeFull();

    /*
       * On the left side, expand the size of the contactList so that it uses
     * all the space left after from bottomLeftLayout
     */
    leftLayout.setExpandRatio(contactList, 1);
    contactList.setSizeFull();

    /*
     * In the bottomLeftLayout, searchField takes all the width there is
     * after adding addNewContactButton. The height of the layout is defined
     * by the tallest component.
     */
    bottomLeftLayout.setWidth("100%");
    searchField.setWidth("100%");
    bottomLeftLayout.setExpandRatio(searchField, 1);

    /* Put a little margin around the fields in the right side editor */
    editorLayout.setMargin(true);
    editorLayout.setVisible(false);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java

License:Apache License

private Component getEmailSettingTab() {
    VerticalLayout s2 = new VerticalLayout();
    HorizontalSplitPanel split2 = new HorizontalSplitPanel();
    s2.addComponent(split2);/*from   w w  w  .  ja va 2 s .c  o  m*/
    Tree sTree2 = new Tree(TRANSLATOR.translate("general.email.settings"));
    sTree2.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (sTree2.getValue() instanceof VmSetting) {
            VmSetting vmSetting = (VmSetting) sTree2.getValue();
            split2.setSecondComponent(displaySetting(vmSetting, !vmSetting.getSetting().equals("mail.enable")));
        }
    });
    split2.setFirstComponent(sTree2);
    VMSettingServer.getSettings().forEach(s -> {
        if (s.getSetting().startsWith("mail")) {
            sTree2.addItem(s);
            sTree2.setChildrenAllowed(s, false);
            sTree2.setItemCaption(s, TRANSLATOR.translate(s.getSetting()));
        }
    });
    Button testEmail = new Button(TRANSLATOR.translate("general.email.settings.test"), listener -> {
        //Show a window to test email settings
        VMWindow w = new VMWindow(TRANSLATOR.translate("general.email.settings.test"));
        VerticalLayout vl = new VerticalLayout();
        TextField to = new TextField(TRANSLATOR.translate("general.email.to"));
        TextField from = new TextField(TRANSLATOR.translate("general.email.from"));
        TextField subject = new TextField(TRANSLATOR.translate("general.email.subject"));
        TextArea mess = new TextArea(TRANSLATOR.translate("general.email.message"));
        mess.setSizeFull();
        TextArea output = new TextArea(TRANSLATOR.translate("general.output"));
        output.setReadOnly(true);
        output.setSizeFull();
        Button send = new Button(TRANSLATOR.translate("general.email.send"), l -> {
            try {
                Lookup.getDefault().lookup(IEmailManager.class).sendEmail(to.getValue(), null, from.getValue(),
                        subject.getValue(), mess.getValue());
                output.setValue(TRANSLATOR.translate("general.email.settings.test.success"));
                //Successful, update the enable setting.
                VMSettingServer enable = new VMSettingServer("mail.enable");
                enable.setBoolVal(true);
                enable.write2DB();
            } catch (Exception ex) {
                LOG.log(Level.SEVERE, null, ex);
                StringWriter sw = new StringWriter();
                ex.printStackTrace(new PrintWriter(sw));
                output.setReadOnly(false);
                output.setValue(sw.toString());
                output.setReadOnly(true);
            }
        });
        vl.addComponent(to);
        vl.addComponent(from);
        vl.addComponent(subject);
        vl.addComponent(mess);
        vl.addComponent(send);
        vl.addComponent(output);
        w.setContent(vl);
        w.setHeight(75, Sizeable.Unit.PERCENTAGE);
        w.setWidth(75, Sizeable.Unit.PERCENTAGE);
        ValidationManagerUI.getInstance().addWindow(w);
    });
    s2.addComponent(testEmail);
    return s2;
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java

License:Apache License

private Component getSettingTab() {
    VerticalLayout sl = new VerticalLayout();
    HorizontalSplitPanel split1 = new HorizontalSplitPanel();
    sl.addComponent(split1);/*from   ww  w .  j a v a2s  . com*/
    Tree sTree = new Tree(TRANSLATOR.translate("general.settings"));
    split1.setFirstComponent(sTree);
    sTree.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (sTree.getValue() instanceof VmSetting) {
            split1.setSecondComponent(displaySetting((VmSetting) sTree.getValue()));
        }
    });
    VMSettingServer.getSettings().forEach(s -> {
        if (!s.getSetting().startsWith("mail")) {
            sTree.addItem(s);
            sTree.setChildrenAllowed(s, false);
            sTree.setItemCaption(s, TRANSLATOR.translate(s.getSetting()));
        }
    });
    return sl;
}