Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.ToolItem


    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());
         
          String helpContextId = null;
          try {
            helpContextId = commandService.getHelpContextId(command
                .getCommand().getId());
          } catch (NotDefinedException e) {
            // No helpContextId
          }

          IWorkbench workbench = PlatformUI.getWorkbench();
          if (workbench != null && helpContextId != null) {
            workbench.getHelpSystem().setHelp(menu, helpContextId);
          }
         
          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
View Full Code Here


          .getResources());
      item.setImage(icon == null ? null : m.createImage(icon));
      disposeOldImages();
      localResourceManager = m;
    } else if (widget instanceof ToolItem) {
      ToolItem item = (ToolItem) widget;
      LocalResourceManager m = new LocalResourceManager(JFaceResources
          .getResources());
      item.setDisabledImage(disabledIcon == null ? null : m
          .createImage(disabledIcon));
      item.setHotImage(hoverIcon == null ? null : m
          .createImage(hoverIcon));
      item.setImage(icon == null ? null : m.createImage(icon));
      disposeOldImages();
      localResourceManager = m;
    }
  }
View Full Code Here

    // ContributionItem
    //
    ////////////////////////////////////////////////////////////////////////////
    @Override
    public void fill(ToolBar toolBar, int index) {
      m_toolItem = new ToolItem(toolBar, SWT.PUSH);
      m_toolItem.setImage(PORTRAIT);
      m_toolItem.setToolTipText("Flip orientation");
      m_toolItem.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
          flipOrientation();
View Full Code Here

    // ContributionItem
    //
    ////////////////////////////////////////////////////////////////////////////
    @Override
    public void fill(final ToolBar toolBar, int index) {
      m_toolItem = new ToolItem(toolBar, SWT.DROP_DOWN);
      m_toolItem.setImage(Activator.getImage("device/device.png"));
      // bind menu
      createMenu(toolBar);
      m_toolItem.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
View Full Code Here

       
        // ...In with the new
        chevronMenu = new Menu(coolBar);

        for (int j = i; j < toolCount; j++) {
            ToolItem tool = tools[j];
            MenuItem menuItem = new MenuItem(chevronMenu, SWT.NONE);
            if (tool.getSelection()) {
        menuItem.setEnabled(false);
      }
           
            // Show the full text of the perspective name in the chevron menu.
      if (tool.getData() instanceof PerspectiveBarContributionItem) {
        menuItem.setText(((PerspectiveBarContributionItem) tool
            .getData()).getPerspective().getLabel());
      } else {
        menuItem.setText(tool.getText());
      }
            menuItem.setImage(tool.getImage());

            menuItem.setData("IContributionItem", tool.getData()); //$NON-NLS-1$

            menuItem.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    //rotate the selected item in and the other items right
                    // don't touch the "Open" item
View Full Code Here

                    toolItem.dispose();
                    toolItem = null;
                }
            });

            toolItem = new ToolItem(parent, SWT.PUSH);
            if (image == null || image.isDisposed()) {
                image = WorkbenchImages.getImageDescriptor(
                        IWorkbenchGraphicConstants.IMG_ETOOL_NEW_PAGE)
                        .createImage();
            }
            toolItem.setImage(image);

            toolItem.setText(""); //$NON-NLS-1$
            toolItem.setToolTipText(WorkbenchMessages.PerspectiveBarNewContributionItem_toolTip);
            toolItem.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    menuManager.update(true);
                    Point point = new Point(event.x, event.y);
                    if (event.widget instanceof ToolItem) {
                        ToolItem toolItem = (ToolItem) event.widget;
                        Rectangle rectangle = toolItem.getBounds();
                        point = new Point(rectangle.x, rectangle.y
                                + rectangle.height);
                    }
                    Menu menu = menuManager.createContextMenu(parent);
                    point = parent.toDisplay(point);
View Full Code Here

      Point position, Rectangle dragRectangle) {
    // If we're trying to drop onto a 'standalone' stack, don't...
    if (isStandaloneStack())
      return null;
   
        ToolItem targetItem = getToolItem(position);
        if (draggedObject instanceof ViewPane) {
            ViewPane pane = (ViewPane) draggedObject;

            // Can't drag views between windows
            if (pane.getWorkbenchWindow() != wbw) {
View Full Code Here

            boolean usingKeyboard) {
        int index = getIndex(ref);
        if (index == -1)
          return;
       
        ToolItem item = tbm.getControl().getItem(index);
        Rectangle dragRect = Geometry.toDisplay(tbm.getControl(), item.getBounds());
        startDrag(((WorkbenchPartReference) ref).getPane(), dragRect, position,
        usingKeyboard);
    }
View Full Code Here

  public void initToolBarManager(final ToolBarManager mgr) {
    // Set up the ToolBar with a restore button
    IContributionItem restoreContrib = new ContributionItem() {
      public void fill(ToolBar parent, int index) {
            ToolItem restoreItem = new  ToolItem(mgr.getControl(), SWT.PUSH, index);       
            Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART);
            restoreItem.setImage(tbImage);      
            String menuTip = WorkbenchMessages.StandardSystemToolbar_Restore;
            restoreItem.setToolTipText(menuTip);
            restoreItem.addSelectionListener(new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent e) {
            restoreToPresentation();
          }
          public void widgetSelected(SelectionEvent e) {
            restoreToPresentation();
          }
            });
      }
    };
    mgr.add(restoreContrib);

    // Set up the ToolBar with a button represing the Editor Area
    IContributionItem eaContrib = new ContributionItem() {
      public void fill(ToolBar parent, int index) {
            ToolItem editorAreaItem = new  ToolItem(mgr.getControl(), SWT.PUSH, index);       
            Image tbImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_ETOOL_EDITOR_TRIMPART);
            editorAreaItem.setImage(tbImage);      
            String menuTip = WorkbenchMessages.EditorArea_Tooltip;
            editorAreaItem.setToolTipText(menuTip);
            editorAreaItem.addSelectionListener(new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent e) {
            restoreToPresentation();
          }
          public void widgetSelected(SelectionEvent e) {
            restoreToPresentation();
View Full Code Here

  /**
   * @param ref
   * @param selected
   */
  public void setIconSelection(IViewReference ref, boolean selected) {
    ToolItem item = ShowFastViewContribution.getItem(tbMgr.getControl(), ref);
    if (item != null)
      item.setSelection(selected);
  }
View Full Code Here

TOP

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

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.