List of usage examples for com.vaadin.ui Button addStyleName
@Override public void addStyleName(String style)
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void fillTagEditor(final Database database, final AbstractLayout layout, final List<String> tags, final boolean allowRemove) { layout.removeAllComponents();// w w w . ja va 2 s . c o m for (int i = 0; i < tags.size(); i++) { String tag = tags.get(i); HorizontalLayout hl = new HorizontalLayout(); if (allowRemove) { final int index = i; 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) { tags.remove(index); fillTagEditor(database, layout, tags, allowRemove); } }); hl.addComponent(b); } Button tagButton = tagButton(database, "dialog", tag, i); hl.addComponent(tagButton); hl.setComponentAlignment(tagButton, Alignment.MIDDLE_LEFT); layout.addComponent(hl); } }
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
public static void manageIndicators(final Main main, final Base base) { String currentTime = main.getUIState().time; boolean showYears = currentTime.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); VerticalLayout content = new VerticalLayout(); content.setSizeFull();//from w w w .j av a 2 s .c om content.setSpacing(true); final Table table = new Table(); table.setSelectable(true); table.setMultiSelect(true); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_COMPACT); table.addContainerProperty("Indikaattori", Label.class, null); if (showYears) table.addContainerProperty("Vuosi", String.class, null); table.setWidth("100%"); table.setHeight("100%"); table.setNullSelectionAllowed(true); table.setEditable(false); table.setColumnExpandRatio("Indikaattori", 2.0f); if (showYears) table.setColumnExpandRatio("Vuosi", 0.0f); makeIndicatorTable(main, base, table); content.addComponent(table); content.setExpandRatio(table, 1.0f); abstract class IndicatorButtonListener implements Button.ClickListener { private static final long serialVersionUID = -7551250112503063540L; protected Indicator getPossibleSelection() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (selected.size() != 1) return null; return (Indicator) selected.iterator().next(); } @SuppressWarnings("unchecked") protected Collection<Indicator> getSelection() { return (Collection<Indicator>) table.getValue(); } protected Map<Base, List<Indicator>> getSelectionByParent(Database database) { return indicatorsByParent(database, getSelection()); } } final Button removeIndicators = new Button("Poista", new IndicatorButtonListener() { private static final long serialVersionUID = -2538054127519468282L; public void buttonClick(ClickEvent event) { Collection<Indicator> selection = getSelection(); for (Indicator i : selection) { Base owner = i.getOwner(database); if (owner == null) continue; owner.removeIndicator(i); } final Set<Base> bases = new HashSet<Base>(); final Strategiakartta map = database.getMap(base); bases.add(map); for (Tavoite t : map.tavoitteet) { bases.add(t); for (Painopiste p : t.painopisteet) { bases.add(p); } } for (Base b : bases) { for (Meter meter : b.getMeters(database)) { Indicator indicator = meter.getPossibleIndicator(database); if (selection.contains(indicator)) { b.removeMeter(meter); } } } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); removeIndicators.addStyleName(ValoTheme.BUTTON_TINY); final Button moveUp = new Button("Siirr ylemms", new IndicatorButtonListener() { private static final long serialVersionUID = -635232943884881464L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Indicator>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveIndicatorsUp(entry.getValue()); } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); moveUp.addStyleName(ValoTheme.BUTTON_TINY); final Button moveDown = new Button("Siirr alemmas", new IndicatorButtonListener() { private static final long serialVersionUID = 2779521990166604444L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Indicator>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveIndicatorsDown(entry.getValue()); } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); moveDown.addStyleName(ValoTheme.BUTTON_TINY); final Button modify = new Button("Mrit"); modify.addClickListener(new IndicatorButtonListener() { private static final long serialVersionUID = 5149432436059288486L; public void buttonClick(ClickEvent event) { Indicator indicator = getPossibleSelection(); if (indicator == null) return; editIndicator(main, base, indicator); } }); modify.addStyleName(ValoTheme.BUTTON_TINY); final TextField indicatorText = new TextField(); indicatorText.setWidth("100%"); indicatorText.addStyleName(ValoTheme.TEXTFIELD_TINY); indicatorText.setCaption("Tunniste"); List<Datatype> types = Datatype.enumerate(database); final ComboBox datatypeSelect = new ComboBox(); datatypeSelect.setWidth("100%"); datatypeSelect.setNullSelectionAllowed(false); datatypeSelect.addStyleName(ValoTheme.COMBOBOX_TINY); datatypeSelect.setCaption("Tietotyyppi"); for (Datatype dt : types) datatypeSelect.addItem(dt); final Button addIndicator = new Button("Lis ptasolle", new Button.ClickListener() { private static final long serialVersionUID = -2395147866745115337L; public void buttonClick(ClickEvent event) { String text = indicatorText.getValue(); Object dt = datatypeSelect.getValue(); if (text.isEmpty() || dt == null || dt.equals(datatypeSelect.getNullSelectionItemId())) return; base.addIndicator(Indicator.create(database, text, (Datatype) dt)); makeIndicatorTable(main, base, table); Updates.update(main, true); } }); addIndicator.addStyleName(ValoTheme.BUTTON_TINY); final Button addSubIndicator = new Button("Lis valitun alle", new IndicatorButtonListener() { private static final long serialVersionUID = -2395147866745115337L; public void buttonClick(ClickEvent event) { Indicator indicator = getPossibleSelection(); if (indicator == null) return; String text = indicatorText.getValue(); Object dt = datatypeSelect.getValue(); if (text.isEmpty() || dt == null || dt.equals(datatypeSelect.getNullSelectionItemId())) return; indicator.addIndicator(Indicator.create(database, text, (Datatype) dt)); makeIndicatorTable(main, base, table); Updates.update(main, true); } }); addSubIndicator.addStyleName(ValoTheme.BUTTON_TINY); final Runnable setStates = new Runnable() { @Override public void run() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (!selected.isEmpty()) { removeIndicators.setEnabled(true); moveUp.setEnabled(true); moveDown.setEnabled(true); if (selected.size() == 1) { modify.setEnabled(true); addSubIndicator.setEnabled(true); } else { addSubIndicator.setEnabled(false); modify.setEnabled(false); } } else { moveUp.setEnabled(false); moveDown.setEnabled(false); removeIndicators.setEnabled(false); addSubIndicator.setEnabled(false); modify.setEnabled(false); } } }; table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1188285609779556446L; @Override public void valueChange(ValueChangeEvent event) { setStates.run(); } }); setStates.run(); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.setWidthUndefined(); hl2.addComponent(modify); hl2.setComponentAlignment(modify, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(modify, 0.0f); hl2.addComponent(removeIndicators); hl2.setComponentAlignment(removeIndicators, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(removeIndicators, 0.0f); hl2.addComponent(moveUp); hl2.setComponentAlignment(moveUp, Alignment.TOP_LEFT); hl2.setExpandRatio(moveUp, 0.0f); hl2.addComponent(moveDown); hl2.setComponentAlignment(moveDown, Alignment.TOP_LEFT); hl2.setExpandRatio(moveDown, 0.0f); HorizontalLayout hl3 = new HorizontalLayout(); hl3.setSpacing(true); hl3.setWidth("100%"); hl3.addComponent(addIndicator); hl3.setComponentAlignment(addIndicator, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addIndicator, 0.0f); hl3.addComponent(addSubIndicator); hl3.setComponentAlignment(addSubIndicator, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addSubIndicator, 0.0f); hl3.addComponent(indicatorText); hl3.setComponentAlignment(indicatorText, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(indicatorText, 1.0f); hl3.addComponent(datatypeSelect); hl3.setComponentAlignment(datatypeSelect, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(datatypeSelect, 2.0f); content.addComponent(hl2); content.setComponentAlignment(hl2, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl2, 0.0f); content.addComponent(hl3); content.setComponentAlignment(hl3, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl3, 0.0f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); final Window dialog = Dialogs.makeDialog(main, "650px", "800px", "Hallitse indikaattoreita", "Sulje", content, buttons); }
From source file:fi.semantum.strategia.widget.Meter.java
License:Open Source License
public static void manageMeters(final Main main, final Base base) { String currentTime = main.getUIState().time; boolean showYears = currentTime.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); VerticalLayout content = new VerticalLayout(); content.setSizeFull();//from ww w.j a v a2s .c o m content.setSpacing(true); final Table table = new Table(); table.setSelectable(true); table.setMultiSelect(true); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_COMPACT); table.addContainerProperty("Mittari", Label.class, null); if (showYears) table.addContainerProperty("Vuosi", String.class, null); table.setWidth("100%"); table.setHeight("100%"); table.setNullSelectionAllowed(true); table.setEditable(false); table.setColumnExpandRatio("Mittari", 2.0f); if (showYears) table.setColumnExpandRatio("Vuosi", 0.0f); makeMeterTable(main, base, table); content.addComponent(table); content.setExpandRatio(table, 1.0f); abstract class MeterButtonListener implements Button.ClickListener { private static final long serialVersionUID = -6640950006518632633L; protected Meter getPossibleSelection() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (selected.size() != 1) return null; return (Meter) selected.iterator().next(); } @SuppressWarnings("unchecked") protected Collection<Meter> getSelection() { return (Collection<Meter>) table.getValue(); } protected Map<Base, List<Meter>> getSelectionByParent(Database database) { return metersByParent(database, getSelection()); } } final Button removeMeters = new Button("Poista", new MeterButtonListener() { private static final long serialVersionUID = 2957964892664902859L; public void buttonClick(ClickEvent event) { for (Meter r : getSelection()) { Base owner = r.getOwner(database); if (owner != null) owner.removeMeter(r); } makeMeterTable(main, base, table); Updates.update(main, true); } }); removeMeters.addStyleName(ValoTheme.BUTTON_TINY); final Button moveUp = new Button("Siirr ylemms", new MeterButtonListener() { private static final long serialVersionUID = 8434251773337788784L; public void buttonClick(ClickEvent event) { Map<Base, List<Meter>> sel = getSelectionByParent(database); if (sel == null) return; for (Map.Entry<Base, List<Meter>> entry : sel.entrySet()) { entry.getKey().moveMetersUp(entry.getValue()); } makeMeterTable(main, base, table); Updates.update(main, true); } }); moveUp.addStyleName(ValoTheme.BUTTON_TINY); final Button moveDown = new Button("Siirr alemmas", new MeterButtonListener() { private static final long serialVersionUID = -5382367112305541842L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Meter>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveMetersDown(entry.getValue()); } makeMeterTable(main, base, table); Updates.update(main, true); } }); moveDown.addStyleName(ValoTheme.BUTTON_TINY); final Button modify = new Button("Mrit"); modify.addClickListener(new MeterButtonListener() { private static final long serialVersionUID = -7109999546516429095L; public void buttonClick(ClickEvent event) { Meter meter = getPossibleSelection(); if (meter == null) return; editMeter(main, base, meter); } }); modify.addStyleName(ValoTheme.BUTTON_TINY); final ComboBox indicatorSelect = new ComboBox(); indicatorSelect.setWidth("100%"); indicatorSelect.setNullSelectionAllowed(false); indicatorSelect.addStyleName(ValoTheme.COMBOBOX_TINY); indicatorSelect.setCaption("Mrittj"); final Strategiakartta map = database.getMap(base); // Indikaattorit for (Indicator i : map.getIndicators(database)) { MeterSpec spec = new MeterSpec(database, i); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } // Enumeraatiot for (Datatype enu : Datatype.enumerate(database)) { if (enu instanceof EnumerationDatatype) { MeterSpec spec = new MeterSpec(database, enu); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } } // Sisnrakennetut { MeterSpec spec = new MeterSpec(database, MeterSpec.IMPLEMENTATION); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } indicatorSelect.setTextInputAllowed(false); final Button addMeter = new Button("Lis ptasolle", new Button.ClickListener() { private static final long serialVersionUID = -5178621686299637238L; public void buttonClick(ClickEvent event) { MeterSpec spec = (MeterSpec) indicatorSelect.getValue(); Object source = spec.getSource(); if (source instanceof Indicator) { Indicator ind = (Indicator) source; Meter.addIndicatorMeter(main, base, ind, Property.AIKAVALI_KAIKKI); } else if (source instanceof EnumerationDatatype) { EnumerationDatatype dt = (EnumerationDatatype) source; Indicator ind = Indicator.create(database, "Uusi " + dt.getId(database), dt); ind.update(main, base, dt.getDefaultValue(), false, "", "Alkuarvo"); ind.update(main, base, dt.getDefaultForecast(), true, "", "Alkuarvo"); Meter.addIndicatorMeter(main, base, ind, Property.AIKAVALI_KAIKKI); } makeMeterTable(main, base, table); Updates.update(main, true); } }); addMeter.addStyleName(ValoTheme.BUTTON_TINY); final Button addSubmeter = new Button("Lis valitun alle", new MeterButtonListener() { private static final long serialVersionUID = -1250285092312682737L; public void buttonClick(ClickEvent event) { Meter meter = getPossibleSelection(); if (meter == null) return; MeterSpec spec = (MeterSpec) indicatorSelect.getValue(); Object source = spec.getSource(); if (source instanceof Indicator) { Indicator ind = (Indicator) source; Meter.addIndicatorMeter(main, meter, ind, Property.AIKAVALI_KAIKKI); } else if (source instanceof EnumerationDatatype) { EnumerationDatatype dt = (EnumerationDatatype) source; Indicator ind = Indicator.create(database, "Uusi " + dt.getId(database), dt); ind.update(main, base, dt.getDefaultValue(), false, "", "Alkuarvo"); ind.update(main, base, dt.getDefaultForecast(), true, "", "Alkuarvo"); Meter.addIndicatorMeter(main, meter, ind, Property.AIKAVALI_KAIKKI); } makeMeterTable(main, base, table); Updates.update(main, true); } }); addSubmeter.addStyleName(ValoTheme.BUTTON_TINY); final Runnable setStates = new Runnable() { @Override public void run() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (!selected.isEmpty()) { removeMeters.setEnabled(true); moveUp.setEnabled(true); moveDown.setEnabled(true); if (selected.size() == 1) { modify.setEnabled(true); addSubmeter.setEnabled(true); } else { addSubmeter.setEnabled(false); modify.setEnabled(false); } } else { moveUp.setEnabled(false); moveDown.setEnabled(false); removeMeters.setEnabled(false); addSubmeter.setEnabled(false); modify.setEnabled(false); } } }; table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 6439090862804667322L; @Override public void valueChange(ValueChangeEvent event) { setStates.run(); } }); setStates.run(); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.setWidthUndefined(); hl2.addComponent(modify); hl2.setComponentAlignment(modify, Alignment.TOP_LEFT); hl2.setExpandRatio(modify, 0.0f); hl2.addComponent(removeMeters); hl2.setComponentAlignment(removeMeters, Alignment.TOP_LEFT); hl2.setExpandRatio(removeMeters, 0.0f); hl2.addComponent(moveUp); hl2.setComponentAlignment(moveUp, Alignment.TOP_LEFT); hl2.setExpandRatio(moveUp, 0.0f); hl2.addComponent(moveDown); hl2.setComponentAlignment(moveDown, Alignment.TOP_LEFT); hl2.setExpandRatio(moveDown, 0.0f); HorizontalLayout hl3 = new HorizontalLayout(); hl3.setSpacing(true); hl3.setWidth("100%"); hl3.addComponent(addMeter); hl3.setComponentAlignment(addMeter, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addMeter, 0.0f); hl3.addComponent(addSubmeter); hl3.setComponentAlignment(addSubmeter, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addSubmeter, 0.0f); hl3.addComponent(indicatorSelect); hl3.setComponentAlignment(indicatorSelect, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(indicatorSelect, 1.0f); content.addComponent(hl2); content.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); content.setExpandRatio(hl2, 0.0f); content.addComponent(hl3); content.setComponentAlignment(hl3, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl3, 0.0f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); final Window dialog = Dialogs.makeDialog(main, "450px", "600px", "Hallitse mittareita", "Sulje", content, buttons); }
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);/* w w w .j a va 2 s . 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;/*ww w. j av a 2 s.c o 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:fr.amapj.view.engine.enumselector.EnumSearcher.java
License:Open Source License
/** * Permet de crer une combo box permettant de choisir parmi une liste de Enum * avec possibilit d'indiquer comment afficher les libelles * /*from w w w.ja va 2 s. c o m*/ * @param binder * @param title * @param enumeration donne la liste afficher * @param propertyId * @return */ static public <T extends Enum<T>> HorizontalLayout createEnumSearcher(FieldGroup binder, String title, String propertyId, T... enumsToExcludes) { Class<T> enumeration = binder.getItemDataSource().getItemProperty(propertyId).getType(); if (enumeration.isEnum() == false) { throw new AmapjRuntimeException("Le champ " + title + " n'est pas de type enum"); } HelpInfo metaData = MetaDataEnum.getHelpInfo(enumeration); ComboBox comboBox = new ComboBox(); comboBox.setWidth("300px"); EnumSet<T> enums = EnumSet.allOf(enumeration); for (T en : enums) { if (isAllowed(en, enumsToExcludes)) { String caption = getCaption(metaData, en); comboBox.addItem(en); comboBox.setItemCaption(en, caption); } } binder.bind(comboBox, propertyId); comboBox.setImmediate(true); HorizontalLayout hl = new HorizontalLayout(); hl.setCaption(title); hl.addComponent(comboBox); if (metaData != null) { Button aide = new Button(); aide.setIcon(FontAwesome.QUESTION_CIRCLE); aide.addStyleName("borderless-colored"); aide.addStyleName("question-mark"); aide.addClickListener(e -> handleAide(metaData)); hl.addComponent(aide); } return hl; }
From source file:fr.amapj.view.engine.grid.currencyvector.PopupCurrencyVector.java
License:Open Source License
protected void createButtonBar() { if (param.readOnly) { Button ok = addDefaultButton("OK", new Button.ClickListener() { @Override/*from w ww.j av a2s. co m*/ public void buttonClick(ClickEvent event) { handleAnnuler(); } }); ok.addStyleName("primary"); } else { if (param.nbLig > 2) { Button copierButton = addButton("Copier la 1re ligne partout", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleCopier(); } }); setButtonAlignement(copierButton, Alignment.TOP_LEFT); } Button cancelButton = addButton("Annuler", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleAnnuler(); } }); Button saveButton = addDefaultButton("Sauvegarder", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { handleSauvegarder(); } }); saveButton.addStyleName("primary"); } }
From source file:fr.amapj.view.engine.grid.integergrid.PopupIntegerGrid.java
License:Open Source License
protected void createButtonBar() { if (param.readOnly) { Button ok = addDefaultButton("Continuer ...", e -> handleContinuer()); } else {/*from w w w .j a v a 2 s .c o m*/ if ((param.buttonCopyFirstLine == true) && (param.nbLig > 1)) { Button copierButton = addButton("Copier la 1re ligne partout", e -> handleCopier()); setButtonAlignement(copierButton, Alignment.TOP_LEFT); } Button cancelButton = addButton("Annuler", e -> handleAnnuler()); Button saveButton = addDefaultButton("Continuer ...", e -> handleSauvegarder()); saveButton.addStyleName("primary"); } }
From source file:fr.amapj.view.engine.menu.MenuPart.java
License:Open Source License
private CssLayout buildMenu(CssLayout menu, CssLayout menuItemsLayout, List<MenuDescription> allMenus, Navigator navigator, AmapUI ui) { final HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName("valo-menu-title"); menu.addComponent(top);//from ww w.jav a2s .c o m final Button showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { if (menu.getStyleName().contains("valo-menu-visible")) { menu.removeStyleName("valo-menu-visible"); } else { menu.addStyleName("valo-menu-visible"); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName("valo-menu-toggle"); showMenu.setIcon(FontAwesome.LIST); menu.addComponent(showMenu); String nomAmap = new ParametresService().getParametres().nomAmap; Label title = new Label("<h2>" + nomAmap + "</h2>", ContentMode.HTML); title.setSizeUndefined(); top.addComponent(title); top.setExpandRatio(title, 1); final MenuBar settings = new MenuBar(); settings.addStyleName("user-menu"); SessionParameters p = SessionManager.getSessionParameters(); MenuItem settingsItem = settings.addItem(p.userPrenom + " " + p.userNom, null, null); settingsItem.addItem("Se dconnecter", new MenuBar.Command() { @Override public void menuSelected(MenuItem selectedItem) { new PasswordManager().disconnect(); ui.buildLoginView(null, null, null); } }); menu.addComponent(settings); menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); boolean first = true; String firstEntry = null; Button firstButton = null; for (MenuDescription menuDescription : allMenus) { final String view = menuDescription.getMenuName().name().toLowerCase(); final String titleView = menuDescription.getMenuName().getTitle(); if (menuDescription.getCategorie() != null) { Label l = new Label(menuDescription.getCategorie(), ContentMode.HTML); l.setPrimaryStyleName("valo-menu-subtitle"); l.addStyleName("h4"); l.setSizeUndefined(); menuItemsLayout.addComponent(l); } final Button b = new Button(titleView, new ClickListener() { @Override public void buttonClick(final ClickEvent event) { setSelected(event.getButton(), menuItemsLayout); navigator.navigateTo("/" + view); } }); b.setId("amapj.menu." + view); b.setHtmlContentAllowed(true); b.setPrimaryStyleName("valo-menu-item"); b.setIcon(menuDescription.getMenuName().getFont()); menuItemsLayout.addComponent(b); viewNameToMenuButton.put("/" + view, b); if (first) { first = false; firstButton = b; firstEntry = view; } } // Gestion de l'url String f = Page.getCurrent().getUriFragment(); if (f != null && f.startsWith("!")) { f = f.substring(1); } if (f == null || f.equals("") || f.equals("/")) { navigateWithProtect(navigator, "/" + firstEntry); setSelected(firstButton, menuItemsLayout); } else { navigateWithProtect(navigator, f); setSelected(viewNameToMenuButton.get(f), menuItemsLayout); } return menu; }
From source file:fr.amapj.view.engine.menu.MenuPart.java
License:Open Source License
/** * /*from ww w . j ava2 s .c o m*/ * @param viewName du style /xxxx */ private void setSelected(Button b, CssLayout menuItemsLayout) { for (final Iterator<Component> it = menuItemsLayout.iterator(); it.hasNext();) { it.next().removeStyleName("selected"); } // b peut etre null dans le cas du error view provider if (b != null) { b.addStyleName("selected"); } }