Example usage for org.eclipse.jgit.internal.storage.file GC getStatistics

List of usage examples for org.eclipse.jgit.internal.storage.file GC getStatistics

Introduction

In this page you can find the example usage for org.eclipse.jgit.internal.storage.file GC getStatistics.

Prototype

public RepoStatistics getStatistics() throws IOException 

Source Link

Document

Returns information about objects and pack files for a FileRepository.

Usage

From source file:org.eclipse.egit.ui.internal.repository.RepositoryStatisticsPage.java

License:Open Source License

protected Control createContents(Composite parent) {
    Table table = new Table(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    String[] titles = { UIText.RepositoryStatistics_Description, UIText.RepositoryStatistics_LooseObjects,
            UIText.RepositoryStatistics_PackedObjects };
    for (int i = 0; i < titles.length; i++) {
        TableColumn column = new TableColumn(table, SWT.NONE);
        column.setText(titles[i]);//ww w. j  av a  2s.com
    }

    Repository repo = (Repository) getElement().getAdapter(Repository.class);
    if (repo == null)
        return table;
    if (repo instanceof FileRepository) {
        GC gc = new GC((FileRepository) repo);
        try {
            RepoStatistics stats = gc.getStatistics();

            table.setLinesVisible(true);
            table.setHeaderVisible(true);
            GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
            data.heightHint = 200;
            table.setLayoutData(data);

            TableItem item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_NrOfObjects);
            item.setText(1, bigIntFmt.format(stats.numberOfLooseObjects));
            item.setText(2, bigIntFmt.format(stats.numberOfPackedObjects));

            item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_NrOfPackfiles);
            item.setText(2, bigIntFmt.format(stats.numberOfPackFiles).toString());

            item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_NrOfRefs);
            item.setText(1, bigIntFmt.format(stats.numberOfLooseRefs).toString());
            item.setText(2, bigIntFmt.format(stats.numberOfPackedRefs).toString());

            item = new TableItem(table, SWT.NONE);
            item.setText(0, UIText.RepositoryStatistics_SpaceNeededOnFilesystem);
            item.setText(1, describeSize(stats.sizeOfLooseObjects));
            item.setText(2, describeSize(stats.sizeOfPackedObjects));

            for (int i = 0; i < titles.length; i++) {
                table.getColumn(i).pack();
            }
            parent.pack();
        } catch (IOException e) {
        }
    }
    return table;
}