Example usage for com.vaadin.ui Button setWidth

List of usage examples for com.vaadin.ui Button setWidth

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

private Component getMembers(Group g) {
    VerticalLayout layoutRootMembers = new VerticalLayout();
    layoutRootMembers.setMargin(false);/*  w  w  w .  j  av  a  2s .  c  o  m*/
    layoutRootMembers.setWidth("100%");
    Panel panelMembers = new Panel(Language.get(Word.MEMBERS));
    Language.setCustom(Word.MEMBERS, s -> panelMembers.setCaption(s));
    panelMembers.setWidth("100%");
    panelMembers.setHeight("200px");

    VerticalLayout layoutMembers = new VerticalLayout();
    mapLayoutMembers.put(g, layoutMembers);
    layoutMembers.setWidth("100%");

    refreshMembers(g, layoutMembers);

    panelMembers.setContent(layoutMembers);
    layoutRootMembers.addComponent(panelMembers);

    if (GroupUtils.isAdmin(g, UserUtils.getCurrent())) {
        CssLayout addUserGroup = new CssLayout();
        addUserGroup.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
        addUserGroup.setWidth("100%");

        TextField textFieldaddUser = new TextField();
        Language.setCustom(Word.USERNAME, s -> textFieldaddUser.setPlaceholder(s));
        textFieldaddUser.setMaxLength(255);
        textFieldaddUser.setWidth("70%");
        addUserGroup.addComponent(textFieldaddUser);

        Button buttonAddUser = new Button();
        buttonAddUser.setIcon(VaadinIcons.PLUS);
        buttonAddUser.addStyleName(ValoTheme.BUTTON_PRIMARY);
        buttonAddUser.setWidth("30%");
        buttonAddUser.addClickListener(e -> {
            try {
                User u = UserUtils.getUser(textFieldaddUser.getValue());
                textFieldaddUser.clear();
                GroupUtils.addUser(g, u);
                refreshAll(g);
            } catch (UserNotFoundException ex) {
                VaadinUtils.errorNotification(Language.get(Word.USER_NOT_FOUND));
            }
        });
        addUserGroup.addComponent(buttonAddUser);

        layoutRootMembers.addComponent(addUserGroup);
    }

    return layoutRootMembers;
}

From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java

private Component getTimeRow(User user, LocalTime time) {
    HorizontalLayout layoutTimeRow = new HorizontalLayout();
    layoutTimeRow.setWidth("100%");

    DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
    Label labelTime = new Label(time.format(formatter));

    Button buttonDelete = new Button(VaadinIcons.TRASH);
    buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER);
    buttonDelete.setWidth("80px");
    buttonDelete.addClickListener(e -> {
        if (layoutClippingTimes.getComponentCount() > 1) {
            layoutClippingTimes.removeComponent(layoutTimeRow);
            UserUtils.removeClippingSendTime(user, time);
        } else {//w w  w .jav  a  2s . c o  m
            VaadinUtils.errorNotification(Language.get(Word.AT_LREAST_ONE_TIME));
        }
    });

    layoutTimeRow.addComponents(labelTime, buttonDelete);
    layoutTimeRow.setComponentAlignment(labelTime, Alignment.MIDDLE_LEFT);
    layoutTimeRow.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER);
    layoutTimeRow.setExpandRatio(labelTime, 5);

    return layoutTimeRow;
}

From source file:edu.kit.dama.ui.admin.LandingPageComponent.java

License:Apache License

