本文整理了Java中org.eclipse.swt.widgets.Widget.getAdapter()
方法的一些代码示例,展示了Widget.getAdapter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Widget.getAdapter()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Widget
类名称:Widget
方法名:getAdapter
[英]Implementation of the Adaptable
interface.
IMPORTANT: This method is not part of the RWT public API. It is marked public only so that it can be shared within the packages provided by RWT. It should never be accessed from application code.
[中]Adaptable
接口的实现。
重要提示:此方法不是RWT公共API的一部分。它被标记为public,以便在RWT提供的包中共享。永远不要从应用程序代码中访问它。
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
@SuppressWarnings( "unchecked" )
public <T> T getAdapter( Class<T> adapter ) {
if( adapter == WidgetLCA.class ) {
return ( T )ScrollBarLCA.INSTANCE;
}
return super.getAdapter( adapter );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
@SuppressWarnings( "unchecked" )
public <T> T getAdapter( Class<T> adapter ) {
if( adapter == WidgetLCA.class ) {
return ( T )DropTargetLCA.INSTANCE;
}
return super.getAdapter( adapter );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
@SuppressWarnings( "unchecked" )
public <T> T getAdapter( Class<T> adapter ) {
if( adapter == WidgetLCA.class ) {
return ( T )DragSourceLCA.INSTANCE;
}
return super.getAdapter( adapter );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
public static ICellToolTipAdapter getAdapter( Widget widget ) {
Object adapter = widget.getAdapter( ICellToolTipAdapter.class );
return ( ICellToolTipAdapter )adapter;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
private static WidgetRemoteAdapter getRemoteAdapter( Widget widget ) {
return ( WidgetRemoteAdapter )widget.getAdapter( RemoteAdapter.class );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
@SuppressWarnings("unchecked")
public <T> T getAdapter( Class<T> adapter ) {
if( adapter == IToolTipAdapter.class ) {
if( toolTipAdapter == null ) {
toolTipAdapter = new IToolTipAdapter() {
@Override
public Point getLocation() {
return new Point( ToolTip.this.x, ToolTip.this.y );
}
};
}
return ( T )toolTipAdapter;
} else if( adapter == WidgetLCA.class ) {
return ( T )ToolTipLCA.INSTANCE;
}
return super.getAdapter( adapter );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
public static <T extends Widget> WidgetLCA<T> getLCA( T widget ) {
WidgetLCA<T> lca = widget.getAdapter( WidgetLCA.class );
if( lca == null ) {
throw new IllegalStateException( "Could not retrieve an instance of WidgetLCA." );
}
return lca;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
public static RemoteAdapter getAdapter( Widget widget ) {
RemoteAdapter adapter = widget.getAdapter( RemoteAdapter.class );
if( adapter == null ) {
throw new IllegalStateException( "Could not retrieve an instance of WidgetAdapter." );
}
return adapter;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
@SuppressWarnings("unchecked")
public <T> T getAdapter( Class<T> adapter ) {
T result = null;
if( adapter == IControlAdapter.class ) {
if( controlAdapter == null ) {
controlAdapter = new ControlAdapter();
}
result = ( T )controlAdapter;
} else if( adapter == ControlThemeAdapter.class ) {
result = ( T )super.getAdapter( ThemeAdapter.class );
} else {
result = super.getAdapter( adapter );
}
return result;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
private static void handleItems( Widget root, WidgetTreeVisitor visitor ) {
ItemProvider itemProvider = root.getAdapter( ItemProvider.class );
if( itemProvider != null ) {
itemProvider.provideItems( visitor );
} else {
IItemHolderAdapter<Item> itemHolder = root.getAdapter( IItemHolderAdapter.class );
if( itemHolder != null ) {
for( Item item : itemHolder.getItems() ) {
accept( item, visitor );
}
}
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
private static void handleToolTips( Widget root, WidgetTreeVisitor visitor ) {
IShellAdapter adapter = root.getAdapter( IShellAdapter.class );
if( adapter != null ) {
ToolTip[] toolTips = adapter.getToolTips();
for( ToolTip toolTip : toolTips ) {
visitor.visit( toolTip );
}
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
@SuppressWarnings( "unchecked" )
public <T> T getAdapter( Class<T> adapter ) {
T result;
if( adapter == RemoteAdapter.class ) {
// TODO [tb] : This way of getting the right id into the WidgetAdapter is obviously
// not ideal. Revise once Bug 397602 (Render operations in the order of their
// occurrence) is fixed.
if( widgetAdapter == null ) {
widgetAdapter = new WidgetRemoteAdapter( getProtocolId() );
}
result = ( T )widgetAdapter;
} else {
result = super.getAdapter( adapter );
}
return result;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
private static boolean hasRoundedBorderChanged( Widget widget ) {
Object adapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
IWidgetGraphicsAdapter graphicsAdapter = ( IWidgetGraphicsAdapter )adapter;
int width = graphicsAdapter.getRoundedBorderWidth();
Color color = graphicsAdapter.getRoundedBorderColor();
Rectangle radius = graphicsAdapter.getRoundedBorderRadius();
return
hasChanged( widget,
PROP_ROUNDED_BORDER_WIDTH,
Integer.valueOf( width ),
Integer.valueOf( 0 ) )
|| hasChanged( widget,
PROP_ROUNDED_BORDER_COLOR,
color,
null )
|| hasChanged( widget,
PROP_ROUNDED_BORDER_RADIUS,
radius,
DEF_ROUNDED_BORDER_RADIUS );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
private static boolean hasRoundedBorderChanged( final Widget widget ) {
Object adapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
IWidgetGraphicsAdapter graphicsAdapter = ( IWidgetGraphicsAdapter )adapter;
int width = graphicsAdapter.getRoundedBorderWidth();
Color color = graphicsAdapter.getRoundedBorderColor();
Rectangle radius = graphicsAdapter.getRoundedBorderRadius();
return
WidgetLCAUtil.hasChanged( widget,
PROP_ROUNDED_BORDER_WIDTH,
new Integer( width ),
new Integer( 0 ) )
|| WidgetLCAUtil.hasChanged( widget,
PROP_ROUNDED_BORDER_COLOR,
color,
null )
|| WidgetLCAUtil.hasChanged( widget,
PROP_ROUNDED_BORDER_RADIUS,
radius,
DEF_ROUNDED_BORDER_RADIUS );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
public static void preserveRoundedBorder( Widget widget ) {
Object adapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
if( adapter != null ) {
IWidgetGraphicsAdapter gfxAdapter = ( IWidgetGraphicsAdapter )adapter;
int width = gfxAdapter.getRoundedBorderWidth();
Color color = gfxAdapter.getRoundedBorderColor();
Rectangle radius = gfxAdapter.getRoundedBorderRadius();
RemoteAdapter widgetAdapter = getAdapter( widget );
widgetAdapter.preserve( PROP_ROUNDED_BORDER_WIDTH, Integer.valueOf( width ) );
widgetAdapter.preserve( PROP_ROUNDED_BORDER_COLOR, color );
widgetAdapter.preserve( PROP_ROUNDED_BORDER_RADIUS, radius );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
private static boolean hasBackgroundGradientChanged( final Widget widget ) {
Object adapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
IWidgetGraphicsAdapter graphicsAdapter = ( IWidgetGraphicsAdapter )adapter;
Color[] bgGradientColors = graphicsAdapter.getBackgroundGradientColors();
int[] bgGradientPercents = graphicsAdapter.getBackgroundGradientPercents();
boolean bgGradientVertical
= graphicsAdapter.isBackgroundGradientVertical();
return WidgetLCAUtil.hasChanged( widget,
PROP_BACKGROUND_GRADIENT_COLORS,
bgGradientColors,
null )
|| WidgetLCAUtil.hasChanged( widget,
PROP_BACKGROUND_GRADIENT_PERCENTS,
bgGradientPercents,
null )
|| WidgetLCAUtil.hasChanged( widget,
PROP_BACKGROUND_GRADIENT_VERTICAL,
new Boolean( bgGradientVertical ),
Boolean.FALSE );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
public static void preserveBackgroundGradient( Widget widget ) {
Object adapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
if( adapter != null ) {
IWidgetGraphicsAdapter gfxAdapter = ( IWidgetGraphicsAdapter )adapter;
Color[] bgGradientColors = gfxAdapter.getBackgroundGradientColors();
int[] bgGradientPercents = gfxAdapter.getBackgroundGradientPercents();
boolean bgGradientVertical = gfxAdapter.isBackgroundGradientVertical();
RemoteAdapter widgetAdapter = getAdapter( widget );
widgetAdapter.preserve( PROP_BACKGROUND_GRADIENT_COLORS, bgGradientColors );
widgetAdapter.preserve( PROP_BACKGROUND_GRADIENT_PERCENTS, bgGradientPercents );
widgetAdapter.preserve( PROP_BACKGROUND_GRADIENT_VERTICAL,
Boolean.valueOf( bgGradientVertical ) );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
private static boolean hasBackgroundGradientChanged( Widget widget ) {
IWidgetGraphicsAdapter graphicsAdapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
Color[] bgGradientColors = graphicsAdapter.getBackgroundGradientColors();
int[] bgGradientPercents = graphicsAdapter.getBackgroundGradientPercents();
boolean bgGradientVertical = graphicsAdapter.isBackgroundGradientVertical();
return hasChanged( widget,
PROP_BACKGROUND_GRADIENT_COLORS,
bgGradientColors,
null )
|| hasChanged( widget,
PROP_BACKGROUND_GRADIENT_PERCENTS,
bgGradientPercents,
null )
|| hasChanged( widget,
PROP_BACKGROUND_GRADIENT_VERTICAL,
Boolean.valueOf( bgGradientVertical ),
Boolean.FALSE );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
/**
* Preserves the rounded border properties of the specified widget.
*
* @param widget the widget whose rounded border properties to preserve
* @see #writeRoundedBorder(Widget)
* @since 1.3
*/
public static void preserveRoundedBorder( final Widget widget ) {
Object adapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
if( adapter != null ) {
IWidgetGraphicsAdapter gfxAdapter = ( IWidgetGraphicsAdapter )adapter;
int width = gfxAdapter.getRoundedBorderWidth();
Color color = gfxAdapter.getRoundedBorderColor();
Rectangle radius = gfxAdapter.getRoundedBorderRadius();
IWidgetAdapter widgetAdapter = WidgetUtil.getAdapter( widget );
widgetAdapter.preserve( PROP_ROUNDED_BORDER_WIDTH, new Integer( width ) );
widgetAdapter.preserve( PROP_ROUNDED_BORDER_COLOR, color );
widgetAdapter.preserve( PROP_ROUNDED_BORDER_RADIUS, radius );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
public static void renderRoundedBorder( Widget widget ) {
if( hasRoundedBorderChanged( widget ) ) {
Object adapter = widget.getAdapter( IWidgetGraphicsAdapter.class );
IWidgetGraphicsAdapter graphicAdapter = ( IWidgetGraphicsAdapter )adapter;
JsonValue args = JsonValue.NULL;
int width = graphicAdapter.getRoundedBorderWidth();
Color color = graphicAdapter.getRoundedBorderColor();
if( width > 0 && color != null ) {
Rectangle radius = graphicAdapter.getRoundedBorderRadius();
args = new JsonArray()
.add( width )
.add( toJson( color ) )
.add( radius.x )
.add( radius.y )
.add( radius.width )
.add( radius.height );
}
getRemoteObject( widget ).set( "roundedBorder", args );
}
}
内容来源于网络,如有侵权,请联系作者删除!