1 /******************************************************************************* 2 * Copyright (c) 2006, 2019 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 ******************************************************************************/ 14 15 package org.eclipse.ui.internal.preferences; 16 17 import java.util.ArrayList; 18 import java.util.Collection; 19 import org.eclipse.core.runtime.IConfigurationElement; 20 import org.eclipse.core.runtime.IExtensionRegistry; 21 import org.eclipse.core.runtime.Platform; 22 import org.eclipse.ui.internal.WorkbenchPlugin; 23 import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; 24 import org.eclipse.ui.internal.registry.RegistryReader; 25 26 /** 27 * The SettingsTransferRegistryReader is the class that supplies all of the 28 * transfer settings used by the settingsTransfer in the preferencesTransfer 29 * extension point. 30 * 31 * 32 * @since 3.3 33 * 34 */ 35 public class SettingsTransferRegistryReader extends RegistryReader { 36 37 Collection<IConfigurationElement> settingsTransfers = new ArrayList<>(); 38 39 /** 40 * Create an instance of the receiver. 41 */ SettingsTransferRegistryReader()42 public SettingsTransferRegistryReader() { 43 44 } 45 46 /** 47 * Get all of the currently registered settings transfers. 48 * 49 * @return IConfigurationElement[] 50 */ getSettingTransfers()51 public IConfigurationElement[] getSettingTransfers() { 52 53 settingsTransfers = new ArrayList<>(); 54 IExtensionRegistry registry = Platform.getExtensionRegistry(); 55 readRegistry(registry, WorkbenchPlugin.PI_WORKBENCH, IWorkbenchRegistryConstants.PL_PREFERENCE_TRANSFER); 56 57 IConfigurationElement[] transfers = new IConfigurationElement[settingsTransfers.size()]; 58 settingsTransfers.toArray(transfers); 59 return transfers; 60 61 } 62 63 @Override readElement(IConfigurationElement element)64 protected boolean readElement(IConfigurationElement element) { 65 if (element.getName().equals(IWorkbenchRegistryConstants.TAG_SETTINGS_TRANSFER)) { 66 67 settingsTransfers.add(element); 68 return true; 69 } 70 71 // Ignore the preference transfers 72 return element.getName().equals(IWorkbenchRegistryConstants.TAG_TRANSFER); 73 } 74 75 } 76