Example usage for com.vaadin.ui Alignment BOTTOM_RIGHT

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

Introduction

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

Prototype

Alignment BOTTOM_RIGHT

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

Click Source Link

Usage

From source file:edu.kit.dama.ui.admin.workflow.DataWorkflowTaskConfigurationTab.java

License:Apache License

@Override
public GridLayout buildMainLayout() {
    String id = "mainLayout";
    LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

    UIUtils7.GridLayoutBuilder mainLayoutBuilder = new UIUtils7.GridLayoutBuilder(2, 2);

    // Add components to mainLayout
    mainLayoutBuilder.fillColumn(getElementTree(), 0, 0, 1);
    mainLayoutBuilder.fillRow(getPropertiesPanel(), 1, 0, 1);
    mainLayoutBuilder.addComponent(getCommitChangesButton(), Alignment.BOTTOM_RIGHT, 1, 1, 1, 1);
    mainLayout = mainLayoutBuilder.getLayout();
    mainLayout.setId(DEBUG_ID_PREFIX + id);
    mainLayout.setSizeFull();/*from  www.  j  a v  a 2s.  c  o m*/
    mainLayout.setImmediate(true);
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);

    mainLayout.setColumnExpandRatio(1, 1f);
    mainLayout.setRowExpandRatio(0, 1f);

    return mainLayout;

}

From source file:edu.kit.dama.ui.admin.workflow.ExecutionEnvironmentBasePropertiesLayout.java

License:Apache License

/**
 * Default constructor./*from w w  w .j  a v  a 2 s.com*/
 */
public ExecutionEnvironmentBasePropertiesLayout() {
    super();

    LOGGER.debug("Building " + DEBUG_ID_PREFIX + " ...");

    setId(DEBUG_ID_PREFIX.substring(0, DEBUG_ID_PREFIX.length() - 1));
    setSizeFull();
    setMargin(true);
    setSpacing(true);

    setColumns(4);
    setRows(6);

    addComponent(getNameField(), 0, 0, 2, 0);
    addComponent(getGroupBox(), 3, 0);
    //
    addComponent(getAccessPointBox(), 0, 1, 2, 1);
    addComponent(getCheckBoxesLayout(), 3, 1);
    //

    addComponent(getAccessPointBasePathField(), 0, 2, 2, 2);
    addComponent(getPathSelectorButton(), 3, 2);
    //
    addComponent(getMaxTasksField(), 0, 3, 2, 3);
    //
    addComponent(getDescriptionArea(), 0, 4, 2, 5);

    //add property selection
    Button addPropertyButton = new Button();
    addPropertyButton.setIcon(new ThemeResource(IconContainer.ADD));
    addPropertyButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            addPropertyComponent.reset();
            addPropertyComponent.showWindow();
        }
    });

    HorizontalLayout layout = new HorizontalLayout(getEnvironmentPropertiesSelect(), addPropertyButton);
    layout.setComponentAlignment(getEnvironmentPropertiesSelect(), Alignment.TOP_LEFT);
    layout.setComponentAlignment(addPropertyButton, Alignment.BOTTOM_RIGHT);
    layout.setSizeFull();
    layout.setExpandRatio(getEnvironmentPropertiesSelect(), .95f);
    layout.setExpandRatio(addPropertyButton, .05f);
    addComponent(layout, 3, 4, 3, 5);

    //add popup to layout
    addPropertyComponent = new AddEnvironmentPropertyComponent(this);

    setComponentAlignment(getPathSelectorButton(), Alignment.BOTTOM_LEFT);
    setColumnExpandRatio(0, 0.2f);
    setColumnExpandRatio(1, 0.2f);
    setColumnExpandRatio(2, 0.2f);
    setColumnExpandRatio(3, 0.2f);
    setRowExpandRatio(5, 1f);
}

From source file:edu.kit.dama.ui.admin.workflow.property.AddEnvironmentPropertyComponent.java

License:Apache License

/**
 * Build the main layout including the type selection combobox, the buttons
 * and the placeholder for the property configuration component.
 *///from w w  w  .  j av  a2s.c o  m
