Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1c501ed3107f19d43f215df0aafd088b40928f51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2013, 2014 Ericsson
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Marc-Andre Laperle - Initial API and implementation
 *******************************************************************************/

package org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg;

import org.eclipse.core.resources.IResource;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tracecompass.internal.tmf.ui.Activator;

/**
 * A trace package element representing a single supplementary file
 *
 * @author Marc-Andre Laperle
 */
public class TracePackageSupplFileElement extends TracePackageElement {

    private static final String SUPPL_FILE_ICON_PATH = "icons/obj16/thread_obj.gif"; //$NON-NLS-1$

    private final IResource fResource;
    private final String fSuppFileName;

    /**
     * Constructor used when exporting
     *
     * @param resource
     *            the resource representing this supplementary file in the
     *            workspace
     * @param parent
     *            the parent element
     */
    public TracePackageSupplFileElement(IResource resource, TracePackageElement parent) {
        super(parent);
        fResource = resource;
        fSuppFileName = null;
    }

    /**
     * Constructor used when importing
     *
     * @param suppFileName
     *            the name to be used for the supplementary file in the
     *            workspace
     * @param parent
     *            the parent element
     */
    public TracePackageSupplFileElement(String suppFileName, TracePackageElement parent) {
        super(parent);
        this.fSuppFileName = suppFileName;
        fResource = null;
    }

    /**
     * Get the resource corresponding to this supplementary file
     *
     * @return the resource corresponding to this supplementary file
     */
    public IResource getResource() {
        return fResource;
    }

    @Override
    public String getText() {
        return fResource != null ? fResource.getName() : fSuppFileName;
    }

    @Override
    public long getSize(boolean checkedOnly) {
        if (checkedOnly && !isChecked()) {
            return 0;
        }

        return fResource.getLocation().toFile().length();
    }

    @Override
    public Image getImage() {
        return Activator.getDefault().getImageFromImageRegistry(SUPPL_FILE_ICON_PATH);
    }

}

Back to the top