]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2006, 2011 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.jdt.internal.ui.javaeditor.saveparticipant; | |
12 | ||
13 | import java.util.ArrayList; | |
14 | import java.util.Map; | |
15 | ||
16 | import org.eclipse.core.runtime.Assert; | |
17 | import org.eclipse.core.runtime.preferences.IScopeContext; | |
18 | ||
19 | /** | |
20 | * Describes a save participant contribution. | |
21 | * | |
22 | * @since 3.3 | |
23 | */ | |
24 | public class SaveParticipantDescriptor { | |
25 | ||
26 | /** The listener */ | |
27 | private final IPostSaveListener fPostSaveListener; | |
28 | /** The preference configuration block, if any */ | |
29 | private ISaveParticipantPreferenceConfiguration fPreferenceConfiguration; | |
30 | ||
31 | /** | |
32 | * Creates a new descriptor which connects a {@link IPostSaveListener} | |
33 | * with an {@link ISaveParticipantPreferenceConfiguration}. | |
34 | * | |
35 | * @param listener the listener | |
36 | */ | |
37 | SaveParticipantDescriptor(IPostSaveListener listener) { | |
38 | Assert.isNotNull(listener); | |
39 | ||
40 | fPostSaveListener= listener; | |
41 | } | |
42 | ||
43 | /** | |
44 | * Returns the post save listener of the described | |
45 | * save participant | |
46 | * | |
47 | * @return the listener | |
48 | */ | |
49 | public IPostSaveListener getPostSaveListener() { | |
50 | return fPostSaveListener; | |
51 | } | |
52 | ||
53 | /** | |
54 | * Creates a new preference configuration of the described | |
55 | * save participant. | |
56 | * | |
57 | * @return the preference configuration | |
58 | */ | |
59 | public ISaveParticipantPreferenceConfiguration createPreferenceConfiguration() { | |
60 | return new AbstractSaveParticipantPreferenceConfiguration() { | |
61 | ||
62 | @Override | |
63 | protected String getPostSaveListenerId() { | |
64 | return fPostSaveListener.getId(); | |
65 | } | |
66 | ||
67 | @Override | |
68 | protected String getPostSaveListenerName() { | |
69 | return fPostSaveListener.getName(); | |
70 | } | |
71 | }; | |
72 | } | |
73 | ||
74 | /** | |
75 | * Returns the preference configuration of the described | |
76 | * save participant. | |
77 | * | |
78 | * @return the preference configuration | |
79 | */ | |
80 | public ISaveParticipantPreferenceConfiguration getPreferenceConfiguration() { | |
81 | if (fPreferenceConfiguration == null) | |
82 | fPreferenceConfiguration= createPreferenceConfiguration(); | |
83 | ||
84 | return fPreferenceConfiguration; | |
85 | } | |
86 | ||
87 | /** | |
88 | * Returns the identifier of the described save participant. | |
89 | * | |
90 | * @return the non-empty id of this descriptor | |
91 | */ | |
92 | public String getId() { | |
93 | return fPostSaveListener.getId(); | |
94 | } | |
95 | ||
96 | public void generated_8850500018469403830(Map<String, SaveParticipantDescriptor> map, SaveParticipantRegistry saveparticipantregistry) { | |
97 | map.put(getId(), this); | |
98 | ||
99 | saveparticipantregistry.fDescriptors= map; | |
100 | } | |
101 | ||
102 | public ArrayList<IPostSaveListener> generated_5939957325016738010(IScopeContext context, ArrayList<IPostSaveListener> result) { | |
103 | if (getPreferenceConfiguration().isEnabled(context)) { | |
104 | if (result == null) { | |
105 | result= new ArrayList<IPostSaveListener>(); | |
106 | } | |
107 | result.add(getPostSaveListener()); | |
108 | } | |
109 | return result; | |
110 | } | |
111 | ||
112 | } |