示例#1
0
    @Override
    public void execute(final GUI gui) {
      final boolean rt = gui.gprop.invert(GUIProp.FILTERRT);
      gui.stop();
      // refresh buttons in input bar
      gui.refreshControls();
      // refresh editor buttons
      gui.editor.refreshMark();

      final Context ctx = gui.context;
      final boolean root = ctx.root();
      final Data data = ctx.data();
      if (!rt) {
        if (!root) {
          gui.notify.context(new Nodes(0, data), true, null);
          gui.notify.mark(ctx.current(), null);
        }
      } else {
        if (root) {
          gui.notify.mark(new Nodes(data), null);
        } else {
          final Nodes mark = ctx.marked;
          ctx.marked = new Nodes(data);
          gui.notify.context(mark, true, null);
        }
      }
    }
示例#2
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);
  }
示例#3
0
 @Override
 public void execute(final GUI gui) {
   gui.gprop.invert(GUIProp.EXECRT);
   gui.stop();
   // refresh buttons in input bar
   gui.refreshControls();
   // refresh editor buttons
   gui.editor.refreshMark();
 }
示例#4
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();
  }
示例#5
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();
 }
示例#6
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();
 }
示例#7
0
 @Override
 public void execute(final GUI gui) {
   final StringBuilder sb = new StringBuilder();
   final Nodes n = gui.context.copied;
   for (int i = 0; i < n.size(); ++i) {
     if (i > 0) sb.append(',');
     sb.append(openPre(n, i));
   }
   gui.context.copied = null;
   gui.execute(new XQuery("insert nodes (" + sb + ") into " + openPre(gui.context.marked, 0)));
 }
示例#8
0
    @Override
    public void execute(final GUI gui) {
      final Nodes n = gui.context.marked;
      final DialogEdit edit = new DialogEdit(gui, n.pres[0]);
      if (!edit.ok()) return;

      String rename = null;
      String replace = null;
      final int k = edit.kind;
      if (k == Data.ELEM || k == Data.PI || k == Data.ATTR) {
        rename = edit.result.get(0);
        if (k != Data.ELEM) replace = edit.result.get(1);
      } else {
        replace = edit.result.get(0);
      }

      if (rename != null)
        gui.execute(new XQuery("rename node " + openPre(n, 0) + " as " + quote(rename)));
      if (replace != null)
        gui.execute(
            new XQuery("replace value of node " + openPre(n, 0) + " with " + quote(replace)));
    }
示例#9
0
 @Override
 public void execute(final GUI gui) {
   if (!BaseXDialog.confirm(gui, DELETE_NODES)) return;
   final StringBuilder sb = new StringBuilder();
   final Nodes n = gui.context.marked;
   for (int i = 0; i < n.size(); ++i) {
     if (i > 0) sb.append(',');
     sb.append(openPre(n, i));
   }
   gui.context.marked = new Nodes(n.data);
   gui.context.copied = null;
   gui.context.focused = -1;
   gui.execute(new XQuery("delete nodes (" + sb + ')'));
 }
示例#10
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();
  }
示例#11
0
 @Override
 public void execute(final GUI gui) {
   // skip operation for root context
   final Context ctx = gui.context;
   if (ctx.root()) return;
   // check if all nodes are document nodes
   boolean doc = true;
   final Data data = ctx.data();
   for (final int pre : ctx.current().pres) doc &= data.kind(pre) == Data.DOC;
   if (doc) {
     // if yes, jump to database root
     ctx.update();
     gui.notify.context(ctx.current(), false, null);
   } else {
     // otherwise, jump to parent nodes
     gui.execute(new Cs(".."));
   }
 }
示例#12
0
    @Override
    public void execute(final GUI gui) {
      final Nodes n = gui.context.marked;
      final DialogInsert insert = new DialogInsert(gui);
      if (!insert.ok()) return;

      final StringList sl = insert.result;
      final NodeType type = ANode.type(insert.kind);
      String item = Token.string(type.string()) + " { " + quote(sl.get(0)) + " }";

      if (type == NodeType.ATT || type == NodeType.PI) {
        item += " { " + quote(sl.get(1)) + " }";
      } else if (type == NodeType.ELM) {
        item += " { () }";
      }

      gui.context.copied = null;
      gui.execute(new XQuery("insert node " + item + " into " + openPre(n, 0)));
    }
示例#13
0
 @Override
 public void execute(final GUI gui) {
   gui.gprop.invert(GUIProp.SHOWEXPLORE);
   gui.layoutViews();
 }
示例#14
0
 @Override
 public void execute(final GUI gui) {
   gui.execute(new XQuery("/"));
 }
示例#15
0
 @Override
 public void execute(final GUI gui) {
   gui.dispose();
 }
示例#16
0
 @Override
 public void execute(final GUI gui) {
   gui.updateControl(gui.status, gui.gprop.invert(GUIProp.SHOWSTATUS), BorderLayout.SOUTH);
 }
示例#17
0
 @Override
 public void execute(final GUI gui) {
   gui.updateControl(gui.nav, gui.gprop.invert(GUIProp.SHOWINPUT), BorderLayout.SOUTH);
 }
示例#18
0
 @Override
 public void execute(final GUI gui) {
   gui.gprop.invert(GUIProp.SHOWBUTTONS);
   gui.updateControl(gui.buttons, gui.gprop.is(GUIProp.SHOWBUTTONS), BorderLayout.CENTER);
 }
示例#19
0
 @Override
 public void execute(final GUI gui) {
   gui.fullscreen();
 }
示例#20
0
 @Override
 public void execute(final GUI gui) {
   gui.execute(new Close());
 }