Search in sources :

Example 21 with RowData

use of org.eclipse.swt.layout.RowData in project netxms by netxms.

the class InputFields method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    objectTool = (ObjectToolDetails) getElement().getAdapter(ObjectToolDetails.class);
    for (InputField f : objectTool.getInputFields()) fields.add(new InputField(f));
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = 2;
    gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT * 6;
    viewer.getTable().setLayoutData(gd);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new InputFieldLabelProvider());
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            return ((InputField) e1).getSequence() - ((InputField) e2).getSequence();
        }
    });
    setupTableColumns();
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            buttonEdit.setEnabled(selection.size() == 1);
            buttonRemove.setEnabled(selection.size() > 0);
            buttonUp.setEnabled(selection.size() == 1);
            buttonDown.setEnabled(selection.size() == 1);
        }
    });
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            editField();
        }
    });
    viewer.setInput(fields.toArray());
    Composite buttonsLeft = new Composite(dialogArea, SWT.NONE);
    RowLayout buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonsLeft.setLayout(buttonLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
    buttonsLeft.setLayoutData(gd);
    buttonUp = new Button(buttonsLeft, SWT.PUSH);
    buttonUp.setText(Messages.get().InputFields_Up);
    buttonUp.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveFieldUp();
        }
    });
    RowData rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonUp.setLayoutData(rd);
    buttonUp.setEnabled(false);
    buttonDown = new Button(buttonsLeft, SWT.PUSH);
    buttonDown.setText(Messages.get().InputFields_Down);
    buttonDown.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveFieldDown();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonDown.setLayoutData(rd);
    buttonDown.setEnabled(false);
    Composite buttonsRight = new Composite(dialogArea, SWT.NONE);
    buttonLayout = new RowLayout();
    buttonLayout.type = SWT.HORIZONTAL;
    buttonLayout.pack = false;
    buttonLayout.marginWidth = 0;
    buttonsRight.setLayout(buttonLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
    buttonsRight.setLayoutData(gd);
    buttonAdd = new Button(buttonsRight, SWT.PUSH);
    buttonAdd.setText(Messages.get().Columns_Add);
    buttonAdd.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            addField();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonAdd.setLayoutData(rd);
    buttonEdit = new Button(buttonsRight, SWT.PUSH);
    buttonEdit.setText(Messages.get().Columns_Edit);
    buttonEdit.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            editField();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonEdit.setLayoutData(rd);
    buttonEdit.setEnabled(false);
    buttonRemove = new Button(buttonsRight, SWT.PUSH);
    buttonRemove.setText(Messages.get().Columns_Delete);
    buttonRemove.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeField();
        }
    });
    rd = new RowData();
    rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
    buttonRemove.setLayoutData(rd);
    buttonRemove.setEnabled(false);
    return dialogArea;
}
Also used : InputField(org.netxms.client.objecttools.InputField) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InputFieldLabelProvider(org.netxms.ui.eclipse.objecttools.propertypages.helpers.InputFieldLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 22 with RowData

use of org.eclipse.swt.layout.RowData in project pmd-eclipse-plugin by pmd.

the class PMDPreferencePage2 method layoutControls.

/**
 * Main layout
 *
 * @param parent
 *            Composite
 */
private void layoutControls(Composite parent) {
    GridLayout layout = new GridLayout(1, false);
    layout.verticalSpacing = 10;
    parent.setLayout(layout);
    Composite checkboxPanel = new Composite(parent, 0);
    RowLayout checkboxPanelLayout = new RowLayout(SWT.VERTICAL);
    checkboxPanelLayout.fill = true;
    checkboxPanelLayout.pack = false;
    checkboxPanel.setLayout(checkboxPanelLayout);
    checkboxPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    final Button checkButton = new Button(checkboxPanel, SWT.CHECK);
    globalRuleManagementCheckButton = checkButton;
    final Composite contentPanel = new Composite(parent, 0);
    contentPanel.setLayout(new FormLayout());
    contentPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
    checkButton.setText(SWTUtil.stringFor(StringKeys.PREF_RULESET_BUTTON_GLOBALRULEMANAGEMENT));
    checkButton.setSelection(preferences.getGlobalRuleManagement());
    checkButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean sel = checkButton.getSelection();
            SWTUtil.setEnabledRecursive(contentPanel.getChildren(), sel);
            setModified();
        }
    });
    Label explanation = new Label(checkboxPanel, SWT.WRAP);
    RowData rowData = new RowData();
    rowData.width = 450;
    explanation.setLayoutData(rowData);
    explanation.setText(SWTUtil.stringFor(StringKeys.PREF_RULESET_BUTTON_GLOBALRULEMANAGEMENT_EXPL));
    // PreferenceUIStore.instance.tableFraction();
    int ruleTableFraction = 55;
    // Create the sash first, so the other controls can be attached to it.
    final Sash sash = new Sash(contentPanel, SWT.HORIZONTAL);
    FormData data = new FormData();
    // attach to left
    data.left = new FormAttachment(0, 0);
    // attach to right
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(ruleTableFraction, 0);
    sash.setLayoutData(data);
    sash.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // Re-attach to the top edge, and we use the y value of the
            // event to determine the offset from the top
            ((FormData) sash.getLayoutData()).top = new FormAttachment(0, event.y);
            // PreferenceUIStore.instance.tableFraction(event.y);
            contentPanel.layout();
        }
    });
    // Create the first text box and attach its bottom edge to the sash
    Composite ruleSection = createRuleSection(contentPanel);
    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(sash, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    ruleSection.setLayoutData(data);
    // Create the second text box and attach its top edge to the sash
    TabFolder propertySection = buildTabFolder(contentPanel);
    data = new FormData();
    data.top = new FormAttachment(sash, 0);
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    propertySection.setLayoutData(data);
    SWTUtil.setEnabledRecursive(contentPanel.getChildren(), checkButton.getSelection());
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) Sash(org.eclipse.swt.widgets.Sash) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) TabFolder(org.eclipse.swt.widgets.TabFolder) GridLayout(org.eclipse.swt.layout.GridLayout) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 23 with RowData

