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;
}
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;
}
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) {
}
});
}
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));
}
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;
}
Aggregations