added berlin model export wizard. added a wizard to create taxonomic trees. refactore...
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / datasource / wizard / CdmDataSourceSQLServerWizardPage.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.datasource.wizard;
12
13 import org.apache.log4j.Logger;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.layout.GridData;
16 import org.eclipse.swt.layout.GridLayout;
17 import org.eclipse.swt.widgets.Group;
18 import org.eclipse.swt.widgets.Label;
19 import org.eclipse.swt.widgets.Text;
20
21 import eu.etaxonomy.cdm.database.CdmDataSource;
22 import eu.etaxonomy.cdm.database.ICdmDataSource;
23
24 /**
25 * @author n.hoffmann
26 * @created 19.05.2009
27 * @version 1.0
28 */
29 public class CdmDataSourceSQLServerWizardPage extends CdmDataSourceCredentialsWizardPage {
30
31
32 private static final Logger logger = Logger
33 .getLogger(CdmDataSourceSQLServerWizardPage.class);
34
35 private Text text_port;
36 private Text text_server;
37
38 private String server;
39
40 private int port;
41
42 /**
43 * @param pageName
44 */
45 public CdmDataSourceSQLServerWizardPage(ICdmDataSource dataSource) {
46 super("SQL Server");
47 setTitle("SQL Server");
48 setDescription("Enter credentials for SQL Server database");
49 this.setDataSource(dataSource);
50 }
51
52 /* (non-Javadoc)
53 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#createDatabaseForm()
54 */
55 @Override
56 public void createDatabaseForm() {
57 logger.warn("Creating");
58
59 // Create group composite for location data
60 locationGroup = new Group(composite, SWT.NONE);
61 locationGroup.setText("Location");
62 locationGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
63 GridLayout locationLayout = new GridLayout();
64 locationLayout.numColumns = 2;
65 locationGroup.setLayout(locationLayout);
66
67 // Create host label
68 Label serverLabel = new Label(locationGroup, SWT.NONE);
69 serverLabel.setText("Host:");
70
71 // Create host input
72 text_server = new Text(locationGroup, SWT.BORDER);
73 text_server.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
74 text_server.addModifyListener(this);
75
76 // Create port label
77 Label portLabel = new Label(locationGroup, SWT.NONE);
78 portLabel.setText("Port:");
79
80 // Create port input
81 text_port = new Text(locationGroup, SWT.BORDER);
82 text_port.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
83
84 text_port.addModifyListener(this);
85 }
86
87 /* (non-Javadoc)
88 * @see eu.etaxonomy.taxeditor.store.datasource.CdmDataSourceCredentialsWizardPage#updateLocation()
89 */
90 @Override
91 public void updateLocation() {
92 server = text_server.getText();
93 try{
94 port = new Integer(text_port.getText());
95 }catch(NumberFormatException e){
96 // logger.warn("Error parsing port number", e);
97 }
98 }
99
100 /* (non-Javadoc)
101 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#updateDataSource()
102 */
103 @Override
104 public void updateDataSource() {
105 setDataSource(CdmDataSource.NewSqlServer2005Instance(server,
106 database,
107 port,
108 username,
109 password));
110 }
111
112 /* (non-Javadoc)
113 * @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#init()
114 */
115 @Override
116 public void init() {
117 if(getDataSource() != null){
118 modifyTextWithoutTriggeringListeners(text_server, this, getDataSource().getServer());
119 modifyTextWithoutTriggeringListeners(text_port, this, getDataSource().getPort()+"");
120 super.init();
121 }
122 }
123
124
125 }