下面列出了org.eclipse.swt.widgets.Composite#isDisposed ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* A recursive method to find out if a composite is an ancestor of a
* control.
*
* @param control
* @param composite
* @return true if the composite is an ancestor, false otherwise.
*/
protected static boolean containsControl(Control control,
Composite composite) {
if (composite != null && !composite.isDisposed()) {
Control[] children = composite.getChildren();
for (Control child : children) {
if (!child.isDisposed()) {
if (child == control) {
return true;
} else if (child instanceof Composite) {
return containsControl(control, (Composite) child);
}
}
}
}
return false;
}
@Override
public Rectangle getBoundsOnDisplay() {
if (isDisposed() || tableRow == null) {
return null;
}
Rectangle bounds = getBoundsRaw();
if (bounds == null) {
return null;
}
TableViewPainted tv = ((TableViewPainted) tableRow.getView());
if (tv == null) {
return null;
}
Composite c = tv.getTableComposite();
if (c == null || c.isDisposed()) {
return null;
}
Point pt = c.toDisplay(bounds.x, bounds.y);
bounds.x = pt.x;
bounds.y = pt.y;
bounds.height = getHeight();
bounds.width = getWidthRaw();
return bounds;
}
protected void
build()
{
Composite parent = (Composite)instance.getProperty( UpdateCheckInstance.PT_UI_PARENT_SWT_COMPOSITE );
if ( parent != null ){
if (parent.isDisposed()) {
throw( new RuntimeException( "cancelled" ));
}
build( parent );
}else{
throw( new RuntimeException( "borkeroo" ));
}
}
private void obfuscatedImage(Composite c, Image image) {
if (c == null || c.isDisposed() || !c.isVisible()) {
return;
}
Control[] children = c.getChildren();
for (Control childControl : children) {
if (!childControl.isVisible()) {
continue;
}
ObfuscateImage oi = (ObfuscateImage) childControl.getData("ObfuscateImage");
if (oi != null) {
oi.obfuscatedImage(image);
continue;
}
if (childControl instanceof Composite) {
obfuscatedImage((Composite) childControl, image);
}
}
}
/**
* Sets the control that is shown when the item is expanded.
*
* @param control
* the new control (or null)
*
* @exception IllegalArgumentException
* <ul>
* <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
* <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
* </ul>
* @exception SWTException
* <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
public void setControl(final Composite control) {
if (control != null) {
if (control.isDisposed()) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
if (control.getParent() != parent) {
SWT.error(SWT.ERROR_INVALID_PARENT);
}
}
this.control = control;
if (control != null) {
control.setVisible(expanded);
final int headerHeight = parent.bandHeight;
control.setBounds(x + BORDER, y + headerHeight, Math.max(0, width - 2 * BORDER),
Math.max(0, height + BORDER));
control.setBackground(IGamaColors.PARAMETERS_BACKGROUND.color());
}
}
protected final static boolean containsControl(Control control, Composite composite) {
if(composite != null && !composite.isDisposed()) {
Control[] children = composite.getChildren();
for(Control child : children) {
if(!child.isDisposed()) {
if(child == control) {
return true;
} else if(child instanceof Composite){
return containsControl(control, (Composite) child);
}
}
}
}
return false;
}
private static boolean isTimeAlignedView(IViewPart view) {
if (view instanceof TmfView && view instanceof ITmfTimeAligned) {
Composite parentComposite = ((TmfView) view).getParentComposite();
if (parentComposite != null && !parentComposite.isDisposed()) {
return true;
}
}
return view instanceof TmfView && view instanceof ITmfTimeAligned;
}
void showItem(final ParameterExpandItem item) {
final Composite control = item.control;
if (control != null && !control.isDisposed()) {
item.setImage(item.expanded ? GamaIcons.create(IGamaIcons.SMALL_COLLAPSE).image()
: GamaIcons.create(IGamaIcons.SMALL_EXPAND).image());
control.setVisible(item.expanded);
}
item.redraw();
final int index = indexOf(item);
layoutItems(index + 1, true);
final Event ev = new Event();
ev.item = this;
notifyListeners(SWT.Resize, ev);
}
/**
* Free all allocated system resources.
*/
public void dispose( )
{
cleanUpTriggers( );
if ( _iun != null )
{
Object obj = _iun.peerInstance( );
if ( obj instanceof Composite )
{
Composite jc = (Composite) obj;
if ( _eh != null )
{
if ( !jc.isDisposed( ) )
{
// We can't promise to remove all the old
// swtEventHandler
// due to SWT limitation here, so be sure to just attach
// the
// update_notifier only to one renderer.
jc.removeMouseListener( _eh );
jc.removeMouseMoveListener( _eh );
jc.removeMouseTrackListener( _eh );
jc.removeKeyListener( _eh );
jc.removeFocusListener( _eh );
}
_eh.dispose( );
_eh = null;
}
}
}
}
public void show() {
SelectedContentManager.clearCurrentlySelectedContent();
UIFunctionsSWT uif = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uif != null) {
//uif.refreshIconBar(); // needed?
uif.refreshTorrentMenu();
}
SWTSkinObject skinObject = getSkinObjectMaster();
if (skinObject == null) {
return;
}
skinObject.setVisible(true);
if (skinObject instanceof SWTSkinObjectContainer) {
SWTSkinObjectContainer container = (SWTSkinObjectContainer) skinObject;
Composite composite = container.getComposite();
if (composite != null && !composite.isDisposed()) {
composite.setVisible(true);
composite.moveAbove(null);
//composite.setFocus();
//container.getParent().relayout();
composite.getParent().layout();
}
// This causes double show because createSkinObject already calls show
//container.triggerListeners(SWTSkinObjectListener.EVENT_SHOW);
}
Composite c = getComposite();
if (c != null && !c.isDisposed()) {
c.setData("BaseMDIEntry", this);
c.setVisible(true);
c.getParent().layout();
}
try {
// In theory, c.setVisible() will trigger TYPE_SHOWN, but let's
// call it anyway (it will be ignored if focus is already gained)
triggerEvent(UISWTViewEvent.TYPE_SHOWN, null);
} catch (Exception e) {
Debug.out(e);
}
setToolbarVisibility(hasToolbarEnableers());
}
private static boolean isDisposedView(TmfView view) {
Composite parentComposite = (view).getParentComposite();
return parentComposite != null && parentComposite.isDisposed();
}
@PostConstruct
public void postConstruct(Composite parent, INxtService nxt,
IUserService userService, IStylingEngine engine, UISynchronize sync) {
/* Interval that checks for needs_refresh flag */
refreshPoll = new Runnable() {
@Override
public void run() {
if (needs_refresh) {
if (mainComposite != null && !mainComposite.isDisposed()
&& mainComposite.isVisible()) {
needs_refresh = false;
refresh();
}
}
Display display = Display.getCurrent();
if (display != null && !display.isDisposed()) {
display.timerExec(REFRESH_INTERVAL, this);
}
}
};
mainComposite = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).spacing(5, 2).margins(0, 0)
.applyTo(mainComposite);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
.applyTo(mainComposite);
paginationContainer = new PaginationContainer(mainComposite, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
.applyTo(paginationContainer);
viewer = new RecentBlocksViewer(paginationContainer.getViewerParent(), nxt,
engine, userService, sync, ContactsService.getInstance());
paginationContainer.setTableViewer(viewer, 100);
/* If Nxt is scanning we can wait for TOPIC_BLOCK_SCANNER_FINISHED */
if (!nxt.isScanning()) {
needs_refresh = true;
}
/* Start the poller */
parent.getDisplay().timerExec(10, refreshPoll);
}
@PostConstruct
public void postConstruct(Composite parent, INxtService nxt,
IUserService userService, IStylingEngine engine, UISynchronize sync) {
/* Interval that checks for needs_refresh flag */
refreshPoll = new Runnable() {
@Override
public void run() {
if (needs_refresh) {
if (mainComposite != null && !mainComposite.isDisposed()
&& mainComposite.isVisible()) {
needs_refresh = false;
refresh();
}
}
Display display = Display.getCurrent();
if (display != null && !display.isDisposed()) {
display.timerExec(REFRESH_INTERVAL, this);
}
}
};
mainComposite = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).spacing(5, 2).margins(0, 0)
.applyTo(mainComposite);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
.applyTo(mainComposite);
paginationContainer = new PaginationContainer(mainComposite, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
.applyTo(paginationContainer);
viewer = new RecentTransactionsViewer(
paginationContainer.getViewerParent(), nxt, engine, userService, sync,
ContactsService.getInstance());
paginationContainer.setTableViewer(viewer, 100);
/* If Nxt is scanning we can wait for TOPIC_BLOCK_SCANNER_FINISHED */
if (!nxt.isScanning()) {
needs_refresh = true;
}
/* Start the poller */
parent.getDisplay().timerExec(10, refreshPoll);
}