use of name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.ClassificationLink in project portfolio by buchen.
the class SecurityTaxonomyPage method createTaxonomySection.
private void createTaxonomySection(final Composite taxonomyPicker, final TaxonomyDesignation designation) {
// label
Label label = new Label(taxonomyPicker, SWT.NONE);
label.setFont(boldFont);
label.setText(designation.getTaxonomy().getName());
boolean isFirst = designation.equals(model.getDesignations().get(0));
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).align(SWT.BEGINNING, SWT.CENTER).indent(0, isFirst ? 0 : 20).applyTo(label);
// drop-down selection block
addBlock(taxonomyPicker, designation);
// add button
Link link = new Link(taxonomyPicker, SWT.UNDERLINE_LINK);
link.setText(Messages.EditWizardMasterDataLinkNewCategory);
GridDataFactory.fillDefaults().span(2, 1).indent(0, 5).align(SWT.BEGINNING, SWT.CENTER).applyTo(link);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ClassificationLink link = new ClassificationLink();
link.setWeight(designation.getLinks().isEmpty() ? Classification.ONE_HUNDRED_PERCENT : 0);
designation.getLinks().add(link);
recreateTaxonomyPicker(taxonomyPicker);
}
});
}
use of name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.ClassificationLink in project portfolio by buchen.
the class SecurityTaxonomyPage method addBlock.
private void addBlock(final Composite taxonomyPicker, final TaxonomyDesignation designation) {
Label sumOfWeights = null;
final List<IObservableValue> weightObservables = new ArrayList<IObservableValue>();
final List<IObservableValue> classificationObservables = new ArrayList<IObservableValue>();
if (designation.getLinks().size() == 1 && designation.getLinks().get(0).getWeight() == Classification.ONE_HUNDRED_PERCENT) {
addSimpleBlock(taxonomyPicker, designation, designation.getLinks().get(0), classificationObservables);
} else if (!designation.getLinks().isEmpty()) {
for (ClassificationLink link : designation.getLinks()) addFullBlock(taxonomyPicker, designation, link, weightObservables, classificationObservables);
// add summary
sumOfWeights = new Label(taxonomyPicker, SWT.NONE);
// $NON-NLS-1$
sumOfWeights.setText("");
GridDataFactory.fillDefaults().span(2, 1).indent(0, 5).align(SWT.BEGINNING, SWT.CENTER).applyTo(sumOfWeights);
}
setupWeightMultiValidator(sumOfWeights, designation, weightObservables);
setupClassificationMultiValidator(designation, classificationObservables);
}
use of name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.ClassificationLink in project portfolio by buchen.
the class SecurityTaxonomyPage method setupWeightMultiValidator.
private void setupWeightMultiValidator(Label sumOfWeights, TaxonomyDesignation designation, final List<IObservableValue> weightObservables) {
MultiValidator multiValidator = new WeightsAreGreaterThan100Validator(sumOfWeights, designation.getTaxonomy(), weightObservables);
bindings.getBindingContext().addValidationStatusProvider(multiValidator);
validators.add(multiValidator);
for (int ii = 0; ii < weightObservables.size(); ii++) {
IObservableValue observable = weightObservables.get(ii);
ClassificationLink link = designation.getLinks().get(ii);
UpdateValueStrategy strategy = new UpdateValueStrategy();
strategy.setAfterConvertValidator(new GreaterThanZeroValidator());
validators.add(bindings.getBindingContext().bindValue(multiValidator.observeValidatedValue(observable), BeanProperties.value("weight").observe(link), strategy, // $NON-NLS-1$
null));
}
}
use of name.abuchen.portfolio.ui.wizards.security.EditSecurityModel.ClassificationLink in project portfolio by buchen.
the class SecurityTaxonomyPage method setupClassificationMultiValidator.
private void setupClassificationMultiValidator(TaxonomyDesignation designation, final List<IObservableValue> classificationObservables) {
MultiValidator multiValidator = new ClassificationNotTwiceValidator(classificationObservables);
bindings.getBindingContext().addValidationStatusProvider(multiValidator);
validators.add(multiValidator);
for (int ii = 0; ii < classificationObservables.size(); ii++) {
IObservableValue observable = classificationObservables.get(ii);
ClassificationLink link = designation.getLinks().get(ii);
UpdateValueStrategy strategy = new UpdateValueStrategy();
strategy.setAfterConvertValidator(new NotNullValidator());
validators.add(bindings.getBindingContext().bindValue(multiValidator.observeValidatedValue(observable), BeanProperties.value("classification").observe(link), strategy, // $NON-NLS-1$
null));
}
}
Aggregations