Search in sources :

Example 11 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project dbeaver by serge-rider.

the class DriverManagerDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    List<DataSourceProviderDescriptor> providers = DataSourceProviderRegistry.getInstance().getDataSourceProviders();
    {
        DataSourceProviderDescriptor manProvider = null;
        for (DataSourceProviderDescriptor provider : providers) {
            if (provider.isDriversManagable()) {
                if (manProvider != null) {
                    manProvider = null;
                    break;
                }
                manProvider = provider;
            }
        }
        if (manProvider != null) {
            onlyManagableProvider = manProvider;
        }
    }
    getShell().setText(CoreMessages.dialog_driver_manager_title);
    getShell().setMinimumSize(300, 300);
    //$NON-NLS-1$
    dialogImage = DBeaverActivator.getImageDescriptor("/icons/driver_manager.png").createImage();
    getShell().setImage(dialogImage);
    Composite group = UIUtils.createPlaceholder((Composite) super.createDialogArea(parent), 2);
    group.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        treeControl = new DriverTreeControl(group, this, providers, false);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        gd.widthHint = 300;
        treeControl.setLayoutData(gd);
    }
    {
        Composite buttonBar = new Composite(group, SWT.TOP);
        buttonBar.setLayout(new GridLayout(1, false));
        GridData gd = new GridData(GridData.FILL_VERTICAL);
        gd.minimumWidth = 100;
        buttonBar.setLayoutData(gd);
        newButton = new Button(buttonBar, SWT.FLAT | SWT.PUSH);
        newButton.setText(CoreMessages.dialog_driver_manager_button_new);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.widthHint = 100;
        newButton.setLayoutData(gd);
        newButton.addSelectionListener(new SelectionListener() {

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

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        editButton = new Button(buttonBar, SWT.FLAT | SWT.PUSH);
        editButton.setText(CoreMessages.dialog_driver_manager_button_edit);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.widthHint = 100;
        editButton.setLayoutData(gd);
        editButton.addSelectionListener(new SelectionListener() {

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

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        deleteButton = new Button(buttonBar, SWT.FLAT | SWT.PUSH);
        deleteButton.setText(CoreMessages.dialog_driver_manager_button_delete);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.widthHint = 100;
        deleteButton.setLayoutData(gd);
        deleteButton.addSelectionListener(new SelectionListener() {

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

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
        {
            final Composite legend = UIUtils.createPlaceholder(buttonBar, 2, 5);
            gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.verticalIndent = 5;
            gd.horizontalSpan = 2;
            legend.setLayoutData(gd);
            UIUtils.createLabel(legend, DBIcon.OVER_LAMP);
            UIUtils.createLabel(legend, CoreMessages.dialog_driver_manager_label_user_defined);
            UIUtils.createLabel(legend, DBIcon.OVER_ERROR);
            UIUtils.createLabel(legend, CoreMessages.dialog_driver_manager_label_unavailable);
        }
    }
    descText = new Text(group, SWT.READ_ONLY);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.verticalIndent = 5;
    gd.horizontalSpan = 2;
    gd.grabExcessHorizontalSpace = true;
    descText.setLayoutData(gd);
    /*
        monitorPart = new ProgressMonitorPart(group, null, true);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.verticalIndent = 5;
        gd.horizontalSpan = 2;
        gd.grabExcessHorizontalSpace = true;
        monitorPart.setLayoutData(gd);
        monitorPart.setVisible(false);
*/
    setDefaultSelection();
    this.updateButtons();
    return group;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 12 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project dbeaver by serge-rider.

the class HexManager method createEditorPart.

/**
     * Creates editor part of parent application. Can only be called once per Manager object.
     *
     * @param parent composite where the part will be drawn.
     * @throws IllegalStateException when editor part exists already (method called twice or more)
     * @throws NullPointerException  if textsParent is null
     */
public Composite createEditorPart(Composite parent, int style) {
    if (hexEditControl != null)
        throw new IllegalStateException("Editor part exists already");
    if (parent == null)
        throw new NullPointerException("Null parent");
    textsParent = parent;
    hexEditControl = new HexEditControl(textsParent, style);
    hexEditControl.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (fontText != null && !fontText.isDisposed())
                fontText.dispose();
        }
    });
    if (fontData != null) {
        fontText = new Font(Display.getCurrent(), fontData);
        hexEditControl.setFont(fontText);
    }
    //hexEditControl.addLongSelectionListener(new ControlSelectionAdapter(ControlSelectionAdapter.UPDATE_POSITION_TEXT));
    hexEditControl.addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (statusLine != null)
                statusLine.updateInsertModeText(hexEditControl == null || !hexEditControl.isOverwriteMode());
        }
    });
    if (listOfStatusChangedListeners != null) {
        for (Listener listOfStatusChangedListener : listOfStatusChangedListeners) {
            hexEditControl.addListener(SWT.Modify, listOfStatusChangedListener);
        }
        listOfStatusChangedListeners = null;
    }
    if (listOfLongListeners != null) {
        for (SelectionListener listOfLongListener : listOfLongListeners) {
            hexEditControl.addLongSelectionListener(listOfLongListener);
        }
        listOfLongListeners = null;
    }
    {
        // Context menu
        MenuManager menuManager = new MenuManager();
        menuManager.setRemoveAllWhenShown(true);
        menuManager.addMenuListener(new IMenuListener() {

            @Override
            public void menuAboutToShow(IMenuManager manager) {
                if (menuListener != null) {
                    menuListener.menuAboutToShow(manager);
                }
            }
        });
        Menu contextMenu = menuManager.createContextMenu(hexEditControl.getHexText());
        hexEditControl.getHexText().setMenu(contextMenu);
        contextMenu = menuManager.createContextMenu(hexEditControl.getPreviewText());
        hexEditControl.getPreviewText().setMenu(contextMenu);
    //getSite().registerContextMenu(menuManager, this);
    }
    return hexEditControl;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) IMenuListener(org.eclipse.jface.action.IMenuListener) SelectionListener(org.eclipse.swt.events.SelectionListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) IMenuListener(org.eclipse.jface.action.IMenuListener) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 13 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project translationstudio8 by heartsome.

