List of usage examples for com.vaadin.ui ProgressBar setValue
public void setValue(float newValue)
From source file:com.cavisson.gui.dashboard.components.controls.Tables.java
License:Apache License
static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);/* w w w . ja v a 2 s . co m*/ table.setMultiSelect(true); table.setSortEnabled(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); table.setPageLength(6); table.addActionHandler(ValoThemeUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(ValoThemeUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(ValoThemeUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(ValoThemeUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(ValoThemeUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(ValoThemeUI.ICON_PROPERTY, "icon"); table.setColumnFooter(ValoThemeUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); table.setHeight("300px"); } else { table.setSizeUndefined(); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(ValoThemeUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(ValoThemeUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.esofthead.mycollab.mobile.module.project.ui.form.field.ProjectFormAttachmentUploadField.java
License:Open Source License
public ProjectFormAttachmentUploadField() { resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class); currentPollInterval = UI.getCurrent().getPollInterval(); receiver = createReceiver();// w w w. ja v a2s . com attachmentBtn = new MultiUpload(); attachmentBtn.setButtonCaption("Select File(s)"); attachmentBtn.setImmediate(true); MultiUploadHandler handler = new MultiUploadHandler() { private LinkedList<ProgressBar> indicators; @Override public void streamingStarted(StreamVariable.StreamingStartEvent event) { } @Override public void streamingFinished(StreamVariable.StreamingEndEvent event) { String tempName = event.getFileName(); final String fileName; int index = tempName.lastIndexOf("."); if (index > 0) { String fileExt = tempName.substring(index + 1, tempName.length()); fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "." + fileExt; } else { fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis(); } if (!indicators.isEmpty()) { rowWrap.replaceComponent(indicators.remove(0), MobileAttachmentUtils.renderAttachmentFieldRow( MobileAttachmentUtils.constructContent(fileName, attachmentPath), new Button.ClickListener() { private static final long serialVersionUID = 581451358291203810L; @Override public void buttonClick(Button.ClickEvent event) { fileStores.remove(fileName); } })); } if (indicators.size() == 0) { UI.getCurrent().setPollInterval(currentPollInterval); } File file = receiver.getFile(); receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived()); receiver.setValue(null); } @Override public void streamingFailed(StreamVariable.StreamingErrorEvent event) { if (!indicators.isEmpty()) { Label uploadResult = new Label("Upload failed! File: " + event.getFileName()); uploadResult.setStyleName("upload-status"); rowWrap.replaceComponent(indicators.remove(0), uploadResult); } } @Override public void onProgress(StreamVariable.StreamingProgressEvent event) { long readBytes = event.getBytesReceived(); long contentLength = event.getContentLength(); float f = (float) readBytes / (float) contentLength; indicators.get(0).setValue(f); } @Override public OutputStream getOutputStream() { MultiUpload.FileDetail next = attachmentBtn.getPendingFileNames().iterator().next(); return receiver.receiveUpload(next.getFileName(), next.getMimeType()); } @Override public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) { UI.getCurrent().setPollInterval(500); if (indicators == null) { indicators = new LinkedList<ProgressBar>(); } for (MultiUpload.FileDetail f : pendingFileNames) { ProgressBar pi = new ProgressBar(); pi.setValue(0f); pi.setStyleName("upload-progress"); pi.setWidth("100%"); rowWrap.addComponentAsFirst(pi); pi.setEnabled(true); pi.setVisible(true); indicators.add(pi); } } @Override public boolean isInterrupted() { return false; } }; attachmentBtn.setHandler(handler); fileStores = new HashMap<String, File>(); constructUI(); }
From source file:com.esofthead.mycollab.mobile.module.project.ui.ProjectCommentInput.java
License:Open Source License
private void prepareUploadField() { receiver = createReceiver();//from w w w. j av a 2s . c o m uploadField = new MultiUpload(); uploadField.setButtonCaption(""); uploadField.setImmediate(true); MultiUploadHandler handler = new MultiUploadHandler() { private LinkedList<ProgressBar> indicators; @Override public void streamingStarted(StreamVariable.StreamingStartEvent event) { } @Override public void streamingFinished(StreamVariable.StreamingEndEvent event) { String fileName = event.getFileName(); int index = fileName.lastIndexOf("."); if (index > 0) { String fileExt = fileName.substring(index + 1, fileName.length()); fileName = MobileAttachmentUtils.ATTACHMENT_NAME_PREFIX + System.currentTimeMillis() + "." + fileExt; } if (!indicators.isEmpty()) { statusWrapper.replaceComponent(indicators.remove(0), createAttachmentRow(fileName)); } if (indicators.size() == 0) { UI.getCurrent().setPollInterval(currentPollInterval); } File file = receiver.getFile(); receiveFile(file, fileName, event.getMimeType(), event.getBytesReceived()); receiver.setValue(null); } @Override public void streamingFailed(StreamVariable.StreamingErrorEvent event) { if (!indicators.isEmpty()) { Label uploadResult = new Label("Upload failed! File: " + event.getFileName()); uploadResult.setStyleName("upload-status"); statusWrapper.replaceComponent(indicators.remove(0), uploadResult); } } @Override public void onProgress(StreamVariable.StreamingProgressEvent event) { long readBytes = event.getBytesReceived(); long contentLength = event.getContentLength(); float f = (float) readBytes / (float) contentLength; indicators.get(0).setValue(f); } @Override public OutputStream getOutputStream() { MultiUpload.FileDetail next = uploadField.getPendingFileNames().iterator().next(); return receiver.receiveUpload(next.getFileName(), next.getMimeType()); } @Override public void filesQueued(Collection<MultiUpload.FileDetail> pendingFileNames) { UI.getCurrent().setPollInterval(500); if (indicators == null) { indicators = new LinkedList<ProgressBar>(); } for (MultiUpload.FileDetail f : pendingFileNames) { ProgressBar pi = new ProgressBar(); pi.setValue(0f); pi.setStyleName("upload-progress"); pi.setWidth("100%"); statusWrapper.addComponent(pi); pi.setEnabled(true); pi.setVisible(true); indicators.add(pi); } } @Override public boolean isInterrupted() { return false; } }; uploadField.setHandler(handler); }
From source file:com.etest.valo.Tables.java
License:Apache License
static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);/*from ww w . j a va2 s . c o m*/ table.setMultiSelect(true); table.setSortEnabled(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); table.setPageLength(6); table.addActionHandler(MainUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(MainUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(MainUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(MainUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(MainUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(MainUI.ICON_PROPERTY, "icon"); table.setColumnFooter(MainUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); table.setHeight("300px"); } else { table.setSizeUndefined(); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(MainUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(MainUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(MainUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.logicbomb.newschool.MyAppWidgetSet.core.DayWidget.java
public DayWidget() { //Creating Panel Panel iPanel = new Panel(); iPanel.addStyleName("backColorWhite"); iPanel.setWidth("876px"); iPanel.setHeight("41px"); ProgressBar iDayProgressBar = new ProgressBar(); iDayProgressBar.setCaption("Period 3, 10th October"); iDayProgressBar.setWidth("875px"); iDayProgressBar.setValue(0.3f); addComponent(iDayProgressBar);/*from w ww . j av a 2s . c o m*/ //Adding Panel to Vertical Layout addComponent(iPanel); VerticalLayout iVerticalLayout = new VerticalLayout(); GridLayout iGridLayout = new GridLayout(9, 1); iGridLayout.setWidth("1000px"); iGridLayout.setHeight("40px"); for (int i = 1; i <= 8; i++) { HourWidget iHourAtAGlanceWidget = new HourWidget(i, 8); iHourAtAGlanceWidget.setSizeFull(); iGridLayout.addComponent(iHourAtAGlanceWidget); iGridLayout.setColumnExpandRatio(i, 1); } iVerticalLayout.addComponent(iGridLayout); iPanel.setContent(iVerticalLayout); }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.components.SearchEngineMetaDescription.java
License:Open Source License
private Component createSEOProgressBar() { ProgressBar seoProgressBar = new ProgressBar(); seoProgressBar.setWidth("250px"); seoProgressBar.setValue(0.5f); HorizontalLayout layout = new HorizontalLayout(); layout.addComponent(new Label("SEO Rating:")); layout.addComponent(seoProgressBar); layout.setSpacing(true);// w w w . j a v a 2s .c om layout.setMargin(new MarginInfo(false, false, true, false)); NativeButton addUpdateButton = new NativeButton("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // do nothing } }); addUpdateButton.addStyleName("update-button"); addUpdateButton.setHeight("28px"); addUpdateButton.setCaption("Update"); addUpdateButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { updateMetaDescriptionPreview(textArea.getValue()); } }); layout.addComponent(addUpdateButton); return layout; }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.umbrellacontent.UmbrellaContentViewImpl.java
License:Open Source License
private Component createSEOProgressBar() { ProgressBar seoProgressBar = new ProgressBar(); seoProgressBar.setWidth("300px"); seoProgressBar.setValue(0.5f); HorizontalLayout layout = new HorizontalLayout(); layout.addComponent(new Label("SEO Rating:")); layout.addComponent(seoProgressBar); layout.setSpacing(true);//from www . j ava 2s. c om layout.setMargin(new MarginInfo(false, false, true, false)); return layout; }
From source file:com.rex.components.valo.Tables.java
License:Apache License
static void configure(Table table, Grid grid, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);/*from ww w . j a v a 2 s.c o m*/ table.setMultiSelect(true); grid.setSelectionMode(SelectionMode.MULTI); table.setSortEnabled(true); for (Column c : grid.getColumns()) { if (!c.getPropertyId().equals("icon")) { c.setSortable(true); } c.setHidable(true); } table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); grid.setColumnReorderingAllowed(true); table.setPageLength(6); grid.setHeightByRows(6); table.addActionHandler(ReportEngineUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(ReportEngineUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(ReportEngineUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(ReportEngineUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(ReportEngineUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(ReportEngineUI.ICON_PROPERTY, "icon"); table.setColumnFooter(ReportEngineUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); grid.setWidth("400px"); table.setHeight("300px"); grid.setHeight("300px"); } else { table.setSizeUndefined(); grid.setSizeUndefined(); } if (componentsInRows) { table.setWidth("100%"); } else { table.setWidth(null); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(ReportEngineUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(ReportEngineUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.DataHandler.java
License:Open Source License
/** * Method to get Bean from either openbis identifier or openbis object. Does NOT check if * corresponding bean is already stored in datahandler map. Should be used if project instance has * been modified from session/* w w w . j av a 2 s. c o m*/ * * @param * @return */ public ProjectBean getProjectFromDB(String projectIdentifier) { List<Experiment> experiments = this.getOpenBisClient().getExperimentsForProject2(projectIdentifier); float projectStatus = this.getOpenBisClient().computeProjectStatus(experiments); Project project = getOpenBisClient().getProjectByIdentifier(projectIdentifier); dtoProjects.put(projectIdentifier, project); ProjectBean newProjectBean = new ProjectBean(); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(projectStatus); Date registrationDate = project.getRegistrationDetails().getRegistrationDate(); // String pi = getDatabaseManager().getInvestigatorDetailsForProject(project.getCode()); String pi = getDatabaseManager().getPersonDetailsForProject(project.getIdentifier(), "PI"); String cp = getDatabaseManager().getPersonDetailsForProject(project.getIdentifier(), "Contact"); // String manager = getDatabaseManager().getPersonDetailsForProject(project.getIdentifier(), // "Manager");//TODO String manager = ""; String longDesc = getDatabaseManager().getLongProjectDescription(project.getIdentifier()); if (pi.equals("")) { newProjectBean.setPrincipalInvestigator("n/a"); } else { newProjectBean.setPrincipalInvestigator(pi); } if (cp.equals("")) { newProjectBean.setContactPerson("n/a"); } else { newProjectBean.setContactPerson(cp); } if (manager.equals("")) { newProjectBean.setProjectManager("n/a"); } else { newProjectBean.setProjectManager(manager); } String secondaryName = getDatabaseManager().getProjectName(projectIdentifier); if (secondaryName == null || secondaryName.isEmpty()) secondaryName = "n/a"; newProjectBean.setSecondaryName(secondaryName); if (longDesc == null) longDesc = ""; newProjectBean.setId(project.getIdentifier()); newProjectBean.setCode(project.getCode()); String desc = project.getDescription(); if (desc == null) desc = ""; newProjectBean.setDescription(desc); newProjectBean.setRegistrationDate(registrationDate); newProjectBean.setProgress(progressBar); newProjectBean.setRegistrator(project.getRegistrationDetails().getUserId()); newProjectBean.setContact(project.getRegistrationDetails().getUserEmail()); BeanItemContainer<ExperimentBean> experimentBeans = new BeanItemContainer<ExperimentBean>( ExperimentBean.class); for (Experiment experiment : experiments) { ExperimentBean newExperimentBean = new ExperimentBean(); String status = ""; Map<String, String> assignedProperties = experiment.getProperties(); if (assignedProperties.keySet().contains("Q_CURRENT_STATUS")) { status = assignedProperties.get("Q_CURRENT_STATUS"); } else if (assignedProperties.keySet().contains("Q_WF_STATUS")) { status = assignedProperties.get("Q_WF_STATUS"); } // Image statusColor = new Image(status, this.setExperimentStatusColor(status)); // statusColor.setWidth("15px"); // statusColor.setHeight("15px"); // statusColor.setCaption(status); newExperimentBean.setId(experiment.getIdentifier()); newExperimentBean.setCode(experiment.getCode()); newExperimentBean.setType(experiment.getExperimentTypeCode()); newExperimentBean.setStatus(status); newExperimentBean.setRegistrator(experiment.getRegistrationDetails().getUserId()); newExperimentBean.setRegistrationDate(experiment.getRegistrationDetails().getRegistrationDate()); experimentBeans.addBean(newExperimentBean); } newProjectBean.setLongDescription(longDesc); List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> projectData = this.getOpenBisClient() .getDataSetsOfProjectByIdentifierWithSearchCriteria(projectIdentifier); Boolean containsData = false; Boolean containsResults = false; Boolean attachmentResult = false; // Boolean containsAttachments = false; for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet ds : projectData) { attachmentResult = false; if (ds.getDataSetTypeCode().equals("Q_PROJECT_DATA")) { attachmentResult = ds.getProperties().get("Q_ATTACHMENT_TYPE").equals("RESULT"); } if (!(ds.getDataSetTypeCode().equals("Q_PROJECT_DATA")) && !(ds.getDataSetTypeCode().contains("RESULTS"))) { containsData = true; } else if (ds.getDataSetTypeCode().contains("RESULTS") || attachmentResult) { containsResults = true; } // else if (ds.getDataSetTypeCode() == "Q_PROJECT_DATA") { // containsAttachments = true; // } } newProjectBean.setContainsData(containsData); newProjectBean.setContainsResults(containsResults); newProjectBean.setExperiments(experimentBeans); newProjectBean.setMembers(new HashSet<String>()); return newProjectBean; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.DataHandler.java
License:Open Source License
/** * Method to get Bean from either openbis identifier or openbis object. Checks if corresponding * bean is already stored in datahandler map. * /*w w w.j av a 2s . co m*/ * @param * @return */ public ProjectBean getProject2(String projectIdentifier) { List<Experiment> experiments = this.getOpenBisClient().getExperimentsForProject3(projectIdentifier);// TODO changed this // from // getExperimentsForProject2 float projectStatus = this.getOpenBisClient().computeProjectStatus(experiments); Project project = getOpenbisDtoProject(projectIdentifier); if (project == null) { project = getOpenBisClient().getProjectByIdentifier(projectIdentifier); addOpenbisDtoProject(project); } ProjectBean newProjectBean = new ProjectBean(); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(projectStatus); Date registrationDate = project.getRegistrationDetails().getRegistrationDate(); // String pi = getDatabaseManager().getInvestigatorDetailsForProject(project.getCode()); String pi = getDatabaseManager().getPersonDetailsForProject(project.getIdentifier(), "PI"); String cp = getDatabaseManager().getPersonDetailsForProject(project.getIdentifier(), "Contact"); String manager = getDatabaseManager().getPersonDetailsForProject(project.getIdentifier(), "Manager"); String longDesc = getDatabaseManager().getLongProjectDescription(project.getIdentifier()); if (pi.equals("")) { newProjectBean.setPrincipalInvestigator("n/a"); } else { newProjectBean.setPrincipalInvestigator(pi); } if (cp.equals("")) { newProjectBean.setContactPerson("n/a"); } else { newProjectBean.setContactPerson(cp); } if (manager.equals("")) { newProjectBean.setProjectManager("n/a"); } else { newProjectBean.setProjectManager(manager); } if (longDesc == null) longDesc = ""; newProjectBean.setLongDescription(longDesc); newProjectBean.setId(project.getIdentifier()); newProjectBean.setCode(project.getCode()); String desc = project.getDescription(); if (desc == null) desc = ""; newProjectBean.setDescription(desc); newProjectBean.setRegistrationDate(registrationDate); newProjectBean.setProgress(progressBar); newProjectBean.setRegistrator(project.getRegistrationDetails().getUserId()); newProjectBean.setContact(project.getRegistrationDetails().getUserEmail()); // Create sample Beans (or fetch them) for samples of experiments List<Sample> allSamples = this.getOpenBisClient() .getSamplesWithParentsAndChildrenOfProjectBySearchService(projectIdentifier); BeanItemContainer<ExperimentBean> experimentBeans = new BeanItemContainer<ExperimentBean>( ExperimentBean.class); AlternativeSecondaryNameCreator altNameCreator = new AlternativeSecondaryNameCreator( openBisClient.getVocabCodesAndLabelsForVocab("Q_NCBI_TAXONOMY")); for (Experiment experiment : experiments) { ExperimentBean newExperimentBean = new ExperimentBean(); // TODO doesn't work with getExperimentsForProject2 Map<String, String> assignedProperties = experiment.getProperties(); String status = ""; if (assignedProperties.keySet().contains("Q_CURRENT_STATUS")) { status = assignedProperties.get("Q_CURRENT_STATUS"); } else if (assignedProperties.keySet().contains("Q_WF_STATUS")) { status = assignedProperties.get("Q_WF_STATUS"); } List<Sample> samples = new ArrayList<Sample>(); for (Sample s : allSamples) { if (s.getExperimentIdentifierOrNull().equals(experiment.getIdentifier())) samples.add(s); } BeanItemContainer<SampleBean> sampleBeans = new BeanItemContainer<SampleBean>(SampleBean.class); for (Sample sample : samples) { SampleBean sbean = new SampleBean(); sbean.setId(sample.getIdentifier()); sbean.setCode(sample.getCode()); sbean.setType(sample.getSampleTypeCode()); sbean.setProperties(sample.getProperties()); sampleBeans.addBean(sbean); } newExperimentBean.setSamples(sampleBeans); newExperimentBean.setAltNameCreator(altNameCreator); newExperimentBean.setProperties(assignedProperties); newExperimentBean.setSecondaryName(assignedProperties.get("Q_SECONDARY_NAME")); newExperimentBean.setId(experiment.getIdentifier()); newExperimentBean.setCode(experiment.getCode()); newExperimentBean.setType(experiment.getExperimentTypeCode()); newExperimentBean.setRegistrator(experiment.getRegistrationDetails().getUserId()); newExperimentBean.setRegistrationDate(experiment.getRegistrationDetails().getRegistrationDate()); newExperimentBean.setStatus(status); experimentBeans.addBean(newExperimentBean); } List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet> projectData = this.getOpenBisClient() .getDataSetsOfProjectByIdentifierWithSearchCriteria(projectIdentifier); Boolean containsData = false; Boolean containsResults = false; Boolean attachmentResult = false; // Boolean containsAttachments = false; for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet ds : projectData) { attachmentResult = false; if (ds.getDataSetTypeCode().equals("Q_PROJECT_DATA")) { attachmentResult = ds.getProperties().get("Q_ATTACHMENT_TYPE").equals("RESULT"); } if (!(ds.getDataSetTypeCode().equals("Q_PROJECT_DATA")) && !(ds.getDataSetTypeCode().contains("RESULTS"))) { containsData = true; } else if (ds.getDataSetTypeCode().contains("RESULTS") || attachmentResult) { containsResults = true; } // else if (ds.getDataSetTypeCode() == "Q_PROJECT_DATA") { // containsAttachments = true; // } } newProjectBean.setContainsData(containsData); newProjectBean.setContainsResults(containsResults); // newProjectBean.setContainsAttachments(containsAttachments); newProjectBean.setExperiments(experimentBeans); newProjectBean.setMembers(new HashSet<String>()); String secondaryName = getDatabaseManager().getProjectName(projectIdentifier); if (secondaryName == null || secondaryName.isEmpty()) secondaryName = "n/a"; newProjectBean.setSecondaryName(secondaryName); return newProjectBean; }