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 141376 Details for
Bug 282575
[CSS] CTabItem should support color, background-color
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]
CTabItem color attributes patch v1
bug282575-patch-v1.txt (text/plain), 12.76 KB, created by
Remy Suen
on 2009-07-12 12:45:17 EDT
(
hide
)
Description:
CTabItem color attributes patch v1
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2009-07-12 12:45:17 EDT
Size:
12.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.ui.css.swt >Index: src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyTextSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyTextSWTHandler.java,v >retrieving revision 1.2 >diff -u -r1.2 CSSPropertyTextSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyTextSWTHandler.java 27 Nov 2008 23:22:36 -0000 1.2 >+++ src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyTextSWTHandler.java 12 Jul 2009 16:38:55 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 Angelo Zerr and others. >+ * Copyright (c) 2008, 2009 Angelo Zerr 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 >@@ -16,6 +16,7 @@ > import org.eclipse.e4.ui.css.swt.CSSSWTConstants; > import org.eclipse.e4.ui.css.swt.helpers.SWTElementHelpers; > import org.eclipse.swt.custom.CTabFolder; >+import org.eclipse.swt.custom.CTabItem; > import org.eclipse.swt.events.VerifyEvent; > import org.eclipse.swt.events.VerifyListener; > import org.eclipse.swt.graphics.Color; >@@ -23,6 +24,7 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Text; >+import org.eclipse.swt.widgets.Widget; > import org.w3c.dom.css.CSSValue; > > public class CSSPropertyTextSWTHandler extends AbstractCSSPropertyTextHandler { >@@ -31,9 +33,9 @@ > > public boolean applyCSSProperty(Object element, String property, > CSSValue value, String pseudo, CSSEngine engine) throws Exception { >- Control control = SWTElementHelpers.getControl(element); >- if (control != null) { >- super.applyCSSProperty(control, property, value, pseudo, engine); >+ Widget widget = SWTElementHelpers.getWidget(element); >+ if (widget != null) { >+ super.applyCSSProperty(widget, property, value, pseudo, engine); > return true; > } > return false; >@@ -42,23 +44,28 @@ > > public String retrieveCSSProperty(Object element, String property, > String pseudo, CSSEngine engine) throws Exception { >- Control control = SWTElementHelpers.getControl(element); >- if (control != null) { >- return super.retrieveCSSProperty(control, property, pseudo, engine); >+ Widget widget = SWTElementHelpers.getWidget(element); >+ if (widget != null) { >+ return super.retrieveCSSProperty(widget, property, pseudo, engine); > } > return null; > } > > public void applyCSSPropertyColor(Object element, CSSValue value, > String pseudo, CSSEngine engine) throws Exception { >- Control control = (Control) element; >+ Widget widget = (Widget) element; > if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { >- Color newColor = (Color) engine.convert(value, Color.class, control >+ Color newColor = (Color) engine.convert(value, Color.class, widget > .getDisplay()); >- if (control instanceof CTabFolder && "selected".equals(pseudo)) { >- ((CTabFolder) control).setSelectionForeground(newColor); >- } else { >- control.setForeground(newColor); >+ if (widget instanceof CTabItem) { >+ CTabFolder folder = ((CTabItem) widget).getParent(); >+ if ("selected".equals(pseudo)) { >+ folder.setSelectionForeground(newColor); >+ } else { >+ folder.setForeground(newColor); >+ } >+ } else if (widget instanceof Control) { >+ ((Control) widget).setForeground(newColor); > } > } > } >@@ -116,8 +123,17 @@ > > public String retrieveCSSPropertyColor(Object element, String pseudo, > CSSEngine engine) throws Exception { >- Control control = (Control) element; >- Color color = control.getForeground(); >+ Widget widget = (Widget) element; >+ Color color = null; >+ if (widget instanceof CTabItem) { >+ if ("selected".equals(pseudo)) { >+ color = ((CTabItem) widget).getParent().getSelectionForeground(); >+ } else { >+ color = ((CTabItem) widget).getParent().getForeground(); >+ } >+ } else if (widget instanceof Control) { >+ color = ((Control) widget).getForeground(); >+ } > return engine.convert(color, Color.class, null); > } > >Index: src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBackgroundSWTHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/bundles/org.eclipse.e4.ui.css.swt/src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBackgroundSWTHandler.java,v >retrieving revision 1.4 >diff -u -r1.4 CSSPropertyBackgroundSWTHandler.java >--- src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBackgroundSWTHandler.java 27 May 2009 17:57:06 -0000 1.4 >+++ src/org/eclipse/e4/ui/css/swt/properties/css2/CSSPropertyBackgroundSWTHandler.java 12 Jul 2009 16:38:55 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 Angelo Zerr and others. >+ * Copyright (c) 2008, 2009 Angelo Zerr 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 >@@ -19,10 +19,12 @@ > import org.eclipse.e4.ui.css.swt.helpers.SWTElementHelpers; > import org.eclipse.e4.ui.css.swt.properties.GradientBackgroundListener; > import org.eclipse.swt.custom.CTabFolder; >+import org.eclipse.swt.custom.CTabItem; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Widget; > import org.w3c.dom.css.CSSValue; > > public class CSSPropertyBackgroundSWTHandler extends >@@ -32,9 +34,9 @@ > > public boolean applyCSSProperty(Object element, String property, > CSSValue value, String pseudo, CSSEngine engine) throws Exception { >- Control control = SWTElementHelpers.getControl(element); >- if (control != null) { >- super.applyCSSProperty(control, property, value, pseudo, engine); >+ Widget widget = SWTElementHelpers.getWidget(element); >+ if (widget != null) { >+ super.applyCSSProperty(widget, property, value, pseudo, engine); > return true; > } > return false; >@@ -43,9 +45,9 @@ > > public String retrieveCSSProperty(Object element, String property, > String pseudo, CSSEngine engine) throws Exception { >- Control control = SWTElementHelpers.getControl(element); >- if (control != null) { >- return super.retrieveCSSProperty(control, property, pseudo, engine); >+ Widget widget = SWTElementHelpers.getWidget(element); >+ if (widget != null) { >+ return super.retrieveCSSProperty(widget, property, pseudo, engine); > } > return null; > } >@@ -59,25 +61,31 @@ > */ > public void applyCSSPropertyBackgroundColor(Object element, CSSValue value, > String pseudo, CSSEngine engine) throws Exception { >- Control control = (Control) element; >+ Widget widget = (Widget) element; > if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { >- Color newColor = (Color) engine.convert(value, Color.class, control >+ Color newColor = (Color) engine.convert(value, Color.class, widget > .getDisplay()); >- if (control instanceof CTabFolder && "selected".equals(pseudo)) { >- ((CTabFolder) control).setSelectionBackground(newColor); >- } else { >- control.setBackground(newColor); >+ if (widget instanceof CTabItem) { >+ CTabFolder folder = ((CTabItem) widget).getParent(); >+ if ("selected".equals(pseudo)) { >+ folder.setSelectionBackground(newColor); >+ } else { >+ folder.setBackground(newColor); >+ } >+ } else if (widget instanceof Control) { >+ ((Control) widget).setBackground(newColor); > } > } else if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { > Gradient grad = (Gradient) engine.convert(value, Gradient.class, >- control.getDisplay()); >- if (control instanceof CTabFolder && "selected".equals(pseudo)) { >- ((CTabFolder) control).setSelectionBackground( >- CSSSWTColorHelper.getSWTColors(grad, control.getDisplay()), >+ widget.getDisplay()); >+ if (widget instanceof CTabItem && "selected".equals(pseudo)) { >+ CTabFolder folder = ((CTabItem) widget).getParent(); >+ folder.setSelectionBackground( >+ CSSSWTColorHelper.getSWTColors(grad, folder.getDisplay()), > CSSSWTColorHelper.getPercents(grad), > true); >- } else { >- GradientBackgroundListener.handle(control, grad); >+ } else if (widget instanceof Control) { >+ GradientBackgroundListener.handle((Control) widget, grad); > } > } > } >@@ -121,8 +129,17 @@ > > public String retrieveCSSPropertyBackgroundColor(Object element, > String pseudo, CSSEngine engine) throws Exception { >- Control control = (Control) element; >- Color color = control.getBackground(); >+ Widget widget = (Widget) element; >+ Color color = null; >+ if (widget instanceof CTabItem) { >+ if ("selected".equals(pseudo)) { >+ color = ((CTabItem) widget).getParent().getSelectionBackground(); >+ } else { >+ color = ((CTabItem) widget).getParent().getBackground(); >+ } >+ } else if (widget instanceof Control) { >+ color = ((Control) widget).getBackground(); >+ } > return engine.convert(color, Color.class, null); > } > >#P org.eclipse.e4.ui.tests.css.swt >Index: src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java,v >retrieving revision 1.15 >diff -u -r1.15 CTabFolderTest.java >--- src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java 8 Jul 2009 15:45:45 -0000 1.15 >+++ src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java 12 Jul 2009 16:38:55 -0000 >@@ -72,16 +72,6 @@ > assertEquals(BLUE, folderToTest.getForeground().getRGB()); > } > >- public void testSelectedPseudo() throws Exception { >- CTabFolder folderToTest = createTestCTabFolder( >- "CTabFolder { color: #FFFFFF; background-color: #0000FF }\n" + >- "CTabFolder:selected { color: #FF0000; background-color: #00FF00 }"); >- assertEquals(WHITE, folderToTest.getForeground().getRGB()); >- assertEquals(BLUE, folderToTest.getBackground().getRGB()); >- assertEquals(RED, folderToTest.getSelectionForeground().getRGB()); >- assertEquals(GREEN, folderToTest.getSelectionBackground().getRGB()); >- } >- > //See GradientTest for testing background gradient > > public void testFontRegular() throws Exception { >Index: src/org/eclipse/e4/ui/tests/css/swt/CTabItemTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CTabItemTest.java,v >retrieving revision 1.2 >diff -u -r1.2 CTabItemTest.java >--- src/org/eclipse/e4/ui/tests/css/swt/CTabItemTest.java 8 Jul 2009 15:45:45 -0000 1.2 >+++ src/org/eclipse/e4/ui/tests/css/swt/CTabItemTest.java 12 Jul 2009 16:38:55 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.swt.custom.CTabFolder; > import org.eclipse.swt.custom.CTabItem; > import org.eclipse.swt.graphics.FontData; >+import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.layout.FillLayout; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; >@@ -538,4 +539,46 @@ > } > } > } >+ >+ public void testBackground() throws Exception { >+ CTabFolder folder = createTestTabFolder("CTabItem { background-color: #0000ff }"); >+ assertEquals(new RGB(0, 0, 255), folder.getBackground().getRGB()); >+ >+ for (int i = 0; i < folder.getItemCount(); i++) { >+ assertEquals("#0000ff", engine.retrieveCSSProperty(folder >+ .getItem(i), "background-color", null)); >+ } >+ } >+ >+ public void testSelectionBackground() throws Exception { >+ CTabFolder folder = createTestTabFolder("CTabItem:selected { background-color: #00ff00 }"); >+ assertEquals(new RGB(0, 255, 0), folder.getSelectionBackground() >+ .getRGB()); >+ >+ for (int i = 0; i < folder.getItemCount(); i++) { >+ assertEquals("#00ff00", engine.retrieveCSSProperty(folder >+ .getItem(i), "background-color", "selected")); >+ } >+ } >+ >+ public void testForeground() throws Exception { >+ CTabFolder folder = createTestTabFolder("CTabItem { color: #0000ff }"); >+ assertEquals(new RGB(0, 0, 255), folder.getForeground().getRGB()); >+ >+ for (int i = 0; i < folder.getItemCount(); i++) { >+ assertEquals("#0000ff", engine.retrieveCSSProperty(folder >+ .getItem(i), "color", null)); >+ } >+ } >+ >+ public void testSelectionForeground() throws Exception { >+ CTabFolder folder = createTestTabFolder("CTabItem:selected { color: #00ff00 }"); >+ assertEquals(new RGB(0, 255, 0), folder.getSelectionForeground() >+ .getRGB()); >+ >+ for (int i = 0; i < folder.getItemCount(); i++) { >+ assertEquals("#00ff00", engine.retrieveCSSProperty(folder >+ .getItem(i), "color", "selected")); >+ } >+ } > }
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 282575
:
141376
|
141377
|
141579