~ubuntu-branches/ubuntu/wily/eclipse-linuxtools/wily

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/project/wizards/tracepkg/importexport/ImportTracePackageWizardPage.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************************
2
 
 * Copyright (c) 2013 Ericsson
 
2
 * Copyright (c) 2013, 2014 Ericsson
3
3
 *
4
4
 * All rights reserved. This program and the accompanying materials are
5
5
 * made available under the terms of the Eclipse Public License v1.0 which
19
19
import java.util.List;
20
20
 
21
21
import org.eclipse.core.resources.IProject;
 
22
import org.eclipse.core.resources.IResource;
22
23
import org.eclipse.core.resources.ResourcesPlugin;
23
24
import org.eclipse.core.runtime.IProgressMonitor;
24
25
import org.eclipse.core.runtime.IStatus;
29
30
import org.eclipse.jface.viewers.CheckboxTreeViewer;
30
31
import org.eclipse.jface.viewers.IStructuredSelection;
31
32
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
32
 
import org.eclipse.linuxtools.internal.tmf.ui.project.model.TmfImportHelper;
33
33
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.AbstractTracePackageOperation;
34
34
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.AbstractTracePackageWizardPage;
35
35
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement;
36
36
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageFilesElement;
37
37
import org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.TracePackageTraceElement;
38
38
import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
39
 
import org.eclipse.linuxtools.tmf.ui.project.model.TmfNavigatorContentProvider;
40
39
import org.eclipse.linuxtools.tmf.ui.project.model.TmfProjectRegistry;
41
 
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement;
42
40
import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceFolder;
43
41
import org.eclipse.linuxtools.tmf.ui.project.model.TraceUtils;
44
42
import org.eclipse.swt.SWT;
137
135
            IProject defaultProject = ResourcesPlugin.getWorkspace().getRoot().getProject(TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME);
138
136
            if (!defaultProject.exists()) {
139
137
                IProject project = TmfProjectRegistry.createProject(TmfCommonConstants.DEFAULT_TRACE_PROJECT_NAME, null, null);
140
 
                TmfImportHelper.forceFolderRefresh(project.getFolder(TmfTraceFolder.TRACE_FOLDER_NAME));
141
138
                fOpenedTmfProjects.add(project);
142
139
            }
143
140
        }
200
197
 
201
198
    private void selectProject(IProject project) {
202
199
        fProjectText.setText(project.getName());
203
 
        new TmfNavigatorContentProvider().getChildren(project);
204
 
        fTmfTraceFolder = TmfProjectRegistry.getProject(project).getTracesFolder();
 
200
        fTmfTraceFolder = TmfProjectRegistry.getProject(project, true).getTracesFolder();
205
201
        updatePageCompletion();
206
202
    }
207
203
 
210
206
        return super.determinePageCompletion() && fTmfTraceFolder != null;
211
207
    }
212
208
 
 
209
    /**
 
210
     * Create the operation that will be responsible of creating the manifest
 
211
     * based on the file name.
 
212
     *
 
213
     * @param fileName the file name to generate the manifest from
 
214
     *
 
215
     * @return the operation that will extract the manifest
 
216
     */
 
217
    protected AbstractTracePackageOperation createExtractManifestOperation(String fileName) {
 
218
        return new TracePackageExtractManifestOperation(fileName);
 
219
    }
 
220
 
213
221
    @Override
214
222
    protected Object createElementViewerInput() {
215
223
 
216
 
        final TracePackageExtractManifestOperation op = new TracePackageExtractManifestOperation(getFilePathValue());
 
224
        final AbstractTracePackageOperation op = createExtractManifestOperation(getFilePathValue());
217
225
 
218
226
        try {
219
227
            getContainer().run(true, true, new IRunnableWithProgress() {
237
245
            // Canceled
238
246
        }
239
247
 
240
 
        TracePackageElement[] resultElements = op.getResultElement();
 
248
        TracePackageElement[] resultElements = op.getResultElements();
241
249
        if (resultElements == null || resultElements.length == 0) {
242
250
            return null;
243
251
        }
338
346
 
339
347
    private boolean checkForOverwrite() {
340
348
        TracePackageElement[] traceElements = (TracePackageElement[]) getElementViewer().getInput();
341
 
        List<TracePackageTraceElement> noImportTraces = new ArrayList<TracePackageTraceElement>();
 
349
        List<TracePackageTraceElement> noImportTraces = new ArrayList<>();
342
350
        boolean noToAll = false;
343
351
        for (TracePackageElement packageElement : traceElements) {
344
352
            TracePackageTraceElement traceElement = (TracePackageTraceElement) packageElement;
351
359
                continue;
352
360
            }
353
361
 
354
 
            String traceName = traceElement.getText();
355
 
            if (traceExists(traceName)) {
356
 
                int returnCode = promptForOverwrite(traceName);
 
362
            if (traceExists(traceElement)) {
 
363
                int returnCode = promptForOverwrite(traceElement.getDestinationElementPath());
 
364
                // The return code is an index to a button in the dialog but the
 
365
                // 'X' button in the window corner is not considered a button
 
366
                // therefore it returns -1 and unfortunately, there is no
 
367
                // constant for that.
 
368
                if (returnCode < 0) {
 
369
                    return false;
 
370
                }
 
371
 
357
372
                final String[] response = new String[] { IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.YES_LABEL };
358
373
                if (response[returnCode].equals(IDialogConstants.YES_TO_ALL_LABEL)) {
359
374
                    break;
378
393
        return true;
379
394
    }
380
395
 
381
 
    private boolean traceExists(String traceName) {
382
 
        List<TmfTraceElement> traces = fTmfTraceFolder.getTraces();
383
 
        for (TmfTraceElement t : traces) {
384
 
            if (t.getName().equals(traceName)) {
385
 
                return true;
386
 
            }
387
 
        }
388
 
 
389
 
        return false;
 
396
    private boolean traceExists(TracePackageTraceElement traceElement) {
 
397
        IResource traceRes = fTmfTraceFolder.getResource().findMember(traceElement.getDestinationElementPath());
 
398
        return traceRes != null;
390
399
    }
391
400
 
392
401
    private int promptForOverwrite(String traceName) {