/**
   * Set the given view to be the current view. Fire a contentsChanged() event to registered view
   * listeners. Throw an exception if the view is not known.
   */
  public void setCurrentView(View v) {
    if ((v != null) && !_views.contains(v)) {
      throw new IllegalArgumentException("View " + v + " is not known by application " + this);
    }

    _views.setSelectedItem(v);
  }
  /**
   * Add a document to the list of documents currently known by this application. Fire a document
   * list event to registered listeners. Throw an exception if the document is already in the list
   * of documents.
   */
  public void addDocument(Document d) {
    if (_documents.contains(d)) {
      throw new IllegalArgumentException(
          "Document " + d + " is already known by application " + this);
    }

    _documents.addElement(d);
  }
  /**
   * Remove a view from the list of views currently known by this application. Fire a list data
   * event to registered view listeners. If the removed view is the current view it is up to the
   * application to decide which view to display next. Throw an exception if the view is not known.
   */
  public void removeView(View v) {
    if (!_views.contains(v)) {
      throw new IllegalArgumentException("View " + v + " is not known by application " + this);
    }

    _views.removeElement(v);

    List views = (List) _documentMap.get(v.getDocument());

    if (views != null) {
      views.remove(v);
    }
  }
  /**
   * Add a view to the list of views currently known by this application. Fire a view list event to
   * registered listeners. Throw an exception if the view is already in the list of views.
   */
  public void addView(View v) {
    if (_views.contains(v)) {
      throw new IllegalArgumentException("View " + v + " is already known by application " + this);
    }

    List l = (List) _documentMap.get(v.getDocument());

    if (l == null) {
      l = new LinkedList();
      _documentMap.put(v.getDocument(), l);
    }

    l.add(v);
    _views.addElement(v);
  }
  /**
   * Remove a document from the list of documents currently known by this application, and remove
   * all of the views associated with this document. Fire a list data event to registered document
   * listeners. Throw an exception if the document is not known.
   */
  public void removeDocument(Document d) {
    if (!_documents.contains(d)) {
      throw new IllegalArgumentException("Document " + d + " is not known by application " + this);
    }

    _documents.removeElement(d);

    List views = (List) _documentMap.get(d);

    for (Iterator i = views.iterator(); i.hasNext(); ) {
      View v = (View) i.next();
      i.remove();
      removeView(v);
    }

    _documentMap.remove(d);
  }
 /** Get a list of all view objects known by this application. */
 public List viewList() {
   return _views.getList();
 }
 /** Remove a view list listener from this application. */
 public void removeViewListener(ListDataListener listener) {
   _views.removeListDataListener(listener);
 }
 /** Remove a document list listener from this application. */
 public void removeDocumentListener(ListDataListener listener) {
   _documents.removeListDataListener(listener);
 }
 /**
  * Get the current view. Generally, this will be the one that is displayed in the window that is
  * top-most in the display.
  */
 public View getCurrentView() {
   return (View) _views.getSelectedItem();
 }
Пример #10
0
 /** Get list of all document objects known by this application. */
 public List documentList() {
   return _documents.getList();
 }
Пример #11
0
 /**
  * Add a view listener to this application. The view listener is in fact a ListDataListener, which
  * will be notified with intervalAdded() and intervalRemoved() events when views are added or
  * removed, and with a contentsChanged() event when the current view is changed.
  */
 public void addViewListener(ListDataListener listener) {
   _views.addListDataListener(listener);
 }
Пример #12
0
 /**
  * Add a document listener to this application. The document listener is in fact a
  * ListDataListener, which will be notified with intervalAdded() and intervalRemoved() events when
  * documents are added or removed, and with a contentsChanged() event when the current document is
  * changed.
  */
 public void addDocumentListener(ListDataListener listener) {
   _documents.addListDataListener(listener);
 }