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

x33g5p2x  于2022-01-29 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(103)

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

Shell.getData介绍

暂无

代码示例

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

/**
 * Returns whether the given widget is a TrayDialog.
 *
 * @param widget the widget to check
 * @return whether or not the widget is a TrayDialog
 */
private boolean isTrayDialog(Widget widget) {
  return (widget instanceof Shell && ((Shell)widget).getData() instanceof TrayDialog);
}

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

public void handleCheck(Shell s) {
  if (s != lastActiveShell) {
    lastActiveShell = s;
    checkActivePart();
    IWorkbenchWindow window = null;
    if (s.getData() instanceof WorkbenchWindow) {
      window = (IWorkbenchWindow) s.getData();
    }
    updateWindows(window);
  }
}

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

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
  if (receiver instanceof Shell) {
    Shell shell = (Shell) receiver;
    if (shell.isDisposed()) {
      return false;
    }
    Object shellData = shell.getData();
    if (shellData instanceof FilteredPreferenceDialog) {
      FilteredPreferenceDialog propertyDialog = (FilteredPreferenceDialog) shellData;
      IPreferencePage currentPage = propertyDialog.getCurrentPage();
      if (currentPage != null) {
        return currentPage.getClass().getName().equals(expectedValue);
      }
    }
  }
  return false;
}

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

public static void restoreDefaultImage(Shell shell) {
  Image defaultImage = (Image) shell.getData(DEFAULT_IMAGE);
  if (defaultImage != null) {
    shell.setImage(defaultImage.isDisposed() ? null : defaultImage);
  }
}

代码示例来源:origin: org.xworker/xworker_swt

@Override
public void shellClosed(ShellEvent event) {
  Shell shell = (Shell) event.widget;
  shell.setVisible(false);
  Control parent = (Control) shell.getData("shell_parent");
  PoolableControlFactory.returnControl(parent, "xworker.swt.xworker.HtmlEditor/@shell", shell);
  event.doit = false;
}

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

public DragHost(Shell shell) {
  dragWindow = (MWindow) shell.getData(AbstractPartRenderer.OWNING_ME);
  baseWindow = (MWindow) shell.getParent().getData(
      AbstractPartRenderer.OWNING_ME);
  dragElement = dragWindow.getChildren().get(0);
}

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

public DragHost(Shell shell) {
  dragWindow = (MWindow) shell.getData(AbstractPartRenderer.OWNING_ME);
  baseWindow = (MWindow) shell.getParent().getData(
      AbstractPartRenderer.OWNING_ME);
  dragElement = dragWindow.getChildren().get(0);
}

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

/**
 * Return the window for the given shell or the currently active window if
 * one could not be determined.
 *
 * @param shellToCheck
 *            the shell to search on
 * @return the window for the given shell or the currently active window if
 *         one could not be determined
 * @since 3.2
 */
public static IWorkbenchWindow getWorkbenchWindowForShell(Shell shellToCheck) {
  IWorkbenchWindow workbenchWindow = null;
  while (workbenchWindow == null && shellToCheck != null) {
    if (shellToCheck.getData() instanceof IWorkbenchWindow) {
      workbenchWindow = (IWorkbenchWindow) shellToCheck.getData();
    } else {
      shellToCheck = (Shell) shellToCheck.getParent();
    }
  }
  if (workbenchWindow == null) {
    workbenchWindow = PlatformUI.getWorkbench()
        .getActiveWorkbenchWindow();
  }
  return workbenchWindow;
}

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

/**
 * Returns whether or not the help tray can handle the given shell. In some
 * cases the help tray is not appropriate for shells that are too short and
 * not resizable. In these cases infopops are used.
 * 
 * @param shell the shell to check
 * @return whether or not the help tray is appropriate for the hsell
 */
public static boolean isAppropriateFor(Shell shell) {
  if (shell != null && !shell.isDisposed() && shell.isVisible()) {
    Object data = shell.getData();
    return (data instanceof TrayDialog && (shell.getSize().y >= MINIMUM_HEIGHT || (shell.getStyle() & SWT.RESIZE) != 0));
  }
  return false;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-tokenization-ui

@Override
  public void mouseDoubleClick(MouseEvent e) {
    
    Object dialog = getData("dialog");
    
    if (dialog instanceof AbstractBaseDialog) {
    
      // Double-click closes the dialog only if it has a parent, and is not a top-level window
      Shell shell = ((AbstractBaseDialog) dialog).getShell();
      Object parent = shell.getData("parent");
      if (parent != null)
        if (dialog instanceof INotifiable)
          ((INotifiable) dialog).exec(this, AbstractBaseDialog.NOTIFICATION_OK, null);
    }                
  }
});

