1 /*******************************************************************************
2 * Copyright (c) 2015 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Marc-Andre Laperle - Initial API and implementation.
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.ui
.project
.wizards
.importtrace
;
15 import java
.io
.IOException
;
16 import java
.io
.InputStream
;
17 import java
.util
.ArrayList
;
18 import java
.util
.List
;
20 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
21 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.DataTransferMessages
;
22 import org
.eclipse
.ui
.internal
.wizards
.datatransfer
.ILeveledImportStructureProvider
;
25 * Leveled Structure provider for Gzip file
27 @SuppressWarnings("restriction")
28 public class GzipLeveledStructureProvider
implements ILeveledImportStructureProvider
{
30 private final GzipFile fFile
;
31 private final GzipEntry root
= new GzipEntry();
32 private final GzipEntry fEntry
;
35 * Creates a <code>GzipFileStructureProvider</code>, which will operate on
36 * the passed Gzip file.
41 public GzipLeveledStructureProvider(GzipFile sourceFile
) {
45 fEntry
= sourceFile
.entries().nextElement();
49 public List
getChildren(Object element
) {
50 ArrayList
<Object
> children
= new ArrayList
<>();
51 if (element
== root
) {
58 public InputStream
getContents(Object element
) {
59 return fFile
.getInputStream((GzipEntry
) element
);
63 public String
getFullPath(Object element
) {
64 return ((GzipEntry
) element
).getName();
68 public String
getLabel(Object element
) {
69 if (element
!= root
&& element
!= fEntry
) {
70 throw new IllegalArgumentException();
72 return ((GzipEntry
) element
).getName();
76 * Returns the entry that this importer uses as the root sentinel.
78 * @return GzipEntry entry
81 public GzipEntry
getRoot() {
86 public boolean closeArchive() {
89 } catch (IOException e
) {
90 Activator
.getDefault().logError(DataTransferMessages
.ZipImport_couldNotClose
91 + fFile
.getName(), e
);
98 public boolean isFolder(Object element
) {
99 return ((GzipEntry
) element
).getFileType() == GzipEntry
.DIRECTORY
;
103 public void setStrip(int level
) {
108 public int getStrip() {