Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Widget


    realMenu.notifyListeners(SWT.Show, null);

    final Listener passThrough = new Listener() {
      public void handleEvent(Event event) {
        if (!event.widget.isDisposed()) {
          Widget realItem = (Widget) event.widget.getData();
          if (!realItem.isDisposed()) {
            int style = event.widget.getStyle();
            if (event.type == SWT.Selection
                && ((style & (SWT.TOGGLE | SWT.CHECK | SWT.RADIO)) != 0)
                && realItem instanceof MenuItem) {
              ((MenuItem) realItem)
                  .setSelection(((MenuItem) event.widget)
                      .getSelection());
            }
            event.widget = realItem;
            realItem.notifyListeners(event.type, event);
          }
        }
      }
    };

    MenuItem[] items = realMenu.getItems();
    for (int i = 0; i < items.length; i++) {
      final MenuItem realItem = items[i];
      final MenuItem proxyItem = new MenuItem(proxy, realItem.getStyle());
      proxyItem.setData(realItem);
      proxyItem.setAccelerator(realItem.getAccelerator());
      proxyItem.setEnabled(realItem.getEnabled());
      proxyItem.setImage(realItem.getImage());
      proxyItem.setSelection(realItem.getSelection());
      proxyItem.setText(realItem.getText());

      // pass through any events
      proxyItem.addListener(SWT.Selection, passThrough);
      proxyItem.addListener(SWT.Arm, passThrough);
      proxyItem.addListener(SWT.Help, passThrough);

      final Menu itemMenu = realItem.getMenu();
      if (itemMenu != null) {
        // create a proxy for any sub menu items
        final Menu subMenu = new Menu(proxy);
        subMenu.setData(itemMenu);
        proxyItem.setMenu(subMenu);
View Full Code Here


    /* (non-Javadoc)
     * Method declared on ICheckable.
     */
    public boolean getChecked(Object element) {
        Widget widget = findItem(element);
        if (widget instanceof TreeItem) {
      return ((TreeItem) widget).getChecked();
    }
        return false;
    }
View Full Code Here

     * @param element the element
     * @return <code>true</code> if the element is grayed,
     *   and <code>false</code> if not grayed
     */
    public boolean getGrayed(Object element) {
        Widget widget = findItem(element);
        if (widget instanceof TreeItem) {
            return ((TreeItem) widget).getGrayed();
        }
        return false;
    }
View Full Code Here

    /* (non-Javadoc)
     * Method declared on ICheckable.
     */
    public boolean setChecked(Object element, boolean state) {
        Assert.isNotNull(element);
        Widget widget = internalExpand(element, false);
        if (widget instanceof TreeItem) {
            ((TreeItem) widget).setChecked(state);
            return true;
        }
        return false;
View Full Code Here

     * @return <code>true</code> if the gray state could be set,
     *  and <code>false</code> otherwise
     */
    public boolean setGrayed(Object element, boolean state) {
        Assert.isNotNull(element);
        Widget widget = internalExpand(element, false);
        if (widget instanceof TreeItem) {
            ((TreeItem) widget).setGrayed(state);
            return true;
        }
        return false;
View Full Code Here

     * @param state a boolean indicating selection or deselection
     * @return boolean indicating success or failure.
     */
    public boolean setGrayChecked(Object element, boolean state) {
        Assert.isNotNull(element);
        Widget widget = internalExpand(element, false);
        if (widget instanceof TreeItem) {
            TreeItem item = (TreeItem) widget;
            item.setChecked(state);
            item.setGrayed(state);
            return true;
View Full Code Here

     *  state could be set, and <code>false</code> otherwise
     * @see #setGrayed
     */
    public boolean setParentsGrayed(Object element, boolean state) {
        Assert.isNotNull(element);
        Widget widget = internalExpand(element, false);
        if (widget instanceof TreeItem) {
            TreeItem item = (TreeItem) widget;
            item.setGrayed(state);
            item = item.getParentItem();
            while (item != null) {
View Full Code Here

     *  and <code>false</code> if it should be unchecked
     * @return <code>true</code> if the checked state could be set,
     *  and <code>false</code> otherwise
     */
    public boolean setSubtreeChecked(Object element, boolean state) {
        Widget widget = internalExpand(element, false);
        if (widget instanceof TreeItem) {
            TreeItem item = (TreeItem) widget;
            item.setChecked(state);
            setCheckedChildren(item, state);
            return true;
View Full Code Here

    }, true);
    GC gc = new GC(owner);
    layout.setColumnData(nameColumn, new ColumnWeightData(1, 200, true));
    for (final DataColumn column : config.getColumns()) {
      Widget createColumn = createColumn(column);
      int ms = Math.max(column.getSizeChar(), column.getName().length()) + 1;
      int another = (gc.getFontMetrics().getAverageCharWidth() + 1) * ms;
      layout.setColumnData(createColumn, new ColumnPixelData(another));
      TreeSortController treeSortController = new TreeSortController(
          viewer, (TreeColumn) createColumn,
View Full Code Here

      public void drop(DropTargetEvent event) {
        if (FeatureStructureTransfer.getInstance().isSupportedType(event.currentDataType)) {

          event.detail = DND.DROP_NONE;

          Widget tableItem = event.item;

          if (tableItem != null) {

            if (tableItem.getData() instanceof FeatureValue) {

              // this can fail
              FeatureValue value = (FeatureValue) tableItem.getData();

              Type range = value.getFeature().getRange();

              FeatureStructure dragFeatureStructure = (FeatureStructure) event.data;

              if (range.equals(dragFeatureStructure.getType())) {

                FeatureStructure target = value.getFeatureStructure();

                target.setFeatureValue(value.getFeature(), dragFeatureStructure);

                document.update(target);

                event.detail = DND.DROP_COPY;
              }
            } else if (tableItem.getData() instanceof ArrayValue) {
              ArrayValue value = (ArrayValue) tableItem.getData();

              if (value.getFeatureStructure() instanceof ArrayFS) {

                ArrayFS array = (ArrayFS) value.getFeatureStructure();
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Widget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.