GrantedAuthoritySelectionDialog implemented for #2990 (implement missing parts of...
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Thu, 13 Sep 2012 10:31:46 +0000 (10:31 +0000)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Thu, 13 Sep 2012 10:31:46 +0000 (10:31 +0000)
.gitattributes
eu.etaxonomy.taxeditor.cdmlib/.classpath
eu.etaxonomy.taxeditor.cdmlib/lib/org.eclipse.osgi-3.7.2.v20120110-1415.jar
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmResourceSelectionDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GrantedAuthoritySelectionDialog.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/group/GrantedAuthorityDetailSection.java

index d5105fce4224ea118a040914a6fa478a17f163cc..58caab21af2db3d69d916225f416676ba88aced7 100644 (file)
@@ -1231,6 +1231,7 @@ eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/sele
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FieldObservationSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FieldObservationSelectionDialog.java -text
+eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GrantedAuthoritySelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GroupSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/InstitutionSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NameSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GroupSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/InstitutionSelectionDialog.java -text
 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NameSelectionDialog.java -text
index afa268e1d1665fb9120f524e724a7c4de0669525..73a0fced3936375c13261566b1e026de4c12345a 100644 (file)
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.13-SNAPSHOT-sources.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.13-SNAPSHOT.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.13-SNAPSHOT-sources.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.13-SNAPSHOT-sources.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.13-SNAPSHOT.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.13-SNAPSHOT-sources.jar"/>
-       <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.13-SNAPSHOT.jar"/>
+       <classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.13-SNAPSHOT.jar" sourcepath="lib/cdmlib-services-3.0.13-SNAPSHOT-sources.jar"/>
        <classpathentry exported="true" kind="lib" path="lib/postgresql-9.1-901.jdbc4.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
        <classpathentry exported="true" kind="lib" path="lib/postgresql-9.1-901.jdbc4.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index f131a431cbf20a8f2194c84912950bd3e0a6485b..25f118068392d39fda76feea6c855dfb3633db17 100644 (file)