public final void update(DigitalObject object, boolean privileged) {
    if (object == null) {
        UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(1, 1);
        builder.fill(new Label("Access to digital object not permitted."), 0, 0);
        mainLayout = builder.getLayout();
        mainLayout.setMargin(true);/*w ww.  ja  va2  s .c om*/
        mainLayout.setSpacing(true);
        mainLayout.setStyleName("landing");
        HorizontalLayout hLayout = new HorizontalLayout(mainLayout);
        hLayout.setSizeFull();
        hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER);
        setCompositionRoot(hLayout);
    } else {
        final TextField oidField = new TextField();
        Button searchButton = new Button("Search");
        Button metsButton = new Button("METS");
        final Button dcButton = new Button("DublinCore");
        Button dataButton = new Button("Download");
        VerticalLayout metadataDownloadButtons = new VerticalLayout(dcButton, metsButton);
        UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(3, 6);

        StreamResource metsResource = new StreamResource(() -> {
            try {
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                MetsBuilder.init(object).createMinimalMetsDocument(UserData.WORLD_USER).write(bout);
                return new ByteArrayInputStream(bout.toByteArray());
            } catch (Exception ex) {
                LOGGER.error("Failed to provide METS document.", ex);
                UIComponentTools.showError(
                        "Failed to initialize METS document for download. Cause: " + ex.getMessage());
                return null;
            }
        }, object.getDigitalObjectIdentifier() + ".mets.xml");

        StreamResource dcResource = new StreamResource(() -> {
            try {
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                DublinCoreHelper.writeDublinCoreDocument(object, UserData.WORLD_USER, bout);
                return new ByteArrayInputStream(bout.toByteArray());
            } catch (ParserConfigurationException ex) {
                LOGGER.error("Failed to provide DC document.", ex);
                UIComponentTools
                        .showError("Failed to initialize DC document for download. Cause: " + ex.getMessage());
                return null;
            }
        }, object.getDigitalObjectIdentifier() + ".dc.xml");

        StreamResource dataResource = new StreamResource(() -> {
            IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
            mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext());
            try {
                IAuthorizationContext ctx = new AuthorizationContext(new UserId(Constants.WORLD_USER_ID),
                        new GroupId(Constants.WORLD_USER_ID), Role.GUEST);
                if (accessGranted(object, ctx) || accessGranted(object, UIHelper.getSessionContext())) {
                    Response response = new PublicDownloadHandler().prepareStream(object);
                    if (response.getStatus() == Response.Status.OK.getStatusCode()) {
                        return (InputStream) response.getEntity();
                    } else {
                        LOGGER.error("Preparation of the public download for object "
                                + object.getDigitalObjectIdentifier() + " returned status "
                                + response.getStatus() + ". Aborting.");
                    }
                }
                throw new IOException("Public access not available.");
            } catch (IOException ex) {
                LOGGER.error(
                        "Failed to provide data stream for object " + object.getDigitalObjectIdentifier() + ".",
                        ex);
                UIComponentTools.showError(
                        "Failed to initialize data stream for public download. Probably, the digital object is not publicly available.");
                return null;
            }
        }, object.getDigitalObjectIdentifier() + ".zip");

        Map<String, String> dcElementMap = new HashMap<>();
        try {
            dcElementMap = DublinCoreHelper.createDublinCoreElementMap(object, UserData.WORLD_USER);
        } catch (ParserConfigurationException ex) {
            LOGGER.error(
                    "Failed to create DC metadata for object with id " + object.getDigitalObjectIdentifier(),
                    ex);
        }
        oidField.setValue(object.getDigitalObjectIdentifier());

        FileDownloader metsDownloader = new FileDownloader(metsResource);
        metsDownloader.extend(metsButton);

        FileDownloader dcDownloader = new FileDownloader(dcResource);
        dcDownloader.extend(dcButton);

        FileDownloader dataDownloader = new FileDownloader(dataResource);
        dataDownloader.extend(dataButton);

        oidField.setSizeFull();
        searchButton.setWidth("128px");

        searchButton.addClickListener((Button.ClickEvent event) -> {
            String oid = oidField.getValue();
            Page.getCurrent().setLocation(
                    URI.create(UIHelper.getWebAppUrl().toString() + "?landing&oid=" + oid).toString());
        });

        dcButton.setWidth("128px");
        metsButton.setWidth("128px");
        dataButton.setWidth("128px");

        metadataDownloadButtons.setComponentAlignment(dcButton, Alignment.TOP_LEFT);
        metadataDownloadButtons.setComponentAlignment(metsButton, Alignment.TOP_LEFT);

        //build layout
        Label oidLabel = new Label("<u>Object Id</u>", ContentMode.HTML);
        builder.fillRow(oidLabel, 0, 0, 1);
        oidLabel.addStyleName("myboldcaption");
        builder.addComponent(oidField, 0, 1, 2, 1).addComponent(searchButton, 2, 1);
        Label dcMetadataLabel = new Label("<u>DC Metadata</u>", ContentMode.HTML);
        builder.fillRow(dcMetadataLabel, 0, 2, 1);
        dcMetadataLabel.addStyleName("myboldcaption");

        Set<Map.Entry<String, String>> entries = dcElementMap.entrySet();

        Table dcTable = new Table();
        dcTable.setPageLength(entries.size() + 1);
        dcTable.addContainerProperty("dc:key", String.class, "-");
        dcTable.addContainerProperty("dc:value", String.class, "-");
        entries.forEach((entry) -> {
            Object newItemId = dcTable.addItem();
            Item row1 = dcTable.getItem(newItemId);
            row1.getItemProperty("dc:key").setValue(entry.getKey());
            row1.getItemProperty("dc:value").setValue(entry.getValue());
        });

        dcTable.setWidth("640px");
        dcTable.addStyleName("myboldcaption");
        builder.addComponent(dcTable, 0, 3, 2, 1);
        builder.addComponent(metadataDownloadButtons, 2, 3, 1, 1);

        builder.fillRow(new Label("<u>Data Access</u>", ContentMode.HTML), 0, 4, 1);
        long bytes = DataOrganizationUtils.getAssociatedDataSize(object.getDigitalObjectId());
        String formatted = AbstractFile.formatSize(bytes);
        Label oidDownloadLabel = new Label(
                object.getDigitalObjectIdentifier() + ".zip (approx. " + formatted + ")");
        oidDownloadLabel.addStyleName("myboldcaption");
        builder.addComponent(oidDownloadLabel, 0, 5, 2, 1);
        builder.addComponent(dataButton, 2, 5, 1, 1);

        mainLayout = builder.getLayout();
        mainLayout.setRowExpandRatio(0, .1f);
        mainLayout.setRowExpandRatio(1, .1f);
        mainLayout.setRowExpandRatio(2, .6f);
        mainLayout.setRowExpandRatio(3, .1f);
        mainLayout.setRowExpandRatio(4, .1f);

        mainLayout.setColumnExpandRatio(0, .1f);
        mainLayout.setColumnExpandRatio(1, .8f);
        mainLayout.setColumnExpandRatio(2, .1f);
    }
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setStyleName("landing");
    HorizontalLayout hLayout = new HorizontalLayout(mainLayout);
    hLayout.setSizeFull();
    hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER);
    setCompositionRoot(hLayout);
}

