public List<MAnnotation> search(IDomeo domeo, String accessFilter, String textSearch) {
   // System.out.println("3**|textSearch:" + textSearch);
   List<MAnnotation> found = new ArrayList<MAnnotation>();
   for (MAnnotation annotation : domeo.getAnnotationPersistenceManager().getAllAnnotations()) {
     ISearchComponent sc =
         domeo
             .getAnnotationSearchManager()
             .getAnnotationSearchComponent(domeo, annotation.getClass().getName());
     if (sc.filterByAccess(annotation, accessFilter)) {
       if (sc.filterByText(annotation, textSearch)) found.add(annotation);
     }
   }
   return found;
 }
Пример #2
0
  public void createSocialBar(HorizontalPanel socialBar, final MAnnotation annotation) {
    try {
      socialBar.clear();

      if (((BooleanPreference)
              _domeo
                  .getPreferences()
                  .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
          .getValue()) {
        Resources resource = Domeo.resources;

        Image commentIcon = new Image(resource.littleCommentIcon());
        commentIcon.setTitle("Comment on Item");
        commentIcon.setStyleName(ATileComponent.tileResources.css().button());
        commentIcon.addClickHandler(
            ActionCommentAnnotation.getClickHandler(_domeo, this, annotation));
        commentIcon.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                _curationPopup.hide();
              }
            });
        socialBar.add(commentIcon);
        socialBar.add(new Label("(10)"));

        Image usersIcon = new Image(resource.usersIcon());
        usersIcon.setTitle("Involved users");
        usersIcon.setStyleName(ATileComponent.tileResources.css().button());
        usersIcon.addClickHandler(
            ActionCommentAnnotation.getClickHandler(_domeo, this, annotation));
        usersIcon.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                _curationPopup.hide();
              }
            });
        socialBar.add(usersIcon);
        socialBar.setCellWidth(usersIcon, "24px");
        socialBar.setCellHorizontalAlignment(usersIcon, HasHorizontalAlignment.ALIGN_RIGHT);
        socialBar.add(new Label("(2)"));
      }
    } catch (Exception e) {
      _domeo.getLogger().exception(this, "create social bar" + e.getMessage());
    }
  }
Пример #3
0
  private void modifyCurationToken(final MAnnotation annotation, String status) {
    MAnnotationSet set =
        _domeo.getAnnotationPersistenceManager().getSetByAnnotationId(annotation.getLocalId());

    // Check if there is already a curation token
    MAnnotation alreadyExisting = null;
    for (MAnnotation token : annotation.getAnnotatedBy()) {
      if (token instanceof MCurationToken
          && token
              .getCreator()
              .getUri()
              .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
        alreadyExisting = token;
      }
    }
    if (alreadyExisting != null) {
      annotation.getAnnotatedBy().remove(alreadyExisting);
      _domeo.getPersistenceManager().removeAnnotation(alreadyExisting);
    }

    MCurationToken ann =
        CurationFactory.createCurationToken(
            _domeo,
            _domeo.getAgentManager().getUserPerson(),
            _domeo.getAgentManager().getSoftware(),
            annotation,
            status,
            "");

    _domeo
        .getAnnotationPersistenceManager()
        .addAnnotationOfAnnotation(
            ann, annotation, _domeo.getAnnotationPersistenceManager().getCurrentSet());
    _domeo.refreshAnnotationComponents();
  }
 public ASearchComponent getAnnotationSearchComponent(IDomeo domeo, String annotationName) {
   if (annotationSearchComponents.containsKey(annotationName)) {
     return annotationSearchComponents.get(annotationName);
   } else {
     domeo.getLogger().exception(this, "No search component found for: " + annotationName);
     domeo.getLogger().warn(this, "Default search component applied");
     return new ASearchComponent(domeo);
   }
 }
