1 18 package org.visualcontent.ui.preferences; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 import org.eclipse.core.runtime.IConfigurationElement; 24 import org.eclipse.core.runtime.IExtensionRegistry; 25 import org.eclipse.core.runtime.Platform; 26 import org.eclipse.jface.preference.FieldEditorPreferencePage; 27 import org.eclipse.jface.preference.RadioGroupFieldEditor; 28 import org.eclipse.ui.IWorkbench; 29 import org.eclipse.ui.IWorkbenchPreferencePage; 30 import org.visualcontent.extensionpoints.VCRepository; 31 import org.visualcontent.ui.UiPlugin; 32 33 public class NodeTreePreferencePage 34 extends FieldEditorPreferencePage 35 implements IWorkbenchPreferencePage { 36 37 private Map sessionIdSessionMap = new HashMap (); 38 private Map sessionIdNameMap = new HashMap (); 39 private String [][] repositoryChoice = null; 40 public NodeTreePreferencePage() { 41 42 super(GRID); 43 setPreferenceStore(UiPlugin.getDefault().getPreferenceStore()); 44 setDescription("Version: "+UiPlugin.getDefault().getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION)); 45 } 46 47 53 public void createFieldEditors() { 54 if (this.repositoryChoice.length>1){ 55 addField(new RadioGroupFieldEditor( 56 PreferenceConstants.P_REPOSITORY_CHOICE, 57 "Please choose the repository connector to use.", 58 1, 59 this.repositoryChoice, getFieldEditorParent())); 60 } 61 } 62 63 66 public void init(IWorkbench workbench) { 67 IExtensionRegistry registry = Platform.getExtensionRegistry (); 68 IConfigurationElement[] repositoryConfigElements = registry.getConfigurationElementsFor("org.visualcontent.extensionpoints.VCRepository"); 69 this.repositoryChoice = new String [repositoryConfigElements.length][2]; 70 for (int i = 0; i < repositoryConfigElements.length; i++) { 71 VCRepository repository = null; 72 this.repositoryChoice[i][0]=repositoryConfigElements[i].getAttribute("name"); 73 this.repositoryChoice[i][1]=repositoryConfigElements[i].getAttribute("id"); 74 } 75 } 76 public static String getDefaultRepositoryId(){ 77 String defaultRepositoryId=""; 78 IExtensionRegistry registry = Platform.getExtensionRegistry (); 79 IConfigurationElement[] repositoryConfigElements = registry.getConfigurationElementsFor("org.visualcontent.extensionpoints.VCRepository"); 80 if (repositoryConfigElements.length<1){ 81 String errorMessage="Please install a Repository connector plugin for the JCR Browser."; 82 UiPlugin.getDefault().showError(errorMessage,new RuntimeException (errorMessage)); 83 } else { 84 defaultRepositoryId=repositoryConfigElements[0].getAttribute("id"); 85 for (int i = 0; i < repositoryConfigElements.length; i++) { 86 if ("org.visualcontent.authentication.jlibrarylistener".equals(repositoryConfigElements[i].getAttribute("id"))){ 87 defaultRepositoryId=repositoryConfigElements[i].getAttribute("id"); 88 } 89 } 90 } 91 return defaultRepositoryId; 92 } 93 } | Popular Tags |