Skip to main content
summaryrefslogtreecommitdiffstats
blob: b33cb3df0a286fa501db2c9b32f06ffd7dba0b95 (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
/*******************************************************************************
 * 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.ats.navigate;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.ats.AtsImage;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.ats.world.WorldEditor;
import org.eclipse.osee.ats.world.WorldEditorSimpleProvider;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;

/**
 * @author Donald G. Dunne
 */
public class VisitedItems extends XNavigateItemAction {

   public static List<String> visitedGuids = new ArrayList<String>();

   public static List<Artifact> getReverseVisited() throws OseeCoreException {
      // Search artifacts and hold on to references so don't get garbage collected
      @SuppressWarnings("unused")
      Collection<Artifact> artifacts = ArtifactQuery.getArtifactListFromIds(visitedGuids, AtsUtil.getAtsBranch());
      List<Artifact> revArts = new ArrayList<Artifact>();
      for (int x = visitedGuids.size(); x <= 0; x--) {
         Artifact art = ArtifactQuery.getArtifactFromId(visitedGuids.get(x), AtsUtil.getAtsBranch());
         if (art != null) {
            revArts.add(art);
         }
      }
      return revArts;
   }

   public static void addVisited(Artifact art) {
      if (!visitedGuids.contains(art.getGuid())) {
         visitedGuids.add(art.getGuid());
      }
   }

   public static void clearVisited() {
      if (visitedGuids != null) {
         visitedGuids.clear();
      }
   }

   /**
    * @param parent
    */
   public VisitedItems(XNavigateItem parent) {
      super(parent, "My Recently Visited", AtsImage.GLOBE);
   }

   @Override
   public void run(TableLoadOption... tableLoadOptions) throws OseeCoreException {
      Collection<Artifact> artifacts = ArtifactQuery.getArtifactListFromIds(visitedGuids, AtsUtil.getAtsBranch());
      WorldEditor.open(new WorldEditorSimpleProvider(getName(), artifacts, null, tableLoadOptions));
   }
}

Back to the top