finalizing preferred refactoring
authorn.hoffmann <n.hoffmann@localhost>
Wed, 17 Jun 2009 15:56:45 +0000 (15:56 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 17 Jun 2009 15:56:45 +0000 (15:56 +0000)
23 files changed:
.gitattributes
taxeditor-store/META-INF/MANIFEST.MF
taxeditor-store/plugin.xml
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceH2WizardPage.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceMySQLWizardPage.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceSQLServerWizardPage.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceWizard.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceWizardPage.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizardPage.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsExportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsImportWizard.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/ImagesUtil.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/AbstractMenuPreferences.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/FeatureMenuPreferences.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizard.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardNewPage.java [deleted file]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardPage.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java

index 7feca141436450212ee8cdd13e66bf7fe40df4c3..00e94460393c2d9acc04e859e70a077fa7508bb8 100644 (file)
@@ -956,6 +956,7 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/view/CdmDataSour
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceCredentialsWizardPage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceH2WizardPage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceMySQLWizardPage.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceSQLServerWizardPage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceWizardPage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/FilteredCdmResourceSelectionDialog.java -text
@@ -965,6 +966,13 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/SelectionDialogDeta
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/SelectionDialogSelectionLabelProvider.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/dialogs/UriDialog.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/handler/ShowDataSourceViewHandler.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizardPage.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbImportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsExportWizard.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsImportWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractDataChangeBehaviour.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/DataChangeBridge.java -text
@@ -1021,7 +1029,7 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/RankMenuPreferen
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/TaxonomicPreferences.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizard.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardEditPage.java -text
-taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardNewPage.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardPage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/StoreUtil.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/store/internal/TaxeditorStorePlugin.java -text
index 2be1c7b837f7c3f0438e2b9d56ce2f42bfefa960..0b282ba17f56b200cfc190d395195b4e1152f247 100644 (file)
@@ -17,7 +17,14 @@ Export-Package: eu.etaxonomy.taxeditor.datasource,
  eu.etaxonomy.taxeditor.preference,
  eu.etaxonomy.taxeditor.store,
  eu.etaxonomy.taxeditor.store.internal
-Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",org.eclipse.core.filesystem;bundle-version="1.2.0",org.eclipse.core.resources;bundle-version="3.4.1",eu.etaxonomy.cdmLibrary;bundle-version="2.1.0",org.eclipse.ui.editors;bundle-version="3.4.0",org.eclipse.jface.text;bundle-version="3.4.1"
+Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.filesystem;bundle-version="1.2.0",
+ org.eclipse.core.resources;bundle-version="3.4.1",
+ eu.etaxonomy.cdmLibrary;bundle-version="2.1.0",
+ org.eclipse.ui.editors;bundle-version="3.4.0",
+ org.eclipse.jface.text;bundle-version="3.4.1",
+ org.eclipse.ui.ide;bundle-version="3.4.2"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Import-Package: junit.framework,org.junit
 Bundle-ActivationPolicy: lazy
index 37791504d1961ff33206c90f6018726c50a42b5e..cad100671a422ec62cd7eec29e40c0b5653b9e00 100644 (file)
@@ -22,7 +22,7 @@
       </page-->
       <page
             category="eu.etaxonomy.taxeditor.preferences.description"
-            class="eu.etaxonomy.taxeditor.preference.FeaturePreferences"
+            class="eu.etaxonomy.taxeditor.preference.FeatureMenuPreferences"
             id="eu.etaxonomy.taxeditor.preferences.feature"
             name="Preferred Features">
       </page>
                style="push">
          </command>
       </menuContribution>
+      <menuContribution
+            locationURI="menu:org.eclipse.ui.main.menu">
+         <menu
+               id="org.eclipse.ui.main.menu.file"
+               label="File">
+            <command
+                  commandId="org.eclipse.ui.file.import"
+                  label="Import..."
+                  style="push">
+            </command>
+            <command
+                  commandId="org.eclipse.ui.file.export"
+                  label="Export..."
+                  style="push">
+            </command>
+         </menu>
+      </menuContribution>
    </extension>
    <extension
          name="Window Menu Commands"
          </view>
       </perspectiveExtension>
    </extension>
+   <extension
+         point="org.eclipse.ui.importWizards">
+      <category
+            id="eu.etaxonomy.taxeditor.import.category.cdm"
+            name="CDM">
+      </category>
+      <wizard
+            category="eu.etaxonomy.taxeditor.import.category.cdm"
+            class="eu.etaxonomy.taxeditor.io.TcsImportWizard"
+            id="eu.etaxonomy.taxeditor.io.import.tcs"
+            name="TCS">
+      </wizard>
+      <wizard
+            category="eu.etaxonomy.taxeditor.import.category.cdm"
+            class="eu.etaxonomy.taxeditor.io.JaxbImportWizard"
+            id="eu.etaxonomy.taxeditor.io.import.excel"
+            name="JAXB">
+      </wizard>
+      <category
+            id="eu.etaxonomy.taxeditor.import.category.excel"
+            name="Excel">
+      </category>
+   </extension>
+   <extension
+         point="org.eclipse.ui.exportWizards">
+      <category
+            id="eu.etaxonomy.taxeditor.export.category.cdm"
+            name="CDM">
+      </category>
+      <wizard
+            category="eu.etaxonomy.taxeditor.import.category.cdm"
+            class="eu.etaxonomy.taxeditor.io.TcsExportWizard"
+            id="eu.etaxonomy.taxeditor.io.export.tcs"
+            name="TCS">
+      </wizard>
+      <wizard
+            category="eu.etaxonomy.taxeditor.export.category.cdm"
+            class="eu.etaxonomy.taxeditor.io.JaxbExportWizard"
+            id="eu.etaxonomy.taxeditor.io.export.excel"
+            name="JAXB">
+         <selection
+               class="selection.Selection1">
+         </selection>
+      </wizard>
+      <category
+            id="eu.etaxonomy.taxeditor.export.category.excel"
+            name="Excel">
+      </category>
+   </extension>
+       <extension
+        point="org.eclipse.ui.activities">
+     <activity
+           description="Test"
+           id="test.Export"
+           name="Test"/>
+     <activityPatternBinding
+           activityId="test.Export"
+           pattern="org\.eclipse\.ui\.wizard\.export\.*/org\.eclipse\.ui\.wizard\.import\.*"/>
+     <categoryActivityBinding
+           activityId="test.Export"
+           categoryId="test.category"/>
+     <category
+           id="test.category"
+           name="testCategory">
+     </category>
+       </extension>
+       <extension  
+               point="org.eclipse.ui.views">  
+               <view  
+                       name="Progress View"  
+                       icon="icons/pview.gif"  
+                       category="org.eclipse.ui"  
+                       class="org.eclipse.ui.ExtensionFactory:progressView"  
+                       id="org.eclipse.ui.views.ProgressView">  
+               </view>  
+       </extension>  
+       
 </plugin>
index 34f6577692bd918ac12c2f74b856531519b34637..183e3e8717e9b96ed363e8ebc16d2bb535aa3839 100644 (file)
@@ -51,11 +51,12 @@ public class CdmDataSourceH2WizardPage extends CdmDataSourceCredentialsWizardPag
                                getWizard().getPassword()
                        );
                
