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

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

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

ToolBar.getItemCount介绍

[英]Returns the number of items contained in the receiver.
[中]返回接收器中包含的项目数。

代码示例

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

/**
 * Returns whether or not children exist for the Application Window's
 * toolbar control.
 * <p>
 * @return boolean true if children exist, false otherwise
 */
protected boolean toolBarChildrenExist() {
  Control toolControl = getToolBarControl();
  if (toolControl instanceof ToolBar) {
    return ((ToolBar) toolControl).getItemCount() > 0;
  }
  return false;
}

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

@Override
public int getLength() {
  return getToolBar().getItemCount();
}

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

/**
 * Returns whether or not children exist for the Application Window's
 * toolbar control.
 * <p>
 * @return boolean true if children exist, false otherwise
 */
protected boolean toolBarChildrenExist() {
  Control toolControl = getToolBarControl();
  if (toolControl instanceof ToolBar) {
    return ((ToolBar) toolControl).getItemCount() > 0;
  }
  return false;
}

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

/**
 * Returns whether or not children exist for the Application Window's
 * toolbar control.
 * <p>
 * @return boolean true if children exist, false otherwise
 */
protected boolean toolBarChildrenExist() {
  Control toolControl = getToolBarControl();
  if (toolControl instanceof ToolBar) {
    return ((ToolBar) toolControl).getItemCount() > 0;
  }
  return false;
}

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

public int getLength() {
  return getToolBar().getItemCount();
}

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

public int getItemCount() {
  ToolBar toolBar = getControl();
  if (toolBar == null || toolBar.isDisposed()) {
    return 0;
  }
  return toolBar.getItemCount();
}

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

@Override
public int getItemCount() {
  ToolBar toolBar = getControl();
  if (toolBar == null || toolBar.isDisposed()) {
    return 0;
  }
  return toolBar.getItemCount();
}

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

@Override
public int getItemCount() {
  ToolBar toolBar = getControl();
  if (toolBar == null || toolBar.isDisposed()) {
    return 0;
  }
  return toolBar.getItemCount();
}

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

@Override
 public boolean matches( Widget widget ) {
  if( widget instanceof ToolItem ) {
   ToolItem item = ( ToolItem )widget;
   ToolBar toolBar = item.getParent();
   return toolBar.getItem( toolBar.getItemCount() - 1 ) == item;
  }
  return false;
 }
};

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

@Override
  public void getName(AccessibleEvent e) {
    if (0 <= e.childID && e.childID < perspSwitcherToolbar.getItemCount()) {
      ToolItem item = perspSwitcherToolbar.getItem(e.childID);
      if (item != null) {
        e.result = item.getToolTipText();
      }
    }
  }
});

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

this( checkNull( parent ), checkStyle( style ), parent.getItemCount() );

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

super (parent, checkStyle (style));
this.parent = parent;
parent.createItem (this, parent.getItemCount ());

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

/**
 * Returns the item at the given, zero-relative index in the
 * receiver. Throws an exception if the index is out of range.
 *
 * @param index the index of the item to return
 * @return the item at the given index
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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 ToolItem getItem (int index) {
  checkWidget();
  if (!(0 <= index && index < getItemCount())) error (SWT.ERROR_INVALID_RANGE);
  return getItems()[index];
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x

/**
 * Returns the item at the given, zero-relative index in the
 * receiver. Throws an exception if the index is out of range.
 *
 * @param index the index of the item to return
 * @return the item at the given index
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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 ToolItem getItem (int index) {
  checkWidget();
  if (!(0 <= index && index < getItemCount())) error (SWT.ERROR_INVALID_RANGE);
  return getItems()[index];
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

/**
 * Returns the item at the given, zero-relative index in the
 * receiver. Throws an exception if the index is out of range.
 *
 * @param index the index of the item to return
 * @return the item at the given index
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</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 ToolItem getItem (int index) {
  checkWidget();
  if (!(0 <= index && index < getItemCount())) error (SWT.ERROR_INVALID_RANGE);
  return getItems()[index];
}

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

public void getName(AccessibleEvent e) {
    if (e.childID != ACC.CHILDID_SELF) {
      Accessible accessible = (Accessible) e
          .getSource();
      ToolBar toolBar = (ToolBar) accessible
          .getControl();
      if (0 <= e.childID
          && e.childID < toolBar.getItemCount()) {
        ToolItem item = toolBar.getItem(e.childID);
        if (item != null) {
          e.result = item.getToolTipText();
        }
      }
    }
  }
});

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

/**
 * This is a HACK ! Due to compatibility restrictions we have the case where
 * we <b>must</b> leave 'empty' toolbars in the trim. This code detects this
 * particular scenario and hides any TB's of this type...
 *
 * @param te
 *            The proposed trim element
 * @return <code>true</code> iff this element represents an empty managed
 *         TB.
 */
