コード例 #1
0
ファイル: EditorView.java プロジェクト: rostam/basex
  /**
   * Closes an editor.
   *
   * @param edit editor to be closed. {@code null} closes the currently opened editor.
   * @return {@code true} if editor was closed
   */
  public boolean close(final EditorArea edit) {
    final EditorArea ea = edit != null ? edit : getEditor();
    if (!confirm(ea)) return false;

    tabs.remove(ea);
    final int t = tabs.getTabCount();
    final int i = tabs.getSelectedIndex();
    if (t == 1) {
      // reopen single tab
      addTab();
    } else if (i + 1 == t) {
      // if necessary, activate last editor tab
      tabs.setSelectedIndex(i - 1);
    }
    return true;
  }
コード例 #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());
 }