use of org.eclipse.swt.layout.RowData in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method createButton.

private void createButton(Composite container) {
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new RowLayout(SWT.VERTICAL));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    Button btnCreate = new Button(composite, SWT.NONE);
    btnCreate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sendTelemetry("CREATE");
            EventUtil.logEvent(EventType.info, WEBAPP, OPEN_CREATEWEBAPP_DIALOG, buildProperties());
            createAppService(project);
        }
    });
    btnCreate.setText("Create...");
    btnDelete = new Button(composite, SWT.NONE);
    btnDelete.setEnabled(false);
    btnDelete.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sendTelemetry("DELETE");
            deleteAppService();
        }
    });
    btnDelete.setText("Delete...");
    Button btnRefresh = new Button(composite, SWT.NONE);
    btnRefresh.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sendTelemetry("REFRESH");
            EventUtil.executeWithLog(WEBAPP, REFRESH_METADATA, (operation) -> {
                table.removeAll();
                fillAppServiceDetails();
                doFillTable(true);
            });
        }
    });
    btnRefresh.setText("Refresh");
    btnDeployToRoot = new Button(composite, SWT.CHECK);
    btnDeployToRoot.setSelection(true);
    btnDeployToRoot.setText("Deploy to root");
    int size = btnDeployToRoot.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    btnCreate.setLayoutData(new RowData(size, SWT.DEFAULT));
    btnDelete.setLayoutData(new RowData(size, SWT.DEFAULT));
    btnRefresh.setLayoutData(new RowData(size, SWT.DEFAULT));
    btnDeployToRoot.setLayoutData(new RowData(size, SWT.DEFAULT));
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Azure(com.microsoft.azure.toolkit.lib.Azure) DefaultToolTip(org.eclipse.jface.window.DefaultToolTip) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) CommonUtils(com.microsoft.azuretools.webapp.util.CommonUtils) PluginUtil(com.microsoft.azuretools.core.utils.PluginUtil) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) REFRESH_METADATA(com.microsoft.azuretools.telemetry.TelemetryConstants.REFRESH_METADATA) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) IWebAppDeploymentSlot(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppDeploymentSlot) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ILog(org.eclipse.core.runtime.ILog) PlatformUI(org.eclipse.ui.PlatformUI) Runtime(com.microsoft.azure.toolkit.lib.appservice.model.Runtime) UpdateProgressIndicator(com.microsoft.azuretools.core.utils.UpdateProgressIndicator) ErrorType(com.microsoft.azuretools.telemetrywrapper.ErrorType) Status(org.eclipse.core.runtime.Status) JavaVersion(com.microsoft.azure.toolkit.lib.appservice.model.JavaVersion) CountDownLatch(java.util.concurrent.CountDownLatch) Window(org.eclipse.jface.window.Window) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) SWT(org.eclipse.swt.SWT) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) SimpleDateFormat(java.text.SimpleDateFormat) CREATE_WEBAPP_SLOT(com.microsoft.azuretools.telemetry.TelemetryConstants.CREATE_WEBAPP_SLOT) IProject(org.eclipse.core.resources.IProject) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) ErrorWindow(com.microsoft.azuretools.core.ui.ErrorWindow) DefaultLoader(com.microsoft.tooling.msservices.components.DefaultLoader) WebComponentExportDataModelProvider(org.eclipse.jst.j2ee.internal.web.archive.operations.WebComponentExportDataModelProvider) GridData(org.eclipse.swt.layout.GridData) RowData(org.eclipse.swt.layout.RowData) Link(org.eclipse.swt.widgets.Link) IWebAppBase(com.microsoft.azure.toolkit.lib.appservice.service.IWebAppBase) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) TableItem(org.eclipse.swt.widgets.TableItem) Shell(org.eclipse.swt.widgets.Shell) DELETE_WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.DELETE_WEBAPP) IOException(java.io.IOException) Mono(reactor.core.publisher.Mono) DataModelFactory(org.eclipse.wst.common.frameworks.datamodel.DataModelFactory) File(java.io.File) ProgressDialog(com.microsoft.azuretools.core.utils.ProgressDialog) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) GridLayout(org.eclipse.swt.layout.GridLayout) Activator(com.microsoft.azuretools.webapp.Activator) URL(java.net.URL) Date(java.util.Date) DEPLOY_WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.DEPLOY_WEBAPP) TableColumn(org.eclipse.swt.widgets.TableColumn) MavenUtils(com.microsoft.azuretools.core.utils.MavenUtils) IncrementalProjectBuilder(org.eclipse.core.resources.IncrementalProjectBuilder) IStatus(org.eclipse.core.runtime.IStatus) WebContainer(com.microsoft.azure.toolkit.lib.appservice.model.WebContainer) AzureWebAppMvpModel(com.microsoft.azuretools.core.mvp.model.webapp.AzureWebAppMvpModel) Button(org.eclipse.swt.widgets.Button) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) UUID(java.util.UUID) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) List(java.util.List) AzureDeploymentProgressNotification(com.microsoft.azuretools.core.ui.views.AzureDeploymentProgressNotification) Optional(java.util.Optional) Label(org.eclipse.swt.widgets.Label) WEBAPP(com.microsoft.azuretools.telemetry.TelemetryConstants.WEBAPP) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) OPEN_CREATEWEBAPP_DIALOG(com.microsoft.azuretools.telemetry.TelemetryConstants.OPEN_CREATEWEBAPP_DIALOG) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) Table(org.eclipse.swt.widgets.Table) IWebApp(com.microsoft.azure.toolkit.lib.appservice.service.IWebApp) FocusListener(org.eclipse.swt.events.FocusListener) IAppServicePlan(com.microsoft.azure.toolkit.lib.appservice.service.IAppServicePlan) Schedulers(reactor.core.scheduler.Schedulers) FillLayout(org.eclipse.swt.layout.FillLayout) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) Combo(org.eclipse.swt.widgets.Combo) Job(org.eclipse.core.runtime.jobs.Job) IJ2EEComponentExportDataModelProperties(org.eclipse.jst.j2ee.datamodel.properties.IJ2EEComponentExportDataModelProperties) Group(org.eclipse.swt.widgets.Group) StringUtils(com.microsoft.azuretools.adauth.StringUtils) RowLayout(org.eclipse.swt.layout.RowLayout) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) AccessibilityUtils(com.microsoft.azuretools.core.utils.AccessibilityUtils) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) AppServiceBaseEntity(com.microsoft.azure.toolkit.lib.appservice.entity.AppServiceBaseEntity) AppInsightsClient(com.microsoft.azuretools.telemetry.AppInsightsClient) TelemetryManager(com.microsoft.azuretools.telemetrywrapper.TelemetryManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusAdapter(org.eclipse.swt.events.FocusAdapter) WebAppSettingModel(com.microsoft.azuretools.core.mvp.model.webapp.WebAppSettingModel) Control(org.eclipse.swt.widgets.Control) RowData(org.eclipse.swt.layout.RowData) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Point(org.eclipse.swt.graphics.Point)

Example 24 with RowData

use of org.eclipse.swt.layout.RowData in project yyl_example by Relucent.

the class MyRowLayout method main.

public static void main(String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell();
    RowLayout rowLayout = new RowLayout();
    rowLayout.marginTop = 10;
    rowLayout.marginLeft = 5;
    rowLayout.spacing = 2;
    // true or false
    rowLayout.wrap = true;
    rowLayout.type = SWT.HORIZONTAL;
    // # rowLayout.type = SWT.VERTICAL;
    rowLayout.pack = true;
    rowLayout.justify = false;
    new Button(shell, SWT.NONE).setText("b1");
    new Button(shell, SWT.NONE).setText("button2");
    Button b = new Button(shell, SWT.NONE);
    b.setText("btn3");
    RowData rowData = new RowData(50, 50);
    b.setLayoutData(rowData);
    shell.setLayout(rowLayout);
    shell.setText("RowLayout");
    shell.setSize(200, 200);
    shell.layout();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) RowData(org.eclipse.swt.layout.RowData) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) Display(org.eclipse.swt.widgets.Display)

