Revert "[Bug #1274] Remove LenientDecimalBox."
This reverts commit 8fa78f51f8.
This commit is contained in:
parent
8fa78f51f8
commit
e796b88be3
6 changed files with 71 additions and 2 deletions
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2011 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.libreplan.web.common;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zul.Decimalbox;
|
||||
|
||||
/**
|
||||
* Same behavior as a {@link Decimalbox}, but it always interprets <b>,</b> and
|
||||
* <b>.</b> as decimals separators. So you can use both freely as decimal
|
||||
* separators.
|
||||
*
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*
|
||||
*/
|
||||
public class LenientDecimalBox extends Decimalbox {
|
||||
|
||||
public LenientDecimalBox() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LenientDecimalBox(BigDecimal value) throws WrongValueException {
|
||||
super(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -60,6 +60,7 @@ import org.libreplan.business.workingday.EffortDuration;
|
|||
import org.libreplan.business.workingday.EffortDuration.IEffortFrom;
|
||||
import org.libreplan.business.workingday.ResourcesPerDay;
|
||||
import org.libreplan.web.common.EffortDurationBox;
|
||||
import org.libreplan.web.common.LenientDecimalBox;
|
||||
import org.libreplan.web.common.Util;
|
||||
import org.libreplan.web.planner.allocation.ResourceAllocationController.DerivedAllocationColumn;
|
||||
import org.zkoss.zk.au.out.AuWrongValue;
|
||||
|
|
@ -283,7 +284,7 @@ public abstract class AllocationRow {
|
|||
|
||||
private EffortDurationBox effortInput = new EffortDurationBox();
|
||||
|
||||
private final Decimalbox intendedResourcesPerDayInput = new Decimalbox();
|
||||
private final Decimalbox intendedResourcesPerDayInput = new LenientDecimalBox();
|
||||
|
||||
private ResourcesPerDay editedValue;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.libreplan.business.resources.entities.ResourceEnum;
|
|||
import org.libreplan.web.I18nHelper;
|
||||
import org.libreplan.web.common.EffortDurationBox;
|
||||
import org.libreplan.web.common.IMessagesForUser;
|
||||
import org.libreplan.web.common.LenientDecimalBox;
|
||||
import org.libreplan.web.common.Util;
|
||||
import org.libreplan.web.common.components.AllocationSelector;
|
||||
import org.libreplan.web.common.components.NewAllocationSelector;
|
||||
|
|
@ -141,7 +142,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
allResourcesPerDay = new Decimalbox();
|
||||
allResourcesPerDay = new LenientDecimalBox();
|
||||
allResourcesPerDay.setWidth("80px");
|
||||
initAllocationLabels();
|
||||
makeReadyInputsForCalculationTypes();
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@
|
|||
<macro-uri>/common/components/templateFinder.zul</macro-uri>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-name>LenientDecimalBox</component-name>
|
||||
<component-class>org.libreplan.web.common.LenientDecimalBox</component-class>
|
||||
<widget-class>webcommon.LenientDecimalBox</widget-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<component-name>LimitingResourcesPanel</component-name>
|
||||
<component-class>org.libreplan.web.limitingresources.LimitingResourcesPanel</component-class>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
zk.$package("webcommon");
|
||||
|
||||
webcommon.LenientDecimalBox = zk.$extends(zul.inp.Decimalbox,{
|
||||
|
||||
coerceFromString_: function (b) {
|
||||
if(!b) {
|
||||
return null;
|
||||
}
|
||||
//replace decimal comma with dot
|
||||
b = b.replace(',','.');
|
||||
//process normally
|
||||
return this.$supers('coerceFromString_', arguments);
|
||||
}
|
||||
});
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
<package name="webcommon" language="xul/html" depends="zul.inp">
|
||||
<widget name="LenientDecimalBox"/>
|
||||
</package>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue