From: <max...@us...> - 2006-02-13 15:56:22
|
Update of /cvsroot/hibernate/HibernateExt/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9600/src/org/hibernate/eclipse/mapper/editors Modified Files: ReverseEngineeringEditor.java HibernateContentAssistProcessor.java HBMXMLStructuredTextViewerConfiguration.java ReverseEngineeringEditorContributor.java HBMXMLHyperlinkDetector.java Removed Files: XMLFormEditorPart.java Log Message: fix license issues Index: ReverseEngineeringEditor.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/ReverseEngineeringEditor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ReverseEngineeringEditor.java 7 Feb 2006 16:17:59 -0000 1.12 +++ ReverseEngineeringEditor.java 13 Feb 2006 15:55:59 -0000 1.13 @@ -29,6 +29,7 @@ import org.hibernate.eclipse.mapper.editors.reveng.RevEngTableFilterPage; import org.hibernate.eclipse.mapper.editors.reveng.RevEngTablesPage; import org.hibernate.eclipse.mapper.editors.reveng.RevEngTypeMappingPage; +import org.hibernate.eclipse.mapper.editors.xpl.XMLFormEditorPart; import org.hibernate.eclipse.mapper.model.DOMReverseEngineeringDefinition; import org.hibernate.eclipse.nature.HibernateNature; import org.w3c.dom.Document; Index: HibernateContentAssistProcessor.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/HibernateContentAssistProcessor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HibernateContentAssistProcessor.java 29 Nov 2005 17:24:08 -0000 1.5 +++ HibernateContentAssistProcessor.java 13 Feb 2006 15:55:59 -0000 1.6 @@ -1,21 +1,10 @@ package org.hibernate.eclipse.mapper.editors; -import java.util.Iterator; -import java.util.List; - import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; -import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor; - -public abstract class HibernateContentAssistProcessor extends XMLContentAssistProcessor { +import org.hibernate.eclipse.mapper.editors.xpl.BaseXMLContentAssistProcessor; +public abstract class HibernateContentAssistProcessor extends BaseXMLContentAssistProcessor { public HibernateContentAssistProcessor() { @@ -25,54 +14,4 @@ return CFGXMLStructuredTextViewerConfiguration.findJavaProject(contentAssistRequest); } - protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) { - super.addAttributeValueProposals(contentAssistRequest); - - IDOMNode node = (IDOMNode) contentAssistRequest.getNode(); - - // Find the attribute region and name for which this position should have a value proposed - IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion(); - ITextRegionList openRegions = open.getRegions(); - int i = openRegions.indexOf(contentAssistRequest.getRegion() ); - if (i < 0) - return; - ITextRegion nameRegion = null; - while (i >= 0) { - nameRegion = openRegions.get(i--); - if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) - break; - } - - String matchString = contentAssistRequest.getMatchString(); - int offset = contentAssistRequest.getReplacementBeginPosition(); - if (matchString == null) { - matchString = ""; //$NON-NLS-1$ - } - if (matchString.length() > 0 && (matchString.startsWith("\"") || matchString.startsWith("'") ) ) {//$NON-NLS-2$//$NON-NLS-1$ - matchString = matchString.substring(1); - offset = offset+1; - } - - if (nameRegion != null) { - String attributeName = open.getText(nameRegion); - - List attributeValueProposals = getAttributeValueProposals(attributeName, matchString, offset, contentAssistRequest); - if(attributeValueProposals!=null) { - for (Iterator iter = attributeValueProposals.iterator(); iter.hasNext();) { - ICompletionProposal element = (ICompletionProposal) iter.next(); - contentAssistRequest.addProposal(element); - } - } - - } - - } - - abstract protected List getAttributeValueProposals(String attributeName, String matchString, int offset, ContentAssistRequest contentAssistRequest); - - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { - return super.computeCompletionProposals(viewer, offset); - - } - } Index: HBMXMLStructuredTextViewerConfiguration.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/HBMXMLStructuredTextViewerConfiguration.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- HBMXMLStructuredTextViewerConfiguration.java 7 Feb 2006 16:17:59 -0000 1.9 +++ HBMXMLStructuredTextViewerConfiguration.java 13 Feb 2006 15:55:59 -0000 1.10 @@ -1,7 +1,9 @@ package org.hibernate.eclipse.mapper.editors; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; @@ -14,34 +16,44 @@ public class HBMXMLStructuredTextViewerConfiguration extends StructuredTextViewerConfigurationXML { - protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) { - IContentAssistProcessor[] processors = null; - - if ((partitionType == IStructuredPartitionTypes.DEFAULT_PARTITION) || (partitionType == IXMLPartitions.XML_DEFAULT)) { - processors = new IContentAssistProcessor[]{new HBMXMLContentAssistProcessor()}; // TODO: return cached one ? - } - else if (partitionType == IStructuredPartitionTypes.UNKNOWN_PARTITION) { - processors = new IContentAssistProcessor[]{new NoRegionContentAssistProcessor()}; - } + static Map partitionToContentAssist = new HashMap(); + static { + IContentAssistProcessor[] contentAssistProcessor = new IContentAssistProcessor[] { new HBMXMLContentAssistProcessor() }; + partitionToContentAssist.put(IStructuredPartitionTypes.DEFAULT_PARTITION, contentAssistProcessor); + partitionToContentAssist.put(IXMLPartitions.XML_DEFAULT, contentAssistProcessor); - return processors; + contentAssistProcessor = new IContentAssistProcessor[] { new NoRegionContentAssistProcessor() }; + partitionToContentAssist.put(IStructuredPartitionTypes.UNKNOWN_PARTITION, contentAssistProcessor ); + } + + protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) { + return (IContentAssistProcessor[]) partitionToContentAssist.get(partitionType); } public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { - if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED) ) + if (sourceViewer == null || hyperLinksEnabled() ) { return null; + } - List allDetectors = new ArrayList(0); - allDetectors.add(new HBMXMLHyperlinkDetector() ); + IHyperlinkDetector[] baseDetectors = super.getHyperlinkDetectors(sourceViewer); + HBMXMLHyperlinkDetector hyperlinkDetector = new HBMXMLHyperlinkDetector(); - IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer); - for (int m = 0; m < superDetectors.length; m++) { - IHyperlinkDetector detector = superDetectors[m]; - if (!allDetectors.contains(detector) ) { - allDetectors.add(detector); + if(baseDetectors==null || baseDetectors.length==0) { + return new IHyperlinkDetector[] { hyperlinkDetector }; + } else { + IHyperlinkDetector[] result = new IHyperlinkDetector[baseDetectors.length+1]; + result[0] = hyperlinkDetector; + for (int i = 0; i < baseDetectors.length; i++) { + result[i+1] = baseDetectors[i]; } + return result; } - return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]); + + } + + + private boolean hyperLinksEnabled() { + return !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED); } } Index: ReverseEngineeringEditorContributor.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/ReverseEngineeringEditorContributor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ReverseEngineeringEditorContributor.java 29 Nov 2005 17:24:08 -0000 1.2 +++ ReverseEngineeringEditorContributor.java 13 Feb 2006 15:55:59 -0000 1.3 @@ -1,207 +1,17 @@ package org.hibernate.eclipse.mapper.editors; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorActionBarContributor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.part.MultiPageEditorActionBarContributor; -import org.eclipse.wst.sse.ui.StructuredTextEditor; -import org.eclipse.wst.sse.ui.internal.ExtendedEditorActionBuilder; -import org.eclipse.wst.sse.ui.internal.IExtendedContributor; -import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor; -import org.eclipse.wst.xml.ui.internal.tabletree.IDesignViewerActionBarContributor; -import org.eclipse.wst.xml.ui.internal.tabletree.SourcePageActionContributor; -import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; +import org.hibernate.eclipse.mapper.editors.reveng.xpl.MultiPageEditorContributor; /** * Manages the installation/deinstallation of global actions for multi-page editors. * Responsible for the redirection of global actions to the active editor. * Multi-page contributor replaces the contributors for the individual editors in the multi-page editor. */ -public class ReverseEngineeringEditorContributor extends MultiPageEditorActionBarContributor { - protected IEditorActionBarContributor designViewerActionBarContributor = null; - protected IEditorActionBarContributor sourceViewerActionContributor = null; - protected XMLMultiPageEditorPart multiPageEditor = null; - - // EditorExtension +public class ReverseEngineeringEditorContributor extends MultiPageEditorContributor { + private static final String EDITOR_ID = "org.hibernate.eclipse.mapper.editors.ReverseEngineeringEditor"; //$NON-NLS-1$ - private IExtendedContributor extendedContributor; - + public ReverseEngineeringEditorContributor() { - super(); - - sourceViewerActionContributor = new SourcePageActionContributor(); - - // Read action extensions. - ExtendedEditorActionBuilder builder = new ExtendedEditorActionBuilder(); - extendedContributor = builder.readActionExtensions(EDITOR_ID); - } - - public void init(IActionBars actionBars) { - super.init(actionBars); - - if (actionBars != null) { - initDesignViewerActionBarContributor(actionBars); - initSourceViewerActionContributor(actionBars); - } - } - - protected void initDesignViewerActionBarContributor(IActionBars actionBars) { - if (designViewerActionBarContributor != null) - designViewerActionBarContributor.init(actionBars, getPage() ); - } - - protected void initSourceViewerActionContributor(IActionBars actionBars) { - if (sourceViewerActionContributor != null) - sourceViewerActionContributor.init(actionBars, getPage() ); - } - - public void dispose() { - super.dispose(); - - if (designViewerActionBarContributor != null) - designViewerActionBarContributor.dispose(); - - if (sourceViewerActionContributor != null) - sourceViewerActionContributor.dispose(); - - if (extendedContributor != null) - extendedContributor.dispose(); - } - - /** - * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(IMenuManager) - */ - public final void contributeToMenu(IMenuManager menu) { - super.contributeToMenu(menu); - - addToMenu(menu); - - if (extendedContributor != null) - extendedContributor.contributeToMenu(menu); - } - - protected void addToMenu(IMenuManager menu) { - } - - /** - * @see IExtendedContributor#contributeToPopupMenu(IMenuManager) - */ - public final void contributeToPopupMenu(IMenuManager menu) { - - addToPopupMenu(menu); - - if (extendedContributor != null) - extendedContributor.contributeToPopupMenu(menu); - } - - protected void addToPopupMenu(IMenuManager menu) { - } - - /** - * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(IToolBarManager) - */ - public final void contributeToToolBar(IToolBarManager toolBarManager) { - super.contributeToToolBar(toolBarManager); - - addToToolBar(toolBarManager); - - if (extendedContributor != null) - extendedContributor.contributeToToolBar(toolBarManager); - } - - protected void addToToolBar(IToolBarManager toolBarManager) { - } - - /** - * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToStatusLine(IStatusLineManager) - */ - public final void contributeToStatusLine(IStatusLineManager manager) { - super.contributeToStatusLine(manager); - - addToStatusLine(manager); - - if (extendedContributor != null) - extendedContributor.contributeToStatusLine(manager); - } - - protected void addToStatusLine(IStatusLineManager manager) { - } - - /** - * @see IExtendedContributor#updateToolbarActions() - */ - public void updateToolbarActions() { - if (extendedContributor != null) - extendedContributor.updateToolbarActions(); - } - - public void setActiveEditor(IEditorPart targetEditor) { - // save multiPageEditor before calling - // super.setActiveEditor(targetEditor) - // super.setActiveEditor will call setActivePage(IEditorPart - // activeEditor) - // multiPageEditor is needed in setActivePage(IEditorPart - // activeEditor) - if (targetEditor instanceof XMLMultiPageEditorPart) - multiPageEditor = (XMLMultiPageEditorPart) targetEditor; - - super.setActiveEditor(targetEditor); - - updateToolbarActions(); - - if (extendedContributor != null) - extendedContributor.setActiveEditor(targetEditor); - } - - public void setActivePage(IEditorPart activeEditor) { - // This contributor is designed for StructuredTextMultiPageEditorPart. - // To safe-guard this from problems caused by unexpected usage by - // other editors, the following - // check is added. - if (multiPageEditor != null) { - if (activeEditor != null && activeEditor instanceof StructuredTextEditor) - activateSourcePage(activeEditor); - else - activateDesignPage(activeEditor); - } - - updateToolbarActions(); - - IActionBars actionBars = getActionBars(); - if (actionBars != null) { - // update menu bar and tool bar - actionBars.updateActionBars(); - } - } - - protected void activateDesignPage(IEditorPart activeEditor) { - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { - designViewerActionBarContributor.setActiveEditor(multiPageEditor); - } - - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { - // if design page is not really an IEditorPart, activeEditor == - // null, so pass in multiPageEditor instead (d282414) - if (activeEditor == null) { - sourceViewerActionContributor.setActiveEditor(multiPageEditor); - } else { - sourceViewerActionContributor.setActiveEditor(activeEditor); - } - ( (ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(false); - } - } - - protected void activateSourcePage(IEditorPart activeEditor) { - if (designViewerActionBarContributor != null && designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) { - designViewerActionBarContributor.setActiveEditor(multiPageEditor); - } - - if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor) { - sourceViewerActionContributor.setActiveEditor(activeEditor); - ( (ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(true); - } + super(EDITOR_ID); } } Index: HBMXMLHyperlinkDetector.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/HBMXMLHyperlinkDetector.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- HBMXMLHyperlinkDetector.java 7 Feb 2006 16:17:59 -0000 1.8 +++ HBMXMLHyperlinkDetector.java 13 Feb 2006 15:55:59 -0000 1.9 @@ -5,40 +5,26 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.Region; import org.eclipse.jface.text.hyperlink.IHyperlink; import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.util.StringUtils; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; +import org.hibernate.eclipse.mapper.editors.xpl.BaseXMLHyperlinkSupport; import org.hibernate.eclipse.mapper.extractor.HBMInfoExtractor; import org.hibernate.eclipse.mapper.extractor.HBMInfoHandler; import org.w3c.dom.Attr; -import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** * hyper link detector for hbm.xml */ -public class HBMXMLHyperlinkDetector implements IHyperlinkDetector { +public class HBMXMLHyperlinkDetector extends BaseXMLHyperlinkSupport implements IHyperlinkDetector { HBMInfoExtractor infoExtractor = new HBMInfoExtractor(); - /** - * Creates a new hbm.xml element hyperlink detector. - * - */ public HBMXMLHyperlinkDetector() { } - /* - * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean) - */ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) { if (region == null || textViewer == null) { return null; @@ -77,78 +63,4 @@ return null; } - - private IRegion getHyperlinkRegion(Node node) { - IRegion hyperRegion = null; - - if (node != null) { - short nodeType = node.getNodeType(); - if (nodeType == Node.DOCUMENT_TYPE_NODE) { - // handle doc type node - IDOMNode docNode = (IDOMNode) node; - hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset() ); - } - else if (nodeType == Node.ATTRIBUTE_NODE) { - // handle attribute nodes - IDOMAttr att = (IDOMAttr) node; - // do not include quotes in attribute value region - int regOffset = att.getValueRegionStartOffset(); - int regLength = att.getValueRegion().getTextLength(); - String attValue = att.getValueRegionText(); - if (StringUtils.isQuoted(attValue) ) { - regOffset = ++regOffset; - regLength = regLength - 2; - } - hyperRegion = new Region(regOffset, regLength); - } - } - return hyperRegion; - } - - private Attr getCurrentAttrNode(Node node, int offset) { - if ( (node instanceof IndexedRegion) && ( (IndexedRegion) node).contains(offset) && (node.hasAttributes() ) ) { - NamedNodeMap attrs = node.getAttributes(); - // go through each attribute in node and if attribute contains - // offset, return that attribute - for (int i = 0; i < attrs.getLength(); ++i) { - // assumption that if parent node is of type IndexedRegion, - // then its attributes will also be of type IndexedRegion - IndexedRegion attRegion = (IndexedRegion) attrs.item(i); - if (attRegion.contains(offset) ) { - return (Attr) attrs.item(i); - } - } - } - return null; - } - - - /** - * Returns the node the cursor is currently on in the document. null if no - * node is selected - * - * @param offset - * @return Node either element, doctype, text, or null - */ - private Node getCurrentNode(IDocument document, int offset) { - // get the current node at the offset (returns either: element, - // doctype, text) - IndexedRegion inode = null; - IStructuredModel sModel = null; - try { - sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document); - inode = sModel.getIndexedRegion(offset); - if (inode == null) - inode = sModel.getIndexedRegion(offset - 1); - } - finally { - if (sModel != null) - sModel.releaseFromRead(); - } - - if (inode instanceof Node) { - return (Node) inode; - } - return null; - } } --- XMLFormEditorPart.java DELETED --- |