use of org.eclipse.swt.events.FocusEvent in project cogtool by cogtool.
the class ActionSet method createTransitionName.
private Text createTransitionName(Composite parent, String txt) {
final Text name = new Text(parent, SWT.BORDER);
final NameInfo info = new NameInfo(txt);
// Note that we have to use a VerifyListener to prevent editing the
// contents of the Text, as SWT has made the rather surprising decision
// that setting its editable field to false also
// takes away our ability to select and navigate in the field, and copy
// its contents. Grr.
name.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent evt) {
// the user's trying to modify an already populated Text. Yuk.
switch(transitionNameState) {
case NORMAL:
info.fullName = evt.text;
evt.text = SWTStringUtil.insertEllipsis(info.fullName, name.getSize().x, StringUtil.EQUAL, name.getFont());
break;
case HAS_FOCUS:
evt.doit = false;
break;
case GAINING_FOCUS:
break;
}
}
});
name.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent evt) {
transitionNameState = TransitionNameState.GAINING_FOCUS;
name.setText(info.fullName);
transitionNameState = TransitionNameState.HAS_FOCUS;
}
@Override
public void focusLost(FocusEvent evt) {
transitionNameState = TransitionNameState.NORMAL;
name.setText(info.fullName);
}
});
name.setText(txt);
return name;
}
use of org.eclipse.swt.events.FocusEvent in project dbeaver by serge-rider.
the class CustomCheckboxCellEditor method createControl.
@Override
protected Control createControl(Composite parent) {
checkBox = new Button(parent, SWT.CHECK);
checkBox.setFont(parent.getFont());
checkBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
applyEditorValue();
// This is needed for MacOS
fireApplyEditorValue();
}
});
checkBox.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
CustomCheckboxCellEditor.this.focusLost();
}
});
return checkBox;
}
use of org.eclipse.swt.events.FocusEvent 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.FocusEvent 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.FocusEvent 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);
}
});
}
Aggregations