use of org.eclipse.swt.events.TraverseListener in project cogtool by cogtool.
the class WebCrawlImportDialog method buildThirdGroup.
public void buildThirdGroup() {
typeHTMLGroup3 = new Group(useSelectionGroup, SWT.SHADOW_NONE);
typeHTMLGroup3.setText("Starting URL #3");
typeHTMLGroup3.setLayout(new FormLayout());
urlText3 = new TextWithEnableFix(typeHTMLGroup3, SWT.BORDER | SWT.SINGLE);
urlText3.setText("http://");
urlText3.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
e.detail = SWT.TRAVERSE_NONE;
questionMarkButtonDomain2.forceFocus();
}
}
});
plusButton3 = makeToolBarButton(typeHTMLGroup3, addGroupListener, questionImages.PLUS_IMAGE);
minusButton3 = makeToolBarButton(typeHTMLGroup3, minusGroupListener3, questionImages.MINUS_IMAGE);
maximumDepthToCrawlLabel3 = new Label(typeHTMLGroup3, SWT.NONE);
maximumDepthToCrawlLabel3.setText("Maximum Depth To Crawl: ");
questionMarkButtonDepth3 = makeToolBarButton(typeHTMLGroup3, depthListener, questionImages.QUESTION_SHADOW);
maxDepthCombo3 = new ComboWithEnableFix(typeHTMLGroup3, SWT.DROP_DOWN | SWT.READ_ONLY);
maxDepthCombo3.add("Unlimited");
for (int i = 0; i < 100; i++) {
maxDepthCombo3.add("" + i);
}
maxDepthCombo3.select(2);
maxDepthCombo3.setVisibleItemCount(21);
useHTML7 = new Button(typeHTMLGroup3, SWT.RADIO);
useHTML7.addSelectionListener(domainListener);
useHTML7.setSelection(true);
useHTML8 = new Button(typeHTMLGroup3, SWT.RADIO);
useHTML8.addSelectionListener(domainListener);
useHTML9 = new Button(typeHTMLGroup3, SWT.RADIO);
useHTML9.addSelectionListener(domainListener);
urlPath7 = new Label(typeHTMLGroup3, SWT.NONE);
urlPath7.setText("Unrestricted");
urlPath8 = new Label(typeHTMLGroup3, SWT.NONE);
urlPath8.setText("http://host_name/");
urlPath9 = new Label(typeHTMLGroup3, SWT.NONE);
urlPath9.setText("http://host_name/path");
urlPath9b = new Label(typeHTMLGroup3, SWT.NONE);
urlPath9b.setText("path");
urlPath9b.setFont(URL_PATH_FONT);
urlPath9b.setVisible(false);
maxDepthCombo3.addSelectionListener(comboListener);
restrictDomainLabel3 = new Label(typeHTMLGroup3, SWT.NONE);
restrictDomainLabel3.setText("Restrict Domain: ");
questionMarkButtonDomain3 = makeToolBarButton(typeHTMLGroup3, domainHelpListener, questionImages.QUESTION_SHADOW);
urlText3.addFocusListener(new TextFocusListener(urlText3, urlPath8, urlPath9, useHTML7, useHTML8, useHTML9, 3));
}
use of org.eclipse.swt.events.TraverseListener 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.TraverseListener in project dbeaver by serge-rider.
the class StatusDetailsDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite composite = super.createDialogArea(parent);
if (!CommonUtils.isEmpty(warnings)) {
// Create warnings table
UIUtils.createControlLabel(composite, "Warnings");
warnTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
TableColumn exColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Exception");
TableColumn msgColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Message");
warnTable.setLinesVisible(true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = 100;
warnTable.setLayoutData(gd);
for (Throwable ex : warnings) {
TableItem warnItem = new TableItem(warnTable, SWT.NONE);
warnItem.setText(0, ex.getClass().getName());
if (ex.getMessage() != null) {
warnItem.setText(1, ex.getMessage());
}
warnItem.setData(ex);
}
exColumn.pack();
msgColumn.pack();
warnTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
openWarning();
}
});
warnTable.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
openWarning();
e.doit = false;
}
}
});
}
return composite;
}
use of org.eclipse.swt.events.TraverseListener in project translationstudio8 by heartsome.
the class TSWizardDialog method aboutToStart.
/**
* About to start a long running operation triggered through the wizard.
* Shows the progress monitor and disables the wizard's buttons and
* controls.
*
* @param enableCancelButton
* <code>true</code> if the Cancel button should be enabled,
* and <code>false</code> if it should be disabled
* @return the saved UI state
*/
private Object aboutToStart(boolean enableCancelButton) {
Map savedState = null;
if (getShell() != null) {
// Save focus control
Control focusControl = getShell().getDisplay().getFocusControl();
if (focusControl != null && focusControl.getShell() != getShell()) {
focusControl = null;
}
boolean needsProgressMonitor = wizard.needsProgressMonitor();
// Set the busy cursor to all shells.
Display d = getShell().getDisplay();
waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
setDisplayCursor(waitCursor);
if (useCustomProgressMonitorPart) {
cancelButton.removeSelectionListener(cancelListener);
// Set the arrow cursor to the cancel component.
arrowCursor = new Cursor(d, SWT.CURSOR_ARROW);
cancelButton.setCursor(arrowCursor);
}
// Deactivate shell
savedState = saveUIState(useCustomProgressMonitorPart && needsProgressMonitor && enableCancelButton);
if (focusControl != null) {
savedState.put(FOCUS_CONTROL, focusControl);
}
// Activate cancel behavior.
if (needsProgressMonitor) {
if (enableCancelButton || useCustomProgressMonitorPart) {
progressMonitorPart.attachToCancelComponent(cancelButton);
}
progressMonitorPart.setVisible(true);
}
// Install traverse listener once in order to implement 'Enter' and 'Space' key blocking
if (timeWhenLastJobFinished == -1) {
timeWhenLastJobFinished = 0;
getShell().addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN || (e.detail == SWT.TRAVERSE_MNEMONIC && e.keyCode == 32)) {
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=287887
if (timeWhenLastJobFinished != 0 && System.currentTimeMillis() - timeWhenLastJobFinished < RESTORE_ENTER_DELAY) {
e.doit = false;
return;
}
timeWhenLastJobFinished = 0;
}
}
});
}
}
return savedState;
}
use of org.eclipse.swt.events.TraverseListener in project translationstudio8 by heartsome.
the class TextCellEditor method activateCell.
@Override
protected Control activateCell(final Composite parent, Object originalCanonicalValue, Character initialEditValue) {
text = createTextControl(parent);
// If we have an initial value, then
if (initialEditValue != null) {
selectionMode = EditorSelectionEnum.END;
text.setText(initialEditValue.toString());
selectText();
} else {
setCanonicalValue(originalCanonicalValue);
}
if (!isEditable()) {
text.setEditable(false);
}
text.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if ((event.keyCode == SWT.CR && event.stateMask == 0) || (event.keyCode == SWT.KEYPAD_CR && event.stateMask == 0)) {
commit(MoveDirectionEnum.NONE);
} else if (event.keyCode == SWT.ESC && event.stateMask == 0) {
close();
}
}
});
text.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent event) {
boolean committed = false;
if (event.keyCode == SWT.TAB && event.stateMask == SWT.SHIFT) {
committed = commit(MoveDirectionEnum.LEFT);
} else if (event.keyCode == SWT.TAB && event.stateMask == 0) {
committed = commit(MoveDirectionEnum.RIGHT);
}
if (!committed) {
event.doit = false;
}
}
});
text.forceFocus();
return text;
}
Aggregations