List of usage examples for com.vaadin.ui Window Window
public Window()
From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java
License:Open Source License
private void showHTML(final String htmlContent, final Application app) throws IllegalArgumentException, NullPointerException { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = -2307854110750435145L; {/*from w w w . j a va 2 s. c o m*/ center(); setWidth("75%"); setHeight("600px"); StreamResource.StreamSource source = new StreamResource.StreamSource() { private static final long serialVersionUID = -3745013501121916404L; public InputStream getStream() { return new ByteArrayInputStream(htmlContent.getBytes()); } }; StreamResource resource = new StreamResource(source, "TestReport.html", app); Embedded e = new Embedded(); e.setMimeType("text/html"); e.setType(Embedded.TYPE_BROWSER); e.setWidth("100%"); e.setHeight("590px"); e.setSource(resource); addComponent(e); } }); }
From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java
License:Open Source License
private void createSubmissionButtons(final VaadinTestApplication app, final SubmissionIO submissionIO, final nl.amc.biolab.datamodel.objects.Error error) { final Link statusLink = new Link("download", new StreamResource(new StreamSource() { private static final long serialVersionUID = 2010850543250392280L; public InputStream getStream() { String status;//from w ww . j a va 2s .com if (error != null) { status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription(); } else { status = "No message"; } return new ByteArrayInputStream(status.getBytes()); } }, "status", getApplication()), "", 400, 300, 2); viewStatusButton = new NativeButton("Details"); viewStatusButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -8337533736203519683L; @Override public void buttonClick(ClickEvent event) { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = 1520192489661790818L; { center(); setWidth("700px"); setHeight("500px"); VerticalLayout vl = new VerticalLayout(); vl.addComponent(statusLink); String status; if (error != null) { status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription(); } else { status = "No message"; } //status += "<img src=\"images/prov.png\""; vl.addComponent(new Label(status, Label.CONTENT_PREFORMATTED)); addComponent(vl); } }); } }); resubmitButton = new NativeButton("Resume"); resubmitButton.setData(processingStatusForm); resubmitButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -6410875548044234734L; @Override public void buttonClick(ClickEvent event) { long dbId = processingStatus.getProcessing().getDbId(); long liferayID = app.getLiferayId(processingStatus.getProcessing().getUser().getLiferayID()); processingService.resubmit(dbId, submissionIO.getSubmission().getDbId(), userDataService.getUserId(), liferayID); processingStatusForm.attach(); } }); markFailButton = new NativeButton("Abort"); markFailButton.setData(processingStatusForm); markFailButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -5019762936706219454L; @Override public void buttonClick(ClickEvent event) { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = 3852384470521127702L; { final Window window = this; center(); setWidth("500px"); setHeight("300px"); VerticalLayout vl = new VerticalLayout(); final TextField text = new TextField("Remarks to the user"); text.setWidth("97%"); text.setHeight("150px"); vl.addComponent(text); final Button okButton = new NativeButton(); okButton.setCaption("Save"); okButton.setImmediate(true); okButton.setWidth("-1px"); okButton.setHeight("-1px"); okButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1754437322024958253L; public void buttonClick(ClickEvent event) { long dbId = processingStatus.getProcessing().getDbId(); long userID = processingStatus.getProcessing().getUser().getDbId(); long liferayID = app .getLiferayId(processingStatus.getProcessing().getUser().getLiferayID()); processingService.markFailed(submissionIO.getSubmission().getDbId(), (String) text.getValue()); processingStatus = processingService.getProcessingStatus( userDataService.getProcessing(dbId), userID, liferayID, false); refreshButton.setData(processingStatus); processingStatusForm.fireValueChange(false);//fireEvent(new Event(refreshButton)); window.getParent().removeWindow(window); } }); vl.addComponent(okButton); addComponent(vl); } }); } }); // } remarksButton = new NativeButton("Why?"); remarksButton.addListener(new Button.ClickListener() { private static final long serialVersionUID = -267778012100029422L; @Override public void buttonClick(ClickEvent event) { app.getMainWindow().addWindow(new Window() { private static final long serialVersionUID = -5026454769214596711L; { List<nl.amc.biolab.datamodel.objects.Error> temp = submissionIO.getSubmission().getErrors(); center(); setWidth("700px"); setHeight("500px"); VerticalLayout vl = new VerticalLayout(); vl.addComponent( new Label(temp.get(temp.size() - 1).getMessage(), Label.CONTENT_PREFORMATTED)); addComponent(vl); } }); } }); }
From source file:org.accelerators.activiti.admin.ui.GroupTab.java
License:Open Source License
@Override public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == create) { /* Create a new popup window. */ popupWindow = new Window(); popupWindow.center();/* w ww.jav a 2 s. c om*/ popupWindow.setModal(true); popupWindow.setWidth("400px"); popupWindow.addStyleName(Consts.POPUP); // Set caption popupWindow.setCaption(app.getMessage(Messages.CreateGroup)); // Create form if (form == null) { form = new GroupCreateForm(app); } // Init form form.setItemDataSource(app.getAdminService().newGroup()); // Add form popupWindow.addComponent(form); // Add the window inside the main window. app.getMainWindow().addWindow(popupWindow); // Listen for close events for the window. popupWindow.addListener(this); } else if (source == refresh) { // Refresh table table.refresh(); } }
From source file:org.accelerators.activiti.admin.ui.GroupTable.java
License:Open Source License
/** * Edit the group//from www . ja v a 2s. co m * * @param itemId * the BeanItem id of the group */ private void editGroup(Object itemId) { Item item = getItem(itemId); // Create form if (form == null) { form = new GroupEditForm(app); } if (item != form.getItemDataSource()) { // Set double-clicked item form.setItemDataSource(item); /* Create a new popup window. */ popupWindow = new Window(); popupWindow.center(); popupWindow.setModal(true); popupWindow.setWidth("400px"); popupWindow.addStyleName(Consts.POPUP); // Set caption popupWindow.setCaption(app.getMessage(Messages.EditGroup)); // Add form popupWindow.addComponent(form); // Listen for close events for the window. popupWindow.addListener(this); } // Add the window inside the main window. app.getMainWindow().addWindow(popupWindow); }
From source file:org.accelerators.activiti.admin.ui.UserTab.java
License:Open Source License
@Override public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == create) { /* Create a new popup window. */ popupWindow = new Window(); popupWindow.center();//from w ww . jav a2 s . c o m popupWindow.setModal(true); popupWindow.setWidth("400px"); popupWindow.addStyleName(Consts.POPUP); // Set caption popupWindow.setCaption(app.getMessage(Messages.CreateUser)); // Create form if (form == null) { form = new UserCreateForm(app); } // Init form form.setItemDataSource(app.getAdminService().newUser()); // Add form popupWindow.addComponent(form); // Add the window inside the main window. app.getMainWindow().addWindow(popupWindow); // Listen for close events for the window. popupWindow.addListener(this); } else if (source == refresh) { // Refresh table table.refresh(); } }
From source file:org.accelerators.activiti.admin.ui.UserTable.java
License:Open Source License
/** * Edit the user//from ww w . j a v a2 s .co m * * @param itemId * the BeanItem id of the user */ private void editUser(Object itemId) { Item item = getItem(itemId); // Edit form if (form == null) { form = new UserEditForm(app); } if (item != form.getItemDataSource()) { // Set double-clicked item form.setItemDataSource(item); // Create a new popup window popupWindow = new Window(); popupWindow.center(); popupWindow.setModal(true); popupWindow.setWidth("400px"); popupWindow.addStyleName(Consts.POPUP); // Set caption popupWindow.setCaption(app.getMessage(Messages.EditUser)); // Add form popupWindow.addComponent(form); // Listen for close events for the window. popupWindow.addListener(this); } // Add the window inside the main window. app.getMainWindow().addWindow(popupWindow); }
From source file:org.activiti.administrator.ui.GroupTab.java
License:Apache License
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == create) { /* Create a new popup window. */ popupWindow = new Window(); popupWindow.center();/*from w w w . j a v a 2s. co m*/ popupWindow.setModal(true); popupWindow.setWidth("400px"); popupWindow.addStyleName(Consts.POPUP); // Set caption popupWindow.setCaption(app.getMessage(Messages.CreateGroup)); // Create form if (form == null) { form = new GroupCreateForm(app); } // Init form form.setItemDataSource(app.getAdminService().newGroup()); // Add form popupWindow.addComponent(form); // Add the window inside the main window. app.getMainWindow().addWindow(popupWindow); // Listen for close events for the window. popupWindow.addListener(this); } else if (source == refresh) { // Refresh table table.refresh(); } }
From source file:org.activiti.administrator.ui.UserTab.java
License:Apache License
public void buttonClick(ClickEvent event) { Button source = event.getButton(); if (source == create) { /* Create a new popup window. */ popupWindow = new Window(); popupWindow.center();// w w w . j ava2 s. c o m popupWindow.setModal(true); popupWindow.setWidth("400px"); popupWindow.addStyleName(Consts.POPUP); // Set caption popupWindow.setCaption(app.getMessage(Messages.CreateUser)); // Create form if (form == null) { form = new UserCreateForm(app); } // Init form form.setItemDataSource(app.getAdminService().newUser()); // Add form popupWindow.addComponent(form); // Add the window inside the main window. app.getMainWindow().addWindow(popupWindow); // Listen for close events for the window. popupWindow.addListener(this); } else if (source == refresh) { // Refresh table table.refresh(); } }
From source file:org.azrul.langkuik.framework.webgui.BeanView.java
private void createForm(EntityRight entityRight, final Set<String> currentUserRoles, final Map<String, Map<Integer, FieldContainer>> groups, String group, final BeanFieldGroup fieldGroup, final List<DataAccessObject<?>> customTypeDaos, final Navigator nav, final FormLayout form) throws FieldGroup.BindException, UnsupportedOperationException { //create bean utils final BeanUtils beanUtils = new BeanUtils(); //select which group we want Map<Integer, FieldContainer> fieldContainerMap = null; if (group == null) { fieldContainerMap = groups.entrySet().iterator().next().getValue(); } else {/*w ww . jav a 2 s . c om*/ fieldContainerMap = groups.get(group); } //collect all activechoices Map<com.vaadin.ui.ComboBox, ActiveChoiceTarget> activeChoicesWithFieldAsKey = new HashMap<>(); Map<String, com.vaadin.ui.ComboBox> activeChoicesFieldWithHierarchyAsKey = new HashMap<>(); //collect all cutsom types List<Class> customTypes = new ArrayList<>(); for (DataAccessObject<?> ctDao : customTypeDaos) { customTypes.add(ctDao.getType()); } //deal with every field everyField: for (Map.Entry<Integer, FieldContainer> entry : fieldContainerMap.entrySet()) { final FieldContainer fieldContainer = entry.getValue(); final ComponentState effectiveFieldState = beanUtils .calculateEffectiveComponentState(fieldContainer.getPojoField(), currentUserRoles, entityRight); //Create form if (ComponentState.INVISIBLE.equals(effectiveFieldState)) { continue everyField; //Continue with next field } //deal with normal form element com.vaadin.ui.Field uifield = null; //deal with plain choices if (fieldContainer.getWebField().choices().length > 0) { //deal with choices com.vaadin.ui.ComboBox formComboBox = new com.vaadin.ui.ComboBox( fieldContainer.getWebField().name()); formComboBox.setImmediate(true); fieldGroup.bind(formComboBox, fieldContainer.getPojoField().getName()); for (Choice choice : fieldContainer.getWebField().choices()) { if (choice.value() == -1) { formComboBox.addItem(choice.textValue()); formComboBox.setItemCaption(choice.textValue(), choice.display()); } else { formComboBox.addItem(choice.value()); formComboBox.setItemCaption(choice.value(), choice.display()); } } form.addComponent(formComboBox); uifield = formComboBox; //deal with active choices } else if (fieldContainer.getWebField().activeChoice().enumTree() != EmptyEnum.class) { //collect active choices - com.vaadin.ui.ComboBox formComboBox = new com.vaadin.ui.ComboBox( fieldContainer.getWebField().name()); formComboBox.setImmediate(true); fieldGroup.bind(formComboBox, fieldContainer.getPojoField().getName()); String hierarchy = fieldContainer.getWebField().activeChoice().hierarchy(); Class<ActiveChoiceEnum> enumTree = (Class<ActiveChoiceEnum>) fieldContainer.getWebField() .activeChoice().enumTree(); ActiveChoiceTarget activeChoiceTarget = ActiveChoiceUtils.build(enumTree, hierarchy); for (String choice : activeChoiceTarget.getSourceChoices()) { formComboBox.addItem(choice); activeChoicesWithFieldAsKey.put(formComboBox, activeChoiceTarget); activeChoicesFieldWithHierarchyAsKey.put(hierarchy, formComboBox); } form.addComponent(formComboBox); uifield = formComboBox; //deal with relationship } else if (fieldContainer.getPojoField().isAnnotationPresent(OneToMany.class) || fieldContainer.getPojoField().isAnnotationPresent(ManyToOne.class) || fieldContainer.getPojoField().isAnnotationPresent(ManyToMany.class)) { //special relationship: deal with custom type form element int state = 0; Class classOfField = null; while (true) { if (state == 0) { if (Collection.class.isAssignableFrom(fieldContainer.getPojoField().getType())) { classOfField = (Class) ((ParameterizedType) fieldContainer.getPojoField() .getGenericType()).getActualTypeArguments()[0]; state = 1; } else { state = 3; break; } } if (state == 1) { if (CustomType.class.isAssignableFrom(classOfField)) { state = 2; break; } else { state = 3; break; } } } if (state == 2) { //Custom type Button openCustom = new Button("Manage " + fieldContainer.getWebField().name(), new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { fieldGroup.commit(); currentBean = (C) fieldGroup.getItemDataSource().getBean(); currentBean = saveBean(currentBean, parentBean, beanUtils, currentUserRoles); fieldGroup.setItemDataSource(currentBean); //field class Class iclassOfField = (Class) ((ParameterizedType) fieldContainer .getPojoField().getGenericType()).getActualTypeArguments()[0]; //find a custom type dao DataAccessObject<? extends CustomType> chosenCTDao = null; for (DataAccessObject cdao : customTypeDaos) { if (cdao.getType().isAssignableFrom(iclassOfField)) { chosenCTDao = cdao; break; } } //deal with windows final Window window = new Window(); final AttachmentCustomTypeUICreator<C> attachmentCustomTypeUICreator = new AttachmentCustomTypeUICreator(); Component customTypeComponent = attachmentCustomTypeUICreator .createUIForForm(currentBean, iclassOfField, fieldContainer.getPojoField().getName(), BeanView.this, dao, chosenCTDao, pageParameter.getRelationManagerFactory(), pageParameter.getConfig(), effectiveFieldState, window); customTypeComponent .setCaption("Manage " + fieldContainer.getWebField().name()); customTypeComponent.setId(customTypeComponent.getCaption()); window.setCaption(customTypeComponent.getCaption()); window.setId(window.getCaption()); window.setContent(customTypeComponent); window.setModal(true); BeanView.this.getUI().addWindow(window); } catch (CommitException ex) { handleFieldsError(fieldGroup); } } }); openCustom.setId(openCustom.getCaption()); form.addComponent(openCustom); } else { //relationship try { fieldContainer.getPojoField().setAccessible(true); final WebField webField = fieldContainer.getPojoField().getAnnotation(WebField.class); Button relationshipButton = null; if (fieldContainer.getPojoField().isAnnotationPresent(OneToMany.class)) { relationshipButton = new Button("Manage " + webField.name(), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { fieldGroup.commit(); currentBean = (C) fieldGroup.getItemDataSource().getBean(); currentBean = saveBean(currentBean, parentBean, beanUtils, currentUserRoles); Class classOfField = (Class) ((ParameterizedType) fieldContainer .getPojoField().getGenericType()) .getActualTypeArguments()[0]; EditorTableView view = new EditorTableView(currentBean, fieldContainer.getPojoField().getName(), effectiveFieldState, classOfField, ChoiceType.CHOOSE_MANY, pageParameter); String targetView = "BEAN_VIEW_" + UUID.randomUUID().toString(); History his = new History(targetView, "Manage " + webField.name()); pageParameter.getHistory().push(his); nav.addView(targetView, view); nav.navigateTo(targetView); } catch (CommitException ex) { handleFieldsError(fieldGroup); } } }); } else if (fieldContainer.getPojoField().isAnnotationPresent(ManyToOne.class)) { relationshipButton = new Button("Manage " + webField.name(), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { fieldGroup.commit(); currentBean = (C) fieldGroup.getItemDataSource().getBean(); fieldGroup.commit(); currentBean = (C) fieldGroup.getItemDataSource().getBean(); currentBean = saveBean(currentBean, parentBean, beanUtils, currentUserRoles); EditorTableView view = new EditorTableView(currentBean, fieldContainer.getPojoField().getName(), effectiveFieldState, fieldContainer.getPojoField().getType(), ChoiceType.CHOOSE_ONE, pageParameter); String targetView = "BEAN_VIEW_" + UUID.randomUUID().toString(); History his = new History(targetView, "Manage " + webField.name()); pageParameter.getHistory().push(his); nav.addView(targetView, view); nav.navigateTo(targetView); } catch (CommitException ex) { handleFieldsError(fieldGroup); } } }); } else if (fieldContainer.getPojoField().isAnnotationPresent(ManyToMany.class)) { relationshipButton = new Button("Manage " + webField.name(), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { try { fieldGroup.commit(); currentBean = (C) fieldGroup.getItemDataSource().getBean(); fieldGroup.commit(); currentBean = (C) fieldGroup.getItemDataSource().getBean(); currentBean = saveBean(currentBean, parentBean, beanUtils, currentUserRoles); Class classOfField = (Class) ((ParameterizedType) fieldContainer .getPojoField().getGenericType()) .getActualTypeArguments()[0]; EditorTableView view = new EditorTableView(currentBean, fieldContainer.getPojoField().getName(), effectiveFieldState, classOfField, ChoiceType.CHOOSE_MANY, pageParameter); String targetView = "BEAN_VIEW_" + UUID.randomUUID().toString(); History his = new History(targetView, "Manage " + webField.name()); pageParameter.getHistory().push(his); nav.addView(targetView, view); nav.navigateTo(targetView); } catch (CommitException ex) { handleFieldsError(fieldGroup); } } }); } relationshipButton.setId(relationshipButton.getCaption()); form.addComponent(relationshipButton); } catch (IllegalArgumentException ex) { Logger.getLogger(BeanView.class.getName()).log(Level.SEVERE, null, ex); } } //deal with id } else if (fieldContainer.getPojoField().isAnnotationPresent(Id.class)) { com.vaadin.ui.Field formField = fieldGroup.buildAndBind(fieldContainer.getWebField().name(), fieldContainer.getPojoField().getName()); if (Number.class.isAssignableFrom(fieldContainer.getPojoField().getType())) { ((TextField) formField).setConverter( new NumberBasedIDConverter((Class<Number>) fieldContainer.getPojoField().getType())); } form.addComponent(formField); uifield = formField; //deal with nominal form element } else { com.vaadin.ui.Field formField = fieldGroup.buildAndBind(fieldContainer.getWebField().name(), fieldContainer.getPojoField().getName()); if (fieldContainer.getPojoField().getType().equals(Date.class)) { //deal with date DateField dateField = (DateField) formField; dateField.setDateFormat(pageParameter.getConfig().get("dateFormat")); dateField.setWidth(100f, Unit.PIXELS); } else if (fieldContainer.getPojoField().getType().equals(BigDecimal.class)) { TextField bdField = (TextField) formField; bdField.setConverter(new StringToBigDecimalConverter()); } form.addComponent(formField); uifield = formField; } if (uifield != null) { //deal with read only if (ComponentState.READ_ONLY.equals(effectiveFieldState)) { uifield.setReadOnly(true); } else { uifield.setReadOnly(false); if (fieldContainer.getWebField().required() == true) { uifield.setRequired(true); } } //set null presentation if (uifield instanceof AbstractTextField) { AbstractTextField textField = (AbstractTextField) uifield; textField.setNullRepresentation(""); } //set debug id uifield.setId(uifield.getCaption()); } } //deal with active choice for (final com.vaadin.ui.ComboBox sourceField : activeChoicesWithFieldAsKey.keySet()) { final ActiveChoiceTarget target = activeChoicesWithFieldAsKey.get(sourceField); final com.vaadin.ui.ComboBox targetField = activeChoicesFieldWithHierarchyAsKey .get(target.getTargetHierarchy()); sourceField.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { List<String> targetValues = target.getTargets().get(sourceField.getValue()); if (targetValues != null && !targetValues.isEmpty() && targetField != null) { targetField.removeAllItems(); for (String targetValue : targetValues) { targetField.addItem(targetValue); } } } }); } }
From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java
License:Open Source License
private void buildLayout() { final HorizontalLayout footer = getFooterLayout(); uploadArtifactDetails = new VerticalLayout(); uploadArtifactDetails.setWidth(SPUIDefinitions.MIN_UPLOAD_CONFIRMATION_POPUP_WIDTH + "px"); uploadArtifactDetails.addStyleName("confirmation-popup"); uploadArtifactDetails.addComponent(uploadDetailsTable); uploadArtifactDetails.setComponentAlignment(uploadDetailsTable, Alignment.MIDDLE_CENTER); uploadArtifactDetails.addComponent(footer); uploadArtifactDetails.setComponentAlignment(footer, Alignment.MIDDLE_CENTER); window = new Window(); window.setContent(uploadArtifactDetails); window.setResizable(Boolean.FALSE); window.setClosable(Boolean.TRUE); window.setDraggable(Boolean.TRUE); window.setModal(true);/*from www . ja v a 2s . co m*/ window.addCloseListener(event -> onPopupClose()); window.setCaption(i18n.getMessage("header.caption.upload.details")); window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION); }