Package com.google.gwt.user.client.ui

Examples of com.google.gwt.user.client.ui.MenuItem


    public Element getSubPartElement(String subPart) {
        int index = Integer.parseInt(subPart.substring(6));
        // ApplicationConnection.getConsole().log(
        // "Searching element for selection index " + index);
        MenuItem item = menu.getItem(index);
        // ApplicationConnection.getConsole().log("Item: " + item);
        // Item refers to the td, which is the parent of the clickable element
        return item.getElement().getFirstChildElement().cast();
    }
View Full Code Here


  @Override
  public MenuItem addItem(SafeHtml title, final Command callback) {
    // TODO(danilatos): Make the titles line up
    //return super.addItem((index++) + ". " + title, callback);
    return super.addItem(new MenuItem(title.asString(), true, new Command() {

      @Override
      public void execute() {
        handler.beforeItemClicked();
        callback.execute();
View Full Code Here

        if (keyCode >= '1' && keyCode <= '9') {
          // TODO(danilatos): Is this ok? i18n etc?
          int index = keyCode - '1';

          if (index >= 0 && index < getItems().size()) {
            MenuItem item = getItems().get(index);
            if (item == null) {
              return;
            }

            item.getCommand().execute();
            DOM.eventPreventDefault(event);
          }
        }
        break;
      }
View Full Code Here

                        presenter.onOpenWizard( AssetFormats.TEST_SCENARIO, false );
                    }
                } );


        addItem( new MenuItem( constants.CreateNew(), createNewMenu ) );
    }
View Full Code Here

        MenuBar rootMenuBar = new MenuBar( true );
        rootMenuBar.setAutoOpen( true );
        rootMenuBar.setAnimationEnabled( true );

        rootMenuBar.addItem( new MenuItem( constants.CreateNew(),
                                           createNewMenu ) );

        return rootMenuBar;
    }
View Full Code Here

      // clear existing items
      updatingMenu_ = true;
      menuBar_.clearItems();
     
      // add items (remember first item for programmatic selection)
      MenuItem firstItem = null;
      for (int i = 0; i<completions.length(); i++)
      {
         final CppCompletion completion = completions.get(i);
        
         SafeHtmlBuilder sb = new SafeHtmlBuilder();
         SafeHtmlUtil.appendImage(sb,
                                  RES.styles().itemImage(),
                                  completion.getIcon());
         SafeHtmlUtil.appendSpan(sb,
                                 RES.styles().itemName(),
                                 completion.getTypedText());  
        
        
         MenuItem menuItem = new MenuItem(sb.toSafeHtml(),
               new ScheduledCommand() {
            @Override
            public void execute()
            {
               docDisplay_.setFocus(true);
               if (isSelectable())
                  onSelected_.execute(completion);
            }
         });
         menuItem.addStyleName(RES.styles().itemMenu());
          
         FontSizer.applyNormalFontSize(menuItem);
        
         addItem(menuItem);
        
View Full Code Here

               toolTip_.setVisible(false);
               return;
            }
              
            // screen unable to find menu or selected item
            final MenuItem selectedItem = event.getSelectedItem();
            if (selectedItem == null)
            {
               toolTip_.setVisible(false);
               return;
            }
           
            int index = menuBar_.getItemIndex(selectedItem);
            if (index == -1)
            {
               toolTip_.setVisible(false);
               return;
            }
           
            // screen no completion text
            CppCompletion completion = completions_.get(index);
            if (completion.getText() == null)
            {
               toolTip_.setVisible(false);
               return;
            }
            String text = completion.getText().get(0);
           
            // only do tooltips for functions and variables
            if (completion.getType() != CppCompletion.FUNCTION &&
                completion.getType() != CppCompletion.VARIABLE)
            {
               toolTip_.setVisible(false);
               return;
            }
           
            // set the tooltip text
            toolTip_.setText(text);
          
            // position it in the next event loop
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

               @Override
               public void execute()
               {
                  // bail if there is no longer a tooltip
                  if (toolTip_ == null)
                     return;
                 
                  // some constants
                  final int H_PAD = 12;
                  final int V_PAD = -3;
                  final int H_BUFFER = 100;
                  final int MIN_WIDTH = 300;
                 
                  // candidate left and top
                  final int left = selectedItem.getAbsoluteLeft()
                             + selectedItem.getOffsetWidth() + H_PAD;
                  final int top = selectedItem.getAbsoluteTop() + V_PAD;
                 
                  // do we have enough room to the right? if not then
                  int roomRight = Window.getClientWidth() - left;
                  int maxWidth = Math.min(roomRight - H_BUFFER, 500);
                  final boolean showLeft = maxWidth < MIN_WIDTH;
                  if (showLeft)
                     maxWidth = selectedItem.getAbsoluteLeft() - H_BUFFER;
                 
                  if (toolTip_.getAbsoluteLeft() != left ||
                      toolTip_.getAbsoluteTop() != top)
                  {
                     toolTip_.setMaxWidth(maxWidth)
                     toolTip_.setPopupPositionAndShow(new PositionCallback(){

                        @Override
                        public void setPosition(int offsetWidth,
                                                int offsetHeight)
                        {
                           // if we are showing left then adjust
                           int adjustedLeft = left;
                           if (showLeft)
                           {
                              adjustedLeft = selectedItem.getAbsoluteLeft() -
                                             offsetWidth - H_PAD;
                           }
                           toolTip_.setPopupPosition(adjustedLeft, top);
                        }
                     });
View Full Code Here

            if (options_.size() == 0)
               return;

            StatusBarPopupMenu menu = new StatusBarPopupMenu();
            for (final String option : options_)
               menu.addItem(new MenuItem(option, new Command()
               {
                  public void execute()
                  {
                     SelectionEvent.fire(StatusBarElementWidget.this, option);
                  }
View Full Code Here

   private MenuItem createLatexMenu(String text,
                                    String prefix,
                                    String suffix,
                                    boolean isSectionMenu)
   {
      return new MenuItem(text, false, createLatexCommand(prefix,
                                                          suffix,
                                                          isSectionMenu));
   }
View Full Code Here

   private MenuItem createLatexListMenu(final String text,
                                        final String type,
                                        final boolean isDescription)
   {
      return new MenuItem(text, false, new Command(){
         @Override
         public void execute()
         {
            editor_.collapseSelection(true);
            Position pos = editor_.getCursorPosition();
View Full Code Here

TOP

Related Classes of com.google.gwt.user.client.ui.MenuItem

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.