1 package org
.argeo
.slc
.client
.ui
.dist
.views
;
3 import org
.apache
.commons
.logging
.Log
;
4 import org
.apache
.commons
.logging
.LogFactory
;
5 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
6 import org
.argeo
.slc
.jcr
.SlcNames
;
7 import org
.eclipse
.swt
.SWT
;
8 import org
.eclipse
.swt
.custom
.SashForm
;
9 import org
.eclipse
.swt
.layout
.GridData
;
10 import org
.eclipse
.swt
.layout
.GridLayout
;
11 import org
.eclipse
.swt
.widgets
.Button
;
12 import org
.eclipse
.swt
.widgets
.Composite
;
13 import org
.eclipse
.swt
.widgets
.Event
;
14 import org
.eclipse
.swt
.widgets
.Label
;
15 import org
.eclipse
.swt
.widgets
.Listener
;
16 import org
.eclipse
.swt
.widgets
.Text
;
18 /** Query SLC Repo to get some artifacts with a JCR SQL 2 request. */
19 public class QueryArtifactsText
extends AbstractQueryArtifactsView
implements
21 private static final Log log
= LogFactory
.getLog(QueryArtifactsText
.class);
22 public static final String ID
= DistPlugin
.ID
+ ".queryArtifactsText";
25 private Button executeBtn
;
26 private Text queryText
;
27 private SashForm sashForm
;
29 private Composite top
, bottom
;
32 public void createPartControl(Composite parent
) {
34 sashForm
= new SashForm(parent
, SWT
.VERTICAL
);
35 sashForm
.setSashWidth(4);
36 sashForm
.setLayout(new GridLayout(1, false));
38 top
= new Composite(sashForm
, SWT
.NONE
);
39 top
.setLayout(new GridLayout(1, false));
41 bottom
= new Composite(sashForm
, SWT
.NONE
);
42 bottom
.setLayout(new GridLayout(1, false));
44 sashForm
.setWeights(new int[] { 25, 75 });
47 createResultPart(bottom
);
50 public void createQueryForm(Composite parent
) {
54 GridLayout gl
= new GridLayout(2, false);
58 lbl
= new Label(parent
, SWT
.SINGLE
);
59 lbl
.setText("Enter a JCR:SQL2 Query");
61 executeBtn
= new Button(parent
, SWT
.PUSH
);
62 executeBtn
.setText("Search");
64 queryText
= new Text(parent
, SWT
.MULTI
| SWT
.WRAP
| SWT
.BORDER
);
65 gd
= new GridData(GridData
.FILL_HORIZONTAL
);
66 gd
.grabExcessHorizontalSpace
= true;
68 gd
.horizontalSpan
= 2;
69 queryText
.setLayoutData(gd
);
71 String query
= generateSelectStatement() + generateFromStatement()
72 + generateWhereStatement();
73 queryText
.setText(query
);
75 Listener executeListener
= new Listener() {
76 public void handleEvent(Event event
) {
80 executeBtn
.addListener(SWT
.Selection
, executeListener
);
83 public void refreshQuery() {
84 String queryStr
= queryText
.getText();
85 executeQuery(queryStr
);
90 private String
generateWhereStatement() {
91 StringBuffer sb
= new StringBuffer(" where ");
96 public void setFocus() {
97 executeBtn
.setFocus();