private void buildMainLayout() {
    propertyEditorLayout = new VerticalLayout();
    propertyEditorLayout.setSizeFull();
    propertyEditorLayout.setMargin(false);
    propertyEditorLayout.setSpacing(true);
    propertyEditorLayout.setWidth("400px");

    propertyTypeSelectionBox = new ComboBox("PROPERTY TYPE");
    propertyTypeSelectionBox.setWidth("100%");
    propertyTypeSelectionBox.setImmediate(true);
    propertyTypeSelectionBox.setNullSelectionAllowed(false);
    propertyTypeSelectionBox.addStyleName(CSSTokenContainer.BOLD_CAPTION);

    for (ENVIRONMENT_PROPERTY_TYPE type : ENVIRONMENT_PROPERTY_TYPE.values()) {
        propertyTypeSelectionBox.addItem(type.toString());
        propertyTypeSelectionBox.setItemCaption(type, type.getName());
    }

    propertyTypeSelectionBox.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            updatePropertySelection(
                    ENVIRONMENT_PROPERTY_TYPE.valueOf((String) propertyTypeSelectionBox.getValue()));
        }
    });

    final Button createButton = new Button("Create");
    final Button cancelButton = new Button("Cancel");

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

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (createButton.equals(event.getButton())) {
                createProperty();
            }
            UI.getCurrent().removeWindow(propertyWindow);
            propertyWindow = null;
        }
    };

    createButton.addClickListener(listener);
    cancelButton.addClickListener(listener);

    HorizontalLayout buttonLayout = new HorizontalLayout(cancelButton, createButton);
    mainLayout = new VerticalLayout(propertyTypeSelectionBox, propertyEditorLayout, buttonLayout);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
    mainLayout.setExpandRatio(propertyTypeSelectionBox, .1f);
    mainLayout.setExpandRatio(propertyEditorLayout, .9f);
    mainLayout.setExpandRatio(buttonLayout, .1f);

    propertyTypeSelectionBox.setValue(ENVIRONMENT_PROPERTY_TYPE.STRING_VALUE_PROPERTY.toString());
}

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.
 *///from   w  w  w.  j a  v  a 2 s .c  om
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.ShareObjectComponent.java

/**
 * Build the main layout of the component.
 *///from www  .  j  ava  2 s . c  o m
private void buildMainLayout() {
    shareList = new TwinColSelect();
    shareList.setRows(10);
    shareList.setMultiSelect(true);
    shareList.setImmediate(true);
    shareList.setLeftColumnCaption("Not accessible by");
    shareList.setRightColumnCaption("Accessible by");

    shareList.setWidth("500px");
    shareList.setHeight("400px");

    final NativeButton shareButton = new NativeButton("Share");
    final NativeButton cancelButton = new NativeButton("Cancel");

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

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (shareButton.equals(event.getButton())) {
                syncShares();
            }
            sharePopup.setPopupVisible(false);
        }
    };

    shareButton.addClickListener(listener);
    cancelButton.addClickListener(listener);

    HorizontalLayout buttonLayout = new HorizontalLayout(cancelButton, shareButton);
    mainLayout = new VerticalLayout(shareList, buttonLayout);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
    mainLayout.setExpandRatio(shareList, .9f);
    mainLayout.setExpandRatio(buttonLayout, .1f);
}

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

License:Apache License

/**
 * Build the search view and execute the provided query immediately.
 *
 * @param pQuery The query to execute or null if an empty view should be
 * shown.//from  w w w .jav a2 s  .  co  m
 */