Пример #5
0
 public boolean selectConnector(IDomeo domeo) {
   if (_connector != null) return true;
   _domeo = domeo;
   if (domeo.isStandaloneMode()) {
     _connector = new StandaloneBioPortalConnector();
   } else {
     if (domeo.isHostedMode()) {
       _connector = new GwtBioPortalServiceConnector();
     } else {
       // Real service
       _connector = new JsonBioPortalConnector(domeo);
     }
   }
   domeo
       .getLogger()
       .debug(this, "BioPortal Connector selected: " + _connector.getClass().getName());
   return false;
 }
Пример #6
0
 @Override
 public boolean filterByAccess(MAnnotation annotation, String creatorFilter) {
   if (creatorFilter.equals(ANYBODY)) {
     return true;
   } else if (creatorFilter.equals(ONLY_MINE)
       && annotation
           .getCreator()
           .getUri()
           .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
     return true;
   } else if (creatorFilter.equals(ONLY_OTHERS)
       && !annotation
           .getCreator()
           .getUri()
           .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
     return true;
   }
   return false;
 }
  public List<MAnnotation> search(
      IDomeo domeo, String accessFilter, Long setLocalId, String typeFilter, String textSearch) {
    // System.out.println("1**|textSearch:" + textSearch);
    List<MAnnotation> found = new ArrayList<MAnnotation>();
    for (MAnnotation annotation : domeo.getAnnotationPersistenceManager().getAllAnnotations()) {
      ISearchComponent sc =
          domeo
              .getAnnotationSearchManager()
              .getAnnotationSearchComponent(domeo, annotation.getClass().getName());

      // System.out.println("0 |annotation name:" + annotation.getClass().getName());
      if (sc.filterBySet(annotation, setLocalId)) {
        // System.out.println("0 | 1");
        if (sc.filterByType(annotation, typeFilter)) {
          // System.out.println("0 | 2");
          if (sc.filterByAccess(annotation, accessFilter)) {
            // System.out.println("0 | 3");
            if (sc.filterByText(annotation, textSearch)) found.add(annotation);
          }
        }
      }
    }
    return found;
  }
Пример #8
0
 private Map<String, Integer> countCurationToken(final MAnnotation annotation) {
   Map<String, Integer> tokens = new HashMap<String, Integer>();
   for (MAnnotation token : annotation.getAnnotatedBy()) {
     if (token instanceof MCurationToken
         && !token
             .getCreator()
             .getUri()
             .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
       String status = ((MCurationToken) token).getStatus();
       if (tokens.containsKey(status)) {
         Integer count = tokens.get(status);
         count++;
         tokens.put(status, count);
       } else {
         tokens.put(status, 1);
       }
     }
   }
   return tokens;
 }
  public void initializeLens(MGenericResource resource, HashMap<String, String> parameters) {
    Resources _resources = Domeo.resources;
    try {
      _resource = (MOpenTrialsDocument) resource;
      _parameters = parameters;

      if (parameters.containsKey(MOpenTrialsDocument.PARAM_URI_READONLY)) {
        if (parameters.get(MOpenTrialsDocument.PARAM_URI_READONLY).equals("true")) {
          uriField.setReadOnly(true);
        }
      }

      if (_iconClickHandler != null) _iconClickHandler.removeHandler();
      _iconClickHandler =
          urlImage.addClickHandler(
              new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  Window.alert("Show extractor details not implemented yet");
                }
              });

      refresh();
    } catch (Exception e) {
      _domeo
          .getLogger()
          .exception(this, "Exception while initialing resource info " + e.getMessage());
      body.clear();
      body.add(
          new HTML(
              "<img src='"
                  + _resources.crossLittleIcon().getSafeUri().asString()
                  + "'/> Exception while initialing OpenTrials resource info "
                  + e.getMessage()));
    }
  }
Пример #10
0
 @Override
 public boolean filterBySet(MAnnotation annotation, Long setFilter) {
   if (setFilter == -1l) return true;
   return _domeo.getAnnotationPersistenceManager().isAnnotationInSet(annotation, setFilter);
 }
