List of usage examples for com.vaadin.ui Label addStyleName
@Override public void addStyleName(String style)
From source file:edu.kit.dama.ui.admin.MainControlPanel.java
License:Apache License
/** * Create a new cell for the UI. Each cell contains an image located in the * provided resource and a help label for the cell adverse to it. * Furthermore, a style is provided which can be 'help-left' or 'help-right' * depending on which side the help text should be aligned (help in left col * -> align right).//from w w w . j av a 2 s. c om * * @param pResourceString The image resource string. * @param The alignment of the image (TOP_LEFT or TOP_RIGHT, depending on * the column) * @param cellNumber The cell number (0-3) counting from top left to bottom * right * @param pHelp The help string which may contain HTML tags. * @param pStyle The help label style ('help-left' or 'help-right'). * * @return The cell layout. */ private VerticalLayout createCell(String pResourceString, Alignment pAlignment, int cellNumber, String pHelp, String pStyle) { final String cellHeight = "132px"; //create the cell image Image cellImage = new Image(null, new ThemeResource(pResourceString)); cellImage.addStyleName("border"); //create the cell image wrapper, which provides the shadow and this show/hide functionality VerticalLayout imageWrapper = new VerticalLayout(cellImage); imageWrapper.addComponent(cellImage); imageWrapper.setComponentAlignment(cellImage, Alignment.MIDDLE_CENTER); imageWrapper.setWidth(cellHeight); imageWrapper.setHeight(cellHeight); imageWrapper.addStyleName("shadow"); imageWrapper.addStyleName("visible"); //help label for the cell adverse to the current cell Label oppositeCellHelp = new Label(pHelp, ContentMode.HTML); oppositeCellHelp.addStyleName(pStyle); oppositeCellHelp.setSizeFull(); oppositeCellHelp.addStyleName("invisible"); oppositeCellHelp.setHeight(cellHeight); //the cell layout containing image and help label VerticalLayout cell = new VerticalLayout(); cell.addComponent(imageWrapper); cell.setComponentAlignment(imageWrapper, pAlignment); cell.setMargin(true); cell.addComponent(oppositeCellHelp); cell.setComponentAlignment(oppositeCellHelp, Alignment.MIDDLE_CENTER); //define component ids depending on the provided cell number //--------- //| 0 | 1 | //| 2 | 3 | //--------- //Each cell gets the id 'image<cellNumber>' //The currently created wrapper and help label are getting the cellId of the adverse cell (0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2). //These ids are used then by edu.kit.dama.ui.admin.client.HelpConnector to show/hide elements on mouse over. switch (cellNumber) { case 0: cellImage.setId("image0"); //this cell contains the help for cell 1 imageWrapper.setId("image1_wrapper"); oppositeCellHelp.setId("image1_help"); break; case 1: cellImage.setId("image1"); //this cell contains the help for cell 0 imageWrapper.setId("image0_wrapper"); oppositeCellHelp.setId("image0_help"); break; case 2: cellImage.setId("image2"); //this cell contains the help for cell 3 imageWrapper.setId("image3_wrapper"); oppositeCellHelp.setId("image3_help"); break; case 3: cellImage.setId("image3"); //this cell contains the help for cell 2 imageWrapper.setId("image2_wrapper"); oppositeCellHelp.setId("image2_help"); break; } //link the HelpExtension to the image new HelpExtension().extend(cellImage); return cell; }
From source file:edu.kit.dama.ui.admin.staging.processors.StagingProcessorBasePropertiesLayout.java
License:Apache License
public StagingProcessorBasePropertiesLayout() { super();//from w w w . j a v a 2 s . co m 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(4); /////////check layout and relocate addComponent(getNameField(), 0, 0, 2, 0); addComponent(getGroupBox(), 0, 1, 1, 1); Label minus = new Label("-"); minus.addStyleName(CSSTokenContainer.BOLD_CAPTION); Label plus = new Label("+"); plus.addStyleName(CSSTokenContainer.BOLD_CAPTION); sliderLayout = new HorizontalLayout(minus, getPrioritySlider(), plus); sliderLayout.setComponentAlignment(minus, Alignment.BOTTOM_RIGHT); sliderLayout.setComponentAlignment(plus, Alignment.BOTTOM_LEFT); sliderLayout.setExpandRatio(getPrioritySlider(), .96f); sliderLayout.setExpandRatio(minus, .02f); sliderLayout.setExpandRatio(plus, .02f); sliderLayout.setWidth("100%"); addComponent(sliderLayout, 0, 2, 1, 2); getCheckBoxesLayout().addComponent(getIngestProcessingSupportedBox()); getCheckBoxesLayout().addComponent(getDownloadProcessingSupportedBox()); addComponent(getCheckBoxesLayout(), 2, 1, 2, 2); addComponent(getDescriptionArea(), 0, 3, 2, 3); setColumnExpandRatio(0, .79f); setColumnExpandRatio(1, 0.01f); setColumnExpandRatio(2, 0.2f); setRowExpandRatio(3, 1f); }
From source file:edu.kit.dama.ui.admin.wizard.FirstStartWizard.java
License:Apache License
private void buildMainLayout() { stepLayout = new VerticalLayout(); back.setEnabled(false);// ww w .j av a 2s. 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.admin.workflow.DataWorkflowBasePropertiesLayout.java
License:Apache License
public DataWorkflowBasePropertiesLayout() { LOGGER.debug("Building " + DEBUG_ID_PREFIX + " ..."); setId(DEBUG_ID_PREFIX.substring(0, DEBUG_ID_PREFIX.length() - 1)); setSizeFull();/* ww w . j a va 2s . co m*/ setMargin(true); setSpacing(true); setCaption("TASK CONFIGURATION"); setColumns(4); setRows(6); //first row addComponent(getNameField(), 0, 0); addComponent(getVersionField(), 1, 0); addComponent(getContactBox(), 2, 0); addComponent(getGroupBox(), 3, 0); //second row addComponent(getApplicationPackageUrlField(), 0, 1, 1, 1); addComponent(getApplicationArgumentsField(), 2, 1); //addComponent(getCheckBoxesLayout(), 3, 1, 3, 2); //add placeholder only addComponent(new VerticalLayout(), 3, 1, 3, 2); Label l = new Label("* Changing fields with a red border will update the version of the associated task."); l.addStyleName("red-text"); addComponent(l, 0, 2, 2, 2); l.setHeight("12px"); setComponentAlignment(l, Alignment.TOP_CENTER); // addComponent(getKeywordsField(), 0, 3, 2, 3); // addComponent(getDescriptionArea(), 0, 4, 2, 5); Button addPropertyButton = new Button(); addPropertyButton.setIcon(new ThemeResource(IconContainer.ADD)); addPropertyButton.addClickListener((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, 3, 3, 5); //add popup to layout addPropertyComponent = new AddEnvironmentPropertyComponent(this); //set dummy row height to 0 setColumnExpandRatio(0, 0.2f); setColumnExpandRatio(1, 0.15f); setColumnExpandRatio(2, 0.2f); setColumnExpandRatio(3, 0.25f); setRowExpandRatio(5, 1f); }
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 ww . j a va 2s.co 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.simon.panel.SimonMainPanel.java
License:Apache License
/** * Build the overview tab including the list of all categories and der * overall status./* ww w. j av a2 s . c o m*/ * * @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.AbstractMmowgliControllerHelper.java
License:Open Source License
void handleShowActiveUsersActionTL(MenuBar menubar) { Session session = HSess.get();// www . j av a2 s. c om Criteria criteria = session.createCriteria(User.class); criteria.setProjection(Projections.rowCount()); criteria.add(Restrictions.eq("accountDisabled", false)); int totcount = ((Long) criteria.list().get(0)).intValue(); // new and improved int count = Mmowgli2UI.getGlobals().getSessionCount(); Window countWin = new Window("Display Active User Count"); countWin.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label lab; hl.addComponent(lab = new HtmlLabel("Number of users* (including yourself)<br/>currently playing:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + count); countTf.addStyleName("m-greyborder"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT); layout.addComponent(hl); layout.addComponent(new Label("* Count incremented on login, decremented on timeout or logout.")); hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(lab = new HtmlLabel("Total registered users:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label totalLab = new HtmlLabel(); totalLab.setWidth("50px"); totalLab.setValue(" " + totcount); totalLab.addStyleName("m-greyborder"); hl.addComponent(totalLab); hl.setComponentAlignment(totalLab, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("325px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleShowNumberCardsActionTL(MenuBar mbar) { Session session = HSess.get();// w ww. j a v a 2s .c o m Criteria criteria = session.createCriteria(Card.class); criteria.setProjection(Projections.rowCount()); int count = ((Long) criteria.list().get(0)).intValue(); // Create the window... Window countWin = new Window("Display Card Count"); countWin.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label lab; hl.addComponent(lab = new HtmlLabel("Number of cards played:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + count); countTf.addStyleName("m-greyborder"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("255px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
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);//www. j av a 2s. c o 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.components.CardSummary.java
License:Open Source License
@SuppressWarnings("serial") public void initGui(Session sess) { setHeight(heightStr);//from w ww .j av a 2s . co m setWidth(widthStr); addStyleName("m-cursor-pointer"); // pointer when over me, because I'm clickable if (bckgrndResource != null) { backImg = new Embedded(null, bckgrndResource); addComponent(backImg, "top:0px;left:0px"); } if (!isFactCard) { String hdrTxt = card.getCardType().getSummaryHeader(); header.setDescription(hdrTxt); if (hdrTxt != null && hdrTxt.length() > 0) { //if(hdrTxt.length()>=15) { // hdrTxt = hdrTxt.substring(0, 15).trim()+"..."; // } header.setValue(hdrTxt); header.setWidth(headerWidthStr); header.setHeight(headerHeightStr); addComponent(header, headerPositionStr); header.addStyleName(headerStyleStr); header.addStyleName(textColorStyleStr); header.addStyleName("m-cursor-pointer"); } if (starGreyResource != null && starRedResource != null) { Set<Card> favs = me.getFavoriteCards(); if (favs != null && favs.contains(card)) { star.setIcon(starRedResource); } else { star.setIcon(starGreyResource); } addComponent(star, starPositionStr); if (!mockupOnly) star.addClickListener(new StarClick()); star.addStyleName("borderless"); star.setDescription("Mark or unmark as a favorite of yours"); } } idLab.setWidth(idLabWidthStr); idLab.setHeight(idLabHeightStr); idLab.setValue("" + card.getId()); idLab.addStyleName(idLabStyleStr); idLab.addStyleName("m-text-align-right"); addComponent(idLab, idLabPositionStr); content.setWidth(contentWidthStr); content.setHeight(contentHeightStr); addComponent(content, contentPositionStr); content.addStyleName(contentStyle); if (card.isHidden()) content.addStyleName(hiddenStyle); // red "HIDDEN" text background content.setValue(formatText(card.getText())); content.addStyleName("m-cursor-pointer"); content.setDescription(card.getText()); if (!isFactCard) { /* We shouldn't have to be setting widths on the components within this horizontal layout. The * fact that we do is, I think, related to the absolutelayout parent. Get rid of that and we might * be able to yank the .setwidth, setheight stuff. */ HorizontalLayout hLay = new HorizontalLayout(); hLay.setMargin(false); hLay.setHeight(userHeightStr); hLay.setWidth(userDateWidthStr); addComponent(hLay, userDatePositionStr); user.setValue(card.getAuthorName()); //.getAuthor().getUserName()); hLay.addComponent(user); user.setWidth(userWidthStr); user.setHeight(userHeightStr); user.addStyleName(userStyle); user.addStyleName("m-cursor-pointer"); Label sp; hLay.addComponent(sp = new Label()); sp.setWidth("1px"); hLay.setExpandRatio(sp, 1.0f); dateLab.setValue(dateFormatter.format(card.getCreationDate())); hLay.addComponent(dateLab); dateLab.setHeight(userHeightStr); dateLab.setWidth(null); //dateWidthStr); dateLab.addStyleName(userStyle); } if (card.getCreatedInMove().getId() != Move.getCurrentMove(sess).getId()) { Label lab = new Label(card.getCreatedInMove().getName()); lab.addStyleName(moveStyleStr); lab.setWidth(moveWidthStr); lab.setHeight(moveHeightStr); addComponent(lab, movePositionStr); } // Listen for layout click events if (!mockupOnly) this.addLayoutClickListener(new LayoutClickListener() { @MmowgliCodeEntry @HibernateOpened @HibernateRead public void layoutClick(LayoutClickEvent event) { HSess.init(); Component c = event.getChildComponent(); Card card = Card.getTL(cardId); if (c == star) { //Let the starlistener below handle it } else if (c == user) { AppEvent evt = new AppEvent(CARDAUTHORCLICK, CardSummary.this, card.getAuthor().getId()); Mmowgli2UI.getGlobals().getController().miscEventTL(evt); } else { //if (c == content) { AppEvent evt = new AppEvent(CARDCLICK, CardSummary.this, card.getId()); Mmowgli2UI.getGlobals().getController().miscEventTL(evt); } HSess.close(); } }); }