/** Loads combo choices fromt he platform and from PDE core preferences */ private void initializeChoices() { IEclipsePreferences node = new InstanceScope().getNode(PDECore.PLUGIN_ID); fOSChoices = new TreeSet<String>(); String[] os = Platform.knownOSValues(); for (int i = 0; i < os.length; i++) { fOSChoices.add(os[i]); } String pref = node.get(ICoreConstants.OS_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fOSChoices, pref); } fWSChoices = new TreeSet<String>(); String[] ws = Platform.knownWSValues(); for (int i = 0; i < ws.length; i++) { fWSChoices.add(ws[i]); } pref = node.get(ICoreConstants.WS_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fWSChoices, pref); } fArchChoices = new TreeSet<String>(); String[] arch = Platform.knownOSArchValues(); for (int i = 0; i < arch.length; i++) { fArchChoices.add(arch[i]); } pref = node.get(ICoreConstants.ARCH_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fArchChoices, pref); } fNLChoices = new TreeSet<String>(); String[] nl = LocaleUtil.getLocales(); for (int i = 0; i < nl.length; i++) { fNLChoices.add(nl[i]); } pref = node.get(ICoreConstants.NL_EXTRA, EMPTY_STRING); if (!EMPTY_STRING.equals(pref)) { addExtraChoices(fNLChoices, pref); } }
/** * Returns <code>ITextSelection.class</code> or <code>null</code> if the class is not available. * * @return <code>ITextSelection.class</code> or <code>null</code> if class not available * @since 1.0 */ private static Class getTextSelectionClass() { if (iTextSelectionClass != null) { // tried before and succeeded return iTextSelectionClass; } if (!textSelectionPossible) { // tried before and failed return null; } // JFace text plug-in is not on prereq chain of generic wb plug-in // hence: ITextSelection.class won't compile // and Class.forName("org.eclipse.jface.text.ITextSelection") won't find // it need to be trickier... Bundle bundle = Platform.getBundle(JFACE_TEXT_PLUG_IN); if (bundle == null || bundle.getState() == Bundle.UNINSTALLED) { // JFace text plug-in is not around, or has already // been removed, assume that it will never be around textSelectionPossible = false; return null; } // plug-in is around // it's not our job to activate the plug-in if (bundle.getState() == Bundle.INSTALLED) { // assume it might come alive later textSelectionPossible = true; return null; } try { Class c = bundle.loadClass(TEXT_SELECTION_CLASS); // remember for next time iTextSelectionClass = c; return iTextSelectionClass; } catch (ClassNotFoundException e) { // unable to load ITextSelection - sounds pretty serious // treat as if JFace text plug-in were unavailable textSelectionPossible = false; return null; } }