From source file:edu.kit.dama.ui.repo.MyVaadinUI.java

License:Apache License

/**
 * Setup the login form including its logic.
 *///from w w  w  .j  ava2s  .  c o  m
private void setupLoginForm() {
    email = UIUtils7.factoryTextField("Email", "Please enter your email.", "300px", true, -1, 255);
    password = UIUtils7.factoryPasswordField("Password", "300px", true, -1, 255);
    Button doLoginButton = new Button("Login");
    //login.setClickShortcut(KeyCode.ENTER);
    doLoginButton.setWidth("100px");
    loginForm = new UIUtils7.GridLayoutBuilder(2, 3).addComponent(email, 0, 0, 2, 1)
            .addComponent(password, 0, 1, 2, 1).addComponent(doLoginButton, 0, 2, 1, 1).getLayout();
    loginForm.setComponentAlignment(doLoginButton, Alignment.MIDDLE_LEFT);

    //login listener
    doLoginButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (!UIUtils7.validate(loginForm)) {
                new Notification("Warning", "Please correct the error(s) above.",
                        Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                return;
            }
            String userMail = email.getValue();
            String userPassword = password.getValue();
            IMetaDataManager manager = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
            manager.setAuthorizationContext(AuthorizationContext.factorySystemContext());
            try {
                ServiceAccessToken token = ServiceAccessUtil.getAccessToken(manager, userMail,
                        MAIN_LOGIN_TOKEN_KEY);
                if (token == null) {
                    new Notification("Login Failed", "No login information found for email " + userMail + ".",
                            Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                    return;
                }

                if (!userPassword.equals(token.getSecret())) {
                    new Notification("Login Failed", "Wrong password for email " + userMail + ".",
                            Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                } else {
                    //login successful
                    UserData template = new UserData();
                    template.setDistinguishedName(token.getUserId());
                    List<UserData> result = manager.find(template, template);
                    if (result.isEmpty() || result.size() > 1) {
                        throw new Exception("Invalid number of user entries found for userId "
                                + token.getUserId() + ". Please contact a system administrator.");
                    }
                    //done
                    loggedInUser = result.get(0);
                    refreshMainLayout();
                }
            } catch (Exception ex) {
                new Notification("Login Failed",
                        "Failed to access login database. Please contact an administrator.",
                        Notification.Type.ERROR_MESSAGE).show(Page.getCurrent());
                LOGGER.error("Login failed.", ex);
            } finally {
                manager.close();
            }
        }
    });

    loginForm.setSpacing(true);
    loginForm.setMargin(true);
}

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

