Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2010 Intalio, Inc. and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* David Carver (Intalio) - bug 256339 - initial API and implementation |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.wst.xsl.ui.internal.style; |
12 |
|
13 |
import java.util.ArrayList; |
14 |
|
15 |
import org.eclipse.jface.preference.IPreferenceStore; |
16 |
import org.eclipse.jface.text.Position; |
17 |
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; |
18 |
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; |
19 |
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; |
20 |
import org.eclipse.wst.sse.ui.internal.style.ISemanticHighlightingExtension; |
21 |
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; |
22 |
import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin; |
23 |
|
24 |
public abstract class AbstractXSLSemanticHighlighting implements |
25 |
ISemanticHighlightingExtension { |
26 |
|
27 |
public abstract String getStylePreferenceKey(); |
28 |
|
29 |
public String getBoldPreferenceKey() { |
30 |
return null; |
31 |
} |
32 |
|
33 |
public String getUnderlinePreferenceKey() { |
34 |
return null; |
35 |
} |
36 |
|
37 |
public String getStrikethroughPreferenceKey() { |
38 |
return null; |
39 |
} |
40 |
|
41 |
public String getItalicPreferenceKey() { |
42 |
return null; |
43 |
} |
44 |
|
45 |
public String getColorPreferenceKey() { |
46 |
return null; |
47 |
} |
48 |
|
49 |
public IPreferenceStore getPreferenceStore() { |
50 |
return XSLUIPlugin.getDefault().getPreferenceStore(); |
51 |
} |
52 |
|
53 |
public String getEnabledPreferenceKey() { |
54 |
return null; |
55 |
} |
56 |
|
57 |
public String getDisplayName() { |
58 |
return null; |
59 |
} |
60 |
|
61 |
public abstract Position[] consumes(IStructuredDocumentRegion region); |
62 |
|
63 |
protected Position[] createSemanticPositions(IStructuredDocumentRegion region, String regionType) { |
64 |
if (!region.getType().equals(DOMRegionContext.XML_TAG_NAME)) { |
65 |
return null; |
66 |
} |
67 |
|
68 |
Position p[] = null; |
69 |
ITextRegionList regionList = region.getRegions(); |
70 |
ITextRegion tagRegion = regionList.get(1); |
71 |
|
72 |
if (region.getFullText(tagRegion).contains("xsl:")) { //$NON-NLS-1$ |
73 |
ArrayList arrpos = new ArrayList(); |
74 |
for (int i = 0; i < regionList.size(); i++) { |
75 |
ITextRegion textRegion = regionList.get(i); |
76 |
if (textRegion.getType().equals(regionType)) { |
77 |
Position pos = new Position(region |
78 |
.getStartOffset(textRegion), textRegion.getLength()); |
79 |
arrpos.add(pos); |
80 |
} |
81 |
} |
82 |
p = new Position[arrpos.size()]; |
83 |
arrpos.toArray(p); |
84 |
} |
85 |
return p; |
86 |
} |
87 |
|
88 |
} |