Example usage for com.vaadin.ui VerticalLayout setComponentAlignment

List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment

Introduction

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

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyMailPanel.java

License:Open Source License

@Override
public void initGui() {
    super.initGui();

    String left = "Players can choose to receive messages in-game or externally (or both or neither).<br/><br/>Player messages are private and"
            + " actual email identities are hidden.<br/><br/>You can find another player's profile by clicking on their name or using the search"
            + " feature. Then you may send a message to that player by clicking on the "
            + "<i>Send player private email</i> link.<br/><br/>If this link is not present or is disabled, then the player has opted "
            + "to receive neither email nor in-game messages.<br/><br/>";
    getLeftLabel().setValue(left);//from   w  w  w .jav  a2 s .  com

    if (!userIsMe) {
        User u = User.getTL(uid);
        if (u.isOkEmail() || u.isOkGameMessages()) {
            final NativeButton sendEmailButt = new NativeButton("Send private mail to this user");
            sendEmailButt.addStyleName(BaseTheme.BUTTON_LINK);
            sendEmailButt.addStyleName("m-userProfile3-sendmail-button");
            Label sp;
            VerticalLayout vl = getRightLayout();

            vl.setSizeUndefined();
            vl.setWidth("100%");
            vl.addComponent(sp = new Label());
            sp.setHeight("50px");
            vl.addComponent(sendEmailButt);
            vl.setComponentAlignment(sendEmailButt, Alignment.MIDDLE_CENTER);
            vl.addComponent(sp = new Label());
            sp.setHeight("1px");
            vl.setExpandRatio(sp, 1.0f);

            sendEmailButt.addClickListener(new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                @MmowgliCodeEntry
                @HibernateOpened
                @HibernateClosed
                public void buttonClick(ClickEvent event) {
                    HSess.init();

                    User u = User.getTL(uid);
                    if (u.isOkEmail() || u.isOkGameMessages()) // redundant here
                        new SendMessageWindow(u, imAdminOrGameMaster);
                    else
                        Notification.show("Sorry", "Player " + u.getUserName() + " does not receive mail.",
                                Notification.Type.WARNING_MESSAGE);

                    HSess.close();
                }
            });
        }
        return;
    }
    VerticalLayout rightVL = getRightLayout();
    rightVL.setSizeUndefined();
    rightVL.setWidth("100%");

    getLeftAddedVerticalLayout()
            .addComponent(showButt = new ToggleLinkButton("View all", "View unhidden only", null)); //,ttArray));
    showButt.addOnListener(new ViewAllListener());
    showButt.addOffListener(new ViewUnhiddenOnlyListener());
    showButt.setToolTips("Temporarily show all messages, including those marked \"hidden\"",
            "Temporarily hide messages marked \"hidden\"");
    Label sp;
    rightVL.addComponent(sp = new Label());
    sp.setHeight("10px");
    rightVL.addComponent(mailPanel);

    User me = Mmowgli2UI.getGlobals().getUserTL();
    Set<Message> msgs = me.getGameMessages();
    if (msgs.size() > 0) {
        Message[] msgsAr = new Message[msgs.size()];
        msgsAr = msgs.toArray(msgsAr); // avoid concurrent mod
        int num = msgsAr.length;// .size();
        int n = num;
        for (Message m : msgsAr) {
            addOneMessage(m, n--, num, null);
        }
    }
}

From source file:edu.nps.moves.mmowgli.utility.HistoryDialog.java

License:Open Source License

