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 24931 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.jst.jsp.ui2.patch
org.eclipse.jst.jsp.ui2.patch (text/plain), 5.64 KB, created by
Amy Wu
on 2005-07-18 14:46:38 EDT
(
hide
)
Description:
org.eclipse.jst.jsp.ui2.patch
Filename:
MIME Type:
Creator:
Amy Wu
Created:
2005-07-18 14:46:38 EDT
Size:
5.64 KB
patch
obsolete
>Index: src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java >=================================================================== >RCS file: /home/webtools/jst/components/jsp/plugins/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java,v >retrieving revision 1.6 >diff -u -r1.6 StructuredTextViewerConfigurationJSP.java >--- src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java 24 Jun 2005 20:12:58 -0000 1.6 >+++ src/org/eclipse/jst/jsp/ui/internal/provisional/StructuredTextViewerConfigurationJSP.java 18 Jul 2005 18:44:43 -0000 >@@ -59,6 +59,7 @@ > import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS; > import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl; > import org.eclipse.wst.html.core.internal.provisional.text.IHTMLPartitionTypes; >+import org.eclipse.wst.html.ui.internal.autoedit.AutoEditStrategyForTabs; > import org.eclipse.wst.html.ui.internal.provisional.StructuredTextViewerConfigurationHTML; > import org.eclipse.wst.html.ui.internal.style.LineStyleProviderForHTML; > import org.eclipse.wst.javascript.ui.internal.common.style.LineStyleProviderForJavaScript; >@@ -108,7 +109,17 @@ > if (contentType == IXMLPartitions.XML_DEFAULT) { > strategies = getXMLSourceViewerConfiguration().getAutoEditStrategies(sourceViewer, contentType); > } else if (contentType == IJSPPartitionTypes.JSP_CONTENT_JAVA) { >- strategies = getJavaSourceViewerConfiguration().getAutoEditStrategies(sourceViewer, IJavaPartitions.JAVA_PARTITIONING); >+ List allStrategies = new ArrayList(0); >+ >+ IAutoEditStrategy[] javaStrategies = getJavaSourceViewerConfiguration().getAutoEditStrategies(sourceViewer, IJavaPartitions.JAVA_PARTITIONING); >+ for (int i = 0; i < javaStrategies.length; i++) { >+ allStrategies.add(javaStrategies[i]); >+ } >+ >+ // add auto edit strategy that handles when tab key is pressed >+ allStrategies.add(new AutoEditStrategyForTabs()); >+ >+ strategies = (IAutoEditStrategy[]) allStrategies.toArray(new IAutoEditStrategy[0]); > } else { > List allStrategies = new ArrayList(0); > >@@ -116,6 +127,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 StructuredAutoEditStrategyJSP()); >Index: src/org/eclipse/jst/jsp/ui/internal/autoedit/AutoEditStrategyForTabs.java >=================================================================== >RCS file: src/org/eclipse/jst/jsp/ui/internal/autoedit/AutoEditStrategyForTabs.java >diff -N src/org/eclipse/jst/jsp/ui/internal/autoedit/AutoEditStrategyForTabs.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/jsp/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.jst.jsp.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