Search in sources :

Example 1 with Visitor

use of name.abuchen.portfolio.model.Taxonomy.Visitor in project portfolio by buchen.

the class OpenSampleHandler method applyTaxonomyLabels.

private void applyTaxonomyLabels(TaxonomyTemplate template, Taxonomy taxonomy) {
    Taxonomy original = template.buildOriginal();
    taxonomy.setName(original.getName());
    taxonomy.setDimensions(original.getDimensions());
    Map<String, Classification> translated = // 
    original.getAllClassifications().stream().collect(Collectors.toMap(c -> c.getId(), c -> c));
    taxonomy.foreach(new Visitor() {

        @Override
        public void visit(Classification classification) {
            Classification t = translated.get(classification.getId());
            if (t != null) {
                classification.setName(t.getName());
                classification.setNote(t.getNote());
            }
        }
    });
}
Also used : Client(name.abuchen.portfolio.model.Client) IServiceConstants(org.eclipse.e4.ui.services.IServiceConstants) ProgressMonitorInputStream(name.abuchen.portfolio.util.ProgressMonitorInputStream) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) Execute(org.eclipse.e4.core.di.annotations.Execute) Classification(name.abuchen.portfolio.model.Classification) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) Visitor(name.abuchen.portfolio.model.Taxonomy.Visitor) Inject(javax.inject.Inject) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) TokenReplacingReader(name.abuchen.portfolio.util.TokenReplacingReader) ResourceBundle(java.util.ResourceBundle) Map(java.util.Map) ClientFactory(name.abuchen.portfolio.model.ClientFactory) Named(javax.inject.Named) ITokenResolver(name.abuchen.portfolio.util.TokenReplacingReader.ITokenResolver) Taxonomy(name.abuchen.portfolio.model.Taxonomy) TaxonomyTemplate(name.abuchen.portfolio.model.TaxonomyTemplate) UIConstants(name.abuchen.portfolio.ui.UIConstants) MApplication(org.eclipse.e4.ui.model.application.MApplication) Shell(org.eclipse.swt.widgets.Shell) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) MissingResourceException(java.util.MissingResourceException) IOException(java.io.IOException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) UISynchronize(org.eclipse.e4.ui.di.UISynchronize) PortfolioPlugin(name.abuchen.portfolio.ui.PortfolioPlugin) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) PartState(org.eclipse.e4.ui.workbench.modeling.EPartService.PartState) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) InputStream(java.io.InputStream) Visitor(name.abuchen.portfolio.model.Taxonomy.Visitor) Taxonomy(name.abuchen.portfolio.model.Taxonomy) Classification(name.abuchen.portfolio.model.Classification)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Map (java.util.Map)1 MissingResourceException (java.util.MissingResourceException)1 ResourceBundle (java.util.ResourceBundle)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 Classification (name.abuchen.portfolio.model.Classification)1 Client (name.abuchen.portfolio.model.Client)1 ClientFactory (name.abuchen.portfolio.model.ClientFactory)1 Taxonomy (name.abuchen.portfolio.model.Taxonomy)1 Visitor (name.abuchen.portfolio.model.Taxonomy.Visitor)1 TaxonomyTemplate (name.abuchen.portfolio.model.TaxonomyTemplate)1 PortfolioPlugin (name.abuchen.portfolio.ui.PortfolioPlugin)1 UIConstants (name.abuchen.portfolio.ui.UIConstants)1