View Javadoc
1   /*
2    * Copyright (c) 2020 bahlef.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v2.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v20.html
7    * Contributors:
8    * bahlef - initial API and implementation and/or initial documentation
9    */
10  
11  package de.funfried.netbeans.plugins.external.formatter.ui.options;
12  
13  import java.util.prefs.Preferences;
14  
15  import javax.swing.JPanel;
16  import javax.swing.event.ChangeListener;
17  
18  /**
19   *
20   * @author bahlef
21   */
22  public interface FormatterOptionsPanel {
23  	/**
24  	 * Returns the {@link JPanel} component for this {@link FormatterOptionsPanel}.
25  	 *
26  	 * @return the {@link JPanel} component for this {@link FormatterOptionsPanel}
27  	 */
28  	JPanel getComponent();
29  
30  	/**
31  	 * Adds a {@link ChangeListener} to this {@link FormatterOptionsPanel} which
32  	 * will be informed if a user makes changes to the shown components.
33  	 *
34  	 * @param listener the {@link ChangeListener} to add
35  	 *
36  	 * @see #removeChangeListener(javax.swing.event.ChangeListener)
37  	 */
38  	void addChangeListener(ChangeListener listener);
39  
40  	/**
41  	 * Loads the current settings from the given {@link Preferences} and sets those
42  	 * to the components of this {@link FormatterOptionsPanel}.
43  	 *
44  	 * @param preferences the {@link Preferences} to load from
45  	 */
46  	void load(Preferences preferences);
47  
48  	/**
49  	 * Removes a {@link ChangeListener} from this {@link FormatterOptionsPanel}.
50  	 *
51  	 * @param listener the {@link ChangeListener} to remove
52  	 *
53  	 * @see #addChangeListener(javax.swing.event.ChangeListener)
54  	 */
55  	void removeChangeListener(ChangeListener listener);
56  
57  	/**
58  	 * Stores all the currently set values of all components to the given
59  	 * {@link Preferences}.
60  	 *
61  	 * @param preferences the {@link Preferences} where to store to
62  	 */
63  	void store(Preferences preferences);
64  
65  	/**
66  	 * Returns {@code true} if the settings that are currently made are valid,
67  	 * otherwise {@code false}.
68  	 *
69  	 * @return {@code true} if the settings that are currently made are valid,
70  	 *         otherwise {@code false}
71  	 */
72  	boolean valid();
73  }