Java 类org.eclipse.swt.events.KeyAdapter 实例源码

项目:neoscada    文件:FilterFreeFormComposite.java   
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 () );
        }
    } );
}
项目:neoscada    文件:FilterAdvancedComposite.java   
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;
}
项目:neoscada    文件:FilterAdvancedComposite.java   
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;
}
项目:convertigo-eclipse    文件:KTableCellEditorMultilineWrapText.java   
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;
}
项目:convertigo-eclipse    文件:KTableCellEditorCombo.java   
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;
}
项目:convertigo-eclipse    文件:KTableCellEditorText.java   
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;
}
项目:convertigo-eclipse    文件:KTableCellEditorMultilineText.java   
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;
}
项目:http4e    文件:ParameterizeTextView.java   
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();
}
项目:TuxGuitar-1.3.1-fork    文件:TGLyricEditor.java   
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;
                }
            }
        }
    });
}
项目:scenarioo-example-swtbot-e4    文件:OrderPage.java   
@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);
}
项目:scenarioo-example-swtbot-e4    文件:OrderDetailsPart.java   
@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);
            }
        }

    });
}
项目:scouter    文件:AlertScriptingView.java   
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()});
                    }
                }
            }
        }
    });
}
项目:EasyShell    文件:MenuPage.java   
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("");
}
项目:EasyShell    文件:CommandPage.java   
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("");
}
项目:JFaceUtils    文件:ListConsole.java   
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;
}
项目:JFaceUtils    文件:ListConsole.java   
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;
}
项目:JFaceUtils    文件:StyledTextConsole.java   
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;
}
项目:JFaceUtils    文件:EnhancedErrorDialog.java   
@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;
}
项目:mytourbook    文件:AutoComplete.java   
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();
            }
        });

    }
项目:mytourbook    文件:DialogMarker.java   
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();
                }
            });
        }
    }
项目:mytourbook    文件:AutoComplete.java   
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();
            }
        });

    }
项目:OpenSPIFe    文件:EMFDetailUtils.java   
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();
            }
        }
    });
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeHierarchyViewPart.java   
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;
                }
                }
        }
    };
}
项目:translationstudio8    文件:TextCellEditor.java   
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;
}
项目:tesb-studio-se    文件:WsdlFieldPart.java   
@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();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeHierarchyViewPart.java   
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;
                }
                }
        }
    };
}
项目:Rel    文件:SpecialCharacters.java   
/**
 * 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;
                }
            }
        }
    });
}
项目:pm    文件:ActionDialogForm.java   
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();
                        }
                    }
                });
            }
        }
    }

}
项目:tmxeditor8    文件:TextCellEditor.java   
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;
}
项目:DynamicSpotter    文件:PropertiesGroupViewer.java   
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();
            }
        }
    });
}
项目:collabthings.swt    文件:ValueEditorDialog.java   
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;
}
项目:NIEM-Modeling-Tool    文件:SimpleInlineTextInputDialog.java   
@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;
}
项目:totallicks-tuxguitar    文件:LyricEditor.java   
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;
                }
            }
        }
    });
}
项目:jbt    文件:NodesSearcher.java   
/**
 * 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;
}
项目:e4translationexample    文件:LocaleChangeItem.java   
@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);
}
项目:elexis-3-core    文件:MultilineFieldEditor.java   
@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;
}
项目:elexis-3-base    文件:MedicalControlFieldProvider.java   
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;
}
项目:elexis-3-base    文件:MedikamentControlFieldProvider.java   
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;
}
项目:pentaho-kettle    文件:Spoon.java   
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();
      }
    }
  } );
}
项目:swt-bling    文件:SquareButton.java   
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;
      }
    }
  });
}