private boolean hideManagedTB(MTrimElement te) {
  if (!(te instanceof MToolBar) || !(te.getRenderer() instanceof ToolBarManagerRenderer))
    return false;
  if (!(te.getWidget() instanceof Composite))
    return false;
  Composite teComp = (Composite) te.getWidget();
  Control[] kids = teComp.getChildren();
  if (kids.length != 1 || !(kids[0] instanceof ToolBar))
    return false;
  boolean barVisible = ((ToolBar) kids[0]).getItemCount() > 0;
  // HACK! The trim dragging code uses the visible attribute as well
  // this is a local 'lock' to prevent the layout from messing with it
  if (!te.getTags().contains("LockVisibility")) { //$NON-NLS-1$
    te.setVisible(barVisible);
  }
  return !barVisible;
}

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

/**
 * This is a HACK ! Due to compatibility restrictions we have the case where
 * we <b>must</b> leave 'empty' toolbars in the trim. This code detects this
 * particular scenario and hides any TB's of this type...
 * 
 * @param te
 *            The proposed trim element
 * @return <code>true</code> iff this element represents an empty managed
 *         TB.
 */
private boolean hideManagedTB(MTrimElement te) {
  if (!(te instanceof MToolBar)
      || !(te.getRenderer() instanceof ToolBarManagerRenderer))
    return false;
  if (!(te.getWidget() instanceof Composite))
    return false;
  Composite teComp = (Composite) te.getWidget();
  Control[] kids = teComp.getChildren();
  if (kids.length != 1 || !(kids[0] instanceof ToolBar))
    return false;
  boolean barVisible = ((ToolBar) kids[0]).getItemCount() > 0;
  // HACK! The trim dragging code uses the visible attribute as well
  // this is a local 'lock' to prevent the layout from messing with it
  if (!te.getTags().contains("LockVisibility")) { //$NON-NLS-1$
    te.setVisible(barVisible);
  }
  return !barVisible;
}

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

@Override
public Control remove(ToolBar parent, Control control) {
  for(ToolItem item : parent.getItems()){
    if(item.getControl() == control){
      Thing parentThing = Designer.getThing(parent);
      Thing itemThing = Designer.getThing(item);                
      parentThing.removeChild(itemThing);
      parentThing.save();
      
      ItemInfo itemInfo = getItemIndex(parent, control);
      int index = itemInfo != null ? itemInfo.index : -1;
      item.dispose();
      control.dispose();
      ToolBarCreator.initToolBar(parent);
      
      
      if(index != -1){
        if(index > 0 && parent.getItemCount() > index - 1){
          return parent.getItem(index - 1).getControl();
        }if(parent.getItemCount() > index){
          return parent.getItem(index).getControl();
        }
      }
      
      return parent;		
    }
  }
  
  return null;
}

代码示例来源:origin: ajermakovics/eclipse-instasearch

itemInsertIndex = filterBar.getItemCount(); // so we insert after separator

相关文章

ToolBar类方法