Subversion Repositories XServices

Rev

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

Rev 30 Rev 39
Line 17... Line 17...
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;
Line -... Line 21...
-
 
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;
Line 22... Line 26...
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;
-
 
32
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
-
 
33
import org.eclipse.swt.SWT;
28
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
34
import org.eclipse.swt.events.SelectionEvent;
29
import org.eclipse.swt.SWT;
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;
-
 
38
import org.eclipse.swt.widgets.Combo;
-
 
39
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Combo;
40
import org.eclipse.swt.widgets.Display;
-
 
41
import org.eclipse.swt.widgets.Event;
-
 
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;
33
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.TableColumn;
-
 
47
import org.eclipse.swt.widgets.TableItem;
Line 34... Line 48...
34
import org.eclipse.swt.widgets.Label;
48
import org.eclipse.swt.widgets.Text;
35
import org.eclipse.swt.widgets.Text;
49
import org.eclipse.swt.widgets.Widget;
36
 
-
 
37
public class SBMRepositoryQueryPage extends AbstractRepositoryQueryPage {
50
 
38
	
51
public class SBMRepositoryQueryPage extends AbstractRepositoryQueryPage {
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) {
Line 50... Line 63...
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
	}
Line 60... Line 71...
60
 
71
 
61
	@Override
72
	@Override
62
	public String getQueryTitle() {
73
	public String getQueryTitle() {
-
 
74
		if (query_title != null && !query_title.getText().isEmpty())
63
		if(query_title!=null && !query_title.getText().isEmpty()) return query_title.getText();
75
			return query_title.getText();
64
		return "new query";
76
		return "new query";
Line 65... Line 77...
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:");
-
 
73
		query_title = new Text(control, SWT.BORDER);
-
 
74
		if(getQuery()!=null) query_title.setText(getQuery().getAttribute("name"));
-
 
75
		
84
		query_label.setText("Query Name:");
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()) {
85
		query_title = new Text(control, SWT.BORDER);
81
			table.add(table_name);
-
 
82
			if(getQuery()!=null && getQuery().getAttribute("table").equals(table_name)) {
-
 
83
				table.setText(table_name);
-
 
Line -... Line 86...
-
 
86
		if (getQuery() != null)
-
 
87
			query_title.setText(getQuery().getAttribute("name"));
Line 84... Line -...
84
			}
-
 
85
		}
-
 
-
 
88
 
-
 
89
				GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
86
 
90
		data.heightHint = 200;
87
		
91
		
88
		
92
		Label label_sql = new Label(control, SWT.NONE);
89
		
93
		label_sql.setText("SQL where:");
-
 
94
		sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
90
		sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
95
		GridData gd = new GridData(300, 150);
91
		GridData gd = new GridData(300, 150);
96
		gd.horizontalSpan = 2;
92
		gd.horizontalSpan = 2;
97
		sql_where_clause.setLayoutData(gd);
93
		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);
-
 
98
		Dialog.applyDialogFont(control);
-
 
99
		setControl(control);
-
 
100
	}
-
 
101
	
102
				query_title);