Package org.eclipse.jface.action

Examples of org.eclipse.jface.action.ICoolBarManager


   * Returns a tool bar manager for this Item.
   *
   * @return the tool bar manager
   */
  public IToolBarManager getToolBarManager() {
    ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
    if (coolBarManager == null) {
      return null;
    }
        return actionBarConfigurer.createToolBarManager();
  }
View Full Code Here


      toolBarId = actionId;
      isAdjunctType = true;
    }

    // Rereive the cool bar manager
    ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
    if (coolBarManager == null) {
      return null;
    }

    // Check to see that there isn't already a tool bar created
    // and the tool bar being requested is not for an adjunct action
    if ((coolItemToolBarMgr != null) && (!isAdjunctType)) {
      return coolItemToolBarMgr;
    }

    // Search for toolBarId in the cool Bar manager
    IContributionItem cbItem = coolBarManager.find(toolBarId);
    // If there hasn't been a tool bar contribution item created for this
    // tool bar
    // id then create one. Otherwise retrieve the tool bar contribution
    // item
    if (cbItem instanceof IToolBarContributionItem) {

      IToolBarContributionItem tbcbItem = (IToolBarContributionItem) cbItem;
      coolItemToolBarMgr = tbcbItem.getToolBarManager();
      // If this not an adjuct type then we can cashe the tool bar
      // contribution type
      if (!isAdjunctType) {
        toolBarContributionItem = tbcbItem;
      }
    } else {
     
      coolItemToolBarMgr = actionBarConfigurer.createToolBarManager();
          
      // If this is not an adjunct type then create a tool bar
      // contribution item
      // we don't create one for an adjunct type because another action
      // set action bars contains one
           
            IContributionItem toolBarContributionItem = actionBarConfigurer
          .createToolBarContributionItem(coolItemToolBarMgr,
              toolBarId);

      toolBarContributionItem.setParent(coolItemToolBarMgr);
      toolBarContributionItem.setVisible(getActive());
      coolItemToolBarMgr.markDirty();

      // Now add the tool bar contribution Item to the cool bar manager
      IContributionItem refItem = findAlphabeticalOrder(
          IWorkbenchActionConstants.MB_ADDITIONS, toolBarId,
          coolBarManager);
      if (refItem != null) {
        coolBarManager.insertAfter(refItem.getId(),
            toolBarContributionItem);
      } else {
        coolBarManager.add(toolBarContributionItem);
      }
    }
    return coolItemToolBarMgr;
  }