Пример #11
0
  // ------------------------------------------------------------------------
  //  CREATION OF ANNOTATIONS OF VARIOUS KIND
  // ------------------------------------------------------------------------
  public ComponentsPanel(IDomeo domeo, PluginsViewerPanel parent) {
    _domeo = domeo;
    _parent = parent;
    // _resources = resources;
    // _listPanel = new LogListPanel(_application);

    // Create layout
    initWidget(binder.createAndBindUi(this));
    this.setWidth((Window.getClientWidth() - 140) + "px");

    // Create a CellTable.
    final CellTable<PluginCard> table = new CellTable<PluginCard>();

    // Create name column.
    TextColumn<PluginCard> nameColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.name;
          }
        };

    // Make the name column sortable.
    nameColumn.setSortable(true);

    // Create type column.
    TextColumn<PluginCard> typeColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.type;
          }
        };
    typeColumn.setSortable(true);

    // Create sub type column.
    TextColumn<PluginCard> subTypeColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.subType;
          }
        };

    // Create sub type column.
    TextColumn<PluginCard> versionColumn =
        new TextColumn<PluginCard>() {
          @Override
          public String getValue(PluginCard pluginCard) {
            return pluginCard.version;
          }
        };

    // Add the columns.
    table.addColumn(typeColumn, "Type");
    table.addColumn(subTypeColumn, "Sub Type");
    table.addColumn(nameColumn, "Name");
    table.addColumn(versionColumn, "Version");

    // Create a data provider.
    ListDataProvider<PluginCard> dataProvider = new ListDataProvider<PluginCard>();

    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);

    // Add the data to the data provider, which automatically pushes it to the
    // widget.
    List<PluginCard> list = dataProvider.getList();
    for (APlugin plugin : _domeo.getPluginsManager().getPluginsList()) {
      if (plugin.getMandatory()) {
        PluginCard pluginCard =
            new PluginCard(
                plugin.getPluginName(),
                plugin.getType(),
                plugin.getSubType(),
                plugin.getVersion(),
                true,
                true);
        list.add(pluginCard);
      }
    }

    ListHandler<PluginCard> nameColumnSortHandler = new ListHandler<PluginCard>(list);
    nameColumnSortHandler.setComparator(
        nameColumn,
        new Comparator<PluginCard>() {
          public int compare(PluginCard o1, PluginCard o2) {
            if (o1 == o2) {
              return 0;
            }

            // Compare the name columns.
            if (o1 != null) {
              return (o2 != null) ? o1.name.compareTo(o2.name) : 1;
            }
            return -1;
          }
        });
    table.addColumnSortHandler(nameColumnSortHandler);

    ListHandler<PluginCard> typeColumnSortHandler = new ListHandler<PluginCard>(list);
    typeColumnSortHandler.setComparator(
        typeColumn,
        new Comparator<PluginCard>() {
          public int compare(PluginCard o1, PluginCard o2) {
            if (o1 == o2) {
              return 0;
            }

            // Compare the name columns.
            if (o1 != null) {
              return (o2 != null) ? o1.type.compareTo(o2.type) : 1;
            }
            return -1;
          }
        });
    table.addColumnSortHandler(typeColumnSortHandler);

    componentsPanel.add(table);
  }
