Search in sources :

Example 46 with TabItem

use of org.eclipse.swt.widgets.TabItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_TabFolder method test_getItemI.

@Test
public void test_getItemI() {
    int number = 15;
    TabItem[] items = new TabItem[number];
    for (int i = 0; i < number; i++) {
        items[i] = new TabItem(tabFolder, 0);
    }
    for (int i = 0; i < number; i++) {
        assertTrue(":a:" + String.valueOf(i), tabFolder.getItem(i).equals(items[i]));
    }
    try {
        tabFolder.getItem(number);
        fail("No exception thrown for illegal index argument");
    } catch (IllegalArgumentException e) {
    }
    try {
        tabFolder.getItem(number + 1);
        fail("No exception thrown for illegal index argument");
    } catch (IllegalArgumentException e) {
    }
    try {
        tabFolder.getItem(-1);
        fail("No exception thrown for index == -1");
    } catch (IllegalArgumentException e) {
    }
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Test(org.junit.Test)

Example 47 with TabItem

use of org.eclipse.swt.widgets.TabItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_TabFolder method test_indexOfLorg_eclipse_swt_widgets_TabItem.

@Test
public void test_indexOfLorg_eclipse_swt_widgets_TabItem() {
    int number = 10;
    TabItem[] tis = new TabItem[number];
    for (int i = 0; i < number; i++) {
        tis[i] = new TabItem(tabFolder, 0);
    }
    for (int i = 0; i < number; i++) {
        assertTrue(":a:" + i, tabFolder.indexOf(tis[i]) == i);
    }
    // 
    makeCleanEnvironment();
    for (int i = 0; i < number; i++) {
        tis[i] = new TabItem(tabFolder, 0);
    }
    for (int i = 0; i < number; i++) {
        try {
            tabFolder.indexOf(null);
            fail("No exception thrown for tabItem == null");
        } catch (IllegalArgumentException e) {
        }
    }
    // 
    makeCleanEnvironment();
    number = 20;
    TabItem[] items = new TabItem[number];
    for (int i = 0; i < number; i++) {
        items[i] = new TabItem(tabFolder, 0);
        items[i].setText(String.valueOf(i));
    }
    // another tabFolder
    TabFolder tabFolder_2 = new TabFolder(shell, 0);
    TabItem[] items_2 = new TabItem[number];
    for (int i = 0; i < number; i++) {
        items_2[i] = new TabItem(tabFolder_2, 0);
        items_2[i].setText(String.valueOf(i));
    }
    for (int i = 0; i < number; i++) {
        assertTrue(":a:" + String.valueOf(i), tabFolder.indexOf(items_2[i]) == -1);
    }
    // 
    TabFolder tabFolder2 = new TabFolder(shell, SWT.NULL);
    TabItem tabItem = new TabItem(tabFolder2, SWT.NULL);
    assertTrue(":a:", tabFolder.indexOf(tabItem) == -1);
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) TabFolder(org.eclipse.swt.widgets.TabFolder) Test(org.junit.Test)

Example 48 with TabItem

use of org.eclipse.swt.widgets.TabItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_TabFolder method test_TabFolder_getChildren.

@Test
public void test_TabFolder_getChildren() {
    ArrayList<Control> children = new ArrayList<>();
    for (int i = 0; i < 6; i++) {
        TabItem item = new TabItem(tabFolder, SWT.NONE);
        item.setText("TabItem " + i);
        Button button = new Button(tabFolder, SWT.PUSH);
        button.setText("Page " + i);
        item.setControl(button);
        children.add(button);
    }
    Label label = new Label(tabFolder, SWT.NONE);
    label.setText("Unused Child");
    children.add(label);
    assertArrayEquals(children.toArray(), tabFolder.getChildren());
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) Test(org.junit.Test)

Example 49 with TabItem

use of org.eclipse.swt.widgets.TabItem in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_TabItem method setUp.

@Override
@Before
public void setUp() {
    super.setUp();
    tabFolder = new TabFolder(shell, 0);
    tabItem = new TabItem(tabFolder, 0);
    setWidget(tabItem);
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) TabFolder(org.eclipse.swt.widgets.TabFolder) Before(org.junit.Before)

Example 50 with TabItem

use of org.eclipse.swt.widgets.TabItem in project xtext-xtend by eclipse.

the class FormatterModifyDialog method addTabPageNewAPI.

// copied from Eclipse Oxygen to support old dialog in Eclipse Photon
private final void addTabPageNewAPI(String title, IModifyDialogTabPage tabPage) {
    final TabItem tabItem = new TabItem(fTabFolder, SWT.NONE);
    applyDialogFont(tabItem.getControl());
    tabItem.setText(title);
    tabItem.setData(tabPage);
    tabItem.setControl(tabPage.createContents(fTabFolder));
    fTabPages.add(tabPage);
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem)

Aggregations

TabItem (org.eclipse.swt.widgets.TabItem)54 Composite (org.eclipse.swt.widgets.Composite)35 GridData (org.eclipse.swt.layout.GridData)33 GridLayout (org.eclipse.swt.layout.GridLayout)33 TabFolder (org.eclipse.swt.widgets.TabFolder)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)19 Button (org.eclipse.swt.widgets.Button)17 Label (org.eclipse.swt.widgets.Label)17 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 Text (org.eclipse.swt.widgets.Text)15 Combo (org.eclipse.swt.widgets.Combo)8 Group (org.eclipse.swt.widgets.Group)7 Test (org.junit.Test)7 FillLayout (org.eclipse.swt.layout.FillLayout)6 TableColumn (org.eclipse.swt.widgets.TableColumn)6 ArrayList (java.util.ArrayList)5 StyledText (org.eclipse.swt.custom.StyledText)5 TableItem (org.eclipse.swt.widgets.TableItem)5 TableViewer (org.eclipse.jface.viewers.TableViewer)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4