예제 #1
0
  /** Notifies all views of a data reference change. */
  public void init() {
    final Data data = initHistory(gui.context);
    if (data != null) {
      // if a large database is opened, the user is asked if complex
      /// visualizations should be closed first
      final long size = data.meta.dbsize();
      boolean open = false;
      for (final View v : view) open |= v.visible() && v.db();
      if (open
          && size > LARGEDB
          && BaseXDialog.confirm(gui, Util.info(H_LARGE_DB, Performance.format(size)))) {
        for (final View v : view) if (v.visible() && v.db()) v.visible(false);
      }
    } else {
      // database closed: close open dialogs
      for (final Window w : gui.getOwnedWindows()) {
        if (w.isVisible() && w instanceof BaseXDialog) ((BaseXDialog) w).cancel();
      }
    }

    gui.context.focused = -1;
    for (final View v : view) v.refreshInit();
    gui.layoutViews();
    gui.setTitle(data != null ? data.meta.name : null);
  }
예제 #2
0
 /** Notifies all views of updates in the data structure. */
 public void update() {
   final Data data = initHistory(gui.context);
   if (data == null) return;
   gui.context.marked = new Nodes(data);
   for (final View v : view) if (v.visible()) v.refreshUpdate();
   gui.refreshControls();
 }
예제 #3
0
  /**
   * Notifies all views of a context change.
   *
   * @param nodes new context set (may be {@code null} if root nodes are addressed)
   * @param quick quick switch
   * @param vw the calling view
   */
  public void context(final Nodes nodes, final boolean quick, final View vw) {
    final Context ctx = gui.context;

    // add new entry if current node set has not been cached yet
    final Nodes newn = nodes.checkRoot();
    final Nodes empty = new Nodes(new int[0], ctx.data(), ctx.marked.ftpos);
    final Nodes curr = quick ? ctx.current() : null;
    final Nodes cmp = quick ? curr : ctx.marked;
    if (cont[hist] == null ? cmp != null : cmp == null || !cont[hist].sameAs(cmp)) {
      checkHist();
      if (quick) {
        // store history entry
        queries[hist] = "";
        marked[hist] = new Nodes(ctx.data());
        // add current entry
        cont[++hist] = curr;
      } else {
        // store history entry
        final String in = gui.input.getText();
        queries[hist] = in;
        marked[hist] = ctx.marked;
        // add current entry
        cont[++hist] = newn;
        queries[hist] = in;
        marked[hist] = empty;
      }
      histsize = hist;
    }
    ctx.set(newn, empty);

    for (final View v : view) if (v != vw && v.visible()) v.refreshContext(true, quick);
    gui.refreshControls();
  }
예제 #4
0
 /**
  * Notifies all views of a selection change.
  *
  * @param mark marked nodes
  * @param vw the calling view
  */
 public void mark(final Nodes mark, final View vw) {
   final Context ctx = gui.context;
   ctx.marked = mark;
   for (final View v : view) if (v != vw && v.visible()) v.refreshMark();
   gui.filter.setEnabled(mark.size() != 0);
   gui.refreshControls();
 }
예제 #5
0
 /**
  * Notifies all views of a focus change.
  *
  * @param pre focused pre value
  * @param vw the calling view
  */
 public void focus(final int pre, final View vw) {
   if (gui.context.focused == pre) return;
   gui.context.focused = pre;
   for (final View v : view) if (v != vw && v.visible()) v.refreshFocus();
   if (pre != -1) {
     gui.status.setText(Token.string(ViewData.path(gui.context.data(), pre)));
   }
 }
예제 #6
0
  /**
   * Moves around in the internal history and notifies all views of a context change.
   *
   * @param forward move forward or backward
   */
  public void hist(final boolean forward) {
    final Context ctx = gui.context;
    final String query;
    if (forward) {
      if (hist == histsize) return;
      query = queries[++hist];
    } else {
      if (hist == 0) return;
      marked[hist] = ctx.marked;
      query = queries[--hist];
    }
    ctx.set(cont[hist], marked[hist]);

    gui.input.setText(query);
    for (final View v : view) if (v.visible()) v.refreshContext(forward, false);
    gui.refreshControls();
  }