public HistoryDialog(SortedSet<Edits> set, String windowTitle, String tableTitle, String columnTitle,
        DoneListener dLis) {//from w  w w.  j  a v  a 2  s.c  o m
    this.set = set;
    this.doneListener = dLis;

    setCaption(windowTitle);
    setModal(true);
    setWidth("500px");
    setHeight("400px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    vLay.setSizeFull();
    table = new Table(tableTitle);
    table.setSelectable(true);
    table.setContainerDataSource(makeContainer());
    table.addValueChangeListener(new TableListener());
    table.setVisibleColumns(new Object[] { "label", "string" });
    table.setColumnHeaders(new String[] { "", columnTitle });
    table.setImmediate(true);

    table.setSizeFull();
    table.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
        private static final long serialVersionUID = 1L;

        public String generateDescription(Component source, Object itemId, Object propertyId) {
            return ((StringBean) itemId).string;
        }
    });

    vLay.addComponent(table);
    vLay.setExpandRatio(table, 1.0f);
    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    HorizontalLayout buttLay = new HorizontalLayout();
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);
    cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    okButt = new NativeButton();
    mLoc.decorateOkButton(okButt);
    buttLay.addComponent(okButt);
    buttLay.setComponentAlignment(okButt, Alignment.BOTTOM_RIGHT);
    okButt.setEnabled(false);

    cancelButt.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            UI.getCurrent().removeWindow(HistoryDialog.this);
            if (doneListener != null)
                doneListener.doneTL(null, -1);
            HSess.close();
        }
    });
    okButt.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        @MmowgliCodeEntry
        @HibernateOpened
        @HibernateClosed
        public void buttonClick(ClickEvent event) {
            HSess.init();
            UI.getCurrent().removeWindow(HistoryDialog.this);
            StringBean obj = (StringBean) table.getValue();
            if (doneListener != null) {
                if (obj != null) {
                    int idx = obj.getOrder();
                    doneListener.doneTL(obj.getString(), idx);
                } else
                    doneListener.doneTL(null, -1);
            }
            HSess.close();
        }
    });
}

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

License:Open Source License

public SigninPopover() {
    setWidth("300px");
    setHeight("350px");
    setClosable(false); // else it can be closed by clicking anywhere outside it

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);//from  w  ww .  jav a2  s  .  c om
    layout.setMargin(true);
    layout.addComponent(nameTF = new TextField("Player name"));
    nameTF.setWidth("100%");
    layout.addComponent(pwTF = new PasswordField("Password"));
    pwTF.setWidth("100%");

    Label lab;
    layout.addComponent(lab = new Label());
    lab.setHeight("25px");

    layout.addComponent(submitButt = new Button("Sign in", new SubmitListener()));
    submitButt.setSizeUndefined();

    layout.addComponent(errorLab = new HtmlLabel(""));
    layout.setComponentAlignment(errorLab, Alignment.TOP_CENTER);
    // Decorate with navigation view
    NavigationView content = new NavigationView(layout);
    content.setCaption("Sign in");
    setContent(content);
    // Have a close button
    /*
    Button close = new Button(null, this);
    close.setIcon(new ThemeResource("../runo/icons/64/cancel.png"));
    content.setRightComponent(close); 
    */
}

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

License:Open Source License

