Esempio n. 1
0
 /**
  * Returns a list of all databases.
  *
  * @param ctx database context
  * @return list of databases
  */
 public static StringList list(final Context ctx) {
   final StringList db = new StringList();
   for (final IOFile f : ctx.mprop.dbpath().children()) {
     final String name = f.name();
     if (f.isDir() && !name.startsWith(".")) db.add(name);
   }
   return db.sort(false);
 }
Esempio n. 2
0
 /**
  * Adds the names of the database that has been addressed by the argument index. No databases will
  * be added if the argument uses glob syntax.
  *
  * @param db databases
  * @param a argument index
  * @return {@code false} if database cannot be determined due to glob syntax
  */
 protected final boolean databases(final StringList db, final int a) {
   // return true if the addressed database argument does not exists
   if (args.length <= a || args[a] == null) return true;
   final boolean noglob = !args[a].matches(".*[\\?\\*,].*");
   if (noglob) db.add(args[a]);
   return noglob;
 }
Esempio n. 3
0
 /**
  * Refreshes the list of recent query files and updates the query path.
  *
  * @param file new file
  */
 void refreshHistory(final IOFile file) {
   final StringList sl = new StringList();
   String path = null;
   if (file != null) {
     path = file.path();
     gui.gprop.set(GUIProp.WORKPATH, file.dirPath());
     sl.add(path);
     tabs.setToolTipTextAt(tabs.getSelectedIndex(), path);
   }
   final String[] qu = gui.gprop.strings(GUIProp.EDITOR);
   for (int q = 0; q < qu.length && q < 19; q++) {
     final String f = qu[q];
     if (!f.equalsIgnoreCase(path) && IO.get(f).exists()) sl.add(f);
   }
   // store sorted history
   gui.gprop.set(GUIProp.EDITOR, sl.toArray());
   hist.setEnabled(!sl.isEmpty());
 }
Esempio n. 4
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)));
    }