-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ConfigurationListener, GlobalConfiguration
The LocalConfiguration already has a facility for listeners, add the same for the Configuration held by the platform by introducing a GlobalConfiguration interface. Rename LocalConfigurationListener to just ConfigurationListener.
- Loading branch information
Showing
12 changed files
with
81 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
net.sourceforge.vrapper.core/src/net/sourceforge/vrapper/platform/GlobalConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.sourceforge.vrapper.platform; | ||
|
||
import net.sourceforge.vrapper.vim.ConfigurationListener; | ||
|
||
/** | ||
* Interface for the global configuration. | ||
*/ | ||
public interface GlobalConfiguration extends Configuration { | ||
|
||
public void removeListener(ConfigurationListener listener); | ||
|
||
/** Add a listener which gets called if a setting is set globally. */ | ||
public void addListener(ConfigurationListener listener); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
net.sourceforge.vrapper.core/src/net/sourceforge/vrapper/vim/SimpleGlobalConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.sourceforge.vrapper.vim; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
import net.sourceforge.vrapper.platform.GlobalConfiguration; | ||
import net.sourceforge.vrapper.platform.SimpleConfiguration; | ||
|
||
/** | ||
* Configuration implementation used for holding the global settings which are used as defaults in | ||
* new editors. | ||
*/ | ||
// This class is implemented in core as it doesn't really depend on platform-specific code. | ||
public class SimpleGlobalConfiguration extends SimpleConfiguration implements GlobalConfiguration { | ||
|
||
protected List<ConfigurationListener> listeners = | ||
new CopyOnWriteArrayList<ConfigurationListener>(); | ||
|
||
@Override | ||
public <T> void set(Option<T> key, T value) { | ||
T oldValue = super.get(key); | ||
super.set(key, value); | ||
for (ConfigurationListener listener : listeners) { | ||
listener.optionChanged(key, oldValue, value); | ||
} | ||
} | ||
|
||
public void addListener(ConfigurationListener listener) { | ||
listeners.add(listener); | ||
} | ||
|
||
public void removeListener(ConfigurationListener listener) { | ||
listeners.remove(listener); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters