30 |
brianR |
1 |
/*
|
|
|
2 |
* Mylyn Connector for Serena Business Mashups
|
|
|
3 |
* Copyright 2010 Brian Rosenberger (Brutex Network)
|
|
|
4 |
*
|
|
|
5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
6 |
* you may not use this file except in compliance with the License.
|
|
|
7 |
* You may obtain a copy of the License at
|
|
|
8 |
*
|
|
|
9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
10 |
*
|
|
|
11 |
* Unless required by applicable law or agreed to in writing, software
|
|
|
12 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
14 |
* See the License for the specific language governing permissions and
|
|
|
15 |
* limitations under the License.
|
|
|
16 |
*
|
|
|
17 |
* Serena, TeamTrack and Serena Business Mashup are
|
|
|
18 |
* registered trademarks of SERENA Software Inc.
|
|
|
19 |
*/
|
|
|
20 |
package net.brutex.mylyn.sbmconnector.ui;
|
|
|
21 |
|
|
|
22 |
import net.brutex.mylyn.sbmconnector.core.SBMRepositoryConnector;
|
|
|
23 |
|
|
|
24 |
import org.eclipse.jface.dialogs.Dialog;
|
|
|
25 |
import org.eclipse.jface.layout.GridDataFactory;
|
|
|
26 |
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
|
|
|
27 |
import org.eclipse.mylyn.tasks.core.TaskRepository;
|
|
|
28 |
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
|
|
|
29 |
import org.eclipse.swt.SWT;
|
|
|
30 |
import org.eclipse.swt.layout.GridData;
|
|
|
31 |
import org.eclipse.swt.layout.GridLayout;
|
|
|
32 |
import org.eclipse.swt.widgets.Combo;
|
|
|
33 |
import org.eclipse.swt.widgets.Composite;
|
|
|
34 |
import org.eclipse.swt.widgets.Label;
|
|
|
35 |
import org.eclipse.swt.widgets.Text;
|
|
|
36 |
|
|
|
37 |
public class SBMRepositoryQueryPage extends AbstractRepositoryQueryPage {
|
|
|
38 |
|
|
|
39 |
private Combo table = null;
|
|
|
40 |
private Text sql_where_clause = null;
|
|
|
41 |
private Text query_title = null;
|
|
|
42 |
|
|
|
43 |
public SBMRepositoryQueryPage(String pageName, TaskRepository repository,
|
|
|
44 |
IRepositoryQuery query) {
|
|
|
45 |
super(pageName, repository, query);
|
|
|
46 |
setTitle("SBM Query");
|
|
|
47 |
setDescription("Please specify table database name.");
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
@Override
|
|
|
51 |
public void applyTo(IRepositoryQuery query) {
|
|
|
52 |
if (getQueryTitle() != null) {
|
|
|
53 |
query.setSummary(getQueryTitle());
|
|
|
54 |
}
|
|
|
55 |
query.setAttribute("table", table.getText());
|
|
|
56 |
query.setAttribute("sql_where", sql_where_clause.getText());
|
|
|
57 |
query.setAttribute("name", query_title.getText());
|
|
|
58 |
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
@Override
|
|
|
62 |
public String getQueryTitle() {
|
|
|
63 |
if(query_title!=null && !query_title.getText().isEmpty()) return query_title.getText();
|
|
|
64 |
return "new query";
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
@Override
|
|
|
68 |
public void createControl(Composite arg0) {
|
|
|
69 |
Composite control = new Composite(arg0,SWT.BORDER);
|
|
|
70 |
control.setLayout(new GridLayout(2, false));
|
|
|
71 |
Label query_label = new Label(control, SWT.NONE);
|
|
|
72 |
query_label.setText("Query Name:");
|
|
|
73 |
query_title = new Text(control, SWT.BORDER);
|
|
|
74 |
if(getQuery()!=null) query_title.setText(getQuery().getAttribute("name"));
|
|
|
75 |
|
|
|
76 |
Label label = new Label(control, SWT.NONE);
|
|
|
77 |
label.setText("Table:");
|
|
|
78 |
|
|
|
79 |
table = new Combo(control, SWT.SINGLE | SWT.BORDER);
|
|
|
80 |
for(String table_name : SBMRepositoryConnector.getClient(getTaskRepository()).getPrimaryTables()) {
|
|
|
81 |
table.add(table_name);
|
|
|
82 |
if(getQuery()!=null && getQuery().getAttribute("table").equals(table_name)) {
|
|
|
83 |
table.setText(table_name);
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
|
|
|
91 |
GridData gd = new GridData(300, 150);
|
|
|
92 |
gd.horizontalSpan = 2;
|
|
|
93 |
sql_where_clause.setLayoutData(gd);
|
|
|
94 |
if(getQuery()!=null) sql_where_clause.setText(getQuery().getAttribute("sql_where"));
|
|
|
95 |
|
|
|
96 |
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(table);
|
|
|
97 |
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(query_title);
|
|
|
98 |
Dialog.applyDialogFont(control);
|
|
|
99 |
setControl(control);
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
}
|