List of usage examples for com.vaadin.ui Button setVisible
@Override public void setVisible(boolean visible)
From source file:com.peergreen.webconsole.scope.deployment.internal.DeploymentScope.java
License:Open Source License
@PostConstruct public void init() { deploymentViewManager = createDeploymentViewManager(); OptionGroup option = new OptionGroup(); HorizontalLayout toolBar = new HorizontalLayout(); toolBar.setWidth("100%"); toolBar.setSpacing(true);/*from ww w . j a v a2 s . co m*/ toolBar.setMargin(true); VerticalLayout uploadLayout = new VerticalLayout(); Upload uploader = new Upload("Upload a file here", null); uploader.setButtonCaption("Upload"); final FileUploader fileUploader = new FileUploader(deploymentViewManager, notifierService, artifactBuilder, option); uploader.setReceiver(fileUploader); uploader.addSucceededListener(fileUploader); uploader.addStartedListener(fileUploader); uploadLayout.addComponent(uploader); HorizontalLayout target = new HorizontalLayout(); option.addContainerProperty("id", String.class, null); option.setItemCaptionPropertyId("id"); option.addItem(DeployableContainerType.DEPLOYABLE.attribute()).getItemProperty("id") .setValue("Add to deployables"); option.addItem(DeployableContainerType.DEPLOYED.attribute()).getItemProperty("id").setValue("Deploy"); option.addItem(DeployableContainerType.DEPLOYMENT_PLAN.attribute()).getItemProperty("id") .setValue("Create a deployment plan"); option.addStyleName("horizontal"); option.select(DeployableContainerType.DEPLOYABLE.attribute()); target.addComponent(option); uploadLayout.addComponent(target); toolBar.addComponent(uploadLayout); Label infoLabel = new Label("Drop files here to create a deployment plan"); infoLabel.setSizeUndefined(); final VerticalLayout deploymentPlanMaker = new VerticalLayout(infoLabel); deploymentPlanMaker.setComponentAlignment(infoLabel, Alignment.MIDDLE_CENTER); Button draft = new Button("A draft is under construction"); draft.addStyleName("link"); draft.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { deploymentViewManager.showDeploymentPlanView(); } }); draft.setVisible(false); deploymentViewManager.setDeploymentPlanDraftViewer(draft); deploymentPlanMaker.addComponent(draft); deploymentPlanMaker.setComponentAlignment(draft, Alignment.TOP_CENTER); deploymentPlanMaker.setSizeFull(); deploymentPlanMaker.addStyleName("drop-area"); deploymentPlanMakerWrapper = new DragAndDropWrapper(deploymentPlanMaker); deploymentPlanMakerWrapper.setSizeFull(); toolBar.addComponent(deploymentPlanMakerWrapper); addComponent(toolBar); addComponent(framesContainer); setExpandRatio(framesContainer, 1.5f); helpWindow = notifierService.createHelpOverlay("Deployment module", "<p>To deploy, or undeploy, artifacts, you can drag and drop elements from deployables panel " + "to deployed panel and vice versa.</p>" + "<p>You can also drag files from desktop and drop them where you want to add them."); }
From source file:com.rdonasco.common.vaadin.view.ButtonUtil.java
License:Apache License
public static void hideButtons(Button... buttons) { for (Button button : buttons) { if (button != null) { button.setVisible(false); }/*from ww w . ja v a 2 s . c om*/ } }
From source file:com.rdonasco.common.vaadin.view.ButtonUtil.java
License:Apache License
public static void showButtons(Button... buttons) { for (Button button : buttons) { button.setVisible(true); if (!button.isEnabled()) { enableButtons(button);/*from ww w . ja va2s . co m*/ } } }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the charts layout./*from ww w . j ava2s. c o m*/ */ private void createChartsLayout() { chartsLayout = new VerticalLayout(); chartsLayout.addStyleName("chartsLayout"); chartsLayout.setHeight("100%"); chartsLayout.setSpacing(true); addComponent(chartsLayout); final HorizontalLayout chartsHeaderLayout = new HorizontalLayout(); chartsHeaderLayout.setStyleName("panelHeaderLayout"); chartsHeaderLayout.setWidth("100%"); chartsHeaderLayout.setSpacing(true); chartsHeaderLayout.setMargin(new MarginInfo(false, true, false, true)); chartsLayout.addComponent(chartsHeaderLayout); chartControls = new ChartControls(); chartControls.addIntervalSelectionListener(chartIntervalListener); chartControls.addThemeSelectionListener(chartThemeListener); chartsHeaderLayout.addComponent(chartControls); chartsHeaderLayout.setComponentAlignment(chartControls, Alignment.MIDDLE_LEFT); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); chartsHeaderLayout.addComponent(buttonsLayout); chartsHeaderLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); SettingsDialog settingsDialog = new SettingsDialog("Edit Monitors...", "Monitors"); final Button editMonitorsButton = settingsDialog.getButton(); editMonitorsButton.setVisible(false); buttonsLayout.addComponent(editMonitorsButton); final Button addChartButton = new Button("Add Chart..."); addChartButton.setVisible(false); buttonsLayout.addComponent(addChartButton); addChartButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new ChartsDialog(chartsArrayLayout, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); chartsArrayLayout.setDragMode(LayoutDragMode.CLONE); chartsArrayLayout.setEditable(true); chartsHeaderLayout.setStyleName("panelHeaderLayout-editable"); editMonitorsButton.setVisible(true); addChartButton.setVisible(true); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(false); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); chartsArrayLayout.setDragMode(LayoutDragMode.NONE); chartsArrayLayout.setEditable(false); chartsHeaderLayout.setStyleName("panelHeaderLayout"); editMonitorsButton.setVisible(false); addChartButton.setVisible(false); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(true); refresh(); } }); final Button expandButton = new NativeButton(); expandButton.setStyleName("expandButton"); expandButton.setDescription("Expand/Reduce viewing area"); buttonsLayout.addComponent(expandButton); buttonsLayout.setComponentAlignment(expandButton, Alignment.MIDDLE_CENTER); expandButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { isExpanded = !isExpanded; AnimatorProxy proxy = getSession().getAttribute(AnimatorProxy.class); proxy.addListener(new AnimationListener() { public void onAnimation(AnimationEvent event) { Component component = event.getComponent(); component.setVisible(isExpanded ? false : true); } }); // OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); // if (!isExpanded) { // overviewPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(overviewPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); // // TopPanel topPanel = getSession().getAttribute(TopPanel.class); // if (!isExpanded) { // topPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(topPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); VerticalLayout topMid = getSession().getAttribute(VerticalLayout.class); if (!isExpanded) { topMid.setVisible(isExpanded ? false : true); } proxy.animate(topMid, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN) .setDuration(500).setDelay(100); expandButton.setStyleName(isExpanded ? "contractButton" : "expandButton"); } }); chartsPanel = new Panel(); chartsPanel.setSizeFull(); chartsPanel.addStyleName(Runo.PANEL_LIGHT); chartsLayout.addComponent(chartsPanel); chartsLayout.setExpandRatio(chartsPanel, 1.0f); }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private HorizontalLayout setDetailsForm(String strUID, String strAction) { cDetailsAndOperations = new HorizontalLayout(); cDetailsAndOperations.setSizeUndefined(); cUPersonalDetails = new FormLayout(); cUPersonalDetails.setMargin(false);/* w w w . j av a 2 s. c o m*/ cUPersonalDetails.setSpacing(false); cUPersonalDetails.setStyleName("frm_details_personal_info"); cUPersonalDetails.setSizeUndefined(); cDetailsAndOperations.addComponent(cUPersonalDetails); arrLAllFormFields = new ArrayList<Object>(); final String btnEditId = "edit"; arrLAllEditableFields = new ArrayList<Object>(); arrLTfEditableVals = new ArrayList<String>(); final Button btnEdit = new Button(); btnEdit.setId(btnEditId); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setStyleName(ValoTheme.BUTTON_ICON_ONLY); btnEdit.setStyleName("btn_link"); btnEdit.setVisible(false); final Button btnCancel = new Button(); btnCancel.setId(btnEditId); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName(ValoTheme.BUTTON_ICON_ONLY); btnCancel.setStyleName("btn_link"); btnCancel.setVisible(false); cBtnEditCancel = new HorizontalLayout(); cBtnEditCancel.setSizeUndefined(); cBtnEditCancel.addComponent(btnEdit); setData(strUID, strAction); return cDetailsAndOperations; }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private VerticalLayout getEUDContainer() { if (cBtnEditCancel != null) cBtnEditCancel.setVisible(false); HashMap<Integer, String> profToID = new HashMap<>(); profToID.put(1, "MATS_ADMIN_USER_PROFILE"); profToID.put(3, "MATS_FINANCIAL_CONTROLLER_USER_PROFILE"); profToID.put(4, "MATS_CUSTOMER_CARE_USER_PROFILE"); profToID.put(6, "MATS_SUPER_AGENT_USER_PROFILE"); profToID.put(7, "MATS_SUB_AGENT_USER_PROFILE"); profToID.put(11, "MATS_DEALER_USER_PROFILE"); profToID.put(15, "MATS_SERVICE_PROVIDER_USER_PROFILE"); VerticalLayout cAgentInfo = new VerticalLayout(); cAgentInfo.setMargin(new MarginInfo(true, false, true, false)); cAgentInfo.setStyleName("c_details_test"); cAgentInfo.setSizeUndefined();/* ww w. j av a2 s . co m*/ VerticalLayout cBasic = new VerticalLayout(); Label lbB = new Label("Basic"); lbB.setStyleName("lb_frm_add_user"); cBasic.addComponent(lbB); TextField tF = new TextField("First Name"); tFFN = tF; tFFN.setRequired(true); tF.setValue("Paul"); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cBasic.addComponent(tF); tF = new TextField("Middle Name"); tF.setValue("Pwndz"); tFMN = tF; tFMN.setRequired(true); cBasic.addComponent(tF); tF = new TextField("Last Name"); tF.setValue("Kigozi"); tFLN = tF; tFLN.setRequired(true); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cBasic.addComponent(tF); OptionGroup opt = new OptionGroup("Gender"); opt.addItem("FEMALE"); // opt.setItemCaption(1, "Female"); opt.addItem("MALE"); // opt.setItemCaption(2, "Male"); opt.select("MALE"); optSex = opt; optSex.setRequired(true); arrLAllFormFields.add(opt); arrLAllEditableFields.add(opt); arrLTfEditableVals.add(opt.getValue().toString()); cBasic.addComponent(opt); ComboBox combo = new ComboBox("Prefix"); combo.addItem("Mr. "); combo.addItem("Mrs. "); combo.addItem("Dr. "); combo.addItem("Eng. "); combo.addItem("Prof. "); comboPref = combo; comboPref.select("Eng. "); arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cBasic.addComponent(combo); combo = new ComboBox("Suffix"); combo.addItem("Ph.D"); combo.addItem("M.B.A"); combo.addItem("RA"); combo.addItem("CISA "); combo.select("Ph.D"); comboSuff = combo; arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cBasic.addComponent(combo); combo = new ComboBox("Language"); combo.addItem(1); combo.select(1); combo.setItemCaption(1, "en-US"); combo.addItem(2); combo.setItemCaption(2, "en-UK"); combo.addItem(3); combo.setItemCaption(3, "fr"); comboLang = combo; comboLang.setRequired(true); arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cBasic.addComponent(combo); tF = new TextField("Occupation"); tF.setValue("Software Engineer"); tFOcc = tF; tFOcc.setRequired(true); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cBasic.addComponent(tF); tF = new TextField("Employer"); tF.setValue("Swifta"); tFEmp = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cBasic.addComponent(tF); PopupDateField dF = new PopupDateField("DoB"); cal = Calendar.getInstance(); cal.set(1988, 11, 12); dF.setValue(cal.getTime()); dFDoB = dF; arrLAllFormFields.add(dF); arrLAllEditableFields.add(dF); arrLTfEditableVals.add(dF.getValue().toString()); cBasic.addComponent(dF); combo = new ComboBox("Country"); comboCountry = combo; comboCountry.setRequired(true); cBasic.addComponent(combo); combo = new ComboBox("State"); comboState = combo; comboState.setRequired(true); comboState.setNullSelectionAllowed(false); arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cBasic.addComponent(combo); combo = new ComboBox("Local Government"); // combo.addItem(1); // combo.setItemCaption(1, "Ca. LG"); // combo.select(1); comboLG = combo; comboLG.setRequired(true); arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cBasic.addComponent(combo); /* * if (!(strUserType.equals("CCO") || strUserType.equals("BA"))) { * * cBasic.addComponent(dF); * * combo.addItem("Passport"); combo.addItem("Voter's Card"); * combo.addItem("Driving License"); combo.addItem("National ID"); * combo.addItem("Residential ID"); cBasic.addComponent(combo); * * tF = new TextField("ID No."); cBasic.addComponent(tF); * * combo = new ComboBox("State"); cBasic.addComponent(combo); * * combo = new ComboBox("Country"); cBasic.addComponent(combo); } */ VerticalLayout cC = new VerticalLayout(); HorizontalLayout cBAndCAndAcc = new HorizontalLayout(); cBAndCAndAcc.addComponent(cBasic); cBAndCAndAcc.addComponent(cC); VerticalLayout cCompany = new VerticalLayout(); // Label lbC = new Label("Company"); Label lbC = new Label("Identification"); lbC.setStyleName("lb_frm_add_user"); combo = new ComboBox("ID Type"); combo.addItem("Passport Number"); combo.addItem("National Registration Identification Number"); combo.addItem("Drivers License Number"); combo.addItem("Identification Card"); combo.addItem("Employer Identification Number"); combo.select("Passport Number"); comboIDType = combo; comboIDType.setRequired(true); arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cCompany.addComponent(combo); tF = new TextField("ID No."); tF.setValue("001"); tFIDNo = tF; tFIDNo.setRequired(true); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cCompany.addComponent(tF); tF = new TextField("Issuer"); tFIssuer = tF; tFIssuer.setValue("Republic of Uganda"); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cCompany.addComponent(tF); dF = new PopupDateField("Issue Date"); // cal = Calendar.getInstance(); cal.set(12, 12, 12); dF.setValue(cal.getTime()); dFDoI = dF; arrLAllFormFields.add(dF); arrLAllEditableFields.add(dF); arrLTfEditableVals.add(dF.getValue().toString()); cCompany.addComponent(dF); dF = new PopupDateField("Expiry Date"); // cal = Calendar.getInstance(); cal.set(14, 12, 12); dF.setValue(cal.getTime()); dF.setValue(cal.getTime()); dFDoE = dF; dFDoE.setRequired(true); dFDoE.setImmediate(true); arrLAllFormFields.add(dF); arrLAllEditableFields.add(dF); arrLTfEditableVals.add(dF.getValue().toString()); cCompany.addComponent(dF); cC.addComponent(cCompany); VerticalLayout pC = new VerticalLayout(); lbC = new Label("Primary Contacts"); HorizontalLayout cLbc = new HorizontalLayout(); cLbc.setSizeUndefined(); cLbc.setMargin(new MarginInfo(true, false, false, false)); cLbc.addComponent(lbC); pC.addComponent(cLbc); tF = new TextField("Mobile Phone No."); tF.setValue("+256704191152"); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); tFPMNo = tF; pC.addComponent(tF); tF = new TextField("Alt. Phone No."); tF.setValue("+1704191152"); tFPANo = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); pC.addComponent(tF); tF = new TextField("Email Address"); tF.setValue("pwndz172@gmail.com"); tFPEmail = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); pC.addComponent(tF); cC.addComponent(pC); VerticalLayout sC = new VerticalLayout(); lbC = new Label("Secondary Contacts"); cLbc = new HorizontalLayout(); cLbc.setSizeUndefined(); cLbc.setMargin(new MarginInfo(true, false, false, false)); cLbc.addComponent(lbC); sC.addComponent(cLbc); tF = new TextField("Mobile Phone No."); tF.setValue("+256804191152"); tFSMNo = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); sC.addComponent(tF); tF = new TextField("Alt. Phone No."); tF.setValue("+1804191152"); tFSANo = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); sC.addComponent(tF); tF = new TextField("E-mail Address"); tF.setValue("pkigozi@swifta.com"); tFSEmail = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); sC.addComponent(tF); cC.addComponent(sC); VerticalLayout physicalC = new VerticalLayout(); lbC = new Label("Physical Address"); cLbc = new HorizontalLayout(); cLbc.setSizeUndefined(); cLbc.setMargin(new MarginInfo(true, false, false, false)); cLbc.addComponent(lbC); physicalC.addComponent(cLbc); tF = new TextField("Street"); tF.setValue("Yusuf Lule Rd."); tFStreet = tF; tFStreet.setRequired(true); physicalC.addComponent(tF); tF = new TextField("Postal Code"); tF.setValue("23"); tFPostalCode = tF; physicalC.addComponent(tF); tF = new TextField("City"); tF.setValue("Kampala"); tFCity = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); tFCity.setRequired(true); physicalC.addComponent(tF); tF = new TextField("Province"); tF.setValue("Central"); tFProv = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); physicalC.addComponent(tF); cC.addComponent(physicalC); /* * || strUserType.equals("BA"))) { tF = new TextField("Fax"); * cC.addComponent(tF); // strAccTypeCaption = Hierarch } */ /* * tF = new TextField("E-mail Address"); cC.addComponent(tF); * * tF = new TextField("Physical Address"); cC.addComponent(tF); */ VerticalLayout cAcc = new VerticalLayout(); Label lbAcc = new Label("Account"); lbAcc.setStyleName("lb_frm_add_user"); cAcc.addComponent(lbAcc); ComboBox comboHierarchy = null; comboHierarchy = new ComboBox("Profile"); Set<Entry<Integer, String>> set = profToID.entrySet(); for (Entry<Integer, String> e : set) { comboHierarchy.addItem(e.getKey()); comboHierarchy.setItemCaption(e.getKey(), e.getValue()); } comboHierarchy.select(1); comboProfile = comboHierarchy; comboProfile.setRequired(true); arrLAllFormFields.add(comboProfile); arrLAllEditableFields.add(comboProfile); arrLTfEditableVals.add((comboProfile.getValue() == null) ? "" : comboProfile.getValue().toString()); cAcc.addComponent(comboHierarchy); final VerticalLayout cLBody = new VerticalLayout(); tF = new TextField("Username"); tF.setValue("Livepwndz"); tFUN = tF; tFUN.setRequired(true); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cLBody.addComponent(tF); tF = new TextField("MSISDN"); tF.setValue("+256774191152"); tFMSISDN = tF; tFMSISDN.setRequired(true); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cLBody.addComponent(tF); // / tF = new TextField("PIN"); // / cLBody.addComponent(tF); tF = new TextField("Email"); tFAccEmail = tF; tFAccEmail.setRequired(true); tFAccEmail.setValue("ppounds1@gmail.com"); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cLBody.addComponent(tF); combo = new ComboBox("Bank Domain"); combo.addItem("Stanbic Bank"); combo.select("Stanbic Bank"); comboBDomain = combo; arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cLBody.addComponent(combo); combo = new ComboBox("Bank Code ID"); combo.addItem("001"); combo.select("001"); comboBID = combo; arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cLBody.addComponent(combo); tF = new TextField("Bank Account"); tF.setValue("00232333452315"); tFBAcc = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); // tFBAcc.setValidationVisible(true); // tFBAcc.addValidator(new NoNull()); cLBody.addComponent(tF); combo.addItem(1); combo.setItemCaption(1, "US Dollars"); combo.select(1); comboCur = combo; arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); cLBody.addComponent(combo); tF = new TextField("Clearing Number"); tF.setValue("00212"); tFClrNo = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cLBody.addComponent(tF); Label lbAccRec = new Label("Account Recovery"); HorizontalLayout cLbAccRec = new HorizontalLayout(); cLbAccRec.setSizeUndefined(); cLbAccRec.setMargin(new MarginInfo(true, false, false, false)); cLbAccRec.addComponent(lbAccRec); // cLBody.addComponent(cLbAccRec); combo = new ComboBox("Security Question"); combo.addItem(1); combo.addItem(2); combo.addItem(3); combo.setItemCaption(1, "What is your grandfather's last name?"); combo.setItemCaption(2, "What was your favorite junior school teacher's name?"); combo.setItemCaption(3, "What was one of your nicknames in school?"); combo.select(2); comboSecQn = combo; arrLAllFormFields.add(combo); arrLAllEditableFields.add(combo); arrLTfEditableVals.add((combo.getValue() == null) ? "" : combo.getValue().toString()); // cLBody.addComponent(combo); tF = new TextField("Answer"); tF.setValue("Mrs. X"); tFSecAns = tF; arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); // cLBody.addComponent(tF); CheckBox chk = new CheckBox("I accept the terms" + " and conditons."); chcTAndC = chk; chk.setStyleName("check_t_and_c"); chk.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { // Notification.show(event.getProperty().getValue().toString()); } }); comboCountry.addFocusListener(new FocusListener() { private static final long serialVersionUID = -5162384967736354225L; @Override public void focus(FocusEvent event) { if (isCSelected) return; Set<Entry<Integer, String>> es = (Set<Entry<Integer, String>>) getCountries().entrySet(); if (es.size() == 0) return; Iterator<Entry<Integer, String>> itr = es.iterator(); comboCountry.setNullSelectionAllowed(false); while (itr.hasNext()) { Entry<Integer, String> e = (Entry<Integer, String>) itr.next(); comboCountry.addItem(e.getKey()); comboCountry.setItemCaption(e.getKey(), e.getValue()); } comboCountry.select(null); isCSelected = true; } }); comboCountry.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -404551290095133508L; @Override public void valueChange(ValueChangeEvent event) { comboState.removeAllItems(); comboLG.removeAllItems(); if (comboCountry.getValue() == null) return; Set<Entry<Integer, String>> es = (Set<Entry<Integer, String>>) getStates( Integer.valueOf(comboCountry.getValue().toString())).entrySet(); if (es.isEmpty()) { return; } Iterator<Entry<Integer, String>> itr = es.iterator(); while (itr.hasNext()) { Entry<Integer, String> e = itr.next(); comboState.addItem(e.getKey()); comboState.setItemCaption(e.getKey(), e.getValue()); } comboState.select(null); } }); comboState.addFocusListener(new FocusListener() { private static final long serialVersionUID = 892516817835461278L; @Override public void focus(FocusEvent event) { Object c = comboCountry.getValue(); if (c == null) { Notification.show("Please select country first", Notification.Type.WARNING_MESSAGE); comboCountry.focus(); return; } } }); comboState.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 8849241310354979908L; @Override public void valueChange(ValueChangeEvent event) { comboLG.removeAllItems(); if (comboState.getValue() == null) return; Set<Entry<Integer, String>> esl = (Set<Entry<Integer, String>>) getLGs( Integer.valueOf(comboState.getValue().toString())).entrySet(); if (esl.isEmpty()) { return; } Iterator<Entry<Integer, String>> itrl = esl.iterator(); while (itrl.hasNext()) { Entry<Integer, String> e = itrl.next(); comboLG.addItem(e.getKey()); comboLG.setItemCaption(e.getKey(), e.getValue()); } } }); comboLG.addFocusListener(new FocusListener() { private static final long serialVersionUID = 8925916817835461278L; @Override public void focus(FocusEvent event) { Object s = comboState.getValue(); if (comboCountry.getValue() == null) { Notification.show("Please select country first", Notification.Type.WARNING_MESSAGE); comboCountry.focus(); return; } if (s == null) { Notification.show("Please select state first", Notification.Type.WARNING_MESSAGE); comboState.focus(); return; } } }); HorizontalLayout cChk = new HorizontalLayout(); cChk.setSizeUndefined(); cChk.setMargin(new MarginInfo(true, false, true, false)); cChk.addComponent(chk); // cLBody.addComponent(cChk); final VerticalLayout cRBody = new VerticalLayout(); String strNameCap = "Username"; tF = new TextField(strNameCap); arrLAllFormFields.add(tF); arrLAllEditableFields.add(tF); arrLTfEditableVals.add(tF.getValue()); cRBody.addComponent(tF); HorizontalLayout cAccBody = new HorizontalLayout(); cAccBody.addComponent(cLBody); cAccBody.addComponent(cRBody); cLBody.setStyleName("c_body_visible"); cRBody.setStyleName("c_body_invisible"); cAcc.addComponent(cAccBody); cBAndCAndAcc.addComponent(cAcc); cC.setMargin(new MarginInfo(false, true, false, true)); cAgentInfo.addComponent(cBAndCAndAcc); final String btnSaveId = "save"; final String btnEditId = "edit"; final Button btnEdit = new Button(); btnEdit.setIcon(FontAwesome.SAVE); btnEdit.setId(btnSaveId); btnEdit.setStyleName("btn_link"); final Button btnCancel = new Button(); btnCancel.setVisible(true); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); final HorizontalLayout cBtnSR = new HorizontalLayout(); cBtnSR.addComponent(btnEdit); cBtnSR.addComponent(btnCancel); // cBtnEditCancel cAcc.addComponent(cBtnSR); btnEdit.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -935880570210949227L; @Override public void buttonClick(ClickEvent event) { /* * Prepare all Editable fields (Entire form) for editing. */ if (event.getButton().getId().equals(btnEditId)) { /* * By Default, btnCancel is not visible, until btnEdit is * clicked. Only until then is it added and visible. */ if (!btnCancel.isVisible()) { event.getButton().setId(btnSaveId); event.getButton().setIcon(FontAwesome.SAVE); btnCancel.setVisible(true); cBtnSR.addComponent(btnCancel); } enableEditableFormFields(arrLAllEditableFields); } else { if (event.getButton().getId().equals(btnSaveId)) { /* * * * * * commit (save) changes i.e, send changes back to the * server. */ try { validateAndSave(); // cUPersonalDetails.removeAllComponents(); // cUPersonalDetails.addComponent(getUDContainer()); // Notification.show("Details successfully saved.", // Notification.Type.WARNING_MESSAGE); } catch (Exception e) { // Notification.show("Hello"); return; } // Remove undo button (btnCancel) btnCancel.setVisible(false); // Reset all Editable fields to readOnly after saving to // the server // disableEditableFields(arrLAllEditableFields); // Reset btnEdit id to btnIdEdit and caption(icon) to // FontAwesome.EDIT btnEdit.setId(btnEditId); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setVisible(false); // Reset Edit status to false uDetailsEditStatus = false; } } } }); btnCancel.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -8179030387969880920L; @Override public void buttonClick(ClickEvent event) { resetForm(arrLAllEditableFields, arrLTfEditableVals); btnEdit.setId(btnEditId); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setVisible(false); btnCancel.setVisible(false); } }); return cAgentInfo; }
From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java
private HorizontalLayout getPC() { VerticalLayout cAgentInfo = new VerticalLayout(); final HorizontalLayout cPlaceholder = new HorizontalLayout(); cAgentInfo.setMargin(new MarginInfo(true, true, true, true)); cAgentInfo.setStyleName("c_details_test"); final VerticalLayout cLBody = new VerticalLayout(); cLBody.setStyleName("c_body_visible"); tb = new Table("Linked child accounts"); // addLinksTable(); final VerticalLayout cAllProf = new VerticalLayout(); HorizontalLayout cProfActions = new HorizontalLayout(); final FormLayout cProfName = new FormLayout(); cProfName.setStyleName("frm_profile_name"); cProfName.setSizeUndefined();/* w w w. j a v a 2 s. co m*/ final Label lbProf = new Label(); final TextField tFProf = new TextField(); lbProf.setCaption("Profile Name: "); lbProf.setValue("Certified Authorized User."); tFProf.setCaption(lbProf.getCaption()); cProfName.addComponent(lbProf); final Button btnEdit = new Button(); btnEdit.setIcon(FontAwesome.EDIT); btnEdit.setStyleName("btn_link"); btnEdit.setDescription("Edit profile name"); final Button btnCancel = new Button(); btnCancel.setIcon(FontAwesome.UNDO); btnCancel.setStyleName("btn_link"); btnCancel.setDescription("Cancel Profile name editting."); Button btnAdd = new Button("+"); // btnAdd.setIcon(FontAwesome.EDIT); btnAdd.setStyleName("btn_link"); btnAdd.setDescription("Set new profile"); Button btnRemove = new Button("-"); // btnRemove.setIcon(FontAwesome.EDIT); btnRemove.setStyleName("btn_link"); btnRemove.setDescription("Remove current profile"); // cProf.addComponent(cProfName); cProfActions.addComponent(btnEdit); cProfActions.addComponent(btnCancel); cProfActions.addComponent(btnAdd); cProfActions.addComponent(btnRemove); btnCancel.setVisible(false); cAllProf.addComponent(cProfName); cAllProf.addComponent(cProfActions); cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER); cLBody.addComponent(cAllProf); // cLBody.addComponent(tb); tb.setSelectable(true); cAgentInfo.addComponent(cLBody); btnLink = new Button("Add New Link"); btnLink.setIcon(FontAwesome.LINK); btnLink.setDescription("Link new account."); // cLBody.addComponent(btnLink); // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT); btnLink.addClickListener(new LinkClickHandler()); cPlaceholder.setVisible(false); addLinkUserContainer(); cPlaceholder.setWidth("100%"); cLBody.addComponent(cPlaceholder); cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER); HorizontalLayout c = new HorizontalLayout(); c.addComponent(cAgentInfo); btnEdit.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -8427226211153164650L; @Override public void buttonClick(ClickEvent event) { if (btnEdit.getIcon().equals(FontAwesome.EDIT)) { tFProf.setValue(lbProf.getValue()); tFProf.selectAll(); cProfName.replaceComponent(lbProf, tFProf); btnEdit.setIcon(FontAwesome.SAVE); btnCancel.setVisible(true); return; } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) { lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); return; } lbProf.setValue(tFProf.getValue()); cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnCancel.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = -2870045546205986347L; @Override public void buttonClick(ClickEvent event) { cProfName.replaceComponent(tFProf, lbProf); btnEdit.setIcon(FontAwesome.EDIT); btnCancel.setVisible(false); } }); btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder)); btnRemove.addClickListener(new RemoveProfileHandler(pop)); return c; }
From source file:com.trivago.mail.pigeon.web.components.mail.NewsletterProgressComponent.java
License:Apache License
public NewsletterProgressComponent(final Mail mail) { Panel rootPanel = new Panel("Progress for Mail with Suject " + mail.getSubject()); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true);/*w w w.j ava 2 s . c o m*/ DateField df = new DateField("Send Date"); df.setValue(mail.getSendDate()); df.setReadOnly(true); df.setResolution(DateField.RESOLUTION_MIN); indicator = new ProgressIndicator(new Float(0.0)); indicator.setPollingInterval(500); int cnt = 0; Iterable<Relationship> recipients = mail.getRecipients(); for (Relationship rec : recipients) { ++cnt; } final int recpCount = cnt; class WorkerThread extends Thread { int current = 0; public volatile int stop = 0; public void run() { while (true) { if (stop > 0) { break; } try { QueueNewsletter qn = new QueueNewsletter(); int progress = qn.getProgress(mail.getId()); current = recpCount - progress; if (current == recpCount) { mail.setDone(); break; } double result = (recpCount / 100.00) * current; indicator.setValue(new Float(result / 100.00)); sleep(500); } catch (InterruptedException e) { } } } } final WorkerThread workerThread = new WorkerThread(); final Button startButton = new Button("Poll status"); final Button stopButton = new Button("Stop polling"); startButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { workerThread.start(); event.getButton().setVisible(false); stopButton.setVisible(true); } }); stopButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { workerThread.stop = 1; workerThread.interrupt(); event.getButton().setVisible(false); startButton.setVisible(true); } }); stopButton.setVisible(false); vl.addComponent(df); vl.addComponent(indicator); vl.addComponent(startButton); vl.addComponent(stopButton); rootPanel.addComponent(vl); setCompositionRoot(rootPanel); }
From source file:de.symeda.sormas.ui.caze.CaseDataForm.java
License:Open Source License
@Override protected void addFields() { if (person == null || disease == null) { return;//w ww . j a v a 2 s . c o m } // Add fields addFields(CaseDataDto.UUID, CaseDataDto.REPORT_DATE, CaseDataDto.REPORTING_USER, CaseDataDto.DISTRICT_LEVEL_DATE, CaseDataDto.REGION_LEVEL_DATE, CaseDataDto.NATIONAL_LEVEL_DATE, CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.CLASSIFICATION_USER, CaseDataDto.CLASSIFICATION_COMMENT, CaseDataDto.NOTIFYING_CLINIC, CaseDataDto.NOTIFYING_CLINIC_DETAILS, CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL); // Button to automatically assign a new epid number Button assignNewEpidNumberButton = new Button( I18nProperties.getCaption(Captions.actionAssignNewEpidNumber)); CssStyles.style(assignNewEpidNumberButton, ValoTheme.BUTTON_PRIMARY, CssStyles.FORCE_CAPTION); getContent().addComponent(assignNewEpidNumberButton, ASSIGN_NEW_EPID_NUMBER_LOC); assignNewEpidNumberButton.setVisible(false); TextField epidField = addField(CaseDataDto.EPID_NUMBER, TextField.class); epidField.setInvalidCommitted(true); CssStyles.style(epidField, CssStyles.ERROR_COLOR_PRIMARY); assignNewEpidNumberButton.addClickListener(e -> { epidField.setValue(FacadeProvider.getCaseFacade().generateEpidNumber(getValue().toReference())); }); addField(CaseDataDto.CASE_CLASSIFICATION, OptionGroup.class); addField(CaseDataDto.INVESTIGATION_STATUS, OptionGroup.class); addField(CaseDataDto.OUTCOME, OptionGroup.class); addField(CaseDataDto.SEQUELAE, OptionGroup.class); addFields(CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.SEQUELAE_DETAILS); ComboBox diseaseField = addDiseaseField(CaseDataDto.DISEASE, false); addField(CaseDataDto.DISEASE_DETAILS, TextField.class); addField(CaseDataDto.PLAGUE_TYPE, OptionGroup.class); addField(CaseDataDto.DENGUE_FEVER_TYPE, OptionGroup.class); addField(CaseDataDto.CASE_ORIGIN, TextField.class); TextField healthFacilityDetails = addField(CaseDataDto.HEALTH_FACILITY_DETAILS, TextField.class); addField(CaseDataDto.REGION, ComboBox.class); addField(CaseDataDto.DISTRICT, ComboBox.class); addField(CaseDataDto.COMMUNITY, ComboBox.class); addField(CaseDataDto.HEALTH_FACILITY, ComboBox.class); ComboBox surveillanceOfficerField = addField(CaseDataDto.SURVEILLANCE_OFFICER, ComboBox.class); surveillanceOfficerField.setNullSelectionAllowed(true); addField(CaseDataDto.POINT_OF_ENTRY, ComboBox.class); addField(CaseDataDto.POINT_OF_ENTRY_DETAILS, TextField.class); addFields(CaseDataDto.PREGNANT, CaseDataDto.VACCINATION, CaseDataDto.VACCINATION_DOSES, CaseDataDto.VACCINATION_INFO_SOURCE, CaseDataDto.SMALLPOX_VACCINATION_SCAR, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, CaseDataDto.VACCINATION_DATE); // Set initial visibilities initializeVisibilitiesAndAllowedVisibilities(disease, viewMode); // Set requirements that don't need visibility changes and read only status setRequired(true, CaseDataDto.REPORT_DATE, CaseDataDto.CASE_CLASSIFICATION, CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.OUTCOME, CaseDataDto.DISEASE); setSoftRequired(true, CaseDataDto.INVESTIGATED_DATE, CaseDataDto.OUTCOME_DATE, CaseDataDto.PLAGUE_TYPE, CaseDataDto.SURVEILLANCE_OFFICER); FieldHelper.setReadOnlyWhen(getFieldGroup(), CaseDataDto.INVESTIGATED_DATE, CaseDataDto.INVESTIGATION_STATUS, Arrays.asList(InvestigationStatus.PENDING), false); setReadOnly(true, CaseDataDto.UUID, CaseDataDto.REPORTING_USER, CaseDataDto.CLASSIFICATION_USER, CaseDataDto.CLASSIFICATION_DATE, CaseDataDto.REGION, CaseDataDto.DISTRICT, CaseDataDto.COMMUNITY, CaseDataDto.HEALTH_FACILITY, CaseDataDto.HEALTH_FACILITY_DETAILS, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS, CaseDataDto.CASE_ORIGIN); setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CHANGE_DISEASE), CaseDataDto.DISEASE); setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_INVESTIGATE), CaseDataDto.INVESTIGATION_STATUS, CaseDataDto.INVESTIGATED_DATE); setReadOnly(!UserProvider.getCurrent().hasUserRight(UserRight.CASE_CLASSIFY), CaseDataDto.CASE_CLASSIFICATION, CaseDataDto.OUTCOME, CaseDataDto.OUTCOME_DATE); // Set conditional visibilities - ALWAYS call isVisibleAllowed before // dynamically setting the visibility if (isVisibleAllowed(CaseDataDto.PREGNANT)) { setVisible(person.getSex() == Sex.FEMALE, CaseDataDto.PREGNANT); } if (isVisibleAllowed(CaseDataDto.VACCINATION_DOSES)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_DOSES, CaseDataDto.VACCINATION, Arrays.asList(Vaccination.VACCINATED), true); } if (isVisibleAllowed(CaseDataDto.VACCINATION_INFO_SOURCE)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_INFO_SOURCE, CaseDataDto.VACCINATION, Arrays.asList(Vaccination.VACCINATED), true); } if (isVisibleAllowed(CaseDataDto.DISEASE_DETAILS)) { FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.DISEASE_DETAILS), CaseDataDto.DISEASE, Arrays.asList(Disease.OTHER), true); FieldHelper.setRequiredWhen(getFieldGroup(), CaseDataDto.DISEASE, Arrays.asList(CaseDataDto.DISEASE_DETAILS), Arrays.asList(Disease.OTHER)); } if (isVisibleAllowed(CaseDataDto.PLAGUE_TYPE)) { FieldHelper.setVisibleWhen(getFieldGroup(), Arrays.asList(CaseDataDto.PLAGUE_TYPE), CaseDataDto.DISEASE, Arrays.asList(Disease.PLAGUE), true); } if (isVisibleAllowed(CaseDataDto.SMALLPOX_VACCINATION_SCAR)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SMALLPOX_VACCINATION_SCAR, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Arrays.asList(YesNoUnknown.YES), true); } if (isVisibleAllowed(CaseDataDto.VACCINATION_DATE)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_DATE, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED, Arrays.asList(YesNoUnknown.YES), true); FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.VACCINATION_DATE, CaseDataDto.VACCINATION, Arrays.asList(Vaccination.VACCINATED), true); } if (isVisibleAllowed(CaseDataDto.OUTCOME_DATE)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.OUTCOME_DATE, CaseDataDto.OUTCOME, Arrays.asList(CaseOutcome.DECEASED, CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true); } if (isVisibleAllowed(CaseDataDto.SEQUELAE)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE, CaseDataDto.OUTCOME, Arrays.asList(CaseOutcome.RECOVERED, CaseOutcome.UNKNOWN), true); } if (isVisibleAllowed(CaseDataDto.SEQUELAE_DETAILS)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.SEQUELAE_DETAILS, CaseDataDto.SEQUELAE, Arrays.asList(YesNoUnknown.YES), true); } if (isVisibleAllowed(CaseDataDto.NOTIFYING_CLINIC_DETAILS)) { FieldHelper.setVisibleWhen(getFieldGroup(), CaseDataDto.NOTIFYING_CLINIC_DETAILS, CaseDataDto.NOTIFYING_CLINIC, Arrays.asList(HospitalWardType.OTHER), true); } setVisible(UserProvider.getCurrent().hasUserRight(UserRight.CASE_MANAGEMENT_ACCESS), CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL); // Other initializations if (disease == Disease.MONKEYPOX) { Image smallpoxVaccinationScarImg = new Image(null, new ThemeResource("img/smallpox-vaccination-scar.jpg")); CssStyles.style(smallpoxVaccinationScarImg, CssStyles.VSPACE_3); getContent().addComponent(smallpoxVaccinationScarImg, SMALLPOX_VACCINATION_SCAR_IMG); // Set up initial image visibility getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG).setVisible(getFieldGroup() .getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).getValue() == YesNoUnknown.YES); // Set up image visibility listener getFieldGroup().getField(CaseDataDto.SMALLPOX_VACCINATION_RECEIVED).addValueChangeListener(e -> { getContent().getComponent(SMALLPOX_VACCINATION_SCAR_IMG) .setVisible(e.getProperty().getValue() == YesNoUnknown.YES); }); } List<String> medicalInformationFields = Arrays.asList(CaseDataDto.PREGNANT, CaseDataDto.VACCINATION, CaseDataDto.SMALLPOX_VACCINATION_RECEIVED); for (String medicalInformationField : medicalInformationFields) { if (getFieldGroup().getField(medicalInformationField).isVisible()) { Label medicalInformationCaptionLabel = new Label( I18nProperties.getString(Strings.headingMedicalInformation)); medicalInformationCaptionLabel.addStyleName(CssStyles.H3); getContent().addComponent(medicalInformationCaptionLabel, MEDICAL_INFORMATION_LOC); break; } } Label paperFormDatesLabel = new Label(I18nProperties.getString(Strings.headingPaperFormDates)); paperFormDatesLabel.addStyleName(CssStyles.H3); getContent().addComponent(paperFormDatesLabel, PAPER_FORM_DATES_LOC); // Automatic case classification rules button - invisible for other diseases if (disease != Disease.OTHER) { Button classificationRulesButton = new Button(I18nProperties.getCaption(Captions.info), VaadinIcons.INFO_CIRCLE); CssStyles.style(classificationRulesButton, ValoTheme.BUTTON_PRIMARY, CssStyles.FORCE_CAPTION); classificationRulesButton.addClickListener(e -> { ControllerProvider.getCaseController().openClassificationRulesPopup(getValue()); }); getContent().addComponent(classificationRulesButton, CLASSIFICATION_RULES_LOC); } addValueChangeListener(e -> { diseaseField.addValueChangeListener(new DiseaseChangeListener(diseaseField, getValue().getDisease())); // Replace classification user if case has been automatically classified if (getValue().getClassificationDate() != null && getValue().getClassificationUser() == null) { getField(CaseDataDto.CLASSIFICATION_USER).setVisible(false); Label classifiedBySystemLabel = new Label(I18nProperties.getCaption(Captions.system)); classifiedBySystemLabel.setCaption( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.CLASSIFIED_BY)); getContent().addComponent(classifiedBySystemLabel, CLASSIFIED_BY_SYSTEM_LOC); } setEpidNumberError(epidField, assignNewEpidNumberButton, getValue().getEpidNumber()); epidField.addValueChangeListener(f -> { setEpidNumberError(epidField, assignNewEpidNumberButton, (String) f.getProperty().getValue()); }); // Set health facility details visibility and caption if (getValue().getHealthFacility() != null) { boolean otherHealthFacility = getValue().getHealthFacility().getUuid() .equals(FacilityDto.OTHER_FACILITY_UUID); boolean noneHealthFacility = getValue().getHealthFacility().getUuid() .equals(FacilityDto.NONE_FACILITY_UUID); boolean detailsVisible = otherHealthFacility || noneHealthFacility; if (isVisibleAllowed(healthFacilityDetails)) { healthFacilityDetails.setVisible(detailsVisible); } if (otherHealthFacility) { healthFacilityDetails.setCaption(I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, CaseDataDto.HEALTH_FACILITY_DETAILS)); } if (noneHealthFacility) { healthFacilityDetails.setCaption( I18nProperties.getPrefixCaption(CaseDataDto.I18N_PREFIX, NONE_HEALTH_FACILITY_DETAILS)); } } else { setVisible(false, CaseDataDto.CLINICIAN_NAME, CaseDataDto.CLINICIAN_PHONE, CaseDataDto.CLINICIAN_EMAIL); } // Set health facility/point of entry visibility based on case origin if (getValue().getCaseOrigin() == CaseOrigin.POINT_OF_ENTRY) { setVisible(true, CaseDataDto.POINT_OF_ENTRY); setVisible(getValue().getPointOfEntry().isOtherPointOfEntry(), CaseDataDto.POINT_OF_ENTRY_DETAILS); if (getValue().getHealthFacility() == null) { setVisible(false, CaseDataDto.COMMUNITY, CaseDataDto.HEALTH_FACILITY, CaseDataDto.HEALTH_FACILITY_DETAILS); } } else { setVisible(false, CaseDataDto.POINT_OF_ENTRY, CaseDataDto.POINT_OF_ENTRY_DETAILS); } // Hide case origin from port health users if (UserRole.isPortHealthUser(UserProvider.getCurrent().getUserRoles())) { setVisible(false, CaseDataDto.CASE_ORIGIN); } }); }
From source file:de.symeda.sormas.ui.caze.CaseDataForm.java
License:Open Source License
private void setEpidNumberError(TextField epidField, Button assignNewEpidNumberButton, String fieldValue) { if (FacadeProvider.getCaseFacade().doesEpidNumberExist(fieldValue, getValue().getUuid())) { epidField.setComponentError(/*from w w w. j a v a 2s . co m*/ new UserError(I18nProperties.getValidationError(Validations.duplicateEpidNumber))); assignNewEpidNumberButton.setVisible(true); } else { epidField.setComponentError(null); assignNewEpidNumberButton.setVisible( !CaseLogic.isEpidNumberPrefix(fieldValue) && !CaseLogic.isCompleteEpidNumber(fieldValue)); } }