My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
/*
* Copyright 2011 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 com.db2.sb.scriptlauncher;

import java.io.IOException;

import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PartInitException;

public class DB2ScriptTabView extends JavaLaunchTab {

private Text db2Alias;
private Text db2User;
private Text db2Password;

public final static String DBACCESS_ID = "com.db2.sb.scriptlauncher.DB2_ACCESS"; //$NON-NLS-1$

public final static String DB_SCRIPT_TO_RUN = "com.db2.sb.scriptlauncher.DB_SCRIPT_TO_RUN"; //$NON-NLS-1$
public final static String DB_CONTENT_TO_RUN = "com.db2.sb.scriptlauncher.DB_CONTENT_TO_RUN"; //$NON-NLS-1$

private final static String DBNAME_LABEL = Messages.DB2ScriptTabView_DB2_ALIAS_NAME;
private final static String DB_USER = Messages.DB2ScriptTabView_DB2_USER_NAME;
private final static String DB_PASSWORD = Messages.DB2ScriptTabView_DB2_PASSWORD;

@SuppressWarnings("restriction")
@Override
public void createControl(final Composite parent) {

ModifyListener listener = new ModifyListener() {

@Override
public void modifyText(ModifyEvent arg0) {
updateLaunchConfigurationDialog();
}
};

Composite comp = SWTFactory.createComposite(parent, 1, 1,
GridData.CENTER);
setControl(comp);
// Composite namecomp = SWTFactory.createComposite(comp, comp.getFont(),
// 4, 1, GridData.FILL_HORIZONTAL, 0, 0);
Group namecomp = SWTFactory.createGroup(comp,
Messages.DB2ScriptTabView_DB2_ACCESS_DATA, 4, 1,
GridData.FILL_HORIZONTAL);

SWTFactory.createLabel(namecomp, DBNAME_LABEL, 1);
db2Alias = SWTFactory.createSingleText(namecomp, 1);
db2Alias.addModifyListener(listener);

// namecomp = SWTFactory.createComposite(comp, comp.getFont(), 4, 1,
// GridData.FILL_HORIZONTAL, 0, 0);

SWTFactory.createLabel(namecomp, DB_USER, 1);
db2User = SWTFactory.createSingleText(namecomp, 1);
db2User.addModifyListener(listener);

// namecomp = SWTFactory.createComposite(comp, comp.getFont(), 4, 1,
// GridData.FILL_HORIZONTAL, 0, 0);

SWTFactory.createLabel(namecomp, DB_PASSWORD, 1);
db2Password = SWTFactory.createSingleText(namecomp, 1);
db2Password.addModifyListener(listener);

Composite bcomp = SWTFactory.createComposite(comp, comp.getFont(), 4,
1, GridData.FILL_HORIZONTAL, 0, 0);
Button b = SWTFactory.createPushButton(bcomp,
Messages.DB2ScriptTabView_DB2_BUTTON_TEST, null);

b.addSelectionListener(new SelectionListener() {

@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void widgetSelected(SelectionEvent arg0) {
try {
updateLaunchConfigurationDialog();
DB2LineFactory.executeDB2Script(parent.getShell(), null,
db2Alias.getText(), db2User.getText(),
db2Password.getText(), null, null);
} catch (IOException e) {
e.printStackTrace();
DB2LogUtil.launchererrorLog(e);
} catch (InterruptedException e) {
e.printStackTrace();
DB2LogUtil.launchererrorLog(e);
} catch (PartInitException e) {
DB2LogUtil.launchererrorLog(e);
e.printStackTrace();
}

}
});

}

@Override
public String getName() {
return Messages.DB2ScriptTabView_DB2_LAUNCHER_NAME;
}

@Override
public void setDefaults(ILaunchConfigurationWorkingCopy arg0) {
DB2AccessData a = DB2AccessData.contructDefa();
arg0.setAttribute(DBACCESS_ID, a.getParamList());
}

@Override
public void initializeFrom(ILaunchConfiguration config) {
DB2AccessData a = DB2AccessData.construct(config);
db2Alias.setText(a.getDb2Alias());
db2User.setText(a.getDb2User());
db2Password.setText(a.getDb2Password());
}

@Override
public boolean canSave() {
return true;
}

@Override
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
DB2AccessData a = DB2AccessData.contructDefa();
a.setDb2Alias(db2Alias.getText());
a.setDb2User(db2User.getText());
a.setDb2Password(db2Password.getText());
configuration.setAttribute(DBACCESS_ID, a.getParamList());
}

}

Change log

r492 by stanislawbartkowski on Nov 28, 2011   Diff
Log reporting added and small changes
Go to: 
Project members, sign in to write a code review

Older revisions

r479 by stanislawbartkowski on Oct 29, 2011   Diff
Two issues fixed
r460 by stanislawbartkowski on Oct 7, 2011   Diff
First checkin
All revisions of this file

File info

Size: 5170 bytes, 158 lines

File properties

svn:mime-type
text/plain
Powered by Google Project Hosting