Warning: session_start(): open(/var/lib/php/sessions/sess_pob0roqgvfl8gql01p1id824kg, 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
sclass G22DatabasesPanel {
G22Utils g22utils;
Concepts concepts;
JObjectTable table;
*(G22Utils *g22utils, Concepts *concepts) {}
record GazelleDB(S name, File dir) {
simplyCached bool loaded() {
ret sameFile(dir, concepts.conceptsDir());
}
}
visualize {
table = swing(-> new JObjectTable);
table.itemToMap = db -> litorderedmap(
"Name" := db.name,
"Directory" := f2s(db.dir),
"Loaded" := db.loaded() ? "Yes" : "No"
);
updateTable();
var tbl = table.visualize();
ret withTopAndBottomMargin(jCenteredRaisedSection("Gazelle Databases",
northAndCenterWithMargins(
jline(
toolTip("Create a new Gazelle database", jbutton("New database...", rThread newDatabase))
),
centerAndEastWithMargin(
tbl,
vstackWithSpacing(
tableDependentButton(table.table, "Open"),
tableDependentButton(table.table, "Delete"),
)))));
}
void newDatabase {
temp g22utils.enter();
var tf = jtextfield();
var lblStatus = jlabel();
var button = jbutton("Create database", r {
temp g22utils.enter();
S name = tf.getText();
File dir = newFile(g22utils.databasesMotherDir(), name);
createEmptyConceptsFileInDir(dir);
updateTable();
});
disableButton(button);
onChange(tf, r {
S name = tf.getText();
bool ok;
S status = "";
if (isValidFileName(name)) {
if (fileExists(newFile(g22utils.databasesMotherDir(), name)))
status = "A database with that name exists";
else
ok = true;
} else //if (!empty(name))
status = "Database name must be a valid file name";
setEnabled(button, ok);
setText(lblStatus, status);
});
showForm_makeFrame("New Database",
vstackWithSpacing(
withLabel("Name for new database", tf),
lblStatus,
button);
}
void updateTable {
new L dbs;
dbs.add(new GazelleDB("Legacy DB", programDir()));
for (File dir : listDirsContainingFileNamed(g22utils.databasesMotherDir(),
"concepts.structure.gz"))
dbs.add(new GazelleDB(fileName(dir), dir));
table.setList(dbs);
}
}