コード例 #1
0
 public Menu getMenu(Control parent) {
   Menu menu = new Menu(parent);
   for (ActionContributionItem action : getActions()) {
     action.fill(menu, -1);
   }
   return menu;
 }
コード例 #2
0
  protected void fillMenuBar(IMenuManager menuBar) {
    MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
    MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);

    menuBar.add(fileMenu);
    // Add a group marker indicating where action set menus will appear.
    menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    menuBar.add(helpMenu);
    helpMenu.add(helpContentsAction);

    // File Menu
    /* fileMenu.add(prefAction);
    fileMenu.add(new Separator());
    fileMenu.add(exitAction); */

    // Ajout sous la forme de ActionContributionItem pour pouvoir rendre les actions ensuite
    // invisibles, car elle sont dŽjˆ prŽsentes dans le menu Pomme du mac.
    ActionContributionItem preferencesActionItem = new ActionContributionItem(prefAction);
    fileMenu.add(preferencesActionItem);
    ActionContributionItem exitActionItem = new ActionContributionItem(exitAction);
    fileMenu.add(exitActionItem);

    if (Util.isMac()) {
      preferencesActionItem.setVisible(false);
      exitActionItem.setVisible(false);
    }
  }
コード例 #3
0
  /** Creates and returns the File menu. */
  private MenuManager createFileMenu() {
    MenuManager menu = new MenuManager(Messages.FileMenuName, IWorkbenchActionConstants.M_FILE);
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));

    ActionContributionItem newExecutableItem = new ActionContributionItem(newExecutableAction);
    menu.add(newExecutableItem);

    ActionContributionItem attachExecutableItem =
        new ActionContributionItem(attachExecutableAction);
    menu.add(attachExecutableItem);

    ActionContributionItem corefileItem = new ActionContributionItem(corefileAction);
    menu.add(corefileItem);

    menu.add(new Separator());

    // If we're on OS X we shouldn't show this command in the File menu. It
    // should be invisible to the user. However, we should not remove it -
    // the carbon UI code will do a search through our menu structure
    // looking for it when Cmd-Q is invoked (or Quit is chosen from the
    // application menu.
    ActionContributionItem quitItem = new ActionContributionItem(quitAction);
    quitItem.setVisible(!Util.isMac());
    menu.add(quitItem);
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
    return menu;
  }
コード例 #4
0
  /** Creates and returns the Help menu. */
  private MenuManager createHelpMenu() {
    MenuManager menu = new MenuManager(Messages.HelpMenuName, IWorkbenchActionConstants.M_HELP);
    menu.add(new GroupMarker("group.intro.ext")); // $NON-NLS-1$
    menu.add(new GroupMarker("group.main")); // $NON-NLS-1$
    menu.add(helpContentsAction);
    menu.add(helpSearchAction);
    menu.add(dynamicHelpAction);
    menu.add(new GroupMarker("group.assist")); // $NON-NLS-1$
    // HELP_START should really be the first item, but it was after
    // quickStartAction and tipsAndTricksAction in 2.1.
    menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START));
    menu.add(new GroupMarker("group.main.ext")); // $NON-NLS-1$
    menu.add(new GroupMarker("group.tutorials")); // $NON-NLS-1$
    menu.add(new GroupMarker("group.tools")); // $NON-NLS-1$
    menu.add(new GroupMarker("group.updates")); // $NON-NLS-1$
    menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END));
    menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    // about should always be at the bottom
    menu.add(new Separator("group.about")); // $NON-NLS-1$

    ActionContributionItem aboutItem = new ActionContributionItem(aboutAction);
    aboutItem.setVisible(!Util.isMac());
    menu.add(aboutItem);
    menu.add(new GroupMarker("group.about.ext")); // $NON-NLS-1$
    return menu;
  }
