Search in sources :

Example 26 with Label

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

the class HexStatusLine method initialize.

private void initialize(boolean withSeparator) {
    GridLayout statusLayout = new GridLayout();
    statusLayout.numColumns = withSeparator ? 6 : 5;
    statusLayout.marginHeight = 0;
    setLayout(statusLayout);
    if (withSeparator) {
        GridData separator1GridData = new GridData();
        separator1GridData.grabExcessVerticalSpace = true;
        separator1GridData.verticalAlignment = SWT.FILL;
        Label separator1 = new Label(this, SWT.SEPARATOR);
        separator1.setLayoutData(separator1GridData);
    }
    GC gc = new GC(this);
    FontMetrics fontMetrics = gc.getFontMetrics();
    position = new Label(this, SWT.SHADOW_NONE);
    GridData gridData1 = new GridData(/*SWT.DEFAULT*/
    (11 + 10 + 12 + 3 + 10 + 12) * fontMetrics.getAverageCharWidth(), SWT.DEFAULT);
    position.setLayoutData(gridData1);
    GridData separator23GridData = new GridData();
    separator23GridData.grabExcessVerticalSpace = true;
    separator23GridData.verticalAlignment = SWT.FILL;
    Label separator2 = new Label(this, SWT.SEPARATOR);
    separator2.setLayoutData(separator23GridData);
    value = new Label(this, SWT.SHADOW_NONE);
    GridData gridData2 = new GridData(/*SWT.DEFAULT*/
    (7 + 3 + 9 + 2 + 9 + 8 + 6) * fontMetrics.getAverageCharWidth(), SWT.DEFAULT);
    value.setLayoutData(gridData2);
    // From Eclipse 3.1's GridData javadoc:
    // NOTE: Do not reuse GridData objects. Every control in a Composite that is managed by a
    // GridLayout must have a unique GridData
    GridData separator3GridData = new GridData();
    separator3GridData.grabExcessVerticalSpace = true;
    separator3GridData.verticalAlignment = SWT.FILL;
    Label separator3 = new Label(this, SWT.SEPARATOR);
    separator3.setLayoutData(separator3GridData);
    insertMode = new Label(this, SWT.SHADOW_NONE);
    GridData gridData3 = new GridData(/*SWT.DEFAULT*/
    (TEXT_OVERWRITE.length() + 2) * fontMetrics.getAverageCharWidth(), SWT.DEFAULT);
    insertMode.setLayoutData(gridData3);
    gc.dispose();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) FontMetrics(org.eclipse.swt.graphics.FontMetrics) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) GC(org.eclipse.swt.graphics.GC)

Example 27 with Label

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

the class MySQLWizardPageSettings method createSecurityGroup.

public void createSecurityGroup(Composite parent) {
    try {
        final SecuredPasswordEncrypter encrypter = new SecuredPasswordEncrypter();
        final DBPConnectionConfiguration connectionInfo = wizard.getConnectionInfo();
        final String authProperty = DBConstants.INTERNAL_PROP_PREFIX + "-auth-" + wizard.getObjectsName() + "@";
        String authUser = null;
        String authPassword = null;
        {
            String authValue = connectionInfo.getProviderProperty(authProperty);
            if (authValue != null) {
                String authCredentials = encrypter.decrypt(authValue);
                int divPos = authCredentials.indexOf(':');
                if (divPos != -1) {
                    authUser = authCredentials.substring(0, divPos);
                    authPassword = authCredentials.substring(divPos + 1);
                }
            }
        }
        wizard.setToolUserName(authUser == null ? connectionInfo.getUserName() : authUser);
        wizard.setToolUserPassword(authPassword == null ? connectionInfo.getUserPassword() : authPassword);
        final boolean savePassword = authUser != null;
        Group securityGroup = UIUtils.createControlGroup(parent, "Security", 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        Label infoLabel = new Label(securityGroup, SWT.NONE);
        infoLabel.setText("Override user credentials (" + wizard.getConnectionInfo().getUserName() + ") for objects '" + wizard.getObjectsName() + "'.\nExternal tools like 'mysqldump' may require different set of permissions.");
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        infoLabel.setLayoutData(gd);
        Button authButton = new Button(securityGroup, SWT.PUSH);
        authButton.setText("Authentication");
        authButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                BaseAuthDialog authDialog = new BaseAuthDialog(getShell(), "Authentication", false);
                authDialog.setUserName(wizard.getToolUserName());
                authDialog.setUserPassword(wizard.getToolUserPassword());
                authDialog.setSavePassword(savePassword);
                if (authDialog.open() == IDialogConstants.OK_ID) {
                    wizard.setToolUserName(authDialog.getUserName());
                    wizard.setToolUserPassword(authDialog.getUserPassword());
                    if (authDialog.isSavePassword()) {
                        try {
                            connectionInfo.setProviderProperty(authProperty, encrypter.encrypt(wizard.getToolUserName() + ':' + wizard.getToolUserPassword()));
                        } catch (EncryptionException e1) {
                        // Never be here
                        }
                    }
                }
            }
        });
        Button resetButton = new Button(securityGroup, SWT.PUSH);
        resetButton.setText("Reset to default");
        resetButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                connectionInfo.getProperties().remove(authProperty);
                wizard.setToolUserName(connectionInfo.getUserName());
                wizard.setToolUserPassword(connectionInfo.getUserPassword());
            }
        });
    } catch (EncryptionException e) {
    // Never be here
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) SecuredPasswordEncrypter(org.jkiss.dbeaver.registry.encode.SecuredPasswordEncrypter) Button(org.eclipse.swt.widgets.Button) BaseAuthDialog(org.jkiss.dbeaver.ui.dialogs.connection.BaseAuthDialog) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EncryptionException(org.jkiss.dbeaver.registry.encode.EncryptionException)

