editor changes for red list project (datasource view and create new datasource from...
authorKatja Luther <k.luther@bgbm.org>
Wed, 18 Jun 2014 12:16:35 +0000 (12:16 +0000)
committerKatja Luther <k.luther@bgbm.org>
Wed, 18 Jun 2014 12:16:35 +0000 (12:16 +0000)
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/handler/DataSourceMenuPropertyTester.java

index 278780a8b0a748f543a3bfed1fe4a248d8bd6405..46c6c24cc5d983d5287f2294031a0e88799962f7 100644 (file)
                label="Specimen"
                style="push">
          </command>
+         <separator
+               name="eu.etaxonomy.navigation.menu.new.separator3">
+         </separator>
+         <command
+               commandId="eu.etaxonomy.taxeditor.editor.command.new.datasource"
+               label="Datasource"
+               style="push">
+         </command>
       </menuContribution>
       <menuContribution
             locationURI="menu:eu.etaxonomy.taxeditor.menu.showView?before=eu.etaxonomy.taxeditor.store.showViewMenu.details">
             id="eu.etaxonomy.taxeditor.editor.handler.openDerivateView"
             name="Open Derivate View">
       </command>
+      <command
+            categoryId="eu.etaxonomy.taxeditor.editor.new.category"
+            defaultHandler="eu.etaxonomy.taxeditor.view.datasource.handler.CreateDataSourceHandler"
+            id="eu.etaxonomy.taxeditor.editor.command.new.datasource"
+            name="New Datasource">
+      </command>
 
    </extension>
    <extension
index c1abd2396b1a568096a534b6f95b65c7d67332b1..7d2b53303b1cac0d05022a152a79ad105cd7d6b1 100644 (file)
                commandId="eu.etaxonomy.taxeditor.store.datasource.change"
                label="Connect"
                style="push">
+               <visibleWhen>
+              <with
+                        variable="selection">
+                        <not>
+                               <test
+                                       property="eu.etaxonomy.taxeditor.datasource.propertyTester.test">
+                               </test>
+                       </not>
+                       </with>
+            </visibleWhen>
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.store.datasource.create"
                commandId="eu.etaxonomy.taxeditor.store.datasource.edit"
                label="Edit"
                style="push">
+                <visibleWhen>
+              <with
+                        variable="selection">
+                        <not>
+                               <test
+                                       property="eu.etaxonomy.taxeditor.datasource.propertyTester.test">
+                               </test>
+                       </not>
+                       </with>
+            </visibleWhen>
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.store.datasource.clone"
                label="Clone"
                style="push">
+                <visibleWhen>
+              <with
+                        variable="selection">
+                        <not>
+                               <test
+                                       property="eu.etaxonomy.taxeditor.datasource.propertyTester.test">
+                               </test>
+                       </not>
+                       </with>
+            </visibleWhen>
          </command>
          <separator
                name="eu.etaxonomy.taxeditor.store.datasource.separator"
                commandId="org.eclipse.ui.edit.delete"
                label="Delete"
                style="push">
+               <visibleWhen>
+              <with
+                        variable="selection">
+                        <not>
+                               <test
+                                       property="eu.etaxonomy.taxeditor.datasource.propertyTester.test">
+                               </test>
+                       </not>
+                       </with>
+            </visibleWhen>
          </command>
          <separator
                name="eu.etaxonomy.taxeditor.store.datasource.separator2"
                commandId="eu.etaxonomy.taxeditor.store.datasource.close"
                label="Close Active Connection"
                style="push">
+               <visibleWhen>
+              <with
+                        variable="selection">
+                        <not>
+                               <test
+                                       property="eu.etaxonomy.taxeditor.datasource.propertyTester.test">
+                               </test>
+                       </not>
+                       </with>
+            </visibleWhen>
          </command>
          <command
                commandId="eu.etaxonomy.taxeditor.store.datasource.update"
                   </reference>
                </not>
             </visibleWhen>
+            
          </command>
       </menuContribution>
       <menuContribution
             </reference></enabledWhen>
       </handler>
    </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.view.datasource.handler.ChangeConnectionHandler"
+            id="eu.etaxonomy.taxeditor.datasource.connect"
+            name="Connect">
+      </command>
+   </extension>
    <extension
          name="Popup Menu Commands"
          point="org.eclipse.ui.commands">
          namespace="eu.etaxonomy.taxeditor.datasource.propertyTester"
          properties="isCompatible"
          type="org.eclipse.jface.viewers.IStructuredSelection">
+   </propertyTester>
+    <propertyTester
+         class="eu.etaxonomy.taxeditor.view.datasource.handler.DataSourceMenuPropertyTester"
+         id="eu.etaxonomy.taxeditor.datasource.propertyTester"
+         namespace="eu.etaxonomy.taxeditor.datasource.propertyTester"
+         properties="test"
+         type="org.eclipse.jface.viewers.IStructuredSelection">
    </propertyTester>
    <propertyTester
          class="eu.etaxonomy.taxeditor.preference.PreferencePropertyTester"
index 41391059cf680ccf95c9444e0ef001ffc7e9a292..a8a01defa134a51bb393d5a2c41ca98c221f17ff 100644 (file)
@@ -25,6 +25,7 @@ import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContaine
 public class DataSourceMenuPropertyTester extends PropertyTester {
 
        private static final String COMPATIBLE = "isCompatible";
+       private static final String TEST = "test";
 
        /*
         * (non-Javadoc)
@@ -39,15 +40,21 @@ public class DataSourceMenuPropertyTester extends PropertyTester {
 
                Object[] selectedElements = ((IStructuredSelection) receiver).toArray();
 
-               if (selectedElements.length == 0) {
+               if (selectedElements.length == 0 && property.equals(TEST)) {
                        // nothing selected so all tests should fail
-                       return false;
+                       return true;
+               }
+               if (selectedElements.length == 0 && COMPATIBLE.equals(property)) {
+                       // nothing selected so all tests should fail
+                       return true;
                }
 
                if (COMPATIBLE.equals(property)) {
                        return isCompatible(selectedElements);
                }
                
+               
+               
 
                return false;
        }
@@ -59,6 +66,11 @@ public class DataSourceMenuPropertyTester extends PropertyTester {
         * @return
         */
        private boolean isCompatible(Object[] selectedElements) {
+               
+               if (selectedElements.length == 0 ) {
+                       // nothing selected so all tests should fail
+                       return false;
+               }
                for (Object object : selectedElements) {
 
                        if (object instanceof CdmMetaDataAwareDataSourceContainer) {
@@ -67,5 +79,6 @@ public class DataSourceMenuPropertyTester extends PropertyTester {
                        }
                }
                return false;
+               
        }
 }