public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList,
        AbstractOrderedLayout layout) {//  ww  w  .java 2  s . co  m
    // messageList can be null if coming in from ActionPlan
    Object key = HSess.checkInit();
    UserListEntry wu = (UserListEntry) message;
    User u = wu.getUser();
    layout.removeAllComponents();

    HorizontalLayout hlay = new HorizontalLayout();
    layout.addComponent(hlay);
    hlay.addStyleName("m-userview-top");
    hlay.setWidth("100%");
    hlay.setMargin(true);
    hlay.setSpacing(true);

    Image img = new Image();
    img.addStyleName("m-ridgeborder");
    img.setSource(mediaLocator.locate(u.getAvatar().getMedia()));
    img.setWidth("90px");
    img.setHeight("90px");
    hlay.addComponent(img);
    hlay.setComponentAlignment(img, Alignment.MIDDLE_CENTER);

    Label lab;
    hlay.addComponent(lab = new Label());
    lab.setWidth("5px");

    VerticalLayout vlay = new VerticalLayout();
    vlay.setSpacing(true);
    hlay.addComponent(vlay);
    hlay.setComponentAlignment(vlay, Alignment.MIDDLE_LEFT);
    vlay.setWidth("100%");
    hlay.setExpandRatio(vlay, 1.0f);
    HorizontalLayout horl = new HorizontalLayout();
    horl.setSpacing(false);
    vlay.addComponent(horl);
    vlay.setComponentAlignment(horl, Alignment.BOTTOM_LEFT);
    horl.addComponent(lab = new Label("name"));
    lab.addStyleName("m-user-top-label"); //light-text");
    horl.addComponent(lab = new HtmlLabel("&nbsp;&nbsp;" + u.getUserName()));
    lab.addStyleName("m-user-top-value");
    horl = new HorizontalLayout();
    horl.setSpacing(false);
    vlay.addComponent(horl);
    vlay.setComponentAlignment(horl, Alignment.TOP_LEFT);

    horl.addComponent(lab = new Label("level"));
    lab.addStyleName("m-user-top-label"); //light-text");
    Level lev = u.getLevel();
    if (u.isGameMaster()) {
        Level l = Level.getLevelByOrdinal(Level.GAME_MASTER_ORDINAL, HSess.get());
        if (l != null)
            lev = l;
    }
    horl.addComponent(lab = new HtmlLabel("&nbsp;&nbsp;&nbsp;" + lev.getDescription()));
    lab.addStyleName("m-user-top-value");

    GridLayout gLay = new GridLayout();
    // gLay.setHeight("155px");  // won't size properly
    gLay.setMargin(true);
    gLay.addStyleName("m-userview-mid");
    gLay.setColumns(2);
    gLay.setRows(11);
    gLay.setSpacing(true);
    gLay.setWidth("100%");
    gLay.setColumnExpandRatio(1, 1.0f);
    layout.addComponent(gLay);

    addRow(gLay, "user ID:", "" + getPojoId(message));
    addRow(gLay, "location:", u.getLocation());
    addRow(gLay, "expertise:", u.getExpertise());
    addRow(gLay, "affiliation:", u.getAffiliation());
    addRow(gLay, "date registered:", formatter.format(u.getRegisterDate()));

    gLay.addComponent(new Hr(), 0, 5, 1, 5);

    Container cntr = new CardsByUserContainer<Card>(u); // expects ThreadLocal session to be setup
    numCards = cntr.size();
    addRow(gLay, "cards played:", "" + numCards);
    cntr = new ActionPlansByUserContainer<Card>(u); // expects ThreadLocal session to be setup
    numAps = cntr.size();
    addRow(gLay, "action plans:", "" + numAps);

    gLay.addComponent(new Hr(), 0, 8, 1, 8);

    addRow(gLay, "exploration points:", "" + u.getBasicScore());
    addRow(gLay, "innovation points:", "" + u.getInnovationScore());

    cardListener = new CardLis(u, mView);
    apListener = new AppLis(u, mView);

    layout.addComponent(makeButtons());

    HSess.checkClose(key);
}

From source file:edu.nps.moves.security.PasswordResetUI.java

License:Open Source License

