Esempio n. 1
0
 @Override
 public void refreshMark() {
   final EditorArea edit = getEditor();
   go.setEnabled(edit.script || edit.xquery && !gui.gprop.is(GUIProp.EXECRT));
   final Nodes mrk = gui.context.marked;
   filter.setEnabled(!gui.gprop.is(GUIProp.FILTERRT) && mrk != null && mrk.size() != 0);
 }
Esempio n. 2
0
  /**
   * Checks if data can be updated.
   *
   * @param n node instance
   * @param no disallowed node types
   * @return result of check
   */
  static boolean updatable(final Nodes n, final int... no) {
    if (n == null || (no.length == 0 ? n.size() < 1 : n.size() != 1)) return false;

    final int k = n.data.kind(n.pres[0]);
    for (final int i : no) if (k == i) return false;
    return true;
  }
Esempio n. 3
0
 @Override
 public void execute(final GUI gui) {
   final Context ctx = gui.context;
   Nodes marked = ctx.marked;
   if (marked.size() == 0) {
     final int pre = gui.context.focused;
     if (pre == -1) return;
     marked = new Nodes(pre, ctx.data());
   }
   gui.notify.context(marked, false, null);
 }
Esempio n. 4
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)));
 }
Esempio n. 5
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 + ')'));
 }
Esempio n. 6
0
  /**
   * Notifies all views of a selection change. The mode flag determines what happens:
   *
   * <ul>
   *   <li>0: set currently focused node as marked node
   *   <li>1: add currently focused node
   *   <li>2: toggle currently focused node
   * </ul>
   *
   * @param mode mark mode
   * @param vw the calling view
   */
  public void mark(final int mode, final View vw) {
    final int f = gui.context.focused;
    if (f == -1) return;

    final Context ctx = gui.context;
    Nodes nodes = ctx.marked;
    if (mode == 0) {
      nodes = new Nodes(f, ctx.data());
    } else if (mode == 1) {
      nodes.union(new int[] {f});
    } else {
      nodes.toggle(f);
    }
    mark(nodes, vw);
  }
Esempio n. 7
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();
  }
Esempio n. 8
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();
 }
Esempio n. 9
0
 @Override
 public void refresh(final GUI gui, final AbstractButton b) {
   final Nodes marked = gui.context.marked;
   b.setEnabled(marked != null && marked.size() != 0);
 }
Esempio n. 10
0
 @Override
 public void refresh(final GUI gui, final AbstractButton b) {
   // disallow copy of empty node set or root node
   final Nodes marked = gui.context.marked;
   b.setEnabled(marked != null && marked.size() != 0);
 }