private void buildSearchView(String pQuery) {
    loginButton.setWidth("70px");
    loginButton.setStyleName(BaseTheme.BUTTON_LINK);
    logoutButton.setWidth("70px");
    logoutButton.setStyleName(BaseTheme.BUTTON_LINK);
    adminButton.setWidth("70px");
    adminButton.setStyleName(BaseTheme.BUTTON_LINK);

    logoutButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            loggedInUser = UserData.NO_USER;
            refreshMainLayout();
        }
    });

    adminButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            Page.getCurrent()
                    .open(DataManagerSettings.getSingleton().getStringProperty(
                            DataManagerSettings.GENERAL_BASE_URL_ID, "http://localhost:8889/BaReDemo")
                            + "/admin", "_blank");
        }
    });

    searchField = UIUtils7.factoryTextField(null, "Search for...");
    searchField.setWidth("920px");
    searchField.setHeight("60px");
    searchField.addStyleName("searchField");

    paginationPanel = new PaginationPanel(this);
    paginationPanel.setSizeFull();
    paginationPanel.setAllEntries(new LinkedList<DigitalObjectId>());

    searchProvider = new FulltextElasticSearchProvider(
            DataManagerSettings.getSingleton()
                    .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_CLUSTER_ID, "KITDataManager"),
            DataManagerSettings.getSingleton()
                    .getStringProperty(DataManagerSettings.ELASTIC_SEARCH_DEFAULT_HOST_ID, "localhost"),
            DataManagerSettings.getSingleton().getStringProperty(
                    DataManagerSettings.ELASTIC_SEARCH_DEFAULT_INDEX_ID,
                    ElasticsearchHelper.ELASTICSEARCH_TYPE),
            ElasticsearchHelper.ELASTICSEARCH_TYPE);
    NativeButton goButton = new NativeButton();
    goButton.setIcon(new ThemeResource("img/24x24/search.png"));
    goButton.setWidth("60px");
    goButton.setHeight("60px");
    goButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            doSearch();
        }
    });
    goButton.setClickShortcut(KeyCode.ENTER);

    setupLoginForm();
    loginForm.setWidth("320px");
    loginForm.setHeight("150px");
    final PopupView loginPopup = new PopupView(null, loginForm);
    loginPopup.setHideOnMouseOut(false);
    loginButton.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //mainLayout.replaceComponent(searchLayout, loginForm);
            loginPopup.setPopupVisible(true);
        }
    });

    Label filler = new Label();
    memberLayout = new HorizontalLayout(filler, adminButton, loginButton, loginPopup);
    memberLayout.setComponentAlignment(loginButton, Alignment.TOP_RIGHT);
    memberLayout.setComponentAlignment(adminButton, Alignment.TOP_RIGHT);
    memberLayout.setComponentAlignment(loginPopup, Alignment.TOP_RIGHT);

    memberLayout.setExpandRatio(filler, 1.0f);
    memberLayout.setMargin(false);
    memberLayout.setSpacing(false);
    memberLayout.setWidth("100%");
    memberLayout.setHeight("30px");

    Label spacer = new Label("<hr/>", ContentMode.HTML);
    spacer.setHeight("20px");

    searchLayout = new UIUtils7.GridLayoutBuilder(3, 4)
            .addComponent(searchField, Alignment.TOP_LEFT, 0, 0, 2, 1)
            .addComponent(goButton, Alignment.TOP_RIGHT, 2, 0, 1, 1).fillRow(spacer, 0, 1, 1)
            .addComponent(paginationPanel, Alignment.MIDDLE_CENTER, 0, 2, 3, 2).getLayout();
    searchLayout.addStyleName("paper");
    searchLayout.setSpacing(true);
    searchLayout.setMargin(true);
    paginationPanel.setWidth("980px");
    //wrapper
    Label icon8Link = new Label("<a href=\"http://icons8.com\">Icons by icon8.com</a>", ContentMode.HTML);
    mainLayout = new VerticalLayout(memberLayout, searchLayout, icon8Link);
    mainLayout.setComponentAlignment(memberLayout, Alignment.TOP_CENTER);
    mainLayout.setComponentAlignment(searchLayout, Alignment.TOP_CENTER);
    mainLayout.setComponentAlignment(icon8Link, Alignment.BOTTOM_RIGHT);
    mainLayout.setExpandRatio(memberLayout, .05f);
    mainLayout.setExpandRatio(searchLayout, .93f);
    mainLayout.setExpandRatio(icon8Link, .02f);

    VerticalLayout fullscreen = new VerticalLayout(mainLayout);
    fullscreen.setComponentAlignment(mainLayout, Alignment.TOP_CENTER);
    fullscreen.setSizeFull();
    setContent(fullscreen);

    mainLayout.setWidth("1024px");
    mainLayout.setHeight("768px");

    if (pQuery != null) {
        searchField.setValue(pQuery);
        doSearch();
    }
}

