private void createComponents () { final FillLayout layout = new FillLayout ( SWT.VERTICAL ); layout.marginHeight = 12; layout.marginWidth = 12; setLayout ( layout ); final Text filterTextField = new Text ( this, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL ); filterTextField.setText ( this.filter ); filterTextField.addKeyListener ( new KeyAdapter () { @Override public void keyReleased ( final KeyEvent e ) { verifyFilter ( filterTextField.getText () ); } } ); }
private Text createAttributeText ( final String attribute ) { final Text t = new Text ( this, SWT.BORDER ); final Fields field = Fields.byField ( attribute ); if ( field == null ) { t.setEditable ( true ); t.setMessage ( Messages.custom_field ); } else { t.setEditable ( false ); t.setText ( field.getName () ); } t.addKeyListener ( new KeyAdapter () { @Override public void keyReleased ( final KeyEvent e ) { AssertionComposite.this.orCondition.updateFilter (); }; } ); final RowData rowData = new RowData (); rowData.width = 132; t.setLayoutData ( rowData ); return t; }
private Text createValueText () { final Text t = new Text ( this, SWT.BORDER ); t.setMessage ( Messages.argument ); t.addKeyListener ( new KeyAdapter () { @Override public void keyReleased ( final KeyEvent e ) { AssertionComposite.this.orCondition.updateFilter (); } } ); final RowData rowData = new RowData (); rowData.width = 132; t.setLayoutData ( rowData ); return t; }
protected Control createControl() { m_Text = new Text(m_Table, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP); m_Text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { try { onKeyPressed(e); } catch (Exception ex) { } } }); m_Text.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent arg0) { onTraverse(arg0); } }); return m_Text; }
protected Control createControl() { m_Combo = new CCombo(m_Table, SWT.READ_ONLY); m_Combo.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_LIST_BACKGROUND)); if (m_Items != null) m_Combo.setItems(m_Items); m_Combo.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { try { onKeyPressed(e); } catch (Exception ex) { } } }); /* * m_Combo.addTraverseListener(new TraverseListener() { public void * keyTraversed(TraverseEvent arg0) { onTraverse(arg0); } }); */ return m_Combo; }
protected Control createControl() { // System.out.println("Created a new one."); m_Text = new Text(m_Table, SWT.NONE); m_Text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { try { onKeyPressed(e); } catch (Exception ex) { } } }); m_Text.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent arg0) { onTraverse(arg0); } }); return m_Text; }
protected Control createControl() { m_Text = new Text(m_Table, SWT.MULTI | SWT.V_SCROLL); m_Text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { try { onKeyPressed(e); } catch (Exception ex) { } } }); m_Text.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent arg0) { onTraverse(arg0); } }); return m_Text; }
private StyledText buildEditorText( Composite parent){ final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR); sourceViewer.configure(sourceConf); sourceViewer.setDocument(DocumentUtils.createDocument1()); sourceViewer.getControl().addKeyListener(new KeyAdapter() { public void keyPressed( KeyEvent e){ // if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) { if (Utils.isAutoAssistInvoked(e)) { IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer); ca.showPossibleCompletions(); } } }); return sourceViewer.getTextWidget(); }
private void loadLyricText(Composite parent){ Composite composite = new Composite(parent,SWT.NONE); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true)); this.text = new Text(composite,SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); this.text.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true)); this.text.setFocus(); this.text.setText(this.track.getLyrics().getLyrics()); this.text.addModifyListener(this.listener); this.text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { for( int i = 0 ; i < KB_ACTIONS.length ; i ++ ){ if( event.keyCode == KB_ACTIONS[i].getKeyBinding().getKey() && event.stateMask == KB_ACTIONS[i].getKeyBinding().getMask() ){ new TGActionProcessorListener(TGLyricEditor.this.context, KB_ACTIONS[i].getAction()).processEvent(event); return; } } } }); }
@Override public void createControl(final Composite parent) { this.orderDetailPanel = new OrderDetailView(parent, order); this.orderDetailPanel.addOrderNumberKeyListener( new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { if (orderDetailPanel.mandatoryFieldsNonEmpty()) { setPageComplete(true); } else { setPageComplete(false); } } }); // required to avoid an error in the system setControl(orderDetailPanel.getControl()); setPageComplete(false); }
@PostConstruct public void createControls(final Composite parent, final ESelectionService selectionService) { this.order = (Order) selectionService.getSelection(); this.orderDetailPanel = new OrderDetailView(parent, order); this.orderDetailPanel.addOrderNumberKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { if (orderNumberHasChanged()) { dirtyable.setDirty(true); } else { dirtyable.setDirty(false); } } }); }
private void addApiDescTableKeyListener() { table.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if(e.stateMask == SWT.CTRL || e.stateMask == SWT.COMMAND){ if (e.keyCode == 'c' || e.keyCode == 'C') { StructuredSelection selection = (StructuredSelection)viewer.getSelection(); if(selection == null) return; ApiDesc apiObject = (ApiDesc)selection.getFirstElement(); if(apiObject != null){ clipboard.setContents(new Object[] {apiObject.fullSignature}, new Transfer[] {TextTransfer.getInstance()}); } } } } }); }
private void createSearchField(Composite parent) { //Label searchLabel = new Label(parent, SWT.NONE); //searchLabel.setText("Search: "); filter = new MenuDataFilter(); searchText = new Text(parent, SWT.BORDER | SWT.SEARCH); searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); searchText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { filter.setSearchText(searchText.getText()); refreshTableViewer(); } }); searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search")); // fake Label label = new Label(parent, SWT.NONE); label.setText(""); }
private void createSearchField(Composite parent) { //Label searchLabel = new Label(parent, SWT.NONE); //searchLabel.setText("Search: "); filter = new CommandDataFilter(); searchText = new Text(parent, SWT.BORDER | SWT.SEARCH); searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); searchText.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { filter.setSearchText(searchText.getText()); tableViewer.refresh(); } }); searchText.setToolTipText(Activator.getResourceString("easyshell.command.page.text.tooltip.search")); // fake Label label = new Label(parent, SWT.NONE); label.setText(""); }
protected MenuItem createSelectAllMenuItem(final List list) { final MenuItem selectAll = new MenuItem(contextMenu, SWT.PUSH); selectAll.setText(JFaceMessages.get("lbl.menu.item.select.all") + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_SELECT_ALL)); selectAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { list.selectAll(); } }); list.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent ke) { if (ke.stateMask == SWT.MOD1 && ke.keyCode == SwtUtils.KEY_SELECT_ALL) { ke.doit = false; list.selectAll(); } } }); return selectAll; }
protected MenuItem createCopyMenuItem(final List list) { final MenuItem copy = new MenuItem(contextMenu, SWT.PUSH); copy.setText(JFaceMessages.get("lbl.menu.item.copy") + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_COPY)); copy.setAccelerator(SWT.MOD1 | SwtUtils.KEY_COPY); copy.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { copy(list); } }); list.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { if (e.stateMask == SWT.MOD1 && e.keyCode == SwtUtils.KEY_COPY) { e.doit = false; // avoids unwanted scrolling copy(list); } } }); return copy; }
protected MenuItem createSelectAllMenuItem(final StyledText styledText) { final MenuItem selectAll = new MenuItem(contextMenu, SWT.PUSH); selectAll.setText(JFaceMessages.get("lbl.menu.item.select.all") + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_SELECT_ALL)); selectAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { styledText.invokeAction(ST.SELECT_ALL); } }); styledText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent ke) { if (ke.stateMask == SWT.MOD1 && ke.keyCode == SwtUtils.KEY_SELECT_ALL) { styledText.invokeAction(ST.SELECT_ALL); } } }); return selectAll; }
@Override protected List createDropDownList(final Composite parent) { final List list = super.createDropDownList(parent); if (list.getMenu() != null) { for (final MenuItem item : list.getMenu().getItems()) { if (item.getText().equals(JFaceResources.getString("copy"))) { item.setText(JFaceMessages.get("lbl.menu.item.copy") + SwtUtils.getMod1ShortcutLabel(SwtUtils.KEY_COPY)); item.setAccelerator(SWT.MOD1 | SwtUtils.KEY_COPY); list.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { if (SWT.MOD1 == e.stateMask && SwtUtils.KEY_COPY == e.keyCode) { e.doit = false; // avoids unwanted scrolling item.notifyListeners(SWT.Selection, null); } } }); break; } } } return list; }
public AutoComplete(final ComboViewer comboViewer) { _comboViewer = comboViewer; final Combo combo = comboViewer.getCombo(); combo.addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { if (e.keyCode == SWT.DEL) setSelection(null); autoCompleteKeyUp(e); } }); combo.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent arg0) { autoCompleteLeave(); } }); }
private void createUI_52_Label(final Composite parent) { /* * Marker name */ { // Label _lblLabel = new Label(parent, SWT.NONE); _firstColumnControls.add(_lblLabel); _lblLabel.setText(Messages.Dlg_TourMarker_Label_Label); // Combo _comboMarkerName = new Combo(parent, SWT.BORDER | SWT.FLAT); GridDataFactory.fillDefaults()// // !!! hint must be set because the width is adjusted to the content .hint(CONTENT_DEFAULT_WIDTH, SWT.DEFAULT) .grab(true, false) .applyTo(_comboMarkerName); _comboMarkerName.addKeyListener(new KeyAdapter() { @Override public void keyReleased(final KeyEvent e) { onChangeMarkerUI(); } }); } }
public static void bindTextModifyUndoable(final Text text, EObject model, String label) { final TextModifyUndoableObservableValue modelObservableValue = new TextModifyUndoableObservableValue(model, label, text); text.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { int stateMask = event.stateMask; int keyCode = event.keyCode; char character = event.character; // System.out.println("State: " + stateMask + "Key: " + keyCode + "Character: " + (int)character); if (character != 0 && (stateMask == 0 || stateMask == (0 | SWT.SHIFT))) { if (keyCode == SWT.ESC || ((text.getStyle() & SWT.MULTI) == 0 && keyCode == SWT.CR)) { return; } modelObservableValue.textModified(); } } }); }
private KeyListener createKeyListener() { return new KeyAdapter() { @Override public void keyReleased(KeyEvent event) { if (event.stateMask == 0) { if (event.keyCode == SWT.F5) { ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy(); if (hierarchy != null) { fHierarchyLifeCycle.typeHierarchyChanged(hierarchy); doTypeHierarchyChangedOnViewers(null); } updateHierarchyViewer(false); return; } } } }; }
protected Text createTextControl(Composite parent) { IStyle cellStyle = getCellStyle(); final Text textControl = new Text(parent, HorizontalAlignmentEnum.getSWTStyle(cellStyle)); textControl.setBackground(cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR)); textControl.setForeground(cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR)); textControl.setFont(cellStyle.getAttributeValue(CellStyleAttributes.FONT)); textControl.addKeyListener(new KeyAdapter() { private final Color originalColor = textControl.getForeground(); @Override public void keyReleased(KeyEvent e) { if (!validateCanonicalValue()) { textControl.setForeground(GUIHelper.COLOR_RED); } else { textControl.setForeground(originalColor); } }; }); return textControl; }
@Override public Control createControl(Composite parent) { wsdlField = new LabelledFileField(parent, "WSDL:", new String[] { "*.wsdl", "*.*" }, 1, SWT.BORDER) { protected void setFileFieldValue(String result) { if (result != null) { setRawFieldValue(result); } } }; wsdlField.getTextControl().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { switch (event.keyCode) { case SWT.CR: case SWT.KEYPAD_CR: refreshTriggered(); } } }); return wsdlField.getTextControl(); }
/** * Create the dialog. * * @param parent * @param style */ public SpecialCharacters(Shell parent, StyledText inputText) { super(parent, SWT.NONE); this.inputText = inputText; inputText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { // System.out.println("character = '" + e.character + "' keycode = '" + // (char)e.keyCode + "' " + (((e.stateMask & SWT.CTRL) != 0) ? "CTRL" : "") + " // " + (((e.stateMask & SWT.SHIFT) != 0) ? "SHIFT" : "")); for (SpecialCharacter specialCharacter : specialCharacters) { if (specialCharacter.matches(e)) { emit(specialCharacter.symbol); break; } } } }); }
protected void addListeners() { if (controls.length == 1) {//XXX Well this is not very accurate and would make sense only with one control ... for (Control control : controls) { if (control instanceof Text) { control.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent evt) { if (evt.keyCode == SWT.CR) { doAction(); } } }); } } } }
private void addKeyListeners() { tblProperties.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) { int index = tblProperties.getSelectionIndex(); if (index != -1) { Object element = propertiesTblViewer.getElementAt(index); propertiesTblViewer.editElement(element, 1); } } else if (e.keyCode == SWT.DEL) { removeSelectedProperties(); } } }); }
protected Control createDialogArea(Composite parent) { Composite c = new CTComposite(parent, SWT.NONE); c.setLayout(new GridLayout(1, false)); CTLabel lvaluename = new CTLabel(c, SWT.NONE); lvaluename.setBounds(0, 0, 55, 15); lvaluename.setText(name); text = new CTText(c, SWT.BORDER | SWT.MULTI); text.setText(value); text.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent arg0) { value = text.getText(); } }); text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); text.setBounds(0, 0, 76, 21); return c; }
@Override protected Control createTextControl(final Composite parent) { text = new Text(parent, SWT.SINGLE | SWT.BORDER); text.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { switch (e.keyCode) { case SWT.CR: okPressed(); break; } } }); text.setFocus(); if (getValue() != null) { text.setText(getValue()); text.selectAll(); } return text; }
private void loadLyricText(Composite parent){ Composite composite = new Composite(parent,SWT.NONE); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true)); this.text = new Text(composite,SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); this.text.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true)); this.text.setFocus(); this.text.setText(this.track.getLyrics().getLyrics()); this.text.addModifyListener(this.listener); this.text.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent event) { for( int i = 0 ; i < KB_ACTIONS.length ; i ++ ){ if(event.keyCode == KB_ACTIONS[i].getKeyBinding().getKey() && event.stateMask == KB_ACTIONS[i].getKeyBinding().getMask()){ TuxGuitar.instance().getAction(KB_ACTIONS[i].getAction()).process(event); return; } } } }); }
/** * Creates the search text field (Text). * * @param parent * the Composite where the text field is placed. * @return the text field. */ private Text createTextField(Composite parent) { final Text textField = new Text(parent, SWT.BORDER); textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); /* If "enter" is pressed, perform the search. */ textField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.CR) { performSearch(textField.getText()); } } }); return textField; }
@PostConstruct public void postConstruct(Composite parent, OsgiMessageRegistry registry) { final Text input = new Text(parent, SWT.BORDER); input.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) { lcs.changeApplicationLocale(input.getText()); } } }); Button button = new Button(parent, SWT.PUSH); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { lcs.changeApplicationLocale(input.getText()); }; }); registry.register(button::setText, (m) -> m.buttonChangeLocale); }
@Override public Text getTextControl(Composite parent){ if (textField == null) { textField = SWTHelper.createText(parent, numOfLines, flags); textField.setFont(parent.getFont()); textField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e){ valueChanged(); } }); textField.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent event){ textField = null; } }); } else { checkParent(textField, parent); } return textField; }
public Composite createControl(final Composite parent){ Composite composite = super.createControl(parent); for (final ElexisText selector : selectors) { selector.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e){ if (e.character == SWT.CR) { String text = selector.getText(); text = text.replaceAll(new Character(SWT.CR).toString(), ""); //$NON-NLS-1$ text = text.replaceAll(new Character(SWT.LF).toString(), ""); //$NON-NLS-1$ text = text.replaceAll(new Character((char) 0).toString(), ""); //$NON-NLS-1$ Event scannerEvent = new Event(); scannerEvent.text = selector.getText(); scannerEvent.widget = selector.getWidget(); scannerInput(scannerEvent); } } }); } return composite; }
public void addDefaultKeyListeners( Control control ) { control.addKeyListener( new KeyAdapter() { @Override public void keyPressed( KeyEvent e ) { // CTRL-W or CTRL-F4 : close tab // if ( ( e.keyCode == 'w' && ( e.stateMask & SWT.CONTROL ) != 0 ) || ( e.keyCode == SWT.F4 && ( e.stateMask & SWT.CONTROL ) != 0 ) ) { closeFile(); } // CTRL-F5 : metastore explorer // if ( e.keyCode == SWT.F5 && ( e.stateMask & SWT.CONTROL ) != 0 ) { new MetaStoreExplorerDialog( shell, metaStore ).open(); } } } ); }
public DefaultButtonClickHandler(final SquareButton button) { button.addMouseListener(new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { clicked(); } }); button.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent keyEvent) { switch (keyEvent.character) { case ' ': case '\r': case '\n': clicked(); break; default: break; } } }); }