Example 25 with RowData

use of org.eclipse.swt.layout.RowData in project dbeaver by serge-rider.

the class DataSourceManagementToolbar method createControl.

Control createControl(Composite parent) {
    workbenchWindow.addPageListener(pageListener);
    IWorkbenchPage activePage = workbenchWindow.getActivePage();
    if (activePage != null) {
        pageListener.pageOpened(activePage);
    }
    // Register as datasource listener in all datasources
    // We need it because at this moment there could be come already loaded registries (on startup)
    DataSourceProviderRegistry.getInstance().addDataSourceRegistryListener(DataSourceManagementToolbar.this);
    for (DataSourceRegistry registry : DataSourceRegistry.getAllRegistries()) {
        handleRegistryLoad(registry);
    }
    Composite comboGroup = new Composite(parent, SWT.NONE);
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.marginTop = 0;
    layout.marginBottom = 0;
    layout.marginWidth = 5;
    layout.marginHeight = 0;
    comboGroup.setLayout(layout);
    final int fontHeight = UIUtils.getFontHeight(parent);
    int comboWidth = fontHeight * 20;
    connectionCombo = new CSmartCombo<>(comboGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER, new ConnectionLabelProvider());
    RowData rd = new RowData();
    rd.width = comboWidth;
    connectionCombo.setLayoutData(rd);
    connectionCombo.setVisibleItemCount(15);
    connectionCombo.setWidthHint(comboWidth);
    connectionCombo.setToolTipText(CoreMessages.toolbar_datasource_selector_combo_datasource_tooltip);
    connectionCombo.addItem(null);
    connectionCombo.select(0);
    connectionCombo.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changeDataSourceSelection();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    connectionCombo.setTableFilter(new CSmartCombo.TableFilter<DBPDataSourceContainer>() {

        boolean enabled = false;

        @Override
        public String getFilterLabel() {
            return "Connected";
        }

        @Override
        public String getDefaultLabel() {
            return "All";
        }

        @Override
        public boolean isEnabled() {
            return enabled;
        }

        @Override
        public boolean setEnabled(boolean enabled) {
            this.enabled = enabled;
            return enabled;
        }

        @Override
        public boolean filter(DBPDataSourceContainer item) {
            return item != null && item.isConnected();
        }
    });
    comboWidth = fontHeight * 16;
    databaseCombo = new CSmartCombo<>(comboGroup, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER, new DatabaseLabelProvider());
    rd = new RowData();
    rd.width = comboWidth;
    databaseCombo.setLayoutData(rd);
    databaseCombo.setVisibleItemCount(15);
    databaseCombo.setWidthHint(comboWidth);
    databaseCombo.setToolTipText(CoreMessages.toolbar_datasource_selector_combo_database_tooltip);
    databaseCombo.addItem(null);
    databaseCombo.select(0);
    databaseCombo.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changeDataBaseSelection();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    resultSetSize = new Text(comboGroup, SWT.BORDER);
    resultSetSize.setTextLimit(10);
    rd = new RowData();
    rd.width = fontHeight * 4;
    resultSetSize.setLayoutData(rd);
    resultSetSize.setToolTipText(CoreMessages.toolbar_datasource_selector_resultset_segment_size);
    final DBPDataSourceContainer dataSourceContainer = getDataSourceContainer();
    if (dataSourceContainer != null) {
        resultSetSize.setText(String.valueOf(dataSourceContainer.getPreferenceStore().getInt(DBeaverPreferences.RESULT_SET_MAX_ROWS)));
    }
    //resultSetSize.setDigits(7);
    resultSetSize.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
    resultSetSize.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
        }

        @Override
        public void focusLost(FocusEvent e) {
            changeResultSetSize();
        }
    });
    comboGroup.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            DataSourceManagementToolbar.this.dispose();
        }
    });
    DBeaverUI.asyncExec(new Runnable() {

        @Override
        public void run() {
            if (workbenchWindow != null && workbenchWindow.getActivePage() != null) {
                setActivePart(workbenchWindow.getActivePage().getActivePart());
            }
        }
    });
    return comboGroup;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) RowData(org.eclipse.swt.layout.RowData) DataSourceRegistry(org.jkiss.dbeaver.registry.DataSourceRegistry) DBPDataSourceRegistry(org.jkiss.dbeaver.model.app.DBPDataSourceRegistry) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) RowLayout(org.eclipse.swt.layout.RowLayout)

Aggregations

RowData (org.eclipse.swt.layout.RowData)55 RowLayout (org.eclipse.swt.layout.RowLayout)52 Composite (org.eclipse.swt.widgets.Composite)48 Button (org.eclipse.swt.widgets.Button)45 GridData (org.eclipse.swt.layout.GridData)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)43 GridLayout (org.eclipse.swt.layout.GridLayout)40 SelectionListener (org.eclipse.swt.events.SelectionListener)33 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)26 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 Label (org.eclipse.swt.widgets.Label)26 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)25 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)25 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)21 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)21 SortableTableViewer (org.netxms.ui.eclipse.widgets.SortableTableViewer)20 Event (org.eclipse.swt.widgets.Event)15 TableViewer (org.eclipse.jface.viewers.TableViewer)12 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Text (org.eclipse.swt.widgets.Text)11