code
stringlengths 67
466k
| docstring
stringlengths 1
13.2k
|
---|---|
protected final Boolean isOverlayInstalled(DefaultOverlayable overlayable, JComponent overlay) {
Assert.notNull(overlay, JideOverlayService.OVERLAY);
if (overlayable != null) {
return (overlayable.getOverlayLocation(overlay) != JideOverlayService.NOT_FOUND);
}
return Boolean.FALSE;
} | {@inheritDoc} |
protected final DefaultOverlayable findOverlayable(JComponent targetComponent) {
// Find overlayable in tart component container
final Container parent = targetComponent.getParent();
if ((parent != null) && (parent instanceof DefaultOverlayable)) {
return (DefaultOverlayable) parent;
}
return null;
} | Tries to find a <code>DefaultOverlayable</code> given a target component.
@param targetComponent
the target component.
@return the associated <code>Overlayable</code> if found and <code>null</code> in other case. |
protected final Boolean setVisible(JComponent targetComponent, JComponent overlay, Boolean show) {
Assert.notNull(targetComponent, JideOverlayService.TARGET_COMPONENT_PARAM);
Assert.notNull(overlay, JideOverlayService.OVERLAY);
Assert.notNull(show, "show");
// If overlay is installed...
if (this.isOverlayInstalled(targetComponent, overlay)) {
// Definitely show or hide overlay
overlay.setVisible(show);
overlay.repaint();
return Boolean.TRUE;
}
return Boolean.FALSE;
} | Show or hide the given overlay depending on the given <code>show</code> parameter.
@param targetComponent
the target component.
@param overlay
the overlay component.
@param show
whether to show or hide the given overlay (<code>true</code> for showing).
@return <code>true</code> if success and <code>false</code> in other case. |
public static TitlePane createTitlePane(DialogPage dialogPage) {
TitlePane titlePane = new TitlePane();
titlePane.setTitle(dialogPage.getTitle());
titlePane.setImage(dialogPage.getImage());
addMessageMonitor(dialogPage, titlePane);
return titlePane;
} | Create a standard {@link TitlePane} wired to receive messages from the
given dialog page. The title pane will also be configured from the dialog
page's title and icon.
@param dialogPage
to process |
public static JComponent createStandardView(DialogPage dialogPage,
ActionCommand okCommand, ActionCommand cancelCommand) {
adaptPageCompletetoGuarded(dialogPage, okCommand);
return createStandardView(dialogPage, new Object[] { okCommand,
cancelCommand });
} | Construct a complete standard layout for a dialog page. This is a panel
with the title/message area at the top, the dialog page control in the
center, and the command button bar (using the provided ok and cancel
commands) on the bottom. The finishCommand provided will automatically be
wired into the page complete status of the dialog page.
@param dialogPage
to process
@param okCommand
Action command to wire into dialogPage's page complete status
@param cancelCommand
to add to the command button bar
@return created component
@see #createTitlePane(DialogPage)
@see #adaptPageCompletetoGuarded(DialogPage, Guarded) |
public static JComponent createStandardView(DialogPage dialogPage,
Object[] commandGroupMembers) {
JPanel viewPanel = new JPanel(new BorderLayout());
JPanel titlePaneContainer = new JPanel(new BorderLayout());
titlePaneContainer.add(createTitlePane(dialogPage).getControl());
titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
viewPanel.add(titlePaneContainer, BorderLayout.NORTH);
JComponent pageControl = dialogPage.getControl();
GuiStandardUtils.attachDialogBorder(pageControl);
viewPanel.add(pageControl);
viewPanel.add(createButtonBar(commandGroupMembers), BorderLayout.SOUTH);
return viewPanel;
} | Construct a complete standard layout for a dialog page. This is a panel
with the title/message area at the top, the dialog page control in the
center, and the command button bar (using the provided group of commands)
on the bottom. You should have already wired any commands to the page
complete status as needed.
@param dialogPage
to process
@param commandGroupMembers
Array of commands to place in the button bar
@return created component
@see #createTitlePane(DialogPage)
@see #adaptPageCompletetoGuarded(DialogPage, Guarded) |
public static JComponent createButtonBar(Object[] groupMembers) {
CommandGroupFactoryBean commandGroupFactoryBean = new CommandGroupFactoryBean(
null, groupMembers);
// CommandGroup dialogCommandGroup =
// CommandGroup.createCommandGroup(null,
// groupMembers);
CommandGroup dialogCommandGroup = commandGroupFactoryBean
.getCommandGroup();
JComponent buttonBar = dialogCommandGroup.createButtonBar();
GuiStandardUtils.attachDialogBorder(buttonBar);
return buttonBar;
} | Return a standardized row of command buttons.
@param groupMembers
@return button bar |
public static void addMessageMonitor(DialogPage dialogPage,
Messagable monitor) {
dialogPage.addPropertyChangeListener(Messagable.MESSAGE_PROPERTY,
new MessageHandler(monitor));
} | Add a message monitor. Each monitor will have its
{@link Messagable#setMessage(Message)} method called whenever the MESSAGE
property on the dialog page changes.
@param dialogPage
to monitor
@param monitor
to add |
public static void adaptPageCompletetoGuarded(DialogPage dialogPage,
Guarded guarded) {
dialogPage.addPropertyChangeListener(DialogPage.PAGE_COMPLETE_PROPERTY,
new PageCompleteAdapter(guarded));
} | Create an adapter that will monitor the page complete status of the
dialog page and adapt it to operations on the provided Guarded object. If
the page is complete, then the guarded object will be enabled. If this
page is not complete, then the guarded object will be disabled.
@param dialogPage
to monitor
@param guarded
object to adapt |
public Counter build()
{
return new Counter(this.getName(), this.getDescription(), this.getNumShards(),
this.getCounterStatus(), this.getCount(), this.getIndexes(), this.getCreationDateTime());
} | Build method for constructing a new Counter.
@return |
public Object invokeVisit(Object visitor, Object argument) {
Assert.notNull(visitor, "The visitor to visit is required");
// Perform call back on the visitor through reflection.
Method method = getMethod(visitor.getClass(), argument);
if (method == null) {
if (logger.isWarnEnabled()) {
logger.warn("No method found by reflection for visitor class ["
+ visitor.getClass().getName()
+ "] and argument of type ["
+ (argument != null ? argument.getClass().getName()
: "") + "]");
}
return null;
}
try {
Object[] args = null;
if (argument != null) {
args = new Object[] { argument };
}
if (!Modifier.isPublic(method.getModifiers())
&& !method.isAccessible()) {
method.setAccessible(true);
}
return method.invoke(visitor, args);
} catch (Exception ex) {
ReflectionUtils.handleReflectionException(ex);
throw new IllegalStateException("Should never get here");
}
} | Use reflection to call the appropriate <code>visit</code> method on the
provided visitor, passing in the specified argument.
@param visitor
the visitor encapsulating the logic to process the argument
@param argument
the argument to dispatch
@throws IllegalArgumentException
if the visitor parameter is null |
private Method getMethod(Class visitorClass, Object argument) {
ClassVisitMethods visitMethods = (ClassVisitMethods) this.visitorClassVisitMethods
.get(visitorClass);
return visitMethods.getVisitMethod(argument != null ? argument
.getClass() : null);
} | Determines the most appropriate visit method for the given visitor class
and argument. |
public static Class getConcreteCollectionType(Class wrappedType) {
Class class2Create;
if (wrappedType.isArray()) {
if (ClassUtils.isPrimitiveArray(wrappedType)) {
throw new IllegalArgumentException("wrappedType can not be an array of primitive types");
}
class2Create = wrappedType;
}
else if (wrappedType == Collection.class) {
class2Create = ArrayList.class;
}
else if (wrappedType == List.class) {
class2Create = ArrayList.class;
}
else if (wrappedType == Set.class) {
class2Create = HashSet.class;
}
else if (wrappedType == SortedSet.class) {
class2Create = TreeSet.class;
}
else if (Collection.class.isAssignableFrom(wrappedType)) {
if (wrappedType.isInterface()) {
throw new IllegalArgumentException("unable to handle Collection of type [" + wrappedType
+ "]. Do not know how to create a concrete implementation");
}
class2Create = wrappedType;
}
else {
throw new IllegalArgumentException("wrappedType [" + wrappedType + "] must be an array or a Collection");
}
return class2Create;
} | } |
private boolean hasSameStructure() {
Object wrappedCollection = getWrappedValue();
if (wrappedCollection == null) {
return bufferedListModel.size() == 0;
}
else if (wrappedCollection instanceof Object[]) {
Object[] wrappedArray = (Object[])wrappedCollection;
if (wrappedArray.length != bufferedListModel.size()) {
return false;
}
for (int i = 0; i < bufferedListModel.size(); i++) {
if(super.hasValueChanged(wrappedArray[i], bufferedListModel.get(i))) {
return false;
}
}
}
else {
if (((Collection)wrappedCollection).size() != bufferedListModel.size()) {
return false;
}
for (Iterator i = ((Collection)wrappedCollection).iterator(), j = bufferedListModel.iterator(); i.hasNext();) {
if (super.hasValueChanged(i.next(), j.next())) {
return false;
}
}
}
return true;
} | Checks if the structure of the buffered list model is the same as the wrapped
collection. "same structure" is defined as having the same elements in the
same order with the one exception that NULL == empty list. |
private Object updateBufferedListModel(final Object wrappedCollection) {
if (bufferedListModel == null) {
bufferedListModel = createBufferedListModel();
bufferedListModel.addListDataListener(listChangeHandler);
setValue(bufferedListModel);
}
if (wrappedCollection == null) {
bufferedListModel.clear();
}
else {
if (wrappedType.isAssignableFrom(wrappedCollection.getClass())) {
Collection buffer = null;
if (wrappedCollection instanceof Object[]) {
Object[] wrappedArray = (Object[])wrappedCollection;
buffer = Arrays.asList(wrappedArray);
}
else {
buffer = (Collection)wrappedCollection;
}
bufferedListModel.clear();
bufferedListModel.addAll(prepareBackingCollection(buffer));
}
else {
throw new IllegalArgumentException("wrappedCollection must be assignable from " + wrappedType.getName());
}
}
return bufferedListModel;
} | Gets the list value associated with this value model, creating a list
model buffer containing its contents, suitable for manipulation.
@return The list model buffer |
private ApplicationContext loadStartupContext(Class<? extends SplashScreenConfig> startupConfig) {
if(startupConfig == null)
return null;
logger.info("Loading startup context from class ("
+ startupConfig.getName()
+ ")");
return new AnnotationConfigApplicationContext(startupConfig);
} | Returns an application context loaded from the bean definition file at
the given classpath-relative location.
@return An application context loaded from the given location, or null if
{@code startupContextPath} is null or empty. |
private ApplicationContext loadRootApplicationContext(String[] configLocations, MessageSource messageSource) {
final ClassPathXmlApplicationContext applicationContext
= new ClassPathXmlApplicationContext(configLocations, false);
if (splashScreen instanceof MonitoringSplashScreen) {
final ProgressMonitor tracker = ((MonitoringSplashScreen) splashScreen).getProgressMonitor();
applicationContext.addBeanFactoryPostProcessor(
new ProgressMonitoringBeanFactoryPostProcessor(tracker));
}
applicationContext.refresh();
return applicationContext;
} | Returns an {@code ApplicationContext}, loaded from the bean definition
files at the classpath-relative locations specified by
{@code configLocations}.
<p>
If a splash screen has been created, the application context will be
loaded with a bean post processor that will notify the splash screen's
progress monitor as each bean is initialized.
</p>
@param configLocations The classpath-relative locations of the files from
which the application context will be loaded.
@return The main application context, never null. |
private void launchMyRichClient() {
if (startupContext == null) {
displaySplashScreen(rootApplicationContext);
}
final Application application;
try {
application = rootApplicationContext.getBean(Application.class);
}
catch (NoSuchBeanDefinitionException e) {
throw new IllegalArgumentException(
"A single bean definition of type "
+ Application.class.getName()
+ " must be defined in the main application context",
e);
}
try {
// To avoid deadlocks when events fire during initialization of some swing components
// Possible to do: in theory not a single Swing component should be created (=modified) in the launcher thread...
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
application.start();
}
});
}
catch (InterruptedException e) {
logger.warn("Application start interrupted", e);
}
catch (InvocationTargetException e) {
Throwable cause = e.getCause();
throw new IllegalStateException("Application start thrown an exception: " + cause.getMessage(), cause);
}
logger.debug("Launcher thread exiting...");
} | Launches the rich client application. If no startup context has so far
been provided, the main application context will be searched for a splash
screen to display. The main application context will then be searched for
the {@link Application} to be launched. |
private void displaySplashScreen(BeanFactory beanFactory) {
this.splashScreen = beanFactory.getBean(SplashScreen.class);
logger.debug("Displaying application splash screen...");
try
{
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
ApplicationLauncher.this.splashScreen.splash();
}
});
}
catch (Exception e)
{
throw new RuntimeException("EDT threading issue while showing splash screen", e);
}
} | Searches the given bean factory for a {@link SplashScreen} and displays it.
@param beanFactory The bean factory that is expected to contain the
splash screen bean definition. Must not be null.
@throws NullPointerException if {@code beanFactory} is null.
@throws org.springframework.beans.factory.BeanNotOfRequiredTypeException if the bean found under the splash
screen bean name is not a {@link SplashScreen}. |
@Override
public void addConfiguredTab(JTabbedPane tabbedPane, String labelKey, JComponent tabComponent) {
this.getDecoratedComponentFactory().addConfiguredTab(tabbedPane, labelKey, tabComponent);
} | {@inheritDoc} |
@Override
public JLabel createLabel(String labelKey, Object[] arguments) {
return this.getDecoratedComponentFactory().createLabel(labelKey, arguments);
} | {@inheritDoc} |
@Override
public JLabel createLabel(String labelKey, ValueModel[] argumentValueHolders) {
return this.getDecoratedComponentFactory().createLabel(labelKey, argumentValueHolders);
} | {@inheritDoc} |
@Override
public JLabel createLabelFor(String labelKey, JComponent comp) {
return this.getDecoratedComponentFactory().createLabelFor(labelKey, comp);
} | {@inheritDoc} |
@Override
public JLabel createLabelFor(String[] labelKeys, JComponent comp) {
return this.getDecoratedComponentFactory().createLabelFor(labelKeys, comp);
} | {@inheritDoc} |
@Override
public JComponent createLabeledSeparator(String labelKey, Alignment alignment) {
return this.getDecoratedComponentFactory().createLabeledSeparator(labelKey, alignment);
} | {@inheritDoc} |
@Override
public JComboBox createListValueModelComboBox(ValueModel selectedItemValueModel,
ValueModel selectableItemsListHolder, String renderedPropertyPath) {
return this.getDecoratedComponentFactory().createListValueModelComboBox(//
selectedItemValueModel, selectableItemsListHolder, renderedPropertyPath);
} | {@inheritDoc} |
@Override
public JScrollPane createScrollPane(Component view, int vsbPolicy, int hsbPolicy) {
return this.getDecoratedComponentFactory().createScrollPane(view, vsbPolicy, hsbPolicy);
} | {@inheritDoc} |
@Override
public JTabbedPane createTabbedPane() {
// (JAF), 20101206, as explained in
// org.bluebell.richclient.application.support.ApplicationUtils#forceFocusGained tabbed panes usually requires
// focus for themselves, this is a problem that also occurs in BbFocusHighlighter (VLDocking module) as
// explained here: http://www.javalobby.org/java/forums/t43667.html
final JTabbedPane tabbedPane = this.getDecoratedComponentFactory().createTabbedPane();
tabbedPane.setFocusable(Boolean.FALSE);
return tabbedPane;
} | {@inheritDoc} |
@Override
public JComponent createTitledBorderFor(String labelKey, JComponent comp) {
return this.getDecoratedComponentFactory().createTitledBorderFor(labelKey, comp);
} | {@inheritDoc} |
public void keyReleased(KeyEvent e) {
char ch = e.getKeyChar();
if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))
return;
int pos = editor.getCaretPosition();
String str = editor.getText();
if (str.length() == 0)
return;
boolean matchFound = false;
for (int k = 0; k < comboBox.getItemCount(); k++) {
String item = comboBox.getItemAt(k).toString();
if (startsWithIgnoreCase(item, str)) {
comboBox.setSelectedIndex(k);
editor.setText(item);
editor.setCaretPosition(item.length());
editor.moveCaretPosition(pos);
// show popup when the user types
if (comboBox.isDisplayable())
comboBox.setPopupVisible(true);
matchFound = true;
break;
}
}
if (!matchFound) {
// hide popup when there is no match
comboBox.setPopupVisible(false);
}
} | Handle a key release event. See if what they've type so far matches anything in the
selectable items list. If so, then show the popup and select the item. If not, then
hide the popup.
@param e key event |
private boolean startsWithIgnoreCase(String str1, String str2) {
return str1 != null && str2 != null && str1.toUpperCase().startsWith(str2.toUpperCase());
} | See if one string begins with another, ignoring case.
@param str1 The string to test
@param str2 The prefix to test for
@return true if str1 starts with str2, ingnoring case |
private void highlightText(int start) {
editor.setCaretPosition(editor.getText().length());
editor.moveCaretPosition(start);
} | Highlight the text from the given start location to the end of the text.
@param start Starting location to highlight |
public GeneralEmail bcc(String bcc) {
if (bcc != null && bcc.length() > 0) {
return bcc(bcc.split(";"));
} else {
return addParameter("bcc", null);
}
} | ε―ιε°ε. ε€δΈͺε°εδ½Ώη¨';'ει
@param bcc ε―ιε°ε
@return E |
public GeneralEmail cc(String cc) {
if (cc != null && cc.length() > 0) {
cc(cc.split(";"));
} else {
return addParameter("cc", null);
}
return getThis();
} | ζιε°ε. ε€δΈͺε°εδ½Ώη¨';'ει
@param cc ζιε°ε
@return E |
protected boolean shouldEnable( int[] selected ) {
return selected != null && selected.length >= 1 && (requiredCount == -1 || requiredCount == selected.length);
} | Determine if the guarded object should be enabled based on the contents
of the current selection model value.
@param selected The array of selected rows
@return boolean true if the guarded object should be enabled |
@Deprecated
public void addVetoableCommitListener(VetoableCommitListener vetoableCommitListener)
{
if (vetoableCommitListeners == null)
vetoableCommitListeners = new ArrayList<VetoableCommitListener>(5);
vetoableCommitListeners.add(vetoableCommitListener);
} | Adding a vetoableCommitListener might prevent a formModel.commit() but this is not the correct location
to add back-end logic to check for a consistent formObject. Besides this the vetoableCommitListener
doesn't add any other real advantage for our case. Therefor deprecating to prevent wrong usage. |
public static boolean supportsBoundProperties(Class beanClass) {
return PropertyChangePublisher.class.isAssignableFrom(beanClass)
|| ((getNamedPCLAdder(beanClass) != null) && (getNamedPCLRemover(beanClass) != null));
} | Checks and answers whether the given class supports bound properties,
i.e. it provides a pair of bound property event listener registration methods:
<pre>
public void addPropertyChangeListener(String, PropertyChangeListener);
public void removePropertyChangeListener(String, PropertyChangeListener);
</pre>
@param beanClass the class to test
@return true if the class supports bound properties, false otherwise |
public static void addPropertyChangeListener(Object bean, String propertyName, PropertyChangeListener listener) {
Assert.notNull(propertyName, "The property name must not be null.");
Assert.notNull(listener, "The listener must not be null.");
if (bean instanceof PropertyChangePublisher) {
((PropertyChangePublisher)bean).addPropertyChangeListener(propertyName, listener);
}
else {
Class beanClass = bean.getClass();
Method namedPCLAdder = getNamedPCLAdder(beanClass);
if (namedPCLAdder == null)
throw new FatalBeanException("Could not find the bean method"
+ "/npublic void addPropertyChangeListener(String, PropertyChangeListener);/nin bean '" + bean
+ "'");
try {
namedPCLAdder.invoke(bean, new Object[] {propertyName, listener});
}
catch (InvocationTargetException e) {
throw new FatalBeanException("Due to an InvocationTargetException we failed to add "
+ "a named PropertyChangeListener to bean '" + bean + "'", e);
}
catch (IllegalAccessException e) {
throw new FatalBeanException("Due to an IllegalAccessException we failed to add "
+ "a named PropertyChangeListener to bean '" + bean + "'", e);
}
}
} | Adds a named property change listener to the given JavaBean. The bean
must provide the optional support for listening on named properties
as described in section 7.4.5 of the
<a href="http://java.sun.com/products/javabeans/docs/spec.html">Java Bean
Specification</a>. The bean class must provide the method:
<pre>
public void addPropertyChangeListener(String, PropertyChangeListener);
</pre>
@param bean the JavaBean to add a property change handler
@param propertyName the name of the property to be observed
@param listener the listener to add
@throws PropertyNotBindableException
if the property change handler cannot be added successfully |
public static void removePropertyChangeListener(Object bean, String propertyName, PropertyChangeListener listener) {
Assert.notNull(propertyName, "The property name must not be null.");
Assert.notNull(listener, "The listener must not be null.");
if (bean instanceof PropertyChangePublisher) {
((PropertyChangePublisher)bean).removePropertyChangeListener(propertyName, listener);
}
else {
Class beanClass = bean.getClass();
Method namedPCLRemover = getNamedPCLRemover(beanClass);
if (namedPCLRemover == null)
throw new FatalBeanException("Could not find the bean method"
+ "/npublic void removePropertyChangeListener(String, PropertyChangeListener);/nin bean '"
+ bean + "'");
try {
namedPCLRemover.invoke(bean, new Object[] {propertyName, listener});
}
catch (InvocationTargetException e) {
throw new FatalBeanException("Due to an InvocationTargetException we failed to remove "
+ "a named PropertyChangeListener from bean '" + bean + "'", e);
}
catch (IllegalAccessException e) {
throw new FatalBeanException("Due to an IllegalAccessException we failed to remove "
+ "a named PropertyChangeListener from bean '" + bean + "'", e);
}
}
} | Removes a named property change listener to the given JavaBean. The bean
must provide the optional support for listening on named properties
as described in section 7.4.5 of the
<a href="http://java.sun.com/products/javabeans/docs/spec.html">Java Bean
Specification</a>. The bean class must provide the method:
<pre>
public void removePropertyChangeHandler(String, PropertyChangeListener);
</pre>
@param bean the bean to remove the property change listener from
@param propertyName the name of the observed property
@param listener the listener to remove
@throws FatalBeanException
if the property change handler cannot be removed successfully |
private static Method getNamedPCLAdder(Class beanClass) {
try {
return beanClass.getMethod("addPropertyChangeListener", NAMED_PCL_PARAMS);
}
catch (NoSuchMethodException e) {
return null;
}
} | Looks up and returns the method that adds a PropertyChangeListener
for a specified property name to instances of the given class.
@param beanClass the class that provides the adder method
@return the method that adds the PropertyChangeListeners |
public static String createDialogTitle(String appName, String dialogName) {
if (appName != null) {
StringBuffer buf = new StringBuffer(appName);
buf.append(": ");
buf.append(dialogName);
return buf.toString();
}
return dialogName;
} | Return text which conforms to the Look and Feel Design Guidelines for the
title of a dialog : the application name, a colon, then the name of the
specific dialog.
@param dialogName
the short name of the dialog. |
public static JComponent createCommandButtonColumn(JButton[] buttons) {
ButtonStackBuilder builder = new ButtonStackBuilder();
for (int i = 0; i < buttons.length; i++) {
if (i > 0) {
builder.addRelatedGap();
}
builder.addGridded(buttons[i]);
}
return builder.getPanel();
} | Make a vertical row of buttons of equal size, whch are equally spaced,
and aligned on the right.
<P>
The returned component has border spacing only on the left (of the size
recommended by the Look and Feel Design Guidelines). All other spacing
must be applied elsewhere ; usually, this will only mean that the
dialog's top-level panel should use {@link #buildStandardBorder}.
@param buttons
contains <code>JButton</code> objects.
@return A column displaying the buttons vertically. |
public static void equalizeSizes(JComponent[] components) {
Dimension targetSize = new Dimension(0, 0);
for (int i = 0; i < components.length; i++) {
JComponent comp = components[i];
Dimension compSize = comp.getPreferredSize();
double width = Math.max(targetSize.getWidth(), compSize.getWidth());
double height = Math.max(targetSize.getHeight(), compSize.getHeight());
targetSize.setSize(width, height);
}
setSizes(components, targetSize);
} | Sets the items in <code>aComponents</code> to the same size.
Sets each component's preferred and maximum sizes. The actual size is
determined by the layout manager, which adjusts for locale-specific
strings and customized fonts. (See this <a
href="http://java.sun.com/products/jlf/ed2/samcode/prefere.html">Sun doc
</a> for more information.)
@param components
contains <code>JComponent</code> objects. |
public static JTextArea createStandardTextArea(String text) {
JTextArea result = new JTextArea(text);
return configureStandardTextArea(result);
} | An alternative to multi-line labels, for the presentation of several
lines of text, and for which the line breaks are determined solely by the
control.
@param text
text that does not contain newline characters or html.
@return <code>JTextArea</code> which is not editable, has improved
spacing over the supplied default (placing
{@link UIConstants#ONE_SPACE}on the left and right), and which
wraps lines on word boundarie. |
public static JTextArea createStandardTextAreaHardNewLines(String text) {
JTextArea result = new JTextArea(text);
result.setEditable(false);
result.setMargin(new Insets(0, UIConstants.ONE_SPACE, 0, UIConstants.ONE_SPACE));
return result;
} | An alternative to multi-line labels, for the presentation of several
lines of text, and for which line breaks are determined solely by
<code>aText</code>, and not by the control.
@param text
the text to be placed in the text area.
@return <code>JTextArea</code> which is not editable and has improved
spacing over the supplied default (placing
{@link UIConstants#ONE_SPACE}on the left and right). |
public static void truncateLabelIfLong(JLabel label) {
String originalText = label.getText();
if (originalText.length() > UIConstants.MAX_LABEL_LENGTH) {
label.setToolTipText(originalText);
String truncatedText = originalText.substring(0, UIConstants.MAX_LABEL_LENGTH) + "...";
label.setText(truncatedText);
}
} | If aLabel has text which is longer than MAX_LABEL_LENGTH, then truncate
the label text and place an ellipsis at the end; the original text is
placed in a tooltip.
This is particularly useful for displaying file names, whose length can
vary widely between deployments.
@param label
The label to truncate if length() > MAX_LABEL_LENGTH. |
public static JTextArea textAreaAsLabel(JTextArea textArea) {
// Turn on word wrap
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
// Perform the other changes to complete the look
textComponentAsLabel(textArea);
return textArea;
} | This will allow selection and copy to work but still retain the label
look |
public static JTextComponent textComponentAsLabel(JTextComponent textcomponent) {
// Make the text component non editable
textcomponent.setEditable(false);
// Make the text area look like a label
textcomponent.setBackground((Color)UIManager.get("Label.background"));
textcomponent.setForeground((Color)UIManager.get("Label.foreground"));
textcomponent.setBorder(null);
return textcomponent;
} | This will allow selection and copy to work but still retain the label
look |
public static void createDebugBorder(JComponent c, Color color) {
if (color == null) {
color = Color.BLACK;
}
c.setBorder(BorderFactory.createLineBorder(color));
} | Useful debug function to place a colored, line border around a component
for layout management debugging.
@param c
the component
@param color
the border color |
public void renderMessage(JComponent component) {
if (component instanceof JTextComponent) {
((JTextComponent)component).setText(getMessage());
}
else if (component instanceof JLabel) {
JLabel label = (JLabel)component;
label.setText(LabelUtils.htmlBlock(getMessage()));
label.setIcon(getIcon());
}
else {
throw new IllegalArgumentException("Unsupported component type " + component);
}
} | Renders this message on the given GUI component. This implementation only
supports components of type {@link javax.swing.text.JTextComponent} or {@link javax.swing.JLabel}.
@throws IllegalArgumentException if {@code component} is not a {@link javax.swing.text.JTextComponent}
or a {@link javax.swing.JLabel}. |
public Icon getIcon() {
if (severity == null) {
return null;
}
try {
IconSource iconSource = ValkyrieRepository.getInstance().getApplicationConfig().iconSource();
return iconSource.getIcon("severity." + severity.getLabel());
}
catch (NoSuchImageResourceException e) {
return null;
}
} | Returns the icon associated with this instance's severity. The icon is
expected to be retrieved using a key {@code severity.<SEVERITY_LABEL>}.
@return The icon associated with this instance's severity, or null if the
instance has no specified severity, or the icon could not be found.
@see Severity#getLabel()
@see IconSource#getIcon(String) |
@Override
public Binding bindControl(JComponent control, String formPropertyPath) {
return new OverlayableBinding(super.bindControl(control, formPropertyPath));
} | {@inheritDoc} |
@Override
public Binding bindControl(JComponent control, String formPropertyPath, @SuppressWarnings("rawtypes") Map context) {
return new OverlayableBinding(super.bindControl(control, formPropertyPath, context));
} | {@inheritDoc} |
@Override
public Binding createBinding(@SuppressWarnings("rawtypes") Class controlType, String formPropertyPath) {
return new OverlayableBinding(super.createBinding(controlType, formPropertyPath));
} | {@inheritDoc} |
public void configure(AbstractButton button, AbstractCommand command, CommandFaceDescriptor faceDescriptor) {
Assert.notNull(button, "The button to configure cannot be null.");
Assert.notNull(faceDescriptor, "The command face descriptor cannot be null.");
faceDescriptor.configureLabel(button);
faceDescriptor.configureIcon(button);
faceDescriptor.configureColor(button);
button.setToolTipText(faceDescriptor.getCaption());
} | {@inheritDoc} |
protected void handleAnchorActivated(HyperlinkEvent e, String anchor) {
((JTextPane)e.getSource()).scrollToReference(anchor);
} | Called when the user clicks on an anchor e.g. <br>
<a href="#top">Go to Top</a>.
<p>
This default implementation will scroll the source pane so that the anchor
target becomes visible. |
protected void handleUrlActivated(HyperlinkEvent e, URL url) {
try {
Desktop.getDesktop().browse(url.toURI());
} catch (Exception ex) {
throw new ApplicationException("Error handling URL " + url, ex);
}
} | Called when the user clicks on a URL link e.g. <br>
<a href="http://some.site">Go to Some Site</a>.
<p>
This default implementation attempt to open the link in the systems
default browser. |
@Bean
public WidgetViewDescriptor itemView() {
return new WidgetViewDescriptor("itemView", new WidgetProvider<Widget>() {
@Override
public Widget getWidget() {
return itemDataEditor();
}
});
} | views |
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan) {
return append(component, colSpan, rowSpan, 0.0, 0.0);
} | Appends the given component to the end of the current line, using the
default insets and no expansion
@param component the component to add to the current line
@param colSpan the number of columns to span
@param rowSpan the number of rows to span
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, boolean expandX, boolean expandY) {
return append(component, colSpan, rowSpan, expandX, expandY, defaultInsets);
} | Appends the given component to the end of the current line, using the
default insets
@param component the component to add to the current line
@param colSpan the number of columns to span
@param rowSpan the number of rows to span
@param expandX should the component "grow" horrizontally?
@param expandY should the component "grow" vertically?
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, boolean expandX, boolean expandY,
Insets insets) {
if (expandX && expandY)
return append(component, colSpan, rowSpan, 1.0, 1.0, insets);
else if (expandX)
return append(component, colSpan, rowSpan, 1.0, 0.0, insets);
else if (expandY)
return append(component, colSpan, rowSpan, 0.0, 1.0, insets);
else
return append(component, colSpan, rowSpan, 0.0, 0.0, insets);
} | Appends the given component to the end of the current line
@param component the component to add to the current line
@param colSpan the number of columns to span
@param rowSpan the number of rows to span
@param expandX should the component "grow" horrizontally?
@param expandY should the component "grow" vertically?
@param insets the insets to use for this component
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, double xweight, double yweight) {
return append(component, colSpan, rowSpan, xweight, yweight, defaultInsets);
} | Appends the given component to the end of the current line, using the
default insets
@param component the component to add to the current line
@param colSpan the number of columns to span
@param rowSpan the number of rows to span
@param xweight the "growth weight" horrizontally
@param yweight the "growth weight" horrizontally
@return "this" to make it easier to string together append calls
@see GridBagConstraints#weightx
@see GridBagConstraints#weighty |
public GridBagLayoutBuilder append(Component component, int colSpan, int rowSpan, double xweight, double yweight,
Insets insets) {
return append(component, getCurrentCol(), getCurrentRow(), colSpan, rowSpan, xweight, yweight, insets);
} | Appends the given component to the end of the current line
@param component the component to add to the current line
@param colSpan the number of columns to span
@param rowSpan the number of rows to span
@param xweight the "growth weight" horrizontally
@param yweight the "growth weight" horrizontally
@param insets the insets to use for this component
@return "this" to make it easier to string together append calls
@see GridBagConstraints#weightx
@see GridBagConstraints#weighty |
public GridBagLayoutBuilder appendLabeledField(String propertyName, final JComponent field,
LabelOrientation labelOrientation) {
return appendLabeledField(propertyName, field, labelOrientation, 1);
} | Appends a label and field to the end of the current line.
<p />
The label will be to the left of the field, and be right-justified.
<br />
The field will "grow" horizontally as space allows.
<p />
@param propertyName the name of the property to create the controls for
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder appendLabeledField(String propertyName, final JComponent field,
LabelOrientation labelOrientation, int colSpan, int rowSpan, boolean expandX, boolean expandY) {
JLabel label = createLabel(propertyName);
return appendLabeledField(label, field, labelOrientation, colSpan, rowSpan, expandX, expandY);
} | Appends a label and field to the end of the current line.<p />
The label will be to the left of the field, and be right-justified.<br />
The field will "grow" horizontally as space allows.<p />
@param propertyName the name of the property to create the controls for
@param colSpan the number of columns the field should span
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder appendLabeledField(final JLabel label, final JComponent field,
LabelOrientation labelOrientation, int colSpan, int rowSpan, boolean expandX, boolean expandY) {
label.setLabelFor(field);
final int col = getCurrentCol();
final int row = getCurrentRow();
final Insets insets = getDefaultInsets();
if (labelOrientation == LabelOrientation.LEFT || labelOrientation == null) {
label.setHorizontalAlignment(SwingConstants.RIGHT);
append(label, col, row, 1, 1, false, expandY, insets);
append(field, col + 1, row, colSpan, rowSpan, expandX, expandY, insets);
}
else if (labelOrientation == LabelOrientation.RIGHT) {
label.setHorizontalAlignment(SwingConstants.LEFT);
append(field, col, row, colSpan, rowSpan, expandX, expandY, insets);
append(label, col + colSpan, row, 1, rowSpan, false, expandY, insets);
}
else if (labelOrientation == LabelOrientation.TOP) {
label.setHorizontalAlignment(SwingConstants.LEFT);
append(label, col, row, colSpan, 1, expandX, false, insets);
append(field, col, row + 1, colSpan, rowSpan, expandX, expandY, insets);
}
else if (labelOrientation == LabelOrientation.BOTTOM) {
label.setHorizontalAlignment(SwingConstants.LEFT);
append(field, col, row, colSpan, rowSpan, expandX, expandY, insets);
append(label, col, row + rowSpan, colSpan, 1, expandX, false, insets);
}
return this;
} | Appends a label and field to the end of the current line.<p />
The label will be to the left of the field, and be right-justified.<br />
The field will "grow" horizontally as space allows.<p />
@param label the label to associate and layout with the field
@param colSpan the number of columns the field should span
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder append(Component component, int x, int y, int colSpan, int rowSpan, double xweight,
double yweight, Insets insets) {
final java.util.List rowList = getRow(y);
ensureCapacity(rowList, Math.max(x, maxCol) + 1);
final int col = bypassPlaceholders(rowList, x);
insertPlaceholdersIfNeeded(rowSpan, y, col, component, colSpan);
final GridBagConstraints gbc = createGridBagConstraint(col, y, colSpan, rowSpan, xweight, yweight, insets);
rowList.set(col, new Item(component, gbc));
if (LOG.isDebugEnabled())
LOG.debug(getDebugString(component, gbc));
// keep track of the largest column this has seen...
this.maxCol = Math.max(this.maxCol, col);
currentCol = col + colSpan;
return this;
} | Appends the given component to the end of the current line
@param component the component to add to the current line
@param x the column to put the component
@param y the row to put the component
@param colSpan the number of columns to span
@param rowSpan the number of rows to span
@param xweight the "growth weight" horrizontally
@param yweight the "growth weight" horrizontally
@param insets the insets to use for this component
@return "this" to make it easier to string together append calls
@see GridBagConstraints#weightx
@see GridBagConstraints#weighty |
public GridBagLayoutBuilder appendLabel(JLabel label, int colSpan) {
return append(label, colSpan, 1, false, false);
} | Appends the given label to the end of the current line. The label does
not "grow."
@param label the label to append
@param colSpan the number of columns to span
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder appendRightLabel(String labelKey, int colSpan) {
final JLabel label = createLabel(labelKey);
label.setHorizontalAlignment(SwingConstants.RIGHT);
return appendLabel(label, colSpan);
} | Appends a right-justified label to the end of the given line, using the
provided string as the key to look in the
{@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
bundle for the text to use.
@param labelKey the key into the message bundle; if not found the key is used
as the text to display
@param colSpan the number of columns to span
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder appendLeftLabel(String labelKey, int colSpan) {
final JLabel label = createLabel(labelKey);
label.setHorizontalAlignment(SwingConstants.LEFT);
return appendLabel(label, colSpan);
} | Appends a left-justified label to the end of the given line, using the
provided string as the key to look in the
{@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
bundle for the text to use.
@param labelKey the key into the message bundle; if not found the key is used
as the text to display
@param colSpan the number of columns to span
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder appendField(Component component, int colSpan) {
return append(component, colSpan, 1, true, false);
} | Appends the given component to the end of the current line. The component
will "grow" horizontally as space allows.
@param component the item to append
@param colSpan the number of columns to span
@return "this" to make it easier to string together append calls |
public GridBagLayoutBuilder appendSeparator(String labelKey) {
if (this.currentRowList.size() > 0) {
nextLine();
}
final JComponent separator = getComponentFactory().createLabeledSeparator(labelKey);
return append(separator, 1, 1, true, false).nextLine();
} | Appends a seperator (usually a horizonal line) using the provided string
as the key to look in the
{@link #setComponentFactory(ComponentFactory) ComponentFactory's}message
bundle for the text to put along with the seperator. Has an implicit
{@link #nextLine()}before and after it.
@return "this" to make it easier to string together append calls |
public JPanel getPanel() {
if (this.currentRowList.size() > 0) {
this.rows.add(this.currentRowList);
}
final JPanel panel = this.showGuidelines ? new GridBagLayoutDebugPanel() : new JPanel(new GridBagLayout());
final int lastRowIndex = this.rows.size() - 1;
for (int currentRowIndex = 0; currentRowIndex <= lastRowIndex; currentRowIndex++) {
final java.util.List row = getRow(currentRowIndex);
addRow(row, currentRowIndex, lastRowIndex, panel);
}
return panel;
} | Creates and returns a JPanel with all the given components in it, using
the "hints" that were provided to the builder.
@return a new JPanel with the components laid-out in it |
public void fire(String methodName, Object arg) {
if (listeners != EMPTY_OBJECT_ARRAY) {
fireEventByReflection(methodName, new Object[] { arg });
}
} | Invokes the method with the given name and a single parameter on each of the listeners
registered with this list.
@param methodName the name of the method to invoke.
@param arg the single argument to pass to each invocation.
@throws IllegalArgumentException if no method with the given name and a single formal
parameter exists on the listener class managed by this list helper. |
public void fire(String methodName, Object arg1, Object arg2) {
if (listeners != EMPTY_OBJECT_ARRAY) {
fireEventByReflection(methodName, new Object[] { arg1, arg2 });
}
} | Invokes the method with the given name and two parameters on each of the listeners
registered with this list.
@param methodName the name of the method to invoke.
@param arg1 the first argument to pass to each invocation.
@param arg2 the second argument to pass to each invocation.
@throws IllegalArgumentException if no method with the given name and 2 formal parameters
exists on the listener class managed by this list helper. |
public void fire(String methodName, Object[] args) {
if (listeners != EMPTY_OBJECT_ARRAY) {
fireEventByReflection(methodName, args);
}
} | Invokes the method with the given name and number of formal parameters on each of the
listeners registered with this list.
@param methodName the name of the method to invoke.
@param args an array of arguments to pass to each invocation.
@throws IllegalArgumentException if no method with the given name and number of formal
parameters exists on the listener class managed by this list helper. |
public boolean add(Object listener) {
if (listener == null) {
return false;
}
checkListenerType(listener);
synchronized (this) {
if (listeners == EMPTY_OBJECT_ARRAY) {
listeners = new Object[] { listener };
}
else {
int listenersLength = listeners.length;
for (int i = 0; i < listenersLength; i++) {
if (listeners[i] == listener) {
return false;
}
}
Object[] tmp = new Object[listenersLength + 1];
tmp[listenersLength] = listener;
System.arraycopy(listeners, 0, tmp, 0, listenersLength);
listeners = tmp;
}
}
return true;
} | Adds <code>listener</code> to the list of registered listeners. If
listener is already registered this method will do nothing.
@param listener The event listener to be registered.
@return true if the listener was registered, false if {@code listener} was null or it is
already registered with this list helper.
@throws IllegalArgumentException if {@code listener} is not assignable to the class of
listener that this instance manages. |
public boolean addAll(Object[] listenersToAdd) {
if (listenersToAdd == null) {
return false;
}
boolean changed = false;
for (int i = 0; i < listenersToAdd.length; i++) {
if (add(listenersToAdd[i])) {
changed = true;
}
}
return changed;
} | Adds all the given listeners to the list of registered listeners. If any of the elements in
the array are null or are listeners that are already registered, they will not be registered
again.
@param listenersToAdd The collection of listeners to be added. May be null.
@return true if the list of registered listeners changed as a result of attempting to
register the given collection of listeners.
@throws IllegalArgumentException if any of the listeners in the given collection are of a
type that is not assignable to the class of listener that this instance manages. |
public void remove(Object listener) {
checkListenerType(listener);
synchronized (this) {
if (listeners == EMPTY_OBJECT_ARRAY)
return;
int listenersLength = listeners.length;
int index = 0;
for (; index < listenersLength; index++) {
if (listeners[index] == listener) {
break;
}
}
if (index < listenersLength) {
if (listenersLength == 1) {
listeners = EMPTY_OBJECT_ARRAY;
}
else {
Object[] tmp = new Object[listenersLength - 1];
System.arraycopy(listeners, 0, tmp, 0, index);
if (index < tmp.length) {
System.arraycopy(listeners, index + 1, tmp, index, tmp.length - index);
}
listeners = tmp;
}
}
}
} | Removes <code>listener</code> from the list of registered listeners.
@param listener The listener to be removed.
@throws IllegalArgumentException if {@code listener} is null or not assignable to the class
of listener that is maintained by this instance. |
private void fireEventByReflection(String methodName, Object[] eventArgs) {
Method eventMethod = (Method)methodCache.get(new MethodCacheKey(listenerClass, methodName, eventArgs.length));
Object[] listenersCopy = listeners;
for (int i = 0; i < listenersCopy.length; i++) {
try {
eventMethod.invoke(listenersCopy[i], eventArgs);
}
catch (InvocationTargetException e) {
throw new EventBroadcastException("Exception thrown by listener", e.getCause());
}
catch (IllegalAccessException e) {
throw new EventBroadcastException("Unable to invoke listener", e);
}
}
} | Invokes the method with the given name on each of the listeners registered with this list
helper. The given arguments are passed to each method invocation.
@param methodName The name of the method to be invoked on the listeners.
@param eventArgs The arguments that will be passed to each method invocation. The number
of arguments is also used to determine the method to be invoked.
@throws EventBroadcastException if an error occurs invoking the event method on any of the
listeners. |
public Object toArray() {
if (listeners == EMPTY_OBJECT_ARRAY)
return Array.newInstance(listenerClass, 0);
Object[] listenersCopy = listeners;
Object copy = Array.newInstance(listenerClass, listenersCopy.length);
System.arraycopy(listenersCopy, 0, copy, 0, listenersCopy.length);
return copy;
} | Returns an object which is a copy of the collection of listeners registered with this instance.
@return A copy of the registered listeners array, never null. |
public boolean isDependentOn(String propertyName) {
boolean dependent = false;
if( getConstraint() instanceof PropertyConstraint ) {
dependent = ((PropertyConstraint) getConstraint()).isDependentOn( propertyName );
}
return super.isDependentOn( propertyName ) || dependent;
} | Determine if this rule is dependent on the given property name. True if either the
direct poperty (from the contstructor) is equal to the given name, or if the "if
true" predicate is a PropertyConstraint and it is dependent on the given property.
@return true if this rule is dependent on the given property |
public boolean allTrue(Constraint constraint) {
WhileTrueController controller = new WhileTrueController(this, constraint);
run(controller);
return controller.allTrue();
} | {@inheritDoc} |
public ElementGenerator findAll(final Constraint constraint) {
return new AbstractElementGenerator(this) {
public void run(final Closure closure) {
getWrappedTemplate().run(new IfBlock(constraint, closure));
}
};
} | {@inheritDoc} |
public Object findFirst(Constraint constraint, Object defaultIfNoneFound) {
ObjectFinder finder = new ObjectFinder(this, constraint);
run(finder);
return (finder.foundObject() ? finder.getFoundObject() : defaultIfNoneFound);
} | {@inheritDoc} |
protected void reset() {
if (this.status == ProcessStatus.STOPPED || this.status == ProcessStatus.COMPLETED) {
if (this.runOnce) {
throw new UnsupportedOperationException("This process template can only safely execute once; "
+ "instantiate a new instance per request");
}
this.status = ProcessStatus.RESET;
}
} | Reset the ElementGenerator if possible.
@throws UnsupportedOperationException if this ElementGenerator was a
runOnce instance. |
public Object call(Object argument) {
Object result = argument;
Iterator it = iterator();
while (it.hasNext()) {
Closure f = (Closure) it.next();
result = f.call(result);
}
return result;
} | {@inheritDoc} |
public void buildInitialLayout(PageLayoutBuilder pageLayout) {
for (Iterator iter = _viewDescriptors.iterator(); iter.hasNext();) {
String viewDescriptorId = (String) iter.next();
pageLayout.addView(viewDescriptorId);
}
} | Builds the initial page layout by iterating the
collection of view descriptors. |
public void commit() {
for (Iterator i = listeners.iterator(); i.hasNext();) {
((CommitTriggerListener) i.next()).commit();
}
} | Triggers a commit event. |
public void revert() {
for (Iterator i = listeners.iterator(); i.hasNext();) {
((CommitTriggerListener) i.next()).revert();
}
} | Triggers a revert event. |
private void internalSetParent(CommandRegistry parentRegistry) {
if (!ObjectUtils.nullSafeEquals(this.parent, parentRegistry)) {
if (this.parent != null) {
this.parent.removeCommandRegistryListener(this);
}
this.parent = parentRegistry;
if (this.parent != null) {
this.parent.addCommandRegistryListener(this);
}
}
} | This method is provided as a private helper so that it can be called by the constructor,
instead of the constructor having to call the public overridable setParent method. |
public ActionCommand getActionCommand(String commandId) {
if (logger.isDebugEnabled()) {
logger.debug("Attempting to retrieve ActionCommand with id ["
+ commandId
+ "] from the command registry.");
}
Object command = getCommand(commandId, ActionCommand.class);
return (ActionCommand) command;
} | {@inheritDoc}
@deprecated |
public CommandGroup getCommandGroup(String groupId) {
if (logger.isDebugEnabled()) {
logger.debug("Attempting to retrieve command group with id ["
+ groupId
+ "] from the command registry.");
}
Object command = getCommand(groupId, CommandGroup.class);
return (CommandGroup) command;
} | {@inheritDoc}
@deprecated |
public boolean containsActionCommand(String commandId) {
if (commandMap.containsKey(commandId)) {
return true;
}
if (parent != null) {
return parent.containsActionCommand(commandId);
}
return false;
} | {@inheritDoc}
@deprecated |
public boolean containsCommandGroup(String groupId) {
if (commandMap.get(groupId) instanceof CommandGroup) {
return true;
}
if (parent != null) {
return parent.containsCommandGroup(groupId);
}
return false;
} | {@inheritDoc}
@deprecated |
public void registerCommand(AbstractCommand command) {
Assert.notNull(command, "Command cannot be null.");
Assert.isTrue(command.getId() != null, "A command must have an identifier to be placed in a registry.");
Object previousCommand = this.commandMap.put(command.getId(), command);
if (previousCommand != null && logger.isWarnEnabled()) {
logger.info("The command ["
+ previousCommand
+ "] was overwritten in the registry with the command ["
+ command
+ "]");
}
if (command instanceof CommandGroup) {
((CommandGroup) command).setCommandRegistry(this);
}
if (logger.isDebugEnabled()) {
logger.debug("Command registered '" + command.getId() + "'");
}
fireCommandRegistered(command);
} | {@inheritDoc} |
protected void fireCommandRegistered(AbstractCommand command) {
Assert.notNull(command, "command");
if (commandRegistryListeners.isEmpty()) {
return;
}
CommandRegistryEvent event = new CommandRegistryEvent(this, command);
for (Iterator i = commandRegistryListeners.iterator(); i.hasNext();) {
((CommandRegistryListener)i.next()).commandRegistered(event);
}
} | Fires a 'commandRegistered' {@link CommandRegistryEvent} for the given command to all
registered listeners.
@param command The command that has been registered. Must not be null.
@throws IllegalArgumentException if {@code command} is null. |
public void setTargetableActionCommandExecutor(String commandId, ActionCommandExecutor executor) {
Assert.notNull(commandId, "commandId");
TargetableActionCommand command
= (TargetableActionCommand) getCommand(commandId, TargetableActionCommand.class);
if (command != null) {
command.setCommandExecutor(executor);
}
} | {@inheritDoc} |
public void addCommandRegistryListener(CommandRegistryListener listener) {
if (logger.isDebugEnabled()) {
logger.debug("Adding command registry listener " + listener);
}
commandRegistryListeners.add(listener);
} | {@inheritDoc} |
public void removeCommandRegistryListener(CommandRegistryListener listener) {
if (logger.isDebugEnabled()) {
logger.debug("Removing command registry listener " + listener);
}
commandRegistryListeners.remove(listener);
} | {@inheritDoc} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.