代码示例来源:origin: org.eclipse.pde/org.eclipse.pde.runtime

@Override
public void build(ScrolledForm form, SpyFormToolkit toolkit, ExecutionEvent event) {
  final Shell shell = HandlerUtil.getActiveShell(event);
  Object object = shell.getData();
  if (object == null)
    return;
  Class<?> clazz = object.getClass();
  Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR);
  section.clientVerticalSpacing = 9;
  section.setText(PDERuntimeMessages.SpyDialog_activeShell_title);
  FormText text = toolkit.createFormText(section, true);
  section.setClient(text);
  TableWrapData td = new TableWrapData();
  td.align = TableWrapData.FILL;
  td.grabHorizontal = true;
  section.setLayoutData(td);
  StringBuilder buffer = new StringBuilder();
  buffer.append("<form>"); //$NON-NLS-1$
  buffer.append(toolkit.createClassSection(text, PDERuntimeMessages.SpyDialog_activeShell_desc, clazz));
  buffer.append("</form>"); //$NON-NLS-1$
  text.setText(buffer.toString(), true, false);
}

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

private static void setActiveWorkbenchWindow(WindowRef windowRef) {
  windowRef.window= null;
  Display display= Display.getCurrent();
  if (display == null)
    return;
  Control shell= display.getActiveShell();
  while (shell != null) {
    Object data= shell.getData();
    if (data instanceof IWorkbenchWindow) {
      windowRef.window= (IWorkbenchWindow)data;
      return;
    }
    shell= shell.getParent();
  }
  Shell shells[]= display.getShells();
  for (int i= 0; i < shells.length; i++) {
    Object data= shells[i].getData();
    if (data instanceof IWorkbenchWindow) {
      windowRef.window= (IWorkbenchWindow)data;
      return;
    }
  }
}

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

private Menu createTabMenu(CTabFolder folder, MPart part) {
  Shell shell = folder.getShell();
  Menu cachedMenu = (Menu) shell.getData(SHELL_CLOSE_EDITORS_MENU);
  if (cachedMenu == null) {
    cachedMenu = new Menu(folder);
    shell.setData(SHELL_CLOSE_EDITORS_MENU, cachedMenu);
  } else {
    for (MenuItem item : cachedMenu.getItems()) {
      item.dispose();
    }
  }
  final Menu menu = cachedMenu;
  populateTabMenu(menu, part);
  return menu;
}

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

public SplitFeedbackOverlay(Shell dragShell, Rectangle rect, int side, float pct,
    boolean enclosed, boolean modified) {
  outerRect = rect;
  curSide = side;
  ratio = pct;
  feedbackShell = new Shell(dragShell, SWT.NO_TRIM);
  feedbackShell.setBounds(dragShell.getBounds());
  MWindow winModel = (MWindow) dragShell.getData(AbstractPartRenderer.OWNING_ME);
  stylingEngine = winModel.getContext().get(IStylingEngine.class);
  // Show the appropriate feedback rectangles
  setFeedback(enclosed, modified);
  defineRegion();
}

代码示例来源:origin: org.xworker/xworker_swt

public void run(){
    ActionContext actionContext = new ActionContext();
    actionContext.put("parent", control.getShell());
    actionContext.put("message", control.getData("toolTip"));		
    Shell toolTipShell = (Shell) PoolableControlFactory.borrowControl(control.getShell(), "xworker.ide.worldExplorer.swt.util.HtmlToolTip/@shell", actionContext);
    if(toolTipShell == null){
      return;
    }
    
    control.setData("toolTipShell", toolTipShell);
    toolTipShell.setData("listsner", listsner);
    Point point = new Point(x, y);
    toolTipShell.setLocation(point);                        
    
    ActionContainer actions = (ActionContainer) toolTipShell.getData("actions");
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("message", control.getData("toolTip"));
    actions.doAction("setContent", param);									
    //toolTipShell.setVisible(true);
    //toolTipShell.dispose();
    
    //加载网页后(setContent)后触发ToolTipStatusListener的completed方法
    //ToolTipShell是在UtilBrowserCreator的html_edit_content1方法中打开显示的
  }
});

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

/**
 * If in a dialog-opening step, will add the appropriate listener for
 * the cheatsheet to jump into the dialog's tray once opened.
 *
 * Should be called before executing any action.
 */
private void hookDialogListener() {
  /*
   * org.eclipse.help.ui is an optional dependency; only perform this
   * step is this plugin is present.
   */
  if (!inDialog && isInDialogItem() && (Platform.getBundle("org.eclipse.help.ui") != null)) { //$NON-NLS-1$
    listener = event -> {
      if (isTrayDialog(event.widget)) {
        dialogOpened((TrayDialog) ((Shell) event.widget).getData());
      }
    };
    Display.getCurrent().addFilter(SWT.Show, listener);
  }
}

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

