Search in sources :

Example 26 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_getItems.

@Test
public void test_getItems() {
    int number = 5;
    TabItem[] items = new TabItem[number];
    assertEquals(0, tabFolder.getItems().length);
    for (int i = 0; i < number; i++) {
        items[i] = new TabItem(tabFolder, 0);
    }
    assertArrayEquals(items, tabFolder.getItems());
    tabFolder.getItems()[0].dispose();
    assertArrayEquals(new TabItem[] { items[1], items[2], items[3], items[4] }, tabFolder.getItems());
    tabFolder.getItems()[3].dispose();
    assertArrayEquals(new TabItem[] { items[1], items[2], items[3] }, tabFolder.getItems());
    tabFolder.getItems()[1].dispose();
    assertArrayEquals(new TabItem[] { items[1], items[3] }, tabFolder.getItems());
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Test(org.junit.Test)

Example 27 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_getSelection.

@Test
public void test_getSelection() {
    int number = 10;
    TabItem[] tis = new TabItem[number];
    for (int i = 0; i < number; i++) {
        tis[i] = new TabItem(tabFolder, 0);
    }
    assertTrue(":a:", tabFolder.getSelection()[0] == tis[0]);
    for (int i = 0; i < number; i++) {
        tabFolder.setSelection(i);
        assertTrue(":b:" + i, tabFolder.getSelection()[0] == tis[i]);
    }
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Test(org.junit.Test)

Example 28 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_setControl.

/**
 * Test the situation where you re-nest a child
 * between tabs dynamically. As found in 458844
 */
@Test
public void test_setControl() {
    int number = 5;
    TabItem[] items = new TabItem[number];
    final Button setControlButton = new Button(tabFolder, SWT.None);
    setControlButton.setText("test button");
    for (int i = 0; i < number; i++) {
        items[i] = new TabItem(tabFolder, 0);
        items[i].setControl(setControlButton);
        assertEquals(items[i].getControl(), setControlButton);
        assertTrue(setControlButton.getVisible());
    }
    items[0].setControl(setControlButton);
    assertEquals(items[0].getControl(), setControlButton);
    assertTrue(setControlButton.getVisible());
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Button(org.eclipse.swt.widgets.Button) Test(org.junit.Test)

Example 29 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 test_ConstructorLorg_eclipse_swt_widgets_TabFolderII.

@Test
public void test_ConstructorLorg_eclipse_swt_widgets_TabFolderII() {
    TabItem tItem = new TabItem(tabFolder, SWT.NULL, 0);
    assertTrue(":a:", tabFolder.getItems()[0] == tItem);
    tItem = new TabItem(tabFolder, SWT.NULL, 1);
    assertTrue(":b:", tabFolder.getItems()[1] == tItem);
    tItem = new TabItem(tabFolder, SWT.NULL, 1);
    assertTrue(":c:", tabFolder.getItems()[1] == tItem);
    try {
        new TabItem(tabFolder, SWT.NULL, -1);
        fail("No exception thrown");
    } catch (IllegalArgumentException e) {
    } finally {
        assertTrue(":d:", tabFolder.getItems()[1] == tItem);
    }
    try {
        new TabItem(tabFolder, SWT.NULL, tabFolder.getItemCount() + 1);
        fail("No exception thrown");
    } catch (IllegalArgumentException e) {
    } finally {
        assertTrue(":e:", tabFolder.getItems()[1] == tItem);
    }
    try {
        new TabItem(null, SWT.NULL, 0);
        fail("No exception thrown");
    } catch (IllegalArgumentException e) {
    }
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Test(org.junit.Test)

Example 30 with TabItem

use of org.eclipse.swt.widgets.TabItem in project cubrid-manager by CUBRID.

the class TableEditorPart method createFkIndexTabItem.

/**
	 * Create foreign key/Index tab item.
	 *
	 * @param tabFolder the object of TabFolder
	 */
private void createFkIndexTabItem(final TabFolder tabFolder) {
    final TabItem foreignKeyTabItem = new TabItem(tabFolder, SWT.NONE);
    foreignKeyTabItem.setText(Messages.infoIndexesTab);
    final Composite composite = new Composite(tabFolder, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    composite.setLayout(gridLayout);
    foreignKeyTabItem.setControl(composite);
    // create the fk table viewer
    final Label fkLabel = new Label(composite, SWT.NONE);
    fkLabel.setText(Messages.lblFK);
    fkTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    fkTable = fkTableView.getTable();
    final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    fkTable.setLayoutData(gdFkTable);
    fkTable.setLinesVisible(true);
    fkTable.setHeaderVisible(true);
    TableColumn tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnFK);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(119);
    tblCol.setText(Messages.tblColumnColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(93);
    tblCol.setText(Messages.tblColumnForeignTable);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(143);
    tblCol.setText(Messages.tblColumnForeignColumnName);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(84);
    tblCol.setText(Messages.tblColumnUpdateRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(86);
    tblCol.setText(Messages.tblColumnDeleteRule);
    tblCol = new TableColumn(fkTable, SWT.NONE);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnCacheColumn);
    FKTableViewerContentProvider fkContentProvider = new FKTableViewerContentProvider();
    FKTableViewerLabelProvider fkLabelProvider = new FKTableViewerLabelProvider(database.getDatabaseInfo());
    fkTableView.setContentProvider(fkContentProvider);
    fkTableView.setLabelProvider(fkLabelProvider);
    fkTableView.setInput(newSchemaInfo);
    CommonUITool.hackForYosemite(fkTableView.getTable());
    final Composite fkBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    fkBtnComposite.setLayoutData(gdBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    fkBtnComposite.setLayout(gridLayout);
    final GridData gdFKBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addFKBTN = new Button(fkBtnComposite, SWT.NONE);
    addFKBTN.setLayoutData(gdFKBTN);
    addFKBTN.setText(Messages.btnAddFk);
    addFKBTN.addSelectionListener(new AddFkBtnListenerOnFkIndexTab());
    final Button editFKBTN = new Button(fkBtnComposite, SWT.NONE);
    editFKBTN.setLayoutData(gdFKBTN);
    editFKBTN.setEnabled(false);
    editFKBTN.setText(Messages.btnEditFk);
    editFKBTN.addSelectionListener(new EditFkBtnListenerOnFkIndexTab());
    final Button deleteFKBTN = new Button(fkBtnComposite, SWT.NONE);
    deleteFKBTN.setLayoutData(gdFKBTN);
    deleteFKBTN.setEnabled(false);
    deleteFKBTN.setText(Messages.btnDelFk);
    deleteFKBTN.addSelectionListener(new DelFkBtnListenerOnFkIndexTab());
    fkTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (database == null || database.getDatabaseInfo() == null || newSchemaInfo == null) {
                return;
            }
            TableItem[] items = fkTable.getSelection();
            if (items == null || items.length == 0) {
                deleteFKBTN.setEnabled(false);
                editFKBTN.setEnabled(false);
            } else {
                deleteFKBTN.setEnabled(true);
                editFKBTN.setEnabled(items.length == 1);
                for (TableItem item : items) {
                    String fkName = item.getText(0);
                    List<SchemaInfo> superList = SuperClassUtil.getSuperClasses(database.getDatabaseInfo(), newSchemaInfo.getSuperClasses());
                    if (newSchemaInfo.isInSuperClasses(superList, fkName)) {
                        deleteFKBTN.setEnabled(false);
                        editFKBTN.setEnabled(false);
                    }
                }
            }
        }
    });
    // create index table view
    final Label indexLabel = new Label(composite, SWT.NONE);
    indexLabel.setText(Messages.lblIndexes);
    indexTableView = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    indexTable = indexTableView.getTable();
    indexTable.setLinesVisible(true);
    indexTable.setHeaderVisible(true);
    final GridData gdIndexTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    indexTable.setLayoutData(gdIndexTable);
    CommonUITool.hackForYosemite(indexTable);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(150);
    tblCol.setText(Messages.tblColumnIndexName);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(78);
    tblCol.setText(Messages.tblColumnIndexType);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(218);
    tblCol.setText(Messages.tblColumnOnColumns);
    tblCol = new TableColumn(indexTable, SWT.NONE);
    tblCol.setWidth(282);
    tblCol.setText(Messages.tblColumnIndexRule);
    if (CompatibleUtil.isCommentSupports(database.getDatabaseInfo())) {
        tblCol = new TableColumn(indexTable, SWT.NONE);
        tblCol.setWidth(250);
        tblCol.setText(Messages.tblColumnIndexMemo);
    }
    IndexTableViewerContentProvider indexContentProvider = new IndexTableViewerContentProvider();
    IndexTableViewerLabelProvider indexLabelProvider = new IndexTableViewerLabelProvider();
    indexTableView.setContentProvider(indexContentProvider);
    indexTableView.setLabelProvider(indexLabelProvider);
    indexTableView.setInput(newSchemaInfo);
    indexTableView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            StructuredSelection selected = (StructuredSelection) event.getSelection();
            if (selected == null) {
                return;
            }
            Constraint constraint = (Constraint) selected.getFirstElement();
            openEditIndexDialog(constraint);
        }
    });
    final Composite indexBtnComposite = new Composite(composite, SWT.NONE);
    final GridData gdIndexBtnComposite = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
    indexBtnComposite.setLayoutData(gdIndexBtnComposite);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    indexBtnComposite.setLayout(gridLayout);
    final GridData gdIndexBTN = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    final Button addIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    addIndexBTN.setLayoutData(gdIndexBTN);
    addIndexBTN.setText(Messages.btnAddIndex);
    addIndexBTN.addSelectionListener(new AddIndexBtnListenerOnFkIndexTab());
    final Button editIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    editIndexBTN.setLayoutData(gdIndexBTN);
    editIndexBTN.setEnabled(false);
    editIndexBTN.setText(Messages.btnEditIndex);
    editIndexBTN.addSelectionListener(new EditIndexBtnListenerOnFkIndexTab());
    final Button deleteIndexBTN = new Button(indexBtnComposite, SWT.NONE);
    deleteIndexBTN.setLayoutData(gdIndexBTN);
    deleteIndexBTN.setEnabled(false);
    deleteIndexBTN.setText(Messages.btnDelIndex);
    deleteIndexBTN.addSelectionListener(new DelIndexBtnListenerOnFkIndexTab());
    indexTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            TableItem[] items = indexTable.getSelection();
            if (items == null || items.length == 0) {
                deleteIndexBTN.setEnabled(false);
                editIndexBTN.setEnabled(false);
            } else {
                deleteIndexBTN.setEnabled(true);
                editIndexBTN.setEnabled(items.length == 1);
            }
        }
    });
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) FKTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IndexTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerContentProvider) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) IndexTableViewerLabelProvider(com.cubrid.common.ui.cubrid.table.control.IndexTableViewerLabelProvider) TabItem(org.eclipse.swt.widgets.TabItem) FKTableViewerContentProvider(com.cubrid.common.ui.cubrid.table.control.FKTableViewerContentProvider) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer)

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