Search in sources :

Example 86 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.

the class StackLayoutTab method createChildWidgets.

/**
 * Creates the widgets in the "child" group.
 */
@Override
void createChildWidgets() {
    /* Add common controls */
    super.createChildWidgets();
    /* Add TableEditors */
    comboEditor = new TableEditor(table);
    nameEditor = new TableEditor(table);
    table.addMouseListener(MouseListener.mouseDownAdapter(e -> {
        resetEditors();
        index = table.getSelectionIndex();
        if (index == -1)
            return;
        // set top layer of stack to the selected item
        setTopControl(index);
        TableItem oldItem = comboEditor.getItem();
        newItem = table.getItem(index);
        if (newItem == oldItem || newItem != lastSelected) {
            lastSelected = newItem;
            return;
        }
        table.showSelection();
        combo = new CCombo(table, SWT.READ_ONLY);
        createComboEditor(combo, comboEditor);
        nameText = new Text(table, SWT.SINGLE);
        nameText.setText(data.get(index)[NAME_COL]);
        createTextEditor(nameText, nameEditor, NAME_COL);
    }));
}
Also used : TableEditor(org.eclipse.swt.custom.TableEditor) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) StackLayout(org.eclipse.swt.custom.StackLayout) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) Group(org.eclipse.swt.widgets.Group) MouseListener(org.eclipse.swt.events.MouseListener) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) CCombo(org.eclipse.swt.custom.CCombo) Control(org.eclipse.swt.widgets.Control) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) CCombo(org.eclipse.swt.custom.CCombo) TableItem(org.eclipse.swt.widgets.TableItem) Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 87 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.

the class MJ_Table method tableEditor_multiple_controls_Snippet149.

/**
 * Snippet 149 was modified.
 * - No added columns.
 * - Button instead of progress bar.
 */
@Test
public void tableEditor_multiple_controls_Snippet149() {
    knownToBeBrokenGtk3("Snippet is broken on Gtk3. See Bug 531885");
    Shell shell = mkShell("Items should be replaced with Buttons (broken on Gtk3, Bug 531885)");
    shell.setLayout(new FillLayout());
    Table table = new Table(shell, SWT.BORDER);
    for (int i = 0; i < 20; i++) {
        TableItem item = new TableItem(table, SWT.NONE);
        item.setText("Task " + i);
        Button button = new Button(table, SWT.NONE);
        button.setText("hello world " + i);
        button.setVisible(true);
        button.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                System.out.println("Button pressed");
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        TableEditor editor = new TableEditor(table);
        editor.grabHorizontal = editor.grabVertical = true;
        editor.setEditor(button, item, 0);
    }
    shell.setSize(SWIDTH, SHEIGHT);
    shell.open();
    mainLoop(shell);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Table(org.eclipse.swt.widgets.Table) Button(org.eclipse.swt.widgets.Button) TableItem(org.eclipse.swt.widgets.TableItem) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FillLayout(org.eclipse.swt.layout.FillLayout) TableEditor(org.eclipse.swt.custom.TableEditor) Point(org.eclipse.swt.graphics.Point) SelectionListener(org.eclipse.swt.events.SelectionListener) Test(org.junit.Test)

Example 88 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project eclipse.platform.swt by eclipse.

the class Bug166720_TableEditorFlicker method main.

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    gd.widthHint = 200;
    table.setLayoutData(gd);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(100);
    for (int i = 0; i < 100; i++) {
        new TableItem(table, SWT.NONE);
    }
    TableItem[] items = table.getItems();
    for (int i = 0; i < items.length; i++) {
        TableEditor editor = new TableEditor(table);
        editor = new TableEditor(table);
        Text text = new Text(table, SWT.NONE);
        text.setText("Text" + i);
        editor.grabHorizontal = true;
        editor.setEditor(text, items[i], 0);
        editor = new TableEditor(table);
    }
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor) Display(org.eclipse.swt.widgets.Display)

Example 89 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method createAppSettingGroup.