public SplitFeedbackOverlay(Shell dragShell, Rectangle rect, int side, float pct,
    boolean enclosed, boolean modified) {
  outerRect = rect;
  curSide = side;
  ratio = pct;
  feedbackShell = new Shell(dragShell, SWT.NO_TRIM | SWT.ON_TOP);
  feedbackShell.setBounds(dragShell.getBounds());
  feedbackShell.setData(DragAndDropUtil.IGNORE_AS_DROP_TARGET, DragAndDropUtil.IGNORE_AS_DROP_TARGET);
  MWindow winModel = (MWindow) dragShell.getData(AbstractPartRenderer.OWNING_ME);
  stylingEngine = winModel.getContext().get(IStylingEngine.class);
  // Show the appropriate feedback rectangles
  setFeedback(enclosed, modified);
  defineRegion();
}

代码示例来源:origin: org.xworker/xworker_swt

public static void editButtonAction(ActionContext actionContext){
  Combo colorText = (Combo) actionContext.get("colorText");
  Shell shell =  (Shell) PoolableControlFactory.borrowControl(colorText.getShell(), 
            "xworker.swt.widgets.ColorDialog", actionContext);
        
  //shell.setLocation(text.getLocation().x, text.getLocation().y);
  ActionContainer ac = (ActionContainer) shell.getData("actions");			
  ColorDialog dialog = (ColorDialog) ac.doAction("getColorDialog");
  //dialog.setl
  int[] rgb = UtilSwt.parseRGB(colorText.getText());
  if(rgb != null){
    dialog.setRGB(new RGB(rgb[0], rgb[1], rgb[2]));
  }
  //dialog.
  RGB colorRgb = dialog.open();
  if(colorRgb != null){
    String rgbStr = UtilSwt.RGBToString(colorRgb);
    colorText.setText("\"" + rgbStr + "\"");
    //UtilSwt.setBackground(text, text.getText(), null);
  }
        
  colorText.setFocus();
}

代码示例来源:origin: org.xworker/xworker_swt

public static void editButtonAction(ActionContext actionContext){
  Combo colorText = (Combo) actionContext.get("colorText");   	
  Shell shell =  (Shell) PoolableControlFactory.borrowControl(colorText.getShell(), 
            "xworker.swt.widgets.ColorDialog", actionContext);
        
  //shell.setLocation(text.getLocation().x, text.getLocation().y);
  ActionContainer ac = (ActionContainer) shell.getData("actions");			
  ColorDialog dialog = (ColorDialog) ac.doAction("getColorDialog");
  //dialog.setl
  int[] rgb = UtilSwt.parseRGB(colorText.getText());
  if(rgb != null){
    dialog.setRGB(new RGB(rgb[0], rgb[1], rgb[2]));
  }
  //dialog.
  RGB colorRgb = dialog.open();
  if(colorRgb != null){
    String rgbStr = UtilSwt.RGBToString(colorRgb);
    colorText.setText("\"" + rgbStr + "\"");
    //UtilSwt.setBackground(text, text.getText(), null);
  }
        
  colorText.setFocus();
}

代码示例来源:origin: org.xworker/xworker_swt

public static void htmlToolBarSelection(ActionContext actionContext){
  Browser browser = (Browser) actionContext.get("browser");
  //取ViewForm数据对象的定义,要编辑的数据对象放置在ViewForm的数据对象中
  Object value = browser.getData();
  ActionContext ctx = new ActionContext();
  ctx.put("value", value);
  ctx.put("toolbarSet", actionContext.get("toolbarSet"));
  ctx.put("htmlThing", actionContext.get("htmlThing"));
  Shell newShell = (Shell) PoolableControlFactory.borrowControl(browser.getShell(), "xworker.swt.xworker.HtmlEditor/@shell", ctx);
  //虽然newShell创建时传入的parent是browser.getShell(),但是 newShell.getParent()还是空,所以设置到data中
  newShell.setData("shell_parent", browser.getShell());
  ActionContext newContext = (ActionContext) newShell.getData("_poolActionContext");
  newContext.put("value", value);
  newContext.put("toolbarSet", actionContext.get("toolbarSet"));
  newContext.put("htmlThing", actionContext.get("htmlThing"));
  ((ActionContainer) newContext.get("actions")).doAction("init");
  newShell.setVisible(true);
}

相关文章

微信公众号

最新文章

更多

Shell类方法