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;
}
});
}
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);
}
Aggregations