Skip to main content
summaryrefslogtreecommitdiffstats
blob: a41e33f52f97bbc0df2b4318ab0560b448b8fec9 (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
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * 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:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.define.traceability.importer;

import java.net.URI;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.osee.define.internal.Activator;
import org.eclipse.osee.define.traceability.operations.ImportTraceUnitsOperation;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;

/**
 * @author Roberto E. Escobar
 */
public class ImportTraceUnitWizard extends Wizard implements IImportWizard {
   private ImportTraceUnitPage page;
   private IStructuredSelection selection;

   public ImportTraceUnitWizard() {
      super();
      setWindowTitle("Import Trace Units Wizard");
   }

   @Override
   public boolean performFinish() {
      try {
         BranchId importToBranch = page.getSelectedBranch();
         boolean isRecursive = page.isFolderRecursionAllowed();
         boolean isPersistChanges = page.isArtifactPersistanceAllowed();
         Iterable<URI> sources = page.getSourceURI();
         String[] traceUnitHandlerIds = page.getTraceUnitHandlerIds();
         boolean fileWithMultiPaths = page.isFileContainingMultiplePaths();
         boolean addGuidToSourceFile = page.isAddGuidToSourceFileAllowed();
         IOperation op = new ImportTraceUnitsOperation("Import Trace Units", importToBranch, sources, isRecursive,
            isPersistChanges, fileWithMultiPaths, addGuidToSourceFile, traceUnitHandlerIds);
         Operations.executeAsJob(op, true);
         page.saveWidgetValues();
      } catch (Exception ex) {
         OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, "Import Trace Unit Error", ex);
      }
      return true;
   }

   @Override
   public void init(IWorkbench workbench, IStructuredSelection selection) {
      this.selection = selection;
   }

   @Override
   public void addPages() {
      page = new ImportTraceUnitPage(selection);
      addPage(page);
   }
}

Back to the top