List of usage examples for com.vaadin.ui Embedded Embedded
public Embedded(String caption, Resource source)
From source file:annis.visualizers.component.AbstractDotVisualizer.java
License:Apache License
@Override public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) { try {/*from w ww . j a v a 2 s . co m*/ final PipedOutputStream out = new PipedOutputStream(); final PipedInputStream in = new PipedInputStream(out); new Thread(new Runnable() { @Override public void run() { writeOutput(visInput, out); } }).start(); String fileName = "dotvis_" + new Random().nextInt(Integer.MAX_VALUE) + ".png"; StreamResource resource = new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { return in; } }, fileName); Embedded emb = new Embedded("", resource); emb.setMimeType("image/png"); emb.setSizeFull(); emb.setStandby("loading image"); emb.setAlternateText("DOT graph visualization"); return new ImagePanel(emb); } catch (IOException ex) { log.error(null, ex); } return new ImagePanel(new Embedded()); }
From source file:annis.visualizers.component.AbstractImageVisualizer.java
License:Apache License
@Override public ImagePanel createComponent(final VisualizerInput visInput, VisualizationToggle visToggle) { final ByteArrayOutputStream out = new ByteArrayOutputStream(); writeOutput(visInput, out);/*from w w w . ja va 2 s. c o m*/ String fileName = "vis_" + UUID.randomUUID().toString() + ".png"; StreamResource resource = new StreamResource(new StreamResource.StreamSource() { @Override public InputStream getStream() { return new ByteArrayInputStream(out.toByteArray()); } }, fileName); Embedded emb = new Embedded("", resource); emb.setMimeType(getContentType()); emb.setSizeUndefined(); emb.setStandby("loading image"); emb.setAlternateText("Visualization of the result"); return new ImagePanel(emb); }
From source file:at.peppol.webgui.app.MainWindow.java
License:Mozilla Public License
@SuppressWarnings("serial") private void initUI() { final VerticalLayout root = new VerticalLayout(); root.setMargin(false);//from w ww.j a va 2s.co m setContent(root); // createTopBar(); // Changed with menuBar -- under testing createMenuBar(); // Changed with custom layout using bootstrap -- under testing // createHeaderMenu(); final UserFolder<File> userFolder = new UserFolder<File>(); final long polling = 20000; int draftInvoicesNum = um.countItemsInSpace(um.getDrafts()); int inboxInvoicesNum = um.countItemsInSpace(um.getInbox()); int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox()); //Buttons final NativeButton inboxInvoices = new NativeButton("Invoices (" + inboxInvoicesNum + ")"); final NativeButton outboxInvoices = new NativeButton("Invoices (" + outboxInvoicesNum + ")"); final NativeButton draftInvoices = new NativeButton("Invoices (" + draftInvoicesNum + ")"); //thread final Thread tFolderCount = new Thread(new Runnable() { @Override public void run() { try { while (true) { int countDrafts = um.countItemsInSpace(um.getDrafts()); int countInbox = um.countItemsInSpace(um.getInbox()); int countOutbox = um.countItemsInSpace(um.getOutbox()); synchronized (MainWindow.this.getApplication()) { String labelD = draftInvoices.getCaption(); labelD = labelD.replaceFirst("[\\d]+", "" + countDrafts); draftInvoices.setCaption(labelD); String labelI = inboxInvoices.getCaption(); labelI = labelI.replaceFirst("[\\d]+", "" + countInbox); inboxInvoices.setCaption(labelI); String labelO = outboxInvoices.getCaption(); labelO = labelO.replaceFirst("[\\d]+", "" + countOutbox); outboxInvoices.setCaption(labelO); itemsPanel.reloadTable(userFolder); } Thread.sleep(polling); } } catch (InterruptedException e) { System.out.println("Thread folders interrupted!!!"); } } }); // ------ START: Left NavBar ------- final CssLayout leftNavBar = new CssLayout(); leftNavBar.setStyleName("sidebar-menu"); leftNavBar.setSizeFull(); leftNavBar.setWidth("220px"); // User theUser = (User) getApplication().getUser(); final Label homeLbl = new Label("HOME"); homeLbl.addStyleName("blue"); leftNavBar.addComponent(homeLbl); leftNavBar.addComponent(new Label("INBOX")); final NativeButton catalogueBtn = new NativeButton("Catalogue"); leftNavBar.addComponent(catalogueBtn); leftNavBar.addComponent(new NativeButton("Orders")); //leftNavBar.addComponent (new NativeButton ("Invoices")); //int inboxInvoicesNum = um.countItemsInSpace(um.getInbox()); //inboxInvoices = new NativeButton ("Invoices ("+inboxInvoicesNum+")"); inboxInvoices.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { inboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getInbox()) + ")"); userFolder.setFolder(um.getInbox().getFolder()); userFolder.setName(um.getInbox().getName()); showInitialMainContent(userFolder); draftInvoices.removeStyleName("v-bold-nativebuttoncaption"); } }); leftNavBar.addComponent(inboxInvoices); leftNavBar.addComponent(new Label("DRAFTS")); leftNavBar.addComponent(new NativeButton("Catalogue")); leftNavBar.addComponent(new NativeButton("Orders")); //int draftInvoicesNum = um.countItemsInSpace(um.getDrafts()); //draftInvoices = new NativeButton ("Invoices ("+draftInvoicesNum+")"); draftInvoices.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { draftInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getDrafts()) + ")"); userFolder.setFolder(um.getDrafts().getFolder()); userFolder.setName(um.getDrafts().getName()); showInitialMainContent(userFolder); draftInvoices.removeStyleName("v-bold-nativebuttoncaption"); } }); leftNavBar.addComponent(draftInvoices); leftNavBar.addComponent(new Label("OUTBOX")); leftNavBar.addComponent(new NativeButton("Catalogue")); leftNavBar.addComponent(new NativeButton("Orders")); //leftNavBar.addComponent (new NativeButton ("Invoices")); //int outboxInvoicesNum = um.countItemsInSpace(um.getOutbox()); //outboxInvoices = new NativeButton ("Invoices ("+outboxInvoicesNum+")"); outboxInvoices.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { outboxInvoices.setCaption("Invoices (" + um.countItemsInSpace(um.getOutbox()) + ")"); userFolder.setFolder(um.getOutbox().getFolder()); userFolder.setName(um.getOutbox().getName()); showInitialMainContent(userFolder); draftInvoices.removeStyleName("v-bold-nativebuttoncaption"); } }); leftNavBar.addComponent(outboxInvoices); leftNavBar.addComponent(new Label("SETTINGS")); leftNavBar.addComponent(new NativeButton("My Profile")); leftNavBar.addComponent(new NativeButton("Customers")); leftNavBar.addComponent(new NativeButton("Suppliers")); final Embedded peppolLogoImg = new Embedded(null, new ExternalResource("img/peppol_logo.png")); peppolLogoImg.setStyleName("logo"); leftNavBar.addComponent(peppolLogoImg); middleContentLayout.addComponent(leftNavBar); /*Button refreshButton = new Button("Refresh"); refreshButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { int draftInvoices = um.countItemsInSpace(um.getDrafts()); invoices.setCaption("Invoices ("+draftInvoices+")"); } }); leftNavBar.addComponent(refreshButton);*/ //workaround so that thread refreshes UI. It seems that when a ProgressIndicator is present, //all components receive server side refreshes ProgressIndicator p = new ProgressIndicator(); p.setPollingInterval((int) polling); p.setWidth("0px"); p.setHeight("0px"); leftNavBar.addComponent(p); showInitialMainContent(null); draftInvoices.click(); tFolderCount.start(); draftInvoices.addStyleName("v-bold-nativebuttoncaption"); }
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);/*from w w w .java2 s . c om*/ 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.cavisson.gui.dashboard.components.controls.Dragging.java
License:Apache License
private List<Component> createComponents() { final List<Component> components = new ArrayList<Component>(); final Label label = new Label("This is a long text block that will wrap."); label.setWidth("120px"); components.add(label);/*from w ww .j av a2s. co m*/ final Embedded image = new Embedded("", new ThemeResource("../runo/icons/64/document.png")); components.add(image); final CssLayout documentLayout = new CssLayout(); documentLayout.setWidth("19px"); for (int i = 0; i < 5; ++i) { final Embedded e = new Embedded(null, new ThemeResource("../runo/icons/16/document.png")); e.setHeight("16px"); e.setWidth("16px"); documentLayout.addComponent(e); } components.add(documentLayout); final VerticalLayout buttonLayout = new VerticalLayout(); final Button button = new Button("Button"); button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent event) { Notification.show("Button clicked"); } }); buttonLayout.addComponent(button); buttonLayout.setComponentAlignment(button, Alignment.MIDDLE_CENTER); components.add(buttonLayout); return components; }
From source file:com.esofthead.mycollab.module.project.view.bug.BugTableDisplay.java
License:Open Source License
public BugTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) { super(ApplicationContextUtil.getSpringBean(BugService.class), SimpleBug.class, viewId, requiredColumn, displayColumns);//w w w. ja va 2 s. c o m this.addGeneratedColumn("id", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(final Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); final Button bugSettingBtn = new Button(null, FontAwesome.COG); bugSettingBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY); final ContextMenu contextMenu = new ContextMenu(); contextMenu.setAsContextMenuOf(bugSettingBtn); contextMenu.addItemClickListener(new ContextMenuItemClickListener() { @Override public void contextMenuItemClicked(ContextMenuItemClickEvent event) { if (((ContextMenuItem) event.getSource()).getData() == null) { return; } String category = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()) .getAction(); String value = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()).getKey(); if ("status".equals(category)) { if (AppContext.getMessage(BugStatus.Verified).equals(value)) { UI.getCurrent().addWindow(new ApproveInputWindow(BugTableDisplay.this, bug)); } else if (AppContext.getMessage(BugStatus.InProgress).equals(value)) { bug.setStatus(BugStatus.InProgress.name()); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); } else if (AppContext.getMessage(BugStatus.Open).equals(value)) { UI.getCurrent().addWindow(new ReOpenWindow(BugTableDisplay.this, bug)); } else if (AppContext.getMessage(BugStatus.Resolved).equals(value)) { UI.getCurrent().addWindow(new ResolvedInputWindow(BugTableDisplay.this, bug)); } } else if ("severity".equals(category)) { bug.setSeverity(value); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); refresh(); } else if ("priority".equals(category)) { bug.setPriority(value); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bugService.updateWithSession(bug, AppContext.getUsername()); refresh(); } else if ("action".equals(category)) { if ("edit".equals(value)) { EventBusFactory.getInstance() .post(new BugEvent.GotoEdit(BugTableDisplay.this, bug)); } else if ("delete".equals(value)) { 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()) { BugService bugService = ApplicationContextUtil .getSpringBean(BugService.class); bugService.removeWithSession(bug.getId(), AppContext.getUsername(), AppContext.getAccountId()); refresh(); } } }); } } } }); bugSettingBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); bugSettingBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { displayContextMenuItem(contextMenu, bug, event.getClientX(), event.getClientY()); } }); return bugSettingBtn; } }); this.addGeneratedColumn("assignuserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(), bug.getAssignuserFullName()); } }); this.addGeneratedColumn("loguserFullName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new ProjectUserLink(bug.getLogby(), bug.getLoguserAvatarId(), bug.getLoguserFullName()); } }); this.addGeneratedColumn("summary", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); String bugname = "[%s-%s] %s"; bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(), bug.getBugkey(), bug.getSummary()); LabelLink b = new LabelLink(bugname, ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); if (StringUtils.isNotBlank(bug.getPriority())) { b.setIconLink(ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority())); } b.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug, AppContext.getSiteUrl(), AppContext.getTimezone())); if (bug.isCompleted()) { b.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.isOverdue()) { b.addStyleName(UIConstants.LINK_OVERDUE); } return b; } }); this.addGeneratedColumn("severity", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); Resource iconPriority = new ExternalResource( ProjectResources.getIconResourceLink12ByBugSeverity(bug.getPriority())); Embedded iconEmbedded = new Embedded(null, iconPriority); Label lbPriority = new Label(AppContext.getMessage(BugSeverity.class, bug.getSeverity())); HorizontalLayout containerField = new HorizontalLayout(); containerField.setSpacing(true); containerField.addComponent(iconEmbedded); containerField.addComponent(lbPriority); containerField.setExpandRatio(lbPriority, 1.0f); return containerField; } }); this.addGeneratedColumn("duedate", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDate(bug.getDuedate())); } }); this.addGeneratedColumn("createdtime", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.formatDateTime(bug.getCreatedtime())); } }); this.addGeneratedColumn("resolution", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId); return new Label(AppContext.getMessage(BugResolution.class, bug.getResolution())); } }); this.setWidth("100%"); }
From source file:com.esofthead.mycollab.module.user.accountsettings.customize.view.LogoEditWindow.java
License:Open Source License
private void editPhoto(byte[] imageData) { try {//from w w w .j ava2s . c o m originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false)) .withFullWidth(); final String logoPath = AppContext.getBillingAccount().getLogopath(); Resource defaultPhoto = AccountAssetsResolver.createLogoResource(logoPath, 150); previewImage = new Embedded(null, defaultPhoto); previewImage.setWidth("100px"); previewBox.addComponent(previewImage); previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT); MVerticalLayout previewBoxRight = new MVerticalLayout().withSpacing(false) .withMargin(new MarginInfo(false, true, false, true)); Label lbPreview = new Label( "<p style='margin: 0px;'><strong>To the below is what your logo will look like.</strong></p><p " + "style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. " + "When you are happy with your photo, click the <strong>Accept</strong> button.</p>", ContentMode.HTML); previewBoxRight.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); controlBtns.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new SettingEvent.GotoGeneralSetting(LogoEditWindow.this, null)); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); controlBtns.with(cancelBtn); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); AccountLogoService accountLogoService = AppContextUtil .getSpringBean(AccountLogoService.class); accountLogoService.upload(AppContext.getUsername(), image, AppContext.getAccountId()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException("Error when saving account logo", e); } } } }); acceptBtn.setStyleName(UIConstants.BUTTON_ACTION); controlBtns.with(acceptBtn); previewBoxRight.with(controlBtns).withAlign(controlBtns, Alignment.TOP_LEFT); previewBox.with(previewBoxRight).expand(previewBoxRight); content.addComponent(previewBox); CssLayout cropBox = new CssLayout(); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(150 / 28); cropField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { VCropSelection newSelection = (VCropSelection) event.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } } }); currentPhotoBox.setWidth("650px"); currentPhotoBox.setHeight("650px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); content.with(previewBox, ELabel.hr(), cropBox); }
From source file:com.esofthead.mycollab.module.user.accountsettings.profile.view.ProfilePhotoUploadViewImpl.java
License:Open Source License
@SuppressWarnings("serial") @Override/*from ww w .j a v a 2 s. c om*/ public void editPhoto(final byte[] imageData) { this.removeAllComponents(); LOG.debug("Receive avatar upload with size: " + imageData.length); try { originalImage = ImageIO.read(new ByteArrayInputStream(imageData)); } catch (IOException e) { throw new UserInvalidInputException("Invalid image type"); } originalImage = ImageUtil.scaleImage(originalImage, 650, 650); MHorizontalLayout previewBox = new MHorizontalLayout().withSpacing(true) .withMargin(new MarginInfo(false, true, true, false)).withWidth("100%"); Resource defaultPhoto = UserAvatarControlFactory.createAvatarResource(AppContext.getUserAvatarId(), 100); previewImage = new Embedded(null, defaultPhoto); previewImage.setWidth("100px"); previewBox.addComponent(previewImage); previewBox.setComponentAlignment(previewImage, Alignment.TOP_LEFT); VerticalLayout previewBoxRight = new VerticalLayout(); previewBoxRight.setMargin(new MarginInfo(false, true, false, true)); Label lbPreview = new Label( "<p style='margin: 0px;'><strong>To the left is what your profile photo will look like.</strong></p><p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. When you are happy with your photo, click the “Accept“ button.</p>", ContentMode.HTML); previewBoxRight.addComponent(lbPreview); MHorizontalLayout controlBtns = new MHorizontalLayout(); controlBtns.setSizeUndefined(); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { EventBusFactory.getInstance() .post(new ProfileEvent.GotoProfileView(ProfilePhotoUploadViewImpl.this, null)); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (scaleImageData != null && scaleImageData.length > 0) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData)); UserAvatarService userAvatarService = ApplicationContextUtil .getSpringBean(UserAvatarService.class); userAvatarService.uploadAvatar(image, AppContext.getUsername(), AppContext.getUserAvatarId()); Page.getCurrent().getJavaScript().execute("window.location.reload();"); } catch (IOException e) { throw new MyCollabException("Error when saving user avatar", e); } } } }); acceptBtn.setStyleName(UIConstants.THEME_GREEN_LINK); acceptBtn.setIcon(FontAwesome.CHECK); controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT); previewBoxRight.addComponent(controlBtns); previewBoxRight.setComponentAlignment(controlBtns, Alignment.TOP_LEFT); previewBox.addComponent(previewBoxRight); previewBox.setExpandRatio(previewBoxRight, 1.0f); this.addComponent(previewBox); CssLayout cropBox = new CssLayout(); cropBox.addStyleName(UIConstants.PHOTO_CROPBOX); cropBox.setWidth("100%"); VerticalLayout currentPhotoBox = new VerticalLayout(); Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage), "image/png"); CropField cropField = new CropField(resource); cropField.setImmediate(true); cropField.setSelectionAspectRatio(1.0f); cropField.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { VCropSelection newSelection = (VCropSelection) event.getProperty().getValue(); int x1 = newSelection.getXTopLeft(); int y1 = newSelection.getYTopLeft(); int x2 = newSelection.getXBottomRight(); int y2 = newSelection.getYBottomRight(); if (x2 > x1 && y2 > y1) { BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1)); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { ImageIO.write(subImage, "png", outStream); scaleImageData = outStream.toByteArray(); displayPreviewImage(); } catch (IOException e) { LOG.error("Error while scale image: ", e); } } } }); currentPhotoBox.setWidth("650px"); currentPhotoBox.setHeight("650px"); currentPhotoBox.addComponent(cropField); cropBox.addComponent(currentPhotoBox); this.addComponent(previewBox); this.addComponent(cropBox); this.setExpandRatio(cropBox, 1.0f); }
From source file:com.esofthead.mycollab.module.user.ui.components.ImagePreviewCropWindow.java
License:Open Source License
private void displayPreviewImage() { previewPhoto.removeAllComponents();//from w ww . j av a 2s . c o m if (scaleImageData != null && scaleImageData.length > 0) { Embedded previewImage = new Embedded(null, new ByteArrayImageResource(scaleImageData, "image/png")); previewImage.setWidth("100px"); previewPhoto.addComponent(previewImage); } else { previewPhoto.addComponent( ELabel.fontIcon(FontAwesome.QUESTION_CIRCLE).withStyleName("icon-48px").withWidthUndefined()); } }
From source file:com.esspl.datagen.ui.ExecutorView.java
License:Open Source License
public ExecutorView(DataGenApplication application) { log.debug("ExecutorView - constructor start"); dataGenApplication = application;//from www .j ava 2 s .co m setSizeFull(); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); setCompositionRoot(vl); splitPanel = new VerticalSplitPanel(); splitPanel.setSizeFull(); //Script TextArea sqlScript = new TextArea(); sqlScript.setSizeFull(); sqlScript.setWordwrap(false); sqlScript.setStyleName("noResizeTextArea"); HorizontalLayout queryOptions = new HorizontalLayout(); queryOptions.setMargin(false, false, false, true); queryOptions.setSpacing(true); queryOptions.setWidth("100%"); queryOptions.setHeight("40px"); Button executeButton = new Button("Execute", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Execute Button clicked"); executeScript(sqlScript.getValue().toString()); } }); executeButton.addStyleName("small"); executeButton.setIcon(DataGenConstant.EXECUTOR_ICON); executeButton.setDescription("Press Ctrl+Enter to execute the query"); Button clearQueryButton = new Button("Clear SQL", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear SQL Button clicked"); sqlScript.setValue(""); } }); clearQueryButton.addStyleName("small"); clearQueryButton.setIcon(DataGenConstant.CLEAR_SMALL); clearQueryButton.setDescription("Clears the Sql"); Button clearConsoleButton = new Button("Clear Console", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear Console Button clicked"); logText.setValue(""); } }); clearConsoleButton.addStyleName("small"); clearConsoleButton.setIcon(DataGenConstant.CLEAR_SMALL); clearConsoleButton.setDescription("Clears the Console"); maxRowsBox = new ComboBox(null, Arrays.asList(10, 100, 500, 1000, 5000, 10000)); maxRowsBox.setDescription("Max number of rows to retrieve"); maxRowsBox.setWidth(100, UNITS_PIXELS); maxRowsBox.setNewItemsAllowed(false); maxRowsBox.setNullSelectionAllowed(false); maxRowsBox.setValue(100); //Bottom section components resultSheet = new TabSheet(); resultSheet.setSizeFull(); resultSheet.addStyleName(Runo.TABSHEET_SMALL); logText = new Label(); logText.setContentMode(Label.CONTENT_XHTML); logText.setSizeFull(); //Panel to add refresher logPanel = new Panel(); logPanel.setSizeFull(); logPanel.setScrollable(true); logPanel.setStyleName(Runo.PANEL_LIGHT); logPanel.addComponent(logText); //Refresher added to show instant log messages refresher = new Refresher(); logPanel.addComponent(refresher); //Loading image loadingImg = new Embedded("", DataGenConstant.LOADING_ICON); loadingImg.setVisible(false); logPanel.addComponent(loadingImg); resultSheet.addTab(logPanel, "Console"); resultTab = resultSheet.addTab(new Label(), "Results"); queryOptions.addComponent(executeButton); queryOptions.setComponentAlignment(executeButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearQueryButton); queryOptions.setComponentAlignment(clearQueryButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearConsoleButton); queryOptions.setComponentAlignment(clearConsoleButton, Alignment.MIDDLE_LEFT); queryOptions.setExpandRatio(clearConsoleButton, 1); queryOptions.addComponent(maxRowsBox); queryOptions.setComponentAlignment(maxRowsBox, Alignment.MIDDLE_RIGHT); splitPanel.setFirstComponent(sqlScript); splitPanel.setSecondComponent(resultSheet); vl.addComponent(queryOptions); vl.addComponent(splitPanel); vl.setExpandRatio(splitPanel, 1); sqlScript.addShortcutListener(new ShortcutListener("Execute Script", null, ShortcutAction.KeyCode.ENTER, ShortcutAction.ModifierKey.CTRL) { @Override public void handleAction(Object sender, Object target) { executeScript(sqlScript.getValue().toString()); } }); log.debug("ExecutorView - constructor end"); }