List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:fi.semantum.strategia.widget.Property.java
License:Open Source License
public static void updateProperties(final Main main, final Base base, boolean canWrite) { final Database database = main.getDatabase(); String headerText = main.getUIState().currentItem.getCaption(database); main.propertyCells.add(Utils.excelRow(headerText)); Label header = new Label(headerText); header.setWidth("800px"); header.addStyleName("propertyHeader"); header.addStyleName(ValoTheme.LABEL_HUGE); header.addStyleName(ValoTheme.LABEL_BOLD); main.properties.addComponent(header); main.properties.setComponentAlignment(header, Alignment.MIDDLE_CENTER); ArrayList<Pair> sorted = new ArrayList<Pair>(main.getUIState().currentItem.properties); Collections.sort(sorted, new Comparator<Pair>() { @Override/* ww w . j av a 2 s. co m*/ public int compare(Pair arg0, Pair arg1) { final Property p0 = database.find(arg0.first); final Property p1 = database.find(arg1.first); return p0.getId(database).compareTo(p1.getId(database)); } }); Property typeProperty = Property.find(database, Property.TYPE); for (Pair pair : sorted) { // Skip type if (typeProperty.uuid.equals(pair.first)) continue; final Property p = database.find(pair.first); String value = pair.second; final HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); String label = p.getText(database); main.propertyCells.add(Utils.excelRow(label, value)); Label l = new Label(label); l.setWidth("450px"); l.addStyleName("propertyName"); hl.addComponent(l); List<String> enumeration = p.getEnumeration(database); if (enumeration.isEmpty()) { final TextField tf = new TextField(); tf.setValue(value); tf.setWidth("350px"); hl.addComponent(tf); hl.setComponentAlignment(tf, Alignment.MIDDLE_LEFT); tf.setReadOnly(p.readOnly); tf.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 7729833503749464603L; @Override public void valueChange(ValueChangeEvent event) { Utils.loseFocus(hl); if (p.set(main, main.getUIState().currentItem, tf.getValue())) Updates.update(main, true); } }); tf.setReadOnly(!canWrite); } else { final ComboBox combo = new ComboBox(); combo.setWidth("350px"); combo.setInvalidAllowed(false); combo.setNullSelectionAllowed(false); for (String e : enumeration) { combo.addItem(e); } combo.select(p.getEnumerationValue(database, value)); combo.setPageLength(0); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3511164709346832901L; @Override public void valueChange(ValueChangeEvent event) { Utils.loseFocus(hl); if (p.set(main, main.getUIState().currentItem, combo.getValue().toString())) Updates.update(main, true); } }); combo.setReadOnly(!canWrite); hl.addComponent(combo); hl.setComponentAlignment(combo, Alignment.MIDDLE_LEFT); } hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); main.properties.addComponent(hl); main.properties.setComponentAlignment(hl, Alignment.MIDDLE_CENTER); } }
From source file:fi.semantum.strategia.widget.Tag.java
License:Open Source License
public static void updateRelatedTags(final Main main, boolean canWrite) { final Database database = main.getDatabase(); final Base base = main.getUIState().currentItem; Collection<Tag> tags = base.getRelatedTags(database); if (!tags.isEmpty() || canWrite) { HorizontalLayout tagHeader = new HorizontalLayout(); tagHeader.setSpacing(true);//from w w w.j av a2s . co m Label header2 = new Label("Aihetunnisteet"); header2.setHeight("32px"); header2.addStyleName(ValoTheme.LABEL_HUGE); header2.addStyleName(ValoTheme.LABEL_BOLD); tagHeader.addComponent(header2); tagHeader.setComponentAlignment(header2, Alignment.BOTTOM_CENTER); if (canWrite) { final Image editTags = new Image("", new ThemeResource("tag_blue_edit.png")); editTags.setHeight("24px"); editTags.setWidth("24px"); editTags.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = -6140867347404571880L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.loseFocus(editTags); Utils.editTags(main, "Muokkaa aihetunnisteita", main.getUIState().currentItem); } }); tagHeader.addComponent(editTags); tagHeader.setComponentAlignment(editTags, Alignment.BOTTOM_CENTER); } main.properties.addComponent(tagHeader); main.properties.setComponentAlignment(tagHeader, Alignment.MIDDLE_CENTER); HorizontalLayout divider = new HorizontalLayout(); main.properties.addComponent(divider); main.properties.setComponentAlignment(divider, Alignment.MIDDLE_CENTER); VerticalLayout left = new VerticalLayout(); left.setSpacing(true); left.setWidth("400px"); left.setMargin(true); divider.addComponent(left); VerticalLayout right = new VerticalLayout(); right.setSpacing(true); right.setWidth("400px"); right.setMargin(true); divider.addComponent(right); Set<Tag> monitoredTags = getMonitoredTags(database, base); int i = 0; for (final Tag tag : tags) { final boolean monitor = base.hasMonitorTag(database, tag); String tagId = tag.getId(database); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setHeight("37px"); Button tagButton = Utils.tagButton(database, "list", tagId, i++); left.addComponent(tagButton); left.setComponentAlignment(tagButton, Alignment.MIDDLE_RIGHT); if (canWrite) { Button b = new Button(); b.addStyleName(ValoTheme.BUTTON_BORDERLESS); b.setIcon(FontAwesome.TIMES_CIRCLE); b.addClickListener(new ClickListener() { private static final long serialVersionUID = -4473258383318654850L; @Override public void buttonClick(ClickEvent event) { base.removeRelatedTags(database, tag); Utils.loseFocus(main.properties); Updates.update(main, true); } }); hl.addComponent(b); hl.setComponentAlignment(b, Alignment.MIDDLE_LEFT); } if (base instanceof Strategiakartta) { Button tagButton2 = new Button(); tagButton2.setCaption(monitor ? "Seurataan toteutuksessa" : "Ei seurata toteutuksessa"); tagButton2.addStyleName(monitor ? "greenButton" : "redButton"); tagButton2.addStyleName(ValoTheme.BUTTON_SMALL); tagButton2.setWidth("200px"); if (canWrite) { tagButton2.addClickListener(new ClickListener() { private static final long serialVersionUID = -1769769368034323594L; @Override public void buttonClick(ClickEvent event) { if (monitor) { base.removeMonitorTags(database, tag); } else { base.assertMonitorTags(database, tag); } Utils.loseFocus(main.properties); Updates.update(main, true); } }); tagButton2.setEnabled(true); } else { tagButton2.setEnabled(false); } hl.addComponent(tagButton2); hl.setComponentAlignment(tagButton2, Alignment.MIDDLE_LEFT); } else { if (monitoredTags.contains(tag)) { Label l = new Label(" toteuttaa seurattavaa aihetta "); hl.addComponent(l); hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); } } right.addComponent(hl); right.setComponentAlignment(hl, Alignment.MIDDLE_LEFT); } } }
From source file:fi.semantum.strategia.widget.Tag.java
License:Open Source License
public static void updateMonitoredTags(final Main main, boolean canWrite) { final Database database = main.getDatabase(); final Base base = main.getUIState().currentItem; if (!(base instanceof Tavoite || base instanceof Painopiste)) return;//from w w w . jav a 2 s . co m Set<Tag> monitoredTags = getMonitoredTags(database, base); monitoredTags.removeAll(base.getRelatedTags(database)); Map<String, Base> implementors = new HashMap<String, Base>(); for (Base impl : Utils.getImplementationSet(database, base)) { for (Tag i : impl.getRelatedTags(database)) { if (monitoredTags.contains(i)) { implementors.put(i.uuid, impl); } } } if (!monitoredTags.isEmpty() || canWrite) { HorizontalLayout tagHeader = new HorizontalLayout(); tagHeader.setSpacing(true); Label header2 = new Label("Seurattavat aihetunnisteet"); header2.setHeight("32px"); header2.addStyleName(ValoTheme.LABEL_HUGE); header2.addStyleName(ValoTheme.LABEL_BOLD); tagHeader.addComponent(header2); tagHeader.setComponentAlignment(header2, Alignment.BOTTOM_CENTER); main.properties.addComponent(tagHeader); main.properties.setComponentAlignment(tagHeader, Alignment.MIDDLE_CENTER); HorizontalLayout divider = new HorizontalLayout(); main.properties.addComponent(divider); main.properties.setComponentAlignment(divider, Alignment.MIDDLE_CENTER); VerticalLayout left = new VerticalLayout(); left.setSpacing(true); left.setWidth("400px"); left.setMargin(true); divider.addComponent(left); VerticalLayout right = new VerticalLayout(); right.setSpacing(true); right.setWidth("400px"); right.setMargin(true); divider.addComponent(right); int i = 0; for (final Tag tag : monitoredTags) { String tagId = tag.getId(database); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setHeight("37px"); Button tagButton = Utils.tagButton(database, "inferred", tagId, i++); left.addComponent(tagButton); left.setComponentAlignment(tagButton, Alignment.MIDDLE_RIGHT); Base implementor = implementors.get(tag.uuid); if (implementor != null) { String desc = implementor.getId(database); if (desc.isEmpty()) desc = implementor.getText(database); Label tagLabel = new Label("Toteutetaan ylemmll tasolla: " + desc); hl.addComponent(tagLabel); hl.setComponentAlignment(tagLabel, Alignment.MIDDLE_LEFT); } else { Button tagButton2 = new Button(); tagButton2.setCaption("Merkitse toteuttajaksi"); tagButton2.addStyleName("redButton"); tagButton2.addStyleName(ValoTheme.BUTTON_SMALL); tagButton2.setWidth("200px"); if (canWrite) { tagButton2.addClickListener(new ClickListener() { private static final long serialVersionUID = -1769769368034323594L; @Override public void buttonClick(ClickEvent event) { base.assertRelatedTags(database, tag); Utils.loseFocus(main.properties); Updates.update(main, true); } }); tagButton2.setEnabled(true); } else { tagButton2.setEnabled(false); } hl.addComponent(tagButton2); hl.setComponentAlignment(tagButton2, Alignment.MIDDLE_LEFT); } right.addComponent(hl); right.setComponentAlignment(hl, Alignment.MIDDLE_LEFT); } } }
From source file:fi.vtt.RVaadin.RUpload.java
License:Apache License
/** * Contruct an upload element for R (implemented as Vaadin CustomComponent). * //from w ww.j a v a 2 s . c om * @param caption * String caption or null * @param R * the corresponding RSession to upload the files to */ public RUpload(String caption, RContainer R) { /* Create the RUpload custom component */ super.setSizeUndefined(); root = new Panel(caption); root.setWidth("90ex"); setCompositionRoot(root); HorizontalLayout hbox = new HorizontalLayout(); hbox.setWidth("100%"); /* Create the Upload component */ final Upload upload = new Upload("Choose file", this); upload.setButtonCaption("Submit"); /* Listen for events regarding the success of upload. */ upload.addSucceededListener(this); upload.addFailedListener(this); hbox.addComponent(upload); Label hfill = new Label(); hbox.addComponent(hfill); hbox.setExpandRatio(hfill, 1.0f); remove = new Button("Remove", new Button.ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { String current = getSelection(); if (current != null) { /* Delete the file */ delete(current); /* Update the lists and the notification area */ int i = fileNames.indexOf(current); fileNames.remove(i); mimeTypes.remove(i); uploadedFiles.removeItem(current); /* Gray out the button, if this was the last item */ if (fileNames.isEmpty()) { remove.setEnabled(false); } } } }); hbox.addComponent(remove); remove.setEnabled(false); hbox.setComponentAlignment(remove, Alignment.BOTTOM_RIGHT); /* Notification area for already uploaded files */ uploadedFiles = new ListSelect("Already submitted files"); uploadedFiles.setMultiSelect(false); uploadedFiles.setNullSelectionAllowed(false); uploadedFiles.setHeight("4em"); uploadedFiles.setWidth("100%"); // Changed for Vaadin 7, not tested!! VerticalLayout vbox = new VerticalLayout(); vbox.addComponent(hbox); vbox.addComponent(uploadedFiles); root.setContent(vbox); /* Bind the component to the given R session */ this.R = R; }
From source file:foo.MyVaadinApplication.java
License:Apache License
/** * Initializes the middle banner/* w w w. ja v a2s . c o m*/ * * @return initialized middle banner */ private Panel initMiddlePanel() { HorizontalLayout h = new HorizontalLayout(); SidePanel sidePanel = new SidePanel(this); h.addComponent(sidePanel); h.setComponentAlignment(sidePanel, Alignment.MIDDLE_LEFT); contentPanel = new ContentPanel(this); h.addComponent(contentPanel); h.setComponentAlignment(contentPanel, Alignment.TOP_CENTER); Panel middlePanel = new Panel(); middlePanel.setContent(h); return middlePanel; }
From source file:fr.amapj.view.engine.basicform.BasicFormListPart.java
License:Open Source License
private void buildMainArea() { createColumn();//from w w w .ja v a 2 s . c o m // Create a persistent person container listPartContainer = new BeanItemContainer(getClazz()); onPopupClose(); // Add a nested property to a many-to-one property for (ColumnInfo colInfo : colInfos) { if (colInfo.isNested()) { listPartContainer.addNestedContainerProperty(colInfo.propertyId); } } // Set up sorting if the natural order is not appropriate listPartContainer.sort(orderByInfo, new boolean[] { true, true }); // Bind it to a component beanTable = createTable(listPartContainer); // Gestion de la liste des colonnes visibles List<String> colNames = new ArrayList<String>(); for (ColumnInfo colInfo : colInfos) { colNames.add(colInfo.propertyId); } beanTable.setVisibleColumns(colNames.toArray()); // Gestion des titres de colonnes for (ColumnInfo colInfo : colInfos) { beanTable.setColumnHeader(colInfo.propertyId, colInfo.title); } beanTable.setSelectable(true); beanTable.setImmediate(true); // Activation au desactivation des boutons delete et edit beanTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { setModificationsEnabled(event.getProperty().getValue() != null); } private void setModificationsEnabled(boolean b) { Long id = IdentifiableUtil.getIdOfSelectedItem(beanTable); if ((id != null) && (b == true) && (isAccessAllowed(id) == false)) { b = false; } deleteButton.setEnabled(b); editButton.setEnabled(b); enableSpecificButton(b); } }); beanTable.setSizeFull(); beanTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { beanTable.select(event.getItemId()); } } }); HorizontalLayout toolbar = new HorizontalLayout(); Label title = new Label(getListPartTitle()); title.setSizeUndefined(); title.addStyleName("stdlistpart-text-title"); newButton = new Button("Ajouter"); newButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleAjouter(); } }); newButton.addStyleName(ChameleonTheme.BUTTON_BIG); deleteButton = new Button("Supprimer"); deleteButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleSupprimer(); } }); deleteButton.setEnabled(false); deleteButton.addStyleName(ChameleonTheme.BUTTON_BIG); editButton = new Button("Editer"); editButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleEditer(); } }); editButton.setEnabled(false); editButton.addStyleName(ChameleonTheme.BUTTON_BIG); searchField = new TextField(); searchField.setInputPrompt(getListPartInputPrompt()); searchField.addTextChangeListener(new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { textFilter = event.getText(); updateFilters(); } }); searchField.addStyleName(ChameleonTheme.TEXTFIELD_BIG); searchField.setWidth("50%"); toolbar.addComponent(newButton); toolbar.addComponent(deleteButton); toolbar.addComponent(editButton); addSpecificButton(toolbar); toolbar.addComponent(searchField); toolbar.setWidth("100%"); toolbar.setExpandRatio(searchField, 1); toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT); setMargin(true); setSpacing(true); addComponent(title); addComponent(toolbar); Component c = getExtraComponent(); if (c != null) { addComponent(c); } addComponent(beanTable); setExpandRatio(beanTable, 1); setSizeFull(); }
From source file:fr.amapj.view.engine.listpart.StandardListPart.java
License:Open Source License
private void buildMainArea() { // Lecture dans la base de donnes mcInfos = new BeanItemContainer<T>(beanClazz); // Bind it to a component cdesTable = createTable(mcInfos);/*from ww w . ja v a 2 s . com*/ drawTable(); cdesTable.setSelectable(true); cdesTable.setMultiSelect(multiSelect); cdesTable.setImmediate(true); // Activation ou desactivation des boutons delete et edit cdesTable.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (multiSelect) { Set s = (Set) event.getProperty().getValue(); buttonBarEditMode(s.size() > 0); } else { buttonBarEditMode(event.getProperty().getValue() != null); } } }); cdesTable.setSizeFull(); cdesTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (event.isDoubleClick()) { cdesTable.select(event.getItemId()); } } }); HorizontalLayout toolbar = new HorizontalLayout(); toolbar.addStyleName("buttonbar"); Label title2 = new Label(getTitle()); title2.setSizeUndefined(); title2.addStyleName("title"); drawButton(); for (ButtonHandler handler : buttons) { toolbar.addComponent(handler.button); } if (searchField != null) { toolbar.addComponent(searchField); toolbar.setWidth("100%"); toolbar.setExpandRatio(searchField, 1); toolbar.setComponentAlignment(searchField, Alignment.TOP_RIGHT); } addComponent(title2); addSelectorComponent(); addComponent(toolbar); addExtraComponent(); addComponent(cdesTable); setExpandRatio(cdesTable, 1); refreshTable(); }
From source file:fr.amapj.view.engine.popup.copypopup.CopyPopup.java
License:Open Source License
protected void createContent(VerticalLayout contentLayout) { // Calcul du texte a afficher String str = contentSupplier.get(); // Construction de la zone d'affichage du texte HorizontalLayout hlTexte = new HorizontalLayout(); hlTexte.setMargin(true);/*from w w w . jav a 2 s.c om*/ hlTexte.setSpacing(true); hlTexte.setWidth("100%"); TextArea listeMails = new TextArea(""); listeMails.setValue(str); listeMails.setReadOnly(true); listeMails.selectAll(); listeMails.setWidth("80%"); listeMails.setHeight(5, Unit.CM); hlTexte.addComponent(listeMails); hlTexte.setExpandRatio(listeMails, 1); hlTexte.setComponentAlignment(listeMails, Alignment.MIDDLE_CENTER); contentLayout.addComponent(hlTexte); }
From source file:fr.amapj.view.engine.popup.errorpopup.ErrorPopup.java
License:Open Source License
protected void createContent(VerticalLayout contentLayout) { setColorStyle(ColorStyle.RED);//w ww.ja v a 2 s . c o m // Message logg SessionParameters p = SessionManager.getSessionParameters(); String debugMessage = null; if (p != null) { debugMessage = p.userNom + " " + p.userPrenom + " a rencontr une erreur :" + message; p.incNbError(); } else { debugMessage = "Pas d'utilisateur encore logg. Erreur :" + message; } logger.info(debugMessage, throwable); String constraintInfo = getConstraintInfo(throwable); if (constraintInfo != null) { logger.info("Constraint Information:" + constraintInfo); } // Message utilisateur String msg = "Dsol, une erreur est survenue.<br/>"; if (message != null) { msg = msg + "Information supplmentaire:<br/>" + message + "<br/>"; } if (constraintInfo != null) { msg = msg + "<br/>" + constraintInfo + "<br/>"; } msg = msg + "Veuillez cliquer sur OK pour continuer<br/>"; // Construction de la zone de texte HorizontalLayout hlTexte = new HorizontalLayout(); hlTexte.setMargin(true); hlTexte.setSpacing(true); hlTexte.setWidth("100%"); Label textArea = new Label(msg, ContentMode.HTML); textArea.setStyleName(ChameleonTheme.TEXTFIELD_BIG); textArea.setWidth("80%"); hlTexte.addComponent(textArea); hlTexte.setExpandRatio(textArea, 1); hlTexte.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER); contentLayout.addComponent(hlTexte); }
From source file:fr.amapj.view.engine.popup.formpopup.AbstractFormPopup.java
License:Open Source License
protected Button addHelpButton(String title, String helpContent) { Button aide = new Button(title); aide.setIcon(FontAwesome.QUESTION_CIRCLE); aide.addStyleName("borderless-colored"); aide.addStyleName("question-mark"); aide.addClickListener(e -> handleAide(helpContent)); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth(100, Unit.PERCENTAGE);//from ww w . j a v a 2 s . c o m hl.addComponent(aide); hl.setComponentAlignment(aide, Alignment.MIDDLE_RIGHT); form.addComponent(hl); return aide; }