License:Open Source License

public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList,
        AbstractOrderedLayout layout) {//from w  w w  . j av a 2 s .c om
    Object key = HSess.checkInit();
    CardListEntry wc = (CardListEntry) message;
    Card c = wc.getCard();
    CardType typ = c.getCardType();

    layout.removeAllComponents();
    layout.setSpacing(true);

    VerticalLayout cardLay = new VerticalLayout();
    cardLay.addStyleName("m-card-render");
    cardLay.setWidth("98%"); //100%");
    cardLay.setSpacing(true);
    layout.addComponent(cardLay);

    HorizontalLayout horl = new HorizontalLayout();
    horl.addStyleName("m-card-header");
    String stl = CardStyler.getCardBaseStyle(typ);
    horl.addStyleName(stl);
    horl.addStyleName(CardStyler.getCardTextColorOverBaseStyle(typ));
    horl.setMargin(true);
    horl.setWidth("100%");

    Label lbl = new Label(typ.getTitle());//c.getText());
    horl.addComponent(lbl);
    lbl = new Label("" + getPojoId(message));
    lbl.addStyleName("m-text-align-right");
    horl.addComponent(lbl);
    cardLay.addComponent(horl);

    horl = new HorizontalLayout();
    horl.setWidth("100%");
    horl.setMargin(true);
    cardLay.addComponent(horl);
    lbl = new Label(c.getText());
    horl.addComponent(lbl);

    horl = new HorizontalLayout();
    horl.addStyleName("m-card-footer");

    horl.setMargin(true);
    horl.setWidth("100%");
    horl.addComponent(lbl = new Label(""));
    lbl.setWidth("5px");

    Image img = new Image();
    img.setSource(mediaLocator.locate(c.getAuthor().getAvatar().getMedia()));
    img.setWidth("30px");
    img.setHeight("30px");
    horl.addComponent(img);

    //    horl.addComponent(lbl=new Label(c.getAuthorName()));
    //    lbl.setWidth("100%");
    //    lbl.addStyleName("m-text-align-center");
    //    horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);
    //    horl.setExpandRatio(lbl, 1.0f);

    Button authButt = new MyButton(c.getAuthorName(), c, mView);
    authButt.setStyleName(BaseTheme.BUTTON_LINK);
    authButt.setWidth("100%");
    horl.addComponent(authButt);
    horl.setComponentAlignment(authButt, Alignment.MIDDLE_CENTER);
    horl.setExpandRatio(authButt, 1.0f);

    horl.addComponent(lbl = new HtmlLabel(formatter.format(message.getTimestamp())));
    lbl.setWidth("115px");
    ;
    lbl.addStyleName("m-text-align-right");
    horl.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);

    cardLay.addComponent(horl);

    //    lbl = new Hr();   
    //    layout.addComponent(lbl);

    lbl = new Label("Child Cards");
    layout.addComponent(lbl);
    lbl.addStyleName("m-text-center");

    //    lbl = new Hr();
    //    layout.addComponent(lbl);

    horl = new HorizontalLayout();
    horl.setSpacing(true);
    horl.setMargin(true);
    horl.setWidth("100%");
    layout.addComponent(horl);

    horl.addComponent(
            makeChildGroupButton("Expand", (CardListEntry) message, CardType.getExpandTypeTL(), messageList));
    horl.addComponent(
            makeChildGroupButton("Counter", (CardListEntry) message, CardType.getCounterTypeTL(), messageList));
    horl.addComponent(
            makeChildGroupButton("Adapt", (CardListEntry) message, CardType.getAdaptTypeTL(), messageList));
    horl.addComponent(
            makeChildGroupButton("Explore", (CardListEntry) message, CardType.getExploreTypeTL(), messageList));

    HSess.checkClose(key);
}

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

