List of usage examples for com.vaadin.ui Button getData
public Object getData()
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.ImpactAnalysisFormLayout.java
License:Mozilla Public License
private void createPagebar(final List<Set> dependentInstances, final Panel searchResultPanel, final int resultSize) { int numPages = resultSize / PAGE_SIZE; if (resultSize % PAGE_SIZE > 0) { numPages++;/*from w w w . ja v a2s . c om*/ } final HorizontalLayout hl = new HorizontalLayout(); for (int n = 0; n < numPages; n++) { final Button linkBtn = new Button("" + (n + 1)); linkBtn.setData(n); linkBtn.setStyleName("link"); linkBtn.setWidth("10px"); linkBtn.addListener(new Button.ClickListener() { public void buttonClick(final Button.ClickEvent event) { //reset pageIndex pageIndex = (Integer) linkBtn.getData(); //rebuild page rebuildPage(dependentInstances, searchResultPanel, pageIndex); } }); hl.addComponent(linkBtn); } searchResultPanel.addComponent(hl); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java
License:Mozilla Public License
private void createPagebar(final Panel searchResultPanel, final int resultSize) { int numPages = resultSize / PAGE_SIZE; if (resultSize % PAGE_SIZE > 0) { numPages++;//from w w w . j av a2 s . c o m } final HorizontalLayout hl = new HorizontalLayout(); for (int n = 0; n < numPages; n++) { final Button linkBtn = new Button("" + (n + 1)); linkBtn.setData(n); linkBtn.setStyleName("link"); linkBtn.setWidth("15px"); linkBtn.addListener(new Button.ClickListener() { public void buttonClick(final Button.ClickEvent event) { //reset pageIndex pageIndex = (Integer) linkBtn.getData(); //rebuild page rebuildPage(searchResultPanel, pageIndex); } }); hl.addComponent(linkBtn); } searchResultPanel.addComponent(hl); }
From source file:org.sensorhub.ui.GenericConfigForm.java
License:Mozilla Public License
protected void addChangeModuleButton(final ComponentContainer parentForm, final String propId, final ComplexProperty prop, final Class<?> objectType) { final Button chgButton = new Button("Modify"); //chgButton.addStyleName(STYLE_QUIET); chgButton.addStyleName(STYLE_SMALL); chgButton.addStyleName(STYLE_SECTION_BUTTONS); chgButton.setIcon(REFRESH_ICON);//from w w w. j a va2 s. c om chgButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { // show popup to select among available module types ModuleTypeSelectionPopup popup = new ModuleTypeSelectionPopup(objectType, new ModuleTypeSelectionCallback() { public void configSelected(Class<?> moduleType, ModuleConfig config) { // regenerate form config.id = null; config.name = null; MyBeanItem<Object> newItem = new MyBeanItem<Object>(config, propId + "."); prop.setValue(newItem); IModuleConfigForm newForm = AdminUI.getInstance().generateForm(config.getClass()); newForm.build(propId, prop); ((VerticalLayout) newForm).addComponent(chgButton, 0); // replace old form in UI allForms.add(newForm); allForms.remove((IModuleConfigForm) chgButton.getData()); replaceComponent((Component) chgButton.getData(), newForm); chgButton.setData(newForm); } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } }); chgButton.setData(parentForm); ((VerticalLayout) parentForm).addComponent(chgButton, 0); }
From source file:org.sensorhub.ui.GenericConfigForm.java
License:Mozilla Public License
protected void addChangeObjectButton(final ComponentContainer parentForm, final String propId, final ComplexProperty prop, final Map<String, Class<?>> typeList) { final Button chgButton = new Button("Modify"); //chgButton.addStyleName(STYLE_QUIET); chgButton.addStyleName(STYLE_SMALL); chgButton.addStyleName(STYLE_SECTION_BUTTONS); chgButton.setIcon(REFRESH_ICON);/* w w w . j a v a2s. c o m*/ chgButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { // show popup to select among available module types ObjectTypeSelectionPopup popup = new ObjectTypeSelectionPopup("Select Type", typeList, new ObjectTypeSelectionCallback() { public void typeSelected(Class<?> objectType) { try { // regenerate form MyBeanItem<Object> newItem = new MyBeanItem<Object>(objectType.newInstance(), propId + "."); prop.setValue(newItem); IModuleConfigForm newForm = AdminUI.getInstance().generateForm(objectType); newForm.build(propId, prop); ((VerticalLayout) newForm).addComponent(chgButton, 0); // replace old form in UI allForms.add(newForm); allForms.remove((IModuleConfigForm) chgButton.getData()); replaceComponent((Component) chgButton.getData(), newForm); chgButton.setData(newForm); } catch (Exception e) { Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } }); chgButton.setData(parentForm); ((VerticalLayout) parentForm).addComponent(chgButton, 0); }
From source file:uicomponents.SummaryTable.java
License:Open Source License
public void initTable(List<AOpenbisSample> samples, LabelingMethod labelingMethod) { if (labelingMethod != null) { this.labelingMethod = labelingMethod; isotopes = true;/*ww w. j a va 2 s.c om*/ } table.setStyleName(Styles.tableTheme); // table.addContainerProperty("ID", String.class, null); // table.setColumnWidth("ID", 35); table.addContainerProperty("Secondary Name", TextField.class, null); table.addContainerProperty("External DB ID", TextField.class, null); table.setColumnWidth("External DB ID", 106); table.setImmediate(true); table.setCaption(samples.size() + " " + name); if (isotopes) table.addContainerProperty(labelingMethod.getName(), ComboBox.class, null); List<String> factorLabels = new ArrayList<String>(); int maxCols = 0; AOpenbisSample mostInformative = samples.get(0); for (AOpenbisSample s : samples) { int size = s.getFactors().size(); if (size > maxCols) { maxCols = size; mostInformative = s; } } List<Property> factors = mostInformative.getFactors(); for (int i = 0; i < factors.size(); i++) { String l = factors.get(i).getLabel(); int j = 2; while (factorLabels.contains(l)) { l = factors.get(i).getLabel() + " (" + Integer.toString(j) + ")"; j++; } factorLabels.add(l); table.addContainerProperty(l, String.class, null); } table.addContainerProperty("Customize", Button.class, null); table.setColumnWidth("Customize", 85); List<String> reagents = null; if (isotopes) reagents = labelingMethod.getReagents(); int i = -1; for (AOpenbisSample s : samples) { i++; // AOpenbisSample s = samples.get(i); // Obje id = Integer.toString(i); // map.put(id, s); // The Table item identifier for the row. // Integer itemId = new Integer(i); // Create a button and handle its click. Button delete = new Button(); Styles.iconButton(delete, FontAwesome.TRASH_O); // delete.setWidth("15px"); // delete.setHeight("30px"); delete.setData(s); delete.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 5414603256990177472L; @Override public void buttonClick(ClickEvent event) { Button b = event.getButton(); Object iid = b.getData(); TextField secNameField = (TextField) table.getItem(iid).getItemProperty("Secondary Name") .getValue(); TextField extIDField = (TextField) table.getItem(iid).getItemProperty("External DB ID") .getValue(); if (secNameField.getValue().equals("DELETED")) { secNameField.setReadOnly(false); extIDField.setReadOnly(false); // String id = (String) table.getItem(iid).getItemProperty("ID").getValue(); secNameField.setValue(s.getQ_SECONDARY_NAME()); extIDField.setValue(s.getQ_EXTERNALDB_ID()); b.setIcon(FontAwesome.TRASH_O); } else { secNameField.setValue("DELETED"); secNameField.setReadOnly(true); extIDField.setValue("DELETED"); extIDField.setReadOnly(true); b.setIcon(FontAwesome.UNDO); } } }); // Create the table row. List<Object> row = new ArrayList<Object>(); TextField secNameField = new StandardTextField(); secNameField.setImmediate(true); String secName = ""; if (s.getQ_SECONDARY_NAME() != null) secName = s.getQ_SECONDARY_NAME(); secNameField.setValue(secName); row.add(secNameField); TextField extIDField = new StandardTextField(); extIDField.setWidth("95px"); extIDField.setImmediate(true); String extID = ""; if (s.getQ_EXTERNALDB_ID() != null) extID = s.getQ_EXTERNALDB_ID(); extIDField.setValue(extID); row.add(extIDField); if (isotopes) { ComboBox cb = new ComboBox(); cb.setImmediate(true); cb.addItems(reagents); cb.select(reagents.get(i % reagents.size())); row.add(cb); } int missing = maxCols - s.getFactors().size(); for (Property f : s.getFactors()) { String v = f.getValue(); if (f.hasUnit()) v += " " + f.getUnit(); row.add(v); } for (int j = 0; j < missing; j++) row.add(""); row.add(delete); table.addItem(row.toArray(new Object[row.size()]), s); } }
From source file:views.MultiAffiliationTab.java
License:Open Source License
public void addDataToTable(List<Person> personsWithAffiliations) { for (Person p : personsWithAffiliations) { // String title = p.getTitle(); // String first = p.getFirst(); // String last = p.getLast(); Map<Integer, RoleAt> map = p.getAffiliationInfos(); for (Integer i : p.getAffiliationInfos().keySet()) { personAffiliationsInTable.put(i, p); String affiliation = map.get(i).getAffiliation(); String role = map.get(i).getRole(); List<Object> row = new ArrayList<Object>(); // row.add(title); // row.add(first); // row.add(last); row.add(affiliation);//w w w. j a v a2 s . c o m ComboBox roleInput = new ComboBox("", availableRoles); roleInput.setStyleName(ValoTheme.COMBOBOX_SMALL); roleInput.setValue(role); row.add(roleInput); Button delete = new Button("Remove"); row.add(delete); delete.setData(i); delete.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 5414693256990177472L; @Override public void buttonClick(ClickEvent event) { Button b = event.getButton(); Integer iid = (Integer) b.getData(); table.removeItem(iid); table.setPageLength(table.size()); personAffiliationsInTable.remove(iid); } }); table.addItem(row.toArray(), i); } } table.setPageLength(table.size()); }