View Full Code Here

   * Activate / Deactivate the contributions.
   */
  protected void setActive(boolean set) {
    super.setActive(set);

    ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
    if (coolBarManager == null) {
      return;
    }

    // 1. Need to set visibility for all non-adjunct actions
    if (coolItemToolBarMgr != null) {
      IContributionItem[] items = coolItemToolBarMgr.getItems();
      for (int i = 0; i < items.length; i++) {
        IContributionItem item = items[i];
        if (item instanceof PluginActionCoolBarContributionItem) {
          PluginActionCoolBarContributionItem actionSetItem = (PluginActionCoolBarContributionItem) item;
          // Only if the action set id for this contribution item is
          // the same
          // as this object
          if (actionSetItem.getActionSetId().equals(actionSetId)) {
            item.setVisible(set);
            coolItemToolBarMgr.markDirty();
            if (!coolBarManager.isDirty()) {
              coolBarManager.markDirty();
            }
          }
        }
      }
      // Update the manager
      coolItemToolBarMgr.update(false);
      if (toolBarContributionItem != null) {
        toolBarContributionItem.update(ICoolBarManager.SIZE);
      }
    }

    // 2. Need to set visibility for all adjunct actions
    if (adjunctContributions.size() > 0) {
      for (Iterator i = adjunctContributions.iterator(); i.hasNext();) {
        IContributionItem item = (IContributionItem) i.next();
        if (item instanceof ContributionItem) {
          item.setVisible(set);
          IContributionManager manager = ((ContributionItem) item)
              .getParent();
          manager.markDirty();
          manager.update(false);
          if (!coolBarManager.isDirty()) {
            coolBarManager.markDirty();
          }
          item.update(ICoolBarManager.SIZE);
        }

      }
View Full Code Here

  private boolean updateCoolBar(ToolBarManager mgr) {
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench()
        .getWorkbenchWindows();
    for (int i = 0; i < windows.length; i++) {
      WorkbenchWindow window = (WorkbenchWindow) windows[i];
      ICoolBarManager cb = window.getCoolBarManager2();
      if (cb != null) {
        IContributionItem[] items = cb.getItems();
        for (int j = 0; j < items.length; j++) {
          if (items[j] instanceof ToolBarContributionItem) {
            IToolBarManager tbm = ((ToolBarContributionItem) items[j])
                .getToolBarManager();
            if (mgr == tbm) {
              cb.update(true);
              return true;
            }
          }
        }
      }
View Full Code Here

    /* (non-Javadoc)
     * @see org.eclipse.ui.application.IWorkbenchWindowConfigurer
     */
    public Control createCoolBarControl(Composite parent) {
      ICoolBarManager coolBarManager = window.getCoolBarManager2();
      if (coolBarManager != null) {
          if (coolBarManager instanceof ICoolBarManager2) {
        return ((ICoolBarManager2) coolBarManager).createControl2(parent);
      }
          if (coolBarManager instanceof CoolBarManager) {
View Full Code Here

         * @param the item id
         * @return <code>true</code> if it is a cool item,
         * and <code>false</code> otherwise
         */
        /* package */boolean containsCoolItem(String id) {
            ICoolBarManager cbManager = getCoolBarManager();
            if (cbManager == null) {
        return false;
      }
            IContributionItem cbItem = cbManager.find(id);
            if (cbItem == null) {
        return false;
      }
            //@ issue: maybe we should check if cbItem is visible?
            return true;
View Full Code Here

                ActionSetActionBars bars) {
            String toolBarId = ad.getToolbarId();
            String toolGroupId = ad.getToolbarGroupId();

            String contributingId = bars.getActionSetId();
            ICoolBarManager coolBarMgr = bars.getCoolBarManager();
            if (coolBarMgr == null) {
                return;
            }

            PluginAction action = ad.getAction();
View Full Code Here

                ActionSetActionBars bars) {
            String toolBarId = ad.getToolbarId();
//            String toolGroupId = ad.getToolbarGroupId();
//
//            String contributingId = bars.getActionSetId();
            ICoolBarManager coolBarMgr = bars.getCoolBarManager();
            //        ((CoolItemToolBarManager)bars.getToolBarManager()).getParentManager();
            PluginAction action = ad.getAction();
            PluginActionCoolBarContributionItem actionContribution = new PluginActionCoolBarContributionItem(
                    action);

            bars.removeAdjunctContribution(actionContribution);

            // remove a coolitem for the toolbar id if it exists      
            IContributionItem cbItem = coolBarMgr.find(toolBarId);
            if (cbItem != null) {
        coolBarMgr.remove(cbItem);
      }

            //      activeManager = cbItem.getToolBarManager(); 
            //      activeManager.remove(contributingId); 
            //      IContributionItem groupMarker = activeManager.find(toolGroupId);
View Full Code Here

     * to its parent (the real CoolBarManager), and replace the reference
     * with a placeholder.
     */
    if (toolBarContributionItem != null) {
      // Create a placeholder and place it in the cool bar manager.
      ICoolBarManager coolBarManager = getCoolBarManager();
      if (coolBarManager instanceof SubContributionManager) {
        SubContributionManager subManager = (SubContributionManager) coolBarManager;
        IContributionManager manager = subManager.getParent();
        if (manager instanceof ContributionManager) {
          final IContributionItem replacementItem = new PlaceholderContributionItem(
              toolBarContributionItem);
          boolean succeeded = ((ContributionManager) manager)
              .replaceItem(replacementItem.getId(),
                  replacementItem);
          if (!succeeded && DEBUG_TOOLBAR_DISPOSAL) {
            System.out
                .println("FAILURE WHILE DISPOSING EditorActionBars"); //$NON-NLS-1$
            System.out
                .println("Could not replace " + replacementItem.getId() + " in the contribution manager."); //$NON-NLS-1$ //$NON-NLS-2$
          }
        } else if (DEBUG_TOOLBAR_DISPOSAL) {
          System.out
              .println("FAILURE WHILE DISPOSING EditorActionBars"); //$NON-NLS-1$
          System.out
              .println("The manager was not a ContributionManager."); //$NON-NLS-1$
          System.out
              .println("It was a " + manager.getClass().getName()); //$NON-NLS-1$
        }
      } else if (DEBUG_TOOLBAR_DISPOSAL) {
        System.out.println("FAILURE WHILE DISPOSING EditorActionBars"); //$NON-NLS-1$
        System.out
            .println("The coolBarManager was not a SubContributionManager"); //$NON-NLS-1$
        System.out
            .println("It was a " + coolBarManager.getClass().getName()); //$NON-NLS-1$
      }

      // Dispose of the replaced item.
      toolBarContributionItem.dispose();
    }
View Full Code Here

   * @return the tool bar manager
   */
  public IToolBarManager getToolBarManager() {

    // by pass the sub coolBar and use the real cool bar.
    ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
    if (coolBarManager == null) {
      return null;
    }

    // add the editor group if the app did not add it already,
    // otherwise the references to it below will fail
    if (coolBarManager.find(IWorkbenchActionConstants.GROUP_EDITOR) == null) {
      coolBarManager.add(new GroupMarker(
          IWorkbenchActionConstants.GROUP_EDITOR));
    }
    if (toolBarContributionItem == null) {
      IContributionItem foundItem = coolBarManager.find(type);
      if ((foundItem instanceof IToolBarContributionItem)) {
        toolBarContributionItem = (IToolBarContributionItem) foundItem;
        coolItemToolBarMgr = toolBarContributionItem.getToolBarManager();
        if (coolItemToolBarMgr == null) {
          coolItemToolBarMgr = actionBarPresentation.createToolBarManager();
          toolBarContributionItem = actionBarPresentation.createToolBarContributionItem(
              coolItemToolBarMgr, type);
          // Add editor item to group
          coolBarManager.prependToGroup(
              IWorkbenchActionConstants.GROUP_EDITOR,
              toolBarContributionItem);
        }
      } else {
        coolItemToolBarMgr = actionBarPresentation.createToolBarManager();
        if ((coolBarManager instanceof ContributionManager)
            && (foundItem instanceof PlaceholderContributionItem)) {
          PlaceholderContributionItem placeholder = (PlaceholderContributionItem) foundItem;
          toolBarContributionItem = createToolBarContributionItem(coolItemToolBarMgr, placeholder);
          // Restore from a placeholder
          ((ContributionManager) coolBarManager).replaceItem(type,
              toolBarContributionItem);
        } else {
          toolBarContributionItem = actionBarPresentation.createToolBarContributionItem(
              coolItemToolBarMgr, type);
          // Add editor item to group
          coolBarManager.prependToGroup(
              IWorkbenchActionConstants.GROUP_EDITOR,
              toolBarContributionItem);
        }
      }
      ((ContributionManager)coolItemToolBarMgr).setOverrides(new Overrides());
View Full Code Here

TOP

Related Classes of org.eclipse.jface.action.ICoolBarManager

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.