コード例 #5
0
 /**
  * Recursive method to create a menu from the contribute items of a manger
  *
  * @param menu actual menu
  * @param items manager contributor items
  */
 private void createMenu(Menu menu, IContributionItem[] items) {
   for (IContributionItem item : items) {
     if (item instanceof MenuManager) {
       MenuManager manager = (MenuManager) item;
       MenuItem subMenuItem = new MenuItem(menu, SWT.CASCADE);
       subMenuItem.setText(manager.getMenuText());
       Menu subMenu = new Menu(Display.getCurrent().getActiveShell(), SWT.DROP_DOWN);
       subMenuItem.setMenu(subMenu);
       createMenu(subMenu, manager.getItems());
     } else if (item instanceof ActionContributionItem) {
       ActionContributionItem actionItem = (ActionContributionItem) item;
       if (actionItem.getAction() instanceof CustomSelectionAction) {
         final CustomSelectionAction action = (CustomSelectionAction) actionItem.getAction();
         MenuItem actionEnrty = new MenuItem(menu, SWT.CHECK);
         action.setSelection(getLastRawSelection());
         actionEnrty.setText(actionItem.getAction().getText());
         actionEnrty.setSelection(action.isChecked());
         actionEnrty.setEnabled(action.canExecute());
         actionEnrty.addSelectionListener(
             new SelectionAdapter() {
               @Override
               public void widgetSelected(SelectionEvent e) {
                 action.run();
               }
             });
       }
     }
   }
 }
コード例 #6
0
  protected void populateSubMenus(
      Menu subMenu, final Object node, ITreeContentProvider provider, final boolean isRunTo) {
    if (provider.hasChildren(node)) {
      /*
       * this is a submenu mark
       */
      MenuItem header = new MenuItem(subMenu, SWT.CASCADE);
      header.setText(node.toString());
      Menu newSubMenu = new Menu(header);
      header.setMenu(newSubMenu);
      for (Object child : provider.getChildren(node))
        populateSubMenus(newSubMenu, child, provider, isRunTo);
    } else {
      /** lone item, this is a runner. */
      ITimeBasedAction action = new TimeBasedAction(this, node, isRunTo);

      action.setText(
          String.format("%s %s", isRunTo ? "Skip to " : "Run for ", _labelProvider.getText(node)));

      _allActions.add(action);

      ActionContributionItem aci = new ActionContributionItem(action);
      aci.fill(subMenu, -1);
    }
  }
コード例 #7
0
  public void testExtensionContributionExpression() throws Exception {
    IAction a =
        new Action() {
          @Override
          public void run() {
            System.out.println("Hello action");
          }
        };
    final MenuManager manager = new MenuManager();
    final ActionContributionItem aci = new ActionContributionItem(a);

    IExtensionRegistry reg = Platform.getExtensionRegistry();
    IExtensionPoint menusExtension = reg.getExtensionPoint("org.eclipse.ui.menus");
    IExtension extension = menusExtension.getExtension(EXTENSION_ID);

    IConfigurationElement[] mas = extension.getConfigurationElements();
    final Expression activeContextExpr[] = new Expression[1];
    for (IConfigurationElement ma : mas) {
      IConfigurationElement[] items = ma.getChildren();
      for (IConfigurationElement item : items) {
        String id = item.getAttribute("id");
        if (id != null && id.equals("org.eclipse.ui.tests.menus.itemX1")) {
          IConfigurationElement visibleWhenElement = item.getChildren("visibleWhen")[0];
          activeContextExpr[0] =
              ExpressionConverter.getDefault().perform(visibleWhenElement.getChildren()[0]);
        }
      }
    }
    assertNotNull("Failed to find expression", activeContextExpr[0]);
    AbstractContributionFactory factory =
        new AbstractContributionFactory(LOCATION, TestPlugin.PLUGIN_ID) {
          @Override
          public void createContributionItems(
              IServiceLocator menuService, IContributionRoot additions) {
            additions.addContributionItem(aci, activeContextExpr[0]);
          }
        };

    menuService.addContributionFactory(factory);
    menuService.populateContributionManager(manager, LOCATION);

    assertFalse("starting state", aci.isVisible());

    activeContext = contextService.activateContext(MenuContributionHarness.CONTEXT_TEST1_ID);
    final Menu menu = manager.createContextMenu(window.getShell());
    menu.notifyListeners(SWT.Show, new Event());
    assertTrue("active context", aci.isVisible());
    menu.notifyListeners(SWT.Hide, new Event());

    contextService.deactivateContext(activeContext);
    activeContext = null;

    menu.notifyListeners(SWT.Show, new Event());
    assertFalse("after deactivation", aci.isVisible());
    menu.notifyListeners(SWT.Hide, new Event());

    menuService.releaseContributions(manager);
    menuService.removeContributionFactory(factory);
    manager.dispose();
  }
