1 8 9 package com.nightlabs.rcp.action; 10 11 import java.util.HashMap ; 12 import java.util.Map ; 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 EXTENSION_POINT_ID = "com.nightlabs.base.editor2perspective"; 23 24 public String 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 editorID2PerspectiveID = new HashMap (); 36 public String getPerspectiveID(String editorID) 37 { 38 checkProcessing(); 39 return (String ) editorID2PerspectiveID.get(editorID); 40 } 41 42 public void processElement(IConfigurationElement element) 43 throws EPProcessorException 44 { 45 if (element.getName().equalsIgnoreCase("registry")) 46 { 47 String editorID = element.getAttribute("editorID"); 48 if (!checkString(editorID)) 49 throw new EPProcessorException("Element registry has to define attribute editorID."); 50 51 String 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 s) 60 { 61 if (s == null || "".equals(s)) 62 return false; 63 64 return true; 65 } 66 67 } 68 | Popular Tags |