Example usage for com.vaadin.ui Alignment BOTTOM_CENTER

List of usage examples for com.vaadin.ui Alignment BOTTOM_CENTER

Introduction

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

Prototype

Alignment BOTTOM_CENTER

To view the source code for com.vaadin.ui Alignment BOTTOM_CENTER.

Click Source Link

Usage

From source file:dhbw.ka.mwi.businesshorizon2.ui.process.navigation.NavigationViewImpl.java

License:Open Source License

/**
 * Diese Methode baut die Navigationsoberflaeche auf.
 * /*from   w w  w.  j a  v a2  s .com*/
 * @author Julius Hacker, Mirko Gpfrich
 */
private void generateUi() {
    this.setSizeFull();

    //this.arrow = new Label("➠");
    //arrow.setContentMode(Label.CONTENT_XHTML);

    this.full = new HorizontalLayout();
    //this.full.setSizeFull();
    this.full.setWidth("270px");

    this.layout = new VerticalLayout();
    this.layout.setStyleName("navigation");
    //this.layout.setSizeFull();
    //this.layout.setWidth("300px");

    this.innerlayout = new HorizontalLayout();
    innerlayout.setStyleName("LayoutNavigationsButtons");

    this.topbar = new VerticalLayout();
    //this.topbar.setSizeFull();
    this.topbar.setWidth("600px");

    this.topbarinnerlayout = new VerticalLayout();

    this.addOverviewButton();

    this.addProjectName();

    this.addNavigationButton(NavigationSteps.METHOD);
    this.addNavigationButton(NavigationSteps.PARAMETER);
    this.addNavigationButton(NavigationSteps.PERIOD);
    this.addNavigationButton(NavigationSteps.SCENARIO);
    this.addNavigationButton(NavigationSteps.OUTPUT);
    this.addLogoutButton("Logout");

    full.addComponent(topbar);
    full.addComponent(layout);
    this.addComponent(full);

    topbar.addComponent(topbarinnerlayout);
    topbar.setComponentAlignment(topbarinnerlayout, Alignment.TOP_LEFT);
    this.addComponent(topbar);

    topbar.addComponent(innerlayout);
    topbar.setComponentAlignment(innerlayout, Alignment.BOTTOM_CENTER);
    this.addComponent(layout);

}

From source file:dhbw.ka.mwi.businesshorizon2.ui.process.navigation.NavigationViewImpl.java

License:Open Source License

/**
 * Diese Methode fuegt der Navigation einen Navigationsbutton hinzu und registriert
 * einen passenden ClickListener auf ihn.
 * // www  .j av a2 s .  com
 * @param value Der Prozessschritt, der durch den Navigationsbutton repraesentiert werden soll.
 * @author Julius Hacker
 */
@Override
public void addNavigationButton(final NavigationSteps navigationStep) {
    //this.innerlayout.addComponent(arrow);
    Button navigationButton = new Button(navigationStep.getCaption());
    this.navigationButtons.put(navigationStep, navigationButton);

    navigationButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = 7411091035775152765L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.showStep(navigationStep);
        }
    });

    navigationButton.setEnabled(false);
    navigationButton.setWidth(Sizeable.SIZE_UNDEFINED, 5);
    this.innerlayout.addComponent(navigationButton);
    this.innerlayout.setComponentAlignment(navigationButton, Alignment.BOTTOM_CENTER);

}

From source file:dhbw.ka.mwi.businesshorizon2.ui.resultscreen.onescenario.OneScenarioResultViewImpl.java

License:Open Source License

/**
 * Erstelle das GUI zum Prozessschritt "Ausgabe"
 * /*from   ww  w  .jav a2s.  c o  m*/
 * @author Florian Stier
 */