Пример #12
0
  public void injectButtons(String plugin, FlowPanel content, final MAnnotation annotation) {
    try {
      if (!((BooleanPreference)
                  _domeo
                      .getPreferences()
                      .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_DISPLAY_PROVENANCE))
              .getValue()
          || !(((BooleanPreference)
                  _domeo
                      .getPreferences()
                      .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_DISPLAY_USER_PROVENANCE))
              .getValue())) {

        Resources resource = Domeo.resources;

        Image commentIcon = null;
        if (((BooleanPreference)
                _domeo
                    .getPreferences()
                    .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
            .getValue()) {
          commentIcon = new Image(resource.littleCommentIcon());
          commentIcon.setTitle("Comment on Item");
          commentIcon.setStyleName(ATileComponent.tileResources.css().button());
          commentIcon.addClickHandler(
              ActionCommentAnnotation.getClickHandler(_domeo, this, annotation));
          commentIcon.addClickHandler(
              new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  _curationPopup.hide();
                }
              });
        }

        Image editIcon = new Image(resource.editLittleIcon());
        editIcon.setTitle("Edit Item");
        if (_domeo.getProfileManager().getUserCurrentProfile().isPluginEnabled(plugin)) {
          editIcon.setStyleName(ATileComponent.tileResources.css().button());
          editIcon.addClickHandler(ActionEditAnnotation.getClickHandler(_domeo, this, annotation));
          editIcon.addClickHandler(
              new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                  _curationPopup.hide();
                }
              });
        }

        Image deleteIcon = new Image(resource.deleteLittleIcon());
        deleteIcon.setTitle("Delete Item");
        deleteIcon.setStyleName(ATileComponent.tileResources.css().button());
        deleteIcon.addClickHandler(
            ActionDeleteAnnotation.getClickHandler(_domeo, this, annotation));
        deleteIcon.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                _curationPopup.hide();
              }
            });

        if (((BooleanPreference)
                _domeo
                    .getPreferences()
                    .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
            .getValue()) {
          content.add(commentIcon);
        }

        content.add(editIcon);
        content.add(deleteIcon);
      }
    } catch (Exception e) {
      _domeo.getLogger().exception(this, "injectButtons: " + e.getMessage());
    }
  }
