private synchronized void attachListener(AppNameAnnotationModel annotationModel) { if (attachedTo == annotationModel) { return; } if (attachedTo != null) { attachedTo.removeAnnotationModelListener(listener); } if (annotationModel != null) { annotationModel.addAnnotationModelListener(listener); } attachedTo = annotationModel; }
@Override protected String compute() { AppNameAnnotationModel annotationModel = appNameAnnotationModel.getValue(); attachListener(annotationModel); if (annotationModel != null) { AppNameAnnotation a = annotationModel.getSelectedAppAnnotation(); if (a != null) { return a.getText(); } } return null; }
{ onDispose( (d) -> { if (attachedTo != null) { attachedTo.removeAnnotationModelListener(listener); } }); }
@Override protected List<String> compute() { AppNameAnnotationModel annotationModel = appNameAnnotationModel.getValue(); attachListener(annotationModel); if (annotationModel != null) { List<String> applicationNames = new ArrayList<>(); for (Iterator<Annotation> itr = annotationModel.getAnnotationIterator(); itr.hasNext(); ) { Annotation next = itr.next(); if (next instanceof AppNameAnnotation) { AppNameAnnotation a = (AppNameAnnotation) next; applicationNames.add(a.getText()); } } return applicationNames; } return Collections.emptyList(); }