idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
7,200
public void setLargeIcon ( Icon icon ) { Icon old = null ; if ( largeIconInfo == CommandButtonIconInfo . BLANK_ICON_INFO ) { if ( icon != null ) { setLargeIconInfo ( new CommandButtonIconInfo ( icon ) ) ; } } else { old = largeIconInfo . getIcon ( ) ; this . largeIconInfo . setIcon ( icon ) ; } firePropertyChange ( LARGE_ICON_PROPERTY , old , icon ) ; }
Sets the main default large icon for the command .
7,201
public void configureIconInfo ( AbstractButton button , boolean useLargeIcons ) { Assert . notNull ( button , "button" ) ; if ( useLargeIcons ) { largeIconInfo . configure ( button ) ; } else { iconInfo . configure ( button ) ; } }
Configures the given button with the icon information contained in this descriptor .
7,202
public void configureColor ( AbstractButton button ) { Assert . notNull ( button , "button" ) ; if ( foreground != null ) { button . setForeground ( foreground ) ; } if ( background != null ) { button . setBackground ( background ) ; } }
Configures the given button with colours for background and foreground if available .
7,203
public void configure ( AbstractButton button , AbstractCommand command , CommandButtonConfigurer configurer ) { Assert . notNull ( button , "button" ) ; Assert . notNull ( configurer , "configurer" ) ; configurer . configure ( button , command , this ) ; }
Configures the given button and command using the given configurer and the information contained in this instance .
7,204
public void configure ( Action action ) { Assert . notNull ( action , "The swing action to configure is required" ) ; action . putValue ( Action . NAME , getText ( ) ) ; action . putValue ( Action . MNEMONIC_KEY , new Integer ( getMnemonic ( ) ) ) ; action . putValue ( Action . SMALL_ICON , getIcon ( ) ) ; action . putValue ( "LargeIcon" , getLargeIcon ( ) ) ; action . putValue ( Action . ACCELERATOR_KEY , getAccelerator ( ) ) ; action . putValue ( Action . SHORT_DESCRIPTION , caption ) ; action . putValue ( Action . LONG_DESCRIPTION , description ) ; }
Configures the given action with the information contained in this descriptor .
7,205
private Image loadImage ( Resource path ) throws IOException { URL url = path . getURL ( ) ; if ( url == null ) { logger . warn ( "Unable to locate splash screen in classpath at: " + path ) ; return null ; } return Toolkit . getDefaultToolkit ( ) . createImage ( url ) ; }
Load image from path .
7,206
protected Component createContentPane ( ) { Image image = getImage ( ) ; if ( image != null ) { return new ImageCanvas ( image ) ; } return null ; }
Returns a component that displays an image in a canvas .
7,207
public static boolean loadPageLayoutData ( DockingManager manager , String pageId , Perspective perspective ) { manager . beginLoadLayoutData ( ) ; try { if ( isValidLayout ( manager , pageId , perspective ) ) { String pageLayout = MessageFormat . format ( PAGE_LAYOUT , pageId , perspective . getId ( ) ) ; manager . loadLayoutDataFrom ( pageLayout ) ; return true ; } else { manager . loadLayoutData ( ) ; return false ; } } catch ( Exception e ) { manager . loadLayoutData ( ) ; return false ; } }
Loads a the previously saved layout for the current page . If no previously persisted layout exists for the given page the built in default layout is used .
7,208
public static void savePageLayoutData ( DockingManager manager , String pageId , String perspectiveId ) { manager . saveLayoutDataAs ( MessageFormat . format ( PAGE_LAYOUT , pageId , perspectiveId ) ) ; }
Saves the current page layout .
7,209
public final void setViewDescriptor ( ViewDescriptor viewDescriptor ) { Assert . notNull ( viewDescriptor , "viewDescriptor" ) ; setId ( viewDescriptor . getId ( ) ) ; setLabel ( viewDescriptor . getShowViewCommandLabel ( ) ) ; setIcon ( viewDescriptor . getIcon ( ) ) ; setCaption ( viewDescriptor . getCaption ( ) ) ; this . viewDescriptor = viewDescriptor ; }
Sets the descriptor for the view that is to be opened by this command object . This command object will be assigned the id label icon and caption from the given view descriptor .
7,210
public Perspective getCurrentPerspective ( ) { String key = MessageFormat . format ( CURRENT_PERSPECTIVE_KEY , new Object [ ] { pageName } ) ; String id = prefs . get ( key , DEFAULT_PERSPECTIVE_KEY ) ; Iterator it = perspectives . iterator ( ) ; while ( it . hasNext ( ) ) { Perspective perspective = ( Perspective ) it . next ( ) ; if ( id . equals ( perspective . getId ( ) ) ) { return perspective ; } } return NullPerspective . NULL_PERSPECTIVE ; }
Returns the current perspective or the NullPerspective instance if no current perspective is defined .
7,211
public void setMessage ( String message ) { this . message = message ; if ( errorMessage == null ) { logger . debug ( "Setting status bar message to \"" + message + "\"" ) ; messageLabel . setText ( this . message ) ; } }
Sets the message text to be displayed on the status bar .
7,212
protected void registerPostProcessorAction ( String actionId ) { if ( postProcessorActionIds . contains ( actionId ) ) { throw new IllegalArgumentException ( "Post-processor Action '" + actionId + "' is already registered" ) ; } postProcessorActionIds . add ( actionId ) ; }
Register a post - processor action . The action id specified must not conflict with any other action registered . Subclasses that provide additional post - processor actions MUST call this method to register them .
7,213
protected void updateControlledObject ( Authorizable controlledObject , boolean authorized ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "setAuthorized( " + authorized + ") on: " + controlledObject ) ; } controlledObject . setAuthorized ( authorized ) ; runPostProcessorActions ( controlledObject , authorized ) ; }
Update a controlled object based on the given authorization state .
7,214
protected void runPostProcessorActions ( Object controlledObject , boolean authorized ) { String actions = getPostProcessorActionsToRun ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Run post-processors actions: " + actions ) ; } String [ ] actionIds = StringUtils . commaDelimitedListToStringArray ( actions ) ; for ( int i = 0 ; i < actionIds . length ; i ++ ) { doPostProcessorAction ( actionIds [ i ] , controlledObject , authorized ) ; } }
Run all the requested post - processor actions .
7,215
protected void doPostProcessorAction ( String actionId , Object controlledObject , boolean authorized ) { if ( VISIBLE_TRACKS_AUTHORIZED_ACTION . equals ( actionId ) ) { setVisibilityOnControlledObject ( controlledObject , authorized ) ; } }
Post - process a controlled object after its authorization state has been updated . Subclasses that override this method MUST ensure that this method is called id they do not process the given action id .
7,216
private void setVisibilityOnControlledObject ( Object controlledObject , boolean authorized ) { try { Method method = controlledObject . getClass ( ) . getMethod ( "setVisible" , new Class [ ] { boolean . class } ) ; method . invoke ( controlledObject , new Object [ ] { new Boolean ( authorized ) } ) ; } catch ( NoSuchMethodException ignored ) { System . out . println ( "NO setVisible method on object: " + controlledObject ) ; } catch ( IllegalAccessException ignored ) { logger . error ( "Could not call setVisible" , ignored ) ; } catch ( InvocationTargetException ignored ) { logger . error ( "Could not call setVisible" , ignored ) ; } }
Set the visible property on a controlled action according to the provided authorization .
7,217
public Object removeControlledObject ( Authorizable object ) { Object removed = null ; for ( Iterator iter = controlledObjects . iterator ( ) ; iter . hasNext ( ) ; ) { WeakReference ref = ( WeakReference ) iter . next ( ) ; Authorizable controlledObject = ( Authorizable ) ref . get ( ) ; if ( controlledObject == null ) { iter . remove ( ) ; } else if ( controlledObject . equals ( object ) ) { removed = controlledObject ; iter . remove ( ) ; } } return removed ; }
Remove an object from our controlled set .
7,218
public void afterPropertiesSet ( ) throws Exception { String [ ] actions = StringUtils . commaDelimitedListToStringArray ( getPostProcessorActionsToRun ( ) ) ; for ( int i = 0 ; i < actions . length ; i ++ ) { if ( ! postProcessorActionIds . contains ( actions [ i ] ) ) { throw new IllegalArgumentException ( "Requested post-processor action '" + actions [ i ] + "' is not registered." ) ; } } }
Validate our configuration .
7,219
protected void setActivePage ( ApplicationPage page ) { getPage ( ) . getControl ( ) ; loadLayoutData ( page . getId ( ) ) ; ( ( JideApplicationPage ) getPage ( ) ) . updateShowViewCommands ( ) ; }
Sets the active page by loading that page s components and applying the layout . Also updates the show view command menu to list the views within the page .
7,220
public void setForm ( AbstractForm form ) { this . form = form ; if ( getId ( ) == null ) { setId ( form . getId ( ) ) ; } }
Set the inner form that needs decorating .
7,221
protected int [ ] indicesOf ( final Object itemSet ) { int [ ] ret = null ; if ( itemSet instanceof Collection ) { Collection collection = ( Collection ) itemSet ; ret = new int [ collection . size ( ) ] ; int i = 0 ; for ( Iterator iter = collection . iterator ( ) ; iter . hasNext ( ) ; i ++ ) { ret [ i ] = indexOf ( iter . next ( ) ) ; } } else if ( itemSet == null ) { ret = new int [ 0 ] ; } else if ( itemSet . getClass ( ) . isArray ( ) ) { Object [ ] items = ( Object [ ] ) itemSet ; ret = new int [ items . length ] ; for ( int i = 0 ; i < items . length ; i ++ ) { ret [ i ] = indexOf ( items [ i ] ) ; } } else { throw new IllegalArgumentException ( "itemSet must be eithe an Array or a Collection" ) ; } return ret ; }
Return an array of indices in the selectableItems for each element in the provided set . The set can be either a Collection or an Array .
7,222
protected boolean arraysEqual ( Object [ ] a1 , Object [ ] a2 ) { if ( a1 != null && a2 != null && a1 . length == a2 . length ) { for ( int i = 0 ; i < a1 . length ; i ++ ) { if ( ! equalByComparator ( a1 [ i ] , a2 [ i ] ) ) { return false ; } } return true ; } else if ( a1 == null && a2 == null ) { return true ; } return false ; }
Compare two arrays for equality using the configured comparator .
7,223
protected boolean collectionsEqual ( Collection a1 , Collection a2 ) { if ( a1 != null && a2 != null && a1 . size ( ) == a2 . size ( ) ) { Iterator iterA1 = a1 . iterator ( ) ; Iterator iterA2 = a2 . iterator ( ) ; while ( iterA1 . hasNext ( ) ) { if ( ! equalByComparator ( iterA1 . next ( ) , iterA2 . next ( ) ) ) { return false ; } } } else if ( a1 == null && a2 == null ) { return true ; } return false ; }
Compare two collections for equality using the configured comparator . Element order must be the same for the collections to compare equal .
7,224
public void addGuarded ( Guarded newGuarded , int mask ) { this . guardedEntries . put ( newGuarded , new Integer ( mask ) ) ; newGuarded . setEnabled ( stateMatchesMask ( getFormModelState ( ) , mask ) ) ; }
Adds a guarded object to be guarded by this FormGuard
7,225
public boolean removeGuarded ( Guarded toRemove ) { Object mask = this . guardedEntries . remove ( toRemove ) ; return mask != null ; }
Removes the guarded object from the management of this FormGuard .
7,226
public static DockableState fixVLDockingBug ( DockingDesktop dockingDesktop , Dockable dockable ) { Assert . notNull ( dockingDesktop , "dockingDesktop" ) ; Assert . notNull ( dockable , "dockable" ) ; final DockingContext dockingContext = dockingDesktop . getContext ( ) ; final DockKey dockKey = dockable . getDockKey ( ) ; DockableState dockableState = dockingDesktop . getDockableState ( dockable ) ; final Boolean thisFixApplies = ( dockingContext . getDockableByKey ( dockKey . getKey ( ) ) != null ) ; if ( ( thisFixApplies ) && ( dockableState == null ) ) { dockingDesktop . registerDockable ( dockable ) ; dockableState = dockingDesktop . getDockableState ( dockable ) ; Assert . notNull ( dockableState , "dockableState" ) ; } return dockableState ; }
Fixes an VLDocking bug consisting on dockables that belong to a docking desktop have no state on it .
7,227
public static String activationKey ( String key , Boolean active ) { Assert . notNull ( key , "key" ) ; Assert . notNull ( active , "active" ) ; final int index = key . lastIndexOf ( VLDockingUtils . DOT ) ; final String overlay = active ? VLDockingUtils . ACTIVE_INFIX : VLDockingUtils . INACTIVE_INFIX ; return key ; }
Transforms a UI object key into an activation aware key name .
7,228
protected void handleLoginEvent ( LoginEvent event ) { ApplicationSessionInitializer asi = getApplicationSessionInitializer ( ) ; if ( asi != null ) { asi . initializeUser ( ) ; Map < String , Object > userAttributes = asi . getUserAttributes ( ) ; if ( userAttributes != null ) { setUserAttributes ( userAttributes ) ; } } Authentication auth = ( Authentication ) event . getSource ( ) ; propertyChangeSupport . firePropertyChange ( USER , null , auth ) ; }
When a correct login occurs read all relevant userinformation into session .
7,229
protected void handleLogoutEvent ( LogoutEvent event ) { clearUser ( ) ; Authentication auth = ( Authentication ) event . getSource ( ) ; propertyChangeSupport . firePropertyChange ( USER , auth , null ) ; }
When a logout occurs remove all user related information from the session .
7,230
public void initializeSession ( ) { ApplicationSessionInitializer asi = getApplicationSessionInitializer ( ) ; if ( asi != null ) { asi . initializeSession ( ) ; Map < String , Object > sessionAttributes = asi . getSessionAttributes ( ) ; if ( sessionAttributes != null ) { setSessionAttributes ( sessionAttributes ) ; } propertyChangeSupport . firePropertyChange ( SESSION_ATTRIBUTES , null , sessionAttributes ) ; } }
Initialize the session attributes .
7,231
public Object getUserAttribute ( String key , Object defaultValue ) { Object attributeValue = this . userAttributes . get ( key ) ; if ( attributeValue == null ) attributeValue = defaultValue ; return attributeValue ; }
Get a value from the user attributes map .
7,232
public Object getSessionAttribute ( String key , Object defaultValue ) { Object attributeValue = this . sessionAttributes . get ( key ) ; if ( attributeValue == null ) attributeValue = defaultValue ; return attributeValue ; }
Get a value from the session attributes map .
7,233
public Object getAttribute ( String key , Object defaultValue ) { Object attributeValue = getUserAttribute ( key , null ) ; if ( attributeValue != null ) return attributeValue ; attributeValue = getSessionAttribute ( key , null ) ; if ( attributeValue != null ) return attributeValue ; return defaultValue ; }
Get a value from the user OR session attributes map .
7,234
private void installPrePackagedUIManagerDefaults ( ) { try { UIManager . setLookAndFeel ( UIManager . getSystemLookAndFeelClassName ( ) ) ; UIManager . put ( "Tree.line" , "Angled" ) ; UIManager . put ( "Tree.leafIcon" , null ) ; UIManager . put ( "Tree.closedIcon" , null ) ; UIManager . put ( "Tree.openIcon" , null ) ; UIManager . put ( "Tree.rightChildIndent" , new Integer ( 10 ) ) ; } catch ( Exception e ) { throw new ApplicationException ( "Unable to set defaults" , e ) ; } }
Initializes the UIManager defaults to values based on recommended best - practices user interface design . This should generally be called once by an initializing application class .
7,235
public void addPropertyChangeListener ( PropertyChangeListener listener ) { if ( listener instanceof PropertyChangeListenerProxy ) { PropertyChangeListenerProxy proxy = ( PropertyChangeListenerProxy ) listener ; addPropertyChangeListener ( proxy . getPropertyName ( ) , ( PropertyChangeListener ) proxy . getListener ( ) ) ; } else { if ( listeners == null ) { listeners = new EventListenerList ( ) ; } listeners . add ( PropertyChangeListener . class , listener ) ; } }
Add a PropertyChangeListener to the listener list . The listener is registered for all properties .
7,236
public void addPropertyChangeListener ( String propertyName , PropertyChangeListener listener ) { if ( children == null ) { children = new HashMap ( ) ; } PropertyChangeSupport child = ( PropertyChangeSupport ) children . get ( propertyName ) ; if ( child == null ) { child = new PropertyChangeSupport ( source ) ; children . put ( propertyName , child ) ; } child . addPropertyChangeListener ( listener ) ; }
Add a PropertyChangeListener for a specific property . The listener will be invoked only when a call on firePropertyChange names that specific property .
7,237
public void removePropertyChangeListener ( String propertyName , PropertyChangeListener listener ) { if ( children == null ) { return ; } PropertyChangeSupport child = ( PropertyChangeSupport ) children . get ( propertyName ) ; if ( child == null ) { return ; } child . removePropertyChangeListener ( listener ) ; }
Remove a PropertyChangeListener for a specific property .
7,238
public void firePropertyChange ( String propertyName , Object oldValue , Object newValue ) { firePropertyChange ( new PropertyChangeEvent ( source , propertyName , oldValue , newValue ) ) ; }
Report a bound property update to any registered listeners . No event is fired if old and new are equal and non - null .
7,239
public void firePropertyChange ( PropertyChangeEvent evt ) { Object oldValue = evt . getOldValue ( ) ; Object newValue = evt . getNewValue ( ) ; if ( ObjectUtils . nullSafeEquals ( oldValue , newValue ) ) { return ; } String propertyName = evt . getPropertyName ( ) ; PropertyChangeSupport child = null ; if ( children != null ) { if ( children != null && propertyName != null ) { child = ( PropertyChangeSupport ) children . get ( propertyName ) ; } } if ( listeners != null ) { Object [ ] listenerList = listeners . getListenerList ( ) ; for ( int i = 0 ; i <= listenerList . length - 2 ; i += 2 ) { if ( listenerList [ i ] == PropertyChangeListener . class ) { ( ( PropertyChangeListener ) listenerList [ i + 1 ] ) . propertyChange ( evt ) ; } } } if ( child != null ) { child . firePropertyChange ( evt ) ; } }
Fire an existing PropertyChangeEvent to any registered listeners . No event is fired if the given event s old and new values are equal and non - null .
7,240
public boolean hasListeners ( String propertyName ) { if ( listeners != null && listeners . getListenerCount ( PropertyChangeListener . class ) > 0 ) { return true ; } if ( children != null ) { PropertyChangeSupport child = ( PropertyChangeSupport ) children . get ( propertyName ) ; if ( child != null ) { return child . hasListeners ( propertyName ) ; } } return false ; }
Check if there are any listeners for a specific property .
7,241
protected void broadcastAuthentication ( Authentication authentication ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "BROADCAST authentication: token=" + authentication ) ; currentAuthentication = authentication ; final Iterator iter = getBeansToUpdate ( AuthenticationAware . class ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ( ( AuthenticationAware ) iter . next ( ) ) . setAuthenticationToken ( authentication ) ; } }
Broadcast an authentication event to all the AuthenticationAware beans .
7,242
protected void broadcastLogin ( Authentication authentication ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "BROADCAST login: token=" + authentication ) ; final Iterator iter = getBeansToUpdate ( LoginAware . class ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ( ( LoginAware ) iter . next ( ) ) . userLogin ( authentication ) ; } }
Broadcast a Login event to all the LoginAware beans .
7,243
protected void broadcastLogout ( Authentication authentication ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "BROADCAST logout: token=" + authentication ) ; final Iterator iter = getBeansToUpdate ( LoginAware . class ) . iterator ( ) ; while ( iter . hasNext ( ) ) { ( ( LoginAware ) iter . next ( ) ) . userLogout ( authentication ) ; } }
Broadcast a Logout event to all the LoginAware beans .
7,244
protected List getBeansToUpdate ( Class beanType ) { final ApplicationContext ac = getApplicationContext ( ) ; final List listeners = new ArrayList ( ) ; if ( ac != null ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Constructing list of beans to notify; bean type=" + beanType . getName ( ) ) ; final Map map = ac . getBeansOfType ( beanType , false , true ) ; if ( logger . isDebugEnabled ( ) ) logger . debug ( "bean map: " + map ) ; listeners . addAll ( map . values ( ) ) ; listeners . addAll ( getNonSingletonListeners ( beanType ) ) ; } if ( logger . isDebugEnabled ( ) ) logger . debug ( "List of beans to notify:" + listeners ) ; return listeners ; }
Construct the list of all the beans we need to update .
7,245
protected List getNonSingletonListeners ( Class beanType ) { final List listeners = new ArrayList ( ) ; synchronized ( nonSingletonListeners ) { for ( Iterator iter = nonSingletonListeners . iterator ( ) ; iter . hasNext ( ) ; ) { final Object bean = ( ( WeakReference ) iter . next ( ) ) . get ( ) ; if ( bean == null ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "REMOVED garbage collected AuthorizationAware non-singleton from list." ) ; iter . remove ( ) ; } else if ( beanType . isAssignableFrom ( bean . getClass ( ) ) ) { listeners . add ( bean ) ; } } } return listeners ; }
Get the list of non - singleton beans we have registered that still exist . Update our registration list if any have been GC ed . Only return beans of the requested type .
7,246
protected void addToNonSingletonListeners ( final Object bean ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "Adding Authentication/LoginAware bean to list of non-singleton listeners: bean='" + bean ) ; nonSingletonListeners . add ( new WeakReference ( bean ) ) ; }
Add a non - singleton bean instance to our list for later notification .
7,247
public void addPage ( DialogPage page ) { pages . add ( page ) ; if ( autoConfigureChildPages ) { String id = getId ( ) + "." + page . getId ( ) ; ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . applicationObjectConfigurer ( ) . configure ( page , id ) ; } }
Adds a DialogPage to the list of pages managed by this CompositeDialogPage .
7,248
public DialogPage addForm ( Form form ) { DialogPage page = createDialogPage ( form ) ; addPage ( page ) ; return page ; }
Adds a new page to the list of pages managed by this CompositeDialogPage . The page is created by wrapping the form page in a FormBackedDialogPage .
7,249
public void addPages ( DialogPage [ ] pages ) { for ( int i = 0 ; i < pages . length ; i ++ ) { addPage ( pages [ i ] ) ; } }
Adds an array DialogPage to the list of pages managed by this CompositeDialogPage .
7,250
public void setActivePage ( DialogPage activePage ) { DialogPage oldPage = this . activePage ; Assert . isTrue ( activePage == null || pages . contains ( activePage ) ) ; if ( oldPage == activePage ) { return ; } this . activePage = activePage ; updateMessage ( ) ; if ( oldPage != null ) { updatePageLabels ( oldPage ) ; } if ( activePage != null ) { updatePageLabels ( activePage ) ; } }
Sets the active page of this CompositeDialogPage .
7,251
protected void prepareDialogPage ( DialogPage page ) { page . addPropertyChangeListener ( childChangeHandler ) ; JComponent c = page . getControl ( ) ; GuiStandardUtils . attachDialogBorder ( c ) ; Dimension size = c . getPreferredSize ( ) ; if ( size . width > largestPageWidth ) { largestPageWidth = size . width ; } if ( size . height > largestPageHeight ) { largestPageHeight = size . height ; } }
Prepare a dialog page - Add our property listeners and configure the control s look .
7,252
protected void prepareValueModel ( ValueModel valueModel ) { if ( valueModel instanceof BufferedValueModel ) { ( ( BufferedValueModel ) valueModel ) . setCommitTrigger ( commitTrigger ) ; } if ( valueModel instanceof DirtyTrackingValueModel ) { ( ( DirtyTrackingValueModel ) valueModel ) . addPropertyChangeListener ( DIRTY_PROPERTY , childStateChangeHandler ) ; } }
Prepare the provided value model for use in this form model .
7,253
private void setDeliverValueChangeEvents ( boolean enable ) { formObjectHolder . setDeliverValueChangeEvents ( enable ) ; for ( Object o : mediatingValueModels . values ( ) ) { FormModelMediatingValueModel valueModel = ( FormModelMediatingValueModel ) o ; valueModel . setDeliverValueChangeEvents ( enable ) ; } }
Disconnect view from data in MediatingValueModels
7,254
public void addChild ( HierarchicalFormModel child ) { Assert . notNull ( child , "child" ) ; if ( child . getParent ( ) == this ) return ; Assert . isTrue ( child . getParent ( ) == null , "Child form model '" + child + "' already has a parent" ) ; child . setParent ( this ) ; children . add ( child ) ; child . addPropertyChangeListener ( DIRTY_PROPERTY , childStateChangeHandler ) ; child . addPropertyChangeListener ( COMMITTABLE_PROPERTY , childStateChangeHandler ) ; if ( child . isDirty ( ) ) { dirtyValueAndFormModels . add ( child ) ; dirtyUpdated ( ) ; } }
Add child to this FormModel . Dirty and committable changes are forwarded to parent model .
7,255
public void removeChild ( HierarchicalFormModel child ) { Assert . notNull ( child , "child" ) ; child . removeParent ( ) ; children . remove ( child ) ; child . removePropertyChangeListener ( DIRTY_PROPERTY , childStateChangeHandler ) ; child . removePropertyChangeListener ( COMMITTABLE_PROPERTY , childStateChangeHandler ) ; if ( dirtyValueAndFormModels . remove ( child ) ) dirtyUpdated ( ) ; }
Remove a child FormModel . Dirty and committable listeners are removed . When child was dirty remove the formModel from the dirty list and update the dirty state .
7,256
protected ValueModel createValueModel ( String formProperty ) { Assert . notNull ( formProperty , "formProperty" ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Creating " + ( buffered ? "buffered" : "" ) + " value model for form property '" + formProperty + "'." ) ; } return buffered ? new BufferedValueModel ( propertyAccessStrategy . getPropertyValueModel ( formProperty ) ) : propertyAccessStrategy . getPropertyValueModel ( formProperty ) ; }
Creates a new value mode for the the given property . Usually delegates to the underlying property access strategy but subclasses may provide alternative value model creation strategies .
7,257
public void registerPropertyConverter ( String propertyName , Converter toConverter , Converter fromConverter ) { DefaultConversionService propertyConversionService = ( DefaultConversionService ) propertyConversionServices . get ( propertyName ) ; propertyConversionService . addConverter ( toConverter ) ; propertyConversionService . addConverter ( fromConverter ) ; }
Register converters for a given property name .
7,258
protected void dirtyUpdated ( ) { boolean dirty = isDirty ( ) ; if ( hasChanged ( oldDirty , dirty ) ) { oldDirty = dirty ; firePropertyChange ( DIRTY_PROPERTY , ! dirty , dirty ) ; } }
Fires the necessary property change event for changes to the dirty property . Must be called whenever the value of dirty is changed .
7,259
protected void readOnlyUpdated ( ) { boolean localReadOnly = isReadOnly ( ) ; if ( hasChanged ( oldReadOnly , localReadOnly ) ) { oldReadOnly = localReadOnly ; firePropertyChange ( READONLY_PROPERTY , ! localReadOnly , localReadOnly ) ; } }
Fires the necessary property change event for changes to the readOnly property . Must be called whenever the value of readOnly is changed .
7,260
protected void enabledUpdated ( ) { boolean enabled = isEnabled ( ) ; if ( hasChanged ( oldEnabled , enabled ) ) { oldEnabled = enabled ; firePropertyChange ( ENABLED_PROPERTY , ! enabled , enabled ) ; } }
Fires the necessary property change event for changes to the enabled property . Must be called whenever the value of enabled is changed .
7,261
protected void committableUpdated ( ) { boolean committable = isCommittable ( ) ; if ( hasChanged ( oldCommittable , committable ) ) { oldCommittable = committable ; firePropertyChange ( COMMITTABLE_PROPERTY , ! committable , committable ) ; } }
Fires the necessary property change event for changes to the committable property . Must be called whenever the value of committable is changed .
7,262
public ObservableList createBoundListModel ( String formProperty ) { final ConfigurableFormModel formModel = ( ( ConfigurableFormModel ) getFormModel ( ) ) ; ValueModel valueModel = formModel . getValueModel ( formProperty ) ; if ( ! ( valueModel instanceof BufferedCollectionValueModel ) ) { valueModel = new BufferedCollectionValueModel ( ( ( ( DefaultFormModel ) formModel ) . getFormObjectPropertyAccessStrategy ( ) ) . getPropertyValueModel ( formProperty ) , formModel . getFieldMetadata ( formProperty ) . getPropertyType ( ) ) ; formModel . add ( formProperty , valueModel ) ; } return ( ObservableList ) valueModel . getValue ( ) ; }
This method will most likely move over to FormModel
7,263
public Binding createBinding ( String propertyPath , String binderId , Map context ) { Assert . notNull ( context , "Context must not be null" ) ; Binder binder = ( ( SwingBinderSelectionStrategy ) getBinderSelectionStrategy ( ) ) . getIdBoundBinder ( binderId ) ; Binding binding = binder . bind ( getFormModel ( ) , propertyPath , context ) ; interceptBinding ( binding ) ; return binding ; }
Create a binding based on a specific binder id .
7,264
public static Goro from ( final IBinder binder ) { if ( binder instanceof GoroService . GoroBinder ) { return ( ( GoroService . GoroBinder ) binder ) . goro ( ) ; } throw new IllegalArgumentException ( "Cannot get Goro from " + binder ) ; }
Gives access to Goro instance that is provided by a service .
7,265
public static Goro createWithDelegate ( final Executor delegateExecutor ) { GoroImpl goro = new GoroImpl ( ) ; goro . queues . setDelegateExecutor ( delegateExecutor ) ; return goro ; }
Creates a new Goro instance which uses the specified executor to delegate tasks .
7,266
private void addCustomGridded ( AbstractButton button ) { builder . getLayout ( ) . appendRow ( this . rowSpec ) ; builder . getLayout ( ) . addGroupedRow ( builder . getRow ( ) ) ; button . putClientProperty ( "jgoodies.isNarrow" , Boolean . TRUE ) ; builder . add ( button ) ; builder . nextRow ( ) ; }
Handle the custom RowSpec .
7,267
private void loadData ( ) { contacts . add ( makeContact ( "Larry" , "Streepy" , "123 Some St." , "Apt. #26C" , "New York" , "NY" , "10010" , ContactType . BUSINESS , "Lorem ipsum..." ) ) ; contacts . add ( makeContact ( "Keith" , "Donald" , "456 WebFlow Rd." , "2" , "Cooltown" , "NY" , "10001" , ContactType . BUSINESS , "Lorem ipsum..." ) ) ; contacts . add ( makeContact ( "Steve" , "Brothers" , "10921 The Other Street" , "" , "Denver" , "CO" , "81234-2121" , ContactType . PERSONAL , "Lorem ipsum..." ) ) ; contacts . add ( makeContact ( "Carlos" , "Mencia" , "4321 Comedy Central" , "" , "Hollywood" , "CA" , "91020" , ContactType . PERSONAL , "Lorem ipsum..." ) ) ; contacts . add ( makeContact ( "Jim" , "Jones" , "1001 Another Place" , "" , "Dallas" , "TX" , "71212" , ContactType . PERSONAL , "Lorem ipsum..." ) ) ; contacts . add ( makeContact ( "Jenny" , "Jones" , "1001 Another Place" , "" , "Dallas" , "TX" , "75201" , ContactType . PERSONAL , "Lorem ipsum..." ) ) ; contacts . add ( makeContact ( "Greg" , "Jones" , "9 Some Other Place" , "Apt. 12D" , "Chicago" , "IL" , "60601" , ContactType . PERSONAL , "Lorem ipsum..." ) ) ; }
Load our initial data .
7,268
private Contact makeContact ( String first , String last , String address1 , String address2 , String city , String state , String zip , ContactType contactType , String memo ) { Contact contact = new Contact ( ) ; contact . setId ( nextId ++ ) ; contact . setContactType ( contactType ) ; contact . setFirstName ( first ) ; contact . setLastName ( last ) ; contact . setMemo ( memo ) ; Address address = contact . getAddress ( ) ; address . setAddress1 ( address1 ) ; address . setAddress2 ( address2 ) ; address . setCity ( city ) ; address . setState ( state ) ; address . setZip ( zip ) ; contact . setTodoItems ( getTodoItemList ( ) ) ; return contact ; }
Make a Contact object with the given data .
7,269
public void execute ( ) { Iterator it = memberList . iterator ( ) ; while ( it . hasNext ( ) ) { GroupMember member = ( GroupMember ) it . next ( ) ; member . getCommand ( ) . execute ( ) ; } }
Executes all the members of this group .
7,270
public JComponent createButtonBar ( Size minimumButtonSize ) { return createButtonBar ( minimumButtonSize , GuiStandardUtils . createTopAndBottomBorder ( UIConstants . TWO_SPACES ) ) ; }
Create a button bar with buttons for all the commands in this group . Adds a border top and bottom of 2 spaces .
7,271
public JComponent createButtonStack ( final Size minimumButtonSize ) { return createButtonStack ( minimumButtonSize , GuiStandardUtils . createLeftAndRightBorder ( UIConstants . TWO_SPACES ) ) ; }
Create a button stack with buttons for all the commands . Adds a border left and right of 2 spaces .
7,272
protected void addCommandsToGroupContainer ( final GroupContainerPopulator groupContainerPopulator ) { final Iterator members = getMemberList ( ) . iterator ( ) ; while ( members . hasNext ( ) ) { final GroupMember member = ( GroupMember ) members . next ( ) ; if ( member . getCommand ( ) instanceof CommandGroup ) { member . fill ( groupContainerPopulator , getButtonFactory ( ) , getPullDownMenuButtonConfigurer ( ) , Collections . EMPTY_LIST ) ; } else { member . fill ( groupContainerPopulator , getButtonFactory ( ) , getDefaultButtonConfigurer ( ) , Collections . EMPTY_LIST ) ; } } groupContainerPopulator . onPopulated ( ) ; }
Create a container with the given GroupContainerPopulator which will hold the members of this group .
7,273
public SecurityController getSecurityController ( String id ) { SecurityController sc = ( SecurityController ) securityControllerMap . get ( id ) ; if ( sc == null ) { try { sc = applicationContext . getBean ( id , SecurityController . class ) ; } catch ( NoSuchBeanDefinitionException e ) { sc = getFallbackSecurityController ( ) ; } } return sc ; }
Get the security controller for the given id . If the id is registered in our map then return the registered controller . If not then try to obtain a bean with the given id if it implements the SecurityController interface .
7,274
public Object call ( Object comparable1 , Object comparable2 ) { int result = COMPARATOR . compare ( comparable1 , comparable2 ) ; if ( result < 0 ) { return comparable1 ; } else if ( result > 0 ) { return comparable2 ; } return comparable1 ; }
Return the minimum of two Comparable objects .
7,275
protected JComponent getInnerComponent ( JComponent component ) { if ( component instanceof JScrollPane ) { return getInnerComponent ( ( JComponent ) ( ( JScrollPane ) component ) . getViewport ( ) . getView ( ) ) ; } if ( component instanceof HasInnerComponent ) { return getInnerComponent ( ( ( HasInnerComponent ) component ) . getInnerComponent ( ) ) ; } return component ; }
Check for JScrollPane .
7,276
public String getHeader ( ) { if ( this . header == null ) { if ( this . headerKeys == null ) { this . headerKeys = new String [ 2 ] ; this . headerKeys [ 0 ] = getPropertyName ( ) + ".header" ; this . headerKeys [ 1 ] = getPropertyName ( ) ; } this . header = ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . messageResolver ( ) . getMessage ( new DefaultMessageSourceResolvable ( this . headerKeys , null , this . headerKeys [ this . headerKeys . length - 1 ] ) ) ; } return "" . equals ( this . header ) ? " " : this . header ; }
Returns the header to be used as column title . If no explicit header was set the headerKeys are used to fetch a message from the available resources .
7,277
protected void fill ( GroupContainerPopulator container , Object factory , CommandButtonConfigurer configurer , List previousButtons ) { container . addSeparator ( ) ; }
Asks the given container populator to add a separator to its underlying container .
7,278
public static < T extends Callable < ? > & Parcelable > Intent taskIntent ( final Context context , final T task ) { return taskIntent ( context , Goro . DEFAULT_QUEUE , task ) ; }
Create an intent that contains a task that should be scheduled on a default queue .
7,279
public static void bind ( final Context context , final ServiceConnection connection ) { Intent serviceIntent = new Intent ( context , GoroService . class ) ; if ( context . startService ( serviceIntent ) == null ) { throw new GoroException ( "Service " + GoroService . class + " does not seem to be included to your manifest file" ) ; } boolean bound = context . bindService ( serviceIntent , connection , 0 ) ; if ( ! bound ) { throw new GoroException ( "Cannot bind to GoroService though this component seems to " + "be registered in the app manifest" ) ; } }
Bind to Goro service . This method will start the service and then bind to it .
7,280
public void configure ( Object object , String objectName ) { if ( object == null ) { logger . debug ( "object to be configured is null" ) ; return ; } Assert . notNull ( objectName , "objectName" ) ; if ( object instanceof TitleConfigurable ) { configureTitle ( ( TitleConfigurable ) object , objectName ) ; } if ( object instanceof LabelConfigurable ) { configureLabel ( ( LabelConfigurable ) object , objectName ) ; } if ( object instanceof ColorConfigurable ) { configureColor ( ( ColorConfigurable ) object , objectName ) ; } if ( object instanceof CommandLabelConfigurable ) { configureCommandLabel ( ( CommandLabelConfigurable ) object , objectName ) ; } if ( object instanceof DescriptionConfigurable ) { configureDescription ( ( DescriptionConfigurable ) object , objectName ) ; } if ( object instanceof ImageConfigurable ) { configureImage ( ( ImageConfigurable ) object , objectName ) ; } if ( object instanceof IconConfigurable ) { configureIcon ( ( IconConfigurable ) object , objectName ) ; } if ( object instanceof CommandIconConfigurable ) { configureCommandIcons ( ( CommandIconConfigurable ) object , objectName ) ; } if ( object instanceof Secured ) { configureSecurityController ( ( Secured ) object , objectName ) ; } }
Configures the given object according to the interfaces that it implements .
7,281
protected void configureCommandIcons ( CommandIconConfigurable configurable , String objectName ) { Assert . notNull ( configurable , "configurable" ) ; Assert . notNull ( objectName , "objectName" ) ; setIconInfo ( configurable , objectName , false ) ; setIconInfo ( configurable , objectName , true ) ; }
Sets the icons of the given object .
7,282
public Authentication getAuthentication ( ) { String username = getValueModel ( LoginDetails . PROPERTY_USERNAME , String . class ) . getValue ( ) ; String password = getValueModel ( LoginDetails . PROPERTY_PASSWORD , String . class ) . getValue ( ) ; return new UsernamePasswordAuthenticationToken ( username , password ) ; }
Get an Authentication token that contains the current username and password .
7,283
protected JComponent createFormControl ( ) { TableFormBuilder formBuilder = new TableFormBuilder ( getBindingFactory ( ) ) ; usernameField = formBuilder . add ( LoginDetails . PROPERTY_USERNAME ) [ 1 ] ; formBuilder . row ( ) ; passwordField = formBuilder . addPasswordField ( LoginDetails . PROPERTY_PASSWORD ) [ 1 ] ; return formBuilder . getForm ( ) ; }
Construct the form with the username and password fields .
7,284
public void setActivePage ( DialogPage page ) { if ( settingSelection ) { return ; } try { settingSelection = true ; super . setActivePage ( page ) ; if ( page != null ) { Tab tab = ( Tab ) page2tab . get ( page ) ; tabbedPaneView . selectTab ( tab ) ; } } finally { settingSelection = false ; } }
Sets the active page of this TabbedDialogPage . This method will also select the tab wich displays the new active page .
7,285
protected void init ( ) { FormModel model = createFormModel ( ) ; if ( getId ( ) == null ) formId = model . getId ( ) ; if ( model instanceof ValidatingFormModel ) { ValidatingFormModel validatingFormModel = ( ValidatingFormModel ) model ; setFormModel ( validatingFormModel ) ; } else { throw new IllegalArgumentException ( "Unsupported form model implementation " + formModel ) ; } getApplicationConfig ( ) . applicationObjectConfigurer ( ) . configure ( this , getId ( ) ) ; }
Hook called when constructing the Form .
7,286
private void putPropertyConstraint ( PropertyConstraint constraint ) { And and = new And ( ) ; and . add ( constraint ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Putting constraint for property '" + constraint . getPropertyName ( ) + "', constraint -> [" + constraint + "]" ) ; } PropertyConstraint compoundConstraint = new CompoundPropertyConstraint ( and ) ; propertiesConstraints . put ( constraint . getPropertyName ( ) , compoundConstraint ) ; orderedConstraints . add ( compoundConstraint ) ; }
Put a constraint into the collection . Store it in the map under the property name and add it to the ordered list .
7,287
public void add ( String propertyName , Constraint [ ] valueConstraints ) { add ( new PropertyValueConstraint ( propertyName , all ( valueConstraints ) ) ) ; }
Adds a value constraint for the specified property .
7,288
public JComponent [ ] add ( Binding binding , String attributes ) { return addBinding ( binding , attributes , getLabelAttributes ( ) ) ; }
Adds the field binding to the form .
7,289
public JComponent [ ] addSelector ( String fieldName , Constraint filter , String attributes ) { Map context = new HashMap ( ) ; context . put ( ComboBoxBinder . FILTER_KEY , filter ) ; return addBinding ( getBindingFactory ( ) . createBinding ( JComboBox . class , fieldName ) , attributes , getLabelAttributes ( ) ) ; }
Adds the field to the form by using a selector component .
7,290
public JComponent [ ] addInScrollPane ( String fieldName , String attributes ) { return addInScrollPane ( createDefaultBinding ( fieldName ) , attributes ) ; }
Adds the field to the form by using the default binding . The component will be placed inside a scrollpane .
7,291
public JComponent addSeparator ( String text , String attributes ) { JComponent separator = getComponentFactory ( ) . createLabeledSeparator ( text ) ; getLayoutBuilder ( ) . cell ( separator , attributes ) ; return separator ; }
Adds a labeled separator to the form
7,292
protected Object [ ] getSourceValues ( ) { Object [ ] values = new Object [ sourceValueModels . length ] ; for ( int i = 0 ; i < values . length ; i ++ ) { values [ i ] = sourceValueModels [ i ] . getValue ( ) ; } return values ; }
Convenience method to extract values from all sourceValueModels that influence the derived value .
7,293
public void setFrameIcon ( Icon newIcon ) { Icon oldIcon = getFrameIcon ( ) ; titleLabel . setIcon ( newIcon ) ; firePropertyChange ( "frameIcon" , oldIcon , newIcon ) ; }
Sets a new frame icon .
7,294
public void setTitle ( String newText ) { String oldText = getTitle ( ) ; titleLabel . setText ( newText ) ; firePropertyChange ( "title" , oldText , newText ) ; }
Sets a new title text .
7,295
public void setToolBar ( JToolBar newToolBar ) { JToolBar oldToolBar = getToolBar ( ) ; if ( oldToolBar == newToolBar ) { return ; } if ( oldToolBar != null ) { headerPanel . remove ( oldToolBar ) ; } if ( newToolBar != null ) { newToolBar . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 0 , 0 ) ) ; headerPanel . add ( newToolBar , BorderLayout . EAST ) ; } updateHeader ( ) ; firePropertyChange ( "toolBar" , oldToolBar , newToolBar ) ; }
Sets a new tool bar in the header .
7,296
public void setContent ( Component newContent ) { Component oldContent = getContent ( ) ; if ( hasContent ( ) ) { remove ( oldContent ) ; } add ( newContent , BorderLayout . CENTER ) ; firePropertyChange ( "content" , oldContent , newContent ) ; }
Sets a new panel content ; replaces any existing content if existing .
7,297
public void setSelected ( boolean newValue ) { boolean oldValue = isSelected ( ) ; isSelected = newValue ; updateHeader ( ) ; firePropertyChange ( "selected" , oldValue , newValue ) ; }
This panel draws its title bar differently if it is selected which may be used to indicate to the user that this panel has the focus or should get more attention than other simple internal frames .
7,298
private void updateHeader ( ) { gradientPanel . setBackground ( getHeaderBackground ( ) ) ; gradientPanel . setOpaque ( isSelected ( ) ) ; titleLabel . setForeground ( getTextForeground ( isSelected ( ) ) ) ; headerPanel . repaint ( ) ; }
Updates the header .
7,299
protected Color getTextForeground ( boolean selected ) { Color c = UIManager . getColor ( selected ? "SimpleInternalFrame.activeTitleForeground" : "SimpleInternalFrame.inactiveTitleForeground" ) ; if ( c != null ) { return c ; } return UIManager . getColor ( selected ? "InternalFrame.activeTitleForeground" : "Label.foreground" ) ; }
Determines and answers the header s text foreground color . Tries to lookup a special color from the L&amp ; F . In case it is absent it uses the standard internal frame forground .