code cleaning
authorKatja Luther <k.luther@bgbm.org>
Wed, 26 Feb 2020 09:18:33 +0000 (10:18 +0100)
committerKatja Luther <k.luther@bgbm.org>
Wed, 26 Feb 2020 09:18:33 +0000 (10:18 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourceTypeSelectionWizardPage.java

index fdde30a62ad7338d728765ced0138758dd2b3075..ab04f6c9c22e95875d4e125d15ee507bd934428a 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * 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.
 */
@@ -39,21 +39,21 @@ import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository;
  * @version 1.0
  */
 public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements ModifyListener{
-       
+
        public static final DatabaseTypeEnum[] supportedDatabaseTypes = new DatabaseTypeEnum[]{
-               DatabaseTypeEnum.MySQL,                                                                                 
-               DatabaseTypeEnum.H2, 
-               DatabaseTypeEnum.PostgreSQL 
+               DatabaseTypeEnum.MySQL,
+               DatabaseTypeEnum.H2,
+               DatabaseTypeEnum.PostgreSQL
                /*DatabaseTypeEnum.SqlServer2005*/
        };
-       
-       
+
+
        private ArrayList<DatabaseTypeEnum> databaseTypes;
-       
+
        private Text datasourceNameText;
        private String dataSourceName;
        private Combo databaseTypeCombo;
-       
+
        private Composite composite;
        private Composite editDatasourceComposite;
 
@@ -61,13 +61,13 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
 
        private boolean dataBaseTypeSelected = false;
        private boolean dataSourceNameSet = false;
-       
+
        private ICdmDataSource dataSource;
 
        private WizardPage nextPage;
 
        private CdmDataSourceCredentialsWizardPage credentialsWizardPage;
-       
+
        /**
         * <p>Constructor for CdmDataSourceTypeSelectionWizardPage.</p>
         *
@@ -75,11 +75,11 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
         */
        public CdmDataSourceTypeSelectionWizardPage(ICdmDataSource dataSource) {
                super("DataSourceWizardPage");
-               
+
                this.dataSource = dataSource;
-               
+
                String pageName = dataSource == null ? "Create New Datasource" : "Edit Existing Datasource";
-               
+
                setTitle(pageName);
        }
 
@@ -87,11 +87,12 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
         * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
         */
        /** {@inheritDoc} */
-       public void createControl(Composite parent) {
+       @Override
+    public void createControl(Composite parent) {
 
                setPageComplete(false);
-               
-               // Create top-level composite 
+
+               // Create top-level composite
                composite = new Composite(parent, SWT.NONE);
                GridLayout gridLayout = new GridLayout();
                gridLayout.numColumns = 1;
@@ -104,7 +105,7 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
                GridLayout datasourceLayout = new GridLayout();
                datasourceLayout.numColumns = 2;
                editDatasourceComposite.setLayout(datasourceLayout);
-               
+
                // Create label and input for dataSource name
                Label datasourceNameLabel = new Label(editDatasourceComposite, SWT.NONE);
                datasourceNameLabel.setText("Datasource Name:");
@@ -112,45 +113,46 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
                datasourceNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
                datasourceNameText.addModifyListener(this);
 
-               // Create label and dropdown for database type          
+               // Create label and dropdown for database type
                Label databaseTypeLabel = new Label(editDatasourceComposite, SWT.NONE);
                databaseTypeLabel.setText("Database Type:");
                databaseTypeCombo = new Combo(editDatasourceComposite, SWT.BORDER | SWT.READ_ONLY);
                GridData comboLayout = new GridData(SWT.FILL, SWT.CENTER, false, false);
                databaseTypeCombo.setLayoutData(comboLayout);
-               populateComboBoxItems();        
-               
+               populateComboBoxItems();
+
                // Create listener to display database type-specific config options
                databaseTypeCombo.addSelectionListener(new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent e) {
-                               
+                       @Override
+            public void widgetSelected(SelectionEvent e) {
+
                                // Get database type at the selected index
                                DatabaseTypeEnum type = databaseTypes.get(databaseTypeCombo.getSelectionIndex());
-                               
+
                                addDatabasePage(type);
                                setDataBaseTypeSelected(true);
                                checkPageComplete();
                        }
                });
-               
+
                // make the composite the wizard pages control
                setControl(composite);
        }
-       
+
        private void populateComboBoxItems() {
-               
+
                // Init DB types
                if (databaseTypes == null) {
                        databaseTypes = new ArrayList<DatabaseTypeEnum>();
                }
-               
+
                // Add types to the type drop-down and to the types collection
                for (DatabaseTypeEnum type : supportedDatabaseTypes) {
                        databaseTypeCombo.add(type.getName());
                        databaseTypes.add(type);
                }
        }
-       
+
        /**
         * @param type
         */
@@ -158,8 +160,8 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
                // add credentials wizard page according to selection
                Wizard wizard = (Wizard) getWizard();
                credentialsWizardPage = null;
-               
-               
+
+
                if(type == DatabaseTypeEnum.H2){
                        credentialsWizardPage = new CdmDataSourceH2WizardPage(dataSource,CdmDataSourceWizard.Mode.CREATE);
                }
@@ -169,12 +171,12 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
                else if(type == DatabaseTypeEnum.PostgreSQL){
                        credentialsWizardPage = new CdmDataSourcePostgreSQLServerWizardPage(dataSource, CdmDataSourceWizard.Mode.CREATE);
                }
-               
+
 //             else if(type == DatabaseTypeEnum.SqlServer2005){
 //                     credentialsWizardPage = new CdmDataSourceSQLServerWizardPage(dataSource);
 //             }
-               
-               if(wizard.getPage(credentialsWizardPage.getName()) != null){
+
+               if(credentialsWizardPage != null && wizard.getPage(credentialsWizardPage.getName()) != null){
                        nextPage = (WizardPage) wizard.getPage(credentialsWizardPage.getName());
                }else{
                        wizard.addPage(credentialsWizardPage);
@@ -198,9 +200,10 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
         * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
         */
        /** {@inheritDoc} */
-       public void modifyText(ModifyEvent e) {
+       @Override
+    public void modifyText(ModifyEvent e) {
                String name = datasourceNameText.getText();
-               
+
                if(name.length() == 0){
                        setDataSourceNameSet(false);
                        setErrorMessage("DataSource name must not be empty.");
@@ -224,10 +227,10 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
        public void checkPageComplete() {
                boolean complete = isDataBaseTypeSelected();
                complete &= isDataSourceNameSet();
-               
+
                setPageComplete(complete);
        }
-       
+
        /**
         * <p>Getter for the field <code>dataSourceName</code>.</p>
         *
@@ -290,6 +293,6 @@ public class CdmDataSourceTypeSelectionWizardPage extends WizardPage implements
        public NomenclaturalCode getNomenclaturalCode() {
                return nomenclaturalCode;
        }
-       
-       
+
+
 }