KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > MemoryViewIdRegistry


1 /*******************************************************************************
2  * Copyright (c) 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.views.memory;
12
13 import java.util.ArrayList JavaDoc;
14
15 /**
16  * Class for managing the secondary ids for Memory View
17  *
18  */

19 public class MemoryViewIdRegistry{
20     
21     private static ArrayList JavaDoc fgRegistry;
22     
23     public static void registerView(String JavaDoc secondaryId)
24     {
25         ArrayList JavaDoc registry = getRegistry();
26         
27         if (!registry.contains(secondaryId))
28         {
29             registry.add(secondaryId);
30         }
31     }
32     
33     public static void deregisterView(String JavaDoc secondaryId)
34     {
35         ArrayList JavaDoc registry = getRegistry();
36         
37         if (registry.contains(secondaryId))
38         {
39             registry.remove(secondaryId);
40         }
41     }
42     
43     public static String JavaDoc getUniqueSecondaryId(String JavaDoc viewId)
44     {
45         int cnt = 0;
46         String JavaDoc id = viewId + "." + cnt; //$NON-NLS-1$
47
ArrayList JavaDoc registry = getRegistry();
48         while (registry.contains(id))
49         {
50             cnt ++;
51             id = viewId + "." + cnt; //$NON-NLS-1$
52
}
53         return id;
54     }
55     
56     private static ArrayList JavaDoc getRegistry()
57     {
58         if (fgRegistry == null)
59             fgRegistry = new ArrayList JavaDoc();
60         
61         return fgRegistry;
62     }
63 }
64
Popular Tags