private void handleChangeTL(User user) {
    this.user = user;
    Game g = Game.getTL();/* w w w. j  a va2 s . co m*/

    String brand = g.getCurrentMove().getTitle();
    Page.getCurrent().setTitle("Password reset for " + brand + " mmowgli");

    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setMargin(true);
    hLay.setWidth("100%");
    setContent(hLay);

    GameLinks gl = GameLinks.getTL();
    String blog = gl.getBlogLink();
    Label lab;
    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    VerticalLayout vl = new VerticalLayout();
    hLay.addComponent(vl);
    vl.setWidth(bannerWidthPx);

    hLay.addComponent(lab = new Label());
    hLay.setExpandRatio(lab, 0.5f);

    vl.addStyleName("m-greyborder");
    vl.setMargin(true);
    vl.setSpacing(true);

    vl.addComponent(lab = new HtmlLabel(""));
    lab.addStyleName("m-font-21-bold");
    lab.setSizeUndefined();
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);
    StringBuilder sb = new StringBuilder();
    sb.append(thanksHdr1);
    sb.append(blog);
    sb.append(thanksHdr2);
    sb.append(brand);
    sb.append(thanksHdr3);
    lab.setValue(sb.toString());

    vl.addComponent(lab = new HtmlLabel(""));
    lab.setHeight("15px");
    vl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER);

    FormLayout fLay = new FormLayout();
    fLay.setSizeUndefined();
    fLay.addStyleName("m-login-form"); // to allow styling contents (v-textfield)
    vl.addComponent(fLay);
    vl.setComponentAlignment(fLay, Alignment.MIDDLE_CENTER);

    newPw = new PasswordField("New Password");
    newPw.setWidth("99%");
    fLay.addComponent(newPw);

    newPw2 = new PasswordField("Again, please");
    newPw2.setWidth("99%");
    fLay.addComponent(newPw2);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vl.addComponent(buttLay);
    vl.setComponentAlignment(buttLay, Alignment.TOP_CENTER);

    NativeButton cancelButt = new NativeButton();
    cancelButt.setStyleName("m-cancelButton");
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    saveButt = new NativeButton();
    saveButt.setClickShortcut(ShortcutAction.KeyCode.ENTER);
    saveButt.setStyleName("m-continueButton"); //m-saveChangesButton");
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    cancelButt.addClickListener(this);
    saveButt.addClickListener(this);
}

From source file:eu.eco2clouds.portal.component.apwizard.SuggestionStep.java

License:Apache License

