KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > javaeditor > saveparticipant > SaveParticipantDescriptor


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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 org.eclipse.core.runtime.Assert;
14
15 /**
16  * Describes a save participant contribution.
17  *
18  * @since 3.3
19  */

20 public class SaveParticipantDescriptor {
21
22     /** The listener */
23     private final IPostSaveListener fPostSaveListener;
24     /** The preference configuration block, if any */
25     private ISaveParticipantPreferenceConfiguration fPreferenceConfiguration;
26     
27     /**
28      * Creates a new descriptor which connects a {@link IPostSaveListener}
29      * with an {@link ISaveParticipantPreferenceConfiguration}.
30      *
31      * @param listener the listener
32      */

33     SaveParticipantDescriptor(IPostSaveListener listener) {
34         Assert.isNotNull(listener);
35
36         fPostSaveListener= listener;
37     }
38
39     /**
40      * Returns the post save listener of the described
41      * save participant
42      *
43      * @return the listener
44      */

45     public IPostSaveListener getPostSaveListener() {
46         return fPostSaveListener;
47     }
48
49     /**
50      * Creates a new preference configuration of the described
51      * save participant.
52      *
53      * @return the preference configuration
54      */

55     public ISaveParticipantPreferenceConfiguration createPreferenceConfiguration() {
56         return new AbstractSaveParticipantPreferenceConfiguration() {
57
58             protected String JavaDoc getPostSaveListenerId() {
59                 return fPostSaveListener.getId();
60             }
61
62             protected String JavaDoc getPostSaveListenerName() {
63                 return fPostSaveListener.getName();
64             }
65         };
66     }
67     
68     /**
69      * Returns the preference configuration of the described
70      * save participant.
71      *
72      * @return the preference configuration
73      */

74     public ISaveParticipantPreferenceConfiguration getPreferenceConfiguration() {
75         if (fPreferenceConfiguration == null)
76             fPreferenceConfiguration= createPreferenceConfiguration();
77         
78         return fPreferenceConfiguration;
79     }
80
81     /**
82      * Returns the identifier of the described save participant.
83      *
84      * @return the non-empty id of this descriptor
85      */

86     public String JavaDoc getId() {
87         return fPostSaveListener.getId();
88     }
89
90 }
91
Popular Tags