|
1
|
|
|
package br.ufrj.ppgi.greco.kettle; |
|
2
|
|
|
|
|
3
|
|
|
import java.util.ArrayList; |
|
4
|
|
|
import java.util.List; |
|
5
|
|
|
|
|
6
|
|
|
import org.eclipse.swt.SWT; |
|
7
|
|
|
import org.eclipse.swt.custom.CTabFolder; |
|
8
|
|
|
import org.eclipse.swt.custom.CTabItem; |
|
9
|
|
|
import org.eclipse.swt.events.ModifyEvent; |
|
10
|
|
|
import org.eclipse.swt.events.ModifyListener; |
|
11
|
|
|
import org.eclipse.swt.events.SelectionAdapter; |
|
12
|
|
|
import org.eclipse.swt.events.SelectionEvent; |
|
13
|
|
|
import org.eclipse.swt.events.SelectionListener; |
|
14
|
|
|
import org.eclipse.swt.events.ShellAdapter; |
|
15
|
|
|
import org.eclipse.swt.events.ShellEvent; |
|
16
|
|
|
import org.eclipse.swt.layout.FormAttachment; |
|
17
|
|
|
import org.eclipse.swt.layout.FormData; |
|
18
|
|
|
import org.eclipse.swt.layout.FormLayout; |
|
19
|
|
|
import org.eclipse.swt.widgets.Button; |
|
20
|
|
|
import org.eclipse.swt.widgets.Composite; |
|
21
|
|
|
import org.eclipse.swt.widgets.Control; |
|
22
|
|
|
import org.eclipse.swt.widgets.Display; |
|
23
|
|
|
import org.eclipse.swt.widgets.Event; |
|
24
|
|
|
import org.eclipse.swt.widgets.FileDialog; |
|
25
|
|
|
import org.eclipse.swt.widgets.Group; |
|
26
|
|
|
import org.eclipse.swt.widgets.Label; |
|
27
|
|
|
import org.eclipse.swt.widgets.Listener; |
|
28
|
|
|
import org.eclipse.swt.widgets.Shell; |
|
29
|
|
|
import org.eclipse.swt.widgets.Text; |
|
30
|
|
|
import org.pentaho.di.core.Const; |
|
31
|
|
|
import org.pentaho.di.core.util.StringUtil; |
|
32
|
|
|
import org.pentaho.di.trans.TransMeta; |
|
33
|
|
|
import org.pentaho.di.trans.step.BaseStepMeta; |
|
34
|
|
|
import org.pentaho.di.trans.step.StepDialogInterface; |
|
35
|
|
|
import org.pentaho.di.ui.core.widget.ColumnInfo; |
|
36
|
|
|
import org.pentaho.di.ui.core.widget.ComboVar; |
|
37
|
|
|
import org.pentaho.di.ui.core.widget.TableView; |
|
38
|
|
|
import org.pentaho.di.ui.core.widget.TextVar; |
|
39
|
|
|
import org.pentaho.di.ui.trans.step.BaseStepDialog; |
|
40
|
|
|
|
|
41
|
|
|
import br.ufrj.ppgi.greco.kettle.plugin.tools.datatable.DataTable; |
|
42
|
|
|
import br.ufrj.ppgi.greco.kettle.plugin.tools.swthelper.SwtHelper; |
|
43
|
|
|
import br.ufrj.ppgi.greco.kettle.silk.Metric; |
|
44
|
|
|
|
|
45
|
|
|
public class LinkDiscoveryToolStepDialog extends BaseStepDialog implements StepDialogInterface { |
|
46
|
|
|
|
|
47
|
|
|
// private static Class<?> PKG = LinkDiscoveryToolStepMeta.class; |
|
48
|
|
|
|
|
49
|
|
|
private LinkDiscoveryToolStepMeta input; |
|
50
|
|
|
private SwtHelper swthlp; |
|
51
|
|
|
private String dialogTitle; |
|
52
|
|
|
|
|
53
|
|
|
private TextVar wConfigFile; |
|
54
|
|
|
|
|
55
|
|
|
/* tab DataSources */ |
|
56
|
|
|
private Group wSourceEndpointGroup; |
|
57
|
|
|
private TextVar wSourceEndpointURL; |
|
58
|
|
|
private TextVar wSourceGraph; |
|
59
|
|
|
private TextVar wSourceRestriction; |
|
60
|
|
|
|
|
61
|
|
|
private Group wTargetEndpointGroup; |
|
62
|
|
|
private TextVar wTargetEndpointURL; |
|
63
|
|
|
private TextVar wTargetGraph; |
|
64
|
|
|
private TextVar wTargetRestriction; |
|
65
|
|
|
|
|
66
|
|
|
/* tab Prefixes */ |
|
67
|
|
|
private TableView wPrefixes; |
|
68
|
|
|
|
|
69
|
|
|
/* tab Linkage Rules */ |
|
70
|
|
|
private TextVar wLinkageType; |
|
71
|
|
|
private ComboVar wAggregationType; |
|
72
|
|
|
private TableView wMetrics; |
|
73
|
|
|
|
|
74
|
|
|
/* tab Output */ |
|
75
|
|
|
private Group wOutputGroup; |
|
76
|
|
|
private TextVar wOutputFolder; |
|
77
|
|
|
private Button wOutputSparql; |
|
78
|
|
|
private TextVar wOutputEndpoint; |
|
79
|
|
|
private TextVar wOutputGraph; |
|
80
|
|
|
|
|
81
|
|
|
/* constants */ |
|
82
|
|
|
protected String[][] defaultPrefixes = { { "xsd", "http://www.w3.org/2001/XMLSchema#" }, |
|
83
|
|
|
{ "rdfs", "http://www.w3.org/2000/01/rdf-schema#" }, |
|
84
|
|
|
{ "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" }, { "owl", "http://www.w3.org/2002/07/owl#" }, |
|
85
|
|
|
{ "dbpedia", "http://dbpedia.org/ontology/" }, { "dbpprop", "http://dbpedia.org/property/" }, |
|
86
|
|
|
{ "dc", "http://purl.org/dc/elements/1.1/" }, { "foaf", "http://xmlns.com/foaf/0.1/" }, |
|
87
|
|
|
{ "vcard", "http://www.w3.org/2006/vcard/ns#" }, { "cc", "http://creativecommons.org/ns#" }, |
|
88
|
|
|
{ "skos", "http://www.w3.org/2004/02/skos/core#" }, { "gn", "http://www.geonames.org/ontology#" } }; |
|
89
|
|
|
private String[] aggregationTypes = { "average", "min", "max", "quadraticMean", "geometricMean" }; |
|
90
|
|
|
|
|
91
|
|
|
public LinkDiscoveryToolStepDialog(Shell parent, Object stepMeta, TransMeta transMeta, String stepname) { |
|
92
|
|
|
super(parent, (BaseStepMeta) stepMeta, transMeta, stepname); |
|
93
|
|
|
|
|
94
|
|
|
input = (LinkDiscoveryToolStepMeta) baseStepMeta; |
|
95
|
|
|
swthlp = new SwtHelper(transMeta, this.props); |
|
96
|
|
|
|
|
97
|
|
|
dialogTitle = "Link Discovery Tool"; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
private void fileDialogFunction(int type, String[] fileExtensions, TextVar receptor, String[] filterNames) { |
|
101
|
|
|
FileDialog dialog = new FileDialog(shell, type); |
|
102
|
|
|
dialog.setFilterExtensions(fileExtensions); |
|
103
|
|
|
if (receptor.getText() != null) { |
|
104
|
|
|
dialog.setFileName(receptor.getText()); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
dialog.setFilterNames(filterNames); |
|
108
|
|
|
|
|
109
|
|
|
if (dialog.open() != null) { |
|
110
|
|
|
String str = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName(); |
|
111
|
|
|
receptor.setText(str); |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
private Control buildContents(Control lastControl, ModifyListener defModListener) { |
|
116
|
|
|
|
|
117
|
|
|
CTabFolder wTabFolder = swthlp.appendTabFolder(shell, lastControl, 90); |
|
118
|
|
|
|
|
119
|
|
|
CTabItem item = new CTabItem(wTabFolder, SWT.NONE); |
|
120
|
|
|
item.setText("Data Sources"); |
|
121
|
|
|
Composite cpt = swthlp.appendComposite(wTabFolder, lastControl); |
|
122
|
|
|
|
|
123
|
|
|
wConfigFile = textVarWithButton(cpt, null, "Config XML file", defModListener, "...", new SelectionAdapter() { |
|
124
|
|
|
public void widgetSelected(SelectionEvent e) { |
|
125
|
|
|
fileDialogFunction(SWT.OPEN, new String[] { "*.xml" }, wConfigFile, new String[] { "XML files" }); |
|
126
|
|
|
} |
|
127
|
|
|
}); |
|
128
|
|
|
wConfigFile.setToolTipText("If a config file is set, all other fields are not going to be used!"); |
|
129
|
|
|
|
|
130
|
|
|
wSourceEndpointGroup = swthlp.appendGroup(cpt, wConfigFile, "Source"); |
|
131
|
|
|
wSourceEndpointURL = textVarWithButton(wSourceEndpointGroup, wSourceEndpointGroup, "Endpoint URL", |
|
132
|
|
|
defModListener, "...", new SelectionAdapter() { |
|
133
|
|
|
public void widgetSelected(SelectionEvent e) { |
|
134
|
|
|
fileDialogFunction(SWT.OPEN, new String[] { "*.csv; *.rdf; *.ttl; *.nt; *.xml" }, |
|
135
|
|
|
wSourceEndpointURL, new String[] { ".(csv, rdf, ttl, nt, xml) files" }); |
|
136
|
|
|
} |
|
137
|
|
|
}); |
|
138
|
|
|
wSourceGraph = swthlp.appendTextVarRow(wSourceEndpointGroup, wSourceEndpointURL, "Graph", defModListener); |
|
139
|
|
|
wSourceRestriction = swthlp.appendTextVarRow(wSourceEndpointGroup, wSourceGraph, "Restriction", defModListener); |
|
140
|
|
|
|
|
141
|
|
|
wTargetEndpointGroup = swthlp.appendGroup(cpt, wSourceEndpointGroup, "Target"); |
|
142
|
|
|
wTargetEndpointURL = textVarWithButton(wTargetEndpointGroup, wTargetEndpointGroup, "Endpoint URL", |
|
143
|
|
|
defModListener, "...", new SelectionAdapter() { |
|
144
|
|
|
public void widgetSelected(SelectionEvent e) { |
|
145
|
|
|
fileDialogFunction(SWT.OPEN, new String[] { "*.csv; *.rdf; *.ttl; *.nt; *.xml" }, |
|
146
|
|
|
wTargetEndpointURL, new String[] { ".(csv, rdf, ttl, nt, xml) files" }); |
|
147
|
|
|
} |
|
148
|
|
|
}); |
|
149
|
|
|
wTargetGraph = swthlp.appendTextVarRow(wTargetEndpointGroup, wTargetEndpointURL, "Graph", defModListener); |
|
150
|
|
|
wTargetRestriction = swthlp.appendTextVarRow(wTargetEndpointGroup, wTargetGraph, "Restriction", defModListener); |
|
151
|
|
|
|
|
152
|
|
|
item.setControl(cpt); |
|
153
|
|
|
|
|
154
|
|
|
item = new CTabItem(wTabFolder, SWT.NONE); |
|
155
|
|
|
item.setText("Prefixes"); |
|
156
|
|
|
|
|
157
|
|
|
ColumnInfo[] columns = new ColumnInfo[] { new ColumnInfo("Prefix", ColumnInfo.COLUMN_TYPE_TEXT), |
|
158
|
|
|
new ColumnInfo("Namespace \u00A0", ColumnInfo.COLUMN_TYPE_TEXT) }; |
|
159
|
|
|
cpt = swthlp.appendComposite(wTabFolder, null); |
|
160
|
|
|
wPrefixes = swthlp.appendTableView(cpt, null, columns, defModListener, 90); |
|
161
|
|
|
|
|
162
|
|
|
swthlp.appendButtonsRow(cpt, wPrefixes, new String[] { "Clear", "Defaults" }, |
|
163
|
|
|
new SelectionListener[] { new SelectionListener() { |
|
164
|
|
|
|
|
165
|
|
|
public void widgetSelected(SelectionEvent arg0) { |
|
166
|
|
|
wPrefixes.removeAll(); |
|
167
|
|
|
input.setChanged(); |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
public void widgetDefaultSelected(SelectionEvent arg0) { |
|
171
|
|
|
input.setChanged(); |
|
172
|
|
|
} |
|
173
|
|
|
}, new SelectionListener() { |
|
174
|
|
|
|
|
175
|
|
|
public void widgetSelected(SelectionEvent arg0) { |
|
176
|
|
|
for (String[] row : defaultPrefixes) |
|
177
|
|
|
insertRow(wPrefixes, row); |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
public void widgetDefaultSelected(SelectionEvent arg0) { |
|
181
|
|
|
input.setChanged(); |
|
182
|
|
|
} |
|
183
|
|
|
} }); |
|
184
|
|
|
item.setControl(cpt); |
|
185
|
|
|
|
|
186
|
|
|
item = new CTabItem(wTabFolder, SWT.NONE); |
|
187
|
|
|
item.setText("Linkage Rules"); |
|
188
|
|
|
cpt = swthlp.appendComposite(wTabFolder, null); |
|
189
|
|
|
|
|
190
|
|
|
wLinkageType = swthlp.appendTextVarRow(cpt, null, "Linkage Type", defModListener); |
|
191
|
|
|
wAggregationType = swthlp.appendComboVarRow(cpt, wLinkageType, "Aggregation Type", defModListener); |
|
192
|
|
|
wAggregationType.setItems(aggregationTypes); |
|
193
|
|
|
|
|
194
|
|
|
columns = new ColumnInfo[] { new ColumnInfo("Source Path", ColumnInfo.COLUMN_TYPE_TEXT), |
|
195
|
|
|
new ColumnInfo("Target Path", ColumnInfo.COLUMN_TYPE_TEXT), |
|
196
|
|
|
new ColumnInfo("Metric", ColumnInfo.COLUMN_TYPE_CCOMBO, Metric.getMetricsNames()) }; |
|
197
|
|
|
|
|
198
|
|
|
wMetrics = swthlp.appendTableView(cpt, wAggregationType, columns, defModListener, 90); |
|
199
|
|
|
|
|
200
|
|
|
item.setControl(cpt); |
|
201
|
|
|
|
|
202
|
|
|
item = new CTabItem(wTabFolder, SWT.NONE); |
|
203
|
|
|
item.setText("Output"); |
|
204
|
|
|
cpt = swthlp.appendComposite(wTabFolder, lastControl); |
|
205
|
|
|
|
|
206
|
|
|
wOutputGroup = swthlp.appendGroup(cpt, null, "Output Config"); |
|
207
|
|
|
|
|
208
|
|
|
wOutputFolder = textVarWithButton(wOutputGroup, wOutputGroup, "Output File", defModListener, "...", |
|
209
|
|
|
new SelectionAdapter() { |
|
210
|
|
|
public void widgetSelected(SelectionEvent e) { |
|
211
|
|
|
fileDialogFunction(SWT.SAVE, new String[] { "*.nt" }, wOutputFolder, |
|
212
|
|
|
new String[] { "RDF/N-TRIPLES files" }); |
|
213
|
|
|
} |
|
214
|
|
|
}); |
|
215
|
|
|
|
|
216
|
|
|
wOutputSparql = swthlp.appendCheckboxRow(wOutputGroup, wOutputFolder, |
|
217
|
|
|
"Output to a Sparql Endpoint?", new SelectionListener() { |
|
218
|
|
|
|
|
219
|
|
|
public void widgetDefaultSelected(SelectionEvent arg0) { |
|
220
|
|
|
widgetSelected(arg0); |
|
221
|
|
|
} |
|
222
|
|
|
|
|
223
|
|
|
public void widgetSelected(SelectionEvent e) { |
|
224
|
|
|
enableSparqlGraph(wOutputSparql.getSelection()); |
|
225
|
|
|
input.setChanged(true); |
|
226
|
|
|
} |
|
227
|
|
|
}); |
|
228
|
|
|
|
|
229
|
|
|
wOutputEndpoint = swthlp.appendTextVarRow(wOutputGroup, wOutputSparql, "Endpoint URL", defModListener); |
|
230
|
|
|
wOutputGraph = swthlp.appendTextVarRow(wOutputGroup, wOutputEndpoint, "Graph", defModListener); |
|
231
|
|
|
|
|
232
|
|
|
item.setControl(cpt); |
|
233
|
|
|
|
|
234
|
|
|
wTabFolder.setSelection(0); |
|
235
|
|
|
|
|
236
|
|
|
return wTabFolder; |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
private void enableSparqlGraph(boolean enable) { |
|
240
|
|
|
wOutputFolder.setEnabled(!enable); |
|
241
|
|
|
wOutputGraph.setEnabled(enable); |
|
242
|
|
|
wOutputEndpoint.setEnabled(enable); |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
private TextVar textVarWithButton(Composite parent, Control lastControl, String label, ModifyListener lsMod, |
|
246
|
|
|
String btnLabel, SelectionListener listener) { |
|
247
|
|
|
int middle = props.getMiddlePct(); |
|
248
|
|
|
int margin = Const.MARGIN; |
|
249
|
|
|
Label wLabel = new Label(parent, SWT.RIGHT); |
|
250
|
|
|
wLabel.setText(label); |
|
251
|
|
|
props.setLook(wLabel); |
|
252
|
|
|
FormData fdLabel = new FormData(); |
|
253
|
|
|
fdLabel.left = new FormAttachment(0, 0); |
|
254
|
|
|
fdLabel.top = new FormAttachment(lastControl, margin); |
|
255
|
|
|
fdLabel.right = new FormAttachment(middle, -margin); |
|
256
|
|
|
wLabel.setLayoutData(fdLabel); |
|
257
|
|
|
|
|
258
|
|
|
Button button = new Button(parent, SWT.PUSH | SWT.CENTER); |
|
259
|
|
|
props.setLook(button); |
|
260
|
|
|
button.setText(btnLabel); |
|
261
|
|
|
FormData fdButton = new FormData(); |
|
262
|
|
|
fdButton.right = new FormAttachment(100, 0); |
|
263
|
|
|
fdButton.top = new FormAttachment(lastControl, margin); |
|
264
|
|
|
button.setLayoutData(fdButton); |
|
265
|
|
|
|
|
266
|
|
|
TextVar text = new TextVar(transMeta, parent, SWT.SINGLE | SWT.LEFT | SWT.BORDER); |
|
267
|
|
|
props.setLook(text); |
|
268
|
|
|
text.addModifyListener(lsMod); |
|
269
|
|
|
FormData fdText = new FormData(); |
|
270
|
|
|
fdText.left = new FormAttachment(middle, 0); |
|
271
|
|
|
fdText.right = new FormAttachment(button, -margin); |
|
272
|
|
|
fdText.top = new FormAttachment(lastControl, margin); |
|
273
|
|
|
text.setLayoutData(fdText); |
|
274
|
|
|
|
|
275
|
|
|
button.addSelectionListener(listener); |
|
276
|
|
|
return text; |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
private void addSelectionListenerToControls(SelectionAdapter lsDef) { |
|
280
|
|
|
wSourceEndpointURL.addSelectionListener(lsDef); |
|
281
|
|
|
wSourceGraph.addSelectionListener(lsDef); |
|
282
|
|
|
wSourceRestriction.addSelectionListener(lsDef); |
|
283
|
|
|
wTargetEndpointURL.addSelectionListener(lsDef); |
|
284
|
|
|
wTargetGraph.addSelectionListener(lsDef); |
|
285
|
|
|
wTargetRestriction.addSelectionListener(lsDef); |
|
286
|
|
|
wLinkageType.addSelectionListener(lsDef); |
|
287
|
|
|
wAggregationType.addSelectionListener(lsDef); |
|
288
|
|
|
wOutputFolder.addSelectionListener(lsDef); |
|
289
|
|
|
wConfigFile.addSelectionListener(lsDef); |
|
290
|
|
|
wOutputGraph.addSelectionListener(lsDef); |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
View Code Duplication |
public String open() { |
|
|
|
|
|
|
294
|
|
|
|
|
295
|
|
|
Shell parent = getParent(); |
|
296
|
|
|
Display display = parent.getDisplay(); |
|
297
|
|
|
|
|
298
|
|
|
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX); |
|
299
|
|
|
props.setLook(shell); |
|
300
|
|
|
setShellImage(shell, input); |
|
301
|
|
|
|
|
302
|
|
|
ModifyListener lsMod = new ModifyListener() { |
|
303
|
|
|
|
|
304
|
|
|
public void modifyText(ModifyEvent e) { |
|
305
|
|
|
input.setChanged(); |
|
306
|
|
|
} |
|
307
|
|
|
}; |
|
308
|
|
|
boolean changed = input.hasChanged(); |
|
309
|
|
|
|
|
310
|
|
|
FormLayout formLayout = new FormLayout(); |
|
311
|
|
|
formLayout.marginWidth = Const.FORM_MARGIN; |
|
312
|
|
|
formLayout.marginHeight = Const.FORM_MARGIN; |
|
313
|
|
|
|
|
314
|
|
|
shell.setLayout(formLayout); |
|
315
|
|
|
|
|
316
|
|
|
shell.setText(dialogTitle); |
|
317
|
|
|
|
|
318
|
|
|
int middle = props.getMiddlePct(); |
|
319
|
|
|
int margin = Const.MARGIN; |
|
320
|
|
|
|
|
321
|
|
|
// Adiciona um label e um input text no topo do dialog shell |
|
322
|
|
|
wlStepname = new Label(shell, SWT.RIGHT); |
|
323
|
|
|
wlStepname.setText("Step Name"); |
|
324
|
|
|
props.setLook(wlStepname); |
|
325
|
|
|
|
|
326
|
|
|
fdlStepname = new FormData(); |
|
327
|
|
|
fdlStepname.left = new FormAttachment(0, 0); |
|
328
|
|
|
fdlStepname.right = new FormAttachment(middle, -margin); |
|
329
|
|
|
fdlStepname.top = new FormAttachment(0, margin); |
|
330
|
|
|
wlStepname.setLayoutData(fdlStepname); |
|
331
|
|
|
|
|
332
|
|
|
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); |
|
333
|
|
|
wStepname.setText(stepname); |
|
334
|
|
|
props.setLook(wStepname); |
|
335
|
|
|
|
|
336
|
|
|
wStepname.addModifyListener(lsMod); |
|
337
|
|
|
fdStepname = new FormData(); |
|
338
|
|
|
fdStepname.left = new FormAttachment(middle, 0); |
|
339
|
|
|
fdStepname.top = new FormAttachment(0, margin); |
|
340
|
|
|
fdStepname.right = new FormAttachment(100, 0); |
|
341
|
|
|
wStepname.setLayoutData(fdStepname); |
|
342
|
|
|
Control lastControl = wStepname; |
|
343
|
|
|
|
|
344
|
|
|
lastControl = buildContents(lastControl, lsMod); |
|
345
|
|
|
|
|
346
|
|
|
// Bottom buttons |
|
347
|
|
|
wOK = new Button(shell, SWT.PUSH); |
|
348
|
|
|
wOK.setText("OK"); //$NON-NLS-1$ |
|
349
|
|
|
wCancel = new Button(shell, SWT.PUSH); |
|
350
|
|
|
wCancel.setText("Cancel"); //$NON-NLS-1$ |
|
351
|
|
|
setButtonPositions(new Button[] { wOK, wCancel }, margin, lastControl); |
|
352
|
|
|
|
|
353
|
|
|
// Add listeners |
|
354
|
|
|
lsCancel = new Listener() { |
|
355
|
|
|
public void handleEvent(Event e) { |
|
356
|
|
|
cancel(); |
|
357
|
|
|
} |
|
358
|
|
|
}; |
|
359
|
|
|
lsOK = new Listener() { |
|
360
|
|
|
public void handleEvent(Event e) { |
|
361
|
|
|
ok(); |
|
362
|
|
|
} |
|
363
|
|
|
}; |
|
364
|
|
|
|
|
365
|
|
|
wCancel.addListener(SWT.Selection, lsCancel); |
|
366
|
|
|
wOK.addListener(SWT.Selection, lsOK); |
|
367
|
|
|
|
|
368
|
|
|
lsDef = new SelectionAdapter() { |
|
369
|
|
|
public void widgetDefaultSelected(SelectionEvent e) { |
|
370
|
|
|
ok(); |
|
371
|
|
|
} |
|
372
|
|
|
}; |
|
373
|
|
|
wStepname.addSelectionListener(lsDef); |
|
374
|
|
|
addSelectionListenerToControls(lsDef); |
|
375
|
|
|
|
|
376
|
|
|
// Detect X or ALT-F4 or something that kills this window... |
|
377
|
|
|
shell.addShellListener(new ShellAdapter() { |
|
378
|
|
|
public void shellClosed(ShellEvent e) { |
|
379
|
|
|
cancel(); |
|
380
|
|
|
} |
|
381
|
|
|
}); |
|
382
|
|
|
|
|
383
|
|
|
// Populate the data of the controls |
|
384
|
|
|
getData(); |
|
385
|
|
|
|
|
386
|
|
|
// Set the shell size, based upon previous time... |
|
387
|
|
|
setSize(); |
|
388
|
|
|
|
|
389
|
|
|
input.setChanged(changed); |
|
390
|
|
|
|
|
391
|
|
|
shell.open(); |
|
392
|
|
|
while (!shell.isDisposed()) { |
|
393
|
|
|
if (!display.readAndDispatch()) |
|
394
|
|
|
display.sleep(); |
|
395
|
|
|
} |
|
396
|
|
|
return stepname; |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
private void getData() { |
|
400
|
|
|
wStepname.selectAll(); |
|
401
|
|
|
|
|
402
|
|
|
try { |
|
403
|
|
|
DataTable<String> table = input.getMetrics(); |
|
404
|
|
|
DataTable<String>.RowFactory rf = this.getRowFactoryRead(table); |
|
405
|
|
|
|
|
406
|
|
|
for (int i = 0; i < table.size(); i++) { |
|
407
|
|
|
wMetrics.add(table.getRowRange(i, rf).getRow()); |
|
408
|
|
|
} |
|
409
|
|
|
wMetrics.remove(0); |
|
410
|
|
|
|
|
411
|
|
|
table = input.getPrefixes(); |
|
412
|
|
|
rf = this.getRowFactoryRead(table); |
|
413
|
|
|
|
|
414
|
|
|
for (int i = 0; i < table.size(); i++) { |
|
415
|
|
|
wPrefixes.add(table.getRowRange(i, rf).getRow()); |
|
416
|
|
|
} |
|
417
|
|
|
wPrefixes.remove(0); |
|
418
|
|
|
|
|
419
|
|
|
this.wConfigFile.setText(Const.NVL(input.getConfigFile(), "")); |
|
420
|
|
|
|
|
421
|
|
|
this.wSourceEndpointURL.setText(Const.NVL(input.getSourceEndpoint(), "")); |
|
422
|
|
|
this.wSourceGraph.setText(Const.NVL(input.getSourceGraph(), "")); |
|
423
|
|
|
this.wSourceRestriction.setText(Const.NVL(input.getSourceRestriction(), "")); |
|
424
|
|
|
this.wTargetEndpointURL.setText(Const.NVL(input.getTargetEndpoint(), "")); |
|
425
|
|
|
this.wTargetGraph.setText(Const.NVL(input.getTargetGraph(), "")); |
|
426
|
|
|
this.wTargetRestriction.setText(Const.NVL(input.getTargetRestriction(), "")); |
|
427
|
|
|
|
|
428
|
|
|
this.wLinkageType.setText(Const.NVL(input.getLinkageType(), "")); |
|
429
|
|
|
this.wAggregationType.setText(Const.NVL(input.getAggregationType(), "")); |
|
430
|
|
|
|
|
431
|
|
|
this.wOutputFolder.setText(Const.NVL(input.getFilePath(), "")); |
|
432
|
|
|
wOutputSparql.setSelection(input.isSparqlOutput()); |
|
433
|
|
|
this.enableSparqlGraph(wOutputSparql.getSelection()); |
|
434
|
|
|
this.wOutputEndpoint.setText(Const.NVL(input.getOutputEndpoint(), "")); |
|
435
|
|
|
this.wOutputGraph.setText(Const.NVL(input.getOutputGraph(), "")); |
|
436
|
|
|
|
|
437
|
|
|
} catch (NullPointerException e) { |
|
438
|
|
|
|
|
439
|
|
|
} |
|
440
|
|
|
} |
|
441
|
|
|
|
|
442
|
|
|
protected void cancel() { |
|
443
|
|
|
stepname = null; |
|
444
|
|
|
input.setChanged(changed); |
|
445
|
|
|
dispose(); |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
protected void ok() { |
|
449
|
|
|
if (StringUtil.isEmpty(wStepname.getText())) |
|
450
|
|
|
return; |
|
451
|
|
|
|
|
452
|
|
|
stepname = wStepname.getText(); |
|
453
|
|
|
|
|
454
|
|
|
DataTable<String> table = new DataTable<String>(LinkDiscoveryToolStepMeta.Field.METRICS_TABLE.name(), |
|
455
|
|
|
LinkDiscoveryToolStepMeta.Field.METRICS_TABLE_SOURCE.name(), |
|
456
|
|
|
LinkDiscoveryToolStepMeta.Field.METRICS_TABLE_TARGET.name(), |
|
457
|
|
|
LinkDiscoveryToolStepMeta.Field.METRICS_TABLE_METRIC.name()); |
|
458
|
|
|
DataTable<String>.RowFactory rf = getRowFactoryMetrics(table); |
|
459
|
|
|
for (int i = 0; i < wMetrics.getItemCount(); i++) { |
|
460
|
|
|
table.add(rf.newRow(wMetrics.getItem(i)).getFullRow()); |
|
461
|
|
|
} |
|
462
|
|
|
input.setMetrics(table); |
|
463
|
|
|
|
|
464
|
|
|
table = new DataTable<String>(LinkDiscoveryToolStepMeta.Field.PREFIXES_TABLE.name(), |
|
465
|
|
|
LinkDiscoveryToolStepMeta.Field.PREFIXES_TABLE_PREFIX.name(), |
|
466
|
|
|
LinkDiscoveryToolStepMeta.Field.PREFIXES_TABLE_NAMESPACE.name()); |
|
467
|
|
|
rf = getRowFactoryPrefixes(table); |
|
468
|
|
|
for (int i = 0; i < wPrefixes.getItemCount(); i++) { |
|
469
|
|
|
table.add(rf.newRow(wPrefixes.getItem(i)).getFullRow()); |
|
470
|
|
|
} |
|
471
|
|
|
input.setPrefixes(table); |
|
472
|
|
|
|
|
473
|
|
|
input.setConfigFile(this.wConfigFile.getText()); |
|
474
|
|
|
|
|
475
|
|
|
input.setSourceEndpoint(this.wSourceEndpointURL.getText()); |
|
476
|
|
|
input.setSourceGraph(this.wSourceGraph.getText()); |
|
477
|
|
|
input.setSourceRestriction(this.wSourceRestriction.getText()); |
|
478
|
|
|
input.setTargetEndpoint(this.wTargetEndpointURL.getText()); |
|
479
|
|
|
input.setTargetGraph(this.wTargetGraph.getText()); |
|
480
|
|
|
input.setTargetRestriction(this.wTargetRestriction.getText()); |
|
481
|
|
|
|
|
482
|
|
|
input.setLinkageType(this.wLinkageType.getText()); |
|
483
|
|
|
input.setAggregationType(this.wAggregationType.getText()); |
|
484
|
|
|
|
|
485
|
|
|
input.setSparqlOutput(this.wOutputSparql.getSelection()); |
|
486
|
|
|
input.setOutputFolder(this.wOutputFolder.getText()); |
|
487
|
|
|
input.setOutputEndpoint(this.wOutputEndpoint.getText()); |
|
488
|
|
|
input.setOutputGraph(this.wOutputGraph.getText()); |
|
489
|
|
|
|
|
490
|
|
|
dispose(); |
|
491
|
|
|
} |
|
492
|
|
|
|
|
493
|
|
|
private DataTable<String>.RowFactory getRowFactoryMetrics(DataTable<String> table) { |
|
494
|
|
|
return table.newRowFactory(LinkDiscoveryToolStepMeta.Field.METRICS_TABLE_SOURCE.name(), |
|
495
|
|
|
LinkDiscoveryToolStepMeta.Field.METRICS_TABLE_TARGET.name(), |
|
496
|
|
|
LinkDiscoveryToolStepMeta.Field.METRICS_TABLE_METRIC.name()); |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
private DataTable<String>.RowFactory getRowFactoryPrefixes(DataTable<String> table) { |
|
500
|
|
|
return table.newRowFactory(LinkDiscoveryToolStepMeta.Field.PREFIXES_TABLE_PREFIX.name(), |
|
501
|
|
|
LinkDiscoveryToolStepMeta.Field.PREFIXES_TABLE_NAMESPACE.name()); |
|
502
|
|
|
} |
|
503
|
|
|
|
|
504
|
|
|
private DataTable<String>.RowFactory getRowFactoryRead(DataTable<String> table) { |
|
505
|
|
|
List<String> header = new ArrayList<String>(); |
|
506
|
|
|
header.addAll(table.getHeader()); |
|
507
|
|
|
return table.newRowFactory(header.toArray(new String[0])); |
|
508
|
|
|
} |
|
509
|
|
|
|
|
510
|
|
|
private void insertRow(TableView tvTable, String[] row) { |
|
511
|
|
|
if (tvTable.table.getItem(0).getText(1).equals("")) { |
|
512
|
|
|
for (int i = 0; i < row.length; i++) |
|
513
|
|
|
tvTable.table.getItem(0).setText(i + 1, row[i]); |
|
514
|
|
|
} else { |
|
515
|
|
|
tvTable.add(row); |
|
516
|
|
|
} |
|
517
|
|
|
} |
|
518
|
|
|
} |
|
519
|
|
|
|