Search in sources :

Example 91 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project eclipse.platform.ui by eclipse-platform.

the class ToolBarManagerTest method testCreateControlWhenParentNull.

public void testCreateControlWhenParentNull() {
    Composite parent = createComposite();
    ToolBarManager manager = new ToolBarManager(DEFAULT_STYLE | SWT.VERTICAL);
    assertNull(manager.createControl(null));
    ToolBar toolBar = manager.createControl(parent);
    assertNotNull(toolBar);
    assertSame(toolBar, manager.createControl(null));
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ToolBar(org.eclipse.swt.widgets.ToolBar) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 92 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project eclipse.platform.ui by eclipse-platform.

the class ToolBarManagerTest method testDispose.

public void testDispose() {
    Composite parent = createComposite();
    ToolBar toolBar = new ToolBar(parent, DEFAULT_STYLE | SWT.VERTICAL);
    ToolBarManager manager = new ToolBarManager(toolBar);
    manager.dispose();
    assertTrue(toolBar.isDisposed());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ToolBar(org.eclipse.swt.widgets.ToolBar) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 93 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project eclipse.platform.ui by eclipse-platform.

the class ToolBarManagerTest method testSetStyleWhenToolBarDoesNotExist.

public void testSetStyleWhenToolBarDoesNotExist() {
    Composite parent = createComposite();
    ToolBarManager manager = new ToolBarManager(DEFAULT_STYLE | SWT.HORIZONTAL);
    manager.setStyle(DEFAULT_STYLE | SWT.VERTICAL);
    ToolBar toolBar = manager.createControl(parent);
    assertFalse(toolBar.isDisposed());
    verifyOrientation(toolBar, SWT.VERTICAL);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ToolBar(org.eclipse.swt.widgets.ToolBar) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Example 94 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project eclipse.platform.ui by eclipse-platform.

the class CoolBarManagerTest method testResetItemOrderBug293433.

public void testResetItemOrderBug293433() {
    IToolBarManager manager = new ToolBarManager();
    manager.add(new Action() {
    });
    coolBarManager.add(manager);
    coolBarManager.update(true);
    CoolItem[] items = coolBar.getItems();
    assertEquals(1, items.length);
    Control control = items[0].getControl();
    // reset causes items to be disposed
    coolBarManager.resetItemOrder();
    // ensure that the control was actually disposed
    assertTrue(control.isDisposed());
}
Also used : Action(org.eclipse.jface.action.Action) Control(org.eclipse.swt.widgets.Control) IToolBarManager(org.eclipse.jface.action.IToolBarManager) CoolItem(org.eclipse.swt.widgets.CoolItem) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IToolBarManager(org.eclipse.jface.action.IToolBarManager)

Example 95 with ToolBarManager

use of org.eclipse.jface.action.ToolBarManager in project eclipse.platform.ui by eclipse-platform.

the class MenuPopulationTest method testToolBarItems.

@Test
public void testToolBarItems() throws Exception {
    ToolBarManager manager = new ToolBarManager();
    menuService.populateContributionManager(manager, "toolbar:" + TEST_CONTRIBUTIONS_CACHE_ID);
    IContributionItem ici = manager.find(ID_DEFAULT);
    if (ici instanceof CommandContributionItem) {
        CommandContributionItem cmd = (CommandContributionItem) ici;
        assertIcon(cmd, ICONS_ANYTHING_GIF);
    } else if (ici instanceof HandledContributionItem) {
        assertIcon((HandledContributionItem) ici, ICONS_ANYTHING_GIF);
    } else {
        fail("Failed to find correct contribution item: " + ID_DEFAULT + ": " + ici);
    }
    ici = manager.find(ID_ALL);
    if (ici instanceof CommandContributionItem) {
        assertIcon((CommandContributionItem) ici, ICONS_MOCK_GIF);
    } else if (ici instanceof HandledContributionItem) {
        assertIcon((HandledContributionItem) ici, ICONS_MOCK_GIF);
    } else {
        fail("Failed to find correct contribution item: " + ID_ALL + ": " + ici);
    }
    ici = manager.find(ID_TOOLBAR);
    if (ici instanceof CommandContributionItem) {
        assertIcon((CommandContributionItem) ici, ICONS_VIEW_GIF);
    } else if (ici instanceof HandledContributionItem) {
        assertIcon((HandledContributionItem) ici, ICONS_VIEW_GIF);
    } else {
        fail("Failed to find correct contribution item: " + ID_TOOLBAR + ": " + ici);
    }
    manager.dispose();
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) HandledContributionItem(org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Test(org.junit.Test)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)237 Composite (org.eclipse.swt.widgets.Composite)86 ToolBar (org.eclipse.swt.widgets.ToolBar)80 Action (org.eclipse.jface.action.Action)70 GridData (org.eclipse.swt.layout.GridData)62 IToolBarManager (org.eclipse.jface.action.IToolBarManager)61 Control (org.eclipse.swt.widgets.Control)51 GridLayout (org.eclipse.swt.layout.GridLayout)49 Separator (org.eclipse.jface.action.Separator)39 List (java.util.List)35 SWT (org.eclipse.swt.SWT)33 ArrayList (java.util.ArrayList)32 IAction (org.eclipse.jface.action.IAction)29 IMenuManager (org.eclipse.jface.action.IMenuManager)27 IContributionItem (org.eclipse.jface.action.IContributionItem)25 MenuManager (org.eclipse.jface.action.MenuManager)25 Images (name.abuchen.portfolio.ui.Images)24 Messages (name.abuchen.portfolio.ui.Messages)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 Inject (javax.inject.Inject)23