Пример #13
0
  public void createCurationBar(HorizontalPanel curationBar, final MAnnotation annotation) {
    try {
      curationBar.clear();

      String myToken = CurationUtils.countCurationTokens(_domeo, annotation);

      if (((BooleanPreference)
              _domeo
                  .getPreferences()
                  .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_CURATION))
          .getValue()) {
        Resources resource = Domeo.resources;

        HorizontalPanel curationPanel = new HorizontalPanel();

        int maxCount = 0;
        String maximum = "";
        Map<String, Integer> counts = countCurationToken(annotation);
        Set<String> keys = counts.keySet();
        for (String key : keys) {
          if (counts.containsKey(key)) {
            if (counts.get(key) > maxCount) {
              maximum = key;
              maxCount = counts.get(key);
            }
          }
        }

        final CustomButton correctButton = new CustomButton();
        final CustomButton broadButton = new CustomButton();
        final CustomButton incorrectButton = new CustomButton();

        if (counts.containsKey(MCurationToken.CORRECT)) {
          correctButton.setText("Correct [" + counts.get(MCurationToken.CORRECT) + "]");
        } else correctButton.setText("Correct");

        if (maximum.equals(MCurationToken.CORRECT)) {
          if (myToken.equals(MCurationToken.CORRECT))
            correctButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonBoldGreen());
          else correctButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonBold());
        } else {
          if (myToken.equals(MCurationToken.CORRECT))
            correctButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonGreen());
          else correctButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());
        }

        correctButton.setResource(resource.acceptIcon());
        correctButton.addClickHandler(
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                correctButton.setStyleName(
                    widgetUtilsResources.widgetCss().curationButtonBoldGreen());
                broadButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());
                incorrectButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());

                if (_span != null) {
                  _span.setClassName(StylesManager.LIGHTGREEN_HIGHLIGHT);
                  _span.setAttribute("annotationdefcss", StylesManager.LIGHTGREEN_HIGHLIGHT);
                }

                modifyCurationToken(annotation, MCurationToken.CORRECT);

                //						MAnnotationSet set =
                // _domeo.getAnnotationPersistenceManager().getSetByAnnotationId(annotation.getLocalId());
                //
                //						MCurationToken ann = CurationFactory.createCurationToken(_domeo,
                //							_domeo.getAgentManager().getUserPerson(),
                //							_domeo.getAgentManager().getSoftware(),
                //							annotation, MCurationToken.CORRECT, "");
                //
                //						_domeo.getAnnotationPersistenceManager().addAnnotationOfAnnotation(ann,
                // annotation, _domeo.getAnnotationPersistenceManager().getCurrentSet());
                //						_domeo.refreshAnnotationComponents();
                //
                //	if(!_annotator.getPreferencesManager().isDontOpenCurationPanelWhenConfirming() &&
                //								_annotator.getPreferencesManager().isAutomaticallyOpenCurationPanel()) {
                //							_this.hide();
                //							_annotator.showAnnotationItemHistory(info,  CurationTokenDTO.CORRECT,
                // currentItems, currentSpans);
                //						} else curateAnnotationItem(span, info, CurationTokenDTO.CORRECT);
              }
            });
        curationPanel.add(correctButton);

        if (counts.containsKey(MCurationToken.CORRECT_BROAD)) {
          broadButton.setText("Broad [" + counts.get(MCurationToken.CORRECT_BROAD) + "]");
        } else broadButton.setText("Broad");

        if (maximum.equals(MCurationToken.CORRECT_BROAD)) {
          if (myToken.equals(MCurationToken.CORRECT_BROAD))
            broadButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonBoldGreen());
          else broadButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonBold());
        } else {
          if (myToken.equals(MCurationToken.CORRECT_BROAD))
            broadButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonGreen());
          else broadButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());
        }

        broadButton.setResource(resource.acceptBroadIcon());
        broadButton.addClickHandler(
            new ClickHandler() {
              public void onClick(ClickEvent event) {

                broadButton.setStyleName(
                    widgetUtilsResources.widgetCss().curationButtonBoldGreen());
                correctButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());
                incorrectButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());

                if (_span != null) {
                  _span.setClassName(StylesManager.LIGHTGREEN_HIGHLIGHT);
                  _span.setAttribute("annotationdefcss", StylesManager.LIGHTGREEN_HIGHLIGHT);
                }

                modifyCurationToken(annotation, MCurationToken.CORRECT_BROAD);

                //						MAnnotationSet set =
                // _domeo.getAnnotationPersistenceManager().getSetByAnnotationId(annotation.getLocalId());
                //
                //						MCurationToken ann = CurationFactory.createCurationToken(_domeo,
                //								_domeo.getAgentManager().getUserPerson(),
                //								_domeo.getAgentManager().getSoftware(),
                //								annotation, MCurationToken.CORRECT_BROAD, "");
                //
                //						_domeo.getAnnotationPersistenceManager().addAnnotationOfAnnotation(ann,
                // annotation, _domeo.getAnnotationPersistenceManager().getCurrentSet());
                //						_domeo.refreshAnnotationComponents();

                //						if(_annotator.getPreferencesManager().isAutomaticallyOpenCurationPanel()) {
                //							_this.hide();
                //							_annotator.showAnnotationItemHistory(info,  CurationTokenDTO.CORRECT_BROAD,
                // currentItems, currentSpans);
                //						} else curateAnnotationItem(span, info, CurationTokenDTO.CORRECT_BROAD);
              }
            });
        curationPanel.add(broadButton);

        if (counts.containsKey(MCurationToken.INCORRECT)) {
          incorrectButton.setText("Wrong [" + counts.get(MCurationToken.INCORRECT) + "]");
        } else incorrectButton.setText("Wrong");

        if (maximum.equals(MCurationToken.INCORRECT)) {
          if (myToken.equals(MCurationToken.INCORRECT))
            incorrectButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonBoldRed());
          else incorrectButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonBold());
        } else {
          if (myToken.equals(MCurationToken.INCORRECT))
            incorrectButton.setStyleName(widgetUtilsResources.widgetCss().curationButtonRed());
          else incorrectButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());
        }

        incorrectButton.setResource(resource.rejectIcon());
        incorrectButton.addClickHandler(
            new ClickHandler() {
              public void onClick(ClickEvent event) {

                incorrectButton.setStyleName(
                    widgetUtilsResources.widgetCss().curationButtonBoldRed());
                correctButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());
                broadButton.setStyleName(widgetUtilsResources.widgetCss().curationButton());

                if (_span != null) {
                  _span.setClassName(StylesManager.LIGHTRED_HIGHLIGHT);
                  _span.setAttribute("annotationdefcss", StylesManager.LIGHTRED_HIGHLIGHT);
                }

                modifyCurationToken(annotation, MCurationToken.INCORRECT);

                //						MAnnotationSet set =
                // _domeo.getAnnotationPersistenceManager().getSetByAnnotationId(annotation.getLocalId());

                //						MCurationToken ann = CurationFactory.createCurationToken(_domeo,
                //								_domeo.getAgentManager().getUserPerson(),
                //								_domeo.getAgentManager().getSoftware(),
                //								annotation, MCurationToken.INCORRECT, "");
                //
                //
                //
                ////
                //	if(((BooleanPreference)_domeo.getPreferences().getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_CURATION_MOTIVATION)).getValue()) {
                ////						    _curationPopup.hide();
                ////						    CurationViewer lwp = new CurationViewer(_domeo, annotation, null);
                ////			                new EnhancedGlassPanel(_domeo, lwp, lwp.getTitle(), false,
                // false, false);
                ////						} else {
                //						    _domeo.getAnnotationPersistenceManager().addAnnotationOfAnnotation(ann,
                // annotation, _domeo.getAnnotationPersistenceManager().getCurrentSet());
                //	                        _domeo.refreshAnnotationComponents();
                //						//}

                //						if(_annotator.getPreferencesManager().isAutomaticallyOpenCurationPanel()) {
                //							_this.hide();
                //							_annotator.showAnnotationItemHistory(info,  CurationTokenDTO.INCORRECT,
                // currentItems, currentSpans);
                //						} else curateAnnotationItem(span, info, CurationTokenDTO.INCORRECT);
              }
            });
        curationPanel.add(incorrectButton);

        curationBar.add(curationPanel);

        // curationBar.add(new HTML("WIP: curation bar"));

      }
    } catch (Exception e) {
      _domeo.getLogger().exception(this, "create curation bar" + e.getMessage());
    }
  }
