use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.
the class GoToDialog method createRadixPanel.
/**
* This method initializes composite
*/
private void createRadixPanel() {
RowLayout rowLayout1 = new RowLayout();
// rowLayout1.marginHeight = 5;
rowLayout1.marginTop = 2;
rowLayout1.marginBottom = 2;
//rowLayout1.marginWidth = 5;
rowLayout1.type = SWT.VERTICAL;
Composite composite = new Composite(textComposite, SWT.NONE);
composite.setLayout(rowLayout1);
SelectionAdapter hexTextSelectionAdapter = new SelectionAdapter() {
@Override
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
// generate event
text.setText(text.getText());
lastHexButtonSelected = e.widget == hexRadioButton;
}
};
// Besides the crashes: the user always knows which number is entering, don't need any automatic
// conversion. What does sometimes happen is one enters the right number and the wrong binary or dec was
// selected. In that case automatic conversion is the wrong thing to do and very annoying.
hexRadioButton = new Button(composite, SWT.RADIO);
//$NON-NLS-1$
hexRadioButton.setText("Hex");
hexRadioButton.addSelectionListener(defaultSelectionAdapter);
hexRadioButton.addSelectionListener(hexTextSelectionAdapter);
decRadioButton = new Button(composite, SWT.RADIO);
//$NON-NLS-1$
decRadioButton.setText("Dec");
decRadioButton.addSelectionListener(defaultSelectionAdapter);
//decTextSelectionAdapter);
decRadioButton.addSelectionListener(hexTextSelectionAdapter);
}
use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.
the class GenerateMultiSQLDialog method createObjectsSelector.
protected void createObjectsSelector(Composite parent) {
if (selectedObjects.size() < 2) {
// Don't need it for a single object
return;
}
UIUtils.createControlLabel(parent, "Tables");
objectsTable = new Table(parent, SWT.BORDER | SWT.CHECK);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 100;
objectsTable.setLayoutData(gd);
for (T table : selectedObjects) {
TableItem item = new TableItem(objectsTable, SWT.NONE);
item.setText(DBUtils.getObjectFullName(table, DBPEvaluationContext.UI));
item.setImage(DBeaverIcons.getImage(DBIcon.TREE_TABLE));
item.setChecked(true);
item.setData(table);
}
objectsTable.addSelectionListener(SQL_CHANGE_LISTENER);
objectsTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean hasChecked = !getCheckedObjects().isEmpty();
getButton(IDialogConstants.OK_ID).setEnabled(hasChecked);
getButton(IDialogConstants.DETAILS_ID).setEnabled(hasChecked);
}
});
}
use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.
the class SQLScriptStatusDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite composite = super.createDialogArea(parent);
objectTree = new Tree(composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 500;
gd.heightHint = 200;
objectTree.setLayoutData(gd);
objectTree.setHeaderVisible(true);
objectTree.setLinesVisible(true);
TreeColumn nameColumn = new TreeColumn(objectTree, SWT.NONE);
nameColumn.setText("Object");
createStatusColumns(objectTree);
for (T object : objects) {
TreeItem item = new TreeItem(objectTree, SWT.NONE);
item.setData(object);
item.setText(0, DBUtils.getObjectFullName(object, DBPEvaluationContext.UI));
}
UIUtils.packColumns(objectTree, false, null);
Composite progressPanel = UIUtils.createPlaceholder(composite, 2, 5);
progressPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
progressBar = new ProgressBar(progressPanel, SWT.HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
progressBar.setLayoutData(gd);
progressBar.setMinimum(0);
progressBar.setMaximum(this.objects.size());
final Button stopButton = UIUtils.createPushButton(progressPanel, null, UIUtils.getShardImage(ISharedImages.IMG_ELCL_STOP));
stopButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
job.cancel();
stopButton.setEnabled(false);
}
});
finishLabel = new Label(composite, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.exclude = true;
finishLabel.setLayoutData(gd);
finishLabel.setText("Finished");
return composite;
}
use of org.eclipse.swt.events.SelectionAdapter in project dbeaver by serge-rider.
the class SearchDataPage method createControl.
@Override
public void createControl(Composite parent) {
super.createControl(parent);
initializeDialogUnits(parent);
Composite searchGroup = new Composite(parent, SWT.NONE);
searchGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
searchGroup.setLayout(new GridLayout(3, false));
setControl(searchGroup);
UIUtils.createControlLabel(searchGroup, "String");
searchText = new Combo(searchGroup, SWT.DROP_DOWN);
searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (params.searchString != null) {
searchText.setText(params.searchString);
}
for (String history : searchHistory) {
searchText.add(history);
}
searchText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
params.searchString = searchText.getText();
updateEnablement();
}
});
Composite optionsGroup = new SashForm(searchGroup, SWT.NONE);
GridLayout layout = new GridLayout(2, true);
layout.marginHeight = 0;
layout.marginWidth = 0;
optionsGroup.setLayout(layout);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.horizontalSpan = 3;
optionsGroup.setLayoutData(gd);
{
final DBeaverCore core = DBeaverCore.getInstance();
Group databasesGroup = UIUtils.createControlGroup(optionsGroup, "Databases", 1, GridData.FILL_BOTH, 0);
gd = new GridData(GridData.FILL_BOTH);
//gd.heightHint = 300;
databasesGroup.setLayoutData(gd);
final DBNProject projectNode = core.getNavigatorModel().getRoot().getProject(core.getProjectRegistry().getActiveProject());
DBNNode rootNode = projectNode == null ? core.getNavigatorModel().getRoot() : projectNode.getDatabases();
dataSourceTree = new DatabaseNavigatorTree(databasesGroup, rootNode, SWT.SINGLE | SWT.CHECK);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
dataSourceTree.setLayoutData(gd);
final CheckboxTreeViewer viewer = (CheckboxTreeViewer) dataSourceTree.getViewer();
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof TreeLoadNode) {
return true;
}
if (element instanceof DBNNode) {
if (element instanceof DBNDatabaseFolder) {
DBNDatabaseFolder folder = (DBNDatabaseFolder) element;
Class<? extends DBSObject> folderItemsClass = folder.getChildrenClass();
return folderItemsClass != null && (DBSObjectContainer.class.isAssignableFrom(folderItemsClass) || DBSEntity.class.isAssignableFrom(folderItemsClass));
}
if (element instanceof DBNLocalFolder || element instanceof DBNProjectDatabases || element instanceof DBNDataSource) {
return true;
}
if (element instanceof DBSWrapper) {
DBSObject obj = ((DBSWrapper) element).getObject();
if (obj instanceof DBSObjectContainer)
return true;
if (obj instanceof DBSDataContainer && obj instanceof DBSEntity) {
if ((((DBSDataContainer) obj).getSupportedFeatures() & DBSDataContainer.DATA_SEARCH) != 0) {
return true;
}
}
}
}
return false;
}
});
checkboxTreeManager = new CheckboxTreeManager(viewer, new Class[] { DBSDataContainer.class });
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateEnablement();
}
});
}
{
//new Label(searchGroup, SWT.NONE);
Composite optionsGroup2 = UIUtils.createControlGroup(optionsGroup, "Settings", 2, GridData.FILL_HORIZONTAL, 0);
optionsGroup2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
if (params.maxResults <= 0) {
params.maxResults = 10;
}
final Spinner maxResultsSpinner = UIUtils.createLabelSpinner(optionsGroup2, "Sample rows", params.maxResults, 1, Integer.MAX_VALUE);
maxResultsSpinner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
maxResultsSpinner.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
params.maxResults = maxResultsSpinner.getSelection();
}
});
final Button caseCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, CoreMessages.dialog_search_objects_case_sensitive, params.caseSensitive);
caseCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
caseCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
params.caseSensitive = caseCheckbox.getSelection();
}
});
final Button fastSearchCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, "Fast search (indexed)", params.fastSearch);
fastSearchCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
fastSearchCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
params.fastSearch = fastSearchCheckbox.getSelection();
}
});
final Button searchNumbersCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, "Search in numbers", params.searchNumbers);
searchNumbersCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
searchNumbersCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
params.searchNumbers = searchNumbersCheckbox.getSelection();
}
});
final Button searchLOBCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, "Search in LOBs", params.searchLOBs);
searchLOBCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
searchLOBCheckbox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
params.searchLOBs = searchNumbersCheckbox.getSelection();
}
});
}
final List<DBNNode> checkedNodes = new ArrayList<>();
dataSourceTree.setEnabled(false);
try {
DBeaverUI.runInProgressDialog(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Load database nodes", 1);
try {
monitor.subTask("Load tree state");
checkedNodes.addAll(loadTreeState(monitor, store, PROP_SOURCES));
} finally {
monitor.done();
}
}
});
} catch (InvocationTargetException e) {
UIUtils.showErrorDialog(getShell(), "Data sources load", "Error loading settings", e.getTargetException());
}
if (!checkedNodes.isEmpty()) {
boolean first = true;
for (DBNNode node : checkedNodes) {
((CheckboxTreeViewer) dataSourceTree.getViewer()).setChecked(node, true);
if (first) {
dataSourceTree.getViewer().reveal(NavigatorUtils.getDataSourceNode(node));
first = false;
}
}
checkboxTreeManager.updateCheckStates();
}
updateEnablement();
dataSourceTree.setEnabled(true);
}
use of org.eclipse.swt.events.SelectionAdapter in project translationstudio8 by heartsome.
the class TermBaseSearchDialog method createHelpControl.
/**
* 添加帮助按钮 robert 2012-09-06
*/
@Override
protected Control createHelpControl(Composite parent) {
// ROBERTHELP 搜索术语
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s04.html#search-terminology", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
((GridLayout) parent.getLayout()).numColumns++;
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
Aggregations