Ejemplo n.º 1
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());
    }
  }
Ejemplo n.º 2
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());
    }
  }
Ejemplo n.º 3
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());
    }
  }
Ejemplo n.º 4
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());
    }
  }