2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.client
.ui
.dist
.views
;
18 import org
.argeo
.slc
.client
.ui
.dist
.DistPlugin
;
19 import org
.argeo
.slc
.jcr
.SlcNames
;
20 import org
.eclipse
.swt
.SWT
;
21 import org
.eclipse
.swt
.custom
.SashForm
;
22 import org
.eclipse
.swt
.layout
.FillLayout
;
23 import org
.eclipse
.swt
.layout
.GridData
;
24 import org
.eclipse
.swt
.layout
.GridLayout
;
25 import org
.eclipse
.swt
.widgets
.Button
;
26 import org
.eclipse
.swt
.widgets
.Composite
;
27 import org
.eclipse
.swt
.widgets
.Event
;
28 import org
.eclipse
.swt
.widgets
.Label
;
29 import org
.eclipse
.swt
.widgets
.Listener
;
30 import org
.eclipse
.swt
.widgets
.Text
;
32 /** Query SLC Repo to get some artifacts with a JCR SQL 2 request. */
33 public class QueryArtifactsText
extends AbstractQueryArtifactsView
implements
35 // private static final Log log =
36 // LogFactory.getLog(QueryArtifactsText.class);
37 public static final String ID
= DistPlugin
.PLUGIN_ID
+ ".queryArtifactsText";
40 private Button executeBtn
;
41 private Text queryText
;
42 private SashForm sashForm
;
44 private Composite top
, bottom
;
47 public void createPartControl(Composite parent
) {
49 sashForm
= new SashForm(parent
, SWT
.VERTICAL
);
50 sashForm
.setSashWidth(4);
51 // Enable the different parts to fill the whole page when the tab is
53 sashForm
.setLayout(new FillLayout());
55 top
= new Composite(sashForm
, SWT
.NONE
);
56 top
.setLayout(new GridLayout(1, false));
58 bottom
= new Composite(sashForm
, SWT
.NONE
);
59 bottom
.setLayout(new GridLayout(1, false));
61 sashForm
.setWeights(new int[] { 25, 75 });
64 createResultPart(bottom
);
67 public void createQueryForm(Composite parent
) {
71 GridLayout gl
= new GridLayout(2, false);
75 lbl
= new Label(parent
, SWT
.SINGLE
);
76 lbl
.setText("Enter a JCR:SQL2 Query");
78 executeBtn
= new Button(parent
, SWT
.PUSH
);
79 executeBtn
.setText("Search");
81 queryText
= new Text(parent
, SWT
.MULTI
| SWT
.WRAP
| SWT
.BORDER
);
82 gd
= new GridData(GridData
.FILL_HORIZONTAL
);
83 gd
.grabExcessHorizontalSpace
= true;
85 gd
.horizontalSpan
= 2;
86 queryText
.setLayoutData(gd
);
88 String query
= generateSelectStatement() + generateFromStatement()
89 + generateWhereStatement();
90 queryText
.setText(query
);
92 Listener executeListener
= new Listener() {
93 private static final long serialVersionUID
= -5028331930076117569L;
95 public void handleEvent(Event event
) {
99 executeBtn
.addListener(SWT
.Selection
, executeListener
);
102 public void refreshQuery() {
103 String queryStr
= queryText
.getText();
104 executeQuery(queryStr
);
109 private String
generateWhereStatement() {
110 StringBuffer sb
= new StringBuffer(" where ");
111 return sb
.toString();
115 public void setFocus() {
116 executeBtn
.setFocus();