Subversion Repositories XServices

Rev

Rev 39 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 52
Line 18... Line 18...
18
 * 	 registered trademarks of SERENA Software Inc.
18
 * 	 registered trademarks of SERENA Software Inc.
19
 */
19
 */
20
package net.brutex.mylyn.sbmconnector.ui;
20
package net.brutex.mylyn.sbmconnector.ui;
Line 21... Line 21...
21
 
21
 
-
 
22
import java.awt.Color;
Line 22... Line 23...
22
import java.awt.Color;
23
import java.util.ArrayList;
23
 
24
 
24
import net.brutex.mylyn.sbmconnector.core.SBMRepositoryConnector;
25
import net.brutex.mylyn.sbmconnector.core.SBMRepositoryConnector;
-
 
26
import net.brutex.mylyn.sbmconnector.core.model.SBMField;
Line 25... Line 27...
25
import net.brutex.mylyn.sbmconnector.core.model.SBMField;
27
import net.brutex.mylyn.sbmconnector.core.model.SBMSystemFields;
26
import net.brutex.mylyn.sbmconnector.core.model.SBMSystemFields;
28
import net.brutex.sbm.wsclient.ReportInfo;
27
 
29
 
28
import org.eclipse.jface.dialogs.Dialog;
30
import org.eclipse.jface.dialogs.Dialog;
Line 45... Line 47...
45
import org.eclipse.swt.widgets.Table;
47
import org.eclipse.swt.widgets.Table;
46
import org.eclipse.swt.widgets.TableColumn;
48
import org.eclipse.swt.widgets.TableColumn;
47
import org.eclipse.swt.widgets.TableItem;
49
import org.eclipse.swt.widgets.TableItem;
48
import org.eclipse.swt.widgets.Text;
50
import org.eclipse.swt.widgets.Text;
49
import org.eclipse.swt.widgets.Widget;
51
import org.eclipse.swt.widgets.Widget;
-
 
52
import org.eclipse.ui.forms.widgets.ExpandableComposite;
-
 
53
import org.eclipse.ui.forms.widgets.FormToolkit;
Line 50... Line 54...
50
 
54
 