コード例 #8
0
 /* (non-Javadoc)
  * @see org.eclipse.ui.application.ActionBarAdvisor#fillMenuBar(org.eclipse.jface.action.IMenuManager)
  */
 @Override
 protected void fillMenuBar(IMenuManager menuBar) {
   MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
   ActionContributionItem preferencesItem = new ActionContributionItem(preferenceAction);
   preferencesItem.setVisible(!SWT.getPlatform().equals("carbon"));
   fileMenu.add(preferencesItem);
   menuBar.add(fileMenu);
   fileMenu.add(exitAction);
 }
コード例 #9
0
  public void testExecPidMenu() throws Exception {
    ILaunchConfigurationWorkingCopy config =
        createConfiguration(proj.getProject()).getWorkingCopy();
    config.setAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, true);
    config.doSave();
    doLaunch(config, "testExec"); // $NON-NLS-1$

    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    MassifViewPart dynamicView = (MassifViewPart) view.getDynamicView();
    MassifOutput output = dynamicView.getOutput();

    MassifPidMenuAction menuAction = null;
    IToolBarManager manager = view.getViewSite().getActionBars().getToolBarManager();
    for (IContributionItem item : manager.getItems()) {
      if (item instanceof ActionContributionItem
          && ((ActionContributionItem) item).getAction() instanceof MassifPidMenuAction) {
        menuAction = (MassifPidMenuAction) ((ActionContributionItem) item).getAction();
      }
    }

    assertNotNull(menuAction);

    Integer[] pids = dynamicView.getOutput().getPids();
    Shell shell = new Shell(Display.getCurrent());
    Menu pidMenu = menuAction.getMenu(shell);

    assertEquals(2, pidMenu.getItemCount());
    ActionContributionItem firstPid = (ActionContributionItem) pidMenu.getItem(0).getData();
    ActionContributionItem secondPid = (ActionContributionItem) pidMenu.getItem(1).getData();

    // check initial state
    assertTrue(firstPid.getAction().isChecked());
    assertFalse(secondPid.getAction().isChecked());
    assertEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());

    // select second pid
    selectItem(pidMenu, 1);

    assertFalse(firstPid.getAction().isChecked());
    assertTrue(secondPid.getAction().isChecked());
    assertEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());

    // select second pid again
    selectItem(pidMenu, 1);

    assertFalse(firstPid.getAction().isChecked());
    assertTrue(secondPid.getAction().isChecked());
    assertEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());

    // select first pid
    selectItem(pidMenu, 0);

    assertTrue(firstPid.getAction().isChecked());
    assertFalse(secondPid.getAction().isChecked());
    assertEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());
  }
コード例 #10
0
  public void testBasicContribution() throws Exception {

    IAction a =
        new Action() {
          @Override
          public void run() {
            System.out.println("Hello action");
          }
        };
    final MenuManager manager = new MenuManager();
    final ActionContributionItem item = new ActionContributionItem(a);
    final Expression activeContextExpr =
        new ActiveContextExpression(
            MenuContributionHarness.CONTEXT_TEST1_ID, new String[] {ISources.ACTIVE_CONTEXT_NAME});
    AbstractContributionFactory factory =
        new AbstractContributionFactory(LOCATION, TestPlugin.PLUGIN_ID) {
          @Override
          public void createContributionItems(
              IServiceLocator menuService, IContributionRoot additions) {
            additions.addContributionItem(item, activeContextExpr);
          }
        };

    menuService.addContributionFactory(factory);
    menuService.populateContributionManager(manager, LOCATION);

    Shell shell = window.getShell();

    // Test the initial menu creation
    final Menu menuBar = manager.createContextMenu(shell);
    Event e = new Event();
    e.type = SWT.Show;
    e.widget = menuBar;
    menuBar.notifyListeners(SWT.Show, e);

    assertFalse("starting state", item.isVisible());

    activeContext = contextService.activateContext(MenuContributionHarness.CONTEXT_TEST1_ID);
    menuBar.notifyListeners(SWT.Show, e);

    assertTrue("active context", item.isVisible());

    contextService.deactivateContext(activeContext);
    activeContext = null;
    menuBar.notifyListeners(SWT.Show, e);

    assertFalse("after deactivation", item.isVisible());

    menuService.releaseContributions(manager);
    menuService.removeContributionFactory(factory);
    manager.dispose();
  }
