use of org.olat.core.util.vfs.version.OrphanVersion in project OpenOLAT by OpenOLAT.
the class VersionMaintenanceForm method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == showOrphanLink) {
List<OrphanVersion> orphans = versionsManager.orphans();
orphansController = new OrphanVersionsController(ureq, getWindowControl(), orphans);
listenTo(orphansController);
cmc = new CloseableModalController(getWindowControl(), "close", orphansController.getInitialComponent());
cmc.activate();
} else if (source == cleanUpLink) {
String text = translate("confirm.delete.orphans");
confirmDeleteOrphansBox = activateYesNoDialog(ureq, null, text, confirmDeleteOrphansBox);
} else if (source == pruneLink) {
String text = translate("confirm.prune.history");
confirmPrunehistoryBox = activateYesNoDialog(ureq, null, text, confirmPrunehistoryBox);
} else if (source == orphanSize) {
orphanSizeEl.setValue(translate("version.orphan.size.calculating"));
taskExecutorManager.execute(new Runnable() {
public void run() {
calculateOrphanSize();
}
});
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.util.vfs.version.OrphanVersion in project OpenOLAT by OpenOLAT.
the class VersionMaintenanceForm method calculateOrphanSize.
public final void calculateOrphanSize() {
long size = 0l;
List<OrphanVersion> orphans = versionsManager.orphans();
for (OrphanVersion orphan : orphans) {
List<VFSRevision> revisions = orphan.getVersions().getRevisions();
if (revisions != null) {
for (VFSRevision revision : revisions) {
size += revision.getSize();
}
}
}
String unit = "KB";
double humanSize = size / 1024.0d;
if (humanSize > 1024) {
humanSize /= 1024;
unit = "MB";
}
DecimalFormat sizeFormat = new DecimalFormat("#0.#", new DecimalFormatSymbols(Locale.ENGLISH));
String readableSize = sizeFormat.format(humanSize) + " " + unit;
if (orphanSizeEl != null && !isDisposed()) {
orphanSizeEl.setValue(readableSize);
}
}
use of org.olat.core.util.vfs.version.OrphanVersion in project openolat by klemens.
the class VersionMaintenanceForm method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == showOrphanLink) {
List<OrphanVersion> orphans = versionsManager.orphans();
orphansController = new OrphanVersionsController(ureq, getWindowControl(), orphans);
listenTo(orphansController);
cmc = new CloseableModalController(getWindowControl(), "close", orphansController.getInitialComponent());
cmc.activate();
} else if (source == cleanUpLink) {
String text = translate("confirm.delete.orphans");
confirmDeleteOrphansBox = activateYesNoDialog(ureq, null, text, confirmDeleteOrphansBox);
} else if (source == pruneLink) {
String text = translate("confirm.prune.history");
confirmPrunehistoryBox = activateYesNoDialog(ureq, null, text, confirmPrunehistoryBox);
} else if (source == orphanSize) {
orphanSizeEl.setValue(translate("version.orphan.size.calculating"));
taskExecutorManager.execute(new Runnable() {
public void run() {
calculateOrphanSize();
}
});
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.util.vfs.version.OrphanVersion in project openolat by klemens.
the class OrphanVersionsController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(rowid);
if (actionid.equals(CMD_DELETE)) {
VersionsManager.getInstance().delete(orphan);
orphans.remove(orphan);
tableCtr.modelChanged();
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
// Multiselect events
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
BitSet selectedOrphans = tmse.getSelection();
String actionid = tmse.getAction();
if (CMD_DELETE.equals(actionid)) {
List<OrphanVersion> toRemove = new ArrayList<OrphanVersion>();
for (int i = selectedOrphans.nextSetBit(0); i >= 0; i = selectedOrphans.nextSetBit(i + 1)) {
int rowCount = tableCtr.getTableDataModel().getRowCount();
if (i >= 0 && i < rowCount) {
OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(i);
VersionsManager.getInstance().delete(orphan);
toRemove.add(orphan);
}
}
for (OrphanVersion orphan : toRemove) {
orphans.remove(orphan);
}
tableCtr.setTableDataModel(new OrphanTableModel(orphans));
tableCtr.modelChanged();
}
}
}
}
use of org.olat.core.util.vfs.version.OrphanVersion in project OpenOLAT by OpenOLAT.
the class OrphanVersionsController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(rowid);
if (actionid.equals(CMD_DELETE)) {
VersionsManager.getInstance().delete(orphan);
orphans.remove(orphan);
tableCtr.modelChanged();
}
} else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) {
// Multiselect events
TableMultiSelectEvent tmse = (TableMultiSelectEvent) event;
BitSet selectedOrphans = tmse.getSelection();
String actionid = tmse.getAction();
if (CMD_DELETE.equals(actionid)) {
List<OrphanVersion> toRemove = new ArrayList<OrphanVersion>();
for (int i = selectedOrphans.nextSetBit(0); i >= 0; i = selectedOrphans.nextSetBit(i + 1)) {
int rowCount = tableCtr.getTableDataModel().getRowCount();
if (i >= 0 && i < rowCount) {
OrphanVersion orphan = (OrphanVersion) tableCtr.getTableDataModel().getObject(i);
VersionsManager.getInstance().delete(orphan);
toRemove.add(orphan);
}
}
for (OrphanVersion orphan : toRemove) {
orphans.remove(orphan);
}
tableCtr.setTableDataModel(new OrphanTableModel(orphans));
tableCtr.modelChanged();
}
}
}
}
Aggregations