Remove "Close Connection" and changed "Connect" to "Create Data Model"
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 11 May 2016 15:28:25 +0000 (17:28 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 11 May 2016 15:28:25 +0000 (17:28 +0200)
#5758

eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/bundle_de.properties
eu.etaxonomy.taxeditor.store/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/handler/CloseConnectionHandler.java [deleted file]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/handler/DataSourceMenuPropertyTester.java

index a583b3c6e92ce25acdf2abeff40e43145cf8ebba..29fb7936d042347de9fa285c9d33b3b62461cc26 100644 (file)
@@ -43,11 +43,10 @@ command.label.2 = Datasource
 command.label.3 = Error Log\r
 command.label.4 = Reporting\r
 command.label.5 = Switch User\r
-command.label.6 = Connect\r
+command.label.6 = Create Data Model\r
 command.label.7 = New\r
 command.label.8 = Edit\r
 command.label.9 = Delete\r
-command.label.10 = Close Active Connection\r
 command.label.11 = Update Datamodel\r
 menu.label.0 = New\r
 command.label.12 = Vocabulary\r
@@ -57,7 +56,6 @@ extension.name = Popup Menu Commands
 command.name = Connect Datasource\r
 command.name.0 = Edit Datasource\r
 command.name.1 = Create Datasource\r
-command.name.2 = Close Active Connection\r
 command.name.3 = Update Datasource\r
 command.name.4 = Show Login Window\r
 command.name.5 = Open Defined Term Editor\r
index 2b82b3b32ef99b290bd476a30849689e442fa629..f4b5a5283818540e4a4d09fc7d7efb4a00c2792a 100644 (file)
@@ -43,12 +43,11 @@ command.label.2 = Datenquelle
 command.label.3 = Fehlermeldungen
 command.label.4 = Berichte
 command.label.5 = Benutzer wechseln
-command.label.6 = Verbinden
+command.label.6 = Datenmodell erstellen
 command.label.7 = Neu
 command.label.8 = Bearbeiten
 command.label.9 = L\u00f6schen
-command.label.10 = Schlie\u00dfe aktive Verbindung
-command.label.11 = Aktualisiere Datenmodel
+command.label.11 = Aktualisiere Datenmodell
 menu.label.0 = Neu
 command.label.12 = Vokabular
 command.label.13 = Definierter Begriff
@@ -57,7 +56,6 @@ extension.name = Popup Men\u00fc Befehle
 command.name = Verbinde Datenquelle
 command.name.0 = Bearbeite Datenquelle
 command.name.1 = Erstelle Datenquelle
-command.name.2 = Schlie\u00dfe aktive Verbindungen
 command.name.3 = Aktualisiere Datenquellen
 command.name.4 = Zeige Login Window
 command.name.5 = \u00d6ffne Editor f\u00fcr definierte Begriffe
index 768db4a3e12809060043ebf65b24be7937bcba21..3ecd5c12a21f9c9f15c322c1e050be3e089e0649 100644 (file)
                label="%command.label.6"
                style="push">
                <visibleWhen>
-              <with
-                        variable="selection">
-                        <not>
-                               <test
-                                       property="eu.etaxonomy.taxeditor.datasource.propertyTester.test">
-                               </test>
-                       </not>
-                       </with>
+                  <not>
+                     <reference
+                           definitionId="hasDataModel">
+                     </reference>
+                  </not>
             </visibleWhen>
          </command>
          <command
                name="eu.etaxonomy.taxeditor.store.datasource.separator2"
                visible="true">
          </separator>
-         <command
-               commandId="eu.etaxonomy.taxeditor.store.datasource.close"
-               label="%command.label.10"
-               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"
                label="%command.label.11"
             id="eu.etaxonomy.taxeditor.store.datasource.create"
             name="%command.name.1">
       </command>
-      <command
-            defaultHandler="eu.etaxonomy.taxeditor.view.datasource.handler.CloseConnectionHandler"
-            id="eu.etaxonomy.taxeditor.store.datasource.close"
-            name="%command.name.2">
-      </command>
       <command
             defaultHandler="eu.etaxonomy.taxeditor.view.datasource.handler.DeleteDataSourceHandler"
             id="eu.etaxonomy.taxeditor.view.datasource.delete"
          class="eu.etaxonomy.taxeditor.view.datasource.handler.DataSourceMenuPropertyTester"
          id="eu.etaxonomy.taxeditor.datasource.propertyTester"
          namespace="eu.etaxonomy.taxeditor.datasource.propertyTester"
-         properties="test"
+         properties="test, hasDataModel"
          type="org.eclipse.jface.viewers.IStructuredSelection">
    </propertyTester>
    <propertyTester
          </test>
       </with>
    </definition>
+   <definition
+         id="hasDataModel">
+      <with
+            variable="selection">
+         <test
+               property="eu.etaxonomy.taxeditor.datasource.propertyTester.hasDataModel">
+         </test>
+      </with>
+   </definition>
    <definition
          id="isShowExperimentalFeatures">
       <with
index 9520f97bc685dc0e8f1dceabd7b4d592fb229276..3beb0d77cc4a8cccd3a4fbbf080bc2002051f5ac 100644 (file)
@@ -38,9 +38,9 @@ import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 import eu.etaxonomy.taxeditor.ui.dialog.LoginDialog;
 import eu.etaxonomy.taxeditor.ui.dialog.RemotingLoginDialog;
-import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
 
 
 /**
@@ -110,9 +110,12 @@ class CdmStoreConnector extends Job {
             try {
                 Thread.currentThread().setPriority(10);
                 applicationController = getApplicationController(cdmSource,subprogressMonitor);
+                return Status.OK_STATUS;
             } catch (Exception e) {
                 if(! causeIsCancelationExceptionRecursive(e)){
-                    return new Status(IStatus.ERROR, "Could not connect to CDM Store", "An error occurred while trying to connect to datasource: " + cdmSource.getName(), e);
+                    MessagingUtils.errorDialog("Could not create data model", CdmStoreConnector.class, "An error occurred while trying to create "
+                            + "data model for data source: " + cdmSource.getName()+"\n Please clear the data base and retry. ", TaxeditorStorePlugin.PLUGIN_ID, e, true);
+                    return Status.CANCEL_STATUS;
                 }
             } finally {
                 monitor.done();
@@ -120,42 +123,7 @@ class CdmStoreConnector extends Job {
             }
         }
 
-
-
-        if (!monitor.isCanceled()) {
-            CdmStore.setInstance(applicationController, cdmSource);
-
-            display.asyncExec(new Runnable() {
-                /*
-                 * (non-Javadoc)
-                 *
-                 * @see java.lang.Runnable#run()
-                 */
-                @Override
-                public void run() {
-                    authenticate();
-
-                    startContext();
-                }
-            });
-
-            MessagingUtils.info("Application context initialized.");
-            return Status.OK_STATUS;
-        } else {
-            // Show datasource view if not shown yet
-            display.asyncExec(new Runnable() {
-                /*
-                 * (non-Javadoc)
-                 *
-                 * @see java.lang.Runnable#run()
-                 */
-                @Override
-                public void run() {
-                    StoreUtil.showView(CdmDataSourceViewPart.ID);
-                }
-            });
             return Status.CANCEL_STATUS;
-        }
 
     }
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/handler/CloseConnectionHandler.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/datasource/handler/CloseConnectionHandler.java
deleted file mode 100644 (file)
index 62867a1..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-// $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.view.datasource.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
-
-/**
- * <p>CloseConnectionHandler class.</p>
- *
- * @author n.hoffmann
- * @created Mar 22, 2010
- * @version 1.0
- */
-public class CloseConnectionHandler extends AbstractHandler {
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-        */
-       /** {@inheritDoc} */
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               Shell shell = HandlerUtil.getActiveShell(event);
-               
-               boolean confirmed = MessageDialog.openConfirm(shell, "Confirm Datasource Close", "Do you really want to close the datasource connection?\n\n");
-               
-               if(confirmed){
-                       CdmStore.close(StoreUtil.getMonitor());
-               }
-               
-               CdmDataSourceViewPart view = (CdmDataSourceViewPart) StoreUtil.getView(CdmDataSourceViewPart.ID, true);
-               
-               view.refresh();
-               
-               return null;
-       }
-}
index a8a01defa134a51bb393d5a2c41ca98c221f17ff..622b5f4dad61fec0d74498a225f6835cb3c7897d 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 /**
  * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy 
+ * 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.
  */
