JBoss Tools SVN: r16755 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-23 15:33:37 -0400 (Thu, 23 Jul 2009)
New Revision: 16755
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
Log:
JBIDE-4307 - god forgot to commit o lawd
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2009-07-23 15:52:38 UTC (rev 16754)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/descriptors/XPathQuery.java 2009-07-23 19:33:37 UTC (rev 16755)
@@ -17,6 +17,7 @@
import org.dom4j.Document;
import org.dom4j.Node;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jaxen.JaxenException;
import org.jaxen.SimpleNamespaceContext;
@@ -38,6 +39,7 @@
*/
protected String name;
protected String baseDir;
+ protected volatile String effectiveBaseDir;
protected String filePattern;
protected String xpathPattern;
protected String attribute;
@@ -60,6 +62,7 @@
this.filePattern = memento.getString("filePattern"); //$NON-NLS-1$
this.xpathPattern = memento.getString("xpathPattern"); //$NON-NLS-1$
this.attribute = memento.getString("attribute"); //$NON-NLS-1$
+ setEffectiveBaseDir();
}
public XPathQuery(String name, List list) {
@@ -68,6 +71,7 @@
this.filePattern = list.get(1).equals(XPathModel.EMPTY_STRING) ? null : (String)list.get(1);
this.xpathPattern = list.get(2).equals(XPathModel.EMPTY_STRING) ? null : (String)list.get(2);
this.attribute = list.size() < 3 || list.get(3).equals(XPathModel.EMPTY_STRING) ? null : (String)list.get(3);
+ setEffectiveBaseDir();
}
public XPathQuery(String name, String baseDir, String filePattern, String xpathPattern, String attribute) {
@@ -77,23 +81,45 @@
this.xpathPattern = xpathPattern;
this.attribute = attribute;
this.results = null;
+ setEffectiveBaseDir();
}
+
+ private void setEffectiveBaseDir() {
+ IPath dir = baseDir == null ? null : new Path(baseDir);
+ if( dir == null && category != null) {
+ dir = getCategory().getServer().getRuntime().getLocation();
+ }
+ if( dir != null && !dir.isAbsolute() && category != null)
+ dir = getCategory().getServer().getRuntime().getLocation().append(dir);
+ effectiveBaseDir = dir == null ? null : dir.toString();
+ }
+
protected AntFileFilter getFilter() {
- if( filter == null )
- filter = new AntFileFilter(baseDir, filePattern);
+ if( filter == null ) {
+ filter = new AntFileFilter(effectiveBaseDir, filePattern);
+ }
return filter;
}
public void refresh() {
String[] files = getFilter().getIncludedFiles();
boolean changed = false;
for( int i = 0; i < files.length; i++ ) {
- changed = changed || getRepository().refresh(new Path(baseDir).append(files[i]).toOSString());
+ changed = changed || getRepository().refresh(new Path(effectiveBaseDir).append(files[i]).toOSString());
}
if( changed ) {
results = null;
}
}
+ /**
+ * Get any files that match the file pattern but may
+ * or may not actually match the xpath
+ * @return
+ */
+ public String[] getPossibleFileMatches() {
+ return getFilter().getIncludedFiles();
+ }
+
public XPathFileResult[] getResults() {
if( results == null )
loadResults();
@@ -111,7 +137,7 @@
ArrayList<XPathFileResult> resultList = new ArrayList<XPathFileResult>();
List<Node> nodeList = null;
for( int i = 0; i < files.length; i++ ) {
- fileLoc = new Path(baseDir).append(files[i]).toOSString();
+ fileLoc = new Path(effectiveBaseDir).append(files[i]).toOSString();
Document d = getRepository().getDocument(fileLoc);
if( d != null ) {
XPath xpath = new Dom4jXPath( xpathPattern );
@@ -178,17 +204,21 @@
}
public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
+ setEffectiveBaseDir();
}
public XPathCategory getCategory() {
return category;
}
public void setCategory(XPathCategory category) {
+ boolean hadCategory = this.category != null;
this.category = category;
+ if( !hadCategory )
+ setEffectiveBaseDir();
}
public void setRepository(XMLDocumentRepository repo) {
this.repository = repo;
}
- protected XMLDocumentRepository getRepository() {
+ public XMLDocumentRepository getRepository() {
return repository == null ? XMLDocumentRepository.getDefault() : repository;
}
}
16 years, 9 months
JBoss Tools SVN: r16754 - in trunk/jst/plugins/org.jboss.tools.jst.jsp: src/org/jboss/tools/jst/jsp and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-07-23 11:52:38 -0400 (Thu, 23 Jul 2009)
New Revision: 16754
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
Old-style CA is replaced by the new one.
Source viewer configurations for jsp and xhtml are supposed to use only the new-style compound CA processor.
Proposal displaying, icons and relevance are updated
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-07-23 15:52:38 UTC (rev 16754)
@@ -403,7 +403,7 @@
id="org.jboss.tools.jst.jsp.contentAssistProcessor"
name="org.jboss.tools.jst.jsp.contentAssistProcessor">
- <contentAssistProcessor
+ <!-- contentAssistProcessor
class="org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor"
id="org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor">
<contenttype id="org.eclipse.jst.jsp.core.jspsource">
@@ -424,10 +424,10 @@
<contenttype id="org.eclipse.wst.html.core.htmlsource">
<partitiontype id="org.eclipse.wst.html.HTML_DEFAULT" />
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL" />
- <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" /> <!-- Is this forgotten? -->
+ <partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
</contenttype>
</contentAssistProcessor>
-
+-->
<!--
//added by estherbin
//fix http://jira.jboss.com/jira/browse/JBIDE-1791
@@ -454,7 +454,6 @@
</contenttype>
</contentAssistProcessor>
- <!--
<contentAssistProcessor
class="org.jboss.tools.jst.jsp.contentassist.XmlContentAssistProcessor"
id="org.jboss.tools.jst.jsp.contentassist.XmlContentAssistProcessor">
@@ -479,7 +478,7 @@
<partitiontype id="org.eclipse.jst.jsp.SCRIPT.JSP_EL2" />
</contenttype>
</contentAssistProcessor>
- -->
+
</extension>
<extension
point="org.eclipse.ui.popupMenus">
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2009-07-23 15:52:38 UTC (rev 16754)
@@ -22,18 +22,12 @@
import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jst.jsp.core.text.IJSPPartitions;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.css.core.text.ICSSPartitions;
-import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor;
import org.eclipse.wst.html.core.text.IHTMLPartitions;
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
import org.eclipse.wst.sse.ui.internal.format.StructuredFormattingStrategy;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorBuilder;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorDefinition;
import org.jboss.tools.common.text.xml.contentassist.SortingCompoundContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
import org.jboss.tools.jst.jsp.format.HTMLFormatProcessor;
import org.osgi.framework.Bundle;
@@ -46,46 +40,21 @@
@SuppressWarnings("restriction")
protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) {
SortingCompoundContentAssistProcessor sortingCompoundProcessor = new SortingCompoundContentAssistProcessor(sourceViewer, partitionType);
- List<IContentAssistProcessor> processors = new ArrayList<IContentAssistProcessor>();
-// if (sortingCompoundProcessor.size() > 0) {
if (sortingCompoundProcessor.supportsPartitionType(partitionType)) {
- processors.add(sortingCompoundProcessor);
- }
+ // Add the default WTP CA processors to our SortingCompoundContentAssistProcessor
+ IContentAssistProcessor[] superProcessors = super.getContentAssistProcessors(sourceViewer, partitionType);
-/*
-// IContentAssistProcessor[] processors = null;
+ if (superProcessors != null && superProcessors.length > 0) {
+ for (int i = 0; i < superProcessors.length; i++)
+ sortingCompoundProcessor.addContentAssistProcessor(partitionType, superProcessors[i]);
+ }
- // if we have our own processors we need
- // to define them in plugin.xml file of their
- // plugins using extention point
- // "org.jboss.tools.common.text.xml.contentAssistProcessor"
-
-
- ContentAssistProcessorDefinition[] defs = ContentAssistProcessorBuilder.getInstance().getContentAssistProcessorDefinitions(partitionType);
-
- if(defs==null) return null;
-
- List<IContentAssistProcessor> processors = new ArrayList<IContentAssistProcessor>();
- for(int i=0; i<defs.length; i++) {
- IContentAssistProcessor processor = defs[i].createContentAssistProcessor();
- if(!processors.contains(processor)) {
- processors.add(processor);
- }
+ return new IContentAssistProcessor[] {sortingCompoundProcessor};
}
- if (partitionType == IHTMLPartitions.HTML_DEFAULT ||
- partitionType == IJSPPartitions.JSP_DEFAULT_EL) {
- processors.add(new FaceletsHtmlContentAssistProcessor());
- }
- //added by estherbin
- //fix http://jira.jboss.com/jira/browse/JBIDE-1791
- if(partitionType.equals(ICSSPartitions.STYLE)){
- processors.add(new CSSContentAssistProcessor());
- }
-
-*/
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
+
+ return new IContentAssistProcessor[0];
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2009-07-23 15:52:38 UTC (rev 16754)
@@ -25,19 +25,10 @@
import org.eclipse.jst.jsp.ui.internal.style.jspel.LineStyleProviderForJSPEL;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.css.core.text.ICSSPartitions;
-import org.eclipse.wst.html.core.text.IHTMLPartitions;
import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
+import org.jboss.tools.common.text.xml.contentassist.SortingCompoundContentAssistProcessor;
import org.osgi.framework.Bundle;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorBuilder;
-import org.jboss.tools.common.text.xml.contentassist.ContentAssistProcessorDefinition;
-import org.jboss.tools.common.text.xml.contentassist.SortingCompoundContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.ExtendedJSPContentAssistProcessor;
-
/**
* @author Igels
*/
@@ -49,52 +40,21 @@
protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) {
SortingCompoundContentAssistProcessor sortingCompoundProcessor = new SortingCompoundContentAssistProcessor(sourceViewer, partitionType);
- List<IContentAssistProcessor> processors = new ArrayList<IContentAssistProcessor>();
-// if (sortingCompoundProcessor.size() > 0) {
if (sortingCompoundProcessor.supportsPartitionType(partitionType)) {
- processors.add(sortingCompoundProcessor);
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
- }
+ // Add the default WTP CA processors to our SortingCompoundContentAssistProcessor
+ IContentAssistProcessor[] superProcessors = super.getContentAssistProcessors(sourceViewer, partitionType);
- /*
- // if we have our own processors we need
- // to define them in plugin.xml file of their
- // plugins using extention point
- // "org.jboss.tools.common.text.xml.contentAssistProcessor"
-
- ContentAssistProcessorDefinition[] defs = ContentAssistProcessorBuilder.getInstance().getContentAssistProcessorDefinitions(partitionType);
+ if (superProcessors != null && superProcessors.length > 0) {
+ for (int i = 0; i < superProcessors.length; i++)
+ sortingCompoundProcessor.addContentAssistProcessor(partitionType, superProcessors[i]);
+ }
- if(defs==null) return null;
-
- List processors = new ArrayList();
- for(int i=0; i<defs.length; i++) {
- IContentAssistProcessor processor = defs[i].createContentAssistProcessor();
- if(!processors.contains(processor)) {
- processors.add(processor);
- }
+ return new IContentAssistProcessor[] {sortingCompoundProcessor};
}
- if ((partitionType == IXMLPartitions.XML_DEFAULT) ||
- (partitionType == IHTMLPartitions.HTML_DEFAULT) ||
- (partitionType == IJSPPartitions.JSP_DEFAULT) ||
- (partitionType == IJSPPartitions.JSP_DIRECTIVE) ||
- (partitionType == IJSPPartitions.JSP_CONTENT_DELIMITER) ||
- (partitionType == IJSPPartitions.JSP_DEFAULT_EL) ||
- (partitionType == IJSPPartitions.JSP_DEFAULT_EL2)) {
- processors.add(new ExtendedJSPContentAssistProcessor());
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
- }
- */
- IContentAssistProcessor[] superProcessors = super.getContentAssistProcessors(sourceViewer, partitionType);
-
- if (superProcessors != null && superProcessors.length > 0) {
- for (int i = 0; i < superProcessors.length; i++)
- processors.add(superProcessors[i]);
- }
-
- return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
+ return new IContentAssistProcessor[0];
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-07-23 15:52:38 UTC (rev 16754)
@@ -162,14 +162,13 @@
* Calculates and adds the attribute name proposals to the Content Assist Request object
*/
protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addAttributeNameProposals() invoked"); //$NON-NLS-1$
}
/**
* Calculates and adds the attribute value proposals to the Content Assist Request object
*/
protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addAttributeValueProposals() invoked"); //$NON-NLS-1$
+// System.out.println("AbstractXMLContentAssistProcessor: addAttributeValueProposals() invoked"); //$NON-NLS-1$
/*
IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
@@ -213,7 +212,6 @@
int attrValueEnd=eqRegionEnd + currentValueText.length();
int attrTextEnd = invokeRegion.getTextEnd();
// attrNode.getValueRegionText()
- System.out.println("AbstractXMLContentAssistProcessor: addAttributeValueProposals() invoked");
}
else {
setErrorMessage(UNKNOWN_CONTEXT);
@@ -225,42 +223,36 @@
* Calculates and adds the comment proposals to the Content Assist Request object
*/
protected void addCommentProposal(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addCommentProposal() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the doc type proposals to the Content Assist Request object
*/
protected void addDocTypeProposal(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addDocTypeProposal() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the empty document proposals to the Content Assist Request object
*/
protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addEmptyDocumentProposals() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the tag name proposals to the Content Assist Request object
*/
protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addEndTagNameProposals() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the end tag proposals to the Content Assist Request object
*/
protected void addEndTagProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addEndTagProposals() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the enttity proposals to the Content Assist Request object
*/
protected void addEntityProposals(ContentAssistRequest contentAssistRequest, int documentPosition, ITextRegion completionRegion, IDOMNode treeNode) {
- System.out.println("AbstractXMLContentAssistProcessor: addEntityProposals() invoked"); //$NON-NLS-1$
super.addEntityProposals(contentAssistRequest, documentPosition, completionRegion, treeNode);
}
@@ -268,28 +260,24 @@
* Calculates and adds the PCDATA proposals to the Content Assist Request object
*/
protected void addPCDATAProposal(String nodeName, ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addPCDATAProposal() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the start document proposals to the Content Assist Request object
*/
protected void addStartDocumentProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addStartDocumentProposals() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the tag close proposals to the Content Assist Request object
*/
protected void addTagCloseProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("AbstractXMLContentAssistProcessor: addTagCloseProposals() invoked"); //$NON-NLS-1$
}
/*
* Calculates and adds the tag insertion proposals to the Content Assist Request object
*/
protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- System.out.println("AbstractXMLContentAssistProcessor: addTagInsertionProposals() invoked"); //$NON-NLS-1$
}
/**
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AutoContentAssistantProposal.java 2009-07-23 15:52:38 UTC (rev 16754)
@@ -30,6 +30,10 @@
super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, IRelevanceConstants.R_NONE);
}
+ public AutoContentAssistantProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance) {
+ super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ }
+
public AutoContentAssistantProposal(boolean autoContentAssistant, String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance) {
super(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
this.autoContentAssistant = autoContentAssistant;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-07-23 15:52:38 UTC (rev 16754)
@@ -19,7 +19,6 @@
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
@@ -181,8 +180,11 @@
protected void addTextELProposals(ContentAssistRequest contentAssistRequest) {
TextRegion prefix = getELPrefix();
if (prefix == null || !prefix.isELStarted()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("#{}", contentAssistRequest.getReplacementBeginPosition(), //$NON-NLS-1$
- 0, 2, null, "#{}", null, JstUIMessages.FaceletPageContectAssistProcessor_NewELExpression, 10000); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
+ contentAssistRequest.getReplacementBeginPosition(),
+ 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression, null,
+ JstUIMessages.FaceletPageContectAssistProcessor_NewELExpressionTextInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
return;
}
@@ -209,15 +211,23 @@
String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
+ }
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
if (prefix.isELStarted() && !prefix.isELClosed()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("}", getOffset(), //$NON-NLS-1$
- 0, 1, null, "}", null, JstUIMessages.FaceletPageContectAssistProcessor_CloseELExpression, 10001); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal("}", //$NON-NLS-1$
+ getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-07-23 15:52:38 UTC (rev 16754)
@@ -24,13 +24,16 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.document.NodeContainer;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
+import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.messages.JstUIMessages;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
@@ -56,6 +59,8 @@
*/
public class JspContentAssistProcessor extends XmlContentAssistProcessor {
+ protected static final Image JSF_EL_PROPOSAL_IMAGE = JspEditorPlugin.getDefault().getImage(JspEditorPlugin.CA_JSF_EL_IMAGE_PATH);
+
/**
* (non-Javadoc)
* @see org.jboss.tools.jst.jsp.contentassist.XmlContentAssistProcessor#createContext()
@@ -326,8 +331,6 @@
return;
}
- // TODO Auto-generated method stub
- System.out.println("JspContentAssistProcessor: addTagInsertionProposals() invoked"); //$NON-NLS-1$
try {
String matchString = contentAssistRequest.getMatchString();
String query = matchString;
@@ -342,32 +345,37 @@
TextProposal textProposal = proposals[i];
String replacementString = textProposal.getReplacementString();
+ String closingTag = textProposal.getLabel();
+ if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
+ closingTag = closingTag.substring(1);
+ }
+
if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
- String closingTag = textProposal.getLabel();
- if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
- closingTag = closingTag.substring(1);
- }
-
replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
}
- System.out.println("Tag Name proposal [" + (i + 1) + "/" + proposals.length + "]: " + replacementString); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
int replacementLength = contentAssistRequest.getReplacementLength();
int cursorPosition = getCursorPositionForProposedText(replacementString);
Image image = textProposal.getImage();
- String displayString = textProposal.getLabel() + ">"; //$NON-NLS-1$
+ if (image == null) {
+ image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+ String displayString = closingTag; //$NON-NLS-1$
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
-
-
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_TAG_INSERTION;
+ }
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addTagInsertionProposals() exited"); //$NON-NLS-1$
}
return;
}
@@ -383,8 +391,6 @@
@Override
protected void addTagNameProposals(
ContentAssistRequest contentAssistRequest, int childPosition) {
- // TODO Auto-generated method stub
- System.out.println("JspContentAssistProcessor: addTagNameProposals() invoked"); //$NON-NLS-1$
try {
String matchString = contentAssistRequest.getMatchString();
String query = matchString;
@@ -399,36 +405,43 @@
TextProposal textProposal = proposals[i];
String replacementString = textProposal.getReplacementString();
+ String closingTag = textProposal.getLabel();
+ if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
+ closingTag = closingTag.substring(1);
+ }
+
if (replacementString.startsWith("<")) { //$NON-NLS-1$
// Because the tag starting char is already in the text
replacementString = replacementString.substring(1);
}
if (!replacementString.endsWith("/>")) { //$NON-NLS-1$
- String closingTag = textProposal.getLabel();
- if (closingTag != null && closingTag.startsWith("<")) { //$NON-NLS-1$
- closingTag = closingTag.substring(1);
- }
-
replacementString += "</" + closingTag + ">"; //$NON-NLS-1$ //$NON-NLS-2$
}
- System.out.println("Tag Name proposal [" + (i + 1) + "/" + proposals.length + "]: " + replacementString); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+
int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
int replacementLength = contentAssistRequest.getReplacementLength();
int cursorPosition = getCursorPositionForProposedText(replacementString);
Image image = textProposal.getImage();
- String displayString = textProposal.getLabel() + ">"; //$NON-NLS-1$
+ if (image == null) {
+ image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
+ }
+
+ String displayString = closingTag; //$NON-NLS-1$
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
-
-
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_TAG_INSERTION;
+ }
+
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addTagNameProposals() exited"); //$NON-NLS-1$
}
return;
}
@@ -441,7 +454,6 @@
* @param childPosition the
*/
protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- System.out.println("JspContentAssistProcessor: addAttributeNameProposals() invoked"); //$NON-NLS-1$
try {
String matchString = contentAssistRequest.getMatchString();
String query = matchString;
@@ -455,8 +467,6 @@
for (int i = 0; proposals != null && i < proposals.length; i++) {
TextProposal textProposal = proposals[i];
- System.out.println("Tag Attribute proposal [" + (i + 1) + "/" + proposals.length + "]: " + textProposal.getReplacementString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
if (isExistingAttribute(textProposal.getLabel()))
continue;
@@ -469,14 +479,15 @@
String displayString = textProposal.getLabel();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
-
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addAttributeNameProposals() exited"); //$NON-NLS-1$
}
}
@@ -510,13 +521,18 @@
String displayString = textProposal.getLabel();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_ATTRIBUTE_VALUE;
+ }
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addAttributeValueProposals() exited"); //$NON-NLS-1$
}
}
@@ -532,8 +548,6 @@
*/
@Override
protected void addAttributeValueELProposals(ContentAssistRequest contentAssistRequest) {
- // TODO Auto-generated method stub
- System.out.println("JspContentAssistProcessor: addAttributeValueELProposals() invoked"); //$NON-NLS-1$
try {
TextRegion prefix = getELPrefix();
if (prefix == null) {
@@ -541,8 +555,10 @@
}
if(!prefix.isELStarted()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("#{}", getOffset(), //$NON-NLS-1$
- 0, 2, null, "#{}", null, JstUIMessages.JspContentAssistProcessor_NewELExpression, 10000); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(true, "#{}", //$NON-NLS-1$
+ getOffset(), 0, 2, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_NewELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_NewELExpressionAttrInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
return;
}
@@ -560,8 +576,6 @@
for (int i = 0; proposals != null && i < proposals.length; i++) {
TextProposal textProposal = proposals[i];
- System.out.println("Tag Attribute Value EL proposal [" + (i + 1) + "/" + proposals.length + "]: " + textProposal.getReplacementString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
@@ -571,19 +585,26 @@
String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
IContextInformation contextInformation = null;
String additionalProposalInfo = (textProposal.getContextInfo() == null ? "" : textProposal.getContextInfo()); //$NON-NLS-1$
- int relevance = textProposal.getRelevance() + 10000;
+ int relevance = textProposal.getRelevance();
+ if (relevance == TextProposal.R_NONE) {
+ relevance = TextProposal.R_JSP_JSF_EL_VARIABLE_ATTRIBUTE_VALUE;
+ }
- CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal(replacementString,
+ replacementOffset, replacementLength, cursorPosition, image, displayString,
+ contextInformation, additionalProposalInfo, relevance);
+
contentAssistRequest.addProposal(proposal);
}
if (prefix.isELStarted() && !prefix.isELClosed()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("}", getOffset(), //$NON-NLS-1$
- 0, 1, null, "}", null, JstUIMessages.JspContentAssistProcessor_CloseELExpression, 10001); //$NON-NLS-1$
+ AutoContentAssistantProposal proposal = new AutoContentAssistantProposal("}", //$NON-NLS-1$
+ getOffset(), 0, 1, JSF_EL_PROPOSAL_IMAGE, JstUIMessages.JspContentAssistProcessor_CloseELExpression,
+ null, JstUIMessages.JspContentAssistProcessor_CloseELExpressionInfo, TextProposal.R_XML_ATTRIBUTE_VALUE_TEMPLATE);
+
contentAssistRequest.addProposal(proposal);
}
} finally {
- System.out.println("JspContentAssistProcessor: addAttributeELProposals() exited"); //$NON-NLS-1$
}
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2009-07-23 15:52:38 UTC (rev 16754)
@@ -50,8 +50,7 @@
public static String CSS_APPLY_CHANGES;
public static String ADD_FONT_FAMILY_TIP;
public static String REMOVE_FONT_FAMILY_TIP;
- public static String FaceletPageContectAssistProcessor_CloseELExpression;
- public static String FaceletPageContectAssistProcessor_NewELExpression;
+ public static String FaceletPageContectAssistProcessor_NewELExpressionTextInfo;
public static String FONT_SIZE;
public static String FONT_STYLE;
public static String FONT_WEIGHT;
@@ -107,7 +106,9 @@
public static String CSS_CLASS_NAME_NOT_VALID;
public static String CSS_INVALID_STYLE_PROPERTY;
public static String JspContentAssistProcessor_CloseELExpression;
+ public static String JspContentAssistProcessor_CloseELExpressionInfo;
public static String JspContentAssistProcessor_NewELExpression;
+ public static String JspContentAssistProcessor_NewELExpressionAttrInfo;
public static String JSPDialogCellEditor_CodeAssist;
public static String JSPDialogCellEditor_EditAttribute;
public static String JSPDialogContentProposalProvider_CloseELExpression;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-07-23 15:42:11 UTC (rev 16753)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2009-07-23 15:52:38 UTC (rev 16754)
@@ -16,8 +16,8 @@
ADD_FONT_FAMILY_TIP=Add font family
REMOVE_FONT_FAMILY_TIP=Remove font family
-FaceletPageContectAssistProcessor_CloseELExpression=Close EL Expression
-FaceletPageContectAssistProcessor_NewELExpression=New EL Expression
+FaceletPageContectAssistProcessor_NewELExpression=New JSF EL Expression - Create a new text with #{}
+FaceletPageContectAssistProcessor_NewELExpressionTextInfo=#{}
FONT_FAMILY_DIALOG_TITLE=Choose font family
BUTTON_APPLY=Apply
BUTTON_CLEAR=Clear
@@ -81,8 +81,10 @@
DEFAULT_PREVIEW_TEXT=CSS file to edit will be displayed here
DEFAULT_TEXT_FOR_BROWSER_PREVIEW=Double click to edit preview. To save changes press Enter button.
-JspContentAssistProcessor_CloseELExpression=Close EL Expression
-JspContentAssistProcessor_NewELExpression=New EL Expression
+JspContentAssistProcessor_CloseELExpression=Close JSF EL Expression
+JspContentAssistProcessor_CloseELExpressionInfo=}
+JspContentAssistProcessor_NewELExpression=New JSF EL Expression - Create a new attribute value with #{}
+JspContentAssistProcessor_NewELExpressionAttrInfo=#{}
JSPDialogCellEditor_CodeAssist=code assist
JSPDialogCellEditor_EditAttribute=Edit {0}
JSPDialogContentProposalProvider_CloseELExpression=Close EL Expression
16 years, 9 months
JBoss Tools SVN: r16753 - trunk/seam/plugins/org.jboss.tools.seam.ui.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-07-23 11:42:11 -0400 (Thu, 23 Jul 2009)
New Revision: 16753
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
Old-style CA for Seam EL is excluded.
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-07-23 15:40:10 UTC (rev 16752)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-07-23 15:42:11 UTC (rev 16753)
@@ -346,7 +346,7 @@
id="org.jboss.tools.seam.ui.contentAssistProcessor"
name="org.jboss.tools.seam.ui.contentAssistProcessor">
- <contentAssistProcessor
+ <!-- contentAssistProcessor
class="org.jboss.tools.seam.ui.text.java.SeamELProposalProcessor"
id="org.jboss.tools.seam.ui.text.java.SeamELProposalProcessor">
<contenttype id="org.eclipse.jst.jsp.core.jspsource">
@@ -392,7 +392,7 @@
<contenttype id="org.jboss.tools.seam.xml.ui.page21xmlsource">
<partitiontype id="org.eclipse.wst.xml.XML_DEFAULT" />
</contenttype>
- </contentAssistProcessor>
+ </contentAssistProcessor -->
</extension>
<extension
16 years, 9 months
JBoss Tools SVN: r16752 - trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-07-23 11:40:10 -0400 (Thu, 23 Jul 2009)
New Revision: 16752
Modified:
trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
SortingCompoundContentAssistProcessor is modified to allow adding CA processors during source viewer configuration initialization as well, as from schema. Proposals unification procedure is also updated.
Modified: trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java 2009-07-23 15:33:29 UTC (rev 16751)
+++ trunk/common/plugins/org.jboss.tools.common.text.xml/src/org/jboss/tools/common/text/xml/contentassist/SortingCompoundContentAssistProcessor.java 2009-07-23 15:40:10 UTC (rev 16752)
@@ -119,6 +119,34 @@
}
}
+
+ private static final String POST_INSTALL_CA_PROCESSORS_CONTENTTYPE_STUB = "$$POST_INSTALL_CA_PROCESSORS_CONTENTTYPE_STUB$$"; //$NON-NLS-1$
+ public void addContentAssistProcessor(String partitionType, IContentAssistProcessor processor) {
+ if (partitionType == null || processor == null)
+ return;
+
+ Map<String, List<IContentAssistProcessor>> contentTypeProcessors = fProcessorsMap.get(POST_INSTALL_CA_PROCESSORS_CONTENTTYPE_STUB);
+ if (contentTypeProcessors == null) {
+ contentTypeProcessors = new HashMap<String, List<IContentAssistProcessor>>();
+ }
+
+ List<IContentAssistProcessor> partitionTypeProcessors = contentTypeProcessors.get(partitionType);
+ if (partitionTypeProcessors == null) {
+ partitionTypeProcessors = new ArrayList<IContentAssistProcessor>();
+ }
+
+ if(!containsAnObjectOfTheSameType(partitionTypeProcessors,processor)) {
+ partitionTypeProcessors.add(processor);
+ }
+
+ if (!contentTypeProcessors.containsKey(partitionType)) {
+ contentTypeProcessors.put(partitionType, partitionTypeProcessors);
+ }
+
+ if (!fProcessorsMap.containsKey(POST_INSTALL_CA_PROCESSORS_CONTENTTYPE_STUB)) {
+ fProcessorsMap.put(POST_INSTALL_CA_PROCESSORS_CONTENTTYPE_STUB, contentTypeProcessors);
+ }
+ }
boolean containsAnObjectOfTheSameType(Collection collection, Object obj) {
if (collection == null || obj == null)
@@ -184,13 +212,17 @@
List<ICompletionProposal> ret = new LinkedList<ICompletionProposal>();
- if (fProcessorsMap.get(contentType) == null)
+ List<IContentAssistProcessor> processors = new LinkedList<IContentAssistProcessor>();
+ if (fProcessorsMap.get(contentType) != null) {
+ processors.addAll(fProcessorsMap.get(contentType).get(fPartitionType));
+ }
+ if (fProcessorsMap.get(POST_INSTALL_CA_PROCESSORS_CONTENTTYPE_STUB) != null) {
+ processors.addAll(fProcessorsMap.get(POST_INSTALL_CA_PROCESSORS_CONTENTTYPE_STUB).get(fPartitionType));
+ }
+ if(processors.size() == 0) {
return new ICompletionProposal[0];
-
- if (fProcessorsMap.get(contentType).get(fPartitionType) == null)
- return new ICompletionProposal[0];
+ }
- List<IContentAssistProcessor> processors = fProcessorsMap.get(contentType).get(fPartitionType);
for (IContentAssistProcessor p : processors) {
ICompletionProposal[] proposals = p.computeCompletionProposals(viewer, offset);
@@ -223,12 +255,28 @@
*/
public ICompletionProposal[] makeUnique(ICompletionProposal[] proposals) {
HashSet<String> present = new HashSet<String>();
+ HashSet<String> info = new HashSet<String>();
ArrayList<ICompletionProposal> unique= new ArrayList<ICompletionProposal>();
for (int i = 0; proposals != null && i < proposals.length; i++) {
-
+ String infoUnquoted = proposals[i].getAdditionalProposalInfo();
+ if (infoUnquoted != null) {
+ if (infoUnquoted.startsWith("\""))
+ infoUnquoted = infoUnquoted.substring(1);
+ if (infoUnquoted.endsWith("\""))
+ infoUnquoted = infoUnquoted.substring(0, infoUnquoted.length() - 1);
+ infoUnquoted = infoUnquoted.trim();
+ }
if (!present.contains(proposals[i].getDisplayString())) {
present.add(proposals[i].getDisplayString());
+ if (infoUnquoted != null && infoUnquoted.length() > 0) {
+ if (!info.contains(infoUnquoted)) {
+ info.add(infoUnquoted);
+ } else {
+ // Do not add proposals with the same info
+ continue;
+ }
+ }
unique.add(proposals[i]);
}
}
16 years, 9 months
JBoss Tools SVN: r16751 - trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/text.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-07-23 11:33:29 -0400 (Thu, 23 Jul 2009)
New Revision: 16751
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/text/TextProposal.java
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
TextProposal is updated with some new proposal relevance constants
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/text/TextProposal.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/text/TextProposal.java 2009-07-23 15:27:21 UTC (rev 16750)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/text/TextProposal.java 2009-07-23 15:33:29 UTC (rev 16751)
@@ -29,7 +29,9 @@
public static final int R_JSP_ATTRIBUTE_VALUE = 830;
public static final int R_XML_ATTRIBUTE_VALUE = 850;
public static final int R_XML_ATTRIBUTE_NAME = 910;
-
+ public static final int R_TAG_INSERTION = 500;
+ public static final int R_XML_ATTRIBUTE_VALUE_TEMPLATE = 91;
+
private static final long serialVersionUID = 3257007635692926512L;
private Object source;
16 years, 9 months
JBoss Tools SVN: r16750 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-23 11:27:21 -0400 (Thu, 23 Jul 2009)
New Revision: 16750
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4642
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-07-23 14:54:33 UTC (rev 16749)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-07-23 15:27:21 UTC (rev 16750)
@@ -195,7 +195,6 @@
|| attrName.equals("class")) {
descriptor = createJSPPropertyDescriptor(d, attrName, false);
} else {
- System.out.println(attrName);
descriptor = createTextPropertyDescriptor(attrName, CATEGORY_ATTRIBUTES, 0);
}
if (descriptor != null) {
16 years, 9 months
JBoss Tools SVN: r16749 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-23 10:54:33 -0400 (Thu, 23 Jul 2009)
New Revision: 16749
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4642
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-07-23 14:04:34 UTC (rev 16748)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPPropertySourceAdapter.java 2009-07-23 14:54:33 UTC (rev 16749)
@@ -36,7 +36,6 @@
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapter;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
import org.eclipse.wst.xml.ui.internal.properties.EnumeratedStringPropertyDescriptor;
@@ -102,7 +101,7 @@
DocumentTypeAdapter adapter = ownerDocument == null ? null : (DocumentTypeAdapter) ((INodeNotifier) ownerDocument).getAdapterFor(DocumentTypeAdapter.class);
if (adapter != null)
fCaseSensitive = adapter.getTagNameCase() == DocumentTypeAdapter.STRICT_CASE;
- offset = ((IDOMElement)fNode).getStartOffset() + ("" + fNode.getNodeType()).length(); //$NON-NLS-1$
+ offset = ((IDOMNode)fNode).getStartOffset() + ("" + fNode.getNodeName()).length(); //$NON-NLS-1$
}
processor = valueHelper.isFacetets() ? new FaceletPageContectAssistProcessor() : new JspContentAssistProcessor();
processor.createContext(getTextViewer(), offset);
16 years, 9 months
JBoss Tools SVN: r16748 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal: mapping/details and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-07-23 10:04:34 -0400 (Thu, 23 Jul 2009)
New Revision: 16748
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/EnterNameDialog.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/NameStateObject.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
Log:
https://jira.jboss.org/jira/browse/JBIDE-4649
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java 2009-07-23 13:40:36 UTC (rev 16747)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorComposite.java 2009-07-23 14:04:34 UTC (rev 16748)
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
-
-import org.eclipse.jpt.core.context.GeneratorHolder;
-import org.eclipse.jpt.ui.internal.mappings.details.GeneratorComposite;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
-import org.eclipse.jpt.utility.internal.StringConverter;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class GenericGeneratorComposite extends GeneratorComposite<GenericGenerator> {
-
- public GenericGeneratorComposite(Pane<? extends GeneratorHolder> parentPane, Composite parent) {
- super(parentPane, parent);
- }
-
- @Override
- protected GenericGenerator buildGenerator(GeneratorHolder subject) {
- return ((GenericGeneratorHolder)subject).addGenericGenerator();
- }
-
- protected GenericGenerator buildGenerator() {
- return this.buildGenerator(this.getSubject());
- }
-
- @Override
- protected GenericGenerator getGenerator(GeneratorHolder subject) {
- return ((GenericGeneratorHolder)subject).getGenericGenerator();
- }
-
- @Override
- protected String getPropertyName() {
- return GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY;
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- // Name widgets
- addLabeledText(
- container,
- HibernateUIMappingMessages.GenericGeneratorComposite_name,
- buildGeneratorNameHolder(),
- null//TODO add help
- );
-
- addLabeledEditableCombo(
- container,
- HibernateUIMappingMessages.GenericGeneratorComposite_strategy,
- new SimpleListValueModel<String>(JavaGenericGeneratorImpl.generatorClasses),
- buildStrategyHolder(),
- StringConverter.Default.<String>instance(),
- null);//TODO add help
-
- new ParametersComposite(this, container);
- }
-
- protected WritablePropertyValueModel<String> buildStrategyHolder() {
- return new PropertyAspectAdapter<GeneratorHolder, String>(getSubjectHolder(),
- GenericGenerator.GENERIC_STRATEGY_PROPERTY) {
- @Override
- protected String buildValue_() {
- return ((GenericGeneratorHolder)subject).getGenericGenerator() == null ?
- null : ((GenericGeneratorHolder)subject).getGenericGenerator().getStrategy();
- }
-
- @Override
- protected void setValue_(String value) {
- if ("".equals(value))value = null; //$NON-NLS-1$
- GenericGenerator generator = ((GenericGeneratorHolder)subject).getGenericGenerator();
- if (generator == null){
- generator = ((GenericGeneratorHolder)subject).addGenericGenerator();
- }
- generator.setStrategy(value);
- }
- };
- }
-
-}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java 2009-07-23 14:04:34 UTC (rev 16748)
@@ -0,0 +1,327 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.Set;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.context.Generator;
+import org.eclipse.jpt.core.context.IdMapping;
+import org.eclipse.jpt.core.context.SequenceGenerator;
+import org.eclipse.jpt.ui.internal.mappings.db.SequenceCombo;
+import org.eclipse.jpt.ui.internal.mappings.details.GenerationComposite;
+import org.eclipse.jpt.ui.internal.util.ControlEnabler;
+import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringConverter;
+import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimpleListValueModel;
+import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
+import org.jboss.tools.hibernate.jpt.ui.internal.widgets.EnterNameDialog;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ *
+ * Here the layout of this pane:
+ * <pre>
+ * -----------------------------------------------------------------------------
+ * | ----------------------------------------------------- |
+ * | Name: | I | |
+ * | ----------------------------------------------------- |
+ * | ----------------------------------------------------- |
+ * | Sequence : | SequenceCombo | |
+ * | ----------------------------------------------------- |
+ * | - Parameters ----------------------------------------------------------- |
+ * | | --------------------------------------------------------------------- | |
+ * | | | | | |
+ * | | | ParametersComposite | | |
+ * | | | | | |
+ * | | --------------------------------------------------------------------- | |
+ * | ------------------------------------------------------------------------- |
+ * -----------------------------------------------------------------------------</pre>
+ *
+ * @see IdMapping
+ * @see SequenceGenerator
+ * @see GenerationComposite - The parent container
+ * @see SequenceCombo
+ *
+ * @version 2.0
+ * @since 1.0
+ */
+public class GenericGeneratorsComposite extends Pane<GenericGeneratorHolder> {
+
+ /**
+ * Shows is Member can contains only 1 @GenericGenerator or not.
+ */
+ private boolean singleGenerator;
+
+ private AddRemoveListPane<GenericGeneratorHolder> listPane;
+ private WritablePropertyValueModel<GenericGenerator> generatorHolder;
+
+ public GenericGeneratorsComposite(Pane<? extends GenericGeneratorHolder> parentPane, Composite parent, boolean singleGenerator) {
+ super(parentPane, parent, false);
+ this.singleGenerator = singleGenerator;
+ }
+
+ private void addGenericGenerator() {
+ Set<String> generatorNames = new HashSet<String>();
+ for (Iterator<Generator> generators = this.getSubject().getPersistenceUnit().generators(); generators.hasNext(); ) {
+ generatorNames.add(generators.next().getName());
+ }
+ EnterNameDialog dialog = new EnterNameDialog(getControl().getShell(),
+ HibernateUIMappingMessages.GenericGeneratorsComposite_addGeneratorNameDescription,
+ null,
+ generatorNames);
+ if (dialog.open() != Window.OK) {
+ return;
+ }
+ String name = dialog.getName();
+ GenericGenerator generator = getSubject().addGenericGenerator(getSubject().genericGeneratorsSize());
+ generator.setName(name);
+ }
+
+ private ListValueModel<GenericGenerator> buildDisplayableGeneratorsListHolder() {
+ return new ItemPropertyListValueModelAdapter<GenericGenerator>(
+ buildGeneratorsListHolder(),
+ GenericGenerator.NAME_PROPERTY
+ );
+ }
+
+ private ListValueModel<GenericGenerator> buildGeneratorsListHolder() {
+ return new ListAspectAdapter<GenericGeneratorHolder, GenericGenerator>(
+ getSubjectHolder(),
+ GenericGeneratorHolder.GENERIC_GENERATORS_LIST)
+ {
+ @Override
+ protected ListIterator<GenericGenerator> listIterator_() {
+ return this.subject.genericGenerators();
+ }
+
+ @Override
+ protected int size_() {
+ return this.subject.genericGeneratorsSize();
+ }
+ };
+ }
+
+ private AddRemoveListPane<GenericGeneratorHolder> addListPane(Composite container) {
+
+ return new AddRemoveListPane<GenericGeneratorHolder>(
+ this,
+ container,
+ buildGenericGeneratorsAdapter(),
+ buildDisplayableGeneratorsListHolder(),
+ this.generatorHolder,
+ buildGeneratorsListLabelProvider(),
+ null//TODO help
+ );
+ }
+
+
+ private ListValueModel<GenericGenerator> buildGenericGeneratorsListHolder() {
+ return new ListAspectAdapter<GenericGeneratorHolder, GenericGenerator>(
+ getSubjectHolder(),
+ GenericGeneratorHolder.GENERIC_GENERATORS_LIST)
+ {
+ @Override
+ protected ListIterator<GenericGenerator> listIterator_() {
+ return this.subject.genericGenerators();
+ }
+
+ @Override
+ protected int size_() {
+ return this.subject.genericGeneratorsSize();
+ }
+ };
+ }
+
+ private Adapter buildGenericGeneratorsAdapter() {
+
+ return new AddRemoveListPane.AbstractAdapter() {
+
+ public void addNewItem(ObjectListSelectionModel listSelectionModel) {
+ addGenericGenerator();
+ }
+
+ public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
+ for (Object item : listSelectionModel.selectedValues()) {
+ getSubject().removeGenericGenerator((GenericGenerator) item);
+ }
+ }
+ };
+ }
+
+
+ private ILabelProvider buildGeneratorsListLabelProvider() {
+ return new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ GenericGenerator genericGenerator = (GenericGenerator) element;
+ String name = genericGenerator.getName();
+
+ if (name == null) {
+ int index = CollectionTools.indexOf(getSubject().genericGenerators(), genericGenerator);
+ name = NLS.bind(HibernateUIMappingMessages.GenericGeneratorsComposite_generatorNullName, index);
+ }
+
+ return name;
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<GenericGenerator> buildGenericGeneratorHolder() {
+ return new SimplePropertyValueModel<GenericGenerator>();
+ }
+
+ @Override
+ public void enableWidgets(boolean enabled) {
+ super.enableWidgets(enabled);
+ this.listPane.enableWidgets(enabled);
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ this.generatorHolder = buildGenericGeneratorHolder();
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ if (singleGenerator){
+ // Name widgets
+ addLabeledText(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_name,
+ buildGeneratorNameHolder(),
+ null//TODO add help
+ );
+ } else {
+ // List pane
+ this.listPane = addListPane(container);
+ }
+
+ Combo c = addLabeledEditableCombo(
+ container,
+ HibernateUIMappingMessages.GenericGeneratorComposite_strategy,
+ new SimpleListValueModel<String>(JavaGenericGeneratorImpl.generatorClasses),
+ buildStrategyHolder(),
+ StringConverter.Default.<String>instance(),
+ null);//TODO add help
+ new ControlEnabler(buildControlEnabler(), c);
+
+ new ParametersComposite(this, container, generatorHolder);
+
+
+ }
+
+ private PropertyValueModel<Boolean> buildControlEnabler() {
+ return new TransformationPropertyValueModel<GenericGenerator, Boolean>(generatorHolder){
+ public Boolean transform(GenericGenerator generator) {
+ return generator != null;
+ }
+ };
+ }
+
+ protected final WritablePropertyValueModel<String> buildGeneratorNameHolder() {
+ return new PropertyAspectAdapter<GenericGenerator, String>(this.generatorHolder, GenericGenerator.NAME_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject == null ? null : subject.getName();
+ }
+
+ @Override
+ public void setValue(String value) {
+ if (subject != null) {
+ setValue_(value);
+ return;
+ }
+
+ if ("".equals(value)){ //$NON-NLS-1$
+ return;
+ }
+
+ GenericGenerator generator =
+ (getSubject().genericGeneratorsSize() == 0) ? getSubject().addGenericGenerator(0)
+ : getSubject().genericGenerators().next();
+
+ generator.setName(value);
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if ("".equals(value)) {//$NON-NLS-1$
+ value = null;
+ }
+ subject.setName(value);
+ }
+ };
+ }
+
+ protected WritablePropertyValueModel<String> buildStrategyHolder() {
+ return new PropertyAspectAdapter<GenericGenerator, String>(this.generatorHolder,
+ GenericGenerator.GENERIC_STRATEGY_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject == null ? null : subject.getStrategy();
+ }
+
+ @Override
+ public void setValue(String value) {
+ if (subject != null) {
+ setValue_(value);
+ return;
+ }
+
+ if ("".equals(value)){ //$NON-NLS-1$
+ return;
+ }
+
+ GenericGenerator generator =
+ (getSubject().genericGeneratorsSize() == 0) ? getSubject().addGenericGenerator(0)
+ : getSubject().genericGenerators().next();
+
+ generator.setStrategy(value);
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if ("".equals(value)) {//$NON-NLS-1$
+ value = null;
+ }
+ subject.setStrategy(value);
+ }
+ };
+ }
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/GenericGeneratorsComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java 2009-07-23 13:40:36 UTC (rev 16747)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateGeneratorsComposite.java 2009-07-23 14:04:34 UTC (rev 16748)
@@ -18,7 +18,9 @@
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
/**
* @author Dmitry Geraskov
@@ -45,6 +47,7 @@
initializeGenericGeneratorPane(container);
}
+ @SuppressWarnings("unchecked")
protected void initializeGenericGeneratorPane(Composite container) {
// Sequence Generator sub-section
@@ -62,29 +65,35 @@
null//TODO add help
);
- // Sequence Generator pane
- new GenericGeneratorComposite(
- this,
- addSubPane(container, 0, genericGeneratorCheckBox.getBorderWidth() + 16)
+ // Generic Generator pane
+ new GenericGeneratorsComposite(
+ (Pane<? extends GenericGeneratorHolder>) this,
+ addSubPane(container, 0, genericGeneratorCheckBox.getBorderWidth() + 16),
+ (getSubject() instanceof HibernateJavaIdMapping)
);
}
+
+ protected GenericGenerator getGenerator(GeneratorHolder subject) {
+ return (((GenericGeneratorHolder)subject).genericGeneratorsSize() == 0) ? null
+ : ((GenericGeneratorHolder)subject).genericGenerators().next();
+ }
private WritablePropertyValueModel<Boolean> buildGenericGeneratorBooleanHolder() {
- return new PropertyAspectAdapter<GeneratorHolder, Boolean>(getSubjectHolder(), GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY) {
+ return new PropertyAspectAdapter<GeneratorHolder, Boolean>(getSubjectHolder(), GenericGeneratorHolder.GENERIC_GENERATORS_LIST) {
+
@Override
protected Boolean buildValue_() {
- return ((GenericGeneratorHolder)subject).getGenericGenerator() != null;
+ return getGenerator(subject) != null;
}
@Override
protected void setValue_(Boolean value) {
-
- if (value && (((GenericGeneratorHolder)subject).getGenericGenerator() == null)) {
- ((GenericGeneratorHolder)subject).addGenericGenerator();
+ if (value && (getGenerator(subject) == null)) {
+ ((GenericGeneratorHolder)subject).addGenericGenerator(0);
}
- else if (!value && (((GenericGeneratorHolder)subject).getGenericGenerator() != null)) {
- ((GenericGeneratorHolder)subject).removeGenericGenerator();
+ else if (!value && (getGenerator(subject) != null)) {
+ ((GenericGeneratorHolder)subject).removeGenericGenerator(0);
}
}
};
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-07-23 13:40:36 UTC (rev 16747)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateUIMappingMessages.java 2009-07-23 14:04:34 UTC (rev 16748)
@@ -19,7 +19,7 @@
public class HibernateUIMappingMessages extends NLS {
private static final String BUNDLE_NAME = "org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.messages"; //$NON-NLS-1$
-
+
public static String GenericGeneratorComposite_name;
public static String GenericGeneratorComposite_strategy;
public static String HibernateGeneratorsComposite_CheckBoxLabel;
@@ -35,7 +35,12 @@
public static String NamedQueryPropertyComposite_timeout;
public static String HibernateAddQueryDialog_hibernateNamedQuery;
public static String HibernateAddQueryDialog_hibernateNamedNativeQuery;
-
+ public static String GenericGeneratorsComposite_generatorNullName;
+ public static String GenericGeneratorsComposite_addGeneratorNameDescription;
+ public static String EnterNameDialog_title;
+ public static String EnterNameDialog_labelText;
+ public static String NameStateObject_nameMustBeSpecified;
+ public static String NameStateObject_nameAlreadyExists;
private HibernateUIMappingMessages() {}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java 2009-07-23 13:40:36 UTC (rev 16747)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/ParametersComposite.java 2009-07-23 14:04:34 UTC (rev 16748)
@@ -19,8 +19,6 @@
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.GeneratorHolder;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
import org.eclipse.jpt.ui.internal.swt.ColumnAdapter;
import org.eclipse.jpt.ui.internal.util.PaneEnabler;
@@ -42,15 +40,14 @@
import org.eclipse.swt.widgets.TableItem;
import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGenerator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorHolder;
/**
* @author Dmitry Geraskov
*
*/
-public class ParametersComposite extends Pane<GeneratorHolder> {
+public class ParametersComposite extends Pane<GenericGenerator> {
- private PropertyValueModel<Generator> generatorHolder;
+ //private WritablePropertyValueModel<GenericGenerator> generatorHolder;
private WritablePropertyValueModel<Parameter> parameterHolder;
@@ -60,20 +57,17 @@
* @param parentPane The parent pane of this one
* @param parent The parent container
*/
- public ParametersComposite(Pane<? extends GeneratorHolder> parentPane,
- Composite container) {
+ public ParametersComposite(Pane<?> parentPane,
+ Composite container, WritablePropertyValueModel<GenericGenerator> generatorHolder) {
- super(parentPane,container);
+ super(parentPane, generatorHolder, container, false);
}
-
- protected GenericGenerator getGenericGenerator(){
- return ((GenericGeneratorHolder) getSubject()).getGenericGenerator();
- }
+
private PropertyValueModel<Boolean> buildPaneEnableHolder() {
- return new TransformationPropertyValueModel<GeneratorHolder, Boolean>(getSubjectHolder()) {
+ return new TransformationPropertyValueModel<GenericGenerator, Boolean>(getSubjectHolder()) {
@Override
- protected Boolean transform(GeneratorHolder generator) {
+ protected Boolean transform(GenericGenerator generator) {
return (generator != null);
}
};
@@ -82,13 +76,13 @@
private Adapter buildParameterAdapter() {
return new AddRemoveTablePane.AbstractAdapter() {
public void addNewItem(ObjectListSelectionModel listSelectionModel) {
- Parameter parameter = getGenericGenerator().addParameter(getGenericGenerator().parametersSize());
+ Parameter parameter = getSubject().addParameter(getSubject().parametersSize());
parameterHolder.setValue(parameter);
}
public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
for (Object item : listSelectionModel.selectedValues()) {
- getGenericGenerator().removeParameter((Parameter) item);
+ getSubject().removeParameter((Parameter) item);
}
}
};
@@ -103,23 +97,21 @@
}
private ListValueModel<Parameter> buildParameterListHolder() {
- return new ListAspectAdapter<Generator, Parameter>(
- generatorHolder,
+ return new ListAspectAdapter<GenericGenerator, Parameter>(
+ getSubjectHolder(),
GenericGenerator.PARAMETERS_LIST) {
@Override
protected ListIterator<Parameter> listIterator_() {
- GenericGenerator generator = (GenericGenerator) subject;
- if (generator == null ){
+ if (subject == null ){
return EmptyListIterator.instance();
} else {
- return generator.parameters();
+ return subject.parameters();
}
}
@Override
protected int size_() {
- GenericGenerator generator = (GenericGenerator) subject;
- return generator == null ? 0 : generator.parametersSize();
+ return subject == null ? 0 : subject.parametersSize();
}
};
}
@@ -127,20 +119,9 @@
@Override
protected void initialize() {
super.initialize();
- this.generatorHolder = buildGeneratorHolder();
parameterHolder = buildParameterHolder();
}
- private PropertyValueModel<Generator> buildGeneratorHolder() {
- return new PropertyAspectAdapter<GeneratorHolder, Generator>(getSubjectHolder(),
- GenericGeneratorHolder.GENERIC_GENERATOR_PROPERTY) {
- @Override
- protected Generator buildValue_() {
- return ParametersComposite.this.getGenericGenerator();
- }
- };
- }
-
@Override
protected void initializeLayout(Composite container) {
@@ -247,7 +228,7 @@
}
}
- private class TablePane extends AddRemoveTablePane<GeneratorHolder> {
+ private class TablePane extends AddRemoveTablePane<GenericGenerator> {
private TablePane(Composite parent) {
super(ParametersComposite.this,
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-07-23 13:40:36 UTC (rev 16747)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/messages.properties 2009-07-23 14:04:34 UTC (rev 16748)
@@ -12,4 +12,10 @@
NamedQueryPropertyComposite_fetchSize=Fetch Size
NamedQueryPropertyComposite_timeout=Timeout
HibernateAddQueryDialog_hibernateNamedQuery=Named Query (hibernate)
-HibernateAddQueryDialog_hibernateNamedNativeQuery=Named Native Query (hibernate)
\ No newline at end of file
+HibernateAddQueryDialog_hibernateNamedNativeQuery=Named Native Query (hibernate)
+GenericGeneratorsComposite_generatorNullName=GenericGenerator_{0}
+GenericGeneratorsComposite_addGeneratorNameDescription=Enter a GenericGenerator name
+EnterNameDialog_title=Name dialog
+EnterNameDialog_labelText=Name
+NameStateObject_nameMustBeSpecified=A name must be specified
+NameStateObject_nameAlreadyExists=The name already exists.
\ No newline at end of file
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/EnterNameDialog.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/EnterNameDialog.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/EnterNameDialog.java 2009-07-23 14:04:34 UTC (rev 16748)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.widgets;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.ui.internal.widgets.DialogPane;
+import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateUIMappingMessages;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class EnterNameDialog extends ValidatingDialog<NameStateObject> {
+
+ private String description;
+ private Image descriptionImage;
+ private String descriptionTitle;
+ private String labelText;
+ private String name;
+ private Collection<String> names;
+
+ public EnterNameDialog(Shell parentShell, String descriptionTitle){
+ this(parentShell, descriptionTitle, null, null);
+ }
+
+ public EnterNameDialog(Shell parentShell, String descriptionTitle, String name,
+ Collection<String> names){
+ this(parentShell,
+ HibernateUIMappingMessages.EnterNameDialog_title,
+ descriptionTitle,
+ null,
+ null,
+ HibernateUIMappingMessages.EnterNameDialog_labelText,
+ name,
+ names);
+ }
+
+ /**
+ * Creates a new <code>EnterNameDialog</code>.
+ *
+ */
+ public EnterNameDialog(Shell parentShell,
+ String dialogTitle,
+ String descriptionTitle,
+ Image descriptionImage,
+ String description,
+ String labelText,
+ String name,
+ Collection<String> names)
+ {
+ super(parentShell, dialogTitle);
+
+ this.name = name;
+ this.labelText = labelText;
+ this.description = description;
+ this.descriptionImage = descriptionImage;
+ this.descriptionTitle = descriptionTitle;
+ this.names = names;
+ }
+
+ @Override
+ protected DialogPane<NameStateObject> buildLayout(Composite container) {
+ return new NewNameDialogPane(container);
+ }
+
+ @Override
+ protected NameStateObject buildStateObject() {
+ return new NameStateObject(name, names);
+ }
+
+ @Override
+ public void create() {
+ super.create();
+
+ NewNameDialogPane pane = (NewNameDialogPane) getPane();
+ pane.selectAll();
+
+ getButton(OK).setEnabled(false);
+ }
+
+ @Override
+ protected String getDescription() {
+ return description;
+ }
+
+ @Override
+ protected Image getDescriptionImage() {
+ return descriptionImage;
+ }
+
+ @Override
+ protected String getDescriptionTitle() {
+ return descriptionTitle;
+ }
+
+ /**
+ * Returns the text field's input, which is the new name the user entered.
+ *
+ * @return The name the user entered
+ */
+ public String getName() {
+ return getSubject().getName();
+ }
+
+ private class NewNameDialogPane extends DialogPane<NameStateObject> {
+
+ private Text text;
+
+ NewNameDialogPane(Composite parent) {
+ super(EnterNameDialog.this.getSubjectHolder(), parent);
+ }
+
+ private WritablePropertyValueModel<String> buildNameHolder() {
+ return new PropertyAspectAdapter<NameStateObject, String>(getSubjectHolder(), NameStateObject.NAME_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return subject.getName();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ subject.setName(value);
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ text = addLabeledText(
+ container,
+ labelText,
+ buildNameHolder()
+ );
+ }
+
+ void selectAll() {
+ text.selectAll();
+ }
+ }
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/EnterNameDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/NameStateObject.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/NameStateObject.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/NameStateObject.java 2009-07-23 14:04:34 UTC (rev 16748)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.internal.widgets;
+
+import java.util.Collection;
+import java.util.List;
+
+
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.node.AbstractNode;
+import org.eclipse.jpt.utility.internal.node.Node;
+import org.eclipse.jpt.utility.internal.node.Problem;
+import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateUIMappingMessages;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+final class NameStateObject extends AbstractNode
+{
+ /**
+ * The initial name or <code>null</code>
+ */
+ private String name;
+
+ /**
+ * The collection of names that can't be used or an empty collection if none
+ * are available.
+ */
+ private Collection<String> names;
+
+ /**
+ * The <code>Validator</code> used to validate this state object.
+ */
+ private Validator validator;
+
+ /**
+ * Notifies a change in the data value property.
+ */
+ static final String NAME_PROPERTY = "nameProperty"; //$NON-NLS-1$
+
+ /**
+ * Creates a new <code>NameStateObject</code>.
+ *
+ * @param name The initial input or <code>null</code> if no initial value can
+ * be specified
+ * @param names The collection of names that can't be used or an empty
+ * collection if none are available
+ */
+ NameStateObject(String name, Collection<String> names) {
+ super(null);
+ this.name = name;
+ this.names = names;
+ }
+
+ private void addNameProblemsTo(List<Problem> currentProblems) {
+ if (StringTools.stringIsEmpty(this.name)) {
+ currentProblems.add(buildProblem(HibernateUIMappingMessages.NameStateObject_nameMustBeSpecified));
+ } else if (names != null && names.contains(name.trim())) {
+ currentProblems.add(buildProblem(HibernateUIMappingMessages.NameStateObject_nameAlreadyExists));
+ }
+ }
+
+ @Override
+ protected void addProblemsTo(List<Problem> currentProblems) {
+ super.addProblemsTo(currentProblems);
+ addNameProblemsTo(currentProblems);
+ }
+
+ @Override
+ protected void checkParent(Node parentNode) {
+ //no parent
+ }
+
+ public String displayString() {
+ return null;
+ }
+
+ String getName() {
+ return this.name;
+ }
+
+ public void setName(String newName) {
+ String oldName = this.name;
+ this.name = newName;
+ firePropertyChanged(NAME_PROPERTY, oldName, newName);
+ }
+
+ @Override
+ public void setValidator(Validator validator) {
+ this.validator = validator;
+ }
+
+ @Override
+ public Validator getValidator() {
+ return this.validator;
+ }
+}
\ No newline at end of file
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/widgets/NameStateObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
16 years, 9 months
JBoss Tools SVN: r16747 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal: context/basic and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-07-23 09:40:36 -0400 (Thu, 23 Jul 2009)
New Revision: 16747
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4649
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -15,11 +15,12 @@
import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider;
import org.eclipse.jpt.core.internal.platform.AbstractJpaAnnotationDefintionProvider;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotationDefinition;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotationDefinition;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotationDefinition;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotationDefinition;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceGenericGeneratorsAnnotation.GenericGeneratorsAnnotationDefinition;
/**
* @author Dmitry Geraskov
@@ -51,6 +52,7 @@
@Override
protected void addTypeSupportingAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) {
definitions.add(GenericGeneratorAnnotationDefinition.instance());
+ definitions.add(GenericGeneratorsAnnotationDefinition.instance());
definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
definitions.add(HibernateNamedQueriesAnnotationDefinition.instance());
definitions.add(HibernateNamedNativeQueryAnnotationDefinition.instance());
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -32,6 +32,9 @@
String GENERATOR_PARAMETER__NAME = "name"; //$NON-NLS-1$
String GENERATOR_PARAMETER__VALUE = "value"; //$NON-NLS-1$
+ String GENERIC_GENERATORS = PACKAGE_ + "GenericGenerators"; //$NON-NLS-1$
+ String GENERIC_GENERATORS__VALUE = "value"; //$NON-NLS-1$
+
String NAMED_QUERY = PACKAGE_ + "NamedQuery"; //$NON-NLS-1$
String NAMED_QUERY__NAME = "name"; //$NON-NLS-1$
String NAMED_QUERY__QUERY = "query"; //$NON-NLS-1$
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import java.util.ListIterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public interface GenericGeneratorAnnotation extends GeneratorAnnotation {
-
- String ANNOTATION_NAME = Hibernate.GENERIC_GENERATOR;
-
- /**
- * Corresponds to the strategy element of the GenericGenerator annotation.
- * Returns null if the strategy element does not exist in java.
- */
- String getStrategy();
-
- /**
- * Corresponds to the strategy element of the GenericGenerator annotation.
- * Set to null to remove the strategy element.
- */
- void setStrategy(String strategy);
- String STRATEGY_PROPERTY = "strategyProperty"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator annotation.
- * Return an empty iterator if the element does not exist in Java.
- */
- ListIterator<ParameterAnnotation> parameters();
- String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator annotation.
- */
- int parametersSize();
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator annotation.
- */
- ParameterAnnotation parameterAt(int index);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator annotation.
- */
- int indexOfParameter(ParameterAnnotation parameter);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator annotation.
- */
- ParameterAnnotation addParameter(int index);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator annotation.
- */
- void moveParameter(int targetIndex, int sourceIndex);
-
- /**
- * Corresponds to the 'parameters' element of the *Generic Generator annotation.
- */
- void removeParameter(int index);
-
- /**
- * Return the {@link TextRange} for the strategy element. If the strategy element
- * does not exist return the {@link TextRange} for the GenericGenerator annotation.
- */
- TextRange getStrategyTextRange(CompilationUnit astRoot);
-
-}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
-import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.AnnotationContainer;
-import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.NestableParameterAnnotation;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.SourceParameterAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class GenericGeneratorAnnotationImpl extends SourceAnnotation<Member>
- implements GenericGeneratorAnnotation {
-
- private final AnnotationElementAdapter<String> nameAdapter;
-
- private final AnnotationElementAdapter<String> strategyAdapter;
-
- private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
-
- private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildNameAdapter();
-
- private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter();
-
- final ParametersAnnotationContainer parametersContainer = new ParametersAnnotationContainer();
-
- private String name;
-
- private String strategy;
-
- final Vector<NestableParameterAnnotation> parameters = new Vector<NestableParameterAnnotation>();
-
- private Integer initialValue = 1;
-
- private Integer allocationSize = 50;
-
- /**
- * @param parent
- * @param member
- */
- public GenericGeneratorAnnotationImpl(JavaResourcePersistentMember parent, Member member) {
- super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
- this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, NAME_ADAPTER);
- this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, STRATEGY_ADAPTER);
- }
-
- public void initialize(CompilationUnit astRoot) {
- this.name = this.name(astRoot);
- this.strategy = this.strategy(astRoot);
- AnnotationContainerTools.initialize(this.parametersContainer, astRoot);
- }
-
- public void update(CompilationUnit astRoot) {
- this.setStrategy(this.strategy(astRoot));
- this.setName(this.name(astRoot));
- AnnotationContainerTools.update(this.parametersContainer, astRoot);
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- public String getStrategy() {
- return this.strategy;
- }
-
- public void setStrategy(String newStrategy) {
- if (attributeValueHasNotChanged(this.strategy, newStrategy)) {
- return;
- }
- String oldStrategy = this.strategy;
- this.strategy = newStrategy;
- this.strategyAdapter.setValue(newStrategy);
- firePropertyChanged(STRATEGY_PROPERTY, oldStrategy, newStrategy);
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- if (attributeValueHasNotChanged(this.name, newName)) {
- return;
- }
- String oldName = this.name;
- this.name = newName;
- this.nameAdapter.setValue(newName);
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(NAME_ADAPTER, astRoot);
- }
-
- public TextRange getStrategyTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(STRATEGY_ADAPTER, astRoot);
- }
-
- public Integer getAllocationSize() {
- return allocationSize;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getAllocationSizeTextRange(org.eclipse.jdt.core.dom.CompilationUnit)
- */
- public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getInitialValue()
- */
- public Integer getInitialValue() {
- return initialValue;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#getInitialValueTextRange(org.eclipse.jdt.core.dom.CompilationUnit)
- */
- public TextRange getInitialValueTextRange(CompilationUnit astRoot) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#setAllocationSize(java.lang.Integer)
- */
- public void setAllocationSize(Integer allocationSize) {
- this.allocationSize = allocationSize;
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.GeneratorAnnotation#setInitialValue(java.lang.Integer)
- */
- public void setInitialValue(Integer initialValue) {
- this.initialValue = initialValue;
-
- }
-
- // ********** java annotations -> persistence model **********
- protected String strategy(CompilationUnit astRoot) {
- //TODO: get Generator instead of String
- //use buildJavaGenericGenerator method before thi will be done
- return this.strategyAdapter.getValue(astRoot);
- }
-
- protected String name(CompilationUnit astRoot) {
- return this.nameAdapter.getValue(astRoot);
- }
-
- // ********** static methods **********
- private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, Hibernate.GENERIC_GENERATOR__NAME, false);
- }
-
- private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, Hibernate.GENERIC_GENERATOR__STRATEGY, false);
- }
-
-
- public static class GenericGeneratorAnnotationDefinition implements AnnotationDefinition
- {
- // singleton
- private static final GenericGeneratorAnnotationDefinition INSTANCE = new GenericGeneratorAnnotationDefinition();
-
- /**
- * Return the singleton.
- */
- public static AnnotationDefinition instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure non-instantiability.
- */
- private GenericGeneratorAnnotationDefinition() {
- super();
- }
-
- public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
- return new GenericGeneratorAnnotationImpl(parent, member);
- }
-
- public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) {
- return null;
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.AnnotationDefinition#buildAnnotation(org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember, org.eclipse.jdt.core.IAnnotation)
- */
- public Annotation buildAnnotation(JavaResourcePersistentMember arg0,
- IAnnotation arg1) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jpt.core.resource.java.AnnotationDefinition#buildNullAnnotation(org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember)
- */
- public Annotation buildNullAnnotation(JavaResourcePersistentMember arg0) {
- // TODO Auto-generated method stub
- return null;
- }
- }
-
- //************************ parameters ***********************
-
- public ParameterAnnotation addParameter(int index) {
- return (NestableParameterAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.parametersContainer);
- }
-
- NestableParameterAnnotation addParameterInternal() {
- NestableParameterAnnotation parameter = this.buildParameter(this.parameters.size());
- this.parameters.add(parameter);
- return parameter;
- }
-
- NestableParameterAnnotation buildParameter(int index) {
- return SourceParameterAnnotation.createGenericGeneratorParameter(this, this.member, this.daa, index);
- }
-
- ListIterator<NestableParameterAnnotation> nestableParameters() {
- return new CloneListIterator<NestableParameterAnnotation>(this.parameters);
- }
-
- void parameterAdded(int index, NestableParameterAnnotation parameter) {
- this.fireItemAdded(PARAMETERS_LIST, index, parameter);
- }
-
- NestableParameterAnnotation moveParameterInternal(int targetIndex, int sourceIndex) {
- return CollectionTools.move(this.parameters, targetIndex, sourceIndex).get(targetIndex);
- }
-
- void parameterMoved(int targetIndex, int sourceIndex) {
- this.fireItemMoved(PARAMETERS_LIST, targetIndex, sourceIndex);
- }
-
- public int indexOfParameter(ParameterAnnotation parameter) {
- return this.parameters.indexOf(parameter);
- }
-
- public void moveParameter(int targetIndex, int sourceIndex) {
- AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.parametersContainer);
- }
-
- public ParameterAnnotation parameterAt(int index) {
- return this.parameters.get(index);
- }
-
- public ListIterator<ParameterAnnotation> parameters() {
- return new CloneListIterator<ParameterAnnotation>(this.parameters);
- }
-
- public int parametersSize() {
- return parameters.size();
- }
-
- public void removeParameter(int index) {
- AnnotationContainerTools.removeNestedAnnotation(index, this.parametersContainer);
- }
-
- NestableParameterAnnotation removeParameterInternal(int index) {
- return this.parameters.remove(index);
- }
-
- void hintRemoved(int index, NestableParameterAnnotation parameter) {
- this.fireItemRemoved(PARAMETERS_LIST, index, parameter);
- }
-
- /**
- * adapt the AnnotationContainer interface to the override's join columns
- */
- class ParametersAnnotationContainer
- implements AnnotationContainer<NestableParameterAnnotation>
- {
- public String getContainerAnnotationName() {
- return GenericGeneratorAnnotationImpl.this.getAnnotationName();
- }
-
- public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) {
- return GenericGeneratorAnnotationImpl.this.getJdtAnnotation(astRoot);
- }
-
- public String getElementName() {
- return Hibernate.GENERIC_GENERATOR__PARAMETERS;
- }
-
- public String getNestableAnnotationName() {
- return ParameterAnnotation.ANNOTATION_NAME;
- }
-
- public ListIterator<NestableParameterAnnotation> nestedAnnotations() {
- return GenericGeneratorAnnotationImpl.this.nestableParameters();
- }
-
- public int nestedAnnotationsSize() {
- return GenericGeneratorAnnotationImpl.this.parametersSize();
- }
-
- public NestableParameterAnnotation addNestedAnnotationInternal() {
- return GenericGeneratorAnnotationImpl.this.addParameterInternal();
- }
-
- public void nestedAnnotationAdded(int index, NestableParameterAnnotation nestedAnnotation) {
- GenericGeneratorAnnotationImpl.this.parameterAdded(index, nestedAnnotation);
- }
-
- public NestableParameterAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) {
- return GenericGeneratorAnnotationImpl.this.moveParameterInternal(targetIndex, sourceIndex);
- }
-
- public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
- GenericGeneratorAnnotationImpl.this.parameterMoved(targetIndex, sourceIndex);
- }
-
- public NestableParameterAnnotation removeNestedAnnotationInternal(int index) {
- return GenericGeneratorAnnotationImpl.this.removeParameterInternal(index);
- }
-
- public void nestedAnnotationRemoved(int index, NestableParameterAnnotation nestedAnnotation) {
- GenericGeneratorAnnotationImpl.this.hintRemoved(index, nestedAnnotation);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- }
-
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorHolder.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+import java.util.ListIterator;
+
import org.eclipse.jpt.core.context.GeneratorHolder;
/**
@@ -17,13 +19,38 @@
*
*/
public interface GenericGeneratorHolder extends GeneratorHolder {
+
+ String GENERIC_GENERATORS_LIST = "genericGenerators"; //$NON-NLS-1$
- String GENERIC_GENERATOR_PROPERTY = "genericGenerator"; //$NON-NLS-1$
+ /**
+ * Return a list iterator of the generic generators.
+ * This will not be null.
+ */
+ <T extends GenericGenerator> ListIterator<T> genericGenerators();
- JavaGenericGenerator getGenericGenerator();
+ /**
+ * Return the number of generic generators.
+ */
+ int genericGeneratorsSize();
- JavaGenericGenerator addGenericGenerator();
+ /**
+ * Add a generic generator to the entity return the object representing it.
+ */
+ GenericGenerator addGenericGenerator(int index);
- void removeGenericGenerator();
+ /**
+ * Remove the generic generator at the index from the entity.
+ */
+ void removeGenericGenerator(int index);
+
+ /**
+ * Remove the generic generator from the entity.
+ */
+ void removeGenericGenerator(GenericGenerator generator);
+
+ /**
+ * Move the generic generator from the source index to the target index.
+ */
+ void moveGenericGenerator(int targetIndex, int sourceIndex);
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -31,7 +31,10 @@
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorsAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
@@ -42,7 +45,7 @@
public class HibernateJavaEntity extends AbstractJavaEntity
implements GenericGeneratorHolder, HibernateQueryContainer {
- protected JavaGenericGenerator genericGenerator;
+ protected final List<JavaGenericGenerator> genericGenerators;
protected final List<HibernateNamedQuery> hibernateNamedQueries;
@@ -50,6 +53,7 @@
public HibernateJavaEntity(JavaPersistentType parent) {
super(parent);
+ this.genericGenerators = new ArrayList<JavaGenericGenerator>();
this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
}
@@ -57,7 +61,7 @@
@Override
public void initialize(JavaResourcePersistentType resourcePersistentType) {
super.initialize(resourcePersistentType);
- this.initializeGenericGenerator();
+ this.initializeGenericGenerators();
this.initializeHibernateNamedQueries();
this.initializeHibernateNamedNativeQueries();
}
@@ -65,9 +69,13 @@
@Override
public void update(JavaResourcePersistentType resourcePersistentType) {
super.update(resourcePersistentType);
- this.updateGenericGenerator();
+ this.updateGenericGenerators();
this.updateHibernateNamedQueries();
this.updateHibernateNamedNativeQueries();
+ }
+
+ protected HibernateJpaFactory getJpaFactory() {
+ return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
}
@SuppressWarnings("unchecked")
@@ -79,95 +87,106 @@
this.hibernateNamedNativeQueries());
}
- // ********************* GenericGenerator **************
@SuppressWarnings("unchecked")
@Override
public Iterator<String> correspondingAnnotationNames() {
return new CompositeIterator<String>(
- new ArrayIterator<String>(Hibernate.GENERIC_GENERATOR,
- Hibernate.NAMED_QUERY,
- Hibernate.NAMED_QUERIES,
- Hibernate.NAMED_NATIVE_QUERY,
- Hibernate.NAMED_NATIVE_QUERIES),
+ new ArrayIterator<String>(
+ Hibernate.GENERIC_GENERATOR,
+ Hibernate.GENERIC_GENERATORS,
+ Hibernate.NAMED_QUERY,
+ Hibernate.NAMED_QUERIES,
+ Hibernate.NAMED_NATIVE_QUERY,
+ Hibernate.NAMED_NATIVE_QUERIES),
super.correspondingAnnotationNames());
}
- public void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = newGenericGenerator;
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator, newGenericGenerator);
+ // ********************* GenericGenerators **************
+
+ public GenericGenerator addGenericGenerator(int index) {
+ JavaGenericGenerator newGenericGenerator = getJpaFactory().buildJavaGenericGenerator(this);
+ this.genericGenerators.add(newGenericGenerator);
+ GenericGeneratorAnnotation genericGeneratorAnnotation = (GenericGeneratorAnnotation)this.javaResourcePersistentType
+ .addSupportingAnnotation(index, GenericGeneratorAnnotation.ANNOTATION_NAME, GenericGeneratorsAnnotation.ANNOTATION_NAME);
+ newGenericGenerator.initialize(genericGeneratorAnnotation);
+ fireItemAdded(GENERIC_GENERATORS_LIST, index, newGenericGenerator);
+ return newGenericGenerator;
}
- protected HibernateJpaFactory getJpaFactory() {
- return (HibernateJpaFactory) this.getJpaPlatform().getJpaFactory();
+ protected void addGenericGenerator(JavaGenericGenerator genericGenerator) {
+ this.addGenericGenerator(genericGeneratorsSize(), genericGenerator);
}
- protected void initializeGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource != null) {
- this.genericGenerator = buildGenericGenerator(genericGeneratorResource);
- }
+ protected void addGenericGenerator(int index, JavaGenericGenerator genericGenerator) {
+ addItemToList(index, genericGenerator, this.genericGenerators, GENERIC_GENERATORS_LIST);
}
- protected GenericGeneratorAnnotation getResourceGenericGenerator() {
- return (GenericGeneratorAnnotation) this.javaResourcePersistentType.getSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
+ @SuppressWarnings("unchecked")
+ public ListIterator<JavaGenericGenerator> genericGenerators() {
+ return new CloneListIterator<JavaGenericGenerator>(genericGenerators);
}
-
- protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation genericGeneratorResource) {
- JavaGenericGenerator generator = getJpaFactory().buildJavaGenericGenerator(this);
- generator.initialize(genericGeneratorResource);
- return generator;
+
+ public int genericGeneratorsSize() {
+ return this.genericGenerators.size();
}
- public JavaGenericGenerator addGenericGenerator() {
- if (getGenericGenerator() != null) {
- throw new IllegalStateException("genericGenerator already exists"); //$NON-NLS-1$
- }
- this.genericGenerator = getJpaFactory().buildJavaGenericGenerator(this);
- GenericGeneratorAnnotation genericGeneratorResource = (GenericGeneratorAnnotation)javaResourcePersistentType
- .addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- this.genericGenerator.initialize(genericGeneratorResource);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, null, this.genericGenerator);
- return this.genericGenerator;
+ public void moveGenericGenerator(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.genericGenerators, targetIndex, sourceIndex);
+ this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex, GenericGeneratorAnnotation.ANNOTATION_NAME);
+ fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
}
- public JavaGenericGenerator getGenericGenerator() {
- return genericGenerator;
+ public void removeGenericGenerator(int index) {
+ JavaGenericGenerator removedGenericGenerator = this.genericGenerators.remove(index);
+ this.javaResourcePersistentType.removeSupportingAnnotation(index, GenericGeneratorAnnotation.ANNOTATION_NAME, GenericGeneratorsAnnotation.ANNOTATION_NAME);
+ fireItemRemoved(GENERIC_GENERATORS_LIST, index, removedGenericGenerator);
}
- public void removeGenericGenerator() {
- if (getGenericGenerator() == null) {
- throw new IllegalStateException("genericGenerator does not exist, cannot be removed"); //$NON-NLS-1$
+ public void removeGenericGenerator(GenericGenerator generator) {
+ removeGenericGenerator(this.genericGenerators.indexOf(generator));
+ }
+
+ protected void removeGenericGenerator_(JavaGenericGenerator generator) {
+ removeItemFromList(generator, this.genericGenerators, GENERIC_GENERATORS_LIST);
+ }
+
+ protected void initializeGenericGenerators() {
+ for (ListIterator<NestableAnnotation> stream = this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME, GenericGeneratorsAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
+ this.genericGenerators.add(buildGenericGenerator((GenericGeneratorAnnotation) stream.next()));
}
- JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
- this.genericGenerator = null;
- this.javaResourcePersistentType.removeSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator,null);
}
+ protected JavaGenericGenerator buildGenericGenerator(GenericGeneratorAnnotation genericGeneratorResource) {
+ JavaGenericGenerator generator = getJpaFactory().buildJavaGenericGenerator(this);
+ generator.initialize(genericGeneratorResource);
+ return generator;
+ }
+
@Override
protected void addGeneratorsTo(ArrayList<JavaGenerator> generators) {
super.addGeneratorsTo(generators);
- if (this.genericGenerator != null) {
- generators.add(this.genericGenerator);
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ generators.add(genericGenerator);
}
}
- protected void updateGenericGenerator() {
- GenericGeneratorAnnotation genericGeneratorResource = getResourceGenericGenerator();
- if (genericGeneratorResource == null) {
- if (getGenericGenerator() != null) {
- setGenericGenerator(null);
+ protected void updateGenericGenerators() {
+ ListIterator<JavaGenericGenerator> genericGenerators = genericGenerators();
+ ListIterator<NestableAnnotation> resourceGenericGenerators = this.javaResourcePersistentType.supportingAnnotations(GenericGeneratorAnnotation.ANNOTATION_NAME, GenericGeneratorsAnnotation.ANNOTATION_NAME);
+
+ while (genericGenerators.hasNext()) {
+ JavaGenericGenerator genericGenerator = genericGenerators.next();
+ if (resourceGenericGenerators.hasNext()) {
+ genericGenerator.update((GenericGeneratorAnnotation) resourceGenericGenerators.next());
}
- }
- else {
- if (getGenericGenerator() == null) {
- setGenericGenerator(buildGenericGenerator(genericGeneratorResource));
- }
else {
- getGenericGenerator().update(genericGeneratorResource);
+ removeGenericGenerator_(genericGenerator);
}
}
+
+ while (resourceGenericGenerators.hasNext()) {
+ addGenericGenerator(buildGenericGenerator((GenericGeneratorAnnotation) resourceGenericGenerators.next()));
+ }
}
// ********************* NamedQuery **************
public ListIterator<HibernateNamedQuery> hibernateNamedQueries() {
@@ -337,9 +356,9 @@
}
protected void validateGenericGenerator(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (genericGenerator != null){
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
genericGenerator.validate(messages, reporter, astRoot);
- }
+ }
}
@Override
@@ -349,8 +368,8 @@
if (result != null) {
return result;
}
- if (this.getGenericGenerator() != null) {
- result = this.getGenericGenerator().javaCompletionProposals(pos, filter, astRoot);
+ for (JavaGenericGenerator genericGenerator : genericGenerators) {
+ result = genericGenerator.javaCompletionProposals(pos, filter, astRoot);
if (result != null) {
return result;
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaIdMapping.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -12,6 +12,7 @@
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
@@ -20,10 +21,13 @@
import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
+import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
/**
* @author Dmitry Geraskov
@@ -71,7 +75,7 @@
: new SingleElementIterator(getGenericGenerator()));
}
- public JavaGenericGenerator addGenericGenerator() {
+ public JavaGenericGenerator addGenericGenerator(int index) {
if (getGenericGenerator() != null) {
throw new IllegalStateException("genericGenerator already exists"); //$NON-NLS-1$
}
@@ -79,28 +83,28 @@
GenericGeneratorAnnotation genericGeneratorResource = (GenericGeneratorAnnotation)getResourcePersistentAttribute()
.addSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
this.genericGenerator.initialize(genericGeneratorResource);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, null, this.genericGenerator);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, null, this.genericGenerator);
return this.genericGenerator;
}
- public JavaGenericGenerator getGenericGenerator() {
+ private JavaGenericGenerator getGenericGenerator() {
return genericGenerator;
}
- public void removeGenericGenerator() {
+ private void removeGenericGenerator() {
if (getGenericGenerator() == null) {
throw new IllegalStateException("genericGenerator does not exist, cannot be removed"); //$NON-NLS-1$
}
JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
this.genericGenerator = null;
this.getResourcePersistentAttribute().removeSupportingAnnotation(GenericGeneratorAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator,null);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator,null);
}
- public void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
+ private void setGenericGenerator(JavaGenericGenerator newGenericGenerator) {
JavaGenericGenerator oldGenericGenerator = this.genericGenerator;
this.genericGenerator = newGenericGenerator;
- firePropertyChanged(GENERIC_GENERATOR_PROPERTY, oldGenericGenerator, newGenericGenerator);
+ firePropertyChanged(GENERIC_GENERATORS_LIST, oldGenericGenerator, newGenericGenerator);
}
@Override
@@ -132,7 +136,7 @@
validateGenericGenerator(messages, reporter, astRoot);
}
- protected void validateGenericGenerator(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ private void validateGenericGenerator(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
if (genericGenerator != null){
genericGenerator.validate(messages, reporter, astRoot);
}
@@ -154,4 +158,30 @@
return null;
}
+ public ListIterator<GenericGenerator> genericGenerators() {
+ return genericGenerator == null ? EmptyListIterator.<GenericGenerator>instance()
+ : new SingleElementListIterator<GenericGenerator>(genericGenerator);
+ }
+
+ public int genericGeneratorsSize() {
+ return genericGenerator == null ? 0 : 1;
+ }
+
+ public void moveGenericGenerator(int targetIndex, int sourceIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeGenericGenerator(int index) {
+ if (genericGeneratorsSize() < index + 1){
+ throw new IndexOutOfBoundsException();
+ }
+ removeGenericGenerator();
+ }
+
+ public void removeGenericGenerator(GenericGenerator generator) {
+ if (this.genericGenerator == generator){
+ removeGenericGenerator();
+ }
+ }
+
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -11,6 +11,7 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaNamedNativeQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-/**
- * @author Dmitry Geraskov
- *
- * Corresponds to the Hibernate annotation
- * org.hibernate.annotations.NamedNativeQuery
- */
-public interface HibernateNamedNativeQueryAnnotation
- extends NestableNamedNativeQueryAnnotation, HibernateQueryAnnotation {
- //replace with Hibernate annotation
- String ANNOTATION_NAME = Hibernate.NAMED_NATIVE_QUERY;
-
- //************************ callable *********************************
- Boolean isCallable();
- void setCallable(Boolean value);
- String CALLABLE_PROPERTY = "callable"; //$NON-NLS-1$
-
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -12,6 +12,7 @@
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedNativeQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * @author Dmitry Geraskov
- *
- * Interface contains Hibernate specific attributes.
- */
-public interface HibernateQueryAnnotation {
-
- //************************ flushMode *********************************
-
- /**
- * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
- * Return null if the element does not exist in Java.
- */
- FlushModeType getFlushMode();
- String FLUSH_MODE_PROPERTY = "flushMode"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
- * Set to null to remove the element.
- */
- void setFlushMode(FlushModeType flushMode);
-
- /**
- * Return the {@link TextRange} for the 'flushMode' element. If element
- * does not exist return the {@link TextRange} for the *NamedQuery annotation.
- */
- TextRange getFlushModeTextRange(CompilationUnit astRoot);
-
- //************************ cacheMode *********************************
-
- /**
- * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
- * Return null if the element does not exist in Java.
- */
- CacheModeType getCacheMode();
- String CACHE_MODE_PROPERTY = "cacheMode"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
- * Set to null to remove the element.
- */
- void setCacheMode(CacheModeType cacheMode);
-
- /**
- * Return the {@link TextRange} for the 'cacheMode' element. If element
- * does not exist return the {@link TextRange} for the *NamedQuery annotation.
- */
- TextRange getCacheModeTextRange(CompilationUnit astRoot);
-
- //************************ cacheable *********************************
- Boolean isCacheable();
- void setCacheable(Boolean value);
- String CACHEABLE_PROPERTY = "cacheable"; //$NON-NLS-1$
-
- //************************ cacheRegion *********************************
- String getCacheRegion();
- void setCacheRegion(String value);
- String CACHE_REGION_PROPERTY = "cacheRegion"; //$NON-NLS-1$
-
- //************************ fetchSize *********************************
- Integer getFetchSize();
- void setFetchSize(Integer value);
- String FETCH_SIZE_PROPERTY = "fetchSize"; //$NON-NLS-1$
-
- //************************ timeout *********************************
- Integer getTimeout();
- void setTimeout(Integer value);
- String TIMEOUT_PROPERTY = "timeout"; //$NON-NLS-1$
-
- //************************ comment *********************************
- String getComment();
- void setComment(String value);
- String COMMENT_PROPERTY = "comment"; //$NON-NLS-1$
-
- //************************ readOnly *********************************
- Boolean isReadOnly();
- void setReadOnly(Boolean value);
- String READ_ONLY_PROPERTY = "readOnly"; //$NON-NLS-1$
-
-}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -1,613 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import java.util.ListIterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
-import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateSourceNamedNativeQueryAnnotation extends SourceAnnotation<Member> implements
- HibernateNamedNativeQueryAnnotation {
-
- public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
-
- private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
- private final AnnotationElementAdapter<String> nameAdapter;
- private String name;
-
- private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
- private final AnnotationElementAdapter<String> queryAdapter;
- private String query;
-
- private final DeclarationAnnotationElementAdapter<String> flushModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> flushModeAdapter;
- private FlushModeType flushMode;
-
- private final DeclarationAnnotationElementAdapter<String> cacheModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheModeAdapter;
- private CacheModeType cacheMode;
-
- private final DeclarationAnnotationElementAdapter<Boolean> cacheableDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> cacheableAdapter;
- private Boolean cacheable;
-
- private final DeclarationAnnotationElementAdapter<String> cacheRegionDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheRegionAdapter;
- private String cacheRegion;
-
- private final DeclarationAnnotationElementAdapter<Integer> fetchSizeDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
- private Integer fetchSize;
-
- private final DeclarationAnnotationElementAdapter<Integer> timeoutDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> timeoutAdapter;
- private Integer timeout;
-
- private final DeclarationAnnotationElementAdapter<String> commentDeclarationAdapter;
- private final AnnotationElementAdapter<String> commentAdapter;
- private String comment;
-
- private final DeclarationAnnotationElementAdapter<Boolean> readOnlyDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
- private Boolean readOnly;
-
- private final DeclarationAnnotationElementAdapter<Boolean> callableDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> callableAdapter;
- private Boolean callable;
-
- private final DeclarationAnnotationElementAdapter<String> resultClassDeclarationAdapter;
- private final AnnotationElementAdapter<String> resultClassAdapter;
- private String resultClass;
-
- private String fullyQualifiedResultClassName;
-
- private final DeclarationAnnotationElementAdapter<String> resultSetMappingDeclarationAdapter;
- private final AnnotationElementAdapter<String> resultSetMappingAdapter;
- private String resultSetMapping;
-
- HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
- super(parent, member, daa, annotationAdapter);
- this.nameDeclarationAdapter = this.buildNameAdapter(daa);
- this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
- this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
- this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
- this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
- this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, flushModeDeclarationAdapter);
- this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
- this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, cacheModeDeclarationAdapter);
- this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
- this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, cacheableDeclarationAdapter);
- this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
- this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
- this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
- this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, fetchSizeDeclarationAdapter);
- this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
- this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, timeoutDeclarationAdapter);
- this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
- this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, commentDeclarationAdapter);
- this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
- this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, readOnlyDeclarationAdapter);
- this.callableDeclarationAdapter = this.buildReadOnlyAdapter(daa);
- this.callableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, callableDeclarationAdapter);
- this.resultClassDeclarationAdapter = this.buildResultClassAdapter(daa);
- this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter);
- this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa);
- this.resultSetMappingAdapter = this.buildAdapter(this.resultSetMappingDeclarationAdapter);
- }
-
- public void initialize(CompilationUnit astRoot) {
- this.name = this.buildName(astRoot);
- this.query = this.buildQuery(astRoot);
- this.flushMode = this.buildFlushMode(astRoot);
- this.cacheMode = this.buildCacheMode(astRoot);
- this.cacheable = this.buildCacheable(astRoot);
- this.cacheRegion = this.buildCacheRegion(astRoot);
- this.fetchSize = this.buildFetchSize(astRoot);
- this.timeout = this.buildTimeout(astRoot);
- this.comment = this.buildComment(astRoot);
- this.readOnly = this.buildReadOnly(astRoot);
- this.callable = this.buildCallable(astRoot);
- this.resultClass = this.buildResultClass(astRoot);
- this.fullyQualifiedResultClassName = this.buildFullyQualifiedResultClassName(astRoot);
- this.resultSetMapping = this.buildResultSetMapping(astRoot);
- }
-
- public void update(CompilationUnit astRoot) {
- this.setName(this.buildName(astRoot));
- this.setQuery(this.buildQuery(astRoot));
- this.setFlushMode(this.buildFlushMode(astRoot));
- this.setCacheMode(this.buildCacheMode(astRoot));
- this.setCacheable(this.buildCacheable(astRoot));
- this.setCacheRegion(this.buildCacheRegion(astRoot));
- this.setFetchSize(this.buildFetchSize(astRoot));
- this.setTimeout(this.buildTimeout(astRoot));
- this.setComment(this.buildComment(astRoot));
- this.setReadOnly(this.buildReadOnly(astRoot));
- this.setCallable(this.buildCallable(astRoot));
- this.setResultClass(this.buildResultClass(astRoot));
- this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot));
- this.setResultSetMapping(this.buildResultSetMapping(astRoot));
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- /**
- * convenience method
- */
- AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
- return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
- }
-
- // ********** BaseNamedNativeQueryAnnotation implementation **********
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- if (this.attributeValueHasNotChanged(this.name, name)) {
- return;
- }
- String old = this.name;
- this.name = name;
- this.nameAdapter.setValue(name);
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- private String buildName(CompilationUnit astRoot) {
- return this.nameAdapter.getValue(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
- }
-
- // ***** query
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String query) {
- if (this.attributeValueHasNotChanged(this.query, query)) {
- return;
- }
- String old = this.query;
- this.query = query;
- this.queryAdapter.setValue(query);
- this.firePropertyChanged(QUERY_PROPERTY, old, query);
- }
-
- private String buildQuery(CompilationUnit astRoot) {
- return this.queryAdapter.getValue(astRoot);
- }
-
- public TextRange getQueryTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
- }
-
- String getQueryElementName() {
- return Hibernate.NAMED_NATIVE_QUERY__QUERY;
- }
-
- // ***** hints
- public ListIterator<QueryHintAnnotation> hints() {
- return EmptyListIterator.instance();
- }
-
- ListIterator<NestableQueryHintAnnotation> nestableHints() {
- return EmptyListIterator.instance();
- }
-
- public int hintsSize() {
- return 0;
- }
-
- public NestableQueryHintAnnotation hintAt(int index) {
- throw new UnsupportedOperationException();
- }
-
- public int indexOfHint(QueryHintAnnotation queryHint) {
- return -1;
- }
-
- public NestableQueryHintAnnotation addHint(int index) {
- return null;
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer);
- }
-
- public void removeHint(int index) {
- //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
- }
-
- // ******************** HibernateNamedNativeQueryAnnotation implementation *************
- // ***** flushMode
-
- public FlushModeType getFlushMode() {
- return flushMode;
- }
-
- public void setFlushMode(FlushModeType flushMode) {
- if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
- return;
- }
- FlushModeType old = this.flushMode;
- this.flushMode = flushMode;
- this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
- this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
- }
-
- private FlushModeType buildFlushMode(CompilationUnit astRoot) {
- return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
- }
-
- public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
- }
-
- // ***** caheMode
-
- public CacheModeType getCacheMode() {
- return cacheMode;
- }
-
- public void setCacheMode(CacheModeType cacheMode) {
- if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
- return;
- }
- CacheModeType old = this.cacheMode;
- this.cacheMode = cacheMode;
- this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
- this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
- }
-
- private CacheModeType buildCacheMode(CompilationUnit astRoot) {
- return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
- }
-
- public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
- }
-
- //************************ cacheable *********************************
- public Boolean isCacheable(){
- return this.cacheable;
- }
-
- public void setCacheable(Boolean cacheable){
- if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
- return;
- }
- Boolean old = this.cacheable;
- this.cacheable = cacheable;
- this.cacheableAdapter.setValue(cacheable);
- this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
- }
-
- private Boolean buildCacheable(CompilationUnit astRoot) {
- return this.cacheableAdapter.getValue(astRoot);
- }
-
- //************************ cacheRegion *********************************
- public String getCacheRegion(){
- return this.cacheRegion;
- }
-
- public void setCacheRegion(String cacheRegion){
- if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
- return;
- }
- String old = this.cacheRegion;
- this.cacheRegion = cacheRegion;
- this.cacheRegionAdapter.setValue(cacheRegion);
- this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
- }
-
- private String buildCacheRegion(CompilationUnit astRoot) {
- return this.cacheRegionAdapter.getValue(astRoot);
- }
- //************************ fetchSize *********************************
- public Integer getFetchSize(){
- return this.fetchSize;
- }
-
- public void setFetchSize(Integer fetchSize){
- if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
- return;
- }
- Integer old = this.fetchSize;
- this.fetchSize = fetchSize;
- this.fetchSizeAdapter.setValue(fetchSize);
- this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
- }
-
- private Integer buildFetchSize(CompilationUnit astRoot) {
- return this.fetchSizeAdapter.getValue(astRoot);
- }
- //************************ timeout *********************************
- public Integer getTimeout(){
- return this.timeout;
- }
- public void setTimeout(Integer timeout){
- if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
- return;
- }
- Integer old = this.timeout;
- this.timeout = timeout;
- this.timeoutAdapter.setValue(timeout);
- this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
- }
-
- private Integer buildTimeout(CompilationUnit astRoot) {
- return this.timeoutAdapter.getValue(astRoot);
- }
- //************************ comment *********************************
- public String getComment(){
- return this.comment;
- }
-
- public void setComment(String comment){
- if (this.attributeValueHasNotChanged(this.comment, comment)) {
- return;
- }
- String old = this.comment;
- this.comment = comment;
- this.commentAdapter.setValue(comment);
- this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
- }
-
- private String buildComment(CompilationUnit astRoot) {
- return this.commentAdapter.getValue(astRoot);
- }
- //************************ readOnly *********************************
- public Boolean isReadOnly(){
- return this.readOnly;
- }
-
- public void setReadOnly(Boolean readOnly){
- if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
- return;
- }
- Boolean old = this.readOnly;
- this.readOnly = readOnly;
- this.readOnlyAdapter.setValue(readOnly);
- this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
- }
-
- private Boolean buildReadOnly(CompilationUnit astRoot) {
- return this.readOnlyAdapter.getValue(astRoot);
- }
- //************************ callable *********************************
- public Boolean isCallable(){
- return this.callable;
- }
-
- public void setCallable(Boolean callable){
- if (this.attributeValueHasNotChanged(this.callable, callable)) {
- return;
- }
- Boolean old = this.callable;
- this.callable = callable;
- this.callableAdapter.setValue(callable);
- this.firePropertyChanged(CALLABLE_PROPERTY, old, callable);
- }
-
- private Boolean buildCallable(CompilationUnit astRoot) {
- return this.callableAdapter.getValue(astRoot);
- }
- // ***** result class
- public String getResultClass() {
- return this.resultClass;
- }
-
- public void setResultClass(String resultClass) {
- if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) {
- return;
- }
- String old = this.resultClass;
- this.resultClass = resultClass;
- this.resultClassAdapter.setValue(resultClass);
- this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass);
- }
-
- private String buildResultClass(CompilationUnit astRoot) {
- return this.resultClassAdapter.getValue(astRoot);
- }
-
- public TextRange getResultClassTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot);
- }
-
- // ***** fully-qualified result class name
- public String getFullyQualifiedResultClassName() {
- return this.fullyQualifiedResultClassName;
- }
-
- private void setFullyQualifiedResultClassName(String name) {
- String old = this.fullyQualifiedResultClassName;
- this.fullyQualifiedResultClassName = name;
- this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name);
- }
-
- private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) {
- return (this.resultClass == null) ? null : JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot));
- }
-
- // ***** result set mapping
- public String getResultSetMapping() {
- return this.resultSetMapping;
- }
-
- public void setResultSetMapping(String resultSetMapping) {
- if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) {
- return;
- }
- String old = this.resultSetMapping;
- this.resultSetMapping = resultSetMapping;
- this.resultSetMappingAdapter.setValue(resultSetMapping);
- this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping);
- }
-
- private String buildResultSetMapping(CompilationUnit astRoot) {
- return this.resultSetMappingAdapter.getValue(astRoot);
- }
-
- public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot);
- }
- // ********** NestableAnnotation implementation **********
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void initializeFrom(NestableAnnotation oldAnnotation) {
- HibernateSourceNamedNativeQueryAnnotation oldQuery = (HibernateSourceNamedNativeQueryAnnotation) oldAnnotation;
- this.setName(oldQuery.getName());
- this.setQuery(oldQuery.getQuery());
- this.setFlushMode(oldQuery.getFlushMode());
- this.setCacheMode(oldQuery.getCacheMode());
- this.setCacheable(oldQuery.isCacheable());
- this.setComment(oldQuery.getComment());
- this.setFetchSize(oldQuery.getFetchSize());
- this.setTimeout(oldQuery.getTimeout());
- this.setCacheRegion(oldQuery.getCacheRegion());
- this.setReadOnly(oldQuery.isReadOnly());
- this.setCallable(oldQuery.isCallable());
- this.setResultClass(oldQuery.getResultClass());
- this.setResultSetMapping(oldQuery.getResultSetMapping());
- }
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void moveAnnotation(int newIndex) {
- this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
- }
-
- private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
- return (IndexedAnnotationAdapter) this.annotationAdapter;
- }
-
- public static HibernateNamedNativeQueryAnnotation createNamedNativeQuery(JavaResourceNode parent, Member member) {
- return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__NAME);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__QUERY);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_NATIVE_QUERY__FLUSH_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHE_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean> buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHEABLE);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHE_REGION);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer> buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_NATIVE_QUERY__FETCH_SIZE);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer> buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_NATIVE_QUERY__TIMEOUT);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__COMMENT);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean> buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__READ_ONLY);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean> buildCallableAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CALLABLE);
- }
-
-
- private DeclarationAnnotationElementAdapter<String> buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new ConversionDeclarationAnnotationElementAdapter<String>(daAdapter, Hibernate.NAMED_NATIVE_QUERY__RESULT_CLASS, SimpleTypeStringExpressionConverter.instance());
- }
-
- private DeclarationAnnotationElementAdapter<String> buildResultSetMappingAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- // ********** static methods **********
-
- public static HibernateSourceNamedNativeQueryAnnotation createHibernateNamedNativeQuery(JavaResourceNode parent, Member member) {
- return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
- }
-
- public static HibernateSourceNamedNativeQueryAnnotation createNestedHibernateNamedNativeQuery(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
- IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
- IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa);
- return new HibernateSourceNamedNativeQueryAnnotation(parent, member, idaa, annotationAdapter);
- }
-
- private static IndexedDeclarationAnnotationAdapter buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter hibernateNamedNativeQueriesAdapter) {
- return new NestedIndexedDeclarationAnnotationAdapter(hibernateNamedNativeQueriesAdapter, index, Hibernate.NAMED_NATIVE_QUERY);
- }
-
-}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -1,489 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import java.util.ListIterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
-import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
-import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<Member>
- implements HibernateNamedQueryAnnotation {
-
- public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
-
- private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
- private final AnnotationElementAdapter<String> nameAdapter;
- private String name;
-
- private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
- private final AnnotationElementAdapter<String> queryAdapter;
- private String query;
-
- private final DeclarationAnnotationElementAdapter<String> flushModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> flushModeAdapter;
- private FlushModeType flushMode;
-
- private final DeclarationAnnotationElementAdapter<String> cacheModeDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheModeAdapter;
- private CacheModeType cacheMode;
-
- private final DeclarationAnnotationElementAdapter<Boolean> cacheableDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> cacheableAdapter;
- private Boolean cacheable;
-
- private final DeclarationAnnotationElementAdapter<String> cacheRegionDeclarationAdapter;
- private final AnnotationElementAdapter<String> cacheRegionAdapter;
- private String cacheRegion;
-
- private final DeclarationAnnotationElementAdapter<Integer> fetchSizeDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
- private Integer fetchSize;
-
- private final DeclarationAnnotationElementAdapter<Integer> timeoutDeclarationAdapter;
- private final AnnotationElementAdapter<Integer> timeoutAdapter;
- private Integer timeout;
-
- private final DeclarationAnnotationElementAdapter<String> commentDeclarationAdapter;
- private final AnnotationElementAdapter<String> commentAdapter;
- private String comment;
-
- private final DeclarationAnnotationElementAdapter<Boolean> readOnlyDeclarationAdapter;
- private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
- private Boolean readOnly;
-
- HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
- super(parent, member, daa, annotationAdapter);
- this.nameDeclarationAdapter = this.buildNameAdapter(daa);
- this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
- this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
- this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
- this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
- this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, flushModeDeclarationAdapter);
- this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
- this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, cacheModeDeclarationAdapter);
- this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
- this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, cacheableDeclarationAdapter);
- this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
- this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
- this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
- this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, fetchSizeDeclarationAdapter);
- this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
- this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, timeoutDeclarationAdapter);
- this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
- this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, commentDeclarationAdapter);
- this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
- this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, readOnlyDeclarationAdapter);
- }
-
- public void initialize(CompilationUnit astRoot) {
- this.name = this.buildName(astRoot);
- this.query = this.buildQuery(astRoot);
- this.flushMode = this.buildFlushMode(astRoot);
- this.cacheMode = this.buildCacheMode(astRoot);
- this.cacheable = this.buildCacheable(astRoot);
- this.cacheRegion = this.buildCacheRegion(astRoot);
- this.fetchSize = this.buildFetchSize(astRoot);
- this.timeout = this.buildTimeout(astRoot);
- this.comment = this.buildComment(astRoot);
- this.readOnly = this.buildReadOnly(astRoot);
- }
-
- public void update(CompilationUnit astRoot) {
- this.setName(this.buildName(astRoot));
- this.setQuery(this.buildQuery(astRoot));
- this.setFlushMode(this.buildFlushMode(astRoot));
- this.setCacheMode(this.buildCacheMode(astRoot));
- this.setCacheable(this.buildCacheable(astRoot));
- this.setCacheRegion(this.buildCacheRegion(astRoot));
- this.setFetchSize(this.buildFetchSize(astRoot));
- this.setTimeout(this.buildTimeout(astRoot));
- this.setComment(this.buildComment(astRoot));
- this.setReadOnly(this.buildReadOnly(astRoot));
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- /**
- * convenience method
- */
- AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
- return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
- }
-
- // ********** BaseNamedQueryAnnotation implementation **********
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- if (this.attributeValueHasNotChanged(this.name, name)) {
- return;
- }
- String old = this.name;
- this.name = name;
- this.nameAdapter.setValue(name);
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- private String buildName(CompilationUnit astRoot) {
- return this.nameAdapter.getValue(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
- }
-
- // ***** query
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String query) {
- if (this.attributeValueHasNotChanged(this.query, query)) {
- return;
- }
- String old = this.query;
- this.query = query;
- this.queryAdapter.setValue(query);
- this.firePropertyChanged(QUERY_PROPERTY, old, query);
- }
-
- private String buildQuery(CompilationUnit astRoot) {
- return this.queryAdapter.getValue(astRoot);
- }
-
- public TextRange getQueryTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
- }
-
- String getQueryElementName() {
- return Hibernate.NAMED_QUERY__QUERY;
- }
-
- // ***** hints
- public ListIterator<QueryHintAnnotation> hints() {
- return EmptyListIterator.instance();
- }
-
- ListIterator<NestableQueryHintAnnotation> nestableHints() {
- return EmptyListIterator.instance();
- }
-
- public int hintsSize() {
- return 0;
- }
-
- public NestableQueryHintAnnotation hintAt(int index) {
- throw new UnsupportedOperationException();
- }
-
- public int indexOfHint(QueryHintAnnotation queryHint) {
- return -1;
- }
-
- public NestableQueryHintAnnotation addHint(int index) {
- return null;
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer);
- }
-
- public void removeHint(int index) {
- //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
- }
-
- // ******************** HibernateNamedQueryAnnotation implementation *************
- // ***** flushMode
-
- public FlushModeType getFlushMode() {
- return flushMode;
- }
-
- public void setFlushMode(FlushModeType flushMode) {
- if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
- return;
- }
- FlushModeType old = this.flushMode;
- this.flushMode = flushMode;
- this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
- this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
- }
-
- private FlushModeType buildFlushMode(CompilationUnit astRoot) {
- return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
- }
-
- public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
- }
-
- // ***** caheMode
-
- public CacheModeType getCacheMode() {
- return cacheMode;
- }
-
- public void setCacheMode(CacheModeType cacheMode) {
- if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
- return;
- }
- CacheModeType old = this.cacheMode;
- this.cacheMode = cacheMode;
- this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
- this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
- }
-
- private CacheModeType buildCacheMode(CompilationUnit astRoot) {
- return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
- }
-
- public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
- return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
- }
-
- //************************ cacheable *********************************
- public Boolean isCacheable(){
- return this.cacheable;
- }
-
- public void setCacheable(Boolean cacheable){
- if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
- return;
- }
- Boolean old = this.cacheable;
- this.cacheable = cacheable;
- this.cacheableAdapter.setValue(cacheable);
- this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
- }
-
- private Boolean buildCacheable(CompilationUnit astRoot) {
- return this.cacheableAdapter.getValue(astRoot);
- }
-
- //************************ cacheRegion *********************************
- public String getCacheRegion(){
- return this.cacheRegion;
- }
-
- public void setCacheRegion(String cacheRegion){
- if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
- return;
- }
- String old = this.cacheRegion;
- this.cacheRegion = cacheRegion;
- this.cacheRegionAdapter.setValue(cacheRegion);
- this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
- }
-
- private String buildCacheRegion(CompilationUnit astRoot) {
- return this.cacheRegionAdapter.getValue(astRoot);
- }
- //************************ fetchSize *********************************
- public Integer getFetchSize(){
- return this.fetchSize;
- }
-
- public void setFetchSize(Integer fetchSize){
- if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
- return;
- }
- Integer old = this.fetchSize;
- this.fetchSize = fetchSize;
- this.fetchSizeAdapter.setValue(fetchSize);
- this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
- }
-
- private Integer buildFetchSize(CompilationUnit astRoot) {
- return this.fetchSizeAdapter.getValue(astRoot);
- }
- //************************ timeout *********************************
- public Integer getTimeout(){
- return this.timeout;
- }
- public void setTimeout(Integer timeout){
- if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
- return;
- }
- Integer old = this.timeout;
- this.timeout = timeout;
- this.timeoutAdapter.setValue(timeout);
- this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
- }
-
- private Integer buildTimeout(CompilationUnit astRoot) {
- return this.timeoutAdapter.getValue(astRoot);
- }
- //************************ comment *********************************
- public String getComment(){
- return this.comment;
- }
-
- public void setComment(String comment){
- if (this.attributeValueHasNotChanged(this.comment, comment)) {
- return;
- }
- String old = this.comment;
- this.comment = comment;
- this.commentAdapter.setValue(comment);
- this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
- }
-
- private String buildComment(CompilationUnit astRoot) {
- return this.commentAdapter.getValue(astRoot);
- }
- //************************ readOnly *********************************
- public Boolean isReadOnly(){
- return this.readOnly;
- }
-
- public void setReadOnly(Boolean readOnly){
- if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
- return;
- }
- Boolean old = this.readOnly;
- this.readOnly = readOnly;
- this.readOnlyAdapter.setValue(readOnly);
- this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
- }
-
- private Boolean buildReadOnly(CompilationUnit astRoot) {
- return this.readOnlyAdapter.getValue(astRoot);
- }
- // ********** NestableAnnotation implementation **********
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void initializeFrom(NestableAnnotation oldAnnotation) {
- HibernateSourceNamedQueryAnnotation oldQuery = (HibernateSourceNamedQueryAnnotation) oldAnnotation;
- this.setName(oldQuery.getName());
- this.setQuery(oldQuery.getQuery());
- this.setFlushMode(oldQuery.getFlushMode());
- this.setCacheMode(oldQuery.getCacheMode());
- this.setCacheable(oldQuery.isCacheable());
- this.setComment(oldQuery.getComment());
- this.setFetchSize(oldQuery.getFetchSize());
- this.setTimeout(oldQuery.getTimeout());
- this.setCacheRegion(oldQuery.getCacheRegion());
- this.setReadOnly(oldQuery.isReadOnly());
- }
-
- /**
- * convenience implementation of method from NestableAnnotation interface
- * for subclasses
- */
- public void moveAnnotation(int newIndex) {
- this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
- }
-
- private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
- return (IndexedAnnotationAdapter) this.annotationAdapter;
- }
-
- public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent, Member member) {
- return new HibernateSourceNamedQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__NAME);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__QUERY);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_QUERY__FLUSH_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
- return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_QUERY__CACHE_MODE);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean> buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_QUERY__CACHEABLE);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__CACHE_REGION);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer> buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_QUERY__FETCH_SIZE);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer> buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_QUERY__TIMEOUT);
- }
-
- protected DeclarationAnnotationElementAdapter<String> buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
- return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__COMMENT);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean> buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_QUERY__READ_ONLY);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- // ********** static methods **********
-
- public static HibernateSourceNamedQueryAnnotation createHibernateNamedQuery(JavaResourceNode parent, Member member) {
- return new HibernateSourceNamedQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
- }
-
- public static HibernateSourceNamedQueryAnnotation createNestedHibernateNamedQuery(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
- IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
- IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa);
- return new HibernateSourceNamedQueryAnnotation(parent, member, idaa, annotationAdapter);
- }
-
- private static IndexedDeclarationAnnotationAdapter buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter hibernateNamedQueriesAdapter) {
- return new NestedIndexedDeclarationAnnotationAdapter(hibernateNamedQueriesAdapter, index, Hibernate.NAMED_QUERY);
- }
-
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGenerator.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaGenerator;
import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
/**
* @author Dmitry Geraskov
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaGenericGeneratorImpl.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -30,6 +30,7 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.Messages;
import org.jboss.tools.hibernate.jpt.core.internal.context.Parameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit.LocalMessage;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.ParameterAnnotation;
/**
@@ -47,7 +48,9 @@
public static List<String> generatorClasses = new ArrayList<String>();
- //see org.hibernate.id.IdentifierGeneratorFactory.GENERATORS
+ /**
+ * @see org.hibernate.id.IdentifierGeneratorFactory.GENERATORS
+ */
static {
generatorClasses.add( "uuid"); //$NON-NLS-1$
generatorClasses.add( "hilo"); //$NON-NLS-1$
@@ -70,20 +73,14 @@
super(parent);
this.parameters = new ArrayList<JavaParameter>();
}
-
- public int getDefaultInitialValue() {
- return GenericGenerator.DEFAULT_INITIAL_VALUE;
- }
protected GenericGeneratorAnnotation getResourceGenerator() {
return this.generatorResource;
}
public void initialize(GenericGeneratorAnnotation generator) {
- generatorResource = generator;
+ this.generatorResource = generator;
this.name = generator.getName();
- this.specifiedInitialValue = generator.getInitialValue();
- this.specifiedAllocationSize = generator.getAllocationSize();
this.strategy = generator.getStrategy();
this.initializeParameters();
}
@@ -91,8 +88,6 @@
public void update(GenericGeneratorAnnotation generator) {
this.generatorResource = generator;
this.setName_(generator.getName());
- this.setSpecifiedInitialValue_(generator.getInitialValue());
- this.setSpecifiedAllocationSize_(generator.getAllocationSize());
this.setSpecifiedStrategy_(generator.getStrategy());
this.updateParameters();
this.getPersistenceUnit().addGenerator(this);
@@ -105,20 +100,6 @@
this.firePropertyChanged(Generator.NAME_PROPERTY, old, name);
}
- public void setSpecifiedInitialValue(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.generatorResource.setInitialValue(specifiedInitialValue);
- this.firePropertyChanged(Generator.SPECIFIED_INITIAL_VALUE_PROPERTY, old, specifiedInitialValue);
- }
-
- public void setSpecifiedAllocationSize(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.generatorResource.setAllocationSize(specifiedAllocationSize);
- this.firePropertyChanged(Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, specifiedAllocationSize);
- }
-
public TextRange getSelectionTextRange(CompilationUnit astRoot) {
return this.generatorResource.getTextRange(astRoot);
}
@@ -300,5 +281,10 @@
parameter.initialize(resourceParameter);
return parameter;
}
+
+ public int getDefaultInitialValue() {
+ return GenericGenerator.DEFAULT_INITIAL_VALUE;
+ }
+
}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotation.java (from rev 16283, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotation.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface GenericGeneratorAnnotation extends
+ NestableAnnotation, GeneratorAnnotation {
+
+ String ANNOTATION_NAME = Hibernate.GENERIC_GENERATOR;
+
+ /**
+ * Corresponds to the strategy element of the GenericGenerator annotation.
+ * Returns null if the strategy element does not exist in java.
+ */
+ String getStrategy();
+
+ /**
+ * Corresponds to the strategy element of the GenericGenerator annotation.
+ * Set to null to remove the strategy element.
+ */
+ void setStrategy(String strategy);
+ String STRATEGY_PROPERTY = "strategyProperty"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ * Return an empty iterator if the element does not exist in Java.
+ */
+ ListIterator<ParameterAnnotation> parameters();
+ String PARAMETERS_LIST = "parameters"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ int parametersSize();
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ ParameterAnnotation parameterAt(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ int indexOfParameter(ParameterAnnotation parameter);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ ParameterAnnotation addParameter(int index);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ void moveParameter(int targetIndex, int sourceIndex);
+
+ /**
+ * Corresponds to the 'parameters' element of the *Generic Generator annotation.
+ */
+ void removeParameter(int index);
+
+ /**
+ * Return the {@link TextRange} for the strategy element. If the strategy element
+ * does not exist return the {@link TextRange} for the GenericGenerator annotation.
+ */
+ TextRange getStrategyTextRange(CompilationUnit astRoot);
+
+}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java (from rev 16283, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/GenericGeneratorAnnotationImpl.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,384 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import java.util.ListIterator;
+import java.util.Vector;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationContainer;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenericGeneratorAnnotationImpl extends SourceAnnotation<Member>
+ implements GenericGeneratorAnnotation {
+
+ private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String> strategyDeclarationAdapter;
+ private final AnnotationElementAdapter<String> strategyAdapter;
+ private String strategy;
+
+ final Vector<NestableParameterAnnotation> parameters = new Vector<NestableParameterAnnotation>();
+ final ParametersAnnotationContainer parametersContainer = new ParametersAnnotationContainer();
+
+ /**
+ * @param parent
+ * @param member
+ */
+ public GenericGeneratorAnnotationImpl(JavaResourceNode parent, Member member,
+ DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, nameDeclarationAdapter);
+ this.strategyDeclarationAdapter = this.buildStrategyAdapter(daa);
+ this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, strategyDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.name(astRoot);
+ this.strategy = this.strategy(astRoot);
+ AnnotationContainerTools.initialize(this.parametersContainer, astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setStrategy(this.strategy(astRoot));
+ this.setName(this.name(astRoot));
+ AnnotationContainerTools.update(this.parametersContainer, astRoot);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public String getStrategy() {
+ return this.strategy;
+ }
+
+ public void setStrategy(String newStrategy) {
+ if (attributeValueHasNotChanged(this.strategy, newStrategy)) {
+ return;
+ }
+ String oldStrategy = this.strategy;
+ this.strategy = newStrategy;
+ this.strategyAdapter.setValue(newStrategy);
+ firePropertyChanged(STRATEGY_PROPERTY, oldStrategy, newStrategy);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String newName) {
+ if (attributeValueHasNotChanged(this.name, newName)) {
+ return;
+ }
+ String oldName = this.name;
+ this.name = newName;
+ this.nameAdapter.setValue(newName);
+ firePropertyChanged(NAME_PROPERTY, oldName, newName);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(nameDeclarationAdapter, astRoot);
+ }
+
+ public TextRange getStrategyTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(strategyDeclarationAdapter, astRoot);
+ }
+
+ public Integer getAllocationSize() {
+ return null;
+ }
+
+ public TextRange getAllocationSizeTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+ public Integer getInitialValue() {
+ return null;
+ }
+
+ public TextRange getInitialValueTextRange(CompilationUnit astRoot) {
+ return null;
+ }
+
+ public void setAllocationSize(Integer allocationSize) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setInitialValue(Integer initialValue) {
+ throw new UnsupportedOperationException();
+ }
+
+ // ********** java annotations -> persistence model **********
+ protected String strategy(CompilationUnit astRoot) {
+ //TODO: get Generator instead of String
+ //use buildJavaGenericGenerator method before this will be done
+ return this.strategyAdapter.getValue(astRoot);
+ }
+
+ protected String name(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+
+ //************************ parameters ***********************
+
+ public NestableParameterAnnotation addParameter(int index) {
+ return (NestableParameterAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation addParameterInternal() {
+ NestableParameterAnnotation parameter = this.buildParameter(this.parameters.size());
+ this.parameters.add(parameter);
+ return parameter;
+ }
+
+ NestableParameterAnnotation buildParameter(int index) {
+ return SourceParameterAnnotation.createGenericGeneratorParameter(this, this.member, this.daa, index);
+ }
+
+ ListIterator<NestableParameterAnnotation> nestableParameters() {
+ return new CloneListIterator<NestableParameterAnnotation>(this.parameters);
+ }
+
+ void parameterAdded(int index, NestableParameterAnnotation parameter) {
+ this.fireItemAdded(PARAMETERS_LIST, index, parameter);
+ }
+
+ NestableParameterAnnotation moveParameterInternal(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.parameters, targetIndex, sourceIndex).get(targetIndex);
+ }
+
+ void parameterMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(PARAMETERS_LIST, targetIndex, sourceIndex);
+ }
+
+ public int indexOfParameter(ParameterAnnotation parameter) {
+ return this.parameters.indexOf(parameter);
+ }
+
+ public void moveParameter(int targetIndex, int sourceIndex) {
+ AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.parametersContainer);
+ }
+
+ public ParameterAnnotation parameterAt(int index) {
+ return this.parameters.get(index);
+ }
+
+ public ListIterator<ParameterAnnotation> parameters() {
+ return new CloneListIterator<ParameterAnnotation>(this.parameters);
+ }
+
+ public int parametersSize() {
+ return parameters.size();
+ }
+
+ public void removeParameter(int index) {
+ AnnotationContainerTools.removeNestedAnnotation(index, this.parametersContainer);
+ }
+
+ NestableParameterAnnotation removeParameterInternal(int index) {
+ return this.parameters.remove(index);
+ }
+
+ void parameterRemoved(int index, NestableParameterAnnotation parameter) {
+ this.fireItemRemoved(PARAMETERS_LIST, index, parameter);
+ }
+
+ // ********** NestableAnnotation implementation **********
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ GenericGeneratorAnnotation oldGenericGenerator = (GenericGeneratorAnnotation) oldAnnotation;
+ this.setName(oldGenericGenerator.getName());
+ this.setStrategy(oldGenericGenerator.getStrategy());
+ //this.setAllocationSize(oldGenericGenerator.getAllocationSize());
+ //this.setInitialValue(oldGenericGenerator.getInitialValue());
+ for (ParameterAnnotation oldParameter : CollectionTools.iterable(oldGenericGenerator.parameters())) {
+ NestableParameterAnnotation newParameter = this.addParameter(oldGenericGenerator.indexOfParameter(oldParameter));
+ newParameter.initializeFrom((NestableParameterAnnotation) oldParameter);
+ }
+ }
+
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ super.toString(sb);
+ sb.append(name);
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, Hibernate.GENERIC_GENERATOR__NAME, false);
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildStrategyAdapter(DeclarationAnnotationAdapter daa) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, Hibernate.GENERIC_GENERATOR__STRATEGY, false);
+ }
+
+ /**
+ * adapt the AnnotationContainer interface to the override's join columns
+ */
+ class ParametersAnnotationContainer
+ implements AnnotationContainer<NestableParameterAnnotation>
+ {
+ public String getContainerAnnotationName() {
+ return GenericGeneratorAnnotationImpl.this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) {
+ return GenericGeneratorAnnotationImpl.this.getJdtAnnotation(astRoot);
+ }
+
+ public String getElementName() {
+ return Hibernate.GENERIC_GENERATOR__PARAMETERS;
+ }
+
+ public String getNestableAnnotationName() {
+ return ParameterAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<NestableParameterAnnotation> nestedAnnotations() {
+ return GenericGeneratorAnnotationImpl.this.nestableParameters();
+ }
+
+ public int nestedAnnotationsSize() {
+ return GenericGeneratorAnnotationImpl.this.parametersSize();
+ }
+
+ public NestableParameterAnnotation addNestedAnnotationInternal() {
+ return GenericGeneratorAnnotationImpl.this.addParameterInternal();
+ }
+
+ public void nestedAnnotationAdded(int index, NestableParameterAnnotation nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterAdded(index, nestedAnnotation);
+ }
+
+ public NestableParameterAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) {
+ return GenericGeneratorAnnotationImpl.this.moveParameterInternal(targetIndex, sourceIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ GenericGeneratorAnnotationImpl.this.parameterMoved(targetIndex, sourceIndex);
+ }
+
+ public NestableParameterAnnotation removeNestedAnnotationInternal(int index) {
+ return GenericGeneratorAnnotationImpl.this.removeParameterInternal(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, NestableParameterAnnotation nestedAnnotation) {
+ GenericGeneratorAnnotationImpl.this.parameterRemoved(index, nestedAnnotation);
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+ }
+
+ public static GenericGeneratorAnnotation createNestedGenericGenerator(
+ JavaResourceNode parent, Member member,
+ int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa);
+ return new GenericGeneratorAnnotationImpl(parent, member, idaa, annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter hibernateGenericGeneratorsAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(hibernateGenericGeneratorsAdapter, index, Hibernate.GENERIC_GENERATOR);
+ }
+
+ public static class GenericGeneratorAnnotationDefinition implements AnnotationDefinition
+ {
+ // singleton
+ private static final GenericGeneratorAnnotationDefinition INSTANCE = new GenericGeneratorAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure non-instantiability.
+ */
+ private GenericGeneratorAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new GenericGeneratorAnnotationImpl(parent, member,
+ DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent, Member member) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return GenericGeneratorAnnotation.ANNOTATION_NAME;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember arg0,
+ IAnnotation arg1) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember arg0) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jpt.core.resource.java.ContainerAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface GenericGeneratorsAnnotation extends
+ ContainerAnnotation<GenericGeneratorAnnotation> {
+
+ String ANNOTATION_NAME = Hibernate.GENERIC_GENERATORS;
+
+ String GENERIC_GENERATORS_LIST = "genericGenerators"; //$NON-NLS-1$
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorsAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -12,7 +12,6 @@
import org.eclipse.jpt.core.resource.java.ContainerAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java (from rev 16544, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ * Corresponds to the Hibernate annotation
+ * org.hibernate.annotations.NamedNativeQuery
+ */
+public interface HibernateNamedNativeQueryAnnotation
+ extends NestableNamedNativeQueryAnnotation, HibernateQueryAnnotation {
+ //replace with Hibernate annotation
+ String ANNOTATION_NAME = Hibernate.NAMED_NATIVE_QUERY;
+
+ //************************ callable *********************************
+ Boolean isCallable();
+ void setCallable(Boolean value);
+ String CALLABLE_PROPERTY = "callable"; //$NON-NLS-1$
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -16,7 +16,6 @@
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -12,7 +12,6 @@
import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryAnnotation;
/**
* @author Dmitry Geraskov
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -16,7 +16,6 @@
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.utility.jdt.Member;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedQueryAnnotation;
/**
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java (from rev 16544, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ * Interface contains Hibernate specific attributes.
+ */
+public interface HibernateQueryAnnotation {
+
+ //************************ flushMode *********************************
+
+ /**
+ * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
+ * Return null if the element does not exist in Java.
+ */
+ FlushModeType getFlushMode();
+ String FLUSH_MODE_PROPERTY = "flushMode"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
+ * Set to null to remove the element.
+ */
+ void setFlushMode(FlushModeType flushMode);
+
+ /**
+ * Return the {@link TextRange} for the 'flushMode' element. If element
+ * does not exist return the {@link TextRange} for the *NamedQuery annotation.
+ */
+ TextRange getFlushModeTextRange(CompilationUnit astRoot);
+
+ //************************ cacheMode *********************************
+
+ /**
+ * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
+ * Return null if the element does not exist in Java.
+ */
+ CacheModeType getCacheMode();
+ String CACHE_MODE_PROPERTY = "cacheMode"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
+ * Set to null to remove the element.
+ */
+ void setCacheMode(CacheModeType cacheMode);
+
+ /**
+ * Return the {@link TextRange} for the 'cacheMode' element. If element
+ * does not exist return the {@link TextRange} for the *NamedQuery annotation.
+ */
+ TextRange getCacheModeTextRange(CompilationUnit astRoot);
+
+ //************************ cacheable *********************************
+ Boolean isCacheable();
+ void setCacheable(Boolean value);
+ String CACHEABLE_PROPERTY = "cacheable"; //$NON-NLS-1$
+
+ //************************ cacheRegion *********************************
+ String getCacheRegion();
+ void setCacheRegion(String value);
+ String CACHE_REGION_PROPERTY = "cacheRegion"; //$NON-NLS-1$
+
+ //************************ fetchSize *********************************
+ Integer getFetchSize();
+ void setFetchSize(Integer value);
+ String FETCH_SIZE_PROPERTY = "fetchSize"; //$NON-NLS-1$
+
+ //************************ timeout *********************************
+ Integer getTimeout();
+ void setTimeout(Integer value);
+ String TIMEOUT_PROPERTY = "timeout"; //$NON-NLS-1$
+
+ //************************ comment *********************************
+ String getComment();
+ void setComment(String value);
+ String COMMENT_PROPERTY = "comment"; //$NON-NLS-1$
+
+ //************************ readOnly *********************************
+ Boolean isReadOnly();
+ void setReadOnly(Boolean value);
+ String READ_ONLY_PROPERTY = "readOnly"; //$NON-NLS-1$
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -23,8 +23,6 @@
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryAnnotation;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedNativeQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java (from rev 16544, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,615 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
+import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateSourceNamedNativeQueryAnnotation extends SourceAnnotation<Member> implements
+ HibernateNamedNativeQueryAnnotation {
+
+ public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
+ private final AnnotationElementAdapter<String> queryAdapter;
+ private String query;
+
+ private final DeclarationAnnotationElementAdapter<String> flushModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> flushModeAdapter;
+ private FlushModeType flushMode;
+
+ private final DeclarationAnnotationElementAdapter<String> cacheModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheModeAdapter;
+ private CacheModeType cacheMode;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> cacheableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> cacheableAdapter;
+ private Boolean cacheable;
+
+ private final DeclarationAnnotationElementAdapter<String> cacheRegionDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheRegionAdapter;
+ private String cacheRegion;
+
+ private final DeclarationAnnotationElementAdapter<Integer> fetchSizeDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
+ private Integer fetchSize;
+
+ private final DeclarationAnnotationElementAdapter<Integer> timeoutDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> timeoutAdapter;
+ private Integer timeout;
+
+ private final DeclarationAnnotationElementAdapter<String> commentDeclarationAdapter;
+ private final AnnotationElementAdapter<String> commentAdapter;
+ private String comment;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> readOnlyDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
+ private Boolean readOnly;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> callableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> callableAdapter;
+ private Boolean callable;
+
+ private final DeclarationAnnotationElementAdapter<String> resultClassDeclarationAdapter;
+ private final AnnotationElementAdapter<String> resultClassAdapter;
+ private String resultClass;
+
+ private String fullyQualifiedResultClassName;
+
+ private final DeclarationAnnotationElementAdapter<String> resultSetMappingDeclarationAdapter;
+ private final AnnotationElementAdapter<String> resultSetMappingAdapter;
+ private String resultSetMapping;
+
+ HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
+ this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
+ this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
+ this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, flushModeDeclarationAdapter);
+ this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
+ this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, cacheModeDeclarationAdapter);
+ this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
+ this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, cacheableDeclarationAdapter);
+ this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
+ this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
+ this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
+ this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, fetchSizeDeclarationAdapter);
+ this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
+ this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, timeoutDeclarationAdapter);
+ this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
+ this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, commentDeclarationAdapter);
+ this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, readOnlyDeclarationAdapter);
+ this.callableDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.callableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, callableDeclarationAdapter);
+ this.resultClassDeclarationAdapter = this.buildResultClassAdapter(daa);
+ this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter);
+ this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa);
+ this.resultSetMappingAdapter = this.buildAdapter(this.resultSetMappingDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.query = this.buildQuery(astRoot);
+ this.flushMode = this.buildFlushMode(astRoot);
+ this.cacheMode = this.buildCacheMode(astRoot);
+ this.cacheable = this.buildCacheable(astRoot);
+ this.cacheRegion = this.buildCacheRegion(astRoot);
+ this.fetchSize = this.buildFetchSize(astRoot);
+ this.timeout = this.buildTimeout(astRoot);
+ this.comment = this.buildComment(astRoot);
+ this.readOnly = this.buildReadOnly(astRoot);
+ this.callable = this.buildCallable(astRoot);
+ this.resultClass = this.buildResultClass(astRoot);
+ this.fullyQualifiedResultClassName = this.buildFullyQualifiedResultClassName(astRoot);
+ this.resultSetMapping = this.buildResultSetMapping(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ this.setFlushMode(this.buildFlushMode(astRoot));
+ this.setCacheMode(this.buildCacheMode(astRoot));
+ this.setCacheable(this.buildCacheable(astRoot));
+ this.setCacheRegion(this.buildCacheRegion(astRoot));
+ this.setFetchSize(this.buildFetchSize(astRoot));
+ this.setTimeout(this.buildTimeout(astRoot));
+ this.setComment(this.buildComment(astRoot));
+ this.setReadOnly(this.buildReadOnly(astRoot));
+ this.setCallable(this.buildCallable(astRoot));
+ this.setResultClass(this.buildResultClass(astRoot));
+ this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot));
+ this.setResultSetMapping(this.buildResultSetMapping(astRoot));
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ /**
+ * convenience method
+ */
+ AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ // ********** BaseNamedNativeQueryAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ // ***** query
+ public String getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(String query) {
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
+ }
+ String old = this.query;
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
+ }
+
+ private String buildQuery(CompilationUnit astRoot) {
+ return this.queryAdapter.getValue(astRoot);
+ }
+
+ public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
+ }
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_NATIVE_QUERY__QUERY;
+ }
+
+ // ***** hints
+ public ListIterator<QueryHintAnnotation> hints() {
+ return EmptyListIterator.instance();
+ }
+
+ ListIterator<NestableQueryHintAnnotation> nestableHints() {
+ return EmptyListIterator.instance();
+ }
+
+ public int hintsSize() {
+ return 0;
+ }
+
+ public NestableQueryHintAnnotation hintAt(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int indexOfHint(QueryHintAnnotation queryHint) {
+ return -1;
+ }
+
+ public NestableQueryHintAnnotation addHint(int index) {
+ return null;
+ }
+
+ public void moveHint(int targetIndex, int sourceIndex) {
+ //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer);
+ }
+
+ public void removeHint(int index) {
+ //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
+ }
+
+ // ******************** HibernateNamedNativeQueryAnnotation implementation *************
+ // ***** flushMode
+
+ public FlushModeType getFlushMode() {
+ return flushMode;
+ }
+
+ public void setFlushMode(FlushModeType flushMode) {
+ if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
+ return;
+ }
+ FlushModeType old = this.flushMode;
+ this.flushMode = flushMode;
+ this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
+ this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
+ }
+
+ private FlushModeType buildFlushMode(CompilationUnit astRoot) {
+ return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
+ }
+
+ // ***** caheMode
+
+ public CacheModeType getCacheMode() {
+ return cacheMode;
+ }
+
+ public void setCacheMode(CacheModeType cacheMode) {
+ if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
+ return;
+ }
+ CacheModeType old = this.cacheMode;
+ this.cacheMode = cacheMode;
+ this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
+ this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
+ }
+
+ private CacheModeType buildCacheMode(CompilationUnit astRoot) {
+ return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
+ }
+
+ //************************ cacheable *********************************
+ public Boolean isCacheable(){
+ return this.cacheable;
+ }
+
+ public void setCacheable(Boolean cacheable){
+ if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
+ return;
+ }
+ Boolean old = this.cacheable;
+ this.cacheable = cacheable;
+ this.cacheableAdapter.setValue(cacheable);
+ this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
+ }
+
+ private Boolean buildCacheable(CompilationUnit astRoot) {
+ return this.cacheableAdapter.getValue(astRoot);
+ }
+
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return this.cacheRegion;
+ }
+
+ public void setCacheRegion(String cacheRegion){
+ if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
+ return;
+ }
+ String old = this.cacheRegion;
+ this.cacheRegion = cacheRegion;
+ this.cacheRegionAdapter.setValue(cacheRegion);
+ this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
+ }
+
+ private String buildCacheRegion(CompilationUnit astRoot) {
+ return this.cacheRegionAdapter.getValue(astRoot);
+ }
+ //************************ fetchSize *********************************
+ public Integer getFetchSize(){
+ return this.fetchSize;
+ }
+
+ public void setFetchSize(Integer fetchSize){
+ if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
+ return;
+ }
+ Integer old = this.fetchSize;
+ this.fetchSize = fetchSize;
+ this.fetchSizeAdapter.setValue(fetchSize);
+ this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
+ }
+
+ private Integer buildFetchSize(CompilationUnit astRoot) {
+ return this.fetchSizeAdapter.getValue(astRoot);
+ }
+ //************************ timeout *********************************
+ public Integer getTimeout(){
+ return this.timeout;
+ }
+ public void setTimeout(Integer timeout){
+ if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
+ return;
+ }
+ Integer old = this.timeout;
+ this.timeout = timeout;
+ this.timeoutAdapter.setValue(timeout);
+ this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
+ }
+
+ private Integer buildTimeout(CompilationUnit astRoot) {
+ return this.timeoutAdapter.getValue(astRoot);
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return this.comment;
+ }
+
+ public void setComment(String comment){
+ if (this.attributeValueHasNotChanged(this.comment, comment)) {
+ return;
+ }
+ String old = this.comment;
+ this.comment = comment;
+ this.commentAdapter.setValue(comment);
+ this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
+ }
+
+ private String buildComment(CompilationUnit astRoot) {
+ return this.commentAdapter.getValue(astRoot);
+ }
+ //************************ readOnly *********************************
+ public Boolean isReadOnly(){
+ return this.readOnly;
+ }
+
+ public void setReadOnly(Boolean readOnly){
+ if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
+ return;
+ }
+ Boolean old = this.readOnly;
+ this.readOnly = readOnly;
+ this.readOnlyAdapter.setValue(readOnly);
+ this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
+ }
+
+ private Boolean buildReadOnly(CompilationUnit astRoot) {
+ return this.readOnlyAdapter.getValue(astRoot);
+ }
+ //************************ callable *********************************
+ public Boolean isCallable(){
+ return this.callable;
+ }
+
+ public void setCallable(Boolean callable){
+ if (this.attributeValueHasNotChanged(this.callable, callable)) {
+ return;
+ }
+ Boolean old = this.callable;
+ this.callable = callable;
+ this.callableAdapter.setValue(callable);
+ this.firePropertyChanged(CALLABLE_PROPERTY, old, callable);
+ }
+
+ private Boolean buildCallable(CompilationUnit astRoot) {
+ return this.callableAdapter.getValue(astRoot);
+ }
+ // ***** result class
+ public String getResultClass() {
+ return this.resultClass;
+ }
+
+ public void setResultClass(String resultClass) {
+ if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) {
+ return;
+ }
+ String old = this.resultClass;
+ this.resultClass = resultClass;
+ this.resultClassAdapter.setValue(resultClass);
+ this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass);
+ }
+
+ private String buildResultClass(CompilationUnit astRoot) {
+ return this.resultClassAdapter.getValue(astRoot);
+ }
+
+ public TextRange getResultClassTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot);
+ }
+
+ // ***** fully-qualified result class name
+ public String getFullyQualifiedResultClassName() {
+ return this.fullyQualifiedResultClassName;
+ }
+
+ private void setFullyQualifiedResultClassName(String name) {
+ String old = this.fullyQualifiedResultClassName;
+ this.fullyQualifiedResultClassName = name;
+ this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name);
+ }
+
+ private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) {
+ return (this.resultClass == null) ? null : JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot));
+ }
+
+ // ***** result set mapping
+ public String getResultSetMapping() {
+ return this.resultSetMapping;
+ }
+
+ public void setResultSetMapping(String resultSetMapping) {
+ if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) {
+ return;
+ }
+ String old = this.resultSetMapping;
+ this.resultSetMapping = resultSetMapping;
+ this.resultSetMappingAdapter.setValue(resultSetMapping);
+ this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping);
+ }
+
+ private String buildResultSetMapping(CompilationUnit astRoot) {
+ return this.resultSetMappingAdapter.getValue(astRoot);
+ }
+
+ public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot);
+ }
+ // ********** NestableAnnotation implementation **********
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ HibernateSourceNamedNativeQueryAnnotation oldQuery = (HibernateSourceNamedNativeQueryAnnotation) oldAnnotation;
+ this.setName(oldQuery.getName());
+ this.setQuery(oldQuery.getQuery());
+ this.setFlushMode(oldQuery.getFlushMode());
+ this.setCacheMode(oldQuery.getCacheMode());
+ this.setCacheable(oldQuery.isCacheable());
+ this.setComment(oldQuery.getComment());
+ this.setFetchSize(oldQuery.getFetchSize());
+ this.setTimeout(oldQuery.getTimeout());
+ this.setCacheRegion(oldQuery.getCacheRegion());
+ this.setReadOnly(oldQuery.isReadOnly());
+ this.setCallable(oldQuery.isCallable());
+ this.setResultClass(oldQuery.getResultClass());
+ this.setResultSetMapping(oldQuery.getResultSetMapping());
+ }
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ public static HibernateNamedNativeQueryAnnotation createNamedNativeQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__NAME);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__QUERY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_NATIVE_QUERY__FLUSH_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHE_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHEABLE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHE_REGION);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer> buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_NATIVE_QUERY__FETCH_SIZE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer> buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_NATIVE_QUERY__TIMEOUT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__COMMENT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__READ_ONLY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildCallableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CALLABLE);
+ }
+
+
+ private DeclarationAnnotationElementAdapter<String> buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new ConversionDeclarationAnnotationElementAdapter<String>(daAdapter, Hibernate.NAMED_NATIVE_QUERY__RESULT_CLASS, SimpleTypeStringExpressionConverter.instance());
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildResultSetMappingAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+ // ********** static methods **********
+
+ public static HibernateSourceNamedNativeQueryAnnotation createHibernateNamedNativeQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public static HibernateSourceNamedNativeQueryAnnotation createNestedHibernateNamedNativeQuery(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa);
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member, idaa, annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter hibernateNamedNativeQueriesAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(hibernateNamedNativeQueriesAdapter, index, Hibernate.NAMED_NATIVE_QUERY);
+ }
+
+}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2009-07-23 11:19:10 UTC (rev 16746)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -23,7 +23,6 @@
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java (from rev 16544, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueryAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,490 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
+import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateSourceNamedQueryAnnotation extends SourceAnnotation<Member>
+ implements HibernateNamedQueryAnnotation {
+
+ public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
+ private final AnnotationElementAdapter<String> queryAdapter;
+ private String query;
+
+ private final DeclarationAnnotationElementAdapter<String> flushModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> flushModeAdapter;
+ private FlushModeType flushMode;
+
+ private final DeclarationAnnotationElementAdapter<String> cacheModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheModeAdapter;
+ private CacheModeType cacheMode;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> cacheableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> cacheableAdapter;
+ private Boolean cacheable;
+
+ private final DeclarationAnnotationElementAdapter<String> cacheRegionDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheRegionAdapter;
+ private String cacheRegion;
+
+ private final DeclarationAnnotationElementAdapter<Integer> fetchSizeDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
+ private Integer fetchSize;
+
+ private final DeclarationAnnotationElementAdapter<Integer> timeoutDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> timeoutAdapter;
+ private Integer timeout;
+
+ private final DeclarationAnnotationElementAdapter<String> commentDeclarationAdapter;
+ private final AnnotationElementAdapter<String> commentAdapter;
+ private String comment;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> readOnlyDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
+ private Boolean readOnly;
+
+ HibernateSourceNamedQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
+ this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
+ this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
+ this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, flushModeDeclarationAdapter);
+ this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
+ this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, cacheModeDeclarationAdapter);
+ this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
+ this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, cacheableDeclarationAdapter);
+ this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
+ this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
+ this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
+ this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, fetchSizeDeclarationAdapter);
+ this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
+ this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, timeoutDeclarationAdapter);
+ this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
+ this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, commentDeclarationAdapter);
+ this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, readOnlyDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.query = this.buildQuery(astRoot);
+ this.flushMode = this.buildFlushMode(astRoot);
+ this.cacheMode = this.buildCacheMode(astRoot);
+ this.cacheable = this.buildCacheable(astRoot);
+ this.cacheRegion = this.buildCacheRegion(astRoot);
+ this.fetchSize = this.buildFetchSize(astRoot);
+ this.timeout = this.buildTimeout(astRoot);
+ this.comment = this.buildComment(astRoot);
+ this.readOnly = this.buildReadOnly(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ this.setFlushMode(this.buildFlushMode(astRoot));
+ this.setCacheMode(this.buildCacheMode(astRoot));
+ this.setCacheable(this.buildCacheable(astRoot));
+ this.setCacheRegion(this.buildCacheRegion(astRoot));
+ this.setFetchSize(this.buildFetchSize(astRoot));
+ this.setTimeout(this.buildTimeout(astRoot));
+ this.setComment(this.buildComment(astRoot));
+ this.setReadOnly(this.buildReadOnly(astRoot));
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ /**
+ * convenience method
+ */
+ AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ // ********** BaseNamedQueryAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ // ***** query
+ public String getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(String query) {
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
+ }
+ String old = this.query;
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
+ }
+
+ private String buildQuery(CompilationUnit astRoot) {
+ return this.queryAdapter.getValue(astRoot);
+ }
+
+ public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
+ }
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_QUERY__QUERY;
+ }
+
+ // ***** hints
+ public ListIterator<QueryHintAnnotation> hints() {
+ return EmptyListIterator.instance();
+ }
+
+ ListIterator<NestableQueryHintAnnotation> nestableHints() {
+ return EmptyListIterator.instance();
+ }
+
+ public int hintsSize() {
+ return 0;
+ }
+
+ public NestableQueryHintAnnotation hintAt(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int indexOfHint(QueryHintAnnotation queryHint) {
+ return -1;
+ }
+
+ public NestableQueryHintAnnotation addHint(int index) {
+ return null;
+ }
+
+ public void moveHint(int targetIndex, int sourceIndex) {
+ //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer);
+ }
+
+ public void removeHint(int index) {
+ //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
+ }
+
+ // ******************** HibernateNamedQueryAnnotation implementation *************
+ // ***** flushMode
+
+ public FlushModeType getFlushMode() {
+ return flushMode;
+ }
+
+ public void setFlushMode(FlushModeType flushMode) {
+ if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
+ return;
+ }
+ FlushModeType old = this.flushMode;
+ this.flushMode = flushMode;
+ this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
+ this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
+ }
+
+ private FlushModeType buildFlushMode(CompilationUnit astRoot) {
+ return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
+ }
+
+ // ***** caheMode
+
+ public CacheModeType getCacheMode() {
+ return cacheMode;
+ }
+
+ public void setCacheMode(CacheModeType cacheMode) {
+ if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
+ return;
+ }
+ CacheModeType old = this.cacheMode;
+ this.cacheMode = cacheMode;
+ this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
+ this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
+ }
+
+ private CacheModeType buildCacheMode(CompilationUnit astRoot) {
+ return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
+ }
+
+ //************************ cacheable *********************************
+ public Boolean isCacheable(){
+ return this.cacheable;
+ }
+
+ public void setCacheable(Boolean cacheable){
+ if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
+ return;
+ }
+ Boolean old = this.cacheable;
+ this.cacheable = cacheable;
+ this.cacheableAdapter.setValue(cacheable);
+ this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
+ }
+
+ private Boolean buildCacheable(CompilationUnit astRoot) {
+ return this.cacheableAdapter.getValue(astRoot);
+ }
+
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return this.cacheRegion;
+ }
+
+ public void setCacheRegion(String cacheRegion){
+ if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
+ return;
+ }
+ String old = this.cacheRegion;
+ this.cacheRegion = cacheRegion;
+ this.cacheRegionAdapter.setValue(cacheRegion);
+ this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
+ }
+
+ private String buildCacheRegion(CompilationUnit astRoot) {
+ return this.cacheRegionAdapter.getValue(astRoot);
+ }
+ //************************ fetchSize *********************************
+ public Integer getFetchSize(){
+ return this.fetchSize;
+ }
+
+ public void setFetchSize(Integer fetchSize){
+ if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
+ return;
+ }
+ Integer old = this.fetchSize;
+ this.fetchSize = fetchSize;
+ this.fetchSizeAdapter.setValue(fetchSize);
+ this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
+ }
+
+ private Integer buildFetchSize(CompilationUnit astRoot) {
+ return this.fetchSizeAdapter.getValue(astRoot);
+ }
+ //************************ timeout *********************************
+ public Integer getTimeout(){
+ return this.timeout;
+ }
+ public void setTimeout(Integer timeout){
+ if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
+ return;
+ }
+ Integer old = this.timeout;
+ this.timeout = timeout;
+ this.timeoutAdapter.setValue(timeout);
+ this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
+ }
+
+ private Integer buildTimeout(CompilationUnit astRoot) {
+ return this.timeoutAdapter.getValue(astRoot);
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return this.comment;
+ }
+
+ public void setComment(String comment){
+ if (this.attributeValueHasNotChanged(this.comment, comment)) {
+ return;
+ }
+ String old = this.comment;
+ this.comment = comment;
+ this.commentAdapter.setValue(comment);
+ this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
+ }
+
+ private String buildComment(CompilationUnit astRoot) {
+ return this.commentAdapter.getValue(astRoot);
+ }
+ //************************ readOnly *********************************
+ public Boolean isReadOnly(){
+ return this.readOnly;
+ }
+
+ public void setReadOnly(Boolean readOnly){
+ if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
+ return;
+ }
+ Boolean old = this.readOnly;
+ this.readOnly = readOnly;
+ this.readOnlyAdapter.setValue(readOnly);
+ this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
+ }
+
+ private Boolean buildReadOnly(CompilationUnit astRoot) {
+ return this.readOnlyAdapter.getValue(astRoot);
+ }
+ // ********** NestableAnnotation implementation **********
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ HibernateSourceNamedQueryAnnotation oldQuery = (HibernateSourceNamedQueryAnnotation) oldAnnotation;
+ this.setName(oldQuery.getName());
+ this.setQuery(oldQuery.getQuery());
+ this.setFlushMode(oldQuery.getFlushMode());
+ this.setCacheMode(oldQuery.getCacheMode());
+ this.setCacheable(oldQuery.isCacheable());
+ this.setComment(oldQuery.getComment());
+ this.setFetchSize(oldQuery.getFetchSize());
+ this.setTimeout(oldQuery.getTimeout());
+ this.setCacheRegion(oldQuery.getCacheRegion());
+ this.setReadOnly(oldQuery.isReadOnly());
+ }
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ public static HibernateNamedQueryAnnotation createNamedQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__NAME);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__QUERY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_QUERY__FLUSH_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_QUERY__CACHE_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_QUERY__CACHEABLE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__CACHE_REGION);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer> buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_QUERY__FETCH_SIZE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer> buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_QUERY__TIMEOUT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_QUERY__COMMENT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_QUERY__READ_ONLY);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+ // ********** static methods **********
+
+ public static HibernateSourceNamedQueryAnnotation createHibernateNamedQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public static HibernateSourceNamedQueryAnnotation createNestedHibernateNamedQuery(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa);
+ return new HibernateSourceNamedQueryAnnotation(parent, member, idaa, annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter hibernateNamedQueriesAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(hibernateNamedQueriesAdapter, index, Hibernate.NAMED_QUERY);
+ }
+
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java 2009-07-23 13:40:36 UTC (rev 16747)
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import java.util.ListIterator;
+import java.util.Vector;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class SourceGenericGeneratorsAnnotation extends SourceAnnotation<Member> implements
+ GenericGeneratorsAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final Vector<GenericGeneratorAnnotation> genericGenerators = new Vector<GenericGeneratorAnnotation>();
+
+
+ public SourceGenericGeneratorsAnnotation(JavaResourceNode parent, Member member) {
+ super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ AnnotationContainerTools.initialize(this, astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ AnnotationContainerTools.update(this, astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.genericGenerators);
+ }
+
+ // ********** AnnotationContainer implementation **********
+
+ public String getContainerAnnotationName() {
+ return this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) {
+ return this.getJdtAnnotation(astRoot);
+ }
+
+ public String getElementName() {
+ return Hibernate.GENERIC_GENERATORS__VALUE;
+ }
+
+ public String getNestableAnnotationName() {
+ return GenericGeneratorAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<GenericGeneratorAnnotation> nestedAnnotations() {
+ return new CloneListIterator<GenericGeneratorAnnotation>(this.genericGenerators);
+ }
+
+ public int nestedAnnotationsSize() {
+ return this.genericGenerators.size();
+ }
+
+ public GenericGeneratorAnnotation addNestedAnnotationInternal() {
+ GenericGeneratorAnnotation genericGenerator = this.buildGenericGenerator(this.genericGenerators.size());
+ this.genericGenerators.add(genericGenerator);
+ return genericGenerator;
+ }
+
+ private GenericGeneratorAnnotation buildGenericGenerator(int index) {
+ return GenericGeneratorAnnotationImpl.createNestedGenericGenerator(this, member, index, this.daa);
+ }
+
+ public void nestedAnnotationAdded(int index, GenericGeneratorAnnotation nestedAnnotation) {
+ this.fireItemAdded(GENERIC_GENERATORS_LIST, index, nestedAnnotation);
+ }
+
+ public GenericGeneratorAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.genericGenerators, targetIndex, sourceIndex).get(targetIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(GENERIC_GENERATORS_LIST, targetIndex, sourceIndex);
+ }
+
+ public GenericGeneratorAnnotation removeNestedAnnotationInternal(int index) {
+ return this.genericGenerators.remove(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, GenericGeneratorAnnotation nestedAnnotation) {
+ this.fireItemRemoved(GENERIC_GENERATORS_LIST, index, nestedAnnotation);
+ }
+
+ public static class GenericGeneratorsAnnotationDefinition implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new GenericGeneratorsAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private GenericGeneratorsAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new SourceGenericGeneratorsAnnotation(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return GenericGeneratorsAnnotation.ANNOTATION_NAME;
+ }
+
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceGenericGeneratorsAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
16 years, 9 months
JBoss Tools SVN: r16746 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks: configuration/editors and 12 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-07-23 07:19:10 -0400 (Thu, 23 Jul 2009)
New Revision: 16746
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/model/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/model/AbstractSmooksGraphicalModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksEditFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractSmooksElementEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataTreeNodeEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataContianerModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataTreeNodeModel.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/EDITreeContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java
Log:
JBIDE-4648
Add new graphical page on Smooks multi editor
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -12,11 +12,14 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.PartInitException;
import org.jboss.tools.smooks.editor.AbstractSmooksFormEditor;
+import org.jboss.tools.smooks.graphical.editors.SmooksGraphicalEditorPart;
/**
*
@@ -25,10 +28,14 @@
public class SmooksMultiFormEditor extends AbstractSmooksFormEditor {
public static final String EDITOR_ID = "org.jboss.tools.smooks.configuration.editors.MultiPageEditor";
-
+
private SmooksConfigurationFormPage configurationPage;
- /* (non-Javadoc)
+ private SmooksGraphicalEditorPart graphicalPage;
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.jboss.tools.smooks.editor.AbstractSmooksFormEditor#addPages()
*/
@Override
@@ -41,15 +48,42 @@
} catch (PartInitException e) {
e.printStackTrace();
}
+
+// graphicalPage = new SmooksGraphicalEditorPart(this);
+// try {
+// int index = this.addPage(graphicalPage, getEditorInput());
+// setPageText(index, "Graph");
+// } catch (PartInitException e) {
+// e.printStackTrace();
+// }
+
super.addPages();
}
-
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ super.doSave(monitor);
+ try {
+ getSmooksGraphicsExt().eResource().save(Collections.emptyMap());
+ if (graphicalPage != null) {
+ if (graphicalPage.getEditDomain() != null) {
+ graphicalPage.getEditDomain().getCommandStack().flush();
+ }
+ }
+ firePropertyChange(PROP_DIRTY);
+ } catch (Throwable t) {
+ }
+ }
+
protected SmooksConfigurationFormPage createSmooksConfigurationFormPage() {
return new SmooksConfigurationFormPage(this, "DesignPage", "Design Page");
}
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.editor.AbstractSmooksFormEditor#activeRecentAffectedModel(java.util.Collection)
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.editor.AbstractSmooksFormEditor#
+ * activeRecentAffectedModel(java.util.Collection)
*/
@Override
public void activeRecentAffectedModel(Collection<?> collection) {
@@ -67,8 +101,11 @@
}
}
- /* (non-Javadoc)
- * @see org.jboss.tools.smooks.editor.AbstractSmooksFormEditor#createNewModelViaTextPage()
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.editor.AbstractSmooksFormEditor#
+ * createNewModelViaTextPage()
*/
@Override
protected void createNewModelViaTextPage() {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -1105,8 +1105,9 @@
if (resource == null)
return null;
URI uri = resource.getURI();
-
- if(uri == null) return null;
+
+ if (uri == null)
+ return null;
IResource workspaceResource = null;
if (uri.isPlatformResource()) {
String path = uri.toPlatformString(true);
@@ -1485,7 +1486,8 @@
}
public static IFile getFile(String uri, IProject project) {
- if(project == null) return null;
+ if (project == null)
+ return null;
if (uri.charAt(0) == '\\' || uri.charAt(0) == '/') {
uri = uri.substring(1);
}
@@ -2266,16 +2268,19 @@
}
}
- public static void expandGraphTree(List<TreeNodeModel> expandNodes, TreeNodeEditPart rootEditPart) {
+ public static void expandGraphTree(List<?> expandNodes, TreeNodeEditPart rootEditPart) {
for (Iterator<?> iterator = expandNodes.iterator(); iterator.hasNext();) {
- TreeNodeModel treeNodeModel = (TreeNodeModel) iterator.next();
+ Object obj = iterator.next();
+ if (!(obj instanceof TreeNodeModel))
+ continue;
+ TreeNodeModel treeNodeModel = (TreeNodeModel) obj;
TreeNodeModel parent = treeNodeModel;
if (parent == null)
continue;
List<TreeNodeModel> parentList = new ArrayList<TreeNodeModel>();
boolean canExpand = true;
while (parent != rootEditPart.getModel()) {
- parent = parent.getParent();
+ parent = (TreeNodeModel) parent.getParent();
if (parent == null) {
canExpand = false;
break;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editor/EDIMapFormPage.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -107,6 +107,7 @@
import org.jboss.tools.smooks.edimap.models.EDIMappingNodeContainerGraphModel;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.common.RootModel;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.gef.tree.editparts.RootEditPart;
import org.jboss.tools.smooks.gef.tree.figures.IMoveableModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
@@ -509,6 +510,9 @@
return editDomain.getCommandStack();
}
}
+ if (type == ISmooksModelProvider.class) {
+ return this.modelProvider;
+ }
if (type == GraphicalViewer.class)
return getGraphicalViewer();
if (type == ActionRegistry.class)
@@ -1065,7 +1069,7 @@
List<TreeNodeConnection> connections = source.getSourceConnections();
for (Iterator<?> iterator = connections.iterator(); iterator.hasNext();) {
TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator.next();
- if(treeNodeConnection.getTargetNode() == target){
+ if (treeNodeConnection.getTargetNode() == target) {
return true;
}
}
@@ -1107,19 +1111,19 @@
private TreeNodeModel findEDIGraphicalModel(Object model) {
if (graphicalRootModel != null) {
List<TreeNodeModel> treeNodeList = graphicalRootModel.getChildren();
- return findEDIGraphicalModel(model, treeNodeList);
+ return (TreeNodeModel)findEDIGraphicalModel(model, treeNodeList);
}
return null;
}
- private TreeNodeModel findEDIGraphicalModel(Object model, List<TreeNodeModel> treeNodeList) {
+ private AbstractSmooksGraphicalModel findEDIGraphicalModel(Object model, List<?> treeNodeList) {
for (Iterator<?> iterator = treeNodeList.iterator(); iterator.hasNext();) {
- TreeNodeModel treeNodeModel = (TreeNodeModel) iterator.next();
+ AbstractSmooksGraphicalModel treeNodeModel = (AbstractSmooksGraphicalModel) iterator.next();
Object data = treeNodeModel.getData();
if (data == model) {
return treeNodeModel;
}
- TreeNodeModel m = findEDIGraphicalModel(model, treeNodeModel.getChildren());
+ AbstractSmooksGraphicalModel m = findEDIGraphicalModel(model, treeNodeModel.getChildren());
if (m != null) {
return m;
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/EDITreeContainerEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/EDITreeContainerEditPart.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/editparts/EDITreeContainerEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -26,7 +26,6 @@
import org.eclipse.gef.tools.DirectEditManager;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.forms.editor.FormPage;
import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
import org.jboss.tools.smooks.edimap.actions.RenameXmlTagNameCommand;
import org.jboss.tools.smooks.edimap.editor.EDIEdiPartDirectEditManager;
@@ -35,11 +34,9 @@
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart;
import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart;
-import org.jboss.tools.smooks.gef.tree.figures.IMoveableModel;
import org.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
import org.jboss.tools.smooks.model.graphics.ext.FigureType;
-import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks.model.medi.MEdiPackage;
import org.jboss.tools.smooks.model.medi.MappingNode;
import org.jboss.tools.smooks.model.medi.Segments;
@@ -82,19 +79,19 @@
public void propertyChange(PropertyChangeEvent evt) {
super.propertyChange(evt);
- if (IMoveableModel.PRO_BOUNDS_CHANGED.equals(evt.getPropertyName())) {
- DefaultEditDomain domain = (DefaultEditDomain) getViewer().getEditDomain();
- IEditorPart editor = domain.getEditorPart();
- if((editor instanceof FormPage)){
- editor = ((FormPage)editor).getEditor();
- }
-
- if(editor instanceof ISmooksModelProvider && getModel() instanceof IMoveableModel){
- SmooksGraphicsExtType graph = ((ISmooksModelProvider)editor).getSmooksGraphicsExt();
- Rectangle rect = ((IMoveableModel)getModel()).getBounds();
- recordBounds(graph,rect);
- }
- }
+// if (IMoveableModel.PRO_BOUNDS_CHANGED.equals(evt.getPropertyName())) {
+// DefaultEditDomain domain = (DefaultEditDomain) getViewer().getEditDomain();
+// IEditorPart editor = domain.getEditorPart();
+// if((editor instanceof FormPage)){
+// editor = ((FormPage)editor).getEditor();
+// }
+//
+// if(editor instanceof ISmooksModelProvider && getModel() instanceof IMoveableModel){
+// SmooksGraphicsExtType graph = ((ISmooksModelProvider)editor).getSmooksGraphicsExt();
+// Rectangle rect = ((IMoveableModel)getModel()).getBounds();
+// recordBounds(graph,rect);
+// }
+// }
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -16,6 +16,7 @@
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
import org.jboss.tools.smooks.model.medi.MEdiPackage;
@@ -72,7 +73,7 @@
public void addSourceConnection(TreeNodeConnection connection) {
super.addSourceConnection(connection);
if (getData() instanceof Segment) {
- TreeNodeModel targetNode = connection.getTargetNode();
+ AbstractSmooksGraphicalModel targetNode = connection.getTargetNode();
if (targetNode != null && targetNode.getData() instanceof EDIDataContainerModel) {
if (domainProvider != null) {
String segCode = ((EDIDataContainerModel) targetNode.getData()).getSegCode();
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/model/AbstractSmooksGraphicalModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/model/AbstractSmooksGraphicalModel.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/model/AbstractSmooksGraphicalModel.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.gef.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.gef.tree.model.IConnectableNode;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class AbstractSmooksGraphicalModel implements IConnectableNode {
+
+ public static final String PRO_ADD_CHILD = "_pro_add_child";
+
+ public static final String PRO_REMOVE_CHILD = "_pro_remove_child";
+
+ public static final String PRO_ADD_SOURCE_CONNECTION = "_pro_add_source_connected";
+
+ public static final String PRO_ADD_TARGET_CONNECTION = "_pro_add_target_connected";
+
+ public static final String PRO_REMOVE_SOURCE_CONNECTION = "_pro_remove_source_connected";
+
+ public static final String PRO_REMOVE_TARGET_CONNECTION = "_pro_remove_target_connected";
+
+ public static final String PRO_TEXT_CHANGED = "_pro_text_changed";
+
+ public static final String PRO_FORCE_VISUAL_CHANGED = "_pro_force_text_changed";
+
+ public static final String PRO_FORCE_CHIDLREN_CHANGED = "_pro_force_children_changed";
+
+ public static final String PRO_FORCE_CONNECTION_CHANGED = "_pro_force_connection_changed";
+
+ protected Object data = null;
+
+ private boolean linkable = true;
+
+ private AbstractSmooksGraphicalModel parent = null;
+
+ private HashMap<String, Object> userDataMap = new HashMap<String, Object>();
+
+ protected PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ protected List<AbstractSmooksGraphicalModel> children = null;
+
+ private List<TreeNodeConnection> sourceConnections = new ArrayList<TreeNodeConnection>();
+
+ private List<TreeNodeConnection> targetConnections = new ArrayList<TreeNodeConnection>();
+
+ public AbstractSmooksGraphicalModel(Object data) {
+ setData(data);
+ }
+
+ public boolean hasChildren() {
+ return true;
+ }
+
+ public AbstractSmooksGraphicalModel getParent() {
+ return parent;
+ }
+
+ public void setParent(AbstractSmooksGraphicalModel parent) {
+ this.parent = parent;
+ }
+
+ //
+ // protected AbstractSmooksGraphicalModel createChildModel(Object model,
+ // ITreeContentProvider contentProvider,
+ // ILabelProvider labelProvider) {
+ // return new TreeNodeModel(model, contentProvider, labelProvider);
+ // }
+
+ public List<AbstractSmooksGraphicalModel> getChildren() {
+ if (children == null) {
+ children = new ArrayList<AbstractSmooksGraphicalModel>();
+ }
+ return children;
+ }
+
+ protected void disconnectAllConnections(AbstractSmooksGraphicalModel node) {
+ List<TreeNodeConnection> sourceConnections = node.getSourceConnections();
+ List<TreeNodeConnection> targetConnections = node.getTargetConnections();
+ List<TreeNodeConnection> tempSourceConnections = new ArrayList<TreeNodeConnection>(sourceConnections);
+ List<TreeNodeConnection> tempTargetConnections = new ArrayList<TreeNodeConnection>(targetConnections);
+
+ for (Iterator<?> iterator2 = tempTargetConnections.iterator(); iterator2.hasNext();) {
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
+ treeNodeConnection.disconnectSource();
+ }
+
+ for (Iterator<?> iterator2 = tempSourceConnections.iterator(); iterator2.hasNext();) {
+ TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
+ treeNodeConnection.disconnectTarget();
+ }
+
+ tempSourceConnections.clear();
+ tempTargetConnections.clear();
+ tempSourceConnections = null;
+ tempTargetConnections = null;
+
+ List<AbstractSmooksGraphicalModel> children = node.getChildren();
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ TreeNodeModel treeNodeModel = (TreeNodeModel) iterator.next();
+ disconnectAllConnections(treeNodeModel);
+ }
+ }
+
+ protected boolean graphicalChildExist(Object model, Object[] models) {
+ for (int i = 0; i < models.length; i++) {
+ if (model == models[i]) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected boolean childExsit(Object model) {
+ if (children != null) {
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ TreeNodeModel node = (TreeNodeModel) iterator.next();
+ if (node.getData() == model) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ support.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ support.removePropertyChangeListener(listener);
+ }
+
+ public void addSourceConnection(TreeNodeConnection connection) {
+ if (this.sourceConnections.indexOf(connection) == -1) {
+ this.sourceConnections.add(connection);
+ support.firePropertyChange(PRO_ADD_SOURCE_CONNECTION, null, connection);
+ }
+ }
+
+ public void removeSourceConnection(TreeNodeConnection connection) {
+ if (this.sourceConnections.indexOf(connection) != -1) {
+ this.sourceConnections.remove(connection);
+ support.firePropertyChange(PRO_REMOVE_SOURCE_CONNECTION, connection, null);
+ }
+ }
+
+ public void addTargetConnection(TreeNodeConnection connection) {
+ if (this.targetConnections.indexOf(connection) == -1) {
+ this.targetConnections.add(connection);
+ support.firePropertyChange(PRO_ADD_TARGET_CONNECTION, null, connection);
+ }
+ }
+
+ public void removeTargetConnection(TreeNodeConnection connection) {
+ if (this.targetConnections.indexOf(connection) != -1) {
+ this.targetConnections.remove(connection);
+ support.firePropertyChange(PRO_REMOVE_TARGET_CONNECTION, connection, null);
+ }
+ }
+
+ public void addChild(AbstractSmooksGraphicalModel node) {
+ if (getChildren().indexOf(node) == -1) {
+ getChildren().add(node);
+ node.setParent(this);
+ support.firePropertyChange(PRO_ADD_CHILD, null, node);
+ }
+ }
+
+ public void removeChild(AbstractSmooksGraphicalModel node) {
+ if (getChildren().indexOf(node) != -1) {
+ getChildren().remove(node);
+ node.setParent(null);
+ support.firePropertyChange(PRO_REMOVE_CHILD, node, null);
+ }
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+
+ public void setUserData(String key, Object data) {
+ userDataMap.put(key, data);
+ }
+
+ public Object getUserData(String key) {
+ return userDataMap.get(key);
+ }
+
+ public String getText() {
+ // if (data != null && labelProvider != null) {
+ // return labelProvider.getText(data);
+ // }
+ return null;
+ }
+
+ public Image getImage() {
+ // if (data != null && labelProvider != null) {
+ // return labelProvider.getImage(data);
+ // }
+ return null;
+ }
+
+ public boolean isLinkable() {
+ return linkable;
+ }
+
+ public void setLinkable(boolean linkable) {
+ this.linkable = linkable;
+ }
+
+ public boolean canLinkWithSource(Object model) {
+ return true;
+ }
+
+ public boolean canLinkWithTarget(Object model) {
+ return true;
+ }
+
+ public void setText(String text) {
+ }
+
+ public List<TreeNodeConnection> getSourceConnections() {
+ return sourceConnections;
+ }
+
+ public List<TreeNodeConnection> getTargetConnections() {
+ return targetConnections;
+ }
+
+ public void fireChildrenChanged() {
+ support.firePropertyChange(PRO_FORCE_CHIDLREN_CHANGED, new Object(), null);
+ }
+
+ public void fireConnectionChanged() {
+ support.firePropertyChange(PRO_FORCE_CONNECTION_CHANGED, new Object(), null);
+ }
+
+ public void fireVisualChanged() {
+ support.firePropertyChange(PRO_FORCE_VISUAL_CHANGED, new Object(), null);
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/model/AbstractSmooksGraphicalModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeContainerEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -10,14 +10,18 @@
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.ui.IEditorPart;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeGraphicalNodeEditPolicy;
import org.jboss.tools.smooks.gef.tree.figures.IMoveableModel;
import org.jboss.tools.smooks.gef.tree.figures.TreeContainerFigure;
import org.jboss.tools.smooks.gef.tree.figures.TreeFigureExpansionEvent;
import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
/**
* @author DartPeng
@@ -90,6 +94,15 @@
super.propertyChange(evt);
if (IMoveableModel.PRO_BOUNDS_CHANGED.equals(evt.getPropertyName())) {
refresh();
+ DefaultEditDomain domain = (DefaultEditDomain) getViewer().getEditDomain();
+ IEditorPart editor = domain.getEditorPart();
+ ISmooksModelProvider modelProvider = (ISmooksModelProvider) editor.getAdapter(ISmooksModelProvider.class);
+
+ if(modelProvider != null && getModel() instanceof IMoveableModel){
+ SmooksGraphicsExtType graph = modelProvider.getSmooksGraphicsExt();
+ Rectangle rect = ((IMoveableModel)getModel()).getBounds();
+ recordBounds(graph,rect);
+ }
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/editparts/TreeNodeConnectionEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -15,11 +15,11 @@
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeConnectionEditPolicy;
import org.jboss.tools.smooks.gef.tree.editpolicy.TreeNodeEndpointEditPolicy;
import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
-import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
/**
* @author DartPeng
@@ -40,8 +40,8 @@
public IFigure createFigure() {
TreeNodeConnection model = (TreeNodeConnection) getModel();
- TreeNodeModel sourceModel = model.getSourceNode();
- TreeNodeModel targetModel = model.getTargetNode();
+ AbstractSmooksGraphicalModel sourceModel = model.getSourceNode();
+ AbstractSmooksGraphicalModel targetModel = model.getTargetNode();
PolylineConnection connection1 = new PolylineConnection() {
@Override
public void paintFigure(Graphics graphics) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeContainerModel.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -1,7 +1,5 @@
package org.jboss.tools.smooks.gef.tree.model;
-import java.util.List;
-
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
@@ -30,10 +28,6 @@
this.sourceLinkNode = sourceLinkNode;
}
- public List<TreeNodeModel> getChildren() {
- return super.getChildren();
- }
-
public Point getLocation() {
return location;
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeConnection.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -4,67 +4,68 @@
package org.jboss.tools.smooks.gef.tree.model;
import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
/**
* @author DartPeng
- *
+ *
*/
public class TreeNodeConnection {
-
- private TreeNodeModel sourceNode;
-
- private TreeNodeModel targetNode;
-
- public TreeNodeConnection(){
-
+
+ private AbstractSmooksGraphicalModel sourceNode;
+
+ private AbstractSmooksGraphicalModel targetNode;
+
+ public TreeNodeConnection() {
+
}
- public TreeNodeConnection(TreeNodeModel sourceNode,TreeNodeModel targetNode){
+ public TreeNodeConnection(AbstractSmooksGraphicalModel sourceNode, AbstractSmooksGraphicalModel targetNode) {
this.sourceNode = sourceNode;
this.targetNode = targetNode;
Assert.isNotNull(sourceNode);
Assert.isNotNull(targetNode);
}
-
- public void connect(){
+
+ public void connect() {
connectSource();
connectTarget();
}
-
- public void disconnect(){
+
+ public void disconnect() {
disconnectSource();
disconnectTarget();
}
-
- public void connectSource(){
+
+ public void connectSource() {
sourceNode.addSourceConnection(this);
}
-
- public void connectTarget(){
+
+ public void connectTarget() {
targetNode.addTargetConnection(this);
}
-
- public void disconnectSource(){
+
+ public void disconnectSource() {
sourceNode.removeSourceConnection(this);
}
-
- public void disconnectTarget(){
+
+ public void disconnectTarget() {
targetNode.removeTargetConnection(this);
}
-
- public TreeNodeModel getSourceNode() {
+
+ public AbstractSmooksGraphicalModel getSourceNode() {
return sourceNode;
}
- public void setSourceNode(TreeNodeModel sourceNode) {
+ public void setSourceNode(AbstractSmooksGraphicalModel sourceNode) {
this.sourceNode = sourceNode;
}
- public TreeNodeModel getTargetNode() {
+ public AbstractSmooksGraphicalModel getTargetNode() {
return targetNode;
}
- public void setTargetNode(TreeNodeModel targetNode) {
+ public void setTargetNode(AbstractSmooksGraphicalModel targetNode) {
this.targetNode = targetNode;
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java 2009-07-23 01:16:12 UTC (rev 16745)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/gef/tree/model/TreeNodeModel.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -1,60 +1,23 @@
package org.jboss.tools.smooks.gef.tree.model;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
-public class TreeNodeModel implements IConnectableNode {
+public class TreeNodeModel extends AbstractSmooksGraphicalModel {
protected ITreeContentProvider contentProvider;
protected ILabelProvider labelProvider;
- public static final String PRO_ADD_CHILD = "_pro_add_child";
-
- public static final String PRO_REMOVE_CHILD = "_pro_remove_child";
-
- public static final String PRO_ADD_SOURCE_CONNECTION = "_pro_add_source_connected";
-
- public static final String PRO_ADD_TARGET_CONNECTION = "_pro_add_target_connected";
-
- public static final String PRO_REMOVE_SOURCE_CONNECTION = "_pro_remove_source_connected";
-
- public static final String PRO_REMOVE_TARGET_CONNECTION = "_pro_remove_target_connected";
-
- public static final String PRO_TEXT_CHANGED = "_pro_text_changed";
-
- public static final String PRO_FORCE_VISUAL_CHANGED = "_pro_force_text_changed";
-
- public static final String PRO_FORCE_CHIDLREN_CHANGED = "_pro_force_children_changed";
-
- public static final String PRO_FORCE_CONNECTION_CHANGED = "_pro_force_connection_changed";
-
- protected Object data = null;
-
- private boolean linkable = true;
-
- private TreeNodeModel parent = null;
-
- private HashMap<String, Object> userDataMap = new HashMap<String, Object>();
-
- protected PropertyChangeSupport support = new PropertyChangeSupport(this);
-
- protected List<TreeNodeModel> children = null;
-
- private List<TreeNodeConnection> sourceConnections = new ArrayList<TreeNodeConnection>();
-
- private List<TreeNodeConnection> targetConnections = new ArrayList<TreeNodeConnection>();
-
public TreeNodeModel(Object data, ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
+ super(data);
setContentProvider(contentProvider);
setLabelProvider(labelProvider);
setData(data);
@@ -66,15 +29,7 @@
}
return true;
}
-
- public TreeNodeModel getParent() {
- return parent;
- }
-
- public void setParent(TreeNodeModel parent) {
- this.parent = parent;
- }
-
+
public ITreeContentProvider getContentProvider() {
return contentProvider;
}
@@ -96,12 +51,12 @@
return new TreeNodeModel(model, contentProvider, labelProvider);
}
- public List<TreeNodeModel> getChildren() {
+ public List<AbstractSmooksGraphicalModel> getChildren() {
if (children == null) {
if (this.contentProvider != null && data != null) {
Object[] models = contentProvider.getChildren(data);
if (models != null) {
- children = new ArrayList<TreeNodeModel>();
+ children = new ArrayList<AbstractSmooksGraphicalModel>();
for (int i = 0; i < models.length; i++) {
Object model = models[i];
TreeNodeModel n = createChildModel(model, contentProvider, labelProvider);
@@ -124,9 +79,9 @@
n.setParent(this);
}
}
- List<TreeNodeModel> temp = new ArrayList<TreeNodeModel>(children);
+ List<AbstractSmooksGraphicalModel> temp = new ArrayList<AbstractSmooksGraphicalModel>(children);
for (Iterator<?> iterator = temp.iterator(); iterator.hasNext();) {
- TreeNodeModel node = (TreeNodeModel) iterator.next();
+ AbstractSmooksGraphicalModel node = (AbstractSmooksGraphicalModel) iterator.next();
Object data = node.getData();
if (!graphicalChildExist(data, models)) {
disconnectAllConnections(node);
@@ -142,123 +97,7 @@
return children;
}
- protected void disconnectAllConnections(TreeNodeModel node) {
- List<TreeNodeConnection> sourceConnections = node.getSourceConnections();
- List<TreeNodeConnection> targetConnections = node.getTargetConnections();
- List<TreeNodeConnection> tempSourceConnections = new ArrayList<TreeNodeConnection>(sourceConnections);
- List<TreeNodeConnection> tempTargetConnections = new ArrayList<TreeNodeConnection>(targetConnections);
- for (Iterator<?> iterator2 = tempTargetConnections.iterator(); iterator2.hasNext();) {
- TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
- treeNodeConnection.disconnectSource();
- }
-
- for (Iterator<?> iterator2 = tempSourceConnections.iterator(); iterator2.hasNext();) {
- TreeNodeConnection treeNodeConnection = (TreeNodeConnection) iterator2.next();
- treeNodeConnection.disconnectTarget();
- }
-
- tempSourceConnections.clear();
- tempTargetConnections.clear();
- tempSourceConnections = null;
- tempTargetConnections = null;
-
- List<TreeNodeModel> children = node.getChildren();
- for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
- TreeNodeModel treeNodeModel = (TreeNodeModel) iterator.next();
- disconnectAllConnections(treeNodeModel);
- }
- }
-
- protected boolean graphicalChildExist(Object model, Object[] models) {
- for (int i = 0; i < models.length; i++) {
- if (model == models[i]) {
- return true;
- }
- }
- return false;
- }
-
- protected boolean childExsit(Object model) {
- if (children != null) {
- for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
- TreeNodeModel node = (TreeNodeModel) iterator.next();
- if (node.getData() == model) {
- return true;
- }
- }
- }
- return false;
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- support.addPropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- support.removePropertyChangeListener(listener);
- }
-
- public void addSourceConnection(TreeNodeConnection connection) {
- if (this.sourceConnections.indexOf(connection) == -1) {
- this.sourceConnections.add(connection);
- support.firePropertyChange(PRO_ADD_SOURCE_CONNECTION, null, connection);
- }
- }
-
- public void removeSourceConnection(TreeNodeConnection connection) {
- if (this.sourceConnections.indexOf(connection) != -1) {
- this.sourceConnections.remove(connection);
- support.firePropertyChange(PRO_REMOVE_SOURCE_CONNECTION, connection, null);
- }
- }
-
- public void addTargetConnection(TreeNodeConnection connection) {
- if (this.targetConnections.indexOf(connection) == -1) {
- this.targetConnections.add(connection);
- support.firePropertyChange(PRO_ADD_TARGET_CONNECTION, null, connection);
- }
- }
-
- public void removeTargetConnection(TreeNodeConnection connection) {
- if (this.targetConnections.indexOf(connection) != -1) {
- this.targetConnections.remove(connection);
- support.firePropertyChange(PRO_REMOVE_TARGET_CONNECTION, connection, null);
- }
- }
-
- public void addChild(TreeNodeModel node) {
- if (getChildren().indexOf(node) == -1) {
- getChildren().add(node);
- node.setParent(this);
- support.firePropertyChange(PRO_ADD_CHILD, null, node);
- }
- }
-
- public void removeChild(TreeNodeModel node) {
- if (getChildren().indexOf(node) != -1) {
- getChildren().remove(node);
- node.setParent(null);
- support.firePropertyChange(PRO_REMOVE_CHILD, node, null);
- }
- }
-
- public Object getData() {
- return data;
- }
-
- public void setData(Object data) {
- this.data = data;
- }
-
- public void setUserData(String key, Object data) {
- userDataMap.put(key, data);
- }
-
- public Object getUserData(String key) {
- return userDataMap.get(key);
- }
-
public String getText() {
if (data != null && labelProvider != null) {
return labelProvider.getText(data);
@@ -273,14 +112,14 @@
return null;
}
- public boolean isLinkable() {
- return linkable;
- }
+// public boolean isLinkable() {
+// return linkable;
+// }
+//
+// public void setLinkable(boolean linkable) {
+// this.linkable = linkable;
+// }
- public void setLinkable(boolean linkable) {
- this.linkable = linkable;
- }
-
public boolean canLinkWithSource(Object model) {
return true;
}
@@ -296,25 +135,4 @@
// support.firePropertyChange(PRO_TEXT_CHANGED, oldtext, this.text);
// }
}
-
- public List<TreeNodeConnection> getSourceConnections() {
- return sourceConnections;
- }
-
- public List<TreeNodeConnection> getTargetConnections() {
- return targetConnections;
- }
-
- public void fireChildrenChanged(){
- support.firePropertyChange(PRO_FORCE_CHIDLREN_CHANGED, new Object(), null);
- }
-
- public void fireConnectionChanged(){
- support.firePropertyChange(PRO_FORCE_CONNECTION_CHANGED, new Object(), null);
- }
-
- public void fireVisualChanged(){
- support.firePropertyChange(PRO_FORCE_VISUAL_CHANGED, new Object(), null);
- }
-
}
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksEditFactory.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksEditFactory.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksEditFactory.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+import org.jboss.tools.smooks.gef.common.RootModel;
+import org.jboss.tools.smooks.gef.common.SmooksGEFEditFactory;
+import org.jboss.tools.smooks.gef.tree.editparts.RootEditPart;
+import org.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart;
+import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeConnectionEditPart;
+import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart;
+import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeConnection;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+import org.jboss.tools.smooks.graphical.editors.editparts.InputDataContainerEditPart;
+import org.jboss.tools.smooks.graphical.editors.editparts.InputDataTreeNodeEditPart;
+import org.jboss.tools.smooks.graphical.editors.model.InputDataContianerModel;
+import org.jboss.tools.smooks.graphical.editors.model.InputDataTreeNodeModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksEditFactory extends SmooksGEFEditFactory implements EditPartFactory{
+
+ public SmooksEditFactory() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public EditPart createEditPart(EditPart context, Object model) {
+ EditPart editPart = null;
+ if(model instanceof RootModel){
+ editPart = new RootEditPart();
+ }
+ if(model.getClass() == TreeNodeModel.class){
+ editPart = new TreeNodeEditPart();
+ }if(model.getClass() == TreeContainerModel.class){
+ editPart = new TreeContainerEditPart();
+ }
+ if(model.getClass() == InputDataTreeNodeModel.class){
+ editPart = new InputDataTreeNodeEditPart();
+ }if(model.getClass() == InputDataContianerModel.class){
+ editPart = new InputDataContainerEditPart();
+ }
+ if(model.getClass() == TreeNodeConnection.class){
+ editPart = new TreeNodeConnectionEditPart();
+ }
+ if(editPart != null){
+ editPart.setModel(model);
+ }
+ return editPart;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksEditFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.commands.CommandStackEvent;
+import org.eclipse.gef.commands.CommandStackEventListener;
+import org.eclipse.gef.editparts.FreeformGraphicalRootEditPart;
+import org.eclipse.gef.ui.parts.GraphicalEditor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.configuration.editors.SelectoreSelectionDialog;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanList;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanModel;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanContentProvider;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanlabelProvider;
+import org.jboss.tools.smooks.configuration.editors.xml.TagList;
+import org.jboss.tools.smooks.configuration.editors.xml.TagObject;
+import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataContentProvider;
+import org.jboss.tools.smooks.configuration.editors.xml.XMLStructuredDataLabelProvider;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.gef.common.RootModel;
+import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
+import org.jboss.tools.smooks.graphical.editors.model.InputDataContianerModel;
+import org.jboss.tools.smooks.model.smooks.DocumentRoot;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksGraphicalEditorPart extends GraphicalEditor {
+
+ private DefaultEditDomain editDomain = null;
+
+ private SmooksMultiFormEditor formEditor = null;
+
+ public SmooksGraphicalEditorPart(SmooksMultiFormEditor formEditor) {
+ super();
+ this.editDomain = new DefaultEditDomain(this);
+ this.editDomain.getCommandStack().addCommandStackEventListener(new CommandStackEventListener() {
+
+ public void stackChanged(CommandStackEvent event) {
+ firePropertyChange(PROP_DIRTY);
+ }
+ });
+ this.formEditor = formEditor;
+ this.setEditDomain(editDomain);
+ }
+
+ public DefaultEditDomain getEditDomain() {
+ return editDomain;
+ }
+
+ @Override
+ protected void configureGraphicalViewer() {
+ super.configureGraphicalViewer();
+ getGraphicalViewer().setEditDomain(editDomain);
+ getGraphicalViewer().setEditPartFactory(new SmooksEditFactory());
+
+ getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.ui.parts.GraphicalEditor#initializeGraphicalViewer()
+ */
+ @Override
+ protected void initializeGraphicalViewer() {
+ Object obj = formEditor.getSmooksModel();
+ if (obj instanceof DocumentRoot) {
+ List<Object> inputDatas = SelectoreSelectionDialog.generateInputData(formEditor.getSmooksGraphicsExt(),
+ ((DocumentRoot) obj).getSmooksResourceList());
+ RootModel root = new RootModel();
+ for (Iterator<?> iterator = inputDatas.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ ITreeContentProvider contentProvider = new XMLStructuredDataContentProvider();
+ ILabelProvider labelProvider = new XMLStructuredDataLabelProvider();
+ Object containerModel = null;
+
+ if (object instanceof JavaBeanModel) {
+ contentProvider = new JavabeanContentProvider();
+ labelProvider = new JavabeanlabelProvider();
+ containerModel = new JavaBeanList();
+ ((JavaBeanList) containerModel).addJavaBean((JavaBeanModel) object);
+ }
+ if (object instanceof TagObject) {
+ containerModel = new TagList();
+ ((TagList) containerModel).addRootTag((TagObject) object);
+ }
+ if (containerModel != null) {
+ TreeContainerModel container = new InputDataContianerModel(containerModel, contentProvider,
+ labelProvider);
+ root.addTreeNode(container);
+ }
+ }
+ getGraphicalViewer().setContents(root);
+ }
+ }
+
+
+
+ @Override
+ public Object getAdapter(Class type) {
+ if(type == ISmooksModelProvider.class){
+ return this.formEditor;
+ }
+ return super.getAdapter(type);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.
+ * IProgressMonitor)
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksGraphicalEditorPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractSmooksElementEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractSmooksElementEditPart.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractSmooksElementEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors.editparts;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.jboss.tools.smooks.gef.model.AbstractSmooksGraphicalModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class AbstractSmooksElementEditPart extends AbstractGraphicalEditPart implements PropertyChangeListener {
+
+ @Override
+ public void activate() {
+ super.activate();
+ Object model = getModel();
+ if (model instanceof AbstractSmooksGraphicalModel) {
+ ((AbstractSmooksGraphicalModel) model).addPropertyChangeListener(this);
+ }
+ }
+
+ @Override
+ public void deactivate() {
+ Object model = getModel();
+ if (model instanceof AbstractSmooksGraphicalModel) {
+ ((AbstractSmooksGraphicalModel) model).removePropertyChangeListener(this);
+ }
+ super.deactivate();
+ }
+
+
+
+ @Override
+ protected List<?> getModelChildren() {
+ Object model = getModel();
+ if (model instanceof AbstractSmooksGraphicalModel) {
+ return ((AbstractSmooksGraphicalModel)model).getChildren();
+ }
+ return super.getModelChildren();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+ */
+ @Override
+ protected IFigure createFigure() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+ */
+ @Override
+ protected void createEditPolicies() {
+
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ String proName = evt.getPropertyName();
+ if (AbstractSmooksGraphicalModel.PRO_FORCE_VISUAL_CHANGED.equals(proName)) {
+ refreshVisuals();
+ }
+ if (AbstractSmooksGraphicalModel.PRO_ADD_CHILD.equals(proName)
+ || AbstractSmooksGraphicalModel.PRO_REMOVE_CHILD.equals(proName)
+ || AbstractSmooksGraphicalModel.PRO_FORCE_CHIDLREN_CHANGED.equals(proName)) {
+ refreshChildren();
+
+ }
+ if (AbstractSmooksGraphicalModel.PRO_ADD_SOURCE_CONNECTION.equals(proName)
+ || AbstractSmooksGraphicalModel.PRO_REMOVE_SOURCE_CONNECTION.equals(proName)) {
+ refreshSourceConnections();
+ }
+ if (AbstractSmooksGraphicalModel.PRO_ADD_TARGET_CONNECTION.equals(proName)
+ || AbstractSmooksGraphicalModel.PRO_REMOVE_TARGET_CONNECTION.equals(proName)) {
+ refreshTargetConnections();
+ }
+
+ if (AbstractSmooksGraphicalModel.PRO_FORCE_CONNECTION_CHANGED.equals(proName)) {
+ refreshSourceConnections();
+ refreshTargetConnections();
+ }
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/AbstractSmooksElementEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors.editparts;
+
+import java.beans.PropertyChangeEvent;
+
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.jboss.tools.smooks.gef.tree.editparts.TreeContainerEditPart;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class InputDataContainerEditPart extends TreeContainerEditPart {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ super.propertyChange(evt);
+ }
+
+ @Override
+ protected String generateFigureID() {
+ TreeNodeModel model = (TreeNodeModel)this.getModel();
+ Object data = model.getData();
+ if(data instanceof IXMLStructuredObject){
+ return ((IXMLStructuredObject)data).getID().toString();
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataContainerEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataTreeNodeEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataTreeNodeEditPart.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataTreeNodeEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors.editparts;
+
+import org.jboss.tools.smooks.gef.tree.editparts.TreeNodeEditPart;
+
+/**
+ * @author Dart
+ *
+ */
+public class InputDataTreeNodeEditPart extends TreeNodeEditPart {
+
+ @Override
+ protected boolean isDragLink() {
+ return true;
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/InputDataTreeNodeEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementContainerEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementContainerEditPart.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementContainerEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors.editparts;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksElementContainerEditPart extends SmooksElementEditPart {
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementContainerEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementEditPart.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementEditPart.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementEditPart.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors.editparts;
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksElementEditPart extends AbstractSmooksElementEditPart {
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/editparts/SmooksElementEditPart.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataContianerModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataContianerModel.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataContianerModel.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors.model;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.gef.tree.model.TreeContainerModel;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class InputDataContianerModel extends TreeContainerModel {
+
+ public InputDataContianerModel(Object data, ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
+ super(data, contentProvider, labelProvider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected TreeNodeModel createChildModel(Object model, ITreeContentProvider contentProvider,
+ ILabelProvider labelProvider) {
+ return new InputDataTreeNodeModel(model, contentProvider, labelProvider);
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataContianerModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataTreeNodeModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataTreeNodeModel.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataTreeNodeModel.java 2009-07-23 11:19:10 UTC (rev 16746)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.graphical.editors.model;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.gef.tree.model.TreeNodeModel;
+
+/**
+ * @author Dart
+ *
+ */
+public class InputDataTreeNodeModel extends TreeNodeModel {
+
+ public InputDataTreeNodeModel(Object data, ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
+ super(data, contentProvider, labelProvider);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected TreeNodeModel createChildModel(Object model, ITreeContentProvider contentProvider,
+ ILabelProvider labelProvider) {
+ return new InputDataTreeNodeModel(model, contentProvider, labelProvider);
+ }
+
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/model/InputDataTreeNodeModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 9 months