List of usage examples for com.vaadin.ui Window setContent
@Override public void setContent(Component content)
From source file:lu.uni.lassy.excalibur.examples.icrash.dev.web.java.views.CoordMobileAuthView.java
License:Open Source License
public CoordMobileAuthView(String CoordID) { CtCoordinator ctCoordinator = (CtCoordinator) sys .getCtCoordinator(new DtCoordinatorID(new PtString(CoordID))); ActCoordinator actCoordinator = sys.getActCoordinator(ctCoordinator); actCoordinator.setActorUI(UI.getCurrent()); env.setActCoordinator(actCoordinator.getName(), actCoordinator); IcrashSystem.assCtAuthenticatedActAuthenticated.replace(ctCoordinator, actCoordinator); IcrashSystem.assCtCoordinatorActCoordinator.replace(ctCoordinator, actCoordinator); thisCoordID = CoordID;/*from www .jav a 2 s . co m*/ setResponsive(true); setWidth("100%"); NavigationBar alertsBar = new NavigationBar(); VerticalComponentGroup alertsContent = new VerticalComponentGroup(); alertsContent.setWidth("100%"); alertsContent.setResponsive(true); HorizontalLayout alertButtons1 = new HorizontalLayout(); HorizontalLayout alertButtons2 = new HorizontalLayout(); //alertButtons.setMargin(true); //alertButtons.setSpacing(true); alertsBar.setCaption("Coordinator " + ctCoordinator.login.toString()); // NavigationButton logoutBtn1 = new NavigationButton("Logout"); Button logoutBtn1 = new Button("Logout"); alertsBar.setRightComponent(logoutBtn1); alertsTable = new Grid(); alertsTable.setContainerDataSource(actCoordinator.getAlertsContainer()); alertsTable.setColumnOrder("ID", "date", "time", "longitude", "latitude", "comment", "status"); alertsTable.setSelectionMode(SelectionMode.SINGLE); alertsTable.setWidth("100%"); alertsTable.setResponsive(true); //alertsTable.setSizeUndefined(); alertsTable.setImmediate(true); Grid inputEventsTable1 = new Grid(); inputEventsTable1.setContainerDataSource(actCoordinator.getMessagesDataSource()); inputEventsTable1.setWidth("100%"); inputEventsTable1.setResponsive(true); alertsContent.addComponents(alertsBar, alertButtons1, alertButtons2, alertsTable, inputEventsTable1); Tab alertsTab = this.addTab(alertsContent); alertsTab.setCaption("Alerts"); alertStatus = new NativeSelect(); alertStatus.setNullSelectionAllowed(false); alertStatus.addItems("Pending", "Valid", "Invalid"); alertStatus.setImmediate(true); alertStatus.select("Pending"); Button validateAlertBtn = new Button("Validate"); Button invalidateAlertBtn = new Button("Invalidate"); Button getAlertsSetBtn = new Button("Get alerts set"); validateAlertBtn.setImmediate(true); invalidateAlertBtn.setImmediate(true); validateAlertBtn.addClickListener(event -> { AlertBean selectedAlertBean = (AlertBean) alertsTable.getSelectedRow(); Integer thisAlertID = new Integer(selectedAlertBean.getID()); PtBoolean res; res = sys.oeValidateAlert(new DtAlertID(new PtString(thisAlertID.toString()))); }); invalidateAlertBtn.addClickListener(event -> { AlertBean selectedAlertBean = (AlertBean) alertsTable.getSelectedRow(); Integer thisAlertID = new Integer(selectedAlertBean.getID()); PtBoolean res; res = sys.oeInvalidateAlert(new DtAlertID(new PtString(thisAlertID.toString()))); }); getAlertsSetBtn.addClickListener(event -> { if (alertStatus.getValue().toString().equals("Pending")) actCoordinator.oeGetAlertsSet(EtAlertStatus.pending); else if (alertStatus.getValue().toString().equals("Valid")) actCoordinator.oeGetAlertsSet(EtAlertStatus.valid); else if (alertStatus.getValue().toString().equals("Invalid")) actCoordinator.oeGetAlertsSet(EtAlertStatus.invalid); }); alertButtons1.addComponents(validateAlertBtn, invalidateAlertBtn); alertButtons2.addComponents(getAlertsSetBtn, alertStatus); ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// NavigationBar crisesBar = new NavigationBar(); VerticalComponentGroup crisesContent = new VerticalComponentGroup(); crisesContent.setWidth("100%"); crisesContent.setResponsive(true); HorizontalLayout crisesButtons1 = new HorizontalLayout(); HorizontalLayout crisesButtons2 = new HorizontalLayout(); crisesBar.setCaption("Coordinator " + ctCoordinator.login.toString()); //NavigationButton logoutBtn2 = new NavigationButton("Logout"); Button logoutBtn2 = new Button("Logout"); crisesBar.setRightComponent(logoutBtn2); crisesTable = new Grid(); crisesTable.setContainerDataSource(actCoordinator.getCrisesContainer()); crisesTable.setColumnOrder("ID", "date", "time", "type", "longitude", "latitude", "comment", "status"); crisesTable.setSelectionMode(SelectionMode.SINGLE); crisesTable.setWidth("100%"); //crisesTable.setSizeUndefined(); crisesTable.setImmediate(true); crisesTable.setResponsive(true); Grid inputEventsTable2 = new Grid(); inputEventsTable2.setContainerDataSource(actCoordinator.getMessagesDataSource()); inputEventsTable2.setWidth("100%"); inputEventsTable2.setResponsive(true); crisesContent.addComponents(crisesBar, crisesButtons1, crisesButtons2, crisesTable, inputEventsTable2); Tab crisesTab = this.addTab(crisesContent); crisesTab.setCaption("Crises"); Button handleCrisesBtn = new Button("Handle"); Button reportOnCrisisBtn = new Button("Report"); Button changeCrisisStatusBtn = new Button("Status"); Button closeCrisisBtn = new Button("Close"); Button getCrisesSetBtn = new Button("Get crises set"); crisesStatus = new NativeSelect(); handleCrisesBtn.setImmediate(true); reportOnCrisisBtn.setImmediate(true); changeCrisisStatusBtn.setImmediate(true); closeCrisisBtn.setImmediate(true); getCrisesSetBtn.setImmediate(true); crisesStatus.setImmediate(true); crisesStatus.addItems("Pending", "Handled", "Solved", "Closed"); crisesStatus.setNullSelectionAllowed(false); crisesStatus.select("Pending"); crisesButtons1.addComponents(handleCrisesBtn, reportOnCrisisBtn, changeCrisisStatusBtn); crisesButtons2.addComponents(closeCrisisBtn, getCrisesSetBtn, crisesStatus); //////////////////////////////////////// Window reportCrisisSubWindow = new Window(); reportCrisisSubWindow.setClosable(false); reportCrisisSubWindow.setResizable(false); reportCrisisSubWindow.setResponsive(true); VerticalLayout reportLayout = new VerticalLayout(); reportLayout.setMargin(true); reportLayout.setSpacing(true); reportCrisisSubWindow.setContent(reportLayout); TextField crisisID = new TextField(); TextField reportText = new TextField(); HorizontalLayout buttonsLayout = new HorizontalLayout(); Button reportCrisisBtn = new Button("Report"); reportCrisisBtn.setClickShortcut(KeyCode.ENTER); reportCrisisBtn.addStyleName(ValoTheme.BUTTON_PRIMARY); Button cancelBtn = new Button("Cancel"); buttonsLayout.addComponents(reportCrisisBtn, cancelBtn); buttonsLayout.setSpacing(true); reportLayout.addComponents(crisisID, reportText, buttonsLayout); cancelBtn.addClickListener(event -> { reportCrisisSubWindow.close(); reportText.clear(); }); reportCrisisBtn.addClickListener(event -> { CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow(); Integer thisCrisisID = new Integer(selectedCrisisBean.getID()); actCoordinator.oeReportOnCrisis(new DtCrisisID(new PtString(thisCrisisID.toString())), new DtComment(new PtString(reportText.getValue()))); reportCrisisSubWindow.close(); reportText.clear(); }); //////////////////////////////////////// Window changeCrisisStatusSubWindow = new Window(); changeCrisisStatusSubWindow.setClosable(false); changeCrisisStatusSubWindow.setResizable(false); changeCrisisStatusSubWindow.setResponsive(true); VerticalLayout statusLayout = new VerticalLayout(); statusLayout.setMargin(true); statusLayout.setSpacing(true); changeCrisisStatusSubWindow.setContent(statusLayout); TextField crisisID1 = new TextField(); NativeSelect crisisStatus = new NativeSelect("crisis status"); crisisStatus.addItems("Pending", "Handled", "Solved", "Closed"); crisisStatus.setNullSelectionAllowed(false); crisisStatus.select("Pending"); HorizontalLayout buttonsLayout1 = new HorizontalLayout(); Button changeCrisisStatusBtn1 = new Button("Change status"); changeCrisisStatusBtn1.setClickShortcut(KeyCode.ENTER); changeCrisisStatusBtn1.addStyleName(ValoTheme.BUTTON_PRIMARY); Button cancelBtn1 = new Button("Cancel"); buttonsLayout1.addComponents(changeCrisisStatusBtn1, cancelBtn1); buttonsLayout1.setSpacing(true); statusLayout.addComponents(crisisID1, crisisStatus, buttonsLayout1); cancelBtn1.addClickListener(event -> changeCrisisStatusSubWindow.close()); changeCrisisStatusBtn1.addClickListener(event -> { CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow(); Integer thisCrisisID = new Integer(selectedCrisisBean.getID()); EtCrisisStatus statusToPut = null; if (crisisStatus.getValue().toString().equals("Pending")) statusToPut = EtCrisisStatus.pending; if (crisisStatus.getValue().toString().equals("Handled")) statusToPut = EtCrisisStatus.handled; if (crisisStatus.getValue().toString().equals("Solved")) statusToPut = EtCrisisStatus.solved; if (crisisStatus.getValue().toString().equals("Closed")) statusToPut = EtCrisisStatus.closed; PtBoolean res = actCoordinator.oeSetCrisisStatus(new DtCrisisID(new PtString(thisCrisisID.toString())), statusToPut); changeCrisisStatusSubWindow.close(); }); //////////////////////////////////////// handleCrisesBtn.addClickListener(event -> { CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow(); Integer thisCrisisID = new Integer(selectedCrisisBean.getID()); PtBoolean res = actCoordinator .oeSetCrisisHandler(new DtCrisisID(new PtString(thisCrisisID.toString()))); }); reportOnCrisisBtn.addClickListener(event -> { CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow(); Integer thisCrisisID = new Integer(selectedCrisisBean.getID()); reportCrisisSubWindow.center(); crisisID.setValue(thisCrisisID.toString()); crisisID.setEnabled(false); reportText.focus(); UI.getCurrent().addWindow(reportCrisisSubWindow); }); changeCrisisStatusBtn.addClickListener(event -> { CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow(); Integer thisCrisisID = new Integer(selectedCrisisBean.getID()); changeCrisisStatusSubWindow.center(); crisisID1.setValue(thisCrisisID.toString()); crisisID1.setEnabled(false); crisisStatus.focus(); UI.getCurrent().addWindow(changeCrisisStatusSubWindow); }); closeCrisisBtn.addClickListener(event -> { CrisisBean selectedCrisisBean = (CrisisBean) crisesTable.getSelectedRow(); Integer thisCrisisID = new Integer(selectedCrisisBean.getID()); PtBoolean res = actCoordinator.oeCloseCrisis(new DtCrisisID(new PtString(thisCrisisID.toString()))); }); getCrisesSetBtn.addClickListener(event -> { if (crisesStatus.getValue().toString().equals("Closed")) actCoordinator.oeGetCrisisSet(EtCrisisStatus.closed); if (crisesStatus.getValue().toString().equals("Handled")) actCoordinator.oeGetCrisisSet(EtCrisisStatus.handled); if (crisesStatus.getValue().toString().equals("Solved")) actCoordinator.oeGetCrisisSet(EtCrisisStatus.solved); if (crisesStatus.getValue().toString().equals("Pending")) actCoordinator.oeGetCrisisSet(EtCrisisStatus.pending); }); ClickListener logoutAction = event -> { PtBoolean res; try { res = actCoordinator.oeLogout(); if (res.getValue()) { } } catch (Exception e) { e.printStackTrace(); } Page.getCurrent().reload(); }; logoutBtn1.addClickListener(logoutAction); logoutBtn2.addClickListener(logoutAction); }
From source file:module.pandabox.presentation.PandaBox.java
License:Open Source License
private void initView() { setCompositionRoot(root);//from w ww . j a va2 s . com root.setSizeFull(); root.setSplitPosition(15); root.setStyleName("small previews"); previewArea.setWidth("100%"); previewTabs = new VerticalLayout(); previewTabs.setSizeFull(); previewTabs.setHeight(null); compoundTabs = new VerticalLayout(); compoundTabs.setSizeFull(); compoundTabs.setHeight(null); bennuStylesTabs = new VerticalLayout(); bennuStylesTabs.setSizeFull(); bennuStylesTabs.setHeight(null); VerticalLayout menu = new VerticalLayout(); menu.setSizeFull(); menu.setStyleName("sidebar-menu"); Button syncThemes = new Button("Sync Themes", new ClickListener() { @Override public void buttonClick(ClickEvent event) { syncThemes(); } }); menu.addComponent(syncThemes); menu.addComponent(new Label("Single Components")); menu.addComponent(previewTabs); menu.addComponent(new Label("Compound Styles")); menu.addComponent(compoundTabs); menu.addComponent(new Label("Bennu Styles")); menu.addComponent(bennuStylesTabs); root.setFirstComponent(menu); CssLayout toolbar = new CssLayout(); toolbar.setWidth("100%"); toolbar.setStyleName("toolbar"); toolbar.addComponent(editorToggle); final Window downloadWindow = new Window("Download Theme"); GridLayout l = new GridLayout(3, 2); l.setSizeUndefined(); l.setMargin(true); l.setSpacing(true); downloadWindow.setContent(l); downloadWindow.setModal(true); downloadWindow.setResizable(false); downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null); downloadWindow.addStyleName("opaque"); Label caption = new Label("Theme Name"); l.addComponent(caption); l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER); final TextField name = new TextField(); name.setValue("my-chameleon"); name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed")); name.setRequired(true); name.setRequiredError("Please give a name for the theme"); downloadWindow.addComponent(name); Label info = new Label( "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.", Label.CONTENT_XHTML); info.addStyleName("tiny"); info.setWidth("200px"); l.addComponent(info, 1, 1, 2, 1); Button download = new Button(null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { getApplication().getMainWindow().addWindow(downloadWindow); name.focus(); } }); download.setDescription("Donwload the current theme"); download.setIcon(new ThemeResource("download.png")); download.setStyleName("icon-only"); toolbar.addComponent(download); menu.addComponent(toolbar); menu.setExpandRatio(toolbar, 1); menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER); }
From source file:myGroup.gwt.client.ui.MyUI.java
License:Open Source License
@Override protected void init(VaadinRequest vaadinRequest) { HorizontalSplitPanel sample = new HorizontalSplitPanel(); sample.setSizeFull();// w w w. ja v a2s . com // sample.setSplitPosition(150.0f, PIXELS); sample.setSecondComponent(new Label("korte")); setContent(sample); Table grid = new Table(); grid.setSizeFull(); for (Object i : getItemContiner().getItemIds()) { System.out.println(i.toString()); } grid.setContainerDataSource(getItemContiner()); grid.setSelectable(true); grid.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { final String valueString = String.valueOf(valueChangeEvent.getProperty().getValue()); Notification.show("Value changed:", valueString, Notification.Type.TRAY_NOTIFICATION); } }); sample.setFirstComponent(grid); // Main window is the primary browser window final Window main = new Window("Hello window"); addWindow(main); // "Hello world" text is added to window as a Label component UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { String email = user.getEmail(); } else { // no user logged in } assert user != null; main.setContent(new Label(user.getUserId())); }
From source file:net.antoinecomte.regex.RegExTesterApplication.java
License:Apache License
@Override public void init() { setTheme("chameleon"); final TextField text = new TextField(); final TextField regex = new TextField(); Panel mainPanel = new Panel("Simple Java regular expression tool "); mainPanel.setWidth("460px"); VerticalLayout mainPanelLayout = new VerticalLayout(); mainPanelLayout.setSpacing(true);// w w w. j a v a 2s . c om mainPanelLayout.setMargin(true); mainPanel.setContent(mainPanelLayout); regex.setCaption("Regular Expression"); regex.setWidth("400px"); regex.addStyleName("big"); regex.setInputPrompt("enter a regular expression here"); regex.setTextChangeEventMode(TextChangeEventMode.TIMEOUT); regex.setImmediate(true); text.setCaption("Test input"); text.setInputPrompt("Enter a test string here"); text.setTextChangeEventMode(TextChangeEventMode.TIMEOUT); text.setImmediate(true); text.setWidth("400px"); text.addStyleName("big"); result.setSizeUndefined(); result.setWidth("460px"); result.setStyleName("light"); result.setVisible(false); regex.addListener(new TextChangeListener() { private static final long serialVersionUID = 7783333579512074097L; @Override public void textChange(TextChangeEvent event) { showResult(event.getText(), text.getValue().toString()); } }); text.addListener(new TextChangeListener() { private static final long serialVersionUID = -2294521048305268959L; @Override public void textChange(TextChangeEvent event) { showResult(regex.getValue().toString(), event.getText()); } }); Window mainWindow = new Window(); VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSpacing(true); mainLayout.setMargin(true); mainWindow.setContent(mainLayout); mainWindow.addComponent(mainPanel); mainPanel.addComponent(regex); mainPanel.addComponent(text); mainWindow.addComponent(result); setMainWindow(mainWindow); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.TemplateComponent.java
License:Apache License
private void displayChildCreationWizard() { Wizard w = new Wizard(); Window cw = new VMWindow(); TemplateNodeComponent tc = new TemplateNodeComponent(new TemplateNode(), true); w.addStep(new WizardStep() { @Override/*from ww w.j a v a 2s .c o m*/ public String getCaption() { return TRANSLATOR.translate("general.add.child"); } @Override public Component getContent() { return tc; } @Override public boolean onAdvance() { return tc.isValid(); } @Override public boolean onBack() { return false; } }); w.addListener(new WizardProgressListener() { @Override public void activeStepChanged(WizardStepActivationEvent event) { //Do nothing } @Override public void stepSetChanged(WizardStepSetChangedEvent event) { //Do nothing } @Override public void wizardCompleted(WizardCompletedEvent event) { try { //Add the item TemplateNode tn = tc.getNode(), parent = null; Template template = null; if (tree.getValue() instanceof TemplateNodePK) { TemplateNodeServer node = new TemplateNodeServer((TemplateNodePK) tree.getValue()); template = node.getTemplate(); parent = node.getEntity(); } else if (tree.getValue() instanceof Template) { template = (Template) tree.getValue(); } tn.setTemplate(template); if (parent != null) { tn.setTemplateNode(parent); } new TemplateNodeJpaController(DataBaseManager.getEntityManagerFactory()).create(tn); addTemplateNode(tn); UI.getCurrent().removeWindow(cw); } catch (Exception ex) { Exceptions.printStackTrace(ex); } } @Override public void wizardCancelled(WizardCancelledEvent event) { UI.getCurrent().removeWindow(cw); } }); cw.setContent(w); cw.setSizeFull(); UI.getCurrent().addWindow(cw); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.execution.ExecutionWizardStep.java
License:Apache License
@Override public Component getContent() { Panel form = new Panel(TRANSLATOR.translate("step.detail")); if (getExecutionStep().getExecutionStart() == null) { //Set the start date. getExecutionStep().setExecutionStart(new Date()); }/*from w ww.j a va2 s .co m*/ FormLayout layout = new FormLayout(); form.setContent(layout); form.addStyleName(ValoTheme.FORMLAYOUT_LIGHT); BeanFieldGroup binder = new BeanFieldGroup(getExecutionStep().getStep().getClass()); binder.setItemDataSource(getExecutionStep().getStep()); TextArea text = new TextArea(TRANSLATOR.translate("general.text")); text.setConverter(new ByteToStringConverter()); binder.bind(text, "text"); text.setSizeFull(); layout.addComponent(text); Field notes = binder.buildAndBind(TRANSLATOR.translate("general.notes"), "notes", TextArea.class); notes.setSizeFull(); layout.addComponent(notes); if (getExecutionStep().getExecutionStart() != null) { start = new DateField(TRANSLATOR.translate("start.date")); start.setResolution(Resolution.SECOND); start.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); start.setValue(getExecutionStep().getExecutionStart()); start.setReadOnly(true); layout.addComponent(start); } if (getExecutionStep().getExecutionEnd() != null) { end = new DateField(TRANSLATOR.translate("end.date")); end.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); end.setResolution(Resolution.SECOND); end.setValue(getExecutionStep().getExecutionEnd()); end.setReadOnly(true); layout.addComponent(end); } binder.setReadOnly(true); //Space to record result if (getExecutionStep().getResultId() != null) { result.setValue(getExecutionStep().getResultId().getResultName()); } layout.addComponent(result); if (reviewer) {//Space to record review if (getExecutionStep().getReviewResultId() != null) { review.setValue(getExecutionStep().getReviewResultId().getReviewName()); } layout.addComponent(review); } //Add Reviewer name if (getExecutionStep().getReviewer() != null) { TextField reviewerField = new TextField(TRANSLATOR.translate("general.reviewer")); reviewerField.setValue(getExecutionStep().getReviewer().getFirstName() + " " + getExecutionStep().getReviewer().getLastName()); reviewerField.setReadOnly(true); layout.addComponent(reviewerField); } if (getExecutionStep().getReviewDate() != null) { reviewDate = new DateField(TRANSLATOR.translate("review.date")); reviewDate.setDateFormat(VMSettingServer.getSetting("date.format").getStringVal()); reviewDate.setResolution(Resolution.SECOND); reviewDate.setValue(getExecutionStep().getReviewDate()); reviewDate.setReadOnly(true); layout.addComponent(reviewDate); } if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { TextArea expectedResult = new TextArea(TRANSLATOR.translate("expected.result")); expectedResult.setConverter(new ByteToStringConverter()); binder.bind(expectedResult, "expectedResult"); expectedResult.setSizeFull(); layout.addComponent(expectedResult); } //Add the fields fields.clear(); getExecutionStep().getStep().getDataEntryList().forEach(de -> { switch (de.getDataEntryType().getId()) { case 1://String TextField tf = new TextField(TRANSLATOR.translate(de.getEntryName())); tf.setRequired(true); tf.setData(de.getEntryName()); if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { //Add expected result DataEntryProperty stringCase = DataEntryServer.getProperty(de, "property.match.case"); DataEntryProperty r = DataEntryServer.getProperty(de, "property.expected.result"); if (r != null && !r.getPropertyValue().equals("null")) { String error = TRANSLATOR.translate("expected.result") + ": " + r.getPropertyValue(); tf.setRequiredError(error); tf.setRequired(DataEntryServer.getProperty(de, "property.required").getPropertyValue() .equals("true")); tf.addValidator((Object val) -> { //We have an expected result and a match case requirement if (stringCase != null && stringCase.getPropertyValue().equals("true") ? !((String) val).equals(r.getPropertyValue()) : !((String) val).equalsIgnoreCase(r.getPropertyValue())) { throw new InvalidValueException(error); } }); } } fields.add(tf); //Set value if already recorded updateValue(tf); layout.addComponent(tf); break; case 2://Numeric NumberField field = new NumberField(TRANSLATOR.translate(de.getEntryName())); field.setSigned(true); field.setUseGrouping(true); field.setGroupingSeparator(','); field.setDecimalSeparator('.'); field.setConverter(new StringToDoubleConverter()); field.setRequired( DataEntryServer.getProperty(de, "property.required").getPropertyValue().equals("true")); field.setData(de.getEntryName()); Double min = null, max = null; for (DataEntryProperty prop : de.getDataEntryPropertyList()) { String value = prop.getPropertyValue(); if (prop.getPropertyName().equals("property.max")) { try { max = Double.parseDouble(value); } catch (NumberFormatException ex) { //Leave as null } } else if (prop.getPropertyName().equals("property.min")) { try { min = Double.parseDouble(value); } catch (NumberFormatException ex) { //Leave as null } } } //Add expected result if (VMSettingServer.getSetting("show.expected.result").getBoolVal() && (min != null || max != null)) { String error = TRANSLATOR.translate("error.out.of.range") + " " + (min == null ? " " : (TRANSLATOR.translate("property.min") + ": " + min)) + " " + (max == null ? "" : (TRANSLATOR.translate("property.max") + ": " + max)); field.setRequiredError(error); field.addValidator(new DoubleRangeValidator(error, min, max)); } fields.add(field); //Set value if already recorded updateValue(field); layout.addComponent(field); break; case 3://Boolean CheckBox cb = new CheckBox(TRANSLATOR.translate(de.getEntryName())); cb.setData(de.getEntryName()); cb.setRequired( DataEntryServer.getProperty(de, "property.required").getPropertyValue().equals("true")); if (VMSettingServer.getSetting("show.expected.result").getBoolVal()) { DataEntryProperty r = DataEntryServer.getProperty(de, "property.expected.result"); if (r != null) { //Add expected result String error = TRANSLATOR.translate("expected.result") + ": " + r.getPropertyValue(); cb.addValidator((Object val) -> { if (!val.toString().equals(r.getPropertyValue())) { throw new InvalidValueException(error); } }); } } fields.add(cb); //Set value if already recorded updateValue(cb); layout.addComponent(cb); break; case 4://Attachment Label l = new Label(TRANSLATOR.translate(de.getEntryName())); layout.addComponent(l); break; default: LOG.log(Level.SEVERE, "Unexpected field type: {0}", de.getDataEntryType().getId()); } }); //Add the Attachments HorizontalLayout attachments = new HorizontalLayout(); attachments.setCaption(TRANSLATOR.translate("general.attachment")); HorizontalLayout comments = new HorizontalLayout(); comments.setCaption(TRANSLATOR.translate("general.comments")); HorizontalLayout issues = new HorizontalLayout(); issues.setCaption(TRANSLATOR.translate("general.issue")); int commentCounter = 0; int issueCounter = 0; for (ExecutionStepHasIssue ei : getExecutionStep().getExecutionStepHasIssueList()) { issueCounter++; Button a = new Button("Issue #" + issueCounter); a.setIcon(VaadinIcons.BUG); a.addClickListener((Button.ClickEvent event) -> { displayIssue(new IssueServer(ei.getIssue())); }); a.setEnabled(!step.getLocked()); issues.addComponent(a); } for (ExecutionStepHasAttachment attachment : getExecutionStep().getExecutionStepHasAttachmentList()) { switch (attachment.getAttachment().getAttachmentType().getType()) { case "comment": { //Comments go in a different section commentCounter++; Button a = new Button("Comment #" + commentCounter); a.setIcon(VaadinIcons.CLIPBOARD_TEXT); a.addClickListener((Button.ClickEvent event) -> { if (!step.getLocked()) { //Prompt if user wants this removed MessageBox mb = getDeletionPrompt(attachment); mb.open(); } else { displayComment(new AttachmentServer(attachment.getAttachment().getAttachmentPK())); } }); a.setEnabled(!step.getLocked()); comments.addComponent(a); break; } default: { Button a = new Button(attachment.getAttachment().getFileName()); a.setEnabled(!step.getLocked()); a.setIcon(VaadinIcons.PAPERCLIP); a.addClickListener((Button.ClickEvent event) -> { if (!step.getLocked()) { //Prompt if user wants this removed MessageBox mb = getDeletionPrompt(attachment); mb.open(); } else { displayAttachment(new AttachmentServer(attachment.getAttachment().getAttachmentPK())); } }); attachments.addComponent(a); break; } } } if (attachments.getComponentCount() > 0) { layout.addComponent(attachments); } if (comments.getComponentCount() > 0) { layout.addComponent(comments); } if (issues.getComponentCount() > 0) { layout.addComponent(issues); } //Add the menu HorizontalLayout hl = new HorizontalLayout(); attach = new Button(TRANSLATOR.translate("add.attachment")); attach.setIcon(VaadinIcons.PAPERCLIP); attach.addClickListener((Button.ClickEvent event) -> { //Show dialog to upload file. Window dialog = new VMWindow(TRANSLATOR.translate("attach.file")); VerticalLayout vl = new VerticalLayout(); MultiFileUpload multiFileUpload = new MultiFileUpload() { @Override protected void handleFile(File file, String fileName, String mimeType, long length) { try { LOG.log(Level.FINE, "Received file {1} at: {0}", new Object[] { file.getAbsolutePath(), fileName }); //Process the file //Create the attachment AttachmentServer a = new AttachmentServer(); a.addFile(file, fileName); //Overwrite the default file name set in addFile. It'll be a temporary file name a.setFileName(fileName); a.write2DB(); //Now add it to this Execution Step if (getExecutionStep().getExecutionStepHasAttachmentList() == null) { getExecutionStep().setExecutionStepHasAttachmentList(new ArrayList<>()); } getExecutionStep().addAttachment(a); getExecutionStep().write2DB(); w.updateCurrentStep(); } catch (Exception ex) { LOG.log(Level.SEVERE, "Error creating attachment!", ex); } } }; multiFileUpload.setCaption(TRANSLATOR.translate("select.files.attach")); vl.addComponent(multiFileUpload); dialog.setContent(vl); dialog.setHeight(25, Sizeable.Unit.PERCENTAGE); dialog.setWidth(25, Sizeable.Unit.PERCENTAGE); ValidationManagerUI.getInstance().addWindow(dialog); }); hl.addComponent(attach); bug = new Button(TRANSLATOR.translate("create.issue")); bug.setIcon(VaadinIcons.BUG); bug.addClickListener((Button.ClickEvent event) -> { displayIssue(new IssueServer()); }); hl.addComponent(bug); comment = new Button(TRANSLATOR.translate("add.comment")); comment.setIcon(VaadinIcons.CLIPBOARD_TEXT); comment.addClickListener((Button.ClickEvent event) -> { AttachmentServer as = new AttachmentServer(); //Get comment type AttachmentType type = AttachmentTypeServer.getTypeForExtension("comment"); as.setAttachmentType(type); displayComment(as); }); hl.addComponent(comment); step.update(); attach.setEnabled(!step.getLocked()); bug.setEnabled(!step.getLocked()); comment.setEnabled(!step.getLocked()); result.setEnabled(!step.getLocked()); layout.addComponent(hl); return layout; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.file.TextDisplay.java
License:Apache License
@Override public Window getViewer(File f) { BufferedReader br = null;/*from w w w . j a v a 2 s. c om*/ Window w = new VMWindow(f.getName()); w.setHeight(80, Sizeable.Unit.PERCENTAGE); w.setWidth(80, Sizeable.Unit.PERCENTAGE); //Just a plain panel will do TextArea text = new TextArea(); text.setSizeFull(); w.setContent(text); try { br = new BufferedReader(new FileReader(f)); String line; StringBuilder sb = new StringBuilder(); try { while ((line = br.readLine()) != null) { sb.append(line).append("\n"); } text.setValue(sb.toString()); text.setReadOnly(true); } catch (IOException ex) { Exceptions.printStackTrace(ex); } } catch (FileNotFoundException ex) { Exceptions.printStackTrace(ex); } finally { try { if (br != null) { br.close(); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } } return w; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.template.TemplateScreenProvider.java
License:Apache License
private void displayTemplateCopyWizard() { Wizard w = new Wizard(); Window cw = new VMWindow(); TemplateComponent tc = new TemplateComponent(new Template(), true); w.addStep(new WizardStep() { @Override/* w w w . ja va 2s . c om*/ public String getCaption() { return TRANSLATOR.translate("template.copy"); } @Override public Component getContent() { return tc; } @Override public boolean onAdvance() { try { TemplateServer t = new TemplateServer(tc.getTemplate()); t.write2DB(); return t.getId() > 0; } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate("general.error.record.creation"), ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE); } return false; } @Override public boolean onBack() { return false; } }); w.addListener(new WizardProgressListener() { @Override public void activeStepChanged(WizardStepActivationEvent event) { //Do nothing } @Override public void stepSetChanged(WizardStepSetChangedEvent event) { //Do nothing } @Override public void wizardCompleted(WizardCompletedEvent event) { ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); UI.getCurrent().removeWindow(cw); } @Override public void wizardCancelled(WizardCancelledEvent event) { UI.getCurrent().removeWindow(cw); } }); cw.setContent(w); cw.setSizeFull(); UI.getCurrent().addWindow(cw); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.template.TemplateScreenProvider.java
License:Apache License
private void displayTemplateCreateWizard() { Wizard w = new Wizard(); Window cw = new VMWindow(); TemplateComponent tc = new TemplateComponent(new Template(), true); w.addStep(new WizardStep() { private final TextField nameField = new TextField(TRANSLATOR.translate("general.name")); @Override/*from w w w . j a v a 2s .co m*/ public String getCaption() { return TRANSLATOR.translate("add.template"); } @Override public Component getContent() { return tc; } @Override public boolean onAdvance() { try { TemplateServer t = new TemplateServer(tc.getTemplate()); t.write2DB(); return t.getId() > 0; } catch (Exception ex) { LOG.log(Level.SEVERE, null, ex); Notification.show(TRANSLATOR.translate("general.error.record.creation"), ex.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE); } return false; } @Override public boolean onBack() { return false; } }); w.addListener(new WizardProgressListener() { @Override public void activeStepChanged(WizardStepActivationEvent event) { //Do nothing } @Override public void stepSetChanged(WizardStepSetChangedEvent event) { //Do nothing } @Override public void wizardCompleted(WizardCompletedEvent event) { ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); UI.getCurrent().removeWindow(cw); } @Override public void wizardCancelled(WizardCancelledEvent event) { UI.getCurrent().removeWindow(cw); } }); cw.setContent(w); cw.setSizeFull(); UI.getCurrent().addWindow(cw); }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.ValidationManagerUI.java
License:Apache License
private void addTestCaseAssignment(ContextMenu menu) { MenuItem create = menu.addItem(TRANSLATOR.translate("assign.test.case.execution"), ASSIGN_ICON, (MenuItem selectedItem) -> { Wizard w = new Wizard(); Window sw = new VMWindow(); w.addStep(new AssignUserStep(ValidationManagerUI.this, tree.getValue())); w.addListener(new WizardProgressListener() { @Override/*from w w w . jav a 2s . c o m*/ public void activeStepChanged(WizardStepActivationEvent event) { //Do nothing } @Override public void stepSetChanged(WizardStepSetChangedEvent event) { //Do nothing } @Override public void wizardCompleted(WizardCompletedEvent event) { removeWindow(sw); } @Override public void wizardCancelled(WizardCancelledEvent event) { removeWindow(sw); } }); sw.setContent(w); sw.setSizeFull(); addWindow(sw); }); create.setEnabled(checkRight("testplan.planning")); }