private void render() {

    this.removeAllComponents();

    if (this.mainLayout != null && this.mainLayout.getMenu() != null
            && this.mainLayout.getMenu().getResourcesStep() != null
            && this.mainLayout.getMenu().getResourcesStep().getNewResourceTable() != null
            && this.mainLayout.getMenu().getGeneralStep().getDuration() != null
            && this.mainLayout.getMenu().getGeneralStep().getDuration().getValue() != null
            && !this.mainLayout.getMenu().getGeneralStep().getDuration().getValue().equals("")) {

        VerticalLayout vlCpuLoad = new VerticalLayout();
        vlCpuLoad.setMargin(false);/*from   w w  w.jav  a2 s. c  o  m*/
        vlCpuLoad.setSpacing(true);
        Label lblCpuLoad = new Label("Average Cpu Load");
        vlCpuLoad.addComponent(lblCpuLoad);

        this.sliderCpuLoad.addValueChangeListener(new Property.ValueChangeListener() {

            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                updateChart();
            }
        });

        HorizontalLayout hl = new HorizontalLayout();
        hl.setMargin(false);
        hl.setSpacing(true);
        hl.addComponent(new Label("min 0", ContentMode.HTML));
        hl.addComponent(sliderCpuLoad);
        hl.addComponent(new Label("100 max", ContentMode.HTML));

        vlCpuLoad.addComponent(hl);

        vlCpuLoad.setComponentAlignment(lblCpuLoad, Alignment.MIDDLE_LEFT);
        vlCpuLoad.setComponentAlignment(hl, Alignment.MIDDLE_LEFT);

        this.deploymentTable.setContainerDataSource(this.getCombination());
        this.deploymentTable.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(final Property.ValueChangeEvent event) {

                DeploymentTableBean item = (DeploymentTableBean) deploymentTable.getValue();
                System.out.println("item is " + item);
                int selected = item.getId() - 1;

                long duration = Long.parseLong(mainLayout.getMenu().getGeneralStep().getDuration().getValue());

                System.out.println("selected " + selected);
                System.out.println("power fr" + power_fr[selected]);
                System.out.println("power uk" + power_uk[selected]);
                System.out.println("power de" + power_de[selected]);

                TrendWindow trendWindow = new TrendWindow(power_fr[selected], power_uk[selected],
                        power_de[selected], duration);
                UI.getCurrent().addWindow(trendWindow);

            }
        });

        this.deploymentTable.addGeneratedColumn("GEC", new ColumnGenerator() {

            @Override
            public Object generateCell(final Table source, final Object itemId, Object columnId) {

                ArrayList<String> locations = new ArrayList<String>();
                String[] vms = ((DeploymentTableBean) itemId).getCombination().split(" ");
                for (int i = 0; i < vms.length; i++) {

                    String vmName = vms[i].split("@")[0];
                    String vmLocation = vms[i].split("@")[1];
                    if (!locations.contains(vmLocation)) {
                        locations.add(vmLocation);
                    }

                }

                SourcePercentage sp = SchedulerManagerFactory.getInstance().getGEC(locations);

                return new Label(Double.toString(sp.getGEC()));
            }
        });

        this.deploymentTable.addGeneratedColumn("", new ColumnGenerator() {

            @Override
            public Object generateCell(final Table source, final Object itemId, Object columnId) {

                Button button = new Button("");
                button.setStyleName(Reindeer.BUTTON_LINK);
                button.setIcon(new ThemeResource("img/pie.png"));
                button.setDescription("GEC");

                button.addClickListener(new Button.ClickListener() {

                    @Override
                    public void buttonClick(Button.ClickEvent event) {

                        ArrayList<String> locations = new ArrayList<String>();
                        String[] vms = ((DeploymentTableBean) itemId).getCombination().split(" ");
                        for (int i = 0; i < vms.length; i++) {

                            String vmName = vms[i].split("@")[0];
                            String vmLocation = vms[i].split("@")[1];
                            if (!locations.contains(vmLocation)) {
                                locations.add(vmLocation);
                            }

                        }

                        SourcePercentage sp = SchedulerManagerFactory.getInstance().getGEC(locations);
                        GECWindow gecWindow = new GECWindow(((DeploymentTableBean) itemId).getCombination(),
                                sp);
                        UI.getCurrent().addWindow(gecWindow);

                    }
                });

                return button;
            }
        });

        this.deploymentTable.addGeneratedColumn(" ", new ColumnGenerator() {

            @Override
            public Object generateCell(final Table source, final Object itemId, Object columnId) {

                Button button = new Button("");
                button.setStyleName(Reindeer.BUTTON_LINK);
                button.setIcon(new ThemeResource("img/trend.png"));
                button.setDescription("CO2 trend");
                button.addClickListener(new Button.ClickListener() {

                    @Override
                    public void buttonClick(Button.ClickEvent event) {

                        //DeploymentTableBean item = (DeploymentTableBean) deploymentTable.getValue();
                        System.out.println("item is " + itemId);
                        int selected = ((DeploymentTableBean) itemId).getId() - 1;

                        long duration = Long
                                .parseLong(mainLayout.getMenu().getGeneralStep().getDuration().getValue());

                        System.out.println("selected " + selected);
                        System.out.println("power fr" + power_fr[selected]);
                        System.out.println("power uk" + power_uk[selected]);
                        System.out.println("power de" + power_de[selected]);

                        TrendWindow trendWindow = new TrendWindow(power_fr[selected], power_uk[selected],
                                power_de[selected], duration);
                        UI.getCurrent().addWindow(trendWindow);

                    }
                });

                return button;
            }
        });

        vlCpuLoad.addComponent(deploymentTable);

        OptionGroup chartAspect = new OptionGroup("Chart aspect");
        chartAspect.addItem(1);
        chartAspect.setItemCaption(1, "NORMAL");
        chartAspect.addItem(2);
        chartAspect.setItemCaption(2, "PERCENTAGE");

        chartAspect.select(1);
        chartAspect.setNullSelectionAllowed(false);
        chartAspect.setImmediate(true);

        chartAspect.addValueChangeListener(new ValueChangeListener() {
            @Override
            public void valueChange(final ValueChangeEvent event) {
                //final String valueString = String.valueOf(event.getProperty()
                //        .getValue());

                if (co2CountryChart != null) {
                    co2CountryChart.toggleAspect();
                }
            }
        });

        vlCpuLoad.addComponent(chartAspect);

        chartHl.addComponent(vlCpuLoad);

        this.compute();

        this.co2CountryChart = new CO2CountryChart(sdf.format(new Date()),
                this.deploymentTable.getItemIds().size(), co2_fr, co2_uk, co2_de,
                this.sliderCpuLoad.getValue());

        chartHl.addComponent(this.co2CountryChart);

        chartHl.setComponentAlignment(vlCpuLoad, Alignment.TOP_LEFT);
        chartHl.setComponentAlignment(this.co2CountryChart, Alignment.TOP_RIGHT);

        this.addComponent(chartHl);

    } else {
        Label lblEmpty = new Label("No resources defined.");
        this.addComponent(lblEmpty);
    }

}

