Warning: session_start(): open(/var/lib/php/sessions/sess_l8i0qvdnb3fnketu6erqa6se8l, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
srecord noeq G22DatabasesPanel(G22Utils g22utils) {
delegate GazelleDB to G22Utils.
JObjectTable table;
FileWatchService dirWatcher;
ReliableSingleThread rstUpdate = new(r _updateTable);
cachedVisualize {
table = swing(-> new JObjectTable);
table.defaultAction(runnableToIVF1(rThread openDB));
table.itemToMap = db -> litorderedmap(
"Name" := db.name,
"Directory" := f2s(db.dir),
"Loaded" := db.loaded() ? "Yes" : "No"
);
var tbl = table.visualize();
bindToComponent(tbl, -> {
dirWatcher = new FileWatchService;
dirWatcher.addNonRecursiveListener(g22utils.databasesMotherDir(), dir ->
rstUpdate!);
g22utils.masterStuff.onLoadedDBsChange(rstUpdate);
rstUpdate!;
}, -> {
g22utils.masterStuff.removeLoadedDBsChangeListener(rstUpdate);
dispose dirWatcher;
});
ret withTopAndBottomMargin(jCenteredRaisedSection("Gazelle Projects",
northAndCenterWithMargins(
jline(
toolTip("Create a new Gazelle project", jbutton("New Gazelle project...", rThread newDatabase))
),
centerAndEastWithMargin(
tbl,
vstackWithSpacing_fixed(
tableDependentButton(table.table, "Open project", rThread openDB),
tableDependentButton(table.table, "Close project", rThread closeDB),
tableDependentButton(table.table, "Delete project (TODO)"),
tableDependentButton(table.table, "Browse files", rThread browse)
))));
}
void newDatabase {
temp g22utils.enter();
var tf = jtextfield();
var lblDir = jlabel(" ");
var lblStatus = jlabel(" ");
var button = jbutton("Create project", r {
temp g22utils.enter();
S name = trim(tf.getText());
File dir = newFile(g22utils.databasesMotherDir(), name);
createEmptyConceptsFileInDir(dir);
disposeFrame(tf);
});
disableButton(button);
onEnter(tf, button);
onChange(tf, r {
S name = trim(tf.getText());
bool ok;
S status = " ", path = " ";
if (isValidFileName(name)) {
File dir = newFile(g22utils.databasesMotherDir(), name);
path = f2s(dir);
if (dirExists(dir))
status = "A project with that name exists";
else
ok = true;
} else if (!empty(name))
status = "Project name must be a valid file name";
setEnabled(button, ok);
setText(lblStatus, status);
setText(lblDir, path);
});
showForm_makeFrame("New Gazelle Project",
vstackWithSpacing(
withLabel("Name for new project", tf),
lblDir,
lblStatus,
button);
}
void _updateTable { table.setData_force(g22utils.gazelleDBs()); }
void browse { desktopOpen(table.selected().dir); }
void openDB { g22utils.masterStuff().openDatabase(table.selected().dir); }
void closeDB { g22utils.masterStuff().closeDatabase(table.selected().dir); }
}