コード例 #11
0
ファイル: ChartTests.java プロジェクト: rafaelmt/linuxtools
 private IAction getChartAction(IViewPart view) {
   IAction result = null;
   IToolBarManager manager = view.getViewSite().getActionBars().getToolBarManager();
   for (IContributionItem item : manager.getItems()) {
     if (item instanceof ActionContributionItem) {
       ActionContributionItem actionItem = (ActionContributionItem) item;
       if (actionItem.getAction().getId().equals(MassifViewPart.CHART_ACTION)) {
         result = actionItem.getAction();
       }
     }
   }
   return result;
 }
コード例 #12
0
  @Override
  public Menu getMenu(Control parent) {
    if (fMenu == null) {
      fMenu = new Menu(parent);
      OpenNewPHPInterfaceWizardAction interfaceAction = new OpenNewPHPInterfaceWizardAction();
      interfaceAction.init(window);

      ActionContributionItem item = new ActionContributionItem(interfaceAction);
      item.fill(fMenu, -1);
      item = new ActionContributionItem(this);
      item.fill(fMenu, -1);
    }
    return fMenu;
  }
コード例 #13
0
ファイル: EventTable.java プロジェクト: mercatis/Lighthouse
  private void createMenu() {
    MenuManager menuMgr = new MenuManager("Events", CONTEXT_MENU_ID);

    ActionContributionItem aItem =
        new ActionContributionItem(
            new AddColumnAsFilterCriteriaAction(site.getWorkbenchWindow(), this));
    aItem.setId("lighthouse.events.actions.filterCriteria");
    menuMgr.add(aItem);
    ActionContributionItem bItem =
        new ActionContributionItem(
            new CreateFilterFromCriteriaAction(site.getWorkbenchWindow(), lighthouseDomain));
    bItem.setId("lighthouse.events.actions.eventToFilter");
    menuMgr.add(bItem);
    menuMgr.add(new Separator());
    ActionContributionItem cItem =
        new ActionContributionItem(new CopyEventXmlAction(site.getWorkbenchWindow()));
    cItem.setId(CopyEventXmlAction.ID);
    menuMgr.add(cItem);
    ActionContributionItem dItem =
        new ActionContributionItem(new CopyEventAsCsvAction(site.getWorkbenchWindow(), this));
    dItem.setId(CopyEventAsCsvAction.ID);
    menuMgr.add(dItem);
    menuMgr.add(new Separator(EVENT_TABLE_ADDITIONS));
    tableMenu = menuMgr.createContextMenu(site.getShell());

    tableViewer.getControl().setMenu(menuMgr.getMenu());
    site.registerContextMenu(CONTEXT_MENU_ID, menuMgr, tableViewer);
  }
コード例 #14
0
  /** Creates and returns the Window menu. */
  private MenuManager createWindowMenu() {
    MenuManager menu = new MenuManager(Messages.WindowMenuName, IWorkbenchActionConstants.M_WINDOW);

    addPerspectiveActions(menu);
    Separator sep = new Separator(IWorkbenchActionConstants.MB_ADDITIONS);
    sep.setVisible(!Util.isMac());
    menu.add(sep);

    // See the comment for quit in createFileMenu
    ActionContributionItem openPreferencesItem = new ActionContributionItem(openPreferencesAction);
    openPreferencesItem.setVisible(!Util.isMac());
    menu.add(openPreferencesItem);

    menu.add(ContributionItemFactory.OPEN_WINDOWS.create(getWindow()));
    return menu;
  }
コード例 #15
0
 private DisplayMode getCurrentMode() {
   String actionText = changeModeAction.getAction().getText();
   for (DisplayMode aMode : DisplayMode.values()) {
     if (aMode.getText().equals(actionText)) return aMode;
   }
   return null;
 }
コード例 #16
0
 private void addActions(Menu menu) { // add repository action
   Presentation selectedPresentation = view.getContentProvider().getPresentation();
   for (final Presentation presentation : Presentation.values()) {
     Action action =
         new Action() {
           @Override
           public void run() {
             view.getContentProvider().setPresentation(presentation);
           }
         };
     action.setText(presentation.toString());
     action.setChecked(presentation == selectedPresentation);
     ActionContributionItem item = new ActionContributionItem(action);
     item.fill(menu, -1);
   }
 }