the class JaretTablePrintDialog method createPrinterSelection.

private void createPrinterSelection(Composite parent) {
    Composite area = new Composite(parent, SWT.NULL);
    area.setLayout(new RowLayout());
    // area.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
    _printerCombo = new CCombo(area, SWT.BORDER | SWT.READ_ONLY);
    _printerCombo.setItems(_printers);
    _printerCombo.select(_pIdx);
    Button select = new Button(area, SWT.PUSH);
    select.setText("Configure");
    select.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            PrintDialog pd = new PrintDialog(Display.getCurrent().getActiveShell());
            PrinterData pdata = pd.open();
            if (pdata != null) {
                _printerData = pdata;
                select(_printerData);
            }
        }

        private void select(PrinterData printerData) {
            for (int i = 0; i < _pdatas.length; i++) {
                PrinterData pd = _pdatas[i];
                if (pd.name.equals(printerData.name)) {
                    _printerCombo.select(i);
                    break;
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) PrintDialog(org.eclipse.swt.printing.PrintDialog) PrinterData(org.eclipse.swt.printing.PrinterData) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 14 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project translationstudio8 by heartsome.

the class JaretTablePrintDialog method createParameterArea.

protected void createParameterArea(Composite parent) {
    GridLayout gl = new GridLayout();
    gl.numColumns = 2;
    parent.setLayout(gl);
    _repeatHeader = new Button(parent, SWT.CHECK);
    _repeatHeader.setSelection(_configuration.getRepeatHeader());
    _repeatHeader.setText("Repeat header");
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    _repeatHeader.setLayoutData(gd);
    final Label scaleText = new Label(parent, SWT.RIGHT);
    scaleText.setText(getScaleText());
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    scaleText.setLayoutData(gd);
    final Scale scale = new Scale(parent, SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    scale.setLayoutData(gd);
    scale.setMaximum(1000);
    scale.setMinimum(10);
    scale.setSelection((int) (_configuration.getScale() * 100));
    scale.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent ev) {
            int val = scale.getSelection();
            double s = (double) val / 100.0;
            _configuration.setScale(s);
            scaleText.setText(getScaleText());
            updateConf();
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    _pagesLabel = new Label(parent, SWT.RIGHT);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    _pagesLabel.setLayoutData(gd);
    _printerData = _pdatas[_printerCombo.getSelectionIndex()];
    Printer printer = new Printer(_printerData);
    _tablePrinter.setPrinter(printer);
    Point pages = _tablePrinter.calculatePageCount(_configuration);
    printer.dispose();
    _pagesLabel.setText(getPagesText(pages));
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Scale(org.eclipse.swt.widgets.Scale) Point(org.eclipse.swt.graphics.Point) Printer(org.eclipse.swt.printing.Printer) JaretTablePrinter(de.jaret.util.ui.table.JaretTablePrinter) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 15 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project translationstudio8 by heartsome.

the class ConfigureColumnsAction method createColumnControlPanel.

/**
     * Create the dialog area. TODO can be done much nicer ... but works for the first draft
     * 
     * @param parent parent composite
     * @return initialized control
     */
private Control createColumnControlPanel(Composite parent) {
    Composite panel = new Composite(parent, SWT.NULL);
    panel.setLayout(new RowLayout());
    Label l = new Label(panel, SWT.NULL);
    l.setText("Configure the columns");
    Table table = new Table(parent, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
    _chkBoxViewer = new CheckboxTableViewer(table);
    _chkBoxViewer.setContentProvider(new ColTableContentProvider());
    _chkBoxViewer.setLabelProvider(new ColTableLabelProvider());
    TableColumn column = new TableColumn(_chkBoxViewer.getTable(), SWT.LEFT);
    column.setText("Column");
    column.setWidth(100);
    _chkBoxViewer.getTable().setHeaderVisible(true);
    _chkBoxViewer.setInput("x");
    final int firstColIdx = _allowFixedColumns ? 0 : _table.getFixedColumns();
    for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
        IColumn col = _table.getTableModel().getColumn(i);
        _chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
    }
    table.getColumn(0).pack();
    table.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (event.detail == SWT.CHECK) {
                TableItem item = (TableItem) event.item;
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (_allowFixedColumns || idx >= _table.getFixedColumns()) {
                    _tvs.setColumnVisible(col, item.getChecked());
                } else {
                    _chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
                }
            }
        }
    });
    Button upButton = new Button(panel, SWT.PUSH);
    upButton.setText("up");
    upButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
                TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (idx > firstColIdx) {
                    _tvs.getSortedColumns().remove(col);
                    _tvs.getSortedColumns().add(idx - 1, col);
                    _table.updateColumnList();
                    _table.redraw();
                    _chkBoxViewer.refresh();
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    Button downButton = new Button(panel, SWT.PUSH);
    downButton.setText("down");
    downButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
                TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (idx < _tvs.getSortedColumns().size() - 1) {
                    _tvs.getSortedColumns().remove(col);
                    _tvs.getSortedColumns().add(idx + 1, col);
                    _table.updateColumnList();
                    _table.redraw();
                    _chkBoxViewer.refresh();
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    return panel;
}
Also used : Table(org.eclipse.swt.widgets.Table) JaretTable(de.jaret.util.ui.table.JaretTable) Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) TableColumn(org.eclipse.swt.widgets.TableColumn) IColumn(de.jaret.util.ui.table.model.IColumn) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

SelectionListener (org.eclipse.swt.events.SelectionListener)190 SelectionEvent (org.eclipse.swt.events.SelectionEvent)184 Button (org.eclipse.swt.widgets.Button)94 GridData (org.eclipse.swt.layout.GridData)91 Composite (org.eclipse.swt.widgets.Composite)88 GridLayout (org.eclipse.swt.layout.GridLayout)87 Label (org.eclipse.swt.widgets.Label)69 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)52 Text (org.eclipse.swt.widgets.Text)45 Group (org.eclipse.swt.widgets.Group)43 FormAttachment (org.eclipse.swt.layout.FormAttachment)36 FormData (org.eclipse.swt.layout.FormData)36 Combo (org.eclipse.swt.widgets.Combo)34 ModifyEvent (org.eclipse.swt.events.ModifyEvent)31 ModifyListener (org.eclipse.swt.events.ModifyListener)31 FormLayout (org.eclipse.swt.layout.FormLayout)26 Point (org.eclipse.swt.graphics.Point)21 ArrayList (java.util.ArrayList)19 FillLayout (org.eclipse.swt.layout.FillLayout)17 Menu (org.eclipse.swt.widgets.Menu)17