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 24932 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.html.ui2.patch
org.eclipse.wst.html.ui2.patch (text/plain), 7.97 KB, created by
Amy Wu
on 2005-07-18 14:46:56 EDT
(
hide
)
Description:
org.eclipse.wst.html.ui2.patch
Filename:
MIME Type:
Creator:
Amy Wu
Created:
2005-07-18 14:46:56 EDT
Size:
7.97 KB
patch
obsolete
>Index: src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java >=================================================================== >RCS file: /home/webtools/wst/components/html/plugins/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java,v >retrieving revision 1.1 >diff -u -r1.1 StructuredAutoEditStrategyHTML.java >--- src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java 6 Jun 2005 05:07:39 -0000 1.1 >+++ src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java 18 Jul 2005 18:44:59 -0000 >@@ -10,20 +10,16 @@ > *******************************************************************************/ > package org.eclipse.wst.html.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; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.texteditor.ITextEditor; > import org.eclipse.ui.texteditor.ITextEditorExtension3; >-import org.eclipse.wst.html.core.internal.HTMLCorePlugin; >-import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; > import org.eclipse.wst.html.ui.internal.Logger; > import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; > import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager; >@@ -53,10 +49,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) { >@@ -105,40 +97,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 = HTMLCorePlugin.getDefault().getPluginPreferences(); >- if (HTMLCorePreferenceNames.SPACE.equals(preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR))) { >- int indentationWidth = preferences.getInt(HTMLCorePreferenceNames.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/html/ui/internal/provisional/StructuredTextViewerConfigurationHTML.java >=================================================================== >RCS file: /home/webtools/wst/components/html/plugins/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/provisional/StructuredTextViewerConfigurationHTML.java,v >retrieving revision 1.3 >diff -u -r1.3 StructuredTextViewerConfigurationHTML.java >--- src/org/eclipse/wst/html/ui/internal/provisional/StructuredTextViewerConfigurationHTML.java 7 Jun 2005 20:29:28 -0000 1.3 >+++ src/org/eclipse/wst/html/ui/internal/provisional/StructuredTextViewerConfigurationHTML.java 18 Jul 2005 18:44:59 -0000 >@@ -42,6 +42,7 @@ > import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; > import org.eclipse.wst.html.core.internal.provisional.text.IHTMLPartitionTypes; > import org.eclipse.wst.html.core.internal.text.StructuredTextPartitionerForHTML; >+import org.eclipse.wst.html.ui.internal.autoedit.AutoEditStrategyForTabs; > import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor; > import org.eclipse.wst.html.ui.internal.contentassist.NoRegionContentAssistProcessorForHTML; > import org.eclipse.wst.html.ui.internal.hyperlink.URIHyperlinkDetector; >@@ -101,6 +102,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 == IHTMLPartitionTypes.HTML_DEFAULT || contentType == IHTMLPartitionTypes.HTML_DECLARATION) { > allStrategies.add(new StructuredAutoEditStrategyXML()); >Index: src/org/eclipse/wst/html/ui/internal/autoedit/AutoEditStrategyForTabs.java >=================================================================== >RCS file: src/org/eclipse/wst/html/ui/internal/autoedit/AutoEditStrategyForTabs.java >diff -N src/org/eclipse/wst/html/ui/internal/autoedit/AutoEditStrategyForTabs.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/html/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.html.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.html.core.internal.HTMLCorePlugin; >+import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames; >+import org.eclipse.wst.html.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 = HTMLCorePlugin.getDefault().getPluginPreferences(); >+ if (HTMLCorePreferenceNames.SPACE.equals(preferences.getString(HTMLCorePreferenceNames.INDENTATION_CHAR))) { >+ int indentationWidth = preferences.getInt(HTMLCorePreferenceNames.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