If you want to add a popup with the spell check menus added on your text components you can create a PopupInterceptorFactory and a SpellCheckTextComponentPopup that work just like the org.springframework.richclient.text.TextComponentP opupInterceptorFactory
and its associated TextComponentPopup and add in the spell check menus like this (in my SpellCheckTextComponentPopup class):
Code:
private final SpellCheckExecutor spellCheck = new SpellCheckExecutor();
protected CommandGroup getEditableCommandGroup() {
CommandGroup editGroup = getCommandManager().getCommandGroup("textEditMenu");
if(editGroup == null) {
JMenu checkerMenu = SpellChecker.createCheckerMenu();
IconSource iconSource = (IconSource)Application.services().getService(IconSource.class);
checkerMenu.setIcon(iconSource.getIcon("spellingCommand.icon"));
JMenu languagesMenu = SpellChecker.createLanguagesMenu();
languagesMenu.setIcon(iconSource.getIcon("languagesCommand.icon"));
editGroup = getCommandManager().createCommandGroup(
"textEditMenu",
new Object[] {checkerMenu, languagesMenu, "separator", GlobalCommandIds.UNDO, GlobalCommandIds.REDO, "separator", GlobalCommandIds.CUT,
GlobalCommandIds.COPY, GlobalCommandIds.PASTE, "separator", GlobalCommandIds.SELECT_ALL});
}
return editGroup;
}
private void registerCommandExecutors() {
CommandManager commandManager = getCommandManager();
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.UNDO, undo);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.REDO, redo);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.CUT, cut);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.COPY, copy);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.PASTE, paste);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.SELECT_ALL, selectAll);
commandManager.setTargetableActionCommandExecutor("spellCheckCommand", spellCheck);
}
private void unregisterCommandExecutors() {
CommandManager commandManager = getCommandManager();
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.UNDO, null);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.REDO, null);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.CUT, null);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.COPY, null);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.PASTE, null);
commandManager.setTargetableActionCommandExecutor(GlobalCommandIds.SELECT_ALL, null);
commandManager.setTargetableActionCommandExecutor("spellCheckCommand", null);
}
private class SpellCheckExecutor extends AbstractActionCommandExecutor {
public SpellCheckExecutor() {
super();
setEnabled(true);
}
@Override
public void execute() {
textComponent.getActionMap().get("spell-checking").actionPerformed(new ActionEvent(textComponent, ActionEvent.ACTION_PERFORMED, "spell-checking"));
}
}
Now I can just register my interceptors with my component interceptor factory:
Code:
<bean id="formComponentInterceptorFactory"
class="org.springframework.richclient.form.builder.support.ChainedInterceptorFactory">
<property name="interceptorFactories">
<list>
<bean class="org.springframework.richclient.form.builder.support.ColorValidationInterceptorFactory">
<property name="errorColor" value="255,245,245"/>
</bean>
<bean class="org.springframework.richclient.list.ComboBoxAutoCompletionInterceptorFactory"/>
<bean class="org.springframework.richclient.form.builder.support.OverlayValidationInterceptorFactory"/>
<bean class="org.chd.hydra.form.interceptor.PromptTextFieldFormComponentInterceptorFactory"/>
<bean class="org.chd.hydra.form.interceptor.ShowDescriptionInStatusBarInterceptorFactory"/>
<bean class="org.chd.hydra.form.interceptor.SpellCheckTextComponentInterceptorFactory">
<property name="dictionaries">
<value>classpath:dictionaries/</value>
</property>
<property name="hasPopup" value="false"/>
<property name="userDictionaryPath" value="${user.home}/Application Data/CHD/${application.title}"/>
</bean>
<bean class="org.chd.hydra.form.interceptor.SpellCheckTextComponentPopupInterceptorFactory"/>
<!--<bean class="org.springframework.richclient.text.TextComponentPopupInterceptorFactory"/>-->
</list>
</property>
</bean>
add the spellCheckCommand to my windowCommandManager and viewMenu, and configure the spellCheckCommand label,caption and icon, as well as provide icons for the spellingCommand and languagesCommand that will be loded by the getEditableCommandGroup method shown above if desired.