idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
7,100
public PropertyConstraint gteProperty ( String propertyName , String otherPropertyName ) { return valueProperties ( propertyName , GreaterThanEqualTo . instance ( ) , otherPropertyName ) ; }
Apply a greater than or equal to constraint to two properties .
7,101
public PropertyConstraint ltProperty ( String propertyName , String otherPropertyName ) { return valueProperties ( propertyName , LessThan . instance ( ) , otherPropertyName ) ; }
Apply a less than constraint to two properties .
7,102
public PropertyConstraint lteProperty ( String propertyName , String otherPropertyName ) { return valueProperties ( propertyName , LessThanEqualTo . instance ( ) , otherPropertyName ) ; }
Apply a less than or equal to constraint to two properties .
7,103
public PropertyConstraint inRangeProperties ( String propertyName , String minPropertyName , String maxPropertyName ) { Constraint min = gteProperty ( propertyName , minPropertyName ) ; Constraint max = lteProperty ( propertyName , maxPropertyName ) ; return new CompoundPropertyConstraint ( new And ( min , max ) ) ; }
Apply a inclusive range constraint between two other properties to a bean property .
7,104
public Contact [ ] getSelectedContacts ( ) { int [ ] selected = getTable ( ) . getSelectedRows ( ) ; Contact [ ] contacts = new Contact [ selected . length ] ; for ( int i = 0 ; i < selected . length ; i ++ ) { contacts [ i ] = ( Contact ) getTableModel ( ) . getElementAt ( selected [ i ] ) ; } return contacts ; }
Get the array of selected Contact objects in the table .
7,105
public final void processComponent ( String propertyName , final JComponent component ) { final AbstractOverlayHandler overlayHandler = this . createOverlayHandler ( propertyName , component ) ; final PropertyChangeListener wait4ParentListener = new PropertyChangeListener ( ) { public void propertyChange ( PropertyChangeEvent e ) { final JComponent targetComponent = overlayHandler . getTargetComponent ( ) ; final JComponent overlay = overlayHandler . getOverlay ( ) ; final int position = AbstractOverlayFormComponentInterceptor . this . getPosition ( ) ; final Boolean success = AbstractOverlayFormComponentInterceptor . this . getOverlayService ( ) . installOverlay ( targetComponent , overlay , position , null ) ; if ( success ) { targetComponent . removePropertyChangeListener ( AbstractOverlayFormComponentInterceptor . ANCESTOR_PROPERTY , this ) ; } } } ; component . addPropertyChangeListener ( AbstractOverlayFormComponentInterceptor . ANCESTOR_PROPERTY , wait4ParentListener ) ; }
Creates an overlay handler for the given property name and component and installs the overlay .
7,106
protected void initRules ( ) { this . validationRules = new Rules ( getClass ( ) ) { protected void initRules ( ) { add ( PROPERTY_USERNAME , all ( new Constraint [ ] { required ( ) , minLength ( getUsernameMinLength ( ) ) } ) ) ; add ( PROPERTY_PASSWORD , all ( new Constraint [ ] { required ( ) , minLength ( getPasswordMinLength ( ) ) } ) ) ; } protected int getUsernameMinLength ( ) { return 2 ; } protected int getPasswordMinLength ( ) { return 2 ; } } ; }
Initialize the field constraints for our properties . Minimal constraints are enforced here . If you need more control you should override this in a subtype .
7,107
private Icon getIcon ( Severity severity ) { if ( severity == Severity . ERROR ) { return getErrorIcon ( ) ; } if ( severity == Severity . WARNING ) { return getWarningIcon ( ) ; } return getInfoIcon ( ) ; }
Returns the icon for the given severity .
7,108
public void setAuthorizingRoles ( String roles ) { ConfigAttributeEditor editor = new ConfigAttributeEditor ( ) ; editor . setAsText ( roles ) ; this . roles = ( List < ConfigAttribute > ) editor . getValue ( ) ; rolesString = roles ; }
Set the roles to compare against the current user s authenticated roles . The secured objects will be authorized if the user holds one or more of these roles . This should be specified as a simple list of comma separated role names .
7,109
public static Class < ? > getTypeForProperty ( Method getter ) { Class < ? > returnType = getter . getReturnType ( ) ; if ( returnType . equals ( Void . TYPE ) ) throw new IllegalArgumentException ( "Getter " + getter . toString ( ) + " does not have a returntype." ) ; else if ( returnType . isPrimitive ( ) ) return MethodUtils . getPrimitiveWrapper ( returnType ) ; return returnType ; }
Returns the type of the property checking if it actually does return something and wrapping primitives if needed .
7,110
public static final Method getWriteMethod ( Class < ? > clazz , String propertyName , Class < ? > propertyType ) { String propertyNameCapitalized = capitalize ( propertyName ) ; try { return clazz . getMethod ( "set" + propertyNameCapitalized , new Class [ ] { propertyType } ) ; } catch ( Exception e ) { return null ; } }
Lookup the setter method for the given property .
7,111
public static String capitalize ( String s ) { if ( s == null || s . length ( ) == 0 ) { return s ; } char chars [ ] = s . toCharArray ( ) ; chars [ 0 ] = Character . toUpperCase ( chars [ 0 ] ) ; return new String ( chars ) ; }
Small helper method to capitalize the first character of the given string .
7,112
public static void attachOverlay ( JComponent overlay , JComponent overlayTarget , int center , int xOffset , int yOffset ) { new OverlayHelper ( overlay , overlayTarget , center , xOffset , yOffset ) ; }
Attaches an overlay to the specified component .
7,113
private Rectangle findLargestVisibleRectFor ( final Rectangle overlayRect ) { Rectangle visibleRect = null ; int curxoffset = 0 ; int curyoffset = 0 ; if ( overlayTarget == null ) { return null ; } JComponent comp = overlayTarget ; do { visibleRect = comp . getVisibleRect ( ) ; visibleRect . x -= curxoffset ; visibleRect . y -= curyoffset ; if ( visibleRect . contains ( overlayRect ) ) { return visibleRect ; } curxoffset += comp . getX ( ) ; curyoffset += comp . getY ( ) ; comp = comp . getParent ( ) instanceof JComponent ? ( JComponent ) comp . getParent ( ) : null ; } while ( comp != null && ! ( comp instanceof JViewport ) && ! ( comp instanceof JScrollPane ) ) ; return visibleRect ; }
Searches up the component hierarchy to find the largest possible visible rect that can enclose the entire rectangle .
7,114
protected void listWorkerDone ( List < Object > rows , Map < String , Object > parameters ) { setRows ( rows ) ; validationResultsModel . removeMessage ( maximumRowsExceededMessage ) ; if ( ( rows == null ) || ( rows . size ( ) == 0 ) ) { return ; } Object defaultSelectedObject = null ; if ( parameters . containsKey ( PARAMETER_DEFAULT_SELECTED_OBJECT ) ) { defaultSelectedObject = parameters . get ( PARAMETER_DEFAULT_SELECTED_OBJECT ) ; } if ( defaultSelectedObject == null ) { getTableWidget ( ) . selectRowObject ( 0 , null ) ; } else { getTableWidget ( ) . selectRowObject ( defaultSelectedObject , null ) ; } }
This method is called on the gui - thread when the worker ends . As default it will check for the PARAMETER_DEFAULT_SELECTED_OBJECT parameter in the map .
7,115
public Widget createDetailWidget ( ) { return new AbstractWidget ( ) { public void onAboutToShow ( ) { DefaultDataEditorWidget . this . onAboutToShow ( ) ; } public void onAboutToHide ( ) { DefaultDataEditorWidget . this . onAboutToHide ( ) ; } public JComponent getComponent ( ) { return getDetailForm ( ) . getControl ( ) ; } public List < ? extends AbstractCommand > getCommands ( ) { return Arrays . asList ( getDetailForm ( ) . getCommitCommand ( ) ) ; } public String getId ( ) { return DefaultDataEditorWidget . this . getId ( ) + "." + getDetailForm ( ) . getId ( ) ; } } ; }
Returns only the detail form widget
7,116
protected void setDetailForm ( AbstractForm detailForm ) { if ( this . detailForm != null ) { validationResultsModel . remove ( this . detailForm . getFormModel ( ) . getValidationResults ( ) ) ; } this . detailForm = detailForm ; if ( this . detailForm != null ) { validationResultsModel . add ( this . detailForm . getFormModel ( ) . getValidationResults ( ) ) ; } }
Set the form that will handle one detail item .
7,117
protected void setFilterForm ( FilterForm filterForm ) { if ( this . filterForm != null ) { validationResultsModel . remove ( this . filterForm . getFormModel ( ) . getValidationResults ( ) ) ; } this . filterForm = filterForm ; if ( this . filterForm != null ) { validationResultsModel . add ( filterForm . getFormModel ( ) . getValidationResults ( ) ) ; } }
Set the form to use as filter .
7,118
protected void setDataProvider ( DataProvider provider ) { if ( ( this . dataProvider != null ) && ( this . dataProvider . getRefreshPolicy ( ) == DataProvider . RefreshPolicy . ON_USER_SWITCH ) ) { getApplicationConfig ( ) . applicationSession ( ) . removePropertyChangeListener ( ApplicationSession . USER , this ) ; } this . dataProvider = provider ; if ( ( this . dataProvider != null ) && ( this . dataProvider . getRefreshPolicy ( ) == DataProvider . RefreshPolicy . ON_USER_SWITCH ) ) { getApplicationConfig ( ) . applicationSession ( ) . addPropertyChangeListener ( ApplicationSession . USER , this ) ; } }
Set the provider to use for data manipulation .
7,119
protected CommandGroup createCommandGroup ( ) { CommandGroup group ; if ( isExclusive ( ) ) { ExclusiveCommandGroup g = new ExclusiveCommandGroup ( getGroupId ( ) , getCommandRegistry ( ) ) ; g . setAllowsEmptySelection ( isAllowsEmptySelection ( ) ) ; group = g ; } else { group = new CommandGroup ( getGroupId ( ) , getCommandRegistry ( ) ) ; } group . setSecurityControllerId ( getSecurityControllerId ( ) ) ; initCommandGroupMembers ( group ) ; return group ; }
registry has not been provided .
7,120
protected void initCommandGroupMembers ( CommandGroup group ) { for ( int i = 0 ; i < members . length ; i ++ ) { Object o = members [ i ] ; if ( o instanceof AbstractCommand ) { group . addInternal ( ( AbstractCommand ) o ) ; configureIfNecessary ( ( AbstractCommand ) o ) ; } else if ( o instanceof Component ) { group . addComponentInternal ( ( Component ) o ) ; } else if ( o instanceof String ) { String str = ( String ) o ; if ( str . equalsIgnoreCase ( SEPARATOR_MEMBER_CODE ) ) { group . addSeparatorInternal ( ) ; } else if ( str . equalsIgnoreCase ( GLUE_MEMBER_CODE ) ) { group . addGlueInternal ( ) ; } else if ( str . startsWith ( COMMAND_MEMBER_PREFIX ) ) { String commandId = str . substring ( COMMAND_MEMBER_PREFIX . length ( ) ) ; if ( ! StringUtils . hasText ( commandId ) ) { throw new InvalidGroupMemberEncodingException ( "The group member encoding does not specify a command id" , str ) ; } addCommandMember ( str . substring ( COMMAND_MEMBER_PREFIX . length ( ) ) , group ) ; } else if ( str . startsWith ( GROUP_MEMBER_PREFIX ) ) { String commandId = str . substring ( GROUP_MEMBER_PREFIX . length ( ) ) ; if ( ! StringUtils . hasText ( commandId ) ) { throw new InvalidGroupMemberEncodingException ( "The group member encoding does not specify a command id" , str ) ; } addCommandMember ( commandId , group ) ; } else { addCommandMember ( str , group ) ; } } } }
Iterates over the collection of encoded members and adds them to the given command group .
7,121
private void addCommandMember ( String commandId , CommandGroup group ) { Assert . notNull ( commandId , "commandId" ) ; Assert . notNull ( group , "group" ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "adding command group member with id [" + commandId + "] to group [" + group . getId ( ) + "]" ) ; } AbstractCommand command = null ; if ( getCommandRegistry ( ) != null ) { command = ( AbstractCommand ) getCommandRegistry ( ) . getCommand ( commandId ) ; if ( command != null ) { group . addInternal ( command ) ; } } if ( command == null ) { group . addLazyInternal ( commandId ) ; } }
Adds the command object with the given id to the given command group . If a command registry has not yet been provided to this factory the command id will be passed as a lazy placeholder to the group instead .
7,122
public void updateShowViewCommands ( ) { ViewDescriptorRegistry viewDescriptorRegistry = ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . viewDescriptorRegistry ( ) ; ViewDescriptor [ ] views = viewDescriptorRegistry . getViewDescriptors ( ) ; for ( ViewDescriptor view : views ) { String id = view . getId ( ) ; CommandManager commandManager = window . getCommandManager ( ) ; if ( commandManager . isTypeMatch ( id , ActionCommand . class ) ) { ActionCommand command = ( ActionCommand ) commandManager . getCommand ( id , ActionCommand . class ) ; command . setVisible ( pageViews . contains ( view . getId ( ) ) ) ; } } }
This sets the visible flag on all show view commands that are registered with the command manager . If the page contains the view the command is visible otherwise not . The registration of the show view command with the command manager is the responsibility of the view descriptor .
7,123
public void openEditor ( Object editorInput , boolean activateAfterOpen ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Attempting to open editor for " + editorInput . getClass ( ) . getName ( ) ) ; } if ( workspaceComponent == null ) { log . debug ( "WorkspaceComponent is null" ) ; return ; } PageDescriptor descriptor = getPageDescriptor ( ) ; if ( descriptor instanceof JidePageDescriptor ) { if ( editorInput . getClass ( ) . isArray ( ) ) { Object [ ] array = ( Object [ ] ) editorInput ; for ( Object editorObject : array ) { processEditorObject ( editorObject , activateAfterOpen ) ; } } else { processEditorObject ( editorInput , activateAfterOpen ) ; } } }
Implementation of the openEditor command using the editor factory injected into the page descriptor . The editor input is used as the key the factory uses to get the requires editor descriptor . If not editor factory is injected into the page descriptor then the default factory is used which simply returns null for every editor object resulting in no editor being opened .
7,124
public void setValue ( Object toEntity , Object newValue ) throws IllegalAccessException , InvocationTargetException { Object propertyValue = getter . invoke ( toEntity ) ; if ( propertyValue != null ) nestedWriter . setValue ( propertyValue , newValue ) ; }
Set the value on the source entity . If at any point the chaining results in a null value . The chaining should end .
7,125
protected JComponent createControl ( ) { PropertyColumnTableDescription desc = new PropertyColumnTableDescription ( "contactViewTable" , Contact . class ) ; desc . addPropertyColumn ( "lastName" ) . withMinWidth ( 150 ) ; desc . addPropertyColumn ( "firstName" ) . withMinWidth ( 150 ) ; desc . addPropertyColumn ( "address.address1" ) ; desc . addPropertyColumn ( "address.city" ) ; desc . addPropertyColumn ( "address.state" ) ; desc . addPropertyColumn ( "address.zip" ) ; widget = new GlazedListTableWidget ( Arrays . asList ( contactDataStore . getAllContacts ( ) ) , desc ) ; JPanel table = new JPanel ( new BorderLayout ( ) ) ; table . add ( widget . getListSummaryLabel ( ) , BorderLayout . NORTH ) ; table . add ( widget . getComponent ( ) , BorderLayout . CENTER ) ; table . add ( widget . getButtonBar ( ) , BorderLayout . SOUTH ) ; CommandGroup popup = new CommandGroup ( ) ; popup . add ( ( ActionCommand ) getWindowCommandManager ( ) . getCommand ( "deleteCommand" , ActionCommand . class ) ) ; popup . addSeparator ( ) ; popup . add ( ( ActionCommand ) getWindowCommandManager ( ) . getCommand ( "propertiesCommand" , ActionCommand . class ) ) ; JPopupMenu popupMenu = popup . createPopupMenu ( ) ; widget . getTable ( ) . addMouseListener ( new MouseAdapter ( ) { public void mousePressed ( MouseEvent e ) { if ( e . getButton ( ) == MouseEvent . BUTTON3 ) { int rowUnderMouse = widget . getTable ( ) . rowAtPoint ( e . getPoint ( ) ) ; if ( rowUnderMouse != - 1 && ! widget . getTable ( ) . isRowSelected ( rowUnderMouse ) ) { widget . getTable ( ) . getSelectionModel ( ) . setSelectionInterval ( rowUnderMouse , rowUnderMouse ) ; } } } public void mouseClicked ( MouseEvent e ) { if ( e . getClickCount ( ) >= 2 ) { if ( propertiesExecutor . isEnabled ( ) ) propertiesExecutor . execute ( ) ; } } } ) ; widget . getTable ( ) . addMouseListener ( new PopupMenuMouseListener ( popupMenu ) ) ; ValueModel selectionHolder = new ListSelectionValueModelAdapter ( widget . getTable ( ) . getSelectionModel ( ) ) ; new ListSingleSelectionGuard ( selectionHolder , deleteExecutor ) ; new ListSingleSelectionGuard ( selectionHolder , propertiesExecutor ) ; JPanel view = new JPanel ( new BorderLayout ( ) ) ; view . add ( widget . getTextFilterField ( ) , BorderLayout . NORTH ) ; view . add ( table , BorderLayout . CENTER ) ; return view ; }
Create the control for this view . This method is called by the platform in order to obtain the control to add to the surrounding window and page .
7,126
protected void registerLocalCommandExecutors ( PageComponentContext context ) { context . register ( "newContactCommand" , newContactExecutor ) ; context . register ( GlobalCommandIds . PROPERTIES , propertiesExecutor ) ; getApplicationConfig ( ) . securityControllerManager ( ) . addSecuredObject ( propertiesExecutor ) ; context . register ( GlobalCommandIds . DELETE , deleteExecutor ) ; getApplicationConfig ( ) . securityControllerManager ( ) . addSecuredObject ( deleteExecutor ) ; }
Register the local command executors to be associated with named commands . This is called by the platform prior to making the view visible .
7,127
public EditorDescriptor getEditorDescriptor ( Object editorObject ) { Class editorClass = editorObject . getClass ( ) ; EditorDescriptor descriptor = ( EditorDescriptor ) editorMap . get ( editorClass ) ; if ( descriptor == null ) { Iterator it = editorMap . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { Class klass = ( Class ) it . next ( ) ; if ( klass . isAssignableFrom ( editorClass ) ) { descriptor = ( EditorDescriptor ) editorMap . get ( klass ) ; } } } return descriptor ; }
Returns an EditorDescriptor keyed by the class of the injected object . If non exists null is returned .
7,128
protected Object doParseValue ( String formattedString , Class targetClass ) throws ParseException { return dateFormat . parse ( formattedString ) ; }
convert back from string to date
7,129
protected PageComponent createPageComponent ( PageComponentDescriptor descriptor ) { PageComponent pageComponent = descriptor . createPageComponent ( ) ; pageComponent . setContext ( new DefaultViewContext ( this , createPageComponentPane ( pageComponent ) ) ) ; if ( pageComponent instanceof ApplicationListener && getApplicationEventMulticaster ( ) != null ) { getApplicationEventMulticaster ( ) . addApplicationListener ( ( ApplicationListener ) pageComponent ) ; } return pageComponent ; }
Creates a PageComponent for the given PageComponentDescriptor .
7,130
public boolean processKeyBinding ( KeyStroke ks , KeyEvent e , int condition , boolean pressed ) { if ( ks == KeyStroke . getKeyStroke ( KeyEvent . VK_ENTER , 0 ) || ks == KeyStroke . getKeyStroke ( KeyEvent . VK_ESCAPE , 0 ) ) { return false ; } return super . processKeyBinding ( ks , e , condition , pressed ) ; }
Overiding this method prevents the TextField from intercepting the Enter Key when focus is not on it . This allows default buttons to function . This should be removed when Swing fixes their bug .
7,131
private boolean managesCommand ( Component component , String commandId ) { if ( component instanceof AbstractButton ) { AbstractButton button = ( AbstractButton ) component ; if ( null != button . getActionCommand ( ) ) { if ( button . getActionCommand ( ) . equals ( commandId ) ) { return true ; } } } else if ( component instanceof Container ) { Component [ ] subComponents = ( ( Container ) component ) . getComponents ( ) ; for ( int i = 0 ; i < subComponents . length ; ++ i ) { if ( managesCommand ( subComponents [ i ] , commandId ) ) { return true ; } } } return false ; }
Searches through the component and nested components in order to see if the command with supplied id exists in this component .
7,132
protected void fill ( GroupContainerPopulator containerPopulator , Object controlFactory , CommandButtonConfigurer buttonConfigurer , java . util . List previousButtons ) { Assert . notNull ( containerPopulator , "containerPopulator" ) ; containerPopulator . add ( component ) ; }
Asks the given container populator to add a component to its underlying container .
7,133
protected void update ( ) { putValue ( Action . ACTION_COMMAND_KEY , command . getActionCommand ( ) ) ; CommandFaceDescriptor face = command . getFaceDescriptor ( ) ; if ( face != null ) { face . configure ( this ) ; } setEnabled ( command . isEnabled ( ) ) ; }
Updates this instance according to the properties provided by the underlying command .
7,134
public final void setConstraint ( Constraint constraint ) { Assert . notNull ( constraint ) ; if ( ! constraint . equals ( this . constraint ) ) { if ( this . constraint instanceof Observable ) { ( ( Observable ) constraint ) . deleteObserver ( this ) ; } this . constraint = constraint ; if ( constraint instanceof Observable ) { ( ( Observable ) constraint ) . addObserver ( this ) ; } fireContentsChanged ( this , - 1 , - 1 ) ; } }
Defines the constraint which is applied to the list model elements
7,135
public static void customizeFocusTraversalOrder ( JComponent container , java . util . List componentsInOrder ) { for ( Iterator i = componentsInOrder . iterator ( ) ; i . hasNext ( ) ; ) { Component comp = ( Component ) i . next ( ) ; if ( comp . getParent ( ) != container ) { throw new IllegalArgumentException ( "Component [" + comp + "] is not a child of [" + container + "]." ) ; } } container . putClientProperty ( FOCUS_ORDER_PROPERTY_NAME , createOrderMapFromList ( componentsInOrder ) ) ; }
Sets a custom focus traversal order for the given container . Child components for which there is no order specified will receive focus after components that do have an order specified in the standard layout order .
7,136
protected void init ( ) { addPropertyChangeListener ( ENABLED_PROPERTY , new PropertyChangeListener ( ) { public void propertyChange ( PropertyChangeEvent evt ) { validatingUpdated ( ) ; } } ) ; validationResultsModel . addPropertyChangeListener ( ValidationResultsModel . HAS_ERRORS_PROPERTY , childStateChangeHandler ) ; }
Initialization of DefaultFormModel . Adds a listener on the Enabled property in order to switch validating state on or off . When disabling a formModel no validation will happen .
7,137
public ValidatingFormModel createChildPageFormModel ( HierarchicalFormModel parentModel , String childPageName , String childFormObjectPropertyPath ) { final ValueModel childValueModel = parentModel . getValueModel ( childFormObjectPropertyPath ) ; return createChildPageFormModel ( parentModel , childPageName , childValueModel ) ; }
Create a child form model nested by this form model identified by the provided name . The form object associated with the created child model is the value model at the specified parent property path .
7,138
public FormModel getChild ( HierarchicalFormModel formModel , String childPageName ) { if ( childPageName == null ) throw new IllegalArgumentException ( "childPageName == null" ) ; if ( formModel == null ) throw new IllegalArgumentException ( "formModel == null" ) ; final FormModel [ ] children = formModel . getChildren ( ) ; if ( children == null ) return null ; for ( int i = 0 ; i < children . length ; i ++ ) { final FormModel child = children [ i ] ; if ( childPageName . equals ( child . getId ( ) ) ) return child ; } return null ; }
Returns the child of the formModel with the given page name .
7,139
public static void setFieldProtected ( FormModel formModel , String fieldName , boolean protectedField ) { FieldMetadata metaData = formModel . getFieldMetadata ( fieldName ) ; metaData . getAllUserMetadata ( ) . put ( PROTECTED_FIELD , Boolean . valueOf ( protectedField ) ) ; }
defines the protectable state for a field
7,140
public CompoundConstraint addAll ( List constraints ) { Algorithms . instance ( ) . forEach ( constraints , new Block ( ) { protected void handle ( Object o ) { add ( ( Constraint ) o ) ; } } ) ; return this ; }
Add the list of constraints to the set of constraints aggregated by this compound constraint .
7,141
private void processUncaughtException ( Thread thread , Throwable throwable ) { if ( exceptionPurger != null ) { throwable = exceptionPurger . purge ( throwable ) ; } logException ( thread , throwable ) ; notifyUserAboutException ( thread , throwable ) ; }
Logs an exception and shows it to the user .
7,142
public void logException ( Thread thread , Throwable throwable ) { String logMessage ; String errorCode = extractErrorCode ( throwable ) ; if ( errorCode != null ) { logMessage = "Uncaught throwable handled with errorCode (" + errorCode + ")." ; } else { logMessage = "Uncaught throwable handled." ; } doLogException ( logMessage , throwable ) ; }
Log an exception
7,143
public void setCommandExecutor ( ActionCommandExecutor commandExecutor ) { if ( ObjectUtils . nullSafeEquals ( this . commandExecutor , commandExecutor ) ) { return ; } if ( commandExecutor == null ) { detachCommandExecutor ( ) ; } else { if ( this . commandExecutor instanceof GuardedActionCommandExecutor ) { unsubscribeFromGuardedCommandDelegate ( ) ; } this . commandExecutor = commandExecutor ; attachCommandExecutor ( ) ; } }
Attaches the given executor to this command instance detaching the current executor in the process .
7,144
public void detachCommandExecutor ( ) { if ( this . commandExecutor instanceof GuardedActionCommandExecutor ) { unsubscribeFromGuardedCommandDelegate ( ) ; } this . commandExecutor = null ; setEnabled ( false ) ; logger . debug ( "Command delegate detached." ) ; }
Detaches the current executor from this command and sets the command to disabled state .
7,145
protected void doExecuteCommand ( ) { if ( this . commandExecutor instanceof ParameterizableActionCommandExecutor ) { ( ( ParameterizableActionCommandExecutor ) this . commandExecutor ) . execute ( getParameters ( ) ) ; } else { if ( this . commandExecutor != null ) { this . commandExecutor . execute ( ) ; } } }
Executes this command by delegating to the currently assigned executor .
7,146
public void validationResultsChanged ( ValidationResults results ) { if ( resultsModel . getMessageCount ( ) == 0 ) { messageReceiver . setMessage ( null ) ; } else { ValidationMessage message = getValidationMessage ( resultsModel ) ; messageReceiver . setMessage ( message ) ; } }
Handle a change in the validation results model . Update the message receiver based on our current results model state .
7,147
protected void doExecuteCommand ( ) { if ( ! ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . applicationSecurityManager ( ) . isSecuritySupported ( ) ) { return ; } CompositeDialogPage tabbedPage = new TabbedDialogPage ( "loginForm" ) ; final LoginForm loginForm = createLoginForm ( ) ; tabbedPage . addForm ( loginForm ) ; if ( getDefaultUserName ( ) != null ) { loginForm . setUserName ( getDefaultUserName ( ) ) ; } dialog = new TitledPageApplicationDialog ( tabbedPage ) { protected boolean onFinish ( ) { loginForm . commit ( ) ; Authentication authentication = loginForm . getAuthentication ( ) ; ApplicationSecurityManager sm = getApplicationConfig ( ) . applicationSecurityManager ( ) ; try { sm . doLogin ( authentication ) ; postLogin ( ) ; return true ; } finally { if ( isClearPasswordOnFailure ( ) ) { loginForm . setPassword ( "" ) ; } loginForm . requestFocusInWindow ( ) ; } } protected void onCancel ( ) { super . onCancel ( ) ; if ( isCloseOnCancel ( ) ) { ApplicationSecurityManager sm = getApplicationConfig ( ) . applicationSecurityManager ( ) ; Authentication authentication = sm . getAuthentication ( ) ; if ( authentication == null ) { LoginCommand . this . logger . info ( "User canceled login; close the application." ) ; getApplicationConfig ( ) . application ( ) . close ( ) ; } } } protected ActionCommand getCallingCommand ( ) { return LoginCommand . this ; } protected void onAboutToShow ( ) { loginForm . requestFocusInWindow ( ) ; } } ; dialog . setDisplayFinishSuccessMessage ( displaySuccessMessage ) ; dialog . showDialog ( ) ; }
Execute the login command . Display the dialog and attempt authentication .
7,148
public static void installJideRepaintManagerIfNeeded ( ) { final RepaintManager current = RepaintManager . currentManager ( null ) ; if ( current != JideRepaintManager . getInstance ( ) ) { ObjectUtils . shallowCopy ( current , JideRepaintManager . getInstance ( ) ) ; RepaintManager . setCurrentManager ( JideRepaintManager . getInstance ( ) ) ; } }
Installs this repaint manager if not already set .
7,149
public void addUserInputListener ( UserInputListener listener ) { if ( this . listeners == null ) this . listeners = new ArrayList ( ) ; this . listeners . add ( listener ) ; }
Add a UserInputListener .
7,150
private void fireUserInputChange ( ) { if ( ! internallySettingText && ( this . listeners != null ) ) { for ( Iterator it = this . listeners . iterator ( ) ; it . hasNext ( ) ; ) { UserInputListener userInputListener = ( UserInputListener ) it . next ( ) ; userInputListener . update ( this ) ; } } }
Fire an event to all UserInputListeners .
7,151
public Number getValue ( ) { if ( ( getText ( ) == null ) || "" . equals ( getText ( ) . trim ( ) ) ) return null ; try { Number n = format . parse ( getText ( ) ) ; if ( n . getClass ( ) == this . numberClass ) return n ; else if ( this . numberClass == BigDecimal . class ) { BigDecimal bd = new BigDecimal ( n . doubleValue ( ) ) ; if ( scale != null ) { bd = bd . setScale ( scale . intValue ( ) , BigDecimal . ROUND_HALF_UP ) ; } return bd ; } else if ( this . numberClass == Double . class ) return new Double ( n . doubleValue ( ) ) ; else if ( this . numberClass == Float . class ) return new Float ( n . floatValue ( ) ) ; else if ( this . numberClass == BigInteger . class ) return ( ( BigDecimal ) n ) . toBigInteger ( ) ; else if ( this . numberClass == Long . class ) return new Long ( n . longValue ( ) ) ; else if ( this . numberClass == Integer . class ) return new Integer ( n . intValue ( ) ) ; else if ( this . numberClass == Short . class ) return new Short ( n . shortValue ( ) ) ; else if ( this . numberClass == Byte . class ) return new Byte ( n . byteValue ( ) ) ; return null ; } catch ( Exception pe ) { log . error ( "Error: " + getText ( ) + " is not a number." , pe ) ; return null ; } }
Parses a number from the inputField and will adjust it s class if needed .
7,152
public void setValue ( Number number ) { String txt = null ; if ( number != null ) { txt = this . format . format ( number ) ; } setText ( txt ) ; }
Format the number and show it .
7,153
public TableLayoutBuilder row ( ) { ++ currentRow ; lastCC = null ; maxColumns = Math . max ( maxColumns , currentCol ) ; currentCol = 0 ; return this ; }
Inserts a new row . No gap row is inserted before this row .
7,154
public TableLayoutBuilder row ( RowSpec gapRowSpec ) { row ( ) ; gapRows . put ( new Integer ( currentRow ) , gapRowSpec ) ; return this ; }
Inserts a new row . A gap row with specified RowSpec will be inserted before this row .
7,155
public TableLayoutBuilder separator ( String labelKey , String attributes ) { Cell cc = cellInternal ( getComponentFactory ( ) . createLabeledSeparator ( labelKey ) , attributes ) ; lastCC = cc ; items . add ( cc ) ; return this ; }
Inserts a separator with the given label . Attributes my be zero or more of rowSpec columnSpec colGrId rowGrId align and valign .
7,156
public void setFocusTraversalOrder ( int traversalOrder ) { Assert . isTrue ( traversalOrder == COLUMN_MAJOR_FOCUS_ORDER || traversalOrder == ROW_MAJOR_FOCUS_ORDER , "traversalOrder must be one of COLUMN_MAJOR_FOCUS_ORDER or ROW_MAJOR_FOCUS_ORDER" ) ; List focusOrder = new ArrayList ( items . size ( ) ) ; if ( traversalOrder == ROW_MAJOR_FOCUS_ORDER ) { for ( int row = 0 ; row < rowOccupiers . size ( ) - 1 ; row ++ ) { for ( int col = 0 ; col < maxColumns ; col ++ ) { Cell currentCell = getOccupier ( row , col ) ; if ( currentCell != null && currentCell . getComponent ( ) != null && ! focusOrder . contains ( currentCell . getComponent ( ) ) ) { focusOrder . add ( currentCell . getComponent ( ) ) ; } } } } else if ( traversalOrder == COLUMN_MAJOR_FOCUS_ORDER ) { for ( int col = 0 ; col < maxColumns ; col ++ ) { for ( int row = 0 ; row < rowOccupiers . size ( ) - 1 ; row ++ ) { Cell currentCell = getOccupier ( row , col ) ; if ( currentCell != null && currentCell . getComponent ( ) != null && ! focusOrder . contains ( currentCell . getComponent ( ) ) ) { focusOrder . add ( currentCell . getComponent ( ) ) ; } } } } setCustomFocusTraversalOrder ( focusOrder ) ; }
Set the focus traversal order .
7,157
public void documentComponentClosed ( DocumentComponentEvent event ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Page component " + pageComponent . getId ( ) + " closed" ) ; } workspace . remove ( pageComponent ) ; ( ( JideApplicationPage ) workspace . getContext ( ) . getPage ( ) ) . fireClosed ( pageComponent ) ; }
Default closed implementation removes the given page component from the workspace view and so the document from the document pane .
7,158
protected String getTitle ( ) { if ( ! StringUtils . hasText ( this . title ) ) { if ( StringUtils . hasText ( getCallingCommandText ( ) ) ) return getCallingCommandText ( ) ; return DEFAULT_DIALOG_TITLE ; } return this . title ; }
Returns the title of this dialog . If no specific title has been set the calling command s text will be used . If that doesn t yield a result the default title is returned .
7,159
private void constructDialog ( ) { if ( getParentWindow ( ) instanceof Frame ) { dialog = new JDialog ( ( Frame ) getParentWindow ( ) , getTitle ( ) , modal ) ; } else { dialog = new JDialog ( ( Dialog ) getParentWindow ( ) , getTitle ( ) , modal ) ; } dialog . getContentPane ( ) . setLayout ( new BorderLayout ( ) ) ; dialog . setDefaultCloseOperation ( WindowConstants . DO_NOTHING_ON_CLOSE ) ; dialog . setResizable ( resizable ) ; initStandardCommands ( ) ; addCancelByEscapeKey ( ) ; }
Construct the visual dialog frame on which the content needs to be added .
7,160
protected String getFinishSuccessMessage ( ) { ActionCommand callingCommand = getCallingCommand ( ) ; if ( callingCommand != null ) { String [ ] successMessageKeys = new String [ ] { callingCommand . getId ( ) + "." + SUCCESS_FINISH_MESSAGE_KEY , DEFAULT_FINISH_SUCCESS_MESSAGE_KEY } ; return getApplicationConfig ( ) . messageResolver ( ) . getMessage ( successMessageKeys , getFinishSuccessMessageArguments ( ) ) ; } return getApplicationConfig ( ) . messageResolver ( ) . getMessage ( DEFAULT_FINISH_SUCCESS_MESSAGE_KEY ) ; }
Returns the message to use upon succesful finish .
7,161
protected String getFinishSuccessTitle ( ) { ActionCommand callingCommand = getCallingCommand ( ) ; if ( callingCommand != null ) { String [ ] successTitleKeys = new String [ ] { callingCommand . getId ( ) + "." + SUCCESS_FINISH_TITLE_KEY , DEFAULT_FINISH_SUCCESS_TITLE_KEY } ; return getApplicationConfig ( ) . messageResolver ( ) . getMessage ( successTitleKeys , getFinishSuccessTitleArguments ( ) ) ; } return getApplicationConfig ( ) . messageResolver ( ) . getMessage ( DEFAULT_FINISH_SUCCESS_TITLE_KEY ) ; }
Returns the title to use upon succesful finish .
7,162
private void addCancelByEscapeKey ( ) { int noModifiers = 0 ; KeyStroke escapeKey = KeyStroke . getKeyStroke ( KeyEvent . VK_ESCAPE , noModifiers , false ) ; addActionKeyBinding ( escapeKey , cancelCommand . getId ( ) ) ; }
Force the escape key to call the same action as pressing the Cancel button . This does not always work . See class comment .
7,163
protected void addDialogComponents ( ) { JComponent dialogContentPane = createDialogContentPane ( ) ; GuiStandardUtils . attachDialogBorder ( dialogContentPane ) ; if ( getPreferredSize ( ) != null ) { dialogContentPane . setPreferredSize ( getPreferredSize ( ) ) ; } getDialogContentPane ( ) . add ( dialogContentPane ) ; getDialogContentPane ( ) . add ( createButtonBar ( ) , BorderLayout . SOUTH ) ; }
Subclasses may override to customize how this dialog is built .
7,164
protected JComponent createButtonBar ( ) { this . dialogCommandGroup = getCommandManager ( ) . createCommandGroup ( null , getCommandGroupMembers ( ) ) ; JComponent buttonBar = this . dialogCommandGroup . createButtonBar ( ) ; GuiStandardUtils . attachDialogBorder ( buttonBar ) ; return buttonBar ; }
Return a standardized row of command buttons right - justified and all of the same size with OK as the default button and no mnemonics used as per the Java Look and Feel guidelines .
7,165
protected java . util . List < ? extends AbstractCommand > getCommandGroupMembers ( ) { return Lists . < AbstractCommand > newArrayList ( getFinishCommand ( ) , getCancelCommand ( ) ) ; }
Template getter method to return the commands to populate the dialog button bar .
7,166
protected void fill ( GroupContainerPopulator containerPopulator , Object controlFactory , CommandButtonConfigurer configurer , List previousButtons ) { Assert . notNull ( containerPopulator , "containerPopulator" ) ; Assert . notNull ( controlFactory , "controlFactory" ) ; Assert . notNull ( configurer , "configurer" ) ; if ( members . size ( ) > 0 && isLeadingSeparator ( ) ) { containerPopulator . addSeparator ( ) ; } for ( Iterator iterator = members . iterator ( ) ; iterator . hasNext ( ) ; ) { GroupMember member = ( GroupMember ) iterator . next ( ) ; member . fill ( containerPopulator , controlFactory , configurer , previousButtons ) ; } if ( members . size ( ) > 0 && isEndingSeparator ( ) ) { containerPopulator . addSeparator ( ) ; } }
Adds each member of this expansion point to a GUI container using the given container populator . Leading and trailing separators will also be added as determined by the appropriate flags set on this instance .
7,167
public GroupMember getMemberFor ( String commandId ) { for ( Iterator it = members . iterator ( ) ; it . hasNext ( ) ; ) { GroupMember member = ( GroupMember ) it . next ( ) ; if ( member . managesCommand ( commandId ) ) { return member ; } } return null ; }
Returns the group member that manages the command with the given id or null if none of the members in this expansion point manage a command with that id .
7,168
protected ConversionExecutor getPropertyConversionExecutor ( ) { if ( conversionExecutor == null ) { conversionExecutor = getConversionService ( ) . getConversionExecutor ( Object [ ] . class , getPropertyType ( ) ) ; } return conversionExecutor ; }
Returns a conversion executor which converts a value of the given sourceType into the fieldType
7,169
protected void updateSelectedItemsFromValueModel ( ) { Object value = getValue ( ) ; Object [ ] selectedValues = EMPTY_VALUES ; if ( value != null ) { selectedValues = ( Object [ ] ) convertValue ( value , Object [ ] . class ) ; } selectingValues = true ; try { ListSelectionModel selectionModel = getList ( ) . getSelectionModel ( ) ; selectionModel . setValueIsAdjusting ( true ) ; try { int [ ] valueIndexes = determineValueIndexes ( selectedValues ) ; int selectionMode = getSelectionMode ( ) ; if ( selectionMode == ListSelectionModel . SINGLE_SELECTION && valueIndexes . length > 1 ) { getList ( ) . setSelectedIndex ( valueIndexes [ 0 ] ) ; } else { getList ( ) . setSelectedIndices ( valueIndexes ) ; } if ( valueIndexes . length != selectedValues . length && ! isReadOnly ( ) && isEnabled ( ) || ( selectionMode == ListSelectionModel . SINGLE_SELECTION && valueIndexes . length > 1 ) ) { updateSelectedItemsFromSelectionModel ( ) ; } } finally { selectionModel . setValueIsAdjusting ( false ) ; } } finally { selectingValues = false ; } }
Updates the selection model with the selected values from the value model .
7,170
public final void setSelected ( boolean selected ) { if ( isExclusiveGroupMember ( ) ) { boolean oldState = isSelected ( ) ; exclusiveController . handleSelectionRequest ( this , selected ) ; if ( oldState == isSelected ( ) ) { Iterator iter = buttonIterator ( ) ; while ( iter . hasNext ( ) ) { AbstractButton button = ( AbstractButton ) iter . next ( ) ; button . setSelected ( isSelected ( ) ) ; } } } else { requestSetSelection ( selected ) ; } }
Set the selection state of the command .
7,171
protected boolean requestSetSelection ( boolean selected ) { boolean previousState = isSelected ( ) ; if ( previousState != selected ) { this . selected = onSelection ( selected ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Toggle command selection returned '" + this . selected + "'" ) ; } } Iterator it = buttonIterator ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Updating all attached toggle buttons to '" + isSelected ( ) + "'" ) ; } while ( it . hasNext ( ) ) { AbstractButton button = ( AbstractButton ) it . next ( ) ; button . setSelected ( isSelected ( ) ) ; } if ( previousState != isSelected ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Selection changed; firing property change event" ) ; } firePropertyChange ( SELECTED_PROPERTY , previousState , isSelected ( ) ) ; } return isSelected ( ) ; }
Handles the switching of the selected state . All attached buttons are updated .
7,172
protected void addPage ( String wizardConfigurationKey , WizardPage page ) { pages . add ( page ) ; page . setWizard ( this ) ; if ( autoConfigureChildPages ) { String key = ( ( wizardConfigurationKey != null ) ? wizardConfigurationKey + "." : "" ) + page . getId ( ) ; ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . applicationObjectConfigurer ( ) . configure ( page , key ) ; } }
Adds a new page to this wizard . The page is inserted at the end of the page list .
7,173
public boolean canFinish ( ) { for ( int i = 0 ; i < pages . size ( ) ; i ++ ) { if ( ! ( ( WizardPage ) pages . get ( i ) ) . isPageComplete ( ) ) return false ; } return true ; }
Returns true if all the pages of this wizard have been completed .
7,174
protected final Binding doBind ( JComponent control , FormModel formModel , String formPropertyPath , Map context ) { AbstractListBinding binding = createListBinding ( control , formModel , formPropertyPath ) ; Assert . notNull ( binding ) ; applyContext ( binding , context ) ; return binding ; }
Creates the binding and applies any context values
7,175
protected void applyContext ( AbstractListBinding binding , Map context ) { if ( context . containsKey ( SELECTABLE_ITEMS_KEY ) ) { binding . setSelectableItems ( decorate ( context . get ( SELECTABLE_ITEMS_KEY ) , selectableItems ) ) ; } else if ( selectableItems != null ) { binding . setSelectableItems ( selectableItems ) ; } if ( context . containsKey ( COMPARATOR_KEY ) ) { binding . setComparator ( ( Comparator ) decorate ( context . get ( COMPARATOR_KEY ) , comparator ) ) ; } else if ( comparator != null ) { binding . setComparator ( comparator ) ; } if ( context . containsKey ( FILTER_KEY ) ) { binding . setFilter ( ( Constraint ) decorate ( context . get ( FILTER_KEY ) , filter ) ) ; } else if ( filter != null ) { binding . setFilter ( filter ) ; } }
Applies any context or preset value .
7,176
protected JComponent createControl ( ) { JTextPane textPane = new JTextPane ( ) ; JScrollPane spDescription = getApplicationConfig ( ) . componentFactory ( ) . createScrollPane ( textPane ) ; try { textPane . setPage ( getDescriptionTextPath ( ) . getURL ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( "Unable to load description URL" , e ) ; } JLabel lblMessage = getApplicationConfig ( ) . componentFactory ( ) . createLabel ( getFirstMessage ( ) ) ; lblMessage . setBorder ( BorderFactory . createEmptyBorder ( 5 , 0 , 5 , 0 ) ) ; JPanel panel = getApplicationConfig ( ) . componentFactory ( ) . createPanel ( new BorderLayout ( ) ) ; panel . add ( spDescription ) ; panel . add ( lblMessage , BorderLayout . SOUTH ) ; return panel ; }
Create the actual UI control for this view . It will be placed into the window according to the layout of the page holding this view .
7,177
private static String escapeXml ( String input ) { return input == null ? "" : input . replace ( "&" , "&amp;" ) . replace ( "<" , "&lt;" ) . replace ( ">" , "&gt;" ) ; }
Converts the incoming string to an escaped output string . This method is far from perfect only escaping &lt ; &gt ; and &amp ; characters
7,178
public int compareTo ( Object o ) { ViewDescriptor castObj = ( ViewDescriptor ) o ; return this . getDisplayName ( ) . compareToIgnoreCase ( castObj . getDisplayName ( ) ) ; }
Compares the display names of the view descriptors
7,179
public static void runInEventDispatcherThread ( Runnable runnable , Boolean wait ) { Assert . notNull ( runnable , "runnable" ) ; Assert . notNull ( wait , "wait" ) ; if ( EventQueue . isDispatchThread ( ) ) { runnable . run ( ) ; } else if ( wait ) { try { EventQueue . invokeAndWait ( runnable ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } catch ( InvocationTargetException e ) { throw new RuntimeException ( e ) ; } } else { EventQueue . invokeLater ( runnable ) ; } }
Ensures the given runnable is executed into the event dispatcher thread .
7,180
public static Component getDescendantNamed ( String name , Component parent ) { Assert . notNull ( name , "name" ) ; Assert . notNull ( parent , "parent" ) ; if ( name . equals ( parent . getName ( ) ) ) { return parent ; } else if ( parent instanceof Container ) { for ( final Component component : ( ( Container ) parent ) . getComponents ( ) ) { final Component foundComponent = SwingUtils . getDescendantNamed ( name , component ) ; if ( foundComponent != null ) { return foundComponent ; } } } return null ; }
Does a pre - order search of a component with a given name .
7,181
public static JComponent generateComponent ( Image image ) { if ( image == null ) { return new LabelUIResource ( "Image is null" ) ; } return SwingUtils . generateComponent ( new ImageIcon ( image ) ) ; }
Generates a component to view an image .
7,182
protected FocusListener createFocusListener ( ) { return new FocusAdapter ( ) { public void focusLost ( FocusEvent e ) { String textFieldValue = getKeyComponentText ( ) ; boolean empty = "" . equals ( textFieldValue . trim ( ) ) ; Object ref = LookupBinding . this . getValue ( ) ; if ( evaluateFocusLost ( e ) ) { if ( revertValueOnFocusLost ( ) ) { if ( empty ) getValueModel ( ) . setValue ( null ) ; else valueModelChanged ( LookupBinding . super . getValue ( ) ) ; } else { if ( empty && ( ref != null ) ) getValueModel ( ) . setValue ( null ) ; else if ( ! empty && ( ( ref == null ) || ! textFieldValue . equals ( getObjectLabel ( ref ) ) ) ) getValueModel ( ) . setValue ( createFilterFromString ( textFieldValue ) ) ; } } } } ; }
Create a focus listener to attach to the textComponent and dataEditorButton that will decide what happens with the changed value . Here a revert can be done if no value is selected or a new value can be created as needed .
7,183
protected Object initializeDataEditor ( ) { final String textFieldValue = getKeyComponentText ( ) ; Object ref = super . getValue ( ) ; if ( ( ref != null ) && textFieldValue . equals ( getObjectLabel ( ref ) ) ) return getDataEditor ( ) . setSelectedSearch ( ref ) ; return getDataEditor ( ) . setSelectedSearch ( createFilterFromString ( textFieldValue ) ) ; }
Initialize the dataEditor by passing the search referable as search parameter .
7,184
protected ActionCommand createDataEditorCommand ( ) { ActionCommand selectDialogCommand = new ActionCommand ( getSelectDialogCommandId ( ) ) { private ApplicationDialog dataEditorDialog ; protected void doExecuteCommand ( ) { if ( LookupBinding . this . propertyChangeMonitor . proceedOnChange ( ) ) { if ( dataEditorDialog == null ) { dataEditorDialog = new TitledWidgetApplicationDialog ( getDataEditor ( ) , TitledWidgetApplicationDialog . SELECT_CANCEL_MODE ) { protected boolean onFinish ( ) { if ( getDataEditor ( ) . canClose ( ) ) return LookupBinding . this . onFinish ( ) ; return false ; } protected boolean onSelectNone ( ) { getDataEditor ( ) . getTableWidget ( ) . unSelectAll ( ) ; return super . onSelectNone ( ) ; } protected void onCancel ( ) { if ( getDataEditor ( ) . canClose ( ) ) super . onCancel ( ) ; } } ; dataEditorDialog . setParentComponent ( getDataEditorButton ( ) ) ; getDataEditor ( ) . setSelectMode ( AbstractDataEditorWidget . ON ) ; getApplicationConfig ( ) . applicationObjectConfigurer ( ) . configure ( dataEditorDialog , getSelectDialogId ( ) ) ; } if ( getParameter ( NO_INITIALIZE_DATA_EDITOR ) != ON ) initializeDataEditor ( ) ; if ( getDialogSize ( ) != null ) { dataEditorDialog . getDialog ( ) . setMinimumSize ( getDialogSize ( ) ) ; } dataEditorDialog . showDialog ( ) ; } } } ; getApplicationConfig ( ) . commandConfigurer ( ) . configure ( selectDialogCommand ) ; return selectDialogCommand ; }
Create the dataEditorCommand .
7,185
protected String getMessage ( String contextId , String fieldPath , String [ ] faceDescriptorProperties , String defaultValue ) { String [ ] keys = getMessageKeys ( contextId , fieldPath , faceDescriptorProperties ) ; try { return getMessageSourceAccessor ( ) . getMessage ( new DefaultMessageSourceResolvable ( keys , null , defaultValue ) ) ; } catch ( NoSuchMessageException e ) { if ( log . isDebugEnabled ( ) ) { log . debug ( e . getMessage ( ) ) ; } return null ; } }
Returns the value of the required property of the FieldFace . Delegates to the getMessageKeys for the message key generation strategy .
7,186
public void postProcessBeanFactory ( final ConfigurableListableBeanFactory beanFactory ) throws BeansException { if ( beanFactory == null ) { return ; } String [ ] beanNames = beanFactory . getBeanDefinitionNames ( ) ; int singletonBeanCount = 0 ; for ( int i = 0 ; i < beanNames . length ; i ++ ) { BeanDefinition beanDefinition = beanFactory . getBeanDefinition ( beanNames [ i ] ) ; if ( beanDefinition . isSingleton ( ) ) { singletonBeanCount ++ ; } } this . progressMonitor . taskStarted ( this . loadingAppContextMessage , singletonBeanCount ) ; beanFactory . addBeanPostProcessor ( new ProgressMonitoringBeanPostProcessor ( beanFactory ) ) ; }
Notifies this instance s associated progress monitor of progress made while processing the given bean factory .
7,187
public void setSearchString ( String queryString ) { this . searchString = queryString ; if ( this . textFilterField != null ) { this . textFilterField . setText ( this . searchString ) ; } }
Set the local text filter field value
7,188
protected ActionCommand createUpdateCommand ( ) { ActionCommand command = new ActionCommand ( UPDATE_COMMAND_ID ) { protected void doExecuteCommand ( ) { doUpdate ( ) ; } } ; command . setSecurityControllerId ( getId ( ) + "." + UPDATE_COMMAND_ID ) ; getApplicationConfig ( ) . commandConfigurer ( ) . configure ( command ) ; getDetailForm ( ) . addGuarded ( command , FormGuard . LIKE_COMMITCOMMAND ) ; return command ; }
Creates the save command .
7,189
protected ActionCommand createCreateCommand ( ) { ActionCommand command = new ActionCommand ( CREATE_COMMAND_ID ) { protected void doExecuteCommand ( ) { doCreate ( ) ; } } ; command . setSecurityControllerId ( getId ( ) + "." + CREATE_COMMAND_ID ) ; getApplicationConfig ( ) . commandConfigurer ( ) . configure ( command ) ; getDetailForm ( ) . addGuarded ( command , FormGuard . LIKE_COMMITCOMMAND ) ; return command ; }
Creates the create command .
7,190
protected CommandGroup getTablePopupMenuCommandGroup ( ) { return getApplicationConfig ( ) . commandManager ( ) . createCommandGroup ( Lists . newArrayList ( getEditRowCommand ( ) , "separator" , getAddRowCommand ( ) , getCloneRowCommand ( ) , getRemoveRowsCommand ( ) , "separator" , getRefreshCommand ( ) , "separator" , getCopySelectedRowsToClipboardCommand ( ) ) ) ; }
Returns the commandGroup that should be used to create the popup menu for the table .
7,191
public void fireFocusGainedOnActiveComponent ( ) { String documentName = contentPane . getActiveDocumentName ( ) ; if ( documentName != null ) { PageComponent component = ( PageComponent ) pageComponentMap . get ( documentName ) ; JideApplicationPage page = ( JideApplicationPage ) getActiveWindow ( ) . getPage ( ) ; page . fireFocusGained ( component ) ; } }
This is a bit of a hack to get over a limitation in the JIDE docking framework . When focus is regained to the workspace by activation the currently activated document the documentComponentActivated is not fired . This needs to be fired when we know the workspace has become active . For some reason it dosen t work when using the componentFocusGained method
7,192
public void addDocumentComponent ( final PageComponent pageComponent , boolean activateAfterOpen ) { String id = pageComponent . getId ( ) ; if ( ! closeAndReopenEditor && contentPane . getDocument ( id ) != null ) { contentPane . setActiveDocument ( id ) ; } else { if ( contentPane . getDocument ( id ) != null ) { contentPane . closeDocument ( id ) ; } DocumentComponent document = constructDocumentComponent ( pageComponent ) ; DocumentComponentListener lifecycleListener = constructLifecycleListener ( pageComponent ) ; document . addDocumentComponentListener ( lifecycleListener ) ; if ( contentPane . getDocument ( id ) == null ) { contentPane . openDocument ( document ) ; } if ( activateAfterOpen ) { contentPane . setActiveDocument ( id ) ; } registerDropTargetListeners ( pageComponent . getControl ( ) ) ; document . addDocumentComponentListener ( new DocumentComponentAdapter ( ) { public void documentComponentClosed ( DocumentComponentEvent event ) { int count = contentPane . getDocumentCount ( ) ; if ( count == 0 ) { fireFocusGainedOnWorkspace ( ) ; } } } ) ; pageComponentMap . put ( id , pageComponent ) ; } }
Adds a document to the editor workspace . The behaviour when an editor is already open with editor identity defined by id property is determined by the closeAndReopenEditor property . If this property is true the default the editor is closed and reopened . If false the existing editor becomes the active one .
7,193
public void propertyChange ( PropertyChangeEvent evt ) { int [ ] selected = ( int [ ] ) selectionHolder . getValue ( ) ; guarded . setEnabled ( shouldEnable ( selected ) ) ; }
Handle a change in the selectionHolder value .
7,194
public void activateView ( ) { if ( SwingUtilities . isEventDispatchThread ( ) ) { ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . windowManager ( ) . getActiveWindow ( ) . getPage ( ) . showView ( getId ( ) ) ; } else { SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . windowManager ( ) . getActiveWindow ( ) . getPage ( ) . showView ( getId ( ) ) ; } } ) ; } }
Activates this view taking care of EDT issues
7,195
private void loadIfNecessary ( ) { if ( loadedMember != null ) { return ; } CommandRegistry commandRegistry = parentGroup . getCommandRegistry ( ) ; Assert . isTrue ( parentGroup . getCommandRegistry ( ) != null , "Command registry must be set for group '" + parentGroup . getId ( ) + "' in order to load lazy command '" + lazyCommandId + "'." ) ; if ( commandRegistry . containsCommandGroup ( lazyCommandId ) ) { CommandGroup group = commandRegistry . getCommandGroup ( lazyCommandId ) ; loadedMember = new SimpleGroupMember ( parentGroup , group ) ; } else if ( commandRegistry . containsActionCommand ( lazyCommandId ) ) { ActionCommand command = commandRegistry . getActionCommand ( lazyCommandId ) ; loadedMember = new SimpleGroupMember ( parentGroup , command ) ; } else { if ( logger . isWarnEnabled ( ) ) { logger . warn ( "Lazy command '" + lazyCommandId + "' was asked to display; however, no backing command instance exists in registry." ) ; } } if ( addedLazily && loadedMember != null ) { loadedMember . onAdded ( ) ; } }
Attempts to load the lazy command from the command registry of the parent command group but only if it hasn t already been loaded .
7,196
protected String getMessage ( String key , Object [ ] params ) { MessageSource messageSource = ValkyrieRepository . getInstance ( ) . getApplicationConfig ( ) . messageSource ( ) ; return messageSource . getMessage ( key , params , Locale . getDefault ( ) ) ; }
Method to obtain a message from the message source defined via the services locator at the default locale .
7,197
public void dispose ( ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Disposing of editor " + getId ( ) ) ; } context . register ( GlobalCommandIds . SAVE , null ) ; context . register ( GlobalCommandIds . SAVE_AS , null ) ; concreteDispose ( ) ; }
This method is called when an editor is removed from the workspace .
7,198
public void setButtonLabelInfo ( String encodedLabelInfo ) { CommandButtonLabelInfo newLabelInfo = CommandButtonLabelInfo . valueOf ( encodedLabelInfo ) ; setLabelInfo ( newLabelInfo ) ; }
Sets the label information for the command using the given encoded label descriptor .
7,199
public void setIcon ( Icon icon ) { Icon old = null ; if ( iconInfo == CommandButtonIconInfo . BLANK_ICON_INFO ) { if ( icon != null ) { setIconInfo ( new CommandButtonIconInfo ( icon ) ) ; } } else { old = iconInfo . getIcon ( ) ; this . iconInfo . setIcon ( icon ) ; } firePropertyChange ( ICON_PROPERTY , old , icon ) ; }
Set the main default icon to be associated with the command .