コード例 #17
0
 protected IAction getPyUnitViewAction(ViewPart view, Class<?> class1) {
   IAction action = null;
   IContributionItem[] items = view.getViewSite().getActionBars().getToolBarManager().getItems();
   for (IContributionItem iContributionItem : items) {
     if (iContributionItem instanceof ActionContributionItem) {
       ActionContributionItem item = (ActionContributionItem) iContributionItem;
       IAction lAction = item.getAction();
       if (class1.isInstance(lAction)) {
         action = lAction;
       }
     }
   }
   if (action == null) {
     fail("Could not find action of class: " + class1);
   }
   return action;
 }
コード例 #18
0
  private void initializeToolbars(Composite parent) {
    ToolBarManager tbm = CompareViewerPane.getToolBarManager(parent);
    if (tbm != null) {
      tbm.removeAll();

      // define groups
      tbm.add(new Separator("modes")); // $NON-NLS-1$
      tbm.add(new Separator("merge")); // $NON-NLS-1$
      tbm.add(new Separator("navigation")); // $NON-NLS-1$

      CompareConfiguration cc = getCompareConfiguration();

      if (cc.isRightEditable()) {
        fCopyLeftToRightAction =
            new Action() {
              public void run() {
                copy(true);
              }
            };
        Utilities.initAction(
            fCopyLeftToRightAction, getResourceBundle(), "action.CopyLeftToRight."); // $NON-NLS-1$
        tbm.appendToGroup("merge", fCopyLeftToRightAction); // $NON-NLS-1$
        fHandlerService.registerAction(
            fCopyLeftToRightAction, "org.eclipse.compare.copyAllLeftToRight"); // $NON-NLS-1$
      }

      if (cc.isLeftEditable()) {
        fCopyRightToLeftAction =
            new Action() {
              public void run() {
                copy(false);
              }
            };
        Utilities.initAction(
            fCopyRightToLeftAction, getResourceBundle(), "action.CopyRightToLeft."); // $NON-NLS-1$
        tbm.appendToGroup("merge", fCopyRightToLeftAction); // $NON-NLS-1$
        fHandlerService.registerAction(
            fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); // $NON-NLS-1$
      }

      final ChangePropertyAction a =
          new ChangePropertyAction(
              fBundle,
              getCompareConfiguration(),
              "action.EnableAncestor.",
              ICompareUIConstants.PROP_ANCESTOR_VISIBLE); // $NON-NLS-1$
      a.setChecked(fAncestorVisible);
      fAncestorItem = new ActionContributionItem(a);
      fAncestorItem.setVisible(false);
      tbm.appendToGroup("modes", fAncestorItem); // $NON-NLS-1$
      tbm.getControl().addDisposeListener(a);

      createToolItems(tbm);
      updateToolItems();

      tbm.update(true);
    }
  }
コード例 #19
0
  /**
   * Create on the table manger the toolbar actions for the outline. The actions are created only if
   * the toolbar manager dosen't contains them already. Actually the added action are the one the
   * show the standard outline and the one to show the thumbnail of the report.
   *
   * @param tbm the toolbar manager for the outline.
   */
  public void registerToolbarAction(IToolBarManager tbm) {
    IContributionItem items[] = tbm.getItems();
    HashSet<String> existingItems = new HashSet<String>();
    for (IContributionItem item : items) {
      existingItems.add(item.getId());
    }

    showOutlineAction =
        new Action() {
          @Override
          public void run() {
            showPage(ID_ACTION_OUTLINE);
          }
        };
    showOutlineAction.setId(ID_ACTION_OUTLINE);
    showOutlineAction.setImageDescriptor(
        JaspersoftStudioPlugin.getInstance()
            .getImageDescriptor("icons/outline.gif")); // $NON-NLS-1$
    showOutlineAction.setToolTipText(Messages.JDReportOutlineView_show_outline_tool_tip);
    if (!existingItems.contains(ID_ACTION_OUTLINE)) {
      ActionContributionItem showOutlineItem = new ActionContributionItem(showOutlineAction);
      showOutlineItem.setVisible(true);
      tbm.add(showOutlineItem);
    }

    showOverviewAction =
        new Action() {
          @Override
          public void run() {
            showPage(ID_ACTION_OVERVIEW);
          }
        };
    showOverviewAction.setId(ID_ACTION_OVERVIEW);
    showOverviewAction.setImageDescriptor(
        JaspersoftStudioPlugin.getInstance()
            .getImageDescriptor("icons/overview.gif")); // $NON-NLS-1$
    showOverviewAction.setToolTipText(Messages.JDReportOutlineView_show_overview_tool_tip);
    if (!existingItems.contains(ID_ACTION_OVERVIEW)) {
      ActionContributionItem showOverviewItem = new ActionContributionItem(showOverviewAction);
      showOverviewItem.setVisible(true);
      tbm.add(showOverviewItem);
    }
  }
