X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fui%2Fjcr%2Feditors%2FAbstractJcrQueryEditor.java;h=f41c7ca80c12460630d0500e43677ff9976a466f;hb=07b21659cba964ffdc81403718d0962c2d09175d;hp=e229a00397f57f700074e6581f4c77d77819f3aa;hpb=91332be0589725988adf921a8e0836197e105476;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/editors/AbstractJcrQueryEditor.java b/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/editors/AbstractJcrQueryEditor.java index e229a0039..f41c7ca80 100644 --- a/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/editors/AbstractJcrQueryEditor.java +++ b/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/editors/AbstractJcrQueryEditor.java @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2007-2012 Mathieu Baudier + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.argeo.eclipse.ui.jcr.editors; import java.util.ArrayList; @@ -46,13 +61,15 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { protected String initialQuery; protected String initialQueryType; - /** DEPENDENCY INJECTION */ + /* DEPENDENCY INJECTION */ private Session session; + // Widgets private TableViewer viewer; private List tableViewerColumns = new ArrayList(); private GenericTableComparator comparator; + /** Override to layout a form enabling the end user to build his query */ protected abstract void createQueryForm(Composite parent); @Override @@ -101,6 +118,9 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { protected void executeQuery(String statement) { try { + if (log.isDebugEnabled()) + log.debug("Query : " + statement); + QueryResult qr = session.getWorkspace().getQueryManager() .createQuery(statement, initialQueryType).execute(); @@ -117,10 +137,7 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { i++; } - // We must create a local list because query result can be read only - // once. - // viewer.setInput(qr); - + // Must create a local list: QueryResults can only be read once. try { List rows = new ArrayList(); RowIterator rit = qr.getRows(); @@ -136,8 +153,6 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { ErrorDialog.openError(null, "Error", "Cannot execute JCR query: " + statement, new Status(IStatus.ERROR, "org.argeo.eclipse.ui.jcr", e.getMessage())); - // throw new ArgeoException("Cannot execute JCR query " + statement, - // e); } } @@ -235,7 +250,7 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { public Object[] getElements(Object inputElement) { if (inputElement instanceof List) - return ((List) inputElement).toArray(); + return ((List) inputElement).toArray(); // Never reached might be deleted in future release if (!(inputElement instanceof QueryResult)) @@ -302,10 +317,7 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { } /** - * To be overriden to enable sorting. - * - * @author bsinou - * + * To be overridden to enable sorting. */ protected GenericTableComparator getComparator() { return null; @@ -319,7 +331,6 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { @Override public void doSave(IProgressMonitor monitor) { // TODO save the query in JCR? - } @Override @@ -331,7 +342,12 @@ public abstract class AbstractJcrQueryEditor extends EditorPart { return false; } - // IoC + /** Returns the injected current session */ + protected Session getSession() { + return session; + } + + /* DEPENDENCY INJECTION */ public void setSession(Session session) { this.session = session; }