use of org.eclipse.swt.events.FocusListener in project dbeaver by serge-rider.
the class BaseValueEditor method initInlineControl.
protected void initInlineControl(final Control inlineControl) {
boolean isInline = (valueController.getEditType() == IValueController.EditType.INLINE);
if (isInline && UIUtils.isInDialog(inlineControl)) {
//isInline = false;
}
UIUtils.enableHostEditorKeyBindingsSupport(valueController.getValueSite(), inlineControl);
// if (!isInline) {
// inlineControl.setBackground(valueController.getEditPlaceholder().getBackground());
// }
final IContextService contextService = valueController.getValueSite().getService(IContextService.class);
inlineControl.addFocusListener(new FocusListener() {
private IContextActivation activationEditor;
@Override
public void focusGained(FocusEvent e) {
if (contextService != null) {
activationEditor = contextService.activateContext(RESULTS_EDIT_CONTEXT_ID);
}
}
@Override
public void focusLost(FocusEvent e) {
contextService.deactivateContext(activationEditor);
activationEditor = null;
}
});
if (isInline) {
inlineControl.setFont(valueController.getEditPlaceholder().getFont());
inlineControl.setFocus();
if (valueController instanceof IMultiController) {
// In dialog it also should handle all standard stuff because we have params dialog
inlineControl.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
saveValue();
((IMultiController) valueController).closeInlineEditor();
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
((IMultiController) valueController).closeInlineEditor();
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
} else if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
saveValue();
((IMultiController) valueController).nextInlineEditor(e.detail == SWT.TRAVERSE_TAB_NEXT);
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
}
}
});
if (!UIUtils.isInDialog(inlineControl)) {
addAutoSaveSupport(inlineControl);
}
}
}
final ControlModifyListener modifyListener = new ControlModifyListener();
control.addListener(SWT.Modify, modifyListener);
control.addListener(SWT.Selection, modifyListener);
}
use of org.eclipse.swt.events.FocusListener in project dbeaver by serge-rider.
the class SQLEditorNested method createPartControl.
@Override
public void createPartControl(Composite parent) {
pageControl = new EditorPageControl(parent, SWT.SHEET);
boolean hasCompiler = getCompileCommandId() != null;
if (hasCompiler) {
editorSash = new SashForm(pageControl.createContentContainer(), SWT.VERTICAL | SWT.SMOOTH);
super.createPartControl(editorSash);
editorControl = editorSash.getChildren()[0];
compileLog = new ObjectCompilerLogViewer(editorSash, false);
} else {
super.createPartControl(pageControl.createContentContainer());
}
// Create new or substitute progress control
pageControl.createOrSubstituteProgressPanel(getSite());
pageControl.setInfo("Source");
if (hasCompiler) {
editorSash.setWeights(new int[] { 70, 30 });
editorSash.setMaximizedControl(editorControl);
}
// Use focus to activate page control
final Control editorControl = getEditorControl();
assert editorControl != null;
editorControl.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (pageControl != null && !pageControl.isDisposed()) {
pageControl.activate(true);
}
}
@Override
public void focusLost(FocusEvent e) {
if (pageControl != null && !pageControl.isDisposed()) {
pageControl.activate(false);
}
}
});
}
use of org.eclipse.swt.events.FocusListener in project dbeaver by serge-rider.
the class TabbedFolderPageNode method createControl.
@Override
public void createControl(Composite parent) {
itemControl = new ItemListControl(parent, SWT.SHEET, mainEditor.getSite(), node, metaNode);
//itemControl.getLayout().marginHeight = 0;
//itemControl.getLayout().marginWidth = 0;
ProgressPageControl progressControl = null;
if (mainEditor instanceof IProgressControlProvider) {
progressControl = ((IProgressControlProvider) mainEditor).getProgressControl();
}
if (progressControl != null) {
itemControl.substituteProgressPanel(progressControl);
} else {
itemControl.createProgressPanel();
}
parent.layout();
// Activate items control on focus
itemControl.getItemsViewer().getControl().addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// Update selection provider and selection
final ISelectionProvider selectionProvider = itemControl.getSelectionProvider();
if (mainEditor.getSite().getSelectionProvider() != selectionProvider) {
mainEditor.getSite().setSelectionProvider(selectionProvider);
selectionProvider.setSelection(selectionProvider.getSelection());
}
itemControl.activate(true);
// We need it to update search actions and other contributions provided by node editor
if (mainEditor.getSite() instanceof MultiPageEditorSite) {
MultiPageEditorPart multiPageEditor = ((MultiPageEditorSite) mainEditor.getSite()).getMultiPageEditor();
if (multiPageEditor.getSelectedPage() != mainEditor) {
multiPageEditor.setActiveEditor(mainEditor);
}
}
}
@Override
public void focusLost(FocusEvent e) {
itemControl.activate(false);
}
});
}
use of org.eclipse.swt.events.FocusListener in project translationstudio8 by heartsome.
the class NatTable method initInternalListener.
protected void initInternalListener() {
modeSupport = new ModeSupport(this);
modeSupport.registerModeEventHandler(Mode.NORMAL_MODE, new ConfigurableModeEventHandler(modeSupport, this));
modeSupport.switchMode(Mode.NORMAL_MODE);
addPaintListener(this);
addFocusListener(new FocusListener() {
public void focusLost(final FocusEvent arg0) {
redraw();
}
public void focusGained(final FocusEvent arg0) {
redraw();
}
});
addListener(SWT.Resize, new Listener() {
public void handleEvent(final Event e) {
doCommand(new ClientAreaResizeCommand(NatTable.this));
}
});
}
use of org.eclipse.swt.events.FocusListener in project translationstudio8 by heartsome.
the class CustomFilterDialog method setGray.
/**
* 为Text控件增加灰色提醒,获得焦点时自动清除灰色提醒
* @param text
* Text控件
* @param initTxt
* 灰色提醒字符串
*/
private void setGray(final Text text, final String initTxt) {
text.setForeground(gray);
text.setText(initTxt);
text.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
if (text.getText().trim().equals("")) {
if (!text.getForeground().equals(gray)) {
text.setForeground(gray);
}
text.setText(initTxt);
} else {
if (!text.getForeground().equals(black)) {
text.setForeground(black);
}
}
}
public void focusGained(FocusEvent arg0) {
if (text.getText().trim().equals(initTxt)) {
text.setText("");
text.setForeground(black);
} else {
if (!text.getForeground().equals(black)) {
text.setForeground(black);
}
}
}
});
}
Aggregations