コード例 #20
0
 private void setAncestorVisibility(boolean visible, boolean enabled) {
   if (fAncestorItem != null) {
     Action action = (Action) fAncestorItem.getAction();
     if (action != null) {
       action.setChecked(visible);
       action.setEnabled(enabled);
     }
   }
   getCompareConfiguration()
       .setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, new Boolean(visible));
 }
コード例 #21
0
 /**
  * @see com.aptana.ide.core.ui.widgets.ToolTip#shouldCreateToolTip(org.eclipse.swt.widgets.Event)
  */
 protected boolean shouldCreateToolTip(Event event) {
   boolean shouldCreateToolTip = super.shouldCreateToolTip(event);
   if (shouldCreateToolTip) {
     ToolItem item = tb.getItem(new Point(event.x, event.y));
     if (item == null) {
       return false;
     }
     Object data2 = item.getData();
     ContributionItem citem = (ContributionItem) data2;
     if (citem instanceof ActionContributionItem) {
       ActionContributionItem cm = (ActionContributionItem) citem;
       IAction action = cm.getAction();
       String id = action.getId();
       if (id != null) {
         if (id.equals(this.id)) {
           return true;
         }
       }
     }
   }
   return false;
 }
コード例 #22
0
    public final void testAdditionalNonePresent() {
      ShapeWrapper sw =
          new ShapeWrapper(
              "rect",
              new RectangleShape(
                  new WorldLocation(12.1, 12.3, 12), new WorldLocation(1.1, 1.1, 12)),
              Color.red,
              new HiResDate(2222));
      Editable[] editables = new Editable[] {sw};
      MenuManager menu = new MenuManager("Holder");

      RightClickSupport.getDropdownListFor(menu, editables, null, null, null, true);

      boolean foundTransparent = false;

      // note: this next test may return 4 if run from within IDE,
      // some contributions provided by plugins
      assertEquals("Has items", 2, menu.getSize(), 2);

      IContributionItem[] items = menu.getItems();
      for (int i = 0; i < items.length; i++) {
        IContributionItem thisI = items[i];
        if (thisI instanceof MenuManager) {
          MenuManager subMenu = (MenuManager) thisI;
          IContributionItem[] subItems = subMenu.getItems();
          for (int j = 0; j < subItems.length; j++) {
            IContributionItem subI = subItems[j];
            if (subI instanceof ActionContributionItem) {
              ActionContributionItem ac = (ActionContributionItem) subI;
              String theName = ac.getAction().getText();
              if (theName.equals("Semi transparent")) foundTransparent = true;
            }
          }
        }
      }

      assertTrue("The additional bean info got processed!", foundTransparent);
    }
コード例 #23
0
  private void internalRefresh(Object input) {

    IMergeViewerContentProvider content = getMergeContentProvider();
    if (content == null) {
      return;
    }
    Object ancestor = content.getAncestorContent(input);
    boolean oldFlag = fIsThreeWay;
    if (Utilities.isHunk(input)) {
      fIsThreeWay = true;
    } else if (input instanceof ICompareInput)
      fIsThreeWay = (((ICompareInput) input).getKind() & Differencer.DIRECTION_MASK) != 0;
    else fIsThreeWay = ancestor != null;

    if (fAncestorItem != null) fAncestorItem.setVisible(fIsThreeWay);

    if (fAncestorVisible && oldFlag != fIsThreeWay) fComposite.layout(true);

    Object left = content.getLeftContent(input);
    Object right = content.getRightContent(input);
    updateContent(ancestor, left, right);

    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=453799
    // Content provider may be disposed after call to updateContent()
    content = getMergeContentProvider();
    if (content == null) {
      return;
    }

    updateHeader();
    ToolBarManager tbm = CompareViewerPane.getToolBarManager(fComposite.getParent());
    if (tbm != null) {
      updateToolItems();
      tbm.update(true);
      tbm.getControl().getParent().layout(true);
    }
  }