From source file:eu.eco2clouds.portal.component.PictureWindow.java

License:Apache License

private void render() {

    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);//w  w  w.ja  v a 2s .c o m
    content.setMargin(true);
    content.setSizeFull();

    Image image = new Image();
    //image.setSource(new ThemeResource("img/applicationsample.png"));
    image.setSource(new FileResource(
            new File(Configuration.propertiesDir + File.separator + "sample_applicationprofile.png")));
    //image.setHeight("300px");
    content.addComponent(image);

    Button btnClose = new Button("Close");
    btnClose.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {

            close();
        }
    });

    content.addComponent(btnClose);
    content.setExpandRatio(image, 1.0f);
    content.setComponentAlignment(btnClose, Alignment.BOTTOM_CENTER);
    this.setContent(content);

    this.setHeight("450px");
    this.setWidth("900px");

    this.center();
    this.setModal(true);
}

From source file:eu.lod2.stat.dsdrepo.DSDRepoComponentWrapper.java

private void refresh() {
    mainContainer.removeAllComponents();
    String currentGraph = state.getCurrentGraph();
    if (currentGraph == null || currentGraph.isEmpty()) {
        VerticalLayout l = new VerticalLayout();
        l.setSizeFull();//from   w  w w . j ava2 s.  c  o m
        mainContainer.addComponent(l);
        Label message = new Label("No graph is currently selected. You can select one below:");
        l.addComponent(message);
        l.setExpandRatio(message, 0.0f);
        ConfigurationTab config = new ConfigurationTab(this.state);
        l.addComponent(config);
        l.setExpandRatio(config, 2.0f);
        l.setComponentAlignment(message, Alignment.TOP_LEFT);
        l.setComponentAlignment(config, Alignment.TOP_LEFT);

        return;
    }

    mainContainer.addComponent(new DSDRepoComponent(state.getRdfStore(), currentGraph));
}

From source file:eu.lod2.stat.StatLOD2Demo.java

License:Apache License

/**
 * A function to get an ontowiki export command
 * @param format - the formating string defining the format to export in
 *//*from  w  ww.jav  a 2  s .co m*/
