01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.internal.ui;
16:
17: import java.util.Set;
18:
19: import net.refractions.udig.ui.AbstractStrategizedTransfer;
20: import net.refractions.udig.ui.internal.Messages;
21:
22: import org.eclipse.jface.preference.FieldEditorPreferencePage;
23: import org.eclipse.jface.preference.IPreferenceStore;
24: import org.eclipse.jface.preference.RadioGroupFieldEditor;
25: import org.eclipse.swt.dnd.Transfer;
26: import org.eclipse.ui.IWorkbench;
27: import org.eclipse.ui.IWorkbenchPreferencePage;
28:
29: /**
30: * TODO Purpose of
31: * <p>
32: *
33: * </p>
34: * @author Jesse
35: * @since 1.1.0
36: */
37: public class TransferPreference extends FieldEditorPreferencePage
38: implements IWorkbenchPreferencePage {
39:
40: public TransferPreference() {
41: super (GRID);
42: IPreferenceStore store = UiPlugin.getDefault()
43: .getPreferenceStore();
44: setPreferenceStore(store);
45: setDescription(Messages.TransferPreference_transfer_preference_description);
46: }
47:
48: @Override
49: protected void createFieldEditors() {
50: Set<Transfer> transfers = UDIGDNDProcessor.getTransfers();
51: for (Transfer transfer : transfers) {
52: if (transfer instanceof AbstractStrategizedTransfer) {
53: AbstractStrategizedTransfer ast = (AbstractStrategizedTransfer) transfer;
54: String[] names = ast.getStrategyNames();
55: if (names.length < 2)
56: continue;
57:
58: String[][] labelsAndValues = new String[names.length][];
59: for (int i = 0; i < labelsAndValues.length; i++) {
60: labelsAndValues[i] = new String[] { names[i],
61: "" + i }; //$NON-NLS-1$
62: getPreferenceStore().setDefault(
63: ast.getClass().getName(), ""); //$NON-NLS-1$
64: }
65: addField(new RadioGroupFieldEditor(transfer.getClass()
66: .getName(), ast.getTransferName(), 2,
67: labelsAndValues, getFieldEditorParent(), true));
68: }
69: }
70: }
71:
72: public void init(IWorkbench workbench) {
73: }
74:
75: }
|