List of usage examples for com.vaadin.ui Alignment TOP_RIGHT
Alignment TOP_RIGHT
To view the source code for com.vaadin.ui Alignment TOP_RIGHT.
Click Source Link
From source file:edu.kit.dama.ui.admin.administration.usergroup.GroupMembershipEditorWindow.java
License:Apache License
private GridLayout getMainLayout() throws AuthorizationException, UnsupportedEnumException { if (mainPanel == null) { String id = "mainPanel"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2); //add table and exclude button builder.addComponent(getMembersTable(), 0, 0).addComponent(getExcludeMembersButton(), Alignment.BOTTOM_LEFT, 0, 1, 1, 1); Label l = new Label( "To add members select them in the list below and click <i>'Add Member(s)'</i>. To exclude members select them in the table and click <i>'Exclude Member(s)'</i>", ContentMode.HTML); Button closeButton = new Button("Close"); closeButton.addClickListener((event) -> { close();//from w ww. j a v a2 s . co m }); VerticalLayout actionLayout = new VerticalLayout(l, getUserSelector(), getAddMembersButton()); actionLayout.setComponentAlignment(l, Alignment.TOP_CENTER); actionLayout.setComponentAlignment(getUserSelector(), Alignment.TOP_RIGHT); actionLayout.setComponentAlignment(getAddMembersButton(), Alignment.TOP_RIGHT); actionLayout.setExpandRatio(getUserSelector(), 1.0f); actionLayout.setSpacing(true); actionLayout.setSizeFull(); builder.addComponent(actionLayout, 1, 0, 1, 1).addComponent(closeButton, Alignment.BOTTOM_RIGHT, 1, 1, 1, 1); mainPanel = builder.getLayout(); mainPanel.setId(DEBUG_ID_PREFIX + id); mainPanel.setSizeFull(); mainPanel.setColumnExpandRatio(0, .7f); mainPanel.setColumnExpandRatio(1, .3f); mainPanel.setRowExpandRatio(0, .99f); mainPanel.setRowExpandRatio(1, .01f); mainPanel.setSpacing(true); mainPanel.setMargin(true); updateMainPanel(); } return mainPanel; }
From source file:edu.kit.dama.ui.admin.AdminUIMainView.java
License:Apache License
/** * Update the view depending on the user selection. * * @param pView The new view./*from w w w . java2s.c om*/ */ public void updateView(VIEW pView) { currentView = pView; mainLayout.removeAllComponents(); switch (pView) { case SIMON: loginInformationBar.setVisible(true); if (simonPanel == null) { simonPanel = new SimonMainPanel(); } viewComponent = simonPanel; break; case INFORMATION: loginInformationBar.setVisible(true); if (informationView == null) { informationView = new InformationView(); } viewComponent = informationView; break; case LOGIN: loginInformationBar.setVisible(false); viewComponent = loginForm; break; case PROFILE: loginInformationBar.setVisible(true); if (profileView == null) { profileView = new ProfileView(); } profileView.reload(); viewComponent = profileView; break; case SETTINGS: loginInformationBar.setVisible(true); if (datamanagerSettings == null) { datamanagerSettings = new DataManagerSettingsPanel(); } /* if (!datamanagerSettings.getUserAdministrationTab().equals(datamanagerSettings.getMainComponentContainer().getSelectedTab())) { datamanagerSettings.getMainComponentContainer().setSelectedTab(datamanagerSettings.getUserAdministrationTab()); } datamanagerSettings.getUserAdministrationTab().reload();*/ viewComponent = datamanagerSettings; break; case LANDING: loginInformationBar.setVisible(false); if (landingPage == null) { landingPage = new LandingPageComponent(); } viewComponent = landingPage; break; } mainLayout.addComponent(header); mainLayout.addComponent(loginInformationBar); mainLayout.addComponent(viewComponent); mainLayout.setExpandRatio(header, .09f); mainLayout.setExpandRatio(loginInformationBar, .11f); mainLayout.setExpandRatio(viewComponent, .8f); mainLayout.setComponentAlignment(header, Alignment.MIDDLE_CENTER); mainLayout.setComponentAlignment(viewComponent, Alignment.MIDDLE_CENTER); mainLayout.setComponentAlignment(loginInformationBar, Alignment.TOP_RIGHT); mainLayout.addLayoutClickListener((LayoutEvents.LayoutClickEvent event) -> { if (header.equals(event.getClickedComponent()) || title.equals(event.getClickedComponent()) || logo.equals(event.getClickedComponent())) { refreshMainLayout(); } }); }
From source file:edu.kit.dama.ui.admin.MainControlPanel.java
License:Apache License
/** * Build the main layout./*from w ww . ja v a2s . c o m*/ */ private void buildMainLayout() { infoCell = createCell("img/128x128/information2.png", Alignment.TOP_RIGHT, 0, "<p>Show/edit your profile and personel settings.</p>", "help-right"); profileCell = createCell("img/128x128/preferences.png", Alignment.TOP_LEFT, 1, "<p>Get information on how you use this KIT Data Manager instance.</p>", "help-left"); administrationCell = createCell("img/128x128/gears_preferences.png", Alignment.BOTTOM_RIGHT, 2, "<p>Logout.</p>", "help-right"); logoutCell = createCell("img/128x128/exit.png", Alignment.BOTTOM_LEFT, 3, "<p>Show KIT Data Manager settings.<br/>This view is only available for administrators and group manager</p>.", "help-left"); GridLayout actionCellLayout = new UIUtils7.GridLayoutBuilder(2, 2) .addComponent(infoCell, Alignment.BOTTOM_RIGHT, 0, 0, 1, 1) .addComponent(profileCell, Alignment.BOTTOM_LEFT, 1, 0, 1, 1) .addComponent(administrationCell, Alignment.TOP_RIGHT, 0, 1, 1, 1) .addComponent(logoutCell, Alignment.TOP_LEFT, 1, 1, 1, 1).getLayout(); actionCellLayout.setSpacing(true); actionCellLayout.setMargin(true); actionCellLayout.setSizeFull(); actionCellLayout.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { if (event.getClickedComponent() instanceof Image) { // Check if childComponent is disabled if (!event.getChildComponent().isEnabled()) { return; } Image img = (Image) event.getClickedComponent(); if ("image0".equals(img.getId())) { parent.updateView(AdminUIMainView.VIEW.INFORMATION); } else if ("image1".equals(img.getId())) { parent.updateView(AdminUIMainView.VIEW.PROFILE); } else if ("image2".equals(img.getId())) { parent.updateView(AdminUIMainView.VIEW.SETTINGS); } else if ("image3".equals(img.getId())) { parent.logout(); } } } }); mainLayout = new VerticalLayout(actionCellLayout); mainLayout.setSizeFull(); }
From source file:edu.kit.dama.ui.admin.schedule.SchedulerBasePropertiesLayout.java
License:Apache License
/** * Default constructor./*from w ww .j av a 2 s . co m*/ */ public SchedulerBasePropertiesLayout() { super(); LOGGER.debug("Building " + DEBUG_ID_PREFIX + " ..."); setId(DEBUG_ID_PREFIX.substring(0, DEBUG_ID_PREFIX.length() - 1)); setSizeFull(); setMargin(true); setSpacing(true); setColumns(3); setRows(3); //first row addComponent(getIdField(), 0, 0); addComponent(getGroupField(), 1, 0); addComponent(getNameField(), 2, 0); //second row addComponent(getDescriptionArea(), 0, 1, 2, 1); Button addTriggerButton = new Button(); addTriggerButton.setDescription("Add a new trigger."); addTriggerButton.setIcon(new ThemeResource(IconContainer.ADD)); addTriggerButton.addClickListener((Button.ClickEvent event) -> { addTrigger(); }); Button removeTriggerButton = new Button(); removeTriggerButton.setDescription("Remove the selected trigger."); removeTriggerButton.setIcon(new ThemeResource(IconContainer.DELETE)); removeTriggerButton.addClickListener((Button.ClickEvent event) -> { removeTrigger(); }); Button refreshTriggerButton = new Button(); refreshTriggerButton.setDescription("Refresh the list of triggers."); refreshTriggerButton.setIcon(new ThemeResource(IconContainer.REFRESH)); refreshTriggerButton.addClickListener((Button.ClickEvent event) -> { reloadTriggers(); }); VerticalLayout buttonLayout = new VerticalLayout(addTriggerButton, refreshTriggerButton, removeTriggerButton); buttonLayout.setComponentAlignment(addTriggerButton, Alignment.TOP_RIGHT); buttonLayout.setComponentAlignment(removeTriggerButton, Alignment.TOP_RIGHT); buttonLayout.setMargin(true); GridLayout triggerLayout = new UIUtils7.GridLayoutBuilder(2, 2).addComponent(getTriggerTable(), 0, 0, 1, 2) .addComponent(buttonLayout, 1, 0, 1, 2).getLayout(); triggerLayout.setSizeFull(); triggerLayout.setMargin(false); triggerLayout.setColumnExpandRatio(0, .95f); triggerLayout.setColumnExpandRatio(1, .05f); triggerLayout.setRowExpandRatio(0, .9f); triggerLayout.setRowExpandRatio(1, .05f); triggerLayout.setRowExpandRatio(2, .05f); //third row addComponent(triggerLayout, 0, 2, 2, 2); addTriggerComponent = new AddTriggerComponent(this); setRowExpandRatio(1, .3f); setRowExpandRatio(2, .6f); }
From source file:edu.kit.dama.ui.admin.wizard.FirstStartWizard.java
License:Apache License
private void buildMainLayout() { stepLayout = new VerticalLayout(); back.setEnabled(false);/* w ww . ja v a2 s . c o m*/ stepLayout.addComponent(stepList[currentStep]); stepLayout.setComponentAlignment(stepList[currentStep], Alignment.TOP_RIGHT); stepLayout.setSpacing(false); stepLayout.setMargin(false); stepLayout.setWidth("100%"); stepLayout.setHeight("500px"); final VerticalLayout stepLabels = new VerticalLayout(); for (WizardStep step : stepList) { Label stepLabel = new Label(step.getStepName()); stepLabel.setWidth("250px"); stepLabels.addComponent(stepLabel); stepLabels.setComponentAlignment(stepLabel, Alignment.TOP_LEFT); } //make introduction label bold stepLabels.getComponent(0).addStyleName("myboldcaption"); Label spacer = new Label(); stepLabels.addComponent(spacer); stepLabels.setExpandRatio(spacer, 1.0f); stepLabels.setWidth("275px"); stepLabels.setHeight("550px"); stepLabels.setSpacing(true); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2); HorizontalLayout buttonLayout = new HorizontalLayout(back, next); buttonLayout.setSizeFull(); buttonLayout.setComponentAlignment(back, Alignment.BOTTOM_RIGHT); buttonLayout.setComponentAlignment(next, Alignment.BOTTOM_RIGHT); buttonLayout.setExpandRatio(back, 1.0f); next.addClickListener((event) -> { if ("Go To Login".equals(next.getCaption())) { Page.getCurrent().reload(); } else if ("Finish".equals(next.getCaption())) { //do finish WizardPersistHelper helper = new WizardPersistHelper(); if (helper.persist(properties)) { UIUtils7.showInformation("Success", "All information have been successfully stored into the database. For details, please refer to the log output above.\n" + "You may now dismiss this message and click 'Go To Login' in order to access the login page.\n" + "From there you can to login using your administrator account or create a personalized user account.", 3000); back.setVisible(false); next.setCaption("Go To Login"); } else { UIUtils7.showError("Failed to store collected information in database.\n" + "Please refer to the log output above."); } ((WizardSummary) stepList[currentStep]).setSummary(helper.getMessages()); } else { if (currentStep + 1 <= stepList.length - 1) { if (stepList[currentStep].validate()) { stepList[currentStep].collectProperties(properties); currentStep++; stepLayout.replaceComponent(stepList[currentStep - 1], stepList[currentStep]); Label currentLabel = (Label) stepLabels.getComponent(currentStep); Label prevLabel = (Label) stepLabels.getComponent(currentStep - 1); currentLabel.addStyleName("myboldcaption"); prevLabel.removeStyleName("myboldcaption"); if (stepList[currentStep] instanceof WizardSummary) { StringBuilder summary = new StringBuilder(); for (WizardStep step : stepList) { summary.append(step.getSummary()).append("\n"); } ((WizardSummary) stepList[currentStep]).setSummary(summary.toString()); } } } if (currentStep == stepList.length - 1) { //finish next.setCaption("Finish"); } else { next.setCaption("Next"); } back.setEnabled(true); } }); back.addClickListener((event) -> { if (currentStep - 1 >= 0) { stepList[currentStep].collectProperties(properties); currentStep--; stepLayout.replaceComponent(stepList[currentStep + 1], stepList[currentStep]); Label currentLabel = (Label) stepLabels.getComponent(currentStep); Label prevLabel = (Label) stepLabels.getComponent(currentStep + 1); currentLabel.addStyleName("myboldcaption"); prevLabel.removeStyleName("myboldcaption"); } next.setEnabled(true); back.setEnabled(currentStep > 0); next.setCaption("Next"); }); builder.addComponent(stepLabels, Alignment.TOP_LEFT, 0, 0, 1, 2); builder.addComponent(stepLayout, Alignment.TOP_LEFT, 1, 0, 1, 1); builder.addComponent(buttonLayout, Alignment.BOTTOM_LEFT, 1, 1, 1, 1); mainLayout = builder.getLayout(); mainLayout.setMargin(true); mainLayout.setSizeFull(); // mainLayout.setColumnExpandRatio(0, .3f); mainLayout.setColumnExpandRatio(1, 1f); mainLayout.setRowExpandRatio(0, .95f); mainLayout.setRowExpandRatio(1, .05f); }
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 w w . j a va2 s.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.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 .java 2 s .c om */ 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.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
private void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning, MenuBar mbar) {/*w w w.ja v a 2 s . c om*/ // Create the window... final Window bcastWindow = new Window(title); bcastWindow.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); bcastWindow.setContent(layout); layout.addComponent(new Label("Compose message (255 char limit):")); final TextArea ta = new TextArea(); ta.setRows(5); ta.setWidth("99%"); layout.addComponent(ta); HorizontalLayout buttHl = new HorizontalLayout(); final Button bcancelButt = new Button("Cancel"); buttHl.addComponent(bcancelButt); Button bokButt = new Button(buttName); bokButt.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttHl.addComponent(bokButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); if (doWarning) layout.addComponent(new Label("Use with great deliberation!")); bcastWindow.setWidth("320px"); UI.getCurrent().addWindow(bcastWindow); bcastWindow.setPositionX(0); bcastWindow.setPositionY(0); ta.focus(); @SuppressWarnings("serial") ClickListener lis = new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { if (event.getButton() == bcancelButt) ; // nothin else { // This check is now done in GameEvent.java, but should ideally prompt the user. String msg = ta.getValue().toString().trim(); if (msg.length() > 0) { HSess.init(); if (msg.length() > 255) // clamp to 255 to avoid db exception msg = msg.substring(0, 254); User u = Mmowgli2UI.getGlobals().getUserTL(); if (typ == GameEvent.EventType.GAMEMASTERNOTE) GameEventLogger.logGameMasterCommentTL(msg, u); else GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); HSess.close(); } } bcastWindow.close(); } }; bcancelButt.addClickListener(lis); bokButt.addClickListener(lis); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
private Component makeHL(String s, int num) { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true);//from w ww. ja va 2 s .co m Label lab; hl.addComponent(lab = new HtmlLabel(s)); hl.setExpandRatio(lab, 1.0f); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + num); countTf.addStyleName("m-greyborder"); countTf.addStyleName("m-textalignright"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.TOP_RIGHT); hl.setWidth("100%"); return hl; }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleLoginLimitActionTL() { // Create the window... final Window loginWin = new Window("Change Session Login Limit"); loginWin.setModal(true);//from w w w . ja v a 2 s .c o m VerticalLayout layout = new VerticalLayout(); loginWin.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(new Label("Max users to be logged in")); final TextField utf = new TextField(); utf.setColumns(10); final int oldVal = Game.getTL().getMaxUsersOnline(); utf.setValue("" + oldVal); hl.addComponent(utf); layout.addComponent(hl); HorizontalLayout buttHl = new HorizontalLayout(); // LLListener llis = new LLListener(loginWin); final Button cancelButt = new Button("Cancel"); buttHl.addComponent(cancelButt); final Button okButt = new Button("Save"); buttHl.addComponent(okButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); layout.addComponent(new Label("Use with great deliberation!")); loginWin.setWidth("320px"); UI.getCurrent().addWindow(loginWin); loginWin.center(); @SuppressWarnings("serial") ClickListener llis = new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (event.getButton() == cancelButt) { } else if (event.getButton() == okButt) { HSess.init(); try { int i = Integer.parseInt(utf.getValue().toString()); Game g = Game.getTL(); g.setMaxUsersOnline(i); Game.updateTL(); GameEventLogger.logLoginLimitChangeTL(oldVal, i); } catch (Throwable t) { Notification.show("Error", "Invalid integer", Notification.Type.ERROR_MESSAGE); HSess.close(); return; } HSess.close(); } loginWin.close(); } }; cancelButt.addClickListener(llis); okButt.addClickListener(llis); }