From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java

License:Apache License

/**
 * Build the overview tab including the list of all categories and der
 * overall status./*from  w  ww  . j av  a  2  s.  c  om*/
 *
 * @param pCategories A list of all categories.
 *
 * @return The tab component.
 */
private Component buildOverviewTab(String[] pCategories) {
    AbsoluteLayout abLay = new AbsoluteLayout();
    UIUtils7.GridLayoutBuilder layoutBuilder = new UIUtils7.GridLayoutBuilder(4, pCategories.length + 1);

    updateButton = new Button("Update Status");
    updateButton.addClickListener(this);
    Embedded logo = new Embedded(null, new ThemeResource("img/simon.png"));
    abLay.addComponent(logo, "top:30px;left:30px;");

    Label simonSaysLabel = new Label("", ContentMode.HTML);
    simonSaysLabel.setHeight("150px");
    setSimonSaysContent(simonSaysLabel, "Everything is fine.");
    abLay.addComponent(simonSaysLabel, "top:30px;left:250px;");

    int row = 0;
    for (String category : pCategories) {
        HorizontalLayout rowLayout = new HorizontalLayout();
        Label name = new Label(category);
        name.setWidth("200px");
        name.setHeight("24px");
        List<AbstractProbe> probes = probesByCategory.get(category);
        Collections.sort(probes, new Comparator<AbstractProbe>() {
            @Override
            public int compare(AbstractProbe o1, AbstractProbe o2) {
                return o1.getCurrentStatus().compareTo(o2.getCurrentStatus());
            }
        });

        int failed = 0;
        int unknown = 0;
        int unavailable = 0;
        int charactersPerProbe = 100;
        if (probes.size() > 0) {
            charactersPerProbe = (int) Math.rint((700.0 / probes.size()) / 8.0);
        }

        for (AbstractProbe probe : probes) {
            Label probeLabel = new Label(StringUtils.abbreviate(probe.getName(), charactersPerProbe));
            probeLabel.setHeight("24px");
            switch (probe.getCurrentStatus()) {
            case UNKNOWN:
                probeLabel.setDescription(probe.getName() + ": UNKNOWN");
                probeLabel.addStyleName("probe-unknown");
                unknown++;
                break;
            case UPDATING:
                probeLabel.setDescription(probe.getName() + ": UPDATING");
                probeLabel.addStyleName("probe-updating");
                break;
            case UNAVAILABLE:
                probeLabel.setDescription(probe.getName() + ": UNAVAILABLE");
                probeLabel.addStyleName("probe-unavailable");
                unavailable++;
                break;
            case FAILED:
                probeLabel.setDescription(probe.getName() + ": FAILED");
                probeLabel.addStyleName("probe-failed");
                failed++;
                break;
            default:
                probeLabel.setDescription(probe.getName() + ": SUCCESS");
                probeLabel.addStyleName("probe-success");
            }

            probeLabel.addStyleName("probe");
            rowLayout.addComponent(probeLabel);
        }

        if (failed != 0) {
            setSimonSaysContent(simonSaysLabel, "There are errors!");
        } else {
            if (unknown != 0) {
                setSimonSaysContent(simonSaysLabel, "There are unknown states. Please select 'Update Status'.");
            } else {
                if (unavailable != 0) {
                    setSimonSaysContent(simonSaysLabel,
                            "Some probes are unavailable. Please check their configuration.");
                }
            }
        }

        rowLayout.setWidth("700px");
        layoutBuilder.addComponent(name, Alignment.TOP_LEFT, 0, row, 1, 1).addComponent(rowLayout,
                Alignment.TOP_LEFT, 1, row, 3, 1);
        row++;
    }

    layoutBuilder.addComponent(updateButton, Alignment.BOTTOM_RIGHT, 3, row, 1, 1);

    GridLayout tabLayout = layoutBuilder.getLayout();
    tabLayout.setSpacing(true);
    tabLayout.setMargin(true);
    Panel p = new Panel();
    p.setContent(tabLayout);
    p.setWidth("1024px");
    p.setHeight("400px");
    abLay.addComponent(p, "top:160px;left:30px;");
    abLay.setSizeFull();
    return abLay;
}