@@ -13,11 +13,10 @@ package eu.etaxonomy.taxeditor.view.datasource.handler;
 import org.eclipse.core.expressions.PropertyTester;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
+import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
 import eu.etaxonomy.taxeditor.view.datasource.CdmMetaDataAwareDataSourceContainer;
 
 /**
- * <p>DataSourceMenuPropertyTester class.</p>
- *
  * @author n.hoffmann
  * @created Sep 23, 2010
  * @version 1.0
@@ -26,20 +25,14 @@ public class DataSourceMenuPropertyTester extends PropertyTester {
 
        private static final String COMPATIBLE = "isCompatible";
        private static final String TEST = "test";
+       private static final String HAS_DATA_MODEL = "hasDataModel";
 
-       /*
-        * (non-Javadoc)
-        * 
-        * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
-        * java.lang.String, java.lang.Object[], java.lang.Object)
-        */
        /** {@inheritDoc} */
        @Override
        public boolean test(Object receiver, String property, Object[] args,
                        Object expectedValue) {
 
                Object[] selectedElements = ((IStructuredSelection) receiver).toArray();
-
                if (selectedElements.length == 0 && property.equals(TEST)) {
                        // nothing selected so all tests should fail
                        return true;
@@ -52,21 +45,33 @@ public class DataSourceMenuPropertyTester extends PropertyTester {
                if (COMPATIBLE.equals(property)) {
                        return isCompatible(selectedElements);
                }
-               
-               
-               
-
+               if (HAS_DATA_MODEL.equals(property)) {
+                   return hasDataModel(selectedElements);
+               }
                return false;
        }
 
+          private boolean hasDataModel(Object[] selectedElements) {
+
+               if (selectedElements.length == 0 ) {
+                   // nothing selected so all tests should fail
+                   return false;
+               }
+               for (Object object : selectedElements) {
+
+                   if (object instanceof CdmMetaDataAwareDataSourceContainer) {
+                       CdmMetaDataAwareDataSourceContainer container = (CdmMetaDataAwareDataSourceContainer) object;
+                       String schemaVersion = container.getMetaData(MetaDataPropertyName.DB_SCHEMA_VERSION);
+                    return !schemaVersion.equals(CdmMetaDataAwareDataSourceContainer.DEFAULT_ENTRY);
+                   }
+               }
+               return false;
+
+           }
 
 
-       /**
-        * @param selectedElements
-        * @return
-        */
        private boolean isCompatible(Object[] selectedElements) {
-               
+
                if (selectedElements.length == 0 ) {
                        // nothing selected so all tests should fail
                        return false;
@@ -79,6 +84,6 @@ public class DataSourceMenuPropertyTester extends PropertyTester {
                        }
                }
                return false;
-               
+
        }
 }