Don't show not-persistent attributes in AutocompleteTextField

This commit is contained in:
Konstantin Krivopustov 2013-03-05 14:25:36 +00:00
parent 65566cb962
commit 0713c9e5b2
3 changed files with 46 additions and 31 deletions

View File

@ -1,12 +1,7 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Konstantin Krivopustov
* Created: 26.12.2008 10:10:03
*
* $Id$
*/
package com.haulmont.cuba.core.global;
@ -16,11 +11,15 @@ import com.haulmont.cuba.core.sys.jpql.transform.QueryTransformerAstBased;
import org.antlr.runtime.RecognitionException;
/**
* Factory to get {@link QueryParser} and {@link QueryTransformer} instances
* Factory to get {@link QueryParser} and {@link QueryTransformer} instances.
*
* @author krivopustov
* @version $Id$
*/
public class QueryTransformerFactory {
private static boolean useAst = ConfigProvider.getConfig(GlobalConfig.class).getUseAstBasedJpqlTransformer();
private static boolean useAst = AppBeans.get(Configuration.class)
.getConfig(GlobalConfig.class).getUseAstBasedJpqlTransformer();
private static volatile DomainModel domainModel;
@ -28,8 +27,9 @@ public class QueryTransformerFactory {
if (useAst) {
try {
if (domainModel == null) {
DomainModelBuilder builder = new DomainModelBuilder();
domainModel = builder.produce(AppBeans.get(MetadataTools.class).getAllPersistentMetaClasses());
DomainModelBuilder builder = new DomainModelBuilder(
AppBeans.get(MetadataTools.class), AppBeans.get(MessageTools.class));
domainModel = builder.produce();
}
return new QueryTransformerAstBased(domainModel, query, targetEntity);
} catch (RecognitionException e) {

View File

@ -1,28 +1,37 @@
/*
* Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.core.sys.jpql;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.chile.core.model.MetaProperty;
import com.haulmont.chile.core.model.Range;
import com.haulmont.chile.core.model.impl.MetaModelImpl;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.MessageTools;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.core.sys.jpql.model.Entity;
import com.haulmont.cuba.core.sys.jpql.model.EntityBuilder;
import java.util.Collection;
/**
* Author: Alexander Chevelev
* Date: 08.11.2010
* Time: 22:24:22
* @author Alexander Chevelev
* @version $Id$
*/
public class DomainModelBuilder {
public DomainModel produce(MetaModelImpl metaModel) {
Collection<MetaClass> classes = metaModel.getClasses();
return produce(classes);
private MetadataTools metadataTools;
private MessageTools messageTools;
public DomainModelBuilder(MetadataTools metadataTools, MessageTools messageTools) {
this.metadataTools = metadataTools;
this.messageTools = messageTools;
}
public DomainModel produce(Collection<MetaClass> classes) {
public DomainModel produce() {
Collection<MetaClass> classes = metadataTools.getAllPersistentMetaClasses();
DomainModel result = new DomainModel();
EntityBuilder builder = new EntityBuilder();
for (MetaClass aClass : classes) {
@ -30,7 +39,8 @@ public class DomainModelBuilder {
Collection<MetaProperty> props = aClass.getProperties();
for (MetaProperty prop : props) {
addProperty(builder, prop);
if (metadataTools.isPersistent(prop))
addProperty(builder, prop);
}
Entity entity = builder.produce();
@ -41,7 +51,7 @@ public class DomainModelBuilder {
private void addProperty(EntityBuilder builder, MetaProperty prop) {
String name = prop.getName();
String userFriendlyName = AppBeans.get(MessageTools.class).getPropertyCaption(prop);
String userFriendlyName = messageTools.getPropertyCaption(prop);
MetaProperty.Type type = prop.getType();
Class<?> javaType = prop.getJavaType();
Range range = prop.getRange();

View File

@ -1,8 +1,12 @@
/*
* Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.gui.autocomplete;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.MetadataProvider;
import com.haulmont.cuba.core.global.MetadataTools;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.core.sys.jpql.DomainModel;
import com.haulmont.cuba.core.sys.jpql.DomainModelBuilder;
import com.haulmont.cuba.gui.autocomplete.impl.HintProvider;
@ -14,9 +18,8 @@ import java.util.ArrayList;
import java.util.List;
/**
* Author: Alexander Chevelev
* Date: 26.11.2010
* Time: 3:44:24
* @author Alexander Chevelev
* @version $Id$
*/
public class JpqlSuggestionFactory {
@ -42,9 +45,11 @@ public class JpqlSuggestionFactory {
return new Suggestion(sender, displayedValue, value, valueSuffix, startPosition, endPosition);
}
public static List<Suggestion> requestHint(String query, int queryPosition, AutoCompleteSupport sender, int senderCursorPosition) {
DomainModelBuilder builder = new DomainModelBuilder();
DomainModel domainModel = builder.produce(AppBeans.get(MetadataTools.class).getAllPersistentMetaClasses());
public static List<Suggestion> requestHint(String query, int queryPosition, AutoCompleteSupport sender,
int senderCursorPosition) {
DomainModelBuilder builder = new DomainModelBuilder(
AppBeans.get(MetadataTools.class), AppBeans.get(MessageTools.class));
DomainModel domainModel = builder.produce();
HintProvider provider = new HintProvider(domainModel);
try {