/** * Returns the current serialization options. * * @param mth consider specified serialization method (may be {@code null}) * @return options * @throws BaseXException database exception */ private SerializerOptions options(final SerialMethod mth) throws BaseXException { final SerializerOptions sopts = new SerializerOptions(); sopts.assign(params.getText()); sopts.set(SerializerOptions.METHOD, SerialMethod.valueOf(method.getSelectedItem())); sopts.set(SerializerOptions.ENCODING, encoding.getSelectedItem()); if (mth == SerialMethod.JSON) { final JsonSerialOptions jopts = new JsonSerialOptions(); jopts.assign(mparams.getText()); sopts.set(SerializerOptions.JSON, jopts); } else if (mth == SerialMethod.CSV) { final CsvOptions copts = new CsvOptions(); copts.assign(mparams.getText()); sopts.set(SerializerOptions.CSV, copts); } return sopts; }
@Override public void action(final Object cmp) { creds.setText(TRANSLATION + COLS + creds(lang.getSelectedItem().toString())); if (cmp == names) { gui.gprop.set(GUIProp.SHOWNAME, names.isSelected()); gui.notify.layout(); } final int mh = hitsAsProperty(); label.setText(mh == -1 ? ALL : Integer.toString(mh)); }
@Override public void close() { try { gui.set(MainOptions.EXPORTER, options(SerialMethod.valueOf(method.getSelectedItem()))); } catch (final BaseXException ex) { throw Util.notExpected(ex); } if (!ok) return; super.close(); path.store(); }
@Override public void close() { final MainProp mprop = gui.context.mprop; mprop.set(MainProp.LANG, lang.getSelectedItem().toString()); // new database path: close existing database final String dbpath = path.getText(); if (!mprop.get(MainProp.DBPATH).equals(dbpath)) gui.execute(new Close()); mprop.set(MainProp.DBPATH, dbpath); mprop.write(); final int mh = hitsAsProperty(); gui.context.prop.set(Prop.MAXHITS, mh); final GUIProp gprop = gui.gprop; gprop.set(GUIProp.MOUSEFOCUS, focus.isSelected()); gprop.set(GUIProp.SIMPLEFD, simpfd.isSelected()); gprop.set(GUIProp.JAVALOOK, javalook.isSelected()); gprop.set(GUIProp.MAXHITS, mh); gprop.write(); dispose(); }
@Override public void action(final Object comp) { final String pth = path(); final IOFile io = new IOFile(pth); String inf = io.isDir() && io.children().length > 0 ? DIR_NOT_EMPTY : null; ok = !pth.isEmpty(); final SerialMethod mth = SerialMethod.valueOf(method.getSelectedItem()); final OptionsOption<? extends Options> opts = mth == SerialMethod.JSON ? SerializerOptions.JSON : mth == SerialMethod.CSV ? SerializerOptions.CSV : null; final boolean showmparams = opts != null; mparams.setEnabled(showmparams); if (ok) { gui.gopts.set(GUIOptions.INPUTPATH, pth); try { if (comp == method) { if (showmparams) { final Options mopts = options(null).get(opts); mparams.setToolTipText(tooltip(mopts)); mparams.setText(mopts.toString()); } else { mparams.setToolTipText(null); mparams.setText(""); } } Serializer.get(new ArrayOutput(), options(mth)); } catch (final IOException ex) { ok = false; inf = ex.getMessage(); } } info.setText(inf, ok ? Msg.WARN : Msg.ERROR); enableOK(buttons, B_OK, ok); }