Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.ToolItem


      } else if ((style & SWT.DROP_DOWN) != 0) {
        if (e.detail == 4) { // on drop-down button
          if (action.getStyle() == IAction.AS_DROP_DOWN_MENU) {
            IMenuCreator mc = action.getMenuCreator();
            menuCreatorCalled = true;
            ToolItem ti = (ToolItem) item;
            // we create the menu as a sub-menu of "dummy" so that
            // we can use
            // it in a cascading menu too.
            // If created on a SWT control we would get an SWT
            // error...
            // Menu dummy= new Menu(ti.getParent());
            // Menu m= mc.getMenu(dummy);
            // dummy.dispose();
            if (mc != null) {
              Menu m = mc.getMenu(ti.getParent());
              if (m != null) {
                // position the menu below the drop down item
                Point point = ti.getParent().toDisplay(
                    new Point(e.x, e.y));
                m.setLocation(point.x, point.y); // waiting
                                  // for SWT
                // 0.42
                m.setVisible(true);
View Full Code Here


          .getStyle() == IAction.AS_RADIO_BUTTON)
          && (propertyName == null || propertyName
              .equals(IAction.CHECKED));

      if (widget instanceof ToolItem) {
        ToolItem ti = (ToolItem) widget;
        String text = action.getText();
        // the set text is shown only if there is no image or if forced
        // by MODE_FORCE_TEXT
        boolean showText = text != null
            && ((getMode() & MODE_FORCE_TEXT) != 0 || !hasImages(action));

        // only do the trimming if the text will be used
        if (showText && text != null) {
          text = Action.removeAcceleratorText(text);
          text = Action.removeMnemonics(text);
        }

        if (textChanged) {
          String textToSet = showText ? text : ""; //$NON-NLS-1$
          boolean rightStyle = (ti.getParent().getStyle() & SWT.RIGHT) != 0;
          if (rightStyle || !ti.getText().equals(textToSet)) {
            // In addition to being required to update the text if
            // it
            // gets nulled out in the action, this is also a
            // workaround
            // for bug 50151: Using SWT.RIGHT on a ToolBar leaves
            // blank space
            ti.setText(textToSet);
          }
        }

        if (imageChanged) {
          // only substitute a missing image if it has no text
          updateImages(!showText);
        }

        if (tooltipTextChanged || textChanged) {
          String toolTip = action.getToolTipText();
          if ((toolTip == null) || (toolTip.length() == 0)) {
            toolTip = text;
          }

          ExternalActionManager.ICallback callback = ExternalActionManager
              .getInstance().getCallback();
          String commandId = action.getActionDefinitionId();
          if ((callback != null) && (commandId != null)
              && (toolTip != null)) {
            String acceleratorText = callback
                .getAcceleratorText(commandId);
            if (acceleratorText != null
                && acceleratorText.length() != 0) {
              toolTip = JFaceResources.format(
                  "Toolbar_Tooltip_Accelerator", //$NON-NLS-1$
                  new Object[] { toolTip, acceleratorText });
            }
          }

          // if the text is showing, then only set the tooltip if
          // different
          if (!showText || toolTip != null && !toolTip.equals(text)) {
            ti.setToolTipText(toolTip);
          } else {
            ti.setToolTipText(null);
          }
        }

        if (enableStateChanged) {
          boolean shouldBeEnabled = action.isEnabled()
              && isEnabledAllowed();

          if (ti.getEnabled() != shouldBeEnabled) {
            ti.setEnabled(shouldBeEnabled);
          }
        }

        if (checkChanged) {
          boolean bv = action.isChecked();

          if (ti.getSelection() != bv) {
            ti.setSelection(bv);
          }
        }
        return;
      }
View Full Code Here

        if (chevronMenuManager != null) {
            chevronMenuManager.dispose();
        }
        chevronMenuManager = new MenuManager();
        for (Iterator i = hidden.iterator(); i.hasNext();) {
            ToolItem toolItem = (ToolItem) i.next();
            IContributionItem data = (IContributionItem) toolItem.getData();
            if (data instanceof ActionContributionItem) {
                ActionContributionItem contribution = new ActionContributionItem(
                        ((ActionContributionItem) data).getAction());
                chevronMenuManager.add(contribution);
            } else if (data instanceof SubContributionItem) {
View Full Code Here

    public void widgetDefaultSelected(SelectionEvent e) {}

    public void widgetSelected(SelectionEvent e) {
      Object selection = e.getSource();
      if (selection instanceof ToolItem) {
        ToolItem toolItem = (ToolItem)selection;
        ToolBar toolbar = toolItem.getParent();
        if(toolbar != null) {
          ToolItem[] items = toolbar.getItems();
          for (int i = 0; i < items.length; i++) {
            items[i].setSelection(items[i] == toolItem);
          }
        }
        if (!showPage((CatalogElementPage) toolItem.getData())) {
          // Page flipping wasn't successful
          // handleError();
        }
      }
    }
View Full Code Here

    createRewriteButton();
    createSuffixCatalogButton();
    createNextCatalogButton();
    createDelegateCatalogButton();
    if (toolBar.getItemCount() > 0) {
      ToolItem item = toolBar.getItem(0);
      showPage((CatalogElementPage) (item.getData()));
    }
    return composite1;
  }
View Full Code Here

  }
 
  protected void createCatalogEntryButton() {
    CatalogElementPage page = new CatalogEntryPage();
    page.createControl(pageContainer);
    ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
    toolItem.setImage(catalogEntryToolBarImage);
    toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_catalogEntryLabel);
    toolItem.setData(page);
    toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
    toolItem.setSelection(true);
  }
View Full Code Here

  }

  protected void createNextCatalogButton() {
    CatalogElementPage page = new NextCatalogPage();
    page.createControl(pageContainer);
    ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
    toolItem.setImage(nextCatalogToolBarImage);
    toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_nextCatalogLabel);
    toolItem.setData(page);
    toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());

  }
View Full Code Here

  }
 
  protected void createRewriteButton() {
    CatalogElementPage page = new RewriteEntryPage();
    page.createControl(pageContainer);
    ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
    toolItem.setImage(rewriteToolBarImage);
    toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_rewriteEntryLabel);
    toolItem.setData(page);
    toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
  }
View Full Code Here

  }
 
  protected void createDelegateCatalogButton() {
    CatalogElementPage page = new DelegateCatalogPage();
    page.createControl(pageContainer);
    ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
    toolItem.setImage(delegateCatalogToolBarImage);
    toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_delegateCatalogLabel);
    toolItem.setData(page);
    toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
  }
View Full Code Here

  }
 
  protected void createSuffixCatalogButton() {
    CatalogElementPage page = new SuffixEntryPage();
    page.createControl(pageContainer);
    ToolItem toolItem = new ToolItem(toolBar, SWT.CHECK);
    toolItem.setImage(suffixToolBarImage);
    toolItem.setText(XMLCatalogMessages.EditCatalogEntryDialog_suffixEntryLabel);
    toolItem.setData(page);
    toolItem.addSelectionListener(new ToolBarItemSelectionChangeListener());
  }
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.