private void generateUi() {

    setSizeFull();
    planningLayout = new HorizontalLayout();
    planningLabel = new Label("Planungsprmissen:");
    scenarioLayout = new GridLayout(2, 5);
    renditeEKLabel = new Label("Renditeforderung EK:");
    renditeFKLabel = new Label("Renditeforderung FK:");
    gewerbeStLabel = new Label("Gewerbesteuer:");
    koerperStLabel = new Label("Krperschaftssteuer inkl. Solidarittszuschlag:");
    personalTaxRateLabel = new Label("Persnlicher Steuersatz");
    renditeEK = new Label();
    renditeFK = new Label();
    gewerbeSt = new Label();
    koerperSt = new Label();
    personalTaxRate = new Label();
    companyValueLayout = new HorizontalLayout();
    companyValueLabel = new Label("Unternehmenswert:");
    companyValue = new Label();
    gap = new Label();
    gap2 = new Label();
    gap3 = new Label();
    gap4 = new Label();
    expandingGap = new Label();
    expandingGap2 = new Label();
    expandingGap3 = new Label();
    capitalChartLayout = new VerticalLayout();
    cashflowChartLayout = new VerticalLayout();
    chartArea = new HorizontalLayout();

    gap.setWidth("20px");
    gap2.setWidth("20px");
    gap3.setHeight("20px");
    gap4.setHeight("20px");
    expandingGap.setSizeFull();

    planningLayout.setWidth(100, UNITS_PERCENTAGE);
    companyValueLayout.setHeight(100, UNITS_PIXELS);
    companyValueLayout.setWidth(100, UNITS_PERCENTAGE);
    scenarioLayout.setWidth(100, UNITS_PERCENTAGE);
    planningLabel.setWidth(SIZE_UNDEFINED, 0);
    companyValue.setWidth(SIZE_UNDEFINED, 0);
    companyValueLabel.setWidth(SIZE_UNDEFINED, 0);
    capitalChartLayout.setWidth(250, UNITS_PIXELS);
    capitalChartLayout.setHeight(250, UNITS_PIXELS);
    cashflowChartLayout.setWidth(350, UNITS_PIXELS);
    cashflowChartLayout.setHeight(250, UNITS_PIXELS);
    chartArea.setWidth(100, UNITS_PERCENTAGE);
    chartArea.setHeight(SIZE_UNDEFINED, 0);

    planningLabel.setStyleName("font12bold");
    renditeEKLabel.setStyleName("font12bold");
    renditeFKLabel.setStyleName("font12bold");
    gewerbeStLabel.setStyleName("font12bold");
    koerperStLabel.setStyleName("font12bold");
    personalTaxRateLabel.setStyleName("font12bold");
    renditeEK.setStyleName("font12bold");
    renditeFK.setStyleName("font12bold");
    gewerbeSt.setStyleName("font12bold");
    koerperSt.setStyleName("font12bold");
    personalTaxRate.setStyleName("font12bold");
    companyValueLabel.setStyleName("font14bold");
    companyValue.setStyleName("font14bold");

    scenarioLayout.setStyleName("resultScenarioLayout");
    companyValueLayout.setStyleName("companyValueLayout");

    planningLayout.addComponent(planningLabel);
    planningLayout.addComponent(gap2);
    planningLayout.addComponent(scenarioLayout);
    scenarioLayout.addComponent(renditeEKLabel, 0, 0);
    scenarioLayout.addComponent(renditeEK, 1, 0);
    scenarioLayout.addComponent(renditeFKLabel, 0, 1);
    scenarioLayout.addComponent(renditeFK, 1, 1);
    scenarioLayout.addComponent(gewerbeStLabel, 0, 2);
    scenarioLayout.addComponent(gewerbeSt, 1, 2);
    scenarioLayout.addComponent(koerperStLabel, 0, 3);
    scenarioLayout.addComponent(koerperSt, 1, 3);
    scenarioLayout.addComponent(personalTaxRateLabel, 0, 4);
    scenarioLayout.addComponent(personalTaxRate, 1, 4);
    companyValueLayout.addComponent(expandingGap2);
    companyValueLayout.addComponent(companyValueLabel);
    companyValueLayout.addComponent(gap);
    companyValueLayout.addComponent(companyValue);
    companyValueLayout.addComponent(expandingGap3);

    planningLayout.setComponentAlignment(planningLabel, Alignment.MIDDLE_LEFT);
    planningLayout.setExpandRatio(scenarioLayout, 1.0f);
    companyValueLayout.setComponentAlignment(companyValueLabel, Alignment.MIDDLE_CENTER);
    companyValueLayout.setComponentAlignment(companyValue, Alignment.MIDDLE_CENTER);
    companyValueLayout.setExpandRatio(expandingGap2, 1.0f);
    companyValueLayout.setExpandRatio(expandingGap3, 1.0f);
    //      scenarioLayout.setColumnExpandRatio(1, 1.0f);
    //      scenarioLayout.setComponentAlignment(renditeEK, Alignment.MIDDLE_RIGHT);
    //      scenarioLayout.setComponentAlignment(renditeFK, Alignment.MIDDLE_RIGHT);
    //      scenarioLayout.setComponentAlignment(gewerbeSt, Alignment.MIDDLE_RIGHT);
    scenarioLayout.setComponentAlignment(koerperSt, Alignment.BOTTOM_CENTER);

    chartArea.addComponent(capitalChartLayout);
    chartArea.addComponent(cashflowChartLayout);

    addComponent(planningLayout);
    addComponent(gap3);
    addComponent(companyValueLayout);
    addComponent(gap4);
    addComponent(chartArea);
    addComponent(expandingGap);

    setExpandRatio(expandingGap, 1.0f);
}

