/**
   * Determines if the selection was on the dropdown affordance and, if so, opens the drop down menu
   * (populated using the same id as this item...
   *
   * @param event The <code>SWT.Selection</code> event to be tested
   * @return <code>true</code> iff a drop down menu was opened
   */
  private boolean openDropDownMenu(final Event event) {
    final Widget item = event.widget;
    if (item != null) {
      final int style = item.getStyle();
      if ((style & SWT.DROP_DOWN) != 0) {
        if (event.detail == 4) { // on drop-down button
          final ToolItem ti = (ToolItem) item;

          final MenuManager menuManager = new MenuManager();
          final Menu menu = menuManager.createContextMenu(ti.getParent());
          if (this.workbenchHelpSystem != null) {
            this.workbenchHelpSystem.setHelp(menu, this.helpContextId);
          }
          initDropDownMenu(menuManager);

          // position the menu below the drop down item
          final Point point = ti.getParent().toDisplay(new Point(event.x, event.y));
          menu.setLocation(point.x, point.y); // waiting for SWT
          // 0.42
          menu.setVisible(true);
          return true; // we don't fire the action
        }
      }
    }

    return false;
  }
  /**
   * Determines if the selection was on the dropdown affordance and, if so, opens the drop down menu
   * (populated using the same id as this item...
   *
   * @param event The <code>SWT.Selection</code> event to be tested
   * @return <code>true</code> iff a drop down menu was opened
   */
  private boolean openDropDownMenu(Event event) {
    Widget item = event.widget;
    if (item != null) {
      int style = item.getStyle();
      if ((style & SWT.DROP_DOWN) != 0) {
        if (event.detail == 4) { // on drop-down button
          ToolItem ti = (ToolItem) item;

          final MenuManager menuManager = new MenuManager();
          Menu menu = menuManager.createContextMenu(ti.getParent());
          menuManager.addMenuListener(
              new IMenuListener() {
                public void menuAboutToShow(IMenuManager manager) {
                  String id = getId();
                  if (dropDownMenuOverride != null) {
                    id = dropDownMenuOverride;
                  }
                  menuService.populateContributionManager(menuManager, "menu:" + id); // $NON-NLS-1$
                }
              });
          // position the menu below the drop down item
          Rectangle b = ti.getBounds();
          Point p = ti.getParent().toDisplay(new Point(b.x, b.y + b.height));
          menu.setLocation(p.x, p.y); // waiting for SWT
          // 0.42
          menu.setVisible(true);
          return true; // we don't fire the action
        }
      }
    }

    return false;
  }
예제 #3
0
 private static AbstractLabelLCADelegate getDelegate(final Widget widget) {
   AbstractLabelLCADelegate result;
   if ((widget.getStyle() & SWT.SEPARATOR) != 0) {
     result = SEPARATOR_LCA;
   } else {
     result = LABEL_LCA;
   }
   return result;
 }
예제 #4
0
  public void renderInitialization(final Widget widget) throws IOException {
    IWidgetSynchronizer synchronizer = WidgetSynchronizerFactory.getSynchronizerForWidget(widget);
    List styleList = new ArrayList();
    int style = widget.getStyle();
    if ((style & SWT.BORDER) != 0) {
      styleList.add("BORDER");
    }
    if ((style & MODAL) != 0) {
      styleList.add("MODAL");
    }
    if ((style & SWT.ON_TOP) != 0) {
      styleList.add("ON_TOP");
    }
    if ((style & SWT.TITLE) != 0) {
      styleList.add("TITLE");
    }
    if ((style & SWT.TOOL) != 0) {
      styleList.add("TOOL");
    }
    if ((style & SWT.SHEET) != 0) {
      styleList.add("SHEET");
    }
    if ((style & SWT.MIN) != 0) {
      styleList.add("MIN");
    }
    if ((style & SWT.MAX) != 0) {
      styleList.add("MAX");
    }
    if ((style & SWT.CLOSE) != 0) {
      styleList.add("CLOSE");
    }
    if ((style & SWT.RESIZE) != 0) {
      styleList.add("RESIZE");
    }
    String[] styles = new String[styleList.size()];
    styleList.toArray(styles);
    Composite parent = ((Shell) widget).getParent();
    if (parent instanceof Shell) {
      String parentId = WidgetUtil.getId(parent);
      synchronizer.newWidget(styles, new Object[] {parentId});
    }
    synchronizer.newWidget(styles);

    // old
    //    JSWriter writer = JSWriter.getWriterFor( widget );
    //    Shell shell = ( Shell )widget;
    //    writer.newWidget( QX_TYPE );
    //    ControlLCAUtil.writeStyleFlags( shell );
    //    if( ( style & MODAL ) != 0 ) {
    //      writer.call( "addState", new Object[] { "rwt_APPLICATION_MODAL" } );
    //    }
    //    if( ( style & SWT.ON_TOP ) != 0 ) {
    //      writer.call( "addState", new Object[] { "rwt_ON_TOP" } );
    //    }
    //    if( ( style & SWT.TITLE ) != 0 ) {
    //      writer.call( "addState", new Object[]{ "rwt_TITLE" } );
    //    }
    //    if( ( style & SWT.TOOL ) != 0 ) {
    //      writer.call( "addState", new Object[]{ "rwt_TOOL" } );
    //    }
    //    if( ( style & SWT.SHEET ) != 0 ) {
    //      writer.call( "addState", new Object[]{ "rwt_SHEET" } );
    //    }
    //    writer.set( "showMinimize", ( style & SWT.MIN ) != 0 );
    //    writer.set( "allowMinimize", ( style & SWT.MIN ) != 0 );
    //    writer.set( "showMaximize", ( style & SWT.MAX ) != 0 );
    //    writer.set( "allowMaximize", ( style & SWT.MAX ) != 0 );
    //    writer.set( "showClose", ( style & SWT.CLOSE ) != 0 );
    //    writer.set( "allowClose", ( style & SWT.CLOSE ) != 0 );
    //    Boolean resizable = Boolean.valueOf( ( style & SWT.RESIZE ) != 0 );
    //    writer.set( "resizable",
    //                new Object[] { resizable, resizable, resizable, resizable } );
    //    if( parent instanceof Shell ) {
    //      writer.set( "parentShell", parent );
    //    }
    //    writer.call( "initialize", null );
  }