コード例 #24
0
 // TODO: should have better way of doing this
 @Override
 protected void setManualFilteringAndLinkingEnabled(boolean on) {
   IViewPart part = super.getPartForAction();
   if (part instanceof CommonNavigator) {
     for (IContributionItem item :
         ((CommonNavigator) part).getViewSite().getActionBars().getToolBarManager().getItems()) {
       if (item instanceof ActionContributionItem) {
         ActionContributionItem actionItem = (ActionContributionItem) item;
         if (actionItem.getAction() instanceof LinkEditorAction) {
           actionItem.getAction().setEnabled(on);
         }
       }
     }
     for (IContributionItem item :
         ((CommonNavigator) part).getViewSite().getActionBars().getMenuManager().getItems()) {
       if (item instanceof ActionContributionItem) {
         ActionContributionItem actionItem = (ActionContributionItem) item;
         if (actionItem.getAction() instanceof SelectFiltersAction) {
           actionItem.getAction().setEnabled(on);
         }
       }
     }
   }
 }
 public void setRemoveEnabled(boolean enabled) {
   removeToolbarContributionItem.getAction().setEnabled(enabled);
   removeMenuContributionItem.getAction().setEnabled(enabled);
 }
コード例 #26
0
 protected void addActionToMenu(Menu parent, Action action) {
   ActionContributionItem item = new ActionContributionItem(action);
   item.fill(parent, -1);
 }
コード例 #27
0
  /**
   * The menu to show in the workbench menu
   *
   * @param menu the menu to fill entries into it
   */
  protected void fillMenu(Menu menu) {

    IWorkbenchPart activePart = JavaPlugin.getActivePage().getActivePart();
    if (!(activePart instanceof CompilationUnitEditor)) {
      ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION);
      item.fill(menu, -1);
      return;
    }

    CompilationUnitEditor editor = (CompilationUnitEditor) activePart;
    if (editor.isBreadcrumbActive()) {
      ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION);
      item.fill(menu, -1);
      return;
    }

    IAction[] actions = getTemplateActions(editor);

    boolean addSurroundWith = !isInJavadoc(editor);
    if (addSurroundWith) {
      SurroundWithTryCatchAction surroundAction = createSurroundWithTryCatchAction(editor);
      ActionContributionItem surroundItem = new ActionContributionItem(surroundAction);
      surroundItem.fill(menu, -1);
    }

    boolean hasTemplateActions = actions != null && actions.length > 0;
    if (!hasTemplateActions && !addSurroundWith) {
      ActionContributionItem item = new ActionContributionItem(NONE_APPLICABLE_ACTION);
      item.fill(menu, -1);
    } else if (hasTemplateActions) {
      if (addSurroundWith) {
        Separator templateGroup = new Separator(TEMPLATE_GROUP);
        templateGroup.fill(menu, -1);
      }

      for (int i = 0; i < actions.length; i++) {
        ActionContributionItem item = new ActionContributionItem(actions[i]);
        item.fill(menu, -1);
      }
    }

    Separator configGroup = new Separator(CONFIG_GROUP);
    configGroup.fill(menu, -1);

    ActionContributionItem configAction =
        new ActionContributionItem(new ConfigureTemplatesAction());
    configAction.fill(menu, -1);
  }
コード例 #28
0
 protected Control createContents(Composite parent) {
   getShell().setText("Action/Contribution Example");
   parent.setSize(290, 150);
   aci.fill(parent);
   return parent;
 }
コード例 #29
0
 private boolean getSingleValueMode() {
   if (singleValueToggleAction != null) return singleValueToggleAction.getAction().isChecked();
   return false;
 }
コード例 #30
0
ファイル: GridViewer.java プロジェクト: Tagin/aurora-ide
 private ActionContributionItem createActionContributionItem(IAction action) {
   ActionContributionItem aci = new ActionContributionItem(action);
   aci.setMode(ActionContributionItem.MODE_FORCE_TEXT);
   return aci;
 }