Пример #14
0
  public void createProvenanceBar(
      String plugin, HorizontalPanel provenance, final MAnnotation annotation) {
    try {
      Resources resource = Domeo.resources;

      Image commentIcon = null;
      if (((BooleanPreference)
              _domeo
                  .getPreferences()
                  .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
          .getValue()) {
        commentIcon = new Image(resource.littleCommentIcon());
        commentIcon.setTitle("Comment on Item");
        commentIcon.setStyleName(ATileComponent.tileResources.css().button());
        commentIcon.addClickHandler(
            ActionCommentAnnotation.getClickHandler(_domeo, this, annotation));
        commentIcon.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                _curationPopup.hide();
              }
            });
      }

      Image editIcon = new Image(resource.editLittleIcon());
      editIcon.setTitle("Edit Item");
      if (_domeo.getProfileManager().getUserCurrentProfile().isPluginEnabled(plugin)) {
        editIcon.setStyleName(ATileComponent.tileResources.css().button());
        editIcon.addClickHandler(ActionEditAnnotation.getClickHandler(_domeo, this, annotation));
        editIcon.addClickHandler(
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                _curationPopup.hide();
              }
            });
      }

      Image deleteIcon = new Image(resource.deleteLittleIcon());
      deleteIcon.setTitle("Delete Item");
      deleteIcon.setStyleName(ATileComponent.tileResources.css().button());
      deleteIcon.addClickHandler(ActionDeleteAnnotation.getClickHandler(_domeo, this, annotation));
      deleteIcon.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              _curationPopup.hide();
            }
          });

      // TODO move to an abstract tile class
      if (((BooleanPreference)
              _domeo
                  .getPreferences()
                  .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_DISPLAY_PROVENANCE))
          .getValue()) {
        if (annotation
            .getCreator()
            .getUri()
            .equals(_domeo.getAgentManager().getUserPerson().getUri())) {
          if (((BooleanPreference)
                  _domeo
                      .getPreferences()
                      .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_DISPLAY_USER_PROVENANCE))
              .getValue()) {
            provenance.clear();

            // TODO Externalize the icon management to the plugins
            if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
              Image ic = new Image(Domeo.resources.multipleLittleIcon());
              ic.setTitle("Annotation on multiple targets");
              provenance.add(ic);
              provenance.setCellWidth(ic, "18px");
            } else if (annotation.getSelector() != null
                && annotation.getSelector().getTarget() instanceof MOnlineImage) {
              Image ic = new Image(Domeo.resources.littleImageIcon());
              ic.setTitle("Annotation on image");
              provenance.add(ic);
              provenance.setCellWidth(ic, "18px");
            } else {
              Image ic = new Image(Domeo.resources.littleTextIcon());
              ic.setTitle("Annotation on text");
              provenance.add(ic);
              provenance.setCellWidth(ic, "18px");
            }

            provenance.add(new Label("By Me on " + annotation.getFormattedCreationDate()));

            if (((BooleanPreference)
                    _domeo
                        .getPreferences()
                        .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
                .getValue()) {
              provenance.add(commentIcon);
              provenance.setCellWidth(commentIcon, "20px");
              provenance.setCellHorizontalAlignment(
                  commentIcon, HasHorizontalAlignment.ALIGN_RIGHT);
            }

            provenance.add(editIcon);
            provenance.setCellWidth(editIcon, "20px");
            provenance.setCellHorizontalAlignment(editIcon, HasHorizontalAlignment.ALIGN_RIGHT);
            provenance.add(deleteIcon);
            provenance.setCellWidth(deleteIcon, "20px");
            provenance.setCellHorizontalAlignment(deleteIcon, HasHorizontalAlignment.ALIGN_RIGHT);
          } else {
            provenance.setVisible(false);
          }
        } else {
          provenance.clear();

          // TODO Externalize the icon management to the plugins
          if (SelectorUtils.isOnMultipleTargets(annotation.getSelectors())) {
            Image ic = new Image(Domeo.resources.multipleLittleIcon());
            ic.setTitle("Annotation on multiple targets");
            provenance.add(ic);
            provenance.setCellWidth(ic, "18px");
          } else if (annotation.getSelector() != null
              && annotation.getSelector().getTarget() instanceof MOnlineImage) {
            Image ic = new Image(Domeo.resources.littleImageIcon());
            ic.setTitle("Annotation on image");
            provenance.add(ic);
            provenance.setCellWidth(ic, "18px");
          } else {
            Image ic = new Image(Domeo.resources.littleTextIcon());
            ic.setTitle("Annotation on text");
            provenance.add(ic);
            provenance.setCellWidth(ic, "18px");
          }

          provenance.add(
              new Label(
                  "By "
                      + annotation.getCreator().getName()
                      + " on "
                      + annotation.getFormattedCreationDate()));

          if (((BooleanPreference)
                  _domeo
                      .getPreferences()
                      .getPreferenceItem(Domeo.class.getName(), Domeo.PREF_ALLOW_COMMENTING))
              .getValue()) {
            provenance.add(commentIcon);
            provenance.setCellWidth(commentIcon, "20px");
            provenance.setCellHorizontalAlignment(commentIcon, HasHorizontalAlignment.ALIGN_RIGHT);
          }

          provenance.add(editIcon);
          provenance.setCellWidth(editIcon, "20px");
          provenance.setCellHorizontalAlignment(editIcon, HasHorizontalAlignment.ALIGN_RIGHT);
          provenance.add(deleteIcon);
          provenance.setCellWidth(deleteIcon, "20px");
          provenance.setCellHorizontalAlignment(deleteIcon, HasHorizontalAlignment.ALIGN_RIGHT);
        }
      } else {
        provenance.setVisible(false);
      }
    } catch (Exception e) {
      _domeo.getLogger().exception(this, "createProvenanceBar2" + e.getMessage());
    }
  }
  public void refresh() {
    Resources _resources = Domeo.resources;

    try {
      init();
      uriField.setValue(_resource.getUrl());
      // sourceField.add(new HTML("<img src='" + Domeo.resources.externalLinkIcon().getURL() + "'/>
      // <a href='" +
      //	_resource.getSource().getHomepage() + "' target='_blank'>"+_resource.getSource().getName()
      // + "</a> "));

      String synonyms = _resource.getIsAbout().getSynonyms();
      aboutField.add(
          new HTML(
              _resource.getIsAbout().getLabel()
                  + " "
                  + (_resource.getIsAbout().getSynonyms() != null ? synonyms : "")));

      if (_domeo.getExtractorsManager().isExtractorDefined()) {
        urlImage.setResource(_resources.checkIcon());
        urlImage.setTitle(
            "Known resource, executed extractor '"
                + _domeo.getExtractorsManager().getExtractorLabel()
                + "'");
        urlImage.setVisible(true);
      } else {
        urlImage.setVisible(false);
      }

      if (_resource != null) {
        extractionProvenanceImage.setUrl(
            Domeo.resources.pluginsGrayLittleIcon().getSafeUri().asString());
        extractionProvenanceImage.setTitle(_resource.getCreator().getName());
        extractorProvenanceDetails.setText("Extracted by " + _resource.getCreator().getName());
        extractionSourceDetails.setHTML(
            "Source <a href='"
                + _resource.getSource().getHomepage()
                + "' target='_blank'> <img src='"
                + Domeo.resources.externalLinkIcon().getSafeUri().asString()
                + "'/> "
                + _resource.getSource().getName()
                + "</a>");
        extractionDateDetails.setText("On " + _resource.getFormattedCreationDate());
      }
    } catch (Exception e) {
      _domeo
          .getLogger()
          .exception(this, "Exception while rendering OpenTrials resource info " + e.getMessage());
      body.clear();
      body.add(
          new HTML(
              "<img src='"
                  + _resources.crossLittleIcon().getSafeUri().asString()
                  + "'/> Exception while rendering OpenTrials resource info "
                  + e.getMessage()));
    }

    // References
    try {
      CitationReferencesPanel p = new CitationReferencesPanel(_domeo, false);
      referencesPanel.clear();
      referencesPanel.add(p);
    } catch (Exception e) {
      _domeo
          .getLogger()
          .exception(this, "Exception while rendering resource info " + e.getMessage());
      referencesPanel.clear();
      referencesPanel.add(
          new HTML(
              "<img src='"
                  + _resources.crossLittleIcon().getSafeUri().asString()
                  + "'/> Exception while rendering PubMed resource info "
                  + e.getMessage()));
    }

    // Generic Document Resource
    try {
      LDocumentResourceCardPanel d = new LDocumentResourceCardPanel(_domeo);
      d.initializeLens(_resource, _parameters);
      contentPanel.clear();
      contentPanel.add(d);
    } catch (Exception e) {
      _domeo
          .getLogger()
          .exception(this, "Exception while rendering resource info " + e.getMessage());
      body.clear();
      body.add(
          new HTML(
              "<img src='"
                  + _resources.crossLittleIcon().getSafeUri().asString()
                  + "'/> Exception while rendering OpenTrials resource info "
                  + e.getMessage()));
    }
  }