use of org.eclipse.swt.events.FocusListener in project OpenGrok by OpenGrok.
the class ResultsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
parent.setLayout(new GridLayout(1, true));
filter = new Text(parent, SWT.FILL);
filter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
TextUtils.setToDefault(filter, FILTER_DEFAULT);
filter.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if ("".equals(filter.getText())) {
TextUtils.setToDefault(filter, FILTER_DEFAULT);
}
}
@Override
public void focusGained(FocusEvent e) {
TextUtils.makeEditable(filter);
}
});
filter.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
viewer.refresh();
}
});
return parent;
}
use of org.eclipse.swt.events.FocusListener in project OpenGrok by OpenGrok.
the class ToolBarControl method createControl.
@Override
protected Control createControl(Composite parent) {
final Text searchBox = new Text(parent, SWT.FILL | SWT.BORDER);
TextUtils.setToDefault(searchBox, "{OpenGrok");
searchBox.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
if (!disableFocusLostEvent) {
TextUtils.setToDefault(searchBox, "{OpenGrok");
}
}
@Override
public void focusGained(FocusEvent e) {
TextUtils.makeEditable(searchBox);
}
});
searchBox.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
doSearch();
} else if (e.keyCode == SWT.ARROW_UP) {
historyIndex++;
if (historyIndex > history.size()) {
historyIndex = history.size();
}
if (historyIndex >= 0 && history.size() >= historyIndex) {
searchBox.setText(history.get(historyIndex - 1));
}
} else if (e.keyCode == SWT.ARROW_DOWN) {
historyIndex--;
if (historyIndex < 0) {
historyIndex = 0;
} else if (history.size() > historyIndex) {
searchBox.setText(history.get(historyIndex));
}
} else if ((e.stateMask & SWT.CTRL) == SWT.CTRL && e.keyCode == 'v') {
searchBox.setText("");
searchBox.paste();
if ((e.stateMask & SWT.SHIFT) == SWT.SHIFT) {
doSearch();
}
} else if (e.stateMask == SWT.CTRL && e.keyCode == 'c') {
searchBox.copy();
}
}
private void doSearch() {
String text = searchBox.getText();
if (text != null && !"".equals(text)) {
history.add(0, text);
historyIndex = 0;
Rectangle bounds = searchBox.getBounds();
Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
topLeft = searchBox.getShell().toDisplay(topLeft);
final ResultsDialog dialog = new ResultsDialog(Display.getCurrent().getActiveShell(), text, topLeft);
Query query = new Query(text);
disableFocusLostEvent = true;
query.run(dialog);
disableFocusLostEvent = false;
}
}
});
return parent;
}
use of org.eclipse.swt.events.FocusListener in project dbeaver by serge-rider.
the class TabbedFolderPageEditor method createControl.
@Override
public void createControl(Composite parent) {
editor = editorDescriptor.createEditor();
final IWorkbenchPartSite ownerSite = this.mainEditor.getSite();
if (ownerSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart ownerMultiPageEditor = ((MultiPageEditorSite) ownerSite).getMultiPageEditor();
nestedEditorSite = new TabbedFolderPageEditorSite(ownerMultiPageEditor, editor);
// We need it to tell owner editor about dirty state change
if (ownerMultiPageEditor instanceof IPropertyChangeReflector) {
editor.addPropertyListener(new IPropertyListener() {
@Override
public void propertyChanged(Object source, int propId) {
((IPropertyChangeReflector) ownerMultiPageEditor).handlePropertyChange(propId);
}
});
}
} else {
nestedEditorSite = new SubEditorSite(mainEditor.getEditorSite());
}
try {
editor.init(nestedEditorSite, editorDescriptor.getNestedEditorInput(mainEditor.getEditorInput()));
} catch (PartInitException e) {
UIUtils.showErrorDialog(parent.getShell(), "Create SQL viewer", null, e);
}
editor.createPartControl(parent);
if (editor instanceof ISingleControlEditor) {
// Use focus to active selection provider and contributed actions
Control editorControl = ((ISingleControlEditor) editor).getEditorControl();
assert editorControl != null;
editorControl.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
mainEditor.getSite().setSelectionProvider(selectionProvider);
if (actionContributor != null) {
actionContributor.setActiveEditor(editor);
}
activateNestedSite(true);
}
@Override
public void focusLost(FocusEvent e) {
activateNestedSite(false);
if (actionContributor != null) {
actionContributor.setActiveEditor(null);
}
}
});
}
parent.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (editor != null) {
editor.dispose();
editor = null;
}
}
});
}
use of org.eclipse.swt.events.FocusListener in project cubrid-manager by CUBRID.
the class GeneralInfoPage method createLogVolumeGroup.
/**
* Create log volume information group
*
* @param parent the parent composite
*/
private void createLogVolumeGroup(Composite parent) {
Group logVolumeGroup = new Group(parent, SWT.NONE);
logVolumeGroup.setText(Messages.grpLogVolInfo);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
logVolumeGroup.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
logVolumeGroup.setLayoutData(gridData);
if (CompatibleUtil.isSupportLogPageSize(server.getServerInfo())) {
Label logPageSizeLabel = new Label(logVolumeGroup, SWT.LEFT | SWT.WRAP);
logPageSizeLabel.setText(Messages.lblLogPageSize);
gridData = new GridData();
gridData.widthHint = 150;
logPageSizeLabel.setLayoutData(gridData);
logPageSizeCombo = new Combo(logVolumeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
logPageSizeCombo.setLayoutData(gridData);
logPageSizeCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
valid();
}
});
}
Label logSizeLabel = new Label(logVolumeGroup, SWT.LEFT | SWT.WRAP);
logSizeLabel.setText(Messages.lblVolSize);
gridData = new GridData();
gridData.widthHint = 150;
logSizeLabel.setLayoutData(gridData);
logVolumeSizeText = new Text(logVolumeGroup, SWT.BORDER);
logVolumeSizeText.setTextLimit(20);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
logVolumeSizeText.setLayoutData(gridData);
logVolumeSizeText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
logVolumeSizeText.addModifyListener(GeneralInfoPage.this);
}
public void focusLost(FocusEvent event) {
logVolumeSizeText.removeModifyListener(GeneralInfoPage.this);
}
});
Label logVolumePathLabel = new Label(logVolumeGroup, SWT.LEFT | SWT.WRAP);
logVolumePathLabel.setText(Messages.lblLogVolPath);
gridData = new GridData();
gridData.widthHint = 150;
logVolumePathLabel.setLayoutData(gridData);
logVolumePathText = new Text(logVolumeGroup, SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
logVolumePathText.setLayoutData(gridData);
Button selectDirectoryButton = new Button(logVolumeGroup, SWT.NONE);
selectDirectoryButton.setText(Messages.btnBrowse);
selectDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
selectDirectoryButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
if (databasePath != null && databasePath.trim().length() > 0) {
dlg.setFilterPath(databasePath);
}
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String dir = dlg.open();
if (dir != null) {
logVolumePathText.setText(dir);
}
}
});
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo != null && !serverInfo.isLocalServer()) {
selectDirectoryButton.setEnabled(false);
}
}
use of org.eclipse.swt.events.FocusListener in project mechanoid by robotoworks.
the class NewMechanoidNetServiceClientPage method onAfterAddNameField.
@Override
protected void onAfterAddNameField(Composite parent, Font font) {
mBaseUrlField = new TextField(parent, Messages.NewMechanoidNetServiceClientPage_Widget_Label_Url);
mBaseUrlField.getTextField().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
}
@Override
public void focusGained(FocusEvent e) {
getFieldInfoLabel().setText(Messages.NewMechanoidNetServiceClientPage_Widget_Label_Message_Url);
}
});
}
Aggregations