License:Apache License

@Override
public Component getLayout() {
    // start-source
    final DDHorizontalLayout layout = new DDHorizontalLayout();
    layout.setComponentHorizontalDropRatio(EQUAL_HORIZONTAL_RATIO);
    layout.setDragMode(LayoutDragMode.CLONE);
    layout.setDropHandler(new DefaultHorizontalLayoutDropHandler());

    layout.addComponent(new Label("These components are stacked horizontally, try reordering them"));
    Button btn1 = new Button("Button 1");
    btn1.setWidth("100px");
    layout.addComponent(btn1);/*www  .  j av a2 s. c om*/

    Button btn2 = new Button("Button 2");
    btn2.setWidth("150px");
    layout.addComponent(btn2);

    Button btn3 = new Button("Button 3");
    btn3.setWidth("200px");
    layout.addComponent(btn3);
    // end-source
    return layout;
}

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

License:Apache License

@Override
public Component getLayout() {
    // start-source
    final DDVerticalLayout layout = new DDVerticalLayout();
    layout.setComponentVerticalDropRatio(EQUAL_VERTICAL_RATIO);
    layout.setDragMode(LayoutDragMode.CLONE);
    layout.setDropHandler(new DefaultVerticalLayoutDropHandler());

    layout.addComponent(new Label("These components are stacked vertically, try reordering them"));
    Button btn = new Button("Button 1");
    btn.setWidth("100px");
    layout.addComponent(btn);// w w  w .j a  va2s .  c o m
    btn = new Button("Button 2");
    btn.setWidth("150px");
    layout.addComponent(btn);
    btn = new Button("Button 3");
    btn.setWidth("200px");
    layout.addComponent(btn);
    // end-source
    return layout;
}

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

License:Apache License

@Override
protected void init(WrappedRequest request) {

    // Create data tables
    feedTable = createFeedsTable();/*from   w w w. jav  a  2 s . c om*/
    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.semantum.strategia.Utils.java

License:Open Source License

public static void updateYears(final Database database, final VerticalLayout vl) {

    vl.removeAllComponents();//from   w  w  w . j a v a  2 s . c  o  m

    final TimeConfiguration tc = TimeConfiguration.getInstance(database);
    TimeInterval ti = TimeInterval.parse(tc.getRange());
    for (int i = ti.startYear; i <= ti.endYear; i++) {
        final int year = i;
        HorizontalLayout hl = new HorizontalLayout();
        hl.setSpacing(true);
        String caption = Integer.toString(i) + (tc.isFrozen(i) ? " Muutokset estetty" : " Muokattavissa");
        Label l = new Label(caption);
        l.setWidth("250px");
        l.setHeight("100%");
        hl.addComponent(l);
        Button b = new Button(tc.isFrozen(i) ? "Avaa muokattavaksi" : "Est muutokset");
        b.addStyleName(ValoTheme.BUTTON_SMALL);
        b.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 556680407448842136L;

            @Override
            public void buttonClick(ClickEvent event) {
                if (tc.isFrozen(year)) {
                    tc.unfreeze(year);
                } else {
                    tc.freeze(year);
                }
                updateYears(database, vl);
            }

        });
        b.setWidth("200px");
        hl.addComponent(b);
        //hl.setWidth("100%");
        vl.addComponent(hl);
    }

}

From source file:fi.semantum.strategia.widget.Tag.java

License:Open Source License

