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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.javaeditor.saveparticipant;
13 import org.eclipse.core.runtime.Assert;
16 * Describes a save participant contribution.
20 public class SaveParticipantDescriptor {
23 private final IPostSaveListener fPostSaveListener;
24 /** The preference configuration block, if any */
25 private ISaveParticipantPreferenceConfiguration fPreferenceConfiguration;
28 * Creates a new descriptor which connects a {@link IPostSaveListener}
29 * with an {@link ISaveParticipantPreferenceConfiguration}.
31 * @param listener the listener
33 SaveParticipantDescriptor(IPostSaveListener listener) {
34 Assert.isNotNull(listener);
36 fPostSaveListener= listener;
40 * Returns the post save listener of the described
43 * @return the listener
45 public IPostSaveListener getPostSaveListener() {
46 return fPostSaveListener;
50 * Creates a new preference configuration of the described
53 * @return the preference configuration
55 public ISaveParticipantPreferenceConfiguration createPreferenceConfiguration() {
56 return new AbstractSaveParticipantPreferenceConfiguration() {
59 protected String getPostSaveListenerId() {
60 return fPostSaveListener.getId();
64 protected String getPostSaveListenerName() {
65 return fPostSaveListener.getName();
71 * Returns the preference configuration of the described
74 * @return the preference configuration
76 public ISaveParticipantPreferenceConfiguration getPreferenceConfiguration() {
77 if (fPreferenceConfiguration == null)
78 fPreferenceConfiguration= createPreferenceConfiguration();
80 return fPreferenceConfiguration;
84 * Returns the identifier of the described save participant.
86 * @return the non-empty id of this descriptor
88 public String getId() {
89 return fPostSaveListener.getId();