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