Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 191181 Details for
Bug 337930
[feature] Validation and content assist for Named Queries in Java source
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Full JPQL query support
patch_2011.03.14 (text/plain), 267.31 KB, created by
Pascal Filion
on 2011-03-14 22:01:01 EDT
(
hide
)
Description:
Full JPQL query support
Filename:
MIME Type:
Creator:
Pascal Filion
Created:
2011-03-14 22:01:01 EDT
Size:
267.31 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jpt.common.ui >Index: src/org/eclipse/jpt/common/ui/WidgetFactory.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java,v >retrieving revision 1.1 >diff -u -r1.1 WidgetFactory.java >--- src/org/eclipse/jpt/common/ui/WidgetFactory.java 31 Jan 2011 21:41:44 -0000 1.1 >+++ src/org/eclipse/jpt/common/ui/WidgetFactory.java 15 Mar 2011 01:56:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 Oracle. All rights reserved. >+ * Copyright (c) 2008, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -10,6 +10,7 @@ > package org.eclipse.jpt.common.ui; > > import org.eclipse.swt.custom.CCombo; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; >@@ -35,8 +36,8 @@ > * adopters on the understanding that any code that uses this API will almost > * certainly be broken (repeatedly) as the API evolves. > * >- * @version 2.0 >- * @since 2.0 >+ * @version 3.0 >+ * @since 3.0 > */ > public interface WidgetFactory { > >@@ -163,6 +164,15 @@ > * > * @param parent The parent container > * @param parent The number of lines the text area should display >+ * @return A new <code>StyledText</code> >+ */ >+ StyledText createMultiLineStyledText(Composite parent); >+ >+ /** >+ * Creates a new editable text area. >+ * >+ * @param parent The parent container >+ * @param parent The number of lines the text area should display > * @return A new <code>Text</code> > */ > Text createMultiLineText(Composite parent); >Index: src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java,v >retrieving revision 1.2 >diff -u -r1.2 SWTTools.java >--- src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java 5 Feb 2011 16:41:43 -0000 1.2 >+++ src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java 15 Mar 2011 01:56:23 -0000 >@@ -10,7 +10,6 @@ > package org.eclipse.jpt.common.ui.internal.utility.swt; > > import java.util.Arrays; >- > import org.eclipse.jpt.common.utility.internal.BitTools; > import org.eclipse.jpt.common.utility.internal.StringConverter; > import org.eclipse.jpt.common.utility.internal.model.value.StaticCollectionValueModel; >@@ -21,6 +20,7 @@ > import org.eclipse.jpt.common.utility.model.value.WritableCollectionValueModel; > import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Control; >@@ -68,6 +68,14 @@ > new TextFieldModelBinding(textModel, textField); > } > >+ /** >+ * Bind the specified text model to the specified text field. >+ */ >+ public static <E> void bind(WritablePropertyValueModel<String> textModel, StyledText textField) { >+ // the new binding will add itself as a listener to the text model and the text field >+ new StyledTextFieldModelBinding(textModel, textField); >+ } >+ > > // ********** list box ********** > >Index: src/org/eclipse/jpt/common/ui/internal/utility/swt/StyledTextFieldModelBinding.java >=================================================================== >RCS file: src/org/eclipse/jpt/common/ui/internal/utility/swt/StyledTextFieldModelBinding.java >diff -N src/org/eclipse/jpt/common/ui/internal/utility/swt/StyledTextFieldModelBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/common/ui/internal/utility/swt/StyledTextFieldModelBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,196 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0, which accompanies this distribution >+ * and is available at http://www.eclipse.org/legal/epl-v10.html. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.jpt.common.ui.internal.utility.swt; >+ >+import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent; >+import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener; >+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; >+import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+ >+/** >+ * This binding can be used to keep a styled text field >+ * synchronized with a model text/string. >+ * >+ * @see WritablePropertyValueModel >+ * @see StyledText >+ */ >+@SuppressWarnings("nls") >+class StyledTextFieldModelBinding { >+ >+ /** >+ * The text model we keep synchronized with the text field. >+ */ >+ private final WritablePropertyValueModel<String> textModel; >+ >+ /** >+ * A listener that allows us to synchronize the text field's contents with >+ * the text model. >+ */ >+ private final PropertyChangeListener textModelChangeListener; >+ >+ /** >+ * The text field we keep synchronized with the text model. >+ */ >+ private final StyledText textField; >+ >+ /** >+ * A listener that allows us to synchronize our text model >+ * with the text field's contents. >+ */ >+ private final ModifyListener textFieldModifyListener; >+ >+ /** >+ * A listener that allows us to stop listening to stuff when the text field >+ * is disposed. >+ */ >+ private final DisposeListener textFieldDisposeListener; >+ >+ /** >+ * Hmm... >+ */ >+ private boolean settingTextFieldText = false; >+ >+ >+ // ********** constructor ********** >+ >+ /** >+ * Constructor - the text model and text field are required. >+ */ >+ StyledTextFieldModelBinding(WritablePropertyValueModel<String> textModel, StyledText textField) { >+ super(); >+ if ((textModel == null) || (textField == null)) { >+ throw new NullPointerException(); >+ } >+ this.textModel = textModel; >+ this.textField = textField; >+ >+ this.textModelChangeListener = this.buildTextModelChangeListener(); >+ this.textModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.textModelChangeListener); >+ >+ this.textFieldModifyListener = this.buildTextFieldModifyListener(); >+ this.textField.addModifyListener(this.textFieldModifyListener); >+ >+ this.textFieldDisposeListener = this.buildTextFieldDisposeListener(); >+ this.textField.addDisposeListener(this.textFieldDisposeListener); >+ >+ this.setTextFieldText(textModel.getValue()); >+ } >+ >+ >+ // ********** initialization ********** >+ >+ private PropertyChangeListener buildTextModelChangeListener() { >+ return new SWTPropertyChangeListenerWrapper(this.buildTextModelChangeListener_()); >+ } >+ >+ private PropertyChangeListener buildTextModelChangeListener_() { >+ return new PropertyChangeListener() { >+ public void propertyChanged(PropertyChangeEvent event) { >+ StyledTextFieldModelBinding.this.textModelChanged(event); >+ } >+ @Override >+ public String toString() { >+ return "text listener"; >+ } >+ }; >+ } >+ >+ private ModifyListener buildTextFieldModifyListener() { >+ return new ModifyListener() { >+ public void modifyText(ModifyEvent event) { >+ StyledTextFieldModelBinding.this.textFieldModified(); >+ } >+ @Override >+ public String toString() { >+ return "text field modify listener"; >+ } >+ }; >+ } >+ >+ private DisposeListener buildTextFieldDisposeListener() { >+ return new DisposeListener() { >+ public void widgetDisposed(DisposeEvent event) { >+ StyledTextFieldModelBinding.this.textFieldDisposed(); >+ } >+ @Override >+ public String toString() { >+ return "text field dispose listener"; >+ } >+ }; >+ } >+ >+ >+ // ********** text model events ********** >+ >+ /* CU private */ void textModelChanged(PropertyChangeEvent event) { >+ if ( ! this.textField.isDisposed()) { // ??? >+ this.setTextFieldText((String) event.getNewValue()); >+ } >+ } >+ >+ private void setTextFieldText(String text) { >+ // the text model can be null, but the text field cannot >+ this.setTextFieldText_((text == null) ? "" : text); >+ } >+ >+ private void setTextFieldText_(String text) { >+ if ( ! text.equals(this.textField.getText())) { // ??? >+ this.setTextFieldText__(text); >+ } >+ } >+ >+ private void setTextFieldText__(String text) { >+ this.settingTextFieldText = true; >+ try { >+ this.textField.setText(text); >+ } finally { >+ this.settingTextFieldText = false; >+ } >+ } >+ >+ >+ // ********** text field events ********** >+ >+ /* CU private */ void textFieldModified() { >+ if ( ! this.settingTextFieldText) { >+ this.setTextModelText(this.textField.getText()); >+ } >+ } >+ >+ private void setTextModelText(String text) { >+ if ( ! text.equals(this.textModel.getValue())) { // ??? >+ this.textModel.setValue(text); >+ } >+ } >+ >+ /* CU private */ void textFieldDisposed() { >+ // the text field is not yet "disposed" when we receive this event >+ // so we can still remove our listeners >+ this.textField.removeDisposeListener(this.textFieldDisposeListener); >+ this.textField.removeModifyListener(this.textFieldModifyListener); >+ this.textModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.textModelChangeListener); >+ } >+ >+ >+ // ********** standard methods ********** >+ >+ @Override >+ public String toString() { >+ return StringTools.buildToStringFor(this, this.textModel); >+ } >+ >+} >Index: src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java,v >retrieving revision 1.1 >diff -u -r1.1 DefaultWidgetFactory.java >--- src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java 31 Jan 2011 21:41:43 -0000 1.1 >+++ src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java 15 Mar 2011 01:56:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2008, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -12,6 +12,7 @@ > import org.eclipse.jpt.common.ui.WidgetFactory; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.CCombo; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Combo; >@@ -33,8 +34,8 @@ > /** > * This <code>WidgetFactory</code> simply creates plain SWT widgets. > * >- * @version 2.0 >- * @since 2.0 >+ * @version 2.3 >+ * @since 2.3 > */ > public class DefaultWidgetFactory implements WidgetFactory { > >@@ -109,7 +110,7 @@ > public Composite createComposite(Composite parent) { > return new Composite(parent, SWT.NULL); > } >- >+ > /** > * {@inheritDoc} > */ >@@ -197,6 +198,13 @@ > /** > * {@inheritDoc} > */ >+ public StyledText createMultiLineStyledText(Composite parent) { >+ return new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ > public Text createMultiLineText(Composite parent) { > return new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); > } >Index: src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java,v >retrieving revision 1.1 >diff -u -r1.1 FormWidgetFactory.java >--- src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java 31 Jan 2011 21:41:43 -0000 1.1 >+++ src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java 15 Mar 2011 01:56:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2008, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -13,6 +13,7 @@ > import org.eclipse.jpt.common.ui.WidgetFactory; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.CCombo; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >@@ -39,8 +40,8 @@ > * > * @see FormToolkit > * >- * @version 2.0 >- * @since 2.0 >+ * @version 2.3 >+ * @since 2.3 > */ > @SuppressWarnings("nls") > public class FormWidgetFactory implements WidgetFactory { >@@ -254,6 +255,13 @@ > /** > * {@inheritDoc} > */ >+ public StyledText createMultiLineStyledText(Composite parent) { >+ return createStyledText(parent, SWT.MULTI | SWT.V_SCROLL); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ > public Text createMultiLineText(Composite parent) { > return createText(parent, SWT.MULTI | SWT.V_SCROLL); > } >@@ -315,6 +323,12 @@ > return createText(parent, SWT.NONE); > } > >+ protected StyledText createStyledText(Composite parent, int style) { >+ StyledText text = new StyledText(parent, SWT.BORDER | SWT.FLAT | style); >+ widgetFactory.adapt(text, true, false); >+ return text; >+ } >+ > protected Text createText(Composite parent, int style) { > return widgetFactory.createText(parent, null, SWT.BORDER | SWT.FLAT | style); > } >Index: src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java,v >retrieving revision 1.2 >diff -u -r1.2 Pane.java >--- src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java 5 Feb 2011 16:41:43 -0000 1.2 >+++ src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java 15 Mar 2011 01:56:26 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2008, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -41,6 +41,7 @@ > import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; > import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.events.ModifyListener; > import org.eclipse.swt.events.MouseAdapter; > import org.eclipse.swt.events.MouseEvent; >@@ -87,8 +88,8 @@ > * @see FormPane > * @see DialogPane > * >- * @version 2.0 >- * @since 2.0 >+ * @version 2.3 >+ * @since 2.3 > */ > @SuppressWarnings("nls") > public abstract class Pane<T extends Model> >@@ -1687,7 +1688,7 @@ > * @param stringConverter The converter responsible to transform each item > * into a string representation > * @param helpId The topic help ID to be registered for the given center >- * compositer >+ * composite > * @return The newly created <code>Combo</code> > * > * @category Layout >@@ -1711,6 +1712,30 @@ > } > > /** >+ * Adjusts the layout of the given container so that the text control has the correct amount of >+ * lines by default. >+ */ >+ private void adjustMultiLineTextLayout(Composite container, >+ int lineCount, >+ Control text, >+ int lineHeight) { >+ >+ int textHeight = text.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ >+ // Specify the number of lines the text area should display >+ GridData gridData = (GridData) text.getLayoutData(); >+ gridData.heightHint = lineHeight * lineCount; >+ >+ // Move the label to the top of its cell >+ Control label = container.getChildren()[0]; >+ int labelHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ >+ gridData = (GridData) label.getLayoutData(); >+ gridData.verticalAlignment = SWT.TOP; >+ gridData.verticalIndent += (Math.abs(textHeight - labelHeight) / 2); >+ } >+ >+ /** > * Creates a new container that will have a text field as the center control > * labeled with the given label. > * >@@ -1724,10 +1749,10 @@ > * @category Layout > */ > protected final Text addLabeledMultiLineText(Composite container, >- String labelText, >- WritablePropertyValueModel<String> textHolder, >- int lineCount, >- String helpId) { >+ String labelText, >+ WritablePropertyValueModel<String> textHolder, >+ int lineCount, >+ String helpId) { > > Text text = this.addMultiLineText(container, textHolder, lineCount); > >@@ -1738,19 +1763,40 @@ > helpId > ); > >- int textHeight = text.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ adjustMultiLineTextLayout(container, lineCount, text, text.getLineHeight()); > >- // Specify the number of lines the text area should display >- GridData gridData = (GridData) text.getLayoutData(); >- gridData.heightHint = text.getLineHeight() * lineCount; >+ return text; >+ } > >- // Move the label to the top of its cell >- Control label = container.getChildren()[0]; >- int labelHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; >+ /** >+ * Creates a new container that will have a text field as the center control >+ * labeled with the given label. >+ * >+ * @param container The parent container >+ * @param labelText The text area's label >+ * @param textHolder The holder of the text field's input >+ * @param lineCount The number of lines the text area should display >+ * @param helpId The topic help ID to be registered for the text field >+ * @return The newly created <code>StyledText</code> >+ * >+ * @category Layout >+ */ >+ protected final StyledText addLabeledMultiLineStyledText(Composite container, >+ String labelText, >+ WritablePropertyValueModel<String> textHolder, >+ int lineCount, >+ String helpId) { > >- gridData = (GridData) label.getLayoutData(); >- gridData.verticalAlignment = SWT.TOP; >- gridData.verticalIndent += (Math.abs(textHeight - labelHeight) / 2); >+ StyledText text = this.addMultiLineStyledText(container, textHolder, lineCount); >+ >+ container = this.addLabeledComposite( >+ container, >+ labelText, >+ text, >+ helpId >+ ); >+ >+ adjustMultiLineTextLayout(container, lineCount, text, text.getLineHeight()); > > return text; > } >@@ -2268,16 +2314,14 @@ > } > > /** >- * Creates a new lable expanding on multiple lines. >+ * Creates a new label expanding on multiple lines. > * > * @param parent The parent container > * @param labelText The label's text > * > * @category Layout > */ >- protected final FormText addMultiLineLabel(Composite container, >- String labelText) { >- >+ protected final FormText addMultiLineLabel(Composite container, String labelText) { > FormText label = this.widgetFactory.createMultiLineLabel(container, labelText); > manageWidget(label); > return label; >@@ -2300,6 +2344,21 @@ > } > > /** >+ * Creates a new <code>StyledText</code> widget that has multiple lines. >+ * >+ * @param container The parent container >+ * @return The newly created <code>StyledText</code> widget >+ */ >+ protected final StyledText addMultiLineStyledText(Composite container) { >+ >+ StyledText text = this.widgetFactory.createMultiLineStyledText(container); >+ text.setLayoutData(getFieldGridData()); >+ this.manageWidget(text); >+ >+ return text; >+ } >+ >+ /** > * Creates a new <code>Text</code> widget that has multiple lines. > * > * @param container The parent container >@@ -2327,6 +2386,33 @@ > } > > /** >+ * Creates a new <code>StyledText</code> widget that has multiple lines. >+ * >+ * @param container The parent container >+ * @param lineCount The number of lines the text area should display >+ * @param helpId The topic help ID to be registered for the new text >+ * @return The newly created <code>StyledText</code> widget >+ * >+ * @category Layout >+ */ >+ protected final StyledText addMultiLineStyledText(Composite container, >+ int lineCount, >+ String helpId) { >+ >+ StyledText text = this.addMultiLineStyledText(container); >+ >+ GridData gridData = getFieldGridData(); >+ gridData.heightHint = text.getLineHeight() * lineCount; >+ text.setLayoutData(gridData); >+ >+ if (helpId != null) { >+ getHelpSystem().setHelp(text, helpId); >+ } >+ >+ return text; >+ } >+ >+ /** > * Creates a new <code>Text</code> widget that has multiple lines. > * > * @param container The parent container >@@ -2337,13 +2423,30 @@ > * @category Layout > */ > protected final Text addMultiLineText(Composite container, >- WritablePropertyValueModel<String> textHolder, >- int lineCount) { >+ WritablePropertyValueModel<String> textHolder, >+ int lineCount) { > > return this.addMultiLineText(container, textHolder, lineCount, null); > } > > /** >+ * Creates a new <code>StyledText</code> widget that has multiple lines. >+ * >+ * @param container The parent container >+ * @param textHolder The holder of the text field's input >+ * @param lineCount The number of lines the text area should display >+ * @return The newly created <code>StyledText</code> widget >+ * >+ * @category Layout >+ */ >+ protected final StyledText addMultiLineStyledText(Composite container, >+ WritablePropertyValueModel<String> textHolder, >+ int lineCount) { >+ >+ return this.addMultiLineStyledText(container, textHolder, lineCount, null); >+ } >+ >+ /** > * Creates a new <code>Text</code> widget that has multiple lines. > * > * @param container The parent container >@@ -2354,9 +2457,9 @@ > * @category Layout > */ > protected final Text addMultiLineText(Composite container, >- WritablePropertyValueModel<String> textHolder, >- int lineCount, >- String helpId) { >+ WritablePropertyValueModel<String> textHolder, >+ int lineCount, >+ String helpId) { > > Text text = this.addMultiLineText(container, lineCount, helpId); > SWTTools.bind(textHolder, text); >@@ -2364,6 +2467,26 @@ > } > > /** >+ * Creates a new <code>StyledText</code> widget that has multiple lines. >+ * >+ * @param container The parent container >+ * @param textHolder The holder of the text field's input >+ * @param helpId The topic help ID to be registered for the new text >+ * @return The newly created <code>StyledText</code> widget >+ * >+ * @category Layout >+ */ >+ protected final StyledText addMultiLineStyledText(Composite container, >+ WritablePropertyValueModel<String> textHolder, >+ int lineCount, >+ String helpId) { >+ >+ StyledText text = this.addMultiLineStyledText(container, lineCount, helpId); >+ SWTTools.bind(textHolder, text); >+ return text; >+ } >+ >+ /** > * Creates a new <code>PageBook</code> and set the proper layout and layout > * data. > * >#P org.eclipse.jpt.jpa.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF,v >retrieving revision 1.2 >diff -u -r1.2 MANIFEST.MF >--- META-INF/MANIFEST.MF 7 Feb 2011 16:41:27 -0000 1.2 >+++ META-INF/MANIFEST.MF 15 Mar 2011 01:56:27 -0000 >@@ -25,6 +25,7 @@ > org.eclipse.jst.common.project.facet.core;bundle-version="[1.3.100,2.0.0)", > org.eclipse.jst.j2ee;bundle-version="[1.1.200,2.0.0)", > org.eclipse.jst.j2ee.core;bundle-version="[1.1.200,2.0.0)", >+ org.eclipse.persistence.jpa.jpql;bundle-version="1.0.0", > org.eclipse.wst.common.emf;bundle-version="[1.1.200,2.0.0)", > org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.200,2.0.0)", > org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)", >@@ -62,6 +63,7 @@ > org.eclipse.jpt.jpa.core.internal.jpa2.resource.java;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.binary;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.source;x-internal:=true, >+ org.eclipse.jpt.jpa.core.internal.jpql;x-friends:="org.eclipse.jpt.jpa.ui", > org.eclipse.jpt.jpa.core.internal.libprov;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.libval;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.operations;x-internal:=true, >Index: property_files/jpa_jpql_validation.properties >=================================================================== >RCS file: property_files/jpa_jpql_validation.properties >diff -N property_files/jpa_jpql_validation.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ property_files/jpa_jpql_validation.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,481 @@ >+################################################################################ >+# Copyright (c) 2011 Oracle. All rights reserved. >+# This program and the accompanying materials are made available under the >+# terms of the Eclipse Public License v1.0, which accompanies this distribution >+# and is available at http:#www.eclipse.org/legal/epl-v10.html. >+# >+# Contributors: >+# Oracle - initial API and implementation >+################################################################################ >+ >+# AbsExpression - Grammar >+ABS_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+ABS_EXPRESSION_MISSING_EXPRESSION = The encapsulated expression must be provided for an ABS expression. >+ABS_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the ABS expression. >+ABS_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the ABS expression. >+# AbsExpression - Semantic >+ABS_EXPRESSION_INVALID_NUMERIC_EXPRESSION = The encapsulated expression is not a valid numeric expression. >+ >+# AbstractFromClause - Grammar >+ABSTRACT_FROM_CLAUSE_IDENTIFICATION_VARIABLE_DECLARATION_ENDS_WITH_COMMA = The FROM clause cannot end with a comma. >+ABSTRACT_FROM_CLAUSE_IDENTIFICATION_VARIABLE_DECLARATION_IS_MISSING_COMMA = The FROM clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ABSTRACT_FROM_CLAUSE_MISSING_IDENTIFICATION_VARIABLE_DECLARATION = The FROM clause must defined at least one identification variable declaration. >+ABSTRACT_FROM_CLAUSE_WRONG_ORDER_OF_IDENTIFICATION_VARIABLE_DECLARATION = The identification variable ''{0}'' is declared after its usage. Identification variables are evaluated from left to right. >+ >+# AbstractPathExpression - Grammar >+ABSTRACT_PATH_EXPRESSION_CANNOT_END_WITH_COMMA = A path expression cannot end with a comma. >+ABSTRACT_PATH_EXPRESSION_MISSING_IDENTIFICATION_VARIABLE = A path expression must start with an identification variable. >+ >+# AbstractSchemaName - Grammar >+ABSTRACT_SCHEMA_NAME_INVALID = The abstract schema type ''{0}'' is unknown. >+ABSTRACT_SCHEMA_NAME_NOT_RESOLVABLE = ''{0}'' cannot be resolved to a type. >+# AbstractSchemaName - Semantic >+PATH_EXPRESSION_NOT_RELATIONSHIP_MAPPING = The derived path ''{0}'' does not represent an association field. >+ >+# AbstractSelectClause - Grammar >+ABSTRACT_SELECT_CLAUSE_SELECT_EXPRESSION_ENDS_WITH_COMMA = The select expression cannot end with a comma. >+ABSTRACT_SELECT_CLAUSE_SELECT_EXPRESSION_IS_MISSING_COMMA = The SELECT clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ABSTRACT_SELECT_CLAUSE_SELECT_EXPRESSION_MALFORMED = The select expression is malformed. >+ABSTRACT_SELECT_CLAUSE_SELECT_MISSING_EXPRESSION = The select expression is missing from the SELECT clause. >+ >+# AbstractSelectStatement - Grammar >+ABSTRACT_SELECT_STATEMENT_FROM_CLAUSE_MSSING = A select statement must have a FROM clause. >+ >+# AdditionExpression - Semantic >+ADDITION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the addition is not a valid arithmetic expression. >+ADDITION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the addition is not a valid arithmetic expression. >+ >+# AllOrAnyExpression - Grammar >+ALL_OR_ANY_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+ALL_OR_ANY_EXPRESSION_MISSING_EXPRESSION = The subquery must be provided for an {0} expression. >+ALL_OR_ANY_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the {0} expression. >+ALL_OR_ANY_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the {0} expression. >+ALL_OR_ANY_EXPRESSION_NOT_PART_OF_COMPARISON_EXPRESSION = The {0} expression must be part of a comparison expression. >+ >+# ArithmeticFactor - Grammar >+ARITHMETIC_FACTOR_MISSING_EXPRESSION = An arithmetic factor must be followed by an expression. >+# ArithmeticFactor - Semantic >+ARITHMETIC_FACTOR_INVALID_EXPRESSION = The expression must be an arithmetic expression. >+ >+# ArithmeticExpression - Grammar >+ARITHMETIC_EXPRESSION_INVALID_LEFT_EXPRESSION = The left expression is not an arithmetic expression. >+ARITHMETIC_EXPRESSION_INVALID_RIGHT_EXPRESSION = The right expression is not an arithmetic expression. >+ARITHMETIC_EXPRESSION_MISSING_LEFT_EXPRESSION = The left expression is missing from the arithmetic expression. >+ARITHMETIC_EXPRESSION_MISSING_RIGHT_EXPRESSION = The right expression is missing from the arithmetic expression. >+ >+# AvgFunction - Grammar >+AVG_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+AVG_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the AVG expression. >+AVG_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for an AVG expression. >+AVG_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the AVG expression. >+# AvgFunction - Semantic >+AVG_FUNCTION_INVALID_NUMERIC_EXPRESSION = The encapsulated expression is not a valid numeric expression. >+ >+# BetweenExpression - Grammar >+BETWEEN_EXPRESSION_MISSING_EXPRESSION = The result expression is missing from the BETWEEN expression. >+BETWEEN_EXPRESSION_MISSING_LOWER_BOUND_EXPRESSION = The lower bound expression is missing from the BETWEEN expression. >+BETWEEN_EXPRESSION_MISSING_AND = The identifier AND is missing from the BETWEEN expression. >+BETWEEN_EXPRESSION_MISSING_UPPER_BOUND_EXPRESSION = The upper bound expression is missing from the BETWEEN expression. >+# BetweenExpression - Semantic >+BETWEEN_EXPRESSION_WRONG_TYPE = The expression's type and the lower and upper bound expressions' type have to be the same type. >+ >+# CaseExpression - Grammar >+CASE_EXPRESSION_MISSING_ELSE_EXPRESSION = A CASE expression must have an ELSE expression. >+CASE_EXPRESSION_MISSING_ELSE_IDENTIFIER = The identifier ELSE is missing from the CASE expression. >+CASE_EXPRESSION_MISSING_END_IDENTIFIER = The identifier END is missing from the CASE expression. >+CASE_EXPRESSION_MISSING_WHEN_CLAUSE = A CASE expression must define at least one WHEN clause. >+CASE_EXPRESSION_WHEN_CLAUSES_END_WITH_COMMA = The WHEN clauses cannot end with a comma. >+CASE_EXPRESSION_WHEN_CLAUSES_HAS_COMMA = Two WHEN clauses cannot be separated by a comma. >+ >+# CoalesceExpression - Grammar >+COALESCE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+COALESCE_EXPRESSION_MISSING_EXPRESSION = The encapsulated expressions must be provided for a COALESCE expression. >+COALESCE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the COALESCE expression. >+COALESCE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the COALESCE expression. >+ >+# CollectionMemberExpression - Grammar >+COLLECTION_MEMBER_EXPRESSION_MISSING_ENTITY_EXPRESSION = A collection member expression must define an entity expression. >+COLLECTION_MEMBER_EXPRESSION_MISSING_COLLECTION_VALUED_PATH_EXPRESSION = A collection member expression must define a collection valued path expression. >+# CollectionMemberExpression - Semantic >+COLLECTION_MEMBER_EXPRESSION_EMBEDDABLE = An embeddable type is not supported. >+ >+# CollectionMemberDeclaration - Grammar >+COLLECTION_MEMBER_DECLARATION_MISSING_COLLECTION_VALUED_PATH_EXPRESSION = The collection-valued path expression is missing from the collection member declaration. >+COLLECTION_MEMBER_DECLARATION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the collection member declaration. >+COLLECTION_MEMBER_DECLARATION_MISSING_IDENTIFICATION_VARIABLE = An identification variable must be specified for a collection member declaration. >+COLLECTION_MEMBER_DECLARATION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the collection member declaration. >+ >+# CollectionValuedPathExpression - Semantic >+COLLECTION_VALUED_PATH_EXPRESSION_NOT_RESOLVABLE" , "The collection-valued path ''{0}'' cannot be resolved to a valid association field. >+COLLECTION_VALUED_PATH_EXPRESSION_NOT_COLLECTION_TYPE = The collection-valued path ''{0}'' must resolve to an association field. >+ >+# ComparisonExpression - Grammar >+COMPARISON_EXPRESSION_MISSING_LEFT_EXPRESSION = A comparison expression must define the left side of the comparison. >+COMPARISON_EXPRESSION_MISSING_RIGHT_EXPRESSION = A comparison expression must define the right side of the comparison. >+# ComparisonExpression - Semantic >+COMPARISON_EXPRESSION_WRONG_COMPARISON_TYPE = The left and right expressions' type must be of the same type. >+ >+# ConcatExpression - Grammar >+CONCAT_EXPRESSION_INVALID_EXPRESSION = The expression ''{0}'' is not valid expression. >+CONCAT_EXPRESSION_MISSING_EXPRESSION = The encapsulated expression is missing from the CONCAT expression. >+CONCAT_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the CONCAT expression. >+CONCAT_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the CONCAT expression. >+# ConcatExpression - Semantic >+CONCAT_EXPRESSION_EXPRESSION_WRONG_TYPE = The expression ''{0}'' is not a String. >+ >+# ConstructorExpression - Grammar >+CONSTRUCTOR_EXPRESSION_CONSTRUCTOR_ITEM_ENDS_WITH_COMMA = The constructor items cannot end with a comma. >+CONSTRUCTOR_EXPRESSION_CONSTRUCTOR_ITEM_IS_MISSING_COMMA = The constructor expression has two constructor items (''{0}'' and ''{1}'') that are not separated by a comma. >+CONSTRUCTOR_EXPRESSION_MISSING_CONSTRUCTOR_ITEM = A constructor expression must define at least one constructor item. >+CONSTRUCTOR_EXPRESSION_MISSING_CONSTRUCTOR_NAME = The fully qualified class name must be specified. >+CONSTRUCTOR_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the constructor expression. >+CONSTRUCTOR_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the constructor expression. >+# ConstructorExpression - Semantic >+CONSTRUCTOR_EXPRESSION_MISMATCHED_PARAMETER_TYPES = No constructors can be found that match the argument types. >+CONSTRUCTOR_EXPRESSION_UNKNOWN_TYPE = ''{0}'' cannot be resolved to a type. >+ >+# CountFunction - Grammar >+COUNT_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+COUNT_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a COUNT expression. >+COUNT_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the COUNT expression. >+COUNT_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the COUNT expression. >+# CountFunction - Semantic >+COUNT_FUNCTION_DISTINCT_EMBEDDABLE = The use of DISTINCT is not supported for arguments of embeddable types. >+ >+# DateTime - Grammar >+DATE_TIME_JDBC_ESCAPE_FORMAT_INVALID_SPECIFICATION = The JDBC escape format does not start with either 'd', 't' or 'ts'. >+DATE_TIME_JDBC_ESCAPE_FORMAT_MISSING_CLOSE_QUOTE = The JDBC escape format is missing the close quote. >+DATE_TIME_JDBC_ESCAPE_FORMAT_MISSING_OPEN_QUOTE = The JDBC escape format is missing the open quote. >+DATE_TIME_JDBC_ESCAPE_FORMAT_MISSING_RIGHT_CURLY_BRACE = The JDBC escape format is missing the right curly brace. >+ >+# DeleteClause - Grammar >+DELETE_CLAUSE_FROM_MISSING = The identifier FROM is missing from the DELETE FROM clause. >+DELETE_CLAUSE_MULTIPLE_RANGE_VARIABLE_DECLARATION = Only one entity abstract schema type can be defined. >+DELETE_CLAUSE_RANGE_VARIABLE_DECLARATION_MALFORMED = The entity abstract schema type declaration is malformed. >+DELETE_CLAUSE_RANGE_VARIABLE_DECLARATION_MISSING = A DELETE clause must define an entity abstract schema type. >+ >+# DivisionExpression - Semantic >+DIVISION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the division is not a valid arithmetic expression. >+DIVISION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the division is not a valid arithmetic expression. >+ >+# EclipseLinkQueryBuilder - Validation >+ECLIPSE_LINK_QUERY_BUILDER_GRAMMAR_VALIDATOR_ERROR_MESSAGE = Syntax error parsing the query [{0}]. {1} >+ECLIPSE_LINK_QUERY_BUILDER_SEMANTIC_VALIDATOR_ERROR_MESSAGE = Problem compiling the query [{0}]. {1} >+ >+# EncapsulatedIdentificationVariableExpression - Semantic >+ENCAPSULATED_IDENTIFICATION_VARIABLE_EXPRESSION_NOT_MAP_VALUED = The {0} operator may only be applied to identification variables that correspond to map-valued associations or map-valued element collections. >+ >+# EmptyCollectionComparisonExpression - Grammar >+EMPTY_COLLECTION_COMPARISON_EXPRESSION_MISSING_EXPRESSION = The collection valued path expression must be defined. >+ >+# EntityTypeLiteral - Semantic >+ENTITY_TYPE_LITERAL_NOT_RESOLVABLE = ''{0}'' cannot be resolved to a type. >+ >+# EntryExpression - Grammar >+ENTRY_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+ENTRY_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for an ENTRY expression. >+ENTRY_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the ENTRY expression. >+ENTRY_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the ENTRY expression. >+ >+# ExistsExpression - Grammar >+EXISTS_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+EXISTS_EXPRESSION_MISSING_EXPRESSION = A subquery must be provided for an EXISTS expression. >+EXISTS_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the EXISTS expression. >+EXISTS_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the EXISTS expression. >+ >+# FuncExpression - Grammar >+FUNC_EXPRESSION_MISSING_FUNCTION_NAME = The SQL function name must be specified. >+FUNC_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the FUNC expression. >+FUNC_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the FUNC expression. >+ >+# GroupByClause - Grammar >+GROUP_BY_CLAUSE_GROUP_BY_ITEM_ENDS_WITH_COMMA = The select expression cannot end with a comma. >+GROUP_BY_CLAUSE_GROUP_BY_ITEM_IS_MISSING_COMMA = The GROUP BY clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+GROUP_BY_CLAUSE_GROUP_BY_ITEM_MISSING = The grouping item is missing from the GROUP BY clause. >+ >+# HavingClause - Grammar >+HAVING_CLAUSE_INVALID_CONDITIONAL_EXPRESSION = The expression is not a valid conditional expression. >+HAVING_CLAUSE_MISSING_CONDITIONAL_EXPRESSION = The conditional expression is missing from the HAVING clause. >+ >+# IdentificationVariable - Grammar >+IDENTIFICATION_VARIABLE_INVALID_DUPLICATE = The identification variable ''{0}'' cannot be declared more than once. >+IDENTIFICATION_VARIABLE_INVALID_JAVA_IDENTIFIER = The identification variable ''{0}'' is not following the rules for a Java identifier. >+IDENTIFICATION_VARIABLE_INVALID_RESERVED_WORD = The identification variable ''{0}'' cannot be a reserved word. >+# IdentificationVariable - Semantic >+IDENTIFICATION_VARIABLE_ENTITY_NAME = An identification variable must not have the same name as any entity in the same persistence unit. >+IDENTIFICATION_VARIABLE_INVALID_NOT_DECLARED = The identification variable ''{0}'' is not defined in the FROM clause. >+ >+# IdentificationVariableDeclaration - Grammar >+IDENTIFICATION_VARIABLE_DECLARATION_MISSING_RANGE_VARIABLE_DECLARATION = The range variable declaration must be specified. >+ >+# IndexExpression - Grammar >+INDEX_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+INDEX_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for an INDEX expression. >+INDEX_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the INDEX expression. >+INDEX_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the INDEX expression. >+# IndexExpression - Semantic >+INDEX_EXPRESSION_WRONG_VARIABLE = The identification variable ''{0}'' does not represent an association or element collection. >+ >+# InExpression - Grammar >+IN_EXPRESSION_IN_ITEM_ENDS_WITH_COMMA = The items cannot end with a comma. >+IN_EXPRESSION_IN_ITEM_IS_MISSING_COMMA = The IN expression has ''{0}'' and ''{1}'' that are not separated by a comma. >+IN_EXPRESSION_MALFORMED_EXPRESSION = The IN expression does not have a valid state field path expression or TYPE expession. >+IN_EXPRESSION_MISSING_IN_ITEMS = A least one item must be defined for the IN expression. >+IN_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the IN expression. >+IN_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the IN expression. >+IN_EXPRESSION_MISSING_EXPRESSION = A state field path expression or TYPE expression must be defined. >+ >+# InputParameter - Grammar >+INPUT_PARAMETER_JAVA_IDENTIFIER = The named input parameter ''{0}'' is not following the rules for a Java identifier. >+INPUT_PARAMETER_MISSING_PARAMETER = The parameter value is missing from the input parameter. >+INPUT_PARAMETER_MIXTURE = Named and positional input parameters must not be mixed in a single query. >+INPUT_PARAMETER_NOT_INTEGER = The positional input parameter ''{0}'' cannot use non-Integer characters. >+INPUT_PARAMETER_SMALLER_THAN_ONE = The number used for the positional input parameter ''{0}'' must be greater than 0. >+INPUT_PARAMETER_WRONG_CLAUSE_DECLARATION = Input parameters can only be used in the WHERE clause or HAVING clause of a query. >+ >+# Join - Grammar >+JOIN_MISSING_IDENTIFICATION_VARIABLE = An identification variable must be defined for a JOIN expression. >+JOIN_MISSING_JOIN_ASSOCIATION_PATH = The join association path is missing from the JOIN expression. >+ >+# JoinFetch - Grammar >+JOIN_FETCH_MISSING_JOIN_ASSOCIATION_PATH = The join association path is missing from the JOIN FETCH expression. >+JOIN_FETCH_WRONG_CLAUSE_DECLARATION = JOIN FETCH expressions cannot be used in a FROM clause of a subquery. >+ >+# JPQLExpression - Grammar >+JPQL_EXPRESSION_INVALID_QUERY = The query does not start with a valid identifier, has to be either SELECT, UPDATE or DELETE FROM. >+JPQL_EXPRESSION_UNKNOWN_ENDING = The query contains a malformed ending. >+ >+# KeyExpression - Grammar >+KEY_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+KEY_EXPRESSION_MISSING_EXPRESSION = The identification variable must be provided for an ABS expression. >+KEY_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the ABS expression. >+KEY_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the ABS expression. >+ >+# LengthExpression - Grammar >+LENGTH_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+LENGTH_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a LENGTH expression. >+LENGTH_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the LENGTH expression. >+LENGTH_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the LENGTH expression. >+# LikeExpression - Semantic >+LENGTH_EXPRESSION_WRONG_TYPE = The encapsulated expression is not of string type. >+ >+# LikeExpression - Grammar >+LIKE_EXPRESSION_INVALID_ESCAPE_CHARACTER = {0} is not a valid escape character. >+LIKE_EXPRESSION_MISSING_ESCAPE_CHARACTER = The escape character is missing from the LIKE expression. >+LIKE_EXPRESSION_MISSING_PATTERN_VALUE = The pattern value is missing from the LIKE expression. >+LIKE_EXPRESSION_MISSING_STRING_EXPRESSION = The string expression is missing from the LIKE expression. >+ >+# LocateExpression - Grammar >+LOCATE_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+LOCATE_EXPRESSION_INVALID_SECOND_EXPRESSION = The second argument is not a valid expression. >+LOCATE_EXPRESSION_INVALID_THIRD_EXPRESSION = The third argument is not a valid expression. >+LOCATE_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_FIRST_COMMA = The first comma is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_SECOND_COMMA = The second comma is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_THIRD_EXPRESSION = The third argument is missing from the LOCATE expression. >+# LocateExpression - Semantic >+LOCATE_EXPRESSION_FIRST_EXPRESSION_WRONG_TYPE = The first expression is not of string type. >+LOCATE_EXPRESSION_SECOND_EXPRESSION_WRONG_TYPE = The second expression is not of string type. >+LOCATE_EXPRESSION_THIRD_EXPRESSION_WRONG_TYPE = The third encapsulated expression is not of numeric type. >+ >+# LogicalExpression - Grammar >+LOGICAL_EXPRESSION_INVALID_LEFT_EXPRESSION = The left expression is missing from the logical expression. >+LOGICAL_EXPRESSION_INVALID_RIGHT_EXPRESSION = The right expression is missing from the logical expression. >+LOGICAL_EXPRESSION_MISSING_LEFT_EXPRESSION = The left expression is not a valid expression. >+LOGICAL_EXPRESSION_MISSING_RIGHT_EXPRESSION = The right expression is not a valid expression. >+ >+# LowerExpression - Grammar >+LOWER_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+LOWER_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a LOWER expression. >+LOWER_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the LOWER expression. >+LOWER_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the LOWER expression. >+# UpperExpression - Semantic >+LOWER_EXPRESSION_WRONG_TYPE = The expression is not a String. >+ >+# MaxFunction - Grammar >+MAX_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+MAX_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a MAX expression. >+MAX_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the MAX expression. >+MAX_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the MAX expression. >+ >+# MinFunction - Grammar >+MIN_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+MIN_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a MIN expression. >+MIN_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the MIN expression. >+MIN_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the MIN expression. >+ >+# ModExpression - Grammar >+MOD_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+MOD_EXPRESSION_INVALID_SECOND_PARENTHESIS = The second argument is not a valid expression. >+MOD_EXPRESSION_MISSING_COMMA = The comma is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the MOD expression. >+# ModExpression - Semantic >+MOD_EXPRESSION_FIRST_EXPRESSION_WRONG_TYPE = The first expression is not an Integer. >+MOD_EXPRESSION_SECOND_EXPRESSION_WRONG_TYPE = The second expression is not an Integer. >+ >+# MultiplicationExpression - Semantic >+MULTIPLICATION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the multiplication is not a valid arithmetic expression. >+MULTIPLICATION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the multiplication is not a valid arithmetic expression. >+ >+# NotExpression - Grammar >+NOT_EXPRESSION_MISSING_EXPRESSION = The expression is missing after the identifier NOT. >+# NotExpression - Semantic >+NOT_EXPRESSION_WRONG_TYPE = The expression is not of boolean type. >+ >+# NullComparisonExpression - Grammar >+NULL_COMPARISON_EXPRESSION_MISSING_EXPRESSION = The expression is missing from the null comparison expression. >+# NullComparisonExpression - Semantic >+NULL_COMPARISON_EXPRESSION_INVALID_COLLECTION_EXPRESSION = ''{0}'' cannot be resolved to a collection type. >+ >+# NullIfExpression - Grammar >+NULL_IF_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+NULL_IF_EXPRESSION_INVALID_SECOND_EXPRESSION = The second argument is not a valid expression. >+NULL_IF_EXPRESSION_MISSING_COMMA = The comma is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the NULLIF expression. >+ >+# NumericLiteral - Grammar >+NUMERIC_LITERAL_INVALID = ''{0}'' is not a valid numeric value. >+ >+# ObjectByItem - Grammar >+ORDER_BY_ITEM_INVALID_PATH = ''{0}'' is not a valid state field path expression. >+ORDER_BY_ITEM_MISSING_STATE_FIELD_PATH_EXPRESSION = A state field path expression must be specified. >+ >+# ObjectExpression - Grammar >+OBJECT_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+OBJECT_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for an OBJECT expression. >+OBJECT_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the OBJECT expression. >+OBJECT_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the OBJECT expression. >+ >+# OrderByClause - Grammar >+ORDER_BY_CLAUSE_ORDER_BY_ITEM_ENDS_WITH_COMMA = The select expression cannot end with a comma. >+ORDER_BY_CLAUSE_ORDER_BY_ITEM_IS_MISSING_COMMA = The ORDER BY clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ORDER_BY_CLAUSE_ORDER_BY_ITEM_MISSING = The ordering item is missing from the ORDER BY clause. >+ >+# RangeVariableDeclaration - Grammar >+RANGE_VARIABLE_DECLARATION_MISSING_ABSTRACT_SCHEMA_NAME = An abstract schema name must be specified. >+RANGE_VARIABLE_DECLARATION_MISSING_IDENTIFICATION_VARIABLE = An identification variable must be provider for a range variable declaration. >+ >+# ResultVariable - Grammar >+RESULT_VARIABLE_MISSING_SELECT_EXPRESSION = The select item is missing from the result variable declaration. >+RESULT_VARIABLE_MISSING_RESULT_VARIABLE = The result variable is missing from the select item declaration. >+ >+# SelectStatement - Semantic >+SELECT_STATEMENT_SELECT_CLAUSE_HAS_NON_AGGREGATE_FUNCTIONS = The select list can only consist of aggregate functions because there is no GROUP BY clause and the HAVING clause is used. >+ >+# SimpleSelectClause - Grammar >+SIMPLE_SELECT_CLAUSE_NOT_SINGLE_EXPRESSION = Only one expression can be declared in a SELECT clause of a subquery. >+ >+# SizeExpression - Grammar >+SIZE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+SIZE_EXPRESSION_MISSING_EXPRESSION = A collection-valued path expression must be provided for a SIZE expression. >+SIZE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SIZE expression. >+SIZE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SIZE expression. >+ >+# SqrtExpression - Grammar >+SQRT_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+SQRT_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a SQRT expression. >+SQRT_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SQRT expression. >+SQRT_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SQRT expression. >+# SqrtExpression - Semantic >+SQRT_EXPRESSION_WRONG_TYPE = The expression is not a numeric type. >+ >+# StateFieldPathExpression - Semantic >+STATE_FIELD_PATH_EXPRESSION_ASSOCIATION_FIELD = The association field ''{0}'' cannot be used as a state field path. >+STATE_FIELD_PATH_EXPRESSION_COLLECTION_TYPE = The state field path ''{0}'' cannot resolve to a collection type. >+STATE_FIELD_PATH_EXPRESSION_INVALID_ENUM_CONSTANT = ''{0}'' cannot be resolved to an Enum constant. >+STATE_FIELD_PATH_EXPRESSION_NO_MAPPING = No mapping is associated with the state field path ''{0}''. >+STATE_FIELD_PATH_EXPRESSION_NOT_RESOLVABLE = The state field path ''{0}'' cannot be resolved to a valid type. >+ >+# SubExpression - Grammar >+SUB_EXPRESSION_MISSING_EXPRESSION = The encapsulated expression is missing. >+SUB_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the sub-expression. >+ >+# SubstractionExpression - Semantic >+SUBTRACTION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the subtraction is not a valid arithmetic expression. >+SUBTRACTION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the subtraction is not a valid arithmetic expression. >+ >+# SubstringExpression - Grammar >+SUBSTRING_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+SUBSTRING_EXPRESSION_INVALID_SECOND_EXPRESSION = The second argument is not a valid expression. >+SUBSTRING_EXPRESSION_INVALID_THIRD_EXPRESSION = The third argument is not a valid expression. >+SUBSTRING_EXPRESSION_MISSING_FIRST_COMMA = The first comma is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_SECOND_COMMA = The second comma is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_THIRD_EXPRESSION = The third argument is missing from the SUBSTRING expression. >+# SubstringExpression - Semantic >+SUBSTRING_EXPRESSION_FIRST_EXPRESSION_WRONG_TYPE = The first argument is not a String value. >+SUBSTRING_EXPRESSION_SECOND_EXPRESSION_WRONG_TYPE = The first argument is not an integer value. >+SUBSTRING_EXPRESSION_THIRD_EXPRESSION_WRONG_TYPE = The first argument is not an integer value. >+ >+# SumFunction - Grammar >+SUM_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+SUM_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a SUM expression. >+SUM_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SUM expression. >+SUM_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SUM expression. >+# SumFunction - Semantic >+SUM_FUNCTION_WRONG_TYPE = The argument must be numeric. >+ >+# TrimExpression - Grammar >+TRIM_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+TRIM_EXPRESSION_INVALID_TRIM_CHARACTER = The trim character should be a single-character string literal or a character-valued input parameter (i.e., char or Character). >+TRIM_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a TRIM expression. >+TRIM_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the TRIM expression. >+TRIM_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the TRIM expression. >+TRIM_EXPRESSION_NOT_SINGLE_STRING_LITERAL = The trim character should be a single-character string literal. >+ >+# TypeExpression - Grammar >+TYPE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+TYPE_EXPRESSION_MISSING_EXPRESSION = An identification variable or a path expression must be provided for a TYPE expression. >+TYPE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the TYPE expression. >+TYPE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the TYPE expression. >+# TypeExpression - Semantic >+ >+# UpdateClause - Grammar >+UPDATE_CLAUSE_MISSING_RANGE_VARIABLE_DECLARATION = The range variable declaration is missing from the UPDATE clause. >+UPDATE_CLAUSE_MISSING_SET = The SET identifier is missing from the UPDATE clause. >+UPDATE_CLAUSE_MISSING_UPDATE_ITEMS = At least one update item must be specified for an UPDATE clause. >+UPDATE_CLAUSE_UPDATE_ITEM_ENDS_WITH_COMMA = The update item cannot end with a comma. >+UPDATE_CLAUSE_UPDATE_ITEM_IS_MISSING_COMMA = The UPDATE clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ >+# UpdateItem - Grammar >+UPDATE_ITEM_MISSING_EQUAL_SIGN = The equal sign must be specified. >+UPDATE_ITEM_MISSING_NEW_VALUE = The new value must be specified. >+UPDATE_ITEM_MISSING_STATE_FIELD_PATH_EXPRESSION = The state field path expression is missing. >+# UpdateItem - Semantic >+UPDATE_ITEM_NOT_ASSIGNABLE = Type mismatch: cannot convert from {0} to {1}. >+UPDATE_ITEM_NOT_RESOLVABLE = The state field cannot be resolved. >+ >+# UpperExpression - Grammar >+UPPER_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+UPPER_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a UPPER expression. >+UPPER_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the UPPER expression. >+UPPER_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the UPPER expression. >+# UpperExpression - Semantic >+UPPER_EXPRESSION_WRONG_TYPE = The expression is not a String. >+ >+# ValueExpression - Grammar >+VALUE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+VALUE_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for a VALUE expression. >+VALUE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the VALUE expression. >+VALUE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the VALUE expression. >+ >+# WhenClause - Grammar >+WHEN_CLAUSE_MISSING_THEN_EXPRESSION = A conditional expression must be provider for a WHEN clause. >+WHEN_CLAUSE_MISSING_THEN_IDENTIFIER = The identifier THEN is missing from the WHEN clause. >+WHEN_CLAUSE_MISSING_WHEN_EXPRESSION = A WHEN expression must be provided for a WHEN clause. >+ >+# WhereClause - Grammar >+WHERE_CLAUSE_INVALID_CONDITIONAL_EXPRESSION = The expression is not a valid conditional expression. >+WHERE_CLAUSE_MISSING_CONDITIONAL_EXPRESSION = The conditional expression is missing from the WHERE clause. >Index: src/org/eclipse/jpt/jpa/core/context/orm/OrmNamedQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmNamedQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 OrmNamedQuery.java >--- src/org/eclipse/jpt/jpa/core/context/orm/OrmNamedQuery.java 6 Feb 2011 02:07:22 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/context/orm/OrmNamedQuery.java 15 Mar 2011 01:56:27 -0000 >@@ -21,7 +21,7 @@ > * stability. It is available at this early stage to solicit feedback from > * pioneering adopters on the understanding that any code that uses this API > * will almost certainly be broken (repeatedly) as the API evolves. >- * >+ * > * @version 2.1 > * @since 2.0 > */ >@@ -32,4 +32,5 @@ > > // required to resolve ambiguity > ListIterable<OrmQueryHint> getHints(); >-} >+ >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 OrmQuery.java >--- src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java 6 Feb 2011 02:07:22 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java 15 Mar 2011 01:56:27 -0000 >@@ -3,7 +3,7 @@ > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ >@@ -23,7 +23,7 @@ > * stability. It is available at this early stage to solicit feedback from > * pioneering adopters on the understanding that any code that uses this API > * will almost certainly be broken (repeatedly) as the API evolves. >- * >+ * > * @version 2.1 > * @since 2.0 > */ >@@ -46,4 +46,6 @@ > // ********** validation ********** > > TextRange getNameTextRange(); >+ >+ TextRange getQueryTextRange(); > } >Index: src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 AbstractOrmQuery.java >--- src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java 6 Feb 2011 02:07:18 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java 15 Mar 2011 01:56:27 -0000 >@@ -10,7 +10,6 @@ > package org.eclipse.jpt.jpa.core.internal.context.orm; > > import java.util.Vector; >- > import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.common.utility.internal.iterables.ListIterable; > import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable; >@@ -55,7 +54,7 @@ > // ********** synchronize/update ********** > > @Override >- public void synchronizeWithResourceModel() { >+ public void synchronizeWithResourceModel() { > super.synchronizeWithResourceModel(); > this.setName_(this.xmlQuery.getName()); > this.setQuery_(this.xmlQuery.getQuery()); >@@ -231,6 +230,10 @@ > return this.xmlQuery.getNameTextRange(); > } > >+ public TextRange getQueryTextRange() { >+ return this.xmlQuery.getQueryTextRange(); >+ } >+ > @Override > public void toString(StringBuilder sb) { > sb.append(this.name); >Index: src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericJavaNamedQuery.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java 6 Feb 2011 02:07:16 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java 15 Mar 2011 01:56:27 -0000 >@@ -1,18 +1,27 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2007, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ > package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; > >+import java.util.List; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; > import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery; > import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationPreferences; > import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation; >+import org.eclipse.persistence.jpa.jpql.JPQLQueryProblem; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IReporter; > > /** > * Java named query >@@ -24,4 +33,32 @@ > public GenericJavaNamedQuery(JavaJpaContextNode parent, NamedQueryAnnotation queryAnnotation) { > super(parent, queryAnnotation); > } >-} >+ >+ >+ // ********** validation ********** >+ >+ private boolean shouldValidate() { >+ return JpaValidationPreferences.getProblemSeverityPreference(this, JpaValidationMessages.JPQL_QUERY_VALIDATION) == -1; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { >+ super.validate(messages, reporter, astRoot); >+ >+ // Make this quick check so we don't validate the query, which is time consuming >+ if (shouldValidate()) { >+ JpaJpqlQueryHelper helper = new JpaJpqlQueryHelper(this); >+ String parsedJpqlQuery = helper.getParsedJPQLQuery(); >+ String actualQuery = getQuery(); >+ >+ for (JPQLQueryProblem problem : helper.validate()) { >+ TextRange textRange = this.getQueryAnnotation().getQueryTextRange(astRoot); >+ IMessage message = helper.buildProblem(this, textRange, problem, parsedJpqlQuery, actualQuery, 1); >+ messages.add(message); >+ } >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericJavaQueryContainer.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java 6 Feb 2011 02:07:16 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java 15 Mar 2011 01:56:28 -0000 >@@ -308,10 +308,10 @@ > @Override > public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { > super.validate(messages, reporter, astRoot); >- this.validateQueries(messages, astRoot); >+ this.validateQueries(messages, reporter, astRoot); > } > >- protected void validateQueries(List<IMessage> messages, CompilationUnit astRoot) { >+ protected void validateQueries(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { > for (Iterator<JavaQuery> localQueries = this.queries(); localQueries.hasNext(); ) { > JavaQuery localQuery = localQueries.next(); > String name = localQuery.getName(); >@@ -354,6 +354,9 @@ > ) > ); > } >+ else { >+ localQuery.validate(messages, reporter, astRoot); >+ } > } > } > >Index: src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericOrmNamedQuery.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedQuery.java 6 Feb 2011 02:07:13 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedQuery.java 15 Mar 2011 01:56:28 -0000 >@@ -1,18 +1,26 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2007, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ > package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; > >+import java.util.List; >+import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.jpa.core.context.XmlContextNode; > import org.eclipse.jpt.jpa.core.context.orm.OrmNamedQuery; > import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationPreferences; > import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedQuery; >+import org.eclipse.persistence.jpa.jpql.JPQLQueryProblem; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IReporter; > > /** > * <code>orm.xml</code> named query >@@ -24,4 +32,31 @@ > public GenericOrmNamedQuery(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) { > super(parent, resourceNamedQuery); > } >-} >+ >+ // ********** validation ********** >+ >+ private boolean shouldValidate() { >+ return JpaValidationPreferences.getProblemSeverityPreference(this, JpaValidationMessages.JPQL_QUERY_VALIDATION) == -1; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void validate(List<IMessage> messages, IReporter reporter) { >+ super.validate(messages, reporter); >+ >+ // Make this quick check so we don't validate the query, which is time consuming >+ if (shouldValidate()) { >+ JpaJpqlQueryHelper helper = new JpaJpqlQueryHelper(this); >+ String parsedJpqlQuery = helper.getParsedJPQLQuery(); >+ String actualQuery = getQuery(); >+ >+ for (JPQLQueryProblem problem : helper.validate()) { >+ TextRange textRange = this.getQueryTextRange(); >+ IMessage message = helper.buildProblem(this, textRange, problem, parsedJpqlQuery, actualQuery, 0); >+ messages.add(message); >+ } >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericOrmQueryContainer.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java 6 Feb 2011 02:07:13 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java 15 Mar 2011 01:56:28 -0000 >@@ -14,7 +14,6 @@ > import java.util.List; > import java.util.ListIterator; > import java.util.Vector; >- > import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.common.utility.internal.StringTools; > import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable; >@@ -300,10 +299,10 @@ > @Override > public void validate(List<IMessage> messages, IReporter reporter) { > super.validate(messages, reporter); >- this.validateQueries(messages); >+ this.validateQueries(messages, reporter); > } > >- protected void validateQueries(List<IMessage> messages) { >+ protected void validateQueries(List<IMessage> messages, IReporter reporter) { > for (OrmQuery localQuery : this.getQueries()) { > String name = localQuery.getName(); > if (StringTools.stringIsEmpty(name)){ >@@ -345,6 +344,9 @@ > ) > ); > } >+ else { >+ localQuery.validate(messages, reporter); >+ } > } > } > >Index: src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericJavaNamedQuery2_0.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java 6 Feb 2011 02:07:24 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java 15 Mar 2011 01:56:28 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2009, 2010 Oracle. All rights reserved. >+* Copyright (c) 2009, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -9,11 +9,20 @@ > *******************************************************************************/ > package org.eclipse.jpt.jpa.core.internal.jpa2.context.java; > >+import java.util.List; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; > import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationPreferences; > import org.eclipse.jpt.jpa.core.jpa2.context.LockModeType2_0; > import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaNamedQuery2_0; > import org.eclipse.jpt.jpa.core.jpa2.resource.java.NamedQuery2_0Annotation; >+import org.eclipse.persistence.jpa.jpql.JPQLQueryProblem; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IReporter; > > /** > * JPA 2.0 >@@ -87,4 +96,31 @@ > return LockModeType2_0.NONE; > } > >-} >+ >+ // ********** validation ********** >+ >+ private boolean shouldValidate() { >+ return JpaValidationPreferences.getProblemSeverityPreference(this, JpaValidationMessages.JPQL_QUERY_VALIDATION) == -1; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { >+ super.validate(messages, reporter, astRoot); >+ >+ // Make this quick check so we don't validate the query, which is time consuming >+ if (shouldValidate()) { >+ JpaJpqlQueryHelper helper = new JpaJpqlQueryHelper(this); >+ String parsedJpqlQuery = helper.getParsedJPQLQuery(); >+ String actualQuery = getQuery(); >+ >+ for (JPQLQueryProblem problem : helper.validate()) { >+ TextRange textRange = this.getQueryAnnotation().getQueryTextRange(astRoot); >+ IMessage message = helper.buildProblem(this, textRange, problem, parsedJpqlQuery, actualQuery, 1); >+ messages.add(message); >+ } >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericOrmNamedQuery2_0.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java 6 Feb 2011 02:07:26 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java 15 Mar 2011 01:56:28 -0000 >@@ -1,19 +1,27 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2007, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ > package org.eclipse.jpt.jpa.core.internal.jpa2.context.orm; > >+import java.util.List; >+import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.jpa.core.context.XmlContextNode; > import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationPreferences; > import org.eclipse.jpt.jpa.core.jpa2.context.LockModeType2_0; > import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmNamedQuery2_0; > import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedQuery; >+import org.eclipse.persistence.jpa.jpql.JPQLQueryProblem; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IReporter; > > /** > * JPA 2.0 >@@ -87,4 +95,30 @@ > return LockModeType2_0.NONE; > } > >-} >+ // ********** validation ********** >+ >+ private boolean shouldValidate() { >+ return JpaValidationPreferences.getProblemSeverityPreference(this, JpaValidationMessages.JPQL_QUERY_VALIDATION) == -1; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void validate(List<IMessage> messages, IReporter reporter) { >+ super.validate(messages, reporter); >+ >+ // Make this quick check so we don't validate the query, which is time consuming >+ if (shouldValidate()) { >+ JpaJpqlQueryHelper helper = new JpaJpqlQueryHelper(this); >+ String parsedJpqlQuery = helper.getParsedJPQLQuery(); >+ String actualQuery = getQuery(); >+ >+ for (JPQLQueryProblem problem : helper.validate()) { >+ TextRange textRange = this.getQueryTextRange(); >+ IMessage message = helper.buildProblem(this, textRange, problem, parsedJpqlQuery, actualQuery, 0); >+ messages.add(message); >+ } >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,102 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jdt.core.dom.IMethodBinding; >+import org.eclipse.jdt.core.dom.ITypeBinding; >+import org.eclipse.jdt.core.dom.MethodDeclaration; >+import org.eclipse.persistence.jpa.jpql.spi.IConstructor; >+import org.eclipse.persistence.jpa.jpql.spi.IType; >+import org.eclipse.persistence.jpa.jpql.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link IConstructor} that is wrapping the design-time >+ * representation of a Java constructor. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaConstructor implements IConstructor { >+ >+ /** >+ * The design-time representation of a Java constructor. >+ */ >+ private final MethodDeclaration method; >+ >+ /** >+ * The cached {@link ITypeDeclaration ITypeDeclarations} representing each of the constructor's >+ * parameter types. >+ */ >+ private ITypeDeclaration[] typeDeclarations; >+ >+ /** >+ * The repository of Java types. >+ */ >+ private final JpaTypeRepository typeRepository; >+ >+ /** >+ * Creates a new <code>JpaConstructor</code>. >+ * >+ * @param typeRepository The repository of Java types >+ * @param method The design-time representation of a Java constructor >+ */ >+ JpaConstructor(JpaTypeRepository typeRepository, MethodDeclaration method) { >+ super(); >+ this.method = method; >+ this.typeRepository = typeRepository; >+ } >+ >+ private ITypeDeclaration buildTypeDeclaration(ITypeBinding parameterType) { >+ >+ boolean array = parameterType.isArray(); >+ String typeName = array ? parameterType.getComponentType().getBinaryName() : parameterType.getBinaryName(); >+ >+ // Retrieve the fully qualified name of the type >+ ITypeBinding[] typeArguments = parameterType.getTypeArguments(); >+ ITypeDeclaration[] genericTypes = new ITypeDeclaration[typeArguments.length]; >+ int index = 0; >+ >+ for (ITypeBinding typeArgument : typeArguments) { >+ String genericTypeName = typeArgument.getErasure().getBinaryName(); >+ IType genericType = typeRepository.getType(genericTypeName); >+ genericTypes[index++] = genericType.getTypeDeclaration(); >+ } >+ >+ return new JpaTypeDeclaration(typeRepository.getType(typeName), genericTypes, array); >+ } >+ >+ private ITypeDeclaration[] buildTypeDeclarations() { >+ >+ IMethodBinding binding = method.resolveBinding(); >+ ITypeBinding[] parameterTypes = binding.getParameterTypes(); >+ ITypeDeclaration[] declarations = new ITypeDeclaration[parameterTypes.length]; >+ >+ for (int index = declarations.length; --index >= 0; ) { >+ declarations[index] = buildTypeDeclaration(parameterTypes[index]); >+ } >+ >+ return declarations; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration[] getParameterTypes() { >+ if (typeDeclarations == null) { >+ typeDeclarations = buildTypeDeclarations(); >+ } >+ return typeDeclarations; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.jpa.core.context.Embeddable; >+import org.eclipse.persistence.jpa.jpql.spi.IEmbeddable; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedTypeVisitor; >+ >+/** >+ * The concrete implementation of {@link IEmbeddable} that is wrapping the design-time >+ * representation of a JPA embeddable. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaEmbeddable extends JpaManagedType >+ implements IEmbeddable { >+ >+ /** >+ * Creates a new <code>JpaEmbeddable</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param embeddable The design-time model object wrapped by this class >+ */ >+ JpaEmbeddable(JpaManagedTypeProvider provider, Embeddable embeddable) { >+ super(provider, embeddable); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ visitor.visit(this); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ Embeddable getManagedType() { >+ return (Embeddable) super.getManagedType(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,103 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.HashMap; >+import java.util.ListIterator; >+import java.util.Map; >+import org.eclipse.jpt.jpa.core.context.Entity; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.persistence.jpa.jpql.spi.IEntity; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.jpa.jpql.spi.IQuery; >+ >+/** >+ * The concrete implementation of {@link IEntity} that is wrapping the design-time representation >+ * of a JPA entity. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+abstract class JpaEntity extends JpaManagedType >+ implements IEntity { >+ >+ /** >+ * The cached used to quickly retrieve any queries that have been cached. >+ */ >+ private Map<String, IQuery> queries; >+ >+ /** >+ * Creates a new <code>JpaEntity</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param entity The design-time model object wrapped by this class >+ */ >+ JpaEntity(JpaManagedTypeProvider provider, Entity entity) { >+ super(provider, entity); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ visitor.visit(this); >+ } >+ >+ final IQuery buildQuery(JpaManagedTypeProvider provider, NamedQuery namedQuery) { >+ return new JpaQuery(provider, namedQuery); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ Entity getManagedType() { >+ return (Entity) super.getManagedType(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final String getName() { >+ return getManagedType().getName(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IQuery getNamedQuery(String queryName) { >+ initializeQueries(); >+ return queries.get(queryName); >+ } >+ >+ private void initializeQueries() { >+ if (queries == null) { >+ queries = new HashMap<String, IQuery>(); >+ initializeQueries(queries); >+ } >+ } >+ >+ void initializeQueries(Map<String, IQuery> queries) { >+ JpaManagedTypeProvider provider = getProvider(); >+ for (ListIterator<NamedQuery> iter = namedQueries(); iter.hasNext(); ) { >+ NamedQuery namedQuery = iter.next(); >+ queries.put(namedQuery.getName(), buildQuery(provider, namedQuery)); >+ } >+ } >+ >+ private ListIterator<NamedQuery> namedQueries() { >+ return getManagedType().getQueryContainer().namedQueries(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,209 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.common.core.internal.utility.SimpleTextRange; >+import org.eclipse.jpt.common.core.utility.TextRange; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages; >+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationPreferences; >+import org.eclipse.persistence.jpa.jpql.ExpressionTools; >+import org.eclipse.persistence.jpa.jpql.JPQLQueryHelper; >+import org.eclipse.persistence.jpa.jpql.JPQLQueryProblem; >+import org.eclipse.persistence.jpa.jpql.spi.IQuery; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+ >+/** >+ * This helper can perform the following operations over a JPQL query: >+ * <ul> >+ * <li>Calculates the result type of a query: {@link #getResultType()};</li> >+ * <li>Calculates the type of an input parameter: {@link #getParameterType(String)}.</li> >+ * <li>Calculates the possible choices to complete the query from a given >+ * position (used for content assist): {@link #buildContentAssistItems(int)}.</li> >+ * <li>Validates the query by introspecting its grammar and semantic: >+ * <ul> >+ * <li>{@link #validate()},</li> >+ * <li>{@link #validateGrammar()},</li> >+ * <li>{@link #validateSemantic()}.</li> >+ * </ul></li> >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+public final class JpaJpqlQueryHelper extends JPQLQueryHelper<NamedQuery> { >+ >+ /** >+ * The actual JPQL query, which can differ from the one owned by the model object, which happens >+ * when the model is out of sync because it has not been updated yet. >+ */ >+ private final String actualQuery; >+ >+ /** >+ * The external form of the JPQL query that was already created before this helper, which happens >+ * during the execution of the unit-tests. >+ */ >+ private IQuery localQuery; >+ >+ /** >+ * Creates a new <code>JpaJpqlQueryHelper</code>. This constructor is used only by the unit-tests. >+ * >+ * @param query The external form that is already wrapping the {@link MWNamedQuery} >+ * @exception NullPointerException If the query is <code>null</code> >+ */ >+ public JpaJpqlQueryHelper(IQuery query) { >+ this(((JpaQuery) query).getQuery()); >+ this.localQuery = query; >+ } >+ >+ /** >+ * Creates a new <code>JpaJpqlQueryHelper</code>. >+ * >+ * @param query The model object where the JPQL query is stored >+ * @exception NullPointerException If the given {@link NamedQuery} is <code>null</code> >+ */ >+ public JpaJpqlQueryHelper(NamedQuery query) { >+ this(query, query.getQuery()); >+ } >+ >+ /** >+ * Creates a new <code>JpaQueryHelper</code>. >+ * >+ * @param query The model object where the JPQL query is stored >+ * @param actualQuery The actual JPQL query, which can differ from the one owned by the model >+ * object, which happens when the model is out of sync because it has not been updated yet >+ * @exception NullPointerException If the given {@link NamedQuery} is <code>null</code> >+ */ >+ public JpaJpqlQueryHelper(NamedQuery query, String actualQuery) { >+ super(query); >+ this.actualQuery = actualQuery; >+ } >+ >+ /** >+ * Calculates the start and end positions by adjusting to the given <em>jpqlQuery</em>, which may >+ * differ from the string representation of the parsed tree since the parsed tree does not keep >+ * track of multiple whitespace but only one. It also increase the length when the start and end >+ * positions are the same. >+ * >+ * @param problem The {@link JPQLQueryProblem problem} that was found in the JPQL query, which is >+ * either a grammatical or semantic problem >+ * @param parsedJpqlQuery The string representation of the parsed tree representation of the JPQL >+ * query, which may differ from the actual JPQL query since it does not keep more than one >+ * whitespace >+ * @param actualQuery The actual JPQL query that was parsed and validated >+ * @return The start and end positions, which may have been adjusted >+ */ >+ public int[] buildPositions(JPQLQueryProblem problem, String parsedJpqlQuery, String actualQuery) { >+ >+ int startPosition = problem.getStartPosition(); >+ int endPosition = problem.getEndPosition(); >+ >+ // If the start and end positions are the same, then expand the text range >+ if (startPosition == endPosition) { >+ startPosition = Math.max(startPosition - 1, 0); >+ } >+ >+ // Reposition the cursor so it's correctly positioned in the actual query, which is the >+ // since it may contains more than one whitespace for a single whitespace >+ int newStartPosition = ExpressionTools.repositionCursor(parsedJpqlQuery, startPosition, actualQuery); >+ >+ if (newStartPosition != startPosition) { >+ endPosition += (newStartPosition - startPosition); >+ startPosition = newStartPosition; >+ } >+ >+ return new int[] { startPosition, endPosition }; >+ } >+ >+ /** >+ * Creates a new {@link IMessage} for the given {@link JPQLQueryProblem}. >+ * >+ * @param targetObject The object for which a new {@link IMessage} is creating describing the >+ * problem >+ * @param problem The {@link JPQLQueryProblem problem} that was found in the JPQL query, which is >+ * either a grammatical or semantic problem >+ * @param textRange The range of the JPQL query in the Java source file >+ * @param parsedJpqlQuery The string representation of the parsed tree representation of the JPQL >+ * query, which may differ from the actual JPQL query since it does not keep more than one >+ * whitespace >+ * @param actualQuery The actual JPQL query that was parsed and validated >+ * @param offset This offset is used to move the start position >+ * @return A new {@link IMessage} that has the required information to display the problem >+ * underline and the error message in the Problems view >+ */ >+ public IMessage buildProblem(Object targetObject, >+ TextRange textRange, >+ JPQLQueryProblem problem, >+ String parsedJpqlQuery, >+ String actualQuery, >+ int offset) { >+ >+ int[] positions = buildPositions(problem, parsedJpqlQuery, actualQuery); >+ >+ // Create the text range of the problem >+ textRange = new SimpleTextRange( >+ textRange.getOffset() + positions[0] + offset, >+ positions[1] - positions[0], >+ textRange.getLineNumber() >+ ); >+ >+ // Now create the message >+ IMessage message = DefaultJpaValidationMessages.buildMessage( >+ severity(targetObject), >+ problem.getMessageKey(), >+ problem.getMessageArguments(), >+ targetObject, >+ textRange >+ ); >+ message.setBundleName("jpa_jpql_validation"); >+ return message; >+ } >+ >+ private JpaManagedTypeProvider buildProvider(NamedQuery query) { >+ try { >+ return new JpaPersistenceUnit(query.getJpaProject(), query.getPersistenceUnit()); >+ } >+ catch (Exception e) { >+ return new JpaMappingFile(query.getJpaProject(), query.getMappingFileRoot().getParent()); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected IQuery buildQuery(NamedQuery query) { >+ if (localQuery == null) { >+ localQuery = new JpaQuery(buildProvider(query), query, actualQuery); >+ } >+ return localQuery; >+ } >+ >+ /** >+ * Retrieve the severity that is associated to JPQL query validation, which cannot be retrieved >+ * using the JPQL problem message key. >+ >+ * @param targetObject The object for which a new {@link IMessage} is creating describing the >+ * problem >+ * @return The global severity for validating JPQL queries >+ */ >+ private int severity(Object targetObject) { >+ return JpaValidationPreferences.getProblemSeverityPreference( >+ targetObject, >+ JpaValidationMessages.JPQL_QUERY_VALIDATION >+ ); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,135 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import org.eclipse.jpt.jpa.core.context.AttributeMapping; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedType; >+import org.eclipse.persistence.jpa.jpql.spi.IMapping; >+ >+/** >+ * The abstract definition of {@link IManagedType} defined for wrapping the design-time mapped class >+ * object. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+abstract class JpaManagedType implements IManagedType { >+ >+ /** >+ * The design-time model object wrapped by this class. >+ */ >+ private final TypeMapping managedType; >+ >+ /** >+ * The cached collection of {@link IMapping mappings} that prevent rebuilding them every time one >+ * is requested. >+ */ >+ private Map<String, IMapping> mappings; >+ >+ /** >+ * The provider of JPA managed types. >+ */ >+ private final JpaManagedTypeProvider provider; >+ >+ /** >+ * The cached wrapper over {@link TODO}. >+ */ >+ private JpaType type; >+ >+ /** >+ * Creates a new <code>JDeveloperManagedType</code>. >+ * >+ * @param managedType The provider of JPA managed types >+ * @param mappedClass The design-time model object wrapped by this class >+ */ >+ JpaManagedType(JpaManagedTypeProvider provider, TypeMapping managedType) { >+ super(); >+ this.provider = provider; >+ this.managedType = managedType; >+ } >+ >+ private IMapping buildMapping(AttributeMapping mapping) { >+ return new JpaMapping(this, mapping); >+ } >+ >+ private Map<String, IMapping> buildMappings() { >+ Map<String, IMapping> mappings = new HashMap<String, IMapping>(); >+ for (Iterator<AttributeMapping> iter = managedType.allAttributeMappings(); iter.hasNext(); ) { >+ AttributeMapping mapping = iter.next(); >+ mappings.put(mapping.getName(), buildMapping(mapping)); >+ } >+ return mappings; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int compareTo(IManagedType managedType) { >+ return getType().getName().compareTo(managedType.getType().getName()); >+ } >+ >+ /** >+ * Returns the encapsulated model object. >+ * >+ * @return The managed type wrapped by this external form >+ */ >+ TypeMapping getManagedType() { >+ return managedType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final IMapping getMappingNamed(String name) { >+ initializeMappings(); >+ return mappings.get(name); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final JpaManagedTypeProvider getProvider() { >+ return provider; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final JpaType getType() { >+ if (type == null) { >+ type = provider.getTypeRepository().getType(managedType.getPersistentType().getName()); >+ } >+ return type; >+ } >+ >+ private void initializeMappings() { >+ if (mappings == null) { >+ mappings = buildMappings(); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final Iterable<IMapping> mappings() { >+ initializeMappings(); >+ return Collections.unmodifiableCollection(mappings.values()); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,276 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import org.eclipse.jpt.jpa.core.JpaFacet; >+import org.eclipse.jpt.jpa.core.JpaPlatform; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.context.Embeddable; >+import org.eclipse.jpt.jpa.core.context.Entity; >+import org.eclipse.jpt.jpa.core.context.MappedSuperclass; >+import org.eclipse.jpt.jpa.core.context.PersistentType; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.jpt.jpa.core.context.persistence.PersistentTypeContainer; >+import org.eclipse.persistence.jpa.jpql.spi.IEmbeddable; >+import org.eclipse.persistence.jpa.jpql.spi.IEntity; >+import org.eclipse.persistence.jpa.jpql.spi.IJPAVersion; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedType; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedTypeProvider; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.jpa.jpql.spi.IMappedSuperclass; >+import org.eclipse.persistence.jpa.jpql.spi.IPlatform; >+import org.eclipse.persistence.jpa.jpql.spi.IType; >+ >+/** >+ * The abstract implementation of {@link IManagedTypeProvider} that is wrapping the design-time >+ * representation of a provider of managed types. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+abstract class JpaManagedTypeProvider implements IManagedTypeProvider { >+ >+ /** >+ * The filtered collection of managed types that are the abstract schema types. >+ */ >+ private Collection<IEntity> abstractSchemaTypes; >+ >+ /** >+ * The project that gives access to the application's metadata. >+ */ >+ private final JpaProject jpaProject; >+ >+ /** >+ * The cached {@link IManagedType managed types}. >+ */ >+ private Map<String, IManagedType> managedTypes; >+ >+ /** >+ * The design-time provider of managed types. >+ */ >+ private final PersistentTypeContainer persistentTypeContainer; >+ >+ /** >+ * The external form of a type repository. >+ */ >+ private JpaTypeRepository typeRepository; >+ >+ /** >+ * The version of the Java Persistence this entity for which it was defined. >+ */ >+ private IJPAVersion version; >+ >+ /** >+ * Creates a new <code>JpaManagedTypeProvider</code>. >+ * >+ * @param jpaProject The project that gives access to the application's metadata >+ * @param persistentTypeContainer The design-time provider of managed types >+ */ >+ JpaManagedTypeProvider(JpaProject jpaProject, PersistentTypeContainer persistentTypeContainer) { >+ >+ super(); >+ this.jpaProject = jpaProject; >+ this.persistentTypeContainer = persistentTypeContainer; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterable<IEntity> abstractSchemaTypes() { >+ if (abstractSchemaTypes == null) { >+ initializeManagedTypes(); >+ EntityCollector visitor = new EntityCollector(); >+ for (IManagedType managedType : managedTypes.values()) { >+ managedType.accept(visitor); >+ } >+ abstractSchemaTypes = visitor.entities; >+ } >+ return Collections.unmodifiableCollection(abstractSchemaTypes); >+ } >+ >+ abstract JpaEntity buildEntity(TypeMapping mappedClass); >+ >+ private IManagedType buildManagedType(PersistentType persistentType) { >+ >+ TypeMapping mappedClass = persistentType.getMapping(); >+ >+ if (mappedClass instanceof Entity) { >+ return buildEntity(mappedClass); >+ } >+ >+ if (mappedClass instanceof MappedSuperclass) { >+ return new JpaMappedSuperclass(this, (MappedSuperclass) mappedClass); >+ } >+ >+ if (mappedClass instanceof Embeddable) { >+ return new JpaEmbeddable(this, (Embeddable) mappedClass); >+ } >+ >+ return new JpaNullManagedType(this, mappedClass); >+ } >+ >+ private Map<String, IManagedType> buildManagedTypes() { >+ Map<String, IManagedType> managedTypes = new HashMap<String, IManagedType>(); >+ for (Iterator<? extends PersistentType> iter = persistenceTypes(); iter.hasNext(); ) { >+ PersistentType persistentType = iter.next(); >+ managedTypes.put(persistentType.getMapping().getName(), buildManagedType(persistentType)); >+ } >+ return managedTypes; >+ } >+ >+ private IJPAVersion convert(JpaPlatform.Version version) { >+ >+ String jpaVersion = version.getJpaVersion(); >+ >+ if (JpaFacet.VERSION_1_0.getVersionString().equals(jpaVersion)) { >+ return IJPAVersion.VERSION_1_0; >+ } >+ >+ return IJPAVersion.VERSION_2_0; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedType getManagedType(IType type) { >+ >+ initializeManagedTypes(); >+ >+ for (IManagedType managedType : managedTypes.values()) { >+ if (managedType.getType() == type) { >+ return managedType; >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedType getManagedType(String abstractSchemaName) { >+ initializeManagedTypes(); >+ return managedTypes.get(abstractSchemaName); >+ } >+ >+ /** >+ * Returns the container of managed types. >+ * >+ * @return The container of managed types >+ */ >+ PersistentTypeContainer getPersistentTypeContainer() { >+ return persistentTypeContainer; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IPlatform getPlatform() { >+ return IPlatform.JAVA; >+ // TODO >+// return (jpaProject instanceof EclipseLinkJpaProject) ? IPlatform.ECLIPSE_LINK : IPlatform.JAVA; >+ } >+ >+ /** >+ * Returns the encapsulated {@link PersistentType}, which is the actual object. >+ * >+ * @return The design-time representation of a managed type provider >+ */ >+ PersistentTypeContainer getProvider() { >+ return persistentTypeContainer; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaTypeRepository getTypeRepository() { >+ if (typeRepository == null) { >+ typeRepository = new JpaTypeRepository(jpaProject.getJavaProject()); >+ } >+ return typeRepository; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IJPAVersion getVersion() { >+ if (version == null) { >+ version = convert(jpaProject.getJpaPlatform().getJpaVersion()); >+ } >+ return version; >+ } >+ >+ private void initializeManagedTypes() { >+ if (managedTypes == null) { >+ managedTypes = buildManagedTypes(); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterable<IManagedType> managedTypes() { >+ initializeManagedTypes(); >+ return Collections.unmodifiableCollection(managedTypes.values()); >+ } >+ >+ /** >+ * Retrieves the managed types from the design-time provider. >+ * >+ * @return The managed types that are defined only in the provider >+ */ >+ abstract Iterator<? extends PersistentType> persistenceTypes(); >+ >+ private static class EntityCollector implements IManagedTypeVisitor { >+ >+ /** >+ * The collection of {@link IEntity entities} that got visited. >+ */ >+ private final Collection<IEntity> entities; >+ >+ /** >+ * Creates a new <code>EntityCollector</code>. >+ */ >+ EntityCollector() { >+ super(); >+ entities = new ArrayList<IEntity>(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void visit(IEmbeddable embeddable) { >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void visit(IEntity entity) { >+ entities.add(entity); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void visit(IMappedSuperclass mappedSuperclass) { >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.jpa.core.context.MappedSuperclass; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.jpa.jpql.spi.IMappedSuperclass; >+ >+/** >+ * The concrete implementation of {@link IMappedSuperclass} that is wrapping the design-time >+ * representation of a JPA mapped superclass. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaMappedSuperclass extends JpaManagedType >+ implements IMappedSuperclass { >+ >+ /** >+ * Creates a new <code>JpaMappedSuperclass</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param mappedSuperclass The design-time model object wrapped by this class >+ */ >+ JpaMappedSuperclass(JpaManagedTypeProvider provider, MappedSuperclass mappedSuperclass) { >+ super(provider, mappedSuperclass); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ visitor.visit(this); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ MappedSuperclass getManagedType() { >+ return (MappedSuperclass) super.getManagedType(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,252 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.lang.annotation.Annotation; >+import java.util.Iterator; >+import java.util.List; >+import org.eclipse.jpt.common.utility.internal.CollectionTools; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; >+import org.eclipse.jpt.jpa.core.MappingKeys; >+import org.eclipse.jpt.jpa.core.context.AttributeMapping; >+import org.eclipse.jpt.jpa.core.context.PersistentAttribute; >+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; >+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0; >+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedType; >+import org.eclipse.persistence.jpa.jpql.spi.IMapping; >+import org.eclipse.persistence.jpa.jpql.spi.IMappingType; >+import org.eclipse.persistence.jpa.jpql.spi.IType; >+import org.eclipse.persistence.jpa.jpql.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link IMapping} that is wrapping the design-time representation >+ * of a mapping. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+final class JpaMapping implements IMapping { >+ >+ /** >+ * The design-time {@link AttributeMapping} wrapped by this class. >+ */ >+ private final AttributeMapping mapping; >+ >+ /** >+ * The type of the actual mapping. >+ */ >+ private IMappingType mappingType; >+ >+ /** >+ * The parent of this mapping. >+ */ >+ private final JpaManagedType parent; >+ >+ /** >+ * The type declaration of the property represented by the mapping. >+ */ >+ private ITypeDeclaration typeDeclaration; >+ >+ /** >+ * Creates a new <code>JpaMapping</code>. >+ * >+ * @param parent The parent of this mapping >+ * @param mapping The design-time {@link AttributeMapping} wrapped by this class >+ */ >+ JpaMapping(JpaManagedType parent, AttributeMapping mapping) { >+ super(); >+ this.parent = parent; >+ this.mapping = mapping; >+ } >+ >+ private ITypeDeclaration[] buildGenericTypeDeclarations() { >+ JavaPersistentAttribute javaPersistentAttribute = mapping.getPersistentAttribute().getJavaPersistentAttribute(); >+ JavaResourcePersistentAttribute resource = javaPersistentAttribute.getResourcePersistentAttribute(); >+ List<ITypeDeclaration> declarations = CollectionTools.list(buildGenericTypeDeclarations(resource)); >+ return declarations.toArray(new ITypeDeclaration[declarations.size()]); >+ } >+ >+ private Iterator<ITypeDeclaration> buildGenericTypeDeclarations(JavaResourcePersistentAttribute resource) { >+ return new TransformationIterator<String, ITypeDeclaration>(resource.typeTypeArgumentNames()) { >+ @Override >+ protected ITypeDeclaration transform(String next) { >+ return getTypeRepository().getType(next).getTypeDeclaration(); >+ } >+ }; >+ } >+ >+ private ITypeDeclaration buildTypeDeclaration() { >+ return new JpaTypeDeclaration( >+ getTypeRepository().getType(mapping.getPersistentAttribute().getTypeName()), >+ buildGenericTypeDeclarations(), >+ false /*TODO*/ >+ ); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int compareTo(IMapping mapping) { >+ return getName().compareTo(mapping.getName()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IMappingType getMappingType() { >+ if (mappingType == null) { >+ mappingType = mappingType(); >+ } >+ return mappingType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getName() { >+ return mapping.getName(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedType getParent() { >+ return parent; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IType getType() { >+ PersistentAttribute property = mapping.getPersistentAttribute(); >+ return getTypeRepository().getType(property.getTypeName()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration getTypeDeclaration() { >+ if (typeDeclaration == null) { >+ typeDeclaration = buildTypeDeclaration(); >+ } >+ return typeDeclaration; >+ } >+ >+ private JpaTypeRepository getTypeRepository() { >+ return parent.getType().getTypeRepository(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean hasAnnotation(Class<? extends Annotation> annotationType) { >+ JavaResourcePersistentAttribute attribute = mapping.getPersistentAttribute().getJavaPersistentAttribute().getResourcePersistentAttribute(); >+ return attribute.getAnnotation(annotationType.getName()) != null; >+ } >+ >+ private IMappingType mappingType() { >+ >+ String type = mapping.getKey(); >+ >+ // Basic >+ if (type == MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.BASIC; >+ } >+ >+ // Embedded >+ if (type == MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.EMBEDDED; >+ } >+ >+ // Embedded Id >+ if (type == MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.EMBEDDED_ID; >+ } >+ >+ // Id >+ if (type == MappingKeys.ID_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ID; >+ } >+ >+ // M:M >+ if (type == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.MANY_TO_MANY; >+ } >+ >+ // 1:M >+ if (type == MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ONE_TO_MANY; >+ } >+ >+ // M:1 >+ if (type == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.MANY_TO_ONE; >+ } >+ >+ // 1:1 >+ if (type == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ONE_TO_ONE; >+ } >+ >+ // Version >+ if (type == MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.VERSION; >+ } >+ >+ // Element Collection >+ if (type == MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ELEMENT_COLLECTION; >+ } >+ >+ // Basic Collection >+// if (type == EclipseLinkMappingKeys.BASIC_COLLECTION_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.BASIC_COLLECTION; >+// } >+// >+// // Basic Map >+// if (type == EclipseLinkMappingKeys.BASIC_MAP_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.BASIC_MAP; >+// } >+// >+// // Transformation >+// if (type == EclipseLinkMappingKeys.TRANSFORMATION_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.TRANSFORMATION; >+// } >+// >+// // Variable 1:1 >+// if (type == EclipseLinkMappingKeys.VARIABLE_ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.VARIABLE_ONE_TO_ONE; >+// } >+ >+ return IMappingType.TRANSIENT; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ StringBuilder sb = new StringBuilder(); >+ StringTools.buildSimpleToStringOn(this, sb); >+ sb.append("name="); >+ sb.append(getName()); >+ sb.append(", mappingType="); >+ sb.append(getMappingType()); >+ return sb.toString(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.Iterator; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.context.Entity; >+import org.eclipse.jpt.jpa.core.context.MappingFile; >+import org.eclipse.jpt.jpa.core.context.PersistentType; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+ >+/** >+ * The concrete implementation that is wrapping the design-time representation of a mapping file. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+public class JpaMappingFile extends JpaManagedTypeProvider { >+ >+ /** >+ * Creates a new <code>JpaMappingFile</code>. >+ * >+ * @param jpaProject The project that gives access to the application's metadata >+ * @param persistentTypeContainer The design-time provider of managed types >+ */ >+ public JpaMappingFile(JpaProject jpaProject, MappingFile persistentTypeContainer) { >+ super(jpaProject, persistentTypeContainer); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ JpaEntity buildEntity(TypeMapping mappedClass) { >+ return new JpaOrmEntity(this, (Entity) mappedClass); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected MappingFile getPersistentTypeContainer() { >+ return (MappingFile) super.getPersistentTypeContainer(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Iterator<? extends PersistentType> persistenceTypes() { >+ return getPersistentTypeContainer().getPersistentTypes().iterator(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,104 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedType; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedTypeProvider; >+import org.eclipse.persistence.jpa.jpql.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.jpa.jpql.spi.IMapping; >+import org.eclipse.persistence.jpa.jpql.spi.IType; >+ >+/** >+ * The concrete implementation of {@link IManagedType} that is wrapping the design-time >+ * representation a "null" managed type. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaNullManagedType implements IManagedType { >+ >+ /** >+ * The provider of JPA managed types. >+ */ >+ private final JpaManagedTypeProvider provider; >+ >+ /** >+ * The cached {@link IType} of this "null" managed type. >+ */ >+ private IType type; >+ >+ /** >+ * The design-time model object wrapped by this class. >+ */ >+ private final TypeMapping typeMapping; >+ >+ /** >+ * Creates a new <code>JpaNullManagedType</code>. >+ * >+ * @param managedType The provider of JPA managed types >+ * @param typeMapping The design-time model object wrapped by this class >+ */ >+ JpaNullManagedType(JpaManagedTypeProvider provider, TypeMapping typeMapping) { >+ super(); >+ this.provider = provider; >+ this.typeMapping = typeMapping; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int compareTo(IManagedType managedType) { >+ return getType().getName().compareTo(managedType.getType().getName()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IMapping getMappingNamed(String name) { >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedTypeProvider getProvider() { >+ return provider; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IType getType() { >+ if (type == null) { >+ type = provider.getTypeRepository().getType(typeMapping.getPersistentType().getName()); >+ } >+ return type; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterable<IMapping> mappings() { >+ return EmptyIterable.instance(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaOrmEntity.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaOrmEntity.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaOrmEntity.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaOrmEntity.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,59 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0, which accompanies this distribution >+ * and is available at http://www.eclipse.org/legal/epl-v10.html. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.ListIterator; >+import java.util.Map; >+import org.eclipse.jpt.jpa.core.context.Entity; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping; >+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; >+import org.eclipse.persistence.jpa.jpql.spi.IQuery; >+ >+/** >+ * The concrete implementation of {@link IEntity} that is wrapping the design-time representation >+ * of a JPA entity defined in an ORM configuration. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaOrmEntity extends JpaEntity { >+ >+ /** >+ * Creates a new <code>JpaOrmEntity</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param entity The design-time model object wrapped by this class >+ */ >+ JpaOrmEntity(JpaMappingFile provider, Entity entity) { >+ super(provider, entity); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ void initializeQueries(Map<String, IQuery> queries) { >+ super.initializeQueries(queries); >+ >+ JpaManagedTypeProvider provider = getProvider(); >+ OrmPersistentType type = (OrmPersistentType) getManagedType().getPersistentType(); >+ JavaTypeMapping mapping = type.getJavaPersistentType().getMapping(); >+ >+ if (mapping instanceof Entity) { >+ Entity entity = (Entity) mapping; >+ for (ListIterator<NamedQuery> iter = entity.getQueryContainer().namedQueries(); iter.hasNext(); ) { >+ NamedQuery namedQuery = iter.next(); >+ queries.put(namedQuery.getName(), buildQuery(provider, namedQuery)); >+ } >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.Iterator; >+import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator; >+import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.context.Entity; >+import org.eclipse.jpt.jpa.core.context.PersistentType; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; >+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; >+ >+/** >+ * The concrete implementation that is wrapping the design-time representation of a persistence unit. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+public final class JpaPersistenceUnit extends JpaManagedTypeProvider { >+ >+ /** >+ * Creates a new <code>JpaPersistenceUnit</code>. >+ * >+ * @param jpaProject The project that gives access to the application's metadata >+ * @param persistentUnit The design-time persistence unit >+ */ >+ public JpaPersistenceUnit(JpaProject jpaProject, PersistenceUnit persistentUnit) { >+ super(jpaProject, persistentUnit); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ JpaEntity buildEntity(TypeMapping mappedClass) { >+ return new JpaPersistenceUnitEntity(this, (Entity) mappedClass); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ PersistenceUnit getPersistentTypeContainer() { >+ return (PersistenceUnit) super.getPersistentTypeContainer(); >+ } >+ >+ @SuppressWarnings("unchecked") >+ private Iterator<ClassRef> javaClassRefs() { >+ return new CompositeIterator<ClassRef>( >+ getPersistentTypeContainer().specifiedClassRefs(), >+ getPersistentTypeContainer().impliedClassRefs() >+ ); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ Iterator<? extends PersistentType> persistenceTypes() { >+ return new TransformationIterator<ClassRef, PersistentType>(javaClassRefs()) { >+ @Override >+ protected PersistentType transform(ClassRef classRef) { >+ return classRef.getJavaPersistentType(); >+ } >+ }; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnitEntity.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnitEntity.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnitEntity.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnitEntity.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0, which accompanies this distribution >+ * and is available at http://www.eclipse.org/legal/epl-v10.html. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.jpa.core.context.Entity; >+ >+/** >+ * The concrete implementation of {@link IEntity} that is wrapping the design-time representation >+ * of a JPA entity defined in a persistence unit. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaPersistenceUnitEntity extends JpaEntity { >+ >+ /** >+ * Creates a new <code>JpaPersistenceUnitEntity</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param entity The design-time model object wrapped by this class >+ */ >+ JpaPersistenceUnitEntity(JpaManagedTypeProvider provider, Entity entity) { >+ super(provider, entity); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,115 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.persistence.jpa.jpql.spi.IQuery; >+ >+/** >+ * The concrete implementation of {@link IQuery} that is wrapping the design-time representation >+ * of a JPQL query. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+public final class JpaQuery implements IQuery { >+ >+ /** >+ * The actual JPQL query, which can differ from the one owned by the model object, which happens >+ * when the model is out of sync because it has not been updated yet. >+ */ >+ private String actualQuery; >+ >+ /** >+ * The provider of managed types. >+ */ >+ private JpaManagedTypeProvider provider; >+ >+ /** >+ * The model object holding onto the JPQL query. >+ */ >+ private NamedQuery query; >+ >+ /** >+ * Creates a new <code>JpaQuery</code>. >+ * >+ * @param provider The provider of managed types >+ * @param query The model object of the JPQL query >+ */ >+ public JpaQuery(JpaManagedTypeProvider provider, NamedQuery query) { >+ this(provider, query, query.getQuery()); >+ } >+ >+ /** >+ * Creates a new <code>JpaQuery</code>. >+ * >+ * @param provider The provider of managed types >+ * @param query The model object of the JPQL query >+ * @param actualQuery The actual JPQL query, which can differ from the one owned by the model >+ * object, which happens when the model is out of sync because it has not been updated yet >+ */ >+ JpaQuery(JpaManagedTypeProvider provider, NamedQuery query, String actualQuery) { >+ super(); >+ initialize(provider, query, actualQuery); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getExpression() { >+ return actualQuery; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaManagedTypeProvider getProvider() { >+ return provider; >+ } >+ >+ /** >+ * Returns the encapsulated {@link NamedQuery}, which is the actual object. >+ * >+ * @return The design-time representation of a JPQL query >+ */ >+ NamedQuery getQuery() { >+ return query; >+ } >+ >+ private void initialize(JpaManagedTypeProvider provider, NamedQuery query, String actualQuery) { >+ >+ this.query = query; >+ this.provider = provider; >+ this.actualQuery = actualQuery; >+ >+ if (this.actualQuery == null) { >+ this.actualQuery = StringTools.EMPTY_STRING; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ StringBuilder sb = new StringBuilder(); >+ sb.append(super.toString()); >+ sb.append(", query="); >+ sb.append(getExpression()); >+ return sb.toString(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,361 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.lang.annotation.Annotation; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.List; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.jdt.core.IField; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.ITypeHierarchy; >+import org.eclipse.jdt.core.dom.AST; >+import org.eclipse.jdt.core.dom.ASTNode; >+import org.eclipse.jdt.core.dom.ASTParser; >+import org.eclipse.jdt.core.dom.ASTVisitor; >+import org.eclipse.jdt.core.dom.MethodDeclaration; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.persistence.jpa.jpql.ExpressionTools; >+import org.eclipse.persistence.jpa.jpql.spi.IConstructor; >+import org.eclipse.persistence.jpa.jpql.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link org.eclipse.persistence.jpa.query.spi.IType IType} that is >+ * wrapping the design-time representation of a Java type. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaType implements org.eclipse.persistence.jpa.jpql.spi.IType { >+ >+ /** >+ * The cached collection of {@link IConstructor constructors}. >+ */ >+ private Collection<IConstructor> constructors; >+ >+ /** >+ * The list of names for the {@link Enum}'s constants otherwise an empty array. >+ */ >+ private String[] enumConstants; >+ >+ /** >+ * The actual Java type. >+ */ >+ private Class<?> javaType; >+ >+ /** >+ * The design-time representation of a Java type. >+ */ >+ private IType type; >+ >+ /** >+ * Caches the type hierarchy of the {@link IType} in order to prevent rebuilding it each time. >+ */ >+ private ITypeDeclaration typeDeclaration; >+ >+ /** >+ * Caches the type hierarchy of the {@link IType} in order to prevent rebuilding it each time >+ * {@link #isAssignableTo(org.eclipse.persistence.jpa.query.spi.IType)} is called. >+ */ >+ private ITypeHierarchy typeHierarchy; >+ >+ /** >+ * The fully qualified name of the Java type. >+ */ >+ private final String typeName; >+ >+ /** >+ * The external form of a type repository. >+ */ >+ private final JpaTypeRepository typeRepository; >+ >+ /** >+ * Creates a new <code>JpaType</code>. >+ * >+ * @param typeRepository The external form of a type repository >+ * @param javaType The actual Java type >+ */ >+ JpaType(JpaTypeRepository typeRepository, Class<?> javaType) { >+ this(typeRepository, javaType.getName()); >+ this.javaType = javaType; >+ } >+ >+ /** >+ * Creates a new <code>JpaType</code>. >+ * >+ * @param typeRepository The external form of a type repository >+ * @param type The design-time representation of a Java type >+ */ >+ JpaType(JpaTypeRepository typeRepository, IType type) { >+ this(typeRepository, type.getFullyQualifiedName()); >+ this.type = type; >+ } >+ >+ /** >+ * Creates a new <code>JpaType</code>. >+ * >+ * @param typeRepository The external form of a type repository >+ * @param typeName The fully qualified name of the Java type >+ */ >+ JpaType(JpaTypeRepository typeRepository, String typeName) { >+ super(); >+ this.typeName = typeName; >+ this.typeRepository = typeRepository; >+ } >+ >+ private ASTNode buildASTNode() { >+ >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ >+ if (type.getElementType() == IJavaElement.CLASS_FILE) { >+ parser.setSource(type.getClassFile()); >+ } >+ else { >+ parser.setSource(type.getTypeRoot()); >+ } >+ >+ parser.setIgnoreMethodBodies(true); // we don't need method bodies >+ parser.setResolveBindings(true); >+ parser.setBindingsRecovery(true); // see bugs 196200, 222735 >+ >+ return parser.createAST(new NullProgressMonitor()); >+ } >+ >+ private IConstructor buildConstructor(MethodDeclaration method) { >+ return new JpaConstructor(typeRepository, method); >+ } >+ >+ private Collection<IConstructor> buildConstructors() { >+ >+ if (type == null) { >+ return Collections.emptyList(); >+ } >+ >+ final Collection<IConstructor> constructors = new ArrayList<IConstructor>(); >+ ASTNode astNode = buildASTNode(); >+ >+ astNode.accept(new ASTVisitor() { >+ @Override >+ public boolean visit(MethodDeclaration node) { >+ if (node.isConstructor()) { >+ constructors.add(buildConstructor(node)); >+ } >+ return true; >+ } >+ }); >+ >+ return constructors; >+ } >+ >+ private String[] buildEnumConstants() { >+ >+ try { >+ if ((type != null) && type.isEnum()) { >+ >+ List<String> names = new ArrayList<String>(); >+ >+ for (IField field : type.getFields()) { >+ if (field.isEnumConstant()) { >+ names.add(field.getElementName()); >+ } >+ } >+ >+ return names.toArray(new String[names.size()]); >+ } >+ } >+ catch (Exception e) { >+ // Just ignore and return an empty array >+ } >+ >+ return ExpressionTools.EMPTY_STRING_ARRAY; >+ } >+ >+ private ITypeDeclaration buildTypeDeclaration() { >+ return new JpaTypeDeclaration(this, new ITypeDeclaration[0], false); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterable<IConstructor> constructors() { >+ if (constructors == null) { >+ constructors = buildConstructors(); >+ } >+ return Collections.unmodifiableCollection(constructors); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean equals(Object object) { >+ return (this == object) || equals((org.eclipse.persistence.jpa.jpql.spi.IType) object); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean equals(org.eclipse.persistence.jpa.jpql.spi.IType type) { >+ return (this == type) || typeName.equals(type.getName()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String[] getEnumConstants() { >+ if (enumConstants == null) { >+ enumConstants = buildEnumConstants(); >+ } >+ return enumConstants; >+ } >+ >+ /** >+ * Returns the encapsulated Java {@link Class}, which is the actual type. >+ * >+ * @return The actual Java type >+ */ >+ Class<?> getJavaType() { >+ return javaType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getName() { >+ return typeName; >+ } >+ >+ /** >+ * Returns the encapsulated {@link Type}, which is the actual type. >+ * >+ * @return The design-time representation of a Java type >+ */ >+ IType getType() { >+ return type; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration getTypeDeclaration() { >+ if (typeDeclaration == null) { >+ typeDeclaration = buildTypeDeclaration(); >+ } >+ return typeDeclaration; >+ } >+ >+ /** >+ * Returns the repository that gives access to the application's classes. >+ * >+ * @return The external form of the type repository >+ */ >+ JpaTypeRepository getTypeRepository() { >+ return typeRepository; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean hasAnnotation(Class<? extends Annotation> annotationType) { >+ >+ if (type != null) { >+ return type.getAnnotation(annotationType.getName()) != null; >+ } >+ >+ if (javaType != null) { >+ return javaType.isAnnotationPresent(annotationType); >+ } >+ >+ return false; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public int hashCode() { >+ return typeName.hashCode(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isAssignableTo(org.eclipse.persistence.jpa.jpql.spi.IType type) { >+ >+ if (this == type) { >+ return true; >+ } >+ >+ JpaType jpaType = (JpaType) type; >+ >+ // Dealing with two IType >+ if ((this.type != null) && (jpaType.type != null)) { >+ try { >+ // TODO: Use ASTTools.typeIsSubTypeOf() instead >+ if (typeHierarchy == null) { >+ typeHierarchy = this.type.newTypeHierarchy(new NullProgressMonitor()); >+ } >+ return typeHierarchy.contains(jpaType.type); >+ } >+ catch (Exception e) { >+ return false; >+ } >+ } >+ >+ // Dealing with two Class<?> >+ if ((javaType != null) && (jpaType.javaType != null)) { >+ return jpaType.javaType.isAssignableFrom(javaType); >+ } >+ >+ // Anything else is always false >+ return false; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isEnum() { >+ >+ if (javaType != null) { >+ return javaType.isEnum(); >+ } >+ >+ try { >+ return (type != null) ? type.isEnum() : false; >+ } >+ catch (Exception e) { >+ // Simply ignore and return no >+ return false; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isResolvable() { >+ return (type != null) || (javaType != null); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ return StringTools.buildToStringFor(this, typeName); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.persistence.jpa.jpql.spi.IType; >+import org.eclipse.persistence.jpa.jpql.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link ITypeDeclaration} that is wrapping the design-time >+ * representation of the declaration description of a type. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaTypeDeclaration implements ITypeDeclaration { >+ >+ /** >+ * Determines whether this type represents an array or not. >+ */ >+ private boolean array; >+ >+ /** >+ * The generics of the given type or an empty list if the type is not parameterized. >+ */ >+ private final ITypeDeclaration[] genericTypes; >+ >+ /** >+ * The external form of the Java type. >+ */ >+ private final IType type; >+ >+ /** >+ * Creates a new <code>JpaTypeDeclaration</code>. >+ * >+ * @param type The external form of the Java type >+ * @param genericTypes The generics of the given type or an empty list if the type is not >+ * parameterized >+ * @param array Determines whether this type represents an array or not >+ */ >+ JpaTypeDeclaration(IType type, ITypeDeclaration[] genericTypes, boolean array) { >+ super(); >+ this.type = type; >+ this.genericTypes = genericTypes; >+ this.array = array; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int getDimensionality() { >+ return array ? 1 : 0; // TODO >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IType getType() { >+ return type; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration[] getTypeParameters() { >+ return genericTypes; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isArray() { >+ return array; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ return type.getName(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,309 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.HashMap; >+import java.util.Map; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.persistence.jpa.jpql.TypeHelper; >+import org.eclipse.persistence.jpa.jpql.spi.IType; >+import org.eclipse.persistence.jpa.jpql.spi.ITypeRepository; >+ >+/** >+ * The concrete implementation of {@link ITypeRepository} that is wrapping the design-time >+ * representation of a type repository. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+final class JpaTypeRepository implements ITypeRepository { >+ >+ /** >+ * The Java project that gives access the design-time objects representing the Java types. >+ */ >+ private final IJavaProject javaProject; >+ >+ /** >+ * Keeps a map of the primitives for fast access. >+ */ >+ private Map<String, Class<?>> primitives; >+ >+ /** >+ * The cached helper that is using this repository for retrieving {@link IType types}. >+ */ >+ private TypeHelper typeHelper; >+ >+ /** >+ * The types that have been cached for faster access. >+ */ >+ private final Map<String, JpaType> types; >+ >+ /** >+ * The {@link IType} that represents a unresolvable or simply an unknown type, which is created >+ * when {@link #getType(String)} is invoked with {@link IType#UNRESOLVABLE_TYPE}. >+ */ >+ private JpaType unresolvableType; >+ >+ /** >+ * Creates a new <code>JpaTypeRepository</code>. >+ * >+ * @param javaProject The Java project that gives access the design-time objects representing >+ * the Java types >+ */ >+ JpaTypeRepository(IJavaProject javaProject) { >+ super(); >+ this.javaProject = javaProject; >+ this.types = new HashMap<String, JpaType>(); >+ } >+ >+ private Map<String, Class<?>> buildPrimitives() { >+ Map<String, Class<?>> primitives = new HashMap<String, Class<?>>(); >+ primitives.put(Byte .TYPE.getName(), Byte .TYPE); >+ primitives.put(Short .TYPE.getName(), Short .TYPE); >+ primitives.put(Character.TYPE.getName(), Character.TYPE); >+ primitives.put(Integer .TYPE.getName(), Integer .TYPE); >+ primitives.put(Long .TYPE.getName(), Long .TYPE); >+ primitives.put(Float .TYPE.getName(), Float .TYPE); >+ primitives.put(Double .TYPE.getName(), Double .TYPE); >+ primitives.put(Boolean .TYPE.getName(), Boolean .TYPE); >+ return primitives; >+ } >+ >+ private JpaType buildType(Class<?> javaType) { >+ JpaType jpaType = new JpaType(this, javaType); >+ types.put(jpaType.getName(), jpaType); >+ return jpaType; >+ } >+ >+ private JpaType buildType(org.eclipse.jdt.core.IType type) { >+ JpaType jpaType = new JpaType(this, type); >+ types.put(jpaType.getName(), jpaType); >+ return jpaType; >+ } >+ >+ private JpaType buildType(String typeName) { >+ return new JpaType(this, typeName); >+ } >+ >+ private Class<?> findPrimitive(String typeName) { >+ if (primitives == null) { >+ primitives = buildPrimitives(); >+ } >+ return primitives.get(typeName); >+ } >+ >+ /** >+ * Retrieves the design-time Java type for the given type name, which has to be the fully >+ * qualified type name. >+ * >+ * @param typeName The fully qualified type name >+ * @return The design-time Java type if it could be retrieved; <code>null</code> otherwise >+ */ >+ private org.eclipse.jdt.core.IType findType(String typeName) { >+ try { >+ return javaProject.findType(typeName); >+ } >+ catch (JavaModelException e) { >+ return null; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaType getEnumType(String enumTypeName) { >+ >+ // Get the position of the last dot so we can remove the constant >+ int lastDotIndex = enumTypeName.lastIndexOf("."); >+ >+ if (lastDotIndex == -1) { >+ return null; >+ } >+ >+ // Retrieve the fully qualified enum type name >+ String typeName = enumTypeName.substring(0, lastDotIndex); >+ >+ // Attempt to load the enum type >+ JpaType type = getType(typeName); >+ return type.isEnum() ? type: null; >+ } >+ >+ /** >+ * Returns >+ * >+ * @return >+ */ >+ IJavaProject getJavaProject() { >+ return javaProject; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaType getType(Class<?> javaClass) { >+ return getType(javaClass.getName()); >+ } >+ >+ /** >+ * Retrieves the {@link org.eclipse.jdt.core.IType IType} for the given {@link IResource}. >+ * >+ * @param resource The workspace location of the {@link org.eclipse.jdt.core.IType IType} to >+ * retrieve >+ * @return The design-time representation of a Java type >+ */ >+ org.eclipse.jdt.core.IType getType(IResource resource) { >+ try { >+ return (org.eclipse.jdt.core.IType) javaProject.findElement((IPath) resource); >+ } >+ catch (Exception e) { >+ return null; >+ } >+ } >+ >+ /** >+ * Retrieves the {@link org.eclipse.jdt.core.IType IType} for the given {@link IResource}. >+ * >+ * @param resource The workspace location of the {@link org.eclipse.jdt.core.IType IType} to >+ * retrieve >+ * @return The design-time representation of a Java type >+ */ >+ IType getType(org.eclipse.jdt.core.IType type) { >+ try { >+ IType jpaType = types.get(type.getFullyQualifiedName()); >+ if (jpaType == null) { >+ jpaType = buildType(type); >+ } >+ return jpaType; >+ } >+ catch (Exception e) { >+ return null; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaType getType(String typeName) { >+ >+ if (IType.UNRESOLVABLE_TYPE == typeName) { >+ return unresolvableType(); >+ } >+ >+ if (typeName.charAt(0) == '[') { >+ return loadArrayType(typeName); >+ } >+ >+ return loadTypeImp(typeName); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public TypeHelper getTypeHelper() { >+ if (typeHelper == null) { >+ typeHelper = new TypeHelper(this); >+ } >+ return typeHelper; >+ } >+ >+ private JpaType loadArrayType(String typeName) { >+ >+ JpaType type = types.get(typeName); >+ >+ if (type == null) { >+ try { >+ // Try to see if the type is a JDK class, otherwise, just use the type name >+ // since IType doesn't support array types >+ type = buildType(Class.forName(typeName)); >+ } >+ catch (Exception e) { >+ type = buildType(typeName); >+ } >+ >+ types.put(typeName, type); >+ } >+ >+ return type; >+ } >+ >+ private JpaType loadInnerType(String typeName) { >+ >+ int index = typeName.lastIndexOf("."); >+ >+ if (index == -1) { >+ return null; >+ } >+ >+ StringBuilder sb = new StringBuilder(); >+ sb.append(typeName.substring(0, index)); >+ sb.append("$"); >+ sb.append(typeName.substring(index + 1, typeName.length())); >+ typeName = sb.toString(); >+ >+ JpaType type = types.get(typeName); >+ >+ if (type == null) { >+ type = loadTypeImp(typeName); >+ } >+ >+ return type; >+ } >+ >+ private JpaType loadTypeImp(String typeName) { >+ >+ JpaType type = types.get(typeName); >+ >+ // The type was already cached, simply return it >+ if (type != null) { >+ return type; >+ } >+ >+ // First check for primitive, they don't have a corresponding IType >+ Class<?> primitive = findPrimitive(typeName); >+ >+ if (primitive != null) { >+ return buildType(primitive); >+ } >+ >+ // Attempt to load the Java type >+ org.eclipse.jdt.core.IType iType = findType(typeName); >+ >+ // A Java type exists, return it >+ if (iType != null) { >+ return buildType(iType); >+ } >+ >+ // Now try with a possible inner enum type >+ type = loadInnerType(typeName); >+ >+ // No Java type exists, create a "null" IType >+ if (type == null) { >+ type = buildType(typeName); >+ } >+ >+ return type; >+ } >+ >+ private JpaType unresolvableType() { >+ if (unresolvableType == null) { >+ unresolvableType = new JpaType(this, IType.UNRESOLVABLE_TYPE); >+ } >+ return unresolvableType; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java,v >retrieving revision 1.4 >diff -u -r1.4 JpaValidationMessages.java >--- src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java 3 Mar 2011 00:01:17 -0000 1.4 >+++ src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidationMessages.java 15 Mar 2011 01:56:30 -0000 >@@ -3,7 +3,7 @@ > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ >@@ -13,7 +13,7 @@ > public interface JpaValidationMessages { > > public static final String BUNDLE_NAME = "jpa_validation"; >- >+ > public static final String PROJECT_INVALID_LIBRARY_PROVIDER = "PROJECT_INVALID_LIBRARY_PROVIDER"; > public static final String PROJECT_NO_CONNECTION = "PROJECT_NO_CONNECTION"; > public static final String PROJECT_INVALID_CONNECTION = "PROJECT_INVALID_CONNECTION"; >@@ -43,6 +43,7 @@ > public static final String GENERATOR_NAME_UNDEFINED = "GENERATOR_NAME_UNDEFINED"; > public static final String QUERY_DUPLICATE_NAME = "QUERY_DUPLICATE_NAME"; > public static final String QUERY_NAME_UNDEFINED = "QUERY_NAME_UNDEFINED"; >+ public static final String JPQL_QUERY_VALIDATION = "JPQL_QUERY_VALIDATION"; > public static final String QUERY_STATEMENT_UNDEFINED = "QUERY_STATEMENT_UNDEFINED"; > public static final String MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA = "MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA"; > public static final String PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT = "PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT"; >@@ -158,7 +159,7 @@ > public static final String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_NAME = "VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_NAME"; > public static final String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_CATALOG = "VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_CATALOG"; > public static final String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_SCHEMA = "VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_SCHEMA"; >- >+ > public static final String GENERATED_VALUE_UNRESOLVED_GENERATOR = "GENERATED_VALUE_UNRESOLVED_GENERATOR"; > public static final String PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME = "PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_NAME"; > public static final String PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS = "PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS"; >@@ -176,7 +177,7 @@ > public static final String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME = "VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_UNRESOLVED_REFERENCED_COLUMN_NAME"; > public static final String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS = "VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS"; > public static final String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS = "VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS"; >- >+ > public static final String NO_JPA_PROJECT = "NO_JPA_PROJECT"; > public static final String TARGET_ENTITY_NOT_DEFINED = "TARGET_ENTITY_NOT_DEFINED"; > public static final String VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED = "VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED"; >@@ -186,7 +187,7 @@ > public static final String ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM = "ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM"; > public static final String ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM = "ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM"; > public static final String TARGET_NOT_AN_EMBEDDABLE = "TARGET_NOT_AN_EMBEDDABLE"; >- >+ > public static final String COLUMN_TABLE_NOT_VALID="COLUMN_TABLE_NOT_VALID"; > public static final String VIRTUAL_ATTRIBUTE_COLUMN_TABLE_NOT_VALID="VIRTUAL_ATTRIBUTE_COLUMN_TABLE_NOT_VALID"; > public static final String VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID="VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID"; >@@ -228,5 +229,4 @@ > public static final String VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID="VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID"; > public static final String MAP_KEY_COLUMN_TABLE_NOT_VALID="MAP_KEY_COLUMN_TABLE_NOT_VALID"; > public static final String VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID="VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID"; >- >-} >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedNativeQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedNativeQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 XmlNamedNativeQuery.java >--- src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedNativeQuery.java 6 Feb 2011 02:07:20 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedNativeQuery.java 15 Mar 2011 01:56:30 -0000 >@@ -3,7 +3,7 @@ > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ >@@ -29,7 +29,7 @@ > /** > * <!-- begin-user-doc --> > * A representation of the model object '<em><b>Named Native Query</b></em>'. >- * >+ * > * Provisional API: This interface is part of an interim API that is still > * under development and expected to change significantly before reaching > * stability. It is available at this early stage to solicit feedback from >@@ -538,11 +538,15 @@ > result.append(')'); > return result.toString(); > } >- >+ > public TextRange getNameTextRange() { > return getAttributeTextRange(JPA.NAME); > } >- >+ >+ public TextRange getQueryTextRange() { >+ return getAttributeTextRange(JPA.QUERY); >+ } >+ > // ********** translators ********** > > public static Translator buildTranslator(String elementName, EStructuralFeature structuralFeature) { >@@ -563,23 +567,23 @@ > protected static Translator buildNameTranslator() { > return new Translator(JPA.NAME, OrmPackage.eINSTANCE.getXmlQuery_Name(), Translator.DOM_ATTRIBUTE); > } >- >+ > protected static Translator buildResultClassTranslator() { > return new Translator(JPA.RESULT_CLASS, OrmPackage.eINSTANCE.getXmlNamedNativeQuery_ResultClass(), Translator.DOM_ATTRIBUTE); > } >- >+ > protected static Translator buildResultSetMappingTranslator() { > return new Translator(JPA.RESULT_SET_MAPPING, OrmPackage.eINSTANCE.getXmlNamedNativeQuery_ResultSetMapping(), Translator.DOM_ATTRIBUTE); > } >- >+ > protected static Translator buildDescriptionTranslator() { > return new Translator(JPA2_0.DESCRIPTION, OrmV2_0Package.eINSTANCE.getXmlQuery_2_0_Description()); > } >- >+ > protected static Translator buildQueryTranslator() { > return new Translator(JPA.QUERY, OrmPackage.eINSTANCE.getXmlQuery_Query()); > } >- >+ > protected static Translator buildHintTranslator() { > return XmlQueryHint.buildTranslator(JPA.HINT, OrmPackage.eINSTANCE.getXmlQuery_Hints()); > } >Index: src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 XmlNamedQuery.java >--- src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedQuery.java 6 Feb 2011 02:07:20 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/resource/orm/XmlNamedQuery.java 15 Mar 2011 01:56:30 -0000 >@@ -3,7 +3,7 @@ > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ >@@ -19,6 +19,7 @@ > import org.eclipse.emf.ecore.impl.ENotificationImpl; > import org.eclipse.emf.ecore.util.EObjectContainmentEList; > import org.eclipse.emf.ecore.util.InternalEList; >+import org.eclipse.jpt.common.core.internal.utility.SimpleTextRange; > import org.eclipse.jpt.common.core.internal.utility.translators.SimpleTranslator; > import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.jpa.core.resource.orm.v2_0.JPA2_0; >@@ -27,11 +28,12 @@ > import org.eclipse.jpt.jpa.core.resource.orm.v2_0.XmlNamedQuery_2_0; > import org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaEObject; > import org.eclipse.wst.common.internal.emf.resource.Translator; >+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; > > /** > * <!-- begin-user-doc --> > * A representation of the model object '<em><b>Named Query</b></em>'. >- * >+ * > * Provisional API: This interface is part of an interim API that is still > * under development and expected to change significantly before reaching > * stability. It is available at this early stage to solicit feedback from >@@ -503,11 +505,31 @@ > result.append(')'); > return result.toString(); > } >- >+ > public TextRange getNameTextRange() { > return getAttributeTextRange(JPA.NAME); > } >- >+ >+ public TextRange getQueryTextRange() { >+ // <named-query> >+ IDOMNode node = getElementNode(JPA.QUERY); >+ if (node != null) { >+ // The query element has text >+ if (node.hasChildNodes()) { >+ return buildTextRange((IDOMNode) node.getFirstChild()); >+ } >+ // The query element does not have text >+ TextRange textRange = buildTextRange(node); >+ return new SimpleTextRange( >+ node.getEndStructuredDocumentRegion().getStartOffset(), >+ 0, >+ textRange.getLineNumber() >+ ); >+ } >+ >+ return this.getValidationTextRange(); >+ } >+ > // ********** translators ********** > > public static Translator buildTranslator(String elementName, EStructuralFeature structuralFeature) { >@@ -527,15 +549,15 @@ > protected static Translator buildNameTranslator() { > return new Translator(JPA.NAME, OrmPackage.eINSTANCE.getXmlQuery_Name(), Translator.DOM_ATTRIBUTE); > } >- >+ > protected static Translator buildDescriptionTranslator() { > return new Translator(JPA2_0.DESCRIPTION, OrmV2_0Package.eINSTANCE.getXmlQuery_2_0_Description()); > } >- >+ > protected static Translator buildQueryTranslator() { > return new Translator(JPA.QUERY, OrmPackage.eINSTANCE.getXmlQuery_Query()); > } >- >+ > protected static Translator buildLockModeTranslator() { > return new Translator(JPA2_0.NAMED_QUERY__LOCK_MODE, OrmV2_0Package.eINSTANCE.getXmlNamedQuery_2_0_LockMode()); > } >Index: src/org/eclipse/jpt/jpa/core/resource/orm/XmlQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/orm/XmlQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 XmlQuery.java >--- src/org/eclipse/jpt/jpa/core/resource/orm/XmlQuery.java 6 Feb 2011 02:07:20 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/resource/orm/XmlQuery.java 15 Mar 2011 01:56:30 -0000 >@@ -3,7 +3,7 @@ > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ >@@ -16,7 +16,7 @@ > /** > * <!-- begin-user-doc --> > * A representation of the model object '<em><b>Query</b></em>'. >- * >+ * > * Provisional API: This interface is part of an interim API that is still > * under development and expected to change significantly before reaching > * stability. It is available at this early stage to solicit feedback from >@@ -106,6 +106,8 @@ > * @generated > */ > EList<XmlQueryHint> getHints(); >- >- public TextRange getNameTextRange(); >+ >+ TextRange getNameTextRange(); >+ >+ TextRange getQueryTextRange(); > } >#P org.eclipse.jpt.jpa.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.3 >diff -u -r1.3 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Feb 2011 17:58:29 -0000 1.3 >+++ META-INF/MANIFEST.MF 15 Mar 2011 01:56:32 -0000 >@@ -32,6 +32,7 @@ > org.eclipse.jst.common.project.facet.ui;bundle-version="[1.3.100,2.0.0)", > org.eclipse.jst.j2ee;bundle-version="[1.1.200,2.0.0)", > org.eclipse.jst.j2ee.ui;bundle-version="[1.1.200,2.0.0)", >+ org.eclipse.persistence.jpa.jpql;bundle-version="1.0.0", > org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ui.views.properties.tabbed;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ui.navigator;bundle-version="[3.3.100,4.0.0)", >@@ -64,6 +65,7 @@ > org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.connection;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.options;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.jpa2.platform.generic;x-internal:=true, >+ org.eclipse.jpt.jpa.ui.internal.jpql;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.listeners;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.menus;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.navigator;x-internal:=true, >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 9 Feb 2011 21:19:08 -0000 1.4 >+++ plugin.xml 15 Mar 2011 01:56:31 -0000 >@@ -69,10 +69,9 @@ > <partition type="__dftl_partition_content_type"/> > <partition type="__java_string"/> > </javaCompletionProposalComputer> >- >+ > </extension> >- >- >+ > <extension > point="org.eclipse.jdt.ui.javaCompletionProposalComputer" > id="jpaProposalCategory" >@@ -80,8 +79,36 @@ > <proposalCategory > icon="$nl$/icons/full/eview16/jpa_perspective.gif"/> > </extension> >- >- >+ >+ <extension >+ point="org.eclipse.jdt.ui.javaCompletionProposalComputer" >+ id="JpaJpqlCompletionProposalComputer"> >+ >+ <javaCompletionProposalComputer >+ activate="true" >+ categoryId="org.eclipse.jpt.jpa.ui.jpaProposalCategory" >+ class="org.eclipse.jpt.jpa.ui.internal.jpql.JpaJpqlJavaCompletionProposalComputer"> >+ <partition type="__dftl_partition_content_type"/> >+ <partition type="__java_string"/> >+ </javaCompletionProposalComputer> >+ >+ </extension> >+ >+ <extension >+ id="JpaJpqlSseCompletionProposal" >+ point="org.eclipse.wst.sse.ui.completionProposal"> >+ <proposalComputer >+ activate="true" >+ categoryId="org.eclipse.wst.xml.ui.proposalCategory.xmlTags" >+ class="org.eclipse.jpt.jpa.ui.internal.jpql.JpaJpqlSseCompletionProposalComputer" >+ id="org.eclipse.jpt.jpa.ui.internal.jpql.JpaJpqlSseCompletionProposalComputer"> >+ <contentType >+ id="org.eclipse.jpt.jpa.core.content.orm"> >+ </contentType> >+ </proposalComputer> >+ </extension> >+ >+ > <extension > point="org.eclipse.jpt.jpa.ui.jpaPlatformUis"> > >@@ -94,7 +121,7 @@ > id="generic2_0.ui" > jpaPlatform="generic2_0" > factoryClass="org.eclipse.jpt.jpa.ui.internal.jpa2.platform.generic.Generic2_0JpaPlatformUiFactory"/> >- >+ > </extension> > > >Index: property_files/jpt_ui.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties,v >retrieving revision 1.2 >diff -u -r1.2 jpt_ui.properties >--- property_files/jpt_ui.properties 1 Mar 2011 16:07:29 -0000 1.2 >+++ property_files/jpt_ui.properties 15 Mar 2011 01:56:32 -0000 >@@ -126,6 +126,10 @@ > JpaProblemSeveritiesPage_Info=Info > JpaProblemSeveritiesPage_Warning=Warning > >+JpqlContentProposalProvider_Description=Content Assist Available ({0}) >+JpaJpqlJavaCompletionProposalComputer_Error=Can't retrieve JPQL proposals due to an internal error. >+JpaJpqlSseCompletionProposalComputer_Error=Can't retrieve JPQL proposals due to an internal error. >+ > MappingFileWizard_title=New Mapping File > MappingFileWizardPage_newFile_title=Mapping file > MappingFileWizardPage_newFile_desc=Specify mapping file name and location >Index: property_files/jpt_ui_jpql_identifiers.properties >=================================================================== >RCS file: property_files/jpt_ui_jpql_identifiers.properties >diff -N property_files/jpt_ui_jpql_identifiers.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ property_files/jpt_ui_jpql_identifiers.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,25 @@ >+################################################################################ >+# Copyright (c) 2011 Oracle. All rights reserved. >+# This program and the accompanying materials are made available under the >+# terms of the Eclipse Public License v1.0, which accompanies this distribution >+# and is available at http://www.eclipse.org/legal/epl-v10.html. >+# >+# Contributors: >+# Oracle - initial API and implementation >+################################################################################ >+ >+ABS=The <b>ABS</b> function removes the minus sign from a specified argument and returns the absolute value, which is always a positive number or zero.<p><p>The <b>ABS</b> function takes a numeric argument and returns a number (integer, float, or double) of the same type as the argument to the function. >+ALL=An <b>ALL</b> conditional expression is a predicate that is <code>true</code> if the comparison operation is <code>true</code> for all values in the result of the subquery or the result of the subquery is empty. An <b>ALL</b> conditional expression is <code>false</code> if the result of the comparison is <code>false</code> for at least one row, and is unknown if neither <code>true</code> nor <code>false</code>. The comparison operators used with <b>ALL</b> conditional expressions are =, <, <=, >, >=, <>. The result of the subquery must be like that of the other argument to the comparison operator in type. >+AND= >+ANY=An <b>ANY</b> conditional expression is a predicate that is <code>true</code> if the comparison operation is <code>true</code> for some value in the result of the subquery. An <b>ANY</b> conditional expression is <code>false</code> if the result of the subquery is empty or if the comparison operation is <code>false</code> for every value in the result of the subquery, and is unknown if neither <code>true</code> nor <code>false</code>. The comparison operators used with <b>ANY</b> conditional expressions are =, <, <=, >, >=, <>. The result of the subquery must be like that of the other argument to the comparison operator in type. >+AVG=One of the aggregate functions. The arguments must be numeric. <b>AVG</b> returns <code>Double</code>. >+BETWEEN=Used in conditional expression to determine whether the result of an expression falls within an inclusive range of values. Numeric, string and date expression can be evaluated in this way. >+CASE= >+COALESCE=A <b>COALESCE</b> expression returns <code>null</code> if all its arguments evaluate to <code>null</code>, and the value of the first non-<code>null</code> argument otherwise.<p><p>The return type is the type returned by the arguments if they are all of the same type, otherwise it is undetermined. >+DELETE_FROM=A delete statement provide bulk operations over sets of entities. >+IN=An identification variable declared by a collection member declaration ranges over values of a collection obtained by navigation using a path expression. Such a path expression represents a navigation involving the association-fields of an entity abstract schema type. Because a path expression can be based on another path expression, the navigation can use the association-fields of related entities. An identification variable of a collection member declaration is declared using a special operator, the reserved identifier <b>IN</b>. The argument to the <b>IN</b> operator is a collection-valued path expression. The path expression evaluates to a collection type specified as a result of navigation to a collection-valued association-field of an entity abstract schema type. >+MEMBER= >+OR= >+SELECT=The <b>SELECT</b> clause determines the type of the objects or values to be selected. >+SOME=A <b>SOME</b> conditional expression is a predicate that is <code>true</code> if the comparison operation is <code>true</code> for some value in the result of the subquery. An <b>ANY</b> conditional expression is <code>false</code> if the result of the subquery is empty or if the comparison operation is <code>false</code> for every value in the result of the subquery, and is unknown if neither <code>true</code> nor <code>false</code>. The comparison operators used with <b>SOME</b> conditional expressions are =, <, <=, >, >=, <>. The result of the subquery must be like that of the other argument to the comparison operator in type. >+UPDATE=An update statement provide bulk operations over sets of entities. >Index: property_files/jpt_ui_validation_preferences.properties >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_validation_preferences.properties,v >retrieving revision 1.1 >diff -u -r1.1 jpt_ui_validation_preferences.properties >--- property_files/jpt_ui_validation_preferences.properties 6 Feb 2011 02:26:36 -0000 1.1 >+++ property_files/jpt_ui_validation_preferences.properties 15 Mar 2011 01:56:32 -0000 >@@ -209,3 +209,4 @@ > ID_MAPPING_UNRESOLVED_GENERATOR_NAME=Unresolved generator name: > GENERATED_VALUE_UNRESOLVED_GENERATOR=Generator is not defined in the persistence unit: > QUERY_DUPLICATE_NAME=Duplicate query defined: >+JPQL_QUERY_VALIDATION=Invalid or incomplete JPQL queries: >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/JptUiIcons.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiIcons.java,v >retrieving revision 1.1 >diff -u -r1.1 JptUiIcons.java >--- src/org/eclipse/jpt/jpa/ui/internal/JptUiIcons.java 6 Feb 2011 02:26:31 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/JptUiIcons.java 15 Mar 2011 01:56:32 -0000 >@@ -124,4 +124,13 @@ > public static final String TRANSIENT = "full/obj16/transient"; > > public static final String NULL_ATTRIBUTE_MAPPING = "full/obj16/null-attribute-mapping"; >-} >+ >+ >+ // **************** Content Assist icons ********************************** >+ >+ public static final String JPQL_FUNCTION = "full/obj16/jpql.function"; >+ >+ public static final String JPQL_IDENTIFIER = "full/obj16/jpql.identifier"; >+ >+ public static final String JPQL_VARIABLE = "full/obj16/jpql.variable"; >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java,v >retrieving revision 1.1 >diff -u -r1.1 JptUiMessages.java >--- src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java 6 Feb 2011 02:26:31 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java 15 Mar 2011 01:56:33 -0000 >@@ -92,6 +92,8 @@ > public static String JpaFacetWizardPage_title; > public static String JpaFacetWizardPage_userLibsLink; > public static String JpaFacetWizardPage_userServerLibLabel; >+ public static String JpaJpqlJavaCompletionProposalComputer_Error; >+ public static String JpaJpqlSseCompletionProposalComputer_Error; > public static String JpaLibraryProviderInstallPanel_includeLibraries; > public static String JpaMakePersistentWizardPage_title; > public static String JpaMakePersistentWizardPage_message; >@@ -110,6 +112,7 @@ > public static String JpaStructureView_linkWithEditorTooltip; > public static String JpaStructureView_structureNotAvailable; > public static String JpaStructureView_numItemsSelected; >+ public static String JpqlContentProposalProvider_Description; > public static String MappingFileWizard_title; > public static String MappingFileWizardPage_newFile_title; > public static String MappingFileWizardPage_newFile_desc; >@@ -140,7 +143,7 @@ > public static String JpaProblemSeveritiesPage_Warning; > public static String SelectJpaOrmMappingFileDialog_newButton; > >- >+ > private static final String BUNDLE_NAME = "jpt_ui"; //$NON-NLS-1$ > private static final Class<?> BUNDLE_CLASS = JptUiMessages.class; > static { >Index: src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java,v >retrieving revision 1.1 >diff -u -r1.1 JptUiValidationPreferenceMessages.java >--- src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java 6 Feb 2011 02:26:31 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/JptUiValidationPreferenceMessages.java 15 Mar 2011 01:56:33 -0000 >@@ -1,9 +1,9 @@ > /******************************************************************************* >- * Copyright (c) 2009, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2009, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >- * >+ * > * Contributors: > * Oracle - initial API and implementation > ******************************************************************************/ >@@ -19,9 +19,9 @@ > public static String PROJECT_INVALID_CONNECTION; > public static String PROJECT_INACTIVE_CONNECTION; > public static String PROJECT_NO_PERSISTENCE_XML; >- >+ > public static String XML_VERSION_NOT_LATEST; >- >+ > public static String PROJECT_MULTIPLE_PERSISTENCE_XML; > public static String PERSISTENCE_NO_PERSISTENCE_UNIT; > public static String PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS; >@@ -82,13 +82,13 @@ > public static String ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED; > public static String ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE; > public static String ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED; >- >+ > public static String DATABASE_CATEGORY; > public static String TABLE_CATEGORY; > public static String COLUMN_CATEGORY; > public static String OVERRIDES_CATEGORY; > public static String IMPLIED_ATTRIBUTE_LEVEL_CATEGORY; >- >+ > public static String TABLE_UNRESOLVED_CATALOG; > public static String TABLE_UNRESOLVED_SCHEMA; > public static String TABLE_UNRESOLVED_NAME; >@@ -125,12 +125,12 @@ > public static String VIRTUAL_SECONDARY_TABLE_PRIMARY_KEY_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; > public static String MAP_KEY_COLUMN_TABLE_NOT_VALID; > public static String VIRTUAL_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; >- >+ > public static String COLLECTION_TABLE_UNRESOLVED_CATALOG; > public static String COLLECTION_TABLE_UNRESOLVED_SCHEMA; > public static String COLLECTION_TABLE_UNRESOLVED_NAME; > public static String ORDER_COLUMN_UNRESOLVED_NAME; >- >+ > public static String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_CATALOG; > public static String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA; > public static String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME; >@@ -170,7 +170,7 @@ > public static String VIRTUAL_ATTRIBUTE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_JOIN_COLUMNS; > public static String VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID; > public static String VIRTUAL_ATTRIBUTE_MAP_KEY_ATTRIBUTE_OVERRIDE_COLUMN_TABLE_NOT_VALID; >- >+ > public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_CATALOG; > public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_SCHEMA; > public static String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_TABLE_UNRESOLVED_NAME; >@@ -205,6 +205,7 @@ > public static String ID_MAPPING_UNRESOLVED_GENERATOR_NAME; > public static String GENERATED_VALUE_UNRESOLVED_GENERATOR; > public static String QUERY_DUPLICATE_NAME; >+ public static String JPQL_QUERY_VALIDATION; > > private static final String BUNDLE_NAME = "jpt_ui_validation_preferences"; //$NON-NLS-1$ > private static final Class<?> BUNDLE_CLASS = JptUiValidationPreferenceMessages.class; >@@ -215,6 +216,4 @@ > private JptUiValidationPreferenceMessages() { > throw new UnsupportedOperationException(); > } >- >- >-} >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/details/NamedQueryPropertyComposite.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/NamedQueryPropertyComposite.java,v >retrieving revision 1.1 >diff -u -r1.1 NamedQueryPropertyComposite.java >--- src/org/eclipse/jpt/jpa/ui/internal/details/NamedQueryPropertyComposite.java 6 Feb 2011 02:26:32 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/details/NamedQueryPropertyComposite.java 15 Mar 2011 01:56:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2009 Oracle. All rights reserved. >+ * Copyright (c) 2008, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -15,10 +15,12 @@ > import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; > import org.eclipse.jpt.jpa.core.context.NamedQuery; > import org.eclipse.jpt.jpa.core.context.Query; >+import org.eclipse.jpt.jpa.ui.internal.jpql.JpqlContentProposalProvider; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.widgets.Composite; > > /** >- * Here the layout of this pane: >+ * Here's the layout of this pane: > * <pre> > * ----------------------------------------------------------------------------- > * | ------------------------------------------------------------------ | >@@ -40,11 +42,11 @@ > * @see NamedQueriesComposite - The parent container > * @see QueryHintsComposite > * >- * @version 2.0 >- * @since 2.0 >+ * @version 2.3 >+ * @since 2.3 > */ >-public class NamedQueryPropertyComposite<T extends NamedQuery> extends Pane<T> >-{ >+public class NamedQueryPropertyComposite<T extends NamedQuery> extends Pane<T> { >+ > /** > * Creates a new <code>NamedQueryPropertyComposite</code>. > * >@@ -59,6 +61,24 @@ > super(parentPane, subjectHolder, parent); > } > >+ protected WritablePropertyValueModel<String> buildNameTextHolder() { >+ return new PropertyAspectAdapter<NamedQuery, String>( >+ getSubjectHolder(), Query.NAME_PROPERTY) { >+ @Override >+ protected String buildValue_() { >+ return this.subject.getName(); >+ } >+ >+ @Override >+ protected void setValue_(String value) { >+ if (value.length() == 0) { >+ value = null; >+ } >+ this.subject.setName(value); >+ } >+ }; >+ } >+ > protected WritablePropertyValueModel<String> buildQueryHolder() { > return new PropertyAspectAdapter<NamedQuery, String>(getSubjectHolder(), Query.QUERY_PROPERTY) { > @Override >@@ -73,6 +93,9 @@ > }; > } > >+ /** >+ * {@inheritDoc} >+ */ > @Override > protected void initializeLayout(Composite container) { > >@@ -82,7 +105,7 @@ > buildNameTextHolder()); > > // Query text area >- addLabeledMultiLineText( >+ StyledText text = addLabeledMultiLineStyledText( > container, > JptUiDetailsMessages.NamedQueryPropertyComposite_query, > buildQueryHolder(), >@@ -90,6 +113,8 @@ > null > ); > >+ new JpqlContentProposalProvider(getSubjectHolder(), text); >+ > // Query Hints pane > container = addTitledGroup( > addSubPane(container, 5), >@@ -98,22 +123,4 @@ > > new QueryHintsComposite(this, container); > } >- >- protected WritablePropertyValueModel<String> buildNameTextHolder() { >- return new PropertyAspectAdapter<NamedQuery, String>( >- getSubjectHolder(), Query.NAME_PROPERTY) { >- @Override >- protected String buildValue_() { >- return this.subject.getName(); >- } >- >- @Override >- protected void setValue_(String value) { >- if (value.length() == 0) { >- value = null; >- } >- this.subject.setName(value); >- } >- }; >- } > } >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/details/QueriesComposite.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/QueriesComposite.java,v >retrieving revision 1.1 >diff -u -r1.1 QueriesComposite.java >--- src/org/eclipse/jpt/jpa/ui/internal/details/QueriesComposite.java 6 Feb 2011 02:26:32 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/details/QueriesComposite.java 15 Mar 2011 01:56:33 -0000 >@@ -17,8 +17,8 @@ > import org.eclipse.jface.window.Window; > import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher; > import org.eclipse.jpt.common.ui.internal.widgets.AddRemoveListPane; >-import org.eclipse.jpt.common.ui.internal.widgets.Pane; > import org.eclipse.jpt.common.ui.internal.widgets.AddRemovePane.Adapter; >+import org.eclipse.jpt.common.ui.internal.widgets.Pane; > import org.eclipse.jpt.common.utility.internal.CollectionTools; > import org.eclipse.jpt.common.utility.internal.Transformer; > import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel; >@@ -75,7 +75,7 @@ > { > private AddRemoveListPane<QueryContainer> listPane; > NamedNativeQueryPropertyComposite namedNativeQueryPane; >- NamedQueryPropertyComposite<? extends NamedQuery> namedQueryPane; >+ Pane<? extends NamedQuery> namedQueryPane; > private WritablePropertyValueModel<Query> queryHolder; > > >@@ -295,7 +295,7 @@ > installPaneSwitcher(pageBook); > } > >- protected NamedQueryPropertyComposite<? extends NamedQuery> buildNamedQueryPropertyComposite(PageBook pageBook) { >+ protected Pane<? extends NamedQuery> buildNamedQueryPropertyComposite(PageBook pageBook) { > return new NamedQueryPropertyComposite<NamedQuery>( > this, > this.buildNamedQueryHolder(), >Index: src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java,v >retrieving revision 1.1 >diff -u -r1.1 NamedQueryProperty2_0Composite.java >--- src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java 6 Feb 2011 02:26:34 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/NamedQueryProperty2_0Composite.java 15 Mar 2011 01:56:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2009 Oracle. All rights reserved. >+* Copyright (c) 2009, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -10,18 +10,49 @@ > package org.eclipse.jpt.jpa.ui.internal.jpa2.details; > > import org.eclipse.jpt.common.ui.internal.widgets.Pane; >+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter; > import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; >+import org.eclipse.jpt.common.utility.model.value.WritablePropertyValueModel; >+import org.eclipse.jpt.jpa.core.context.Query; > import org.eclipse.jpt.jpa.core.jpa2.context.NamedQuery2_0; > import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages; >-import org.eclipse.jpt.jpa.ui.internal.details.NamedQueryPropertyComposite; > import org.eclipse.jpt.jpa.ui.internal.details.QueryHintsComposite; >+import org.eclipse.jpt.jpa.ui.internal.jpql.JpqlContentProposalProvider; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.widgets.Composite; > > /** >- * NamedQueryProperty2_0Composite >+ * Here's the layout of this pane: >+ * <pre> >+ * ----------------------------------------------------------------------------- >+ * | -------------------------------------------------------------- | >+ * | Query: | I | | >+ * | | | | >+ * | | | | >+ * | -------------------------------------------------------------- | >+ * | -------------------------------------------------------------- | >+ * | Lock Mode: | |v| | >+ * | -------------------------------------------------------------- | >+ * | | >+ * | - Query Hints ----------------------------------------------------------- | >+ * | | --------------------------------------------------------------------- | | >+ * | | | | | | >+ * | | | QueryHintsComposite | | | >+ * | | | | | | >+ * | | --------------------------------------------------------------------- | | >+ * | ------------------------------------------------------------------------- | >+ * -----------------------------------------------------------------------------</pre> >+ * >+ * >+ * @see NamedQuery2_0 >+ * @see NamedQueriesComposite - The parent container >+ * @see QueryHintsComposite >+ * >+ * @version 2.0 >+ * @since 2.0 > */ >-public class NamedQueryProperty2_0Composite extends NamedQueryPropertyComposite<NamedQuery2_0> >-{ >+public class NamedQueryProperty2_0Composite extends Pane<NamedQuery2_0> { >+ > /** > * Creates a new <code>NamedQueryProperty2_0Composite</code>. > * >@@ -30,12 +61,46 @@ > * @param parent The parent container > */ > public NamedQueryProperty2_0Composite(Pane<?> parentPane, >- PropertyValueModel<NamedQuery2_0> subjectHolder, >- Composite parent) { >+ PropertyValueModel<NamedQuery2_0> subjectHolder, >+ Composite parent) { > > super(parentPane, subjectHolder, parent); > } > >+ protected WritablePropertyValueModel<String> buildNameTextHolder() { >+ return new PropertyAspectAdapter<NamedQuery2_0, String>(getSubjectHolder(), Query.NAME_PROPERTY) { >+ @Override >+ protected String buildValue_() { >+ return this.subject.getName(); >+ } >+ >+ @Override >+ protected void setValue_(String value) { >+ if (value.length() == 0) { >+ value = null; >+ } >+ this.subject.setName(value); >+ } >+ }; >+ } >+ >+ protected WritablePropertyValueModel<String> buildQueryHolder() { >+ return new PropertyAspectAdapter<NamedQuery2_0, String>(getSubjectHolder(), Query.QUERY_PROPERTY) { >+ @Override >+ protected String buildValue_() { >+ return this.subject.getQuery(); >+ } >+ >+ @Override >+ protected void setValue_(String value) { >+ this.subject.setQuery(value); >+ } >+ }; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ > @Override > protected void initializeLayout(Composite container) { > >@@ -45,7 +110,7 @@ > this.buildNameTextHolder()); > > // Query text area >- this.addLabeledMultiLineText( >+ StyledText text = this.addLabeledMultiLineStyledText( > container, > JptUiDetailsMessages.NamedQueryPropertyComposite_query, > this.buildQueryHolder(), >@@ -53,6 +118,9 @@ > null > ); > >+ new JpqlContentProposalProvider(getSubjectHolder(), text); >+ >+ // Lock Mode type > new LockModeComposite(this, container); > > // Query Hints pane >@@ -63,5 +131,4 @@ > > new QueryHintsComposite(this, container); > } >- >-} >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Queries2_0Composite.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Queries2_0Composite.java,v >retrieving revision 1.1 >diff -u -r1.1 Queries2_0Composite.java >--- src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Queries2_0Composite.java 6 Feb 2011 02:26:34 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/Queries2_0Composite.java 15 Mar 2011 01:56:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2009 Oracle. All rights reserved. >+* Copyright (c) 2009, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -12,11 +12,9 @@ > import org.eclipse.jpt.common.ui.internal.widgets.Pane; > import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel; > import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; >-import org.eclipse.jpt.jpa.core.context.NamedQuery; > import org.eclipse.jpt.jpa.core.context.Query; > import org.eclipse.jpt.jpa.core.context.QueryContainer; > import org.eclipse.jpt.jpa.core.jpa2.context.NamedQuery2_0; >-import org.eclipse.jpt.jpa.ui.internal.details.NamedQueryPropertyComposite; > import org.eclipse.jpt.jpa.ui.internal.details.QueriesComposite; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.part.PageBook; >@@ -35,9 +33,8 @@ > super(parentPane, subjectHolder, parent); > } > >- > @Override >- protected NamedQueryPropertyComposite<NamedQuery2_0> buildNamedQueryPropertyComposite(PageBook pageBook) { >+ protected Pane<NamedQuery2_0> buildNamedQueryPropertyComposite(PageBook pageBook) { > return new NamedQueryProperty2_0Composite( > this, > this.buildNamedQuery2_0Holder(), >@@ -48,8 +45,8 @@ > return new TransformationPropertyValueModel<Query, NamedQuery2_0>(this.getQueryHolder()) { > @Override > protected NamedQuery2_0 transform_(Query value) { >- return (value instanceof NamedQuery) ? (NamedQuery2_0) value : null; >+ return (value instanceof NamedQuery2_0) ? (NamedQuery2_0) value : null; > } > }; > } >-} >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlCompletionProposalComputer.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlCompletionProposalComputer.java >diff -N src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlCompletionProposalComputer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlCompletionProposalComputer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,422 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.ui.internal.jpql; >+ >+import java.lang.reflect.Field; >+import java.util.ArrayList; >+import java.util.Comparator; >+import java.util.List; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.ui.PreferenceConstants; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.resource.ImageRegistry; >+import org.eclipse.jpt.common.utility.internal.CollectionTools; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; >+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; >+import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; >+import org.eclipse.persistence.jpa.internal.jpql.parser.Expression; >+import org.eclipse.persistence.jpa.internal.jpql.parser.IdentifierRole; >+import org.eclipse.persistence.jpa.internal.jpql.parser.JPQLExpression; >+import org.eclipse.persistence.jpa.jpql.ContentAssistItems; >+import org.eclipse.persistence.jpa.jpql.spi.IEntity; >+import org.eclipse.persistence.jpa.jpql.spi.IMapping; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Display; >+ >+import static org.eclipse.jpt.common.utility.internal.CollectionTools.*; >+ >+/** >+ * The abstract definition of JPQL content assist support. >+ * <p> >+ * TODO: Add style to the display string by implementing ICompletionProposalExtension6. >+ * StyledString.QUALIFIER_STYLER >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings({"nls", "restriction"}) >+abstract class JpaJpqlCompletionProposalComputer<T> { >+ >+ /** >+ * The current value of the query element. >+ */ >+ String actualQuery; >+ >+ /** >+ * Flag used to determine if the word following the cursor should be overwritten or not. >+ */ >+ boolean completionInserts; >+ >+ /** >+ * The provider of content assist items based on the position of the cursor within the JPQL query. >+ */ >+ ContentAssistItems contentAssistItems; >+ >+ /** >+ * The local registry containing the images used to display the possible choices. The registry is >+ * disposed when the session ended. >+ */ >+ private ImageRegistry imageRegistry; >+ >+ /** >+ * This helper is responsible to retrieve the possible choices to complete or to add more >+ * information to a JPQL based on the position of the cursor. >+ */ >+ JpaJpqlQueryHelper queryHelper; >+ >+ /** >+ * Creates a new <code>JpaJpqlCompletionProposalComputer</code>. >+ */ >+ public JpaJpqlCompletionProposalComputer() { >+ super(); >+ } >+ >+ /** >+ * Adds completion proposals for the abstract schema types that are possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new completion proposals >+ */ >+ private void addAbstractSchemaTypes(String query, int position, int offset, List<T> proposals) { >+ for (IEntity abstractSchemaType : sortByNames(contentAssistItems.abstractSchemaTypes())) { >+ T proposal = buildAbstractSchemaTypeProposal(query, abstractSchemaType, position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ /** >+ * Adds completion proposals for the identification variables that are possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new completion proposals >+ */ >+ private void addIdentificationVariables(String query, int position, int offset, List<T> proposals) { >+ for (String choice : sort(contentAssistItems.identificationVariables())) { >+ T proposal = buildIdentificationVariableProposal(query, choice, position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ /** >+ * Adds completion proposals for the JPQL identifiers that are possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new completion proposals >+ */ >+ private void addIdentifiers(String query, int position, int offset, List<T> proposals) { >+ for (String choice : sort(contentAssistItems.identifiers())) { >+ T proposal = buildIdentifierProposal(query, choice, position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ final String additionalInfo(String choice) { >+ try { >+ // Convert the choice into a valid constant >+ if (choice.endsWith("()")) { >+ choice = choice.substring(0, choice.length() - 2); >+ } >+ choice = choice.replace(" ", "_"); >+ >+ // Retrieve the constant's value >+ Field constant = JpqlIdentifierMessages.class.getField(choice); >+ return (String) constant.get(null); >+ } >+ catch (Exception e) { >+ // The choice is not a JPQL identifier >+ return null; >+ } >+ } >+ >+ /** >+ * Adds completion proposals for the state fields and association fields that are possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new completion proposals >+ */ >+ private void addMappings(String query, int position, int offset, List<T> proposals) { >+ for (IMapping mapping : sort(contentAssistItems.mappings())) { >+ T proposal = buildMappingProposal(query, mapping, position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ private T buildAbstractSchemaTypeProposal(String query, >+ IEntity abstractSchemaType, >+ int position, >+ int offset) { >+ >+ String choice = abstractSchemaType.getName(); >+ return buildProposal(query, choice, choice, entityImage(), position, offset); >+ } >+ >+ private Comparator<IEntity> buildEntityNameComparator() { >+ return new Comparator<IEntity>() { >+ public int compare(IEntity entity1, IEntity entity2) { >+ return entity1.getName().compareTo(entity2.getName()); >+ } >+ }; >+ } >+ >+ private String buildIdentificationVariableDisplayString(String identificationVariable) { >+ >+ IEntity abstractSchemaType = contentAssistItems.getAbstractSchemaType(identificationVariable); >+ >+ if (abstractSchemaType != null) { >+ StringBuilder sb = new StringBuilder(); >+ sb.append(identificationVariable); >+ sb.append(" : "); >+ sb.append(abstractSchemaType.getName()); >+ identificationVariable = sb.toString(); >+ } >+ >+ return identificationVariable; >+ } >+ >+ private T buildIdentificationVariableProposal(String query, String choice, int position, int offset) { >+ return buildProposal( >+ query, >+ choice, >+ buildIdentificationVariableDisplayString(choice), >+ identificationVariableImage(), >+ position, >+ offset >+ ); >+ } >+ >+ private T buildIdentifierProposal(String query, String choice, int position, int offset) { >+ >+ IdentifierRole role = JPQLExpression.identifierRole(choice); >+ boolean realFunction = (role == IdentifierRole.FUNCTION) && isRealFunction(choice); >+ int cursorOffset = 0; >+ >+ // For JPQL function, we add () to the display string, example: AVG() >+ // But for TRUE, FALSE, etc, we don't add () >+ if (realFunction) { >+ choice += "()"; >+ cursorOffset--; >+ } >+ >+ return buildProposal( >+ query, >+ choice, >+ choice, >+ identifierImage(role, realFunction), >+ position, >+ offset, >+ cursorOffset >+ ); >+ } >+ >+ private T buildMappingProposal(String query, IMapping mapping, int position, int offset) { >+ String choice = mapping.getName(); >+ return buildProposal(query, choice, choice, mappingImage(mapping), position, offset); >+ } >+ >+ private T buildProposal(String query, >+ String choice, >+ String displayString, >+ Image image, >+ int position, >+ int offset) { >+ >+ return buildProposal(query, choice, displayString, image, position, offset, 0); >+ } >+ >+ /** >+ * Creates a new completion proposal for the given choice. >+ * >+ * @param query The model object may sometimes be out of sync with the actual content, the actual >+ * query is required for proper content assist >+ * @param choice A valid choice that can be inserted into the query >+ * @param displayString The human readable string of the choice >+ * @param image The image that represents the choice >+ * @param position The position of the cursor within the query >+ * @param offset The beginning of the string within the document >+ * @param cursorOffset An offset that moves the cursor backward or forward after it is adjusted >+ * based on the given choice >+ * @return The completion proposal >+ */ >+ abstract T buildProposal(String query, >+ String choice, >+ String displayString, >+ Image image, >+ int position, >+ int offset, >+ int cursorOffset); >+ >+ /** >+ * Creates the list of completion proposals based on the current content of the JPQL query and at >+ * the specified position. >+ * >+ * @param namedQuery The model object used to access the application metadata information >+ * @param actualQuery The model object may sometimes be out of sync with the actual content, the >+ * actual query is required for proper content assist >+ * @param offset The beginning of the string within the document >+ * @param position The position of the cursor within the query, which starts at the beginning of >+ * that query and not the document >+ * @return The list of completion proposals >+ */ >+ final List<T> buildProposals(NamedQuery namedQuery, >+ String actualQuery, >+ int offset, >+ int position) { >+ >+ this.actualQuery = actualQuery; >+ this.completionInserts = isCompletionInserts(namedQuery.getJpaProject().getJavaProject()); >+ this.queryHelper = new JpaJpqlQueryHelper(namedQuery, actualQuery); >+ this.contentAssistItems = queryHelper.buildContentAssistItems(position); >+ >+ List<T> proposals = new ArrayList<T>(); >+ addAbstractSchemaTypes (actualQuery, position, offset, proposals); >+ addIdentificationVariables(actualQuery, position, offset, proposals); >+ addIdentifiers (actualQuery, position, offset, proposals); >+ addMappings (actualQuery, position, offset, proposals); >+ >+ return proposals; >+ } >+ >+ final void checkCanceled(IProgressMonitor monitor) throws InterruptedException { >+ if (monitor.isCanceled()) { >+ throw new InterruptedException(); >+ } >+ } >+ >+ private Image entityImage() { >+ return getImage(JptUiIcons.ENTITY); >+ } >+ >+ /** >+ * Returns the reason why this computer was unable to produce any completion proposals or >+ * context information. >+ * >+ * @return An error message or <code>null</code> if no error occurred >+ */ >+ public String getErrorMessage() { >+ return null; >+ } >+ >+ private Image getImage(String key) { >+ ImageRegistry imageRegistry = getImageRegistry(); >+ Image image = imageRegistry.get(key); >+ if (image == null) { >+ imageRegistry.put(key, getImageDescriptor(key)); >+ image = imageRegistry.get(key); >+ } >+ return image; >+ } >+ >+ private ImageDescriptor getImageDescriptor(String key) { >+ return JptJpaUiPlugin.getImageDescriptor(key); >+ } >+ >+ private ImageRegistry getImageRegistry() { >+ if (imageRegistry == null) { >+ imageRegistry = new ImageRegistry(Display.getCurrent()); >+ } >+ return imageRegistry; >+ } >+ >+ private Image identificationVariableImage() { >+ return getImage(JptUiIcons.JPQL_VARIABLE); >+ } >+ >+ @SuppressWarnings("fallthrough") >+ private Image identifierImage(IdentifierRole role, boolean realFunction) { >+ >+ if (role != null) { >+ switch (role) { >+ case FUNCTION: { >+ if (realFunction) { >+ return getImage(JptUiIcons.JPQL_FUNCTION); >+ } >+ } >+ default: { >+ return getImage(JptUiIcons.JPQL_IDENTIFIER); >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ private boolean isCompletionInserts(IJavaProject javaProject) { >+ String value = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, javaProject); >+ return Boolean.valueOf(value); >+ } >+ >+ private boolean isRealFunction(String identifier) { >+ return identifier != Expression.TRUE && >+ identifier != Expression.FALSE && >+ identifier != Expression.NULL && >+ identifier != Expression.CURRENT_DATE && >+ identifier != Expression.CURRENT_TIME && >+ identifier != Expression.CURRENT_TIMESTAMP; >+ } >+ >+ private Image mappingImage(IMapping mapping) { >+ switch (mapping.getMappingType()) { >+ case BASIC: return getImage(JptUiIcons.BASIC); >+ case BASIC_COLLECTION: return getImage(JptUiIcons.ELEMENT_COLLECTION); >+ case BASIC_MAP: return getImage(JptUiIcons.ELEMENT_COLLECTION); >+ case ELEMENT_COLLECTION: return getImage(JptUiIcons.ELEMENT_COLLECTION); >+ case EMBEDDED: return getImage(JptUiIcons.EMBEDDED); >+ case EMBEDDED_ID: return getImage(JptUiIcons.EMBEDDED_ID); >+ case ID: return getImage(JptUiIcons.ID); >+ case MANY_TO_MANY: return getImage(JptUiIcons.MANY_TO_MANY); >+ case MANY_TO_ONE: return getImage(JptUiIcons.MANY_TO_ONE); >+ case ONE_TO_MANY: return getImage(JptUiIcons.ONE_TO_MANY); >+ case ONE_TO_ONE: return getImage(JptUiIcons.ONE_TO_ONE); >+ case TRANSFORMATION: return getImage(JptUiIcons.TRANSIENT); // TODO >+ case VARIABLE_ONE_TO_ONE: return getImage(JptUiIcons.ONE_TO_ONE); // TODO >+ case VERSION: return getImage(JptUiIcons.VERSION); >+ default: return getImage(JptUiIcons.TRANSIENT); >+ } >+ } >+ >+ /** >+ * Informs the computer that a content assist session has ended. >+ */ >+ public void sessionEnded() { >+ >+ queryHelper = null; >+ contentAssistItems = null; >+ >+ if (imageRegistry != null) { >+ imageRegistry.dispose(); >+ } >+ } >+ >+ /** >+ * Informs the computer that a content assist session has started. >+ */ >+ public void sessionStarted() { >+ // Nothing to do >+ } >+ >+ private Iterable<IEntity> sortByNames(Iterable<IEntity> abstractSchemaTypes) { >+ return CollectionTools.sort(abstractSchemaTypes, buildEntityNameComparator()); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlJavaCompletionProposalComputer.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlJavaCompletionProposalComputer.java >diff -N src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlJavaCompletionProposalComputer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlJavaCompletionProposalComputer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,308 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.ui.internal.jpql; >+ >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.core.CompletionContext; >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.dom.ASTNode; >+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; >+import org.eclipse.jdt.core.dom.Annotation; >+import org.eclipse.jdt.core.dom.ArrayInitializer; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jdt.core.dom.IExtendedModifier; >+import org.eclipse.jdt.core.dom.MemberValuePair; >+import org.eclipse.jdt.core.dom.NormalAnnotation; >+import org.eclipse.jdt.core.dom.SingleMemberAnnotation; >+import org.eclipse.jdt.core.dom.StringLiteral; >+import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; >+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer; >+import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; >+import org.eclipse.jface.text.contentassist.CompletionProposal; >+import org.eclipse.jface.text.contentassist.ICompletionProposal; >+import org.eclipse.jface.text.contentassist.IContextInformation; >+import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools; >+import org.eclipse.jpt.common.core.utility.TextRange; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.jpa.core.JpaFile; >+import org.eclipse.jpt.jpa.core.JpaStructureNode; >+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.context.java.JavaEntity; >+import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery; >+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; >+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping; >+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; >+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; >+import org.eclipse.persistence.jpa.jpql.ExpressionTools; >+import org.eclipse.persistence.jpa.jpql.ResultQuery; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * This computer adds content assist support when it is invoked inside the query element of {@link >+ * javax.persistence.NamedQuery @NamedQuery}. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("restriction") >+public final class JpaJpqlJavaCompletionProposalComputer extends JpaJpqlCompletionProposalComputer<ICompletionProposal> >+ implements IJavaCompletionProposalComputer { >+ >+ /** >+ * Creates a new <code>JpaJpqlJavaCompletionProposalComputer</code>. >+ */ >+ public JpaJpqlJavaCompletionProposalComputer() { >+ super(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ ICompletionProposal buildProposal(String query, >+ String choice, >+ String displayString, >+ Image image, >+ int position, >+ int offset, >+ int cursorOffset) { >+ >+ ResultQuery result = contentAssistItems.buildEscapedQuery(query, choice, position, completionInserts); >+ >+ return new CompletionProposal( >+ result.getQuery(), // The new string that replaces the current string >+ offset + 1, // The start position of the current string to replace in the document >+ actualQuery.length(), // The length of the current string >+ result.getPosition() + cursorOffset, // The new position of the cursor >+ image, >+ displayString, >+ null, >+ additionalInfo(choice) >+ ); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, >+ IProgressMonitor monitor) { >+ >+ if (context instanceof JavaContentAssistInvocationContext) { >+ monitor.beginTask(null, 100); >+ try { >+ return computeCompletionProposals((JavaContentAssistInvocationContext) context, monitor); >+ } >+ catch (Exception e) { >+ Status status = new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, JptUiMessages.JpaJpqlJavaCompletionProposalComputer_Error, e); >+ JptJpaCorePlugin.log(status); >+ } >+ finally { >+ monitor.done(); >+ } >+ } >+ >+ return Collections.emptyList(); >+ } >+ >+ private List<ICompletionProposal> computeCompletionProposals(JavaContentAssistInvocationContext context, >+ IProgressMonitor monitor) throws Exception { >+ >+ CompletionContext completionContext = context.getCoreContext(); >+ >+ // The token "start" is the offset of the token's first character within the document. >+ // A token start of -1 can means: >+ // It is inside the string representation of a unicode character, \\u0|0E9 where | is the >+ // cursor, then -1 is returned; >+ // The string is not valid (it has some invalid characters) >+ int tokenStart = completionContext.getTokenStart(); >+ if (tokenStart == -1) return Collections.emptyList(); >+ >+ int[] position = { completionContext.getOffset() - tokenStart - 1 }; >+ if (position[0] < 0) return Collections.emptyList(); >+ >+ ICompilationUnit compilationUnit = context.getCompilationUnit(); >+ if (compilationUnit == null) return Collections.emptyList(); >+ CompilationUnit astRoot = ASTTools.buildASTRoot(compilationUnit); >+ >+ // Retrieve the actual value of the element "query" since the content assist can be >+ // invoked before the model received the new content >+ String jpqlQuery = retrieveQuery(astRoot, tokenStart, completionContext.getTokenEnd()); >+ >+ if (jpqlQuery == null) { >+ jpqlQuery = StringTools.EMPTY_STRING; >+ } >+ else { >+ jpqlQuery = jpqlQuery.substring(1, jpqlQuery.length() - 1); >+ jpqlQuery = ExpressionTools.unescape(jpqlQuery, position); >+ } >+ >+ IFile file = getCorrespondingResource(compilationUnit); >+ if (file == null) return Collections.emptyList(); >+ >+ JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); >+ if (jpaFile == null) return Collections.emptyList(); >+ >+ monitor.worked(80); >+ checkCanceled(monitor); >+ >+ // Retrieve the JPA's model object >+ NamedQuery namedQuery = namedQuery(astRoot, jpaFile, tokenStart); >+ if (namedQuery == null) return Collections.emptyList(); >+ >+ // Now create the proposals >+ return buildProposals(namedQuery, jpqlQuery, tokenStart, position[0]); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, >+ IProgressMonitor monitor) { >+ >+ return Collections.emptyList(); >+ } >+ >+ private NamedQuery findNamedQuery(JpaStructureNode structureNode, >+ CompilationUnit astRoot, >+ int tokenStart) { >+ >+ if (structureNode instanceof JavaPersistentType) { >+ JavaPersistentType persistentType = (JavaPersistentType) structureNode; >+ JavaTypeMapping typeMapping = persistentType.getMapping(); >+ >+ if (typeMapping instanceof JavaEntity) { >+ JavaEntity entity = (JavaEntity) typeMapping; >+ >+ for (Iterator<JavaNamedQuery> queries = entity.getQueryContainer().namedQueries(); queries.hasNext(); ) { >+ JavaNamedQuery namedQuery = queries.next(); >+ TextRange textRange = namedQuery.getQueryAnnotation().getQueryTextRange(astRoot); >+ >+ if (textRange.includes(tokenStart)) { >+ return namedQuery; >+ } >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ private IFile getCorrespondingResource(ICompilationUnit compilationUnit) { >+ try { >+ return (IFile) compilationUnit.getCorrespondingResource(); >+ } >+ catch (JavaModelException ex) { >+ JptJpaCorePlugin.log(ex); >+ return null; >+ } >+ } >+ >+ private boolean isInsideNode(ASTNode node, int tokenStart, int tokenEnd) { >+ int startPosition = node.getStartPosition(); >+ return startPosition <= tokenStart && >+ startPosition + node.getLength() >= tokenEnd; >+ } >+ >+ private NamedQuery namedQuery(CompilationUnit astRoot, JpaFile jpaFile, int tokenStart) { >+ >+ for (JpaStructureNode node : jpaFile.getRootStructureNodes()) { >+ NamedQuery namedQuery = findNamedQuery(node, astRoot, tokenStart); >+ if (namedQuery != null) { >+ return namedQuery; >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * This twisted code is meant to retrieve the real string value that is not escaped and to also >+ * retrieve the position within the non-escaped string. The query could have escape characters, >+ * such as \r, \n etc being written as \\r, \\n, the position is based on that escaped string, >+ * the conversion will convert them into \r and \r and adjust the position accordingly. >+ * >+ * @param astRoot The parsed tree representation of the Java source file >+ * @param tokenStart The beginning of the query expression of the {@link javax.persistence.NamedQuery >+ * @NamedQuery}'s query member within the source file >+ * @param tokenEnd The end of the query member within the source file >+ * @param position The position of the cursor within the query expression >+ * @return The actual value retrieved from the query element >+ */ >+ @SuppressWarnings("unchecked") >+ private String retrieveQuery(CompilationUnit astRoot, int tokenStart, int tokenEnd) { >+ >+ // Dig into the TypeDeclarations >+ for (AbstractTypeDeclaration type : (List<AbstractTypeDeclaration>) astRoot.types()) { >+ >+ if (isInsideNode(type, tokenStart, tokenEnd)) { >+ >+ // Dig inside its modifiers and annotations >+ for (IExtendedModifier modifier : (List<IExtendedModifier>) type.modifiers()) { >+ >+ if (!modifier.isAnnotation()) { >+ continue; >+ } >+ >+ Annotation annotation = (Annotation) modifier; >+ >+ // Dig inside the annotation >+ if (isInsideNode(annotation, tokenStart, tokenEnd)) { >+ >+ // @NamedQueries({...}) >+ if (annotation.isSingleMemberAnnotation()) { >+ SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation) annotation; >+ ArrayInitializer array = (ArrayInitializer) singleMemberAnnotation.getValue(); >+ >+ for (org.eclipse.jdt.core.dom.Expression expression : (List<org.eclipse.jdt.core.dom.Expression>) array.expressions()) { >+ if (isInsideNode(expression, tokenStart, tokenEnd)) { >+ return retrieveQuery((NormalAnnotation) expression, tokenStart, tokenEnd); >+ } >+ } >+ } >+ // @NamedQuery() >+ else if (annotation.isNormalAnnotation()) { >+ return retrieveQuery((NormalAnnotation) annotation, tokenStart, tokenEnd); >+ } >+ } >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ @SuppressWarnings("unchecked") >+ private String retrieveQuery(NormalAnnotation annotation, int tokenStart, int tokenEnd) { >+ >+ for (MemberValuePair pair : (List<MemberValuePair>) annotation.values()) { >+ org.eclipse.jdt.core.dom.Expression expression = pair.getValue(); >+ >+ if (isInsideNode(expression, tokenStart, tokenEnd)) { >+ StringLiteral literal = (StringLiteral) pair.getValue(); >+ return literal.getEscapedValue(); >+ } >+ } >+ >+ return null; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlSseCompletionProposalComputer.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlSseCompletionProposalComputer.java >diff -N src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlSseCompletionProposalComputer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlSseCompletionProposalComputer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,227 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.ui.internal.jpql; >+ >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; >+import org.eclipse.core.filebuffers.FileBuffers; >+import org.eclipse.core.filebuffers.ITextFileBuffer; >+import org.eclipse.core.filebuffers.ITextFileBufferManager; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.text.contentassist.CompletionProposal; >+import org.eclipse.jface.text.contentassist.ICompletionProposal; >+import org.eclipse.jface.text.contentassist.IContextInformation; >+import org.eclipse.jpt.common.core.utility.TextRange; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.jpa.core.JpaFile; >+import org.eclipse.jpt.jpa.core.JpaStructureNode; >+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.context.PersistentType; >+import org.eclipse.jpt.jpa.core.context.QueryContainer; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings; >+import org.eclipse.jpt.jpa.core.context.orm.OrmEntity; >+import org.eclipse.jpt.jpa.core.context.orm.OrmNamedQuery; >+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; >+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; >+import org.eclipse.persistence.jpa.jpql.ResultQuery; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; >+import org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer; >+ >+/** >+ * This computer adds content assist support when it is invoked inside the <query> element >+ * defined in a mapping file (ORM Configuration). >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+public final class JpaJpqlSseCompletionProposalComputer extends JpaJpqlCompletionProposalComputer<ICompletionProposal> >+ implements ICompletionProposalComputer { >+ >+ /** >+ * Keep track of the beginning of the text since the entire string is always replaced. >+ */ >+ private int tokenStart; >+ >+ /** >+ * Creates a new <code>JpaJpqlSseCompletionProposalComputer</code>. >+ */ >+ public JpaJpqlSseCompletionProposalComputer() { >+ super(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ ICompletionProposal buildProposal(String query, >+ String choice, >+ String displayString, >+ Image image, >+ int position, >+ int offset, >+ int cursorOffset) { >+ >+ ResultQuery result = contentAssistItems.buildQuery(query, choice, position, completionInserts); >+ >+ return new CompletionProposal( >+ result.getQuery(), // The new string that replaces the current string >+ tokenStart, // The start position of the current string to replace in the document >+ actualQuery.length(), // The length of the current string >+ result.getPosition() + cursorOffset, // The new position of the cursor >+ image, >+ displayString, >+ null, >+ additionalInfo(choice) >+ ); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public List<ICompletionProposal> computeCompletionProposals(CompletionProposalInvocationContext context, >+ IProgressMonitor monitor) { >+ >+ monitor.beginTask(null, 100); >+ >+ try { >+ int offset = context.getInvocationOffset(); >+ if (offset == -1) return Collections.emptyList(); >+ >+ ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); >+ ITextFileBuffer buffer = manager.getTextFileBuffer(context.getDocument()); >+ if (buffer == null) return Collections.emptyList(); >+ >+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); >+ IFile file = root.getFile(buffer.getLocation()); >+ >+ JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); >+ if (jpaFile == null) return Collections.emptyList(); >+ >+ monitor.worked(80); >+ checkCanceled(monitor); >+ >+ // Retrieve the JPA's model object >+ int[] position = new int[1]; >+ NamedQuery namedQuery = namedQuery(jpaFile, context.getInvocationOffset(), position); >+ if (namedQuery == null) return Collections.emptyList(); >+ >+ // Keep track of the beginning of the text since the entire string is always replaced >+ tokenStart = context.getInvocationOffset() - position[0]; >+ >+ // Now create the proposals >+ String query = retrieveQuery(namedQuery, position[0]); >+ return buildProposals(namedQuery, query, offset, position[0]); >+ } >+ catch (Exception e) { >+ Status status = new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, JptUiMessages.JpaJpqlSseCompletionProposalComputer_Error, e); >+ JptJpaCorePlugin.log(status); >+ } >+ finally { >+ monitor.done(); >+ } >+ >+ return Collections.emptyList(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public List<IContextInformation> computeContextInformation(CompletionProposalInvocationContext context, >+ IProgressMonitor monitor) { >+ >+ return Collections.emptyList(); >+ } >+ >+ private NamedQuery findNamedQuery(JpaStructureNode structureNode, int offset, int[] position) { >+ >+ if (structureNode instanceof EntityMappings) { >+ EntityMappings entityMappings = (EntityMappings) structureNode; >+ >+ // First look into the global queries >+ NamedQuery query = findNamedQuery(entityMappings.getQueryContainer(), offset, position); >+ >+ // Now traverse each entity >+ if (query != null) { >+ return query; >+ } >+ >+ for (PersistentType persistentType : entityMappings.getPersistentTypes()) { >+ TypeMapping typeMapping = persistentType.getMapping(); >+ >+ if (typeMapping instanceof OrmEntity) { >+ query = findNamedQuery(((OrmEntity) typeMapping).getQueryContainer(), offset, position); >+ >+ if (query != null) { >+ return query; >+ } >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ private NamedQuery findNamedQuery(QueryContainer container, int offset, int[] position) { >+ >+ for (Iterator<OrmNamedQuery> queries = container.namedQueries(); queries.hasNext(); ) { >+ OrmNamedQuery namedQuery = queries.next(); >+ TextRange textRange = namedQuery.getQueryTextRange(); >+ >+ if (textRange.touches(offset)) { >+ position[0] = offset - textRange.getOffset(); >+ return namedQuery; >+ } >+ } >+ >+ return null; >+ } >+ >+ private NamedQuery namedQuery(JpaFile jpaFile, int offset, int[] position) { >+ >+ for (JpaStructureNode node : jpaFile.getRootStructureNodes()) { >+ NamedQuery namedQuery = findNamedQuery(node, offset, position); >+ if (namedQuery != null) { >+ return namedQuery; >+ } >+ } >+ >+ return null; >+ } >+ >+ private String retrieveQuery(NamedQuery namedQuery, int position) { >+ >+ String query = namedQuery.getQuery(); >+ >+ if (query == null) { >+ query = StringTools.EMPTY_STRING; >+ } >+ >+ // The NamedQuery's query does not have the trailing whitespace, add them >+ if (query.length() < position) { >+ query = StringTools.pad(query, position, ' '); >+ } >+ >+ return query; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlContentProposalProvider.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlContentProposalProvider.java >diff -N src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlContentProposalProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlContentProposalProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,679 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.ui.internal.jpql; >+ >+import java.text.MessageFormat; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.Collections; >+import java.util.Comparator; >+import java.util.List; >+import java.util.Locale; >+import java.util.ResourceBundle; >+import org.eclipse.core.commands.ParameterizedCommand; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.ui.PreferenceConstants; >+import org.eclipse.jface.bindings.Binding; >+import org.eclipse.jface.bindings.Trigger; >+import org.eclipse.jface.bindings.keys.KeyStroke; >+import org.eclipse.jface.bindings.keys.SWTKeySupport; >+import org.eclipse.jface.fieldassist.ContentProposal; >+import org.eclipse.jface.fieldassist.ContentProposalAdapter; >+import org.eclipse.jface.fieldassist.ControlDecoration; >+import org.eclipse.jface.fieldassist.FieldDecorationRegistry; >+import org.eclipse.jface.fieldassist.IContentProposal; >+import org.eclipse.jface.fieldassist.IContentProposalProvider; >+import org.eclipse.jface.fieldassist.IControlContentAdapter; >+import org.eclipse.jface.fieldassist.IControlContentAdapter2; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel; >+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; >+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.persistence.jpa.jpql.JPQLQueryProblem; >+import org.eclipse.persistence.jpa.jpql.ResultQuery; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.StyleRange; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.editors.text.EditorsPlugin; >+import org.eclipse.ui.keys.IBindingService; >+import org.eclipse.ui.texteditor.AnnotationPreference; >+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; >+ >+/** >+ * This provider is responsible install content assist support onto a {@link StyledText} widget in >+ * order to give choices at any given position within a JPQL query. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings({"nls", "restriction"}) >+public final class JpqlContentProposalProvider extends JpaJpqlCompletionProposalComputer<IContentProposal> { >+ >+ /** >+ * The adapter used to add content assist support to a {@link Text} widget. >+ */ >+ private ContentProposalAdapter adapter; >+ >+ /** >+ * Flag used to determine if the word following the cursor should be overwritten or not. >+ */ >+ private boolean completionInserts; >+ >+ /** >+ * The {@link Color} of the highlight. >+ */ >+ private Color errorColor; >+ >+ /** >+ * The position within the JPQL query. >+ */ >+ private int position; >+ >+ /** >+ * The holder of the named query. >+ */ >+ private PropertyValueModel<? extends NamedQuery> queryHolder; >+ >+ /** >+ * This manager is responsible to only keep the union of the ranges that were created by >+ * validating the JPQL query. >+ */ >+ private RangeManager rangeManager; >+ >+ /** >+ * The {@link ResourceBundle} that contains the JPQL problems. >+ */ >+ private ResourceBundle resourceBundle; >+ >+ /** >+ * The widget used to display the JPQL query. >+ */ >+ private StyledText text; >+ >+ /** >+ * Creates a new <code>JpqlContentProposalProvider</code>. >+ * >+ * @param queryHolder The holder of the named query >+ * @param text The {@link StyledText} widget that shows the JPQL query >+ */ >+ public JpqlContentProposalProvider(PropertyValueModel<? extends NamedQuery> queryHolder, >+ StyledText text) { >+ >+ super(); >+ initialize(queryHolder, text); >+ } >+ >+ private IContentProposalProvider buildContentProposalProvider() { >+ return new IContentProposalProvider() { >+ public IContentProposal[] getProposals(String jpqlQuery, int position) { >+ return buildProposals(jpqlQuery, position); >+ } >+ }; >+ } >+ >+ private IControlContentAdapter buildControlContentAdapter() { >+ return new StyledTextContentAdapter(); >+ } >+ >+ private DisposeListener buildDisposeListener() { >+ return new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ dispose(); >+ } >+ }; >+ } >+ >+ private ILabelProvider buildLabelProvider() { >+ return new LabelProvider() { >+ @Override >+ public Image getImage(Object element) { >+ JpqlContentProposal proposal = (JpqlContentProposal) element; >+ return proposal.getImage(); >+ } >+ @Override >+ public String getText(Object element) { >+ JpqlContentProposal proposal = (JpqlContentProposal) element; >+ return proposal.getLabel(); >+ } >+ }; >+ } >+ >+ private String buildMessage(JPQLQueryProblem problem) { >+ String message = resourceBundle().getString(problem.getMessageKey()); >+ message = MessageFormat.format(message, (Object[]) problem.getMessageArguments()); >+ return message; >+ } >+ >+ private ModifyListener buildModifyListener() { >+ return new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ StyledText text = (StyledText) e.widget; >+ validate(text.getText()); >+ } >+ }; >+ } >+ >+ private Comparator<JPQLQueryProblem> buildProblemComparator() { >+ return new Comparator<JPQLQueryProblem>() { >+ public int compare(JPQLQueryProblem problem1, JPQLQueryProblem problem2) { >+ int result = problem1.getStartPosition() - problem2.getStartPosition(); >+ if (result == 0) { >+ result = problem1.getEndPosition() - problem2.getEndPosition(); >+ } >+ return result; >+ } >+ }; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ IContentProposal buildProposal(String query, >+ String choice, >+ String displayString, >+ Image image, >+ int position, >+ int offset, >+ int cursorOffset) { >+ >+ return new JpqlContentProposal( >+ choice, >+ displayString, >+ image, >+ cursorOffset, >+ additionalInfo(choice) >+ ); >+ } >+ >+ /** >+ * Creates the list of {@link IContentProposal proposals} based on the position of the cursor >+ * within the JPQL query. >+ * >+ * @param jpqlQuery The current string value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @return The list of {@link IContentProposal proposals} >+ */ >+ private IContentProposal[] buildProposals(String jpqlQuery, int position) { >+ >+ this.position = position; >+ this.completionInserts = isCompletionInserts(); >+ >+ // Update the style since we have access to the model now >+ adapter.setProposalAcceptanceStyle(proposalAcceptanceStyle()); >+ >+ // Now create the proposals >+ List<IContentProposal> proposals = super.buildProposals(query(), jpqlQuery, 0, position); >+ return proposals.toArray(new IContentProposal[proposals.size()]); >+ } >+ >+ /** >+ * Makes sure the {@link Color} used to paint the underlying problem is disposed when the >+ * {@link StyledText} widget is disposed. >+ */ >+ private void dispose() { >+ if (errorColor != null) { >+ errorColor.dispose(); >+ errorColor = null; >+ } >+ } >+ >+ private Color errorColor() { >+ // TODO: Support the color changing >+ if (errorColor == null) { >+ // TODO: Is there a better way to do this? >+ for (Object object : EditorsPlugin.getDefault().getMarkerAnnotationPreferences().getAnnotationPreferences()) { >+ AnnotationPreference preference = (AnnotationPreference) object; >+ if ("org.eclipse.ui.workbench.texteditor.error".equals(preference.getAnnotationType())) { >+ errorColor = new Color(text.getDisplay(), preference.getColorPreferenceValue()); >+ break; >+ } >+ } >+ if (errorColor == null) { >+ errorColor = new Color(text.getDisplay(), 255, 0, 0); >+ } >+ } >+ return errorColor; >+ } >+ >+ private KeyStroke findContentAssistTrigger() { >+ >+ IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class); >+ >+ // Dig through the list of available bindings to find the one for content assist >+ for (Binding binding : bindingService.getBindings()) { >+ if (isContentAssistBinding(binding)) { >+ Trigger[] triggers = binding.getTriggerSequence().getTriggers(); >+ if ((triggers != null) && (triggers.length > 0)) { >+ return (KeyStroke) triggers[0]; >+ } >+ } >+ } >+ >+ // The default trigger was not found, use the default >+ return KeyStroke.getInstance(SWT.CTRL, ' '); >+ } >+ >+ private void initialize(PropertyValueModel<? extends NamedQuery> queryHolder, StyledText text) { >+ >+ this.text = text; >+ this.queryHolder = queryHolder; >+ this.rangeManager = new RangeManager(); >+ this.text.addModifyListener (buildModifyListener()); >+ this.text.addDisposeListener(buildDisposeListener()); >+ >+ // Retrieve the content assist trigger >+ KeyStroke contentAssistTrigger = findContentAssistTrigger(); >+ String key = SWTKeySupport.getKeyFormatterForPlatform().format(contentAssistTrigger); >+ >+ // Add the content assist image at the top left corner >+ ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP); >+ decoration.setDescriptionText(NLS.bind(JptUiMessages.JpqlContentProposalProvider_Description, key)); >+ decoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); >+ decoration.setShowOnlyOnFocus(false); >+ >+ // Register the content assist support to the widget >+ adapter = new ContentProposalAdapter( >+ text, >+ buildControlContentAdapter(), >+ buildContentProposalProvider(), >+ contentAssistTrigger, >+ new char[0] >+ ); >+ >+ adapter.setLabelProvider(buildLabelProvider()); >+ >+ validate(text.getText()); >+ } >+ >+ private boolean isCompletionInserts() { >+ IJavaProject javaProject = query().getJpaProject().getJavaProject(); >+ String value = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, javaProject); >+ return Boolean.valueOf(value); >+ } >+ >+ private boolean isContentAssistBinding(Binding binding) { >+ >+ ParameterizedCommand command = binding.getParameterizedCommand(); >+ >+ return command != null && >+ command.getCommand() != null && >+ command.getCommand().getId().equals(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); >+ } >+ >+ private int proposalAcceptanceStyle() { >+ return completionInserts ? ContentProposalAdapter.PROPOSAL_INSERT : ContentProposalAdapter.PROPOSAL_REPLACE; >+ } >+ >+ private NamedQuery query() { >+ return queryHolder.getValue(); >+ } >+ >+ private ResourceBundle resourceBundle() { >+ if (resourceBundle == null) { >+ resourceBundle = ResourceBundle.getBundle( >+ "jpa_jpql_validation", >+ Locale.getDefault(), >+ JptJpaCorePlugin.class.getClassLoader() >+ ); >+ } >+ return resourceBundle; >+ } >+ >+ private List<JPQLQueryProblem> sortProblems(List<JPQLQueryProblem> problems) { >+ Collections.sort(problems, buildProblemComparator()); >+ return problems; >+ } >+ >+ /** >+ * Validates the given JPQL query and add highlights where problems have been found. >+ * >+ * @param actualQuery The JPQL query to validate >+ */ >+ private void validate(String actualQuery) { >+ >+ NamedQuery query = query(); >+ >+ if ((query != null) && !text.isDisposed()) { >+ >+ rangeManager.clear(); >+ >+ JpaJpqlQueryHelper helper = new JpaJpqlQueryHelper(query, actualQuery); >+ String parsedJpqlQuery = helper.getParsedJPQLQuery(); >+ StringBuilder toolTip = new StringBuilder(); >+ >+ for (JPQLQueryProblem problem : sortProblems(helper.validate())) { >+ >+ // Create the range >+ int[] positions = helper.buildPositions(problem, parsedJpqlQuery, actualQuery); >+ rangeManager.addRange(positions); >+ >+ // Add the problem to the tool tip >+ toolTip.append("["); >+ toolTip.append(positions[0]); >+ toolTip.append(", "); >+ toolTip.append(positions[1]); >+ toolTip.append("] "); >+ toolTip.append(buildMessage(problem)); >+ toolTip.append(StringTools.CR); >+ } >+ >+ // Update the widget >+ text.setStyleRanges(rangeManager.buildStyleRanges()); >+ text.setToolTipText(toolTip.toString()); >+ } >+ } >+ >+ /** >+ * The JPQL specific content proposal, which returns the right content based on the completion >+ * insets settings. >+ */ >+ private class JpqlContentProposal extends ContentProposal { >+ >+ /** >+ * The image that represents the choice. >+ */ >+ private final Image image; >+ >+ /** >+ * This offset is used to move the position. >+ */ >+ private final int offset; >+ >+ /** >+ * When the content assist completion is set to "completion overwrites", the content will be >+ * the new JPQL query. >+ */ >+ private ResultQuery result; >+ >+ /** >+ * Creates a new <code>JpqlContentProposal</code>. >+ * >+ * @param choice One of the content assist choices that was found based on the location of >+ * the cursor >+ * @param displayString The display string to show in the content assist popup, which may >+ * differ from the actual choice >+ * @param image The image that represents the choice >+ * @param offset This offset is used to move the position >+ * @param additionalInfo Additional information that will be displayed in a tool tip >+ */ >+ JpqlContentProposal(String choice, >+ String displayString, >+ Image image, >+ int offset, >+ String additionalInfo) { >+ >+ super(choice, displayString, additionalInfo, choice.length() + offset); >+ this.offset = offset; >+ this.image = image; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String getContent() { >+ >+ // If the completion needs to overwrites the partial word following the cursor position, >+ // then the choice becomes the new query >+ if (!completionInserts) { >+ return result().getQuery(); >+ } >+ >+ return super.getContent(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public int getCursorPosition() { >+ >+ // If the completion needs to overwrites the partial word following the cursor position, >+ // then the choice becomes the new query >+ if (!completionInserts) { >+ return result().getPosition() + offset; >+ } >+ >+ return super.getCursorPosition(); >+ } >+ >+ Image getImage() { >+ return image; >+ } >+ >+ private ResultQuery result() { >+ if (result == null) { >+ result = contentAssistItems.buildQuery( >+ queryHelper.getQuery().getExpression(), >+ super.getContent(), >+ JpqlContentProposalProvider.this.position, >+ false >+ ); >+ } >+ return result; >+ } >+ } >+ >+ /** >+ * This manager is responsible to only keep the union of the ranges that were created by >+ * validating the JPQL query. >+ */ >+ private class RangeManager { >+ >+ /** >+ * The {@link StyleRange ranges} that will will be used to paint the highlight under the JPQL >+ * query where the query is grammatically and/or semantically invalid >+ */ >+ List<int[]> ranges; >+ >+ /** >+ * Creates a new <code>RangeManager</code>. >+ */ >+ RangeManager() { >+ super(); >+ ranges = new ArrayList<int[]>(); >+ } >+ >+ /** >+ * Adds the given range (start and end positions) to this manager and if an existing range is >+ * within the given one, then they will be merged to make the union of the two ranges. >+ * >+ * @param range The start and end position of the problem >+ */ >+ void addRange(int[] range) { >+ ranges.add(range); >+ if (ranges.size() > 1) { >+ mergeRanges(); >+ } >+ } >+ >+ private Comparator<StyleRange> buildComparator() { >+ return new Comparator<StyleRange>() { >+ public int compare(StyleRange range1, StyleRange range2) { >+ return range1.start - range2.start; >+ } >+ }; >+ } >+ >+ /** >+ * Creates the list of {@link StyleRange ranges} that will will be used to paint the highlight >+ * under the JPQL query where the query is grammatically and/or semantically invalid. >+ * >+ * @return The list of {@link StyleRange ranges} >+ */ >+ StyleRange[] buildStyleRanges() { >+ >+ StyleRange[] styleRanges = new StyleRange[ranges.size()]; >+ >+ for (int index = ranges.size(); --index >= 0; ) { >+ int[] positions = ranges.get(index); >+ >+ StyleRange styleRange = new StyleRange(); >+ styleRange.start = positions[0]; >+ styleRange.length = positions[1] - positions[0]; >+ styleRange.underline = true; >+ styleRange.underlineColor = errorColor(); >+ styleRange.underlineStyle = SWT.UNDERLINE_ERROR; >+ styleRanges[index] = styleRange; >+ } >+ >+ Arrays.sort(styleRanges, buildComparator()); >+ return styleRanges; >+ } >+ >+ /** >+ * Clears the registered ranges. >+ */ >+ void clear() { >+ ranges.clear(); >+ } >+ >+ private void mergeRanges() { >+ >+ for (int firstIndex = 0, count = ranges.size(); firstIndex < count; firstIndex++) { >+ int[] firstRange = ranges.get(firstIndex); >+ >+ for (int secondIndex = firstIndex + 1; secondIndex < count; secondIndex++) { >+ int[] secondRange = ranges.get(secondIndex); >+ boolean merged = false; >+ >+ // range âââââ >+ // to add ââââââââ >+ // become ââââââââââ >+ if (firstRange[0] <= secondRange[0] && >+ firstRange[1] >= secondRange[0]) { >+ >+ firstRange[1] = Math.max(firstRange[1], secondRange[1]); >+ merged = true; >+ } >+ // range âââââ >+ // to add ââââââââ >+ // become ââââââââââ >+ else if (firstRange[1] >= secondRange[1] && >+ firstRange[0] <= secondRange[1]) { >+ >+ firstRange[0] = Math.min(firstRange[0], secondRange[0]); >+ merged = true; >+ } >+ >+ if (merged) { >+ merged = false; >+ ranges.remove(secondIndex); >+ secondIndex--; >+ count--; >+ } >+ } >+ } >+ } >+ } >+ >+ private class StyledTextContentAdapter implements IControlContentAdapter, >+ IControlContentAdapter2 { >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getControlContents(Control control) { >+ StyledText text = (StyledText) control; >+ return text.getText(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int getCursorPosition(Control control) { >+ StyledText text = (StyledText) control; >+ return text.getCaretOffset(); >+ } >+ >+ public Rectangle getInsertionBounds(Control control) { >+ >+ StyledText text = (StyledText) control; >+ Point caretOrigin = text.getCaret().getLocation(); >+ Rectangle clientArea = text.getClientArea(); >+ >+ // We fudge the y pixels due to problems with getCaretLocation >+ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=52520 >+ return new Rectangle( >+ caretOrigin.x + clientArea.x, >+ caretOrigin.y + clientArea.y + 3, >+ 1, >+ text.getLineHeight() >+ ); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Point getSelection(Control control) { >+ StyledText text = (StyledText) control; >+ return text.getSelection(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void insertControlContents(Control control, String contents, int cursorPosition) { >+ >+ StyledText text = (StyledText) control; >+ Point selection = text.getSelection(); >+ text.insert(contents); >+ >+ // Insert will leave the cursor at the end of the inserted text. If this >+ // is not what we wanted, reset the selection. >+ if (cursorPosition < contents.length()) { >+ text.setSelection(selection.x + cursorPosition, selection.x + cursorPosition); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void setControlContents(Control control, String contents, int cursorPosition) { >+ StyledText text = (StyledText) control; >+ text.setText(contents); >+ text.setSelection(cursorPosition, cursorPosition); >+ } >+ >+ public void setCursorPosition(Control control, int index) { >+ StyledText text = (StyledText) control; >+ text.setSelection(new Point(position, position)); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void setSelection(Control control, Point range) { >+ StyledText text = (StyledText) control; >+ text.setSelection(range); >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlIdentifierMessages.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlIdentifierMessages.java >diff -N src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlIdentifierMessages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpql/JpqlIdentifierMessages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.ui.internal.jpql; >+ >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * The localized messages describing the JPQL identifiers. >+ * >+ * @version 11.2.0 >+ * @since 11.2.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+final class JpqlIdentifierMessages extends NLS { >+ >+ public static String ABS; >+ public static String DELETE_FROM; >+ public static String SELECT; >+ public static String UPDATE; >+ >+ static { >+ NLS.initializeMessages("jpt_ui_jpql_identifiers", JpqlIdentifierMessages.class); >+ } >+ >+ private JpqlIdentifierMessages() { >+ throw new UnsupportedOperationException(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaProblemSeveritiesPage.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaProblemSeveritiesPage.java,v >retrieving revision 1.1 >diff -u -r1.1 JpaProblemSeveritiesPage.java >--- src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaProblemSeveritiesPage.java 6 Feb 2011 02:26:34 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/ui/internal/preferences/JpaProblemSeveritiesPage.java 15 Mar 2011 01:56:35 -0000 >@@ -73,13 +73,13 @@ > > /** > * Default severity levels are stored here, ERROR is the default default so only need >- * to include WARNING, INFO, IGNORE in this Map. These will be displayed if neither the project >+ * to include WARNING, INFO, IGNORE in this Map. These will be displayed if neither the project > * or workspace preference applies. > * <br> key is the preferenceKey which is also the validation message key @see JpaValidationMessages. > * <br> value is a severity level - @see JpaValidationPreferences#ERROR WARNING INFO IGNORE > */ > private Map<String, String> defaultSeverities; >- >+ > /** > * The list of <code>Combo</code>s is cached in order to perform a revert of > * the properties. >@@ -335,7 +335,7 @@ > private void addAttributeLevelCategory(Composite parent) { > > parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.ATTRIBUTE_LEVEL_CATEGORY); >- >+ > addLabeledCombo( > parent, JptUiValidationPreferenceMessages.PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME, > JpaValidationMessages.PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME); >@@ -395,7 +395,7 @@ > JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED); > > parent = addSubExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ATTRIBUTE_LEVEL_CATEGORY); >- >+ > addLabeledCombo( > parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY, > JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY); >@@ -410,7 +410,7 @@ > JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE); > addLabeledCombo( > parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, >- JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED); >+ JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED); > } > > private void addDatabaseCategory(Composite parent) { >@@ -423,9 +423,9 @@ > } > > private void addTableCategory(Composite parent) { >- >+ > parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.TABLE_CATEGORY); >- >+ > addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_CATALOG, JpaValidationMessages.TABLE_UNRESOLVED_CATALOG); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.TABLE_UNRESOLVED_SCHEMA); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.TABLE_UNRESOLVED_NAME, JpaValidationMessages.TABLE_UNRESOLVED_NAME); >@@ -452,10 +452,10 @@ > addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_SCHEMA, JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_SCHEMA); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_NAME); > } >- >- private void addColumnCategory(Composite parent) { >+ >+ private void addColumnCategory(Composite parent) { > parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.COLUMN_CATEGORY); >- >+ > addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_TABLE_NOT_VALID, JpaValidationMessages.COLUMN_TABLE_NOT_VALID); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_UNRESOLVED_TABLE, JpaValidationMessages.COLUMN_UNRESOLVED_TABLE); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.COLUMN_UNRESOLVED_NAME, JpaValidationMessages.COLUMN_UNRESOLVED_NAME); >@@ -503,7 +503,7 @@ > addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID, JpaValidationMessages.VIRTUAL_ATTRIBUTE_MAP_KEY_COLUMN_TABLE_NOT_VALID); > } > >- private void addOverridesCategory(Composite parent) { >+ private void addOverridesCategory(Composite parent) { > > parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.OVERRIDES_CATEGORY); > >@@ -529,7 +529,7 @@ > addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS, JpaValidationMessages.VIRTUAL_ASSOCIATION_OVERRIDE_INVERSE_JOIN_COLUMN_REFERENCED_COLUMN_NAME_MUST_BE_SPECIFIED_MULTIPLE_INVERSE_JOIN_COLUMNS); > >- >+ > parent = addSubExpandableSection(parent, JptUiValidationPreferenceMessages.IMPLIED_ATTRIBUTE_LEVEL_CATEGORY); > > addLabeledCombo(parent, JptUiValidationPreferenceMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_INVALID_NAME, JpaValidationMessages.VIRTUAL_ATTRIBUTE_ATTRIBUTE_OVERRIDE_INVALID_NAME); >@@ -591,12 +591,13 @@ > addLabeledCombo(parent, JptUiValidationPreferenceMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.GENERATED_VALUE_UNRESOLVED_GENERATOR, JpaValidationMessages.GENERATED_VALUE_UNRESOLVED_GENERATOR); > addLabeledCombo(parent, JptUiValidationPreferenceMessages.QUERY_DUPLICATE_NAME, JpaValidationMessages.QUERY_DUPLICATE_NAME); >+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.JPQL_QUERY_VALIDATION, JpaValidationMessages.JPQL_QUERY_VALIDATION); > } >- >+ > private Composite addExpandableSection(Composite parent, String text) { > return addExpandableSection(parent, text, new GridData(GridData.FILL, GridData.FILL, true, false)); > } >- >+ > private Composite addSubExpandableSection(Composite parent, String text) { > return addExpandableSection(parent, text, new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1)); > } >@@ -714,7 +715,7 @@ > String preference = this.defaultSeverities.get(preferenceKey); > return preference == null ? JpaValidationPreferences.ERROR : preference; > } >- >+ > protected int convertPreferenceValueToComboIndex(String preferenceValue) { > if (JpaValidationPreferences.ERROR.equals(preferenceValue)) { > return ERROR_INDEX; >@@ -778,7 +779,7 @@ > revertToDefault(); > } > } >- >+ > @Override > protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) { > super.enableProjectSpecificSettings(useProjectSpecificSettings); >@@ -787,9 +788,9 @@ > // "otherwise the 'enable project specific settings' checkbox is being pressed") > return; > } >- >+ > this.hasProjectSpecificPreferences = Boolean.valueOf(useProjectSpecificSettings); >- >+ > //set all specified workspace preferences in the project preferences > if (useProjectSpecificSettings){ > this.overrideWorkspacePreferences(); >@@ -812,7 +813,7 @@ > preference = getDefaultPreferenceValue(preferenceKey); > } > combo.select(convertPreferenceValueToComboIndex(preference)); >- //UI will show the defaults from the workspace, but set all preferences >+ //UI will show the defaults from the workspace, but set all preferences > //to null so they will be deleted from project preferences > this.severityLevels.put(preferenceKey, null); > } >@@ -833,7 +834,7 @@ > } > } > } >- >+ > // ********** OK/Revert/Apply behavior ********** > > @Override >@@ -858,7 +859,7 @@ > } > catch (InterruptedException ex) { > return false; >- } >+ } > catch (InvocationTargetException ex) { > throw new RuntimeException(ex.getTargetException()); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 337930
:
189609
|
189610
|
189632
|
189633
|
190326
|
190327
|
191181
|
191182
|
191457
|
191822
|
192304
|
192454
|
193077