From bc63b9044c22310cc212bf84000afe0199b076b5 Mon Sep 17 00:00:00 2001 From: Josef Muri Date: Fri, 27 Aug 2021 16:09:38 +0200 Subject: [PATCH 1/4] AB#454 reset value --- src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java b/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java index 5723c75..7f03ac2 100644 --- a/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java +++ b/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java @@ -789,6 +789,8 @@ private void chkExpFlagCostAccount_valueChange(final Property.ValueChangeEvent e this.cmbCostAccountCompany.setRequired(true); } else { this.cmbCostAccountCompany.setRequired(false); + this.cmbCostAccountCompany.setNullSelectionAllowed(true); + this.cmbCostAccountCompany.setValue(null); } From 054894795bccafc8084aa99e4d5ef8eda30cf42e Mon Sep 17 00:00:00 2001 From: Josef Muri Date: Mon, 27 Sep 2021 17:51:48 +0200 Subject: [PATCH 2/4] AB#487 add new Popup to calculate hours --- .../ui/desktop/ProjectTabView.java | 136 +++---- .../ui/desktop/ProjectTabView.ui.xml | 10 +- .../desktop/project/ProjectEffortDefault.java | 381 ++++++++++++++++++ .../project/ProjectEffortDefault.ui.xml | 97 +++++ .../desktop/project/ProjectLookupPopup.java | 15 + .../desktop/project/ProjectLookupPopup.ui.xml | 1 + 6 files changed, 549 insertions(+), 91 deletions(-) create mode 100644 src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.java create mode 100644 src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.ui.xml diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java index 99fb8a1..4b89db2 100644 --- a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java +++ b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.java @@ -1,13 +1,8 @@ package ch.xwr.seicentobilling.ui.desktop; -import java.time.DayOfWeek; -import java.time.LocalDate; -import java.time.ZoneId; -import java.time.temporal.ChronoUnit; import java.util.Calendar; import java.util.Collection; import java.util.Date; -import java.util.EnumSet; import java.util.Iterator; import java.util.List; @@ -15,7 +10,6 @@ import org.apache.poi.ss.formula.functions.T; -import com.google.common.collect.Lists; import com.vaadin.data.Property; import com.vaadin.data.validator.IntegerRangeValidator; import com.vaadin.event.ItemClickEvent; @@ -89,6 +83,7 @@ import ch.xwr.seicentobilling.entities.Vat; import ch.xwr.seicentobilling.ui.desktop.crm.CustomerLookupPopup; import ch.xwr.seicentobilling.ui.desktop.project.ProjectAllocationPopup; +import ch.xwr.seicentobilling.ui.desktop.project.ProjectEffortDefault; public class ProjectTabView extends XdevView { /** Logger initialized */ @@ -257,8 +252,6 @@ private void cmdNew_buttonClick(final Button.ClickEvent event) { this.fieldGroup.setItemDataSource(bean); setROFields(); - - calculateTargetHours(); } /** @@ -625,55 +618,6 @@ private void prepareCustomerCombo(final Customer bean) { ProjectTabView.this.cmbCustomer.setValue(bean); } - private void calculateTargetHours() { - if (this.dateProStartDate.isValid() && this.dateProEndDate.isValid()) { - final long days = getBusinessDaysDifference(this.dateProStartDate.getValue(), this.dateProEndDate.getValue()); - int ihours = (int) (days * 8); - - int ipercent= 0; - try { - ipercent = Integer.parseInt(this.txtProIntensityPercent.getValue()); - } catch (final Exception e) { - //ignore - } - - if (ipercent > 0) { - ihours = ihours * ipercent / 100; - } - if (ihours < 1) { - ihours = 1; - } - - this.txtProHours.setValue("" + ihours); - //System.out.println("set hours: " + ihours); - } - } - - private long getBusinessDaysDifference(final Date dFrom, final Date dTo) { - - final LocalDate startDate = convertToLocalDateViaInstant(dFrom); - final LocalDate endDate = convertToLocalDateViaInstant(dTo); - - final EnumSet weekend = EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY); - final List list = Lists.newArrayList(); - - LocalDate start = startDate; - while (start.isBefore(endDate)) { - list.add(start); - start = start.plus(1, ChronoUnit.DAYS); - } - - final long numberOfDays = list.stream().filter(d -> !weekend.contains(d.getDayOfWeek())).count(); - - return numberOfDays; - } - - public LocalDate convertToLocalDateViaInstant(final Date dateToConvert) { - final java.util.Date utilDate = new java.util.Date(dateToConvert.getTime()); - return utilDate.toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDate(); - } /** * Event handler delegate method for the {@link XdevPopupDateField} @@ -685,10 +629,6 @@ public LocalDate convertToLocalDateViaInstant(final Date dateToConvert) { private void dateProEndDate_valueChange(final Property.ValueChangeEvent event) { validateDateFromTo(); - if (this.dateProEndDate.isModified()) { - calculateTargetHours(); - } - } private void validateDateFromTo() { @@ -703,19 +643,6 @@ private void validateDateFromTo() { } - /** - * Event handler delegate method for the {@link XdevTextField} - * {@link #txtProIntensityPercent}. - * - * @see Property.ValueChangeListener#valueChange(Property.ValueChangeEvent) - * @eventHandlerDelegate Do NOT delete, used by UI designer! - */ - private void txtProIntensityPercent_valueChange(final Property.ValueChangeEvent event) { - if (this.txtProIntensityPercent.isModified()) { - calculateTargetHours(); - } - } - /** * Event handler delegate method for the {@link XdevButton} * {@link #cmdInfoAddress}. @@ -896,6 +823,43 @@ private void dateProStartDate_valueChange(final Property.ValueChangeEvent event) validateDateFromTo(); } + /** + * Event handler delegate method for the {@link XdevButton} {@link #cmdHours}. + * + * @see Button.ClickListener#buttonClick(Button.ClickEvent) + * @eventHandlerDelegate Do NOT delete, used by UI designer! + */ + private void cmdHours_buttonClick(final Button.ClickEvent event) { + final Project proDao = new Project(); + proDao.setProStartDate(this.dateProStartDate.getValue()); + proDao.setProEndDate(this.dateProEndDate.getValue()); + proDao.setProIntensityPercent((Integer) this.txtProIntensityPercent.getConvertedValue()); + proDao.setProHours((Integer) this.txtProHours.getConvertedValue()); + + UI.getCurrent().getSession().setAttribute("ProjectDao", proDao); + + popupProjectEffortDefault(); + } + + private void popupProjectEffortDefault() { + final Window win = ProjectEffortDefault.getPopupWindow(); + + win.addCloseListener(new CloseListener() { + @Override + public void windowClose(final CloseEvent e) { + final Project proDao = (Project) UI.getCurrent().getSession().getAttribute("ProjectDao"); + + ProjectTabView.this.txtProHours.setValue(proDao.getProHours().toString()); + ProjectTabView.this.dateProEndDate.setValue(proDao.getProEndDate()); + ProjectTabView.this.txtProIntensityPercent.setValue(proDao.getProIntensityPercent().toString()); + + } + + }); + this.getUI().addWindow(win); + + } + /* * WARNING: Do NOT edit!
The content of this method is always regenerated by * the UI designer. @@ -932,7 +896,6 @@ private void initUI() { this.dateProEndDate = new XdevPopupDateField(); this.lblProIntensityPercent = new XdevLabel(); this.txtProIntensityPercent = new XdevTextField(); - this.label4 = new XdevLabel(); this.lblProHours = new XdevLabel(); this.txtProHours = new XdevTextField(); this.lblProHoursEffective = new XdevLabel(); @@ -981,6 +944,7 @@ private void initUI() { this.horizontalLayout = new XdevHorizontalLayout(); this.cmdSave = new XdevButton(); this.cmdReset = new XdevButton(); + this.cmdHours = new XdevButton(); this.fieldGroup = new XdevFieldGroup<>(Project.class); this.horizontalSplitPanel.setStyleName("large"); @@ -1065,8 +1029,6 @@ private void initUI() { this.dateProEndDate.setRequired(true); this.lblProIntensityPercent .setValue(StringResourceUtils.optLocalizeString("{$lblProIntensityPercent.value}", this)); - this.label4.setIcon(FontAwesome.INFO_CIRCLE); - this.label4.setDescription("Stunden Soll wird vorgeschlagen, sobald Datum oder Intensität verändert wird."); this.lblProHours.setValue("Stunden Soll"); this.txtProHours .setConverter(ConverterBuilder.stringToDouble().minimumFractionDigits(2).maximumFractionDigits(2).build()); @@ -1168,6 +1130,8 @@ private void initUI() { this.cmdSave.setCaption(StringResourceUtils.optLocalizeString("{$cmdSave.caption}", this)); this.cmdReset.setIcon(FontAwesome.UNDO); this.cmdReset.setCaption(StringResourceUtils.optLocalizeString("{$cmdReset.caption}", this)); + this.cmdHours.setIcon(FontAwesome.CLOCK_O); + this.cmdHours.setCaption("Stunden..."); this.fieldGroup.bind(this.cmbCustomer, Project_.customer.getName()); this.fieldGroup.bind(this.txtProName, Project_.proName.getName()); this.fieldGroup.bind(this.txtProExtReference, Project_.proExtReference.getName()); @@ -1271,9 +1235,6 @@ private void initUI() { this.gridLayout.addComponent(this.lblProIntensityPercent, 0, 4); this.txtProIntensityPercent.setSizeUndefined(); this.gridLayout.addComponent(this.txtProIntensityPercent, 1, 4); - this.label4.setWidth(100, Unit.PERCENTAGE); - this.label4.setHeight(-1, Unit.PIXELS); - this.gridLayout.addComponent(this.label4, 2, 4); this.lblProHours.setSizeUndefined(); this.gridLayout.addComponent(this.lblProHours, 0, 5); this.txtProHours.setSizeUndefined(); @@ -1383,11 +1344,11 @@ private void initUI() { this.verticalLayoutRess.addComponent(verticalLayoutRess_spacer); this.verticalLayoutRess.setExpandRatio(verticalLayoutRess_spacer, 1.0F); this.gridLayoutRess.setColumns(1); - this.gridLayoutRess.setRows(2); + this.gridLayoutRess.setRows(1); this.verticalLayoutRess.setSizeFull(); - this.gridLayoutRess.addComponent(this.verticalLayoutRess, 0, 1); + this.gridLayoutRess.addComponent(this.verticalLayoutRess, 0, 0); this.gridLayoutRess.setColumnExpandRatio(0, 10.0F); - this.gridLayoutRess.setRowExpandRatio(1, 10.0F); + this.gridLayoutRess.setRowExpandRatio(0, 10.0F); this.tableOrder.setSizeFull(); this.verticalLayoutBill.addComponent(this.tableOrder); this.verticalLayoutBill.setComponentAlignment(this.tableOrder, Alignment.MIDDLE_CENTER); @@ -1421,6 +1382,9 @@ private void initUI() { this.cmdReset.setSizeUndefined(); this.horizontalLayout.addComponent(this.cmdReset); this.horizontalLayout.setComponentAlignment(this.cmdReset, Alignment.MIDDLE_CENTER); + this.cmdHours.setSizeUndefined(); + this.horizontalLayout.addComponent(this.cmdHours); + this.horizontalLayout.setComponentAlignment(this.cmdHours, Alignment.MIDDLE_CENTER); this.gridLayoutData.setColumns(1); this.gridLayoutData.setRows(2); this.tabSheet.setSizeFull(); @@ -1451,7 +1415,6 @@ private void initUI() { this.btnSearch.addClickListener(event -> this.btnSearch_buttonClick(event)); this.dateProStartDate.addValueChangeListener(event -> this.dateProStartDate_valueChange(event)); this.dateProEndDate.addValueChangeListener(event -> this.dateProEndDate_valueChange(event)); - this.txtProIntensityPercent.addValueChangeListener(event -> this.txtProIntensityPercent_valueChange(event)); this.cmdNewAddress.addClickListener(event -> this.cmdNewAddress_buttonClick(event)); this.cmdDeleteAddress.addClickListener(event -> this.cmdDeleteAddress_buttonClick(event)); this.cmdEditAddress.addClickListener(event -> this.cmdEditAddress_buttonClick(event)); @@ -1459,13 +1422,14 @@ private void initUI() { this.cmdInfoAddress.addClickListener(event -> this.cmdInfoAddress_buttonClick(event)); this.cmdSave.addClickListener(event -> this.cmdSave_buttonClick(event)); this.cmdReset.addClickListener(event -> this.cmdReset_buttonClick(event)); + this.cmdHours.addClickListener(event -> this.cmdHours_buttonClick(event)); } // // private XdevButton cmdNew, cmdDelete, cmdReload, cmdPlan, cmdReport, cmdInfo, btnSearch, cmdNewAddress, - cmdDeleteAddress, cmdEditAddress, cmdReloadAddress, cmdInfoAddress, cmdSave, cmdReset; + cmdDeleteAddress, cmdEditAddress, cmdReloadAddress, cmdInfoAddress, cmdSave, cmdReset, cmdHours; private XdevLabel lblCustomer, lblProName, lblProExtReference, lblProContact, lblProStartDate, lblProEndDate, - lblProIntensityPercent, label4, lblProHours, lblProHoursEffective, lblProRate, lblVat, lblCostAccount, + lblProIntensityPercent, lblProHours, lblProHoursEffective, lblProRate, lblVat, lblCostAccount, lblBillingAddress, lblProState, lblProModel, lblProOrderStrategy, lblProject, lblProDescription, lblProRemark, lblProProjectState, lblProLastBill; private XdevComboBox cmbCostAccount; diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml index 07252b5..dc31a3f 100644 --- a/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml +++ b/src/ch/xwr/seicentobilling/ui/desktop/ProjectTabView.ui.xml @@ -168,11 +168,7 @@ - valueChange.valueChange - - - @@ -309,7 +305,7 @@ - + @@ -415,6 +411,10 @@ click.buttonClick + + + click.buttonClick + diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.java b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.java new file mode 100644 index 0000000..4eacc85 --- /dev/null +++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.java @@ -0,0 +1,381 @@ +package ch.xwr.seicentobilling.ui.desktop.project; + +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; +import java.util.Calendar; +import java.util.Date; +import java.util.EnumSet; +import java.util.List; + +import com.google.common.collect.Lists; +import com.vaadin.data.validator.IntegerRangeValidator; +import com.vaadin.event.ShortcutAction; +import com.vaadin.server.FontAwesome; +import com.vaadin.shared.ui.MarginInfo; +import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.UI; +import com.vaadin.ui.Window; +import com.xdev.ui.XdevButton; +import com.xdev.ui.XdevGridLayout; +import com.xdev.ui.XdevHorizontalLayout; +import com.xdev.ui.XdevLabel; +import com.xdev.ui.XdevPanel; +import com.xdev.ui.XdevPopupDateField; +import com.xdev.ui.XdevTextField; +import com.xdev.ui.XdevView; +import com.xdev.util.ConverterBuilder; + +import ch.xwr.seicentobilling.business.Seicento; +import ch.xwr.seicentobilling.entities.Project; + +public class ProjectEffortDefault extends XdevView { + private Project proDao = null; + + /** + * + */ + public ProjectEffortDefault() { + super(); + this.initUI(); + + this.setHeight(Seicento.calculateThemeHeight(this.getHeight(),UI.getCurrent().getTheme())); + + // get Parameter + this.proDao = (Project) UI.getCurrent().getSession().getAttribute("ProjectDao"); + + if (this.proDao != null) { + this.datePraStartDate.setValue(this.proDao.getProStartDate()); + this.datePraStartDate.setReadOnly(true); + + this.datePraEndDate.setValue(this.proDao.getProEndDate()); + this.txtPraIntensityPercent.setConvertedValue(this.proDao.getProIntensityPercent()); + this.txtPraHours.setConvertedValue(this.proDao.getProHours()); + } + + //setBeanGui(bean); + + + } + + public static Window getPopupWindow() { + final Window win = new Window(); + //win.setWidth("920"); + //win.setHeight("610"); + win.center(); + win.setModal(true); + win.setContent(new ProjectEffortDefault()); + + return win; + } + + private void calculateTargetHours() { + final Integer dayhours = (Integer) this.txtHoursWorkDay.getConvertedValue(); + + if (this.datePraStartDate.isValid() && this.datePraEndDate.isValid()) { + final long days = getBusinessDaysDifference(this.datePraStartDate.getValue(), this.datePraEndDate.getValue()); + int ihours = (int) (days * dayhours.intValue()); + + int ipercent= 0; + try { + ipercent = Integer.parseInt(this.txtPraIntensityPercent.getValue()); + } catch (final Exception e) { + //ignore + } + + if (ipercent > 0) { + ihours = ihours * ipercent / 100; + } + if (ihours < 1) { + ihours = 1; + } + + this.txtPraHours.setValue("" + ihours); + //System.out.println("set hours: " + ihours); + } + } + + private void calculateTargetIntensity() { + final Integer dayhours = (Integer) this.txtHoursWorkDay.getConvertedValue(); + + if (this.datePraStartDate.isValid() && this.datePraEndDate.isValid()) { + final long days = getBusinessDaysDifference(this.datePraStartDate.getValue(), this.datePraEndDate.getValue()); + final Integer ihours = (Integer) this.txtPraHours.getConvertedValue(); + + final int ihoursFull = (int) (days * dayhours.intValue()); + + int ipercent= 0; + try { + ipercent = 100 * ihours.intValue() / ihoursFull; + } catch (final Exception e) { + //ignore + } + + + this.txtPraIntensityPercent.setValue("" + ipercent); + //System.out.println("set hours: " + ihours); + } + + } + + private void calculateTargetDate() { + final Integer dayhours = (Integer) this.txtHoursWorkDay.getConvertedValue(); + + if (this.datePraStartDate.isValid()) { + final Integer ipercent = (Integer) this.txtPraIntensityPercent.getConvertedValue(); + final Integer ihours = (Integer) this.txtPraHours.getConvertedValue(); + final int day1 = ihours / dayhours * 100 / ipercent.intValue(); + + final Date toDate = addDays(this.datePraStartDate.getValue(), day1); + this.datePraEndDate.setValue(toDate); + } + + } + + private Date addDays(final Date date, final int days) + { + final Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.DATE, days); //minus number would decrement the days + return cal.getTime(); + } + + private long getBusinessDaysDifference(final Date dFrom, final Date dTo) { + + final LocalDate startDate = convertToLocalDateViaInstant(dFrom); + final LocalDate endDate = convertToLocalDateViaInstant(dTo); + + final EnumSet weekend = EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY); + final List list = Lists.newArrayList(); + + LocalDate start = startDate; + while (start.isBefore(endDate)) { + list.add(start); + start = start.plus(1, ChronoUnit.DAYS); + } + + final long numberOfDays = list.stream().filter(d -> !weekend.contains(d.getDayOfWeek())).count(); + + final int daysOff = (int) this.txtDaysOff.getConvertedValue(); + + return numberOfDays - daysOff; + } + + public LocalDate convertToLocalDateViaInstant(final Date dateToConvert) { + final java.util.Date utilDate = new java.util.Date(dateToConvert.getTime()); + return utilDate.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + } + + /** + * Event handler delegate method for the {@link XdevButton} {@link #cmdCancel}. + * + * @see Button.ClickListener#buttonClick(Button.ClickEvent) + * @eventHandlerDelegate Do NOT delete, used by UI designer! + */ + private void cmdCancel_buttonClick(final Button.ClickEvent event) { + //this.fieldGroup.discard(); + ((Window) this.getParent()).close(); + } + + /** + * Event handler delegate method for the {@link XdevButton} {@link #cmdDone}. + * + * @see Button.ClickListener#buttonClick(Button.ClickEvent) + * @eventHandlerDelegate Do NOT delete, used by UI designer! + */ + private void cmdDone_buttonClick(final Button.ClickEvent event) { + if (this.proDao != null) { + this.proDao.setProEndDate(this.datePraEndDate.getValue()); + this.proDao.setProIntensityPercent((Integer) this.txtPraIntensityPercent.getConvertedValue()); + this.proDao.setProHours((Integer) this.txtPraHours.getConvertedValue()); + + UI.getCurrent().getSession().setAttribute("ProjectDao", this.proDao); + } + + ((Window) this.getParent()).close(); + } + + /** + * Event handler delegate method for the {@link XdevButton} + * {@link #cmdPraHours}. + * + * @see Button.ClickListener#buttonClick(Button.ClickEvent) + * @eventHandlerDelegate Do NOT delete, used by UI designer! + */ + private void cmdPraHours_buttonClick(final Button.ClickEvent event) { + calculateTargetHours(); + } + + /** + * Event handler delegate method for the {@link XdevButton} + * {@link #cmdPraPercent}. + * + * @see Button.ClickListener#buttonClick(Button.ClickEvent) + * @eventHandlerDelegate Do NOT delete, used by UI designer! + */ + private void cmdPraPercent_buttonClick(final Button.ClickEvent event) { + calculateTargetIntensity(); + } + + + /** + * Event handler delegate method for the {@link XdevButton} {@link #cmdEndDate}. + * + * @see Button.ClickListener#buttonClick(Button.ClickEvent) + * @eventHandlerDelegate Do NOT delete, used by UI designer! + */ + private void cmdEndDate_buttonClick(final Button.ClickEvent event) { + calculateTargetDate(); + } + + + /* + * WARNING: Do NOT edit!
The content of this method is always regenerated by + * the UI designer. + */ + // + private void initUI() { + this.panel = new XdevPanel(); + this.gridLayout = new XdevGridLayout(); + this.lblPraStartDate = new XdevLabel(); + this.datePraStartDate = new XdevPopupDateField(); + this.lblPraEndDate = new XdevLabel(); + this.hlEndDate = new XdevHorizontalLayout(); + this.datePraEndDate = new XdevPopupDateField(); + this.cmdEndDate = new XdevButton(); + this.lblHoursDay = new XdevLabel(); + this.txtHoursWorkDay = new XdevTextField(); + this.lblDaysOff = new XdevLabel(); + this.txtDaysOff = new XdevTextField(); + this.lblPraHours = new XdevLabel(); + this.hlHours = new XdevHorizontalLayout(); + this.txtPraHours = new XdevTextField(); + this.cmdPraHours = new XdevButton(); + this.lblPraIntensityPercent = new XdevLabel(); + this.hlPraIntensity = new XdevHorizontalLayout(); + this.txtPraIntensityPercent = new XdevTextField(); + this.cmdPraPercent = new XdevButton(); + this.horizontalLayout = new XdevHorizontalLayout(); + this.cmdDone = new XdevButton(); + this.cmdCancel = new XdevButton(); + + this.panel.setCaption("Vorschlag berechnen"); + this.lblPraStartDate.setValue("Projektstart"); + this.datePraStartDate.setRequired(true); + this.lblPraEndDate.setValue("Projektende"); + this.hlEndDate.setMargin(new MarginInfo(false)); + this.cmdEndDate.setIcon(FontAwesome.ANGLE_DOUBLE_LEFT); + this.lblHoursDay.setValue("Arbeitstag Std"); + this.txtHoursWorkDay.setConverter(ConverterBuilder.stringToInteger().build()); + this.txtHoursWorkDay.setValue("8"); + this.txtHoursWorkDay.addValidator(new IntegerRangeValidator("", 1, 24)); + this.lblDaysOff.setValue("Tage abziehen"); + this.txtDaysOff.setConverter(ConverterBuilder.stringToInteger().build()); + this.txtDaysOff.setValue("0"); + this.lblPraHours.setValue("Stundensoll"); + this.hlHours.setMargin(new MarginInfo(false)); + this.txtPraHours.setConverter(ConverterBuilder.stringToInteger().build()); + this.txtPraHours.setValue("0"); + this.cmdPraHours.setIcon(FontAwesome.ANGLE_DOUBLE_LEFT); + this.lblPraIntensityPercent.setValue("Intensität"); + this.hlPraIntensity.setMargin(new MarginInfo(false)); + this.txtPraIntensityPercent.setConverter(ConverterBuilder.stringToInteger().build()); + this.txtPraIntensityPercent.setValue("100"); + this.cmdPraPercent.setIcon(FontAwesome.ANGLE_DOUBLE_LEFT); + this.horizontalLayout.setMargin(new MarginInfo(true, false, false, false)); + this.cmdDone.setIcon(FontAwesome.CHECK_CIRCLE); + this.cmdDone.setCaption("Übernehmen"); + this.cmdDone.setClickShortcut(ShortcutAction.KeyCode.ENTER); + this.cmdCancel.setIcon(FontAwesome.CLOSE); + this.cmdCancel.setCaption("Abbrechen"); + this.cmdCancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE); + + this.datePraEndDate.setSizeUndefined(); + this.hlEndDate.addComponent(this.datePraEndDate); + this.hlEndDate.setExpandRatio(this.datePraEndDate, 100.0F); + this.cmdEndDate.setSizeUndefined(); + this.hlEndDate.addComponent(this.cmdEndDate); + this.hlEndDate.setComponentAlignment(this.cmdEndDate, Alignment.MIDDLE_CENTER); + this.txtPraHours.setSizeUndefined(); + this.hlHours.addComponent(this.txtPraHours); + this.hlHours.setExpandRatio(this.txtPraHours, 100.0F); + this.cmdPraHours.setSizeUndefined(); + this.hlHours.addComponent(this.cmdPraHours); + this.hlHours.setComponentAlignment(this.cmdPraHours, Alignment.MIDDLE_CENTER); + this.txtPraIntensityPercent.setSizeUndefined(); + this.hlPraIntensity.addComponent(this.txtPraIntensityPercent); + this.hlPraIntensity.setExpandRatio(this.txtPraIntensityPercent, 100.0F); + this.cmdPraPercent.setSizeUndefined(); + this.hlPraIntensity.addComponent(this.cmdPraPercent); + this.hlPraIntensity.setComponentAlignment(this.cmdPraPercent, Alignment.MIDDLE_CENTER); + this.cmdDone.setSizeUndefined(); + this.horizontalLayout.addComponent(this.cmdDone); + this.horizontalLayout.setComponentAlignment(this.cmdDone, Alignment.MIDDLE_LEFT); + this.cmdCancel.setSizeUndefined(); + this.horizontalLayout.addComponent(this.cmdCancel); + this.horizontalLayout.setComponentAlignment(this.cmdCancel, Alignment.MIDDLE_LEFT); + this.gridLayout.setColumns(4); + this.gridLayout.setRows(5); + this.lblPraStartDate.setSizeUndefined(); + this.gridLayout.addComponent(this.lblPraStartDate, 0, 0); + this.datePraStartDate.setSizeUndefined(); + this.gridLayout.addComponent(this.datePraStartDate, 1, 0); + this.lblPraEndDate.setSizeUndefined(); + this.gridLayout.addComponent(this.lblPraEndDate, 2, 0); + this.hlEndDate.setSizeUndefined(); + this.gridLayout.addComponent(this.hlEndDate, 3, 0); + this.lblHoursDay.setSizeUndefined(); + this.gridLayout.addComponent(this.lblHoursDay, 0, 1); + this.txtHoursWorkDay.setSizeUndefined(); + this.gridLayout.addComponent(this.txtHoursWorkDay, 1, 1); + this.lblDaysOff.setSizeUndefined(); + this.gridLayout.addComponent(this.lblDaysOff, 2, 1); + this.txtDaysOff.setSizeUndefined(); + this.gridLayout.addComponent(this.txtDaysOff, 3, 1); + this.lblPraHours.setSizeUndefined(); + this.gridLayout.addComponent(this.lblPraHours, 0, 2); + this.hlHours.setSizeUndefined(); + this.gridLayout.addComponent(this.hlHours, 1, 2); + this.lblPraIntensityPercent.setSizeUndefined(); + this.gridLayout.addComponent(this.lblPraIntensityPercent, 2, 2); + this.hlPraIntensity.setSizeUndefined(); + this.gridLayout.addComponent(this.hlPraIntensity, 3, 2); + this.horizontalLayout.setSizeUndefined(); + this.gridLayout.addComponent(this.horizontalLayout, 0, 3, 1, 3); + this.gridLayout.setComponentAlignment(this.horizontalLayout, Alignment.TOP_RIGHT); + this.gridLayout.setColumnExpandRatio(1, 100.0F); + this.gridLayout.setColumnExpandRatio(3, 100.0F); + final CustomComponent gridLayout_vSpacer = new CustomComponent(); + gridLayout_vSpacer.setSizeFull(); + this.gridLayout.addComponent(gridLayout_vSpacer, 0, 4, 3, 4); + this.gridLayout.setRowExpandRatio(4, 1.0F); + this.gridLayout.setSizeFull(); + this.panel.setContent(this.gridLayout); + this.panel.setSizeFull(); + this.setContent(this.panel); + this.setWidth(840, Unit.PIXELS); + this.setHeight(340, Unit.PIXELS); + + this.cmdEndDate.addClickListener(event -> this.cmdEndDate_buttonClick(event)); + this.cmdPraHours.addClickListener(event -> this.cmdPraHours_buttonClick(event)); + this.cmdPraPercent.addClickListener(event -> this.cmdPraPercent_buttonClick(event)); + this.cmdDone.addClickListener(event -> this.cmdDone_buttonClick(event)); + this.cmdCancel.addClickListener(event -> this.cmdCancel_buttonClick(event)); + } // + + // + private XdevLabel lblPraStartDate, lblPraEndDate, lblHoursDay, lblDaysOff, lblPraHours, lblPraIntensityPercent; + private XdevButton cmdEndDate, cmdPraHours, cmdPraPercent, cmdDone, cmdCancel; + private XdevHorizontalLayout hlEndDate, hlHours, hlPraIntensity, horizontalLayout; + private XdevPopupDateField datePraStartDate, datePraEndDate; + private XdevPanel panel; + private XdevGridLayout gridLayout; + private XdevTextField txtHoursWorkDay, txtDaysOff, txtPraHours, txtPraIntensityPercent; + // + +} diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.ui.xml new file mode 100644 index 0000000..f2affde --- /dev/null +++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectEffortDefault.ui.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + click.buttonClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + click.buttonClick + + + + + + + + + + + + + + click.buttonClick + + + + + + + click.buttonClick + + + + click.buttonClick + + + + + + diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java index e6be9e6..baed9ff 100644 --- a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java +++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.java @@ -1,7 +1,9 @@ package ch.xwr.seicentobilling.ui.desktop.project; +import com.vaadin.event.ContextClickEvent; import com.vaadin.event.ItemClickEvent; import com.vaadin.event.ShortcutAction; +import com.vaadin.event.ShortcutAction.KeyCode; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; @@ -213,6 +215,18 @@ private void table2_itemClick(final ItemClickEvent event) { } + /** + * Event handler delegate method for the {@link XdevVerticalLayout} + * {@link #verticalLayout2}. + * + * @see ContextClickEvent.ContextClickListener#contextClick(ContextClickEvent) + * @eventHandlerDelegate Do NOT delete, used by UI designer! + */ + private void verticalLayout2_contextClick(final ContextClickEvent event) { + this.btnSelect.removeClickShortcut(); + this.btnSelect2.setClickShortcut(KeyCode.ENTER,null); + } + /* * WARNING: Do NOT edit!
The content of this method is always regenerated by * the UI designer. @@ -362,6 +376,7 @@ private void initUI() { this.table.addItemClickListener(event -> this.table_itemClick(event)); this.btnSelect.addClickListener(event -> this.btnSelect_buttonClick(event)); this.btnCancel.addClickListener(event -> this.btnCancel_buttonClick(event)); + this.verticalLayout2.addContextClickListener(event -> this.verticalLayout2_contextClick(event)); this.table2.addItemClickListener(event -> this.table2_itemClick(event)); this.btnSelect2.addClickListener(event -> this.btnSelect2_buttonClick(event)); this.btnCancel2.addClickListener(event -> this.btnCancel2_buttonClick(event)); diff --git a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml index 5ec5927..ff87e73 100644 --- a/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml +++ b/src/ch/xwr/seicentobilling/ui/desktop/project/ProjectLookupPopup.ui.xml @@ -62,6 +62,7 @@
+ contextClick.contextClick From d1d90304fe05ba6293559958699c55976eeb96dc Mon Sep 17 00:00:00 2001 From: Josef Muri Date: Fri, 8 Oct 2021 17:53:16 +0200 Subject: [PATCH 3/4] prevent NPE when copying expenses --- src/ch/xwr/seicentobilling/ui/desktop/PeriodeDialogPopup.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ch/xwr/seicentobilling/ui/desktop/PeriodeDialogPopup.java b/src/ch/xwr/seicentobilling/ui/desktop/PeriodeDialogPopup.java index 4786af4..4d969f7 100644 --- a/src/ch/xwr/seicentobilling/ui/desktop/PeriodeDialogPopup.java +++ b/src/ch/xwr/seicentobilling/ui/desktop/PeriodeDialogPopup.java @@ -201,6 +201,9 @@ private Object[] getGridLine(final Expense expObj) { final XdevCheckBox kst = new XdevCheckBox(); kst.setValue(expObj.getExpFlagCostAccount().booleanValue()); kst.setEnabled(false); + if (expObj.getExpFlagGeneric() == null) { + expObj.setExpFlagGeneric(LovState.ExpType.standard); + } final XdevLabel type = new XdevLabel(expObj.getExpFlagGeneric().name()); final XdevLabel text = new XdevLabel(expObj.getExpText()); From a103eea6e2c857d9da87e2d1b5275571d4ee2880 Mon Sep 17 00:00:00 2001 From: Josef Muri Date: Tue, 19 Oct 2021 08:31:07 +0200 Subject: [PATCH 4/4] Prevent NPE when expFlagCostAccount is null --- src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java b/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java index 7f03ac2..268863d 100644 --- a/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java +++ b/src/ch/xwr/seicentobilling/ui/desktop/ExpensePopup.java @@ -785,7 +785,7 @@ private void prepareProjectCombo(final Project bean) { */ private void chkExpFlagCostAccount_valueChange(final Property.ValueChangeEvent event) { final Boolean val = (Boolean) event.getProperty().getValue(); - if (! val.booleanValue()) { + if (val != null && ! val.booleanValue()) { this.cmbCostAccountCompany.setRequired(true); } else { this.cmbCostAccountCompany.setRequired(false);