-               if (dataSource.testConnection()) {
+               try{
+                       dataSource.testConnection();
                        MessageDialog.openConfirm(parent.getShell(), "Test successful", "Test successful");
-               } else {
-                       MessageDialog.openWarning(parent.getShell(), "Test unsuccessful", "Test unsuccessful");
-               }               
+               } catch(Exception e){
+                       MessageDialog.openWarning(parent.getShell(), "Test unsuccessful", "Test unsuccessful \n\n" + e.getCause());
+               }       
        }
 
        /* (non-Javadoc)
index 1e70d2193e2a47b040b7ee436d1a45a8676cae95..a50def93a8b698dd5ddc436a382c692c2eaf7d28 100644 (file)
@@ -91,10 +91,11 @@ public class CdmDataSourceMySQLWizardPage extends CdmDataSourceCredentialsWizard
                                getWizard().getUsername(), 
                                getWizard().getPassword()
                );
-               if (dataSource.testConnection()) {
+               try{
+                       dataSource.testConnection();
                        MessageDialog.openConfirm(parent.getShell(), "Test successful", "Test successful");
-               } else {
-                       MessageDialog.openWarning(parent.getShell(), "Test unsuccessful", "Test unsuccessful");
+               } catch(Exception e){
+                       MessageDialog.openWarning(parent.getShell(), "Test unsuccessful", "Test unsuccessful \n\n" + e.getCause());
                }
        }
 
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceSQLServerWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceSQLServerWizardPage.java
new file mode 100644 (file)
index 0000000..f425d88
--- /dev/null
@@ -0,0 +1,114 @@
+// $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.datasource.wizard;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.cdm.database.CdmDataSource;
+import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
+import eu.etaxonomy.cdm.database.ICdmDataSource;
+
+/**
+ * @author n.hoffmann
+ * @created 19.05.2009
+ * @version 1.0
+ */
+public class CdmDataSourceSQLServerWizardPage extends CdmDataSourceCredentialsWizardPage {
+
+
+       private static final Logger logger = Logger
+                       .getLogger(CdmDataSourceSQLServerWizardPage.class);
+       
+       private Text portText;
+       private Text serverText;
+
+       /**
+        * @param pageName
+        */
+       protected CdmDataSourceSQLServerWizardPage(ICdmDataSource dataSource) {
+               super("SQL Server");
+               setTitle("Enter credentials for SQL Server database");
+               this.dataSource = dataSource;
+       }
+       
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#createDatabaseForm()
+        */
+       @Override
+       public void createDatabaseForm() {
+               logger.warn("Creating");
+               
+               // Create group composite for location data 
+               locationGroup = new Group(composite, SWT.NONE);
+               locationGroup.setText("Location");
+               locationGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+               GridLayout locationLayout = new GridLayout();
+               locationLayout.numColumns = 2;
+               locationGroup.setLayout(locationLayout);
+
+               // Create host label
+               Label serverLabel = new Label(locationGroup, SWT.NONE);
+               serverLabel.setText("Host:");
+
+               // Create host input
+               serverText = new Text(locationGroup, SWT.BORDER);
+               serverText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               serverText.addKeyListener(this);
+
+               // Create port label
+               Label portLabel = new Label(locationGroup, SWT.NONE);
+               portLabel.setText("Port:");
+
+               // Create port input
+               portText = new Text(locationGroup, SWT.BORDER);
+               portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               
+               portText.addKeyListener(this);
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#testDbConfiguration()
+        */
+       @Override
+       public void testDbConfiguration() {
+               ICdmDataSource dataSource = CdmDataSource.NewSqlServer2005Instance(
+                               getWizard().getServer(), 
+                               getWizard().getDatabase(), 
+                               getWizard().getPort(),
+                               getWizard().getUsername(), 
+                               getWizard().getPassword()
+               );
+               try{
+                       dataSource.testConnection();
+                       MessageDialog.openConfirm(parent.getShell(), "Test successful", "Test successful!");
+               } catch(Exception e){
+                       MessageDialog.openWarning(parent.getShell(), "Test unsuccessful", "Test unsuccessful! \n\nSee error.log for details.");
+                       throw new RuntimeException(e);
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#updateLocation()
+        */
+       @Override
+       public void updateLocation() {
+               getWizard().setServer(serverText.getText());
+               int port = new Integer(portText.getText());
+               getWizard().setPort(port);
+       }
+}
index 7f5bf49ef5ef1887aa1965be8cce616ecdd4defb..c0ad5e20e1944e619b80d2fb7e779c7efc8a1a1b 100644 (file)
@@ -92,6 +92,8 @@ public class CdmDataSourceWizard extends Wizard {
                        dataSource = CdmDataSource.NewH2EmbeddedInstance(database, username, password);
                }else if(databaseType == DatabaseTypeEnum.MySQL){
                        dataSource = CdmDataSource.NewMySqlInstance(server, database, port, username, password);
+               }else if(databaseType == DatabaseTypeEnum.SqlServer2005){
+                       dataSource = CdmDataSource.NewSqlServer2005Instance(server, database, port, username, password);
                }
                                        
                CdmDataSourceRepository.getDefault().save(dataSource);
index 144aa19144ac7decf82d2b35bf8bd3bdcf2427b8..766633b8f68d209a7ca15204325251f5f113e14c 100644 (file)
@@ -124,7 +124,8 @@ public class CdmDataSourceWizardPage extends WizardPage implements KeyListener{
                for (DatabaseTypeEnum type : DatabaseTypeEnum.getAllTypes()) {
                        // FIXME right now we filter supported types
                        if(type.equals(DatabaseTypeEnum.MySQL)
-                               || type.equals(DatabaseTypeEnum.H2)){
+                               || type.equals(DatabaseTypeEnum.H2)
+                               || type.equals(DatabaseTypeEnum.SqlServer2005)){
                                databaseTypeCombo.add(type.getName());
                                databaseTypes.add(type);
                        }
@@ -142,6 +143,8 @@ public class CdmDataSourceWizardPage extends WizardPage implements KeyListener{
                        wizardPage = new CdmDataSourceH2WizardPage(dataSource);
                }else if(type == DatabaseTypeEnum.MySQL){
                        wizardPage = new CdmDataSourceMySQLWizardPage(dataSource);
+               }else if(type == DatabaseTypeEnum.SqlServer2005){
+                       wizardPage = new CdmDataSourceSQLServerWizardPage(dataSource);
                }
                
                if(wizard.getPage(wizardPage.getName()) != null){
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelExportWizard.java
new file mode 100644 (file)
index 0000000..55c4792
--- /dev/null
@@ -0,0 +1,44 @@
+// $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.io;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class AbstractExcelExportWizard extends Wizard implements IExportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(AbstractExcelExportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/AbstractExcelImportWizard.java
new file mode 100644 (file)
index 0000000..bae6c24
--- /dev/null
@@ -0,0 +1,44 @@
+// $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.io;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class AbstractExcelImportWizard extends Wizard implements IImportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(AbstractExcelImportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizard.java
new file mode 100644 (file)
index 0000000..f4cb881
--- /dev/null
@@ -0,0 +1,92 @@
+// $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.io;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
+import eu.etaxonomy.cdm.io.common.ICdmExport;
+import eu.etaxonomy.cdm.io.jaxb.JaxbExportConfigurator;
+import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class JaxbExportWizard extends Wizard implements IExportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(JaxbExportWizard.class);
+
+       public final String JAXB_EXPORT = "JAXB_EXPORT";
+
+       private ICdmExport<JaxbExportConfigurator> export;
+
+       private JaxbExportWizardPage page;
+
+       private JaxbExportConfigurator exportConfigurator;
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               
+               export = new CdmDefaultExport<JaxbExportConfigurator>();
+               
+               String url = page.getFolderText() + File.pathSeparator + page.getExportFileName();
+               
+               exportConfigurator = JaxbExportConfigurator.NewInstance(CdmDataSourceRepository.getDefault().getCurrentDataSource(), url);
+               
+               
+               Job exportJob = new Job("JAXB Export"){
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               return export.invoke(exportConfigurator) ? Status.OK_STATUS : Status.CANCEL_STATUS;
+                       }
+               };              
+               
+               exportJob.schedule();
+               
+               return true;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               super.addPages();
+               
+               page = new JaxbExportWizardPage(JAXB_EXPORT);
+               
+               addPage(page);
+       }
+
+       
+
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbExportWizardPage.java
new file mode 100644 (file)
index 0000000..b35f352
--- /dev/null
@@ -0,0 +1,141 @@
+// $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.io;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class JaxbExportWizardPage extends WizardPage{
+
+       public static final String DATE_FORMAT_NOW = "yyyyMMdd-HHmm";
+       
+       private static final Logger logger = Logger
+                       .getLogger(JaxbExportWizardPage.class);
+       private DirectoryDialog folderDialog;
+       private Text exportFileName;
+
+       private Text folderText;
+       
+       
+       /**
+        * @param pageName
+        * @param selection
+        */
+       protected JaxbExportWizardPage(String pageName) {
+               super(pageName);
+               this.setTitle("JAXB Export");
+               
+               this.setDescription("Exports the contents of the currently selected database into the cdm jaxb format.");
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               
+               setPageComplete(false);
+               
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 3;
+               composite.setLayout(gridLayout);
+               
+               Label fileLabel = new Label(composite, SWT.NONE);
+               fileLabel.setText("File");
+               
+               exportFileName = new Text(composite, SWT.NONE);
+               exportFileName.setText(generateFilename());
+               exportFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+               
+               
+               Label folderLabel = new Label(composite, SWT.NONE);
+               folderLabel.setText("Folder");
+               
+               folderDialog = new DirectoryDialog(parent.getShell());
+               
+               folderText = new Text(composite, SWT.NONE);
+               folderText.setEditable(false);
+               folderText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+               
+               Button button = new Button(composite, SWT.PUSH);
+               button.setText("Browse...");
+               
+               button.addMouseListener(new MouseAdapter(){
+
+                       /* (non-Javadoc)
+                        * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
+                        */
+                       @Override
+                       public void mouseUp(MouseEvent e) {
+                               String path = folderDialog.open();
+                               folderText.setText(path);
+                               setPageComplete(true);
+                       }
+                       
+               });
+               
+               // make the composite the wizard pages control
+               setControl(composite);
+       }
+       
+       private String generateFilename(){
+               StringBuffer buffer = new StringBuffer();
+               buffer.append("jaxb_export_");
+               buffer.append(CdmDataSourceRepository.getDefault().getCurrentDataSource());
+               buffer.append("-");
+               
+               Calendar cal = Calendar.getInstance();
+           SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
+               buffer.append(sdf.format(cal.getTime()));
+               
+               buffer.append(".xml");
+               
+               return buffer.toString();
+       }
+
+
+       /**
+        * @return the exportFileName
+        */
+       public Text getExportFileName() {
+               return exportFileName;
+       }
+
+
+       /**
+        * @return the folderText
+        */
+       public Text getFolderText() {
+               return folderText;
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/JaxbImportWizard.java
new file mode 100644 (file)
index 0000000..4d44412
--- /dev/null
@@ -0,0 +1,44 @@
+// $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.io;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class JaxbImportWizard extends Wizard implements IImportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(JaxbImportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsExportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsExportWizard.java
new file mode 100644 (file)
index 0000000..6032458
--- /dev/null
@@ -0,0 +1,44 @@
+// $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.io;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class TcsExportWizard extends Wizard implements IExportWizard {
+       private static final Logger logger = Logger
+                       .getLogger(TcsExportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsImportWizard.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/io/TcsImportWizard.java
new file mode 100644 (file)
index 0000000..7288b42
--- /dev/null
@@ -0,0 +1,44 @@
+// $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.io;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @author n.hoffmann
+ * @created 15.06.2009
+ * @version 1.0
+ */
+public class TcsImportWizard extends Wizard implements IImportWizard{
+       private static final Logger logger = Logger.getLogger(TcsImportWizard.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               // TODO Auto-generated method stub
+               
+       }
+
+}
index 9ecd389b6f1260aed0b7ce04a2c4b44ace3cfa73..467cc4e066e0f1916b8a24dd36dab0a8cd65dee8 100644 (file)
@@ -12,11 +12,14 @@ package eu.etaxonomy.taxeditor.model;
 
 import org.eclipse.jface.resource.ColorRegistry;
 import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.themes.ITheme;
 import org.eclipse.ui.themes.IThemeManager;
 
+import eu.etaxonomy.taxeditor.store.StoreUtil;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
@@ -68,4 +71,14 @@ public abstract class AbstractUtility {
                return getCurrentTheme().getColorRegistry();
        }
        
+       /**
+        * Open a message box that informs the user about unimplemented functionality.
+        * This method is for developer convenience.
+        */
+       public static void notImplementedMessage(){
+               MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
+               messageBox.setText("Not yet implemented");
+               messageBox.open();
+       }
+       
 }
index dffc0dcc3dd168e9aeb22045fc7d3f18cdd40f43..33a404e903dbc916ab107e20b86b20f83932c8af 100644 (file)
@@ -40,7 +40,7 @@ public class ImagesUtil {
                        Feature feature = element.getFeature();\r
                        \r
                        if(feature.equals(Feature.IMAGE())){\r
-                               Set<Media> medias = element.getMedia();\r
+                               List<Media> medias = element.getMedia();\r
                                \r
                                for(Media media : medias){\r
                                        Set<MediaRepresentation> representations = media.getRepresentations();\r
index 60d30a1a48498dfc9c0afa0329f5e79bd202c9f2..1fc4a53e1ff2ef7dd43df46c98b4123b368cd657 100644 (file)
@@ -38,7 +38,7 @@ import eu.etaxonomy.cdm.model.common.DefinedTermBase;
  * @created 12.06.2009
  * @version 1.0
  */
-public abstract class AbstractMenuPreferences extends PreferencePage {
+public abstract class AbstractMenuPreferences extends PreferencePage{
 
        private Button toggleButton;
        protected HashMap<DefinedTermBase, Button> menuButtons;
@@ -47,7 +47,7 @@ public abstract class AbstractMenuPreferences extends PreferencePage {
        
        private List preferedTerms;
        
-       private CheckboxTableViewer tableViewer;
+       protected CheckboxTableViewer tableViewer;
        
        private boolean state = true;
 
@@ -181,5 +181,6 @@ public abstract class AbstractMenuPreferences extends PreferencePage {
         */
        public CheckboxTableViewer getTableViewer() {
                return tableViewer;
-       };
+       }       
+       
 }
\ No newline at end of file
index 821625bfb79554decca169390eed0643fcea33a8..899a1128b411ba6cadffd918b0d3276b7e98fc85 100644 (file)
@@ -11,15 +11,17 @@ package eu.etaxonomy.taxeditor.preference;
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
+import org.eclipse.jface.wizard.WizardDialog;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.events.MouseAdapter;\r
 import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.layout.GridData;\r
 import org.eclipse.swt.widgets.Button;\r
 import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.MessageBox;\r
 import org.eclipse.ui.IWorkbenchPreferencePage;\r
 \r
 import eu.etaxonomy.cdm.model.description.Feature;\r
+import eu.etaxonomy.taxeditor.preference.wizards.FeatureWizard;\r
 import eu.etaxonomy.taxeditor.store.CdmStore;\r
 import eu.etaxonomy.taxeditor.store.StoreUtil;\r
 \r
@@ -63,6 +65,7 @@ public class FeatureMenuPreferences extends AbstractMenuPreferences implements
        protected void createButtons(Composite buttonContainer) {\r
                newButton = new Button(buttonContainer, SWT.PUSH);\r
                newButton.setText("New");\r
+               newButton.setLayoutData(new GridData(SWT.FILL));\r
                newButton.addMouseListener(new MouseAdapter(){\r
 \r
                        /* (non-Javadoc)\r
@@ -71,13 +74,19 @@ public class FeatureMenuPreferences extends AbstractMenuPreferences implements
                        @Override\r
                        public void mouseUp(MouseEvent e) {\r
                                super.mouseUp(e);\r
-                               notImplemented();\r
+                               FeatureWizard wizard = new FeatureWizard(); \r
+                               \r
+                               WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);\r
+                           dialog.open();\r
+                           \r
+                           tableViewer.setInput(CdmStore.getFeatures());\r
                        }\r
                        \r
                });\r
                \r
                editButton = new Button(buttonContainer, SWT.PUSH);\r
                editButton.setText("Edit");\r
+               editButton.setLayoutData(new GridData(SWT.FILL));\r
                editButton.addMouseListener(new MouseAdapter(){\r
 \r
                        /* (non-Javadoc)\r
@@ -86,13 +95,25 @@ public class FeatureMenuPreferences extends AbstractMenuPreferences implements
                        @Override\r
                        public void mouseUp(MouseEvent e) {\r
                                super.mouseUp(e);\r
-                               notImplemented();\r
+\r
+                               StoreUtil.notImplementedMessage();\r
+                               \r
+                               // editing a feature is somewhat more complicated, because basically one can only edit the representation.\r
+//                             Feature feature = (Feature) ((StructuredSelection) tableViewer.getSelection()).getFirstElement();\r
+//                             \r
+//                             FeatureWizard wizard = new FeatureWizard(feature); \r
+//                             \r
+//                             WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);\r
+//                         dialog.open();\r
+//                         \r
+//                         tableViewer.setInput(CdmStore.getFeatures());\r
                        }\r
                        \r
                });\r
                \r
                removeButton = new Button(buttonContainer, SWT.PUSH);\r
                removeButton.setText("Remove");\r
+               removeButton.setLayoutData(new GridData(SWT.FILL));\r
                removeButton.addMouseListener(new MouseAdapter(){\r
 \r
                        /* (non-Javadoc)\r
@@ -101,16 +122,9 @@ public class FeatureMenuPreferences extends AbstractMenuPreferences implements
                        @Override\r
                        public void mouseUp(MouseEvent e) {\r
                                super.mouseUp(e);\r
-                               notImplemented();\r
+                               StoreUtil.notImplementedMessage();\r
                        }\r
                        \r
                });\r
        }\r
-\r
-       private void notImplemented(){\r
-               MessageBox messageBox = new MessageBox(StoreUtil.getShell(), SWT.ICON_WARNING | SWT.OK);\r
-               messageBox.setText("Not yet implemented");\r
-               messageBox.open();\r
-       }\r
-\r
 }\r
index d3b85d702b8464f0a87c716f2a0ee43c8a315201..2f38892db51f07f74ee752d0521722313b4012a9 100644 (file)
@@ -13,7 +13,9 @@ package eu.etaxonomy.taxeditor.preference.wizards;
 import org.apache.log4j.Logger;
 import org.eclipse.jface.wizard.Wizard;
 
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * @author n.hoffmann
@@ -23,7 +25,9 @@ import eu.etaxonomy.cdm.model.description.Feature;
 public class FeatureWizard extends Wizard {
        private static final Logger logger = Logger.getLogger(FeatureWizard.class);
        
-       private Feature selectedFeature = null;
+       private Feature feature = null;
+       
+       private boolean editMode = false;
 
        /**
         * 
@@ -35,7 +39,8 @@ public class FeatureWizard extends Wizard {
         * @param selectedFeature
         */
        public FeatureWizard(Feature selectedFeature){
-               this.selectedFeature = selectedFeature;
+               this.feature = selectedFeature;
+               editMode = true;
        }
        
        /* (non-Javadoc)
@@ -45,7 +50,7 @@ public class FeatureWizard extends Wizard {
        public void addPages() {
                super.addPages();
                
-               addPage(selectedFeature == null ? new FeatureWizardNewPage() : new FeatureWizardEditPage(selectedFeature));
+               addPage(new FeatureWizardPage());
        }
        
        /* (non-Javadoc)
@@ -53,11 +58,41 @@ public class FeatureWizard extends Wizard {
         */
        @Override
        public boolean performFinish() {
-               // TODO Auto-generated method stub
-               return false;
+
+               ConversationHolder conversation = CdmStore.NewTransactionalConversation();
+               
+               if(editMode){
+                       CdmStore.updateFeature(feature);
+               }else{
+                       CdmStore.saveFeature(feature);
+               }
+               
+               conversation.commit(true);
+               
+               return true;
        }
 
 
+       /**
+        * @param text
+        * @param text2
+        * @param text3
+        */
+       public void setFeature(String term, String label, String labelAbbreviation) {
+               feature = Feature.NewInstance(term, label, labelAbbreviation);
+       }
 
+       /**
+        * @return the feature
+        */
+       public Feature getFeature() {
+               return feature;
+       }
 
+       /**
+        * @return the editMode
+        */
+       public boolean isEditMode() {
+               return editMode;
+       }
 }
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardNewPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardNewPage.java
deleted file mode 100644 (file)
index f1a645e..0000000
+++ /dev/null
@@ -1,41 +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.preference.wizards;
-
-import org.apache.log4j.Logger;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @author n.hoffmann
- * @created 12.06.2009
- * @version 1.0
- */
-public class FeatureWizardNewPage extends WizardPage {
-
-       /**
-        * 
-        */
-       public FeatureWizardNewPage() {
-               super("Create new Feature");
-       }
-
-       private static final Logger logger = Logger
-                       .getLogger(FeatureWizardNewPage.class);
-
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
-        */
-       public void createControl(Composite parent) {
-               // TODO Auto-generated method stub
-
-       }
-}
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardPage.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/wizards/FeatureWizardPage.java
new file mode 100644 (file)
index 0000000..8212f7e
--- /dev/null
@@ -0,0 +1,124 @@
+// $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.preference.wizards;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+import eu.etaxonomy.cdm.model.description.Feature;
+
+/**
+ * @author n.hoffmann
+ * @created 12.06.2009
+ * @version 1.0
+ */
+public class FeatureWizardPage extends WizardPage implements ModifyListener {
+
+       private Text text_label;
+       private Text text_labelAbbreviation;
+       private Text text_description;
+
+       
+       
+       /**
+        * 
+        */
+       public FeatureWizardPage() {
+               super("FEATURE_WIZARD_PAGE");           
+       }
+
+       private static final Logger logger = Logger
+                       .getLogger(FeatureWizardPage.class);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               String title = getWizard().isEditMode() ? "Edit Feature" : "Create new Feature";
+               this.setTitle(title);
+               
+               Composite composite = new Composite(parent, SWT.NULL);
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 2;
+               gridLayout.horizontalSpacing = SWT.FILL;
+               gridLayout.verticalSpacing = SWT.FILL;
+               composite.setLayout(gridLayout);
+               
+               // label
+               CLabel label_label = new CLabel(composite, SWT.NULL);
+               label_label.setText("Label");
+               
+               text_label = new Text(composite, SWT.BORDER);
+               text_label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               text_label.addModifyListener(this);
+               
+               // label abbreviation 
+               CLabel label_labelAbbreviation = new CLabel(composite, SWT.NULL);
+               label_labelAbbreviation.setText("Label Abbreviation");
+               
+               text_labelAbbreviation = new Text(composite, SWT.BORDER);
+               text_labelAbbreviation.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               text_labelAbbreviation.addModifyListener(this);
+               
+               // descriptive text
+               CLabel label_description = new CLabel(composite, SWT.NULL);
+               label_description.setText("Description");
+               label_description.setLayoutData(new GridData(SWT.TOP));
+               
+               text_description = new Text(composite, SWT.BORDER | SWT.MULTI);
+               text_description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               text_description.addModifyListener(this);
+               
+               setControl(composite);
+               
+               if(getWizard().getFeature() != null){
+                       Feature feature = getWizard().getFeature();
+                       text_label.setText(feature.getLabel());
+                       // why can't we access labelAbbreviation
+//                     text_labelAbbreviation.setText(feature.get)
+                       // why can't we access the term string?
+//                     text_description.setText(feature.getT)
+               }
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+        */
+       public void modifyText(ModifyEvent e) {
+               if(text_description.getText().length() > 0 &&
+                               text_labelAbbreviation.getText().length() > 0 &&
+                               text_label.getText().length() > 0 ){
+                       setPageComplete(true);
+                       ((FeatureWizard) getWizard()).setFeature(text_description.getText(), text_label.getText(), text_labelAbbreviation.getText());
+               }
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.WizardPage#getWizard()
+        */
+       @Override
+       public FeatureWizard getWizard() {
+               return (FeatureWizard) super.getWizard();
+       }
+       
+       
+}
index 426b3d9408813e6d1d8f41ad21dbb964721cd91b..6fb1108e0430615ab3a496604722726a594606ae 100644 (file)
@@ -17,6 +17,7 @@ import java.util.SortedSet;
 import java.util.UUID;
 
 import org.apache.log4j.Logger;
+import org.springframework.security.providers.ProviderManager;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationController;
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
@@ -30,7 +31,6 @@ import eu.etaxonomy.cdm.api.service.config.impl.TaxonServiceConfiguratorImpl;
 import eu.etaxonomy.cdm.database.DbSchemaValidation;
 import eu.etaxonomy.cdm.database.ICdmDataSource;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
@@ -49,9 +49,9 @@ import eu.etaxonomy.cdm.model.reference.Generic;
 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
 import eu.etaxonomy.cdm.persistence.query.MatchMode;
 import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
-import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 
 /**
  * This implementation of ICdmDataRepository depends on hibernate sessions to store the data correctly 
@@ -184,6 +184,13 @@ public class CdmStore{
                return applicationController.getTaxonService().getRootTaxa(
                                getDefaultSec(), onlyWithChildren, withMisapplications);
        }
+       
+       /**
+        * @return
+        */
+       public List<TaxonomicTree> getTaxonomicTrees() {
+               return applicationController.getTaxonService().getAllTaxonomicTrees(10000, 0);
+       }
 
        public OrderedTermVocabulary<TaxonRelationshipType> getTaxonRelationshipTypes() {
                TermVocabulary vocabulary = HibernateProxyHelper.deproxy
@@ -266,6 +273,11 @@ public class CdmStore{
        public static ILocationService getLocationService(){
                return getDefault().getApplicationController().getLocationService();
        }
+
+       public static ProviderManager getAuthenticationManager() {
+               return getDefault().getApplicationController().getAuthenticationManager();
+       }
+
        
        /**
         * @param searchText
@@ -377,4 +389,26 @@ public class CdmStore{
                
                return nomReferenceTypeMap;
        }
+
+       /**
+        * @param feature
+        */
+       public static void saveFeature(Feature feature) {
+               TermVocabulary<Feature> vocabulary = getDefault().getFeaturesInternal();
+               
+               vocabulary.addTerm(feature);
+               
+               getDefault().getApplicationController().getTermService().saveTermVocabulary(vocabulary);
+       }
+
+       /**
+        * TODO make this more generic
+        * 
+        * @param feature
+        */
+       public static void updateFeature(Feature feature) {
+               TermVocabulary<Feature> vocabulary = getDefault().getFeaturesInternal();
+
+               getDefault().getApplicationController().getTermService().saveTermVocabulary(vocabulary);
+       }
 }