private void createAppSettingGroup(Composite composite) {
    Group group = new Group(composite, SWT.NONE);
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(group.getFont()).setStyle(SWT.BOLD);
    Font boldFont = boldDescriptor.createFont(group.getDisplay());
    group.setFont(boldFont);
    group.setText(GROUP_APPSETTING);
    group.setToolTipText(APPSETTINGS_TOOLTIP);
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    group.setLayout(new GridLayout());
    Composite cpAppSettings = new Composite(group, SWT.NONE);
    cpAppSettings.setLayout(new GridLayout(2, false));
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gridData.heightHint = 150;
    cpAppSettings.setLayoutData(gridData);
    tblAppSettings = new Table(cpAppSettings, SWT.BORDER | SWT.FULL_SELECTION);
    tblAppSettings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tblAppSettings.setHeaderVisible(true);
    tblAppSettings.setLinesVisible(true);
    tblAppSettings.addListener(SWT.MouseDoubleClick, event -> onTblAppSettingMouseDoubleClick(event));
    tblAppSettings.addTraverseListener(new TraverseListener() {

        @Override
        public void keyTraversed(TraverseEvent e) {
            // Edit items when user press enter
            if (e.detail == SWT.TRAVERSE_RETURN) {
                TableItem[] selection = tblAppSettings.getSelection();
                if (selection.length > 0) {
                    editingTableItem(selection[0], 0);
                    e.doit = false;
                }
            }
        }
    });
    AccessibilityUtils.addAccessibilityNameForUIComponent(tblAppSettings, "App settings");
    appSettingsEditor = new TableEditor(tblAppSettings);
    appSettingsEditor.horizontalAlignment = SWT.LEFT;
    appSettingsEditor.grabHorizontal = true;
    TableColumn columnKey = new TableColumn(tblAppSettings, SWT.NONE);
    columnKey.setWidth(300);
    columnKey.setText("Key");
    TableColumn columnValue = new TableColumn(tblAppSettings, SWT.NONE);
    columnValue.setWidth(300);
    columnValue.setText("Value");
    Composite cpTableButtons = new Composite(cpAppSettings, SWT.NONE);
    cpTableButtons.setLayout(new GridLayout(1, false));
    cpTableButtons.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
    btnAppSettingsNew = new Button(cpTableButtons, SWT.NONE);
    btnAppSettingsNew.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAppSettingsNew.setText("New");
    btnAppSettingsNew.setToolTipText("New");
    btnAppSettingsNew.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    btnAppSettingsNew.addListener(SWT.Selection, event -> onBtnNewItemSelection());
    btnAppSettingsDel = new Button(cpTableButtons, SWT.NONE);
    btnAppSettingsDel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnAppSettingsDel.setText("Delete");
    btnAppSettingsDel.setToolTipText("Delete");
    btnAppSettingsDel.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    btnAppSettingsDel.addListener(SWT.Selection, event -> onBtnDeleteItemSelection());
}
Also used : AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) ResourceGroup(com.microsoft.azure.toolkit.lib.common.model.ResourceGroup) Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TraverseListener(org.eclipse.swt.events.TraverseListener) TableEditor(org.eclipse.swt.custom.TableEditor) TableColumn(org.eclipse.swt.widgets.TableColumn) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) FontDescriptor(org.eclipse.jface.resource.FontDescriptor)

Example 90 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project azure-tools-for-java by Microsoft.

the class WebAppBasePropertyEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayout glCpRoot = new GridLayout(1, false);
    glCpRoot.marginWidth = 0;
    glCpRoot.verticalSpacing = 0;
    glCpRoot.horizontalSpacing = 0;
    glCpRoot.marginHeight = 0;
    Composite cpRoot = new Composite(parent, SWT.NONE);
    cpRoot.setLayout(glCpRoot);
    progressBar = new ProgressBar(cpRoot, SWT.INDETERMINATE);
    GridData gdProgressBar = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    gdProgressBar.heightHint = PROGRESS_BAR_HEIGHT;
    progressBar.setLayoutData(gdProgressBar);
    ScrolledComposite scrolledComposite = new ScrolledComposite(cpRoot, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    Composite area = new Composite(scrolledComposite, SWT.NONE);
    GridLayout glArea = new GridLayout(1, false);
    area.setLayout(glArea);
    Composite composite = new Composite(area, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    GridLayout glComposite = new GridLayout(1, false);
    composite.setLayout(glComposite);
    Composite cpControlButtons = new Composite(composite, SWT.NONE);
    cpControlButtons.setLayout(new GridLayout(3, false));
    cpControlButtons.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
    btnGetPublishProfile = new Button(cpControlButtons, SWT.NONE);
    btnGetPublishProfile.setText("Get Publish Profile");
    btnGetPublishProfile.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_PRINT_EDIT));
    btnGetPublishProfile.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnGetPublishProfile", null) {

        @Override
        protected void handleEventFunc(Event event) {
            onBtnGetPublishProfileSelection();
        }
    });
    btnSave = new Button(cpControlButtons, SWT.NONE);
    btnSave.setText("Save");
    btnSave.setEnabled(false);
    btnSave.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT));
    btnSave.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnSave", null) {

        @Override
        protected void handleEventFunc(Event event) {
            setBtnEnableStatus(false);
            webAppBasePropertyViewPresenter.onUpdateWebAppProperty(subscriptionId, webAppId, slotName, cachedAppSettings, editedAppSettings);
        }
    });
    btnDiscard = new Button(cpControlButtons, SWT.NONE);
    btnDiscard.setText("Discard");
    btnDiscard.setEnabled(false);
    btnDiscard.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    btnDiscard.addListener(SWT.Selection, new AzureListenerWrapper(INSIGHT_NAME, "btnDiscard", null) {

        @Override
        protected void handleEventFunc(Event event) {
            updateMapStatus(editedAppSettings, cachedAppSettings);
            resetTblAppSettings(editedAppSettings);
        }
    });
    cpOverview = new Composite(composite, SWT.NONE);
    cpOverview.setLayout(new GridLayout(4, false));
    cpOverview.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblResourceGroup = new Label(cpOverview, SWT.NONE);
    lblResourceGroup.setText("Resource Group:");
    txtResourceGroup = new Text(cpOverview, SWT.NONE);
    txtResourceGroup.setEditable(false);
    txtResourceGroup.setText(TXT_LOADING);
    txtResourceGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblAppServicePlan = new Label(cpOverview, SWT.NONE);
    lblAppServicePlan.setText("App Service Plan:");
    txtAppServicePlan = new Text(cpOverview, SWT.NONE);
    txtAppServicePlan.setEditable(false);
    txtAppServicePlan.setText(TXT_LOADING);
    txtAppServicePlan.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblStatus = new Label(cpOverview, SWT.NONE);
    lblStatus.setText("Status:");
    txtStatus = new Text(cpOverview, SWT.NONE);
    txtStatus.setEditable(false);
    txtStatus.setText(TXT_LOADING);
    txtStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblUrl = new Label(cpOverview, SWT.NONE);
    lblUrl.setText("URL:");
    lnkUrl = new Link(cpOverview, SWT.NONE);
    lnkUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lnkUrl.setText(TXT_LOADING);
    // click to open browser
    lnkUrl.addListener(SWT.Selection, event -> Program.launch(event.text));
    Label lblLocation = new Label(cpOverview, SWT.NONE);
    lblLocation.setText("Location:");
    txtLocation = new Text(cpOverview, SWT.NONE);
    txtLocation.setEditable(false);
    txtLocation.setText(TXT_LOADING);
    txtLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblPricingTier = new Label(cpOverview, SWT.NONE);
    lblPricingTier.setText("Pricing Tier:");
    txtPricingTier = new Text(cpOverview, SWT.NONE);
    txtPricingTier.setEditable(false);
    txtPricingTier.setText(TXT_LOADING);
    txtPricingTier.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Label lblSubscription = new Label(cpOverview, SWT.NONE);
    lblSubscription.setText("Subscription ID:");
    txtSubscription = new Text(cpOverview, SWT.NONE);
    txtSubscription.setEditable(false);
    txtSubscription.setText(TXT_LOADING);
    txtSubscription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    cpExtraInfo = new Composite(composite, SWT.NONE);
    cpExtraInfo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    cpExtraInfo.setLayout(new GridLayout(2, false));
    lblJavaVersion = new Label(cpExtraInfo, SWT.NONE);
    lblJavaVersion.setText("Java Version:");
    txtJavaVersion = new Text(cpExtraInfo, SWT.NONE);
    txtJavaVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtJavaVersion.setEditable(false);
    txtJavaVersion.setText(TXT_LOADING);
    lblContainer = new Label(cpExtraInfo, SWT.NONE);
    lblContainer.setText("Web Container:");
    txtContainer = new Text(cpExtraInfo, SWT.NONE);
    txtContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    txtContainer.setEditable(false);
    txtContainer.setText(TXT_LOADING);
    Composite cpAppSettings = new Composite(composite, SWT.NONE);
    cpAppSettings.setLayout(new GridLayout(2, false));
    cpAppSettings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tblAppSettings = new Table(cpAppSettings, SWT.BORDER | SWT.FULL_SELECTION);
    tblAppSettings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    tblAppSettings.setHeaderVisible(true);
    tblAppSettings.setLinesVisible(true);
    tblAppSettings.addListener(SWT.MouseDoubleClick, event -> onTblAppSettingMouseDoubleClick(event));
    editor = new TableEditor(tblAppSettings);
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    TableColumn tblclmnKey = new TableColumn(tblAppSettings, SWT.NONE);
    tblclmnKey.setWidth(300);
    tblclmnKey.setText("Key");
    TableColumn tblclmnValue = new TableColumn(tblAppSettings, SWT.NONE);
    tblclmnValue.setWidth(300);
    tblclmnValue.setText("Value");
    Composite cpTableButtons = new Composite(cpAppSettings, SWT.NONE);
    cpTableButtons.setLayout(new GridLayout(1, false));
    cpTableButtons.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
    btnNewItem = new Button(cpTableButtons, SWT.NONE);
    btnNewItem.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnNewItem.setText("New");
    btnNewItem.setToolTipText("New");
    btnNewItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
    btnNewItem.setEnabled(false);
    btnNewItem.addListener(SWT.Selection, event -> onBtnNewItemSelection());
    btnDeleteItem = new Button(cpTableButtons, SWT.NONE);
    btnDeleteItem.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnDeleteItem.setText("Delete");
    btnDeleteItem.setToolTipText("Delete");
    btnDeleteItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
    btnDeleteItem.setEnabled(false);
    btnDeleteItem.addListener(SWT.Selection, event -> onBtnDeleteItemSelection());
    btnEditItem = new Button(cpTableButtons, SWT.NONE);
    btnEditItem.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    btnEditItem.setText("Edit");
    btnEditItem.setToolTipText("Edit");
    btnEditItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_CLEAR));
    btnEditItem.setEnabled(false);
    btnEditItem.addListener(SWT.Selection, event -> onBtnEditItemSelection());
    scrolledComposite.setContent(area);
    scrolledComposite.setMinSize(area.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    setExtraInfoVisible(false);
    setChildrenTransparent(cpOverview);
    setChildrenTransparent(cpExtraInfo);
    btnGetPublishProfile.setFocus();
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableEditor(org.eclipse.swt.custom.TableEditor) TableColumn(org.eclipse.swt.widgets.TableColumn) AzureListenerWrapper(com.microsoft.azuretools.core.components.AzureListenerWrapper) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Event(org.eclipse.swt.widgets.Event) ProgressBar(org.eclipse.swt.widgets.ProgressBar) Link(org.eclipse.swt.widgets.Link)

Aggregations

TableEditor (org.eclipse.swt.custom.TableEditor)124 TableItem (org.eclipse.swt.widgets.TableItem)60 GridData (org.eclipse.swt.layout.GridData)52 Table (org.eclipse.swt.widgets.Table)49 Button (org.eclipse.swt.widgets.Button)41 Text (org.eclipse.swt.widgets.Text)40 GridLayout (org.eclipse.swt.layout.GridLayout)36 Point (org.eclipse.swt.graphics.Point)33 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 Composite (org.eclipse.swt.widgets.Composite)30 Label (org.eclipse.swt.widgets.Label)29 TableColumn (org.eclipse.swt.widgets.TableColumn)27 CCombo (org.eclipse.swt.custom.CCombo)26 SWT (org.eclipse.swt.SWT)23 Control (org.eclipse.swt.widgets.Control)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 Rectangle (org.eclipse.swt.graphics.Rectangle)17 FocusEvent (org.eclipse.swt.events.FocusEvent)15 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14