Пример #1
0
  /** Saves the displayed text. */
  private void save() {
    final BaseXFileChooser fc =
        new BaseXFileChooser(SAVE_AS, gui.gopts.get(GUIOptions.WORKPATH), gui).suffix(IO.XMLSUFFIX);

    final IO file = fc.select(Mode.FSAVE);
    if (file == null) return;
    gui.gopts.set(GUIOptions.WORKPATH, file.path());

    gui.cursor(CURSORWAIT, true);
    final MainOptions opts = gui.context.options;
    final int mh = opts.get(MainOptions.MAXHITS);
    opts.set(MainOptions.MAXHITS, -1);
    opts.set(MainOptions.CACHEQUERY, false);

    try (final PrintOutput out = new PrintOutput(file.toString())) {
      if (cmd != null) {
        cmd.execute(gui.context, out);
      } else if (ns != null) {
        ns.serialize(Serializer.get(out));
      } else {
        final byte[] txt = text.getText();
        for (final byte t : txt) if (t < 0 || t > ' ' || ws(t)) out.write(t);
      }
    } catch (final IOException ex) {
      BaseXDialog.error(gui, Util.info(FILE_NOT_SAVED_X, file));
    } finally {
      opts.set(MainOptions.MAXHITS, mh);
      opts.set(MainOptions.CACHEQUERY, true);
      gui.cursor(CURSORARROW, true);
    }
  }
Пример #2
0
 /**
  * Returns next color mark.
  *
  * @param rects rectangle array
  * @param ri current position
  * @return next color mark
  */
 final Color color(final MapRects rects, final int ri) {
   // find marked node
   final DBNodes marked = view.gui.context.marked;
   if (marked != null) {
     final int p = -marked.find(rects.get(ri).pre) - 1;
     if (p >= 0) {
       // mark ancestor of invisible node;
       final int i = rects.find(rects.get(ri));
       return p < marked.size() && i + 1 < rects.size && marked.sorted(p) < rects.sorted[i + 1].pre
           ? GUIConstants.colormark2
           : null;
     }
   }
   // no mark found
   return GUIConstants.colormark1;
 }
Пример #3
0
 /**
  * Serializes the specified nodes.
  *
  * @param n nodes to display
  */
 private void setText(final DBNodes n) {
   if (visible()) {
     try {
       final ArrayOutput ao = new ArrayOutput();
       ao.setLimit(gui.gopts.get(GUIOptions.MAXTEXT));
       if (n != null) n.serialize(Serializer.get(ao));
       setText(ao);
       cmd = null;
       ns = ao.finished() ? n : null;
     } catch (final IOException ex) {
       Util.debug(ex);
     }
   } else {
     home.setEnabled(gui.context.data() != null);
   }
 }