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 92731 Details for
Bug 212330
can't contribute to the XML or any SSE based menu.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Null Pointer Fix and changed Source Popup Menu ID contribution
sseuimenus13.patch (text/plain), 104.13 KB, created by
David Carver
on 2008-03-17 14:38:41 EDT
(
hide
)
Description:
Null Pointer Fix and changed Source Popup Menu ID contribution
Filename:
MIME Type:
Creator:
David Carver
Created:
2008-03-17 14:38:41 EDT
Size:
104.13 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xml.ui >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/plugin.properties,v >retrieving revision 1.32 >diff -u -r1.32 plugin.properties >--- plugin.properties 12 Mar 2008 22:42:56 -0000 1.32 >+++ plugin.properties 17 Mar 2008 18:36:38 -0000 >@@ -10,7 +10,7 @@ > # Jens Lukowski/Innoopract - initial renaming/restructuring > # David Carver / STAR Standards - added XML Catalog Import/Export Wizard > # bug 192568 >-# >+# David Carver / STAR Standards - bug 212330 - migrate to org.eclipse.ui.menus > ############################################################################### > providerName=Eclipse.org > pluginName=XML UI Plugin >@@ -75,6 +75,7 @@ > StructureSelectPrevious_tooltip=Expand selection to include previous sibling > StructureSelectHistory_label=Restore Last Selection > StructureSelectHistory_tooltip=Restore last selection >+SmartInsert_label=Sma&rt Auto Insert > ## > preferenceKeywords.files=editor xml creating saving files line delimiter suffix specified encoding iana validating warn grammar > preferenceKeywords.source=editor xml source formatting line width split multiple attributes new clear blank indent tabs spaces size content assist automatically suggestions prompt characters inserted strategy lax strict grammar constraints inferred absence dtd schema >@@ -84,7 +85,16 @@ > ## > XML_Source_target_name=XML Source > XML_hyperlink=Tags And Attributes >- >+## >+DesignMenu_name=&Design >+Format_mnemonic=F >+FormatElements_mnemonic=i >+ReloadDependencies_name=&Reload Dependencies >+ReloadDependencies_description=Reload Dependencies >+Constraints_name=&Turn off Grammar Constraints >+Constraints_description=Turn off grammar Constraints >+ExpandAll_name=Expand All >+CollapseAll_name=Collapse All > ActionDefinition.nextSibling.name=Go to Next Sibling > ActionDefinition.nextSibling.description=Go to Next Sibling > ActionDefinition.previousSibling.name=Go to Previous Sibling >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/plugin.xml,v >retrieving revision 1.82 >diff -u -r1.82 plugin.xml >--- plugin.xml 12 Mar 2008 22:42:56 -0000 1.82 >+++ plugin.xml 17 Mar 2008 18:36:39 -0000 >@@ -1,5 +1,5 @@ > <?xml version="1.0" encoding="UTF-8"?> >-<?eclipse version="3.0"?> >+<?eclipse version="3.3"?> > <plugin> > > <extension-point id="catalogFileType" name="%XML_Catalog_File_Type_Extension_Point.name" schema="schema/catalogFileType.exsd"/> >@@ -260,6 +260,7 @@ > <!-- =============================================================================== --> > <!-- Allow the 'New XML' wizard to be accessed via the 'Generate' menu on a XSD file --> > <!-- =============================================================================== --> >+<!-- > <extension point="org.eclipse.ui.popupMenus"> > <objectContribution > objectClass="org.eclipse.core.resources.IFile" >@@ -280,10 +281,12 @@ > </action> > </objectContribution> > </extension> >+--> > > <!-- =============================================================================== --> > <!-- Allow the 'New XML' wizard to be accessed via the 'Generate' menu on a DTD file --> > <!-- =============================================================================== --> >+<!-- > <extension point="org.eclipse.ui.popupMenus"> > <objectContribution > objectClass="org.eclipse.core.resources.IFile" >@@ -304,6 +307,7 @@ > </action> > </objectContribution> > </extension> >+--> > > <!-- =============================================================================== --> > <!-- Contribute a New->Example... entry for Editing and Validating XML files --> >@@ -423,7 +427,7 @@ > </provider> > </extension> > >- >+ <!-- To Do: migrate this to the org.eclipse.ui.menus popup: format --> > <extension point="org.eclipse.ui.popupMenus"> > <viewerContribution > targetID="org.eclipse.core.runtime.xml.source.RulerContext" >@@ -473,7 +477,7 @@ > </objectContribution> > </extension> > >- >+<!-- > <extension point="org.eclipse.ui.editorActions"> > <editorContribution > id="org.eclipse.core.runtime.xml.source.editorActions" >@@ -566,6 +570,8 @@ > id="org.eclipse.ui.texteditor.SelectRulerAction"/> > </editorContribution> > </extension> >+--> >+ > <extension > point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets"> > <target >@@ -680,4 +686,444 @@ > schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> > > </extension> >+ >+<!-- >+ This section contains the new org.eclipse.ui.menus extions points and command handler >+ definitions. >+ --> >+ >+ <extension point="org.eclipse.ui.menus"> >+ <menuContribution locationURI="menu:sourceMenuId?after=sourceBegin"> >+ <command commandId="org.eclipse.wst.sse.ui.toggle.comment" >+ id="ToggleComment" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.add.block.comment" >+ id="AddBlockComment" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.remove.block.comment" >+ id="RemoveBlockComment" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </visibleWhen> >+ </command> >+ </menuContribution> >+ >+ <menuContribution locationURI="menu:sourceMenuId?after=shiftBegin"> >+ <command commandId="org.eclipse.ui.edit.text.shiftLeft" >+ id="ShiftLeft" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.ui.edit.text.shiftRight" >+ id="ShiftRight" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </visibleWhen> >+ </command> >+ </menuContribution> >+ >+ <menuContribution locationURI="menu:sourceMenuId?after=shiftEnd"> >+ <command >+ commandId="org.eclipse.wst.sse.ui.cleanup.document" >+ id="CleanupDocument" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.format.document" id="FormatDocument" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.format.active.elements" id="FormatElements" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference> >+ </visibleWhen> >+ </command> >+ </menuContribution> >+ <menuContribution locationURI="menu:org.eclipse.search.menu?after=additions"> >+ <command commandId="org.eclipse.wst.sse.ui.search.find.occurrences" id="OccurencesFile" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference> >+ </visibleWhen> >+ </command> >+ </menuContribution> >+ >+ <menuContribution locationURI="menu:edit?after=additions"> >+ <command commandId="org.eclipse.ui.edit.text.toggleInsertMode" id="ToggleInsertMode" label="%SmartInsert_label" style="toggle"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference> >+ </visibleWhen> >+ </command> >+ </menuContribution> >+ >+ <menuContribution >+ locationURI="menu:org.eclipse.ui.main.menu?before=window"> >+ <menu >+ id="org.eclipse.wst.xml.ui.designMenuId" >+ label="%DesignMenu_name"> >+ <separator >+ name="designStart"> >+ </separator> >+ <command >+ commandId="org.eclipse.wst.xml.ui.disable.grammar.constraints" >+ icon="icons/full/etool16/constrainon.gif" >+ id="ToggleGrammarConstraints" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <and> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ <not> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </not> >+ </and> >+ </visibleWhen> >+ </command> >+ <command >+ commandId="org.eclipse.wst.xml.ui.reload.dependecies" >+ icon="icons/full/etool16/rldgrmr.gif" >+ id="ReloadDependencies" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <and> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ <not> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </not> >+ </and> >+ </visibleWhen> >+ </command> >+ <separator >+ name="expand" >+ visible="true"> >+ </separator> >+ >+ <command >+ commandId="sed.tabletree.expandAll" >+ icon="icons/full/etool16/expand_all.gif" >+ id="ExpandAll" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <and> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ <not> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </not> >+ </and> >+ </visibleWhen> >+ </command> >+ <command >+ commandId="sed.tabletree.collapseAll" >+ icon="icons/full/etool16/collapse_all.gif" >+ id="CollapseAll" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <and> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ <not> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"/> >+ </not> >+ </and> >+ </visibleWhen> >+ </command> >+ >+ <separator >+ name="additions" >+ visible="true"> >+ </separator> >+ <separator >+ name="designEnd" >+ visible="false"> >+ </separator> >+ </menu> >+ </menuContribution> >+ >+ <menuContribution >+ locationURI="popup:sourcePopupMenuId?after=sourceBegin"> >+ <command commandId="org.eclipse.wst.sse.ui.toggle.comment" id="ToggleComment" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.add.block.comment" id="AddBlockComment" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.remove.block.comment" id="RemoveBlockComment" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference> >+ </visibleWhen> >+ </command> >+ <separator name="format" visible="true"></separator> >+ <command >+ commandId="org.eclipse.wst.sse.ui.cleanup.document" >+ id="CleanupDocument" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"></reference> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.format.document" id="FormatDocument" mnemonic="%Format_mnemonic" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"></reference> >+ </visibleWhen> >+ </command> >+ <command commandId="org.eclipse.wst.sse.ui.format.active.elements" id="FormatElements" mnemonic="%FormatElements_mnemonic" style="push"> >+ <visibleWhen checkEnabled="false"> >+ <reference definitionId="org.eclipse.wst.sse.ui.sseActiveContext.definition"></reference> >+ </visibleWhen> >+ </command> >+ </menuContribution> >+ >+ <menuContribution >+ locationURI="popup:org.eclipse.ui.popup.any?after=additions"> >+ <menu >+ id="generateMenuId" >+ label="%genMenuLabel"> >+ <command >+ commandId="org.eclipse.wst.sse.ui.generate.xml" >+ id="GenerateXML" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <or> >+ <iterate> >+ <adapt >+ type="org.eclipse.core.resources.IFile"> >+ <test >+ property="org.eclipse.core.resources.contentTypeId" >+ value="org.eclipse.wst.xsd.core.xsdsource"> >+ </test> >+ </adapt> >+ </iterate> >+ <iterate> >+ <adapt >+ type="org.eclipse.core.resources.IFile"> >+ <test >+ property="org.eclipse.core.resources.contentTypeId" >+ value="org.eclipse.wst.dtd.core.dtdsource"> >+ </test> >+ </adapt> >+ </iterate> >+ </or> >+ </visibleWhen> >+ </command> >+ </menu> >+ </menuContribution> >+ >+ <menuContribution >+ locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions"> >+ <toolbar >+ id="org.eclipse.wst.xml.ui.design.DesignToolBar"> >+ <separator >+ name="sed.tabletree.separator.1" >+ visible="true"> >+ </separator> >+ <command >+ commandId="org.eclipse.wst.xml.ui.disable.grammar.constraints" >+ icon="icons/full/etool16/constrainon.gif" >+ id="ToggleGrammarConstraints" >+ style="push" >+ tooltip="%Constraints_name"> >+ <visibleWhen >+ checkEnabled="false"> >+ <reference >+ definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"> >+ </reference> >+ </visibleWhen> >+ </command> >+ <command >+ commandId="org.eclipse.wst.xml.ui.reload.dependecies" >+ icon="icons/full/etool16/rldgrmr.gif" >+ id="ReloadDependencies" >+ style="push"> >+ <visibleWhen >+ checkEnabled="false"> >+ <reference >+ definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"> >+ </reference> >+ </visibleWhen> >+ </command> >+ <separator >+ name="sed.tabletree.separator.2" >+ visible="true"> >+ </separator> >+ <command >+ commandId="sed.tabletree.expandAll" >+ icon="icons/full/etool16/expand_all.gif" >+ id="ExpandAll" >+ style="push"> >+ <visibleWhen >+ checkEnabled="false"> >+ <reference >+ definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"> >+ </reference> >+ </visibleWhen> >+ </command> >+ <command >+ commandId="sed.tabletree.collapseAll" >+ icon="icons/full/etool16/collapse_all.gif" >+ id="CollapseAll" >+ style="push"> >+ <visibleWhen >+ checkEnabled="false"> >+ <reference >+ definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"> >+ </reference> >+ </visibleWhen> >+ </command> >+ </toolbar> >+ </menuContribution> >+ </extension> >+ >+ <extension point="org.eclipse.core.expressions.definitions"> >+ <definition id="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"> >+ <with variable="activeEditorId"> >+ <equals value="org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart"></equals> >+ </with> >+ </definition> >+ </extension> >+ <extension >+ point="org.eclipse.ui.handlers"> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.CleanupdocumentHandler" >+ commandId="org.eclipse.wst.sse.ui.cleanup.document"> >+ <activeWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </activeWhen> >+ <enabledWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.ToggleCommentHandler" >+ commandId="org.eclipse.wst.sse.ui.toggle.comment"> >+ <activeWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </activeWhen> >+ <enabledWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.AddBlockCommentHandler" >+ commandId="org.eclipse.wst.sse.ui.add.block.comment"> >+ <activeWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </activeWhen> >+ <enabledWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.RemoveBlockCommentHandler" >+ commandId="org.eclipse.wst.sse.ui.remove.block.comment"> >+ <activeWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </activeWhen> >+ <enabledWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.XMLFindOccurencesHandler" >+ commandId="org.eclipse.wst.sse.ui.search.find.occurrences"> >+ <activeWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </activeWhen> >+ <enabledWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.ReloadDependenciesHandler" >+ commandId="org.eclipse.wst.xml.ui.reload.dependecies"> >+ <activeWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </activeWhen> >+ <enabledWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.ToggleEditModeHandler" >+ commandId="org.eclipse.wst.xml.ui.disable.grammar.constraints"> >+ <activeWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </activeWhen> >+ <enabledWhen> >+ <reference definitionId="org.eclipse.wst.xml.ui.xmlSourceContributions.definition"/> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.wizards.NewXMLHandler" >+ commandId="org.eclipse.wst.sse.ui.generate.xml"> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.ExpandAllHandler" >+ commandId="sed.tabletree.expandAll"> >+ <activeWhen> >+ <not> >+ <with variable="activeContexts"> >+ <iterate operator="or"> >+ <equals value="org.eclipse.wst.sse.ui.structuredTextEditorScope"/> >+ </iterate> >+ </with> >+ </not> >+ </activeWhen> >+ </handler> >+ <handler >+ class="org.eclipse.wst.xml.ui.internal.handlers.CollapseAllHandler" >+ commandId="sed.tabletree.collapseAll"> >+ <activeWhen> >+ <not> >+ <with variable="activeContexts"> >+ <iterate operator="or"> >+ <equals value="org.eclipse.wst.sse.ui.structuredTextEditorScope"/> >+ </iterate> >+ </with> >+ </not> >+ </activeWhen> >+ </handler> >+ </extension> >+ >+ <extension >+ point="org.eclipse.ui.commands"> >+ <command >+ id="org.eclipse.wst.sse.ui.generate.xml" >+ name="%_UI_ACTION_CREATE_XML"> >+ </command> >+ <command >+ description="%ReloadDependencies_description" >+ id="org.eclipse.wst.xml.ui.reload.dependecies" >+ name="%ReloadDependencies_name"> >+ </command> >+ <command >+ description="%Constraints_description" >+ id="org.eclipse.wst.xml.ui.disable.grammar.constraints" >+ name="%Constraints_name"> >+ </command> >+ <command >+ id="sed.tabletree.expandAll" >+ name="%ExpandAll_name"> >+ </command> >+ <command >+ id="sed.tabletree.collapseAll" >+ name="%CollapseAll_name"> >+ </command> >+ </extension> >+ > </plugin> >Index: src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java,v >retrieving revision 1.5 >diff -u -r1.5 SourceEditorActionBarContributor.java >--- src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java 10 Apr 2007 20:04:57 -0000 1.5 >+++ src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java 17 Mar 2008 18:36:39 -0000 >@@ -86,7 +86,7 @@ > public final void contributeToMenu(IMenuManager menu) { > super.contributeToMenu(menu); > >- addToMenu(menu); >+ //addToMenu(menu); > > if (extendedContributor != null) { > extendedContributor.contributeToMenu(menu); >Index: src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java,v >retrieving revision 1.17 >diff -u -r1.17 XMLTableTreeActionBarContributor.java >--- src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java 26 Feb 2008 02:58:02 -0000 1.17 >+++ src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java 17 Mar 2008 18:36:39 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * David Carver - bug 212330 - migrate to org.eclipse.ui.menus extension point > *******************************************************************************/ > package org.eclipse.wst.xml.ui.internal.tabletree; > >@@ -14,14 +15,14 @@ > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.action.IContributionManager; > import org.eclipse.jface.action.IMenuManager; >-import org.eclipse.jface.action.IToolBarManager; >-import org.eclipse.jface.action.MenuManager; >-import org.eclipse.jface.action.Separator; >+//import org.eclipse.jface.action.IToolBarManager; >+//import org.eclipse.jface.action.MenuManager; >+//import org.eclipse.jface.action.Separator; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.ui.IActionBars; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IEditorSite; >-import org.eclipse.ui.IWorkbenchActionConstants; >+//import org.eclipse.ui.IWorkbenchActionConstants; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPartSite; > import org.eclipse.ui.texteditor.ITextEditor; >@@ -62,7 +63,7 @@ > } > > protected void removeContributions(IContributionManager manager) { >- try { >+/* try { > doRemove(manager, DESIGN_VIEWER_SEPARATOR_1_ID); > doRemove(manager, DESIGN_VIEWER_SEPARATOR_2_ID); > doRemove(manager, VALIDATE_XML_ID); >@@ -73,26 +74,27 @@ > } > catch (Exception e) { > } >+*/ > } > > protected void doRemove(IContributionManager manager, String id) { >- try { >+/* try { > if (manager.find(id) != null) { > manager.remove(id); > } > } > catch (Exception e) { > } >- } >+*/ } > > public void init(IActionBars bars, IWorkbenchPage page) { > init(bars); > } > > public void init(IActionBars bars) { >- IToolBarManager tbm = bars.getToolBarManager(); >+// IToolBarManager tbm = bars.getToolBarManager(); > >- IMenuManager xmlMenu = bars.getMenuManager().findMenuUsingPath("org.eclipse.core.runtime.xml.design.xmlmenu"); //$NON-NLS-1$ >+/* IMenuManager xmlMenu = bars.getMenuManager().findMenuUsingPath("org.eclipse.core.runtime.xml.design.xmlmenu"); //$NON-NLS-1$ > > if (xmlMenu == null) { > xmlMenu = new MenuManager(XMLEditorMessages.XMLTableTreeActionBarContributor_0, "org.eclipse.core.runtime.xml.design.xmlmenu"); //$NON-NLS-1$ >@@ -106,26 +108,26 @@ > } > > tbm.add(new Separator("DESIGN_VIEWER_SEPARATOR_1_ID")); //$NON-NLS-1$ >- >+*/ > // ToggleEditModeAction > // >- toggleAction = new ToggleEditModeAction(); >+/* toggleAction = new ToggleEditModeAction(); > toggleAction.setId(TOGGLE_EDIT_MODE_ID); > xmlMenu.add(toggleAction); > tbm.add(toggleAction); >- >+*/ > // ReloadGrammarAction > // >- reloadGrammarAction = new ReloadGrammarAction(); >+/* reloadGrammarAction = new ReloadGrammarAction(); > reloadGrammarAction.setId(RELOAD_GRAMMAR_ID); > tbm.add(reloadGrammarAction); > xmlMenu.add(reloadGrammarAction); > > xmlMenu.add(new Separator()); >- >+*/ > // ExpandCollapseAction > // >- xmlMenuExpandAction = new ViewerExpandCollapseAction(true); >+/* xmlMenuExpandAction = new ViewerExpandCollapseAction(true); > xmlMenuExpandAction.setId(EXPAND_ALL_ID); > xmlMenuExpandAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_1); > xmlMenu.add(xmlMenuExpandAction); >@@ -135,6 +137,7 @@ > xmlMenuCollapseAction.setId(EXPAND_ALL_ID); > xmlMenuCollapseAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_2); > xmlMenu.add(xmlMenuCollapseAction); >+*/ > } > > protected void addActionWithId(IMenuManager menuManager, Action action, String id) { >@@ -143,7 +146,7 @@ > } > > public void initViewerSpecificContributions(IActionBars bars) { >- IToolBarManager tbm = bars.getToolBarManager(); >+/* IToolBarManager tbm = bars.getToolBarManager(); > tbm.add(new Separator(DESIGN_VIEWER_SEPARATOR_2_ID)); > > expandAction = new ViewerExpandCollapseAction(true); >@@ -153,10 +156,11 @@ > collapseAction = new ViewerExpandCollapseAction(false); > collapseAction.setId(COLLAPSE_ALL_ID); > tbm.add(collapseAction); >+*/ > } > > public void setViewerSpecificContributionsEnabled(boolean enabled) { >- if (expandAction != null) { >+/* if (expandAction != null) { > expandAction.setEnabled(enabled); > xmlMenuExpandAction.setEnabled(enabled); > } >@@ -165,13 +169,14 @@ > collapseAction.setEnabled(enabled); > xmlMenuCollapseAction.setEnabled(enabled); > } >+*/ > } > > public void setActiveEditor(IEditorPart targetEditor) { > editorPart = targetEditor; > >- IStructuredModel model = getModelForEditorPart(targetEditor); >- reloadGrammarAction.setModel(model); >+// IStructuredModel model = getModelForEditorPart(targetEditor); >+/* reloadGrammarAction.setModel(model); > toggleAction.setModelQuery(ModelQueryUtil.getModelQuery(model)); > > XMLTableTreeViewer tableTreeViewer = getTableTreeViewerForEditorPart(editorPart); >@@ -182,7 +187,7 @@ > xmlMenuExpandAction.setViewer(tableTreeViewer); > xmlMenuCollapseAction.setViewer(tableTreeViewer); > } >- >+*/ > if (editorPart instanceof XMLMultiPageEditorPart) { > IWorkbenchPartSite site = editorPart.getSite(); > if (site instanceof IEditorSite) { >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.27 >diff -u -r1.27 MANIFEST.MF >--- META-INF/MANIFEST.MF 30 Oct 2007 22:42:35 -0000 1.27 >+++ META-INF/MANIFEST.MF 17 Mar 2008 18:36:39 -0000 >@@ -54,6 +54,7 @@ > org.eclipse.wst.xml.core;bundle-version="[1.1.0,1.2.0)", > org.eclipse.wst.common.ui;bundle-version="[1.1.0,1.2.0)", > org.eclipse.wst.validation;bundle-version="[1.1.0,1.2.0)", >- com.ibm.icu;bundle-version="[3.4.4,4.0.0)" >+ com.ibm.icu;bundle-version="[3.4.4,4.0.0)", >+ org.eclipse.core.expressions;bundle-version="[3.3.0,4.0.0)" > Eclipse-LazyStart: true > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,58 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import java.util.Map; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.commands.IElementUpdater; >+import org.eclipse.ui.menus.UIElement; >+import org.eclipse.wst.xml.ui.internal.tabletree.IDesignViewer; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeViewer; >+ >+public class ExpandCollapseAllHandler extends AbstractHandler implements IElementUpdater { >+ >+ protected XMLTableTreeViewer viewer = null; >+ >+ /** >+ * Command handler for handling Expand and Collapse for Tree Viewer >+ */ >+ public ExpandCollapseAllHandler() { >+ super(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ // Implementors to put their code here. >+ >+ return null; >+ } >+ >+ protected XMLTableTreeViewer getTableTreeViewerForEditorPart(IEditorPart targetEditor) { >+ XMLTableTreeViewer result = null; >+ Object object = targetEditor.getAdapter(IDesignViewer.class); >+ if (object instanceof XMLTableTreeViewer) { >+ result = (XMLTableTreeViewer) object; >+ } >+ return result; >+ } >+ >+ public void updateElement(UIElement element, Map parameters) { >+ // TODO Auto-generated method stub >+ >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,67 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; >+import org.eclipse.wst.sse.ui.StructuredTextEditor; >+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; >+import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader; >+import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader; >+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; >+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; >+import org.w3c.dom.Document; >+ >+public class ReloadDependenciesHandler extends AbstractHandler implements >+ IHandler { >+ protected IStructuredModel model; >+ >+ /** >+ * >+ */ >+ public ReloadDependenciesHandler() { >+ // TODO Auto-generated constructor stub >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IEditorPart fEditor = HandlerUtil.getActiveEditor(event); >+ >+ if (fEditor instanceof XMLMultiPageEditorPart) { >+ StructuredTextEditor textEditor = (StructuredTextEditor) fEditor.getAdapter(ITextEditor.class); >+ model = (textEditor != null) ? textEditor.getModel() : null; >+ } >+ >+ if (model != null) { >+ ModelQuery modelQuery = ModelQueryUtil.getModelQuery(model); >+ Document document = ((IDOMModel) model).getDocument(); >+ if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) { >+ modelQuery.getCMDocumentManager().getCMDocumentCache().clear(); >+ // TODO... need to figure out how to access the >+ // DOMObserver via ModelQuery >+ // ...why? >+ CMDocumentLoader loader = new InferredGrammarBuildingCMDocumentLoader(document, modelQuery); >+ loader.loadCMDocuments(); >+ } >+ } >+ return null; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+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.xml.core.internal.document.CommentImpl; >+import org.eclipse.wst.xml.ui.internal.Logger; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+ >+/** >+ * @author dcarver >+ * >+ */ >+public class RemoveBlockCommentHandler extends CommentHandler implements IHandler { >+ >+ public RemoveBlockCommentHandler() { >+ super(); >+ } >+ >+ 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(); >+ } >+ } >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.handlers.HandlerUtil; >+ >+public class CollapseAllHandler extends ExpandCollapseAllHandler implements IHandler { >+ >+ /** >+ * >+ */ >+ public CollapseAllHandler() { >+ super(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IEditorPart editorPart = HandlerUtil.getActiveEditor(event); >+ >+ viewer = getTableTreeViewerForEditorPart(editorPart); >+ >+ if (viewer != null) { >+ // temporarily set the visibility to false >+ // this has a HUGE performance benefit >+ boolean isVisible = viewer.getControl().getVisible(); >+ viewer.getControl().setVisible(false); >+ viewer.collapseAll(); >+ >+ // restore the previous visibility state >+ // >+ viewer.getControl().setVisible(isVisible); >+ } >+ >+ return null; >+ } >+} >Index: src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java >=================================================================== >RCS file: src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java >diff -N src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.wizards; >+ >+import java.util.Iterator; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.handlers.HandlerUtil; >+ >+public class NewXMLHandler extends AbstractHandler implements IHandler { >+ >+ /** >+ * >+ */ >+ public NewXMLHandler() { >+ super(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event); >+ ISelection selection = workbenchWindow.getSelectionService().getSelection(); >+ Object selectedObject = getSelection(selection); >+ >+ if ((selectedObject instanceof IFile) && (selection instanceof IStructuredSelection)) { >+ IFile file = (IFile) selectedObject; >+ IStructuredSelection structuredSelection = (IStructuredSelection) selection; >+ try { >+ NewXMLWizard.showDialog(workbenchWindow.getShell(), file, structuredSelection); >+ } >+ catch (Exception e) { >+ // XMLCorePlugin.getDefault().getLog().log(); >+ } >+ } >+ return null; >+ } >+ >+ public static Object getSelection(ISelection selection) { >+ if (selection == null) { >+ return null; >+ } >+ >+ Object result = null; >+ if (selection instanceof IStructuredSelection) { >+ IStructuredSelection es = (IStructuredSelection) selection; >+ Iterator i = es.iterator(); >+ if (i.hasNext()) { >+ result = i.next(); >+ } >+ } >+ return result; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,116 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation - bug 212330 - >+ * Based off CleanupActionXMLDelegate >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.window.Window; >+import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.core.StructuredModelManager; >+import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor; >+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; >+import org.eclipse.wst.sse.ui.internal.SSEUIMessages; >+import org.eclipse.wst.xml.core.internal.cleanup.CleanupProcessorXML; >+import org.eclipse.wst.xml.ui.internal.actions.CleanupDialogXML; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; >+ >+public class CleanupdocumentHandler extends AbstractHandler implements IHandler { >+ >+ private IEditorPart fEditor; >+ private IStructuredCleanupProcessor fCleanupProcessor; >+ >+ public void dispose() { >+ // nulling out just in case >+ fEditor = null; >+ fCleanupProcessor = null; >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ fEditor = HandlerUtil.getActiveEditor(event); >+ >+ if (fEditor instanceof XMLMultiPageEditorPart) { >+ final ITextEditor editor = (ITextEditor) fEditor.getAdapter(ITextEditor.class); >+ 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()); >+ >+ // tell the model that we are about to make a big >+ // model change >+ model.aboutToChangeModel(); >+ >+ // run >+ BusyIndicator.showWhile(fEditor.getEditorSite().getWorkbenchWindow().getShell().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(); >+ } >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ IStructuredCleanupProcessor getCleanupProcessor() { >+ if (fCleanupProcessor == null) { >+ fCleanupProcessor = new CleanupProcessorXML(); >+ } >+ >+ return fCleanupProcessor; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.commands.IElementUpdater; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.menus.UIElement; >+import org.eclipse.ui.services.IServiceScopes; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; >+import org.eclipse.wst.sse.ui.StructuredTextEditor; >+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; >+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; >+import org.eclipse.wst.xml.ui.internal.XMLUIPlugin; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLEditorMessages; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; >+import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper; >+ >+public class ToggleEditModeHandler extends AbstractHandler implements IElementUpdater { >+ protected ImageDescriptor onImage = SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_CONSTRAINON); >+ protected ImageDescriptor offImage = SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_CONSTRAINOFF); >+ protected ModelQuery modelQuery; >+ >+ public ToggleEditModeHandler() { >+ super(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IEditorPart editor = HandlerUtil.getActiveEditor(event); >+ IStructuredModel model = getModelForEditorPart(editor); >+ >+ modelQuery = ModelQueryUtil.getModelQuery(model); >+ >+ if (modelQuery != null) { >+ int newState = getNextState(modelQuery.getEditMode()); >+ modelQuery.setEditMode(newState); >+ >+ // Force a Refresh on this command so that the image can be updated. >+ ICommandService commandService = (ICommandService) HandlerUtil.getActiveWorkbenchWindow(event).getService(ICommandService.class); >+ Map filter = new HashMap(); >+ filter.put(IServiceScopes.WINDOW_SCOPE, HandlerUtil.getActiveWorkbenchWindow(event)); >+ commandService.refreshElements(event.getCommand().getId(), filter); >+ } >+ >+ return null; >+ } >+ >+ public int getNextState(int editMode) { >+ int result = -1; >+ if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) { >+ result = ModelQuery.EDIT_MODE_UNCONSTRAINED; >+ } >+ else { >+ result = ModelQuery.EDIT_MODE_CONSTRAINED_STRICT; >+ } >+ return result; >+ } >+ >+ >+ // Handlers that need to interact with the ui that the command came from need to use implement this method. >+ public void updateElement(UIElement element, Map parameters) { >+ IEditorPart editor = XMLUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); >+ IStructuredModel model = getModelForEditorPart(editor); >+ modelQuery = ModelQueryUtil.getModelQuery(model); >+ >+ if (modelQuery != null) { >+ setAppearanceForEditMode(modelQuery.getEditMode(), element); >+ } >+ >+ >+ } >+ >+ public void setAppearanceForEditMode(int editMode, UIElement element) { >+ if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) { >+ element.setTooltip(XMLEditorMessages.XMLTableTreeActionBarContributor_3); >+ element.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_4); >+ element.setIcon(onImage); >+ } >+ else { >+ element.setTooltip(XMLEditorMessages.XMLTableTreeActionBarContributor_5); >+ element.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_6); >+ element.setIcon(offImage); >+ } >+ } >+ >+ protected IStructuredModel getModelForEditorPart(IEditorPart targetEditor) { >+ IStructuredModel result = null; >+ if (targetEditor instanceof XMLMultiPageEditorPart) { >+ StructuredTextEditor textEditor = (StructuredTextEditor) targetEditor.getAdapter(ITextEditor.class); >+ result = (textEditor != null) ? textEditor.getModel() : null; >+ } >+ return result; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,134 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation - bug 212330 - >+ * Based off CleanupActionXMLDelegate >+ *******************************************************************************/ >+ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.text.ITypedRegion; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IFileEditorInput; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.ui.internal.SSEUIMessages; >+import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor; >+import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil; >+import org.eclipse.wst.xml.ui.internal.search.XMLFindOccurrencesProcessor; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; >+ >+public class XMLFindOccurencesHandler extends AbstractHandler implements IHandler { >+ >+ private IEditorPart fEditor; >+ private List fProcessors; >+ >+ public void dispose() { >+ // nulling out just in case >+ fEditor = null; >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ fEditor = HandlerUtil.getActiveEditor(event); >+ boolean okay = false; >+ >+ if (fEditor instanceof XMLMultiPageEditorPart) { >+ final ITextEditor textEditor = (ITextEditor) fEditor.getAdapter(ITextEditor.class); >+ IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); >+ if (document != null) { >+ ITextSelection textSelection = getTextSelection(textEditor); >+ FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection); >+ if (findOccurrenceProcessor != null) { >+ if (textEditor.getEditorInput() instanceof IFileEditorInput) { >+ IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile(); >+ okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file); >+ } >+ } >+ } >+ } >+ if (okay) { >+ // clear status message >+ PlatformStatusLineUtil.clearStatusLine(); >+ } >+ else { >+ String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0; //$NON-NLS-1$ >+ PlatformStatusLineUtil.displayErrorMessage(errorMessage); >+ PlatformStatusLineUtil.addOneTimeClearListener(); >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Get the appropriate find occurrences processor >+ * >+ * @param document - >+ * assumes not null >+ * @param textSelection >+ * @return FindOccurrencesProcessor >+ */ >+ private FindOccurrencesProcessor getProcessorForCurrentSelection(IDocument document, ITextSelection textSelection) { >+ // check if we have an action that's enabled on the current partition >+ ITypedRegion tr = getPartition(document, textSelection); >+ String partition = tr != null ? tr.getType() : ""; //$NON-NLS-1$ >+ >+ Iterator it = getProcessors().iterator(); >+ FindOccurrencesProcessor action = null; >+ while (it.hasNext()) { >+ action = (FindOccurrencesProcessor) it.next(); >+ // we just choose the first action that can handle the partition >+ if (action.enabledForParitition(partition)) >+ return action; >+ } >+ return null; >+ } >+ >+ private ITypedRegion getPartition(IDocument document, ITextSelection textSelection) { >+ ITypedRegion region = null; >+ if (textSelection != null) { >+ try { >+ region = document.getPartition(textSelection.getOffset()); >+ } >+ catch (BadLocationException e) { >+ region = null; >+ } >+ } >+ return region; >+ } >+ >+ private ITextSelection getTextSelection(ITextEditor textEditor) { >+ ITextSelection textSelection = null; >+ ISelection selection = textEditor.getSelectionProvider().getSelection(); >+ if (selection instanceof ITextSelection && !selection.isEmpty()) { >+ textSelection = (ITextSelection) selection; >+ } >+ return textSelection; >+ } >+ >+ 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/handlers/ExpandAllHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/ExpandAllHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/ExpandAllHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/ExpandAllHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeViewer; >+ >+public class ExpandAllHandler extends ExpandCollapseAllHandler { >+ >+ protected XMLTableTreeViewer viewer = null; >+ >+ /** >+ * >+ */ >+ public ExpandAllHandler() { >+ super(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ IEditorPart editorPart = HandlerUtil.getActiveEditor(event); >+ >+ viewer = getTableTreeViewerForEditorPart(editorPart); >+ >+ if (viewer != null) { >+ // temporarily set the visibility to false >+ // this has a HUGE performance benefit >+ boolean isVisible = viewer.getControl().getVisible(); >+ viewer.getControl().setVisible(false); >+ viewer.expandAll(); >+ >+ // restore the previous visibility state >+ // >+ viewer.getControl().setVisible(isVisible); >+ } >+ >+ return null; >+ } >+} >Index: src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.ITextSelection; >+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.xml.core.internal.document.CommentImpl; >+import org.eclipse.wst.xml.ui.internal.Logger; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+ >+public class AddBlockCommentHandler extends CommentHandler implements IHandler { >+ >+ public AddBlockCommentHandler() { >+ super(); >+ } >+ >+ 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); >+ super.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/handlers/ToggleCommentHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/ToggleCommentHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/ToggleCommentHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/ToggleCommentHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,193 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+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.handlers.HandlerUtil; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.sse.core.StructuredModelManager; >+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; >+import org.eclipse.wst.xml.ui.internal.Logger; >+import org.eclipse.wst.xml.ui.internal.XMLUIMessages; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; >+ >+public class ToggleCommentHandler extends CommentHandler implements IHandler { >+ >+ public ToggleCommentHandler() { >+ // TODO Auto-generated constructor stub >+ super(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ fEditor = HandlerUtil.getActiveEditor(event); >+ >+ if (fEditor instanceof XMLMultiPageEditorPart) { >+ final ITextEditor textEditor = (ITextEditor) fEditor.getAdapter(ITextEditor.class); >+ fEditor = textEditor; >+ IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); >+ if (document != null) { >+ // get current text selection >+ ITextSelection textSelection = getCurrentSelection(); >+ if (textSelection.isEmpty()) { >+ return null; >+ } >+ >+ processAction(document, textSelection); >+ } >+ } >+ return null; >+ } >+ >+ 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/handlers/CommentHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/handlers/CommentHandler.java >diff -N src/org/eclipse/wst/xml/ui/internal/handlers/CommentHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/handlers/CommentHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation, bug 212330 >+ * >+ *******************************************************************************/ >+package org.eclipse.wst.xml.ui.internal.handlers; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+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.ui.IEditorPart; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.texteditor.ITextEditor; >+import org.eclipse.wst.xml.ui.internal.Logger; >+import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart; >+ >+public class CommentHandler extends AbstractHandler implements IHandler { >+ >+ >+ static final String CLOSE_COMMENT = "-->"; //$NON-NLS-1$ >+ static final String OPEN_COMMENT = "<!--"; //$NON-NLS-1$ >+ >+ IEditorPart fEditor; >+ >+ public CommentHandler() { >+ super(); >+ } >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ fEditor = HandlerUtil.getActiveEditor(event); >+ >+ if (fEditor instanceof XMLMultiPageEditorPart) { >+ final ITextEditor textEditor = (ITextEditor) fEditor.getAdapter(ITextEditor.class); >+ fEditor = textEditor; >+ IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); >+ if (document != null) { >+ // get current text selection >+ ITextSelection textSelection = getCurrentSelection(); >+ if (textSelection.isEmpty()) { >+ return null; >+ } >+ >+ processAction(document, textSelection); >+ } >+ } >+ >+ return null; >+ } >+ >+ protected 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(); >+ } >+ >+ void processAction(IDocument document, ITextSelection textSelection) { >+ // Implementations to over ride. >+ } >+ >+ protected 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); >+ } >+ } >+} >#P org.eclipse.wst.sse.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.29 >diff -u -r1.29 MANIFEST.MF >--- META-INF/MANIFEST.MF 30 Oct 2007 22:40:59 -0000 1.29 >+++ META-INF/MANIFEST.MF 17 Mar 2008 18:36:41 -0000 >@@ -55,6 +55,7 @@ > org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", > org.eclipse.wst.validation;bundle-version="[1.1.0,1.2.0)", > org.eclipse.emf.common;bundle-version="[2.2.0,3.0.0)", >- com.ibm.icu;bundle-version="[3.4.4,4.0.0)" >+ com.ibm.icu;bundle-version="[3.4.4,4.0.0)", >+ org.eclipse.core.expressions;bundle-version="3.4.0" > Eclipse-LazyStart: true > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/plugin.xml,v >retrieving revision 1.47 >diff -u -r1.47 plugin.xml >--- plugin.xml 26 Feb 2008 02:53:29 -0000 1.47 >+++ plugin.xml 17 Mar 2008 18:36:41 -0000 >@@ -1,5 +1,21 @@ > <?xml version="1.0" encoding="UTF-8"?> >-<?eclipse version="3.0"?> >+<?eclipse version="3.3"?> >+<!-- >+******************************************************************************* >+ * Copyright (c) 2001, 2008 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 >+ * David Carver - d_a_carver@yahoo.com - bug 212330 - refactored for using >+ * new menu extension point instead of hard coding the menus in >+ * the java code. Allows adopters to easily extend the existing >+ * WTP menus. >+ *******************************************************************************/ >+--> > <plugin> > > <extension-point >@@ -380,7 +396,8 @@ > id="org.eclipse.wst.sse.ui.StructuredTextEditor"> > </editor> > </extension> >- <extension point="org.eclipse.ui.popupMenus"> >+ >+<!-- <extension point="org.eclipse.ui.popupMenus"> > <objectContribution > objectClass="org.eclipse.core.resources.IContainer" > id="org.eclipse.wst.sse.ui.actions.ContainerSourceActions"> >@@ -416,6 +433,8 @@ > </action> > </objectContribution> > </extension> >+ --> >+ <!-- > <extension > point="org.eclipse.ui.editorActions"> > <editorContribution >@@ -436,7 +455,8 @@ > </action> > </editorContribution> > </extension> >- >+ --> >+ > <!--================================================================================================--> > <!-- contribute a SearchResultViewPage for Occurrences in file --> > <!--================================================================================================--> >@@ -460,4 +480,81 @@ > id="sourcevalidation" > name="%Source_Validation_Extension_Point.name" > schema="schema/org.eclipse.wst.sse.ui.sourcevalidation.exsd" /> >+ >+ <extension point="org.eclipse.ui.menus"> >+ <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=edit"> >+ <menu id="sourceMenuId" label="%Source"></menu> >+ </menuContribution> >+ <menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=sourceMenuId"> >+ <menu id="refactorMenuId" label="%Refactor"></menu> >+ </menuContribution> >+ <menuContribution locationURI="menu:sourceMenuId"> >+ <separator name="sourceBegin" visible="false"></separator> >+ <separator name="shiftBegin" visible="true"></separator> >+ <separator name="shiftEnd" visible="true"></separator> >+ <separator name="additions" visible="true"></separator> >+ <separator name="sourceEnd" visible="false"></separator> >+ </menuContribution> >+ <menuContribution locationURI="popup:org.eclipse.wst.sse.ui.StructuredTextEditor.EditorContext?before=additions"> >+ <menu id="sourcePopupMenuId" label="%Source"> >+ <separator name="sourceBegin" visible="false"></separator> >+ <separator name="additions" visible="true"></separator> >+ <separator name="sourceEnd" visible="false"></separator> >+ </menu> >+ <menu id="refactorPopupMenuId" label="%Refactor"> >+ >+ </menu> >+ </menuContribution> >+ <menuContribution >+ locationURI="popup:org.eclipse.ui.popup.any?after=additions"> >+ <menu >+ id="sourceMenuId" >+ label="%Source"> >+ <command >+ commandId="org.eclipse.wst.sse.ui.format" >+ id="sourceFormat" >+ style="push"> >+ <visibleWhen checkEnabled="false"> >+ <or> >+ <iterate> >+ <adapt >+ type="org.eclipse.core.resources.IContainer"> >+ </adapt> >+ </iterate> >+ <iterate> >+ <adapt >+ type="org.eclipse.core.resources.IFile"> >+ </adapt> >+ </iterate> >+ </or> >+ </visibleWhen> >+ </command> >+ </menu> >+ </menuContribution> >+ </extension> >+ <extension >+ point="org.eclipse.ui.commands"> >+ <command >+ id="org.eclipse.wst.sse.ui.format" >+ name="%command.format.document.name"> >+ </command> >+ </extension> >+ <extension >+ point="org.eclipse.ui.handlers"> >+ <handler >+ class="org.eclipse.wst.sse.ui.internal.handlers.FormatHandler" >+ commandId="org.eclipse.wst.sse.ui.format"> >+ </handler> >+ </extension> >+ <extension point="org.eclipse.core.expressions.definitions"> >+ <definition id="org.eclipse.wst.sse.ui.sseActiveContext.definition"> >+ <with variable="activeContexts"> >+ <iterate operator="or"> >+ <equals value="org.eclipse.wst.sse.ui.structuredTextEditorScope"/> >+ </iterate> >+ </with> >+ </definition> >+ </extension> >+ > </plugin> >+ >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/plugin.properties,v >retrieving revision 1.20 >diff -u -r1.20 plugin.properties >--- plugin.properties 26 Feb 2008 02:53:29 -0000 1.20 >+++ plugin.properties 17 Mar 2008 18:36:41 -0000 >@@ -8,7 +8,7 @@ > # Contributors: > # IBM Corporation - initial API and implementation > # Jens Lukowski/Innoopract - initial renaming/restructuring >-# >+# David Carver - bug 212330 - migrate to org.eclipse.ui.menus extension point > ############################################################################### > providerName=Eclipse.org > pluginName=Structured Source Editor >@@ -69,6 +69,7 @@ > ########################################################################## > Source=&Source > FormatDocument=&Format >+Refactor=Refac&tor > ## > Breakpoint_Extension_Point.name=Breakpoint Extension Point > Source_Validation_Extension_Point.name=Reconcile Validator Extension Point >Index: src/org/eclipse/wst/sse/ui/internal/actions/ActionContributor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/actions/ActionContributor.java,v >retrieving revision 1.6 >diff -u -r1.6 ActionContributor.java >--- src/org/eclipse/wst/sse/ui/internal/actions/ActionContributor.java 26 Feb 2008 02:53:29 -0000 1.6 >+++ src/org/eclipse/wst/sse/ui/internal/actions/ActionContributor.java 17 Mar 2008 18:36:42 -0000 >@@ -8,15 +8,17 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Jens Lukowski/Innoopract - initial renaming/restructuring >+ * David Carver/STAR - [212330] can't contribute to the XML or any SSE based menu > * > *******************************************************************************/ > package org.eclipse.wst.sse.ui.internal.actions; > >+//import java.util.ResourceBundle; >+ > import java.util.ResourceBundle; > > import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.action.GroupMarker; >-import org.eclipse.jface.action.IAction; > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.IStatusLineManager; > import org.eclipse.jface.action.IToolBarManager; >@@ -24,14 +26,9 @@ > import org.eclipse.jface.action.Separator; > import org.eclipse.ui.IActionBars; > import org.eclipse.ui.IEditorPart; >-import org.eclipse.ui.IWorkbenchActionConstants; > import org.eclipse.ui.IWorkbenchPage; >-import org.eclipse.ui.actions.ActionFactory; > import org.eclipse.ui.editors.text.TextEditorActionContributor; >-import org.eclipse.ui.ide.IDEActionFactory; > import org.eclipse.ui.texteditor.ITextEditor; >-import org.eclipse.ui.texteditor.ITextEditorActionConstants; >-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; > import org.eclipse.ui.texteditor.ITextEditorExtension; > import org.eclipse.ui.texteditor.RetargetTextEditorAction; > import org.eclipse.wst.sse.ui.internal.ExtendedEditorActionBuilder; >@@ -88,7 +85,7 @@ > super(); > > ResourceBundle resourceBundle = SSEUIMessages.getResourceBundle(); >- >+/* > fCommandsSeparator = new Separator(); > > // edit commands >@@ -133,21 +130,21 @@ > > fNextAnnotation = new GotoAnnotationAction("Next_annotation", true); //$NON-NLS-1$ > fNextAnnotation.setActionDefinitionId("org.eclipse.ui.navigate.next"); //$NON-NLS-1$ >- >+*/ > fGotoMatchingBracketAction = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_GOTO_MATCHING_BRACKET + StructuredTextEditorActionConstants.UNDERSCORE); > fGotoMatchingBracketAction.setActionDefinitionId(ActionDefinitionIds.GOTO_MATCHING_BRACKET); > > // Read action extensions. > ExtendedEditorActionBuilder builder = new ExtendedEditorActionBuilder(); > extendedContributor = builder.readActionExtensions(getExtensionIDs()); >- >+/* > fMenuAdditionsGroupMarker = new GroupMarker(StructuredTextEditorActionConstants.GROUP_NAME_MENU_ADDITIONS); > fToolbarSeparator = new Separator(); > fToolbarAdditionsGroupMarker = new GroupMarker(StructuredTextEditorActionConstants.GROUP_NAME_TOOLBAR_ADDITIONS); > > fToggleInsertModeAction = new RetargetTextEditorAction(resourceBundle, "Editor.ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$ > fToggleInsertModeAction.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE); >- >+*/ > if (_showDebugStatus) { > fDebugStatusOffset = new OffsetStatusLineContributionItem(StructuredTextEditorActionConstants.STATUS_CATEGORY_OFFSET, true, 20); > } >@@ -155,7 +152,7 @@ > > protected void addToMenu(IMenuManager menu) { > // edit commands >- IMenuManager editMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); >+/* IMenuManager editMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); > if (editMenu != null) { > editMenu.add(fCommandsSeparator); > editMenu.add(fToggleInsertModeAction); >@@ -185,6 +182,7 @@ > if (gotoMenu != null) { > gotoMenu.add(fGotoMatchingBracketAction); > } >+*/ > } > > protected void addToPopupMenu(IMenuManager menu) { >@@ -198,18 +196,18 @@ > } > > protected void addToToolBar(IToolBarManager toolBarManager) { >- toolBarManager.add(fToolbarSeparator); >+/* toolBarManager.add(fToolbarSeparator); > toolBarManager.add(fToolbarAdditionsGroupMarker); >- } >+*/ } > > /** > * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(IMenuManager) > */ > public void contributeToMenu(IMenuManager menu) { > super.contributeToMenu(menu); >- >+/* > addToMenu(menu); >- >+*/ > if (extendedContributor != null) { > extendedContributor.contributeToMenu(menu); > } >@@ -221,9 +219,9 @@ > * @see org.eclipse.wst.sse.ui.extension.IPopupMenuContributor#contributeToPopupMenu(org.eclipse.jface.action.IMenuManager) > */ > public void contributeToPopupMenu(IMenuManager menu) { >- >+/* > addToPopupMenu(menu); >- >+*/ > if (extendedContributor != null) { > extendedContributor.contributeToPopupMenu(menu); > } >@@ -250,8 +248,8 @@ > public void contributeToToolBar(IToolBarManager toolBarManager) { > super.contributeToToolBar(toolBarManager); > >- addToToolBar(toolBarManager); >- >+/* addToToolBar(toolBarManager); >+*/ > if (extendedContributor != null) { > extendedContributor.contributeToToolBar(toolBarManager); > } >@@ -312,7 +310,7 @@ > > ITextEditor textEditor = getTextEditor(activeEditor); > >- IActionBars actionBars = getActionBars(); >+/* IActionBars actionBars = getActionBars(); > if (actionBars != null) { > actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation); > actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation); >@@ -344,7 +342,7 @@ > fGotoMatchingBracketAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_GOTO_MATCHING_BRACKET)); > > fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE)); >- >+*/ > if (extendedContributor != null) { > extendedContributor.setActiveEditor(activeEditor); > } >@@ -361,18 +359,21 @@ > * @see org.eclipse.wst.sse.ui.ISourceViewerActionBarContributor#setViewerSpecificContributionsEnabled(boolean) > */ > public void setViewerSpecificContributionsEnabled(boolean enabled) { >- fShiftRight.setEnabled(enabled); >+/* fShiftRight.setEnabled(enabled); > fShiftLeft.setEnabled(enabled); > fNextAnnotation.setEnabled(enabled); > fPreviousAnnotation.setEnabled(enabled); >- >+*/ > /* > * fComment.setEnabled(enabled); fUncomment.setEnabled(enabled); > */ >+/* > fToggleComment.setEnabled(enabled); > fAddBlockComment.setEnabled(enabled); > fRemoveBlockComment.setEnabled(enabled); >+*/ > // convert line delimiters are not source viewer-specific >+ > } > > /* >Index: src/org/eclipse/wst/sse/ui/StructuredTextEditor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java,v >retrieving revision 1.88 >diff -u -r1.88 StructuredTextEditor.java >--- src/org/eclipse/wst/sse/ui/StructuredTextEditor.java 28 Feb 2008 05:10:11 -0000 1.88 >+++ src/org/eclipse/wst/sse/ui/StructuredTextEditor.java 17 Mar 2008 18:36:42 -0000 >@@ -105,6 +105,7 @@ > import org.eclipse.ui.IWorkbenchActionConstants; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.editors.text.EditorsUI; > import org.eclipse.ui.editors.text.ITextEditorHelpContextIds; > import org.eclipse.ui.editors.text.TextEditor; >@@ -1145,16 +1146,16 @@ > protected void addContextMenuActions(IMenuManager menu) { > // Only offer actions that affect the text if the viewer allows > // modification and supports any of these operations >- IAction formatAll = getAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT); >- IAction formatSelection = getAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS); >- IAction cleanupAll = getAction(StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT); >- boolean enableFormatMenu = (formatAll != null && formatAll.isEnabled()) || (formatSelection != null && formatSelection.isEnabled()) || (cleanupAll != null && cleanupAll.isEnabled()); >- >- if (getSourceViewer().isEditable() && enableFormatMenu) { >- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT); >- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS); >- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT); >- } >+// IAction formatAll = getAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT); >+// IAction formatSelection = getAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS); >+// IAction cleanupAll = getAction(StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT); >+// boolean enableFormatMenu = (formatAll != null && formatAll.isEnabled()) || (formatSelection != null && formatSelection.isEnabled()) || (cleanupAll != null && cleanupAll.isEnabled()); >+// >+// if (getSourceViewer().isEditable() && enableFormatMenu) { >+// addAction(menu, ITextEditorActionConstants.GROUP_EDIT, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT); >+// addAction(menu, ITextEditorActionConstants.GROUP_EDIT, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS); >+// addAction(menu, ITextEditorActionConstants.GROUP_EDIT, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT); >+// } > > // Some Design editors (DTD) rely on this view for their own uses > menu.appendToGroup(IWorkbenchActionConstants.GROUP_ADD, fShowPropertiesAction); >@@ -1466,6 +1467,9 @@ > * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createPartControl(org.eclipse.swt.widgets.Composite) > */ > public void createPartControl(Composite parent) { >+ IContextService contextService = (IContextService) getSite().getService(IContextService.class); >+ contextService.activateContext("org.eclipse.wst.sse.ui.structuredTextEditorScope"); >+ > if (getSourceViewerConfiguration() == null) { > ConfigurationAndTarget cat = createSourceViewerConfiguration(); > fViewerConfigurationTargetId = cat.getTargetId(); >Index: src/org/eclipse/wst/sse/ui/internal/handlers/FormatHandler.java >=================================================================== >RCS file: src/org/eclipse/wst/sse/ui/internal/handlers/FormatHandler.java >diff -N src/org/eclipse/wst/sse/ui/internal/handlers/FormatHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/sse/ui/internal/handlers/FormatHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,266 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Standards for Technology in Automotive Retail 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: >+ * David Carver - initial API and implementation - bug 212330 - >+ * Based off FormatActionDelegate.java >+ *******************************************************************************/ >+ >+package org.eclipse.wst.sse.ui.internal.handlers; >+ >+import java.io.IOException; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.IHandler; >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.core.runtime.content.IContentDescription; >+import org.eclipse.core.runtime.content.IContentType; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.progress.IWorkbenchSiteProgressService; >+import org.eclipse.wst.sse.core.internal.exceptions.MalformedInputExceptionWithDetail; >+import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor; >+import org.eclipse.wst.sse.ui.internal.FormatProcessorsExtensionReader; >+import org.eclipse.wst.sse.ui.internal.Logger; >+import org.eclipse.wst.sse.ui.internal.SSEUIMessages; >+import org.eclipse.wst.sse.ui.internal.SSEUIPlugin; >+ >+public class FormatHandler extends AbstractHandler implements IHandler { >+ >+ protected IStructuredSelection fSelection; >+ >+ public void dispose() { >+ // nulling out just in case >+ } >+ >+ private IWorkbenchSiteProgressService getActiveProgressService() { >+ IWorkbenchSiteProgressService service = null; >+ if (PlatformUI.isWorkbenchRunning()) { >+ IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); >+ if (activeWorkbenchWindow != null) { >+ IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); >+ if (activePage != null) { >+ IWorkbenchPart activePart = activePage.getActivePart(); >+ if (activePart != null) { >+ service = (IWorkbenchSiteProgressService) activePart.getSite().getAdapter(IWorkbenchSiteProgressService.class); >+ } >+ } >+ } >+ } >+ return service; >+ } >+ >+ >+ >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getSelectionService().getSelection(); >+ >+ if (selection instanceof IStructuredSelection) { >+ fSelection = (IStructuredSelection) selection; >+ boolean available = false; >+ >+ Object[] elements = fSelection.toArray(); >+ for (int i = 0; i < elements.length; i++) { >+ if (elements[i] instanceof IResource) { >+ available = processorAvailable((IResource) elements[i]); >+ >+ if (available) >+ break; >+ } >+ } >+ } >+ >+ if (fSelection != null && !fSelection.isEmpty()) { >+ Job job = getJob(); >+ if (job != null) { >+ IWorkbenchSiteProgressService progressService = getActiveProgressService(); >+ if (progressService != null) { >+ progressService.schedule(job); >+ } >+ else { >+ job.schedule(); >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ >+ class FormatJob extends Job { >+ >+ public FormatJob(String name) { >+ super(name); >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ IStatus status = Status.OK_STATUS; >+ >+ Object[] elements = fSelection.toArray(); >+ monitor.beginTask("", elements.length); //$NON-NLS-1$ >+ for (int i = 0; i < elements.length; i++) { >+ if (elements[i] instanceof IResource) { >+ process(new SubProgressMonitor(monitor, 1), (IResource) elements[i]); >+ } >+ else { >+ monitor.worked(1); >+ } >+ } >+ monitor.done(); >+ >+ if (fErrorStatus.getChildren().length > 0) { >+ status = fErrorStatus; >+ fErrorStatus = new MultiStatus(SSEUIPlugin.ID, IStatus.ERROR, SSEUIMessages.FormatActionDelegate_errorStatusMessage, null); //$NON-NLS-1$ >+ } >+ >+ return status; >+ } >+ >+ } >+ >+ private MultiStatus fErrorStatus = new MultiStatus(SSEUIPlugin.ID, IStatus.ERROR, SSEUIMessages.FormatActionDelegate_errorStatusMessage, null); //$NON-NLS-1$ >+ >+ protected void format(IProgressMonitor monitor, IFile file) { >+ try { >+ monitor.beginTask("", 100); >+ IContentDescription contentDescription = file.getContentDescription(); >+ monitor.worked(5); >+ if (contentDescription != null) { >+ IContentType contentType = contentDescription.getContentType(); >+ IStructuredFormatProcessor formatProcessor = getFormatProcessor(contentType.getId()); >+ if (formatProcessor != null && (monitor == null || !monitor.isCanceled())) { >+ String message = NLS.bind(SSEUIMessages.FormatActionDelegate_3, new String[]{file.getFullPath().toString().substring(1)}); monitor.subTask(message); >+ formatProcessor.setProgressMonitor(monitor); >+ formatProcessor.formatFile(file); >+ } >+ } >+ monitor.worked(95); >+ monitor.done(); >+ } catch (MalformedInputExceptionWithDetail e) { >+ String message = NLS.bind(SSEUIMessages.FormatActionDelegate_5, new String[]{file.getFullPath().toString()}); >+ fErrorStatus.add(new Status(IStatus.ERROR, SSEUIPlugin.ID, IStatus.ERROR, message, e)); >+ } catch (IOException e) { >+ String message = NLS.bind(SSEUIMessages.FormatActionDelegate_4, new String[]{file.getFullPath().toString()}); >+ fErrorStatus.add(new Status(IStatus.ERROR, SSEUIPlugin.ID, IStatus.ERROR, message, e)); >+ } catch (CoreException e) { >+ String message = NLS.bind(SSEUIMessages.FormatActionDelegate_4, new String[]{file.getFullPath().toString()}); >+ fErrorStatus.add(new Status(IStatus.ERROR, SSEUIPlugin.ID, IStatus.ERROR, message, e)); >+ } >+ } >+ >+ protected void format(IProgressMonitor monitor, IResource resource) { >+ if (resource instanceof IFile) { >+ IFile file = (IFile) resource; >+ >+ if (monitor == null || !monitor.isCanceled()) >+ format(monitor, file); >+ } else if (resource instanceof IContainer) { >+ IContainer container = (IContainer) resource; >+ >+ try { >+ IResource[] members = container.members(); >+ monitor.beginTask("", members.length); >+ for (int i = 0; i < members.length; i++) { >+ if (monitor == null || !monitor.isCanceled()) >+ format(new SubProgressMonitor(monitor, 1), members[i]); >+ } >+ monitor.done(); >+ } catch (CoreException e) { >+ String message = NLS.bind(SSEUIMessages.FormatActionDelegate_4, new String[]{resource.getFullPath().toString()}); >+ fErrorStatus.add(new Status(IStatus.ERROR, SSEUIPlugin.ID, IStatus.ERROR, message, e)); >+ } >+ } >+ } >+ >+ protected IStructuredFormatProcessor getFormatProcessor(String contentTypeId) { >+ return FormatProcessorsExtensionReader.getInstance().getFormatProcessor(contentTypeId); >+ } >+ >+ protected Job getJob() { >+ return new FormatJob(SSEUIMessages.FormatActionDelegate_jobName); //$NON-NLS-1$ >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.wst.sse.ui.edit.util.ResourceActionDelegate#process(org.eclipse.core.runtime.IProgressMonitor, >+ * org.eclipse.core.resources.IResource) >+ */ >+ protected void process(IProgressMonitor monitor, IResource resource) { >+ monitor.beginTask("", 100); >+ format(new SubProgressMonitor(monitor, 98), resource); >+ >+ try { >+ resource.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 2)); >+ } catch (CoreException e) { >+ String message = NLS.bind(SSEUIMessages.FormatActionDelegate_4, new String[]{resource.getFullPath().toString()}); >+ fErrorStatus.add(new Status(IStatus.ERROR, SSEUIPlugin.ID, IStatus.ERROR, message, e)); >+ } >+ monitor.done(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.wst.sse.ui.internal.actions.ResourceActionDelegate#processorAvailable(org.eclipse.core.resources.IResource) >+ */ >+ protected boolean processorAvailable(IResource resource) { >+ boolean result = false; >+ if (resource.isAccessible()) { >+ try { >+ if (resource instanceof IFile) { >+ IFile file = (IFile) resource; >+ >+ IStructuredFormatProcessor formatProcessor = null; >+ IContentDescription contentDescription = file.getContentDescription(); >+ if (contentDescription != null) { >+ IContentType contentType = contentDescription.getContentType(); >+ formatProcessor = getFormatProcessor(contentType.getId()); >+ } >+ if (formatProcessor != null) >+ result = true; >+ } >+ else if (resource instanceof IContainer) { >+ IContainer container = (IContainer) resource; >+ IResource[] members; >+ members = container.members(); >+ for (int i = 0; i < members.length; i++) { >+ boolean available = processorAvailable(members[i]); >+ >+ if (available) { >+ result = true; >+ break; >+ } >+ } >+ } >+ } >+ catch (CoreException e) { >+ Logger.logException(e); >+ } >+ } >+ >+ return result; >+ } >+ >+}
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
Flags:
bjorn.freeman-benson
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 212330
:
85240
|
85305
|
85343
|
85359
|
85510
|
85614
|
85623
|
85671
|
85691
|
89897
|
90283
|
92198
|
92199
|
92436
| 92731