Skip to main content
summaryrefslogtreecommitdiffstats
blob: 74f6a217d42bbfa6bacbee30401552f597c1fef0 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*******************************************************************************
 * 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.world.search;

import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import org.eclipse.osee.ats.internal.Activator;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.osee.framework.ui.swt.KeyedImage;
import org.eclipse.swt.graphics.Image;

/**
 * @author Donald G. Dunne
 */
public abstract class WorldSearchItem {

   private final String name;
   protected static final Set<Artifact> EMPTY_SET = new HashSet<Artifact>();
   protected boolean cancelled = false;
   private LoadView loadView;
   private KeyedImage oseeImage;
   public static enum LoadView {
      TaskEditor,
      WorldEditor,
      None
   }
   public static enum SearchType {
      Search,
      ReSearch
   };

   public WorldSearchItem(String name) {
      this(name, LoadView.WorldEditor);
   }

   public WorldSearchItem(String name, LoadView loadView) {
      this(name, loadView, null);
   }

   public WorldSearchItem(String name, LoadView loadView, boolean cancelled, KeyedImage oseeImage) {
      super();
      this.name = name;
      this.loadView = loadView;
      this.cancelled = cancelled;
      this.oseeImage = oseeImage;
   }

   public WorldSearchItem(String name, LoadView loadView, KeyedImage oseeImage) {
      this(name, loadView, false, oseeImage);
   }

   public WorldSearchItem(WorldSearchItem worldSearchItem) {
      this(worldSearchItem, null);
   }

   public WorldSearchItem(WorldSearchItem worldSearchItem, KeyedImage oseeImage) {
      this(worldSearchItem.name, worldSearchItem.loadView, worldSearchItem.cancelled, oseeImage);
   }

   public abstract WorldSearchItem copy() throws OseeArgumentException, OseeCoreException;

   @SuppressWarnings("unused")
   public String getName() throws OseeCoreException {
      return name;
   }

   /**
    * Method called to display the current search in the view. Override to provide more information about selected
    * values (eg MyWorld)
    */
   public String getSelectedName(SearchType searchType) throws OseeCoreException {
      return getName();
   }

   public boolean isCancelled() {
      return cancelled;
   }

   public void setCancelled(boolean cancelled) {
      this.cancelled = cancelled;
   }

   public LoadView getLoadView() {
      return loadView;
   }

   public void setLoadView(LoadView loadView) {
      this.loadView = loadView;
   }

   @Override
   public String toString() {
      try {
         return getName();
      } catch (OseeCoreException ex) {
         OseeLog.log(Activator.class, Level.SEVERE, ex);
         return ex.getLocalizedMessage();
      }
   }

   public Image getImage() {
      return oseeImage == null ? null : ImageManager.getImage(oseeImage);
   }

   public KeyedImage getOseeImage() {
      return oseeImage;
   }

   public void setOseeImage(KeyedImage oseeImage) {
      this.oseeImage = oseeImage;
   }

}

Back to the top