コード例 #1
0
ファイル: ProjectList.java プロジェクト: LukasK/basex
 /** Open all selected files externally. */
 private void openExternal() {
   for (final IOFile file : selectedValues()) {
     try {
       file.open();
     } catch (final IOException ex) {
       BaseXDialog.error(project.gui, Util.info(FILE_NOT_OPENED_X, file));
     }
   }
 }
コード例 #2
0
ファイル: EditorView.java プロジェクト: rostam/basex
 /**
  * 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());
 }
コード例 #3
0
ファイル: EditorView.java プロジェクト: rostam/basex
 /**
  * Saves the specified editor contents.
  *
  * @param file file to write
  * @return {@code false} if confirmation was canceled
  */
 private boolean save(final IOFile file) {
   try {
     final EditorArea edit = getEditor();
     file.write(edit.getText());
     edit.file(file);
     return true;
   } catch (final IOException ex) {
     BaseXDialog.error(gui, FILE_NOT_SAVED);
     return false;
   }
 }
コード例 #4
0
ファイル: DialogExport.java プロジェクト: fpapai/basex
  @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);
  }
コード例 #5
0
ファイル: EditorView.java プロジェクト: rostam/basex
  /**
   * Opens the specified query file.
   *
   * @param file query file
   * @return opened editor
   */
  public EditorArea open(final IOFile file) {
    if (!visible()) GUICommands.C_SHOWEDITOR.execute(gui);

    EditorArea edit = find(file, true);
    try {
      if (edit != null) {
        // display open file
        tabs.setSelectedComponent(edit);
        edit.reopen(true);
      } else {
        // get current editor
        edit = getEditor();
        // create new tab if current text is stored on disk or has been modified
        if (edit.opened() || edit.modified) edit = addTab();
        edit.initText(file.read());
        edit.file(file);
      }
    } catch (final IOException ex) {
      BaseXDialog.error(gui, FILE_NOT_OPENED);
    }
    return edit;
  }
コード例 #6
0
ファイル: DialogExport.java プロジェクト: fpapai/basex
 /** Opens a file dialog to choose an XML document or directory. */
 private void choose() {
   final IOFile io = new BaseXFileChooser(CHOOSE_DIR, path.getText(), gui).select(Mode.DOPEN);
   if (io != null) path.setText(io.path());
 }
コード例 #7
0
ファイル: ProjectList.java プロジェクト: LukasK/basex
 /** Tests all files. */
 private void test() {
   for (final IOFile file : selectedValues()) {
     project.gui.execute(new Test(file.path()));
   }
 }