KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > rcp > action > Editor2PerspectiveRegistry


1 /**
2  * <p> Project: com.nightlabs.base </p>
3  * <p> Copyright: Copyright (c) 2005 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 01.07.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8
9 package com.nightlabs.rcp.action;
10
11 import java.util.HashMap JavaDoc;
12 import java.util.Map JavaDoc;
13
14 import org.eclipse.core.runtime.IConfigurationElement;
15
16 import com.nightlabs.rcp.extensionpoint.AbstractEPProcessor;
17 import com.nightlabs.rcp.extensionpoint.EPProcessorException;
18
19 public class Editor2PerspectiveRegistry
20 extends AbstractEPProcessor
21 {
22     public static final String JavaDoc EXTENSION_POINT_ID = "com.nightlabs.base.editor2perspective";
23     
24     public String JavaDoc getExtensionPointID() {
25         return EXTENSION_POINT_ID;
26     }
27
28     private static Editor2PerspectiveRegistry sharedInstance;
29     public static Editor2PerspectiveRegistry getSharedInstance() {
30         if (sharedInstance == null)
31             sharedInstance = new Editor2PerspectiveRegistry();
32         return sharedInstance;
33     }
34         
35     protected Map JavaDoc editorID2PerspectiveID = new HashMap JavaDoc();
36     public String JavaDoc getPerspectiveID(String JavaDoc editorID)
37     {
38         checkProcessing();
39         return (String JavaDoc) editorID2PerspectiveID.get(editorID);
40     }
41     
42     public void processElement(IConfigurationElement element)
43     throws EPProcessorException
44     {
45         if (element.getName().equalsIgnoreCase("registry"))
46         {
47             String JavaDoc editorID = element.getAttribute("editorID");
48             if (!checkString(editorID))
49                 throw new EPProcessorException("Element registry has to define attribute editorID.");
50             
51             String JavaDoc perspectiveID = element.getAttribute("perspectiveID");
52             if (!checkString(perspectiveID))
53                 throw new EPProcessorException("Element registry has to define attribute perspectiveID.");
54             
55             editorID2PerspectiveID.put(editorID, perspectiveID);
56         }
57     }
58
59     protected boolean checkString(String JavaDoc s)
60     {
61         if (s == null || "".equals(s))
62             return false;
63         
64         return true;
65     }
66     
67 }
68
Popular Tags