下面列出了怎么用org.eclipse.ui.forms.FormColors的API类实例代码及写法,或者点击链接到github查看源代码。
public ScrolledPageContent(Composite parent, int style)
{
super(parent, style);
setFont(parent.getFont());
FormColors colors = new FormColors(parent.getDisplay());
colors.setBackground(null);
colors.setForeground(null);
fToolkit = new FormToolkit(colors);
setExpandHorizontal(true);
setExpandVertical(true);
Composite body = new Composite(this, SWT.NONE);
body.setFont(parent.getFont());
setContent(body);
}
public AppEngineDeployPreferencesPanel(Composite parent, IProject project,
IGoogleLoginService loginService, Runnable layoutChangedHandler, boolean requireValues,
ProjectRepository projectRepository, DeployPreferences model) {
super(parent, SWT.NONE);
this.project = project;
this.layoutChangedHandler = Preconditions.checkNotNull(layoutChangedHandler);
this.requireValues = requireValues;
this.projectRepository = projectRepository;
this.model = model;
FormColors colors = new FormColors(getDisplay());
colors.setBackground(null);
colors.setForeground(null);
formToolkit = new FormToolkit(colors);
createCredentialSection(loginService);
createProjectIdSection();
setupAccountEmailDataBinding();
setupProjectSelectorDataBinding();
createCenterArea();
createAdvancedSection();
setupTextFieldDataBinding(bucket, "bucket", new BucketNameValidator());
observables.addObservablesFromContext(bindingContext, true, true);
Dialog.applyDialogFont(this);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(this);
}
private Color createColor(int color1, int color2, int ratio, Display display) {
RGB rgb1= display.getSystemColor(color1).getRGB();
RGB rgb2= display.getSystemColor(color2).getRGB();
RGB blend= FormColors.blend(rgb2, rgb1, ratio);
return new Color(display, blend);
}
private Color createColor(int color1, int color2, int ratio, Display display) {
RGB rgb1= display.getSystemColor(color1).getRGB();
RGB rgb2= display.getSystemColor(color2).getRGB();
RGB blend= FormColors.blend(rgb2, rgb1, ratio);
return new Color(display, blend);
}
private Color createColor( int color1, int color2, int ratio,
Display display )
{
RGB rgb1 = display.getSystemColor( color1 ).getRGB( );
RGB rgb2 = display.getSystemColor( color2 ).getRGB( );
RGB blend = FormColors.blend( rgb2, rgb1, ratio );
return new Color( display, blend );
}
private Color createColor( int color1, int color2, int ratio,
Display display )
{
RGB rgb1 = display.getSystemColor( color1 ).getRGB( );
RGB rgb2 = display.getSystemColor( color2 ).getRGB( );
RGB blend = FormColors.blend( rgb2, rgb1, ratio );
return new Color( display, blend );
}
public void setWidgetBackgroundColor(Color color) {
widgetBackground = color;
RGB black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK).getRGB();
RGB white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE).getRGB();
defaultGradientStart = factory.getColors().createColor("TabbedPropertyList.defaultTabGradientStart", //$NON-NLS-1$
FormColors.blend(widgetBackground.getRGB(), FormColors.blend(white, widgetNormalShadow.getRGB(), 20),
60));
defaultGradientEnd = factory.getColors().createColor("TabbedPropertyList.defaultTabGradientEnd", //$NON-NLS-1$
FormColors.blend(widgetBackground.getRGB(), widgetNormalShadow.getRGB(), 40));
bottomNavigationElementShadowStroke1 = factory.getColors().createColor("TabbedPropertyList.tabShadowStroke1", //$NON-NLS-1$
FormColors.blend(black, widgetBackground.getRGB(), 10));
bottomNavigationElementShadowStroke2 = factory.getColors().createColor("TabbedPropertyList.tabShadowStroke2", //$NON-NLS-1$
FormColors.blend(black, widgetBackground.getRGB(), 5));
hoverGradientStart = factory.getColors().createColor("TabbedPropertyList.hoverBackgroundGradientStart", //$NON-NLS-1$
FormColors.blend(white, widgetBackground.getRGB(), 20));
hoverGradientEnd = factory.getColors().createColor("TabbedPropertyList.hoverBackgroundGradientEnd", //$NON-NLS-1$
FormColors.blend(widgetNormalShadow.getRGB(), widgetBackground.getRGB(), 10));
indentedDefaultBackground = factory.getColors().createColor("TabbedPropertyList.indentedDefaultBackground", //$NON-NLS-1$
FormColors.blend(white, widgetBackground.getRGB(), 10));
indentedHoverBackground = factory.getColors().createColor("TabbedPropertyList.indentedHoverBackground", //$NON-NLS-1$
FormColors.blend(white, widgetBackground.getRGB(), 75));
}
public void setWidgetNormalShadowColor(Color color) {
widgetNormalShadow = color;
RGB white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE).getRGB();
navigationElementShadowStroke = factory.getColors().createColor("TabbedPropertyList.shadowStroke", //$NON-NLS-1$
FormColors.blend(white, widgetNormalShadow.getRGB(), 55));
}
public void resetSectionToolBarColors() {
TabbedPropertySheetWidgetFactory f = new TabbedPropertySheetWidgetFactory();
FormColors defaultColors = f.getColors();
defaultColors.initializeSectionToolBarColors();
FormColors colors = factory.getColors();
colors.createColor(IFormColors.H_GRADIENT_START, defaultColors.getColor(IFormColors.H_GRADIENT_START).getRGB());
colors.createColor(IFormColors.H_GRADIENT_END, defaultColors.getColor(IFormColors.H_GRADIENT_END).getRGB());
colors.createColor(IFormColors.H_BOTTOM_KEYLINE1,
defaultColors.getColor(IFormColors.H_BOTTOM_KEYLINE1).getRGB());
colors.createColor(IFormColors.H_BOTTOM_KEYLINE2,
defaultColors.getColor(IFormColors.H_BOTTOM_KEYLINE2).getRGB());
}
/**
* On first call, gets a formColors instance; on subsequent calls, returns that instance.
*
* @param display the display
* @return a formColors instance
*/
public FormColors getFormColors(Display display) {
if (null == formColors) {
FormColors tempToAvoidSyncIssues = new FormColors(display);
tempToAvoidSyncIssues.markShared(); // keep it from being disposed early
formColors = tempToAvoidSyncIssues;
}
return formColors;
}
/**
* Initialize the colours used.
*/
private void initColours( )
{
/*
* Colour 3 COLOR_LIST_BACKGROUND
*/
listBackground = Display.getCurrent( )
.getSystemColor( SWT.COLOR_LIST_BACKGROUND );
/*
* Colour 13 COLOR_WIDGET_BACKGROUND
*/
widgetBackground = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND );
/*
* Colour 15 COLOR_WIDGET_DARK_SHADOW
*/
widgetDarkShadow = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WIDGET_DARK_SHADOW );
/*
* Colour 16 COLOR_WIDGET_FOREGROUND
*/
widgetForeground = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WIDGET_FOREGROUND );
/*
* Colour 19 COLOR_WIDGET_NORMAL_SHADOW
*/
widgetNormalShadow = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW );
RGB infoBackground = Display.getCurrent( )
.getSystemColor( SWT.COLOR_INFO_BACKGROUND )
.getRGB( );
RGB white = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WHITE )
.getRGB( );
RGB black = Display.getCurrent( )
.getSystemColor( SWT.COLOR_BLACK )
.getRGB( );
/*
* gradient in the default tab: start colour WIDGET_NORMAL_SHADOW 100% +
* white 20% + INFO_BACKGROUND 60% end colour WIDGET_NORMAL_SHADOW 100%
* + INFO_BACKGROUND 40%
*/
defaultGradientStart = factory.getColors( )
.createColor( "TabbedPropertyList.defaultTabGradientStart", //$NON-NLS-1$
FormColors.blend( infoBackground,
FormColors.blend( white,
widgetNormalShadow.getRGB( ),
20 ),
60 ) );
defaultGradientEnd = factory.getColors( )
.createColor( "TabbedPropertyList.defaultTabGradientEnd", //$NON-NLS-1$
FormColors.blend( infoBackground,
widgetNormalShadow.getRGB( ),
40 ) );
navigationElementShadowStroke = factory.getColors( )
.createColor( "TabbedPropertyList.shadowStroke", //$NON-NLS-1$
FormColors.blend( white,
widgetNormalShadow.getRGB( ),
55 ) );
bottomNavigationElementShadowStroke1 = factory.getColors( )
.createColor( "TabbedPropertyList.tabShadowStroke1", //$NON-NLS-1$
FormColors.blend( black, widgetBackground.getRGB( ), 10 ) );
bottomNavigationElementShadowStroke2 = factory.getColors( )
.createColor( "TabbedPropertyList.tabShadowStroke2", //$NON-NLS-1$
FormColors.blend( black, widgetBackground.getRGB( ), 5 ) );
/*
* gradient in the hover tab: start colour WIDGET_BACKGROUND 100% +
* white 20% end colour WIDGET_BACKGROUND 100% + WIDGET_NORMAL_SHADOW
* 10%
*/
hoverGradientStart = factory.getColors( )
.createColor( "TabbedPropertyList.hoverBackgroundGradientStart", //$NON-NLS-1$
FormColors.blend( white, widgetBackground.getRGB( ), 20 ) );
hoverGradientEnd = factory.getColors( )
.createColor( "TabbedPropertyList.hoverBackgroundGradientEnd", //$NON-NLS-1$
FormColors.blend( widgetNormalShadow.getRGB( ),
widgetBackground.getRGB( ),
10 ) );
indentedDefaultBackground = factory.getColors( )
.createColor( "TabbedPropertyList.indentedDefaultBackground", //$NON-NLS-1$
FormColors.blend( white, widgetBackground.getRGB( ), 10 ) );
indentedHoverBackground = factory.getColors( )
.createColor( "TabbedPropertyList.indentedHoverBackground", //$NON-NLS-1$
FormColors.blend( white, widgetBackground.getRGB( ), 75 ) );
}
/**
* Initialize the colours used.
*/
private void initColours( )
{
/*
* Colour 3 COLOR_LIST_BACKGROUND
*/
listBackground = Display.getCurrent( )
.getSystemColor( SWT.COLOR_LIST_BACKGROUND );
/*
* Colour 13 COLOR_WIDGET_BACKGROUND
*/
widgetBackground = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WIDGET_BACKGROUND );
/*
* Colour 16 COLOR_WIDGET_FOREGROUND
*/
widgetForeground = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WIDGET_FOREGROUND );
/*
* Colour 19 COLOR_WIDGET_NORMAL_SHADOW
*/
widgetNormalShadow = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WIDGET_NORMAL_SHADOW );
RGB white = Display.getCurrent( )
.getSystemColor( SWT.COLOR_WHITE )
.getRGB( );
/*
* Mimic palette view look and feel.
*/
defaultGradientStart = factory.getColors( )
.createColor( "TabbedPropertyList.defaultTabGradientStart", //$NON-NLS-1$
FormColors.blend( ColorConstants.button.getRGB( ),
ColorConstants.listBackground.getRGB( ),
85 ) );
defaultGradientEnd = factory.getColors( )
.createColor( "TabbedPropertyList.defaultTabGradientEnd", //$NON-NLS-1$
FormColors.blend( ColorConstants.button.getRGB( ),
ColorConstants.buttonDarker.getRGB( ),
45 ) );
/*
* gradient in the hover tab: start colour WIDGET_BACKGROUND 100% +
* white 20% end colour WIDGET_BACKGROUND 100% + WIDGET_NORMAL_SHADOW
* 10%
*/
hoverGradientStart = factory.getColors( )
.createColor( "TabbedPropertyList.hoverBackgroundGradientStart", //$NON-NLS-1$
FormColors.blend( white, widgetBackground.getRGB( ), 20 ) );
hoverGradientEnd = factory.getColors( )
.createColor( "TabbedPropertyList.hoverBackgroundGradientEnd", //$NON-NLS-1$
FormColors.blend( widgetNormalShadow.getRGB( ),
widgetBackground.getRGB( ),
10 ) );
indentedDefaultBackground = factory.getColors( )
.createColor( "TabbedPropertyList.indentedDefaultBackground", //$NON-NLS-1$
FormColors.blend( white, widgetBackground.getRGB( ), 10 ) );
indentedHoverBackground = factory.getColors( )
.createColor( "TabbedPropertyList.indentedHoverBackground", //$NON-NLS-1$
FormColors.blend( white, widgetBackground.getRGB( ), 75 ) );
}
/**
* Initialize the colours used in the list.
*/
public void initColours() {
/*
* Colour 3 COLOR_LIST_BACKGROUND
*/
listBackground = Display.getCurrent().getSystemColor(
SWT.COLOR_LIST_BACKGROUND);
/*
* Colour 13 COLOR_WIDGET_BACKGROUND
*/
widgetBackground = Display.getCurrent().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND);
/*
* Colour 15 COLOR_WIDGET_DARK_SHADOW
*/
widgetDarkShadow = Display.getCurrent().getSystemColor(
SWT.COLOR_WIDGET_DARK_SHADOW);
/*
* Colour 16 COLOR_WIDGET_FOREGROUND
*/
widgetForeground = Display.getCurrent().getSystemColor(
SWT.COLOR_WIDGET_FOREGROUND);
/*
* Colour 19 COLOR_WIDGET_NORMAL_SHADOW
*/
widgetNormalShadow = Display.getCurrent().getSystemColor(
SWT.COLOR_WIDGET_NORMAL_SHADOW);
RGB white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)
.getRGB();
RGB black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)
.getRGB();
/*
* gradient in the default tab: start colour WIDGET_NORMAL_SHADOW 100% +
* white 20% + WIDGET_BACKGROUND 60% end colour WIDGET_NORMAL_SHADOW
* 100% + WIDGET_BACKGROUND 40%
*/
defaultGradientStart = factory.getColors().createColor(
"TabbedPropertyList.defaultTabGradientStart", //$NON-NLS-1$
FormColors.blend(widgetBackground.getRGB(), FormColors.blend(white,
widgetNormalShadow.getRGB(), 20), 60));
defaultGradientEnd = factory.getColors().createColor(
"TabbedPropertyList.defaultTabGradientEnd", //$NON-NLS-1$
FormColors.blend(widgetBackground.getRGB(), widgetNormalShadow.getRGB(),
40));
navigationElementShadowStroke = factory.getColors().createColor(
"TabbedPropertyList.shadowStroke", //$NON-NLS-1$
FormColors.blend(white, widgetNormalShadow.getRGB(), 55));
bottomNavigationElementShadowStroke1 = factory.getColors().createColor(
"TabbedPropertyList.tabShadowStroke1", //$NON-NLS-1$
FormColors.blend(black, widgetBackground.getRGB(), 10));
bottomNavigationElementShadowStroke2 = factory.getColors().createColor(
"TabbedPropertyList.tabShadowStroke2", //$NON-NLS-1$
FormColors.blend(black, widgetBackground.getRGB(), 5));
/*
* gradient in the hover tab: start colour WIDGET_BACKGROUND 100% +
* white 20% end colour WIDGET_BACKGROUND 100% + WIDGET_NORMAL_SHADOW
* 10%
*/
hoverGradientStart = factory.getColors().createColor(
"TabbedPropertyList.hoverBackgroundGradientStart", //$NON-NLS-1$
FormColors.blend(white, widgetBackground.getRGB(), 20));
hoverGradientEnd = factory.getColors().createColor(
"TabbedPropertyList.hoverBackgroundGradientEnd", //$NON-NLS-1$
FormColors.blend(widgetNormalShadow.getRGB(), widgetBackground
.getRGB(), 10));
indentedDefaultBackground = factory.getColors().createColor(
"TabbedPropertyList.indentedDefaultBackground", //$NON-NLS-1$
FormColors.blend(white, widgetBackground.getRGB(), 10));
indentedHoverBackground = factory.getColors().createColor(
"TabbedPropertyList.indentedHoverBackground", //$NON-NLS-1$
FormColors.blend(white, widgetBackground.getRGB(), 75));
}