From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPage2.java

License:Open Source License

@SuppressWarnings("serial")
private void maybeAddHiddenCheckBoxTL(HorizontalLayout hl, ActionPlan ap) {
    User me = Mmowgli2UI.getGlobals().getUserTL();

    if (me.isAdministrator() || me.isGameMaster()) {
        Label sp;//  w w w.  j  ava 2s  .  c o m
        hl.addComponent(sp = new Label());
        sp.setWidth("80px");

        final CheckBox hidCb = new CheckBox("hidden");
        hidCb.setValue(ap.isHidden());
        hidCb.setDescription("Only game masters see this");
        hidCb.setImmediate(true);
        hl.addComponent(hidCb);
        hl.setComponentAlignment(hidCb, Alignment.BOTTOM_RIGHT);

        hidCb.addValueChangeListener(new ValueChangeListener() {
            @Override
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            public void valueChange(ValueChangeEvent event) {
                HSess.init();
                ActionPlan acntp = ActionPlan.getTL(getApId());
                boolean nowHidden = acntp.isHidden();
                boolean tobeHidden = hidCb.getValue();
                if (nowHidden != tobeHidden) {
                    acntp.setHidden(tobeHidden);
                    ActionPlan.updateTL(acntp);
                }
                HSess.close();
            }
        });

        final CheckBox supIntCb = new CheckBox("super interesting");
        supIntCb.setValue(ap.isSuperInteresting());
        supIntCb.setDescription("Mark plan super-interesting (only game masters see this)");
        supIntCb.setImmediate(true);
        hl.addComponent(supIntCb);
        hl.setComponentAlignment(supIntCb, Alignment.BOTTOM_RIGHT);
        supIntCb.addValueChangeListener(new ValueChangeListener() {

            @Override
            @MmowgliCodeEntry
            @HibernateOpened
            @HibernateClosed
            public void valueChange(ValueChangeEvent event) {
                HSess.init();
                ActionPlan acntp = ActionPlan.getTL(getApId());
                boolean nowSupInt = acntp.isSuperInteresting();
                boolean tobeSupInt = supIntCb.getValue();
                if (nowSupInt != tobeSupInt) {
                    acntp.setSuperInteresting(tobeSupInt);
                    ActionPlan.updateTL(acntp);
                }
                HSess.close();
            }
        });
    }
}

From source file:edu.nps.moves.mmowgli.modules.maps.LeafletMap.java

License:Open Source License

public void initGuiTL() {
    setSpacing(true);//from w  ww.j av  a  2  s .  c  o  m
    setSizeUndefined();
    setWidth("950px");
    addStyleName("m-marginleft-20");
    Label lab;

    HorizontalLayout hLay = new HorizontalLayout();
    hLay.setMargin(false);
    hLay.setSpacing(false);
    hLay.setWidth("100%");
    NativeButton butt;
    hLay.addComponent(butt = new NativeButton("go to default game location", new MyDefaultLocationListener()));
    hLay.setExpandRatio(butt, 0.5f);
    hLay.setComponentAlignment(butt, Alignment.BOTTOM_LEFT);

    hLay.addComponent(lab = new HtmlLabel(title));
    lab.setWidth(null);

    makeLayerPopups();
    HorizontalLayout popLay = new HorizontalLayout();
    popLay.setMargin(false);
    popLay.setSpacing(false);
    popLay.setWidth("100%");

    popLay.addComponent(lab = new Label());
    lab.setWidth("1px");
    popLay.setExpandRatio(lab, 1.0f);
    popLay.addComponent(baseLayerPopup);
    popLay.addComponent(overlayPopup);

    hLay.addComponent(popLay);
    hLay.setComponentAlignment(popLay, Alignment.BOTTOM_RIGHT);
    hLay.setExpandRatio(popLay, 0.5f);

    addComponent(hLay);

    User me = Mmowgli2UI.getGlobals().getUserTL();
    this.imAGuest = me.isViewOnly() || me.isAccountDisabled();

    map.setAttributionPrefix("Powered by Leaflet with v-leaflet");
    map.addStyleName("m-greyborder");
    map.removeAllComponents();
    // map.addControl(new LScale());
    layerMap = installAllLayers(map);

    fillLayerPopupsTL(); // build the widgets

    setDefaultMapValuesTL(me); // set default zoom, center, layers

    if (!imAGuest)
        setUserMapValuesTL(me); // set zoom, center and layers from userID pref.

    setOptionGroupWidgetsFromLayerMap();// syncs up the widgets to match the active layers

    Collection<Extension> exts = map.getExtensions();
    LLayers llayers = null;
    for (Extension ex : exts)
        if (ex instanceof LLayers) {
            llayers = (LLayers) ex;
            break;
        }
    if (llayers != null)
        map.removeExtension(llayers);

    addComponent(map);

    setExpandRatio(map, 1);
    map.setHeight("600px");
    map.setWidth("100%");
    map.addMoveEndListener(new MyMoveEndListener());
}

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

