summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSalvador Zalapa2013-05-16 12:37:44 (EDT)
committerNick Sandonato2013-06-12 16:19:20 (EDT)
commit257ab1564753b48238b509d564bd7421acf08426 (patch)
tree726b14b8cdeda64da3d90100f0235e8b6b374d8a
parent07297d3f285530630c6b6712f1c0306911b700c8 (diff)
downloadwebtools.sourceediting-257ab1564753b48238b509d564bd7421acf08426.zip
webtools.sourceediting-257ab1564753b48238b509d564bd7421acf08426.tar.gz
webtools.sourceediting-257ab1564753b48238b509d564bd7421acf08426.tar.bz2
Bug 120649 - [editor] double-click selection inconsistent when selecting rgb value (#808080 vs #a08080)
-rw-r--r--bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java14
-rw-r--r--bundles/org.eclipse.wst.css.ui/plugin.xml4
-rw-r--r--bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/doubleclick/CSSDoubleClickStrategy.java49
-rw-r--r--bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java14
4 files changed, 79 insertions, 2 deletions
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java
index 68b4cbf..dc11f6d 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/StructuredTextViewerConfigurationJSP.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2012 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -45,6 +45,7 @@ import org.eclipse.jst.jsp.ui.internal.style.LineStyleProviderForJSP;
import org.eclipse.jst.jsp.ui.internal.style.java.LineStyleProviderForJava;
import org.eclipse.jst.jsp.ui.internal.style.jspel.LineStyleProviderForJSPEL;
import org.eclipse.wst.css.core.text.ICSSPartitions;
+import org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS;
import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML;
import org.eclipse.wst.html.core.text.IHTMLPartitions;
import org.eclipse.wst.html.ui.StructuredTextViewerConfigurationHTML;
@@ -88,6 +89,7 @@ public class StructuredTextViewerConfigurationJSP extends StructuredTextViewerCo
private StructuredTextViewerConfiguration fHTMLSourceViewerConfiguration;
private JavaSourceViewerConfiguration fJavaSourceViewerConfiguration;
private StructuredTextViewerConfiguration fXMLSourceViewerConfiguration;
+ private StructuredTextViewerConfiguration fCSSSourceViewerConfiguration;
private ILabelProvider fStatusLineLabelProvider;
/**
@@ -229,6 +231,9 @@ public class StructuredTextViewerConfigurationJSP extends StructuredTextViewerCo
else if (contentType == IJSPPartitions.JSP_DEFAULT)
// JSP (just treat like html)
strategy = getHTMLSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, IHTMLPartitions.HTML_DEFAULT);
+ else if (contentType == ICSSPartitions.STYLE)
+ //CSS style
+ strategy = getCSSSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, contentType);
else
strategy = super.getDoubleClickStrategy(sourceViewer, contentType);
@@ -268,6 +273,13 @@ public class StructuredTextViewerConfigurationJSP extends StructuredTextViewerCo
return fJavaSourceViewerConfiguration;
}
+ private StructuredTextViewerConfiguration getCSSSourceViewerConfiguration() {
+ if (fCSSSourceViewerConfiguration == null) {
+ fCSSSourceViewerConfiguration = new StructuredTextViewerConfigurationCSS();
+ }
+ return fCSSSourceViewerConfiguration;
+ }
+
public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
LineStyleProvider[] providers = null;
diff --git a/bundles/org.eclipse.wst.css.ui/plugin.xml b/bundles/org.eclipse.wst.css.ui/plugin.xml
index 4af0509..5a6f284 100644
--- a/bundles/org.eclipse.wst.css.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.css.ui/plugin.xml
@@ -57,6 +57,10 @@
type="activecontexts"
value="org.eclipse.wst.css.core.csssource, org.eclipse.wst.sse.comments"
target="org.eclipse.wst.css.core.csssource" />
+ <doubleClickStrategy
+ class="org.eclipse.wst.css.ui.doubleclick.CSSDoubleClickStrategy"
+ target="org.eclipse.wst.css.STYLE">
+ </doubleClickStrategy>
</extension>
<extension point="org.eclipse.ui.contexts">
diff --git a/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/doubleclick/CSSDoubleClickStrategy.java b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/doubleclick/CSSDoubleClickStrategy.java
new file mode 100644
index 0000000..c61d658
--- /dev/null
+++ b/bundles/org.eclipse.wst.css.ui/src/org/eclipse/wst/css/ui/doubleclick/CSSDoubleClickStrategy.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *
+ *******************************************************************************/
+
+package org.eclipse.wst.css.ui.doubleclick;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+
+public class CSSDoubleClickStrategy extends DefaultTextDoubleClickStrategy {
+
+ protected IRegion findExtendedDoubleClickSelection(IDocument document, int offset) {
+ IRegion word= super.findExtendedDoubleClickSelection(document, offset);
+ if (word != null)
+ return word;
+ word = findWord(document, offset);
+ IRegion line;
+ try {
+ line = document.getLineInformationOfOffset(offset);
+ if (offset == line.getOffset() + line.getLength())
+ return null;
+ int start= word.getOffset();
+ int end= start + word.getLength();
+ if (start > 0 && document.getChar(start - 1) == '#'){
+ start --;
+ }
+ else if (end == offset && end == start + 1 && end < line.getOffset() + line.getLength() && document.getChar(end) == '#') {
+ return findExtendedDoubleClickSelection(document, offset + 1);
+ }
+ if (start == end)
+ return null;
+ return new Region(start, end - start);
+ } catch (BadLocationException e) {
+ return null;
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java
index 59fc466..17e7f97 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/StructuredTextViewerConfigurationHTML.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2012 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -27,6 +27,7 @@ import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.wst.css.core.text.ICSSPartitions;
+import org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS;
import org.eclipse.wst.css.ui.internal.style.LineStyleProviderForEmbeddedCSS;
import org.eclipse.wst.html.core.internal.HTMLCorePlugin;
import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
@@ -79,6 +80,7 @@ public class StructuredTextViewerConfigurationHTML extends StructuredTextViewerC
* One instance per configuration
*/
private StructuredTextViewerConfiguration fXMLSourceViewerConfiguration;
+ private StructuredTextViewerConfiguration fCSSSourceViewerConfiguration;
private ILabelProvider fStatusLineLabelProvider;
/**
@@ -155,6 +157,9 @@ public class StructuredTextViewerConfigurationHTML extends StructuredTextViewerC
// use xml's doubleclick strategy
return getXMLSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, IXMLPartitions.XML_DEFAULT);
}
+ else if (contentType == ICSSPartitions.STYLE)
+ //CSS style
+ return getCSSSourceViewerConfiguration().getDoubleClickStrategy(sourceViewer, contentType);
else
return super.getDoubleClickStrategy(sourceViewer, contentType);
@@ -269,6 +274,13 @@ public class StructuredTextViewerConfigurationHTML extends StructuredTextViewerC
return fXMLSourceViewerConfiguration;
}
+ private StructuredTextViewerConfiguration getCSSSourceViewerConfiguration() {
+ if (fCSSSourceViewerConfiguration == null) {
+ fCSSSourceViewerConfiguration = new StructuredTextViewerConfigurationCSS();
+ }
+ return fCSSSourceViewerConfiguration;
+ }
+
protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
Map targets = super.getHyperlinkDetectorTargets(sourceViewer);
targets.put(ContentTypeIdForHTML.ContentTypeID_HTML, null);