Revision 5ed160dc
Added by Cherian Mathew almost 10 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/datasource/wizard/CdmDataSourcePostgreSQLServerWizardPage.java | ||
---|---|---|
28 | 28 |
private int port; |
29 | 29 |
|
30 | 30 |
protected CdmDataSourcePostgreSQLServerWizardPage(ICdmDataSource dataSource) { |
31 |
super("PostgreSQL Server"); |
|
31 |
super("PostgreSQL Server", dataSource);
|
|
32 | 32 |
setTitle("PostgreSQL Server"); |
33 | 33 |
setDescription("Enter credentials for PostgreSQL Server database"); |
34 |
this.setDataSource(dataSource); |
|
34 |
|
|
35 | 35 |
} |
36 | 36 |
|
37 | 37 |
/* (non-Javadoc) |
... | ... | |
54 | 54 |
// Create host input |
55 | 55 |
text_server = new Text(locationGroup, SWT.BORDER); |
56 | 56 |
text_server.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
57 |
text_server.addModifyListener(this); |
|
57 |
|
|
58 | 58 |
|
59 | 59 |
// Create port label |
60 | 60 |
Label portLabel = new Label(locationGroup, SWT.NONE); |
... | ... | |
64 | 64 |
text_port = new Text(locationGroup, SWT.BORDER); |
65 | 65 |
text_port.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
66 | 66 |
|
67 |
text_port.addModifyListener(this); |
|
67 |
|
|
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
/* (non-Javadoc) |
... | ... | |
88 | 88 |
*/ |
89 | 89 |
@Override |
90 | 90 |
public void updateDataSource() { |
91 |
setDataSource(CdmDataSource.NewPostgreSQLInstance(server, |
|
92 |
database, |
|
93 |
port, |
|
94 |
username, |
|
95 |
password, |
|
96 |
nomenclaturalCode)); |
|
91 |
|
|
92 |
|
|
93 |
ICdmDataSource dataSource = getDataSource(); |
|
94 |
|
|
95 |
if(dataSource == null) { |
|
96 |
setDataSource(CdmDataSource.NewPostgreSQLInstance(server, |
|
97 |
database, |
|
98 |
port, |
|
99 |
username, |
|
100 |
password, |
|
101 |
nomenclaturalCode)); |
|
102 |
} else { |
|
103 |
dataSource.setName(name); |
|
104 |
dataSource.setServer(server); |
|
105 |
dataSource.setDatabase(database); |
|
106 |
dataSource.setPort(port); |
|
107 |
dataSource.setUsername(username); |
|
108 |
dataSource.setPassword(password); |
|
109 |
dataSource.setNomenclaturalCode(nomenclaturalCode); |
|
110 |
} |
|
97 | 111 |
} |
98 | 112 |
|
113 |
/* (non-Javadoc) |
|
114 |
* @see eu.etaxonomy.taxeditor.datasource.wizard.CdmDataSourceCredentialsWizardPage#init() |
|
115 |
*/ |
|
116 |
/** {@inheritDoc} */ |
|
99 | 117 |
@Override |
100 | 118 |
public void init() { |
119 |
super.init(); |
|
101 | 120 |
if(getDataSource() != null){ |
102 |
modifyTextWithoutTriggeringListeners(text_server, this, getDataSource().getServer()); |
|
103 |
modifyTextWithoutTriggeringListeners(text_port, this, getDataSource().getPort()+""); |
|
104 |
super.init(); |
|
121 |
removeListeners(); |
|
122 |
text_server.setText(getDataSource().getServer()); |
|
123 |
text_port.setText(String.valueOf(getDataSource().getPort())); |
|
124 |
// add listeners after setting text to avoid the modify event being called |
|
125 |
// for the initial value |
|
126 |
addListeners(); |
|
105 | 127 |
} |
128 |
|
|
129 |
} |
|
130 |
|
|
131 |
private void addListeners() { |
|
132 |
text_server.addModifyListener(this); |
|
133 |
text_port.addModifyListener(this); |
|
134 |
} |
|
135 |
|
|
136 |
private void removeListeners() { |
|
137 |
text_server.removeModifyListener(this); |
|
138 |
text_port.removeModifyListener(this); |
|
106 | 139 |
} |
107 | 140 |
|
108 | 141 |
} |
Also available in: Unified diff
refactored wizard dialog and pages to allow for easy in place editing and cloning of datasources.
CdmDataSourceRepository : added methods for (I)PersistentRemoteSource