private double calculateImageProgress() { NameId action = new NameId(); action.setId(propertyId); ArrayList<Image> images = sqlSession.getMapper(ImageMapper.class).imagesbyproductid(action); int imageCount = images.size(); /* set full progress if there are more than 9 images*/ double progress = imageCount < 10 ? imageCount * 10.0 : 100.0; return progress * imageWeightage; }
/* * Creates the panel of license fields. * * @return the panel of license fields. */ private VerticalPanel createContent() { final VerticalPanel form = new VerticalPanel(); final Label title = new Label(CONSTANTS.licenseLabel()); title.addStyleName(AbstractField.CSS.cbtAbstractPopupLabel()); form.add(title); final Label closeButton = new Label(); closeButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { LicensePopup.this.hide(); } }); closeButton.addStyleName(AbstractField.CSS.cbtAbstractPopupClose()); form.add(closeButton); // ----------------------------------------------- // Agent field // ----------------------------------------------- downstreamidField = new SuggestField( this, null, new NameIdAction(Service.PARTY), CONSTANTS.agentLabel(), 20, tab++); downstreamidField.setType(Party.Type.Agent.name()); downstreamidField.setHelpText(CONSTANTS.agentHelp()); form.add(downstreamidField); // ----------------------------------------------- // Product field // ----------------------------------------------- productField = new ListField( this, null, new NameIdAction(Service.PRODUCT), CONSTANTS.productLabel(), true, tab++); productField.setType(Product.Type.Accommodation.name()); productField.setHelpText(CONSTANTS.productHelp()); form.add(productField); // ----------------------------------------------- // Type field // ----------------------------------------------- typeField = new ListField( this, null, NameId.getList(CONSTANTS.types(), License.TYPES), CONSTANTS.typeLabel(), false, tab++); typeField.setDefaultValue(License.Type.All.name()); typeField.setFieldHalf(); typeField.setHelpText(CONSTANTS.typeHelp()); // ----------------------------------------------- // Alert Wait field // ----------------------------------------------- waitField = new IntegerField(this, null, CONSTANTS.waitLabel(), tab++); waitField.setDefaultValue(1000); waitField.setRange(0, 60000); waitField.setEnabled(AbstractRoot.hasPermission(AccessControl.SUPERUSER)); waitField.setHelpText(CONSTANTS.waitHelp()); HorizontalPanel ts = new HorizontalPanel(); form.add(ts); ts.add(typeField); ts.add(waitField); // ----------------------------------------------- // Date span field // ----------------------------------------------- fromtodateField = new DatespanField(this, null, CONSTANTS.fromtodateLabel(), tab++); fromtodateField.setHelpText(CONSTANTS.fromtodateHelp()); form.add(fromtodateField); // ----------------------------------------------- // Subscription field // ----------------------------------------------- subscriptionField = new DoubleField(this, null, CONSTANTS.subscriptionLabel(), AbstractField.IF, tab++); subscriptionField.setHelpText(CONSTANTS.subscriptionHelp()); subscriptionField.setDefaultValue(5.0); subscriptionField.setRange(0.0, 10000.0); subscriptionField.setEnabled(AbstractRoot.getSession().hasPermission(AccessControl.LICENSE)); // ----------------------------------------------- // Transaction field // ----------------------------------------------- transactionField = new DoubleField(this, null, CONSTANTS.transactionLabel(), AbstractField.AF, tab++); transactionField.setHelpText(CONSTANTS.transactionHelp()); transactionField.setDefaultValue(2.0); transactionField.setRange(0.0, 100.0); transactionField.setEnabled(AbstractRoot.getSession().hasPermission(AccessControl.LICENSE)); HorizontalPanel st = new HorizontalPanel(); form.add(st); st.add(subscriptionField); st.add(transactionField); // ----------------------------------------------- // Upstream field // ----------------------------------------------- upstreamField = new DoubleField(this, null, CONSTANTS.upstreamLabel(), AbstractField.AF, tab++); upstreamField.setHelpText(CONSTANTS.upstreamHelp()); upstreamField.setDefaultValue(0.0); upstreamField.setRange(0.0, 100.0); upstreamField.setEnabled(AbstractRoot.getSession().hasPermission(AccessControl.UPSTREAM)); // ----------------------------------------------- // Transaction field // ----------------------------------------------- downstreamField = new DoubleField(this, null, CONSTANTS.downstreamLabel(), AbstractField.AF, tab++); downstreamField.setHelpText(CONSTANTS.downstreamHelp()); downstreamField.setDefaultValue(0.0); downstreamField.setRange(0.0, 100.0); downstreamField.setEnabled(AbstractRoot.getSession().hasPermission(AccessControl.DOWNSTREAM)); HorizontalPanel ud = new HorizontalPanel(); form.add(ud); ud.add(upstreamField); ud.add(downstreamField); // ----------------------------------------------- // Notes field // ----------------------------------------------- notesField = new TextAreaField( this, null, CONSTANTS.notesLabel(), // new LanguageNameId(), tab++); notesField.setMaxLength(255); notesField.setHelpText(CONSTANTS.notesHelp()); form.add(notesField); form.add(createCommands()); onRefresh(); onReset(License.CREATED); return form; }