|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2010 IBM Corporation and others. All rights reserved. This |
| 3 |
* program and the accompanying materials are made available under the terms of |
| 4 |
* the Eclipse Public License v1.0 which accompanies this distribution, and is |
| 5 |
* available at http://www.eclipse.org/legal/epl-v10.html |
| 6 |
* |
| 7 |
* Contributors: IBM Corporation - initial API and implementation |
| 8 |
*******************************************************************************/ |
| 9 |
package org.eclipse.e4.ui.css.swt.properties.custom; |
| 10 |
|
| 11 |
import org.eclipse.e4.ui.widgets.CTabFolder; |
| 12 |
import org.eclipse.e4.ui.widgets.CTabFolderRenderer; |
| 13 |
|
| 14 |
import java.lang.reflect.Method; |
| 15 |
|
| 16 |
import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
| 17 |
import org.eclipse.e4.core.contexts.IEclipseContext; |
| 18 |
import org.eclipse.e4.ui.css.core.dom.properties.Gradient; |
| 19 |
import org.eclipse.e4.ui.css.core.dom.properties.ICSSPropertyHandler; |
| 20 |
import org.eclipse.e4.ui.css.core.engine.CSSEngine; |
| 21 |
import org.eclipse.e4.ui.css.swt.helpers.CSSSWTColorHelper; |
| 22 |
import org.eclipse.e4.ui.css.swt.properties.AbstractCSSPropertySWTHandler; |
| 23 |
import org.eclipse.swt.graphics.Color; |
| 24 |
import org.eclipse.swt.widgets.Control; |
| 25 |
import org.w3c.dom.css.CSSValue; |
| 26 |
|
| 27 |
public class CSSPropertySelectedTabsSWTHandler extends AbstractCSSPropertySWTHandler { |
| 28 |
|
| 29 |
|
| 30 |
public static final ICSSPropertyHandler INSTANCE = new CSSPropertySelectedTabsSWTHandler(); |
| 31 |
|
| 32 |
@Override |
| 33 |
protected void applyCSSProperty(Control control, String property, |
| 34 |
CSSValue value, String pseudo, CSSEngine engine) throws Exception { |
| 35 |
if (!(control instanceof CTabFolder)) return; |
| 36 |
if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { |
| 37 |
Gradient grad = (Gradient) engine.convert(value, Gradient.class, control.getDisplay()); |
| 38 |
CTabFolder folder = ((CTabFolder) control); |
| 39 |
Color[] colors = CSSSWTColorHelper.getSWTColors(grad, folder.getDisplay(), engine); |
| 40 |
int[] percents = CSSSWTColorHelper.getPercents(grad); |
| 41 |
folder.setSelectionBackground(colors, percents, true); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
@Override |
| 47 |
protected String retrieveCSSProperty(Control control, String property, |
| 48 |
String pseudo, CSSEngine engine) throws Exception { |
| 49 |
// TODO Auto-generated method stub |
| 50 |
return null; |
| 51 |
} |
| 52 |
|
| 53 |
} |