Commit 37c126ae authored by Thomas Huster's avatar Thomas Huster

[14358] reworked eigenartikel ui fixed set and display selling price

parent 4b3ca122
......@@ -34,6 +34,7 @@ import ch.elexis.core.ui.databinding.SavingUpdateValueStrategy;
import ch.elexis.core.ui.icons.Images;
import ch.elexis.core.ui.locks.IUnlockable;
import ch.elexis.core.ui.views.controls.StockDetailComposite;
import ch.rgw.tools.Money;
public class EigenartikelComposite extends Composite implements IUnlockable {
......@@ -78,14 +79,7 @@ public class EigenartikelComposite extends Composite implements IUnlockable {
}
public void setEigenartikel(IArticle eigenartikel){
IArticle current = this.drugPackageEigenartikel.getValue();
if (current != null) {
if (current.equals(eigenartikel)) {
this.drugPackageEigenartikel.setValue(eigenartikel);
}
} else {
this.drugPackageEigenartikel.setValue(eigenartikel);
}
this.drugPackageEigenartikel.setValue(eigenartikel);
}
private void createArticlePart(){
......@@ -273,13 +267,18 @@ public class EigenartikelComposite extends Composite implements IUnlockable {
// //
ISWTObservableValue observeTextTxtpubPriceObserveWidget =
WidgetProperties.text(SWT.Modify).observe(txtpubPrice);
IObservableValue<String> drugPackageEigenartikelVKPreisObserveDetailValue =
PojoProperties.value(IArticle.class, "sellingPrice", String.class)
IObservableValue<Money> drugPackageEigenartikelVKPreisObserveDetailValue =
PojoProperties.value(IArticle.class, "sellingPrice", Money.class)
.observeDetail(drugPackageEigenartikel);
SavingUpdateValueStrategy target2ModelStrategy =
new SavingUpdateValueStrategy(CoreModelServiceHolder.get(), drugPackageEigenartikel);
target2ModelStrategy.setConverter(new String2MoneyConverter());
UpdateValueStrategy model2TargetStrategy = new UpdateValueStrategy<>();
model2TargetStrategy.setConverter(new Money2StringConverter());
bindingContext.bindValue(observeTextTxtpubPriceObserveWidget,
drugPackageEigenartikelVKPreisObserveDetailValue,
new SavingUpdateValueStrategy(CoreModelServiceHolder.get(), drugPackageEigenartikel),
null);
target2ModelStrategy,
model2TargetStrategy);
// //
ISWTObservableValue observeTextTxtMeasurementUnitObserveWidget =
WidgetProperties.text(SWT.Modify).observe(txtMeasurementUnit);
......
......@@ -177,7 +177,7 @@ public class EigenartikelDetailDisplay implements IDetailDisplay {
container.setLayout(layout);
compProduct = new Composite(container, SWT.None);
// compProduct.setLayout(new GridLayout(1, false));
compProduct.setLayout(new GridLayout(1, false));
ToolBar toolBar = new ToolBar(compProduct, SWT.BORDER | SWT.FLAT | SWT.RIGHT);
toolBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
......
......@@ -82,7 +82,7 @@ public class EigenartikelProductComposite extends Composite implements IUnlockab
Combo comboProductType = comboViewerProductType.getCombo();
GridData gd_comboProductType = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_comboProductType.widthHint = 150;
gd_comboProductType.widthHint = 300;
comboProductType.setLayoutData(gd_comboProductType);
comboViewerProductType.setContentProvider(ArrayContentProvider.getInstance());
comboViewerProductType.setLabelProvider(new LabelProvider() {
......@@ -107,7 +107,7 @@ public class EigenartikelProductComposite extends Composite implements IUnlockab
txtAtcCode = new Text(compAtcCode, SWT.BORDER);
GridData gd_txtAtcCode = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_txtAtcCode.widthHint = 80;
gd_txtAtcCode.widthHint = 300;
txtAtcCode.setLayoutData(gd_txtAtcCode);
txtAtcCode.setTextLimit(8);
new Label(compAtcCode, SWT.NONE);
......
package ch.elexis.core.ui.eigenartikel;
import org.eclipse.core.databinding.conversion.IConverter;
import ch.rgw.tools.Money;
public class Money2StringConverter implements IConverter<Money, String> {
@Override
public Object getFromType(){
return Money.class;
}
@Override
public Object getToType(){
return String.class;
}
@Override
public String convert(Money fromObject){
if (fromObject != null) {
return fromObject.getCentsAsString();
}
return null;
}
}
package ch.elexis.core.ui.eigenartikel;
import org.eclipse.core.databinding.conversion.IConverter;
import ch.rgw.tools.Money;
public class String2MoneyConverter implements IConverter<String, Money> {
@Override
public Object getFromType(){
return String.class;
}
@Override
public Object getToType(){
return Money.class;
}
@Override
public Money convert(String fromObject){
if (fromObject != null) {
try {
return new Money(Integer.parseInt(fromObject));
} catch (NumberFormatException e) {
System.out.println(e.getMessage());
}
}
return null;
}
}
......@@ -64,7 +64,7 @@ public class ArtikelSelektor extends ViewPart implements ISaveablePart2 {
if (description.isPresent()) {
CTabItem ci = new CTabItem(ctab, SWT.NONE);
ci.setText(description.get().getCodeSystemName());
ci.setData(description); //$NON-NLS-1$
ci.setData(description.get()); //$NON-NLS-1$
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment