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 24933 Details for
Bug 71271
add "insert spaces for tabs" function to sse editors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
org.eclipse.wst.xml.ui2.patch
org.eclipse.wst.xml.ui2.patch (text/plain), 7.97 KB, created by
Amy Wu
on 2005-07-18 14:47:07 EDT
(
hide
)
Description:
org.eclipse.wst.xml.ui2.patch
Filename:
MIME Type:
Creator:
Amy Wu
Created:
2005-07-18 14:47:07 EDT
Size:
7.97 KB
patch
obsolete
>Index: src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java,v >retrieving revision 1.11 >diff -u -r1.11 StructuredAutoEditStrategyXML.java >--- src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java 6 Jun 2005 05:07:38 -0000 1.11 >+++ src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java 18 Jul 2005 18:45:13 -0000 >@@ -12,12 +12,10 @@ > *******************************************************************************/ > package org.eclipse.wst.xml.ui.internal.autoedit; > >-import org.eclipse.core.runtime.Preferences; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.DocumentCommand; > import org.eclipse.jface.text.IAutoEditStrategy; > import org.eclipse.jface.text.IDocument; >-import org.eclipse.jface.text.IRegion; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchWindow; >@@ -28,8 +26,6 @@ > import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; > import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; > import org.eclipse.wst.sse.ui.internal.StructuredDocumentCommand; >-import org.eclipse.wst.xml.core.internal.XMLCorePlugin; >-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames; > import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; > import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; > import org.eclipse.wst.xml.ui.internal.Logger; >@@ -56,10 +52,6 @@ > if (model != null) > model.releaseFromRead(); > } >- >- // spaces for tab character >- if (command.text != null && command.text.length() > 0 && command.text.charAt(0) == '\t') >- smartInsertForTab(command, document); > } > > private boolean isCommentNode(IDOMNode node) { >@@ -108,40 +100,6 @@ > } > > /** >- * Insert spaces for tabs >- * >- * @param command >- */ >- private void smartInsertForTab(DocumentCommand command, IDocument document) { >- // tab key was pressed. now check preferences to see if need to insert >- // spaces instead of tab >- Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences(); >- if (XMLCorePreferenceNames.SPACE.equals(preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR))) { >- int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE); >- >- StringBuffer indent = new StringBuffer(); >- if (indentationWidth != 0) { >- int indentSize = indentationWidth; >- try { >- IRegion firstLine = document.getLineInformationOfOffset(command.offset); >- int offsetInLine = command.offset - firstLine.getOffset(); >- int remainder = offsetInLine % indentationWidth; >- >- indentSize = indentationWidth - remainder; >- } catch (BadLocationException e) { >- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >- } >- >- for (int i = 0; i < indentSize; i++) >- indent.append(' '); >- } >- >- // replace \t characters with spaces >- command.text = indent.toString(); >- } >- } >- >- /** > * Return the active text editor if possible, otherwise the active editor > * part. > * >Index: src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextViewerConfigurationXML.java >=================================================================== >RCS file: /home/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextViewerConfigurationXML.java,v >retrieving revision 1.3 >diff -u -r1.3 StructuredTextViewerConfigurationXML.java >--- src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextViewerConfigurationXML.java 24 Jun 2005 20:13:17 -0000 1.3 >+++ src/org/eclipse/wst/xml/ui/internal/provisional/StructuredTextViewerConfigurationXML.java 18 Jul 2005 18:45:13 -0000 >@@ -55,6 +55,7 @@ > import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; > import org.eclipse.wst.xml.core.internal.provisional.text.IXMLPartitions; > import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML; >+import org.eclipse.wst.xml.ui.internal.autoedit.AutoEditStrategyForTabs; > import org.eclipse.wst.xml.ui.internal.autoedit.StructuredAutoEditStrategyXML; > import org.eclipse.wst.xml.ui.internal.contentassist.NoRegionContentAssistProcessor; > import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentAssistProcessor; >@@ -97,6 +98,9 @@ > for (int i = 0; i < superStrategies.length; i++) { > allStrategies.add(superStrategies[i]); > } >+ >+ // add auto edit strategy that handles when tab key is pressed >+ allStrategies.add(new AutoEditStrategyForTabs()); > > if (contentType == IXMLPartitions.XML_DEFAULT) { > allStrategies.add(new StructuredAutoEditStrategyXML()); >Index: src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java >=================================================================== >RCS file: src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java >diff -N src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * Jens Lukowski/Innoopract - initial renaming/restructuring >+ * >+ */ >+package org.eclipse.wst.xml.ui.internal.autoedit; >+ >+import org.eclipse.core.runtime.Preferences; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.DocumentCommand; >+import org.eclipse.jface.text.IAutoEditStrategy; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.wst.xml.core.internal.XMLCorePlugin; >+import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames; >+import org.eclipse.wst.xml.ui.internal.Logger; >+ >+/** >+ * AutoEditStrategy to handle characters inserted when Tab key is pressed >+ */ >+public class AutoEditStrategyForTabs implements IAutoEditStrategy { >+ >+ public void customizeDocumentCommand(IDocument document, DocumentCommand command) { >+ // spaces for tab character >+ if (command.text != null && command.text.length() > 0 && command.text.charAt(0) == '\t') >+ smartInsertForTab(command, document); >+ } >+ >+ /** >+ * Insert spaces for tabs >+ * >+ * @param command >+ */ >+ private void smartInsertForTab(DocumentCommand command, IDocument document) { >+ // tab key was pressed. now check preferences to see if need to insert >+ // spaces instead of tab >+ Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences(); >+ if (XMLCorePreferenceNames.SPACE.equals(preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR))) { >+ int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE); >+ >+ StringBuffer indent = new StringBuffer(); >+ if (indentationWidth != 0) { >+ int indentSize = indentationWidth; >+ try { >+ IRegion firstLine = document.getLineInformationOfOffset(command.offset); >+ int offsetInLine = command.offset - firstLine.getOffset(); >+ int remainder = offsetInLine % indentationWidth; >+ >+ indentSize = indentationWidth - remainder; >+ } catch (BadLocationException e) { >+ Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e); >+ } >+ >+ for (int i = 0; i < indentSize; i++) >+ indent.append(' '); >+ } >+ >+ // replace \t characters with spaces >+ command.text = indent.toString(); >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 71271
:
22276
|
22277
|
22278
|
22279
|
22281
|
22282
|
22283
|
22284
|
22285
|
22286
|
22287
|
22288
|
22289
|
24931
|
24932
| 24933