My favorites
▼
|
Sign in
javahotel
Hotel Software for small, medium and large
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
examples
/
DatabaseObject
/
src
/
databaseobject
/
properties
/
DatabaseObjectPropertyPage.java
r586
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
* Copyright 2012 stanislawbartkowski@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package databaseobject.properties;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PropertyPage;
import databaseobject.messages.Messages;
import databaseobject.util.CommonProp;
import databaseobject.util.LogUtil;
import databaseobject.util.PluginUtil;
/**
* Class used for implementing project properties
* (contains only database DB2 connection)
* @author sbartkowski
*
*/
public class DatabaseObjectPropertyPage extends PropertyPage {
private static final String PROJECT_TITLE = Messages.DatabaseObjectPropertyPage_0;
private static final String DATABASEC = Messages.DatabaseObjectPropertyPage_1;
private static final String DEFAULT_DATABASE = ""; //$NON-NLS-1$
private static final int TEXT_FIELD_WIDTH = 50;
private final List<IConnectionProfile> pList;
private CCombo databaseConn;
private IProject getProject() {
IResource i = (IResource) getElement();
return i.getProject();
}
private CCombo constructCCombo(Composite parent) {
CCombo combo = new CCombo(parent, SWT.BORDER | SWT.READ_ONLY);
for (IConnectionProfile p : pList) {
combo.add(p.getName());
}
return combo;
}
public DatabaseObjectPropertyPage() {
super();
pList = PluginUtil.getConnectionList();
}
private void addFirstSection(Composite parent) {
Composite composite = createDefaultComposite(parent);
// Label for path field
Label pathLabel = new Label(composite, SWT.NONE);
pathLabel.setText(PROJECT_TITLE);
// Path text field
Text pathValueText = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
IProject iP = getProject();
iP.getName();
pathValueText.setText(iP.getName());
}
private void addSeparator(Composite parent) {
Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
GridData gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
separator.setLayoutData(gridData);
}
private void addSecondSection(Composite parent) {
if (pList.size() == 0) {
PluginUtil
.errorMessage(Messages.DatabaseObjectPropertyPage_2);
}
Composite composite = createDefaultComposite(parent);
// Label for owner field
Label ownerLabel = new Label(composite, SWT.NONE);
ownerLabel.setText(DATABASEC);
// Owner text field
// databaseConn = new Text(composite, SWT.SINGLE | SWT.BORDER);
databaseConn = constructCCombo(parent);
GridData gd = new GridData();
gd.widthHint = convertWidthInCharsToPixels(TEXT_FIELD_WIDTH);
databaseConn.setLayoutData(gd);
// Populate database combo field
IProject iP = getProject();
IConnectionProfile iConn = PluginUtil.getConnection(iP,false);
if (iConn != null) {
databaseConn.setText(iConn.getName());
}
else {
databaseConn.setText(DEFAULT_DATABASE);
}
}
/**
* @see PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
GridData data = new GridData(GridData.FILL);
data.grabExcessHorizontalSpace = true;
composite.setLayoutData(data);
addFirstSection(composite);
addSeparator(composite);
addSecondSection(composite);
return composite;
}
private Composite createDefaultComposite(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
composite.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
composite.setLayoutData(data);
return composite;
}
protected void performDefaults() {
super.performDefaults();
// Populate the owner text field with the default value
databaseConn.setText(null);
}
public boolean performOk() {
// store the value in the owner text field
try {
IProject i = getProject();
String id = null;
String dName = databaseConn.getText();
for (IConnectionProfile p : pList) {
if (p.getName().equals(dName)) {
id = p.getInstanceID();
break;
}
}
i.setPersistentProperty(new QualifiedName("", //$NON-NLS-1$
CommonProp.DATABASECONNECTION_PROPERTY), id);
} catch (CoreException e) {
LogUtil.log(Messages.DatabaseObjectPropertyPage_5, e);
}
return true;
}
}
Show details
Hide details
Change log
r537
by stanislawbartkowski on Feb 5, 2012
Diff
First commit
Go to:
...examples/DatabaseObject/META-INF
...abaseObject/META-INF/MANIFEST.MF
.../DatabaseObject/build.properties
...nk/examples/DatabaseObject/icons
...aseObject/icons/dummy-nature.png
.../DatabaseObject/icons/sample.gif
...amples/DatabaseObject/plugin.xml
/trunk/examples/DatabaseObject/src
...atabaseObject/src/databaseobject
...rc/databaseobject/Activator.java
...ject/src/databaseobject/messages
...aseobject/messages/Messages.java
...ect/messages/messages.properties
...Object/src/databaseobject/nature
...object/nature/ProjectNature.java
...eObject/src/databaseobject/popup
...src/databaseobject/popup/actions
.../popup/actions/DeployAction.java
...t/popup/actions/DrawPackage.java
...p/actions/DrawPackageDialog.java
...popup/actions/ExtractDialog.java
...opup/actions/ExtractObjects.java
...ctions/ExtractObjectsDialog.java
...pup/actions/IButtonSelected.java
...ect/popup/actions/NewAction.java
...ct/src/databaseobject/properties
.../DatabaseObjectPropertyPage.java
...seObject/src/databaseobject/util
...abaseobject/util/CommonProp.java
...bject/util/CreateObjectTree.java
...databaseobject/util/LogUtil.java
...abaseobject/util/PluginUtil.java
...eobject/util/ProjectSupport.java
...bject/src/databaseobject/wizards
...ct/wizards/NewProjectWizard.java
.../examples/DatabaseObject/src/org
...s/DatabaseObject/src/org/feature
...abaseObject/src/org/feature/tree
...rg/feature/tree/FeatureTree.java
...org/feature/tree/TreeDialog.java
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 5534 bytes, 186 lines
View raw file
File properties
svn:mime-type
text/plain
Powered by
Google Project Hosting