From: <tri...@us...> - 2008-10-27 13:01:46
|
Revision: 797 http://equanda.svn.sourceforge.net/equanda/?rev=797&view=rev Author: triathlon98 Date: 2008-10-27 10:23:44 +0000 (Mon, 27 Oct 2008) Log Message: ----------- EQ-249 display relevant descriptions Modified Paths: -------------- trunk/equanda-generate/src/main/java/org/equanda/domain/xml/transform/RootTable.java trunk/equanda-tool/src/main/java/org/equanda/tool/translationsEditor/KeyEditorPanel.java Modified: trunk/equanda-generate/src/main/java/org/equanda/domain/xml/transform/RootTable.java =================================================================== --- trunk/equanda-generate/src/main/java/org/equanda/domain/xml/transform/RootTable.java 2008-10-27 10:15:39 UTC (rev 796) +++ trunk/equanda-generate/src/main/java/org/equanda/domain/xml/transform/RootTable.java 2008-10-27 10:23:44 UTC (rev 797) @@ -698,6 +698,13 @@ return res; } + public Select getSelect( String name ) + { + if ( null == name ) return null; + for ( Select sel : getSelects() ) if ( name.equals( sel.getName() ) ) return sel; + return null; + } + public List<Select> getSingleSelects() { List<Select> res = new ArrayList<Select>(); @@ -722,6 +729,13 @@ return actions; } + public Action getAction( String name ) + { + if ( null == name ) return null; + for ( Action action : getActions() ) if ( name.equals( action.getName() ) ) return action; + return null; + } + public List<Page> getPages() { return pages; Modified: trunk/equanda-tool/src/main/java/org/equanda/tool/translationsEditor/KeyEditorPanel.java =================================================================== --- trunk/equanda-tool/src/main/java/org/equanda/tool/translationsEditor/KeyEditorPanel.java 2008-10-27 10:15:39 UTC (rev 796) +++ trunk/equanda-tool/src/main/java/org/equanda/tool/translationsEditor/KeyEditorPanel.java 2008-10-27 10:23:44 UTC (rev 797) @@ -25,9 +25,9 @@ package org.equanda.tool.translationsEditor; import javolution.lang.TextBuilder; +import org.equanda.domain.xml.Action; import org.equanda.domain.xml.Choice; -import org.equanda.domain.xml.DomainModel; -import org.equanda.domain.xml.Field; +import org.equanda.domain.xml.*; import org.equanda.domain.xml.transform.RootTable; import org.equanda.translations.Key; import org.equanda.translations.Translation; @@ -78,7 +78,7 @@ GridBagConstraints constr = new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0 , GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets( 2, 2, 2, 2 ), 0, 0 ); + new Insets( 2, 2, 2, 2 ), 0, 0 ); constr.weightx = 1.0; trans.add( new JLabel( "Context : " ), constr ); @@ -165,35 +165,36 @@ else if ( "type".equals( base ) ) { RootTable table = addTable( tb, ss.next() ); - // ..... type.TableName.TypeName + addType( tb, table, ss.next() ); } else if ( "group".equals( base ) ) { RootTable table = addTable( tb, ss.next() ); - // ..... group.TableName.GroupName + addGroup( tb, table, ss.next() ); } else if ( "select".equals( base ) ) { RootTable table = addTable( tb, ss.next() ); - // ..... select.TableName.SelectName + addSelect( tb, table, ss.next() ); } else if ( "parameter".equals( base ) ) { RootTable table = addTable( tb, ss.next() ); - // ..... parameter.TableName.SelectName.(selector.getField) + Select select = addSelect( tb, table, ss.next() ); + addSelectField( tb, select, ss.next() ); } else if ( "action".equals( base ) ) { RootTable table = addTable( tb, ss.next() ); - // ..... action.TableName.ActionName + addAction( tb, table, ss.next() ); } else if ( "param".equals( base ) ) { RootTable table = addTable( tb, ss.next() ); - // ..... param.TableName.ActionName.Parameter + Action action = addAction( tb, table, ss.next() ); + addActionParam( tb, action, ss.next() ); } } - System.out.println( "setDescription "+tb.toString() ); description.setText( tb.toString() ); } else @@ -216,6 +217,20 @@ return table; } + private Table addType( TextBuilder tb, RootTable root, String typeName ) + { + Table table = root.getTable( typeName ); + if ( null != table && null != table.getDescription() && !"".equals( table.getDescription() ) ) + { + tb.append( "Type " ); + tb.append( typeName ); + tb.append( " : " ); + tb.append( table.getDescription() ); + tb.append( '\n' ); + } + return table; + } + private Field addField( TextBuilder tb, RootTable table, String fieldName ) { Field field = null; @@ -253,6 +268,94 @@ return choice; } + private Group addGroup( TextBuilder tb, RootTable root, String groupName ) + { + Group group = root.getGroup( groupName ); + if ( null != group && null != group.getDescription() && !"".equals( group.getDescription() ) ) + { + tb.append( "Group " ); + tb.append( groupName ); + tb.append( " : " ); + tb.append( group.getDescription() ); + tb.append( '\n' ); + } + return group; + } + + private Select addSelect( TextBuilder tb, RootTable root, String selectName ) + { + Select select = root.getSelect( selectName ); + if ( null != select && null != select.getDescription() && !"".equals( select.getDescription() ) ) + { + tb.append( "Type " ); + tb.append( selectName ); + tb.append( " : " ); + tb.append( select.getDescription() ); + tb.append( '\n' ); + } + return select; + } + + private void addSelectField( TextBuilder tb, Select select, String fieldName ) + { + if ( fieldName == null ) return; + Field field = null; + for ( Selection s : select.getSelectionsDeep() ) + { + if ( null != s.getField() ) + { + if ( fieldName.equals( s.getField().getName() ) ) + { + field = s.getField(); + break; + } + } + } + if ( null != field && null != field.getDescription() && !"".equals( field.getDescription() ) ) + { + tb.append( "Selection on field " ); + tb.append( fieldName ); + tb.append( " : " ); + tb.append( field.getDescription() ); + tb.append( '\n' ); + } + } + + private Action addAction( TextBuilder tb, RootTable root, String actionName ) + { + Action action = root.getAction( actionName ); + if ( null != action && null != action.getDescription() && !"".equals( action.getDescription() ) ) + { + tb.append( "Action " ); + tb.append( actionName ); + tb.append( " : " ); + tb.append( action.getDescription() ); + tb.append( '\n' ); + } + return action; + } + + private void addActionParam( TextBuilder tb, Action action, String paramName ) + { + Parameter param = null; + for ( Parameter p : action.getParameters() ) + { + if ( paramName.equals( p.getName() ) ) + { + param = p; + break; + } + } + if ( null != param && null != param.getDescription() && !"".equals( param.getDescription() ) ) + { + tb.append( "Parameter " ); + tb.append( paramName ); + tb.append( " : " ); + tb.append( param.getDescription() ); + tb.append( '\n' ); + } + } + public void save() { if ( key == null ) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |