Search in sources :

Example 21 with TabItem

use of org.eclipse.swt.widgets.TabItem in project dbeaver by serge-rider.

the class ConnectionPageSettings method activateCurrentItem.

private void activateCurrentItem() {
    if (tabFolder != null) {
        TabItem[] selection = tabFolder.getSelection();
        if (selection.length == 1) {
            IDialogPage page = (IDialogPage) selection[0].getData();
            page.setVisible(true);
        }
    }
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) IDialogPage(org.eclipse.jface.dialogs.IDialogPage)

Example 22 with TabItem

use of org.eclipse.swt.widgets.TabItem in project dbeaver by serge-rider.

the class ConnectionPageSettings method createProviderPage.

private void createProviderPage(Composite parent) {
    if (this.connectionEditor != null && this.connectionEditor.getControl() != null) {
        return;
    }
    if (getControl() != null) {
        getControl().dispose();
    }
    try {
        if (this.connectionEditor == null) {
            this.connectionEditor = viewDescriptor.createView(IDataSourceConnectionEditor.class);
            this.connectionEditor.setSite(this);
        }
        // init sub pages (if any)
        getSubPages();
        if (wizard.isNew() && !ArrayUtils.isEmpty(subPages)) {
            // Create tab folder
            List<IDialogPage> allPages = new ArrayList<>();
            allPages.add(connectionEditor);
            Collections.addAll(allPages, subPages);
            tabFolder = new TabFolder(parent, SWT.TOP);
            tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
            setControl(tabFolder);
            for (IDialogPage page : allPages) {
                TabItem item = new TabItem(tabFolder, SWT.NONE);
                page.createControl(tabFolder);
                item.setData(page);
                Control pageControl = page.getControl();
                item.setControl(pageControl);
                item.setText(CommonUtils.isEmpty(page.getTitle()) ? "General" : page.getTitle());
                item.setToolTipText(page.getDescription());
            }
            tabFolder.setSelection(0);
            tabFolder.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    activateCurrentItem();
                }
            });
        } else {
            // Create single editor control
            this.connectionEditor.createControl(parent);
            setControl(this.connectionEditor.getControl());
        }
        UIUtils.setHelp(getControl(), IHelpContextIds.CTX_CON_WIZARD_SETTINGS);
    } catch (Exception ex) {
        log.warn(ex);
        setErrorMessage("Can't create settings dialog: " + ex.getMessage());
    }
    parent.layout();
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Control(org.eclipse.swt.widgets.Control) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IDialogPage(org.eclipse.jface.dialogs.IDialogPage) TabFolder(org.eclipse.swt.widgets.TabFolder) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 23 with TabItem

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

the class CreateOrEditSerialDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    tabFolder = new TabFolder(composite, SWT.NONE);
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    layout = new GridLayout();
    tabFolder.setLayout(layout);
    TabItem item = new TabItem(tabFolder, SWT.NONE);
    item.setText(Messages.grpGeneral);
    composite = createGeneralInfoComp();
    item.setControl(composite);
    item = new TabItem(tabFolder, SWT.NONE);
    item.setText(Messages.grpSqlScript);
    composite = createSqlScriptComposite();
    item.setControl(composite);
    tabFolder.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (tabFolder.getSelectionIndex() == 0) {
                serialNameText.setFocus();
            } else if (tabFolder.getSelectionIndex() == tabFolder.getItemCount() - 1) {
                sqlScriptText.setText(getSQLScript());
            }
        }
    });
    initialize();
    if (editedNode == null) {
        setTitle(Messages.titleCreateSerialDialog);
        setMessage(Messages.msgCreateSerialDialog);
    } else {
        setTitle(Messages.titleEditSerialDialog);
        setMessage(Messages.msgEditSerialDialog);
    }
    return parentComp;
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) TabFolder(org.eclipse.swt.widgets.TabFolder) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 24 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)

Example 25 with TabItem

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

the class TableEditorPart method createSqlScriptTabItem.

/**
	 * Create the SQL script tab item
	 *
	 * @param tabFolder the object of TabFolder
	 */
private void createSqlScriptTabItem(final TabFolder tabFolder) {
    TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText(Messages.infoSQLScriptTab);
    Composite composite = new Composite(tabFolder, SWT.NONE);
    composite.setLayout(new GridLayout());
    tabItem.setControl(composite);
    sqlText = new StyledText(composite, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY | SWT.H_SCROLL | SWT.BORDER);
    CommonUITool.registerContextMenu(sqlText, false);
    sqlText.setBackground(white);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.heightHint = 89;
    sqlText.setLayoutData(gd);
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData)

Aggregations

TabItem (org.eclipse.swt.widgets.TabItem)31 Composite (org.eclipse.swt.widgets.Composite)27 GridLayout (org.eclipse.swt.layout.GridLayout)26 GridData (org.eclipse.swt.layout.GridData)25 TabFolder (org.eclipse.swt.widgets.TabFolder)18 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)15 Label (org.eclipse.swt.widgets.Label)13 Button (org.eclipse.swt.widgets.Button)10 Text (org.eclipse.swt.widgets.Text)9 Combo (org.eclipse.swt.widgets.Combo)6 TableViewer (org.eclipse.jface.viewers.TableViewer)5 Group (org.eclipse.swt.widgets.Group)5 ModifyEvent (org.eclipse.swt.events.ModifyEvent)4 ModifyListener (org.eclipse.swt.events.ModifyListener)4 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)3 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)3 StyledText (org.eclipse.swt.custom.StyledText)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 FormAttachment (org.eclipse.swt.layout.FormAttachment)3