Line 51... Line 55...
51
public class SBMRepositoryQueryPage extends AbstractRepositoryQueryPage {
55
public class SBMRepositoryQueryPage extends AbstractRepositoryQueryPage {
52
 
56
 
-
 
57
	private Text sql_where_clause = null;
-
 
58
	private Text query_title = null;
-
 
59
	private Combo reportcombo = null;
-
 
60
	private ReportInfo selectedReport = null;
-
 
61
 
-
 
62
	public static String SQL_QUERY = "sql_where";
-
 
63
	public static String SQL_QUERY_NAME = "name";
Line 53... Line 64...
53
	private Text sql_where_clause = null;
64
	public static String REPORT = "report";
54
	private Text query_title = null;
65
	public static String REPORT_OR_QUERY = "-- use query --";
55
 
66
 
56
	public SBMRepositoryQueryPage(String pageName, TaskRepository repository,
67
	public SBMRepositoryQueryPage(String pageName, TaskRepository repository,
Line 63... Line 74...
63
	@Override
74
	@Override
64
	public void applyTo(IRepositoryQuery query) {
75
	public void applyTo(IRepositoryQuery query) {
65
		if (getQueryTitle() != null) {
76
		if (getQueryTitle() != null) {
66
			query.setSummary(getQueryTitle());
77
			query.setSummary(getQueryTitle());
67
		}
78
		}
68
		query.setAttribute("sql_where", sql_where_clause.getText());
79
		query.setAttribute(SQL_QUERY, sql_where_clause.getText());
69
		query.setAttribute("name", query_title.getText());
80
		query.setAttribute(SQL_QUERY_NAME, query_title.getText());
-
 
81
		query.setAttribute(REPORT, selectedReport.getReportUUID());
70
	}
82
	}
Line 71... Line 83...
71
 
83
 
72
	@Override
84
	@Override
73
	public String getQueryTitle() {
85
	public String getQueryTitle() {
Line 78... Line 90...
78
 
90
 
79
	@Override
91
	@Override
80
	public void createControl(Composite arg0) {
92
	public void createControl(Composite arg0) {
81
		Composite control = new Composite(arg0, SWT.BORDER);
93
		Composite control = new Composite(arg0, SWT.BORDER);
-
 
94
		control.setLayout(new GridLayout(2, false));
-
 
95
 
-
 
96
		Label report_label = new Label(control, SWT.NONE);
-
 
97
		reportcombo = new Combo(control, SWT.SINGLE | SWT.BORDER);
-
 
98
		new Label(control, SWT.NONE).setText(" OR ");
-
 
99
		new Label(control, SWT.SEPARATOR | SWT.HORIZONTAL);
82
		control.setLayout(new GridLayout(2, false));
100
 
83
		Label query_label = new Label(control, SWT.NONE);
101
		Label query_label = new Label(control, SWT.NONE);
-
 
102
		query_label.setText("Query Name:");
-
 
103
 
-
 
104
		report_label.setText("Report");
-
 
105
 
-
 
106
		String solutionname = getTaskRepository().getProperty(
-
 
107
				SBMRepositorySettingsPage.STRING_SOLUTIONTABLE);
-
 
108
 
-
 
109
		try {
-
 
110
			final java.util.List<ReportInfo> reportlist = SBMRepositoryConnector
-
 
111
					.getClient(getTaskRepository()).getReportList(solutionname);
-
 
112
 
-
 
113
			reportcombo.add(REPORT_OR_QUERY);
-
 
114
			reportcombo.select(0);
-
 
115
			for (ReportInfo report : reportlist) {
-
 
116
				reportcombo.add(report.getReportName());
-
 
117
			}
-
 
118
 
-
 
119
			reportcombo.addListener(SWT.Selection, new Listener() {
-
 
120
 
-
 
121
				@Override
-
 
122
				public void handleEvent(Event arg0) {
-
 
123
					if (reportcombo.getSelectionIndex() == 0) {
-
 
124
						query_title.setEditable(true);
-
 
125
						query_title.setEnabled(true);
-
 
126
						sql_where_clause.setEditable(true);
-
 
127
						sql_where_clause.setEnabled(true);
-
 
128
						query_title.setText("");
-
 
129
					} else {
-
 
130
						query_title.setEditable(false);
-
 
131
						query_title.setEnabled(false);
-
 
132
						sql_where_clause.setEditable(false);
-
 
133
						sql_where_clause.setEnabled(false);
-
 
134
						query_title.setText(reportcombo.getText());
-
 
135
						selectedReport = reportlist.get(reportcombo
-
 
136
								.getSelectionIndex() - 1);
-
 
137
 
-
 
138
					}
-
 
139
 
-
 
140
				}
-
 
141
			});
-
 
142
 
-
 
143
		} catch (Exception e) {
-
 
144
		}
-
 
145
		/*
-
 
146
		 * 
-
 
147
		 * 
-
 
148
		 * table.addListener(SWT.Selection, new Listener() {
-
 
149
		 * 
-
 
150
		 * @Override public void handleEvent(Event arg0) { // when the table has
-
 
151
		 * been changed // try to re-read the field list tableFieldList = "";
-
 
152
		 * tableFullFieldList = ""; try { SBMField[] fields =
-
 
153
		 * SBMRepositoryConnector.getClient(
-
 
154
		 * createTaskRepository()).getFields(table.getText()) .toArray(new
-
 
155
		 * SBMField[0]); fillList(list, fields); } catch (Exception e) { } if
-
 
156
		 * (getWizard() != null) { solutionTable = table.getText();
-
 
157
		 * getWizard().getContainer().updateButtons(); } }
-
 
158
		 * 
-
 
159
		 * }); regenerateTables(); expander.setClient(control);
-
 
160
		 */
84
		query_label.setText("Query Name:");
161
 
85
		query_title = new Text(control, SWT.BORDER);
162
		query_title = new Text(control, SWT.BORDER);
86
		if (getQuery() != null)
163
		if (getQuery() != null)
Line 87... Line 164...
87
			query_title.setText(getQuery().getAttribute("name"));
164
			query_title.setText(getQuery().getAttribute("name"));
88
 
165
 
Line 89... Line 166...
89
				GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
166
		GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
90
		data.heightHint = 200;
167
		data.heightHint = 200;
91
		
168
 
-
 
169
		Label label_sql = new Label(control, SWT.NONE);
92
		Label label_sql = new Label(control, SWT.NONE);
170
		label_sql.setText("SQL where:");
93
		label_sql.setText("SQL where:");
171
		sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP
94
		sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
172
				| SWT.V_SCROLL | SWT.BORDER);
95
		GridData gd = new GridData(300, 150);
173
		GridData gd = new GridData(300, 150);
96
		gd.horizontalSpan = 2;
174
		gd.horizontalSpan = 2;
Line 97... Line 175...
97
		sql_where_clause.setLayoutData(gd);
175
		sql_where_clause.setLayoutData(gd);
98
		if (getQuery() != null)
176
		if (getQuery() != null)
99
			sql_where_clause.setText(getQuery().getAttribute("sql_where"));
177
			sql_where_clause.setText(getQuery().getAttribute("sql_where"));
100
 
178
 
101
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(
179
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
102
				query_title);
180
				.applyTo(query_title);