Subversion Repositories XServices

Rev

Rev 30 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
39 brianR 22
import java.awt.Color;
23
 
30 brianR 24
import net.brutex.mylyn.sbmconnector.core.SBMRepositoryConnector;
39 brianR 25
import net.brutex.mylyn.sbmconnector.core.model.SBMField;
26
import net.brutex.mylyn.sbmconnector.core.model.SBMSystemFields;
30 brianR 27
 
28
import org.eclipse.jface.dialogs.Dialog;
29
import org.eclipse.jface.layout.GridDataFactory;
30
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
31
import org.eclipse.mylyn.tasks.core.TaskRepository;
32
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
33
import org.eclipse.swt.SWT;
39 brianR 34
import org.eclipse.swt.events.SelectionEvent;
35
import org.eclipse.swt.events.SelectionListener;
30 brianR 36
import org.eclipse.swt.layout.GridData;
37
import org.eclipse.swt.layout.GridLayout;
38
import org.eclipse.swt.widgets.Combo;
39
import org.eclipse.swt.widgets.Composite;
39 brianR 40
import org.eclipse.swt.widgets.Display;
41
import org.eclipse.swt.widgets.Event;
30 brianR 42
import org.eclipse.swt.widgets.Label;
39 brianR 43
import org.eclipse.swt.widgets.List;
44
import org.eclipse.swt.widgets.Listener;
45
import org.eclipse.swt.widgets.Table;
46
import org.eclipse.swt.widgets.TableColumn;
47
import org.eclipse.swt.widgets.TableItem;
30 brianR 48
import org.eclipse.swt.widgets.Text;
39 brianR 49
import org.eclipse.swt.widgets.Widget;
30 brianR 50
 
51
public class SBMRepositoryQueryPage extends AbstractRepositoryQueryPage {
39 brianR 52
 
30 brianR 53
	private Text sql_where_clause = null;
54
	private Text query_title = null;
39 brianR 55
 
30 brianR 56
	public SBMRepositoryQueryPage(String pageName, TaskRepository repository,
57
			IRepositoryQuery query) {
58
		super(pageName, repository, query);
59
		setTitle("SBM Query");
60
		setDescription("Please specify table database name.");
61
	}
62
 
63
	@Override
64
	public void applyTo(IRepositoryQuery query) {
65
		if (getQueryTitle() != null) {
66
			query.setSummary(getQueryTitle());
67
		}
68
		query.setAttribute("sql_where", sql_where_clause.getText());
69
		query.setAttribute("name", query_title.getText());
70
	}
71
 
72
	@Override
73
	public String getQueryTitle() {
39 brianR 74
		if (query_title != null && !query_title.getText().isEmpty())
75
			return query_title.getText();
30 brianR 76
		return "new query";
77
	}
78
 
79
	@Override
80
	public void createControl(Composite arg0) {
39 brianR 81
		Composite control = new Composite(arg0, SWT.BORDER);
30 brianR 82
		control.setLayout(new GridLayout(2, false));
83
		Label query_label = new Label(control, SWT.NONE);
84
		query_label.setText("Query Name:");
85
		query_title = new Text(control, SWT.BORDER);
39 brianR 86
		if (getQuery() != null)
87
			query_title.setText(getQuery().getAttribute("name"));
30 brianR 88
 
39 brianR 89
				GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
90
		data.heightHint = 200;
30 brianR 91
 
39 brianR 92
		Label label_sql = new Label(control, SWT.NONE);
93
		label_sql.setText("SQL where:");
30 brianR 94
		sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
95
		GridData gd = new GridData(300, 150);
96
		gd.horizontalSpan = 2;
97
		sql_where_clause.setLayoutData(gd);
39 brianR 98
		if (getQuery() != null)
99
			sql_where_clause.setText(getQuery().getAttribute("sql_where"));
100
 
101
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(
102
				query_title);
30 brianR 103
		Dialog.applyDialogFont(control);
104
		setControl(control);
105
	}
106
}