JAXB import successful with test file
authora.babadshanjan <a.babadshanjan@localhost>
Fri, 12 Dec 2008 14:48:38 +0000 (14:48 +0000)
committera.babadshanjan <a.babadshanjan@localhost>
Fri, 12 Dec 2008 14:48:38 +0000 (14:48 +0000)
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ImportAction.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmUtil.java
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java

index fcf5ce7b8a2cec8ee0e744fd51063f59bae6057e..d335b0b95ad6e32797d8af428a453c8278602391 100644 (file)
@@ -77,11 +77,16 @@ public class ImportAction extends Action {
                // Get current data source\r
                ICdmDataSource destination = TaxEditorPlugin.getDefault().getCdmDataSource();\r
                \r
+               // Get plugin application controller\r
+               CdmApplicationController app = TaxEditorPlugin.getDefault().getCdmApp();\r
+               TaxEditorPlugin.getDefault().commitTransaction();\r
+               TaxEditorPlugin.getDefault().getCdmApp().close();\r
+               \r
                // Format file path \r
                String source = null;\r
                try {\r
-                       //source = file.toURI().toURL().toString();\r
-                       source = file.toString();\r
+                       source = file.toURI().toURL().toString();\r
+                       //source = file.toString();\r
                } catch (/*MalformedURL*/Exception e) {\r
                        MessageDialog.openError(UiUtil.getShell(), title, "File could not be read.");\r
                        return;\r
index 687ad3ded9878888d64de57b53757467fead3f63..a3e53a3d38ada0050f77360d33fac83395440e8c 100644 (file)
@@ -398,7 +398,9 @@ public class CdmUtil {
                if (ranks == null) {\r
 //                     TransactionStatus tx = startReadOnlyTransaction();\r
                        OrderedTermVocabulary<Rank> rankVocabulary = TaxEditorPlugin.getDefault().getRankVocabulary();\r
-                       ranks = rankVocabulary.getOrderedTerms(null);\r
+                       if (rankVocabulary != null) {\r
+                               ranks = rankVocabulary.getOrderedTerms(null);\r
+                       } // else { TODO: error message\r
 //                     commitTransaction(tx);\r
                }\r
                return ranks;\r
index 3395178833bd404b35f53f52dd14aba428bd471f..9838009a3428bbf448e402e5cd06ff04c02cb087 100644 (file)
@@ -11,6 +11,7 @@ package eu.etaxonomy.taxeditor.preference;
 \r
 import java.util.HashSet;\r
 import java.util.Set;\r
+import java.util.SortedSet;\r
 \r
 import org.apache.log4j.Logger;\r
 import org.eclipse.jface.preference.IPreferenceStore;\r
@@ -166,14 +167,17 @@ public class PreferencesUtil {
                if (UiUtil.preferredRankSet == null) {\r
                        \r
                        UiUtil.preferredRankSet = new HashSet<Rank>();  \r
-                                               \r
-                       for (Rank rank : CdmUtil.getRanks()) {\r
-                               \r
-                               // If the feature is set to show, add it to preferredFeatureSet\r
-                               if (PreferencesUtil.getRankPreference(rank)) {\r
-                                       UiUtil.preferredRankSet.add(rank);\r
+                       \r
+                       SortedSet<Rank> ranks = CdmUtil.getRanks();\r
+                       if (ranks != null) {\r
+                               for (Rank rank : ranks) {\r
+\r
+                                       // If the feature is set to show, add it to preferredFeatureSet\r
+                                       if (PreferencesUtil.getRankPreference(rank)) {\r
+                                               UiUtil.preferredRankSet.add(rank);\r
+                                       }\r
                                }\r
-                       }\r
+                       } // else { TODO: error message\r
                        \r
                }\r
                return UiUtil.preferredRankSet;\r