List of usage examples for com.vaadin.ui GridLayout setMargin
@Override public void setMargin(MarginInfo marginInfo)
From source file:at.peppol.webgui.app.components.TabInvoiceHeader.java
License:Mozilla Public License
private void initElements() { additionalDocRefList = parent.getInvoice().getAdditionalDocumentReference(); setWidth("100%"); setHeight("100%"); //final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); //outerLayout.setMargin(true); //outerLayout.setSpacing(true); //grid that contains "Details", "Contract", "Order" final GridLayout topGridLayout = new GridLayout(2, 2); //topGridLayout.setSizeFull(); topGridLayout.setMargin(true); topGridLayout.setSpacing(true);/* www. j a v a2 s . co m*/ hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true); hiddenContent.setMargin(true); final Panel outerPanel = new Panel("Invoice Header"); //outerPanel.addComponent(grid); outerPanel.setScrollable(true); outerPanel.setContent(outerLayout); //outerLayout.addComponent(outerPanel); VerticalLayout tabLayout = new VerticalLayout(); tabLayout.addComponent(outerPanel); outerLayout.addComponent(topGridLayout); final Panel invoiceDetailsPanel = new Panel("Invoice Header Details"); invoiceDetailsPanel.setStyleName("light"); invoiceDetailsPanel.setWidth("50%"); //invoiceDetailsPanel.setSizeFull(); invoiceDetailsPanel.addComponent(createInvoiceTopForm()); topGridLayout.addComponent(invoiceDetailsPanel, 0, 0); final Panel orderReferencePanel = new Panel("Referencing Order"); orderReferencePanel.setStyleName("light"); orderReferencePanel.setWidth("50%"); //orderReferencePanel.setSizeFull(); orderReferencePanel.addComponent(createInvoiceOrderReferenceForm()); topGridLayout.addComponent(orderReferencePanel, 0, 1); final VerticalLayout tableVerticalLayout = new VerticalLayout(); //tableVerticalLayout.setSpacing (true); tableVerticalLayout.setMargin(true); outerLayout.addComponent(tableVerticalLayout); table = new InvoiceAdditionalDocRefTable(parent.getInvoice().getAdditionalDocumentReference()); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setSizeFull(); //table.setWidth("300px"); table.setFooterVisible(false); table.addStyleName("striped strong"); Panel tablePanel = new Panel("Relevant Documents"); tablePanel.setStyleName("light"); tablePanel.setWidth("60%"); tableVerticalLayout.addComponent(tablePanel); GridLayout h = new GridLayout(2, 2); h.setMargin(true); h.setSpacing(true); tablePanel.setContent(h); h.addComponent(table, 0, 0); h.setColumnExpandRatio(0, 3); h.setColumnExpandRatio(1, 1); h.setSizeFull(); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceAdditionalDocRefTableEditor editor = new InvoiceAdditionalDocRefTableEditor(editMode); Label label = new Label("<h3>Adding new relevant document</h3>", Label.CONTENT_XHTML); addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table, additionalDocRefList, label)); label = new Label("<h3>Edit relevant document</h3>", Label.CONTENT_XHTML); editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table, additionalDocRefList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); final Button addContractReferenceBtn = new Button("Add Contract Reference"); final Button removeContractReferenceBtn = new Button("Remove Contract Reference"); removeContractReferenceBtn.setVisible(false); addContractReferenceBtn.setStyleName("marginLeft"); removeContractReferenceBtn.setStyleName("marginLeft"); addContractReferenceBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Panel panel = createInvoiceContractReference(removeContractReferenceBtn); topGridLayout.removeComponent(1, 0); topGridLayout.addComponent(panel, 1, 0); removeContractReferenceBtn.setVisible(true); } }); removeContractReferenceBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //remove the legal entity component panel Component c = removeContractReferenceBtn.getParent().getParent(); topGridLayout.removeComponent(c); if (parent.getInvoice().getContractDocumentReference().size() > 0) { //parent.getInvoice().getContractDocumentReference().remove(0); parent.getInvoice().getContractDocumentReference().clear(); ValidatorsList.removeListeners(Utils.getFieldListeners(contractReferenceForm)); } topGridLayout.addComponent(addContractReferenceBtn, 1, 0); } }); h.addComponent(buttonsContainer, 1, 0); topGridLayout.addComponent(addContractReferenceBtn, 1, 0); if (parent.getInvoice().getContractDocumentReference().size() > 0) addContractReferenceBtn.click(); // ---- HIDDEN FORM BEGINS ----- VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); h.addComponent(formLayout, 0, 1); // ---- HIDDEN FORM ENDS ----- setLayout(tabLayout); }
From source file:biz.eelis.translation.EntriesFlowlet.java
License:Apache License
@Override public void initialize() { final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); filterDefinitions.add(new FilterDescriptor("basename", "basename", "Basename", new TextField(), 200, "like", String.class, "")); filterDefinitions.add(new FilterDescriptor("language", "language", "Language", new TextField(), 30, "=", String.class, "")); filterDefinitions.add(//from www . j a v a2 s. c o m new FilterDescriptor("country", "country", "Country", new TextField(), 30, "=", String.class, "")); filterDefinitions .add(new FilterDescriptor("key", "key", "Key", new TextField(), 200, "like", String.class, "")); final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); ContainerUtil.addContainerProperties(container, fieldDescriptors); final GridLayout gridLayout = new GridLayout(1, 2); gridLayout.setSizeFull(); gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(1, 1f); setViewContent(gridLayout); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setSizeUndefined(); gridLayout.addComponent(buttonLayout, 0, 0); final Table table = new FormattingTable(); grid = new Grid(table, container); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); gridLayout.addComponent(grid, 0, 1); final Button addButton = getSite().getButton("add"); buttonLayout.addComponent(addButton); addButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entry = new Entry(); entry.setCreated(new Date()); entry.setModified(entry.getCreated()); entry.setOwner((Company) getSite().getSiteContext().getObject(Company.class)); final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class); entryView.edit(entry, true); } }); final Button editButton = getSite().getButton("edit"); buttonLayout.addComponent(editButton); editButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { final Entry entity = container.getEntity(grid.getSelectedItemId()); final EntryFlowlet entryView = getViewSheet().forward(EntryFlowlet.class); entryView.edit(entity, false); } }); final Button removeButton = getSite().getButton("remove"); buttonLayout.addComponent(removeButton); removeButton.addClickListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { container.removeItem(grid.getSelectedItemId()); container.commit(); } }); final Company company = getSite().getSiteContext().getObject(Company.class); container.removeDefaultFilters(); container.addDefaultFilter(new Compare.Equal("owner.companyId", company.getCompanyId())); grid.refresh(); }
From source file:biz.eelis.translation.EntryFlowlet.java
License:Apache License
@Override public void initialize() { entityManager = getSite().getSiteContext().getObject(EntityManager.class); final GridLayout gridLayout = new GridLayout(1, 3); gridLayout.setSizeFull();/*from w w w. ja va2 s .com*/ gridLayout.setMargin(false); gridLayout.setSpacing(true); gridLayout.setRowExpandRatio(2, 1f); setViewContent(gridLayout); entryEditor = new ValidatingEditor(TranslationSiteFields.getFieldDescriptors(Entry.class)); entryEditor.setCaption("Entry"); entryEditor.addListener((ValidatingEditorStateListener) this); gridLayout.addComponent(entryEditor, 0, 0); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); gridLayout.addComponent(buttonLayout, 0, 1); saveButton = new Button("Save"); saveButton.setImmediate(true); buttonLayout.addComponent(saveButton); saveButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { entryEditor.commit(); entityManager.getTransaction().begin(); try { entity = entityManager.merge(entity); entity.setAuthor(getSite().getSecurityProvider().getUser()); entity.setModified(new Date()); entityManager.persist(entity); entityManager.getTransaction().commit(); entityManager.detach(entity); entryEditor.discard(); container.refresh(); } catch (final Throwable t) { if (entityManager.getTransaction().isActive()) { entityManager.getTransaction().rollback(); } throw new RuntimeException("Failed to save entity: " + entity, t); } } }); discardButton = new Button("Discard"); discardButton.setImmediate(true); buttonLayout.addComponent(discardButton); discardButton.addListener(new ClickListener() { /** Serial version UID. */ private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { entryEditor.discard(); } }); final List<FieldDescriptor> fieldDescriptors = TranslationSiteFields.getFieldDescriptors(Entry.class); final List<FilterDescriptor> filterDefinitions = new ArrayList<FilterDescriptor>(); container = new LazyEntityContainer<Entry>(entityManager, true, true, false, Entry.class, 1000, new String[] { "basename", "key", "language", "country" }, new boolean[] { true, true, true, true }, "entryId"); container.getQueryView().getQueryDefinition().setMaxQuerySize(1); ContainerUtil.addContainerProperties(container, fieldDescriptors); final Table table = new FormattingTable(); final Grid grid = new Grid(table, container); grid.setCaption("All Translations"); grid.setSizeFull(); grid.setFields(fieldDescriptors); grid.setFilters(filterDefinitions); table.setColumnCollapsed("entryId", true); table.setColumnCollapsed("path", true); table.setColumnCollapsed("created", true); table.setColumnCollapsed("modified", true); gridLayout.addComponent(grid, 0, 2); }
From source file:ch.bfh.ti.soed.hs16.srs.purple.view.ReservationView.java
License:Open Source License
/** * Shows the popup window where a reservation can be modified, deleted or inserted * @param res The Reservation Object (for a new reservation, fill the startDate with the current Timestamp!) */// w w w . ja v a2s . com @SuppressWarnings("serial") private void showPopup(Reservation res) { this.res = res; //Update the member boolean newRes = res.getReservationID() > 0 ? false : true; boolean isHost = isHost(actualUser, res.getHostList()); boolean isParticipant = isHost(actualUser, res.getParticipantList()); final GridLayout gridLayout = new GridLayout(3, 5); ValueChangeListener vcl = new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()), new Timestamp(endDate.getValue().getTime())); if (ReservationView.this.res.getReservationID() > 0) { System.out.println("Aktuellen Raum"); rooms.addItem(ReservationView.this.res.getRoom().getRoomID()); rooms.setItemCaption(ReservationView.this.res.getRoom().getRoomID(), ReservationView.this.res.getRoom().getName() + " (" + ReservationView.this.res.getRoom().getNumberOfSeats() + " Pltze)"); rooms.select(ReservationView.this.res.getRoom().getRoomID()); } for (int i = 0; i < roomList.size(); i++) { rooms.addItem(roomList.get(i).getRoomID()); String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats() + " Pltze)"; rooms.setItemCaption(roomList.get(i).getRoomID(), caption); } if (ReservationView.this.res.getReservationID() <= 0 && actualRoom != null) rooms.select(actualRoom.getRoomID()); } }; popUpWindow = new Window(); popUpWindow.center(); popUpWindow.setModal(true); startDate = new DateField("Startzeit"); startDate.setLocale(VaadinSession.getCurrent().getLocale()); startDate.setValue(res.getStart()); startDate.addValueChangeListener(vcl); startDate.setDateFormat("dd.MM.yyyy HH:mm"); startDate.setResolution(Resolution.HOUR); endDate = new DateField("Endzeit"); endDate.setValue(res.getEnd()); endDate.addValueChangeListener(vcl); endDate.setDateFormat("dd.MM.yyyy HH:mm"); endDate.setLocale(VaadinSession.getCurrent().getLocale()); endDate.setResolution(Resolution.HOUR); title = new TextField("Titel"); title.setValue(res.getTitle()); title.setWidth(100, Unit.PERCENTAGE); description = new TextArea("Beschreibung"); description.setValue(res.getDescription()); description.setRows(3); description.setWidth(100, Unit.PERCENTAGE); hosts = new ListSelect("Reservierender"); hosts.setMultiSelect(true); hosts.clear(); for (int i = 0; i < hostList.size(); i++) { hosts.addItem(hostList.get(i).getUserID()); hosts.setItemCaption(hostList.get(i).getUserID(), hostList.get(i).getUsername()); } //select the hosts in list if (!newRes) { List<User> resHosts = res.getHostList(); for (int i = 0; i < resHosts.size(); i++) for (int y = 0; y < hostList.size(); y++) if (hostList.get(y).getUserID() == resHosts.get(i).getUserID()) hosts.select(resHosts.get(i).getUserID()); } else hosts.select(actualUser.getUserID()); hosts.select(0); hosts.setRows(hostList.size() > 5 ? 5 : hostList.size()); participantList = new ListSelect("Teilnehmer"); participantList.setMultiSelect(true); participantList.clear(); for (int i = 0; i < participant.size(); i++) { participantList.addItem(participant.get(i).getUserID()); participantList.setItemCaption(participant.get(i).getUserID(), participant.get(i).getUsername()); } //select the participants in list if (!newRes) { List<User> resPart = res.getParticipantList(); for (int i = 0; i < resPart.size(); i++) for (int y = 0; y < participant.size(); y++) if (participant.get(y).getUserID() == resPart.get(i).getUserID()) participantList.select(resPart.get(i).getUserID()); } participantList.setRows(participant.size() > 5 ? 5 : participant.size()); rooms = new NativeSelect("Raum"); rooms.setNullSelectionAllowed(false); rooms.removeAllItems(); List<Room> roomList = resCont.getAllFreeRooms(new Timestamp(startDate.getValue().getTime()), new Timestamp(endDate.getValue().getTime())); if (!newRes) { rooms.addItem(res.getRoom().getRoomID()); rooms.setItemCaption(res.getRoom().getRoomID(), res.getRoom().getName() + " (" + res.getRoom().getNumberOfSeats() + " Pltze)"); rooms.select(res.getRoom().getRoomID()); } for (int i = 0; i < roomList.size(); i++) { rooms.addItem(roomList.get(i).getRoomID()); String caption = roomList.get(i).getName() + " (" + roomList.get(i).getNumberOfSeats() + " Pltze)"; rooms.setItemCaption(roomList.get(i).getRoomID(), caption); } if (newRes && actualRoom != null) rooms.select(actualRoom.getRoomID()); saveButton = new Button("Speichern"); saveButton.addClickListener(clButton); deleteButton = new Button("Lschen"); deleteButton.addClickListener(clButton); deleteButton.setVisible(res.getReservationID() > 0 ? true : false); if (!newRes) setEditable(false); gridLayout.addComponent(startDate, 0, 0); gridLayout.addComponent(endDate, 0, 1); gridLayout.addComponent(hosts, 1, 0, 1, 1); gridLayout.addComponent(participantList, 2, 0, 2, 1); gridLayout.addComponent(title, 0, 2); gridLayout.addComponent(rooms, 1, 2, 2, 2); gridLayout.addComponent(description, 0, 3, 1, 3); if (roomList.size() == 0) saveButton.setEnabled(false); if (isHost || newRes) //show buttons for edit and delete only if the user is host or its a new reservation { gridLayout.addComponent(saveButton, 0, 4); gridLayout.addComponent(deleteButton, 1, 4); } if (isParticipant) //show buttons for accept oder decline a reservation { acceptButton = new Button("Zusagen"); rejectButton = new Button("Absagen"); acceptButton.addClickListener(clButton); rejectButton.addClickListener(clButton); if (isHost(actualUser, res.getAcceptedParticipantsList())) { acceptButton.setEnabled(false); rejectButton.setEnabled(true); } else { rejectButton.setEnabled(false); acceptButton.setEnabled(true); } gridLayout.addComponent(acceptButton, 0, 4); gridLayout.addComponent(rejectButton, 1, 4); } gridLayout.setSpacing(true); gridLayout.setMargin(new MarginInfo(false, false, false, true)); gridLayout.setWidth(100, Unit.PERCENTAGE); popUpWindow.setContent(gridLayout); popUpWindow.setWidth("600px"); popUpWindow.setHeight("450px"); popUpWindow.setCaption(res.getReservationID() > 0 ? "Reservierungsdetails" : "Neue Reservierung"); UI.getCurrent().addWindow(popUpWindow); }
From source file:com.bellkenz.modules.PersonalInformation.java
public ComponentContainer personalInformation() { employeeInformationDAO = new EmployeeInformationDAO(getEmployeeId()); employeePersonalInformation = new EmployeePersonalInformation(); GridLayout glayout = new GridLayout(5, 9); glayout.setSpacing(true);/*w w w . ja va 2 s .c o m*/ glayout.setMargin(true); final Panel imagePanel = new Panel(); imagePanel.setStyleName("light"); AbstractLayout panelLayout = (AbstractLayout) imagePanel.getContent(); panelLayout.setMargin(false); imagePanel.setSizeFull(); employeeImage = new Embedded(null, new ThemeResource("../myTheme/images/ronnie.jpg")); employeeImage.setImmediate(true); employeeImage.setWidth(90, Sizeable.UNITS_PIXELS); employeeImage.setHeight(90, Sizeable.UNITS_PIXELS); employeeImage.setStyleName("logo-img"); imagePanel.addComponent(employeeImage); glayout.addComponent(employeeImage, 0, 0, 0, 1); glayout.setComponentAlignment(imagePanel, Alignment.MIDDLE_CENTER); firstname = createTextField("Firstname: "); glayout.addComponent(firstname, 1, 0, 2, 0); final TextField middlename = createTextField("Middlename: "); glayout.addComponent(middlename, 3, 0); final TextField lastname = createTextField("Lastname: "); glayout.addComponent(lastname, 4, 0); final TextField houseNo = createTextField("No: "); houseNo.setWidth("40px"); glayout.addComponent(houseNo, 1, 1); final TextField street = createTextField("Street: "); street.setWidth("118"); glayout.addComponent(street, 2, 1); final TextField city = createTextField("City: "); glayout.addComponent(city, 3, 1); final TextField zipCode = createTextField("Zip Code:"); glayout.addComponent(zipCode, 4, 1); final TextField nickname = createTextField("Nickname: "); nickname.setWidth("90px"); glayout.addComponent(nickname, 0, 2); final TextField permanentAddress = createTextField("Permanent/Provincial Address: "); permanentAddress.setWidth("533px"); glayout.addComponent(permanentAddress, 1, 2, 4, 2); Button uploadPicture = new Button("Upload..."); uploadPicture.setWidth("100%"); uploadPicture.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (employeeId == null) { getWindow().showNotification("You did not select and Employee!", Window.Notification.TYPE_WARNING_MESSAGE); return; } Window uploadImage = new UploadImage(imagePanel, employeeImage, employeeId); uploadImage.setWidth("450px"); if (uploadImage.getParent() == null) { getWindow().addWindow(uploadImage); } uploadImage.setModal(true); uploadImage.center(); } }); glayout.addComponent(uploadPicture, 0, 3); final TextField landline = createTextField("Landline #: "); glayout.addComponent(landline, 1, 3, 2, 3); final TextField mobileNo = createTextField("Mobile #: "); glayout.addComponent(mobileNo, 3, 3); final TextField age = createTextField("Age: "); glayout.addComponent(age, 4, 3); final TextField emailAddress = createTextField("Email Address: "); glayout.addComponent(emailAddress, 1, 4, 2, 4); final PopupDateField dob = (PopupDateField) createDateField("Date of Birth: "); glayout.addComponent(dob, 3, 4); final TextField height = createTextField("Height: "); glayout.addComponent(height, 4, 4); final ComboBox civilStatus = new ComboBox("Civil Status: "); civilStatus.setWidth("100%"); dropDownBoxList.populateCivilStatusList(civilStatus); glayout.addComponent(civilStatus, 1, 5, 2, 5); final ComboBox gender = new ComboBox("Gender: "); gender.setWidth("100%"); dropDownBoxList.populateGenderList(gender); glayout.addComponent(gender, 3, 5); final TextField weight = createTextField("Weigth: "); glayout.addComponent(weight, 4, 5); final TextField driversLicenseNo = createTextField("Drivers License: "); glayout.addComponent(driversLicenseNo, 1, 6, 2, 6); final TextField restrictionCode = createTextField("Restriction Code: "); glayout.addComponent(restrictionCode, 3, 6); final TextField religion = createTextField("Religion: "); glayout.addComponent(religion, 4, 6); final ComboBox division = new ComboBox("Division: "); division.setWidth("100%"); dropDownBoxList.populateBranchComboBox(division); glayout.addComponent(division, 1, 7, 2, 7); final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox()); department.setWidth("100%"); division.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (division.getValue() == null) { } else { divisionId = branchDAO.getBranchId(division.getValue().toString()); } } }); glayout.addComponent(department, 3, 7); final TextField position = createTextField("Position: "); glayout.addComponent(position, 4, 7); //glayout.setComponentAlignment(position, Alignment.BOTTOM_LEFT); Button transferButton = new Button("Transfer Employee"); transferButton.setWidth("100%"); transferButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (getEmployeeId() == null) { getWindow().showNotification("You did not select an Employee!", Window.Notification.TYPE_WARNING_MESSAGE); return; } Window subWindow = transferEmployee(getEmployeeId(), division, department, position); if (subWindow.getParent() == null) { getWindow().addWindow(subWindow); } subWindow.setModal(true); subWindow.center(); } }); glayout.addComponent(transferButton, 1, 8, 2, 8); glayout.setComponentAlignment(transferButton, Alignment.BOTTOM_CENTER); if (employeeId != null) { epiList = employeeInformationDAO.employeePersonalInformation(); for (EmployeePersonalInformation epi : epiList) { final byte[] image = epi.getImage(); if (image != null) { StreamResource.StreamSource imageSource = new StreamResource.StreamSource() { @Override public InputStream getStream() { return new ByteArrayInputStream(image); } }; StreamResource imageResource = new StreamResource(imageSource, epi.getFirstname() + ".jpg", getApplication()); imageResource.setCacheTime(0); employeeImage.setSource(imageResource); } firstname.setValue(epi.getFirstname()); middlename.setValue(epi.getMiddlename()); lastname.setValue(epi.getLastname()); houseNo.setValue(epi.getHouseNumber()); street.setValue(epi.getStreet()); city.setValue(epi.getStreet()); zipCode.setValue(epi.getZipCode()); nickname.setValue(epi.getNickname()); permanentAddress.setValue(epi.getPermanentAddress()); landline.setValue(epi.getLandlineNumber()); mobileNo.setValue(epi.getMobileNumber()); age.setValue(epi.getAge()); emailAddress.setValue(epi.getEmailAddress()); if (epi.getDob() != null) { dob.setValue(conUtil.parsingDate(epi.getDob())); } else { dob.setValue(null); } height.setValue(epi.getHeight()); if (epi.getCivilStatus() != null) { Object civilStatusId = civilStatus.addItem(); civilStatus.setItemCaption(civilStatusId, epi.getCivilStatus()); civilStatus.setValue(civilStatusId); } if (epi.getGender() != null) { Object genderId = gender.addItem(); gender.setItemCaption(genderId, epi.getGender()); gender.setValue(genderId); } weight.setValue(epi.getWeight()); driversLicenseNo.setValue(epi.getDriversLicense()); restrictionCode.setValue(epi.getRestrictionCode()); religion.setValue(epi.getReligion()); position.setValue(epi.getPosition()); Object divisionObjectId = division.addItem(); division.setItemCaption(divisionObjectId, epi.getDivision()); division.setValue(divisionObjectId); Object departmentObjectId = department.addItem(); department.setItemCaption(departmentObjectId, epi.getDepartment()); department.setValue(departmentObjectId); } } firstname.addListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { employeePersonalInformation.setFirstname(event.getProperty().getValue().toString()); } }); firstname.setImmediate(true); setInformation(employeePersonalInformation); return glayout; }
From source file:com.cms.utils.CommonUtils.java
public static void setBasicAttributeLayout(GridLayout gridLayout, String caption, boolean isCollapseable) { gridLayout.setWidth("100%"); gridLayout.setHeight("-1px"); gridLayout.setImmediate(true);//from w ww. j a v a 2 s . c o m gridLayout.setMargin(true); gridLayout.setSpacing(true); if (isCollapseable && !DataUtil.isStringNullOrEmpty(caption)) { gridLayout.setStyleName("custom-feildset"); gridLayout.setCaption(MakeURL.makeURLForGrid(caption)); gridLayout.setCaptionAsHtml(isCollapseable); } }
From source file:com.cms.view.ListStaffDepartment.java
public ListStaffDepartment() { super(BundleUtils.getString("caption.title.listDept"), BundleUtils.getString("caption.title.listEmp")); mainLayout.setSplitPosition(30, Unit.PERCENTAGE); setCompositionRoot(mainLayout);/*from ww w .jav a2 s . c o m*/ //khoi tao cac thanh phan //khoi tao form search searchDepartmentForm = new DepartmentSearchPanel(); //khoi tao table ui tblListDepartmentUI = new CommonTableFilterPanel(); //100316 NgocND6 chuyen quyen quan ly hang hoa btnTransferRoleCusts = new Button(TRANSFERROLE); btnTransferRoleCusts.setIcon(new ThemeResource("img/transfer_icon.png")); //them cac component vao layout GridLayout horizontalLayout = new GridLayout(2, 1); horizontalLayout.setWidth("-1px"); horizontalLayout.setMargin(true); horizontalLayout.setSpacing(true); //btn search btnSearchDept = new Button(Constants.BUTTON_SEARCH); btnSearchDept.setIcon(new ThemeResource(Constants.ICON.SEARCH)); horizontalLayout.addComponent(btnSearchDept, 0, 0); //btn refresh btnRefreshDept = new Button(Constants.BUTTON_REFRESH); btnRefreshDept.setIcon(new ThemeResource(Constants.ICON.RESET)); horizontalLayout.addComponent(btnRefreshDept, 1, 0); //add component leftLayout.addComponent(searchDepartmentForm); leftLayout.addComponent(horizontalLayout); leftLayout.addComponent(tblListDepartmentUI); leftLayout.setComponentAlignment(horizontalLayout, Alignment.MIDDLE_CENTER); leftLayout.setMargin(true); //===============right========================== searchStaffForm = new StaffSearchPanel(); //khoi tao table ui tblListStaffUI = new CommonTableFilterPanel(); btnAddMapStaffCustomer = new Button(BundleUtils.getString("staff.customer.map")); btnAddMapStaffCustomer.setDescription(BundleUtils.getString("staff.customer.map")); btnAddMapStaffCustomer.setIcon(new ThemeResource(Constants.ICON.IMPORT)); btnAssignRole = new Button(BundleUtils.getString("assign.roles.button")); btnAssignRole.setIcon(FontAwesome.ANCHOR); //them cac component vao layout GridLayout horizontalLayout2 = new GridLayout(3, 1); horizontalLayout2.setWidth("-1px"); horizontalLayout2.setMargin(true); horizontalLayout2.setSpacing(true); //NgocND6 tao layout de add button chuyen quyen cho nhan vien GridLayout gridLayout = new GridLayout(3, 1); gridLayout.setMargin(true); gridLayout.setSpacing(true); gridLayout.addComponent(btnAssignRole, 0, 0); // gridLayout.addComponent(btnAddMapStaffCustomer, 1, 0); gridLayout.addComponent(btnTransferRoleCusts, 2, 0); //Tam thoi an nut phan bo lai khach hang btnTransferRoleCusts.setVisible(false); //btn search emp btnSearchEmp = new Button(Constants.BUTTON_SEARCH); btnSearchEmp.setIcon(new ThemeResource(Constants.ICON.SEARCH)); horizontalLayout2.addComponent(btnSearchEmp, 0, 0); //btn refresh emp btnRefreshEmp = new Button(Constants.BUTTON_REFRESH); btnRefreshEmp.setIcon(new ThemeResource(Constants.ICON.RESET)); horizontalLayout2.addComponent(btnRefreshEmp, 1, 0); // //add component rightLayout.addComponent(searchStaffForm); rightLayout.addComponent(horizontalLayout2); rightLayout.addComponent(tblListStaffUI); rightLayout.setComponentAlignment(horizontalLayout2, Alignment.MIDDLE_CENTER); rightLayout.addComponent(gridLayout); rightLayout.setComponentAlignment(gridLayout, Alignment.MIDDLE_CENTER); rightLayout.setMargin(true); //============= this.listDeptAndStaffController = new ListDeptAndStaffController(this); }
From source file:com.esofthead.mycollab.module.crm.ui.components.PeopleInfoComp.java
License:Open Source License
public void displayEntryPeople(ValuedBean bean) { this.removeAllComponents(); this.withMargin(new MarginInfo(true, false, true, true)); Label peopleInfoHeader = new Label( FontAwesome.USER.getHtml() + " " + AppContext.getMessage(CrmCommonI18nEnum.SUB_INFO_PEOPLE), ContentMode.HTML);/*from www .j a v a 2 s. co m*/ peopleInfoHeader.setStyleName("info-hdr"); this.addComponent(peopleInfoHeader); GridLayout layout = new GridLayout(2, 2); layout.setSpacing(true); layout.setWidth("100%"); layout.setMargin(new MarginInfo(false, false, false, true)); try { Label createdLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_CREATED_PEOPLE)); createdLbl.setSizeUndefined(); layout.addComponent(createdLbl, 0, 0); String createdUserName = (String) PropertyUtils.getProperty(bean, "createduser"); String createdUserAvatarId = (String) PropertyUtils.getProperty(bean, "createdUserAvatarId"); String createdUserDisplayName = (String) PropertyUtils.getProperty(bean, "createdUserFullName"); UserLink createdUserLink = new UserLink(createdUserName, createdUserAvatarId, createdUserDisplayName); layout.addComponent(createdUserLink, 1, 0); layout.setColumnExpandRatio(1, 1.0f); Label assigneeLbl = new Label(AppContext.getMessage(CrmCommonI18nEnum.ITEM_ASSIGN_PEOPLE)); assigneeLbl.setSizeUndefined(); layout.addComponent(assigneeLbl, 0, 1); String assignUserName = (String) PropertyUtils.getProperty(bean, "assignuser"); String assignUserAvatarId = (String) PropertyUtils.getProperty(bean, "assignUserAvatarId"); String assignUserDisplayName = (String) PropertyUtils.getProperty(bean, "assignUserFullName"); UserLink assignUserLink = new UserLink(assignUserName, assignUserAvatarId, assignUserDisplayName); layout.addComponent(assignUserLink, 1, 1); } catch (Exception e) { LOG.error("Can not build user link {} ", BeanUtility.printBeanObj(bean)); } this.addComponent(layout); }
From source file:com.esofthead.mycollab.module.crm.view.CrmToolbar.java
License:Open Source License
public CrmToolbar() { super();/*from www .j av a 2s .c om*/ this.setStyleName("crm-toolbar"); this.setWidth("100%"); this.setMargin(new MarginInfo(false, true, false, true)); final NavigatorItemListener listener = new NavigatorItemListener(); final Button homeBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DASHBOARD_HEADER), listener); homeBtn.setStyleName("link"); addComponent(homeBtn); final Button accountList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACCOUNTS_HEADER), listener); accountList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_ACCOUNT)); accountList.setStyleName("link"); addComponent(accountList); final Button contactList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CONTACTS_HEADER), listener); contactList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CONTACT)); contactList.setStyleName("link"); addComponent(contactList); final Button campaignList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CAMPAIGNS_HEADER), listener); campaignList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CAMPAIGN)); campaignList.setStyleName("link"); addComponent(campaignList); final Button leadList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_LEADS_HEADER), listener); leadList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_LEAD)); leadList.setStyleName("link"); addComponent(leadList); final Button opportunityList = new Button( AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_OPPORTUNTIES_HEADER), listener); opportunityList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_OPPORTUNITY)); opportunityList.setStyleName("link"); addComponent(opportunityList); final Button caseList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CASES_HEADER), listener); caseList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CASE)); caseList.setStyleName("link"); addComponent(caseList); final Button activitiesList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACTIVITIES_HEADER), listener); final boolean isActivityEnable = AppContext.canRead(RolePermissionCollections.CRM_MEETING) || AppContext.canRead(RolePermissionCollections.CRM_TASK) || AppContext.canRead(RolePermissionCollections.CRM_CALL); activitiesList.setEnabled(isActivityEnable); activitiesList.setStyleName("link"); addComponent(activitiesList); addStyleName("h-sidebar-menu"); final Button fileBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DOCUMENT_HEADER), listener); fileBtn.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_DOCUMENT)); fileBtn.setStyleName("link"); addComponent(fileBtn); final Button notificationBtn = new Button( AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CRMNOTIFICATION_HEADER), listener); notificationBtn.setStyleName("link"); addComponent(notificationBtn); addBtn = new PopupButton(AppContext.getMessage(CrmCommonI18nEnum.BUTTON_CREATE)); final GridLayout addBtnLayout = new GridLayout(3, 2); addBtnLayout.setMargin(true); addBtnLayout.setWidth("370px"); addBtnLayout.setSpacing(true); final ButtonLink newAccountBtn = new ButtonLink(AppContext.getMessage(AccountI18nEnum.BUTTON_NEW_ACCOUNT), listener, false); newAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_ACCOUNT)); newAccountBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT)); addBtnLayout.addComponent(newAccountBtn); final ButtonLink newContactBtn = new ButtonLink(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT), listener, false); newContactBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT)); newContactBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT)); addBtnLayout.addComponent(newContactBtn); final ButtonLink newCampaignBtn = new ButtonLink( AppContext.getMessage(CampaignI18nEnum.BUTTON_NEW_CAMPAIGN), listener, false); newCampaignBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CAMPAIGN)); newCampaignBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CAMPAIGN)); addBtnLayout.addComponent(newCampaignBtn); final ButtonLink newOpportunityBtn = new ButtonLink( AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY), listener, false); newOpportunityBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY)); newOpportunityBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY)); addBtnLayout.addComponent(newOpportunityBtn); final ButtonLink newLeadBtn = new ButtonLink(AppContext.getMessage(LeadI18nEnum.BUTTON_NEW_LEAD), listener, false); newLeadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_LEAD)); newLeadBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD)); addBtnLayout.addComponent(newLeadBtn); final ButtonLink newCaseBtn = new ButtonLink(AppContext.getMessage(CaseI18nEnum.BUTTON_NEW_CASE), listener, false); newCaseBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE)); newCaseBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CASE)); addBtnLayout.addComponent(newCaseBtn); final ButtonLink newTaskBtn = new ButtonLink(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), listener, false); newTaskBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_TASK)); newTaskBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK)); addBtnLayout.addComponent(newTaskBtn); final ButtonLink newCallBtn = new ButtonLink(AppContext.getMessage(CallI18nEnum.BUTTON_NEW_CALL), listener, false); newCallBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL)); newCallBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL)); addBtnLayout.addComponent(newCallBtn); final ButtonLink newMeetingBtn = new ButtonLink(AppContext.getMessage(MeetingI18nEnum.BUTTON_NEW_MEETING), listener, false); newMeetingBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_MEETING)); newMeetingBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING)); addBtnLayout.addComponent(newMeetingBtn); addBtn.setContent(addBtnLayout); addBtn.setStyleName("link"); addBtn.addStyleName("quickadd-btn"); addComponent(addBtn); setExpandRatio(addBtn, 1.0f); setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT); }
From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneListViewImpl.java
License:Open Source License
private ComponentContainer constructMilestoneBox(final SimpleMilestone milestone) { final CssLayout layout = new CssLayout(); layout.addStyleName(UIConstants.MILESTONE_BOX); layout.setWidth("100%"); final LabelLink milestoneLink = new LabelLink(milestone.getName(), ProjectLinkBuilder.generateMilestonePreviewFullLink(milestone.getProjectid(), milestone.getId())); milestoneLink.setStyleName("link"); milestoneLink.addStyleName("bold"); milestoneLink.addStyleName(UIConstants.WORD_WRAP); milestoneLink.addStyleName("milestone-name"); milestoneLink.setWidth("100%"); MHorizontalLayout milestoneHeader = new MHorizontalLayout().withWidth("100%").with(milestoneLink) .expand(milestoneLink);/*from w ww .j a v a 2 s. c o m*/ PopupButton taskSettingPopupBtn = new PopupButton(); taskSettingPopupBtn.setWidth("20px"); MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("100px"); Button editButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new MilestoneEvent.GotoEdit(MilestoneListViewImpl.this, milestone)); } }); editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)); editButton.setStyleName("link"); filterBtnLayout.addComponent(editButton); Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { ConfirmDialogExt.show(UI.getCurrent(), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()), AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE), AppContext.getMessage(GenericI18Enum.BUTTON_YES), AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { MilestoneService projectTaskService = ApplicationContextUtil .getSpringBean(MilestoneService.class); projectTaskService.removeWithSession(milestone.getId(), AppContext.getUsername(), AppContext.getAccountId()); milestones.remove(milestone); displayMilestones(milestones); } } }); } }); deleteBtn.setStyleName("link"); deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.MILESTONES)); filterBtnLayout.addComponent(deleteBtn); taskSettingPopupBtn.setIcon(FontAwesome.COG); taskSettingPopupBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY); taskSettingPopupBtn.setContent(filterBtnLayout); milestoneHeader.addComponent(taskSettingPopupBtn); layout.addComponent(milestoneHeader); MHorizontalLayout spacing = new MHorizontalLayout().withHeight("8px").withWidth("100%"); layout.addComponent(spacing); final GridFormLayoutHelper layoutHelper = new GridFormLayoutHelper(1, 5, "100%", "80px"); layoutHelper.addComponent( new Label(AppContext.formatDate(milestone.getStartdate(), AppContext.getMessage(GenericI18Enum.FORM_EMPTY))), AppContext.getMessage(MilestoneI18nEnum.FORM_START_DATE_FIELD), 0, 0, Alignment.MIDDLE_LEFT); layoutHelper.addComponent( new Label(AppContext.formatDate(milestone.getEnddate(), AppContext.getMessage(GenericI18Enum.FORM_EMPTY))), AppContext.getMessage(MilestoneI18nEnum.FORM_END_DATE_FIELD), 0, 1, Alignment.MIDDLE_LEFT); CssLayout linkWrapper = new CssLayout(); linkWrapper.setWidth("100%"); linkWrapper.addComponent(new ProjectUserLink(milestone.getOwner(), milestone.getOwnerAvatarId(), milestone.getOwnerFullName(), false, true)); layoutHelper.addComponent(linkWrapper, AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE), 0, 2, Alignment.MIDDLE_LEFT); final ProgressBarIndicator progressTask = new ProgressBarIndicator(milestone.getNumTasks(), milestone.getNumOpenTasks()); progressTask.setWidth("100%"); layoutHelper.addComponent(progressTask, AppContext.getMessage(MilestoneI18nEnum.FORM_TASK_FIELD), 0, 3, Alignment.MIDDLE_LEFT); final ProgressBarIndicator progressBug = new ProgressBarIndicator(milestone.getNumBugs(), milestone.getNumOpenBugs()); progressBug.setWidth("100%"); layoutHelper.addComponent(progressBug, AppContext.getMessage(MilestoneI18nEnum.FORM_BUG_FIELD), 0, 4, Alignment.MIDDLE_LEFT); final GridLayout milestoneInfoLayout = layoutHelper.getLayout(); milestoneInfoLayout.setWidth("100%"); milestoneInfoLayout.setMargin(false); milestoneInfoLayout.setSpacing(true); layout.addComponent(milestoneInfoLayout); return layout; }