|
Lines 14-20
Link Here
|
| 14 |
|
14 |
|
| 15 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
| 16 |
import java.util.List; |
16 |
import java.util.List; |
|
|
17 |
import java.util.Vector; |
| 17 |
|
18 |
|
|
|
19 |
import org.eclipse.core.runtime.Preferences; |
| 18 |
import org.eclipse.jface.preference.IPreferenceStore; |
20 |
import org.eclipse.jface.preference.IPreferenceStore; |
| 19 |
import org.eclipse.jface.text.IAutoEditStrategy; |
21 |
import org.eclipse.jface.text.IAutoEditStrategy; |
| 20 |
import org.eclipse.jface.text.IDocument; |
22 |
import org.eclipse.jface.text.IDocument; |
|
Lines 48-53
Link Here
|
| 48 |
import org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor; |
50 |
import org.eclipse.wst.sse.ui.internal.taginfo.ProblemAnnotationHoverProcessor; |
| 49 |
import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager; |
51 |
import org.eclipse.wst.sse.ui.internal.taginfo.TextHoverManager; |
| 50 |
import org.eclipse.wst.sse.ui.internal.util.EditorUtility; |
52 |
import org.eclipse.wst.sse.ui.internal.util.EditorUtility; |
|
|
53 |
import org.eclipse.wst.xml.core.internal.XMLCorePlugin; |
| 54 |
import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames; |
| 51 |
import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; |
55 |
import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; |
| 52 |
import org.eclipse.wst.xml.core.internal.provisional.text.IXMLPartitions; |
56 |
import org.eclipse.wst.xml.core.internal.provisional.text.IXMLPartitions; |
| 53 |
import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML; |
57 |
import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML; |
|
Lines 65-95
Link Here
|
| 65 |
|
69 |
|
| 66 |
/** |
70 |
/** |
| 67 |
* This class provides |
71 |
* This class provides |
|
|
72 |
* |
| 68 |
* @since 1.0 |
73 |
* @since 1.0 |
| 69 |
*/ |
74 |
*/ |
| 70 |
public class StructuredTextViewerConfigurationXML extends StructuredTextViewerConfiguration { |
75 |
public class StructuredTextViewerConfigurationXML extends StructuredTextViewerConfiguration { |
| 71 |
|
76 |
|
| 72 |
InformationPresenter fInformationPresenter = null; |
77 |
InformationPresenter fInformationPresenter = null; |
| 73 |
|
78 |
|
| 74 |
public StructuredTextViewerConfigurationXML() { |
79 |
public StructuredTextViewerConfigurationXML() { |
| 75 |
super(); |
80 |
super(); |
| 76 |
} |
81 |
} |
| 77 |
|
82 |
|
| 78 |
public StructuredTextViewerConfigurationXML(IPreferenceStore store) { |
83 |
public StructuredTextViewerConfigurationXML(IPreferenceStore store) { |
| 79 |
super(store); |
84 |
super(store); |
| 80 |
} |
85 |
} |
| 81 |
|
86 |
|
| 82 |
/* (non-Javadoc) |
87 |
/* |
| 83 |
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String) |
88 |
* (non-Javadoc) |
|
|
89 |
* |
| 90 |
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, |
| 91 |
* java.lang.String) |
| 84 |
*/ |
92 |
*/ |
| 85 |
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { |
93 |
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { |
| 86 |
List allStrategies = new ArrayList(0); |
94 |
List allStrategies = new ArrayList(0); |
| 87 |
|
95 |
|
| 88 |
IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType); |
96 |
IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType); |
| 89 |
for (int i = 0; i < superStrategies.length; i++) { |
97 |
for (int i = 0; i < superStrategies.length; i++) { |
| 90 |
allStrategies.add(superStrategies[i]); |
98 |
allStrategies.add(superStrategies[i]); |
| 91 |
} |
99 |
} |
| 92 |
|
100 |
|
| 93 |
if (contentType == IXMLPartitions.XML_DEFAULT) { |
101 |
if (contentType == IXMLPartitions.XML_DEFAULT) { |
| 94 |
allStrategies.add(new StructuredAutoEditStrategyXML()); |
102 |
allStrategies.add(new StructuredAutoEditStrategyXML()); |
| 95 |
} |
103 |
} |
|
Lines 183-188
Link Here
|
| 183 |
fInformationPresenter.setInformationProvider(xmlInformationProvider, IStructuredPartitionTypes.DEFAULT_PARTITION); |
191 |
fInformationPresenter.setInformationProvider(xmlInformationProvider, IStructuredPartitionTypes.DEFAULT_PARTITION); |
| 184 |
fInformationPresenter.setInformationProvider(xmlInformationProvider, IXMLPartitions.XML_DEFAULT); |
192 |
fInformationPresenter.setInformationProvider(xmlInformationProvider, IXMLPartitions.XML_DEFAULT); |
| 185 |
fInformationPresenter.setSizeConstraints(60, 10, true, true); |
193 |
fInformationPresenter.setSizeConstraints(60, 10, true, true); |
|
|
194 |
fInformationPresenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); |
| 186 |
} |
195 |
} |
| 187 |
return fInformationPresenter; |
196 |
return fInformationPresenter; |
| 188 |
} |
197 |
} |
|
Lines 197-227
Link Here
|
| 197 |
} |
206 |
} |
| 198 |
|
207 |
|
| 199 |
if (fReconciler == null) { |
208 |
if (fReconciler == null) { |
| 200 |
fReconciler = new StructuredRegionProcessor(); |
209 |
fReconciler = new StructuredRegionProcessor(); |
| 201 |
fReconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); |
210 |
fReconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer)); |
| 202 |
} |
211 |
} |
| 203 |
|
212 |
|
| 204 |
boolean reconcilingEnabled = fPreferenceStore.getBoolean(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS); |
213 |
boolean reconcilingEnabled = fPreferenceStore.getBoolean(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS); |
| 205 |
|
214 |
|
| 206 |
if(!reconcilingEnabled) |
215 |
if (!reconcilingEnabled) |
| 207 |
return fReconciler; |
216 |
return fReconciler; |
| 208 |
|
217 |
|
| 209 |
// the second time through, the strategies are set |
218 |
// the second time through, the strategies are set |
| 210 |
if (fReconciler != null) { |
219 |
if (fReconciler != null) { |
| 211 |
|
220 |
|
| 212 |
IDocument doc = ((StructuredTextEditor)editorPart).getDocumentProvider().getDocument(editorPart.getEditorInput()); |
221 |
IDocument doc = ((StructuredTextEditor) editorPart).getDocumentProvider().getDocument(editorPart.getEditorInput()); |
| 213 |
IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(doc); |
222 |
IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(doc); |
| 214 |
|
223 |
|
| 215 |
try { |
224 |
try { |
| 216 |
|
225 |
|
| 217 |
if (sModel != null) { |
226 |
if (sModel != null) { |
| 218 |
|
227 |
|
| 219 |
IReconcilingStrategy markupStrategy = new StructuredTextReconcilingStrategyForMarkup((ITextEditor) editorPart); |
228 |
IReconcilingStrategy markupStrategy = new StructuredTextReconcilingStrategyForMarkup((ITextEditor) editorPart); |
| 220 |
fReconciler.setReconcilingStrategy(markupStrategy, IXMLPartitions.XML_DEFAULT); |
229 |
fReconciler.setReconcilingStrategy(markupStrategy, IXMLPartitions.XML_DEFAULT); |
| 221 |
fReconciler.setDefaultStrategy(markupStrategy); |
230 |
fReconciler.setDefaultStrategy(markupStrategy); |
| 222 |
|
231 |
|
| 223 |
String contentTypeId = sModel.getContentTypeIdentifier(); |
232 |
String contentTypeId = sModel.getContentTypeIdentifier(); |
| 224 |
if(contentTypeId != null) |
233 |
if (contentTypeId != null) |
| 225 |
fReconciler.setValidatorStrategy(createValidatorStrategy(contentTypeId)); |
234 |
fReconciler.setValidatorStrategy(createValidatorStrategy(contentTypeId)); |
| 226 |
} |
235 |
} |
| 227 |
} finally { |
236 |
} finally { |
|
Lines 272-289
Link Here
|
| 272 |
fInformationPresenter.uninstall(); |
281 |
fInformationPresenter.uninstall(); |
| 273 |
} |
282 |
} |
| 274 |
} |
283 |
} |
| 275 |
|
284 |
|
| 276 |
/* (non-Javadoc) |
285 |
/* |
|
|
286 |
* (non-Javadoc) |
| 287 |
* |
| 277 |
* @see org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer) |
288 |
* @see org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer) |
| 278 |
*/ |
289 |
*/ |
| 279 |
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { |
290 |
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { |
| 280 |
if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED)) |
291 |
if (sourceViewer == null || !fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED)) |
| 281 |
return null; |
292 |
return null; |
| 282 |
|
293 |
|
| 283 |
List allDetectors = new ArrayList(0); |
294 |
List allDetectors = new ArrayList(0); |
| 284 |
allDetectors.add(new XMLHyperlinkDetector()); |
295 |
allDetectors.add(new XMLHyperlinkDetector()); |
| 285 |
|
296 |
|
| 286 |
IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer); |
297 |
IHyperlinkDetector[] superDetectors = super.getHyperlinkDetectors(sourceViewer); |
| 287 |
for (int m = 0; m < superDetectors.length; m++) { |
298 |
for (int m = 0; m < superDetectors.length; m++) { |
| 288 |
IHyperlinkDetector detector = superDetectors[m]; |
299 |
IHyperlinkDetector detector = superDetectors[m]; |
| 289 |
if (!allDetectors.contains(detector)) { |
300 |
if (!allDetectors.contains(detector)) { |
|
Lines 292-295
Link Here
|
| 292 |
} |
303 |
} |
| 293 |
return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]); |
304 |
return (IHyperlinkDetector[]) allDetectors.toArray(new IHyperlinkDetector[0]); |
| 294 |
} |
305 |
} |
|
|
306 |
|
| 307 |
public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { |
| 308 |
Vector vector = new Vector(); |
| 309 |
|
| 310 |
// prefix[0] is either '\t' or ' ' x tabWidth, depending on preference |
| 311 |
Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences(); |
| 312 |
int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE); |
| 313 |
String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR); |
| 314 |
boolean useSpaces = XMLCorePreferenceNames.SPACE.equals(indentCharPref); |
| 315 |
|
| 316 |
for (int i = 0; i <= indentationWidth; i++) { |
| 317 |
StringBuffer prefix = new StringBuffer(); |
| 318 |
boolean appendTab = false; |
| 319 |
|
| 320 |
if (useSpaces) { |
| 321 |
for (int j = 0; j + i < indentationWidth; j++) |
| 322 |
prefix.append(' '); |
| 323 |
|
| 324 |
if (i != 0) |
| 325 |
appendTab = true; |
| 326 |
} else { |
| 327 |
for (int j = 0; j < i; j++) |
| 328 |
prefix.append(' '); |
| 329 |
|
| 330 |
if (i != indentationWidth) |
| 331 |
appendTab = true; |
| 332 |
} |
| 333 |
|
| 334 |
if (appendTab) { |
| 335 |
prefix.append('\t'); |
| 336 |
vector.add(prefix.toString()); |
| 337 |
// remove the tab so that indentation - tab is also an indent |
| 338 |
// prefix |
| 339 |
prefix.deleteCharAt(prefix.length() - 1); |
| 340 |
} |
| 341 |
vector.add(prefix.toString()); |
| 342 |
} |
| 343 |
|
| 344 |
vector.add(""); //$NON-NLS-1$ |
| 345 |
|
| 346 |
return (String[]) vector.toArray(new String[vector.size()]); |
| 347 |
} |
| 295 |
} |
348 |
} |