Search in sources :

Example 1 with TracePackageLabelProvider

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageLabelProvider in project tracecompass by tracecompass.

the class RemoteFetchLogWizardRemotePage method createElementViewer.

@Override
protected void createElementViewer(Composite compositeParent) {
    super.createElementViewer(compositeParent);
    CheckboxTreeViewer elementViewer = getElementViewer();
    elementViewer.setLabelProvider(new TracePackageLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof TracePackageTraceElement) {
                for (TracePackageElement files : ((TracePackageTraceElement) element).getChildren()) {
                    if (files instanceof TracePackageFilesElement) {
                        return ((TracePackageFilesElement) files).getFileName();
                    }
                }
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof TracePackageTraceElement) {
                for (TracePackageElement files : ((TracePackageTraceElement) element).getChildren()) {
                    return files.getImage();
                }
            }
            return super.getImage(element);
        }
    });
    elementViewer.setComparator(new ViewerComparator() {

        @Override
        public int category(Object element) {
            if (element instanceof TracePackageTraceElement) {
                return 1;
            }
            return 0;
        }
    });
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) TracePackageFilesElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageTraceElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement) TracePackageLabelProvider(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageLabelProvider) Image(org.eclipse.swt.graphics.Image)

Example 2 with TracePackageLabelProvider

use of org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageLabelProvider in project tracecompass by tracecompass.

the class ExportTracePackageWizardPage method createElementViewer.

@Override
protected void createElementViewer(Composite parent) {
    super.createElementViewer(parent);
    CheckboxTreeViewer elementViewer = getElementViewer();
    elementViewer.getTree().setHeaderVisible(true);
    // Content column
    TreeViewerColumn column = new TreeViewerColumn(elementViewer, SWT.NONE);
    column.getColumn().setWidth(CONTENT_COL_WIDTH);
    column.getColumn().setText(Messages.ExportTracePackageWizardPage_ContentColumnName);
    column.setLabelProvider(new TracePackageLabelProvider());
    // Size column
    column = new TreeViewerColumn(elementViewer, SWT.NONE);
    column.getColumn().setWidth(SIZE_COL_WIDTH);
    column.getColumn().setText(Messages.ExportTracePackageWizardPage_SizeColumnName);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            TracePackageElement tracePackageElement = (TracePackageElement) element;
            long size = tracePackageElement.getSize(false);
            if (size == 0) {
                return null;
            }
            int level = 0;
            TracePackageElement curElement = tracePackageElement.getParent();
            while (curElement != null) {
                curElement = curElement.getParent();
                ++level;
            }
            return indent(getHumanReadable(size), level);
        }

        private String indent(String humanReadable, int level) {
            StringBuilder s = new StringBuilder(humanReadable);
            for (int i = 0; i < level; ++i) {
                // $NON-NLS-1$
                final String indentStr = "  ";
                s.insert(0, indentStr);
            }
            return s.toString();
        }
    });
    elementViewer.setInput(createElementViewerInput());
    elementViewer.expandToLevel(2);
    setAllChecked(elementViewer, false, true);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TracePackageElement(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement) TracePackageLabelProvider(org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageLabelProvider) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn)

Aggregations

CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)2 TracePackageElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement)2 TracePackageLabelProvider (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageLabelProvider)2 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 Image (org.eclipse.swt.graphics.Image)1 TracePackageFilesElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement)1 TracePackageTraceElement (org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement)1