Example 28 with Label

use of org.eclipse.swt.widgets.Label 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 29 with Label

use of org.eclipse.swt.widgets.Label 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)

Example 30 with Label

use of org.eclipse.swt.widgets.Label in project translationstudio8 by heartsome.

the class TermBaseSearchDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite tparent = (Composite) super.createDialogArea(parent);
    tparent.setLayout(new GridLayout());
    GridData parentData = new GridData(GridData.FILL_BOTH);
    parentData.heightHint = 600;
    parentData.widthHint = 775;
    tparent.setLayoutData(parentData);
    Group groupSearch = new Group(tparent, SWT.None);
    groupSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.groupSearch"));
    GridLayoutFactory.swtDefaults().margins(5, 5).numColumns(3).equalWidth(false).applyTo(groupSearch);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(groupSearch);
    Label lblSearch = new Label(groupSearch, SWT.NONE);
    lblSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.lblSearch"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblSearch);
    cmbSearch = new Combo(groupSearch, SWT.DROP_DOWN | SWT.BORDER);
    cmbSearch.setText(strSearchText == null ? "" : strSearchText);
    GridData txtData = new GridData();
    // 解决在 Windows 下文本框高度太小的问题
    // txtData.heightHint = 20;
    txtData.widthHint = 590;
    cmbSearch.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    btnSearch = new Button(groupSearch, SWT.PUSH);
    btnSearch.setText(Messages.getString("dialog.TermBaseSearchDialog.btnSearch"));
    new Label(groupSearch, SWT.NONE);
    Composite compCondition = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(8, 0).numColumns(4).equalWidth(false).applyTo(compCondition);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(compCondition);
    btnIsCaseSensitive = new Button(compCondition, SWT.CHECK);
    btnIsCaseSensitive.setText(Messages.getString("dialog.TermBaseSearchDialog.btnIsCaseSensitive"));
    GridDataFactory.swtDefaults().applyTo(btnIsCaseSensitive);
    btnIsIgnoreMark = new Button(compCondition, SWT.CHECK);
    btnIsIgnoreMark.setText(Messages.getString("dialog.TermBaseSearchDialog.btnIsIgnoreMark"));
    btnIsIgnoreMark.setSelection(true);
    GridDataFactory.swtDefaults().applyTo(btnIsIgnoreMark);
    btnApplyRegularExpression = new Button(compCondition, SWT.CHECK);
    btnApplyRegularExpression.setText(Messages.getString("dialog.TermBaseSearchDialog.btnApplyRegularExpression"));
    GridDataFactory.swtDefaults().applyTo(btnApplyRegularExpression);
    Composite compMatchQuality = new Composite(compCondition, SWT.NONE);
    GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 0).margins(0, 0).spacing(0, 0).numColumns(3).equalWidth(false).applyTo(compMatchQuality);
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(true, false).applyTo(compMatchQuality);
    new Label(compMatchQuality, SWT.NONE).setText(Messages.getString("dialog.TermBaseSearchDialog.lblQuality"));
    spiMatchQuality = new Spinner(compMatchQuality, SWT.BORDER);
    spiMatchQuality.setMaximum(100);
    spiMatchQuality.setMinimum(30);
    spiMatchQuality.setIncrement(5);
    spiMatchQuality.setSelection(100);
    GridData spinnaData = new GridData();
    spinnaData.widthHint = 23;
    spiMatchQuality.setLayoutData(spinnaData);
    new Label(compMatchQuality, SWT.NONE).setText("%");
    Label lblTB = new Label(groupSearch, SWT.NONE);
    lblTB.setText(Messages.getString("dialog.TermBaseSearchDialog.lblTB"));
    GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(lblTB);
    Composite cmpTB = new Composite(groupSearch, SWT.NONE);
    GridLayoutFactory.fillDefaults().spacing(8, 0).numColumns(2).equalWidth(false).applyTo(cmpTB);
    GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(cmpTB);
    cmbDatabase = new Combo(cmpTB, SWT.READ_ONLY);
    GridDataFactory.swtDefaults().hint(120, SWT.DEFAULT).applyTo(cmbDatabase);
    initDatabaseCombo();
    btnSelectLang = new Button(cmpTB, SWT.RIGHT);
    // GridData data = new GridData();
    // data.widthHint = 150;
    // data.heightHint = 27;
    // btnSelectLang.setLayoutData(data);
    // btnSelectLang.setImage(Activator.getImageDescriptor(ImageConstants.CONCORDANCE_SELECT_LANG).createImage());
    // btnSelectLang.addPaintListener(new PaintListener() {
    // public void paintControl(PaintEvent e) {
    // e.gc.drawText(Messages.getString("dialog.TermBaseSearchDialog.btnSelectLang"), 5, 5,
    // SWT.DRAW_TRANSPARENT);
    // }
    // });
    btnSelectLang.setText(Messages.getString("dialog.TermBaseSearchDialog.btnSelectLang"));
    initLanguageMenu();
    Group groupTable = new Group(tparent, SWT.NONE);
    GridLayoutFactory.swtDefaults().margins(10, 10).applyTo(groupTable);
    groupTable.setLayoutData(new GridData(GridData.FILL_BOTH));
    // GridDataFactory.fillDefaults().hint(700, 440).applyTo(groupTable);
    groupTable.setText(Messages.getString("dialog.TermBaseSearchDialog.groupTable"));
    grid = new Grid(groupTable, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    grid.setHeaderVisible(true);
    grid.setLinesVisible(true);
    grid.setLayoutData(new GridData(GridData.FILL_BOTH));
    grid.setAutoHeight(true);
    grid.setRowsResizeable(true);
    grid.setWordWrapHeader(true);
    if (strSrcLang != null) {
        columnSrcLang = new GridColumn(grid, SWT.NONE);
        srcCellRenderer.setVerticalAlignment(SWT.CENTER);
        srcCellRenderer.setStyleColumn(0);
        columnSrcLang.setCellRenderer(srcCellRenderer);
        columnSrcLang.setText(strSrcLang);
        columnSrcLang.setWidth(365);
        columnSrcLang.setWordWrap(true);
    }
    if (strTgtLang != null) {
        GridColumn columnTgtLang = new GridColumn(grid, SWT.NONE);
        TBSearchCellRenderer cellRenderer = new TBSearchCellRenderer();
        cellRenderer.setVerticalAlignment(SWT.CENTER);
        columnTgtLang.setCellRenderer(cellRenderer);
        columnTgtLang.setText(strTgtLang);
        columnTgtLang.setWidth(365);
        columnTgtLang.setWordWrap(true);
    }
    for (String strLang : lstLangs) {
        final GridColumn column = new GridColumn(grid, SWT.NONE);
        TBSearchCellRenderer cellRenderer = new TBSearchCellRenderer();
        cellRenderer.setVerticalAlignment(SWT.CENTER);
        column.setCellRenderer(cellRenderer);
        column.setText(strLang);
        column.setWidth(0);
        column.setWordWrap(true);
    }
    readDialogSettings();
    setEnabled();
    updateCombo(cmbSearch, lstSearchHistory);
    if (!strSearchText.equals("")) {
        cmbSearch.setText(strSearchText);
    } else if (lstSearchHistory != null && lstSearchHistory.size() > 0) {
        cmbSearch.setText(lstSearchHistory.get(0));
    }
    cmbSearch.setSelection(new Point(0, cmbSearch.getText().length()));
    initListener();
    return parent;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) Spinner(org.eclipse.swt.widgets.Spinner) Grid(org.eclipse.nebula.widgets.grid.Grid) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn)

Aggregations

Label (org.eclipse.swt.widgets.Label)849 GridData (org.eclipse.swt.layout.GridData)709 GridLayout (org.eclipse.swt.layout.GridLayout)617 Composite (org.eclipse.swt.widgets.Composite)594 Text (org.eclipse.swt.widgets.Text)394 Button (org.eclipse.swt.widgets.Button)338 SelectionEvent (org.eclipse.swt.events.SelectionEvent)324 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)266 Group (org.eclipse.swt.widgets.Group)241 Combo (org.eclipse.swt.widgets.Combo)164 ModifyEvent (org.eclipse.swt.events.ModifyEvent)140 ModifyListener (org.eclipse.swt.events.ModifyListener)140 SelectionListener (org.eclipse.swt.events.SelectionListener)77 Table (org.eclipse.swt.widgets.Table)63 TableViewer (org.eclipse.jface.viewers.TableViewer)60 Point (org.eclipse.swt.graphics.Point)59 FormAttachment (org.eclipse.swt.layout.FormAttachment)47 FormData (org.eclipse.swt.layout.FormData)47 ArrayList (java.util.ArrayList)45 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)44