diff options
author | nhauge | 2009-12-02 21:43:12 +0000 |
---|---|---|
committer | nhauge | 2009-12-02 21:43:12 +0000 |
commit | 43aa60b5d0f5511953e750a5984fae3b30016bbe (patch) | |
tree | ad3733bea8088e884cc70eb339cf0d775bb1dcb8 | |
parent | be043d585a06c0c6d269ff6b94829d44fd87bddd (diff) | |
download | webtools.dali-43aa60b5d0f5511953e750a5984fae3b30016bbe.tar.gz webtools.dali-43aa60b5d0f5511953e750a5984fae3b30016bbe.tar.xz webtools.dali-43aa60b5d0f5511953e750a5984fae3b30016bbe.zip |
294771 - sort user added associations in entity gen wizard - contributed patch.
-rw-r--r-- | jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java index c42694e86e..126279f92d 100644 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java +++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java @@ -15,6 +15,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -590,6 +592,8 @@ public abstract class ORMGenCustomizer implements java.io.Serializable * the last time the state was persisted. Pass checkExisting true so that the * associations restored above are not overwritten.*/ addForeignKeyAssociations(true/*checkExisting*/); + // sort on restore + sortAssociations( mAssociations ); } } /** @@ -786,4 +790,22 @@ public abstract class ORMGenCustomizer implements java.io.Serializable } int mVersion; } + + private void sortAssociations( List< Association > list ) { + Collections.sort( list, new Comparator< Association >() { + public int compare( Association lhs, Association rhs ) { + // sort by referrer table name first... + int test = lhs.getReferrerTableName().compareTo( rhs.getReferrerTableName() ); + if( test != 0 ) + return test; + // then by referenced table name... + test = lhs.getReferencedTableName().compareTo( rhs.getReferencedTableName() ); + if( test != 0 ) + return test; + // if referrer and referenced tables are the same, they should + // appear next to each other + return 0; + } + } ); + } } |