License:Open Source License

@SuppressWarnings("serial")
public ChangeEmailDialog(EmailPacket pkt) {
    this.packet = pkt;
    // this.uid=uid;
    //User user = DBGet.getUser(uid);

    setCaption("Change Email");
    setModal(true);/*w  ww . ja v  a2s. c om*/
    setWidth("350px");
    //setHeight("200px");

    VerticalLayout vLay = new VerticalLayout();
    setContent(vLay);
    FormLayout fLay = new FormLayout();
    oldEmail = new TextField("Current Email", pkt.original);//user.getEmailAddresses().toString());
    //oldPw.setColumns(20);
    oldEmail.setWidth("99%");
    fLay.addComponent(oldEmail);
    newEmail = new TextField("New Email");
    newEmail.setWidth("99%");
    fLay.addComponent(newEmail);
    newEmail2 = new TextField("Confirm Email");
    newEmail2.setWidth("99%");
    fLay.addComponent(newEmail2);

    vLay.addComponent(fLay);

    HorizontalLayout buttLay = new HorizontalLayout();
    buttLay.setSpacing(true);
    vLay.addComponent(buttLay);
    vLay.setComponentAlignment(buttLay, Alignment.TOP_RIGHT);
    MediaLocator mLoc = Mmowgli2UI.getGlobals().getMediaLocator();
    NativeButton cancelButt = new NativeButton();
    mLoc.decorateCancelButton(cancelButt);
    buttLay.addComponent(cancelButt);
    buttLay.setComponentAlignment(cancelButt, Alignment.BOTTOM_RIGHT);

    //    Label sp;
    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("30px");

    saveButt = new NativeButton();
    //app.globs().mediaLocator().decorateSaveButton(saveButt);  //"save"
    mLoc.decorateOkButton(saveButt); //"ok"
    buttLay.addComponent(saveButt);
    buttLay.setComponentAlignment(saveButt, Alignment.BOTTOM_RIGHT);

    //    buttLay.addComponent(sp = new Label());
    //    sp.setWidth("5px");

    cancelButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().removeWindow(ChangeEmailDialog.this);
        }
    });
    saveButt.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String oldTry = oldEmail.getValue().toString();
            if (!packet.original.equals(oldTry)) {
                Notification.show("Error", "This should never show", Notification.Type.ERROR_MESSAGE);
                return;
            }

            String check = newEmail2.getValue().toString();
            String newStr = newEmail.getValue().toString();
            if (check == null || !newStr.trim().equals(check.trim())) {
                Notification.show("Error", "Emails do not match", Notification.Type.ERROR_MESSAGE);
                return;
            }

            EmailValidator v = new EmailValidator("");
            if (newStr == null || !v.isValid(newStr)) {
                Notification.show("Error", "Please enter a valid email", Notification.Type.ERROR_MESSAGE);
                return;
            }

            packet.updated = newStr.trim();
            if (saveListener != null)
                saveListener.buttonClick(event);
            UI.getCurrent().removeWindow(ChangeEmailDialog.this);
        }
    });
}