From source file:edu.kit.dama.ui.commons.util.PaginationLayout.java

License:Apache License

/**
 * Update the layout. This method is either called internally when scrolling
 * or/* w w  w.jav  a  2 s  .co  m*/
 */
public final void update() {
    //remove all components (old result page and navigation)
    removeAllComponents();

    //add current results
    renderPage();

    //build pagination
    int pages = overallEntries / entriesPerPage;
    if (overallEntries % entriesPerPage > 0) {
        pages++;
    }

    final int overallPages = pages;
    HorizontalLayout navigation = new HorizontalLayout();
    //add "JumpToFirstPage" button
    final NativeButton first = new NativeButton();
    first.setIcon(firstIcon);
    if (firstIcon == null) {
        first.setCaption("<<");
    }
    first.setDescription("First Page");
    first.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = 0;
            update();
        }
    });
    //add "PreviousPage" button
    final NativeButton prev = new NativeButton();
    prev.setIcon(prevIcon);
    if (prevIcon == null) {
        prev.setCaption("<");
    }
    prev.setDescription("Previous Page");
    prev.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage > 0) {
                currentPage--;
                update();
            }
        }
    });
    //add "NextPage" button
    final NativeButton next = new NativeButton();
    next.setIcon(nextIcon);
    if (nextIcon == null) {
        next.setCaption(">");
    }
    next.setDescription("Next Page");
    next.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (currentPage + 1 < overallPages) {
                currentPage++;
                update();
            }
        }
    });
    //add "JumpToLastPage" button
    final NativeButton last = new NativeButton();
    last.setIcon(endIcon);
    if (endIcon == null) {
        next.setCaption(">>");
    }
    last.setDescription("Last Page");
    last.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            currentPage = overallPages - 1;
            update();
        }
    });

    //enable/disable buttons depending on the current page
    if (overallPages == 0) {
        first.setEnabled(false);
        prev.setEnabled(false);
        next.setEnabled(false);
        last.setEnabled(false);
    } else {
        first.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        prev.setEnabled(!(currentPage == 0) || !(overallPages < 2));
        next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
        last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2));
    }

    //at first, put the page size selection box into the navigation
    final ComboBox entriesPerPageBox = new ComboBox();
    entriesPerPageBox.setItemCaptionPropertyId("name");
    entriesPerPageBox.addContainerProperty("name", String.class, null);
    entriesPerPageBox.addItem(5);
    entriesPerPageBox.getContainerProperty(5, "name").setValue("5 Entries / Page");
    entriesPerPageBox.addItem(10);
    entriesPerPageBox.getContainerProperty(10, "name").setValue("10 Entries / Page");
    entriesPerPageBox.addItem(15);
    entriesPerPageBox.getContainerProperty(15, "name").setValue("15 Entries / Page");
    entriesPerPageBox.addItem(20);
    entriesPerPageBox.getContainerProperty(20, "name").setValue("20 Entries / Page");

    entriesPerPageBox.setValue(entriesPerPage);
    entriesPerPageBox.setNullSelectionAllowed(false);
    entriesPerPageBox.setImmediate(true);

    entriesPerPageBox.addListener(new Property.ValueChangeListener() {
        public void valueChange(ValueChangeEvent event) {
            entriesPerPage = (Integer) entriesPerPageBox.getValue();
            update();
        }
    });

    navigation.addComponent(entriesPerPageBox);

    //filler labels are added to the beginning and to the end to keep the navigation in the middle
    Label leftFiller = new Label();
    leftFiller.setWidth("25px");
    navigation.addComponent(leftFiller);
    navigation.addComponent(first);
    navigation.addComponent(prev);

    //Show max. 10 pages at once for performance and layout reasons.
    //If there are more than 10 pages, "move" the to show 10 pages based on the current page.
    int start = currentPage - 5;
    start = (start < 0) ? 0 : start;
    int end = start + 10;
    end = (end > pages) ? pages : end;

    if (end - start < 10 && pages > 10) {
        start = end - 10;
    }

    if (overallPages == 0) {
        Label noEntryLabel = new Label("<i>No entries</i>", Label.CONTENT_XHTML);
        //noEntryLabel.setWidth("80px");
        noEntryLabel.setSizeUndefined();
        navigation.addComponent(noEntryLabel);
        navigation.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER);
    }
    //build the actual page entries
    for (int i = start; i < end; i++) {
        if (i == currentPage) {
            //the current page is marked with a special style
            Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", Label.CONTENT_XHTML);
            pageLink.setStyleName("currentpage");
            pageLink.setWidth("15px");
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        } else {
            //otherwise normal links are added, click-events are handled via LayoutClickListener 
            Link pageLink = new Link(Integer.toString(i + 1), null);
            navigation.addComponent(pageLink);
            navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER);
        }
    }
    //add right navigation buttons
    navigation.addComponent(next);
    navigation.addComponent(last);
    //...and fill the remaining space 
    Label rightFiller = new Label();
    navigation.addComponent(rightFiller);
    //  navigation.setExpandRatio(leftFiller, 1.0f);
    navigation.setExpandRatio(rightFiller, 1.0f);
    navigation.setSpacing(true);

    //put everything ot the middle
    navigation.setComponentAlignment(first, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(prev, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(next, Alignment.MIDDLE_CENTER);
    navigation.setComponentAlignment(last, Alignment.MIDDLE_CENTER);

    //add layout click listener to be able to navigate by clicking the single pages
    navigation.addListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent event) {

            // Get the child component which was clicked
            Component child = event.getChildComponent();

            if (child == null) {
                // Not over any child component
            } else {
                // Over a child component
                if (child instanceof Link) {
                    // Over a valid child element
                    currentPage = Integer.parseInt(((Link) child).getCaption()) - 1;
                    update();
                }
            }
        }
    });

    //finalize
    navigation.setWidth("100%");
    navigation.setHeight("25px");

    //add navigation and align it right below the result page
    addComponent(page);
    setExpandRatio(page, 1f);
    if (overallEntries > 0) {
        addComponent(navigation);
        setComponentAlignment(navigation, Alignment.BOTTOM_CENTER);
        setExpandRatio(navigation, .05f);
    }
    requestRepaint();
}

