Subversion Repositories XServices

Rev

Rev 30 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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