Binary files a/eu.etaxonomy.taxeditor.cdmlib/lib/org.eclipse.osgi-3.7.2.v20120110-1415.jar and b/eu.etaxonomy.taxeditor.cdmlib/lib/org.eclipse.osgi-3.7.2.v20120110-1415.jar differ
index 5b9ed355d90dd4d8018fd98463bdfcc694d2a752..b302a8ead9cb24191968cf44f35949e54690b83f 100644 (file)
@@ -249,18 +249,18 @@ public class CdmStore {
        }
 
        /**
        }
 
        /**
-        * Generic method that will return an implementation of the given service
-        * interface or <code>null</code> if the
+        * Generic method that will scan the getters of {@link ICdmApplicationConfiguration} for the given service
+        * interface. If a matching getter is found the according service implementation is returned by 
+        * invoking the getter otherwise the method returns <code>null</code>. 
         * 
         * @param <T>
         * @param serviceClass
         * 
         * @param <T>
         * @param serviceClass
-        * @return
+        * @return the configured implementation of <code>serviceClass</code> or <code>null</code>
         */
        public static <T extends IService> T getService(Class<T> serviceClass) {
                ICdmApplicationConfiguration configuration = getCurrentApplicationConfiguration();
 
         */
        public static <T extends IService> T getService(Class<T> serviceClass) {
                ICdmApplicationConfiguration configuration = getCurrentApplicationConfiguration();
 
-               Method[] methods = ICdmApplicationConfiguration.class
-                               .getDeclaredMethods();
+               Method[] methods = ICdmApplicationConfiguration.class.getDeclaredMethods();
 
                T service = null;
 
 
                T service = null;
 
index 4f024bd3c8ae041a3047f3a08c874ade6aed3193..242af03207e4efce790bf86f87526b2d13f52f03 100644 (file)
@@ -493,8 +493,10 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        public void update(CdmDataChangeMap changeEvents) {}
 
        /**
        public void update(CdmDataChangeMap changeEvents) {}
 
        /**
-        * Don't want to add a taxon or synonym to itself so filter the list to remove the taxon in question
-        * so it is not available to add as a concept relation
+        * Don't want to add for example a taxon or synonym to itself 
+        * so filter the list to remove the taxon in question 
+        * (<code>cdmBaseToBeFiltered</code>)
+        * so it is not available in the filtered list.
         */
        private void filterExcludedObjects() {
                if (model != null && cdmBaseToBeFiltered != null) {
         */
        private void filterExcludedObjects() {
                if (model != null && cdmBaseToBeFiltered != null) {
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GrantedAuthoritySelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GrantedAuthoritySelectionDialog.java
new file mode 100644 (file)
index 0000000..794f7b6
--- /dev/null
@@ -0,0 +1,102 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.ui.dialog.selection;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.swt.widgets.Shell;
+import org.springframework.security.core.GrantedAuthority;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
+import eu.etaxonomy.cdm.api.service.IGroupService;
+import eu.etaxonomy.cdm.api.service.IUserService;
+import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
+import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
+import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.newWizard.NewGroupWizard;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author a.kohlbecker
+ * @created Sept 12, 2011
+ * @version 1.0
+ */
+public class GrantedAuthoritySelectionDialog extends   AbstractFilteredCdmResourceSelectionDialog<GrantedAuthorityImpl> {
+
+       public static GrantedAuthority select(Shell shell, ConversationHolder conversation, GrantedAuthorityImpl authority){
+               
+               GrantedAuthoritySelectionDialog dialog = new GrantedAuthoritySelectionDialog(shell, conversation,
+                               "Choose Granted Authority", false, GrantedAuthoritySelectionDialog.class.getCanonicalName(), authority);
+               
+               return getSelectionFromDialog(dialog);
+       }
+       
+       /**
+        * @param shell
+        * @param conversation
+        * @param title
+        * @param multi
+        * @param settings
+        * @param cdmObject
+        */
+       protected GrantedAuthoritySelectionDialog(Shell shell,
+                       ConversationHolder conversation, String title, boolean multi,
+                       String settings, GrantedAuthorityImpl cdmObject) {
+               super(shell, conversation, title, multi, settings, cdmObject);
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
+        */
+       @Override
+       protected void initModel() {
+               List<GrantedAuthorityImpl> authorities = CdmStore.getService(IGrantedAuthorityService.class).list(GrantedAuthorityImpl.class, null, null, null, null);
+               
+               model = new ArrayList<UuidAndTitleCache<GrantedAuthorityImpl>>();
+               
+               for(GrantedAuthorityImpl authority : authorities){
+                       model.add(new UuidAndTitleCache<GrantedAuthorityImpl>(GrantedAuthorityImpl.class, authority.getUuid(),String.format("%s", authority.getAuthority())));
+               }       
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
+        */
+       @Override
+       protected String getNewWizardLinkText() {
+               return "Create a new <A>GrantedAuthority</A>.";
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
+        */
+       @Override
+       protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
+               return new NewGroupWizard();
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
+        */
+       @Override
+       protected GrantedAuthorityImpl getPersistentObject(UUID uuid) {
+               return CdmStore.getService(IGrantedAuthorityService.class).load(uuid);
+       }
+       
+       @Override
+       protected String getTitle(GrantedAuthorityImpl authority) {
+               return authority != null ? authority.getAuthority() : "";
+       }
+
+}
index 10a15547460fbc3498a68e5f0988d1a6a777ec2d..aebc5a524109c56021a19e603178f0a73136a331 100644 (file)
@@ -17,6 +17,7 @@ import org.springframework.security.core.GrantedAuthority;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.GrantedAuthoritySelectionDialog;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
@@ -62,11 +63,11 @@ public class GrantedAuthorityDetailSection extends
         */
        @Override
        public GrantedAuthority createNewElement() {
         */
        @Override
        public GrantedAuthority createNewElement() {
-               StoreUtil
-                               .warningDialog("Not implemented yet", getClass(),
-                                               "This functionality needs to be implemented in CDM Library first.");
-               // TODO GrantedAuthoritySelectionDialog.select(...);
-               GrantedAuthority selection = null;
+//             StoreUtil
+//                             .warningDialog("Not implemented yet", getClass(),
+//                                             "This functionality needs to be implemented in CDM Library first.");
+               
+               GrantedAuthority selection = GrantedAuthoritySelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
                return selection;
        }
 
                return selection;
        }
 
@@ -101,7 +102,7 @@ public class GrantedAuthorityDetailSection extends
         */
        @Override
        public String getEmptyString() {
         */
        @Override
        public String getEmptyString() {
-               return "No Granted Athorities yet.";
+               return "No Granted Authorities yet.";
        }
 
        /*
        }
 
        /*