private MenuBar.Command getOWExportCommand(final String format) {
    return new MenuBar.Command() {
        public void menuSelected(final MenuItem selectedItem) {
            String currentGraph = state.getCurrentGraph();
            if (currentGraph == null || currentGraph.isEmpty()) {
                final Window window = new Window("No graph selected");
                window.setWidth("550px");
                LOD2DemoState.CurrentGraphListener listener = new LOD2DemoState.CurrentGraphListener() {
                    boolean ignoreFirst = true;

                    public void notifyCurrentGraphChange(String graph) {
                        if (ignoreFirst) {
                            ignoreFirst = false;
                            return;
                        }
                        window.getParent().removeWindow(window);
                        menuSelected(selectedItem);
                        state.removeCurrentGraphListener(this);
                    }
                };
                VerticalLayout layout = (VerticalLayout) window.getContent();
                layout.addComponent(new Label(
                        "You did not specify a graph to work with. Please do so below and try again: "));
                ConfigurationTab configure = new ConfigurationTab(state);
                layout.addComponent(configure);
                layout.setComponentAlignment(configure, Alignment.BOTTOM_CENTER);
                getMainWindow().addWindow(window);
                window.center();
                state.addCurrentGraphListener(listener);
                return;
            }
            try {
                getMainWindow()
                        .open(new ExternalResource(state.getHostNameWithoutPort() + "/ontowiki/model/export?m="
                                + URLEncoder.encode(currentGraph, "UTF-8") + "&f=" + format));
            } catch (UnsupportedEncodingException e) {
                // should never happen
                throw new RuntimeException("The lod2 server encountered error when exporting the graph: "
                        + e.getMessage() + " Please contact an administrator");
            }
        }
    };
}

From source file:eu.maxschuster.vaadin.buttonlink.demo.DemoUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    final VerticalLayout wrapper = new VerticalLayout();
    wrapper.setSizeFull();/*from  w  w w.j av  a2  s  . c  o  m*/
    setContent(wrapper);

    // Show it in the middle of the screen
    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeUndefined();
    wrapper.addComponent(layout);
    wrapper.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

    final Label themeName = new Label();
    themeName.setCaption("Current Theme:");
    themeName.addStyleName("h1");
    layout.addComponent(themeName);

    Label waring = new Label("<strong>Attention:</strong><br />\nChanging the theme may take a few seconds!");
    waring.setContentMode(ContentMode.HTML);
    layout.addComponent(waring);

    getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() {

        @Override
        public void uriFragmentChanged(UriFragmentChangedEvent event) {
            String fragment = event.getUriFragment().replace("!", "");
            if (fragment.isEmpty()) {
                fragment = defaultTheme;
            }
            loadTheme(fragment);
        }
    });

    themeSelect.setSizeFull();
    themeSelect.setNullSelectionAllowed(false);
    themeSelect.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            String fragment = "!" + themeSelect.getValue();
            getPage().setUriFragment(fragment);
        }
    });
    layout.addComponent(themeSelect);
    layout.setComponentAlignment(themeSelect, Alignment.BOTTOM_CENTER);

    final CheckBox useIcon = new CheckBox("Use icons");
    useIcon.setValue(false);
    layout.addComponent(useIcon);

    final HorizontalLayout comparsionLayout = new HorizontalLayout();
    comparsionLayout.setSpacing(true);
    layout.addComponent(comparsionLayout);
    layout.setComponentAlignment(comparsionLayout, Alignment.TOP_CENTER);

    final Button button = new Button("This is a \"normal\" Button", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            Notification.show("Hello World!");
        }
    });
    comparsionLayout.addComponent(button);
    comparsionLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

    // Initialize our new UI component
    final ButtonLink buttonLink = new ButtonLink("This is a ButtonLink",
            new ExternalResource("https://vaadin.com"));
    buttonLink.setTargetName("_blank");
    buttonLink.setDescription("Visit vaadin.com in a new tab or window.");
    buttonLink.addStyleName("test-stylename");
    comparsionLayout.addComponent(buttonLink);
    comparsionLayout.setComponentAlignment(buttonLink, Alignment.MIDDLE_LEFT);

    themeName.setPropertyDataSource(themeSelect);

    useIcon.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            boolean b = (Boolean) event.getProperty().getValue();
            if (b) {
                button.setIcon(vaadinIcon, "Vaadin Logo");
                buttonLink.setIcon(vaadinIcon, "Vaadin Logo");
            } else {
                button.setIcon(null);
                buttonLink.setIcon(null);
            }
        }
    });

    String fragment = getPage().getUriFragment();

    loadTheme(
            fragment == null || fragment.replace("!", "").isEmpty() ? defaultTheme : fragment.replace("!", ""));
}