From source file:edu.kit.dama.ui.repo.components.EntryRenderPanel.java

License:Apache License

/**
 * Build the main layout of the representation of one digital object.
 *
 * @param pContext The authorization context used to decide whether special
 * administrative features are available or not.
 *//* w  ww .jav  a 2s.  c  o m*/
private void buildMainLayout(IAuthorizationContext pContext) {
    //check if the object could be obtained or not, e.g. due to missing permissions. If not, show an error message.
    if (ERROR_PLACEHOLDER.equals(object.getLabel())) {
        Label warnLabel = new Label("<h3>Failed to obtain entry with identifier '"
                + object.getDigitalObjectIdentifier() + "' from database.</h3>", ContentMode.HTML);
        final Button cleanup = new Button("Cleanup");
        cleanup.setDescription("Click to remove object from search index.");
        cleanup.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                cleanup.setEnabled(false);
                new Notification("Information", "Cleanup not implemented, yet.",
                        Notification.Type.TRAY_NOTIFICATION).show(Page.getCurrent());
            }
        });
        if (pContext.getRoleRestriction().atLeast(Role.ADMINISTRATOR)) {
            //show cleanup button
            mainLayout = new HorizontalLayout(warnLabel, cleanup);
        } else {
            //no cleanup available
            mainLayout = new HorizontalLayout(warnLabel);
        }
        mainLayout.setSizeFull();
        return;
    }

    //initialize image field
    typeImage = new Image();
    typeImage.setSizeFull();
    setImage(object);

    //initialize title label/field
    titleField = UIUtils7.factoryTextField(null, "dc:title");
    titleField.addStyleName("basic_title");
    titleLabel = new Label("dc:title");
    titleLabel.setWidth("100%");
    titleLabel.addStyleName("basic_title");

    //initialize creator label
    if (object.getUploader() != null) {
        creatorLabel = new Label(StringUtils.abbreviate(object.getUploader().getFullname(), 100));
        creatorLabel.setEnabled(true);
    } else {
        creatorLabel = new Label("dc:creator");
        creatorLabel.setEnabled(false);
    }
    creatorLabel.setWidth("100%");
    creatorLabel.addStyleName("basic_left");

    //initialize creation label
    if (object.getStartDate() != null) {
        creationLabel = new Label(new SimpleDateFormat().format(object.getStartDate()));
        creationLabel.setEnabled(true);
    } else {
        creationLabel = new Label("dc:date");
        creationLabel.setEnabled(false);
    }

    creationLabel.setWidth("100%");

    //initialize identifier label
    objectIdLabel = new Label(StringUtils.abbreviate(object.getDigitalObjectIdentifier(), 100));
    objectIdLabel.setWidth("100%");
    //initialize description label/area
    descriptionLabel = new Label("dc:description");
    descriptionArea = UIUtils7.factoryTextArea(null, "dc:description");
    descriptionArea.setHeight("50px");
    descriptionLabel.setHeight("50px");
    descriptionLabel.setWidth("100%");

    //action buttons
    downloadButton = new NativeButton("Download");
    downloadButton.setIcon(new ThemeResource("img/32x32/download.png"));
    downloadButton.setStyleName(BaseTheme.BUTTON_LINK);
    downloadButton.setDescription("Download the data of this digital object.");
    downloadButton.setWidth("100%");

    shareButton = new NativeButton("Share");
    shareButton.setIcon(new ThemeResource("img/16x16/share.png"));
    shareButton.setStyleName(BaseTheme.BUTTON_LINK);
    shareButton.setDescription("Share this digital object.");
    Role eligibleRole = Role.GUEST;
    if (parent.getParentUI().isUserLoggedIn()) {
        //obtain role only if a user is logged in and we are not in ingest mode.
        //Otherwise, the dummy context of MyVaadinUI would be used and will cause unwanted access.
        try {
            //Determine eligible role of currently logged in user
            eligibleRole = ResourceServiceLocal.getSingleton().getGrantRole(object.getSecurableResourceId(),
                    parent.getParentUI().getAuthorizationContext().getUserId(),
                    AuthorizationContext.factorySystemContext());
        } catch (EntityNotFoundException | UnauthorizedAccessAttemptException ex) {
            LOGGER.warn("Failed to determine eligable role for context "
                    + parent.getParentUI().getAuthorizationContext() + ". Continue with GUEST permissions.",
                    ex);
        }
    }

    //Update share button depending on role. Only possessing the role MANAGER (being the owner) entitles to share an object. 
    if (eligibleRole.atLeast(Role.MANAGER)) {
        shareButton.setEnabled(true);
        shareButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                if (parent != null) {
                    parent.showSharingPopup(object);
                }
            }
        });
    } else {
        shareButton.setEnabled(false);
        shareButton.setDescription("Only the object owner is allowed to change sharing information.");
    }

    editButton = new NativeButton("Edit Metadata");
    editButton.setIcon(new ThemeResource("img/16x16/edit.png"));
    editButton.setStyleName(BaseTheme.BUTTON_LINK);
    editButton.setDescription("Edit this digital object's metadata.");

    //Update edit button depending on role. If the object is shared with or owned by the logged in user, editing will be allowed.
    if (eligibleRole.atLeast(Role.MEMBER)) {
        editButton.setEnabled(true);
        editButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                switchEditMode();
            }
        });
    } else {
        editButton.setEnabled(false);
        editButton.setDescription(
                "Only the object owner and users the object is shared with are allowed to change metadata information.");
    }

    starButton = new NativeButton("Favorite");
    starButton.setImmediate(true);
    starButton.setIcon(new ThemeResource("img/16x16/unstarred.png"));
    starButton.setStyleName(BaseTheme.BUTTON_LINK);
    starButton.setDescription("Add/remove digital object to/from favorites.");

    //Update star button depending on role. If the object is shared with or owned by the logged in user, "star'ing" will be allowed.
    if (eligibleRole.atLeast(Role.MEMBER)) {
        starButton.setEnabled(true);
        starButton.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
                mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext());

                try {
                    DigitalObjectType favoriteType = mdm
                            .findSingleResult("SELECT t FROM DigitalObjectType t WHERE t.identifier='"
                                    + MyVaadinUI.FAVORITE_TYPE_IDENTIFIER + "' AND t.typeDomain='"
                                    + MyVaadinUI.FAVORITE_TYPE_DOMAIN + "'", DigitalObjectType.class);
                    if (DigitalObjectTypeHelper.isTypeAssignedToObject(object, favoriteType,
                            AuthorizationContext.factorySystemContext())) {
                        //remove favorite status
                        DigitalObjectTypeHelper.removeTypeFromObject(object, favoriteType,
                                AuthorizationContext.factorySystemContext());
                        starButton.setIcon(new ThemeResource("img/16x16/unstarred.png"));
                        new Notification("Information",
                                "Successfully removed favorite tag from object "
                                        + object.getDigitalObjectIdentifier() + ".",
                                Notification.Type.TRAY_NOTIFICATION).show(Page.getCurrent());
                    } else {
                        //assign favorite status
                        DigitalObjectTypeHelper.assignTypeToObject(object, favoriteType,
                                AuthorizationContext.factorySystemContext());
                        starButton.setIcon(new ThemeResource("img/16x16/starred.png"));
                        new Notification("Information",
                                "Successfully added favorite tag to object "
                                        + object.getDigitalObjectIdentifier() + ".",
                                Notification.Type.TRAY_NOTIFICATION).show(Page.getCurrent());
                    }
                } catch (Exception e) {
                    LOGGER.error("Failed to change 'favorite' status of digital object.", e);
                    new Notification("Warning", "Failed to update favorite status.",
                            Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                }
            }
        });
    } else {
        starButton.setEnabled(false);
        starButton.setDescription(
                "Only the object owner and users the object is shared with are allowed to change the favorite state.");
    }

    dcLayout = new UIUtils7.GridLayoutBuilder(3, 5).addComponent(titleLabel, 0, 0, 2, 1)
            .addComponent(creationLabel, 2, 0, 1, 1).addComponent(creatorLabel, 0, 1, 3, 1)
            .addComponent(objectIdLabel, 0, 2, 3, 1).fill(descriptionLabel, 0, 3).getLayout();
    dcLayout.setSizeFull();

    Button.ClickListener saveCancelButtonListener = new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (saveEditButton.equals(event.getButton())) {
                //do save
                IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
                mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext());
                try {
                    String title = titleField.getValue();
                    String description = descriptionArea.getValue();
                    Investigation investigation = object.getInvestigation();
                    boolean wasError = false;
                    if (description != null && description.length() <= 1024 && investigation != null) {
                        if (!description.equals(investigation.getDescription())) {
                            investigation.setDescription(description);
                            //store investigation
                            mdm.save(investigation);
                        }
                    } else {
                        LOGGER.warn(
                                "Failed to commit updated description '{}'. Either length is exceeded or investigation '{}' is null.",
                                description, investigation);
                        wasError = true;
                    }
                    //store object
                    if (title != null && title.length() >= 3 && title.length() <= 255) {
                        if (!title.equals(object.getLabel())) {
                            //store object
                            object.setLabel(title);
                            object = mdm.save(object);
                        }
                    } else {
                        LOGGER.warn("Failed to commit updated title '{}'. Length is invalid (3<=l<=255).",
                                title);
                        wasError = true;
                    }
                    if (wasError) {
                        new Notification("Warning",
                                "Failed to update title and/or description. See logfile for details.",
                                Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());
                    }

                    //As there is not automatic sync between database and search index the entry has to be reindexed at this point in order
                    //to keep both systems consistent. However, changes taking place in between are lost.
                    LOGGER.debug("Object committed to database. Updating index.");
                    ElasticsearchHelper.indexEntry(object);
                } catch (UnauthorizedAccessAttemptException ex) {
                    LOGGER.error("Failed to commit changes.", ex);
                    new Notification("Warning", "Failed to commit changes. See logfile for details.",
                            Notification.Type.WARNING_MESSAGE).show(Page.getCurrent());

                } finally {
                    mdm.close();
                }
            }
            //do cancel/reload and switch back to read-mode
            reset();
            switchEditMode();
        }
    };

    //save/cancel buttons
    saveEditButton = new NativeButton("Commit Update");
    saveEditButton.setIcon(new ThemeResource("img/16x16/save.png"));
    saveEditButton.setStyleName(BaseTheme.BUTTON_LINK);
    saveEditButton.setDescription("Save changes to this digital object's metadata.");
    saveEditButton.addClickListener(saveCancelButtonListener);
    cancelEditButton = new NativeButton("Cancel Update");
    cancelEditButton.setIcon(new ThemeResource("img/16x16/cancel.png"));
    cancelEditButton.setStyleName(BaseTheme.BUTTON_LINK);
    cancelEditButton.setDescription("Withdraw all changes to this digital object's metadata.");
    cancelEditButton.addClickListener(saveCancelButtonListener);

    //default action layout
    Label spacerMiscActionLayout = new Label();
    miscActionLayout = new HorizontalLayout(editButton, shareButton, starButton, spacerMiscActionLayout);
    miscActionLayout.setWidth("100%");
    miscActionLayout.setHeight("18px");
    miscActionLayout.setSpacing(false);
    miscActionLayout.setMargin(false);
    miscActionLayout.setExpandRatio(spacerMiscActionLayout, .9f);

    //edit action layout
    Label spacerEditActionLayout = new Label();
    editActionLayout = new HorizontalLayout(saveEditButton, cancelEditButton, spacerEditActionLayout);
    editActionLayout.setWidth("100%");
    editActionLayout.setHeight("18px");
    editActionLayout.setSpacing(false);
    editActionLayout.setMargin(false);
    editActionLayout.setExpandRatio(spacerEditActionLayout, .9f);

    //divider generation
    Label dividerTop = new Label();
    dividerTop.setHeight("5px");
    dividerTop.addStyleName("horizontal-line");
    dividerTop.setWidth("90%");
    Label dividerBottom = new Label();
    dividerBottom.setHeight("5px");
    dividerBottom.addStyleName("horizontal-line");
    dividerBottom.setWidth("90%");
    Label dividerLeft = new Label();
    dividerLeft.addStyleName("vertical-line");
    dividerLeft.setWidth("5px");
    dividerLeft.setHeight("90%");
    Label dividerRight = new Label();
    dividerRight.addStyleName("vertical-line");
    dividerRight.setWidth("5px");
    dividerRight.setHeight("90%");

    //build content layout
    HorizontalLayout contentLayout = new HorizontalLayout(typeImage, dividerLeft, dcLayout, dividerRight,
            downloadButton);
    contentLayout.setSizeFull();
    contentLayout.setSpacing(true);
    contentLayout.setComponentAlignment(typeImage, Alignment.TOP_RIGHT);
    contentLayout.setComponentAlignment(dividerLeft, Alignment.MIDDLE_CENTER);
    contentLayout.setComponentAlignment(dcLayout, Alignment.MIDDLE_CENTER);
    contentLayout.setComponentAlignment(dividerRight, Alignment.MIDDLE_CENTER);
    contentLayout.setComponentAlignment(downloadButton, Alignment.BOTTOM_CENTER);
    contentLayout.setExpandRatio(typeImage, .1f);
    contentLayout.setExpandRatio(dcLayout, .8f);
    contentLayout.setExpandRatio(downloadButton, .1f);

    //build main layout
    mainLayout = new VerticalLayout(dividerTop, contentLayout, dividerBottom, miscActionLayout);
    mainLayout.setExpandRatio(dividerTop, .05f);
    mainLayout.setComponentAlignment(dividerTop, Alignment.TOP_LEFT);
    mainLayout.setExpandRatio(contentLayout, .80f);
    mainLayout.setExpandRatio(dividerBottom, .05f);
    mainLayout.setComponentAlignment(dividerBottom, Alignment.BOTTOM_RIGHT);
    mainLayout.setExpandRatio(miscActionLayout, .1f);
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.addStyleName("basic");
    mainLayout.setWidth("100%");
    mainLayout.setHeight("185px");
    //do reset to load title and description
    reset();
    LOGGER.debug("Layout successfully build up.");
}

