3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.datasource
.wizard
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.layout
.GridData
;
17 import org
.eclipse
.swt
.layout
.GridLayout
;
18 import org
.eclipse
.swt
.widgets
.Group
;
19 import org
.eclipse
.swt
.widgets
.Label
;
20 import org
.eclipse
.swt
.widgets
.Text
;
22 import eu
.etaxonomy
.cdm
.database
.CdmDataSource
;
23 import eu
.etaxonomy
.cdm
.database
.DatabaseTypeEnum
;
24 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
31 public class CdmDataSourceSQLServerWizardPage
extends CdmDataSourceCredentialsWizardPage
{
34 private static final Logger logger
= Logger
35 .getLogger(CdmDataSourceSQLServerWizardPage
.class);
37 private Text portText
;
38 private Text serverText
;
43 protected CdmDataSourceSQLServerWizardPage(ICdmDataSource dataSource
) {
45 setTitle("Enter credentials for SQL Server database");
46 this.dataSource
= dataSource
;
50 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#createDatabaseForm()
53 public void createDatabaseForm() {
54 logger
.warn("Creating");
56 // Create group composite for location data
57 locationGroup
= new Group(composite
, SWT
.NONE
);
58 locationGroup
.setText("Location");
59 locationGroup
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
60 GridLayout locationLayout
= new GridLayout();
61 locationLayout
.numColumns
= 2;
62 locationGroup
.setLayout(locationLayout
);
65 Label serverLabel
= new Label(locationGroup
, SWT
.NONE
);
66 serverLabel
.setText("Host:");
69 serverText
= new Text(locationGroup
, SWT
.BORDER
);
70 serverText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
71 serverText
.addKeyListener(this);
74 Label portLabel
= new Label(locationGroup
, SWT
.NONE
);
75 portLabel
.setText("Port:");
78 portText
= new Text(locationGroup
, SWT
.BORDER
);
79 portText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
81 portText
.addKeyListener(this);
85 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#testDbConfiguration()
88 public void testDbConfiguration() {
89 ICdmDataSource dataSource
= CdmDataSource
.NewSqlServer2005Instance(
90 getWizard().getServer(),
91 getWizard().getDatabase(),
92 getWizard().getPort(),
93 getWizard().getUsername(),
94 getWizard().getPassword()
97 dataSource
.testConnection();
98 MessageDialog
.openConfirm(parent
.getShell(), "Test successful", "Test successful!");
100 MessageDialog
.openWarning(parent
.getShell(), "Test unsuccessful", "Test unsuccessful! \n\nSee error.log for details.");
101 throw new RuntimeException(e
);
106 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#updateLocation()
109 public void updateLocation() {
110 getWizard().setServer(serverText
.getText());
111 int port
= new Integer(portText
.getText());
112 getWizard().setPort(port
);