示例#1
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;
  }
示例#2
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);
 }
示例#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);
 }
示例#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)));
 }
示例#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 + ')'));
 }
示例#6
0
 @Override
 public void refresh(final GUI gui, final AbstractButton b) {
   final Nodes marked = gui.context.marked;
   b.setEnabled(marked != null && marked.size() != 0);
 }
示例#7
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);
 }