From source file:edu.kit.dama.ui.repo.components.PaginationPanel.java

License:Apache License

/**
 * Build the main layout./*from   w w w . j a v  a2 s.  com*/
 */
private void buildMainLayout() {
    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    pageLayout.setSizeFull();
    pageLayout.setSpacing(true);
    mainLayout.addComponent(pageLayout);
    mainLayout.addComponent(navigation);
    mainLayout.setComponentAlignment(pageLayout, Alignment.MIDDLE_CENTER);
    mainLayout.setComponentAlignment(navigation, Alignment.BOTTOM_CENTER);
    mainLayout.setExpandRatio(pageLayout, 1.0f);
    mainLayout.setExpandRatio(navigation, .1f);
    mainLayout.addComponent(shareComponent.getPopupView());
    mainLayout.setComponentAlignment(shareComponent.getPopupView(), Alignment.MIDDLE_CENTER);
}

From source file:edu.nps.moves.mmowgli.components.VideoWithRightTextPanel.java

License:Open Source License

public void initGui() {
    addStyleName("m-calltoaction-novideo"); // m-calltoaction"); // puts up background
    setMargin(false);/*from   w w w.jav  a2 s  . c o  m*/
    setSpacing(false);
    setWidth("988px");

    Label lab;

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

    HorizontalLayout horLay = new HorizontalLayout();
    horLay.setSpacing(false);
    horLay.setMargin(false);
    horLay.setWidth("100%");
    addComponent(horLay);

    horLay.addComponent(lab = new Label());
    lab.setWidth("38px");

    if (vidMedia != null && vidMedia.getUrl() != null && vidMedia.getUrl().trim().length() > 0) {
        if (vidMedia.getType() == MediaType.YOUTUBE) {
            try {
                Flash ytp = new Flash();
                ytp.setSource(new ExternalResource("https://www.youtube.com/v/" + vidMedia.getUrl()));
                ytp.setParameter("allowFullScreen", "true");
                ytp.setParameter("showRelated", "false");
                ytp.setWidth(539.0f, Unit.PIXELS); //VID_W_PX,Unit.PIXELS);
                ytp.setHeight(342.0f, Unit.PIXELS); //VID_H_PX,Unit.PIXELS);
                player = ytp;
            } catch (Exception ex) {
                System.err.println("Exception instantiating YouTubePlayer: " + ex.getClass().getSimpleName()
                        + ": " + ex.getLocalizedMessage());
            }
        } else {
            System.err.println("Bad media file in VideoWithRightTextPanel");
            player = new Label("missing video");
        }
        VerticalLayout plyrLinkWrap = new VerticalLayout();
        plyrLinkWrap.setMargin(false);
        plyrLinkWrap.setSpacing(true);
        plyrLinkWrap.setSizeUndefined();

        VerticalLayout playerVL = new VerticalLayout(); //AbsoluteLayout();
        playerVL.setWidth("539px");
        playerVL.setHeight("342px");
        playerVL.addStyleName("m-boxshadow-5");
        playerVL.addComponent(player);
        plyrLinkWrap.addComponent(playerVL);

        Link link = getAlternateVideoLink(vidMedia);
        if (link != null) {
            plyrLinkWrap.addComponent(link);
            plyrLinkWrap.setComponentAlignment(link, Alignment.BOTTOM_CENTER);
        }
        horLay.addComponent(plyrLinkWrap);
        horLay.addComponent(lab = new Label());
        lab.setWidth("22px");
    }
    VerticalLayout rightColVLayout = new VerticalLayout();
    horLay.addComponent(rightColVLayout);
    horLay.setExpandRatio(rightColVLayout, 1.0f);

    horLay.addComponent(lab = new Label());
    lab.setWidth("35px");

    rightColVLayout.setSpacing(true);

    if (headerImg != null) { // Image takes priority over text
        rightColVLayout.addComponent(headerImg);
    } else {
        headingLab = new HtmlLabel(heading);
        if (largerText)
            headingLab.addStyleName("m-orientation-heading");
        else
            headingLab.addStyleName("m-calltoaction-thesituation-heading");
        rightColVLayout.addComponent(headingLab);
    }

    summaryLab = new HtmlLabel(summary);
    if (largerText)
        summaryLab.addStyleName("m-orientation-summary");
    else
        summaryLab.addStyleName("m-calltoaction-thesituation-summary");
    rightColVLayout.addComponent(summaryLab);

    // text = text.replace("\n", "<br/><br/>"); // pure html with <p> tags seems to work well
    textLab = new HtmlLabel(text);
    if (largerText)
        textLab.addStyleName("m-orientation-text");
    else
        textLab.addStyleName("m-calltoaction-thesituation-text");
    rightColVLayout.addComponent(textLab);

    // Move 2, no room
    /*
     * if (promptImg != null) { // Image priority over text rightColVLayout.addComponent(promptImg); } else if (prompt != null){ promptLab = new Label(prompt);
     * promptLab.setContentMode(Label.CONTENT_XHTML); if(largerText) promptLab.addStyleName("m-orientation-prompt"); else
     * promptLab.addStyleName("m-calltoaction-thesituation-prompt"); rightColVLayout.addComponent(promptLab); }
     */
    // spacer so background doesn't look cut-off
    addComponent(lab = new Label());
    lab.setHeight("25px");
}

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

License:Apache License

private void render() {

    VerticalLayout content = new VerticalLayout();
    content.setSpacing(true);/* www . j  a va  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.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.  ja  v a 2  s.com*/
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 ww .j a  v  a2 s .com*/
    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("!", ""));
}