Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 27094 Details for
Bug 109468
get rid of subclasses of StructuredTextEditor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
org.eclipse.wst.xml.ui.patch
org.eclipse.wst.xml.ui.patch (text/plain), 59.45 KB, created by
Amy Wu
on 2005-09-14 02:20:33 EDT
(
hide
)
Description:
org.eclipse.wst.xml.ui.patch
Filename:
MIME Type:
Creator:
Amy Wu
Created:
2005-09-14 02:20:33 EDT
Size:
59.45 KB
patch
obsolete
>Index: plugin.properties >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/plugin.properties,v >retrieving revision 1.15 >diff -u -r1.15 plugin.properties >--- plugin.properties 21 Jul 2005 01:49:46 -0000 1.15 >+++ plugin.properties 14 Sep 2005 06:18:35 -0000 >@@ -49,4 +49,22 @@ > ############################################################################### > _UI_XML_VALIDATOR = XML Validator > _UI_REF_FILE_SHOW_DETAILS = Show Details... >-_UI_MENU_VALIDATE_XML = Validate XML File >\ No newline at end of file >+_UI_MENU_VALIDATE_XML = Validate XML File >+## >+CleanupDocument_label=Cleanup Document... >+CleanupDocument_tooltip=Cleanup Document >+ToggleComment_label=Toggle Comment >+ToggleComment_tooltip=Toggle Comment >+AddBlockComment_label=Add Block Comment >+AddBlockComment_tooltip=Add Block Comment >+RemoveBlockComment_label=Remove Block Comment >+RemoveBlockComment_tooltip=Remove Block Comment >+FindOccurrences_label=Occurrences in File >+StructureSelectEnclosing_label=Enclosing Element >+StructureSelectEnclosing_tooltip=Expand selection to include enclosing element >+StructureSelectNext_label=Next Element >+StructureSelectNext_tooltip=Expand selection to include next sibling >+StructureSelectPrevious_label=Previous Element >+StructureSelectPrevious_tooltip=Expand selection to include previous sibling >+StructureSelectHistory_label=Restore Last Selection >+StructureSelectHistory_tooltip=Restore last selection >\ No newline at end of file >Index: plugin.xml >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/plugin.xml,v >retrieving revision 1.51 >diff -u -r1.51 plugin.xml >--- plugin.xml 7 Sep 2005 23:49:21 -0000 1.51 >+++ plugin.xml 14 Sep 2005 06:18:36 -0000 >@@ -477,5 +477,81 @@ > </validator> > </extension> > >- >+ <extension point="org.eclipse.ui.editorActions"> >+ <editorContribution >+ id="org.eclipse.core.runtime.xml.source.editorActions" >+ targetID="org.eclipse.core.runtime.xml.source"> >+ <action >+ id="CleanupDocument" >+ label="%CleanupDocument_label" >+ definitionId="org.eclipse.wst.sse.ui.cleanup.document" >+ tooltip="%CleanupDocument_tooltip" >+ class="org.eclipse.wst.xml.ui.internal.actions.CleanupActionXMLDelegate" >+ actionID="CleanupDocument"> >+ </action> >+ <action >+ id="ToggleComment" >+ label="%ToggleComment_label" >+ definitionId="org.eclipse.wst.sse.ui.toggle.comment" >+ tooltip="%ToggleComment_tooltip" >+ class="org.eclipse.wst.xml.ui.internal.actions.ToggleCommentActionXMLDelegate" >+ actionID="ToggleComment"> >+ </action> >+ <action >+ id="AddBlockComment" >+ label="%AddBlockComment_label" >+ definitionId="org.eclipse.wst.sse.ui.add.block.comment" >+ tooltip="%AddBlockComment_tooltip" >+ class="org.eclipse.wst.xml.ui.internal.actions.AddBlockCommentActionXMLDelegate" >+ actionID="AddBlockComment"> >+ </action> >+ <action >+ id="RemoveBlockComment" >+ label="%RemoveBlockComment_label" >+ definitionId="org.eclipse.wst.sse.ui.remove.block.comment" >+ tooltip="%RemoveBlockComment_tooltip" >+ class="org.eclipse.wst.xml.ui.internal.actions.RemoveBlockCommentActionXMLDelegate" >+ actionID="RemoveBlockComment"> >+ </action> >+ <action >+ id="FindOccurrences" >+ label="%FindOccurrences_label" >+ definitionId="org.eclipse.wst.sse.ui.search.find.occurrences" >+ class="org.eclipse.wst.xml.ui.internal.search.XMLFindOccurrencesActionDelegate" >+ actionID="FindOccurrences"> >+ </action> >+ <action >+ id="StructureSelectEnclosing" >+ label="%StructureSelectEnclosing_label" >+ definitionId="org.eclipse.wst.sse.ui.structure.select.enclosing" >+ tooltip="%StructureSelectEnclosing_tooltip" >+ class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectEnclosingXMLActionDelegate" >+ actionID="StructureSelectEnclosing"> >+ </action> >+ <action >+ id="StructureSelectNext" >+ label="%StructureSelectNext_label" >+ definitionId="org.eclipse.wst.sse.ui.structure.select.next" >+ tooltip="%StructureSelectNext_tooltip" >+ class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectNextXMLActionDelegate" >+ actionID="StructureSelectNext"> >+ </action> >+ <action >+ id="StructureSelectPrevious" >+ label="%StructureSelectPrevious_label" >+ definitionId="org.eclipse.wst.sse.ui.structure.select.previous" >+ tooltip="%StructureSelectPrevious_tooltip" >+ class="org.eclipse.wst.xml.ui.internal.selection.StructuredSelectPreviousXMLActionDelegate" >+ actionID="StructureSelectPrevious"> >+ </action> >+ <action >+ id="StructureSelectHistory" >+ label="%StructureSelectHistory_label" >+ definitionId="org.eclipse.wst.sse.ui.structure.select.last" >+ tooltip="%StructureSelectHistory_tooltip" >+ class="org.eclipse.wst.sse.ui.internal.selection.StructuredSelectHistoryActionDelegate" >+ actionID="StructureSelectHistory"> >+ </action> >+ </editorContribution> >+ </extension> > </plugin> >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.8 >diff -u -r1.8 MANIFEST.MF >--- META-INF/MANIFEST.MF 7 Sep 2005 23:49:20 -0000 1.8 >+++ META-INF/MANIFEST.MF 14 Sep 2005 06:18:36 -0000 >@@ -27,6 +27,7 @@ > org.eclipse.wst.xml.ui.internal.provisional, > org.eclipse.wst.xml.ui.internal.registry, > org.eclipse.wst.xml.ui.internal.search, >+ org.eclipse.wst.xml.ui.internal.selection, > org.eclipse.wst.xml.ui.internal.style, > org.eclipse.wst.xml.ui.internal.tabletree, > org.eclipse.wst.xml.ui.internal.taginfo, >Index: src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java,v >retrieving revision 1.5 >diff -u -r1.5 XMLUIMessages.java >--- src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java 23 Aug 2005 01:48:45 -0000 1.5 >+++ src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java 14 Sep 2005 06:18:36 -0000 >@@ -271,6 +271,15 @@ > public static String OpenFileFromSource_tooltip; // Resource bundle > public static String OpenFileFromSource_description; // Resource bundle > public static String XMLContentOutlineConfiguration_0; >+ public static String StructureSelectEnclosing_label; >+ public static String StructureSelectEnclosing_tooltip; >+ public static String StructureSelectEnclosing_description; >+ public static String StructureSelectNext_label; >+ public static String StructureSelectNext_tooltip; >+ public static String StructureSelectNext_description; >+ public static String StructureSelectPrevious_label; >+ public static String StructureSelectPrevious_tooltip; >+ public static String StructureSelectPrevious_description; > > static { > // load message values from bundle file >Index: src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties,v >retrieving revision 1.7 >diff -u -r1.7 XMLUIPluginResources.properties >--- src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties 23 Aug 2005 01:48:45 -0000 1.7 >+++ src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties 14 Sep 2005 06:18:36 -0000 >@@ -269,19 +269,19 @@ > Uncomment_label=&Uncomment > Uncomment_tooltip=Uncomment > Uncomment_description=Uncomment >-ToggleComment_label=Togg&le Comment >+ToggleComment_label=Toggle Comment > ToggleComment_tooltip=Toggle Comment > ToggleComment_description=Toggle Comment >-AddBlockComment_label=Add &Block Comment >+AddBlockComment_label=Add Block Comment > AddBlockComment_tooltip=Add Block Comment > AddBlockComment_description=Add Block Comment >-RemoveBlockComment_label=Remove Bloc&k Comment >+RemoveBlockComment_label=Remove Block Comment > RemoveBlockComment_tooltip=Remove Block Comment > RemoveBlockComment_description=Remove Block Comment >-CleanupDocument_label=C&leanup Document... >+CleanupDocument_label=Cleanup Document... > CleanupDocument_tooltip=Cleanup Document > CleanupDocument_description=Cleanup Document >-FindOccurrences_label=O&ccurrences in File >+FindOccurrences_label=Occurrences in File > ShowTooltipDesc_label=Show &Tooltip Description > ShowTooltipDesc_tooltip=Displays the hover help for the selected element > ShowTooltipDesc_description=Displays the hover help for the selected element >@@ -301,3 +301,12 @@ > OpenFileFromSource_tooltip=Open an editor on the selected link > OpenFileFromSource_description=Open an editor on the selected link > XMLContentOutlineConfiguration_0=Show Attributes >+StructureSelectEnclosing_label=Enclosing Element >+StructureSelectEnclosing_tooltip=Expand selection to include enclosing element >+StructureSelectEnclosing_description=Expand selection to include enclosing element >+StructureSelectNext_label=Next Element >+StructureSelectNext_tooltip=Expand selection to include next sibling >+StructureSelectNext_description=Expand selection to include next sibling >+StructureSelectPrevious_label=Previous Element >+StructureSelectPrevious_tooltip=Expand selection to include previous sibling >+StructureSelectPrevious_description=Expand selection to include previous sibling >\ No newline at end of file >Index: src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java,v >retrieving revision 1.2 >diff -u -r1.2 AddBlockCommentActionXML.java >--- src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java 18 Apr 2005 07:59:12 -0000 1.2 >+++ src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXML.java 14 Sep 2005 06:18:37 -0000 >@@ -21,6 +21,9 @@ > import org.eclipse.wst.xml.core.internal.document.CommentImpl; > import org.eclipse.wst.xml.ui.internal.XMLUIMessages; > >+/** >+ * @deprecated use AddBlockCommentActionXMLDelegate instead >+ */ > public class AddBlockCommentActionXML extends CommentActionXML { > protected int fCloseCommentOffset; > protected int fOpenCommentOffset; >Index: src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java,v >retrieving revision 1.1 >diff -u -r1.1 CleanupActionXML.java >--- src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java 13 Apr 2005 22:43:44 -0000 1.1 >+++ src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXML.java 14 Sep 2005 06:18:37 -0000 >@@ -21,7 +21,9 @@ > import org.eclipse.wst.sse.ui.internal.actions.CleanupAction; > import org.eclipse.wst.xml.core.internal.cleanup.CleanupProcessorXML; > >- >+/** >+ * @deprecated Use CleanupActionXMLDelegate instead. >+ */ > public class CleanupActionXML extends CleanupAction { > protected IStructuredCleanupProcessor fCleanupProcessor; > >Index: src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java,v >retrieving revision 1.2 >diff -u -r1.2 CommentActionXML.java >--- src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java 18 Apr 2005 07:59:12 -0000 1.2 >+++ src/org/eclipse/wst/xml/ui/internal/actions/CommentActionXML.java 14 Sep 2005 06:18:37 -0000 >@@ -32,6 +32,10 @@ > import org.eclipse.wst.sse.core.internal.provisional.exceptions.SourceEditingRuntimeException; > import org.eclipse.wst.xml.ui.internal.XMLUIMessages; > >+/** >+ * @deprecated use AbstractCommentActionXMLDelegate or >+ * ToggleCommentActionXMLDelegate instead >+ */ > public class CommentActionXML extends TextEditorAction { > protected static final String CLOSE_COMMENT = "-->"; //$NON-NLS-1$ > protected static final String OPEN_COMMENT = "<!--"; //$NON-NLS-1$ >Index: src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java,v >retrieving revision 1.2 >diff -u -r1.2 RemoveBlockCommentActionXML.java >--- src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java 18 Apr 2005 07:59:12 -0000 1.2 >+++ src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXML.java 14 Sep 2005 06:18:37 -0000 >@@ -20,6 +20,9 @@ > import org.eclipse.wst.xml.core.internal.document.CommentImpl; > import org.eclipse.wst.xml.ui.internal.XMLUIMessages; > >+/** >+ * @deprecated use RemoveBlockCommentActionXMLDelegate instead >+ */ > public class RemoveBlockCommentActionXML extends AddBlockCommentActionXML { > public RemoveBlockCommentActionXML(ResourceBundle bundle, String prefix, ITextEditor editor) { > super(bundle, prefix, editor); >Index: src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java,v >retrieving revision 1.2 >diff -u -r1.2 ToggleCommentActionXML.java >--- src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java 18 Apr 2005 07:59:12 -0000 1.2 >+++ src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXML.java 14 Sep 2005 06:18:37 -0000 >@@ -20,6 +20,9 @@ > import org.eclipse.wst.sse.core.internal.provisional.exceptions.SourceEditingRuntimeException; > import org.eclipse.wst.xml.ui.internal.XMLUIMessages; > >+/** >+ * @deprecated use ToggleCommentActionXMLDelegate instead >+ */ > public class ToggleCommentActionXML extends UncommentActionXML { > public ToggleCommentActionXML(ResourceBundle bundle, String prefix, ITextEditor editor) { > super(bundle, prefix, editor); >Index: src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java,v >retrieving revision 1.2 >diff -u -r1.2 UncommentActionXML.java >--- src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java 18 Apr 2005 07:59:12 -0000 1.2 >+++ src/org/eclipse/wst/xml/ui/internal/actions/UncommentActionXML.java 14 Sep 2005 06:18:37 -0000 >@@ -20,6 +20,9 @@ > import org.eclipse.wst.sse.core.internal.provisional.exceptions.SourceEditingRuntimeException; > import org.eclipse.wst.xml.ui.internal.XMLUIMessages; > >+/** >+ * @deprecated use ToggleCommentActionXMLDelegate instead >+ */ > public class UncommentActionXML extends CommentActionXML { > public UncommentActionXML(ResourceBundle bundle, String prefix, ITextEditor editor) { > super(bundle, prefix, editor); >Index: src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java,v >retrieving revision 1.1 >diff -u -r1.1 StructuredTextEditorXML.java >--- src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java 18 Apr 2005 07:59:12 -0000 1.1 >+++ src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextEditorXML.java 14 Sep 2005 06:18:37 -0000 >@@ -27,6 +27,10 @@ > import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds; > import org.eclipse.wst.xml.ui.internal.search.XMLFindOccurrencesAction; > >+/** >+ * @deprecated XML editor is created from StructuredTextEditor with >+ * XML configurations >+ */ > public class StructuredTextEditorXML extends StructuredTextEditor { > private final static String UNDERSCORE = "_"; //$NON-NLS-1$ > >Index: src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java,v >retrieving revision 1.7 >diff -u -r1.7 XMLFindOccurrencesAction.java >--- src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java 18 Apr 2005 07:59:12 -0000 1.7 >+++ src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesAction.java 14 Sep 2005 06:18:37 -0000 >@@ -30,7 +30,7 @@ > * Uses default <code>getSearchQuery()</code>. > * </p> > * >- * @author pavery >+ * @deprecated use XMLFindOccurrencesProcessor instead > */ > public class XMLFindOccurrencesAction extends BasicFindOccurrencesAction { > >Index: src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java,v >retrieving revision 1.9 >diff -u -r1.9 XMLMultiPageEditorPart.java >--- src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java 13 Sep 2005 22:25:51 -0000 1.9 >+++ src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java 14 Sep 2005 06:18:38 -0000 >@@ -42,9 +42,9 @@ > import org.eclipse.wst.common.ui.provisional.editors.PostSelectionMultiPageEditorPart; > import org.eclipse.wst.sse.ui.internal.StructuredTextEditor; > import org.eclipse.wst.xml.core.internal.provisional.IXMLPreferenceNames; >+import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML; > import org.eclipse.wst.xml.ui.internal.Logger; > import org.eclipse.wst.xml.ui.internal.XMLUIPlugin; >-import org.eclipse.wst.xml.ui.internal.provisional.StructuredTextEditorXML; > > public class XMLMultiPageEditorPart extends PostSelectionMultiPageEditorPart { > >@@ -467,6 +467,12 @@ > } > return contributor; > } >+ >+ public String getId() { >+ // sets this id so nested editor is considered xml source >+ // page >+ return ContentTypeIdForXML.ContentTypeID_XML + ".source"; //$NON-NLS-1$; >+ } > }; > } > else { >@@ -494,7 +500,7 @@ > * @return StructuredTextEditor > */ > private StructuredTextEditor createTextEditor() { >- return new StructuredTextEditorXML(); >+ return new StructuredTextEditor(); > } > > private void disconnectDesignPage() { >Index: src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,115 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.actions; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.xml.ui.internal.Logger; >+ >+/** >+ * Abstract comment action delegate for XML editors >+ */ >+abstract public class AbstractCommentActionXMLDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { >+ static final String CLOSE_COMMENT = "-->"; //$NON-NLS-1$ >+ static final String OPEN_COMMENT = "<!--"; //$NON-NLS-1$ >+ >+ IEditorPart fEditor; >+ >+ public void setActiveEditor(IAction action, IEditorPart targetEditor) { >+ fEditor = targetEditor; >+ } >+ >+ public void dispose() { >+ // nulling out just in case >+ fEditor = null; >+ } >+ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ public void run(IAction action) { >+ if (fEditor instanceof ITextEditor) { >+ ITextEditor textEditor = (ITextEditor) fEditor; >+ IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); >+ if (document != null) { >+ // get current text selection >+ ITextSelection textSelection = getCurrentSelection(); >+ if (textSelection.isEmpty()) >+ return; >+ >+ processAction(document, textSelection); >+ } >+ } >+ } >+ >+ public void init(IViewPart view) { >+ // do nothing >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ // do nothing >+ } >+ >+ private ITextSelection getCurrentSelection() { >+ if (fEditor instanceof ITextEditor) { >+ ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider(); >+ if (provider != null) { >+ ISelection selection = provider.getSelection(); >+ if (selection instanceof ITextSelection) >+ return (ITextSelection) selection; >+ } >+ } >+ return TextSelection.emptySelection(); >+ } >+ >+ abstract void processAction(IDocument document, ITextSelection textSelection); >+ >+ void removeOpenCloseComments(IDocument document, int offset, int length) { >+ try { >+ int adjusted_length = length; >+ >+ // remove open comments >+ String string = document.get(offset, length); >+ int index = string.lastIndexOf(OPEN_COMMENT); >+ while (index != -1) { >+ document.replace(offset + index, OPEN_COMMENT.length(), ""); //$NON-NLS-1$ >+ index = string.lastIndexOf(OPEN_COMMENT, index - 1); >+ adjusted_length -= OPEN_COMMENT.length(); >+ } >+ >+ // remove close comments >+ string = document.get(offset, adjusted_length); >+ index = string.lastIndexOf(CLOSE_COMMENT); >+ while (index != -1) { >+ document.replace(offset + index, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$ >+ index = string.lastIndexOf(CLOSE_COMMENT, index - 1); >+ } >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.actions; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+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.xml.core.internal.document.CommentImpl; >+import org.eclipse.wst.xml.ui.internal.Logger; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+ >+/** >+ * Add block comment action delegate for XML editor >+ */ >+public class AddBlockCommentActionXMLDelegate extends AbstractCommentActionXMLDelegate { >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(XMLUIMessages.AddBlockComment_label); >+ action.setToolTipText(XMLUIMessages.AddBlockComment_tooltip); >+ action.setDescription(XMLUIMessages.AddBlockComment_description); >+ } >+ } >+ >+ void processAction(IDocument document, ITextSelection textSelection) { >+ IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document); >+ if (model != null) { >+ try { >+ IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset()); >+ IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength()); >+ >+ if (selectionStartIndexedRegion == null) >+ return; >+ if (selectionEndIndexedRegion == null && textSelection.getLength() > 0) { >+ selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength() - 1); >+ } >+ if (selectionEndIndexedRegion == null) >+ return; >+ >+ int openCommentOffset = selectionStartIndexedRegion.getStartOffset(); >+ int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() + OPEN_COMMENT.length(); >+ >+ >+ if (textSelection.getLength() == 0 && selectionStartIndexedRegion instanceof CommentImpl) >+ return; >+ >+ model.beginRecording(this, XMLUIMessages.AddBlockComment_tooltip); >+ model.aboutToChangeModel(); >+ >+ try { >+ document.replace(openCommentOffset, 0, OPEN_COMMENT); >+ document.replace(closeCommentOffset, 0, CLOSE_COMMENT); >+ removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length()); >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ finally { >+ model.changedModel(); >+ model.endRecording(this); >+ } >+ } >+ finally { >+ model.releaseFromEdit(); >+ } >+ } >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,136 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.actions; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.ui.IActionDelegate2; >+import org.eclipse.ui.IEditorActionDelegate; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IViewActionDelegate; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor; >+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; >+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; >+import org.eclipse.wst.sse.ui.internal.SSEUIMessages; >+import org.eclipse.wst.sse.ui.internal.StructuredTextEditor; >+import org.eclipse.wst.xml.core.internal.cleanup.CleanupProcessorXML; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+ >+/** >+ * Cleanup action delegate for CSS editor >+ */ >+public class CleanupActionXMLDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate { >+ private IEditorPart fEditor; >+ private IStructuredCleanupProcessor fCleanupProcessor; >+ >+ public void setActiveEditor(IAction action, IEditorPart targetEditor) { >+ fEditor = targetEditor; >+ } >+ >+ public void dispose() { >+ // nulling out just in case >+ fEditor = null; >+ fCleanupProcessor = null; >+ } >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(XMLUIMessages.CleanupDocument_label); >+ action.setToolTipText(XMLUIMessages.CleanupDocument_tooltip); >+ action.setDescription(XMLUIMessages.CleanupDocument_description); >+ } >+ } >+ >+ public void runWithEvent(IAction action, Event event) { >+ run(action); >+ } >+ >+ public void init(IViewPart view) { >+ // do nothing >+ } >+ >+ public void run(IAction action) { >+ if (fEditor instanceof StructuredTextEditor) { >+ final StructuredTextEditor editor = (StructuredTextEditor) fEditor; >+ Dialog cleanupDialog = new CleanupDialogXML(editor.getSite().getShell()); >+ if (cleanupDialog.open() == Window.OK) { >+ // setup runnable >+ Runnable runnable = new Runnable() { >+ public void run() { >+ IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor(); >+ if (cleanupProcessor != null) { >+ IStructuredModel model = null; >+ try { >+ model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput())); >+ if (model != null) >+ cleanupProcessor.cleanupModel(model); >+ } >+ finally { >+ if (model != null) >+ model.releaseFromEdit(); >+ } >+ } >+ } >+ }; >+ >+ // TODO: make independent of 'model'. >+ IStructuredModel model = null; >+ try { >+ model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput())); >+ if (model != null) { >+ // begin recording >+ ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); >+ model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength()); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ // tell the model that we are about to make a big >+ // model change >+ model.aboutToChangeModel(); >+ >+ // run >+ BusyIndicator.showWhile(editor.getTextViewer().getControl().getDisplay(), runnable); >+ } >+ } >+ finally { >+ if (model != null) { >+ // tell the model that we are done with the big >+ // model >+ // change >+ model.changedModel(); >+ >+ // end recording >+ ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection(); >+ model.endRecording(this, selection.getOffset(), selection.getLength()); >+ model.releaseFromEdit(); >+ } >+ } >+ } >+ } >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ // do nothing >+ } >+ >+ IStructuredCleanupProcessor getCleanupProcessor() { >+ if (fCleanupProcessor == null) >+ fCleanupProcessor = new CleanupProcessorXML(); >+ >+ return fCleanupProcessor; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.actions; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+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.xml.core.internal.document.CommentImpl; >+import org.eclipse.wst.xml.ui.internal.Logger; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+ >+/** >+ * Remove block comment action delegate for XML editor >+ */ >+public class RemoveBlockCommentActionXMLDelegate extends AbstractCommentActionXMLDelegate { >+ >+ void processAction(IDocument document, ITextSelection textSelection) { >+ IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document); >+ if (model != null) { >+ try { >+ IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset()); >+ IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength()); >+ >+ if (selectionStartIndexedRegion == null || selectionEndIndexedRegion == null) >+ return; >+ >+ int openCommentOffset = selectionStartIndexedRegion.getStartOffset(); >+ int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() - OPEN_COMMENT.length() - CLOSE_COMMENT.length(); >+ >+ model.beginRecording(this, XMLUIMessages.RemoveBlockComment_tooltip); >+ model.aboutToChangeModel(); >+ >+ try { >+ if (textSelection.getLength() == 0) { >+ if (selectionStartIndexedRegion instanceof CommentImpl) { >+ document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$ >+ document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$ >+ } >+ } >+ else { >+ if (selectionStartIndexedRegion instanceof CommentImpl) { >+ document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$ >+ } >+ >+ if (selectionEndIndexedRegion instanceof CommentImpl) { >+ document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$ >+ } >+ } >+ removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length()); >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ finally { >+ model.changedModel(); >+ model.endRecording(this); >+ } >+ } >+ finally { >+ model.releaseFromEdit(); >+ } >+ } >+ } >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(XMLUIMessages.RemoveBlockComment_label); >+ action.setToolTipText(XMLUIMessages.RemoveBlockComment_tooltip); >+ action.setDescription(XMLUIMessages.RemoveBlockComment_description); >+ } >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,170 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.actions; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.Position; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; >+import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; >+import org.eclipse.wst.xml.ui.internal.Logger; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+ >+/** >+ * Toggle comment action delegate for XML editor >+ */ >+public class ToggleCommentActionXMLDelegate extends AbstractCommentActionXMLDelegate { >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(XMLUIMessages.ToggleComment_label); >+ action.setToolTipText(XMLUIMessages.ToggleComment_tooltip); >+ action.setDescription(XMLUIMessages.ToggleComment_description); >+ } >+ } >+ >+ void processAction(IDocument document, ITextSelection textSelection) { >+ // get text selection lines info >+ int selectionStartLine = textSelection.getStartLine(); >+ int selectionEndLine = textSelection.getEndLine(); >+ try { >+ int selectionEndLineOffset = document.getLineOffset(selectionEndLine); >+ int selectionEndOffset = textSelection.getOffset() + textSelection.getLength(); >+ >+ // adjust selection end line >+ if (selectionEndLine > selectionStartLine && selectionEndLineOffset == selectionEndOffset) >+ selectionEndLine--; >+ >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ >+ // save the selection position since it will be changing >+ Position selectionPosition = null; >+ boolean updateStartOffset = false; >+ try { >+ selectionPosition = new Position(textSelection.getOffset(), textSelection.getLength()); >+ document.addPosition(selectionPosition); >+ >+ // extra check if commenting from beginning of line >+ int selectionStartLineOffset = document.getLineOffset(selectionStartLine); >+ if (textSelection.getLength() > 0 && selectionStartLineOffset == textSelection.getOffset() && !isCommentLine(document, selectionStartLine)) >+ updateStartOffset = true; >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ >+ processAction(document, selectionStartLine, selectionEndLine); >+ >+ updateCurrentSelection(selectionPosition, document, updateStartOffset); >+ } >+ >+ private void processAction(IDocument document, int selectionStartLine, int selectionEndLine) { >+ IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document); >+ if (model != null) { >+ try { >+ model.beginRecording(this, XMLUIMessages.ToggleComment_tooltip); >+ model.aboutToChangeModel(); >+ >+ for (int i = selectionStartLine; i <= selectionEndLine; i++) { >+ try { >+ if (document.getLineLength(i) > 0) { >+ if (isCommentLine(document, i)) { >+ int lineOffset = document.getLineOffset(i); >+ IRegion region = document.getLineInformation(i); >+ String string = document.get(region.getOffset(), region.getLength()); >+ int openCommentOffset = lineOffset + string.indexOf(OPEN_COMMENT); >+ int closeCommentOffset = lineOffset + string.indexOf(CLOSE_COMMENT) - OPEN_COMMENT.length(); >+ uncomment(document, openCommentOffset, closeCommentOffset); >+ } >+ else { >+ int openCommentOffset = document.getLineOffset(i); >+ int lineDelimiterLength = document.getLineDelimiter(i) == null ? 0 : document.getLineDelimiter(i).length(); >+ int closeCommentOffset = openCommentOffset + document.getLineLength(i) - lineDelimiterLength + OPEN_COMMENT.length(); >+ comment(document, openCommentOffset, closeCommentOffset); >+ } >+ } >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ } >+ } >+ finally { >+ model.changedModel(); >+ model.endRecording(this); >+ model.releaseFromEdit(); >+ } >+ } >+ } >+ >+ private boolean isCommentLine(IDocument document, int line) { >+ boolean isComment = false; >+ >+ try { >+ IRegion region = document.getLineInformation(line); >+ String string = document.get(region.getOffset(), region.getLength()).trim(); >+ isComment = string.length() >= OPEN_COMMENT.length() + CLOSE_COMMENT.length() && string.startsWith(OPEN_COMMENT) && string.endsWith(CLOSE_COMMENT); >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ return isComment; >+ } >+ >+ private void comment(IDocument document, int openCommentOffset, int closeCommentOffset) { >+ try { >+ document.replace(openCommentOffset, 0, OPEN_COMMENT); >+ document.replace(closeCommentOffset, 0, CLOSE_COMMENT); >+ removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length()); >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ } >+ >+ private void uncomment(IDocument document, int openCommentOffset, int closeCommentOffset) { >+ try { >+ document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$ >+ document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$ >+ } >+ catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ } >+ >+ private void updateCurrentSelection(Position selectionPosition, IDocument document, boolean updateStartOffset) { >+ if (fEditor instanceof ITextEditor) { >+ // update the selection if text selection changed >+ if (selectionPosition != null) { >+ ITextSelection selection = null; >+ if (updateStartOffset) >+ selection = new TextSelection(document, selectionPosition.getOffset() - OPEN_COMMENT.length(), selectionPosition.getLength() + OPEN_COMMENT.length()); >+ else >+ selection = new TextSelection(document, selectionPosition.getOffset(), selectionPosition.getLength()); >+ ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider(); >+ if (provider != null) { >+ provider.setSelection(selection); >+ } >+ document.removePosition(selectionPosition); >+ } >+ } >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,34 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.search; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesActionDelegate; >+ >+/** >+ * Sets up FindOccurrencesActionDelegate for xml find occurrences processors >+ */ >+public class XMLFindOccurrencesActionDelegate extends FindOccurrencesActionDelegate { >+ private List fProcessors; >+ >+ protected List getProcessors() { >+ if (fProcessors == null) { >+ fProcessors = new ArrayList(); >+ XMLFindOccurrencesProcessor htmlProcessor = new XMLFindOccurrencesProcessor(); >+ fProcessors.add(htmlProcessor); >+ } >+ return fProcessors; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java >diff -N src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.search; >+ >+import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor; >+import org.eclipse.wst.xml.core.internal.provisional.text.IXMLPartitions; >+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; >+ >+/** >+ * Configures a FindOccurrencesProcessor with XML partitions and regions >+ */ >+public class XMLFindOccurrencesProcessor extends FindOccurrencesProcessor { >+ >+ protected String[] getPartitionTypes() { >+ return new String[]{IXMLPartitions.XML_DEFAULT}; >+ } >+ >+ protected String[] getRegionTypes() { >+ return new String[]{DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE}; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.selection; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.Region; >+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; >+import org.eclipse.wst.sse.ui.internal.selection.StructuredSelectActionDelegate; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+import org.w3c.dom.Node; >+ >+public class StructuredSelectEnclosingXMLActionDelegate extends StructuredSelectActionDelegate { >+ >+ protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) { >+ IndexedRegion indexedRegion = null; >+ >+ indexedRegion = getIndexedRegion(document, textSelection.getOffset()); >+ >+ return indexedRegion; >+ } >+ >+ protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) { >+ Region newRegion = null; >+ if (indexedRegion instanceof Node) { >+ Node cursorNode = (Node) indexedRegion; >+ >+ // use parent node for empty text node >+ if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) { >+ cursorNode = cursorNode.getParentNode(); >+ >+ if (cursorNode instanceof IndexedRegion) >+ indexedRegion = (IndexedRegion) cursorNode; >+ } >+ >+ Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset()); >+ >+ if (cursorNodeRegion.getOffset() >= textSelection.getOffset() && cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength()) { >+ Node newNode = cursorNode.getParentNode(); >+ >+ if (newNode instanceof IndexedRegion) { >+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode; >+ newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset()); >+ } >+ } >+ else >+ newRegion = cursorNodeRegion; >+ } >+ return newRegion; >+ } >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(XMLUIMessages.StructureSelectEnclosing_label); >+ action.setToolTipText(XMLUIMessages.StructureSelectEnclosing_tooltip); >+ action.setDescription(XMLUIMessages.StructureSelectEnclosing_description); >+ } >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,88 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.selection; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; >+import org.eclipse.wst.sse.ui.internal.selection.StructuredSelectActionDelegate; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+import org.w3c.dom.Node; >+ >+public class StructuredSelectNextXMLActionDelegate extends StructuredSelectActionDelegate { >+ >+ protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) { >+ int offset = textSelection.getOffset() + textSelection.getLength(); >+ if (offset < 0) >+ offset = 0; >+ >+ IndexedRegion indexedRegion = null; >+ >+ indexedRegion = getIndexedRegion(document, offset); >+ >+ return indexedRegion; >+ } >+ >+ protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) { >+ Region newRegion = null; >+ if (indexedRegion instanceof Node) { >+ Node cursorNode = (Node) indexedRegion; >+ >+ // use parent node for empty text node >+ if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) { >+ cursorNode = cursorNode.getParentNode(); >+ >+ if (cursorNode instanceof IndexedRegion) >+ indexedRegion = (IndexedRegion) cursorNode; >+ } >+ >+ Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset()); >+ >+ if (cursorNodeRegion.getOffset() >= textSelection.getOffset() && cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength()) { >+ Node newNode = cursorNode.getNextSibling(); >+ if (newNode == null) { >+ newNode = cursorNode.getParentNode(); >+ >+ if (newNode instanceof IndexedRegion) { >+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode; >+ newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset()); >+ } >+ } >+ else { >+ if (newNode instanceof IndexedRegion) { >+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode; >+ newRegion = new Region(textSelection.getOffset(), newIndexedRegion.getEndOffset() - textSelection.getOffset()); >+ >+ if (newNode.getNodeType() == Node.TEXT_NODE) >+ newRegion = getNewSelectionRegion(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength())); >+ } >+ } >+ } >+ else >+ newRegion = cursorNodeRegion; >+ } >+ return newRegion; >+ } >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(XMLUIMessages.StructureSelectNext_label); >+ action.setToolTipText(XMLUIMessages.StructureSelectNext_tooltip); >+ action.setDescription(XMLUIMessages.StructureSelectNext_description); >+ } >+ } >+ >+} >Index: src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java >diff -N src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.selection; >+ >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.TextSelection; >+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; >+import org.eclipse.wst.sse.ui.internal.selection.StructuredSelectActionDelegate; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+import org.w3c.dom.Node; >+ >+public class StructuredSelectPreviousXMLActionDelegate extends StructuredSelectActionDelegate { >+ >+ protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) { >+ IndexedRegion indexedRegion = null; >+ >+ indexedRegion = getIndexedRegion(document, textSelection.getOffset()); >+ >+ return indexedRegion; >+ } >+ >+ protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) { >+ Region newRegion = null; >+ if (indexedRegion instanceof Node) { >+ Node cursorNode = (Node) indexedRegion; >+ >+ // use parent node for empty text node >+ if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) { >+ cursorNode = cursorNode.getParentNode(); >+ >+ if (cursorNode instanceof IndexedRegion) >+ indexedRegion = (IndexedRegion) cursorNode; >+ } >+ >+ Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset()); >+ >+ if (cursorNodeRegion.getOffset() >= textSelection.getOffset() && cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset() && cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength()) { >+ Node newNode = cursorNode.getPreviousSibling(); >+ if (newNode == null) { >+ newNode = cursorNode.getParentNode(); >+ >+ if (newNode instanceof IndexedRegion) { >+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode; >+ newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset()); >+ } >+ } >+ else { >+ if (newNode instanceof IndexedRegion) { >+ IndexedRegion newIndexedRegion = (IndexedRegion) newNode; >+ newRegion = new Region(newIndexedRegion.getStartOffset(), textSelection.getOffset() + textSelection.getLength() - newIndexedRegion.getStartOffset()); >+ >+ if (newNode.getNodeType() == Node.TEXT_NODE) >+ newRegion = getNewSelectionRegion(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength())); >+ } >+ } >+ >+ } >+ else >+ newRegion = cursorNodeRegion; >+ } >+ return newRegion; >+ } >+ >+ public void init(IAction action) { >+ if (action != null) { >+ action.setText(XMLUIMessages.StructureSelectPrevious_label); >+ action.setToolTipText(XMLUIMessages.StructureSelectPrevious_tooltip); >+ action.setDescription(XMLUIMessages.StructureSelectPrevious_description); >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 109468
:
27089
|
27090
|
27091
|
27092
|
27093
| 27094 |
27095
|
27128