public static void updateRelatedTags(final Main main, boolean canWrite) {

    final Database database = main.getDatabase();

    final Base base = main.getUIState().currentItem;

    Collection<Tag> tags = base.getRelatedTags(database);
    if (!tags.isEmpty() || canWrite) {

        HorizontalLayout tagHeader = new HorizontalLayout();
        tagHeader.setSpacing(true);// w  w  w .  ja v  a  2 s  .com

        Label header2 = new Label("Aihetunnisteet");
        header2.setHeight("32px");
        header2.addStyleName(ValoTheme.LABEL_HUGE);
        header2.addStyleName(ValoTheme.LABEL_BOLD);
        tagHeader.addComponent(header2);
        tagHeader.setComponentAlignment(header2, Alignment.BOTTOM_CENTER);

        if (canWrite) {
            final Image editTags = new Image("", new ThemeResource("tag_blue_edit.png"));
            editTags.setHeight("24px");
            editTags.setWidth("24px");
            editTags.addClickListener(new MouseEvents.ClickListener() {

                private static final long serialVersionUID = -6140867347404571880L;

                @Override
                public void click(com.vaadin.event.MouseEvents.ClickEvent event) {
                    Utils.loseFocus(editTags);
                    Utils.editTags(main, "Muokkaa aihetunnisteita", main.getUIState().currentItem);
                }

            });
            tagHeader.addComponent(editTags);
            tagHeader.setComponentAlignment(editTags, Alignment.BOTTOM_CENTER);
        }

        main.properties.addComponent(tagHeader);
        main.properties.setComponentAlignment(tagHeader, Alignment.MIDDLE_CENTER);

        HorizontalLayout divider = new HorizontalLayout();
        main.properties.addComponent(divider);
        main.properties.setComponentAlignment(divider, Alignment.MIDDLE_CENTER);

        VerticalLayout left = new VerticalLayout();
        left.setSpacing(true);
        left.setWidth("400px");
        left.setMargin(true);
        divider.addComponent(left);
        VerticalLayout right = new VerticalLayout();
        right.setSpacing(true);
        right.setWidth("400px");
        right.setMargin(true);
        divider.addComponent(right);

        Set<Tag> monitoredTags = getMonitoredTags(database, base);

        int i = 0;
        for (final Tag tag : tags) {

            final boolean monitor = base.hasMonitorTag(database, tag);
            String tagId = tag.getId(database);

            HorizontalLayout hl = new HorizontalLayout();
            hl.setSpacing(true);
            hl.setHeight("37px");

            Button tagButton = Utils.tagButton(database, "list", tagId, i++);
            left.addComponent(tagButton);
            left.setComponentAlignment(tagButton, Alignment.MIDDLE_RIGHT);

            if (canWrite) {
                Button b = new Button();
                b.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                b.setIcon(FontAwesome.TIMES_CIRCLE);
                b.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = -4473258383318654850L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        base.removeRelatedTags(database, tag);
                        Utils.loseFocus(main.properties);
                        Updates.update(main, true);
                    }

                });
                hl.addComponent(b);
                hl.setComponentAlignment(b, Alignment.MIDDLE_LEFT);
            }

            if (base instanceof Strategiakartta) {

                Button tagButton2 = new Button();
                tagButton2.setCaption(monitor ? "Seurataan toteutuksessa" : "Ei seurata toteutuksessa");
                tagButton2.addStyleName(monitor ? "greenButton" : "redButton");
                tagButton2.addStyleName(ValoTheme.BUTTON_SMALL);
                tagButton2.setWidth("200px");
                if (canWrite) {
                    tagButton2.addClickListener(new ClickListener() {

                        private static final long serialVersionUID = -1769769368034323594L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            if (monitor) {
                                base.removeMonitorTags(database, tag);
                            } else {
                                base.assertMonitorTags(database, tag);
                            }
                            Utils.loseFocus(main.properties);
                            Updates.update(main, true);
                        }

                    });
                    tagButton2.setEnabled(true);
                } else {
                    tagButton2.setEnabled(false);
                }

                hl.addComponent(tagButton2);
                hl.setComponentAlignment(tagButton2, Alignment.MIDDLE_LEFT);

            } else {

                if (monitoredTags.contains(tag)) {
                    Label l = new Label(" toteuttaa seurattavaa aihetta ");
                    hl.addComponent(l);
                    hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT);
                }

            }

            right.addComponent(hl);
            right.setComponentAlignment(hl, Alignment.MIDDLE_LEFT);

        }

    }

}