Exemple #1
0
  private void checkMarkers() {

    int touchesLocks = 0;
    int touchesNotes = 0;
    LinkedList<String> touchingMarkers = new LinkedList<String>();
    Map<String, Marker> markers = editor.getShared().getValue().getMarkers();
    boolean redraw = false;
    for (Entry<String, Marker> e : markers.entrySet()) {
      final Marker m = e.getValue();
      if (!isTabWorthyMarker(m)) {
        continue;
      }
      if (!latestMarkers.containsKey(e.getKey())) {
        redraw = true;
      }
      if (m.touches(selMin, selMax)) {
        touchingMarkers.add(e.getKey());
        if (m.getType() == Marker.Type.LOCK) touchesLocks++;
        if (m.getType() == Marker.Type.COMMENT) touchesNotes++;
      }
    }

    if (!redraw) {
      for (String mid : latestMarkers.keySet()) {
        if (!markers.containsKey(mid)) {
          redraw = true;
          break;
        }
      }
    }

    if (redraw) {
      updateMarkers(markers);
    }

    boolean selected = (selMin != selMax);
    boolean notingEnabled = selected && touchesNotes == 0;
    boolean lockingEnabled = selected && touchesLocks == 0;

    if (touchingMarkers.size() > 0) {
      if (!touchingMarkers.contains(activeMarker)) {
        activeMarker = touchingMarkers.getFirst();
        showMarkerPopup();
      }
    } else if (notingEnabled || lockingEnabled) {
      showAddMarkerPopup(notingEnabled, lockingEnabled);
    } else {
      if (popup != null) {
        popup.setVisible(false);
      }
      activeMarker = null;
    }
  }
Exemple #2
0
  private void showPopup(String title, Component content, int yCoord) {

    if (popup == null) {
      popup = new EditorPopupWindow();
      popup.addListener(
          new CloseListener() {
            public void windowClose(CloseEvent e) {
              popup = null;
            }
          });
      getWindow().addWindow(popup);
    } else {
      popup.removeAllComponents();
      popup.setVisible(true);
    }

    int bw = ((WebApplicationContext) getApplication().getContext()).getBrowser().getScreenWidth();

    popup.setPositionX(bw - 250 - 80);
    popup.setPositionY(yCoord);
    popup.setWidth("250px");
    popup.setHeight("250px");
    popup.setVisible(true);
    popup.setCaption(title);

    popup.getContent().setSizeFull();
    popup.addComponent(content);
  }