org.eclipse.swt.widgets.Widget.getData()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(193)

本文整理了Java中org.eclipse.swt.widgets.Widget.getData()方法的一些代码示例,展示了Widget.getData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Widget.getData()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Widget
类名称:Widget
方法名:getData

Widget.getData介绍

[英]Returns the application defined widget data associated with the receiver, or null if it has not been set. The widget data is a single, unnamed field that is stored with every widget.

Applications may put arbitrary objects in this field. If the object stored in the widget data needs to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so.
[中]返回与接收器关联的应用程序定义的小部件数据,如果尚未设置,则返回null。小部件数据是一个单独的未命名字段,与每个小部件一起存储。
应用程序可以在该字段中放置任意对象。如果在处理小部件时需要通知存储在小部件数据中的对象,则应用程序有责任将Dispose事件挂接到小部件上并执行此操作。

代码示例

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public void widgetSelected(SelectionEvent e) {
  Object device = e.widget.getData("Device");
  if (device instanceof TranscodeTarget) {
    selectedTranscodeTarget = (TranscodeTarget) device;
  } else if (device instanceof DeviceTemplate) {
    selectedDeviceTemplate = (DeviceTemplate) device;
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

@Override
  public void widgetSelected(SelectionEvent event) {
    setAccessModifier((String)event.widget.getData());
  }
});

代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui

public boolean isEnabled(DropTargetEvent event) {
  Object target= event.item != null ? event.item.getData() : null;
  if (target == null)
    return false;
  return target instanceof IJavaElement || target instanceof IResource;
}

代码示例来源:origin: com.diffplug.durian/durian-swt

@SuppressWarnings("unchecked")
@Nullable
public T getNullable(Widget widget) {
  if (key == null) {
    return (T) widget.getData();
  } else {
    return (T) widget.getData(key);
  }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.css.swt

/**
 * Return true if the given widget can be styled
 *
 * @param widget
 *            the widget
 * @return true if the widget can be styled
 */
protected boolean isStylable(Widget widget) {
  // allows widgets to be selectively excluded from styling
  return !Boolean.TRUE.equals(widget.getData("org.eclipse.e4.ui.css.disabled")); //$NON-NLS-1$
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void handleEvent(Event event) {
    final boolean rename_it = ((Boolean) event.widget.getData("rename")).booleanValue();
    final boolean retarget_it = ((Boolean) event.widget.getData("retarget")).booleanValue();
    final boolean batch = ((Boolean) event.widget.getData("batch")).booleanValue();
    rename(tv, all_files.toArray( new Object[all_files.size()]), rename_it, retarget_it, batch);
  }
};

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public void widgetSelected(SelectionEvent e) {
  String id = (String) e.widget.getData("Plugin.viewID");
  showEntryByID(id);
}

代码示例来源:origin: BiglySoftware/BiglyBT

private static String getID(Widget widget) {
  if (null != widget && !widget.isDisposed()) {
    Object id = widget.getData(KEY_MENU_ID);
    if (null != id) {
      return id.toString();
    }
  }
  return "";
}

代码示例来源:origin: BiglySoftware/BiglyBT

public static int getEnablementKeys(Widget widget) {
  if (null != widget && !widget.isDisposed()) {
    Object keys = widget.getData(KEY_ENABLEMENT);
    if (keys instanceof Integer) {
      return ((Integer) keys).intValue();
    }
  }
  return -1;
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

@Override
  public void widgetSelected(SelectionEvent event) {
    final Integer selectedModifier= (Integer)event.widget.getData();
    fSettings.put(ACCESS_MODIFIER, selectedModifier.intValue());
    setVisibility(selectedModifier);
  }
});

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

@Override
  public void widgetSelected(SelectionEvent event) {
    visibilityChangeListener.visibilityChanged(((Integer)event.widget.getData()).intValue());
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

@Override
  public void widgetSelected(SelectionEvent event) {
    buttonPressed(((Integer) event.widget.getData()).intValue());
  }
});

代码示例来源:origin: org.eclipse.platform/org.eclipse.debug.ui

@Override
  public void close(CTabFolderEvent event) {
    if (event.item.getData() instanceof MemoryViewTab) {
      RenderingViewPane.this.removeMemoryRendering(((MemoryViewTab) event.item.getData()).getRendering());
    }
    event.doit = false;
  }
});

代码示例来源:origin: org.eclipse.e4.ui.css/swt

public String getCSSStyle() {
  Widget widget = getWidget();
  // TODO should have key in CSSSWT
  Object id = widget.getData("style");
  if (id != null)
    return id.toString();
  return null;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

@Override
  public void widgetSelected(SelectionEvent event) {
    fRefactoring.setVisibility(((Integer)event.widget.getData()).intValue());
  }
});

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * Handles a tree expand event from the SWT widget.
 *
 * @param event
 *            the SWT tree event
 */
protected void handleTreeExpand(TreeEvent event) {
  createChildren(event.item);
  if (event.item.getData() != null) {
    fireTreeExpanded(new TreeExpansionEvent(this, event.item.getData()));
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Handles a tree expand event from the SWT widget.
 *
 * @param event
 *            the SWT tree event
 */
protected void handleTreeExpand(TreeEvent event) {
  createChildren(event.item);
  if (event.item.getData() != null) {
    fireTreeExpanded(new TreeExpansionEvent(this, event.item.getData()));
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui

@Override
public void mouseEnter(MouseEvent e) {
  Item item= (Item) ((Widget) e.getSource()).getData();
  if (item != null)
    item.selected();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

@Override
  public void widgetDefaultSelected(SelectionEvent e) {
    NonNLSElement element= (NonNLSElement)e.item.getData();
    ExternalizeWizard.open(element.cu, getShell());
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

@Override
  public void widgetDisposed(DisposeEvent e) {
    Item item= (Item) ((Widget) e.getSource()).getData();
    item.deselect();
    item.canvas= null;
    item.fAnnotation= null;
    item.oldStyles= null;
    ((Widget) e.getSource()).setData(null);
  }
}

相关文章

Widget类方法